expo-image-picker 14.5.0 → 14.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -10,6 +10,24 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
+ ## 14.7.0 — 2023-11-14
14
+
15
+ ### 🛠 Breaking changes
16
+
17
+ - Bumped iOS deployment target to 13.4. ([#25063](https://github.com/expo/expo/pull/25063) by [@gabrieldonadel](https://github.com/gabrieldonadel))
18
+ - On `Android` bump `compileSdkVersion` and `targetSdkVersion` to `34`. ([#24708](https://github.com/expo/expo/pull/24708) by [@alanjhughes](https://github.com/alanjhughes))
19
+
20
+ ## 14.6.0 — 2023-10-17
21
+
22
+ ### 🛠 Breaking changes
23
+
24
+ - Dropped support for Android SDK 21 and 22. ([#24201](https://github.com/expo/expo/pull/24201) by [@behenate](https://github.com/behenate))
25
+
26
+ ### 🎉 New features
27
+
28
+ - On Android, support `fileName` and `filesize` in the returned assets. ([#24524](https://github.com/expo/expo/pull/24524) by [@alanjhughes](https://github.com/alanjhughes))
29
+ - Support returning the mime type of the returned assets. ([#24659](https://github.com/expo/expo/pull/24659) by [@alanjhughes](https://github.com/alanjhughes))
30
+
13
31
  ## 14.5.0 — 2023-09-04
14
32
 
15
33
  ### 🎉 New features
@@ -3,15 +3,20 @@ apply plugin: 'kotlin-android'
3
3
  apply plugin: 'maven-publish'
4
4
 
5
5
  group = 'host.exp.exponent'
6
- version = '14.5.0'
6
+ version = '14.7.0'
7
7
 
8
- buildscript {
9
- def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
10
- if (expoModulesCorePlugin.exists()) {
11
- apply from: expoModulesCorePlugin
12
- applyKotlinExpoModulesCorePlugin()
8
+ def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
9
+ if (expoModulesCorePlugin.exists()) {
10
+ apply from: expoModulesCorePlugin
11
+ applyKotlinExpoModulesCorePlugin()
12
+ // Remove this check, but keep the contents after SDK49 support is dropped
13
+ if (safeExtGet("expoProvidesDefaultConfig", false)) {
14
+ useExpoPublishing()
15
+ useCoreDependencies()
13
16
  }
17
+ }
14
18
 
19
+ buildscript {
15
20
  // Simple helper that allows the root project to override versions declared by this library.
16
21
  ext.safeExtGet = { prop, fallback ->
17
22
  rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
@@ -35,23 +40,44 @@ buildscript {
35
40
  }
36
41
  }
37
42
 
38
- afterEvaluate {
39
- publishing {
40
- publications {
41
- release(MavenPublication) {
42
- from components.release
43
+ // Remove this if and it's contents, when support for SDK49 is dropped
44
+ if (!safeExtGet("expoProvidesDefaultConfig", false)) {
45
+ afterEvaluate {
46
+ publishing {
47
+ publications {
48
+ release(MavenPublication) {
49
+ from components.release
50
+ }
43
51
  }
44
- }
45
- repositories {
46
- maven {
47
- url = mavenLocal().url
52
+ repositories {
53
+ maven {
54
+ url = mavenLocal().url
55
+ }
48
56
  }
49
57
  }
50
58
  }
51
59
  }
52
60
 
53
61
  android {
54
- compileSdkVersion safeExtGet("compileSdkVersion", 33)
62
+ // Remove this if and it's contents, when support for SDK49 is dropped
63
+ if (!safeExtGet("expoProvidesDefaultConfig", false)) {
64
+ compileSdkVersion safeExtGet("compileSdkVersion", 34)
65
+
66
+ defaultConfig {
67
+ minSdkVersion safeExtGet("minSdkVersion", 23)
68
+ targetSdkVersion safeExtGet("targetSdkVersion", 34)
69
+ }
70
+
71
+ publishing {
72
+ singleVariant("release") {
73
+ withSourcesJar()
74
+ }
75
+ }
76
+
77
+ lintOptions {
78
+ abortOnError false
79
+ }
80
+ }
55
81
 
56
82
  def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION
57
83
  if (agpVersion.tokenize('.')[0].toInteger() < 8) {
@@ -67,29 +93,22 @@ android {
67
93
 
68
94
  namespace "expo.modules.imagepicker"
69
95
  defaultConfig {
70
- minSdkVersion safeExtGet("minSdkVersion", 21)
71
- targetSdkVersion safeExtGet("targetSdkVersion", 33)
72
96
  versionCode 22
73
- versionName "14.5.0"
74
- }
75
- lintOptions {
76
- abortOnError false
77
- }
78
- publishing {
79
- singleVariant("release") {
80
- withSourcesJar()
81
- }
97
+ versionName "14.7.0"
82
98
  }
83
99
  }
84
100
 
85
101
  dependencies {
86
- implementation project(':expo-modules-core')
102
+ // Remove this if and it's contents, when support for SDK49 is dropped
103
+ if (!safeExtGet("expoProvidesDefaultConfig", false)) {
104
+ implementation project(':expo-modules-core')
105
+ implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${getKotlinVersion()}"
106
+ }
87
107
 
88
108
  implementation "androidx.activity:activity-ktx:1.7.2"
89
109
  implementation "androidx.appcompat:appcompat:1.6.1"
90
110
  implementation "androidx.exifinterface:exifinterface:1.3.3"
91
111
  implementation "com.github.CanHub:Android-Image-Cropper:4.3.1"
92
- implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${getKotlinVersion()}"
93
112
  implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.3"
94
113
  implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.3"
95
114
  }
@@ -162,7 +162,7 @@ class ImagePickerModule : Module() {
162
162
  */
163
163
  private suspend fun launchPicker(
164
164
  pickerLauncher: suspend () -> ImagePickerContractResult,
165
- ): ImagePickerContractResult.Success = withContext(Dispatchers.Main) {
165
+ ): ImagePickerContractResult.Success = withContext(Dispatchers.IO) {
166
166
  when (val pickingResult = pickerLauncher()) {
167
167
  is ImagePickerContractResult.Success -> pickingResult
168
168
  is ImagePickerContractResult.Cancelled -> throw OperationCanceledException()
@@ -11,6 +11,9 @@ internal class ImagePickerAsset(
11
11
  @Field val uri: String = "",
12
12
  @Field val width: Int = 0,
13
13
  @Field val height: Int = 0,
14
+ @Field val fileName: String? = null,
15
+ @Field val filesize: Long? = null,
16
+ @Field val mimeType: String? = null,
14
17
  @Field val base64: String? = null,
15
18
  @Field val exif: Bundle? = null,
16
19
  @Field val duration: Int? = null,
@@ -3,6 +3,7 @@ package expo.modules.imagepicker
3
3
  import android.content.Context
4
4
  import android.media.MediaMetadataRetriever
5
5
  import android.net.Uri
6
+ import android.provider.OpenableColumns
6
7
  import android.util.Base64
7
8
  import androidx.core.net.toUri
8
9
  import expo.modules.imagepicker.exporters.CompressionImageExporter
@@ -46,7 +47,8 @@ internal class MediaHandler(
46
47
  } else {
47
48
  CompressionImageExporter(appContextProvider, options.quality)
48
49
  }
49
- val outputFile = createOutputFile(cacheDirectory, getType(context.contentResolver, sourceUri).toImageFileExtension())
50
+ val mimeType = getType(context.contentResolver, sourceUri)
51
+ val outputFile = createOutputFile(cacheDirectory, mimeType.toImageFileExtension())
50
52
 
51
53
  val exportedImage = exporter.exportAsync(sourceUri, outputFile, context.contentResolver)
52
54
  val base64 = options.base64.takeIf { it }
@@ -55,17 +57,35 @@ internal class MediaHandler(
55
57
  val exif = options.exif.takeIf { it }
56
58
  ?.let { exportedImage.exif(context.contentResolver) }
57
59
 
60
+ val fileData = getAdditionalFileData(sourceUri)
61
+
58
62
  return ImagePickerAsset(
59
63
  type = MediaType.IMAGE,
60
64
  uri = Uri.fromFile(outputFile).toString(),
61
65
  width = exportedImage.width,
62
66
  height = exportedImage.height,
67
+ fileName = fileData?.fileName,
68
+ filesize = fileData?.filesize,
69
+ mimeType = mimeType,
63
70
  base64 = base64,
64
71
  exif = exif,
65
72
  assetId = sourceUri.getMediaStoreAssetId(),
66
73
  )
67
74
  }
68
75
 
76
+ private fun getAdditionalFileData(uri: Uri): AdditionalFileData? = context.contentResolver.query(uri, null, null, null, null)?.use { cursor ->
77
+ val nameIndex = cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME)
78
+ val sizeIndex = cursor.getColumnIndex(OpenableColumns.SIZE)
79
+ cursor.moveToFirst()
80
+
81
+ val name: String? = cursor.getString(nameIndex)
82
+ val size = cursor.getLong(sizeIndex)
83
+ AdditionalFileData(
84
+ name,
85
+ size
86
+ )
87
+ }
88
+
69
89
  private suspend fun handleVideo(
70
90
  sourceUri: Uri,
71
91
  ): ImagePickerAsset {
@@ -78,11 +98,17 @@ internal class MediaHandler(
78
98
  setDataSource(context, outputUri)
79
99
  }
80
100
 
101
+ val fileData = getAdditionalFileData(sourceUri)
102
+ val mimeType = getType(context.contentResolver, sourceUri)
103
+
81
104
  return ImagePickerAsset(
82
105
  type = MediaType.VIDEO,
83
106
  uri = outputUri.toString(),
84
107
  width = metadataRetriever.extractInt(MediaMetadataRetriever.METADATA_KEY_VIDEO_WIDTH),
85
108
  height = metadataRetriever.extractInt(MediaMetadataRetriever.METADATA_KEY_VIDEO_HEIGHT),
109
+ fileName = fileData?.fileName,
110
+ filesize = fileData?.filesize,
111
+ mimeType = mimeType,
86
112
  duration = metadataRetriever.extractInt(MediaMetadataRetriever.METADATA_KEY_DURATION),
87
113
  rotation = metadataRetriever.extractInt(MediaMetadataRetriever.METADATA_KEY_VIDEO_ROTATION),
88
114
  assetId = sourceUri.getMediaStoreAssetId()
@@ -92,3 +118,8 @@ internal class MediaHandler(
92
118
  }
93
119
  }
94
120
  }
121
+
122
+ data class AdditionalFileData(
123
+ val fileName: String?,
124
+ val filesize: Long?
125
+ )
@@ -14,6 +14,7 @@ import expo.modules.imagepicker.UNLIMITED_SELECTION
14
14
  import expo.modules.imagepicker.getAllDataUris
15
15
  import expo.modules.imagepicker.toMediaType
16
16
  import expo.modules.kotlin.activityresult.AppContextActivityResultContract
17
+ import expo.modules.kotlin.exception.Exceptions
17
18
  import expo.modules.kotlin.providers.AppContextProvider
18
19
  import java.io.Serializable
19
20
 
@@ -28,9 +29,8 @@ internal class ImageLibraryContract(
28
29
  private val appContextProvider: AppContextProvider,
29
30
  ) : AppContextActivityResultContract<ImageLibraryContractOptions, ImagePickerContractResult> {
30
31
  private val contentResolver: ContentResolver
31
- get() = requireNotNull(appContextProvider.appContext.reactContext) {
32
- "React Application Context is null"
33
- }.contentResolver
32
+ get() = appContextProvider.appContext.reactContext?.contentResolver
33
+ ?: throw Exceptions.ReactContextLost()
34
34
 
35
35
  override fun createIntent(context: Context, input: ImageLibraryContractOptions): Intent {
36
36
  val request = PickVisualMediaRequest.Builder()
@@ -86,9 +86,9 @@ internal class ImageLibraryContract(
86
86
  )
87
87
  } else {
88
88
  if (intent.data != null) {
89
- intent.data?.let {
90
- val type = it.toMediaType(contentResolver)
91
- ImagePickerContractResult.Success(listOf(type to it))
89
+ intent.data?.let { uri ->
90
+ val type = uri.toMediaType(contentResolver)
91
+ ImagePickerContractResult.Success(listOf(type to uri))
92
92
  }
93
93
  } else {
94
94
  uris.firstOrNull()?.let { uri ->
@@ -107,6 +107,8 @@ function readFile(targetFile, options) {
107
107
  uri,
108
108
  width: image.naturalWidth ?? image.width,
109
109
  height: image.naturalHeight ?? image.height,
110
+ mimeType: targetFile.type,
111
+ fileName: targetFile.name,
110
112
  // The blob's result cannot be directly decoded as Base64 without
111
113
  // first removing the Data-URL declaration preceding the
112
114
  // Base64-encoded data. To retrieve only the Base64 encoded string,
@@ -1 +1 @@
1
- {"version":3,"file":"ExponentImagePicker.web.js","sourceRoot":"","sources":["../src/ExponentImagePicker.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,gBAAgB,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAEnF,OAAO,EAGL,gBAAgB,GAEjB,MAAM,qBAAqB,CAAC;AAE7B,MAAM,cAAc,GAAG;IACrB,CAAC,gBAAgB,CAAC,GAAG,CAAC,EAAE,uDAAuD;IAC/E,CAAC,gBAAgB,CAAC,MAAM,CAAC,EAAE,SAAS;IACpC,CAAC,gBAAgB,CAAC,MAAM,CAAC,EAAE,+CAA+C;CAC3E,CAAC;AAEF,eAAe;IACb,IAAI,IAAI;QACN,OAAO,qBAAqB,CAAC;IAC/B,CAAC;IAED,KAAK,CAAC,uBAAuB,CAAC,EAC5B,UAAU,GAAG,gBAAgB,CAAC,MAAM,EACpC,uBA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;wBAC3C,iEAAiE;wBACjE,wDAAwD;wBACxD,mEAAmE;wBACnE,iDAAiD;wBACjD,4EAA4E;wBAC5E,GAAG,CAAC,OAAO,CAAC,MAAM,IAAI,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;qBACpE,CAAC,CAAC;gBACL,CAAC,CAAC;gBACF,KAAK,CAAC,OAAO,GAAG,GAAG,EAAE,CAAC,SAAS,EAAE,CAAC;aACnC;iBAAM;gBACL,SAAS,EAAE,CAAC;aACb;QACH,CAAC,CAAC;QAEF,MAAM,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;IACnC,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { PermissionResponse, PermissionStatus, Platform } from 'expo-modules-core';\n\nimport {\n ImagePickerAsset,\n ImagePickerResult,\n MediaTypeOptions,\n OpenFileBrowserOptions,\n} from './ImagePicker.types';\n\nconst MediaTypeInput = {\n [MediaTypeOptions.All]: 'video/mp4,video/quicktime,video/x-m4v,video/*,image/*',\n [MediaTypeOptions.Images]: 'image/*',\n [MediaTypeOptions.Videos]: 'video/mp4,video/quicktime,video/x-m4v,video/*',\n};\n\nexport default {\n get name(): string {\n return 'ExponentImagePicker';\n },\n\n async launchImageLibraryAsync({\n mediaTypes = MediaTypeOptions.Images,\n allowsMultipleSelection = false,\n base64 = false,\n }): Promise<ImagePickerResult> {\n // SSR guard\n if (!Platform.isDOMAvailable) {\n return { canceled: true, assets: null };\n }\n return await openFileBrowserAsync({\n mediaTypes,\n allowsMultipleSelection,\n base64,\n });\n },\n\n async launchCameraAsync({\n mediaTypes = MediaTypeOptions.Images,\n allowsMultipleSelection = false,\n base64 = false,\n }): Promise<ImagePickerResult> {\n // SSR guard\n if (!Platform.isDOMAvailable) {\n return { canceled: true, assets: null };\n }\n return await openFileBrowserAsync({\n mediaTypes,\n allowsMultipleSelection,\n capture: true,\n base64,\n });\n },\n\n /*\n * Delegate to expo-permissions to request camera permissions\n */\n async getCameraPermissionsAsync() {\n return permissionGrantedResponse();\n },\n async requestCameraPermissionsAsync() {\n return permissionGrantedResponse();\n },\n\n /*\n * Camera roll permissions don't need to be requested on web, so we always\n * respond with granted.\n */\n async getMediaLibraryPermissionsAsync(_writeOnly: boolean) {\n return permissionGrantedResponse();\n },\n async requestMediaLibraryPermissionsAsync(_writeOnly: boolean): Promise<PermissionResponse> {\n return permissionGrantedResponse();\n },\n};\n\nfunction permissionGrantedResponse(): PermissionResponse {\n return {\n status: PermissionStatus.GRANTED,\n expires: 'never',\n granted: true,\n canAskAgain: true,\n };\n}\n\nfunction openFileBrowserAsync({\n mediaTypes,\n capture = false,\n allowsMultipleSelection = false,\n base64,\n}: OpenFileBrowserOptions): Promise<ImagePickerResult> {\n const mediaTypeFormat = MediaTypeInput[mediaTypes];\n\n const input = document.createElement('input');\n input.style.display = 'none';\n input.setAttribute('type', 'file');\n input.setAttribute('accept', mediaTypeFormat);\n input.setAttribute('id', String(Math.random()));\n if (allowsMultipleSelection) {\n input.setAttribute('multiple', 'multiple');\n }\n if (capture) {\n input.setAttribute('capture', 'camera');\n }\n document.body.appendChild(input);\n\n return new Promise((resolve) => {\n input.addEventListener('change', async () => {\n if (input.files) {\n const files = allowsMultipleSelection ? input.files : [input.files[0]];\n const assets: ImagePickerAsset[] = await Promise.all(\n Array.from(files).map((file) => readFile(file, { base64 }))\n );\n\n resolve({ canceled: false, assets });\n } else {\n resolve({ canceled: true, assets: null });\n }\n document.body.removeChild(input);\n });\n\n const event = new MouseEvent('click');\n input.dispatchEvent(event);\n });\n}\n\nfunction readFile(targetFile: Blob, options: { base64: boolean }): Promise<ImagePickerAsset> {\n return new Promise((resolve, reject) => {\n const reader = new FileReader();\n reader.onerror = () => {\n reject(new Error(`Failed to read the selected media because the operation failed.`));\n };\n reader.onload = ({ target }) => {\n const uri = (target as any).result;\n const returnRaw = () => resolve({ uri, width: 0, height: 0 });\n\n if (typeof uri === 'string') {\n const image = new Image();\n image.src = uri;\n image.onload = () => {\n resolve({\n uri,\n width: image.naturalWidth ?? image.width,\n height: image.naturalHeight ?? image.height,\n // The blob's result cannot be directly decoded as Base64 without\n // first removing the Data-URL declaration preceding the\n // Base64-encoded data. To retrieve only the Base64 encoded string,\n // first remove data:*/*;base64, from the result.\n // https://developer.mozilla.org/en-US/docs/Web/API/FileReader/readAsDataURL\n ...(options.base64 && { base64: uri.substr(uri.indexOf(',') + 1) }),\n });\n };\n image.onerror = () => returnRaw();\n } else {\n returnRaw();\n }\n };\n\n reader.readAsDataURL(targetFile);\n });\n}\n"]}
1
+ {"version":3,"file":"ExponentImagePicker.web.js","sourceRoot":"","sources":["../src/ExponentImagePicker.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,gBAAgB,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAEnF,OAAO,EAGL,gBAAgB,GAEjB,MAAM,qBAAqB,CAAC;AAE7B,MAAM,cAAc,GAAG;IACrB,CAAC,gBAAgB,CAAC,GAAG,CAAC,EAAE,uDAAuD;IAC/E,CAAC,gBAAgB,CAAC,MAAM,CAAC,EAAE,SAAS;IACpC,CAAC,gBAAgB,CAAC,MAAM,CAAC,EAAE,+CAA+C;CAC3E,CAAC;AAEF,eAAe;IACb,IAAI,IAAI;QACN,OAAO,qBAAqB,CAAC;IAC/B,CAAC;IAED,KAAK,CAAC,uBAAuB,CAAC,EAC5B,UAAU,GAAG,gBAAgB,CAAC,MAAM,EACpC,uBAAuB,GAAG,KAAK,EAC/B,MAAM,GAAG,KAAK,GACf;QACC,YAAY;QACZ,IAAI,CAAC,QAAQ,CAAC,cAAc,EAAE;YAC5B,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;SACzC;QACD,OAAO,MAAM,oBAAoB,CAAC;YAChC,UAAU;YACV,uBAAuB;YACvB,MAAM;SACP,CAAC,CAAC;IACL,CAAC;IAED,KA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G,CAAC,CAAC,EAAE,CAAC;qBACpE,CAAC,CAAC;gBACL,CAAC,CAAC;gBACF,KAAK,CAAC,OAAO,GAAG,GAAG,EAAE,CAAC,SAAS,EAAE,CAAC;aACnC;iBAAM;gBACL,SAAS,EAAE,CAAC;aACb;QACH,CAAC,CAAC;QAEF,MAAM,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;IACnC,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { PermissionResponse, PermissionStatus, Platform } from 'expo-modules-core';\n\nimport {\n ImagePickerAsset,\n ImagePickerResult,\n MediaTypeOptions,\n OpenFileBrowserOptions,\n} from './ImagePicker.types';\n\nconst MediaTypeInput = {\n [MediaTypeOptions.All]: 'video/mp4,video/quicktime,video/x-m4v,video/*,image/*',\n [MediaTypeOptions.Images]: 'image/*',\n [MediaTypeOptions.Videos]: 'video/mp4,video/quicktime,video/x-m4v,video/*',\n};\n\nexport default {\n get name(): string {\n return 'ExponentImagePicker';\n },\n\n async launchImageLibraryAsync({\n mediaTypes = MediaTypeOptions.Images,\n allowsMultipleSelection = false,\n base64 = false,\n }): Promise<ImagePickerResult> {\n // SSR guard\n if (!Platform.isDOMAvailable) {\n return { canceled: true, assets: null };\n }\n return await openFileBrowserAsync({\n mediaTypes,\n allowsMultipleSelection,\n base64,\n });\n },\n\n async launchCameraAsync({\n mediaTypes = MediaTypeOptions.Images,\n allowsMultipleSelection = false,\n base64 = false,\n }): Promise<ImagePickerResult> {\n // SSR guard\n if (!Platform.isDOMAvailable) {\n return { canceled: true, assets: null };\n }\n return await openFileBrowserAsync({\n mediaTypes,\n allowsMultipleSelection,\n capture: true,\n base64,\n });\n },\n\n /*\n * Delegate to expo-permissions to request camera permissions\n */\n async getCameraPermissionsAsync() {\n return permissionGrantedResponse();\n },\n async requestCameraPermissionsAsync() {\n return permissionGrantedResponse();\n },\n\n /*\n * Camera roll permissions don't need to be requested on web, so we always\n * respond with granted.\n */\n async getMediaLibraryPermissionsAsync(_writeOnly: boolean) {\n return permissionGrantedResponse();\n },\n async requestMediaLibraryPermissionsAsync(_writeOnly: boolean): Promise<PermissionResponse> {\n return permissionGrantedResponse();\n },\n};\n\nfunction permissionGrantedResponse(): PermissionResponse {\n return {\n status: PermissionStatus.GRANTED,\n expires: 'never',\n granted: true,\n canAskAgain: true,\n };\n}\n\nfunction openFileBrowserAsync({\n mediaTypes,\n capture = false,\n allowsMultipleSelection = false,\n base64,\n}: OpenFileBrowserOptions): Promise<ImagePickerResult> {\n const mediaTypeFormat = MediaTypeInput[mediaTypes];\n\n const input = document.createElement('input');\n input.style.display = 'none';\n input.setAttribute('type', 'file');\n input.setAttribute('accept', mediaTypeFormat);\n input.setAttribute('id', String(Math.random()));\n if (allowsMultipleSelection) {\n input.setAttribute('multiple', 'multiple');\n }\n if (capture) {\n input.setAttribute('capture', 'camera');\n }\n document.body.appendChild(input);\n\n return new Promise((resolve) => {\n input.addEventListener('change', async () => {\n if (input.files) {\n const files = allowsMultipleSelection ? input.files : [input.files[0]];\n const assets: ImagePickerAsset[] = await Promise.all(\n Array.from(files).map((file) => readFile(file, { base64 }))\n );\n\n resolve({ canceled: false, assets });\n } else {\n resolve({ canceled: true, assets: null });\n }\n document.body.removeChild(input);\n });\n\n const event = new MouseEvent('click');\n input.dispatchEvent(event);\n });\n}\n\nfunction readFile(targetFile: File, options: { base64: boolean }): Promise<ImagePickerAsset> {\n return new Promise((resolve, reject) => {\n const reader = new FileReader();\n reader.onerror = () => {\n reject(new Error(`Failed to read the selected media because the operation failed.`));\n };\n reader.onload = ({ target }) => {\n const uri = (target as any).result;\n const returnRaw = () => resolve({ uri, width: 0, height: 0 });\n\n if (typeof uri === 'string') {\n const image = new Image();\n image.src = uri;\n\n image.onload = () => {\n resolve({\n uri,\n width: image.naturalWidth ?? image.width,\n height: image.naturalHeight ?? image.height,\n mimeType: targetFile.type,\n fileName: targetFile.name,\n // The blob's result cannot be directly decoded as Base64 without\n // first removing the Data-URL declaration preceding the\n // Base64-encoded data. To retrieve only the Base64 encoded string,\n // first remove data:*/*;base64, from the result.\n // https://developer.mozilla.org/en-US/docs/Web/API/FileReader/readAsDataURL\n ...(options.base64 && { base64: uri.substr(uri.indexOf(',') + 1) }),\n });\n };\n image.onerror = () => returnRaw();\n } else {\n returnRaw();\n }\n };\n\n reader.readAsDataURL(targetFile);\n });\n}\n"]}
@@ -232,13 +232,11 @@ export type ImagePickerAsset = {
232
232
  * Preferred filename to use when saving this item. This might be `null` when the name is unavailable
233
233
  * or user gave limited permission to access the media library.
234
234
  *
235
- * @platform ios
236
235
  */
237
236
  fileName?: string | null;
238
237
  /**
239
238
  * File size of the picked image or video, in bytes.
240
239
  *
241
- * @platform ios
242
240
  */
243
241
  fileSize?: number;
244
242
  /**
@@ -263,6 +261,10 @@ export type ImagePickerAsset = {
263
261
  * Length of the video in milliseconds or `null` if the asset is not a video.
264
262
  */
265
263
  duration?: number | null;
264
+ /**
265
+ * The MIME type of the selected asset or `null` if could not be determined.
266
+ */
267
+ mimeType?: string;
266
268
  };
267
269
  export type ImagePickerErrorResult = {
268
270
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"ImagePicker.types.d.ts","sourceRoot":"","sources":["../src/ImagePicker.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAGvD;;GAEG;AACH,MAAM,MAAM,wBAAwB,GAAG,kBAAkB,CAAC;AAG1D;;GAEG;AACH,MAAM,MAAM,8BAA8B,GAAG,kBAAkB,GAAG;IAChE;;OAEG;IACH,gBAAgB,CAAC,EAAE,KAAK,GAAG,SAAS,GAAG,MAAM,CAAC;CAC/C,CAAC;AAGF,oBAAY,gBAAgB;IAC1B;;OAEG;IACH,GAAG,QAAQ;IACX;;OAEG;IACH,MAAM,WAAW;IACjB;;OAEG;IACH,MAAM,WAAW;CAClB;AAGD,oBAAY,iBAAiB;IAC3B;;;;OAIG;IACH,WAAW,IAAI;IACf;;;;OAIG;IACH,UAAU,IAAI;I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ker.types.d.ts","sourceRoot":"","sources":["../src/ImagePicker.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAGvD;;GAEG;AACH,MAAM,MAAM,wBAAwB,GAAG,kBAAkB,CAAC;AAG1D;;GAEG;AACH,MAAM,MAAM,8BAA8B,GAAG,kBAAkB,GAAG;IAChE;;OAEG;IACH,gBAAgB,CAAC,EAAE,KAAK,GAAG,SAAS,GAAG,MAAM,CAAC;CAC/C,CAAC;AAGF,oBAAY,gBAAgB;IAC1B;;OAEG;IACH,GAAG,QAAQ;IACX;;OAEG;IACH,MAAM,WAAW;IACjB;;OAEG;IACH,MAAM,WAAW;CAClB;AAGD,oBAAY,iBAAiB;IAC3B;;;;OAIG;IACH,WAAW,IAAI;IACf;;;;OAIG;IACH,UAAU,IAAI;IACd;;;;OAIG;IACH,aAAa,IAAI;IACjB;;;;OAIG;IACH,cAAc,IAAI;IAClB;;;;OAIG;IACH,YAAY,IAAI;IAChB;;;;OAIG;IACH,YAAY,IAAI;IAChB;;;;OAIG;IACH,aAAa,IAAI;IACjB;;;;OAIG;IACH,cAAc,IAAI;IAClB;;;;OAIG;IACH,cAAc,IAAI;IAClB;;;;OAIG;IACH,cAAc,IAAI;IAClB;;;;OAIG;IACH,cAAc,KAAK;CACpB;AAGD,oBAAY,kCAAkC;IAC5C;;OAEG;IACH,IAAI,IAAI;IACR;;OAEG;IACH,MAAM,IAAI;IACV;;OAEG;IACH,GAAG,IAAI;IACP;;OAEG;IACH,UAAU,IAAI;IACd;;OAEG;IACH,cAAc,IAAI;IAClB;;OAEG;IACH,aAAa,IAAI;CAClB;AAED;;;;GAIG;AACH,oBAAY,8BAA8B;IACxC;;OAEG;IACH,WAAW,eAAe;IAC1B;;OAEG;IACH,UAAU,cAAc;IACxB;;OAEG;IACH,UAAU,cAAc;IACxB;;OAEG;IACH,eAAe,mBAAmB;IAClC;;OAEG;IACH,gBAAgB,mBAAmB;IACnC;;OAE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ACH,iBAAiB,CAAC,EAAE,8BAA8B,CAAC;IACnD;;;;;;;OAOG;IACH,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB;;;;;OAKG;IACH,gCAAgC,CAAC,EAAE,6CAA6C,CAAC;CAClF,CAAC;AAGF,MAAM,MAAM,sBAAsB,GAAG;IACnC;;;OAGG;IACH,UAAU,EAAE,gBAAgB,CAAC;IAE7B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;OAGG;IACH,uBAAuB,EAAE,OAAO,CAAC;IACjC;;OAEG;IACH,MAAM,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,uBAAuB,CAAC,CAAC,SAAS,kBAAkB,GAAG,sBAAsB,IACvF,CAAC,SAAS;IACR,uBAAuB,EAAE,IAAI,CAAC;CAC/B,GACG,iBAAiB,GACjB,iBAAiB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"ImagePicker.types.js","sourceRoot":"","sources":["../src/ImagePicker.types.ts"],"names":[],"mappings":"AAmBA,cAAc;AACd,MAAM,CAAN,IAAY,gBAaX;AAbD,WAAY,gBAAgB;IAC1B;;OAEG;IACH,+BAAW,CAAA;IACX;;OAEG;IACH,qCAAiB,CAAA;IACjB;;OAEG;IACH,qCAAiB,CAAA;AACnB,CAAC,EAbW,gBAAgB,KAAhB,gBAAgB,QAa3B;AAED,cAAc;AACd,MAAM,CAAN,IAAY,iBAmEX;AAnED,WAAY,iBAAiB;IAC3B;;;;OAIG;IACH,uEAAe,CAAA;IACf;;;;OAIG;IACH,qEAAc,CAAA;IACd;;;;OAIG;IACH,2EAAiB,CAAA;IACjB;;;;OAIG;IACH,6EAAkB,CAAA;IAClB;;;;OAIG;IACH,yEAAgB,CAAA;IAChB;;;;OAIG;IACH,yEAAgB,CAAA;IAChB;;;;OAIG;IACH,2EAAiB,CAAA;IACjB;;;;OAIG;IACH,6EAAkB,CAAA;IAClB;;;;OAIG;IACH,6EAAkB,CAAA;IAClB;;;;OAIG;IACH,6EAAkB,CAAA;IAClB;;;;OAIG;IACH,8EAAmB,CAAA;AACrB,CAAC,EAnEW,iBAAiB,KAAjB,iBAAiB,QAmE5B;AAED,cAAc;AACd,MAAM,CAAN,IAAY,kCAyBX;AAzBD,WAAY,kCAAkC;IAC5C;;OAEG;IACH,2FAAQ,CAAA;IACR;;OAEG;IACH,+FAAU,CAAA;IACV;;OAEG;IACH,yFAAO,CAAA;IACP;;OAEG;IACH,uGAAc,CAAA;IACd;;OAEG;IACH,+GAAkB,CAAA;IAClB;;OAEG;IACH,6GAAiB,CAAA;AACnB,CAAC,EAzBW,kCAAkC,KAAlC,kCAAkC,QAyB7C;AAED;;;;GAIG;AACH,MAAM,CAAN,IAAY,8BAoCX;AApCD,WAAY,8BAA8B;IACxC;;OAEG;IACH,4DAA0B,CAAA;IAC1B;;OAEG;IACH,0DAAwB,CAAA;IACxB;;OAEG;IACH,0DAAwB,CAAA;IACxB;;OAEG;IACH,oEAAkC,CAAA;IAClC;;OAEG;IACH,qEAAmC,CAAA;IACnC;;OAEG;IACH,6EAA2C,CAAA;IAC3C;;OAEG;IACH,qDAAmB,CAAA;IACnB;;;;;OAKG;IACH,yDAAuB,CAAA;AACzB,CAAC,EApCW,8BAA8B,KAA9B,8BAA8B,QAoCzC;AAED;;;;GAIG;AACH,MAAM,CAAN,IAAY,6CAaX;AAbD,WAAY,6CAA6C;IACvD;;OAEG;IACH,wEAAuB,CAAA;IACvB;;OAEG;IACH,0EAAyB,CAAA;IACzB;;OAEG;IACH,oEAAmB,CAAA;AACrB,CAAC,EAbW,6CAA6C,KAA7C,6CAA6C,QAaxD;AAED,MAAM,CAAN,IAAY,UASX;AATD,WAAY,UAAU;IACpB;;OAEG;IACH,2BAAa,CAAA;IACb;;OAEG;IACH,6BAAe,CAAA;AACjB,CAAC,EATW,UAAU,KAAV,UAAU,QASrB","sourcesContent":["import { PermissionResponse } from 'expo-modules-core';\n\n// @needsAudit\n/**\n * Alias for `PermissionResponse` type exported by `expo-modules-core`.\n */\nexport type CameraPermissionResponse = PermissionResponse;\n\n// @needsAudit\n/**\n * Extends `PermissionResponse` type exported by `expo-modules-core`, containing additional iOS-specific field.\n */\nexport type MediaLibraryPermissionResponse = PermissionResponse & {\n /**\n * @platform ios\n */\n accessPrivileges?: 'all' | 'limited' | 'none';\n};\n\n// @needsAudit\nexport enum MediaTypeOptions {\n /**\n * Images and videos.\n */\n All = 'All',\n /**\n * Only videos.\n */\n Videos = 'Videos',\n /**\n * Only images.\n */\n Images = 'Images',\n}\n\n// @needsAudit\nexport enum VideoExportPreset {\n /**\n * Resolution: __Unchanged__ •\n * Video compression: __None__ •\n * Audio compression: __None__\n */\n Passthrough = 0,\n /**\n * Resolution: __Depends on the device__ •\n * Video compression: __H.264__ •\n * Audio compression: __AAC__\n */\n LowQuality = 1,\n /**\n * Resolution: __Depends on the device__ •\n * Video compression: __H.264__ •\n * Audio compression: __AAC__\n */\n MediumQuality = 2,\n /**\n * Resolution: __Depends on the device__ •\n * Video compression: __H.264__ •\n * Audio compression: __AAC__\n */\n HighestQuality = 3,\n /**\n * Resolution: __640 × 480__ •\n * Video compression: __H.264__ •\n * Audio compression: __AAC__\n */\n H264_640x480 = 4,\n /**\n * Resolution: __960 × 540__ •\n * Video compression: __H.264__ •\n * Audio compression: __AAC__\n */\n H264_960x540 = 5,\n /**\n * Resolution: __1280 × 720__ •\n * Video compression: __H.264__ •\n * Audio compression: __AAC__\n */\n H264_1280x720 = 6,\n /**\n * Resolution: __1920 × 1080__ •\n * Video compression: __H.264__ •\n * Audio compression: __AAC__\n */\n H264_1920x1080 = 7,\n /**\n * Resolution: __3840 × 2160__ •\n * Video compression: __H.264__ •\n * Audio compression: __AAC__\n */\n H264_3840x2160 = 8,\n /**\n * Resolution: __1920 × 1080__ •\n * Video compression: __HEVC__ •\n * Audio compression: __AAC__\n */\n HEVC_1920x1080 = 9,\n /**\n * Resolution: __3840 × 2160__ •\n * Video compression: __HEVC__ •\n * Audio compression: __AAC__\n */\n HEVC_3840x2160 = 10,\n}\n\n// @needsAudit\nexport enum UIImagePickerControllerQualityType {\n /**\n * Highest available resolution.\n */\n High = 0,\n /**\n * Depends on the device.\n */\n Medium = 1,\n /**\n * Depends on the device.\n */\n Low = 2,\n /**\n * 640 × 480\n */\n VGA640x480 = 3,\n /**\n * 1280 × 720\n */\n IFrame1280x720 = 4,\n /**\n * 960 × 540\n */\n IFrame960x540 = 5,\n}\n\n/**\n * Picker presentation style. Its values are directly mapped to the [`UIModalPresentationStyle`](https://developer.apple.com/documentation/uikit/uiviewcontroller/1621355-modalpresentationstyle).\n *\n * @platform ios\n */\nexport enum UIImagePickerPresentationStyle {\n /**\n * A presentation style in which the presented picker covers the screen.\n */\n FULL_SCREEN = 'fullScreen',\n /**\n * A presentation style that partially covers the underlying content.\n */\n PAGE_SHEET = 'pageSheet',\n /**\n * A presentation style that displays the picker centered in the screen.\n */\n FORM_SHEET = 'formSheet',\n /**\n * A presentation style where the picker is displayed over the app's content.\n */\n CURRENT_CONTEXT = 'currentContext',\n /**\n * A presentation style in which the picker view covers the screen.\n */\n OVER_FULL_SCREEN = 'overFullScreen',\n /**\n * A presentation style where the picker is displayed over the app's content.\n */\n OVER_CURRENT_CONTEXT = 'overCurrentContext',\n /**\n * A presentation style where the picker is displayed in a popover view.\n */\n POPOVER = 'popover',\n /**\n * The default presentation style chosen by the system.\n * On older iOS versions, falls back to `WebBrowserPresentationStyle.FullScreen`.\n *\n * @platform ios 13+\n */\n AUTOMATIC = 'automatic',\n}\n\n/**\n * Picker preferred asset representation mode. Its values are directly mapped to the [`PHPickerConfigurationAssetRepresentationMode`](https://developer.apple.com/documentation/photokit/phpickerconfigurationassetrepresentationmode).\n *\n * @platform ios\n */\nexport enum UIImagePickerPreferredAssetRepresentationMode {\n /**\n * A mode that indicates that the system chooses the appropriate asset representation.\n */\n Automatic = 'automatic',\n /**\n * A mode that uses the most compatible asset representation.\n */\n Compatible = 'compatible',\n /**\n * A mode that uses the current representation to avoid transcoding, if possible.\n */\n Current = 'current',\n}\n\nexport enum CameraType {\n /**\n * Back/rear camera.\n */\n back = 'back',\n /**\n * Front camera\n */\n front = 'front',\n}\n\n/**\n * @hidden\n * @deprecated Use `ImagePickerAsset` instead\n */\nexport type ImageInfo = ImagePickerAsset;\n\n/**\n * Represents an asset (image or video) returned by the image picker or camera.\n */\nexport type ImagePickerAsset = {\n /**\n * URI to the local image or video file (usable as the source of an `Image` element, in the case of\n * an image) and `width` and `height` specify the dimensions of the media.\n */\n uri: string;\n /**\n * The unique ID that represents the picked image or video, if picked from the library. It can be used\n * by [expo-media-library](./media-library) to manage the picked asset.\n *\n * > This might be `null` when the ID is unavailable or the user gave limited permission to access the media library.\n * > On Android, the ID is unavailable when the user selects a photo by directly browsing file system.\n *\n * @platform ios\n * @platform android\n */\n assetId?: string | null;\n /**\n * Width of the image or video.\n */\n width: number;\n /**\n * Height of the image or video.\n */\n height: number;\n /**\n * The type of the asset.\n */\n type?: 'image' | 'video';\n /**\n * Preferred filename to use when saving this item. This might be `null` when the name is unavailable\n * or user gave limited permission to access the media library.\n *\n * @platform ios\n */\n fileName?: string | null;\n /**\n * File size of the picked image or video, in bytes.\n *\n * @platform ios\n */\n fileSize?: number;\n /**\n * The `exif` field is included if the `exif` option is truthy, and is an object containing the\n * image's EXIF data. The names of this object's properties are EXIF tags and the values are the\n * respective EXIF values for those tags.\n */\n exif?: Record<string, any> | null;\n /**\n * When the `base64` option is truthy, it is a Base64-encoded string of the selected image's JPEG data, otherwise `null`.\n * If you prepend this with `'data:image/jpeg;base64,'` to create a data URI,\n * you can use it as the source of an `Image` element; for example:\n * ```ts\n * <Image\n * source={{ uri: 'data:image/jpeg;base64,' + asset.base64 }}\n * style={{ width: 200, height: 200 }}\n * />\n * ```\n */\n base64?: string | null;\n /**\n * Length of the video in milliseconds or `null` if the asset is not a video.\n */\n duration?: number | null;\n};\n\n// @needsAudit\nexport type ImagePickerErrorResult = {\n /**\n * The error code.\n */\n code: string;\n /**\n * The error message.\n */\n message: string;\n /**\n * The exception which caused the error.\n */\n exception?: string;\n};\n\n// @needsAudit\n/**\n * Type representing successful and canceled pick result.\n */\nexport type ImagePickerResult = ImagePickerSuccessResult | ImagePickerCanceledResult;\n\n/**\n * Type representing successful pick result.\n */\nexport type ImagePickerSuccessResult = {\n /**\n * Boolean flag set to `false` showing that the request was successful.\n */\n canceled: false;\n /**\n * An array of picked assets.\n */\n assets: ImagePickerAsset[];\n};\n\n/**\n * Type representing canceled pick result.\n */\nexport type ImagePickerCanceledResult = {\n /**\n * Boolean flag set to `true` showing that the request was canceled.\n */\n canceled: true;\n /**\n * `null` signifying that the request was canceled.\n */\n assets: null;\n};\n\n/**\n * @hidden\n * @deprecated Use `ImagePickerResult` instead.\n */\nexport type ImagePickerCancelledResult = ImagePickerCanceledResult;\n\n/**\n * @hidden\n * @deprecated `ImagePickerMultipleResult` has been deprecated in favor of `ImagePickerResult`.\n */\nexport type ImagePickerMultipleResult = ImagePickerResult;\n\n// @needsAudit\nexport type ImagePickerOptions = {\n /**\n * Whether to show a UI to edit the image after it is picked. On Android the user can crop and\n * rotate the image and on iOS simply crop it.\n *\n * > - Cropping multiple images is not supported - this option is mutually exclusive with `allowsMultipleSelection`.\n * > - On iOS, this option is ignored if `allowsMultipleSelection` is enabled.\n * > - On iOS cropping a `.bmp` image will convert it to `.png`.\n *\n * @default false\n * @platform ios\n * @platform android\n */\n allowsEditing?: boolean;\n /**\n * An array with two entries `[x, y]` specifying the aspect ratio to maintain if the user is\n * allowed to edit the image (by passing `allowsEditing: true`). This is only applicable on\n * Android, since on iOS the crop rectangle is always a square.\n */\n aspect?: [number, number];\n /**\n * Specify the quality of compression, from `0` to `1`. `0` means compress for small size,\n * `1` means compress for maximum quality.\n * > Note: If the selected image has been compressed before, the size of the output file may be\n * > bigger than the size of the original image.\n *\n * > Note: On iOS, if a `.bmp` or `.png` image is selected from the library, this option is ignored.\n *\n * @default 0.2\n * @platform ios\n * @platform android\n */\n quality?: number;\n /**\n * Choose what type of media to pick.\n * @default ImagePicker.MediaTypeOptions.Images\n */\n mediaTypes?: MediaTypeOptions;\n /**\n * Whether to also include the EXIF data for the image. On iOS the EXIF data does not include GPS\n * tags in the camera case.\n */\n exif?: boolean;\n /**\n * Whether to also include the image data in Base64 format.\n */\n base64?: boolean;\n /**\n * Specify preset which will be used to compress selected video.\n * @default ImagePicker.VideoExportPreset.Passthrough\n * @platform ios 11+\n * @deprecated See [`videoExportPreset`](https://developer.apple.com/documentation/uikit/uiimagepickercontroller/2890964-videoexportpreset?language=objc)\n * in Apple documentation.\n */\n videoExportPreset?: VideoExportPreset;\n /**\n * Specify the quality of recorded videos. Defaults to the highest quality available for the device.\n * @default ImagePicker.UIImagePickerControllerQualityType.High\n * @platform ios\n */\n videoQuality?: UIImagePickerControllerQualityType;\n /**\n * Whether or not to allow selecting multiple media files at once.\n *\n * > Cropping multiple images is not supported - this option is mutually exclusive with `allowsEditing`.\n * > If this option is enabled, then `allowsEditing` is ignored.\n *\n * @default false\n * @platform ios 14+\n * @platform android\n * @platform web\n */\n allowsMultipleSelection?: boolean;\n /**\n * The maximum number of items that user can select. Applicable when `allowsMultipleSelection` is enabled.\n * Setting the value to `0` sets the selection limit to the maximum that the system supports.\n *\n * @platform ios 14+\n * @platform android\n * @default 0\n */\n selectionLimit?: number;\n /**\n * Whether to display number badges when assets are selected. The badges are numbered\n * in selection order. Assets are then returned in the exact same order they were selected.\n *\n * > Assets should be returned in the selection order regardless of this option,\n * > but there is no guarantee that it is always true when this option is disabled.\n *\n * @platform ios 15+\n * @default false\n */\n orderedSelection?: boolean;\n /**\n * Maximum duration, in seconds, for video recording. Setting this to `0` disables the limit.\n * Defaults to `0` (no limit).\n * - **On iOS**, when `allowsEditing` is set to `true`, maximum duration is limited to 10 minutes.\n * This limit is applied automatically, if `0` or no value is specified.\n * - **On Android**, effect of this option depends on support of installed camera app.\n * - **On Web** this option has no effect - the limit is browser-dependant.\n */\n videoMaxDuration?: number;\n /**\n * Choose [presentation style](https://developer.apple.com/documentation/uikit/uiviewcontroller/1621355-modalpresentationstyle?language=objc)\n * to customize view during taking photo/video.\n * @default ImagePicker.UIImagePickerPresentationStyle.Automatic\n * @platform ios\n */\n presentationStyle?: UIImagePickerPresentationStyle;\n /**\n * Selects the camera-facing type. The `CameraType` enum provides two options:\n * `front` for the front-facing camera and `back` for the back-facing camera.\n * - **On Android**, the behavior of this option may vary based on the camera app installed on the device.\n * @default CameraType.back\n * @platform ios\n * @platform android\n */\n cameraType?: CameraType;\n /**\n * Choose [preferred asset representation mode](https://developer.apple.com/documentation/photokit/phpickerconfigurationassetrepresentationmode)\n * to use when loading assets.\n * @default ImagePicker.UIImagePickerPreferredAssetRepresentationMode.Automatic\n * @platform ios 14+\n */\n preferredAssetRepresentationMode?: UIImagePickerPreferredAssetRepresentationMode;\n};\n\n// @needsAudit\nexport type OpenFileBrowserOptions = {\n /**\n * Choose what type of media to pick.\n * @default ImagePicker.MediaTypeOptions.Images\n */\n mediaTypes: MediaTypeOptions;\n // @docsMissing\n capture?: boolean;\n /**\n * Whether or not to allow selecting multiple media files at once.\n * @platform web\n */\n allowsMultipleSelection: boolean;\n /**\n * Whether to also include the image data in Base64 format.\n */\n base64: boolean;\n};\n\n/**\n * @hidden\n * @deprecated Use `ImagePickerResult` or `OpenFileBrowserOptions` instead.\n */\nexport type ExpandImagePickerResult<T extends ImagePickerOptions | OpenFileBrowserOptions> =\n T extends {\n allowsMultipleSelection: true;\n }\n ? ImagePickerResult\n : ImagePickerResult;\n"]}
1
+ {"version":3,"file":"ImagePicker.types.js","sourceRoot":"","sources":["../src/ImagePicker.types.ts"],"names":[],"mappings":"AAmBA,cAAc;AACd,MAAM,CAAN,IAAY,gBAaX;AAbD,WAAY,gBAAgB;IAC1B;;OAEG;IACH,+BAAW,CAAA;IACX;;OAEG;IACH,qCAAiB,CAAA;IACjB;;OAEG;IACH,qCAAiB,CAAA;AACnB,CAAC,EAbW,gBAAgB,KAAhB,gBAAgB,QAa3B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WAAY,6CAA6C;IACvD;;OAEG;IACH,wEAAuB,CAAA;IACvB;;OAEG;IACH,0EAAyB,CAAA;IACzB;;OAEG;IACH,oEAAmB,CAAA;AACrB,CAAC,EAbW,6CAA6C,KAA7C,6CAA6C,QAaxD;AAED,MAAM,CAAN,IAAY,UASX;AATD,WAAY,UAAU;IACpB;;OAEG;IACH,2BAAa,CAAA;IACb;;OAEG;IACH,6BAAe,CAAA;AACjB,CAAC,EATW,UAAU,KAAV,UAAU,QASrB","sourcesContent":["import { PermissionResponse } from 'expo-modules-core';\n\n// @needsAudit\n/**\n * Alias for `PermissionResponse` type exported by `expo-modules-core`.\n */\nexport type CameraPermissionResponse = PermissionResponse;\n\n// @needsAudit\n/**\n * Extends `PermissionResponse` type exported by `expo-modules-core`, containing additional iOS-specific field.\n */\nexport type MediaLibraryPermissionResponse = PermissionResponse & {\n /**\n * @platform ios\n */\n accessPrivileges?: 'all' | 'limited' | 'none';\n};\n\n// @needsAudit\nexport enum MediaTypeOptions {\n /**\n * Images and videos.\n */\n All = 'All',\n /**\n * Only videos.\n */\n Videos = 'Videos',\n /**\n * Only images.\n */\n Images = 'Images',\n}\n\n// @needsAudit\nexport enum VideoExportPreset {\n /**\n * Resolution: __Unchanged__ •\n * Video compression: __None__ •\n * Audio compression: __None__\n */\n Passthrough = 0,\n /**\n * Resolution: __Depends on the device__ •\n * Video compression: __H.264__ •\n * Audio compression: __AAC__\n */\n LowQuality = 1,\n /**\n * Resolution: __Depends on the device__ •\n * Video compression: __H.264__ •\n * Audio compression: __AAC__\n */\n MediumQuality = 2,\n /**\n * Resolution: __Depends on the device__ •\n * Video compression: __H.264__ •\n * Audio compression: __AAC__\n */\n HighestQuality = 3,\n /**\n * Resolution: __640 × 480__ •\n * Video compression: __H.264__ •\n * Audio compression: __AAC__\n */\n H264_640x480 = 4,\n /**\n * Resolution: __960 × 540__ •\n * Video compression: __H.264__ •\n * Audio compression: __AAC__\n */\n H264_960x540 = 5,\n /**\n * Resolution: __1280 × 720__ •\n * Video compression: __H.264__ •\n * Audio compression: __AAC__\n */\n H264_1280x720 = 6,\n /**\n * Resolution: __1920 × 1080__ •\n * Video compression: __H.264__ •\n * Audio compression: __AAC__\n */\n H264_1920x1080 = 7,\n /**\n * Resolution: __3840 × 2160__ •\n * Video compression: __H.264__ •\n * Audio compression: __AAC__\n */\n H264_3840x2160 = 8,\n /**\n * Resolution: __1920 × 1080__ •\n * Video compression: __HEVC__ •\n * Audio compression: __AAC__\n */\n HEVC_1920x1080 = 9,\n /**\n * Resolution: __3840 × 2160__ •\n * Video compression: __HEVC__ •\n * Audio compression: __AAC__\n */\n HEVC_3840x2160 = 10,\n}\n\n// @needsAudit\nexport enum UIImagePickerControllerQualityType {\n /**\n * Highest available resolution.\n */\n High = 0,\n /**\n * Depends on the device.\n */\n Medium = 1,\n /**\n * Depends on the device.\n */\n Low = 2,\n /**\n * 640 × 480\n */\n VGA640x480 = 3,\n /**\n * 1280 × 720\n */\n IFrame1280x720 = 4,\n /**\n * 960 × 540\n */\n IFrame960x540 = 5,\n}\n\n/**\n * Picker presentation style. Its values are directly mapped to the [`UIModalPresentationStyle`](https://developer.apple.com/documentation/uikit/uiviewcontroller/1621355-modalpresentationstyle).\n *\n * @platform ios\n */\nexport enum UIImagePickerPresentationStyle {\n /**\n * A presentation style in which the presented picker covers the screen.\n */\n FULL_SCREEN = 'fullScreen',\n /**\n * A presentation style that partially covers the underlying content.\n */\n PAGE_SHEET = 'pageSheet',\n /**\n * A presentation style that displays the picker centered in the screen.\n */\n FORM_SHEET = 'formSheet',\n /**\n * A presentation style where the picker is displayed over the app's content.\n */\n CURRENT_CONTEXT = 'currentContext',\n /**\n * A presentation style in which the picker view covers the screen.\n */\n OVER_FULL_SCREEN = 'overFullScreen',\n /**\n * A presentation style where the picker is displayed over the app's content.\n */\n OVER_CURRENT_CONTEXT = 'overCurrentContext',\n /**\n * A presentation style where the picker is displayed in a popover view.\n */\n POPOVER = 'popover',\n /**\n * The default presentation style chosen by the system.\n * On older iOS versions, falls back to `WebBrowserPresentationStyle.FullScreen`.\n *\n * @platform ios 13+\n */\n AUTOMATIC = 'automatic',\n}\n\n/**\n * Picker preferred asset representation mode. Its values are directly mapped to the [`PHPickerConfigurationAssetRepresentationMode`](https://developer.apple.com/documentation/photokit/phpickerconfigurationassetrepresentationmode).\n *\n * @platform ios\n */\nexport enum UIImagePickerPreferredAssetRepresentationMode {\n /**\n * A mode that indicates that the system chooses the appropriate asset representation.\n */\n Automatic = 'automatic',\n /**\n * A mode that uses the most compatible asset representation.\n */\n Compatible = 'compatible',\n /**\n * A mode that uses the current representation to avoid transcoding, if possible.\n */\n Current = 'current',\n}\n\nexport enum CameraType {\n /**\n * Back/rear camera.\n */\n back = 'back',\n /**\n * Front camera\n */\n front = 'front',\n}\n\n/**\n * @hidden\n * @deprecated Use `ImagePickerAsset` instead\n */\nexport type ImageInfo = ImagePickerAsset;\n\n/**\n * Represents an asset (image or video) returned by the image picker or camera.\n */\nexport type ImagePickerAsset = {\n /**\n * URI to the local image or video file (usable as the source of an `Image` element, in the case of\n * an image) and `width` and `height` specify the dimensions of the media.\n */\n uri: string;\n /**\n * The unique ID that represents the picked image or video, if picked from the library. It can be used\n * by [expo-media-library](./media-library) to manage the picked asset.\n *\n * > This might be `null` when the ID is unavailable or the user gave limited permission to access the media library.\n * > On Android, the ID is unavailable when the user selects a photo by directly browsing file system.\n *\n * @platform ios\n * @platform android\n */\n assetId?: string | null;\n /**\n * Width of the image or video.\n */\n width: number;\n /**\n * Height of the image or video.\n */\n height: number;\n /**\n * The type of the asset.\n */\n type?: 'image' | 'video';\n /**\n * Preferred filename to use when saving this item. This might be `null` when the name is unavailable\n * or user gave limited permission to access the media library.\n *\n */\n fileName?: string | null;\n /**\n * File size of the picked image or video, in bytes.\n *\n */\n fileSize?: number;\n /**\n * The `exif` field is included if the `exif` option is truthy, and is an object containing the\n * image's EXIF data. The names of this object's properties are EXIF tags and the values are the\n * respective EXIF values for those tags.\n */\n exif?: Record<string, any> | null;\n /**\n * When the `base64` option is truthy, it is a Base64-encoded string of the selected image's JPEG data, otherwise `null`.\n * If you prepend this with `'data:image/jpeg;base64,'` to create a data URI,\n * you can use it as the source of an `Image` element; for example:\n * ```ts\n * <Image\n * source={{ uri: 'data:image/jpeg;base64,' + asset.base64 }}\n * style={{ width: 200, height: 200 }}\n * />\n * ```\n */\n base64?: string | null;\n /**\n * Length of the video in milliseconds or `null` if the asset is not a video.\n */\n duration?: number | null;\n /**\n * The MIME type of the selected asset or `null` if could not be determined.\n */\n mimeType?: string;\n};\n\n// @needsAudit\nexport type ImagePickerErrorResult = {\n /**\n * The error code.\n */\n code: string;\n /**\n * The error message.\n */\n message: string;\n /**\n * The exception which caused the error.\n */\n exception?: string;\n};\n\n// @needsAudit\n/**\n * Type representing successful and canceled pick result.\n */\nexport type ImagePickerResult = ImagePickerSuccessResult | ImagePickerCanceledResult;\n\n/**\n * Type representing successful pick result.\n */\nexport type ImagePickerSuccessResult = {\n /**\n * Boolean flag set to `false` showing that the request was successful.\n */\n canceled: false;\n /**\n * An array of picked assets.\n */\n assets: ImagePickerAsset[];\n};\n\n/**\n * Type representing canceled pick result.\n */\nexport type ImagePickerCanceledResult = {\n /**\n * Boolean flag set to `true` showing that the request was canceled.\n */\n canceled: true;\n /**\n * `null` signifying that the request was canceled.\n */\n assets: null;\n};\n\n/**\n * @hidden\n * @deprecated Use `ImagePickerResult` instead.\n */\nexport type ImagePickerCancelledResult = ImagePickerCanceledResult;\n\n/**\n * @hidden\n * @deprecated `ImagePickerMultipleResult` has been deprecated in favor of `ImagePickerResult`.\n */\nexport type ImagePickerMultipleResult = ImagePickerResult;\n\n// @needsAudit\nexport type ImagePickerOptions = {\n /**\n * Whether to show a UI to edit the image after it is picked. On Android the user can crop and\n * rotate the image and on iOS simply crop it.\n *\n * > - Cropping multiple images is not supported - this option is mutually exclusive with `allowsMultipleSelection`.\n * > - On iOS, this option is ignored if `allowsMultipleSelection` is enabled.\n * > - On iOS cropping a `.bmp` image will convert it to `.png`.\n *\n * @default false\n * @platform ios\n * @platform android\n */\n allowsEditing?: boolean;\n /**\n * An array with two entries `[x, y]` specifying the aspect ratio to maintain if the user is\n * allowed to edit the image (by passing `allowsEditing: true`). This is only applicable on\n * Android, since on iOS the crop rectangle is always a square.\n */\n aspect?: [number, number];\n /**\n * Specify the quality of compression, from `0` to `1`. `0` means compress for small size,\n * `1` means compress for maximum quality.\n * > Note: If the selected image has been compressed before, the size of the output file may be\n * > bigger than the size of the original image.\n *\n * > Note: On iOS, if a `.bmp` or `.png` image is selected from the library, this option is ignored.\n *\n * @default 0.2\n * @platform ios\n * @platform android\n */\n quality?: number;\n /**\n * Choose what type of media to pick.\n * @default ImagePicker.MediaTypeOptions.Images\n */\n mediaTypes?: MediaTypeOptions;\n /**\n * Whether to also include the EXIF data for the image. On iOS the EXIF data does not include GPS\n * tags in the camera case.\n */\n exif?: boolean;\n /**\n * Whether to also include the image data in Base64 format.\n */\n base64?: boolean;\n /**\n * Specify preset which will be used to compress selected video.\n * @default ImagePicker.VideoExportPreset.Passthrough\n * @platform ios 11+\n * @deprecated See [`videoExportPreset`](https://developer.apple.com/documentation/uikit/uiimagepickercontroller/2890964-videoexportpreset?language=objc)\n * in Apple documentation.\n */\n videoExportPreset?: VideoExportPreset;\n /**\n * Specify the quality of recorded videos. Defaults to the highest quality available for the device.\n * @default ImagePicker.UIImagePickerControllerQualityType.High\n * @platform ios\n */\n videoQuality?: UIImagePickerControllerQualityType;\n /**\n * Whether or not to allow selecting multiple media files at once.\n *\n * > Cropping multiple images is not supported - this option is mutually exclusive with `allowsEditing`.\n * > If this option is enabled, then `allowsEditing` is ignored.\n *\n * @default false\n * @platform ios 14+\n * @platform android\n * @platform web\n */\n allowsMultipleSelection?: boolean;\n /**\n * The maximum number of items that user can select. Applicable when `allowsMultipleSelection` is enabled.\n * Setting the value to `0` sets the selection limit to the maximum that the system supports.\n *\n * @platform ios 14+\n * @platform android\n * @default 0\n */\n selectionLimit?: number;\n /**\n * Whether to display number badges when assets are selected. The badges are numbered\n * in selection order. Assets are then returned in the exact same order they were selected.\n *\n * > Assets should be returned in the selection order regardless of this option,\n * > but there is no guarantee that it is always true when this option is disabled.\n *\n * @platform ios 15+\n * @default false\n */\n orderedSelection?: boolean;\n /**\n * Maximum duration, in seconds, for video recording. Setting this to `0` disables the limit.\n * Defaults to `0` (no limit).\n * - **On iOS**, when `allowsEditing` is set to `true`, maximum duration is limited to 10 minutes.\n * This limit is applied automatically, if `0` or no value is specified.\n * - **On Android**, effect of this option depends on support of installed camera app.\n * - **On Web** this option has no effect - the limit is browser-dependant.\n */\n videoMaxDuration?: number;\n /**\n * Choose [presentation style](https://developer.apple.com/documentation/uikit/uiviewcontroller/1621355-modalpresentationstyle?language=objc)\n * to customize view during taking photo/video.\n * @default ImagePicker.UIImagePickerPresentationStyle.Automatic\n * @platform ios\n */\n presentationStyle?: UIImagePickerPresentationStyle;\n /**\n * Selects the camera-facing type. The `CameraType` enum provides two options:\n * `front` for the front-facing camera and `back` for the back-facing camera.\n * - **On Android**, the behavior of this option may vary based on the camera app installed on the device.\n * @default CameraType.back\n * @platform ios\n * @platform android\n */\n cameraType?: CameraType;\n /**\n * Choose [preferred asset representation mode](https://developer.apple.com/documentation/photokit/phpickerconfigurationassetrepresentationmode)\n * to use when loading assets.\n * @default ImagePicker.UIImagePickerPreferredAssetRepresentationMode.Automatic\n * @platform ios 14+\n */\n preferredAssetRepresentationMode?: UIImagePickerPreferredAssetRepresentationMode;\n};\n\n// @needsAudit\nexport type OpenFileBrowserOptions = {\n /**\n * Choose what type of media to pick.\n * @default ImagePicker.MediaTypeOptions.Images\n */\n mediaTypes: MediaTypeOptions;\n // @docsMissing\n capture?: boolean;\n /**\n * Whether or not to allow selecting multiple media files at once.\n * @platform web\n */\n allowsMultipleSelection: boolean;\n /**\n * Whether to also include the image data in Base64 format.\n */\n base64: boolean;\n};\n\n/**\n * @hidden\n * @deprecated Use `ImagePickerResult` or `OpenFileBrowserOptions` instead.\n */\nexport type ExpandImagePickerResult<T extends ImagePickerOptions | OpenFileBrowserOptions> =\n T extends {\n allowsMultipleSelection: true;\n }\n ? ImagePickerResult\n : ImagePickerResult;\n"]}
@@ -10,13 +10,13 @@ Pod::Spec.new do |s|
10
10
  s.license = package['license']
11
11
  s.author = package['author']
12
12
  s.homepage = package['homepage']
13
- s.platform = :ios, '13.0'
13
+ s.platform = :ios, '13.4'
14
14
  s.swift_version = '5.4'
15
15
  s.source = { git: 'https://github.com/expo/expo.git' }
16
16
  s.static_framework = true
17
17
 
18
18
  s.dependency 'ExpoModulesCore'
19
-
19
+
20
20
  # Swift/Objective-C compatibility
21
21
  s.pod_target_xcconfig = {
22
22
  'DEFINES_MODULE' => 'YES',
@@ -49,10 +49,10 @@ internal struct ImagePickerOptions: Record {
49
49
 
50
50
  @Field
51
51
  var allowsMultipleSelection: Bool = false
52
-
52
+
53
53
  @Field
54
54
  var selectionLimit: Int = UNLIMITED_SELECTION
55
-
55
+
56
56
  @Field
57
57
  var orderedSelection: Bool = false
58
58
  }
@@ -35,6 +35,7 @@ internal struct AssetInfo: Record {
35
35
  @Field var height: Double = 0
36
36
  @Field var fileName: String? = nil
37
37
  @Field var fileSize: Int? = nil
38
+ @Field var mimeType: String? = nil
38
39
  @Field var base64: String? = nil
39
40
  @Field var exif: ExifInfo? = nil
40
41
  @Field var duration: Double? = nil
@@ -74,6 +74,7 @@ internal struct MediaHandler {
74
74
  options: options)
75
75
 
76
76
  let targetUrl = try generateUrl(withFileExtension: fileExtension)
77
+ let mimeType = getMimeType(from: ".\(targetUrl.pathExtension)")
77
78
 
78
79
  // no modification requested
79
80
  let imageModified = options.allowsEditing || options.quality != nil
@@ -104,6 +105,7 @@ internal struct MediaHandler {
104
105
  height: image.size.height,
105
106
  fileName: fileName,
106
107
  fileSize: fileSize,
108
+ mimeType: mimeType,
107
109
  base64: base64,
108
110
  exif: exif)
109
111
  let response = ImagePickerResponse(assets: [imageInfo], canceled: false)
@@ -134,6 +136,7 @@ internal struct MediaHandler {
134
136
  itemProvider: itemProvider,
135
137
  options: self.options)
136
138
 
139
+ let mimeType = getMimeType(from: fileExtension)
137
140
  let targetUrl = try generateUrl(withFileExtension: fileExtension)
138
141
  try ImageUtils.write(imageData: imageData, to: targetUrl)
139
142
  let fileSize = getFileSize(from: targetUrl)
@@ -153,6 +156,7 @@ internal struct MediaHandler {
153
156
  height: image.size.height,
154
157
  fileName: fileName,
155
158
  fileSize: fileSize,
159
+ mimeType: mimeType,
156
160
  base64: base64,
157
161
  exif: exif)
158
162
  completion(index, .success(imageInfo))
@@ -164,6 +168,22 @@ internal struct MediaHandler {
164
168
  } // loadObject
165
169
  }
166
170
 
171
+ private func getMimeType(from pathExtension: String) -> String? {
172
+ let filenameExtension = String(pathExtension.dropFirst())
173
+ if #available(iOS 14, *) {
174
+ return UTType(filenameExtension: filenameExtension)?.preferredMIMEType
175
+ }
176
+ if let uti = UTTypeCreatePreferredIdentifierForTag(
177
+ kUTTagClassFilenameExtension,
178
+ pathExtension as NSString, nil
179
+ )?.takeRetainedValue() {
180
+ if let mimetype = UTTypeCopyPreferredTagWithClass(uti, kUTTagClassMIMEType)?.takeRetainedValue() {
181
+ return mimetype as String
182
+ }
183
+ }
184
+ return nil
185
+ }
186
+
167
187
  // MARK: - Video
168
188
 
169
189
  // TODO: convert to async/await syntax once we drop support for iOS 12
@@ -188,6 +208,7 @@ internal struct MediaHandler {
188
208
  let duration = VideoUtils.readDurationFrom(url: videoUrlToReadDurationFrom)
189
209
 
190
210
  let asset = mediaInfo[.phAsset] as? PHAsset
211
+ let mimeType = getMimeType(from: ".\(targetUrl.pathExtension)")
191
212
  let fileName = asset?.value(forKey: "filename") as? String
192
213
  let fileSize = getFileSize(from: targetUrl)
193
214
  let videoInfo = AssetInfo(assetId: asset?.localIdentifier,
@@ -197,6 +218,7 @@ internal struct MediaHandler {
197
218
  height: dimensions.height,
198
219
  fileName: fileName,
199
220
  fileSize: fileSize,
221
+ mimeType: mimeType,
200
222
  duration: duration)
201
223
 
202
224
  completion(.success(ImagePickerResponse(assets: [videoInfo], canceled: false)))
@@ -224,6 +246,7 @@ internal struct MediaHandler {
224
246
  let transcodeFileType = AVFileType.mp4
225
247
  let transcodeFileExtension = ".mp4"
226
248
  let originalExtension = ".\(videoUrl.pathExtension)"
249
+ let mimeType = getMimeType(from: originalExtension)
227
250
 
228
251
  // We need to copy the result into a place that we control, because the picker
229
252
  // can remove the original file during conversion.
@@ -241,7 +264,7 @@ internal struct MediaHandler {
241
264
  return completion(index, .failure(exception))
242
265
  case .success(let targetUrl):
243
266
  let fileName = itemProvider.suggestedName.map { $0 + transcodeFileExtension }
244
- let videoResult = buildVideoResult(for: targetUrl, withName: fileName, assetId: selectedVideo.assetIdentifier)
267
+ let videoResult = buildVideoResult(for: targetUrl, withName: fileName, mimeType: mimeType, assetId: selectedVideo.assetIdentifier)
245
268
  return completion(index, videoResult)
246
269
  }
247
270
  }
@@ -283,7 +306,7 @@ internal struct MediaHandler {
283
306
  return url
284
307
  }
285
308
 
286
- private func buildVideoResult(for videoUrl: URL, withName fileName: String?, assetId: String?) -> SelectedMediaResult {
309
+ private func buildVideoResult(for videoUrl: URL, withName fileName: String?, mimeType: String?, assetId: String?) -> SelectedMediaResult {
287
310
  guard let size = VideoUtils.readSizeFrom(url: videoUrl) else {
288
311
  return .failure(FailedToReadVideoSizeException())
289
312
  }
@@ -297,6 +320,7 @@ internal struct MediaHandler {
297
320
  height: size.height,
298
321
  fileName: fileName,
299
322
  fileSize: fileSize,
323
+ mimeType: mimeType,
300
324
  duration: duration)
301
325
  return .success(result)
302
326
  }
@@ -501,7 +525,7 @@ private struct ImageUtils {
501
525
 
502
526
  let options = PHContentEditingInputRequestOptions()
503
527
  options.isNetworkAccessAllowed = true
504
- asset.requestContentEditingInput(with: options) { input, info in
528
+ asset.requestContentEditingInput(with: options) { input, _ in
505
529
  guard let imageUrl = input?.fullSizeImageURL,
506
530
  let properties = CIImage(contentsOf: imageUrl)?.properties
507
531
  else {
@@ -4,8 +4,7 @@ extension UIImagePickerController {
4
4
  func fixCannotMoveEditingBox() {
5
5
  if let cropView = cropView,
6
6
  let scrollView = scrollView,
7
- scrollView.contentOffset.y == 0
8
- {
7
+ scrollView.contentOffset.y == 0 {
9
8
  let top = cropView.frame.minY + self.view.safeAreaInsets.top
10
9
  let bottom = scrollView.frame.height - cropView.frame.height - top
11
10
  scrollView.contentInset = UIEdgeInsets(top: top, left: 0, bottom: bottom, right: 0)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-image-picker",
3
- "version": "14.5.0",
3
+ "version": "14.7.0",
4
4
  "description": "Provides access to the system's UI for selecting images and videos from the phone's library or taking a photo with the camera.",
5
5
  "main": "build/ImagePicker.js",
6
6
  "types": "build/ImagePicker.d.ts",
@@ -36,7 +36,7 @@
36
36
  "preset": "expo-module-scripts"
37
37
  },
38
38
  "dependencies": {
39
- "expo-image-loader": "~4.4.0"
39
+ "expo-image-loader": "~4.6.0"
40
40
  },
41
41
  "devDependencies": {
42
42
  "expo-module-scripts": "^3.0.0"
@@ -44,5 +44,5 @@
44
44
  "peerDependencies": {
45
45
  "expo": "*"
46
46
  },
47
- "gitHead": "79607a7325f47aa17c36d266100d09a4ff2cc544"
47
+ "gitHead": "3142a086578deffd8704a8f1b6f0f661527d836c"
48
48
  }
@@ -123,7 +123,7 @@ function openFileBrowserAsync({
123
123
  });
124
124
  }
125
125
 
126
- function readFile(targetFile: Blob, options: { base64: boolean }): Promise<ImagePickerAsset> {
126
+ function readFile(targetFile: File, options: { base64: boolean }): Promise<ImagePickerAsset> {
127
127
  return new Promise((resolve, reject) => {
128
128
  const reader = new FileReader();
129
129
  reader.onerror = () => {
@@ -136,11 +136,14 @@ function readFile(targetFile: Blob, options: { base64: boolean }): Promise<Image
136
136
  if (typeof uri === 'string') {
137
137
  const image = new Image();
138
138
  image.src = uri;
139
+
139
140
  image.onload = () => {
140
141
  resolve({
141
142
  uri,
142
143
  width: image.naturalWidth ?? image.width,
143
144
  height: image.naturalHeight ?? image.height,
145
+ mimeType: targetFile.type,
146
+ fileName: targetFile.name,
144
147
  // The blob's result cannot be directly decoded as Base64 without
145
148
  // first removing the Data-URL declaration preceding the
146
149
  // Base64-encoded data. To retrieve only the Base64 encoded string,
@@ -247,13 +247,11 @@ export type ImagePickerAsset = {
247
247
  * Preferred filename to use when saving this item. This might be `null` when the name is unavailable
248
248
  * or user gave limited permission to access the media library.
249
249
  *
250
- * @platform ios
251
250
  */
252
251
  fileName?: string | null;
253
252
  /**
254
253
  * File size of the picked image or video, in bytes.
255
254
  *
256
- * @platform ios
257
255
  */
258
256
  fileSize?: number;
259
257
  /**
@@ -278,6 +276,10 @@ export type ImagePickerAsset = {
278
276
  * Length of the video in milliseconds or `null` if the asset is not a video.
279
277
  */
280
278
  duration?: number | null;
279
+ /**
280
+ * The MIME type of the selected asset or `null` if could not be determined.
281
+ */
282
+ mimeType?: string;
281
283
  };
282
284
 
283
285
  // @needsAudit