@qr-platform/qr-code.js 0.9.10 → 0.10.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/CHANGELOG.md +6 -0
- package/README.md +1 -0
- package/docs/advanced-examples.md +177 -56
- package/docs/api-reference-guide.md +26 -6
- package/docs/border-methods-update-plan.md +28 -0
- package/docs/border-text-implementation-plan.md +155 -0
- package/docs/documentation.md +276 -11
- package/docs/examples.md +160 -37
- package/docs/license-management.md +4 -4
- package/docs/typescript-types-definitions.md +2 -2
- package/docs/usage-guide.md +71 -41
- package/lib/config/runtime-config.d.ts +3 -0
- package/lib/core/qr-code-js.d.ts +82 -7
- package/lib/core/qr-options-validation.d.ts +1 -1
- package/lib/core/qr-svg.d.ts +3 -1
- package/lib/core/templates/qr-styles-dark.d.ts +2 -0
- package/lib/core/templates/qr-styles.d.ts +9 -0
- package/lib/core/templates/qr-template-borders.d.ts +4 -0
- package/lib/core/templates/qr-template-text.d.ts +4 -0
- package/lib/core/templates/qr-templates.d.ts +12 -0
- package/lib/demo.d.ts +1 -0
- package/lib/index.d.ts +135 -21
- package/lib/index.js +1 -1
- package/lib/license/LicenseManager.d.ts +1 -1
- package/lib/node/config/runtime-config.d.ts +3 -0
- package/lib/node/core/qr-code-js.d.ts +82 -7
- package/lib/node/core/qr-options-validation.d.ts +1 -1
- package/lib/node/core/qr-svg.d.ts +3 -1
- package/lib/node/core/templates/qr-styles-dark.d.ts +2 -0
- package/lib/node/core/templates/qr-styles.d.ts +9 -0
- package/lib/node/core/templates/qr-template-borders.d.ts +4 -0
- package/lib/node/core/templates/qr-template-text.d.ts +4 -0
- package/lib/node/core/templates/qr-templates.d.ts +12 -0
- package/lib/node/demo.d.ts +1 -0
- package/lib/node/index.d.ts +135 -21
- package/lib/node/license/LicenseManager.d.ts +1 -1
- package/lib/node/node.d.ts +128 -17
- package/lib/node/options-demo.d.ts +2 -239
- package/lib/node/templates/scan-validators/tests/cases/colors.d.ts +0 -6
- package/lib/node/types/helper.d.ts +3 -0
- package/lib/node/types/style-options.d.ts +8 -2
- package/lib/node/types/text-options.d.ts +11 -0
- package/lib/node/utils/_network-helpers_multi_env.d.ts +16 -0
- package/lib/node/utils/gradient.d.ts +2 -1
- package/lib/node/utils/network-helpers.d.ts +17 -0
- package/lib/node/utils/options.d.ts +26 -21
- package/lib/node.d.ts +128 -17
- package/lib/node.js +1 -1
- package/lib/options-demo.d.ts +2 -239
- package/lib/templates/scan-validators/tests/cases/colors.d.ts +0 -6
- package/lib/types/helper.d.ts +3 -0
- package/lib/types/style-options.d.ts +8 -2
- package/lib/types/text-options.d.ts +11 -0
- package/lib/utils/_network-helpers_multi_env.d.ts +16 -0
- package/lib/utils/gradient.d.ts +2 -1
- package/lib/utils/network-helpers.d.ts +17 -0
- package/lib/utils/options.d.ts +26 -21
- package/package.json +1 -1
- package/lib/core/qr-styles.d.ts +0 -4
- package/lib/core/qr-templates.d.ts +0 -10
- package/lib/node/core/qr-styles.d.ts +0 -4
- package/lib/node/core/qr-templates.d.ts +0 -10
|
@@ -10,7 +10,7 @@ export interface ValidationResult {
|
|
|
10
10
|
}
|
|
11
11
|
export declare class LicenseManager {
|
|
12
12
|
private static _instance;
|
|
13
|
-
private static
|
|
13
|
+
private static _customLicenseApiUrl;
|
|
14
14
|
private static _currentHostname;
|
|
15
15
|
private _hls;
|
|
16
16
|
private _decodedToken;
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import { CanvasOptions } from '~/utils/canvas-options';
|
|
2
|
-
import { RecursivePartial } from '../types/helper';
|
|
2
|
+
import { MethodOverrideOptions, RecursivePartial } from '../types/helper';
|
|
3
3
|
import { StyleOptions } from '../types/style-options';
|
|
4
|
-
import {
|
|
4
|
+
import { QRTextTemplateDefinition, TextOptions } from '../types/text-options';
|
|
5
|
+
import { BorderOptions, Options } from '../utils/options';
|
|
6
|
+
import { findStyleById, findStyleByName, QRStyleDefinition } from './templates/qr-styles';
|
|
7
|
+
import { findBorderById, findBorderByName } from './templates/qr-template-borders';
|
|
8
|
+
import { findTextByName, findTextById as findTextTemplateById } from './templates/qr-template-text';
|
|
9
|
+
import { findTemplateById, findTemplateByName, type QRTemplateDefinition } from './templates/qr-templates';
|
|
10
|
+
export type { QRTemplateDefinition, QRStyleDefinition, QRTextTemplateDefinition, StyleOptions };
|
|
5
11
|
export declare enum FileExtension {
|
|
6
12
|
svg = "svg",
|
|
7
13
|
png = "png",
|
|
@@ -13,30 +19,99 @@ export declare class QRCodeJs {
|
|
|
13
19
|
/** Library version injected at build time */
|
|
14
20
|
static version: string;
|
|
15
21
|
private static _selectedTemplate;
|
|
22
|
+
private static _selectedBorder;
|
|
16
23
|
private static _selectedStyle;
|
|
24
|
+
private static _selectedImage;
|
|
25
|
+
private static _selectedImageOverride;
|
|
26
|
+
private static _selectedText;
|
|
27
|
+
private static _selectedTextOverride;
|
|
17
28
|
private options;
|
|
18
29
|
private container?;
|
|
19
30
|
private qr?;
|
|
20
31
|
private extension?;
|
|
21
32
|
private svgDrawingPromise?;
|
|
22
33
|
private qrSVG?;
|
|
34
|
+
private _svgId;
|
|
23
35
|
get size(): {
|
|
24
36
|
width: number;
|
|
25
37
|
height: number;
|
|
26
38
|
} | undefined;
|
|
27
39
|
constructor(options: RecursivePartial<Options>, _?: boolean);
|
|
28
|
-
|
|
40
|
+
/**
|
|
41
|
+
* Sets the static template to be used as a base for new instances,
|
|
42
|
+
* accepting either a template name or a template options object.
|
|
43
|
+
* @param templateNameOrOptions - The user-friendly name of the template or a partial options object.
|
|
44
|
+
* @returns The QRCodeJs class for chaining.
|
|
45
|
+
*/
|
|
46
|
+
static setTemplate(templateNameOrOptions: string | RecursivePartial<Options> | null): typeof QRCodeJs;
|
|
47
|
+
/**
|
|
48
|
+
* Sets the static template to be used as a base for new instances by its ID.
|
|
49
|
+
* @param templateId - The ID of the template (original key).
|
|
50
|
+
* @returns The QRCodeJs class for chaining.
|
|
51
|
+
*/
|
|
52
|
+
static setTemplateId(templateId: string | null): typeof QRCodeJs;
|
|
53
|
+
static getTemplates(): {
|
|
54
|
+
findTextTemplateById: typeof findTextTemplateById;
|
|
55
|
+
findTextByName: typeof findTextByName;
|
|
56
|
+
findTemplateByName: typeof findTemplateByName;
|
|
57
|
+
findTemplateById: typeof findTemplateById;
|
|
58
|
+
findBorderById: typeof findBorderById;
|
|
59
|
+
findBorderByName: typeof findBorderByName;
|
|
60
|
+
findStyleById: typeof findStyleById;
|
|
61
|
+
findStyleByName: typeof findStyleByName;
|
|
62
|
+
baseTemplates: QRTemplateDefinition[];
|
|
63
|
+
borderTemplates: QRTemplateDefinition[];
|
|
64
|
+
styleTemplates: QRStyleDefinition[];
|
|
65
|
+
textTemplates: QRTextTemplateDefinition[];
|
|
66
|
+
};
|
|
29
67
|
/**
|
|
30
68
|
* Sets the static style to be used as a base for new instances.
|
|
31
69
|
* Accepts either a predefined style name or a StyleOptions object.
|
|
32
70
|
* @param styleNameOrOptions - The name of the style or the StyleOptions object.
|
|
71
|
+
* @param styleNameOrOptions - The name of the style or the StyleOptions object.
|
|
72
|
+
* @returns The QRCodeJs class for chaining.
|
|
73
|
+
*/
|
|
74
|
+
static setStyle(styleNameOrOptions: string | StyleOptions | null): typeof QRCodeJs;
|
|
75
|
+
/**
|
|
76
|
+
* Sets the static border template to be used as a base for new instances,
|
|
77
|
+
* accepting either a border template name or a BorderOptions object.
|
|
78
|
+
* @param borderNameOrOptions - The user-friendly name of the border template or a BorderOptions object.
|
|
79
|
+
* @returns The QRCodeJs class for chaining.
|
|
80
|
+
*/
|
|
81
|
+
static setBorder(borderNameOrOptions: string | RecursivePartial<BorderOptions> | null): typeof QRCodeJs;
|
|
82
|
+
/**
|
|
83
|
+
* Sets the static border template to be used as a base for new instances by its ID.
|
|
84
|
+
* @param borderId - The ID of the border template.
|
|
85
|
+
* @returns The QRCodeJs class for chaining.
|
|
86
|
+
*/
|
|
87
|
+
static setBorderId(borderId: string | null): typeof QRCodeJs;
|
|
88
|
+
/**
|
|
89
|
+
* Sets the static style to be used as a base for new instances by its ID.
|
|
90
|
+
* @param styleId - The ID of the style.
|
|
91
|
+
* @returns The QRCodeJs class for chaining.
|
|
92
|
+
*/
|
|
93
|
+
static setStyleId(styleId: string | null): typeof QRCodeJs;
|
|
94
|
+
/**
|
|
95
|
+
* Sets the static image URL to be used as a base for new instances.
|
|
96
|
+
* @param imageUrl - The URL of the image or null to clear.
|
|
97
|
+
* @returns The QRCodeJs class for chaining.
|
|
98
|
+
*/
|
|
99
|
+
static setImage(imageUrl: string | null, overrideOpts?: MethodOverrideOptions): typeof QRCodeJs;
|
|
100
|
+
/**
|
|
101
|
+
* Sets the static text template or options to be used for new instances.
|
|
102
|
+
* @param textNameOrOptions - The name of the text template, a TextOptions object, or null to clear.
|
|
103
|
+
* @returns The QRCodeJs class for chaining.
|
|
104
|
+
*/
|
|
105
|
+
static setText(textNameOrOptions: string | TextOptions | null, overrideOpts?: MethodOverrideOptions): typeof QRCodeJs;
|
|
106
|
+
/**
|
|
107
|
+
* Sets the static text template to be used for new instances by its ID.
|
|
108
|
+
* @param textId - The ID of the text template or null to clear.
|
|
33
109
|
* @returns The QRCodeJs class for chaining.
|
|
34
110
|
*/
|
|
35
|
-
static
|
|
111
|
+
static setTextId(textId: string | null, overrideOpts?: MethodOverrideOptions): typeof QRCodeJs;
|
|
112
|
+
getOptions(): Options;
|
|
36
113
|
update(options?: RecursivePartial<Options>): Promise<void>;
|
|
37
|
-
append(
|
|
38
|
-
/** This container will be used for appending of the QR code */
|
|
39
|
-
container?: HTMLElement): QRCodeJs | undefined;
|
|
114
|
+
append(container?: HTMLElement): this;
|
|
40
115
|
applyExtension(extension: ExtensionFunction): Promise<void>;
|
|
41
116
|
deleteExtension(): Promise<void>;
|
|
42
117
|
serialize(inverted?: boolean): Promise<string | undefined>;
|
|
@@ -19,6 +19,7 @@ type QRSVGOptions = Pick<Options, 'width' | 'height' | 'isResponsive' | 'margin'
|
|
|
19
19
|
};
|
|
20
20
|
export declare class QRSVG {
|
|
21
21
|
static instanceCount: number;
|
|
22
|
+
private static readonly FALLBACK_IMAGE_DATA_URL;
|
|
22
23
|
private _element;
|
|
23
24
|
private defs;
|
|
24
25
|
private backgroundMask?;
|
|
@@ -53,11 +54,12 @@ export declare class QRSVG {
|
|
|
53
54
|
drawBackgroundForBorder(padding: number, baseRadius: number): SVGElement | undefined;
|
|
54
55
|
drawDots(filter?: (i: number, j: number) => boolean): void;
|
|
55
56
|
drawCorners(): void;
|
|
56
|
-
drawImage({ width, height, count, dotSize }: {
|
|
57
|
+
drawImage({ width, height, count, dotSize, radius }: {
|
|
57
58
|
width: number;
|
|
58
59
|
height: number;
|
|
59
60
|
count: number;
|
|
60
61
|
dotSize: number;
|
|
62
|
+
radius?: string | number;
|
|
61
63
|
}): Promise<void>;
|
|
62
64
|
createColor({ options, borderOptions, color, additionalRotation, x, y, height, width, name, returnSVGGroup }: {
|
|
63
65
|
options?: Gradient;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { StyleOptions } from '../../types/style-options';
|
|
2
|
+
export interface QRStyleDefinition {
|
|
3
|
+
id: string;
|
|
4
|
+
name: string;
|
|
5
|
+
style: StyleOptions;
|
|
6
|
+
}
|
|
7
|
+
export declare const qrStyleDefinitions: QRStyleDefinition[];
|
|
8
|
+
export declare function findStyleByName(name: string): QRStyleDefinition | undefined;
|
|
9
|
+
export declare function findStyleById(id: string): QRStyleDefinition | undefined;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { QRTemplateDefinition } from './qr-templates';
|
|
2
|
+
export declare const qrBorderTemplates: QRTemplateDefinition[];
|
|
3
|
+
export declare function findBorderByName(name: string): QRTemplateDefinition | undefined;
|
|
4
|
+
export declare function findBorderById(id: string): QRTemplateDefinition | undefined;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { QRTextTemplateDefinition } from '../../types/text-options';
|
|
2
|
+
export declare const qrTextTemplates: QRTextTemplateDefinition[];
|
|
3
|
+
export declare function findTextByName(name: string): QRTextTemplateDefinition | undefined;
|
|
4
|
+
export declare function findTextById(id: string): QRTextTemplateDefinition | undefined;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type Options } from '~/utils/options';
|
|
2
|
+
import { RecursivePartial } from '~/types/helper';
|
|
3
|
+
export interface QRTemplateDefinition {
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
options: RecursivePartial<Options>;
|
|
7
|
+
}
|
|
8
|
+
export declare const baseQRTemplateOptions: RecursivePartial<Options>;
|
|
9
|
+
export declare const qrTemplates: QRTemplateDefinition[];
|
|
10
|
+
export declare function findTemplateByName(name: string): QRTemplateDefinition | undefined;
|
|
11
|
+
export declare function findTemplateById(id: string): QRTemplateDefinition | undefined;
|
|
12
|
+
export declare const baseQRTemplate: QRTemplateDefinition | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const initializeQRCode: () => Promise<void>;
|
package/lib/node/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { QRCodeJs as _QRCodeJs } from './core/qr-code-js';
|
|
2
|
-
import { RecursivePartial } from './types/helper';
|
|
2
|
+
import { MethodOverrideOptions, RecursivePartial } from './types/helper';
|
|
3
3
|
import { StyleOptions } from './types/style-options';
|
|
4
|
-
import {
|
|
4
|
+
import { TextOptions } from './types/text-options';
|
|
5
|
+
import { type Options as _QRCodeJsOptions, type BorderOptions } from './utils/options';
|
|
5
6
|
import { ScanValidatorResponse } from './utils/scan-validators/abstract-scan-validator';
|
|
6
7
|
import { type DecodedLicenseToken } from './utils/token-validator';
|
|
7
8
|
export { ErrorCorrectionLevel, Mode, TypeNumber } from './lib/qrcode/QRCodeMinimal';
|
|
@@ -11,9 +12,13 @@ export { type RecursivePartial } from './types/helper';
|
|
|
11
12
|
export { type CanvasOptions } from './utils/canvas-options';
|
|
12
13
|
export { GradientType, type Gradient } from './utils/gradient';
|
|
13
14
|
export { STORAGE_KEY } from './license/LicenseManager';
|
|
14
|
-
export { type BorderOptions,
|
|
15
|
+
export { type BorderOptions, // Keep exporting the type
|
|
16
|
+
CornerDotType, CornerSquareType, DotType, ImageMode, ShapeType } from './utils/options.js';
|
|
17
|
+
export type Options = RecursivePartial<_QRCodeJsOptions>;
|
|
18
|
+
export type { Options as QRCodeJsOptions };
|
|
19
|
+
type QRCodeJsConstructor = new (options: Options, internal?: boolean) => QRCodeJs;
|
|
15
20
|
export declare class QRCodeJs extends _QRCodeJs {
|
|
16
|
-
constructor(options: RecursivePartial<
|
|
21
|
+
constructor(options: RecursivePartial<_QRCodeJsOptions>, _?: boolean);
|
|
17
22
|
protected _hls(): boolean;
|
|
18
23
|
static initializeIfNeeded(): Promise<boolean>;
|
|
19
24
|
static get hls(): boolean;
|
|
@@ -48,13 +53,19 @@ export declare class QRCodeJs extends _QRCodeJs {
|
|
|
48
53
|
validateScanning(_validatorId?: string, // Default validator
|
|
49
54
|
debug?: boolean): Promise<ScanValidatorResponse>;
|
|
50
55
|
/**
|
|
51
|
-
* Creates a QRCodeBuilder instance initialized with a specific template.
|
|
52
|
-
* Allows for fluent configuration chaining.
|
|
53
|
-
* @param templateName - The name of the template to start with.
|
|
54
|
-
* @param templateNameOrOptions - The name of the template or a partial options object to start with.
|
|
56
|
+
* Creates a QRCodeBuilder instance initialized with a specific template by its name.
|
|
57
|
+
* Allows for fluent configuration chaining.
|
|
58
|
+
* @param templateName - The user-friendly name of the template to start with.
|
|
55
59
|
* @returns A new QRCodeBuilder instance.
|
|
56
60
|
*/
|
|
57
|
-
static useTemplate(
|
|
61
|
+
static useTemplate(templateName: string): QRCodeBuilder;
|
|
62
|
+
/**
|
|
63
|
+
* Creates a QRCodeBuilder instance initialized with a specific template by its ID.
|
|
64
|
+
* Allows for fluent configuration chaining.
|
|
65
|
+
* @param templateId - The ID (original key) of the template to start with.
|
|
66
|
+
* @returns A new QRCodeBuilder instance.
|
|
67
|
+
*/
|
|
68
|
+
static useTemplateId(templateId: string): QRCodeBuilder;
|
|
58
69
|
/**
|
|
59
70
|
* Creates a QRCodeBuilder instance initialized with a specific style.
|
|
60
71
|
* Allows for fluent configuration chaining.
|
|
@@ -62,37 +73,140 @@ export declare class QRCodeJs extends _QRCodeJs {
|
|
|
62
73
|
* @returns A new QRCodeBuilder instance.
|
|
63
74
|
*/
|
|
64
75
|
static useStyle(styleNameOrOptions: string | StyleOptions): QRCodeBuilder;
|
|
76
|
+
/**
|
|
77
|
+
* Creates a QRCodeBuilder instance initialized with a specific style by its ID.
|
|
78
|
+
* Allows for fluent configuration chaining.
|
|
79
|
+
* @param styleId - The ID of the predefined style.
|
|
80
|
+
* @returns A new QRCodeBuilder instance.
|
|
81
|
+
*/
|
|
82
|
+
static useStyleId(styleId: string): QRCodeBuilder;
|
|
83
|
+
/**
|
|
84
|
+
* Creates a QRCodeBuilder instance initialized with specific border options.
|
|
85
|
+
* Allows for fluent configuration chaining.
|
|
86
|
+
* @param borderNameOrOptions - The name of the predefined border or a BorderOptions object.
|
|
87
|
+
* @returns A new QRCodeBuilder instance.
|
|
88
|
+
*/
|
|
89
|
+
static useBorder(borderNameOrOptions: string | BorderOptions): QRCodeBuilder;
|
|
90
|
+
/**
|
|
91
|
+
* Creates a QRCodeBuilder instance initialized with a specific border by its ID.
|
|
92
|
+
* Allows for fluent configuration chaining.
|
|
93
|
+
* @param borderId - The ID of the predefined border.
|
|
94
|
+
* @returns A new QRCodeBuilder instance.
|
|
95
|
+
*/
|
|
96
|
+
static useBorderId(borderId: string): QRCodeBuilder;
|
|
97
|
+
/**
|
|
98
|
+
* Creates a QRCodeBuilder instance initialized with a specific image.
|
|
99
|
+
* Allows for fluent configuration chaining.
|
|
100
|
+
* @param imageUrl - The URL or data URL of the image to use.
|
|
101
|
+
* @returns A new QRCodeBuilder instance.
|
|
102
|
+
*/
|
|
103
|
+
static useImage(imageUrl: string, overrideOpts?: MethodOverrideOptions): QRCodeBuilder;
|
|
104
|
+
/**
|
|
105
|
+
* Creates a QRCodeBuilder instance initialized with specific text options.
|
|
106
|
+
* Allows for fluent configuration chaining.
|
|
107
|
+
* @param textNameOrOptions - The name of the predefined text template or a TextOptions object.
|
|
108
|
+
* @returns A new QRCodeBuilder instance.
|
|
109
|
+
*/
|
|
110
|
+
static useText(textNameOrOptions: string | TextOptions, overrideOpts?: MethodOverrideOptions): QRCodeBuilder;
|
|
111
|
+
/**
|
|
112
|
+
* Creates a QRCodeBuilder instance initialized with a specific text template by its ID.
|
|
113
|
+
* Allows for fluent configuration chaining.
|
|
114
|
+
* @param textId - The ID of the predefined text template.
|
|
115
|
+
* @returns A new QRCodeBuilder instance.
|
|
116
|
+
*/
|
|
117
|
+
static useTextId(textId: string, overrideOpts?: MethodOverrideOptions): QRCodeBuilder;
|
|
65
118
|
}
|
|
66
119
|
export declare class _ extends QRCodeJs {
|
|
67
120
|
protected _hls(): boolean;
|
|
68
|
-
constructor(options:
|
|
121
|
+
constructor(options: Options);
|
|
69
122
|
}
|
|
70
123
|
declare class QRCodeBuilder {
|
|
71
|
-
|
|
124
|
+
private _qrCodeConstructor;
|
|
125
|
+
protected _templateSource: string | Options | null;
|
|
126
|
+
protected _borderSource: string | BorderOptions | null;
|
|
127
|
+
protected _styleSource: string | StyleOptions | null;
|
|
128
|
+
protected _imageSource: string | null;
|
|
129
|
+
protected _imageOverride: boolean;
|
|
130
|
+
protected _textSource: string | TextOptions | null;
|
|
131
|
+
protected _textOverride: boolean;
|
|
132
|
+
protected _isTemplateById: boolean;
|
|
133
|
+
protected _isBorderById: boolean;
|
|
134
|
+
protected _isStyleById: boolean;
|
|
135
|
+
protected _isTextById: boolean;
|
|
136
|
+
protected _initialOptions: Options | null;
|
|
72
137
|
/**
|
|
73
138
|
* Creates a new QRCodeBuilder instance.
|
|
139
|
+
* @param qrCodeConstructor - The constructor function (QRCodeJs or _) to use for the final instance.
|
|
74
140
|
* @param templateNameOrOptions - Optional name of a predefined template or a partial options object to start with.
|
|
75
141
|
*/
|
|
76
|
-
constructor(templateNameOrOptions?: string |
|
|
142
|
+
constructor(qrCodeConstructor: QRCodeJsConstructor, templateNameOrOptions?: string | Options);
|
|
77
143
|
/**
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
* @param templateNameOrOptions - The name of the template or a partial options object to apply.
|
|
144
|
+
* Sets the template to use by its name. Overwrites any previously set template.
|
|
145
|
+
* @param templateName - The user-friendly name of the template to apply.
|
|
81
146
|
* @returns The builder instance for chaining.
|
|
82
147
|
*/
|
|
83
|
-
useTemplate(
|
|
148
|
+
useTemplate(templateName: string): this;
|
|
84
149
|
/**
|
|
85
|
-
*
|
|
86
|
-
* @param
|
|
150
|
+
* Sets the template to use by its ID. Overwrites any previously set template.
|
|
151
|
+
* @param templateId - The ID (original key) of the template to apply.
|
|
152
|
+
* @returns The builder instance for chaining.
|
|
153
|
+
*/
|
|
154
|
+
useTemplateId(templateId: string): this;
|
|
155
|
+
/**
|
|
156
|
+
* Sets the style to use by its name or a style options object. Overwrites any previously set style.
|
|
157
|
+
* @param styleNameOrOptions - Name of a predefined style or a StyleOptions object to apply.
|
|
87
158
|
* @returns The builder instance for chaining.
|
|
88
159
|
*/
|
|
89
160
|
useStyle(styleNameOrOptions: string | StyleOptions): this;
|
|
90
161
|
/**
|
|
91
|
-
*
|
|
92
|
-
* @param
|
|
162
|
+
* Sets the style to use by its ID. Overwrites any previously set style.
|
|
163
|
+
* @param styleId - ID of the predefined style to apply.
|
|
164
|
+
* @returns The builder instance for chaining.
|
|
165
|
+
*/
|
|
166
|
+
useStyleId(styleId: string): this;
|
|
167
|
+
/**
|
|
168
|
+
* Sets the border to use by its name or a border options object. Overwrites any previously set border.
|
|
169
|
+
* @param borderNameOrOptions - Name of a predefined border or a BorderOptions object to apply.
|
|
170
|
+
* @returns The builder instance for chaining.
|
|
171
|
+
*/
|
|
172
|
+
useBorder(borderNameOrOptions: string | BorderOptions): this;
|
|
173
|
+
/**
|
|
174
|
+
* Sets the border to use by its ID. Overwrites any previously set border.
|
|
175
|
+
* @param borderId - ID of the predefined border to apply.
|
|
176
|
+
* @returns The builder instance for chaining.
|
|
177
|
+
*/
|
|
178
|
+
useBorderId(borderId: string): this;
|
|
179
|
+
/**
|
|
180
|
+
* Sets the image to use. Overwrites any previously set image from other sources like templates.
|
|
181
|
+
* @param imageUrl - The URL or data URL of the image to apply.
|
|
93
182
|
* @returns The builder instance for chaining.
|
|
94
183
|
*/
|
|
95
|
-
|
|
184
|
+
useImage(imageUrl: string, overrideOpts?: MethodOverrideOptions): this;
|
|
185
|
+
/**
|
|
186
|
+
* Sets the text to use by its name or a text options object. Overwrites any previously set text.
|
|
187
|
+
* @param textNameOrOptions - Name of a predefined text template or a TextOptions object to apply.
|
|
188
|
+
* @returns The builder instance for chaining.
|
|
189
|
+
*/
|
|
190
|
+
useText(textNameOrOptions: string | TextOptions, overrideOpts?: MethodOverrideOptions): this;
|
|
191
|
+
/**
|
|
192
|
+
* Sets the text to use by its ID. Overwrites any previously set text.
|
|
193
|
+
* @param textId - ID of the predefined text template to apply.
|
|
194
|
+
* @returns The builder instance for chaining.
|
|
195
|
+
*/
|
|
196
|
+
useTextId(textId: string, overrideOpts?: MethodOverrideOptions): this;
|
|
197
|
+
/**
|
|
198
|
+
* Resolves the template, border, style, and image sources and merges them in the correct order.
|
|
199
|
+
* Order: Base Template -> Selected Template -> Selected Border -> Selected Text -> Selected Style -> Selected Image -> Final Options
|
|
200
|
+
* @param finalOptions - The final options object passed to .options() or .build().
|
|
201
|
+
* @returns The fully resolved and merged Options object.
|
|
202
|
+
*/
|
|
203
|
+
private _resolveAndMergeConfig;
|
|
204
|
+
/**
|
|
205
|
+
* Merges the provided options into the builder's configuration and creates the QRCodeJs instance.
|
|
206
|
+
* @param options - A partial options object to merge as the final step.
|
|
207
|
+
* @returns The created QRCodeJs instance.
|
|
208
|
+
*/
|
|
209
|
+
options(options: Options): QRCodeJs;
|
|
96
210
|
/**
|
|
97
211
|
* Builds the QRCodeJs instance with the accumulated configuration.
|
|
98
212
|
* @returns The created QRCodeJs instance.
|
|
@@ -10,7 +10,7 @@ export interface ValidationResult {
|
|
|
10
10
|
}
|
|
11
11
|
export declare class LicenseManager {
|
|
12
12
|
private static _instance;
|
|
13
|
-
private static
|
|
13
|
+
private static _customLicenseApiUrl;
|
|
14
14
|
private static _currentHostname;
|
|
15
15
|
private _hls;
|
|
16
16
|
private _decodedToken;
|
package/lib/node/node.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { QRCodeJs as _QRCodeJs } from './core/qr-code-js';
|
|
2
2
|
import { type ValidationResult } from './license/LicenseManagerNode';
|
|
3
3
|
import type * as _browserUtils from './tools/browser-utils';
|
|
4
|
-
import { RecursivePartial } from './types/helper';
|
|
4
|
+
import { MethodOverrideOptions, RecursivePartial } from './types/helper';
|
|
5
5
|
import { StyleOptions } from './types/style-options';
|
|
6
|
-
import {
|
|
6
|
+
import { TextOptions } from './types/text-options';
|
|
7
|
+
import { Options, type BorderOptions } from './utils/options';
|
|
7
8
|
import { ImageDataLike } from './utils/scan-validator-worker';
|
|
8
9
|
import { ScanValidatorResponse } from './utils/scan-validators/abstract-scan-validator';
|
|
9
10
|
import { type DecodedLicenseToken } from './utils/token-validator';
|
|
@@ -13,9 +14,10 @@ export { FileExtension } from './tools/browser-utils';
|
|
|
13
14
|
export { type RecursivePartial } from './types/helper';
|
|
14
15
|
export { type CanvasOptions } from './utils/canvas-options';
|
|
15
16
|
export { GradientType, type Gradient } from './utils/gradient';
|
|
16
|
-
export { CornerDotType, CornerSquareType, DotType, ImageMode, ShapeType, type Options } from './utils/options';
|
|
17
|
+
export { CornerDotType, CornerSquareType, DotType, ImageMode, ShapeType, type Options, type BorderOptions } from './utils/options';
|
|
17
18
|
export { ErrorCorrectionPercents } from './utils/qrcode';
|
|
18
19
|
export declare const browserUtils: typeof _browserUtils | undefined;
|
|
20
|
+
type QRCodeJsConstructor = new (options: RecursivePartial<Options>, internal?: boolean) => QRCodeJs;
|
|
19
21
|
export declare class QRCodeJs extends _QRCodeJs {
|
|
20
22
|
static initializeIfNeeded(): Promise<boolean>;
|
|
21
23
|
static get hls(): boolean;
|
|
@@ -40,11 +42,17 @@ export declare class QRCodeJs extends _QRCodeJs {
|
|
|
40
42
|
/**
|
|
41
43
|
* Creates a QRCodeBuilder instance initialized with a specific template.
|
|
42
44
|
* Allows for fluent configuration chaining. We need it here to avoid circular dependency
|
|
43
|
-
* @param templateName - The name of the template to start with.
|
|
44
|
-
* @param templateNameOrOptions - The name of the template or a partial options object to start with.
|
|
45
|
+
* @param templateName - The user-friendly name of the template to start with.
|
|
45
46
|
* @returns A new QRCodeBuilder instance.
|
|
46
47
|
*/
|
|
47
|
-
static useTemplate(
|
|
48
|
+
static useTemplate(templateName: string): QRCodeBuilder;
|
|
49
|
+
/**
|
|
50
|
+
* Creates a QRCodeBuilder instance initialized with a specific template by its ID.
|
|
51
|
+
* Allows for fluent configuration chaining.
|
|
52
|
+
* @param templateId - The ID (original key) of the template to start with.
|
|
53
|
+
* @returns A new QRCodeBuilder instance.
|
|
54
|
+
*/
|
|
55
|
+
static useTemplateId(templateId: string): QRCodeBuilder;
|
|
48
56
|
/**
|
|
49
57
|
* Creates a QRCodeBuilder instance initialized with a specific style.
|
|
50
58
|
* Allows for fluent configuration chaining.
|
|
@@ -52,32 +60,135 @@ export declare class QRCodeJs extends _QRCodeJs {
|
|
|
52
60
|
* @returns A new QRCodeBuilder instance.
|
|
53
61
|
*/
|
|
54
62
|
static useStyle(styleNameOrOptions: string | StyleOptions): QRCodeBuilder;
|
|
63
|
+
/**
|
|
64
|
+
* Creates a QRCodeBuilder instance initialized with a specific style by its ID.
|
|
65
|
+
* Allows for fluent configuration chaining.
|
|
66
|
+
* @param styleId - The ID of the predefined style.
|
|
67
|
+
* @returns A new QRCodeBuilder instance.
|
|
68
|
+
*/
|
|
69
|
+
static useStyleId(styleId: string): QRCodeBuilder;
|
|
70
|
+
/**
|
|
71
|
+
* Creates a QRCodeBuilder instance initialized with specific border options.
|
|
72
|
+
* Allows for fluent configuration chaining.
|
|
73
|
+
* @param borderNameOrOptions - The name of the predefined border or a BorderOptions object.
|
|
74
|
+
* @returns A new QRCodeBuilder instance.
|
|
75
|
+
*/
|
|
76
|
+
static useBorder(borderNameOrOptions: string | BorderOptions): QRCodeBuilder;
|
|
77
|
+
/**
|
|
78
|
+
* Creates a QRCodeBuilder instance initialized with a specific border by its ID.
|
|
79
|
+
* Allows for fluent configuration chaining.
|
|
80
|
+
* @param borderId - The ID of the predefined border.
|
|
81
|
+
* @returns A new QRCodeBuilder instance.
|
|
82
|
+
*/
|
|
83
|
+
static useBorderId(borderId: string): QRCodeBuilder;
|
|
84
|
+
/**
|
|
85
|
+
* Creates a QRCodeBuilder instance initialized with a specific image.
|
|
86
|
+
* Allows for fluent configuration chaining.
|
|
87
|
+
* @param imageUrl - The URL or data URL of the image to use.
|
|
88
|
+
* @returns A new QRCodeBuilder instance.
|
|
89
|
+
*/
|
|
90
|
+
static useImage(imageUrl: string, overrideOpts?: MethodOverrideOptions): QRCodeBuilder;
|
|
91
|
+
/**
|
|
92
|
+
* Creates a QRCodeBuilder instance initialized with specific text options.
|
|
93
|
+
* Allows for fluent configuration chaining.
|
|
94
|
+
* @param textNameOrOptions - The name of the predefined text template or a TextOptions object.
|
|
95
|
+
* @returns A new QRCodeBuilder instance.
|
|
96
|
+
*/
|
|
97
|
+
static useText(textNameOrOptions: string | TextOptions, overrideOpts?: MethodOverrideOptions): QRCodeBuilder;
|
|
98
|
+
/**
|
|
99
|
+
* Creates a QRCodeBuilder instance initialized with a specific text template by its ID.
|
|
100
|
+
* Allows for fluent configuration chaining.
|
|
101
|
+
* @param textId - The ID of the predefined text template.
|
|
102
|
+
* @returns A new QRCodeBuilder instance.
|
|
103
|
+
*/
|
|
104
|
+
static useTextId(textId: string, overrideOpts?: MethodOverrideOptions): QRCodeBuilder;
|
|
55
105
|
}
|
|
56
|
-
declare class QRCodeBuilder {
|
|
57
|
-
|
|
106
|
+
export declare class QRCodeBuilder {
|
|
107
|
+
private _qrCodeConstructor;
|
|
108
|
+
protected _templateSource: string | RecursivePartial<Options> | null;
|
|
109
|
+
protected _borderSource: string | BorderOptions | null;
|
|
110
|
+
protected _styleSource: string | StyleOptions | null;
|
|
111
|
+
protected _imageSource: string | null;
|
|
112
|
+
protected _imageOverride: boolean;
|
|
113
|
+
protected _textSource: string | TextOptions | null;
|
|
114
|
+
protected _textOverride: boolean;
|
|
115
|
+
protected _isTemplateById: boolean;
|
|
116
|
+
protected _isBorderById: boolean;
|
|
117
|
+
protected _isStyleById: boolean;
|
|
118
|
+
protected _isTextById: boolean;
|
|
119
|
+
protected _initialOptions: RecursivePartial<Options> | null;
|
|
58
120
|
/**
|
|
59
121
|
* Creates a new QRCodeBuilder instance.
|
|
122
|
+
* @param qrCodeConstructor - The constructor function (QRCodeJs or _) to use for the final instance.
|
|
60
123
|
* @param templateNameOrOptions - Optional name of a predefined template or a partial options object to start with.
|
|
61
124
|
*/
|
|
62
|
-
constructor(templateNameOrOptions?: string | RecursivePartial<Options>);
|
|
125
|
+
constructor(qrCodeConstructor: QRCodeJsConstructor, templateNameOrOptions?: string | RecursivePartial<Options>);
|
|
63
126
|
/**
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
* @param templateNameOrOptions - The name of the template or a partial options object to apply.
|
|
127
|
+
* Sets the template to use by its name. Overwrites any previously set template.
|
|
128
|
+
* @param templateName - The user-friendly name of the template to apply.
|
|
67
129
|
* @returns The builder instance for chaining.
|
|
68
130
|
*/
|
|
69
|
-
useTemplate(
|
|
131
|
+
useTemplate(templateName: string): this;
|
|
70
132
|
/**
|
|
71
|
-
*
|
|
72
|
-
* @param
|
|
133
|
+
* Sets the template to use by its ID. Overwrites any previously set template.
|
|
134
|
+
* @param templateId - The ID (original key) of the template to apply.
|
|
135
|
+
* @returns The builder instance for chaining.
|
|
136
|
+
*/
|
|
137
|
+
useTemplateId(templateId: string): this;
|
|
138
|
+
/**
|
|
139
|
+
* Sets the style to use by its name or a style options object. Overwrites any previously set style.
|
|
140
|
+
* @param styleNameOrOptions - Name of a predefined style or a StyleOptions object to apply.
|
|
73
141
|
* @returns The builder instance for chaining.
|
|
74
142
|
*/
|
|
75
143
|
useStyle(styleNameOrOptions: string | StyleOptions): this;
|
|
76
144
|
/**
|
|
77
|
-
*
|
|
78
|
-
* @param
|
|
145
|
+
* Sets the style to use by its ID. Overwrites any previously set style.
|
|
146
|
+
* @param styleId - ID of the predefined style to apply.
|
|
79
147
|
* @returns The builder instance for chaining.
|
|
80
148
|
*/
|
|
149
|
+
useStyleId(styleId: string): this;
|
|
150
|
+
/**
|
|
151
|
+
* Sets the border to use by its name or a border options object. Overwrites any previously set border.
|
|
152
|
+
* @param borderNameOrOptions - Name of a predefined border or a BorderOptions object to apply.
|
|
153
|
+
* @returns The builder instance for chaining.
|
|
154
|
+
*/
|
|
155
|
+
useBorder(borderNameOrOptions: string | BorderOptions): this;
|
|
156
|
+
/**
|
|
157
|
+
* Sets the border to use by its ID. Overwrites any previously set border.
|
|
158
|
+
* @param borderId - ID of the predefined border to apply.
|
|
159
|
+
* @returns The builder instance for chaining.
|
|
160
|
+
*/
|
|
161
|
+
useBorderId(borderId: string): this;
|
|
162
|
+
/**
|
|
163
|
+
* Sets the image to use. Overwrites any previously set image from other sources like templates.
|
|
164
|
+
* @param imageUrl - The URL or data URL of the image to apply.
|
|
165
|
+
* @returns The builder instance for chaining.
|
|
166
|
+
*/
|
|
167
|
+
useImage(imageUrl: string, overrideOpts?: MethodOverrideOptions): this;
|
|
168
|
+
/**
|
|
169
|
+
* Sets the text to use by its name or a text options object. Overwrites any previously set text.
|
|
170
|
+
* @param textNameOrOptions - Name of a predefined text template or a TextOptions object to apply.
|
|
171
|
+
* @returns The builder instance for chaining.
|
|
172
|
+
*/
|
|
173
|
+
useText(textNameOrOptions: string | TextOptions, overrideOpts?: MethodOverrideOptions): this;
|
|
174
|
+
/**
|
|
175
|
+
* Sets the text to use by its ID. Overwrites any previously set text.
|
|
176
|
+
* @param textId - ID of the predefined text template to apply.
|
|
177
|
+
* @returns The builder instance for chaining.
|
|
178
|
+
*/
|
|
179
|
+
useTextId(textId: string, overrideOpts?: MethodOverrideOptions): this;
|
|
180
|
+
/**
|
|
181
|
+
* Resolves the template, border, style, and image sources and merges them in the correct order.
|
|
182
|
+
* Order: Base Template -> Selected Template -> Selected Border -> Selected Text -> Selected Style -> Selected Image -> Final Options
|
|
183
|
+
* @param finalOptions - The final options object passed to .options() or .build().
|
|
184
|
+
* @returns The fully resolved and merged Options object.
|
|
185
|
+
*/
|
|
186
|
+
private _resolveAndMergeConfig;
|
|
187
|
+
/**
|
|
188
|
+
* Merges the provided options into the builder's configuration and creates the QRCodeJs instance.
|
|
189
|
+
* @param options - A partial options object to merge as the final step.
|
|
190
|
+
* @returns The created QRCodeJs instance.
|
|
191
|
+
*/
|
|
81
192
|
options(options: RecursivePartial<Options>): QRCodeJs;
|
|
82
193
|
/**
|
|
83
194
|
* Builds the QRCodeJs instance with the accumulated configuration.
|