@idscan/idvc2
Version:
component for the capturing documents
80 lines (79 loc) • 2.71 kB
TypeScript
import { Base64Image } from '../helpers/image';
import { StepType, StepTypeImageName } from '../environment/stepsDescription';
import { StepMode } from '../defaultConfig';
import { ErrorCodes } from '../environment/langs';
import { DocumentTypeName } from '../environment/documentTypes';
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: Base64Image | null;
err?: string | null;
text?: string;
time?: number;
configs?: StepConfig[];
stepTypeImageName: StepTypeImageName;
shouldRecordVideo?: boolean;
}
export interface IStepCallback {
/** base64 encoded step image */
img: Base64Image | null;
/** blob step image */
blob: Blob | null;
/** blob step video */
videoBlob?: 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?: Base64Image | null;
/** cropped blob mrz image */
mrzBlob?: Blob | null;
/** recognized text */
text?: string;
}
export default class Step implements IStepCallback, IStepObj {
blob: Blob | null;
videoBlob: Blob | null;
errorCode: ErrorCodes | null | undefined;
mrzText?: string;
mrzImg?: Base64Image | 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: Base64Image | null;
cameraInfo: Record<string, any>;
stepTypeImageName: StepTypeImageName;
shouldRecordVideo: boolean;
constructor(nameOrObj: string | IStepObj, type?: StepType, camera?: VideoFacingModeEnum, time?: number, img?: Base64Image | null);
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;
}