import * as i0 from '@angular/core'; import { OnInit, OnDestroy, ElementRef, EventEmitter } from '@angular/core'; import { Result, Exception, BarcodeFormat, DecodeHintType } from '@zxing/library'; import { BrowserMultiFormatReader, IScannerControls } from '@zxing/browser'; import { Observable } from 'rxjs'; import * as i2 from '@angular/common'; import * as i3 from '@angular/forms'; interface ResultAndError { result?: Result; error?: Exception; } /** * Based on zxing-typescript BrowserCodeReader */ declare class BrowserMultiFormatContinuousReader extends BrowserMultiFormatReader { /** * Allows to call scanner controls API while scanning. * Will be undefined if no scanning is running. */ protected scannerControls: IScannerControls; /** * Returns the code reader scanner controls. */ getScannerControls(): IScannerControls; /** * Starts the decoding from the current or a new video element. * * @param deviceId The device's to be used Id * @param previewEl A new video element */ scanFromDeviceObservable(deviceId?: string, previewEl?: HTMLVideoElement): Promise>; } declare class ZXingScannerComponent implements OnInit, OnDestroy { /** * Supported Hints map. */ private _hints; /** * The ZXing code reader. */ private _codeReader; /** * The device that should be used to scan things. */ private _device; /** * The device that should be used to scan things. */ private _enabled; /** * */ private _isAutostarting; /** * Has `navigator` access. */ private hasNavigator; /** * Says if some native API is supported. */ private isMediaDevicesSupported; /** * If the user-agent allowed the use of the camera or not. */ private hasPermission; /** * Unsubscribe to stop scanning. */ private _scanSubscription?; /** * Reference to the preview element, should be the `video` tag. */ previewElemRef: ElementRef; /** * Enable or disable autofocus of the camera (might have an impact on performance) */ autofocusEnabled: boolean; /** * Delay between attempts to decode (default is 500ms) */ timeBetweenScans: number; /** * Delay between successful decode (default is 500ms) */ delayBetweenScanSuccess: number; /** * Emits when and if the scanner is autostarted. */ autostarted: EventEmitter; /** * True during autostart and false after. It will be null if won't autostart at all. */ autostarting: EventEmitter; /** * If the scanner should autostart with the first available device. */ autostart: boolean; /** * How the preview element should be fit inside the :host container. */ previewFitMode: 'fill' | 'contain' | 'cover' | 'scale-down' | 'none'; /** * Url of the HTML video poster */ poster: string; /** * Emits events when the torch compatibility is changed. */ torchCompatible: EventEmitter; /** * Emits events when a scan is successful performed, will inject the string value of the QR-code to the callback. */ scanSuccess: EventEmitter; /** * Emits events when a scan fails without errors, useful to know how much scan tries where made. */ scanFailure: EventEmitter; /** * Emits events when a scan throws some error, will inject the error to the callback. */ scanError: EventEmitter; /** * Emits events when a scan is performed, will inject the Result value of the QR-code scan (if available) to the callback. */ scanComplete: EventEmitter; /** * Emits events when no cameras are found, will inject an exception (if available) to the callback. */ camerasFound: EventEmitter; /** * Emits events when no cameras are found, will inject an exception (if available) to the callback. */ camerasNotFound: EventEmitter; /** * Emits events when the users answers for permission. */ permissionResponse: EventEmitter; /** * Emits events when has devices status is update. */ hasDevices: EventEmitter; private _ready; private _devicePreStart; /** * Exposes the current code reader, so the user can use it's APIs. */ get codeReader(): BrowserMultiFormatContinuousReader; /** * User device input */ set device(device: MediaDeviceInfo | undefined); /** * Emits when the current device is changed. */ deviceChange: EventEmitter; /** * User device accessor. */ get device(): MediaDeviceInfo | undefined; /** * Returns all the registered formats. */ get formats(): BarcodeFormat[]; /** * Registers formats the scanner should support. * * @param input BarcodeFormat or case-insensitive string array. */ set formats(input: BarcodeFormat[]); /** * Returns all the registered hints. */ get hints(): Map; /** * Does what it takes to set the hints. */ set hints(hints: Map); /** * Sets the desired constraints in all video tracks. * @experimental */ set videoConstraints(constraints: MediaTrackConstraints); /** * */ set isAutostarting(state: boolean); /** * */ get isAutostarting(): boolean; /** * Can turn on/off the device flashlight. * * @experimental Torch/Flash APIs are not stable in all browsers, it may be buggy! */ set torch(onOff: boolean); /** * Starts and Stops the scanning. */ set enable(enabled: boolean); /** * Tells if the scanner is enabled or not. */ get enabled(): boolean; /** * If is `tryHarder` enabled. */ get tryHarder(): boolean; /** * Enable/disable tryHarder hint. */ set tryHarder(enable: boolean); /** * Constructor to build the object and do some DI. */ constructor(); /** * Gets and registers all cameras. */ askForPermission(): Promise; /** * */ getAnyVideoDevice(): Promise; /** * Terminates a stream and it's tracks. */ private terminateStream; private init; /** * Initializes the component without starting the scanner. */ private initAutostartOff; /** * Initializes the component and starts the scanner. * Permissions are asked to accomplish that. */ private initAutostartOn; /** * Checks if the given device is the current defined one. */ isCurrentDevice(device?: MediaDeviceInfo): boolean; /** * Executes some actions before destroy the component. */ ngOnDestroy(): void; /** * */ ngOnInit(): void; /** * Stops the scanning, if any. */ scanStop(): void; /** * Stops the scanning, if any. */ scanStart(): void; /** * Stops old `codeReader` and starts scanning in a new one. */ restart(): void; /** * Discovers and updates known video input devices. */ updateVideoInputDevices(): Promise; /** * Starts the scanner with the back camera otherwise take the last * available device. */ private autostartScanner; /** * Dispatches the scan success event. * * @param result the scan result. */ private dispatchScanSuccess; /** * Dispatches the scan failure event. */ private dispatchScanFailure; /** * Dispatches the scan error event. * * @param error the error thing. */ private dispatchScanError; /** * Dispatches the scan event. * * @param result the scan result. */ private dispatchScanComplete; /** * Returns the filtered permission. */ private handlePermissionException; /** * Returns a valid BarcodeFormat or fails. */ private getBarcodeFormatOrFail; /** * Return a code reader, create one if non exist */ private getCodeReader; /** * Starts the continuous scanning for the given device. * * @param deviceId The deviceId from the device. */ private scanFromDevice; /** * Handles decode errors. */ private _onDecodeError; /** * Handles decode results. */ private _onDecodeResult; /** * Stops the code reader and returns the previous selected device. */ private _reset; /** * Resets the scanner and emits device change. */ reset(): void; /** * Sets the current device. */ private setDevice; /** * Sets the permission value and emits the event. */ private setPermission; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵcmp: i0.ɵɵComponentDeclaration; } declare class ZXingScannerModule { static ɵfac: i0.ɵɵFactoryDeclaration; static ɵmod: i0.ɵɵNgModuleDeclaration; static ɵinj: i0.ɵɵInjectorDeclaration; } export { ZXingScannerComponent, ZXingScannerModule };