import type { Merge } from "type-fest"; import { type ReaderOptions, type ReadResult, type WriterOptions, type ZXingReaderOptions, type ZXingReadResult, type ZXingVector, type ZXingWriteResult, type ZXingWriterOptions } from "./bindings/index.js"; export type ZXingModuleType = "reader" | "writer" | "full"; /** * @internal */ export interface ZXingReaderModule extends EmscriptenModule { readBarcodesFromImage(bufferPtr: number, bufferLength: number, zxingReaderOptions: ZXingReaderOptions): ZXingVector; readBarcodesFromPixmap(bufferPtr: number, imgWidth: number, imgHeight: number, zxingReaderOptions: ZXingReaderOptions): ZXingVector; } /** * @internal */ export interface ZXingWriterModule extends EmscriptenModule { writeBarcodeFromText(text: string, zxingWriterOptions: ZXingWriterOptions): ZXingWriteResult; writeBarcodeFromBytes(bufferPtr: number, bufferLength: number, zxingWriterOptions: ZXingWriterOptions): ZXingWriteResult; } /** * @internal */ export interface ZXingFullModule extends ZXingReaderModule, ZXingWriterModule { } export type ZXingReaderModuleFactory = EmscriptenModuleFactory; export type ZXingWriterModuleFactory = EmscriptenModuleFactory; export type ZXingFullModuleFactory = EmscriptenModuleFactory; interface TypeModuleMap { reader: [ZXingReaderModule, ZXingReaderModuleFactory]; writer: [ZXingWriterModule, ZXingWriterModuleFactory]; full: [ZXingFullModule, ZXingFullModuleFactory]; } export type ZXingModule = TypeModuleMap[T][0]; export type ZXingModuleFactory = TypeModuleMap[T][1]; export type ZXingModuleOverrides = Partial; export declare const ZXING_WASM_VERSION: string; export declare const ZXING_CPP_COMMIT: string; export interface PrepareZXingModuleOptions { /** * The Emscripten module overrides to be passed to the factory function. * The `locateFile` function is overridden by default to load the WASM file from the jsDelivr CDN. */ overrides?: ZXingModuleOverrides; /** * A function to compare the cached overrides with the input overrides. * So that the module promise can be reused if the overrides are the same. * Defaults to a shallow equality function. */ equalityFn?: (cachedOverrides: ZXingModuleOverrides, overrides: ZXingModuleOverrides) => boolean; /** * Whether to instantiate the module immediately. * If `true`, the module is eagerly instantiated and a promise of the module is returned. * If `false`, only the overrides are updated and module instantiation is deferred * to the first read/write operation. * * @default false */ fireImmediately?: boolean; } /** * Performs a shallow equality comparison between two objects. * * @param a - First object to compare * @param b - Second object to compare * @returns `true` if objects are shallowly equal, `false` otherwise * * @remarks * Objects are considered shallowly equal if: * - They are the same reference (using Object.is) * - They have the same number of keys * - All keys in `a` exist in `b` with strictly equal values (===) * * Note: This comparison only checks the first level of properties. * Nested objects or arrays are compared by reference, not by value. * * @example * ```ts * shallow({ a: 1, b: 2 }, { a: 1, b: 2 }) // returns true * shallow({ a: 1 }, { a: 1, b: 2 }) // returns false * shallow({ a: {x: 1} }, { a: {x: 1} }) // returns false (different object references) * ``` */ export declare function shallow>(a: T, b: T): boolean; export declare function prepareZXingModuleWithFactory(zxingModuleFactory: ZXingModuleFactory, options?: Merge): void; export declare function prepareZXingModuleWithFactory(zxingModuleFactory: ZXingModuleFactory, options: Merge): Promise>; export declare function prepareZXingModuleWithFactory(zxingModuleFactory: ZXingModuleFactory, options?: PrepareZXingModuleOptions): void | Promise>; /** * Removes a ZXing module instance from the internal cache. * * @param zxingModuleFactory - The factory function used to create the ZXing module instance * * @remarks * This function is used to clean up cached ZXing module instances when they are no longer needed. */ export declare function purgeZXingModuleWithFactory(zxingModuleFactory: ZXingModuleFactory): void; /** * Reads barcodes from an image using a ZXing module factory. * * @param zxingModuleFactory - Factory function to create a ZXing module instance * @param input - Source image data as a Blob, ArrayBuffer, Uint8Array, or ImageData * @param readerOptions - Optional configuration options for barcode reading (defaults to defaultReaderOptions) * @returns An array of ReadResult objects containing decoded barcode information * * @remarks * The function manages memory allocation and deallocation for the ZXing module * and properly cleans up resources after processing. */ export declare function readBarcodesWithFactory(zxingModuleFactory: ZXingModuleFactory, input: Blob | ArrayBuffer | Uint8Array | ImageData, readerOptions?: ReaderOptions): Promise; /** * Generates a barcode image using a ZXing module factory with support for text and binary input. * * @param zxingModuleFactory - The factory function that creates a ZXing module instance * @param input - The data to encode in the barcode, either as a string or Uint8Array * @param writerOptions - Optional configuration options for barcode generation * @returns A promise that resolves to the barcode write result * * @remarks * The function handles memory management automatically when processing binary input, * ensuring proper allocation and deallocation of memory in the ZXing module. */ export declare function writeBarcodeWithFactory(zxingModuleFactory: ZXingModuleFactory, input: string | Uint8Array, writerOptions?: WriterOptions): Promise<{ image: Blob | null; svg: string; utf8: string; error: string; symbol: import("./bindings/barcodeSymbol.js").BarcodeSymbol; }>; export {};