/// /** * Error correction level, ordered by recovery capacity (and overhead): * L ~7%, M ~15%, Q ~25%, H ~30%. */ export type QrErrorCorrectionLevel = 'L' | 'M' | 'Q' | 'H'; /** * Encoding mode for the payload. * - `numeric`: digits only (most compact) * - `alphanumeric`: 0-9 A-Z and ` $%*+-./:` (uppercase only) * - `byte`: any string, encoded as UTF-8 * * When omitted, the smallest applicable mode is auto-detected. */ export type QrMode = 'numeric' | 'alphanumeric' | 'byte'; export interface QrCodeOptions { /** * Error correction level. Default: `M`. */ ecl?: QrErrorCorrectionLevel; /** * QR version 1..40 (matrix grows by 4 modules per step: v1=21x21, v40=177x177). * Default: `0` = auto-select the smallest version that fits the payload. */ typeNumber?: number; /** * Force an encoding mode. Default: auto-detect (`numeric` < `alphanumeric` < `byte`). * Ignored when the content is a `Uint8Array` (always `byte`). */ mode?: QrMode; } export interface QrSvgOptions { /** Pixels per module (the rendered `width`/`height` = `(size + border*2) * scale`). Default `4`. */ scale?: number; /** Quiet-zone width in modules. The spec recommends `4`. Default `4`. */ border?: number; /** Color of dark modules. Default `#000000`. */ dark?: string; /** Color of light modules / background. Default `#ffffff`. */ light?: string; } export interface QrAsciiOptions { /** Quiet-zone width in modules. Default `2`. */ border?: number; /** Swap dark/light glyphs (useful on dark terminal backgrounds). Default `false`. */ invert?: boolean; } export interface QrCanvasOptions { /** Pixels per module. Default `4`. */ scale?: number; /** Quiet-zone width in modules. Default `4`. */ border?: number; /** Color of dark modules. Default `#000000`. */ dark?: string; /** Color of light modules. Default `#ffffff`. */ light?: string; } /** * Create a QR code from a string or raw bytes. * * @example * createQrCode('https://example.com').toDataUrl() * createQrCode('HELLO', { ecl: 'H' }).toSvg({ scale: 8 }) */ export declare function createQrCode(content: string | Uint8Array, opt?: QrCodeOptions): QrCode; /** * An immutable QR code: a square matrix of dark/light modules, plus renderers. */ export declare class QrCode { /** Width/height of the matrix in modules (`typeNumber * 4 + 17`). */ readonly size: number; /** `modules[row][col]` - `true` = dark. */ readonly modules: readonly boolean[][]; /** Error correction level used. */ readonly ecl: QrErrorCorrectionLevel; constructor( /** Width/height of the matrix in modules (`typeNumber * 4 + 17`). */ size: number, /** `modules[row][col]` - `true` = dark. */ modules: readonly boolean[][], /** Error correction level used. */ ecl: QrErrorCorrectionLevel); /** Whether the module at `[row, col]` is dark. */ isDark(row: number, col: number): boolean; /** * Render as a standalone SVG document string. */ toSvg(opt?: QrSvgOptions): string; /** * Render as an `data:image/svg+xml` URL, ready for `` or CSS `background`. */ toDataUrl(opt?: QrSvgOptions): string; /** * Render as ASCII art using block characters - handy for terminals and logs. * Each module is 2 chars wide so the output keeps a square aspect ratio. */ toAscii(opt?: QrAsciiOptions): string; /** Same as {@link toAscii} with defaults. */ toString(): string; /** * Paint the QR code onto a 2d canvas context (browser). */ renderToCanvas(ctx: CanvasRenderingContext2D, opt?: QrCanvasOptions): void; }