@qr-platform/qr-code.js 0.8.20 → 0.8.22
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/docs/documentation.md +5 -4
- package/docs/examples.md +62 -0
- package/docs/usage-guide.md +20 -0
- package/lib/builder/index.d.ts +13 -0
- package/lib/builder/node.d.ts +13 -0
- package/lib/builder/qr-code-builder.d.ts +25 -0
- package/lib/chunks/zbar-scan-validator-B3GQk_mt.js +1 -0
- package/lib/chunks/zxing-scan-validator-CYcyNnMt.js +1 -0
- package/lib/core/qr-code-js.d.ts +2 -0
- package/lib/core/qr-templates.d.ts +3 -0
- package/lib/index.d.ts +9 -1
- package/lib/index.js +1 -0
- package/lib/lib/zxing-js/src/browser/BrowserCodeReader.d.ts +3 -263
- package/lib/lib/zxing-js/src/core/NodeLuminanceSource.d.ts +10 -13
- package/lib/node.d.ts +8 -0
- package/lib/node.js +1 -0
- package/lib/utils/scan-validator-zxing-node.d.ts +18 -0
- package/package.json +8 -8
- package/lib/lib/zxing-js/src/browser/BrowserQRCodeSvgWriter.d.ts +0 -46
- package/lib/lib/zxing-js/src/browser/BrowserSvgCodeWriter.d.ts +0 -49
- package/lib/lib/zxing-js/src/browser/DecodeContinuouslyCallback.d.ts +0 -6
- package/lib/lib/zxing-js/src/browser/VideoInputDevice.d.ts +0 -22
- package/lib/lib/zxing-js/src/core/Dimension.d.ts +0 -13
- package/lib/lib/zxing-js/src/core/EncodeHintType.d.ts +0 -99
- package/lib/lib/zxing-js/src/core/PlanarYUVLuminanceSource.d.ts +0 -35
- package/lib/lib/zxing-js/src/core/RGBLuminanceSource.d.ts +0 -21
- package/lib/lib/zxing-js/src/core/Writer.d.ts +0 -30
- package/lib/lib/zxing-js/src/core/WriterException.d.ts +0 -7
- package/lib/lib/zxing-js/src/core/common/ECIEncoderSet.d.ts +0 -37
- package/lib/lib/zxing-js/src/core/common/ECIInput.d.ts +0 -79
- package/lib/lib/zxing-js/src/core/common/MinimalECIInput.d.ts +0 -123
- package/lib/lib/zxing-js/src/core/common/detector/CornerDetector.d.ts +0 -35
- package/lib/lib/zxing-js/src/core/common/detector/WhiteRectangleDetector.d.ts +0 -71
- package/lib/lib/zxing-js/src/core/common/reedsolomon/AbstractGenericGFPoly.d.ts +0 -36
- package/lib/lib/zxing-js/src/core/common/reedsolomon/ReedSolomonEncoder.d.ts +0 -41
- package/lib/lib/zxing-js/src/core/qrcode/QRCodeWriter.d.ts +0 -13
- package/lib/lib/zxing-js/src/core/qrcode/encoder/BlockPair.d.ts +0 -7
- package/lib/lib/zxing-js/src/core/qrcode/encoder/ByteMatrix.d.ts +0 -24
- package/lib/lib/zxing-js/src/core/qrcode/encoder/Encoder.d.ts +0 -85
- package/lib/lib/zxing-js/src/core/qrcode/encoder/MaskUtil.d.ts +0 -47
- package/lib/lib/zxing-js/src/core/qrcode/encoder/MatrixUtil.d.ts +0 -37
- package/lib/lib/zxing-js/src/core/qrcode/encoder/QRCode.d.ts +0 -29
- package/lib/lib/zxing-js/src/core/util/ByteArrayOutputStream.d.ts +0 -174
- package/lib/lib/zxing-js/src/core/util/Collections.d.ts +0 -11
- package/lib/lib/zxing-js/src/core/util/Formatter.d.ts +0 -28
- package/lib/lib/zxing-js/src/core/util/Long.d.ts +0 -12
- package/lib/lib/zxing-js/src/core/util/OutputStream.d.ts +0 -106
- package/lib/lib/zxing-js/src/core/util/StandardCharsets.d.ts +0 -7
- package/lib/qr-code-js-node.js +0 -1
- package/lib/qr-code-js.js +0 -1
package/CHANGELOG.md
CHANGED
package/docs/documentation.md
CHANGED
@@ -110,10 +110,11 @@ Options that affect the QR code generation algorithm.
|
|
110
110
|
- **Type**: `ErrorCorrectionLevel` enum
|
111
111
|
- **Default**: `'Q'`
|
112
112
|
- **Possible values**:
|
113
|
-
- `'L'`: 7% error recovery
|
114
|
-
- `'M'`: 15% error recovery
|
115
|
-
- `'Q'`: 25% error recovery
|
116
|
-
- `'H'`: 30% error recovery
|
113
|
+
- `'L'`: Low - 7% error recovery
|
114
|
+
- `'M'`: Medium - 15% error recovery
|
115
|
+
- `'Q'`: Quality - 25% error recovery
|
116
|
+
- `'H'`: High - 30% error recovery
|
117
|
+
|
117
118
|
- **Example**:
|
118
119
|
```typescript
|
119
120
|
qrOptions: {
|
package/docs/examples.md
CHANGED
@@ -37,6 +37,68 @@ if (container && qrCode.svgElement) {
|
|
37
37
|
|
38
38
|
---
|
39
39
|
|
40
|
+
## Using Templates
|
41
|
+
|
42
|
+
Templates provide a way to apply a predefined set of options easily. You can use built-in templates or define your own.
|
43
|
+
|
44
|
+
**Example 1: Using a Predefined Template ('rounded')**
|
45
|
+
|
46
|
+
```javascript
|
47
|
+
// filepath: /Users/kurdin/projects/qr-platform/qr-code-js/docs/examples.md
|
48
|
+
|
49
|
+
// Set the 'rounded' template globally for subsequent instances
|
50
|
+
QRCodeJs.setTemplate('rounded');
|
51
|
+
|
52
|
+
const qrUsingTemplate = new QRCodeJs({
|
53
|
+
data: 'Uses the rounded template'
|
54
|
+
});
|
55
|
+
qrUsingTemplate.append(document.getElementById('template-rounded-container'));
|
56
|
+
|
57
|
+
// Note: The template remains set until changed or cleared.
|
58
|
+
```
|
59
|
+
|
60
|
+
**Example 2: Using a Custom Template Object**
|
61
|
+
|
62
|
+
```javascript
|
63
|
+
// filepath: /Users/kurdin/projects/qr-platform/qr-code-js/docs/examples.md
|
64
|
+
|
65
|
+
const myCustomTemplate = {
|
66
|
+
dotsOptions: { type: 'classy', color: '#8A2BE2' }, // BlueViolet classy dots
|
67
|
+
backgroundOptions: { color: '#FAFAFA' }, // Off-white background
|
68
|
+
cornersSquareOptions: { type: 'dot', color: '#8A2BE2' }
|
69
|
+
};
|
70
|
+
|
71
|
+
// Set the custom template globally
|
72
|
+
QRCodeJs.setTemplate(myCustomTemplate);
|
73
|
+
|
74
|
+
const qrCustomTemplate = new QRCodeJs({
|
75
|
+
data: 'Uses a custom template object'
|
76
|
+
});
|
77
|
+
qrCustomTemplate.append(document.getElementById('template-custom-container'));
|
78
|
+
```
|
79
|
+
|
80
|
+
**Example 3: Overriding Template Options**
|
81
|
+
|
82
|
+
```javascript
|
83
|
+
// filepath: /Users/kurdin/projects/qr-platform/qr-code-js/docs/examples.md
|
84
|
+
|
85
|
+
// Assume 'dots' template is set globally
|
86
|
+
QRCodeJs.setTemplate('dots');
|
87
|
+
|
88
|
+
const qrOverrideTemplate = new QRCodeJs({
|
89
|
+
data: 'Overrides template color',
|
90
|
+
// This color will override the black color from the 'dots' template
|
91
|
+
dotsOptions: { color: '#FF4500' } // OrangeRed dots
|
92
|
+
});
|
93
|
+
qrOverrideTemplate.append(document.getElementById('template-override-container'));
|
94
|
+
|
95
|
+
// Remember to clear the template if you don't want it for subsequent QRs
|
96
|
+
// QRCodeJs.setTemplate(null); // Or set back to 'basic' or another template
|
97
|
+
```
|
98
|
+
|
99
|
+
---
|
100
|
+
|
101
|
+
|
40
102
|
## Examples by Option Group
|
41
103
|
|
42
104
|
### Core Options
|
package/docs/usage-guide.md
CHANGED
@@ -516,6 +516,26 @@ if (validationResult.isValid) {
|
|
516
516
|
Configures a custom function for fetching license tokens.
|
517
517
|
|
518
518
|
|
519
|
+
- **`QRCodeJs.setTemplate(templateNameOrOptions: string | RecursivePartial<Options>): void`**
|
520
|
+
Sets a default template to be used for subsequent `QRCodeJs` instances. This template's options will be merged with the options provided during instantiation, with the instantiation options taking precedence. You can provide either the name of a predefined template (e.g., `'rounded'`, `'dots'`) or a custom options object.
|
521
|
+
|
522
|
+
```typescript
|
523
|
+
// Set a predefined template by name
|
524
|
+
QRCodeJs.setTemplate('rounded');
|
525
|
+
const qr1 = new QRCodeJs({ data: 'Uses rounded template' });
|
526
|
+
|
527
|
+
// Set a custom template object
|
528
|
+
const myTemplate = { dotsOptions: { type: 'classy', color: '#AA00AA' } };
|
529
|
+
QRCodeJs.setTemplate(myTemplate);
|
530
|
+
const qr2 = new QRCodeJs({ data: 'Uses custom classy template' });
|
531
|
+
|
532
|
+
// Clear the template (falls back to basic)
|
533
|
+
// @ts-expect-error - Accessing private static for testing/clearing
|
534
|
+
QRCodeJs._selectedTemplate = null;
|
535
|
+
const qr3 = new QRCodeJs({ data: 'Uses basic template again' });
|
536
|
+
```
|
537
|
+
|
538
|
+
|
519
539
|
## FAQ
|
520
540
|
|
521
541
|
### How do I handle CORS issues with embedded images?
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import { QRCodeJs } from '../index';
|
2
|
+
import { QRCodeBuilderCore } from './qr-code-builder';
|
3
|
+
/**
|
4
|
+
* Builder class specifically for the browser environment.
|
5
|
+
* Extends the core builder and provides the browser QRCodeJs constructor.
|
6
|
+
*/
|
7
|
+
export declare class QRCodeBuilder extends QRCodeBuilderCore<QRCodeJs> {
|
8
|
+
/**
|
9
|
+
* Creates a new QRCodeBuilder instance for the browser.
|
10
|
+
* @param templateName - Optional name of a predefined template to start with.
|
11
|
+
*/
|
12
|
+
constructor(templateName?: string);
|
13
|
+
}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import { QRCodeJs } from '../node';
|
2
|
+
import { QRCodeBuilderCore } from './qr-code-builder';
|
3
|
+
/**
|
4
|
+
* Builder class specifically for the Node.js environment.
|
5
|
+
* Extends the core builder and provides the node QRCodeJs constructor.
|
6
|
+
*/
|
7
|
+
export declare class QRCodeBuilder extends QRCodeBuilderCore<QRCodeJs> {
|
8
|
+
/**
|
9
|
+
* Creates a new QRCodeBuilder instance for Node.js.
|
10
|
+
* @param templateName - Optional name of a predefined template to start with.
|
11
|
+
*/
|
12
|
+
constructor(templateName?: string);
|
13
|
+
}
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import { QRCodeJs as QRCodeJsBase } from '../core/qr-code-js';
|
2
|
+
import { RecursivePartial } from '../types/helper';
|
3
|
+
import { Options } from '../utils/options';
|
4
|
+
type QRCodeJsConstructor<T extends QRCodeJsBase = QRCodeJsBase> = new (options: Options) => T;
|
5
|
+
/**
|
6
|
+
* Core Builder class for fluently configuring QRCodeJs instances.
|
7
|
+
* This class is generic and requires the specific QRCodeJs constructor to be passed.
|
8
|
+
*/
|
9
|
+
export declare class QRCodeBuilderCore<T extends QRCodeJsBase> {
|
10
|
+
protected config: RecursivePartial<Options>;
|
11
|
+
protected qrCodeJsConstructor: QRCodeJsConstructor<T>;
|
12
|
+
/**
|
13
|
+
* Creates a new QRCodeBuilderCore instance.
|
14
|
+
* @param qrCodeJsConstructor - The constructor of the specific QRCodeJs class to use.
|
15
|
+
* @param templateName - Optional name of a predefined template to start with.
|
16
|
+
*/
|
17
|
+
constructor(qrCodeJsConstructor: QRCodeJsConstructor<T>, templateName?: string);
|
18
|
+
/**
|
19
|
+
* Merges the provided options into the builder's configuration and creates the QRCodeJs instance.
|
20
|
+
* @param options - A partial options object to merge.
|
21
|
+
* @returns The created QRCodeJs instance.
|
22
|
+
*/
|
23
|
+
options(options: RecursivePartial<Options>): T;
|
24
|
+
}
|
25
|
+
export {};
|