expo-image-picker 14.4.0 → 14.5.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.5.0 — 2023-09-04
14
+
15
+ ### 🎉 New features
16
+
17
+ - Added support for React Native 0.73. ([#24018](https://github.com/expo/expo/pull/24018) by [@kudo](https://github.com/kudo))
18
+
19
+ ### 🐛 Bug fixes
20
+
21
+ - On Android, the `Uri` type is not serializable and causes a crash when recreating the activity. ([#23768](https://github.com/expo/expo/pull/23768) by [@alanjhughes](https://github.com/alanjhughes))
22
+
23
+ ### 💡 Others
24
+
25
+ - Remove deprecation warnings on `ImagePickerResult`. ([#24226](https://github.com/expo/expo/pull/24226) by [@alanjhughes](https://github.com/alanjhughes))
26
+
27
+ ## 14.4.1 — 2023-08-02
28
+
29
+ _This version does not introduce any user-facing changes._
30
+
13
31
  ## 14.4.0 — 2023-07-28
14
32
 
15
33
  _This version does not introduce any user-facing changes._
package/README.md CHANGED
@@ -62,7 +62,7 @@ This package automatically adds the `CAMERA`, `READ_EXTERNAL_STORAGE`, and `WRIT
62
62
 
63
63
  > This plugin is applied automatically in EAS Build, only add the config plugin if you want to pass in extra properties.
64
64
 
65
- After installing this npm package, add the [config plugin](https://docs.expo.dev/home/config-plugins/introduction) to the [`plugins`](https://docs.expo.io/versions/latest/config/app/#plugins) array of your `app.json` or `app.config.js`:
65
+ After installing this npm package, add the [config plugin](https://docs.expo.dev/config-plugins/introduction) to the [`plugins`](https://docs.expo.io/versions/latest/config/app/#plugins) array of your `app.json` or `app.config.js`:
66
66
 
67
67
  ```json
68
68
  {
@@ -3,7 +3,7 @@ apply plugin: 'kotlin-android'
3
3
  apply plugin: 'maven-publish'
4
4
 
5
5
  group = 'host.exp.exponent'
6
- version = '14.4.0'
6
+ version = '14.5.0'
7
7
 
8
8
  buildscript {
9
9
  def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
@@ -53,13 +53,16 @@ afterEvaluate {
53
53
  android {
54
54
  compileSdkVersion safeExtGet("compileSdkVersion", 33)
55
55
 
56
- compileOptions {
57
- sourceCompatibility JavaVersion.VERSION_11
58
- targetCompatibility JavaVersion.VERSION_11
59
- }
56
+ def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION
57
+ if (agpVersion.tokenize('.')[0].toInteger() < 8) {
58
+ compileOptions {
59
+ sourceCompatibility JavaVersion.VERSION_11
60
+ targetCompatibility JavaVersion.VERSION_11
61
+ }
60
62
 
61
- kotlinOptions {
62
- jvmTarget = JavaVersion.VERSION_11.majorVersion
63
+ kotlinOptions {
64
+ jvmTarget = JavaVersion.VERSION_11.majorVersion
65
+ }
63
66
  }
64
67
 
65
68
  namespace "expo.modules.imagepicker"
@@ -67,7 +70,7 @@ android {
67
70
  minSdkVersion safeExtGet("minSdkVersion", 21)
68
71
  targetSdkVersion safeExtGet("targetSdkVersion", 33)
69
72
  versionCode 22
70
- versionName "14.4.0"
73
+ versionName "14.5.0"
71
74
  }
72
75
  lintOptions {
73
76
  abortOnError false
@@ -63,7 +63,7 @@ class ImagePickerModule : Module() {
63
63
 
64
64
  val mediaFile = createOutputFile(cacheDirectory, options.mediaTypes.toFileExtension())
65
65
  val uri = mediaFile.toContentUri(context)
66
- val contractOptions = options.toCameraContractOptions(uri)
66
+ val contractOptions = options.toCameraContractOptions(uri.toString())
67
67
 
68
68
  launchContract({ cameraLauncher.launch(contractOptions) }, options)
69
69
  }
@@ -138,7 +138,7 @@ class ImagePickerModule : Module() {
138
138
  result.data[0].first == MediaType.IMAGE
139
139
  ) {
140
140
  result = launchPicker {
141
- cropImageLauncher.launch(CropImageContractOptions(result.data[0].second, options))
141
+ cropImageLauncher.launch(CropImageContractOptions(result.data[0].second.toString(), options))
142
142
  }
143
143
  }
144
144
  mediaHandler.readExtras(result.data, options)
@@ -1,7 +1,6 @@
1
1
  package expo.modules.imagepicker
2
2
 
3
3
  import java.io.Serializable
4
- import android.net.Uri
5
4
  import android.provider.MediaStore
6
5
  import androidx.annotation.FloatRange
7
6
  import androidx.annotation.IntRange
@@ -46,7 +45,7 @@ internal class ImagePickerOptions : Record, Serializable {
46
45
  @Field
47
46
  var cameraType: CameraType = CameraType.BACK
48
47
 
49
- fun toCameraContractOptions(uri: Uri) = CameraContractOptions(uri, this)
48
+ fun toCameraContractOptions(uri: String) = CameraContractOptions(uri, this)
50
49
 
51
50
  fun toImageLibraryContractOptions() = ImageLibraryContractOptions(this)
52
51
  }
@@ -7,6 +7,7 @@ import android.content.Intent
7
7
  import android.net.Uri
8
8
  import android.provider.MediaStore
9
9
  import androidx.activity.result.contract.ActivityResultContract
10
+ import androidx.core.net.toUri
10
11
  import expo.modules.imagepicker.ImagePickerOptions
11
12
  import expo.modules.imagepicker.CameraType
12
13
  import expo.modules.imagepicker.toMediaType
@@ -30,7 +31,7 @@ internal class CameraContract(
30
31
 
31
32
  override fun createIntent(context: Context, input: CameraContractOptions): Intent =
32
33
  Intent(input.options.mediaTypes.toCameraIntentAction())
33
- .putExtra(MediaStore.EXTRA_OUTPUT, input.uri)
34
+ .putExtra(MediaStore.EXTRA_OUTPUT, input.uri.toUri())
34
35
  .apply {
35
36
  if (input.options.mediaTypes.toCameraIntentAction() == MediaStore.ACTION_VIDEO_CAPTURE) {
36
37
  putExtra(MediaStore.EXTRA_DURATION_LIMIT, input.options.videoMaxDuration)
@@ -48,9 +49,9 @@ internal class CameraContract(
48
49
 
49
50
  override fun parseResult(input: CameraContractOptions, resultCode: Int, intent: Intent?): ImagePickerContractResult =
50
51
  if (resultCode == Activity.RESULT_CANCELED) {
51
- ImagePickerContractResult.Cancelled()
52
+ ImagePickerContractResult.Cancelled
52
53
  } else {
53
- val uri = input.uri
54
+ val uri = Uri.parse(input.uri)
54
55
  val type = uri.toMediaType(contentResolver)
55
56
  ImagePickerContractResult.Success(listOf(type to uri))
56
57
  }
@@ -60,6 +61,6 @@ internal data class CameraContractOptions(
60
61
  /**
61
62
  * Destination file in a form of content-[Uri] to save results coming from camera to.
62
63
  */
63
- val uri: Uri,
64
+ val uri: String,
64
65
  val options: ImagePickerOptions,
65
66
  ) : Serializable
@@ -8,6 +8,6 @@ import expo.modules.imagepicker.MediaType
8
8
  */
9
9
  internal sealed class ImagePickerContractResult private constructor() {
10
10
  class Success(val data: List<Pair<MediaType, Uri>>) : ImagePickerContractResult()
11
- class Cancelled : ImagePickerContractResult()
12
- class Error : ImagePickerContractResult()
11
+ object Cancelled : ImagePickerContractResult()
12
+ object Error : ImagePickerContractResult()
13
13
  }
@@ -3,7 +3,6 @@ package expo.modules.imagepicker.contracts
3
3
  import android.app.Activity
4
4
  import android.content.Context
5
5
  import android.content.Intent
6
- import android.net.Uri
7
6
  import android.os.Build
8
7
  import androidx.core.net.toFile
9
8
  import androidx.core.net.toUri
@@ -26,7 +25,7 @@ internal class CropImageContract(
26
25
  private val appContextProvider: AppContextProvider,
27
26
  ) : AppContextActivityResultContract<CropImageContractOptions, ImagePickerContractResult> {
28
27
  override fun createIntent(context: Context, input: CropImageContractOptions) = Intent(context, CropImageActivity::class.java).apply {
29
- val mediaType = expo.modules.imagepicker.getType(context.contentResolver, input.sourceUri)
28
+ val mediaType = expo.modules.imagepicker.getType(context.contentResolver, input.sourceUri.toUri())
30
29
  val compressFormat = mediaType.toBitmapCompressFormat()
31
30
  val cacheDirectory = appContextProvider.appContext.cacheDirectory
32
31
  val outputUri = createOutputFile(cacheDirectory, compressFormat.toImageFileExtension()).toUri()
@@ -34,7 +33,7 @@ internal class CropImageContract(
34
33
  putExtra(
35
34
  CropImage.CROP_IMAGE_EXTRA_BUNDLE,
36
35
  bundleOf(
37
- CropImage.CROP_IMAGE_EXTRA_SOURCE to input.sourceUri,
36
+ CropImage.CROP_IMAGE_EXTRA_SOURCE to input.sourceUri.toUri(),
38
37
  CropImage.CROP_IMAGE_EXTRA_OPTIONS to CropImageOptions().apply {
39
38
  outputCompressFormat = compressFormat
40
39
  outputCompressQuality = (input.options.quality * 100).toInt()
@@ -47,8 +46,6 @@ internal class CropImageContract(
47
46
  fixAspectRatio = true
48
47
  initialCropWindowPaddingRatio = 0f
49
48
  }
50
-
51
- validate()
52
49
  }
53
50
  )
54
51
  )
@@ -61,16 +58,16 @@ internal class CropImageContract(
61
58
  intent?.getParcelableExtra(CropImage.CROP_IMAGE_EXTRA_RESULT)
62
59
  }
63
60
  if (resultCode == Activity.RESULT_CANCELED || result == null) {
64
- return ImagePickerContractResult.Cancelled()
61
+ return ImagePickerContractResult.Cancelled
65
62
  }
66
63
  val targetUri = requireNotNull(result.uriContent)
67
64
  val contentResolver = requireNotNull(appContextProvider.appContext.reactContext) { "React Application Context is null" }.contentResolver
68
- runBlocking { copyExifData(input.sourceUri, targetUri.toFile(), contentResolver) }
65
+ runBlocking { copyExifData(input.sourceUri.toUri(), targetUri.toFile(), contentResolver) }
69
66
  return ImagePickerContractResult.Success(listOf(MediaType.IMAGE to targetUri))
70
67
  }
71
68
  }
72
69
 
73
70
  internal data class CropImageContractOptions(
74
- val sourceUri: Uri,
71
+ val sourceUri: String,
75
72
  val options: ImagePickerOptions,
76
73
  ) : Serializable
@@ -75,7 +75,7 @@ internal class ImageLibraryContract(
75
75
 
76
76
  override fun parseResult(input: ImageLibraryContractOptions, resultCode: Int, intent: Intent?) =
77
77
  if (resultCode == Activity.RESULT_CANCELED) {
78
- ImagePickerContractResult.Cancelled()
78
+ ImagePickerContractResult.Cancelled
79
79
  } else {
80
80
  intent?.takeIf { resultCode == Activity.RESULT_OK }?.getAllDataUris()?.let { uris ->
81
81
  if (input.options.allowsMultipleSelection) {
@@ -94,10 +94,10 @@ internal class ImageLibraryContract(
94
94
  uris.firstOrNull()?.let { uri ->
95
95
  val type = uri.toMediaType(contentResolver)
96
96
  ImagePickerContractResult.Success(listOf(type to uri))
97
- } ?: ImagePickerContractResult.Error()
97
+ } ?: ImagePickerContractResult.Error
98
98
  }
99
99
  }
100
- } ?: ImagePickerContractResult.Error()
100
+ } ?: ImagePickerContractResult.Error
101
101
  }
102
102
  }
103
103
 
@@ -1 +1 @@
1
- {"version":3,"file":"ImagePicker.d.ts","sourceRoot":"","sources":["../src/ImagePicker.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,qBAAqB,EACrB,kBAAkB,EAInB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EACL,wBAAwB,EACxB,8BAA8B,EAC9B,iBAAiB,EACjB,sBAAsB,EACtB,kBAAkB,EACnB,MAAM,qBAAqB,CAAC;AAsE7B;;;GAGG;AACH,wBAAsB,yBAAyB,IAAI,OAAO,CAAC,wBAAwB,CAAC,CAEnF;AAGD;;;;GAIG;AACH,wBAAsB,+BAA+B,CACnD,SAAS,GAAE,OAAe,GACzB,OAAO,CAAC,8BAA8B,CAAC,CAEzC;AAGD;;;;GAIG;AACH,wBAAsB,6BAA6B,IAAI,OAAO,CAAC,wBAAwB,CAAC,CAEvF;AAGD;;;;GAIG;AACH,wBAAsB,mCAAmC,CACvD,SAAS,GAAE,OAAe,GACzB,OAAO,CAAC,8BAA8B,CAAC,CAGzC;AAGD;;;;;;;;GAQG;AACH,eAAO,MAAM,0BAA0B;;wJAOrC,CAAC;AAGH;;;;;;;;GAQG;AACH,eAAO,MAAM,oBAAoB,4JAG/B,CAAC;AAGH;;;;;;;;;;GAUG;AACH,wBAAsB,qBAAqB,IAAI,OAAO,CACpD,CAAC,iBAAiB,GAAG,sBAAsB,CAAC,EAAE,CAC/C,CAKA;AAGD;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,iBAAiB,CACrC,OAAO,GAAE,kBAAuB,GAC/B,OAAO,CAAC,iBAAiB,CAAC,CAM5B;AAGD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,uBAAuB,CAC3C,OAAO,CAAC,EAAE,kBAAkB,GAC3B,OAAO,CAAC,iBAAiB,C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AiB,CAAC,CAY5B;AAED,cAAc,qBAAqB,CAAC;AAEpC,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,CAAC"}
@@ -16,37 +16,6 @@ function validateOptions(options) {
16
16
  }
17
17
  return options;
18
18
  }
19
- const DEPRECATED_RESULT_KEYS = [
20
- 'uri',
21
- 'assetId',
22
- 'width',
23
- 'height',
24
- 'type',
25
- 'exif',
26
- 'base64',
27
- 'duration',
28
- 'fileName',
29
- 'fileSize',
30
- ];
31
- function mergeDeprecatedResult(result) {
32
- const firstAsset = result?.assets?.[0];
33
- const deprecatedResult = {
34
- ...result,
35
- get cancelled() {
36
- console.warn('Key "cancelled" in the image picker result is deprecated and will be removed in SDK 48, use "canceled" instead');
37
- return this.canceled;
38
- },
39
- };
40
- for (const key of DEPRECATED_RESULT_KEYS) {
41
- Object.defineProperty(deprecatedResult, key, {
42
- get() {
43
- console.warn(`Key "${key}" in the image picker result is deprecated and will be removed in SDK 48, you can access selected assets through the "assets" array instead`);
44
- return firstAsset?.[key];
45
- },
46
- });
47
- }
48
- return deprecatedResult;
49
- }
50
19
  // @needsAudit
51
20
  /**
52
21
  * Checks user's permissions for accessing camera.
@@ -150,8 +119,7 @@ export async function launchCameraAsync(options = {}) {
150
119
  if (!ExponentImagePicker.launchCameraAsync) {
151
120
  throw new UnavailabilityError('ImagePicker', 'launchCameraAsync');
152
121
  }
153
- const result = await ExponentImagePicker.launchCameraAsync(validateOptions(options));
154
- return mergeDeprecatedResult(result);
122
+ return await ExponentImagePicker.launchCameraAsync(validateOptions(options));
155
123
  }
156
124
  // @needsAudit
157
125
  /**
@@ -183,8 +151,7 @@ export async function launchImageLibraryAsync(options) {
183
151
  "Disable either 'allowsEditing' or 'allowsMultipleSelection' in 'launchImageLibraryAsync' " +
184
152
  'to fix this warning.');
185
153
  }
186
- const result = await ExponentImagePicker.launchImageLibraryAsync(options ?? {});
187
- return mergeDeprecatedResult(result);
154
+ return await ExponentImagePicker.launchImageLibraryAsync(options ?? {});
188
155
  }
189
156
  export * from './ImagePicker.types';
190
157
  export { PermissionStatus };
@@ -1 +1 @@
1
- {"version":3,"file":"ImagePicker.js","sourceRoot":"","sources":["../src/ImagePicker.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAIhB,oBAAoB,EACpB,mBAAmB,EACnB,UAAU,GACX,MAAM,mBAAmB,CAAC;AAE3B,OAAO,mBAAmB,MAAM,uBAAuB,CAAC;AASxD,SAAS,eAAe,CAAC,OAA2B;IAClD,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,EAAE,GAAG,OAAO,CAAC;IAEtD,IAAI,MAAM,IAAI,IAAI,EAAE;QAClB,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,MAAM,CAAC;QAEtB,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;YACpB,MAAM,IAAI,UAAU,CAClB,sBAAsB,EACtB,+BAA+B,CAAC,IAAI,CAAC,6BAA6B,CACnE,CAAC;SACH;KACF;IAED,IAAI,OAAO,IAAI,CAAC,OAAO,GAAG,CAAC,IAAI,OAAO,GAAG,CAAC,CAAC,EAAE;QAC3C,MAAM,IAAI,UAAU,CAClB,sBAAsB,EACtB,2BAA2B,OAAO,oCAAoC,CACvE,CAAC;KACH;IAED,IAAI,gBAAgB,IAAI,gBAAgB,GAAG,CAAC,EAAE;QAC5C,MAAM,IAAI,UAAU,CAClB,sBAAsB,EACtB,oCAAoC,gBAAgB,kCAAkC,CACvF,CAAC;KACH;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,MAAM,sBAAsB,GAAG;IAC7B,KAAK;IACL,SAAS;IACT,OAAO;IACP,QAAQ;IACR,MAAM;IACN,MAAM;IACN,QAAQ;IACR,UAAU;IACV,UAAU;IACV,UAAU;CACX,CAAC;AACF,SAAS,qBAAqB,CAAC,MAAyB;IACtD,MAAM,UAAU,GAAG,MAAM,EAAE,M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;KACH;IACD,MAAM,MAAM,GAAG,MAAM,mBAAmB,CAAC,uBAAuB,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC;IAChF,OAAO,qBAAqB,CAAC,MAAM,CAAC,CAAC;AACvC,CAAC;AAED,cAAc,qBAAqB,CAAC;AAEpC,OAAO,EAAE,gBAAgB,EAAmE,CAAC","sourcesContent":["import {\n PermissionStatus,\n PermissionExpiration,\n PermissionHookOptions,\n PermissionResponse,\n createPermissionHook,\n UnavailabilityError,\n CodedError,\n} from 'expo-modules-core';\n\nimport ExponentImagePicker from './ExponentImagePicker';\nimport {\n CameraPermissionResponse,\n MediaLibraryPermissionResponse,\n ImagePickerResult,\n ImagePickerErrorResult,\n ImagePickerOptions,\n} from './ImagePicker.types';\n\nfunction validateOptions(options: ImagePickerOptions) {\n const { aspect, quality, videoMaxDuration } = options;\n\n if (aspect != null) {\n const [x, y] = aspect;\n\n if (x <= 0 || y <= 0) {\n throw new CodedError(\n 'ERR_INVALID_ARGUMENT',\n `Invalid aspect ratio values ${x}:${y}. Provide positive numbers.`\n );\n }\n }\n\n if (quality && (quality < 0 || quality > 1)) {\n throw new CodedError(\n 'ERR_INVALID_ARGUMENT',\n `Invalid 'quality' value ${quality}. Provide a value between 0 and 1.`\n );\n }\n\n if (videoMaxDuration && videoMaxDuration < 0) {\n throw new CodedError(\n 'ERR_INVALID_ARGUMENT',\n `Invalid 'videoMaxDuration' value ${videoMaxDuration}. Provide a non-negative number.`\n );\n }\n\n return options;\n}\n\nconst DEPRECATED_RESULT_KEYS = [\n 'uri',\n 'assetId',\n 'width',\n 'height',\n 'type',\n 'exif',\n 'base64',\n 'duration',\n 'fileName',\n 'fileSize',\n];\nfunction mergeDeprecatedResult(result: ImagePickerResult): ImagePickerResult {\n const firstAsset = result?.assets?.[0];\n const deprecatedResult = {\n ...result,\n get cancelled() {\n console.warn(\n 'Key \"cancelled\" in the image picker result is deprecated and will be removed in SDK 48, use \"canceled\" instead'\n );\n return this.canceled;\n },\n };\n for (const key of DEPRECATED_RESULT_KEYS) {\n Object.defineProperty(deprecatedResult, key, {\n get() {\n console.warn(\n `Key \"${key}\" in the image picker result is deprecated and will be removed in SDK 48, you can access selected assets through the \"assets\" array instead`\n );\n return firstAsset?.[key];\n },\n });\n }\n return deprecatedResult;\n}\n\n// @needsAudit\n/**\n * Checks user's permissions for accessing camera.\n * @return A promise that fulfills with an object of type [CameraPermissionResponse](#camerapermissionresponse).\n */\nexport async function getCameraPermissionsAsync(): Promise<CameraPermissionResponse> {\n return ExponentImagePicker.getCameraPermissionsAsync();\n}\n\n// @needsAudit\n/**\n * Checks user's permissions for accessing photos.\n * @param writeOnly Whether to request write or read and write permissions. Defaults to `false`\n * @return A promise that fulfills with an object of type [MediaLibraryPermissionResponse](#medialibrarypermissionresponse).\n */\nexport async function getMediaLibraryPermissionsAsync(\n writeOnly: boolean = false\n): Promise<MediaLibraryPermissionResponse> {\n return ExponentImagePicker.getMediaLibraryPermissionsAsync(writeOnly);\n}\n\n// @needsAudit\n/**\n * Asks the user to grant permissions for accessing camera. This does nothing on web because the\n * browser camera is not used.\n * @return A promise that fulfills with an object of type [CameraPermissionResponse](#camerarollpermissionresponse).\n */\nexport async function requestCameraPermissionsAsync(): Promise<CameraPermissionResponse> {\n return ExponentImagePicker.requestCameraPermissionsAsync();\n}\n\n// @needsAudit\n/**\n * Asks the user to grant permissions for accessing user's photo. This method does nothing on web.\n * @param writeOnly Whether to request write or read and write permissions. Defaults to `false`\n * @return A promise that fulfills with an object of type [MediaLibraryPermissionResponse](#medialibrarypermissionresponse).\n */\nexport async function requestMediaLibraryPermissionsAsync(\n writeOnly: boolean = false\n): Promise<MediaLibraryPermissionResponse> {\n const imagePickerMethod = ExponentImagePicker.requestMediaLibraryPermissionsAsync;\n return imagePickerMethod(writeOnly);\n}\n\n// @needsAudit\n/**\n * Check or request permissions to access the media library.\n * This uses both `requestMediaLibraryPermissionsAsync` and `getMediaLibraryPermissionsAsync` to interact with the permissions.\n *\n * @example\n * ```ts\n * const [status, requestPermission] = ImagePicker.useMediaLibraryPermissions();\n * ```\n */\nexport const useMediaLibraryPermissions = createPermissionHook<\n MediaLibraryPermissionResponse,\n { writeOnly?: boolean }\n>({\n // TODO(cedric): permission requesters should have an options param or a different requester\n getMethod: (options) => getMediaLibraryPermissionsAsync(options?.writeOnly),\n requestMethod: (options) => requestMediaLibraryPermissionsAsync(options?.writeOnly),\n});\n\n// @needsAudit\n/**\n * Check or request permissions to access the camera.\n * This uses both `requestCameraPermissionsAsync` and `getCameraPermissionsAsync` to interact with the permissions.\n *\n * @example\n * ```ts\n * const [status, requestPermission] = ImagePicker.useCameraPermissions();\n * ```\n */\nexport const useCameraPermissions = createPermissionHook({\n getMethod: getCameraPermissionsAsync,\n requestMethod: requestCameraPermissionsAsync,\n});\n\n// @needsAudit\n/**\n * Android system sometimes kills the `MainActivity` after the `ImagePicker` finishes. When this\n * happens, we lost the data selected from the `ImagePicker`. However, you can retrieve the lost\n * data by calling `getPendingResultAsync`. You can test this functionality by turning on\n * `Don't keep activities` in the developer options.\n * @return\n * - **On Android:** a promise that resolves to an array of objects of exactly same type as in\n * `ImagePicker.launchImageLibraryAsync` or `ImagePicker.launchCameraAsync` if the `ImagePicker`\n * finished successfully. Otherwise, to the array of [`ImagePickerErrorResult`](#imagepickerimagepickererrorresult).\n * - **On other platforms:** an empty array.\n */\nexport async function getPendingResultAsync(): Promise<\n (ImagePickerResult | ImagePickerErrorResult)[]\n> {\n if (ExponentImagePicker.getPendingResultAsync) {\n return ExponentImagePicker.getPendingResultAsync();\n }\n return [];\n}\n\n// @needsAudit\n/**\n * Display the system UI for taking a photo with the camera. Requires `Permissions.CAMERA`.\n * On Android and iOS 10 `Permissions.CAMERA_ROLL` is also required. On mobile web, this must be\n * called immediately in a user interaction like a button press, otherwise the browser will block\n * the request without a warning.\n * > **Note:** Make sure that you handle `MainActivity` destruction on **Android**. See [ImagePicker.getPendingResultAsync](#imagepickergetpendingresultasync).\n * > **Notes for Web:** The system UI can only be shown after user activation (e.g. a `Button` press).\n * Therefore, calling `launchCameraAsync` in `componentDidMount`, for example, will **not** work as\n * intended. The `cancelled` event will not be returned in the browser due to platform restrictions\n * and inconsistencies across browsers.\n * @param options An `ImagePickerOptions` object.\n * @return A promise that resolves to an object with `canceled` and `assets` fields.\n * When the user canceled the action the `assets` is always `null`, otherwise it's an array of\n * the selected media assets which have a form of [`ImagePickerAsset`](#imagepickerasset).\n */\nexport async function launchCameraAsync(\n options: ImagePickerOptions = {}\n): Promise<ImagePickerResult> {\n if (!ExponentImagePicker.launchCameraAsync) {\n throw new UnavailabilityError('ImagePicker', 'launchCameraAsync');\n }\n const result = await ExponentImagePicker.launchCameraAsync(validateOptions(options));\n return mergeDeprecatedResult(result);\n}\n\n// @needsAudit\n/**\n * Display the system UI for choosing an image or a video from the phone's library.\n * Requires `Permissions.MEDIA_LIBRARY` on iOS 10 only. On mobile web, this must be called\n * immediately in a user interaction like a button press, otherwise the browser will block the\n * request without a warning.\n *\n * **Animated GIFs support:** On Android, if the selected image is an animated GIF, the result image will be an\n * animated GIF too if and only if `quality` is explicitly set to `1.0` and `allowsEditing` is set to `false`.\n * Otherwise compression and/or cropper will pick the first frame of the GIF and return it as the\n * result (on Android the result will be a PNG). On iOS, both quality and cropping are supported.\n *\n * > **Notes for Web:** The system UI can only be shown after user activation (e.g. a `Button` press).\n * Therefore, calling `launchImageLibraryAsync` in `componentDidMount`, for example, will **not**\n * work as intended. The `cancelled` event will not be returned in the browser due to platform\n * restrictions and inconsistencies across browsers.\n * @param options An object extended by [`ImagePickerOptions`](#imagepickeroptions).\n * @return A promise that resolves to an object with `canceled` and `assets` fields.\n * When the user canceled the action the `assets` is always `null`, otherwise it's an array of\n * the selected media assets which have a form of [`ImagePickerAsset`](#imagepickerasset).\n */\nexport async function launchImageLibraryAsync(\n options?: ImagePickerOptions\n): Promise<ImagePickerResult> {\n if (!ExponentImagePicker.launchImageLibraryAsync) {\n throw new UnavailabilityError('ImagePicker', 'launchImageLibraryAsync');\n }\n if (options?.allowsEditing && options.allowsMultipleSelection) {\n console.warn(\n '[expo-image-picker] `allowsEditing` is not supported when `allowsMultipleSelection` is enabled and will be ignored.' +\n \"Disable either 'allowsEditing' or 'allowsMultipleSelection' in 'launchImageLibraryAsync' \" +\n 'to fix this warning.'\n );\n }\n const result = await ExponentImagePicker.launchImageLibraryAsync(options ?? {});\n return mergeDeprecatedResult(result);\n}\n\nexport * from './ImagePicker.types';\n\nexport { PermissionStatus, PermissionExpiration, PermissionHookOptions, PermissionResponse };\n"]}
1
+ {"version":3,"file":"ImagePicker.js","sourceRoot":"","sources":["../src/ImagePicker.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAIhB,oBAAoB,EACpB,mBAAmB,EACnB,UAAU,GACX,MAAM,mBAAmB,CAAC;AAE3B,OAAO,mBAAmB,MAAM,uBAAuB,CAAC;AASxD,SAAS,eAAe,CAAC,OAA2B;IAClD,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,EAAE,GAAG,OAAO,CAAC;IAEtD,IAAI,MAAM,IAAI,IAAI,EAAE;QAClB,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,MAAM,CAAC;QAEtB,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;YACpB,MAAM,IAAI,UAAU,CAClB,sBAAsB,EACtB,+BAA+B,CAAC,IAAI,CAAC,6BAA6B,CACnE,CAAC;SACH;KACF;IAED,IAAI,OAAO,IAAI,CAAC,OAAO,GAAG,CAAC,IAAI,OAAO,GAAG,CAAC,CAAC,EAAE;QAC3C,MAAM,IAAI,UAAU,CAClB,sBAAsB,EACtB,2BAA2B,OAAO,oCAAoC,CACvE,CAAC;KACH;IAED,IAAI,gBAAgB,IAAI,gBAAgB,GAAG,CAAC,EAAE;QAC5C,MAAM,IAAI,UAAU,CAClB,sBAAsB,EACtB,oCAAoC,gBAAgB,kCAAkC,CACvF,CAAC;KACH;IAED,OAAO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ACD,OAAO,EAAE,CAAC;AACZ,CAAC;AAED,cAAc;AACd;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,UAA8B,EAAE;IAEhC,IAAI,CAAC,mBAAmB,CAAC,iBAAiB,EAAE;QAC1C,MAAM,IAAI,mBAAmB,CAAC,aAAa,EAAE,mBAAmB,CAAC,CAAC;KACnE;IACD,OAAO,MAAM,mBAAmB,CAAC,iBAAiB,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,CAAC;AAC/E,CAAC;AAED,cAAc;AACd;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAC3C,OAA4B;IAE5B,IAAI,CAAC,mBAAmB,CAAC,uBAAuB,EAAE;QAChD,MAAM,IAAI,mBAAmB,CAAC,aAAa,EAAE,yBAAyB,CAAC,CAAC;KACzE;IACD,IAAI,OAAO,EAAE,aAAa,IAAI,OAAO,CAAC,uBAAuB,EAAE;QAC7D,OAAO,CAAC,IAAI,CACV,qHAAqH;YACnH,2FAA2F;YAC3F,sBAAsB,CACzB,CAAC;KACH;IACD,OAAO,MAAM,mBAAmB,CAAC,uBAAuB,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC;AAC1E,CAAC;AAED,cAAc,qBAAqB,CAAC;AAEpC,OAAO,EAAE,gBAAgB,EAAmE,CAAC","sourcesContent":["import {\n PermissionStatus,\n PermissionExpiration,\n PermissionHookOptions,\n PermissionResponse,\n createPermissionHook,\n UnavailabilityError,\n CodedError,\n} from 'expo-modules-core';\n\nimport ExponentImagePicker from './ExponentImagePicker';\nimport {\n CameraPermissionResponse,\n MediaLibraryPermissionResponse,\n ImagePickerResult,\n ImagePickerErrorResult,\n ImagePickerOptions,\n} from './ImagePicker.types';\n\nfunction validateOptions(options: ImagePickerOptions) {\n const { aspect, quality, videoMaxDuration } = options;\n\n if (aspect != null) {\n const [x, y] = aspect;\n\n if (x <= 0 || y <= 0) {\n throw new CodedError(\n 'ERR_INVALID_ARGUMENT',\n `Invalid aspect ratio values ${x}:${y}. Provide positive numbers.`\n );\n }\n }\n\n if (quality && (quality < 0 || quality > 1)) {\n throw new CodedError(\n 'ERR_INVALID_ARGUMENT',\n `Invalid 'quality' value ${quality}. Provide a value between 0 and 1.`\n );\n }\n\n if (videoMaxDuration && videoMaxDuration < 0) {\n throw new CodedError(\n 'ERR_INVALID_ARGUMENT',\n `Invalid 'videoMaxDuration' value ${videoMaxDuration}. Provide a non-negative number.`\n );\n }\n\n return options;\n}\n\n// @needsAudit\n/**\n * Checks user's permissions for accessing camera.\n * @return A promise that fulfills with an object of type [CameraPermissionResponse](#camerapermissionresponse).\n */\nexport async function getCameraPermissionsAsync(): Promise<CameraPermissionResponse> {\n return ExponentImagePicker.getCameraPermissionsAsync();\n}\n\n// @needsAudit\n/**\n * Checks user's permissions for accessing photos.\n * @param writeOnly Whether to request write or read and write permissions. Defaults to `false`\n * @return A promise that fulfills with an object of type [MediaLibraryPermissionResponse](#medialibrarypermissionresponse).\n */\nexport async function getMediaLibraryPermissionsAsync(\n writeOnly: boolean = false\n): Promise<MediaLibraryPermissionResponse> {\n return ExponentImagePicker.getMediaLibraryPermissionsAsync(writeOnly);\n}\n\n// @needsAudit\n/**\n * Asks the user to grant permissions for accessing camera. This does nothing on web because the\n * browser camera is not used.\n * @return A promise that fulfills with an object of type [CameraPermissionResponse](#camerarollpermissionresponse).\n */\nexport async function requestCameraPermissionsAsync(): Promise<CameraPermissionResponse> {\n return ExponentImagePicker.requestCameraPermissionsAsync();\n}\n\n// @needsAudit\n/**\n * Asks the user to grant permissions for accessing user's photo. This method does nothing on web.\n * @param writeOnly Whether to request write or read and write permissions. Defaults to `false`\n * @return A promise that fulfills with an object of type [MediaLibraryPermissionResponse](#medialibrarypermissionresponse).\n */\nexport async function requestMediaLibraryPermissionsAsync(\n writeOnly: boolean = false\n): Promise<MediaLibraryPermissionResponse> {\n const imagePickerMethod = ExponentImagePicker.requestMediaLibraryPermissionsAsync;\n return imagePickerMethod(writeOnly);\n}\n\n// @needsAudit\n/**\n * Check or request permissions to access the media library.\n * This uses both `requestMediaLibraryPermissionsAsync` and `getMediaLibraryPermissionsAsync` to interact with the permissions.\n *\n * @example\n * ```ts\n * const [status, requestPermission] = ImagePicker.useMediaLibraryPermissions();\n * ```\n */\nexport const useMediaLibraryPermissions = createPermissionHook<\n MediaLibraryPermissionResponse,\n { writeOnly?: boolean }\n>({\n // TODO(cedric): permission requesters should have an options param or a different requester\n getMethod: (options) => getMediaLibraryPermissionsAsync(options?.writeOnly),\n requestMethod: (options) => requestMediaLibraryPermissionsAsync(options?.writeOnly),\n});\n\n// @needsAudit\n/**\n * Check or request permissions to access the camera.\n * This uses both `requestCameraPermissionsAsync` and `getCameraPermissionsAsync` to interact with the permissions.\n *\n * @example\n * ```ts\n * const [status, requestPermission] = ImagePicker.useCameraPermissions();\n * ```\n */\nexport const useCameraPermissions = createPermissionHook({\n getMethod: getCameraPermissionsAsync,\n requestMethod: requestCameraPermissionsAsync,\n});\n\n// @needsAudit\n/**\n * Android system sometimes kills the `MainActivity` after the `ImagePicker` finishes. When this\n * happens, we lost the data selected from the `ImagePicker`. However, you can retrieve the lost\n * data by calling `getPendingResultAsync`. You can test this functionality by turning on\n * `Don't keep activities` in the developer options.\n * @return\n * - **On Android:** a promise that resolves to an array of objects of exactly same type as in\n * `ImagePicker.launchImageLibraryAsync` or `ImagePicker.launchCameraAsync` if the `ImagePicker`\n * finished successfully. Otherwise, to the array of [`ImagePickerErrorResult`](#imagepickerimagepickererrorresult).\n * - **On other platforms:** an empty array.\n */\nexport async function getPendingResultAsync(): Promise<\n (ImagePickerResult | ImagePickerErrorResult)[]\n> {\n if (ExponentImagePicker.getPendingResultAsync) {\n return ExponentImagePicker.getPendingResultAsync();\n }\n return [];\n}\n\n// @needsAudit\n/**\n * Display the system UI for taking a photo with the camera. Requires `Permissions.CAMERA`.\n * On Android and iOS 10 `Permissions.CAMERA_ROLL` is also required. On mobile web, this must be\n * called immediately in a user interaction like a button press, otherwise the browser will block\n * the request without a warning.\n * > **Note:** Make sure that you handle `MainActivity` destruction on **Android**. See [ImagePicker.getPendingResultAsync](#imagepickergetpendingresultasync).\n * > **Notes for Web:** The system UI can only be shown after user activation (e.g. a `Button` press).\n * Therefore, calling `launchCameraAsync` in `componentDidMount`, for example, will **not** work as\n * intended. The `cancelled` event will not be returned in the browser due to platform restrictions\n * and inconsistencies across browsers.\n * @param options An `ImagePickerOptions` object.\n * @return A promise that resolves to an object with `canceled` and `assets` fields.\n * When the user canceled the action the `assets` is always `null`, otherwise it's an array of\n * the selected media assets which have a form of [`ImagePickerAsset`](#imagepickerasset).\n */\nexport async function launchCameraAsync(\n options: ImagePickerOptions = {}\n): Promise<ImagePickerResult> {\n if (!ExponentImagePicker.launchCameraAsync) {\n throw new UnavailabilityError('ImagePicker', 'launchCameraAsync');\n }\n return await ExponentImagePicker.launchCameraAsync(validateOptions(options));\n}\n\n// @needsAudit\n/**\n * Display the system UI for choosing an image or a video from the phone's library.\n * Requires `Permissions.MEDIA_LIBRARY` on iOS 10 only. On mobile web, this must be called\n * immediately in a user interaction like a button press, otherwise the browser will block the\n * request without a warning.\n *\n * **Animated GIFs support:** On Android, if the selected image is an animated GIF, the result image will be an\n * animated GIF too if and only if `quality` is explicitly set to `1.0` and `allowsEditing` is set to `false`.\n * Otherwise compression and/or cropper will pick the first frame of the GIF and return it as the\n * result (on Android the result will be a PNG). On iOS, both quality and cropping are supported.\n *\n * > **Notes for Web:** The system UI can only be shown after user activation (e.g. a `Button` press).\n * Therefore, calling `launchImageLibraryAsync` in `componentDidMount`, for example, will **not**\n * work as intended. The `cancelled` event will not be returned in the browser due to platform\n * restrictions and inconsistencies across browsers.\n * @param options An object extended by [`ImagePickerOptions`](#imagepickeroptions).\n * @return A promise that resolves to an object with `canceled` and `assets` fields.\n * When the user canceled the action the `assets` is always `null`, otherwise it's an array of\n * the selected media assets which have a form of [`ImagePickerAsset`](#imagepickerasset).\n */\nexport async function launchImageLibraryAsync(\n options?: ImagePickerOptions\n): Promise<ImagePickerResult> {\n if (!ExponentImagePicker.launchImageLibraryAsync) {\n throw new UnavailabilityError('ImagePicker', 'launchImageLibraryAsync');\n }\n if (options?.allowsEditing && options.allowsMultipleSelection) {\n console.warn(\n '[expo-image-picker] `allowsEditing` is not supported when `allowsMultipleSelection` is enabled and will be ignored.' +\n \"Disable either 'allowsEditing' or 'allowsMultipleSelection' in 'launchImageLibraryAsync' \" +\n 'to fix this warning.'\n );\n }\n return await ExponentImagePicker.launchImageLibraryAsync(options ?? {});\n}\n\nexport * from './ImagePicker.types';\n\nexport { PermissionStatus, PermissionExpiration, PermissionHookOptions, PermissionResponse };\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-image-picker",
3
- "version": "14.4.0",
3
+ "version": "14.5.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.3.0"
39
+ "expo-image-loader": "~4.4.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": "663654577a7068c641b5e9474efbc502e3f334ea"
47
+ "gitHead": "79607a7325f47aa17c36d266100d09a4ff2cc544"
48
48
  }
@@ -48,42 +48,6 @@ function validateOptions(options: ImagePickerOptions) {
48
48
  return options;
49
49
  }
50
50
 
51
- const DEPRECATED_RESULT_KEYS = [
52
- 'uri',
53
- 'assetId',
54
- 'width',
55
- 'height',
56
- 'type',
57
- 'exif',
58
- 'base64',
59
- 'duration',
60
- 'fileName',
61
- 'fileSize',
62
- ];
63
- function mergeDeprecatedResult(result: ImagePickerResult): ImagePickerResult {
64
- const firstAsset = result?.assets?.[0];
65
- const deprecatedResult = {
66
- ...result,
67
- get cancelled() {
68
- console.warn(
69
- 'Key "cancelled" in the image picker result is deprecated and will be removed in SDK 48, use "canceled" instead'
70
- );
71
- return this.canceled;
72
- },
73
- };
74
- for (const key of DEPRECATED_RESULT_KEYS) {
75
- Object.defineProperty(deprecatedResult, key, {
76
- get() {
77
- console.warn(
78
- `Key "${key}" in the image picker result is deprecated and will be removed in SDK 48, you can access selected assets through the "assets" array instead`
79
- );
80
- return firstAsset?.[key];
81
- },
82
- });
83
- }
84
- return deprecatedResult;
85
- }
86
-
87
51
  // @needsAudit
88
52
  /**
89
53
  * Checks user's permissions for accessing camera.
@@ -205,8 +169,7 @@ export async function launchCameraAsync(
205
169
  if (!ExponentImagePicker.launchCameraAsync) {
206
170
  throw new UnavailabilityError('ImagePicker', 'launchCameraAsync');
207
171
  }
208
- const result = await ExponentImagePicker.launchCameraAsync(validateOptions(options));
209
- return mergeDeprecatedResult(result);
172
+ return await ExponentImagePicker.launchCameraAsync(validateOptions(options));
210
173
  }
211
174
 
212
175
  // @needsAudit
@@ -243,8 +206,7 @@ export async function launchImageLibraryAsync(
243
206
  'to fix this warning.'
244
207
  );
245
208
  }
246
- const result = await ExponentImagePicker.launchImageLibraryAsync(options ?? {});
247
- return mergeDeprecatedResult(result);
209
+ return await ExponentImagePicker.launchImageLibraryAsync(options ?? {});
248
210
  }
249
211
 
250
212
  export * from './ImagePicker.types';
package/tsconfig.json CHANGED
@@ -5,5 +5,5 @@
5
5
  "outDir": "./build"
6
6
  },
7
7
  "include": ["./src"],
8
- "exclude": ["**/__mocks__/*", "**/__tests__/*", "**/__stories__/*"]
8
+ "exclude": ["**/__mocks__/*", "**/__tests__/*"]
9
9
  }