expo-image-picker
Advanced tools
Comparing version 10.1.4 to 10.2.0
@@ -1,12 +0,14 @@ | ||
import { PermissionResponse } from 'unimodules-permissions-interface'; | ||
import { PermissionResponse } from 'expo-modules-core'; | ||
import { ImagePickerMultipleResult, ImagePickerResult, MediaTypeOptions } from './ImagePicker.types'; | ||
declare const _default: { | ||
readonly name: string; | ||
launchImageLibraryAsync({ mediaTypes, allowsMultipleSelection, }: { | ||
launchImageLibraryAsync({ mediaTypes, allowsMultipleSelection, base64, }: { | ||
mediaTypes?: MediaTypeOptions | undefined; | ||
allowsMultipleSelection?: boolean | undefined; | ||
base64?: boolean | undefined; | ||
}): Promise<ImagePickerResult | ImagePickerMultipleResult>; | ||
launchCameraAsync({ mediaTypes, allowsMultipleSelection, }: { | ||
launchCameraAsync({ mediaTypes, allowsMultipleSelection, base64, }: { | ||
mediaTypes?: MediaTypeOptions | undefined; | ||
allowsMultipleSelection?: boolean | undefined; | ||
base64?: boolean | undefined; | ||
}): Promise<ImagePickerResult | ImagePickerMultipleResult>; | ||
@@ -13,0 +15,0 @@ getCameraPermissionsAsync(): Promise<PermissionResponse>; |
import { Platform } from '@unimodules/core'; | ||
import { PermissionStatus } from 'unimodules-permissions-interface'; | ||
import { PermissionStatus } from 'expo-modules-core'; | ||
import { v4 } from 'uuid'; | ||
@@ -14,3 +14,3 @@ import { MediaTypeOptions, } from './ImagePicker.types'; | ||
}, | ||
async launchImageLibraryAsync({ mediaTypes = MediaTypeOptions.Images, allowsMultipleSelection = false, }) { | ||
async launchImageLibraryAsync({ mediaTypes = MediaTypeOptions.Images, allowsMultipleSelection = false, base64 = false, }) { | ||
// SSR guard | ||
@@ -23,5 +23,6 @@ if (!Platform.isDOMAvailable) { | ||
allowsMultipleSelection, | ||
base64, | ||
}); | ||
}, | ||
async launchCameraAsync({ mediaTypes = MediaTypeOptions.Images, allowsMultipleSelection = false, }) { | ||
async launchCameraAsync({ mediaTypes = MediaTypeOptions.Images, allowsMultipleSelection = false, base64 = false, }) { | ||
// SSR guard | ||
@@ -35,2 +36,3 @@ if (!Platform.isDOMAvailable) { | ||
capture: true, | ||
base64, | ||
}); | ||
@@ -66,3 +68,3 @@ }, | ||
} | ||
function openFileBrowserAsync({ mediaTypes, capture = false, allowsMultipleSelection = false, }) { | ||
function openFileBrowserAsync({ mediaTypes, capture = false, allowsMultipleSelection = false, base64, }) { | ||
const mediaTypeFormat = MediaTypeInput[mediaTypes]; | ||
@@ -85,3 +87,3 @@ const input = document.createElement('input'); | ||
if (!allowsMultipleSelection) { | ||
const img = await readFile(input.files[0]); | ||
const img = await readFile(input.files[0], { base64 }); | ||
resolve({ | ||
@@ -93,3 +95,3 @@ cancelled: false, | ||
else { | ||
const imgs = await Promise.all(Array.from(input.files).map(readFile)); | ||
const imgs = await Promise.all(Array.from(input.files).map(file => readFile(file, { base64 }))); | ||
resolve({ | ||
@@ -107,3 +109,3 @@ cancelled: false, | ||
} | ||
function readFile(targetFile) { | ||
function readFile(targetFile, options) { | ||
return new Promise((resolve, reject) => { | ||
@@ -128,2 +130,8 @@ const reader = new FileReader(); | ||
height: image.naturalHeight ?? image.height, | ||
// The blob's result cannot be directly decoded as Base64 without | ||
// first removing the Data-URL declaration preceding the | ||
// Base64-encoded data. To retrieve only the Base64 encoded string, | ||
// first remove data:*/*;base64, from the result. | ||
// https://developer.mozilla.org/en-US/docs/Web/API/FileReader/readAsDataURL | ||
...(options.base64 && { base64: uri.substr(uri.indexOf(',') + 1) }), | ||
}); | ||
@@ -130,0 +138,0 @@ image.onerror = () => returnRaw(); |
@@ -1,2 +0,2 @@ | ||
import { PermissionStatus, PermissionExpiration } from 'unimodules-permissions-interface'; | ||
import { PermissionStatus, PermissionExpiration } from 'expo-modules-core'; | ||
import { CameraPermissionResponse, CameraRollPermissionResponse, MediaLibraryPermissionResponse, ImagePickerResult, ImagePickerErrorResult, MediaTypeOptions, ImagePickerOptions, VideoExportPreset, ExpandImagePickerResult } from './ImagePicker.types'; | ||
@@ -3,0 +3,0 @@ export declare function getCameraPermissionsAsync(): Promise<CameraPermissionResponse>; |
import { UnavailabilityError, CodedError } from '@unimodules/core'; | ||
import { PermissionStatus } from 'unimodules-permissions-interface'; | ||
import { PermissionStatus } from 'expo-modules-core'; | ||
import ExponentImagePicker from './ExponentImagePicker'; | ||
@@ -4,0 +4,0 @@ import { MediaTypeOptions, VideoExportPreset, } from './ImagePicker.types'; |
@@ -1,2 +0,2 @@ | ||
import { PermissionResponse } from 'unimodules-permissions-interface'; | ||
import { PermissionResponse } from 'expo-modules-core'; | ||
export { PermissionResponse as CameraPermissionResponse }; | ||
@@ -81,2 +81,3 @@ export declare type MediaLibraryPermissionResponse = PermissionResponse & { | ||
allowsMultipleSelection: boolean; | ||
base64: boolean; | ||
}; | ||
@@ -83,0 +84,0 @@ export declare type ExpandImagePickerResult<T extends ImagePickerOptions | OpenFileBrowserOptions> = T extends { |
@@ -11,6 +11,16 @@ # Changelog | ||
## 10.1.4 — 2021-04-16 | ||
### 💡 Others | ||
_This version does not introduce any user-facing changes._ | ||
## 10.2.0 — 2021-06-16 | ||
### 🐛 Bug fixes | ||
- Fixed `base64` return on web. ([#12529](https://github.com/expo/expo/pull/12529) by [@simonezuccala](https://github.com/simonezuccala) and [@misterdev](https://github.com/misterdev)) | ||
- Enable kotlin in all modules. ([#12716](https://github.com/expo/expo/pull/12716) by [@wschurman](https://github.com/wschurman)) | ||
- Fixed cases where Picker & Camera would be transparent on iOS 14.5. ([#12897](https://github.com/expo/expo/pull/12897) by [@cruzach](https://github.com/cruzach)) | ||
### 💡 Others | ||
- Migrated from `unimodules-file-system-interface` and `unimodules-permissions-interface` to `expo-modules-core`. ([#12961](https://github.com/expo/expo/pull/12961) by [@tsapeta](https://github.com/tsapeta)) | ||
## 10.1.3 — 2021-04-13 | ||
@@ -17,0 +27,0 @@ |
{ | ||
"name": "expo-image-picker", | ||
"version": "10.1.4", | ||
"version": "10.2.0", | ||
"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.", | ||
@@ -39,10 +39,9 @@ "main": "build/ImagePicker.js", | ||
"unimodulePeerDependencies": { | ||
"@unimodules/core": "*", | ||
"unimodules-permissions-interface": "*" | ||
"@unimodules/core": "*" | ||
}, | ||
"dependencies": { | ||
"@expo/config-plugins": "^1.0.18", | ||
"expo-permissions": "~12.0.1", | ||
"uuid": "7.0.2", | ||
"unimodules-permissions-interface": "~6.1.0" | ||
"@expo/config-plugins": "^2.0.0", | ||
"expo-modules-core": "~0.1.1", | ||
"expo-permissions": "~12.1.0", | ||
"uuid": "7.0.2" | ||
}, | ||
@@ -52,3 +51,3 @@ "devDependencies": { | ||
}, | ||
"gitHead": "3f978ec39f1cc69d9672c68dd7ae8b13083c91ff" | ||
"gitHead": "c80d4c938920c5111e34c2dbca3a6bf500dff0e1" | ||
} |
import { Platform } from '@unimodules/core'; | ||
import { PermissionResponse, PermissionStatus } from 'unimodules-permissions-interface'; | ||
import { PermissionResponse, PermissionStatus } from 'expo-modules-core'; | ||
import { v4 } from 'uuid'; | ||
@@ -28,2 +28,3 @@ | ||
allowsMultipleSelection = false, | ||
base64 = false, | ||
}): Promise<ImagePickerResult | ImagePickerMultipleResult> { | ||
@@ -37,2 +38,3 @@ // SSR guard | ||
allowsMultipleSelection, | ||
base64, | ||
}); | ||
@@ -44,2 +46,3 @@ }, | ||
allowsMultipleSelection = false, | ||
base64 = false, | ||
}): Promise<ImagePickerResult | ImagePickerMultipleResult> { | ||
@@ -54,2 +57,3 @@ // SSR guard | ||
capture: true, | ||
base64, | ||
}); | ||
@@ -93,2 +97,3 @@ }, | ||
allowsMultipleSelection = false, | ||
base64, | ||
}: T): Promise<ExpandImagePickerResult<T>> { | ||
@@ -114,3 +119,3 @@ const mediaTypeFormat = MediaTypeInput[mediaTypes]; | ||
if (!allowsMultipleSelection) { | ||
const img: ImageInfo = await readFile(input.files[0]); | ||
const img: ImageInfo = await readFile(input.files[0], { base64 }); | ||
resolve({ | ||
@@ -121,3 +126,5 @@ cancelled: false, | ||
} else { | ||
const imgs: ImageInfo[] = await Promise.all(Array.from(input.files).map(readFile)); | ||
const imgs: ImageInfo[] = await Promise.all( | ||
Array.from(input.files).map(file => readFile(file, { base64 })) | ||
); | ||
resolve({ | ||
@@ -137,3 +144,3 @@ cancelled: false, | ||
function readFile(targetFile: Blob): Promise<ImageInfo> { | ||
function readFile(targetFile: Blob, options: { base64: boolean }): Promise<ImageInfo> { | ||
return new Promise((resolve, reject) => { | ||
@@ -161,2 +168,8 @@ const reader = new FileReader(); | ||
height: image.naturalHeight ?? image.height, | ||
// The blob's result cannot be directly decoded as Base64 without | ||
// first removing the Data-URL declaration preceding the | ||
// Base64-encoded data. To retrieve only the Base64 encoded string, | ||
// first remove data:*/*;base64, from the result. | ||
// https://developer.mozilla.org/en-US/docs/Web/API/FileReader/readAsDataURL | ||
...(options.base64 && { base64: uri.substr(uri.indexOf(',') + 1) }), | ||
}); | ||
@@ -163,0 +176,0 @@ image.onerror = () => returnRaw(); |
import { UnavailabilityError, CodedError } from '@unimodules/core'; | ||
import { PermissionStatus, PermissionExpiration } from 'unimodules-permissions-interface'; | ||
import { PermissionStatus, PermissionExpiration } from 'expo-modules-core'; | ||
@@ -4,0 +4,0 @@ import ExponentImagePicker from './ExponentImagePicker'; |
@@ -1,2 +0,2 @@ | ||
import { PermissionResponse } from 'unimodules-permissions-interface'; | ||
import { PermissionResponse } from 'expo-modules-core'; | ||
@@ -85,2 +85,3 @@ export { PermissionResponse as CameraPermissionResponse }; | ||
allowsMultipleSelection: boolean; | ||
base64: boolean; | ||
}; | ||
@@ -87,0 +88,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
146311
889
58
+ Addedexpo-modules-core@~0.1.1
+ Added@expo/config-plugins@2.0.4(transitive)
+ Added@expo/config-types@41.0.0(transitive)
+ Addeddebug@4.4.0(transitive)
+ Addedexpo-modules-core@0.1.10.2.0(transitive)
+ Addedexpo-permissions@12.1.1(transitive)
+ Addedms@2.1.3(transitive)
- Removed@babel/runtime@7.26.0(transitive)
- Removed@expo/config-plugins@1.0.33(transitive)
- Removed@expo/config-types@40.0.0-beta.2(transitive)
- Removed@expo/configure-splash-screen@0.4.0(transitive)
- Removed@expo/image-utils@0.3.14(transitive)
- Removed@expo/spawn-async@1.5.0(transitive)
- Removed@jimp/bmp@0.12.1(transitive)
- Removed@jimp/core@0.12.1(transitive)
- Removed@jimp/custom@0.12.1(transitive)
- Removed@jimp/gif@0.12.1(transitive)
- Removed@jimp/jpeg@0.12.1(transitive)
- Removed@jimp/plugin-blit@0.12.1(transitive)
- Removed@jimp/plugin-blur@0.12.1(transitive)
- Removed@jimp/plugin-circle@0.12.1(transitive)
- Removed@jimp/plugin-color@0.12.1(transitive)
- Removed@jimp/plugin-contain@0.12.1(transitive)
- Removed@jimp/plugin-cover@0.12.1(transitive)
- Removed@jimp/plugin-crop@0.12.1(transitive)
- Removed@jimp/plugin-displace@0.12.1(transitive)
- Removed@jimp/plugin-dither@0.12.1(transitive)
- Removed@jimp/plugin-fisheye@0.12.1(transitive)
- Removed@jimp/plugin-flip@0.12.1(transitive)
- Removed@jimp/plugin-gaussian@0.12.1(transitive)
- Removed@jimp/plugin-invert@0.12.1(transitive)
- Removed@jimp/plugin-mask@0.12.1(transitive)
- Removed@jimp/plugin-normalize@0.12.1(transitive)
- Removed@jimp/plugin-print@0.12.1(transitive)
- Removed@jimp/plugin-resize@0.12.1(transitive)
- Removed@jimp/plugin-rotate@0.12.1(transitive)
- Removed@jimp/plugin-scale@0.12.1(transitive)
- Removed@jimp/plugin-shadow@0.12.1(transitive)
- Removed@jimp/plugin-threshold@0.12.1(transitive)
- Removed@jimp/plugins@0.12.1(transitive)
- Removed@jimp/png@0.12.1(transitive)
- Removed@jimp/tiff@0.12.1(transitive)
- Removed@jimp/types@0.12.1(transitive)
- Removed@jimp/utils@0.12.1(transitive)
- Removedansi-styles@4.3.0(transitive)
- Removedany-base@1.1.0(transitive)
- Removedbmp-js@0.1.0(transitive)
- Removedbuffer@5.7.1(transitive)
- Removedbuffer-equal@0.0.1(transitive)
- Removedcentra@2.7.0(transitive)
- Removedchalk@4.1.2(transitive)
- Removedcolor-convert@2.0.1(transitive)
- Removedcolor-name@1.1.4(transitive)
- Removedcolor-string@1.9.1(transitive)
- Removedcommander@5.1.0(transitive)
- Removedcross-spawn@6.0.6(transitive)
- Removedcrypto-random-string@1.0.0(transitive)
- Removeddom-walk@0.1.2(transitive)
- Removedexif-parser@0.1.12(transitive)
- Removedexpo-permissions@12.0.1(transitive)
- Removedfile-type@9.0.0(transitive)
- Removedfollow-redirects@1.15.9(transitive)
- Removedglobal@4.4.0(transitive)
- Removedhas-flag@4.0.0(transitive)
- Removedieee754@1.2.1(transitive)
- Removedis-arrayish@0.3.2(transitive)
- Removedis-function@1.0.2(transitive)
- Removedisexe@2.0.0(transitive)
- Removedjimp@0.12.1(transitive)
- Removedjpeg-js@0.4.4(transitive)
- Removedload-bmfont@1.4.2(transitive)
- Removedlodash@4.17.21(transitive)
- Removedmime@1.6.02.6.0(transitive)
- Removedmin-document@2.19.0(transitive)
- Removedmkdirp@0.5.6(transitive)
- Removednice-try@1.0.5(transitive)
- Removednode-fetch@2.7.0(transitive)
- Removedomggif@1.0.10(transitive)
- Removedpako@1.0.11(transitive)
- Removedparse-bmfont-ascii@1.0.6(transitive)
- Removedparse-bmfont-binary@1.0.6(transitive)
- Removedparse-bmfont-xml@1.1.6(transitive)
- Removedparse-headers@2.0.5(transitive)
- Removedparse-png@2.1.0(transitive)
- Removedpath-key@2.0.1(transitive)
- Removedphin@2.9.33.7.1(transitive)
- Removedpixelmatch@4.0.2(transitive)
- Removedpngjs@3.4.05.0.0(transitive)
- Removedprocess@0.11.10(transitive)
- Removedregenerator-runtime@0.13.110.14.1(transitive)
- Removedsemver@5.7.27.3.2(transitive)
- Removedshebang-command@1.2.0(transitive)
- Removedshebang-regex@1.0.0(transitive)
- Removedsimple-swizzle@0.2.2(transitive)
- Removedsupports-color@7.2.0(transitive)
- Removedtemp-dir@1.0.0(transitive)
- Removedtempy@0.3.0(transitive)
- Removedtimm@1.7.1(transitive)
- Removedtinycolor2@1.6.0(transitive)
- Removedtr46@0.0.3(transitive)
- Removedtype-fest@0.3.1(transitive)
- Removedunimodules-permissions-interface@6.1.0(transitive)
- Removedunique-string@1.0.0(transitive)
- Removedutif@2.0.1(transitive)
- Removedwebidl-conversions@3.0.1(transitive)
- Removedwhatwg-url@5.0.0(transitive)
- Removedwhich@1.3.1(transitive)
- Removedxhr@2.6.0(transitive)
- Removedxml-js@1.6.11(transitive)
- Removedxml-parse-from-string@1.0.1(transitive)
- Removedxml2js@0.5.0(transitive)
- Removedxtend@4.0.2(transitive)
Updated@expo/config-plugins@^2.0.0
Updatedexpo-permissions@~12.1.0