@forgesworn/qr
Version:
Dependency-free QR code encoder and decoder for TypeScript, browsers, workers and Node, with optional WebAssembly and tracked camera scanning.
37 lines (36 loc) • 1.66 kB
TypeScript
import { type ImageLike, type DecodeOptions } from './image.js';
export type { ImageLike, DecodeOptions } from './image.js';
import { type Point, type Work } from './locate.js';
import { type Payload } from './symbol.js';
/** A symbol found in a picture. */
export interface DecodeResult extends Payload {
/** The symbol was mirrored (read transposed). */
readonly mirrored: boolean;
/** The symbol was light on dark. */
readonly inverted: boolean;
/** Picture coordinates of the finder pattern centres, and of the alignment pattern if one was used. */
readonly location: {
readonly topLeft: Point;
readonly topRight: Point;
readonly bottomLeft: Point;
readonly alignment: Point | undefined;
};
}
/**
* Finds and reads one QR code in a picture. Returns undefined when no
* readable code is found.
*/
export declare function decode(image: ImageLike, options?: DecodeOptions): DecodeResult | undefined;
/** Working storage owned by one decoder session, never the caller's data. */
export interface DecodeWorkspace {
luminance?: Uint8Array | undefined;
}
/** Counts search work for tests; optional internal storage leaves ordinary decode() stateless. */
export declare function decodeCounted(image: ImageLike, options?: DecodeOptions, work?: Work, workspace?: DecodeWorkspace): DecodeResult | undefined;
/**
* Reads a symbol from its module grid, `size` by `size`, row by row, truthy
* for dark, with no quiet zone. Mirrored grids read too.
*/
export declare function decodeModules(modules: ArrayLike<number | boolean>, size: number): (Payload & {
readonly mirrored: boolean;
}) | undefined;