/** * MIT License * * Copyright (C) 2025 Huawei Device Co., Ltd. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ import type { TurboModule } from "react-native/library/TurboModule/RCTExport"; import { TurboModuleRegistry } from "react-native"; type ImageOrVideo = Image | Video; type SmartAlbums = | 'Regular' | 'SyncedEvent' | 'SyncedFaces'; type CompressVideoPresets = | 'LowQuality' | 'MediumQuality' | 'HighestQuality' | 'Passthrough'; type Options = AnyOptions | VideoOptions | ImageOptions; type MediaType = 'photo' | 'video' | 'any'; type AnyOptions = Omit & Omit & { mediaType?: 'any'; } type VideoOptions = CommonOptions & { mediaType: 'video'; compressVideoPreset?: CompressVideoPresets; } type CropperOptions = ImageOptions & { path: string; } type ImageOptions = CommonOptions & { mediaType: MediaType; width?: number; height?: number; includeBase64?: boolean; includeExif?: boolean; forceJpg?: boolean; cropping?: boolean; avoidEmptySpaceAroundImage?: boolean; cropperActiveWidgetColor?: string; cropperStatusBarColor?: string; cropperToolbarColor?: string; cropperToolbarWidgetColor?: string; cropperToolbarTitle?: string; freeStyleCropEnabled?: boolean; cropperTintColor?: string; cropperCircleOverlay?: boolean; cropperCancelText?: string; cropperCancelColor?: string; cropperChooseText?: string; cropperChooseColor?: string; cropperRotateButtonHidden?: boolean showCropGuidelines?: boolean; showCropFrame?: boolean; enableRotationGesture?: boolean; disableCropperColorSetters?: boolean; compressImageMaxWidth?: number; compressImageMaxHeight?: number; compressImageQuality?: number; } export interface CommonOptions { multiple?: boolean; minFiles?: number; maxFiles?: number; waitAnimationEnd?: boolean; smartAlbums?: SmartAlbums[]; useFrontCamera?: boolean; loadingLabelText?: string; showsSelectedCount?: boolean; sortOrder?: 'none' | 'asc' | 'desc'; hideBottomControls?: boolean; writeTempFile?: boolean; } export interface CropRect { x: number; y: number; width: number; height: number; } interface ImageVideoCommon { path: string; size: number; width: number; height: number; mime: string; exif?: Exif; localIdentifier?: string; sourceURL?: string; filename?: string; creationDate?: string; modificationDate?: string; } export interface Exif { } interface Image extends ImageVideoCommon { data?: string | null; cropRect?: CropRect | null; } interface Video extends ImageVideoCommon { duration: number | null; } export interface Spec extends TurboModule { openPicker(options: Options): Promise; openCamera(options: Options): Promise; openCropper(options: CropperOptions): Promise; clean(): Promise; cleanSingle(path: string): Promise; } export default TurboModuleRegistry.getEnforcing('ImageCropPicker')