UNPKG

@idscan/idvc2

Version:

component for the capturing documents

85 lines (84 loc) 2.87 kB
import { StepType, StepTypeImageName } from '../environment/stepsDescription'; import { StepMode } from '../defaultConfig'; import { ErrorCodes } from '../environment/langs'; import { DocumentTypeName } from '../environment/documentTypes'; import { Base64 } from '../helpers/base64'; import { MessageAfterDelay } from '../types/core/MessageAfterDelay'; export interface IStepConfigMode { name: 'mode'; value: StepMode; } export type StepConfig = IStepConfigMode; export type StepConfigNames = StepConfig['name']; export type StepConfigValues = StepConfig['value']; export interface IStepObj { name: string; type: StepType; camera: VideoFacingModeEnum; img: Base64 | null; err?: string | null; text?: string; time?: number; configs?: StepConfig[]; stepTypeImageName: StepTypeImageName; shouldRecordMultiImages?: boolean; delayUntilCaptureButtonVisible?: number; messageAfterDelay?: MessageAfterDelay; } export interface IStepCallback { /** base64 encoded step image */ img: Base64 | null; /** blob step image */ blob: Blob | null; /** blob step MultiImages */ multiImagesBlob?: Blob | null; /** step type */ type: StepType; /** is it autocaptured from camera */ isAuto?: boolean; /** image source */ source?: 'video' | 'file' | ''; /** step index */ index?: number; /** trackstring from mrz or pdf */ trackString?: string; /** mrz recognized text */ mrzText?: string; /** cropped base64 encoded mrz image */ mrzImg?: Base64 | null; /** cropped blob mrz image */ mrzBlob?: Blob | null; /** recognized text */ text?: string; } export default class Step implements IStepCallback, IStepObj { blob: Blob | null; multiImagesBlob: Blob | null; errorCode: ErrorCodes | null | undefined; mrzText?: string; mrzImg?: Base64 | null; mrzBlob?: Blob | null; trackString?: string; err?: string | null; text?: string; isAuto?: boolean; source?: 'video' | 'file'; configs: StepConfig[]; name: string; type: StepType; camera: VideoFacingModeEnum; img: Base64 | null; cameraInfo: Record<string, any>; stepTypeImageName: StepTypeImageName; shouldRecordMultiImages: boolean; delayUntilCaptureButtonVisible?: number; messageAfterDelay?: MessageAfterDelay; constructor(nameOrObj: string | IStepObj); get isShowManualSwitchButton(): boolean; get capturingMode(): StepMode; static createStep(stepObj: IStepObj, currentDocumentType: DocumentTypeName | ''): Step; setConfig(configName: StepConfigNames, configValue: StepConfigValues): void; hasConfig(configName: StepConfigNames): StepConfig | undefined; getConfig(configName: StepConfigNames): StepConfigValues | null; prepareStepForCallback(index: number): IStepCallback; }