import * as react_native from 'react-native'; import * as react_native_vision_camera from 'react-native-vision-camera'; import { Frame, CameraProps, Code, Orientation } from 'react-native-vision-camera'; import * as react_native_worklets_core from 'react-native-worklets-core'; /** * @see https://developers.google.com/android/reference/com/google/mlkit/vision/barcode/Barcode.BarcodeFormat */ declare const enum AndroidBarcodeFormat { UNKNOWN = -1, ALL_FORMATS = 0, CODE_128 = 1, CODE_39 = 2, CODE_93 = 4, CODABAR = 8, DATA_MATRIX = 16, EAN_13 = 32, EAN_8 = 64, ITF = 128, QR_CODE = 256, UPC_A = 512, UPC_E = 1024, PDF417 = 2048, AZTEC = 4096 } /** * @see https://developers.google.com/android/reference/com/google/mlkit/vision/barcode/Barcode.BarcodeValueType */ declare const enum AndroidBarcodeValueType { UNKNOWN = 0, CONTACT_INFO = 1, EMAIL = 2, ISBN = 3, PHONE = 4, PRODUCT = 5, SMS = 6, TEXT = 7, URL = 8, WIFI = 9, GEO = 10, CALENDAR_EVENT = 11, DRIVER_LICENSE = 12 } /** * @see https://developers.google.com/android/reference/com/google/mlkit/vision/barcode/Barcode.Address.AddressType */ declare const enum AndroidAddressType { UNKNOWN = 0, WORK = 1, HOME = 2 } /** * @see https://developers.google.com/android/reference/com/google/mlkit/vision/barcode/Barcode.WiFi.EncryptionType */ declare const enum AndroidEncryptionType { OPEN = 1, WPA = 2, WEP = 3 } /** * @see https://developers.google.com/android/reference/com/google/mlkit/vision/barcode/Barcode.Email.FormatType */ declare const enum AndroidEmailType { UNKNOWN = 0, WORK = 1, HOME = 2 } /** * @see https://developers.google.com/android/reference/com/google/mlkit/vision/barcode/Barcode.Phone.FormatType */ declare const enum AndroidPhoneType { UNKNOWN = 0, WORK = 1, HOME = 2, FAX = 3, MOBILE = 4 } declare const Templates: { /** * HD-quality for faster Frame Processing in YUV pixelFormat (e.g. 720p) */ readonly FrameProcessingYUV: [{ readonly videoResolution: { readonly width: 1080; readonly height: 720; }; }]; /** * XGA-quality for faster Frame Processing in YUV pixelFormat */ readonly FrameProcessingBarcodeXGA: [{ readonly videoResolution: { readonly width: 1024; readonly height: 768; }; }]; }; type Point = { x: number; y: number; }; type Size = { width: number; height: number; }; type Rect = Point & Size; type Key = string | number | bigint; /** * {@link https://developers.google.com/android/reference/com/google/mlkit/vision/barcode/Barcode.Address} */ interface AndroidAddress { addressLines?: string[]; type?: AndroidAddressType; } /** * {@link https://developers.google.com/android/reference/com/google/mlkit/vision/barcode/Barcode.PersonName} */ interface AndroidPersonName { first?: string; formattedName?: string; last?: string; middle?: string; prefix?: string; pronunciation?: string; suffix?: string; } /** * {@link https://developers.google.com/android/reference/com/google/mlkit/vision/barcode/Barcode.ContactInfo} */ interface AndroidContactInfo { addresses?: AndroidAddress[]; emails?: AndroidEmail[]; name?: AndroidPersonName; organization?: string; phones?: AndroidPhone[]; title?: string; urls?: string[]; } /** * {@link https://developers.google.com/android/reference/com/google/mlkit/vision/barcode/Barcode.Email} */ interface AndroidEmail { address?: string; body?: string; subject?: string; type?: AndroidEmailType; } /** * {@link https://developers.google.com/android/reference/com/google/mlkit/vision/barcode/Barcode.Phone} */ interface AndroidPhone { number?: string; type?: AndroidPhoneType; } /** * {@link https://developers.google.com/android/reference/com/google/mlkit/vision/barcode/Barcode.Sms} */ interface AndroidSms { message?: string; phoneNumber?: string; } /** * {@link https://developers.google.com/android/reference/com/google/mlkit/vision/barcode/Barcode.UrlBookmark} */ interface AndroidUrlBookmark { title?: string; url?: string; } /** * {@link https://developers.google.com/android/reference/com/google/mlkit/vision/barcode/Barcode.WiFi} */ interface AndroidWifi { encryptionType?: AndroidEncryptionType; password?: string; ssid?: string; } /** * {@link https://developers.google.com/android/reference/com/google/mlkit/vision/barcode/Barcode.GeoPoint} */ interface AndroidGeoPoint { lat?: number; lng?: number; } /** * {@link https://developers.google.com/android/reference/com/google/mlkit/vision/barcode/Barcode.CalendarDateTime} */ interface AndroidDate { day: number; hours: number; minutes: number; month: number; rawValue: string; seconds: number; year: number; isUtc: boolean; } /** * {@link https://developers.google.com/android/reference/com/google/mlkit/vision/barcode/Barcode.CalendarEvent} */ interface AndroidCalendarEvent { description?: string; end?: Date; location?: string; organizer?: string; start?: Date; status?: string; summary?: string; } /** * {@link https://developers.google.com/android/reference/com/google/mlkit/vision/barcode/common/Barcode.DriverLicense} */ interface AndroidDriverLicense { addressCity?: string; addressState?: string; addressStreet?: string; addressZip?: string; birthDate?: string; documentType?: string; expiryDate?: string; firstName?: string; gender?: string; issueDate?: string; issuingCountry?: string; lastName?: string; licenseNumber?: string; middleName?: string; } /** * {@link https://developer.android.com/reference/android/graphics/Rect.html} */ type AndroidRect = { bottom: number; left: number; right: number; top: number; }; /** * {@link https://developers.google.com/android/reference/com/google/mlkit/vision/barcode/common/Barcode} */ type AndroidBarcode = { boundingBox: AndroidRect; cornerPoints: Point[]; displayValue: string; rawValue: string; format: AndroidBarcodeFormat; content: { type: AndroidBarcodeValueType.UNKNOWN | AndroidBarcodeValueType.ISBN | AndroidBarcodeValueType.TEXT; data: string; } | { type: AndroidBarcodeValueType.CONTACT_INFO; data: AndroidContactInfo; } | { type: AndroidBarcodeValueType.EMAIL; data: AndroidEmail; } | { type: AndroidBarcodeValueType.PHONE; data: AndroidPhone; } | { type: AndroidBarcodeValueType.SMS; data: AndroidSms; } | { type: AndroidBarcodeValueType.URL; data: AndroidUrlBookmark; } | { type: AndroidBarcodeValueType.WIFI; data: AndroidWifi; } | { type: AndroidBarcodeValueType.GEO; data: AndroidGeoPoint; } | { type: AndroidBarcodeValueType.CALENDAR_EVENT; data: AndroidCalendarEvent; } | { type: AndroidBarcodeValueType.DRIVER_LICENSE; data: AndroidDriverLicense; }; }; type iOSBoundingBox = { origin: Point; size: Size; }; type iOSCorners = { bottomRight: Point; topRight: Point; topLeft: Point; bottomLeft: Point; }; /** * {@link https://developer.apple.com/documentation/vision/vnbarcodesymbology} */ type iOSSymbology = 'VNBarcodeSymbologyAztec' | 'VNBarcodeSymbologyCode39' | 'VNBarcodeSymbologyCode39Checksum' | 'VNBarcodeSymbologyCode39FullASCII' | 'VNBarcodeSymbologyCode39FullASCIIChecksum' | 'VNBarcodeSymbologyCode93' | 'VNBarcodeSymbologyCode93i' | 'VNBarcodeSymbologyCode128' | 'VNBarcodeSymbologyDataMatrix' | 'VNBarcodeSymbologyEAN8' | 'VNBarcodeSymbologyEAN13' | 'VNBarcodeSymbologyGS1DataBar' | 'VNBarcodeSymbologyGS1DataBarExpanded' | 'VNBarcodeSymbologyGS1DataBarLimited' | 'VNBarcodeSymbologyI2of5' | 'VNBarcodeSymbologyI2of5Checksum' | 'VNBarcodeSymbologyITF14' | 'VNBarcodeSymbologyMicroPDF417' | 'VNBarcodeSymbologyMicroQR' | 'VNBarcodeSymbologyMSIPlessey' | 'VNBarcodeSymbologyPDF417' | 'VNBarcodeSymbologyQR' | 'VNBarcodeSymbologyUPCE'; /** * {@link https://developer.apple.com/documentation/vision/vnbarcodeobservation} */ type iOSBarcode = { boundingBox: iOSBoundingBox; timeRange?: { start: number; duration: number; }; symbology: iOSSymbology; confidence: number; uuid: string; payload: string; supplementalPayload?: string; corners: iOSCorners; }; type VisionCameraConstants = { MODULE_NAME: string; BARCODE_TYPES: { [key: string]: number; }; BARCODE_FORMATS: { [key: string]: number; }; }; type BoundingBox = iOSBoundingBox; type CornerPoints = Point[]; type BarcodeType = 'aztec' | 'codabar' | 'code-128' | 'code-39' | 'code-93' | 'data-matrix' | 'ean-13' | 'ean-8' | 'gs1-databar' | 'itf' | 'msi-plessey' | 'pdf-417' | 'qr' | 'upc-a' | 'upc-e' | 'unknown'; type Barcode = { value: string | null; type: BarcodeType; boundingBox: BoundingBox; cornerPoints: CornerPoints; native: iOSBarcode | AndroidBarcode; }; type Highlight = Barcode & { key: Key; cornerPoints: CornerPoints; boundingBox: BoundingBox; }; type PointMapperFn = (point: Point, layout: Size, frame: Frame['orientation']) => Point; type BasicParameterType = string | number | boolean | undefined; type ParameterType = BasicParameterType | BasicParameterType[] | Record; interface FrameProcessorPlugin { /** * Call the native Frame Processor Plugin with the given Frame and options. * @param frame The Frame from the Frame Processor. * @param options (optional) Additional options. Options will be converted to a native dictionary * @returns (optional) A value returned from the native Frame Processor Plugin (or undefined) */ call: (frame: Frame, options?: Record) => ParameterType; } type ResizeMode = NonNullable; type UseBarcodeScannerOptions = { barcodeTypes?: BarcodeType[]; regionOfInterest?: Rect; fps?: number; onBarcodeScanned?: (barcodes: Barcode[], frame: Frame) => void; pointMapper?: PointMapperFn; disableHighlighting?: boolean; resizeMode?: ResizeMode; scanMode?: 'continuous' | 'once'; isMountedRef?: { value: boolean; }; }; declare const useBarcodeScanner: ({ barcodeTypes, regionOfInterest, onBarcodeScanned, pointMapper, disableHighlighting, resizeMode, scanMode, isMountedRef, fps, }: UseBarcodeScannerOptions) => { props: { pixelFormat: "yuv"; frameProcessor: react_native_vision_camera.ReadonlyFrameProcessor; onLayout: (event: react_native.LayoutChangeEvent) => void; }; highlights: Highlight[]; }; declare function useLatestSharedValue(value: T, dependencies?: unknown[]): react_native_worklets_core.ISharedValue; declare const VisionCameraSimpleScanner: any; declare const BARCODE_TYPES: { [key: string]: number; }; declare const BARCODE_FORMATS: { [key: string]: number; }; declare const onBarcodeDetected: (callback: (barcode: iOSBarcode | AndroidBarcode) => unknown) => void; type ScanBarcodesOptions = { barcodeTypes?: BarcodeType[]; regionOfInterest?: [number, number, number, number]; }; declare const scanCodes: (frame: Frame, options?: ScanBarcodesOptions) => Barcode[]; declare const isIOSBarcode: (barcode: iOSBarcode | AndroidBarcode) => barcode is iOSBarcode; declare const isAndroidBarcode: (barcode: iOSBarcode | AndroidBarcode) => barcode is AndroidBarcode; declare const computeBoundingBoxFromCornerPoints: (cornerPoints: Point[]) => BoundingBox; declare const normalizePrecision: (number: number) => number; declare const normalizeNativeBarcode: (barcode: iOSBarcode | AndroidBarcode, frame: Frame) => Barcode; declare const convertVisionCameraCodeToBarcode: (code: Code) => Omit; declare const applyScaleFactor: ({ x, y }: Point, source: Size, target: Size, resizeMode?: CameraProps['resizeMode']) => Point; declare const applyTransformation: ({ x, y }: Point, { width, height }: Size, orientation: Orientation) => Point; declare const computeHighlights: (barcodes: Barcode[], frame: Pick, layout: Size, resizeMode?: CameraProps['resizeMode'], pointMapper?: PointMapperFn) => Highlight[]; declare const normalizeiOSCodeType: (symbology: iOSSymbology) => BarcodeType; declare const normalizeAndroidCodeType: (format: AndroidBarcodeFormat) => BarcodeType; export { type AndroidAddress, AndroidAddressType, type AndroidBarcode, AndroidBarcodeFormat, AndroidBarcodeValueType, type AndroidCalendarEvent, type AndroidContactInfo, type AndroidDate, type AndroidDriverLicense, type AndroidEmail, AndroidEmailType, AndroidEncryptionType, type AndroidGeoPoint, type AndroidPersonName, type AndroidPhone, AndroidPhoneType, type AndroidRect, type AndroidSms, type AndroidUrlBookmark, type AndroidWifi, BARCODE_FORMATS, BARCODE_TYPES, type Barcode, type BarcodeType, type BasicParameterType, type BoundingBox, type CornerPoints, type FrameProcessorPlugin, type Highlight, type Key, type ParameterType, type Point, type PointMapperFn, type Rect, type ScanBarcodesOptions, type Size, Templates, type UseBarcodeScannerOptions, type VisionCameraConstants, VisionCameraSimpleScanner, applyScaleFactor, applyTransformation, computeBoundingBoxFromCornerPoints, computeHighlights, convertVisionCameraCodeToBarcode, type iOSBarcode, type iOSBoundingBox, type iOSCorners, type iOSSymbology, isAndroidBarcode, isIOSBarcode, normalizeAndroidCodeType, normalizeNativeBarcode, normalizePrecision, normalizeiOSCodeType, onBarcodeDetected, scanCodes, useBarcodeScanner, useLatestSharedValue };