1import { PermissionResponse } from 'expo-modules-core'; 2 3// @needsAudit 4/** 5 * Alias for `PermissionResponse` type exported by `expo-modules-core`. 6 */ 7export type CameraPermissionResponse = PermissionResponse; 8 9// @needsAudit 10/** 11 * Extends `PermissionResponse` type exported by `expo-modules-core`, containing additional iOS-specific field. 12 */ 13export type MediaLibraryPermissionResponse = PermissionResponse & { 14 /** 15 * @platform ios 16 */ 17 accessPrivileges?: 'all' | 'limited' | 'none'; 18}; 19 20// @needsAudit 21export enum MediaTypeOptions { 22 /** 23 * Images and videos. 24 */ 25 All = 'All', 26 /** 27 * Only videos. 28 */ 29 Videos = 'Videos', 30 /** 31 * Only images. 32 */ 33 Images = 'Images', 34} 35 36// @needsAudit 37export enum VideoExportPreset { 38 /** 39 * Resolution: __Unchanged__ • 40 * Video compression: __None__ • 41 * Audio compression: __None__ 42 */ 43 Passthrough = 0, 44 /** 45 * Resolution: __Depends on the device__ • 46 * Video compression: __H.264__ • 47 * Audio compression: __AAC__ 48 */ 49 LowQuality = 1, 50 /** 51 * Resolution: __Depends on the device__ • 52 * Video compression: __H.264__ • 53 * Audio compression: __AAC__ 54 */ 55 MediumQuality = 2, 56 /** 57 * Resolution: __Depends on the device__ • 58 * Video compression: __H.264__ • 59 * Audio compression: __AAC__ 60 */ 61 HighestQuality = 3, 62 /** 63 * Resolution: __640 × 480__ • 64 * Video compression: __H.264__ • 65 * Audio compression: __AAC__ 66 */ 67 H264_640x480 = 4, 68 /** 69 * Resolution: __960 × 540__ • 70 * Video compression: __H.264__ • 71 * Audio compression: __AAC__ 72 */ 73 H264_960x540 = 5, 74 /** 75 * Resolution: __1280 × 720__ • 76 * Video compression: __H.264__ • 77 * Audio compression: __AAC__ 78 */ 79 H264_1280x720 = 6, 80 /** 81 * Resolution: __1920 × 1080__ • 82 * Video compression: __H.264__ • 83 * Audio compression: __AAC__ 84 */ 85 H264_1920x1080 = 7, 86 /** 87 * Resolution: __3840 × 2160__ • 88 * Video compression: __H.264__ • 89 * Audio compression: __AAC__ 90 */ 91 H264_3840x2160 = 8, 92 /** 93 * Resolution: __1920 × 1080__ • 94 * Video compression: __HEVC__ • 95 * Audio compression: __AAC__ 96 */ 97 HEVC_1920x1080 = 9, 98 /** 99 * Resolution: __3840 × 2160__ • 100 * Video compression: __HEVC__ • 101 * Audio compression: __AAC__ 102 */ 103 HEVC_3840x2160 = 10, 104} 105 106// @needsAudit 107export enum UIImagePickerControllerQualityType { 108 /** 109 * Highest available resolution. 110 */ 111 High = 0, 112 /** 113 * Depends on the device. 114 */ 115 Medium = 1, 116 /** 117 * Depends on the device. 118 */ 119 Low = 2, 120 /** 121 * 640 × 480 122 */ 123 VGA640x480 = 3, 124 /** 125 * 1280 × 720 126 */ 127 IFrame1280x720 = 4, 128 /** 129 * 960 × 540 130 */ 131 IFrame960x540 = 5, 132} 133 134/** 135 * Picker presentation style. Its values are directly mapped to the [`UIModalPresentationStyle`](https://developer.apple.com/documentation/uikit/uiviewcontroller/1621355-modalpresentationstyle). 136 * 137 * @platform ios 138 */ 139export enum UIImagePickerPresentationStyle { 140 /** 141 * A presentation style in which the presented picker covers the screen. 142 */ 143 FULL_SCREEN = 'fullScreen', 144 /** 145 * A presentation style that partially covers the underlying content. 146 */ 147 PAGE_SHEET = 'pageSheet', 148 /** 149 * A presentation style that displays the picker centered in the screen. 150 */ 151 FORM_SHEET = 'formSheet', 152 /** 153 * A presentation style where the picker is displayed over the app's content. 154 */ 155 CURRENT_CONTEXT = 'currentContext', 156 /** 157 * A presentation style in which the picker view covers the screen. 158 */ 159 OVER_FULL_SCREEN = 'overFullScreen', 160 /** 161 * A presentation style where the picker is displayed over the app's content. 162 */ 163 OVER_CURRENT_CONTEXT = 'overCurrentContext', 164 /** 165 * A presentation style where the picker is displayed in a popover view. 166 */ 167 POPOVER = 'popover', 168 /** 169 * The default presentation style chosen by the system. 170 * On older iOS versions, falls back to `WebBrowserPresentationStyle.FullScreen`. 171 * 172 * @platform ios 13+ 173 */ 174 AUTOMATIC = 'automatic', 175} 176 177/** 178 * Picker preferred asset representation mode. Its values are directly mapped to the [`PHPickerConfigurationAssetRepresentationMode`](https://developer.apple.com/documentation/photokit/phpickerconfigurationassetrepresentationmode). 179 * 180 * @platform ios 181 */ 182export enum UIImagePickerPreferredAssetRepresentationMode { 183 /** 184 * A mode that indicates that the system chooses the appropriate asset representation. 185 */ 186 Automatic = 'automatic', 187 /** 188 * A mode that uses the most compatible asset representation. 189 */ 190 Compatible = 'compatible', 191 /** 192 * A mode that uses the current representation to avoid transcoding, if possible. 193 */ 194 Current = 'current', 195} 196 197export enum CameraType { 198 /** 199 * Back/rear camera. 200 */ 201 back = 'back', 202 /** 203 * Front camera 204 */ 205 front = 'front', 206} 207 208/** 209 * @hidden 210 * @deprecated Use `ImagePickerAsset` instead 211 */ 212export type ImageInfo = ImagePickerAsset; 213 214/** 215 * Represents an asset (image or video) returned by the image picker or camera. 216 */ 217export type ImagePickerAsset = { 218 /** 219 * URI to the local image or video file (usable as the source of an `Image` element, in the case of 220 * an image) and `width` and `height` specify the dimensions of the media. 221 */ 222 uri: string; 223 /** 224 * The unique ID that represents the picked image or video, if picked from the library. It can be used 225 * by [expo-media-library](./media-library) to manage the picked asset. 226 * 227 * > This might be `null` when the ID is unavailable or the user gave limited permission to access the media library. 228 * > On Android, the ID is unavailable when the user selects a photo by directly browsing file system. 229 * 230 * @platform ios 231 * @platform android 232 */ 233 assetId?: string | null; 234 /** 235 * Width of the image or video. 236 */ 237 width: number; 238 /** 239 * Height of the image or video. 240 */ 241 height: number; 242 /** 243 * The type of the asset. 244 */ 245 type?: 'image' | 'video'; 246 /** 247 * Preferred filename to use when saving this item. This might be `null` when the name is unavailable 248 * or user gave limited permission to access the media library. 249 * 250 */ 251 fileName?: string | null; 252 /** 253 * File size of the picked image or video, in bytes. 254 * 255 */ 256 fileSize?: number; 257 /** 258 * The `exif` field is included if the `exif` option is truthy, and is an object containing the 259 * image's EXIF data. The names of this object's properties are EXIF tags and the values are the 260 * respective EXIF values for those tags. 261 */ 262 exif?: Record<string, any> | null; 263 /** 264 * When the `base64` option is truthy, it is a Base64-encoded string of the selected image's JPEG data, otherwise `null`. 265 * If you prepend this with `'data:image/jpeg;base64,'` to create a data URI, 266 * you can use it as the source of an `Image` element; for example: 267 * ```ts 268 * <Image 269 * source={{ uri: 'data:image/jpeg;base64,' + asset.base64 }} 270 * style={{ width: 200, height: 200 }} 271 * /> 272 * ``` 273 */ 274 base64?: string | null; 275 /** 276 * Length of the video in milliseconds or `null` if the asset is not a video. 277 */ 278 duration?: number | null; 279}; 280 281// @needsAudit 282export type ImagePickerErrorResult = { 283 /** 284 * The error code. 285 */ 286 code: string; 287 /** 288 * The error message. 289 */ 290 message: string; 291 /** 292 * The exception which caused the error. 293 */ 294 exception?: string; 295}; 296 297// @needsAudit 298/** 299 * Type representing successful and canceled pick result. 300 */ 301export type ImagePickerResult = ImagePickerSuccessResult | ImagePickerCanceledResult; 302 303/** 304 * Type representing successful pick result. 305 */ 306export type ImagePickerSuccessResult = { 307 /** 308 * Boolean flag set to `false` showing that the request was successful. 309 */ 310 canceled: false; 311 /** 312 * An array of picked assets. 313 */ 314 assets: ImagePickerAsset[]; 315}; 316 317/** 318 * Type representing canceled pick result. 319 */ 320export type ImagePickerCanceledResult = { 321 /** 322 * Boolean flag set to `true` showing that the request was canceled. 323 */ 324 canceled: true; 325 /** 326 * `null` signifying that the request was canceled. 327 */ 328 assets: null; 329}; 330 331/** 332 * @hidden 333 * @deprecated Use `ImagePickerResult` instead. 334 */ 335export type ImagePickerCancelledResult = ImagePickerCanceledResult; 336 337/** 338 * @hidden 339 * @deprecated `ImagePickerMultipleResult` has been deprecated in favor of `ImagePickerResult`. 340 */ 341export type ImagePickerMultipleResult = ImagePickerResult; 342 343// @needsAudit 344export type ImagePickerOptions = { 345 /** 346 * Whether to show a UI to edit the image after it is picked. On Android the user can crop and 347 * rotate the image and on iOS simply crop it. 348 * 349 * > - Cropping multiple images is not supported - this option is mutually exclusive with `allowsMultipleSelection`. 350 * > - On iOS, this option is ignored if `allowsMultipleSelection` is enabled. 351 * > - On iOS cropping a `.bmp` image will convert it to `.png`. 352 * 353 * @default false 354 * @platform ios 355 * @platform android 356 */ 357 allowsEditing?: boolean; 358 /** 359 * An array with two entries `[x, y]` specifying the aspect ratio to maintain if the user is 360 * allowed to edit the image (by passing `allowsEditing: true`). This is only applicable on 361 * Android, since on iOS the crop rectangle is always a square. 362 */ 363 aspect?: [number, number]; 364 /** 365 * Specify the quality of compression, from `0` to `1`. `0` means compress for small size, 366 * `1` means compress for maximum quality. 367 * > Note: If the selected image has been compressed before, the size of the output file may be 368 * > bigger than the size of the original image. 369 * 370 * > Note: On iOS, if a `.bmp` or `.png` image is selected from the library, this option is ignored. 371 * 372 * @default 0.2 373 * @platform ios 374 * @platform android 375 */ 376 quality?: number; 377 /** 378 * Choose what type of media to pick. 379 * @default ImagePicker.MediaTypeOptions.Images 380 */ 381 mediaTypes?: MediaTypeOptions; 382 /** 383 * Whether to also include the EXIF data for the image. On iOS the EXIF data does not include GPS 384 * tags in the camera case. 385 */ 386 exif?: boolean; 387 /** 388 * Whether to also include the image data in Base64 format. 389 */ 390 base64?: boolean; 391 /** 392 * Specify preset which will be used to compress selected video. 393 * @default ImagePicker.VideoExportPreset.Passthrough 394 * @platform ios 11+ 395 * @deprecated See [`videoExportPreset`](https://developer.apple.com/documentation/uikit/uiimagepickercontroller/2890964-videoexportpreset?language=objc) 396 * in Apple documentation. 397 */ 398 videoExportPreset?: VideoExportPreset; 399 /** 400 * Specify the quality of recorded videos. Defaults to the highest quality available for the device. 401 * @default ImagePicker.UIImagePickerControllerQualityType.High 402 * @platform ios 403 */ 404 videoQuality?: UIImagePickerControllerQualityType; 405 /** 406 * Whether or not to allow selecting multiple media files at once. 407 * 408 * > Cropping multiple images is not supported - this option is mutually exclusive with `allowsEditing`. 409 * > If this option is enabled, then `allowsEditing` is ignored. 410 * 411 * @default false 412 * @platform ios 14+ 413 * @platform android 414 * @platform web 415 */ 416 allowsMultipleSelection?: boolean; 417 /** 418 * The maximum number of items that user can select. Applicable when `allowsMultipleSelection` is enabled. 419 * Setting the value to `0` sets the selection limit to the maximum that the system supports. 420 * 421 * @platform ios 14+ 422 * @platform android 423 * @default 0 424 */ 425 selectionLimit?: number; 426 /** 427 * Whether to display number badges when assets are selected. The badges are numbered 428 * in selection order. Assets are then returned in the exact same order they were selected. 429 * 430 * > Assets should be returned in the selection order regardless of this option, 431 * > but there is no guarantee that it is always true when this option is disabled. 432 * 433 * @platform ios 15+ 434 * @default false 435 */ 436 orderedSelection?: boolean; 437 /** 438 * Maximum duration, in seconds, for video recording. Setting this to `0` disables the limit. 439 * Defaults to `0` (no limit). 440 * - **On iOS**, when `allowsEditing` is set to `true`, maximum duration is limited to 10 minutes. 441 * This limit is applied automatically, if `0` or no value is specified. 442 * - **On Android**, effect of this option depends on support of installed camera app. 443 * - **On Web** this option has no effect - the limit is browser-dependant. 444 */ 445 videoMaxDuration?: number; 446 /** 447 * Choose [presentation style](https://developer.apple.com/documentation/uikit/uiviewcontroller/1621355-modalpresentationstyle?language=objc) 448 * to customize view during taking photo/video. 449 * @default ImagePicker.UIImagePickerPresentationStyle.Automatic 450 * @platform ios 451 */ 452 presentationStyle?: UIImagePickerPresentationStyle; 453 /** 454 * Selects the camera-facing type. The `CameraType` enum provides two options: 455 * `front` for the front-facing camera and `back` for the back-facing camera. 456 * - **On Android**, the behavior of this option may vary based on the camera app installed on the device. 457 * @default CameraType.back 458 * @platform ios 459 * @platform android 460 */ 461 cameraType?: CameraType; 462 /** 463 * Choose [preferred asset representation mode](https://developer.apple.com/documentation/photokit/phpickerconfigurationassetrepresentationmode) 464 * to use when loading assets. 465 * @default ImagePicker.UIImagePickerPreferredAssetRepresentationMode.Automatic 466 * @platform ios 14+ 467 */ 468 preferredAssetRepresentationMode?: UIImagePickerPreferredAssetRepresentationMode; 469}; 470 471// @needsAudit 472export type OpenFileBrowserOptions = { 473 /** 474 * Choose what type of media to pick. 475 * @default ImagePicker.MediaTypeOptions.Images 476 */ 477 mediaTypes: MediaTypeOptions; 478 // @docsMissing 479 capture?: boolean; 480 /** 481 * Whether or not to allow selecting multiple media files at once. 482 * @platform web 483 */ 484 allowsMultipleSelection: boolean; 485 /** 486 * Whether to also include the image data in Base64 format. 487 */ 488 base64: boolean; 489}; 490 491/** 492 * @hidden 493 * @deprecated Use `ImagePickerResult` or `OpenFileBrowserOptions` instead. 494 */ 495export type ExpandImagePickerResult<T extends ImagePickerOptions | OpenFileBrowserOptions> = 496 T extends { 497 allowsMultipleSelection: true; 498 } 499 ? ImagePickerResult 500 : ImagePickerResult; 501