expo-camera 13.4.2 → 13.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 +7 -1
- package/android/build.gradle +2 -2
- package/build/Camera.types.d.ts +2 -2
- package/build/Camera.types.js.map +1 -1
- package/build/ExponentCameraManager.web.d.ts.map +1 -1
- package/build/ExponentCameraManager.web.js +31 -17
- package/build/ExponentCameraManager.web.js.map +1 -1
- package/package.json +2 -2
- package/src/Camera.types.ts +2 -2
- package/src/ExponentCameraManager.web.ts +30 -17
package/CHANGELOG.md
CHANGED
|
@@ -10,7 +10,13 @@
|
|
|
10
10
|
|
|
11
11
|
### 💡 Others
|
|
12
12
|
|
|
13
|
-
## 13.
|
|
13
|
+
## 13.5.0 — 2023-07-28
|
|
14
|
+
|
|
15
|
+
### 🐛 Bug fixes
|
|
16
|
+
|
|
17
|
+
- Fixed issue with checking camera/microphone permissions in Firefox. ([#22855](https://github.com/expo/expo/pull/22855) by [@loganrosen](https://github.com/loganrosen))
|
|
18
|
+
|
|
19
|
+
## 13.4.2 - 2023-07-04
|
|
14
20
|
|
|
15
21
|
### 🐛 Bug fixes
|
|
16
22
|
|
package/android/build.gradle
CHANGED
|
@@ -3,7 +3,7 @@ apply plugin: 'kotlin-android'
|
|
|
3
3
|
apply plugin: 'maven-publish'
|
|
4
4
|
|
|
5
5
|
group = 'host.exp.exponent'
|
|
6
|
-
version = '13.
|
|
6
|
+
version = '13.5.0'
|
|
7
7
|
|
|
8
8
|
buildscript {
|
|
9
9
|
def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
|
|
@@ -67,7 +67,7 @@ android {
|
|
|
67
67
|
minSdkVersion safeExtGet("minSdkVersion", 21)
|
|
68
68
|
targetSdkVersion safeExtGet("targetSdkVersion", 33)
|
|
69
69
|
versionCode 32
|
|
70
|
-
versionName "13.
|
|
70
|
+
versionName "13.5.0"
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
lintOptions {
|
package/build/Camera.types.d.ts
CHANGED
|
@@ -401,8 +401,8 @@ export type CameraProps = ViewProps & {
|
|
|
401
401
|
*/
|
|
402
402
|
useCamera2Api?: boolean;
|
|
403
403
|
/**
|
|
404
|
-
* A string representing the size of pictures [`takePictureAsync`](#
|
|
405
|
-
* Available sizes can be fetched with [`getAvailablePictureSizesAsync`](#
|
|
404
|
+
* A string representing the size of pictures [`takePictureAsync`](#takepictureasyncoptions) will take.
|
|
405
|
+
* Available sizes can be fetched with [`getAvailablePictureSizesAsync`](#getavailablepicturesizesasyncratio).
|
|
406
406
|
*/
|
|
407
407
|
pictureSize?: string;
|
|
408
408
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Camera.types.js","sourceRoot":"","sources":["../src/Camera.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,gBAAgB,GAGjB,MAAM,mBAAmB,CAAC;AAG3B,MAAM,CAAN,IAAY,UAGX;AAHD,WAAY,UAAU;IACpB,6BAAe,CAAA;IACf,2BAAa,CAAA;AACf,CAAC,EAHW,UAAU,KAAV,UAAU,QAGrB;AAED,MAAM,CAAN,IAAY,SAKX;AALD,WAAY,SAAS;IACnB,sBAAS,CAAA;IACT,wBAAW,CAAA;IACX,0BAAa,CAAA;IACb,4BAAe,CAAA;AACjB,CAAC,EALW,SAAS,KAAT,SAAS,QAKpB;AAED,MAAM,CAAN,IAAY,SAWX;AAXD,WAAY,SAAS;IACnB,sBAAS,CAAA;IACT,wBAAW,CAAA;IACX;;OAEG;IACH,0BAAa,CAAA;IACb;;OAEG;IACH,sCAAyB,CAAA;AAC3B,CAAC,EAXW,SAAS,KAAT,SAAS,QAWpB;AAED,MAAM,CAAN,IAAY,YAmCX;AAnCD,WAAY,YAAY;IACtB,6BAAa,CAAA;IACb;;;OAGG;IACH,+BAAe,CAAA;IACf;;;OAGG;IACH,iCAAiB,CAAA;IACjB;;;OAGG;IACH,iCAAiB,CAAA;IACjB;;;OAGG;IACH,6CAA6B,CAAA;IAC7B;;;OAGG;IACH,2CAA2B,CAAA;IAC3B;;OAEG;IACH,yCAAyB,CAAA;IACzB;;OAEG;IACH,iCAAiB,CAAA;AACnB,CAAC,EAnCW,YAAY,KAAZ,YAAY,QAmCvB;AAED,MAAM,CAAN,IAAY,SAGX;AAHD,WAAY,SAAS;IACnB,wBAAW,CAAA;IACX,wBAAW,CAAA;AACb,CAAC,EAHW,SAAS,KAAT,SAAS,QAGpB;AAED;;;GAGG;AACH,MAAM,CAAN,IAAY,UAMX;AAND,WAAY,UAAU;IACpB,2BAAa,CAAA;IACb,2BAAa,CAAA;IACb,2BAAa,CAAA;IACb,qCAAuB,CAAA;IACvB,sCAAwB,CAAA;AAC1B,CAAC,EANW,UAAU,KAAV,UAAU,QAMrB;AAED;;;GAGG;AACH,MAAM,CAAN,IAAY,kBAKX;AALD,WAAY,kBAAkB;IAC5B,iCAAW,CAAA;IACX,2CAAqB,CAAA;IACrB,6CAAuB,CAAA;IACvB,mCAAa,CAAA;AACf,CAAC,EALW,kBAAkB,KAAlB,kBAAkB,QAK7B;AAED,eAAe;AACf,MAAM,CAAN,IAAY,YAMX;AAND,WAAY,YAAY;IACtB,+BAAiB,CAAA;IACjB,+BAAiB,CAAA;IACjB,6BAAe,CAAA;IACf,6BAAe,CAAA;IACf,2BAAa,CAAA;AACf,CAAC,EANW,YAAY,KAAZ,YAAY,QAMvB;AAED,MAAM,CAAN,IAAY,iBAKX;AALD,WAAY,iBAAiB;IAC3B,iEAAY,CAAA;IACZ,qFAAsB,CAAA;IACtB,2EAAiB,CAAA;IACjB,6EAAkB,CAAA;AACpB,CAAC,EALW,iBAAiB,KAAjB,iBAAiB,QAK5B;AA2aD,OAAO,EAAsB,gBAAgB,EAA+C,CAAC","sourcesContent":["import {\n PermissionResponse,\n PermissionStatus,\n PermissionExpiration,\n PermissionHookOptions,\n} from 'expo-modules-core';\nimport type { ViewProps } from 'react-native';\n\nexport enum CameraType {\n front = 'front',\n back = 'back',\n}\n\nexport enum FlashMode {\n on = 'on',\n off = 'off',\n auto = 'auto',\n torch = 'torch',\n}\n\nexport enum AutoFocus {\n on = 'on',\n off = 'off',\n /**\n * @platform web\n */\n auto = 'auto',\n /**\n * @platform web\n */\n singleShot = 'singleShot',\n}\n\nexport enum WhiteBalance {\n auto = 'auto',\n /**\n * @platform android\n * @platform ios\n */\n sunny = 'sunny',\n /**\n * @platform android\n * @platform ios\n */\n cloudy = 'cloudy',\n /**\n * @platform android\n * @platform ios\n */\n shadow = 'shadow',\n /**\n * @platform android\n * @platform ios\n */\n incandescent = 'incandescent',\n /**\n * @platform android\n * @platform ios\n */\n fluorescent = 'fluorescent',\n /**\n * @platform web\n */\n continuous = 'continuous',\n /**\n * @platform web\n */\n manual = 'manual',\n}\n\nexport enum ImageType {\n png = 'png',\n jpg = 'jpg',\n}\n\n/**\n * This option specifies what codec to use when recording a video.\n * @platform ios\n */\nexport enum VideoCodec {\n H264 = 'avc1',\n HEVC = 'hvc1',\n JPEG = 'jpeg',\n AppleProRes422 = 'apcn',\n AppleProRes4444 = 'ap4h',\n}\n\n/**\n * This option specifies the stabilization mode to use when recording a video.\n * @platform ios\n */\nexport enum VideoStabilization {\n off = 'off',\n standard = 'standard',\n cinematic = 'cinematic',\n auto = 'auto',\n}\n\n// @docsMissing\nexport enum VideoQuality {\n '2160p' = '2160p',\n '1080p' = '1080p',\n '720p' = '720p',\n '480p' = '480p',\n '4:3' = '4:3',\n}\n\nexport enum CameraOrientation {\n portrait = 1,\n portraitUpsideDown = 2,\n landscapeLeft = 3,\n landscapeRight = 4,\n}\n\n// @docsMissing\n/**\n * @hidden We do not expose related web methods in docs.\n * @platform web\n */\nexport type ImageSize = {\n width: number;\n height: number;\n};\n\n// @docsMissing\n/**\n * @hidden We do not expose related web methods in docs.\n * @platform web\n */\nexport type WebCameraSettings = {\n autoFocus?: string;\n flashMode?: string;\n whiteBalance?: string;\n exposureCompensation?: number;\n colorTemperature?: number;\n iso?: number;\n brightness?: number;\n contrast?: number;\n saturation?: number;\n sharpness?: number;\n focusDistance?: number;\n zoom?: number;\n};\n\n// @needsAudit\nexport type CameraCapturedPicture = {\n /**\n * Captured image width.\n */\n width: number;\n /**\n * Captured image height.\n */\n height: number;\n /**\n * On web, the value of `uri` is the same as `base64` because file system URLs are not supported in the browser.\n */\n uri: string;\n /**\n * A Base64 representation of the image.\n */\n base64?: string;\n /**\n * On Android and iOS this object may include various fields based on the device and operating system.\n * On web, it is a partial representation of the [`MediaTrackSettings`](https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackSettings) dictionary.\n */\n exif?: Partial<MediaTrackSettings> | any;\n};\n\n// @needsAudit\nexport type CameraPictureOptions = {\n /**\n * Specify the quality of compression, from 0 to 1. 0 means compress for small size, 1 means compress for maximum quality.\n */\n quality?: number;\n /**\n * Whether to also include the image data in Base64 format.\n */\n base64?: boolean;\n /**\n * Whether to also include the EXIF data for the image.\n */\n exif?: boolean;\n /**\n * Additional EXIF data to be included for the image. Only useful when `exif` option is set to `true`.\n * @platform android\n * @platform ios\n */\n additionalExif?: { [name: string]: any };\n /**\n * A callback invoked when picture is saved. If set, the promise of this method will resolve immediately with no data after picture is captured.\n * The data that it should contain will be passed to this callback. If displaying or processing a captured photo right after taking it\n * is not your case, this callback lets you skip waiting for it to be saved.\n * @param picture\n */\n onPictureSaved?: (picture: CameraCapturedPicture) => void;\n // TODO(Bacon): Is it possible to implement this in the browser?\n /**\n * If set to `true`, camera skips orientation adjustment and returns an image straight from the device's camera.\n * If enabled, `quality` option is discarded (processing pipeline is skipped as a whole).\n * Although enabling this option reduces image delivery time significantly, it may cause the image to appear in a wrong orientation\n * in the `Image` component (at the time of writing, it does not respect EXIF orientation of the images).\n * > **Note**: Enabling `skipProcessing` would cause orientation uncertainty. `Image` component does not respect EXIF\n * > stored orientation information, that means obtained image would be displayed wrongly (rotated by 90°, 180° or 270°).\n * > Different devices provide different orientations. For example some Sony Xperia or Samsung devices don't provide\n * > correctly oriented images by default. To always obtain correctly oriented image disable `skipProcessing` option.\n */\n skipProcessing?: boolean;\n /**\n * @platform web\n */\n scale?: number;\n /**\n * @platform web\n */\n imageType?: ImageType;\n /**\n * @platform web\n */\n isImageMirror?: boolean;\n /**\n * @hidden\n */\n id?: number;\n /**\n * @hidden\n */\n fastMode?: boolean;\n /**\n * @hidden\n */\n maxDownsampling?: number;\n};\n\n// @needsAudit\nexport type CameraRecordingOptions = {\n /**\n * Maximum video duration in seconds.\n */\n maxDuration?: number;\n /**\n * Maximum video file size in bytes.\n */\n maxFileSize?: number;\n /**\n * Specify the quality of recorded video. Use one of [`VideoQuality.<value>`](#videoquality).\n * Possible values: for 16:9 resolution `2160p`, `1080p`, `720p`, `480p` : `Android only` and for 4:3 `4:3` (the size is 640x480).\n * If the chosen quality is not available for a device, the highest available is chosen.\n */\n quality?: number | string;\n /**\n * If present, video will be recorded with no sound.\n */\n mute?: boolean;\n /**\n * If `true`, the recorded video will be flipped along the vertical axis. iOS flips videos recorded with the front camera by default,\n * but you can reverse that back by setting this to `true`. On Android, this is handled in the user's device settings.\n * @platform ios\n */\n mirror?: boolean;\n /**\n * Only works if `useCamera2Api` is set to `true`. This option specifies a desired video bitrate. For example, `5*1000*1000` would be 5Mbps.\n * @platform android\n */\n videoBitrate?: number;\n /**\n * This option specifies what codec to use when recording the video. See [`VideoCodec`](#videocodec) for the possible values.\n * @platform ios\n */\n codec?: VideoCodec;\n};\n\n/**\n * @hidden\n */\nexport type PictureSavedListener = (event: {\n nativeEvent: { data: CameraCapturedPicture; id: number };\n}) => void;\n\n/**\n * @hidden\n */\nexport type CameraReadyListener = () => void;\n\n/**\n * @hidden\n */\nexport type ResponsiveOrientationChangedListener = (event: {\n nativeEvent: ResponsiveOrientationChanged;\n}) => void;\n\nexport type ResponsiveOrientationChanged = { orientation: CameraOrientation };\n\n/**\n * @hidden\n */\nexport type MountErrorListener = (event: { nativeEvent: CameraMountError }) => void;\n\n// @docsMissing\nexport type CameraMountError = { message: string };\n\n// @docsMissing\nexport type Point = {\n x: number;\n y: number;\n};\n\nexport type BarCodeSize = {\n /**\n * The height value.\n */\n height: number;\n /**\n * The width value.\n */\n width: number;\n};\n\n/**\n * These coordinates are represented in the coordinate space of the camera source (e.g. when you\n * are using the camera view, these values are adjusted to the dimensions of the view).\n */\nexport type BarCodePoint = Point;\n\nexport type BarCodeBounds = {\n /**\n * The origin point of the bounding box.\n */\n origin: BarCodePoint;\n /**\n * The size of the bounding box.\n */\n size: BarCodeSize;\n};\n\n// @needsAudit\nexport type BarCodeScanningResult = {\n /**\n * The barcode type.\n */\n type: string;\n /**\n * The information encoded in the bar code.\n */\n data: string;\n /**\n * Corner points of the bounding box.\n * `cornerPoints` is not always available and may be empty. On iOS, for `code39` and `pdf417`\n * you don't get this value.\n */\n cornerPoints: BarCodePoint[];\n /**\n * The [BarCodeBounds](#barcodebounds) object.\n * `bounds` in some case will be representing an empty rectangle.\n * Moreover, `bounds` doesn't have to bound the whole barcode.\n * For some types, they will represent the area used by the scanner.\n */\n bounds: BarCodeBounds;\n};\n\nexport type FaceDetectionResult = {\n /**\n * Array of objects representing results of face detection.\n * See [`FaceFeature`](facedetector/#facefeature) in FaceDetector documentation for more details.\n */\n faces: object[];\n};\n\n/**\n * @hidden\n */\nexport type ConstantsType = {\n Type: CameraType;\n FlashMode: FlashMode;\n AutoFocus: AutoFocus;\n WhiteBalance: WhiteBalance;\n VideoQuality: VideoQuality;\n VideoStabilization: VideoStabilization;\n VideoCodec: VideoCodec;\n};\n\n// @needsAudit\nexport type CameraProps = ViewProps & {\n /**\n * Camera facing. Use one of `CameraType`. When `CameraType.front`, use the front-facing camera.\n * When `CameraType.back`, use the back-facing camera.\n * @default CameraType.back\n */\n type?: number | CameraType;\n /**\n * Camera flash mode. Use one of [`FlashMode.<value>`](#flashmode-1). When `FlashMode.on`, the flash on your device will\n * turn on when taking a picture, when `FlashMode.off`, it won't. Setting to `FlashMode.auto` will fire flash if required,\n * `FlashMode.torch` turns on flash during the preview.\n * @default FlashMode.off\n */\n flashMode?: number | FlashMode;\n /**\n * Camera white balance. Use one of [`WhiteBalance.<value>`](#whitebalance). If a device does not support any of these values previous one is used.\n * @default WhiteBalance.auto\n */\n whiteBalance?: number | WhiteBalance;\n /**\n * State of camera auto focus. Use one of [`AutoFocus.<value>`](#autofocus-1). When `AutoFocus.on`,\n * auto focus will be enabled, when `AutoFocus.off`, it won't and focus will lock as it was in the moment of change,\n * but it can be adjusted on some devices via `focusDepth` prop.\n * @default AutoFocus.on\n */\n autoFocus?: boolean | number | AutoFocus;\n /**\n * A value between `0` and `1` being a percentage of device's max zoom. `0` - not zoomed, `1` - maximum zoom.\n * @default 0\n */\n zoom?: number;\n /**\n * A string representing aspect ratio of the preview, eg. `4:3`, `16:9`, `1:1`. To check if a ratio is supported\n * by the device use [`getSupportedRatiosAsync`](#getsupportedratiosasync).\n * @default 4:3\n * @platform android\n */\n ratio?: string;\n /**\n * Distance to plane of the sharpest focus. A value between `0` and `1` where: `0` - infinity focus, `1` - focus as close as possible.\n * For Android this is available only for some devices and when `useCamera2Api` is set to `true`.\n * @default 0\n */\n focusDepth?: number;\n /**\n * Callback invoked when camera preview has been set.\n */\n onCameraReady?: () => void;\n /**\n * Whether to use Android's Camera2 API. See `Note` at the top of this page.\n * @platform android\n */\n useCamera2Api?: boolean;\n /**\n * A string representing the size of pictures [`takePictureAsync`](#takepictureasync) will take.\n * Available sizes can be fetched with [`getAvailablePictureSizesAsync`](#getavailablepicturesizesasync).\n */\n pictureSize?: string;\n /**\n * The video stabilization mode used for a video recording. Use one of [`VideoStabilization.<value>`](#videostabilization).\n * You can read more about each stabilization type in [Apple Documentation](https://developer.apple.com/documentation/avfoundation/avcapturevideostabilizationmode).\n * @platform ios\n */\n videoStabilizationMode?: VideoStabilization;\n /**\n * Callback invoked when camera preview could not been started.\n * @param event Error object that contains a `message`.\n */\n onMountError?: (event: CameraMountError) => void;\n /**\n * Settings exposed by [`BarCodeScanner`](bar-code-scanner) module. Supported settings: **barCodeTypes**.\n * @example\n * ```tsx\n * <Camera\n * barCodeScannerSettings={{\n * barCodeTypes: [BarCodeScanner.Constants.BarCodeType.qr],\n * }}\n * />\n * ```\n */\n barCodeScannerSettings?: BarCodeSettings;\n /**\n * Callback that is invoked when a bar code has been successfully scanned. The callback is provided with\n * an object of the [`BarCodeScanningResult`](#barcodescanningresult) shape, where the `type`\n * refers to the bar code type that was scanned and the `data` is the information encoded in the bar code\n * (in this case of QR codes, this is often a URL). See [`BarCodeScanner.Constants.BarCodeType`](bar-code-scanner#supported-formats)\n * for supported values.\n * @param scanningResult\n */\n onBarCodeScanned?: (scanningResult: BarCodeScanningResult) => void;\n /**\n * A settings object passed directly to an underlying module providing face detection features.\n * See [`DetectionOptions`](facedetector/#detectionoptions) in FaceDetector documentation for details.\n */\n faceDetectorSettings?: object;\n /**\n * Callback invoked with results of face detection on the preview.\n * See [`DetectionResult`](facedetector/#detectionresult) in FaceDetector documentation for more details.\n * @param faces\n */\n onFacesDetected?: (faces: FaceDetectionResult) => void;\n /**\n * A URL for an image to be shown while the camera is loading.\n * @platform web\n */\n poster?: string;\n /**\n * Whether to allow responsive orientation of the camera when the screen orientation is locked (i.e. when set to `true`\n * landscape photos will be taken if the device is turned that way, even if the app or device orientation is locked to portrait)\n * @platform ios\n */\n responsiveOrientationWhenOrientationLocked?: boolean;\n /**\n * Callback invoked when responsive orientation changes. Only applicable if `responsiveOrientationWhenOrientationLocked` is `true`\n * @param event result object that contains updated orientation of camera\n * @platform ios\n */\n onResponsiveOrientationChanged?: (event: ResponsiveOrientationChanged) => void;\n};\n\n/**\n * @hidden\n */\nexport type CameraNativeProps = {\n pointerEvents?: any;\n style?: any;\n ref?: Function;\n onCameraReady?: CameraReadyListener;\n onMountError?: MountErrorListener;\n onBarCodeScanned?: (event: { nativeEvent: BarCodeScanningResult }) => void;\n onFacesDetected?: (event: { nativeEvent: FaceDetectionResult }) => void;\n onFaceDetectionError?: (event: { nativeEvent: Error }) => void;\n onPictureSaved?: PictureSavedListener;\n onResponsiveOrientationChanged?: ResponsiveOrientationChangedListener;\n type?: number | string;\n flashMode?: number | string;\n autoFocus?: string | boolean | number;\n focusDepth?: number;\n zoom?: number;\n whiteBalance?: number | string;\n pictureSize?: string;\n barCodeScannerSettings?: BarCodeSettings;\n faceDetectorSettings?: object;\n barCodeScannerEnabled?: boolean;\n faceDetectorEnabled?: boolean;\n ratio?: string;\n useCamera2Api?: boolean;\n poster?: string;\n responsiveOrientationWhenOrientationLocked?: boolean;\n};\n\n// @docsMissing\nexport type BarCodeSettings = {\n barCodeTypes: string[];\n interval?: number;\n};\n\nexport { PermissionResponse, PermissionStatus, PermissionExpiration, PermissionHookOptions };\n"]}
|
|
1
|
+
{"version":3,"file":"Camera.types.js","sourceRoot":"","sources":["../src/Camera.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,gBAAgB,GAGjB,MAAM,mBAAmB,CAAC;AAG3B,MAAM,CAAN,IAAY,UAGX;AAHD,WAAY,UAAU;IACpB,6BAAe,CAAA;IACf,2BAAa,CAAA;AACf,CAAC,EAHW,UAAU,KAAV,UAAU,QAGrB;AAED,MAAM,CAAN,IAAY,SAKX;AALD,WAAY,SAAS;IACnB,sBAAS,CAAA;IACT,wBAAW,CAAA;IACX,0BAAa,CAAA;IACb,4BAAe,CAAA;AACjB,CAAC,EALW,SAAS,KAAT,SAAS,QAKpB;AAED,MAAM,CAAN,IAAY,SAWX;AAXD,WAAY,SAAS;IACnB,sBAAS,CAAA;IACT,wBAAW,CAAA;IACX;;OAEG;IACH,0BAAa,CAAA;IACb;;OAEG;IACH,sCAAyB,CAAA;AAC3B,CAAC,EAXW,SAAS,KAAT,SAAS,QAWpB;AAED,MAAM,CAAN,IAAY,YAmCX;AAnCD,WAAY,YAAY;IACtB,6BAAa,CAAA;IACb;;;OAGG;IACH,+BAAe,CAAA;IACf;;;OAGG;IACH,iCAAiB,CAAA;IACjB;;;OAGG;IACH,iCAAiB,CAAA;IACjB;;;OAGG;IACH,6CAA6B,CAAA;IAC7B;;;OAGG;IACH,2CAA2B,CAAA;IAC3B;;OAEG;IACH,yCAAyB,CAAA;IACzB;;OAEG;IACH,iCAAiB,CAAA;AACnB,CAAC,EAnCW,YAAY,KAAZ,YAAY,QAmCvB;AAED,MAAM,CAAN,IAAY,SAGX;AAHD,WAAY,SAAS;IACnB,wBAAW,CAAA;IACX,wBAAW,CAAA;AACb,CAAC,EAHW,SAAS,KAAT,SAAS,QAGpB;AAED;;;GAGG;AACH,MAAM,CAAN,IAAY,UAMX;AAND,WAAY,UAAU;IACpB,2BAAa,CAAA;IACb,2BAAa,CAAA;IACb,2BAAa,CAAA;IACb,qCAAuB,CAAA;IACvB,sCAAwB,CAAA;AAC1B,CAAC,EANW,UAAU,KAAV,UAAU,QAMrB;AAED;;;GAGG;AACH,MAAM,CAAN,IAAY,kBAKX;AALD,WAAY,kBAAkB;IAC5B,iCAAW,CAAA;IACX,2CAAqB,CAAA;IACrB,6CAAuB,CAAA;IACvB,mCAAa,CAAA;AACf,CAAC,EALW,kBAAkB,KAAlB,kBAAkB,QAK7B;AAED,eAAe;AACf,MAAM,CAAN,IAAY,YAMX;AAND,WAAY,YAAY;IACtB,+BAAiB,CAAA;IACjB,+BAAiB,CAAA;IACjB,6BAAe,CAAA;IACf,6BAAe,CAAA;IACf,2BAAa,CAAA;AACf,CAAC,EANW,YAAY,KAAZ,YAAY,QAMvB;AAED,MAAM,CAAN,IAAY,iBAKX;AALD,WAAY,iBAAiB;IAC3B,iEAAY,CAAA;IACZ,qFAAsB,CAAA;IACtB,2EAAiB,CAAA;IACjB,6EAAkB,CAAA;AACpB,CAAC,EALW,iBAAiB,KAAjB,iBAAiB,QAK5B;AA2aD,OAAO,EAAsB,gBAAgB,EAA+C,CAAC","sourcesContent":["import {\n PermissionResponse,\n PermissionStatus,\n PermissionExpiration,\n PermissionHookOptions,\n} from 'expo-modules-core';\nimport type { ViewProps } from 'react-native';\n\nexport enum CameraType {\n front = 'front',\n back = 'back',\n}\n\nexport enum FlashMode {\n on = 'on',\n off = 'off',\n auto = 'auto',\n torch = 'torch',\n}\n\nexport enum AutoFocus {\n on = 'on',\n off = 'off',\n /**\n * @platform web\n */\n auto = 'auto',\n /**\n * @platform web\n */\n singleShot = 'singleShot',\n}\n\nexport enum WhiteBalance {\n auto = 'auto',\n /**\n * @platform android\n * @platform ios\n */\n sunny = 'sunny',\n /**\n * @platform android\n * @platform ios\n */\n cloudy = 'cloudy',\n /**\n * @platform android\n * @platform ios\n */\n shadow = 'shadow',\n /**\n * @platform android\n * @platform ios\n */\n incandescent = 'incandescent',\n /**\n * @platform android\n * @platform ios\n */\n fluorescent = 'fluorescent',\n /**\n * @platform web\n */\n continuous = 'continuous',\n /**\n * @platform web\n */\n manual = 'manual',\n}\n\nexport enum ImageType {\n png = 'png',\n jpg = 'jpg',\n}\n\n/**\n * This option specifies what codec to use when recording a video.\n * @platform ios\n */\nexport enum VideoCodec {\n H264 = 'avc1',\n HEVC = 'hvc1',\n JPEG = 'jpeg',\n AppleProRes422 = 'apcn',\n AppleProRes4444 = 'ap4h',\n}\n\n/**\n * This option specifies the stabilization mode to use when recording a video.\n * @platform ios\n */\nexport enum VideoStabilization {\n off = 'off',\n standard = 'standard',\n cinematic = 'cinematic',\n auto = 'auto',\n}\n\n// @docsMissing\nexport enum VideoQuality {\n '2160p' = '2160p',\n '1080p' = '1080p',\n '720p' = '720p',\n '480p' = '480p',\n '4:3' = '4:3',\n}\n\nexport enum CameraOrientation {\n portrait = 1,\n portraitUpsideDown = 2,\n landscapeLeft = 3,\n landscapeRight = 4,\n}\n\n// @docsMissing\n/**\n * @hidden We do not expose related web methods in docs.\n * @platform web\n */\nexport type ImageSize = {\n width: number;\n height: number;\n};\n\n// @docsMissing\n/**\n * @hidden We do not expose related web methods in docs.\n * @platform web\n */\nexport type WebCameraSettings = {\n autoFocus?: string;\n flashMode?: string;\n whiteBalance?: string;\n exposureCompensation?: number;\n colorTemperature?: number;\n iso?: number;\n brightness?: number;\n contrast?: number;\n saturation?: number;\n sharpness?: number;\n focusDistance?: number;\n zoom?: number;\n};\n\n// @needsAudit\nexport type CameraCapturedPicture = {\n /**\n * Captured image width.\n */\n width: number;\n /**\n * Captured image height.\n */\n height: number;\n /**\n * On web, the value of `uri` is the same as `base64` because file system URLs are not supported in the browser.\n */\n uri: string;\n /**\n * A Base64 representation of the image.\n */\n base64?: string;\n /**\n * On Android and iOS this object may include various fields based on the device and operating system.\n * On web, it is a partial representation of the [`MediaTrackSettings`](https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackSettings) dictionary.\n */\n exif?: Partial<MediaTrackSettings> | any;\n};\n\n// @needsAudit\nexport type CameraPictureOptions = {\n /**\n * Specify the quality of compression, from 0 to 1. 0 means compress for small size, 1 means compress for maximum quality.\n */\n quality?: number;\n /**\n * Whether to also include the image data in Base64 format.\n */\n base64?: boolean;\n /**\n * Whether to also include the EXIF data for the image.\n */\n exif?: boolean;\n /**\n * Additional EXIF data to be included for the image. Only useful when `exif` option is set to `true`.\n * @platform android\n * @platform ios\n */\n additionalExif?: { [name: string]: any };\n /**\n * A callback invoked when picture is saved. If set, the promise of this method will resolve immediately with no data after picture is captured.\n * The data that it should contain will be passed to this callback. If displaying or processing a captured photo right after taking it\n * is not your case, this callback lets you skip waiting for it to be saved.\n * @param picture\n */\n onPictureSaved?: (picture: CameraCapturedPicture) => void;\n // TODO(Bacon): Is it possible to implement this in the browser?\n /**\n * If set to `true`, camera skips orientation adjustment and returns an image straight from the device's camera.\n * If enabled, `quality` option is discarded (processing pipeline is skipped as a whole).\n * Although enabling this option reduces image delivery time significantly, it may cause the image to appear in a wrong orientation\n * in the `Image` component (at the time of writing, it does not respect EXIF orientation of the images).\n * > **Note**: Enabling `skipProcessing` would cause orientation uncertainty. `Image` component does not respect EXIF\n * > stored orientation information, that means obtained image would be displayed wrongly (rotated by 90°, 180° or 270°).\n * > Different devices provide different orientations. For example some Sony Xperia or Samsung devices don't provide\n * > correctly oriented images by default. To always obtain correctly oriented image disable `skipProcessing` option.\n */\n skipProcessing?: boolean;\n /**\n * @platform web\n */\n scale?: number;\n /**\n * @platform web\n */\n imageType?: ImageType;\n /**\n * @platform web\n */\n isImageMirror?: boolean;\n /**\n * @hidden\n */\n id?: number;\n /**\n * @hidden\n */\n fastMode?: boolean;\n /**\n * @hidden\n */\n maxDownsampling?: number;\n};\n\n// @needsAudit\nexport type CameraRecordingOptions = {\n /**\n * Maximum video duration in seconds.\n */\n maxDuration?: number;\n /**\n * Maximum video file size in bytes.\n */\n maxFileSize?: number;\n /**\n * Specify the quality of recorded video. Use one of [`VideoQuality.<value>`](#videoquality).\n * Possible values: for 16:9 resolution `2160p`, `1080p`, `720p`, `480p` : `Android only` and for 4:3 `4:3` (the size is 640x480).\n * If the chosen quality is not available for a device, the highest available is chosen.\n */\n quality?: number | string;\n /**\n * If present, video will be recorded with no sound.\n */\n mute?: boolean;\n /**\n * If `true`, the recorded video will be flipped along the vertical axis. iOS flips videos recorded with the front camera by default,\n * but you can reverse that back by setting this to `true`. On Android, this is handled in the user's device settings.\n * @platform ios\n */\n mirror?: boolean;\n /**\n * Only works if `useCamera2Api` is set to `true`. This option specifies a desired video bitrate. For example, `5*1000*1000` would be 5Mbps.\n * @platform android\n */\n videoBitrate?: number;\n /**\n * This option specifies what codec to use when recording the video. See [`VideoCodec`](#videocodec) for the possible values.\n * @platform ios\n */\n codec?: VideoCodec;\n};\n\n/**\n * @hidden\n */\nexport type PictureSavedListener = (event: {\n nativeEvent: { data: CameraCapturedPicture; id: number };\n}) => void;\n\n/**\n * @hidden\n */\nexport type CameraReadyListener = () => void;\n\n/**\n * @hidden\n */\nexport type ResponsiveOrientationChangedListener = (event: {\n nativeEvent: ResponsiveOrientationChanged;\n}) => void;\n\nexport type ResponsiveOrientationChanged = { orientation: CameraOrientation };\n\n/**\n * @hidden\n */\nexport type MountErrorListener = (event: { nativeEvent: CameraMountError }) => void;\n\n// @docsMissing\nexport type CameraMountError = { message: string };\n\n// @docsMissing\nexport type Point = {\n x: number;\n y: number;\n};\n\nexport type BarCodeSize = {\n /**\n * The height value.\n */\n height: number;\n /**\n * The width value.\n */\n width: number;\n};\n\n/**\n * These coordinates are represented in the coordinate space of the camera source (e.g. when you\n * are using the camera view, these values are adjusted to the dimensions of the view).\n */\nexport type BarCodePoint = Point;\n\nexport type BarCodeBounds = {\n /**\n * The origin point of the bounding box.\n */\n origin: BarCodePoint;\n /**\n * The size of the bounding box.\n */\n size: BarCodeSize;\n};\n\n// @needsAudit\nexport type BarCodeScanningResult = {\n /**\n * The barcode type.\n */\n type: string;\n /**\n * The information encoded in the bar code.\n */\n data: string;\n /**\n * Corner points of the bounding box.\n * `cornerPoints` is not always available and may be empty. On iOS, for `code39` and `pdf417`\n * you don't get this value.\n */\n cornerPoints: BarCodePoint[];\n /**\n * The [BarCodeBounds](#barcodebounds) object.\n * `bounds` in some case will be representing an empty rectangle.\n * Moreover, `bounds` doesn't have to bound the whole barcode.\n * For some types, they will represent the area used by the scanner.\n */\n bounds: BarCodeBounds;\n};\n\nexport type FaceDetectionResult = {\n /**\n * Array of objects representing results of face detection.\n * See [`FaceFeature`](facedetector/#facefeature) in FaceDetector documentation for more details.\n */\n faces: object[];\n};\n\n/**\n * @hidden\n */\nexport type ConstantsType = {\n Type: CameraType;\n FlashMode: FlashMode;\n AutoFocus: AutoFocus;\n WhiteBalance: WhiteBalance;\n VideoQuality: VideoQuality;\n VideoStabilization: VideoStabilization;\n VideoCodec: VideoCodec;\n};\n\n// @needsAudit\nexport type CameraProps = ViewProps & {\n /**\n * Camera facing. Use one of `CameraType`. When `CameraType.front`, use the front-facing camera.\n * When `CameraType.back`, use the back-facing camera.\n * @default CameraType.back\n */\n type?: number | CameraType;\n /**\n * Camera flash mode. Use one of [`FlashMode.<value>`](#flashmode-1). When `FlashMode.on`, the flash on your device will\n * turn on when taking a picture, when `FlashMode.off`, it won't. Setting to `FlashMode.auto` will fire flash if required,\n * `FlashMode.torch` turns on flash during the preview.\n * @default FlashMode.off\n */\n flashMode?: number | FlashMode;\n /**\n * Camera white balance. Use one of [`WhiteBalance.<value>`](#whitebalance). If a device does not support any of these values previous one is used.\n * @default WhiteBalance.auto\n */\n whiteBalance?: number | WhiteBalance;\n /**\n * State of camera auto focus. Use one of [`AutoFocus.<value>`](#autofocus-1). When `AutoFocus.on`,\n * auto focus will be enabled, when `AutoFocus.off`, it won't and focus will lock as it was in the moment of change,\n * but it can be adjusted on some devices via `focusDepth` prop.\n * @default AutoFocus.on\n */\n autoFocus?: boolean | number | AutoFocus;\n /**\n * A value between `0` and `1` being a percentage of device's max zoom. `0` - not zoomed, `1` - maximum zoom.\n * @default 0\n */\n zoom?: number;\n /**\n * A string representing aspect ratio of the preview, eg. `4:3`, `16:9`, `1:1`. To check if a ratio is supported\n * by the device use [`getSupportedRatiosAsync`](#getsupportedratiosasync).\n * @default 4:3\n * @platform android\n */\n ratio?: string;\n /**\n * Distance to plane of the sharpest focus. A value between `0` and `1` where: `0` - infinity focus, `1` - focus as close as possible.\n * For Android this is available only for some devices and when `useCamera2Api` is set to `true`.\n * @default 0\n */\n focusDepth?: number;\n /**\n * Callback invoked when camera preview has been set.\n */\n onCameraReady?: () => void;\n /**\n * Whether to use Android's Camera2 API. See `Note` at the top of this page.\n * @platform android\n */\n useCamera2Api?: boolean;\n /**\n * A string representing the size of pictures [`takePictureAsync`](#takepictureasyncoptions) will take.\n * Available sizes can be fetched with [`getAvailablePictureSizesAsync`](#getavailablepicturesizesasyncratio).\n */\n pictureSize?: string;\n /**\n * The video stabilization mode used for a video recording. Use one of [`VideoStabilization.<value>`](#videostabilization).\n * You can read more about each stabilization type in [Apple Documentation](https://developer.apple.com/documentation/avfoundation/avcapturevideostabilizationmode).\n * @platform ios\n */\n videoStabilizationMode?: VideoStabilization;\n /**\n * Callback invoked when camera preview could not been started.\n * @param event Error object that contains a `message`.\n */\n onMountError?: (event: CameraMountError) => void;\n /**\n * Settings exposed by [`BarCodeScanner`](bar-code-scanner) module. Supported settings: **barCodeTypes**.\n * @example\n * ```tsx\n * <Camera\n * barCodeScannerSettings={{\n * barCodeTypes: [BarCodeScanner.Constants.BarCodeType.qr],\n * }}\n * />\n * ```\n */\n barCodeScannerSettings?: BarCodeSettings;\n /**\n * Callback that is invoked when a bar code has been successfully scanned. The callback is provided with\n * an object of the [`BarCodeScanningResult`](#barcodescanningresult) shape, where the `type`\n * refers to the bar code type that was scanned and the `data` is the information encoded in the bar code\n * (in this case of QR codes, this is often a URL). See [`BarCodeScanner.Constants.BarCodeType`](bar-code-scanner#supported-formats)\n * for supported values.\n * @param scanningResult\n */\n onBarCodeScanned?: (scanningResult: BarCodeScanningResult) => void;\n /**\n * A settings object passed directly to an underlying module providing face detection features.\n * See [`DetectionOptions`](facedetector/#detectionoptions) in FaceDetector documentation for details.\n */\n faceDetectorSettings?: object;\n /**\n * Callback invoked with results of face detection on the preview.\n * See [`DetectionResult`](facedetector/#detectionresult) in FaceDetector documentation for more details.\n * @param faces\n */\n onFacesDetected?: (faces: FaceDetectionResult) => void;\n /**\n * A URL for an image to be shown while the camera is loading.\n * @platform web\n */\n poster?: string;\n /**\n * Whether to allow responsive orientation of the camera when the screen orientation is locked (i.e. when set to `true`\n * landscape photos will be taken if the device is turned that way, even if the app or device orientation is locked to portrait)\n * @platform ios\n */\n responsiveOrientationWhenOrientationLocked?: boolean;\n /**\n * Callback invoked when responsive orientation changes. Only applicable if `responsiveOrientationWhenOrientationLocked` is `true`\n * @param event result object that contains updated orientation of camera\n * @platform ios\n */\n onResponsiveOrientationChanged?: (event: ResponsiveOrientationChanged) => void;\n};\n\n/**\n * @hidden\n */\nexport type CameraNativeProps = {\n pointerEvents?: any;\n style?: any;\n ref?: Function;\n onCameraReady?: CameraReadyListener;\n onMountError?: MountErrorListener;\n onBarCodeScanned?: (event: { nativeEvent: BarCodeScanningResult }) => void;\n onFacesDetected?: (event: { nativeEvent: FaceDetectionResult }) => void;\n onFaceDetectionError?: (event: { nativeEvent: Error }) => void;\n onPictureSaved?: PictureSavedListener;\n onResponsiveOrientationChanged?: ResponsiveOrientationChangedListener;\n type?: number | string;\n flashMode?: number | string;\n autoFocus?: string | boolean | number;\n focusDepth?: number;\n zoom?: number;\n whiteBalance?: number | string;\n pictureSize?: string;\n barCodeScannerSettings?: BarCodeSettings;\n faceDetectorSettings?: object;\n barCodeScannerEnabled?: boolean;\n faceDetectorEnabled?: boolean;\n ratio?: string;\n useCamera2Api?: boolean;\n poster?: string;\n responsiveOrientationWhenOrientationLocked?: boolean;\n};\n\n// @docsMissing\nexport type BarCodeSettings = {\n barCodeTypes: string[];\n interval?: number;\n};\n\nexport { PermissionResponse, PermissionStatus, PermissionExpiration, PermissionHookOptions };\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExponentCameraManager.web.d.ts","sourceRoot":"","sources":["../src/ExponentCameraManager.web.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EAEpB,kBAAkB,EAEnB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"ExponentCameraManager.web.d.ts","sourceRoot":"","sources":["../src/ExponentCameraManager.web.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EAEpB,kBAAkB,EAEnB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;wBA6J7B,QAAQ,OAAO,CAAC;yBAI/B,oBAAoB,UACrB,iBAAiB,GACxB,QAAQ,qBAAqB,CAAC;yBAGN,iBAAiB,GAAG,QAAQ,IAAI,CAAC;0BAGhC,iBAAiB,GAAG,QAAQ,IAAI,CAAC;oCAGvB,QAAQ,MAAM,EAAE,CAAC;oCAYjB,MAAM,UAAU,iBAAiB,GAAG,QAAQ,MAAM,EAAE,CAAC;2BAe9D,QAAQ,kBAAkB,CAAC;+BAGvB,QAAQ,kBAAkB,CAAC;iCAGzB,QAAQ,kBAAkB,CAAC;qCAGvB,QAAQ,kBAAkB,CAAC;qCAG3B,QAAQ,kBAAkB,CAAC;yCAGvB,QAAQ,kBAAkB,CAAC;;AAhGxE,wBA+GE"}
|
|
@@ -66,29 +66,43 @@ async function handlePermissionsQueryAsync(query) {
|
|
|
66
66
|
if (!navigator?.permissions?.query) {
|
|
67
67
|
throw new UnavailabilityError('expo-camera', 'navigator.permissions API is not available');
|
|
68
68
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
69
|
+
try {
|
|
70
|
+
const { state } = await navigator.permissions.query({ name: query });
|
|
71
|
+
switch (state) {
|
|
72
|
+
case 'prompt':
|
|
73
|
+
return {
|
|
74
|
+
status: PermissionStatus.UNDETERMINED,
|
|
75
|
+
expires: 'never',
|
|
76
|
+
canAskAgain: true,
|
|
77
|
+
granted: false,
|
|
78
|
+
};
|
|
79
|
+
case 'granted':
|
|
80
|
+
return {
|
|
81
|
+
status: PermissionStatus.GRANTED,
|
|
82
|
+
expires: 'never',
|
|
83
|
+
canAskAgain: true,
|
|
84
|
+
granted: true,
|
|
85
|
+
};
|
|
86
|
+
case 'denied':
|
|
87
|
+
return {
|
|
88
|
+
status: PermissionStatus.DENIED,
|
|
89
|
+
expires: 'never',
|
|
90
|
+
canAskAgain: true,
|
|
91
|
+
granted: false,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
catch (e) {
|
|
96
|
+
// Firefox doesn't support querying for the camera permission, so return undetermined status
|
|
97
|
+
if (e instanceof TypeError) {
|
|
72
98
|
return {
|
|
73
99
|
status: PermissionStatus.UNDETERMINED,
|
|
74
100
|
expires: 'never',
|
|
75
101
|
canAskAgain: true,
|
|
76
102
|
granted: false,
|
|
77
103
|
};
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
status: PermissionStatus.GRANTED,
|
|
81
|
-
expires: 'never',
|
|
82
|
-
canAskAgain: true,
|
|
83
|
-
granted: true,
|
|
84
|
-
};
|
|
85
|
-
case 'denied':
|
|
86
|
-
return {
|
|
87
|
-
status: PermissionStatus.DENIED,
|
|
88
|
-
expires: 'never',
|
|
89
|
-
canAskAgain: true,
|
|
90
|
-
granted: false,
|
|
91
|
-
};
|
|
104
|
+
}
|
|
105
|
+
throw e;
|
|
92
106
|
}
|
|
93
107
|
}
|
|
94
108
|
export default {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExponentCameraManager.web.js","sourceRoot":"","sources":["../src/ExponentCameraManager.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAExD,OAAO,EAGL,UAAU,EAEV,gBAAgB,GACjB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,eAAe,EACf,0BAA0B,EAC1B,2BAA2B,GAC5B,MAAM,uBAAuB,CAAC;AAE/B,SAAS,YAAY,CAAC,WAAmC;IACvD,IAAI,SAAS,CAAC,YAAY,IAAI,SAAS,CAAC,YAAY,CAAC,YAAY,EAAE;QACjE,OAAO,SAAS,CAAC,YAAY,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC;KACzD;IAED,iFAAiF;IACjF,+DAA+D;IAC/D,oEAAoE;IAEpE,yDAAyD;IACzD,MAAM,YAAY;IAChB,yHAAyH;IACzH,SAAS,CAAC,YAAY;QACtB,SAAS,CAAC,kBAAkB;QAC5B,SAAS,CAAC,eAAe;QACzB;YACE,MAAM,KAAK,GAAQ,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;YACzD,KAAK,CAAC,IAAI,GAAG,CAAC,CAAC;YACf,KAAK,CAAC,IAAI,GAAG,iBAAiB,CAAC;YAC/B,MAAM,KAAK,CAAC;QACd,CAAC,CAAC;IAEJ,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,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zC,CAAC;IACD,KAAK,CAAC,6BAA6B;QACjC,OAAO,2BAA2B,CAAC,YAAY,CAAC,CAAC;IACnD,CAAC;IACD,KAAK,CAAC,iCAAiC;QACrC,IAAI;YACF,MAAM,YAAY,CAAC;gBACjB,KAAK,EAAE,IAAI;aACZ,CAAC,CAAC;YACH,OAAO;gBACL,MAAM,EAAE,gBAAgB,CAAC,OAAO;gBAChC,OAAO,EAAE,OAAO;gBAChB,WAAW,EAAE,IAAI;gBACjB,OAAO,EAAE,IAAI;aACd,CAAC;SACH;QAAC,OAAO,EAAE,OAAO,EAAE,EAAE;YACpB,OAAO,uBAAuB,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;SAC7C;IACH,CAAC;CACF,CAAC","sourcesContent":["import { UnavailabilityError } from 'expo-modules-core';\n\nimport {\n CameraCapturedPicture,\n CameraPictureOptions,\n CameraType,\n PermissionResponse,\n PermissionStatus,\n} from './Camera.types';\nimport { ExponentCameraRef } from './ExponentCamera.web';\nimport {\n canGetUserMedia,\n isBackCameraAvailableAsync,\n isFrontCameraAvailableAsync,\n} from './WebUserMediaManager';\n\nfunction getUserMedia(constraints: MediaStreamConstraints): Promise<MediaStream> {\n if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {\n return navigator.mediaDevices.getUserMedia(constraints);\n }\n\n // Some browsers partially implement mediaDevices. We can't just assign an object\n // with getUserMedia as it would overwrite existing properties.\n // Here, we will just add the getUserMedia property if it's missing.\n\n // First get ahold of the legacy getUserMedia, if present\n const getUserMedia =\n // TODO: this method is deprecated, migrate to https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia\n navigator.getUserMedia ||\n navigator.webkitGetUserMedia ||\n navigator.mozGetUserMedia ||\n function () {\n const error: any = new Error('Permission unimplemented');\n error.code = 0;\n error.name = 'NotAllowedError';\n throw error;\n };\n\n return new Promise((resolve, reject) => {\n getUserMedia.call(navigator, constraints, resolve, reject);\n });\n}\n\nfunction handleGetUserMediaError({ message }: { message: string }): PermissionResponse {\n // name: NotAllowedError\n // code: 0\n if (message === 'Permission dismissed') {\n return {\n status: PermissionStatus.UNDETERMINED,\n expires: 'never',\n canAskAgain: true,\n granted: false,\n };\n } else {\n // TODO: Bacon: [OSX] The system could deny access to chrome.\n // TODO: Bacon: add: { status: 'unimplemented' }\n return {\n status: PermissionStatus.DENIED,\n expires: 'never',\n canAskAgain: true,\n granted: false,\n };\n }\n}\n\nasync function handleRequestPermissionsAsync(): Promise<PermissionResponse> {\n try {\n await getUserMedia({\n video: true,\n });\n return {\n status: PermissionStatus.GRANTED,\n expires: 'never',\n canAskAgain: true,\n granted: true,\n };\n } catch ({ message }) {\n return handleGetUserMediaError({ message });\n }\n}\n\nasync function handlePermissionsQueryAsync(\n query: 'camera' | 'microphone'\n): Promise<PermissionResponse> {\n if (!navigator?.permissions?.query) {\n throw new UnavailabilityError('expo-camera', 'navigator.permissions API is not available');\n }\n\n const { state } = await navigator.permissions.query({ name: query });\n switch (state) {\n case 'prompt':\n return {\n status: PermissionStatus.UNDETERMINED,\n expires: 'never',\n canAskAgain: true,\n granted: false,\n };\n case 'granted':\n return {\n status: PermissionStatus.GRANTED,\n expires: 'never',\n canAskAgain: true,\n granted: true,\n };\n case 'denied':\n return {\n status: PermissionStatus.DENIED,\n expires: 'never',\n canAskAgain: true,\n granted: false,\n };\n }\n}\n\nexport default {\n get name(): string {\n return 'ExponentCameraManager';\n },\n get Type() {\n return {\n back: 'back',\n front: 'front',\n };\n },\n get FlashMode() {\n return {\n on: 'on',\n off: 'off',\n auto: 'auto',\n torch: 'torch',\n };\n },\n get AutoFocus() {\n return {\n on: 'on',\n off: 'off',\n auto: 'auto',\n singleShot: 'singleShot',\n };\n },\n get WhiteBalance() {\n return {\n auto: 'auto',\n continuous: 'continuous',\n manual: 'manual',\n };\n },\n get VideoQuality() {\n return {};\n },\n get VideoStabilization() {\n return {};\n },\n async isAvailableAsync(): Promise<boolean> {\n return canGetUserMedia();\n },\n async takePicture(\n options: CameraPictureOptions,\n camera: ExponentCameraRef\n ): Promise<CameraCapturedPicture> {\n return await camera.takePicture(options);\n },\n async pausePreview(camera: ExponentCameraRef): Promise<void> {\n await camera.pausePreview();\n },\n async resumePreview(camera: ExponentCameraRef): Promise<void> {\n return await camera.resumePreview();\n },\n async getAvailableCameraTypesAsync(): Promise<string[]> {\n if (!canGetUserMedia() || !navigator.mediaDevices.enumerateDevices) return [];\n\n const devices = await navigator.mediaDevices.enumerateDevices();\n\n const types: (string | null)[] = await Promise.all([\n (await isFrontCameraAvailableAsync(devices)) && CameraType.front,\n (await isBackCameraAvailableAsync()) && CameraType.back,\n ]);\n\n return types.filter(Boolean) as string[];\n },\n async getAvailablePictureSizes(ratio: string, camera: ExponentCameraRef): Promise<string[]> {\n return await camera.getAvailablePictureSizes(ratio);\n },\n /* async getSupportedRatios(camera: ExponentCameraRef): Promise<string[]> {\n // TODO: Support on web\n },\n async record(\n options?: CameraRecordingOptions,\n camera: ExponentCameraRef\n ): Promise<{ uri: string }> {\n // TODO: Support on web\n },\n async stopRecording(camera: ExponentCameraRef): Promise<void> {\n // TODO: Support on web\n }, */\n async getPermissionsAsync(): Promise<PermissionResponse> {\n return handlePermissionsQueryAsync('camera');\n },\n async requestPermissionsAsync(): Promise<PermissionResponse> {\n return handleRequestPermissionsAsync();\n },\n async getCameraPermissionsAsync(): Promise<PermissionResponse> {\n return handlePermissionsQueryAsync('camera');\n },\n async requestCameraPermissionsAsync(): Promise<PermissionResponse> {\n return handleRequestPermissionsAsync();\n },\n async getMicrophonePermissionsAsync(): Promise<PermissionResponse> {\n return handlePermissionsQueryAsync('microphone');\n },\n async requestMicrophonePermissionsAsync(): Promise<PermissionResponse> {\n try {\n await getUserMedia({\n audio: true,\n });\n return {\n status: PermissionStatus.GRANTED,\n expires: 'never',\n canAskAgain: true,\n granted: true,\n };\n } catch ({ message }) {\n return handleGetUserMediaError({ message });\n }\n },\n};\n"]}
|
|
1
|
+
{"version":3,"file":"ExponentCameraManager.web.js","sourceRo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AI;YACF,MAAM,YAAY,CAAC;gBACjB,KAAK,EAAE,IAAI;aACZ,CAAC,CAAC;YACH,OAAO;gBACL,MAAM,EAAE,gBAAgB,CAAC,OAAO;gBAChC,OAAO,EAAE,OAAO;gBAChB,WAAW,EAAE,IAAI;gBACjB,OAAO,EAAE,IAAI;aACd,CAAC;SACH;QAAC,OAAO,EAAE,OAAO,EAAE,EAAE;YACpB,OAAO,uBAAuB,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;SAC7C;IACH,CAAC;CACF,CAAC","sourcesContent":["import { UnavailabilityError } from 'expo-modules-core';\n\nimport {\n CameraCapturedPicture,\n CameraPictureOptions,\n CameraType,\n PermissionResponse,\n PermissionStatus,\n} from './Camera.types';\nimport { ExponentCameraRef } from './ExponentCamera.web';\nimport {\n canGetUserMedia,\n isBackCameraAvailableAsync,\n isFrontCameraAvailableAsync,\n} from './WebUserMediaManager';\n\nfunction getUserMedia(constraints: MediaStreamConstraints): Promise<MediaStream> {\n if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {\n return navigator.mediaDevices.getUserMedia(constraints);\n }\n\n // Some browsers partially implement mediaDevices. We can't just assign an object\n // with getUserMedia as it would overwrite existing properties.\n // Here, we will just add the getUserMedia property if it's missing.\n\n // First get ahold of the legacy getUserMedia, if present\n const getUserMedia =\n // TODO: this method is deprecated, migrate to https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia\n navigator.getUserMedia ||\n navigator.webkitGetUserMedia ||\n navigator.mozGetUserMedia ||\n function () {\n const error: any = new Error('Permission unimplemented');\n error.code = 0;\n error.name = 'NotAllowedError';\n throw error;\n };\n\n return new Promise((resolve, reject) => {\n getUserMedia.call(navigator, constraints, resolve, reject);\n });\n}\n\nfunction handleGetUserMediaError({ message }: { message: string }): PermissionResponse {\n // name: NotAllowedError\n // code: 0\n if (message === 'Permission dismissed') {\n return {\n status: PermissionStatus.UNDETERMINED,\n expires: 'never',\n canAskAgain: true,\n granted: false,\n };\n } else {\n // TODO: Bacon: [OSX] The system could deny access to chrome.\n // TODO: Bacon: add: { status: 'unimplemented' }\n return {\n status: PermissionStatus.DENIED,\n expires: 'never',\n canAskAgain: true,\n granted: false,\n };\n }\n}\n\nasync function handleRequestPermissionsAsync(): Promise<PermissionResponse> {\n try {\n await getUserMedia({\n video: true,\n });\n return {\n status: PermissionStatus.GRANTED,\n expires: 'never',\n canAskAgain: true,\n granted: true,\n };\n } catch ({ message }) {\n return handleGetUserMediaError({ message });\n }\n}\n\nasync function handlePermissionsQueryAsync(\n query: 'camera' | 'microphone'\n): Promise<PermissionResponse> {\n if (!navigator?.permissions?.query) {\n throw new UnavailabilityError('expo-camera', 'navigator.permissions API is not available');\n }\n\n try {\n const { state } = await navigator.permissions.query({ name: query });\n switch (state) {\n case 'prompt':\n return {\n status: PermissionStatus.UNDETERMINED,\n expires: 'never',\n canAskAgain: true,\n granted: false,\n };\n case 'granted':\n return {\n status: PermissionStatus.GRANTED,\n expires: 'never',\n canAskAgain: true,\n granted: true,\n };\n case 'denied':\n return {\n status: PermissionStatus.DENIED,\n expires: 'never',\n canAskAgain: true,\n granted: false,\n };\n }\n } catch (e) {\n // Firefox doesn't support querying for the camera permission, so return undetermined status\n if (e instanceof TypeError) {\n return {\n status: PermissionStatus.UNDETERMINED,\n expires: 'never',\n canAskAgain: true,\n granted: false,\n };\n }\n throw e;\n }\n}\n\nexport default {\n get name(): string {\n return 'ExponentCameraManager';\n },\n get Type() {\n return {\n back: 'back',\n front: 'front',\n };\n },\n get FlashMode() {\n return {\n on: 'on',\n off: 'off',\n auto: 'auto',\n torch: 'torch',\n };\n },\n get AutoFocus() {\n return {\n on: 'on',\n off: 'off',\n auto: 'auto',\n singleShot: 'singleShot',\n };\n },\n get WhiteBalance() {\n return {\n auto: 'auto',\n continuous: 'continuous',\n manual: 'manual',\n };\n },\n get VideoQuality() {\n return {};\n },\n get VideoStabilization() {\n return {};\n },\n async isAvailableAsync(): Promise<boolean> {\n return canGetUserMedia();\n },\n async takePicture(\n options: CameraPictureOptions,\n camera: ExponentCameraRef\n ): Promise<CameraCapturedPicture> {\n return await camera.takePicture(options);\n },\n async pausePreview(camera: ExponentCameraRef): Promise<void> {\n await camera.pausePreview();\n },\n async resumePreview(camera: ExponentCameraRef): Promise<void> {\n return await camera.resumePreview();\n },\n async getAvailableCameraTypesAsync(): Promise<string[]> {\n if (!canGetUserMedia() || !navigator.mediaDevices.enumerateDevices) return [];\n\n const devices = await navigator.mediaDevices.enumerateDevices();\n\n const types: (string | null)[] = await Promise.all([\n (await isFrontCameraAvailableAsync(devices)) && CameraType.front,\n (await isBackCameraAvailableAsync()) && CameraType.back,\n ]);\n\n return types.filter(Boolean) as string[];\n },\n async getAvailablePictureSizes(ratio: string, camera: ExponentCameraRef): Promise<string[]> {\n return await camera.getAvailablePictureSizes(ratio);\n },\n /* async getSupportedRatios(camera: ExponentCameraRef): Promise<string[]> {\n // TODO: Support on web\n },\n async record(\n options?: CameraRecordingOptions,\n camera: ExponentCameraRef\n ): Promise<{ uri: string }> {\n // TODO: Support on web\n },\n async stopRecording(camera: ExponentCameraRef): Promise<void> {\n // TODO: Support on web\n }, */\n async getPermissionsAsync(): Promise<PermissionResponse> {\n return handlePermissionsQueryAsync('camera');\n },\n async requestPermissionsAsync(): Promise<PermissionResponse> {\n return handleRequestPermissionsAsync();\n },\n async getCameraPermissionsAsync(): Promise<PermissionResponse> {\n return handlePermissionsQueryAsync('camera');\n },\n async requestCameraPermissionsAsync(): Promise<PermissionResponse> {\n return handleRequestPermissionsAsync();\n },\n async getMicrophonePermissionsAsync(): Promise<PermissionResponse> {\n return handlePermissionsQueryAsync('microphone');\n },\n async requestMicrophonePermissionsAsync(): Promise<PermissionResponse> {\n try {\n await getUserMedia({\n audio: true,\n });\n return {\n status: PermissionStatus.GRANTED,\n expires: 'never',\n canAskAgain: true,\n granted: true,\n };\n } catch ({ message }) {\n return handleGetUserMediaError({ message });\n }\n },\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-camera",
|
|
3
|
-
"version": "13.
|
|
3
|
+
"version": "13.5.0",
|
|
4
4
|
"description": "A React component that renders a preview for the device's either front or back camera. Camera's parameters like zoom, auto focus, white balance and flash mode are adjustable. With expo-camera, one can also take photos and record videos that are saved to the app's cache. Morever, the component is also capable of detecting faces and bar codes appearing on the preview.",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -43,5 +43,5 @@
|
|
|
43
43
|
"peerDependencies": {
|
|
44
44
|
"expo": "*"
|
|
45
45
|
},
|
|
46
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "663654577a7068c641b5e9474efbc502e3f334ea"
|
|
47
47
|
}
|
package/src/Camera.types.ts
CHANGED
|
@@ -434,8 +434,8 @@ export type CameraProps = ViewProps & {
|
|
|
434
434
|
*/
|
|
435
435
|
useCamera2Api?: boolean;
|
|
436
436
|
/**
|
|
437
|
-
* A string representing the size of pictures [`takePictureAsync`](#
|
|
438
|
-
* Available sizes can be fetched with [`getAvailablePictureSizesAsync`](#
|
|
437
|
+
* A string representing the size of pictures [`takePictureAsync`](#takepictureasyncoptions) will take.
|
|
438
|
+
* Available sizes can be fetched with [`getAvailablePictureSizesAsync`](#getavailablepicturesizesasyncratio).
|
|
439
439
|
*/
|
|
440
440
|
pictureSize?: string;
|
|
441
441
|
/**
|
|
@@ -86,29 +86,42 @@ async function handlePermissionsQueryAsync(
|
|
|
86
86
|
throw new UnavailabilityError('expo-camera', 'navigator.permissions API is not available');
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
89
|
+
try {
|
|
90
|
+
const { state } = await navigator.permissions.query({ name: query });
|
|
91
|
+
switch (state) {
|
|
92
|
+
case 'prompt':
|
|
93
|
+
return {
|
|
94
|
+
status: PermissionStatus.UNDETERMINED,
|
|
95
|
+
expires: 'never',
|
|
96
|
+
canAskAgain: true,
|
|
97
|
+
granted: false,
|
|
98
|
+
};
|
|
99
|
+
case 'granted':
|
|
100
|
+
return {
|
|
101
|
+
status: PermissionStatus.GRANTED,
|
|
102
|
+
expires: 'never',
|
|
103
|
+
canAskAgain: true,
|
|
104
|
+
granted: true,
|
|
105
|
+
};
|
|
106
|
+
case 'denied':
|
|
107
|
+
return {
|
|
108
|
+
status: PermissionStatus.DENIED,
|
|
109
|
+
expires: 'never',
|
|
110
|
+
canAskAgain: true,
|
|
111
|
+
granted: false,
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
} catch (e) {
|
|
115
|
+
// Firefox doesn't support querying for the camera permission, so return undetermined status
|
|
116
|
+
if (e instanceof TypeError) {
|
|
92
117
|
return {
|
|
93
118
|
status: PermissionStatus.UNDETERMINED,
|
|
94
119
|
expires: 'never',
|
|
95
120
|
canAskAgain: true,
|
|
96
121
|
granted: false,
|
|
97
122
|
};
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
status: PermissionStatus.GRANTED,
|
|
101
|
-
expires: 'never',
|
|
102
|
-
canAskAgain: true,
|
|
103
|
-
granted: true,
|
|
104
|
-
};
|
|
105
|
-
case 'denied':
|
|
106
|
-
return {
|
|
107
|
-
status: PermissionStatus.DENIED,
|
|
108
|
-
expires: 'never',
|
|
109
|
-
canAskAgain: true,
|
|
110
|
-
granted: false,
|
|
111
|
-
};
|
|
123
|
+
}
|
|
124
|
+
throw e;
|
|
112
125
|
}
|
|
113
126
|
}
|
|
114
127
|
|