export type { Frame, CameraProps, CameraDevice, } from 'react-native-vision-camera'; export type { ForwardedRef } from 'react'; import type { CameraProps, Frame } from 'react-native-vision-camera'; export type ReadonlyFrameProcessor = (frame: Frame) => void; export type Languages = | 'af' | 'sq' | 'ar' | 'be' | 'bn' | 'bg' | 'ca' | 'zh' | 'cs' | 'da' | 'nl' | 'en' | 'eo' | 'et' | 'fi' | 'fr' | 'gl' | 'ka' | 'de' | 'el' | 'gu' | 'ht' | 'he' | 'hi' | 'hu' | 'is' | 'id' | 'ga' | 'it' | 'ja' | 'kn' | 'ko' | 'lv' | 'lt' | 'mk' | 'ms' | 'mt' | 'mr' | 'no' | 'fa' | 'pl' | 'pt' | 'ro' | 'ru' | 'sk' | 'sl' | 'es' | 'sw' | 'tl' | 'ta' | 'te' | 'th' | 'tr' | 'uk' | 'ur' | 'vi' | 'cy'; /** * Percentage string type (e.g., "0%", "50%", "100%") */ export type Percentage = `${number}%`; export type ScanRegion = { left: Percentage; top: Percentage; width: Percentage; height: Percentage; }; export type TextRecognitionOptions = { /** * Language to recognize * @default 'latin' */ language?: 'latin' | 'chinese' | 'devanagari' | 'japanese' | 'korean'; /** * Scan region within the frame to focus text recognition on * @default undefined */ scanRegion?: ScanRegion; /** * Performance optimization: Skip frames to reduce processing load * Higher values = better performance, lower accuracy * @default 10 */ frameSkipThreshold?: number; /** * Use lightweight processing for better performance (Android only) * Skips corner points, languages, and element processing for better performance * Has no effect on iOS - iOS always returns full data structure * @default false */ useLightweightMode?: boolean; }; export type TranslatorOptions = { from: Languages; to: Languages; /** * Scan region within the frame to focus text recognition on * @default undefined */ scanRegion?: ScanRegion; }; export type CameraTypes = { callback: (data: string | Text) => void; mode: 'translate' | 'recognize'; } & CameraProps & ( | { mode: 'recognize'; options: TextRecognitionOptions } | { mode: 'translate'; options: TranslatorOptions } ); export type ScanTextConfig = { scanRegion: ScanRegion }; export type TextRecognitionPlugin = { scanText: (frame: Frame, config?: ScanTextConfig) => Text; }; export type TranslatorPlugin = { /** Worklet-safe synchronous call that returns the last completed OCR result while OCR runs asynchronously. */ scanText: (frame: Frame) => Text; /** Async translation of a text string — runs on the JS thread. */ translate: (text: string) => Promise; }; export type Text = { blocks: BlockData[]; resultText: string; }; export type BlockData = { blockText: string; blockCornerPoints?: CornerPointsType; blockFrame: FrameType; lines: LineData[]; }; export type CornerPointsType = { x: number; y: number }[]; export type FrameType = { boundingCenterX: number; boundingCenterY: number; height: number; width: number; x: number; y: number; }; export type LineData = { lineText: string; lineCornerPoints?: CornerPointsType; lineFrame: FrameType; lineLanguages?: string[]; elements: ElementData[]; }; export type ElementData = { elementText: string; elementCornerPoints?: CornerPointsType; elementFrame: FrameType; }; export type PhotoOptions = { uri: string; orientation?: | 'landscapeRight' | 'portrait' | 'portraitUpsideDown' | 'landscapeLeft'; };