@forgesworn/qr
Version:
Dependency-free QR code encoder and decoder for TypeScript, browsers, workers and Node, with optional WebAssembly and tracked camera scanning.
30 lines (29 loc) • 1.58 kB
TypeScript
import { type Decoder } from './session.js';
import { type ImageLike, type DecodeOptions } from './image.js';
import type { DecodeResult } from './decode.js';
import type { EncodeOptions, QrCode } from './encode.js';
import type { Payload } from './symbol.js';
/** The bundled module, relative to this entry. Fetch in browsers; read as a file URL in Node. */
export declare const wasmUrl: string;
export interface WasmQr {
/** Tracks one camera independently, sharing this instance's native input allocation. */
createDecoder(): Decoder;
encode(data: string | Uint8Array, options?: EncodeOptions | null): QrCode;
/** Uses the host character sets with the same text rules as the TypeScript decoder. */
decode(image: ImageLike, options?: DecodeOptions): DecodeResult | undefined;
decodeModules(modules: ArrayLike<number | boolean>, size: number): (Payload & {
mirrored: boolean;
}) | undefined;
/** Frees reusable input storage. The module remains usable. */
reset(): void;
/** Frees input storage, releases module references and rejects subsequent operations. Idempotent. */
dispose(): void;
/** Current WebAssembly linear memory size; zero after disposal. */
readonly memoryBytes: number;
}
/**
* Instantiates the bundled ABI from bytes supplied by the caller. Performs no
* network or filesystem access. Instances and their reusable input buffers are
* independent; returned bytes/modules are copies that survive reset/disposal.
*/
export declare function loadWasm(bytes: Uint8Array | ArrayBuffer): Promise<WasmQr>;