UNPKG

@qrcode-ai-com/qrcode-barcode-scanner-wasm

Version:

QR and barcode decoding + scannability scoring — one portable browser WASM with camera, tracking and overlay modules, plus optional URL destination checks

98 lines (88 loc) • 5.76 kB
/* tslint:disable */ /* eslint-disable */ export * from "./report-types.js"; import type { Capabilities, ScanReport } from "./report-types.js"; /** * The readers compiled into this module: its report `versions`, decode * `engines` and the `symbologies` they can return (spec/01-report.md * § Capabilities). Says which readers are included, not that an image * will decode. */ export function capabilities(): Capabilities; /** * Scan a raw RGBA8 frame (`ImageData.data`, width, height). Defaults to the * `frame` profile (decode-only, tight budget) — pass another to override. * `budget_ms` overrides the profile's wall-clock budget, in the same * domain as [`scan_image`]'s. The arguments after it are [`scan_image`]'s * other options with the same domains and errors, appended so that a * positional call written for the earlier five arguments keeps its * meaning: `max_dimension`, `max_pixels`, `score_skip_axes`, * `score_skip_checks`, `alpha_background` (transparent pixels of the * frame flatten over it before luma), `alpha_palette`, `score_preset`, * `formats`. */ export function scan_frame(data: Uint8Array, width: number, height: number, profile?: string | null, budget_ms?: number | null, max_dimension?: number | null, max_pixels?: number | null, score_skip_axes?: string[] | null, score_skip_checks?: string[] | null, alpha_background?: string | null, alpha_palette?: string[] | null, score_preset?: string | null, formats?: string[] | null): ScanReport; /** * Scan encoded image bytes (PNG/JPEG/WebP/GIF). Profile: full | fast | * frame. `max_dimension` / `max_pixels` cap the input (whole numbers from * 1; anything else rejects `[QRS-006]`). `budget_ms` overrides the * profile's wall-clock budget (the scan runs synchronously on the calling * thread — bound it in UI contexts; `0`, a negative, `NaN` or `Infinity` = * unbounded, a fraction floors to whole ms, above 4294967295 rejects * `[QRS-006]`, unset = the profile default). A report the budget cut * says so (`trace.budget_exhausted: true`): a `null` score beside * detections then means "not judged", never 0. * `score_skip_axes` (wire names, e.g. `["perspective","rotation"]`) * excludes axes from scoring: their cells never run and the composite * renormalizes engine-side — the generated-preview integration config. * `score_skip_checks` (`["uec","iso15415","alpha_envelope"]`) withholds * report SECTIONS the host does not display: wire carries null, and the * section-driven hints never fire. The UEC margin is still measured and * caps the value, so the composite never moves. * `alpha_background` (`auto` | `white` | `black` | `none` | * `#rrggbb`) picks the background flattened under transparent pixels — * `auto` (default) reads the design's own content and retries the * opposite on a zero-detection scan; opaque inputs are untouched. * `formats` (wire names, e.g. `["qr_code"]`) restricts the scan to the * symbologies the host handles: no reader of another symbology runs, and * the report says what was looked for (`trace.formats`). Unset or empty = * every symbology; an unknown name rejects `[QRS-006]`. */ export function scan_image(bytes: Uint8Array, profile?: string | null, max_dimension?: number | null, max_pixels?: number | null, budget_ms?: number | null, score_skip_axes?: string[] | null, score_skip_checks?: string[] | null, alpha_background?: string | null, alpha_palette?: string[] | null, score_preset?: string | null, formats?: string[] | null): ScanReport; /** * Crate version (the `versions.scanner` of every report). */ export function version(): string; export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module; export interface InitOutput { readonly memory: WebAssembly.Memory; readonly bcmp: (a: number, b: number, c: number) => number; readonly memcmp: (a: number, b: number, c: number) => number; readonly capabilities: (a: number) => void; readonly scan_frame: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number, n: number, o: number, p: number, q: number, r: number, s: number, t: number, u: number, v: number, w: number, x: number, y: number) => void; readonly scan_image: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number, n: number, o: number, p: number, q: number, r: number, s: number, t: number, u: number, v: number, w: number) => void; readonly version: (a: number) => void; readonly __wbindgen_export: (a: number, b: number) => number; readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number; readonly __wbindgen_add_to_stack_pointer: (a: number) => number; readonly __wbindgen_export3: (a: number, b: number, c: number) => void; } export type SyncInitInput = BufferSource | WebAssembly.Module; /** * Instantiates the given `module`, which can either be bytes or * a precompiled `WebAssembly.Module`. * * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated. * * @returns {InitOutput} */ export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput; /** * If `module_or_path` is {RequestInfo} or {URL}, makes a request and * for everything else, calls `WebAssembly.instantiate` directly. * * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated. * * @returns {Promise<InitOutput>} */ export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;