UNPKG

@akamfoad/qrcode

Version:

The library is generating QR codes as SVG, HTML5 Canvas, PNG and JPG files, or text.

123 lines (117 loc) 4.19 kB
declare const ERROR_CORRECTION_LEVEL_LOW = "L"; declare const ERROR_CORRECTION_LEVEL_MEDIUM = "M"; declare const ERROR_CORRECTION_LEVEL_QUARTILE = "Q"; declare const ERROR_CORRECTION_LEVEL_HIGH = "H"; type ErrorCorrectionLevelType = typeof ERROR_CORRECTION_LEVEL_LOW | typeof ERROR_CORRECTION_LEVEL_MEDIUM | typeof ERROR_CORRECTION_LEVEL_QUARTILE | typeof ERROR_CORRECTION_LEVEL_HIGH; type OptionsType$4 = { level: ErrorCorrectionLevelType; typeNumber: number; padding: number; invert: boolean; errorsEnabled: boolean; }; type QRCodeDataType = boolean[][]; declare class QRCodeRaw { value: string; level: ErrorCorrectionLevelType; typeNumber: number; padding: number; errorsEnabled: boolean; invert: boolean; qrCodeData: QRCodeDataType | null | undefined; constructor(value: string, options?: Partial<OptionsType$4>); setValue(value: string): void; getDataSize(): number; _clearCache(): void; _getQrCodeData(modules: QRCodeDataType): QRCodeDataType; getData(): QRCodeDataType | null; } type ImageConfigType = { source: string | typeof Image | HTMLCanvasElement | Promise<unknown>; width: number | string; height: number | string; x: number | string; y: number | string; border?: number; }; type OptionsType$3 = OptionsType$4 & { image?: ImageConfigType; }; declare class AbstractQRCodeWithImage extends QRCodeRaw { image: ImageConfigType | null; imageConfig: ImageConfigType | null; constructor(value: string, options?: Partial<OptionsType$3>); _clearCache(): void; _getImageSource(imageConfig: ImageConfigType): string | null; _getImageConfig(): ImageConfigType | null; getData(): QRCodeDataType | null; } type OptionsType$2 = OptionsType$3 & { fgColor?: string; bgColor?: string; scale?: number; size?: number; }; declare class QRCodeCanvas extends AbstractQRCodeWithImage { fgColor: string; bgColor: string; scale: number; size: number | null; canvas: HTMLCanvasElement; canvasContext: CanvasRenderingContext2D; constructor(value: string, options?: Partial<OptionsType$2>); _clearCache(): void; _getCanvasSize(): number | null; draw(canvas?: HTMLCanvasElement | null): null | HTMLCanvasElement | Promise<HTMLCanvasElement>; _getImageSource(imageConfig: ImageConfigType): null | typeof Image | HTMLCanvasElement | Promise<unknown>; _drawImage(qrCodeCanvasContext: HTMLCanvasElement, pixelSize: number): null | true | Promise<unknown>; getCanvas(): null | HTMLCanvasElement | Promise<unknown>; toDataUrl(type?: string, encoderOptions?: number): null | string | Promise<unknown>; } declare const TYPE_INT_WHITE = 0; declare const TYPE_INT_BLACK = 1; declare const TYPE_INT_PROCESSED = 2; type DataIntType = (typeof TYPE_INT_WHITE | typeof TYPE_INT_BLACK | typeof TYPE_INT_PROCESSED)[][]; type RectType = { x: number; y: number; width?: number; height?: number; id?: string | null; }; type OptionsType$1 = OptionsType$3 & { fgColor: string; bgColor?: string; width?: number; height?: number; }; declare class QRCodeSVG extends AbstractQRCodeWithImage { fgColor: string; bgColor: string; qrCodeSVG: string | null; height?: number; width?: number; qrCodeDataUrl: string | null; constructor(value: string, options?: Partial<OptionsType$1>); _clearCache(): void; _getDataInt(): DataIntType | null; _getRects(): RectType[] | null; _processRect(dataInt: DataIntType, begX: number, endX: number, begY: number): RectType | null; _getRelativeRects(): RectType[] | null; _buildSVG(rects: RectType[]): string; toString(): null | string; toDataUrl(): null | string; } type OptionsType = OptionsType$4 & { blackSymbol: string; whiteSymbol: string; }; declare class QRCodeText extends QRCodeRaw { blackSymbol: string; whiteSymbol: string; qrCodeText: string | undefined | null; constructor(value: string, options?: Partial<OptionsType>); _clearCache(): void; toString(): null | string; } export { AbstractQRCodeWithImage, QRCodeCanvas, QRCodeRaw, QRCodeSVG, QRCodeText };