@twin.org/qr 0.0.1-next.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/LICENSE +201 -0
- package/README.md +21 -0
- package/dist/cjs/index.cjs +2006 -0
- package/dist/esm/index.mjs +2000 -0
- package/dist/types/data/qrAlphaNumeric.d.ts +23 -0
- package/dist/types/data/qrByte8.d.ts +23 -0
- package/dist/types/data/qrNumber.d.ts +23 -0
- package/dist/types/helpers/bitBuffer.d.ts +36 -0
- package/dist/types/helpers/mathHelper.d.ts +23 -0
- package/dist/types/helpers/polynomial.d.ts +45 -0
- package/dist/types/helpers/qrHelper.d.ts +49 -0
- package/dist/types/helpers/rsBlock.d.ts +30 -0
- package/dist/types/index.d.ts +9 -0
- package/dist/types/models/IBitmapRendererOptions.d.ts +15 -0
- package/dist/types/models/IRendererOptions.d.ts +13 -0
- package/dist/types/models/ITextRendererOptions.d.ts +14 -0
- package/dist/types/models/errorCorrectLevel.d.ts +27 -0
- package/dist/types/models/maskPattern.d.ts +43 -0
- package/dist/types/models/qrCellData.d.ts +4 -0
- package/dist/types/models/qrDataBase.d.ts +42 -0
- package/dist/types/models/qrDataMode.d.ts +23 -0
- package/dist/types/qr.d.ts +35 -0
- package/dist/types/renderers/jpegRenderer.d.ts +14 -0
- package/dist/types/renderers/pngRenderer.d.ts +14 -0
- package/dist/types/renderers/textRenderer.d.ts +14 -0
- package/docs/changelog.md +5 -0
- package/docs/examples.md +1 -0
- package/docs/reference/classes/JpegRenderer.md +37 -0
- package/docs/reference/classes/PngRenderer.md +37 -0
- package/docs/reference/classes/QR.md +98 -0
- package/docs/reference/classes/TextRenderer.md +37 -0
- package/docs/reference/index.md +23 -0
- package/docs/reference/interfaces/IBitmapRendererOptions.md +47 -0
- package/docs/reference/interfaces/IRendererOptions.md +24 -0
- package/docs/reference/interfaces/ITextRendererOptions.md +47 -0
- package/docs/reference/type-aliases/ErrorCorrectLevel.md +6 -0
- package/docs/reference/type-aliases/QRCellData.md +5 -0
- package/docs/reference/variables/ErrorCorrectLevel.md +32 -0
- package/locales/en.json +34 -0
- package/package.json +64 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { BitBuffer } from "../helpers/bitBuffer";
|
|
2
|
+
import { QRDataBase } from "../models/qrDataBase";
|
|
3
|
+
/**
|
|
4
|
+
* QR Data for representing a alpha numeric.
|
|
5
|
+
* Based on https://github.com/kazuhikoarase/qrcode-generator/ .
|
|
6
|
+
*/
|
|
7
|
+
export declare class QRAlphaNumeric extends QRDataBase {
|
|
8
|
+
/**
|
|
9
|
+
* Create a new instance of QRAlphaNumeric.
|
|
10
|
+
* @param data The data for the qr alpha numeric.
|
|
11
|
+
*/
|
|
12
|
+
constructor(data: string);
|
|
13
|
+
/**
|
|
14
|
+
* Get the length of the data.
|
|
15
|
+
* @returns The length of the data.
|
|
16
|
+
*/
|
|
17
|
+
getLength(): number;
|
|
18
|
+
/**
|
|
19
|
+
* Write data into the buffer.
|
|
20
|
+
* @param buffer The buffer to write into.
|
|
21
|
+
*/
|
|
22
|
+
write(buffer: BitBuffer): void;
|
|
23
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { BitBuffer } from "../helpers/bitBuffer";
|
|
2
|
+
import { QRDataBase } from "../models/qrDataBase";
|
|
3
|
+
/**
|
|
4
|
+
* QR Data for representing a 8 bit data.
|
|
5
|
+
* Based on https://github.com/kazuhikoarase/qrcode-generator/ .
|
|
6
|
+
*/
|
|
7
|
+
export declare class QRByte8 extends QRDataBase {
|
|
8
|
+
/**
|
|
9
|
+
* Create a new instance of QRByte8.
|
|
10
|
+
* @param data The data for the qr 8 bit data.
|
|
11
|
+
*/
|
|
12
|
+
constructor(data: string);
|
|
13
|
+
/**
|
|
14
|
+
* Get the length of the data.
|
|
15
|
+
* @returns The length of the data.
|
|
16
|
+
*/
|
|
17
|
+
getLength(): number;
|
|
18
|
+
/**
|
|
19
|
+
* Write data into the buffer.
|
|
20
|
+
* @param buffer The buffer to write into.
|
|
21
|
+
*/
|
|
22
|
+
write(buffer: BitBuffer): void;
|
|
23
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { BitBuffer } from "../helpers/bitBuffer";
|
|
2
|
+
import { QRDataBase } from "../models/qrDataBase";
|
|
3
|
+
/**
|
|
4
|
+
* QR Data for representing a number.
|
|
5
|
+
* Based on https://github.com/kazuhikoarase/qrcode-generator/ .
|
|
6
|
+
*/
|
|
7
|
+
export declare class QRNumber extends QRDataBase {
|
|
8
|
+
/**
|
|
9
|
+
* Create a new instance of QRNumber.
|
|
10
|
+
* @param data The data for the qr number.
|
|
11
|
+
*/
|
|
12
|
+
constructor(data: string);
|
|
13
|
+
/**
|
|
14
|
+
* Get the length of the data.
|
|
15
|
+
* @returns The length of the data.
|
|
16
|
+
*/
|
|
17
|
+
getLength(): number;
|
|
18
|
+
/**
|
|
19
|
+
* Write data into the buffer.
|
|
20
|
+
* @param buffer The buffer to write into.
|
|
21
|
+
*/
|
|
22
|
+
write(buffer: BitBuffer): void;
|
|
23
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Class for maintaining data bits.
|
|
3
|
+
* Based on https://github.com/kazuhikoarase/qrcode-generator/ .
|
|
4
|
+
*/
|
|
5
|
+
export declare class BitBuffer {
|
|
6
|
+
/**
|
|
7
|
+
* Create a new instance of BitBuffer.
|
|
8
|
+
*/
|
|
9
|
+
constructor();
|
|
10
|
+
/**
|
|
11
|
+
* Get the buffer.
|
|
12
|
+
* @returns The buffer.
|
|
13
|
+
*/
|
|
14
|
+
getBuffer(): number[];
|
|
15
|
+
/**
|
|
16
|
+
* Get the length in bits.
|
|
17
|
+
* @returns The length.
|
|
18
|
+
*/
|
|
19
|
+
getLengthInBits(): number;
|
|
20
|
+
/**
|
|
21
|
+
* Put a value in to the bit buffer.
|
|
22
|
+
* @param num The value.
|
|
23
|
+
* @param length The length.
|
|
24
|
+
*/
|
|
25
|
+
put(num: number, length: number): void;
|
|
26
|
+
/**
|
|
27
|
+
* Put a bit.
|
|
28
|
+
* @param bit The bit to put.
|
|
29
|
+
*/
|
|
30
|
+
putBit(bit: boolean): void;
|
|
31
|
+
/**
|
|
32
|
+
* Convert to string.
|
|
33
|
+
* @returns The buffer as string.
|
|
34
|
+
*/
|
|
35
|
+
toString(): string;
|
|
36
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Class to helper with math.
|
|
3
|
+
* Based on https://github.com/kazuhikoarase/qrcode-generator/ .
|
|
4
|
+
*/
|
|
5
|
+
export declare class MathHelper {
|
|
6
|
+
/**
|
|
7
|
+
* Initialize the math helper.
|
|
8
|
+
*/
|
|
9
|
+
static initialize(): void;
|
|
10
|
+
/**
|
|
11
|
+
* Get the log of the value.
|
|
12
|
+
* @param value The value to get the log of.
|
|
13
|
+
* @returns The log of the value.
|
|
14
|
+
* @throws Error if value < 1.
|
|
15
|
+
*/
|
|
16
|
+
static gLog(value: number): number;
|
|
17
|
+
/**
|
|
18
|
+
* Get the exponent of the value.
|
|
19
|
+
* @param value The value to get the exponent of.
|
|
20
|
+
* @returns The exponent of the value.
|
|
21
|
+
*/
|
|
22
|
+
static gExp(value: number): number;
|
|
23
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Class to represent a polynomial.
|
|
3
|
+
* Based on https://github.com/kazuhikoarase/qrcode-generator/ .
|
|
4
|
+
*/
|
|
5
|
+
export declare class Polynomial {
|
|
6
|
+
/**
|
|
7
|
+
* Create a new instance of Polynomial.
|
|
8
|
+
* @param num The num of the polynomial.
|
|
9
|
+
* @param shift The shift for the polynomial.
|
|
10
|
+
*/
|
|
11
|
+
constructor(num: number[], shift?: number);
|
|
12
|
+
/**
|
|
13
|
+
* The the value of the polynomial at given index.
|
|
14
|
+
* @param index The index.
|
|
15
|
+
* @returns The value of the polynomial.
|
|
16
|
+
*/
|
|
17
|
+
getAt(index: number): number;
|
|
18
|
+
/**
|
|
19
|
+
* Get the length of the polynomial.
|
|
20
|
+
* @returns The polynomial.
|
|
21
|
+
*/
|
|
22
|
+
getLength(): number;
|
|
23
|
+
/**
|
|
24
|
+
* Convert the polynomial to a string.
|
|
25
|
+
* @returns The string representation of the polynomial.
|
|
26
|
+
*/
|
|
27
|
+
toString(): string;
|
|
28
|
+
/**
|
|
29
|
+
* Get the log representation of the polynomial.
|
|
30
|
+
* @returns The log representation of the polynomial.
|
|
31
|
+
*/
|
|
32
|
+
toLogString(): string;
|
|
33
|
+
/**
|
|
34
|
+
* Multiply the polynomial with another one.
|
|
35
|
+
* @param e The polynomial to multiply.
|
|
36
|
+
* @returns The multiplication of the polynomials.
|
|
37
|
+
*/
|
|
38
|
+
multiply(e: Polynomial): Polynomial;
|
|
39
|
+
/**
|
|
40
|
+
* Get the modulus of the polynomial from another.
|
|
41
|
+
* @param e The polynomial.
|
|
42
|
+
* @returns The modules of the polynomials.
|
|
43
|
+
*/
|
|
44
|
+
mod(e: Polynomial): Polynomial;
|
|
45
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Polynomial } from "./polynomial";
|
|
2
|
+
import { ErrorCorrectLevel } from "../models/errorCorrectLevel";
|
|
3
|
+
import { QRDataMode } from "../models/qrDataMode";
|
|
4
|
+
/**
|
|
5
|
+
* Helper methods for QR generation.
|
|
6
|
+
* Based on https://github.com/kazuhikoarase/qrcode-generator/ .
|
|
7
|
+
*/
|
|
8
|
+
export declare class QRHelper {
|
|
9
|
+
/**
|
|
10
|
+
* Get the pattern position for the given type number.
|
|
11
|
+
* @param typeNumber The type number to get the pattern for.
|
|
12
|
+
* @returns The pattern for the type number.
|
|
13
|
+
*/
|
|
14
|
+
static getPatternPosition(typeNumber: number): number[];
|
|
15
|
+
/**
|
|
16
|
+
* Get the max length of the data.
|
|
17
|
+
* @param typeNumber The type number to get the max length for.
|
|
18
|
+
* @param mode The data mode to get data max length for.
|
|
19
|
+
* @param errorCorrectLevel The error correction to get the max length for.
|
|
20
|
+
* @returns The max length.
|
|
21
|
+
* @throws Error with unknown correction level.
|
|
22
|
+
*/
|
|
23
|
+
static getMaxLength(typeNumber: number, mode: QRDataMode, errorCorrectLevel: ErrorCorrectLevel): number;
|
|
24
|
+
/**
|
|
25
|
+
* Get the error correction polynomial for the error correct to length.
|
|
26
|
+
* @param errorCorrectLength The error correction length to get the polynomial for.
|
|
27
|
+
* @returns The polynomial for the error correction length.
|
|
28
|
+
*/
|
|
29
|
+
static getErrorCorrectPolynomial(errorCorrectLength: number): Polynomial;
|
|
30
|
+
/**
|
|
31
|
+
* Get the mask method for the given pattern.
|
|
32
|
+
* @param maskPattern The pattern to get the mask for.
|
|
33
|
+
* @returns The mask method for the pattern.
|
|
34
|
+
* @throws Error with invalid mask.
|
|
35
|
+
*/
|
|
36
|
+
static getMaskMethod(maskPattern: number): (i: number, j: number) => boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Get the BCH type info.
|
|
39
|
+
* @param data The data to get the BCH type info for.
|
|
40
|
+
* @returns The type info.
|
|
41
|
+
*/
|
|
42
|
+
static getBCHTypeInfo(data: number): number;
|
|
43
|
+
/**
|
|
44
|
+
* Get the BCH type number.
|
|
45
|
+
* @param data The data to get the BCH type number for.
|
|
46
|
+
* @returns The type number.
|
|
47
|
+
*/
|
|
48
|
+
static getBCHTypeNumber(data: number): number;
|
|
49
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ErrorCorrectLevel } from "../models/errorCorrectLevel";
|
|
2
|
+
/**
|
|
3
|
+
* Class to represent a RS Block.
|
|
4
|
+
* Based on https://github.com/kazuhikoarase/qrcode-generator/ .
|
|
5
|
+
*/
|
|
6
|
+
export declare class RSBlock {
|
|
7
|
+
/**
|
|
8
|
+
* Create a new instance of RSBlock.
|
|
9
|
+
* @param totalCount The total count for the block.
|
|
10
|
+
* @param dataCount The data count for the block.
|
|
11
|
+
*/
|
|
12
|
+
constructor(totalCount: number, dataCount: number);
|
|
13
|
+
/**
|
|
14
|
+
* Get RS Blocks for the type number and error correct level.
|
|
15
|
+
* @param typeNumber The type number.
|
|
16
|
+
* @param errorCorrectLevel The error correct level.
|
|
17
|
+
* @returns The RS Blocks.
|
|
18
|
+
*/
|
|
19
|
+
static getRSBlocks(typeNumber: number, errorCorrectLevel: ErrorCorrectLevel): RSBlock[];
|
|
20
|
+
/**
|
|
21
|
+
* Get the data count of the block.
|
|
22
|
+
* @returns The data count.
|
|
23
|
+
*/
|
|
24
|
+
getDataCount(): number;
|
|
25
|
+
/**
|
|
26
|
+
* Get the total count of blocks.
|
|
27
|
+
* @returns The total count.
|
|
28
|
+
*/
|
|
29
|
+
getTotalCount(): number;
|
|
30
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from "./models/errorCorrectLevel";
|
|
2
|
+
export * from "./models/IBitmapRendererOptions";
|
|
3
|
+
export * from "./models/IRendererOptions";
|
|
4
|
+
export * from "./models/ITextRendererOptions";
|
|
5
|
+
export * from "./models/qrCellData";
|
|
6
|
+
export * from "./qr";
|
|
7
|
+
export * from "./renderers/jpegRenderer";
|
|
8
|
+
export * from "./renderers/pngRenderer";
|
|
9
|
+
export * from "./renderers/textRenderer";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Color } from "@twin.org/image";
|
|
2
|
+
import type { IRendererOptions } from "./IRendererOptions";
|
|
3
|
+
/**
|
|
4
|
+
* Options for rendering.
|
|
5
|
+
*/
|
|
6
|
+
export interface IBitmapRendererOptions extends IRendererOptions {
|
|
7
|
+
/**
|
|
8
|
+
* Background color.
|
|
9
|
+
*/
|
|
10
|
+
background?: Color | string;
|
|
11
|
+
/**
|
|
12
|
+
* Foreground color.
|
|
13
|
+
*/
|
|
14
|
+
foreground?: Color | string;
|
|
15
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { IRendererOptions } from "./IRendererOptions";
|
|
2
|
+
/**
|
|
3
|
+
* Options for rendering as text.
|
|
4
|
+
*/
|
|
5
|
+
export interface ITextRendererOptions extends IRendererOptions {
|
|
6
|
+
/**
|
|
7
|
+
* The character to use for on pixels.
|
|
8
|
+
*/
|
|
9
|
+
onChar?: string;
|
|
10
|
+
/**
|
|
11
|
+
* The character to use for off pixels.
|
|
12
|
+
*/
|
|
13
|
+
offChar?: string;
|
|
14
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error correction level to use for the QR Code.
|
|
3
|
+
* Based on https://github.com/kazuhikoarase/qrcode-generator/ .
|
|
4
|
+
*/
|
|
5
|
+
export declare const ErrorCorrectLevel: {
|
|
6
|
+
/**
|
|
7
|
+
* 7% Error correction.
|
|
8
|
+
*/
|
|
9
|
+
readonly L: 1;
|
|
10
|
+
/**
|
|
11
|
+
* 15% Error correction.
|
|
12
|
+
*/
|
|
13
|
+
readonly M: 0;
|
|
14
|
+
/**
|
|
15
|
+
* 25% Error correction.
|
|
16
|
+
*/
|
|
17
|
+
readonly Q: 3;
|
|
18
|
+
/**
|
|
19
|
+
* 30% Error correction.
|
|
20
|
+
*/
|
|
21
|
+
readonly H: 2;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Error correction level to use for the QR Code.
|
|
25
|
+
* Based on https://github.com/kazuhikoarase/qrcode-generator/ .
|
|
26
|
+
*/
|
|
27
|
+
export type ErrorCorrectLevel = (typeof ErrorCorrectLevel)[keyof typeof ErrorCorrectLevel];
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mask patterns for QR codes.
|
|
3
|
+
* Based on https://github.com/kazuhikoarase/qrcode-generator/ .
|
|
4
|
+
*/
|
|
5
|
+
export declare const MaskPattern: {
|
|
6
|
+
/**
|
|
7
|
+
* Mask pattern 000.
|
|
8
|
+
*/
|
|
9
|
+
readonly PATTERN000: 0;
|
|
10
|
+
/**
|
|
11
|
+
* Mask pattern 001.
|
|
12
|
+
*/
|
|
13
|
+
readonly PATTERN001: 1;
|
|
14
|
+
/**
|
|
15
|
+
* Mask pattern 010.
|
|
16
|
+
*/
|
|
17
|
+
readonly PATTERN010: 2;
|
|
18
|
+
/**
|
|
19
|
+
* Mask pattern 011.
|
|
20
|
+
*/
|
|
21
|
+
readonly PATTERN011: 3;
|
|
22
|
+
/**
|
|
23
|
+
* Mask pattern 100.
|
|
24
|
+
*/
|
|
25
|
+
readonly PATTERN100: 4;
|
|
26
|
+
/**
|
|
27
|
+
* Mask pattern 101.
|
|
28
|
+
*/
|
|
29
|
+
readonly PATTERN101: 5;
|
|
30
|
+
/**
|
|
31
|
+
* Mask pattern 110.
|
|
32
|
+
*/
|
|
33
|
+
readonly PATTERN110: 6;
|
|
34
|
+
/**
|
|
35
|
+
* Mask pattern 111.
|
|
36
|
+
*/
|
|
37
|
+
readonly PATTERN111: 7;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Mask patterns for QR codes.
|
|
41
|
+
* Based on https://github.com/kazuhikoarase/qrcode-generator/ .
|
|
42
|
+
*/
|
|
43
|
+
export type MaskPattern = (typeof MaskPattern)[keyof typeof MaskPattern];
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { QRDataMode } from "./qrDataMode";
|
|
2
|
+
import type { BitBuffer } from "../helpers/bitBuffer";
|
|
3
|
+
/**
|
|
4
|
+
* Base class for storing QR Data.
|
|
5
|
+
* Based on https://github.com/kazuhikoarase/qrcode-generator/ .
|
|
6
|
+
*/
|
|
7
|
+
export declare abstract class QRDataBase {
|
|
8
|
+
/**
|
|
9
|
+
* Create a new instance of QRDataBase.
|
|
10
|
+
* @param className The class name for the derived class.
|
|
11
|
+
* @param mode The mode for the data.
|
|
12
|
+
* @param data The data.
|
|
13
|
+
*/
|
|
14
|
+
constructor(className: string, mode: QRDataMode, data: string);
|
|
15
|
+
/**
|
|
16
|
+
* Get the data mode.
|
|
17
|
+
* @returns The data mode.
|
|
18
|
+
*/
|
|
19
|
+
getMode(): QRDataMode;
|
|
20
|
+
/**
|
|
21
|
+
* Get the data for the qr.
|
|
22
|
+
* @returns The data.
|
|
23
|
+
*/
|
|
24
|
+
getData(): string;
|
|
25
|
+
/**
|
|
26
|
+
* Get the length in bits of the data.
|
|
27
|
+
* @param typeNumber The type number to get the length for.
|
|
28
|
+
* @returns The length in bits.
|
|
29
|
+
* @throws Error if the typeNumber if invalid.
|
|
30
|
+
*/
|
|
31
|
+
getLengthInBits(typeNumber: number): number;
|
|
32
|
+
/**
|
|
33
|
+
* Get the length of the data.
|
|
34
|
+
* @returns The length of the data.
|
|
35
|
+
*/
|
|
36
|
+
abstract getLength(): number;
|
|
37
|
+
/**
|
|
38
|
+
* Write data into the buffer.
|
|
39
|
+
* @param buffer The buffer to write into.
|
|
40
|
+
*/
|
|
41
|
+
abstract write(buffer: BitBuffer): void;
|
|
42
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The mode for the qr data.
|
|
3
|
+
* Based on https://github.com/kazuhikoarase/qrcode-generator/ .
|
|
4
|
+
*/
|
|
5
|
+
export declare const QRDataMode: {
|
|
6
|
+
/**
|
|
7
|
+
* Number.
|
|
8
|
+
*/
|
|
9
|
+
readonly Number: 1;
|
|
10
|
+
/**
|
|
11
|
+
* Alphabet and number.
|
|
12
|
+
*/
|
|
13
|
+
readonly AlphaNumeric: 2;
|
|
14
|
+
/**
|
|
15
|
+
* 8bit byte.
|
|
16
|
+
*/
|
|
17
|
+
readonly Byte8: 4;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* The mode for the qr data.
|
|
21
|
+
* Based on https://github.com/kazuhikoarase/qrcode-generator/ .
|
|
22
|
+
*/
|
|
23
|
+
export type QRDataMode = (typeof QRDataMode)[keyof typeof QRDataMode];
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ErrorCorrectLevel } from "./models/errorCorrectLevel";
|
|
2
|
+
import type { QRCellData } from "./models/qrCellData";
|
|
3
|
+
/**
|
|
4
|
+
* Class to generates QR codes from data.
|
|
5
|
+
* Based on https://github.com/kazuhikoarase/qrcode-generator/ .
|
|
6
|
+
*/
|
|
7
|
+
export declare class QR {
|
|
8
|
+
/**
|
|
9
|
+
* Create a new instance of QR.
|
|
10
|
+
* @param typeNumber 0 to 40, 0 means autodetect.
|
|
11
|
+
* @param errorCorrectLevel 'L','M','Q','H'.
|
|
12
|
+
* @throws Error if the typeNumber is invalid.
|
|
13
|
+
*/
|
|
14
|
+
constructor(typeNumber?: number, errorCorrectLevel?: ErrorCorrectLevel);
|
|
15
|
+
/**
|
|
16
|
+
* Add text data to the QR Code.
|
|
17
|
+
* @param qrData The data to add.
|
|
18
|
+
*/
|
|
19
|
+
addText(qrData: string): void;
|
|
20
|
+
/**
|
|
21
|
+
* Add number to the QR Code.
|
|
22
|
+
* @param qrData The data to add.
|
|
23
|
+
*/
|
|
24
|
+
addNumber(qrData: string): void;
|
|
25
|
+
/**
|
|
26
|
+
* Add alpha numeric to the QR Code.
|
|
27
|
+
* @param qrData The data to add.
|
|
28
|
+
*/
|
|
29
|
+
addAlphaNumeric(qrData: string): void;
|
|
30
|
+
/**
|
|
31
|
+
* Generate the display buffer.
|
|
32
|
+
* @returns Boolean buffer of pixels.
|
|
33
|
+
*/
|
|
34
|
+
generate(): QRCellData;
|
|
35
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { IBitmapRendererOptions } from "../models/IBitmapRendererOptions";
|
|
2
|
+
import type { QRCellData } from "../models/qrCellData";
|
|
3
|
+
/**
|
|
4
|
+
* Class to render qr data as jpeg.
|
|
5
|
+
*/
|
|
6
|
+
export declare class JpegRenderer {
|
|
7
|
+
/**
|
|
8
|
+
* Render the QR code data as a bitmap.
|
|
9
|
+
* @param cellData The cell data for the QR code.
|
|
10
|
+
* @param options The options for rendering.
|
|
11
|
+
* @returns The bitmap content.
|
|
12
|
+
*/
|
|
13
|
+
static render(cellData: QRCellData, options?: IBitmapRendererOptions): Promise<Uint8Array>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { IBitmapRendererOptions } from "../models/IBitmapRendererOptions";
|
|
2
|
+
import type { QRCellData } from "../models/qrCellData";
|
|
3
|
+
/**
|
|
4
|
+
* Class to render qr data as png.
|
|
5
|
+
*/
|
|
6
|
+
export declare class PngRenderer {
|
|
7
|
+
/**
|
|
8
|
+
* Render the QR code data as a bitmap.
|
|
9
|
+
* @param cellData The cell data for the QR code.
|
|
10
|
+
* @param options The options for rendering.
|
|
11
|
+
* @returns The bitmap content.
|
|
12
|
+
*/
|
|
13
|
+
static render(cellData: QRCellData, options?: IBitmapRendererOptions): Promise<Uint8Array>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ITextRendererOptions } from "../models/ITextRendererOptions";
|
|
2
|
+
import type { QRCellData } from "../models/qrCellData";
|
|
3
|
+
/**
|
|
4
|
+
* Class to render qr data as text.
|
|
5
|
+
*/
|
|
6
|
+
export declare class TextRenderer {
|
|
7
|
+
/**
|
|
8
|
+
* Render the QR code data as text.
|
|
9
|
+
* @param cellData The cell data for the QR code.
|
|
10
|
+
* @param options The options for rendering.
|
|
11
|
+
* @returns The text content.
|
|
12
|
+
*/
|
|
13
|
+
static render(cellData: QRCellData, options?: ITextRendererOptions): Promise<string>;
|
|
14
|
+
}
|
package/docs/examples.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# @twin.org/qr - Examples
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Class: JpegRenderer
|
|
2
|
+
|
|
3
|
+
Class to render qr data as jpeg.
|
|
4
|
+
|
|
5
|
+
## Constructors
|
|
6
|
+
|
|
7
|
+
### new JpegRenderer()
|
|
8
|
+
|
|
9
|
+
> **new JpegRenderer**(): [`JpegRenderer`](JpegRenderer.md)
|
|
10
|
+
|
|
11
|
+
#### Returns
|
|
12
|
+
|
|
13
|
+
[`JpegRenderer`](JpegRenderer.md)
|
|
14
|
+
|
|
15
|
+
## Methods
|
|
16
|
+
|
|
17
|
+
### render()
|
|
18
|
+
|
|
19
|
+
> `static` **render**(`cellData`, `options`?): `Promise`\<`Uint8Array`\>
|
|
20
|
+
|
|
21
|
+
Render the QR code data as a bitmap.
|
|
22
|
+
|
|
23
|
+
#### Parameters
|
|
24
|
+
|
|
25
|
+
• **cellData**: [`QRCellData`](../type-aliases/QRCellData.md)
|
|
26
|
+
|
|
27
|
+
The cell data for the QR code.
|
|
28
|
+
|
|
29
|
+
• **options?**: [`IBitmapRendererOptions`](../interfaces/IBitmapRendererOptions.md)
|
|
30
|
+
|
|
31
|
+
The options for rendering.
|
|
32
|
+
|
|
33
|
+
#### Returns
|
|
34
|
+
|
|
35
|
+
`Promise`\<`Uint8Array`\>
|
|
36
|
+
|
|
37
|
+
The bitmap content.
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Class: PngRenderer
|
|
2
|
+
|
|
3
|
+
Class to render qr data as png.
|
|
4
|
+
|
|
5
|
+
## Constructors
|
|
6
|
+
|
|
7
|
+
### new PngRenderer()
|
|
8
|
+
|
|
9
|
+
> **new PngRenderer**(): [`PngRenderer`](PngRenderer.md)
|
|
10
|
+
|
|
11
|
+
#### Returns
|
|
12
|
+
|
|
13
|
+
[`PngRenderer`](PngRenderer.md)
|
|
14
|
+
|
|
15
|
+
## Methods
|
|
16
|
+
|
|
17
|
+
### render()
|
|
18
|
+
|
|
19
|
+
> `static` **render**(`cellData`, `options`?): `Promise`\<`Uint8Array`\>
|
|
20
|
+
|
|
21
|
+
Render the QR code data as a bitmap.
|
|
22
|
+
|
|
23
|
+
#### Parameters
|
|
24
|
+
|
|
25
|
+
• **cellData**: [`QRCellData`](../type-aliases/QRCellData.md)
|
|
26
|
+
|
|
27
|
+
The cell data for the QR code.
|
|
28
|
+
|
|
29
|
+
• **options?**: [`IBitmapRendererOptions`](../interfaces/IBitmapRendererOptions.md)
|
|
30
|
+
|
|
31
|
+
The options for rendering.
|
|
32
|
+
|
|
33
|
+
#### Returns
|
|
34
|
+
|
|
35
|
+
`Promise`\<`Uint8Array`\>
|
|
36
|
+
|
|
37
|
+
The bitmap content.
|