UNPKG

@scandit/web-datacapture-id

Version:

Scandit Data Capture SDK for the Web

124 lines (123 loc) 5.05 kB
import type { DataCaptureContext, DataCaptureMode, DataCaptureModeJSON } from "@scandit/web-datacapture-core"; import { CameraSettings } from "@scandit/web-datacapture-core"; import type { Serializable } from "@scandit/web-datacapture-core/build/js/private/Serializable"; import { IdCaptureFeedback } from "./IdCaptureFeedback"; import type { IdCaptureSettings, IdCaptureSettingsJSON } from "./IdCaptureSettings"; import type { Listener } from "./Listener"; import { CapturedId } from "./captured-id/CapturedId"; type IdCaptureJSON = DataCaptureModeJSON<IdCaptureSettingsJSON & { licensee: string; licenseKey: string; }>; export declare const STATE: { readonly Initializing: "Initializing"; readonly Available: "Available"; readonly ProcessingFrame: "ProcessingFrame"; readonly ProcessingQueue: "ProcessingQueue"; }; export declare class IdCapture implements DataCaptureMode, Serializable<IdCaptureJSON> { private readonly type; private readonly _synchronousFrameFlow; private state; private _isEnabled; private settings; private _context; private listeners; private overlayListeners; private contextListener; private _centaurusConnector; private _endOfCycleTasks; private _feedback; private _safariOOMDetector?; private _safariOOMStatsCollector?; private readonly _onProcessFrameListener; private readonly workerMessageListener; private constructor(); static get recommendedCameraSettings(): CameraSettings; get context(): DataCaptureContext | null; get feedback(): IdCaptureFeedback; private get privateContext(); static forContext(context: DataCaptureContext | null, settings: IdCaptureSettings): Promise<IdCapture>; setFeedback(feedback: IdCaptureFeedback): Promise<void>; addListener(listener: Listener): void; removeListener(listener: Listener): void; isEnabled(): boolean; setEnabled(enabled: boolean): Promise<void>; reset(): Promise<void>; applySettings(settings: IdCaptureSettings): Promise<void>; parse(code: string): Promise<CapturedId | null>; setExternalTransactionId(transactionId: string | null): Promise<void>; getExternalTransactionId(): Promise<string | null>; toJSONObject(): IdCaptureJSON; /** * Reflects if enableVIZDocuments was enabled in the IdCaptureLoaderOptions. */ private shouldEnableCentaurus; private initCentaurusConnector; private onSDCResetDone; /** * Called when the context has changed source. * It is possible that we are still processing a frame when a source change occurs, which could prevent the * current frame from completing its processing and leave us in an unexpected state (processing a frame forever). */ private didChangeFrameSource; private moveToState; private doReset; private doApplySettings; private addOverlayListener; private removeOverlayListener; /** * If settings require VIZ scanning but the SDK was not configured with "VIZEnabled: true", we issue a warning. */ private checkCaptureSettingsAgainstSDKConfiguration; /** * Called many times by the DataCaptureContext when it receives a frame to process. * * To avoid any synchronization issue between Centaurus and SDC, we only process one frame at a time and don't allow * any other asynchronous operation (like reset()) while a frame is being processed both by Centaurus and SDC. * Any incoming async operation should be performed after the frame was processed, or before we process the next * frame. * The end of the frame processing is notified by the DataCaptureContext through the "onFrameProcessingFinished" * event. * @param frame FrameCapture * @returns A promise informing the Context on the next steps to undertake. */ private onProcessFrame; private doProcessFrame; private onAfterProcessFrame; private logPerformance; private enqueueTask; private processQueue; private shouldEnableVIZScanner; private attachedToContext; private detachedFromContext; private dispose; private didChange; private onWorkerMessage; private processFrameWithCentaurus; private reportToBackend; private uint8ArrayImageToBase64; private convertRawImagesToBase64; private triggerListenersForLocalization; private triggerListenersForResult; private notifyRecoveryAfterCrash; private triggerErrorListener; /** * Send the last result to the worker so that the SDC engine can get it. */ private reportLastResult; /** * Send the last error to the worker so that the SDC engine can get it. */ private reportLastError; /** * Send the last localized ID to the worker so that the SDC engine can get it. */ private reportLastLocalizedId; /** * Send the last detection issue to the worker so that the SDC engine can get it. */ private reportLastDetectionIssue; private onPageAbruptlyReloaded; } export {};