expo-camera 12.1.1 → 12.3.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.
Files changed (54) hide show
  1. package/CHANGELOG.md +33 -1
  2. package/README.md +3 -3
  3. package/android/build.gradle +27 -12
  4. package/android/src/main/java/expo/modules/camera/ExpoCameraView.kt +5 -5
  5. package/android/src/main/java/expo/modules/camera/tasks/BarCodeScannerAsyncTask.kt +2 -1
  6. package/build/Camera.d.ts +91 -6
  7. package/build/Camera.d.ts.map +1 -0
  8. package/build/Camera.js +95 -3
  9. package/build/Camera.js.map +1 -1
  10. package/build/Camera.types.d.ts +209 -76
  11. package/build/Camera.types.d.ts.map +1 -0
  12. package/build/Camera.types.js +32 -51
  13. package/build/Camera.types.js.map +1 -1
  14. package/build/ExponentCamera.d.ts +1 -0
  15. package/build/ExponentCamera.d.ts.map +1 -0
  16. package/build/ExponentCamera.web.d.ts +4 -1
  17. package/build/ExponentCamera.web.d.ts.map +1 -0
  18. package/build/ExponentCameraManager.d.ts +1 -0
  19. package/build/ExponentCameraManager.d.ts.map +1 -0
  20. package/build/ExponentCameraManager.web.d.ts +1 -0
  21. package/build/ExponentCameraManager.web.d.ts.map +1 -0
  22. package/build/WebCameraUtils.d.ts +3 -2
  23. package/build/WebCameraUtils.d.ts.map +1 -0
  24. package/build/WebCameraUtils.js.map +1 -1
  25. package/build/WebCapabilityUtils.d.ts +1 -0
  26. package/build/WebCapabilityUtils.d.ts.map +1 -0
  27. package/build/WebConstants.d.ts +1 -0
  28. package/build/WebConstants.d.ts.map +1 -0
  29. package/build/WebUserMediaManager.d.ts +1 -0
  30. package/build/WebUserMediaManager.d.ts.map +1 -0
  31. package/build/index.d.ts +3 -1
  32. package/build/index.d.ts.map +1 -0
  33. package/build/index.js +2 -1
  34. package/build/index.js.map +1 -1
  35. package/build/useWebCameraStream.d.ts +1 -0
  36. package/build/useWebCameraStream.d.ts.map +1 -0
  37. package/build/useWebQRScanner.d.ts +2 -2
  38. package/build/useWebQRScanner.d.ts.map +1 -0
  39. package/build/useWebQRScanner.js +3 -3
  40. package/build/useWebQRScanner.js.map +1 -1
  41. package/build/utils/props.d.ts +1 -0
  42. package/build/utils/props.d.ts.map +1 -0
  43. package/ios/EXCamera.xcframework/ios-arm64/EXCamera.framework/EXCamera +0 -0
  44. package/ios/EXCamera.xcframework/ios-arm64/EXCamera.framework/Info.plist +0 -0
  45. package/ios/EXCamera.xcframework/ios-arm64_x86_64-simulator/EXCamera.framework/EXCamera +0 -0
  46. package/ios/EXCamera.xcframework/ios-arm64_x86_64-simulator/EXCamera.framework/Info.plist +0 -0
  47. package/package.json +3 -3
  48. package/plugin/src/withCamera.ts +6 -4
  49. package/src/Camera.tsx +99 -26
  50. package/src/Camera.types.ts +217 -84
  51. package/src/WebCameraUtils.ts +4 -4
  52. package/src/index.ts +17 -4
  53. package/src/useWebQRScanner.ts +4 -5
  54. package/tsconfig.json +1 -1
package/CHANGELOG.md CHANGED
@@ -10,7 +10,39 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
- ## 12.1.1 — 2022-02-01
13
+ ## 12.3.0 — 2022-07-07
14
+
15
+ ### 🐛 Bug fixes
16
+
17
+ - On Web prevent the QR worker to be immediately cleaned up after finishing it's job to allow reusing it later (e.g. do not re-download every script upon repetitive worker launch). ([#15369](https://github.com/expo/expo/pull/15369) by [@jer-sen](https://github.com/jer-sen) and [#17833](https://github.com/expo/expo/pull/17833) by [@bbarthec](https://github.com/bbarthec))
18
+ - Fix bug on Android that would only allow you to scan one bar code. ([#17655](https://github.com/expo/expo/pull/17655) by [@witheroux](https://github.com/witheroux))
19
+
20
+ ## 12.2.0 — 2022-04-18
21
+
22
+ ### 🎉 New features
23
+
24
+ - Update `useWebQRScanner` to allow scanning QR codes with inverted colors (light foreground and dark background). ([#16106](https://github.com/expo/expo/pull/16106) by [@rissois](https://github.com/rissois))
25
+
26
+ ### 🐛 Bug fixes
27
+
28
+ - Fix crash on Android when app is restored from background by check for null value of `pendingFaceDetectorSettings`. ([#16543](https://github.com/expo/expo/pull/16543) by [@giautm](https://github.com/giautm))
29
+
30
+ ### 💡 Others
31
+
32
+ - Updated `@expo/config-plugins` from `4.0.2` to `4.0.14` ([#15621](https://github.com/expo/expo/pull/15621) by [@EvanBacon](https://github.com/EvanBacon))
33
+ - Replace `CapturedPicture` type with `CameraCapturedPicture` in events callback to avoid duplicated types. ([#15936](https://github.com/expo/expo/pull/15936) by [@Simek](https://github.com/Simek))
34
+
35
+ ### ⚠️ Notices
36
+
37
+ - On Android bump `compileSdkVersion` to `31`, `targetSdkVersion` to `31` and `Java` version to `11`. ([#16941](https://github.com/expo/expo/pull/16941) by [@bbarthec](https://github.com/bbarthec))
38
+
39
+ ## 12.1.2 - 2022-02-04
40
+
41
+ ### 🐛 Bug fixes
42
+
43
+ - Fix null pointer exception when barcode scanner or face detector are not installed. ([#16167](https://github.com/expo/expo/pull/16167) by [@tsapeta](https://github.com/tsapeta))
44
+
45
+ ## 12.1.1 - 2022-02-01
14
46
 
15
47
  ### 🐛 Bug fixes
16
48
 
package/README.md CHANGED
@@ -4,12 +4,12 @@ A React component that renders a preview for the device's either front or back c
4
4
 
5
5
  # API documentation
6
6
 
7
- - [Documentation for the master branch](https://github.com/expo/expo/blob/master/docs/pages/versions/unversioned/sdk/camera.md)
8
- - [Documentation for the latest stable release](https://docs.expo.io/versions/latest/sdk/camera/)
7
+ - [Documentation for the main branch](https://github.com/expo/expo/blob/main/docs/pages/versions/unversioned/sdk/camera.md)
8
+ - [Documentation for the latest stable release](https://docs.expo.dev/versions/latest/sdk/camera/)
9
9
 
10
10
  # Installation in managed Expo projects
11
11
 
12
- For managed [managed](https://docs.expo.io/versions/latest/introduction/managed-vs-bare/) Expo projects, please follow the installation instructions in the [API documentation for the latest stable release](https://docs.expo.io/versions/latest/sdk/camera/).
12
+ For [managed](https://docs.expo.dev/versions/latest/introduction/managed-vs-bare/) Expo projects, please follow the installation instructions in the [API documentation for the latest stable release](https://docs.expo.dev/versions/latest/sdk/camera/).
13
13
 
14
14
  # Installation in bare React Native projects
15
15
 
@@ -3,20 +3,35 @@ apply plugin: 'kotlin-android'
3
3
  apply plugin: 'maven-publish'
4
4
 
5
5
  group = 'host.exp.exponent'
6
- version = '12.1.1'
6
+ version = '12.3.0'
7
7
 
8
8
  buildscript {
9
+ def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
10
+ if (expoModulesCorePlugin.exists()) {
11
+ apply from: expoModulesCorePlugin
12
+ applyKotlinExpoModulesCorePlugin()
13
+ }
14
+
9
15
  // Simple helper that allows the root project to override versions declared by this library.
10
16
  ext.safeExtGet = { prop, fallback ->
11
17
  rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
12
18
  }
13
19
 
20
+ // Ensures backward compatibility
21
+ ext.getKotlinVersion = {
22
+ if (ext.has("kotlinVersion")) {
23
+ ext.kotlinVersion()
24
+ } else {
25
+ ext.safeExtGet("kotlinVersion", "1.6.10")
26
+ }
27
+ }
28
+
14
29
  repositories {
15
30
  mavenCentral()
16
31
  }
17
32
 
18
33
  dependencies {
19
- classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${safeExtGet('kotlinVersion', '1.4.21')}")
34
+ classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${getKotlinVersion()}")
20
35
  }
21
36
  }
22
37
 
@@ -44,22 +59,22 @@ afterEvaluate {
44
59
  }
45
60
 
46
61
  android {
47
- compileSdkVersion safeExtGet("compileSdkVersion", 30)
62
+ compileSdkVersion safeExtGet("compileSdkVersion", 31)
48
63
 
49
64
  compileOptions {
50
- sourceCompatibility JavaVersion.VERSION_1_8
51
- targetCompatibility JavaVersion.VERSION_1_8
65
+ sourceCompatibility JavaVersion.VERSION_11
66
+ targetCompatibility JavaVersion.VERSION_11
67
+ }
68
+
69
+ kotlinOptions {
70
+ jvmTarget = JavaVersion.VERSION_11.majorVersion
52
71
  }
53
72
 
54
73
  defaultConfig {
55
74
  minSdkVersion safeExtGet("minSdkVersion", 21)
56
- targetSdkVersion safeExtGet("targetSdkVersion", 30)
75
+ targetSdkVersion safeExtGet("targetSdkVersion", 31)
57
76
  versionCode 32
58
- versionName "12.1.1"
59
- }
60
-
61
- kotlinOptions {
62
- jvmTarget = JavaVersion.VERSION_1_8
77
+ versionName "12.3.0"
63
78
  }
64
79
 
65
80
  lintOptions {
@@ -80,5 +95,5 @@ dependencies {
80
95
  api "androidx.exifinterface:exifinterface:1.0.0"
81
96
  api 'com.google.android:cameraview:1.0.0'
82
97
 
83
- implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${safeExtGet('kotlinVersion', '1.4.21')}"
98
+ implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${getKotlinVersion()}"
84
99
  }
@@ -178,8 +178,8 @@ class ExpoCameraView(
178
178
  * Additionally supports [codabar, code128, maxicode, rss14, rssexpanded, upc_a, upc_ean]
179
179
  */
180
180
  private fun initBarCodeScanner() {
181
- val barCodeScannerProvider: BarCodeScannerProviderInterface by moduleRegistry()
182
- barCodeScanner = barCodeScannerProvider.createBarCodeDetectorWithContext(context)
181
+ val barCodeScannerProvider: BarCodeScannerProviderInterface? by moduleRegistry()
182
+ barCodeScanner = barCodeScannerProvider?.createBarCodeDetectorWithContext(context)
183
183
  }
184
184
 
185
185
  fun setShouldScanBarCodes(shouldScanBarCodes: Boolean) {
@@ -210,9 +210,9 @@ class ExpoCameraView(
210
210
  isNew = false
211
211
  if (!Build.FINGERPRINT.contains("generic")) {
212
212
  start()
213
- val faceDetectorProvider: FaceDetectorProviderInterface by moduleRegistry()
214
- faceDetector = faceDetectorProvider.createFaceDetectorWithContext(context)
215
- pendingFaceDetectorSettings.let {
213
+ val faceDetectorProvider: FaceDetectorProviderInterface? by moduleRegistry()
214
+ faceDetector = faceDetectorProvider?.createFaceDetectorWithContext(context)
215
+ pendingFaceDetectorSettings?.let {
216
216
  faceDetector?.setSettings(it)
217
217
  pendingFaceDetectorSettings = null
218
218
  }
@@ -21,6 +21,7 @@ class BarCodeScannerAsyncTask(
21
21
  super.onPostExecute(result)
22
22
  result?.let {
23
23
  delegate.onBarCodeScanned(result)
24
- } ?: delegate.onBarCodeScanningTaskCompleted()
24
+ }
25
+ delegate.onBarCodeScanningTaskCompleted()
25
26
  }
26
27
  }
package/build/Camera.d.ts CHANGED
@@ -1,9 +1,24 @@
1
1
  import * as React from 'react';
2
- import { BarCodeScanningResult, CameraCapturedPicture, CameraMountError, CameraNativeProps, CameraPictureOptions, CameraProps, CameraRecordingOptions, ConstantsType, FaceDetectionResult, PermissionExpiration, PermissionResponse, PermissionStatus, VideoCodec } from './Camera.types';
2
+ import { CameraCapturedPicture, CameraPictureOptions, CameraProps, CameraRecordingOptions, CameraType, ConstantsType, PermissionResponse, VideoCodec } from './Camera.types';
3
3
  export default class Camera extends React.Component<CameraProps> {
4
+ /**
5
+ * Check whether the current device has a camera. This is useful for web and simulators cases.
6
+ * This isn't influenced by the Permissions API (all platforms), or HTTP usage (in the browser).
7
+ * You will still need to check if the native permission has been accepted.
8
+ * @platform web
9
+ */
4
10
  static isAvailableAsync(): Promise<boolean>;
5
- static getAvailableCameraTypesAsync(): Promise<('front' | 'back')[]>;
6
- static getAvailableVideoCodecsAsync(): Promise<string[]>;
11
+ /**
12
+ * Returns a list of camera types `['front', 'back']`. This is useful for desktop browsers which only have front-facing cameras.
13
+ * @platform web
14
+ */
15
+ static getAvailableCameraTypesAsync(): Promise<CameraType[]>;
16
+ /**
17
+ * Queries the device for the available video codecs that can be used in video recording.
18
+ * @return A promise that resolves to a list of strings that represents available codecs.
19
+ * @platform ios
20
+ */
21
+ static getAvailableVideoCodecsAsync(): Promise<VideoCodec[]>;
7
22
  static Constants: ConstantsType;
8
23
  static ConversionTables: {
9
24
  type: Record<"front" | "back", string | number | undefined>;
@@ -13,14 +28,27 @@ export default class Camera extends React.Component<CameraProps> {
13
28
  };
14
29
  static defaultProps: CameraProps;
15
30
  /**
16
- * @deprecated Use `getCameraPermissionsAync` or `getMicrophonePermissionsAsync` instead.
31
+ * @deprecated Use `getCameraPermissionsAsync` or `getMicrophonePermissionsAsync` instead.
32
+ * Checks user's permissions for accessing camera.
17
33
  */
18
34
  static getPermissionsAsync(): Promise<PermissionResponse>;
19
35
  /**
36
+ * Asks the user to grant permissions for accessing camera.
37
+ * On iOS this will require apps to specify both `NSCameraUsageDescription` and `NSMicrophoneUsageDescription` entries in the **Info.plist**.
38
+ * @return A promise that resolves to an object of type [PermissionResponse](#permissionresponse).
20
39
  * @deprecated Use `requestCameraPermissionsAsync` or `requestMicrophonePermissionsAsync` instead.
21
40
  */
22
41
  static requestPermissionsAsync(): Promise<PermissionResponse>;
42
+ /**
43
+ * Checks user's permissions for accessing camera.
44
+ * @return A promise that resolves to an object of type [PermissionResponse](#permissionresponse).
45
+ */
23
46
  static getCameraPermissionsAsync(): Promise<PermissionResponse>;
47
+ /**
48
+ * Asks the user to grant permissions for accessing camera.
49
+ * On iOS this will require apps to specify an `NSCameraUsageDescription` entry in the **Info.plist**.
50
+ * @return A promise that resolves to an object of type [PermissionResponse](#permissionresponse).
51
+ */
24
52
  static requestCameraPermissionsAsync(): Promise<PermissionResponse>;
25
53
  /**
26
54
  * Check or request permissions to access the camera.
@@ -32,7 +60,16 @@ export default class Camera extends React.Component<CameraProps> {
32
60
  * ```
33
61
  */
34
62
  static useCameraPermissions: (options?: import("expo-modules-core").PermissionHookOptions<object> | undefined) => [PermissionResponse | null, () => Promise<PermissionResponse>, () => Promise<PermissionResponse>];
63
+ /**
64
+ * Checks user's permissions for accessing microphone.
65
+ * @return A promise that resolves to an object of type [PermissionResponse](#permissionresponse).
66
+ */
35
67
  static getMicrophonePermissionsAsync(): Promise<PermissionResponse>;
68
+ /**
69
+ * Asks the user to grant permissions for accessing the microphone.
70
+ * On iOS this will require apps to specify an `NSMicrophoneUsageDescription` entry in the **Info.plist**.
71
+ * @return A promise that resolves to an object of type [PermissionResponse](#permissionresponse).
72
+ */
36
73
  static requestMicrophonePermissionsAsync(): Promise<PermissionResponse>;
37
74
  /**
38
75
  * Check or request permissions to access the microphone.
@@ -52,15 +89,63 @@ export default class Camera extends React.Component<CameraProps> {
52
89
  _lastEventsTimes: {
53
90
  [eventName: string]: Date;
54
91
  };
92
+ /**
93
+ * Takes a picture and saves it to app's cache directory. Photos are rotated to match device's orientation
94
+ * (if `options.skipProcessing` flag is not enabled) and scaled to match the preview. Anyway on Android it is essential
95
+ * to set ratio prop to get a picture with correct dimensions.
96
+ * > **Note**: Make sure to wait for the [`onCameraReady`](#oncameraready) callback before calling this method.
97
+ * @param options An object in form of `CameraPictureOptions` type.
98
+ * @return Returns a Promise that resolves to `CameraCapturedPicture` object, where `uri` is a URI to the local image file on iOS,
99
+ * Android, and a base64 string on web (usable as the source for an `Image` element). The `width` and `height` properties specify
100
+ * the dimensions of the image. `base64` is included if the `base64` option was truthy, and is a string containing the JPEG data
101
+ * of the image in Base64--prepend that with `'data:image/jpg;base64,'` to get a data URI, which you can use as the source
102
+ * for an `Image` element for example. `exif` is included if the `exif` option was truthy, and is an object containing EXIF
103
+ * data for the image--the names of its properties are EXIF tags and their values are the values for those tags.
104
+ *
105
+ * > On native platforms, the local image URI is temporary. Use [`FileSystem.copyAsync`](filesystem.md#filesystemcopyasyncoptions)
106
+ * > to make a permanent copy of the image.
107
+ *
108
+ * > On web, the `uri` is a base64 representation of the image because file system URLs are not supported in the browser.
109
+ * > The `exif` data returned on web is a partial representation of the [`MediaTrackSettings`](https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackSettings),
110
+ * > if available.
111
+ */
55
112
  takePictureAsync(options?: CameraPictureOptions): Promise<CameraCapturedPicture>;
113
+ /**
114
+ * Get aspect ratios that are supported by the device and can be passed via `ratio` prop.
115
+ * @return Returns a Promise that resolves to an array of strings representing ratios, eg. `['4:3', '1:1']`.
116
+ * @platform android
117
+ */
56
118
  getSupportedRatiosAsync(): Promise<string[]>;
119
+ /**
120
+ * Get picture sizes that are supported by the device for given `ratio`.
121
+ * @param ratio A string representing aspect ratio of sizes to be returned.
122
+ * @return Returns a Promise that resolves to an array of strings representing picture sizes that can be passed to `pictureSize` prop.
123
+ * The list varies across Android devices but is the same for every iOS.
124
+ */
57
125
  getAvailablePictureSizesAsync(ratio?: string): Promise<string[]>;
126
+ /**
127
+ * Starts recording a video that will be saved to cache directory. Videos are rotated to match device's orientation.
128
+ * Flipping camera during a recording results in stopping it.
129
+ * @param options A map of `CameraRecordingOptions` type.
130
+ * @return Returns a Promise that resolves to an object containing video file `uri` property and a `codec` property on iOS.
131
+ * The Promise is returned if `stopRecording` was invoked, one of `maxDuration` and `maxFileSize` is reached or camera preview is stopped.
132
+ * @platform android
133
+ * @platform ios
134
+ */
58
135
  recordAsync(options?: CameraRecordingOptions): Promise<{
59
136
  uri: string;
60
- codec?: VideoCodec;
61
137
  }>;
138
+ /**
139
+ * Stops recording if any is in progress.
140
+ */
62
141
  stopRecording(): void;
142
+ /**
143
+ * Pauses the camera preview. It is not recommended to use `takePictureAsync` when preview is paused.
144
+ */
63
145
  pausePreview(): void;
146
+ /**
147
+ * Resumes the camera preview.
148
+ */
64
149
  resumePreview(): void;
65
150
  _onCameraReady: () => void;
66
151
  _onMountError: ({ nativeEvent }: {
@@ -75,4 +160,4 @@ export default class Camera extends React.Component<CameraProps> {
75
160
  render(): JSX.Element;
76
161
  }
77
162
  export declare const Constants: ConstantsType, getPermissionsAsync: typeof Camera.getPermissionsAsync, requestPermissionsAsync: typeof Camera.requestPermissionsAsync, getCameraPermissionsAsync: typeof Camera.getCameraPermissionsAsync, requestCameraPermissionsAsync: typeof Camera.requestCameraPermissionsAsync, getMicrophonePermissionsAsync: typeof Camera.getMicrophonePermissionsAsync, requestMicrophonePermissionsAsync: typeof Camera.requestMicrophonePermissionsAsync;
78
- export { CameraCapturedPicture, CameraNativeProps, CameraPictureOptions, CameraProps, CameraRecordingOptions, PermissionResponse, PermissionStatus, PermissionExpiration, BarCodeScanningResult, FaceDetectionResult, CameraMountError, };
163
+ //# sourceMappingURL=Camera.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Camera.d.ts","sourceRoot":"","sources":["../src/Camera.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,WAAW,EACX,sBAAsB,EACtB,UAAU,EACV,aAAa,EACb,kBAAkB,EAClB,UAAU,EACX,MAAM,gBAAgB,CAAC;AAoDxB,MAAM,CAAC,OAAO,OAAO,MAAO,SAAQ,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC;IAC9D;;;;;OAKG;WACU,gBAAgB,IAAI,OAAO,CAAC,OAAO,CAAC;IAQjD;;;OAGG;WACU,4BAA4B,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;IASlE;;;;OAIG;WACU,4BAA4B,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;IAQlE,MAAM,CAAC,SAAS,EAAE,aAAa,CAQ7B;IAGF,MAAM,CAAC,gBAAgB;;;;;MAAoB;IAE3C,MAAM,CAAC,YAAY,EAAE,WAAW,CAS9B;IAGF;;;OAGG;WACU,mBAAmB,IAAI,OAAO,CAAC,kBAAkB,CAAC;IAQ/D;;;;;OAKG;WACU,uBAAuB,IAAI,OAAO,CAAC,kBAAkB,CAAC;IAQnE;;;OAGG;WACU,yBAAyB,IAAI,OAAO,CAAC,kBAAkB,CAAC;IAKrE;;;;OAIG;WACU,6BAA6B,IAAI,OAAO,CAAC,kBAAkB,CAAC;IAKzE;;;;;;;;OAQG;IACH,MAAM,CAAC,oBAAoB,yLAGxB;IAGH;;;OAGG;WACU,6BAA6B,IAAI,OAAO,CAAC,kBAAkB,CAAC;IAKzE;;;;OAIG;WACU,iCAAiC,IAAI,OAAO,CAAC,kBAAkB,CAAC;IAK7E;;;;;;;;OAQG;IACH,MAAM,CAAC,wBAAwB,yLAG5B;IAEH,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,UAAU,CAAC,EAAE,KAAK,CAAC,SAAS,GAAG,IAAI,CAAC;IACpC,WAAW,EAAE;QAAE,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAM;IAClD,gBAAgB,EAAE;QAAE,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAM;IAGrD;;;;;;;;;;;;;;;;;;;OAmBG;IACG,gBAAgB,CAAC,OAAO,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAMtF;;;;OAIG;IACG,uBAAuB,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAQlD;;;;;OAKG;IACG,6BAA6B,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAOtE;;;;;;;;OAQG;IACG,WAAW,CAAC,OAAO,CAAC,EAAE,sBAAsB,GAAG,OAAO,CAAC;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC;IAS7E;;OAEG;IACH,aAAa;IAQb;;OAEG;IACH,YAAY;IAQZ;;OAEG;IACH,aAAa;IAQb,cAAc,aAIZ;IAEF,aAAa;qBAAoC;YAAE,OAAO,EAAE,MAAM,CAAA;SAAE;eAIlE;IAEF,iBAAiB;qBAEkB,GAAG;eAgBlC;IAEJ,aAAa,2DAaX;IAEF,MAAM;CAoBP;AAED,eAAO,MACL,SAAS,iBACT,mBAAmB,qCACnB,uBAAuB,yCACvB,yBAAyB,2CACzB,6BAA6B,+CAC7B,6BAA6B,+CAC7B,iCAAiC,iDACzB,CAAC"}
package/build/Camera.js CHANGED
@@ -1,7 +1,6 @@
1
1
  import { createPermissionHook, Platform, UnavailabilityError } from 'expo-modules-core';
2
2
  import * as React from 'react';
3
3
  import { findNodeHandle } from 'react-native';
4
- import { PermissionStatus, } from './Camera.types';
5
4
  import ExponentCamera from './ExponentCamera';
6
5
  import CameraManager from './ExponentCameraManager';
7
6
  import { ConversionTables, ensureNativeProps } from './utils/props';
@@ -40,18 +39,34 @@ function _onPictureSaved({ nativeEvent, }) {
40
39
  }
41
40
  }
42
41
  export default class Camera extends React.Component {
42
+ /**
43
+ * Check whether the current device has a camera. This is useful for web and simulators cases.
44
+ * This isn't influenced by the Permissions API (all platforms), or HTTP usage (in the browser).
45
+ * You will still need to check if the native permission has been accepted.
46
+ * @platform web
47
+ */
43
48
  static async isAvailableAsync() {
44
49
  if (!CameraManager.isAvailableAsync) {
45
50
  throw new UnavailabilityError('expo-camera', 'isAvailableAsync');
46
51
  }
47
52
  return await CameraManager.isAvailableAsync();
48
53
  }
54
+ /**
55
+ * Returns a list of camera types `['front', 'back']`. This is useful for desktop browsers which only have front-facing cameras.
56
+ * @platform web
57
+ */
49
58
  static async getAvailableCameraTypesAsync() {
50
59
  if (!CameraManager.getAvailableCameraTypesAsync) {
51
60
  throw new UnavailabilityError('expo-camera', 'getAvailableCameraTypesAsync');
52
61
  }
53
62
  return await CameraManager.getAvailableCameraTypesAsync();
54
63
  }
64
+ // @needsAudit
65
+ /**
66
+ * Queries the device for the available video codecs that can be used in video recording.
67
+ * @return A promise that resolves to a list of strings that represents available codecs.
68
+ * @platform ios
69
+ */
55
70
  static async getAvailableVideoCodecsAsync() {
56
71
  if (!CameraManager.getAvailableVideoCodecsAsync) {
57
72
  throw new UnavailabilityError('Camera', 'getAvailableVideoCodecsAsync');
@@ -79,23 +94,40 @@ export default class Camera extends React.Component {
79
94
  flashMode: CameraManager.FlashMode.off,
80
95
  whiteBalance: CameraManager.WhiteBalance.auto,
81
96
  };
97
+ // @needsAudit
82
98
  /**
83
- * @deprecated Use `getCameraPermissionsAync` or `getMicrophonePermissionsAsync` instead.
99
+ * @deprecated Use `getCameraPermissionsAsync` or `getMicrophonePermissionsAsync` instead.
100
+ * Checks user's permissions for accessing camera.
84
101
  */
85
102
  static async getPermissionsAsync() {
86
103
  console.warn(`"getPermissionsAsync()" is now deprecated. Please use "getCameraPermissionsAsync()" or "getMicrophonePermissionsAsync()" instead.`);
87
104
  return CameraManager.getPermissionsAsync();
88
105
  }
106
+ // @needsAudit
89
107
  /**
108
+ * Asks the user to grant permissions for accessing camera.
109
+ * On iOS this will require apps to specify both `NSCameraUsageDescription` and `NSMicrophoneUsageDescription` entries in the **Info.plist**.
110
+ * @return A promise that resolves to an object of type [PermissionResponse](#permissionresponse).
90
111
  * @deprecated Use `requestCameraPermissionsAsync` or `requestMicrophonePermissionsAsync` instead.
91
112
  */
92
113
  static async requestPermissionsAsync() {
93
114
  console.warn(`"requestPermissionsAsync()" is now deprecated. Please use "requestCameraPermissionsAsync()" or "requestMicrophonePermissionsAsync()" instead.`);
94
115
  return CameraManager.requestPermissionsAsync();
95
116
  }
117
+ // @needsAudit
118
+ /**
119
+ * Checks user's permissions for accessing camera.
120
+ * @return A promise that resolves to an object of type [PermissionResponse](#permissionresponse).
121
+ */
96
122
  static async getCameraPermissionsAsync() {
97
123
  return CameraManager.getCameraPermissionsAsync();
98
124
  }
125
+ // @needsAudit
126
+ /**
127
+ * Asks the user to grant permissions for accessing camera.
128
+ * On iOS this will require apps to specify an `NSCameraUsageDescription` entry in the **Info.plist**.
129
+ * @return A promise that resolves to an object of type [PermissionResponse](#permissionresponse).
130
+ */
99
131
  static async requestCameraPermissionsAsync() {
100
132
  return CameraManager.requestCameraPermissionsAsync();
101
133
  }
@@ -113,9 +145,20 @@ export default class Camera extends React.Component {
113
145
  getMethod: Camera.getCameraPermissionsAsync,
114
146
  requestMethod: Camera.requestCameraPermissionsAsync,
115
147
  });
148
+ // @needsAudit
149
+ /**
150
+ * Checks user's permissions for accessing microphone.
151
+ * @return A promise that resolves to an object of type [PermissionResponse](#permissionresponse).
152
+ */
116
153
  static async getMicrophonePermissionsAsync() {
117
154
  return CameraManager.getMicrophonePermissionsAsync();
118
155
  }
156
+ // @needsAudit
157
+ /**
158
+ * Asks the user to grant permissions for accessing the microphone.
159
+ * On iOS this will require apps to specify an `NSMicrophoneUsageDescription` entry in the **Info.plist**.
160
+ * @return A promise that resolves to an object of type [PermissionResponse](#permissionresponse).
161
+ */
119
162
  static async requestMicrophonePermissionsAsync() {
120
163
  return CameraManager.requestMicrophonePermissionsAsync();
121
164
  }
@@ -137,22 +180,63 @@ export default class Camera extends React.Component {
137
180
  _cameraRef;
138
181
  _lastEvents = {};
139
182
  _lastEventsTimes = {};
183
+ // @needsAudit
184
+ /**
185
+ * Takes a picture and saves it to app's cache directory. Photos are rotated to match device's orientation
186
+ * (if `options.skipProcessing` flag is not enabled) and scaled to match the preview. Anyway on Android it is essential
187
+ * to set ratio prop to get a picture with correct dimensions.
188
+ * > **Note**: Make sure to wait for the [`onCameraReady`](#oncameraready) callback before calling this method.
189
+ * @param options An object in form of `CameraPictureOptions` type.
190
+ * @return Returns a Promise that resolves to `CameraCapturedPicture` object, where `uri` is a URI to the local image file on iOS,
191
+ * Android, and a base64 string on web (usable as the source for an `Image` element). The `width` and `height` properties specify
192
+ * the dimensions of the image. `base64` is included if the `base64` option was truthy, and is a string containing the JPEG data
193
+ * of the image in Base64--prepend that with `'data:image/jpg;base64,'` to get a data URI, which you can use as the source
194
+ * for an `Image` element for example. `exif` is included if the `exif` option was truthy, and is an object containing EXIF
195
+ * data for the image--the names of its properties are EXIF tags and their values are the values for those tags.
196
+ *
197
+ * > On native platforms, the local image URI is temporary. Use [`FileSystem.copyAsync`](filesystem.md#filesystemcopyasyncoptions)
198
+ * > to make a permanent copy of the image.
199
+ *
200
+ * > On web, the `uri` is a base64 representation of the image because file system URLs are not supported in the browser.
201
+ * > The `exif` data returned on web is a partial representation of the [`MediaTrackSettings`](https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackSettings),
202
+ * > if available.
203
+ */
140
204
  async takePictureAsync(options) {
141
205
  const pictureOptions = ensurePictureOptions(options);
142
206
  return await CameraManager.takePicture(pictureOptions, this._cameraHandle);
143
207
  }
208
+ /**
209
+ * Get aspect ratios that are supported by the device and can be passed via `ratio` prop.
210
+ * @return Returns a Promise that resolves to an array of strings representing ratios, eg. `['4:3', '1:1']`.
211
+ * @platform android
212
+ */
144
213
  async getSupportedRatiosAsync() {
145
214
  if (!CameraManager.getSupportedRatios) {
146
215
  throw new UnavailabilityError('Camera', 'getSupportedRatiosAsync');
147
216
  }
148
217
  return await CameraManager.getSupportedRatios(this._cameraHandle);
149
218
  }
219
+ /**
220
+ * Get picture sizes that are supported by the device for given `ratio`.
221
+ * @param ratio A string representing aspect ratio of sizes to be returned.
222
+ * @return Returns a Promise that resolves to an array of strings representing picture sizes that can be passed to `pictureSize` prop.
223
+ * The list varies across Android devices but is the same for every iOS.
224
+ */
150
225
  async getAvailablePictureSizesAsync(ratio) {
151
226
  if (!CameraManager.getAvailablePictureSizes) {
152
227
  throw new UnavailabilityError('Camera', 'getAvailablePictureSizesAsync');
153
228
  }
154
229
  return await CameraManager.getAvailablePictureSizes(ratio, this._cameraHandle);
155
230
  }
231
+ /**
232
+ * Starts recording a video that will be saved to cache directory. Videos are rotated to match device's orientation.
233
+ * Flipping camera during a recording results in stopping it.
234
+ * @param options A map of `CameraRecordingOptions` type.
235
+ * @return Returns a Promise that resolves to an object containing video file `uri` property and a `codec` property on iOS.
236
+ * The Promise is returned if `stopRecording` was invoked, one of `maxDuration` and `maxFileSize` is reached or camera preview is stopped.
237
+ * @platform android
238
+ * @platform ios
239
+ */
156
240
  async recordAsync(options) {
157
241
  if (!CameraManager.record) {
158
242
  throw new UnavailabilityError('Camera', 'recordAsync');
@@ -160,18 +244,27 @@ export default class Camera extends React.Component {
160
244
  const recordingOptions = ensureRecordingOptions(options);
161
245
  return await CameraManager.record(recordingOptions, this._cameraHandle);
162
246
  }
247
+ /**
248
+ * Stops recording if any is in progress.
249
+ */
163
250
  stopRecording() {
164
251
  if (!CameraManager.stopRecording) {
165
252
  throw new UnavailabilityError('Camera', 'stopRecording');
166
253
  }
167
254
  CameraManager.stopRecording(this._cameraHandle);
168
255
  }
256
+ /**
257
+ * Pauses the camera preview. It is not recommended to use `takePictureAsync` when preview is paused.
258
+ */
169
259
  pausePreview() {
170
260
  if (!CameraManager.pausePreview) {
171
261
  throw new UnavailabilityError('Camera', 'pausePreview');
172
262
  }
173
263
  CameraManager.pausePreview(this._cameraHandle);
174
264
  }
265
+ /**
266
+ * Resumes the camera preview.
267
+ */
175
268
  resumePreview() {
176
269
  if (!CameraManager.resumePreview) {
177
270
  throw new UnavailabilityError('Camera', 'resumePreview');
@@ -228,5 +321,4 @@ export default class Camera extends React.Component {
228
321
  }
229
322
  }
230
323
  export const { Constants, getPermissionsAsync, requestPermissionsAsync, getCameraPermissionsAsync, requestCameraPermissionsAsync, getMicrophonePermissionsAsync, requestMicrophonePermissionsAsync, } = Camera;
231
- export { PermissionStatus, };
232
324
  //# sourceMappingURL=Camera.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Camera.js","sourceRoot":"","sources":["../src/Camera.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,QAAQ,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxF,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,EAYL,gBAAgB,GAEjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAC9C,OAAO,aAAa,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAEpE,MAAM,eAAe,GAAG,GAAG,CAAC;AAE5B,MAAM,wBAAwB,GAAG,EAAE,CAAC;AAEpC,IAAI,kBAAkB,GAAG,CAAC,CAAC;AAE3B,SAAS,oBAAoB,CAAC,OAA8B;IAC1D,MAAM,cAAc,GAClB,CAAC,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC;IAEzD,IAAI,CAAC,cAAc,CAAC,O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createPermissionHook, Platform, UnavailabilityError } from 'expo-modules-core';\nimport * as React from 'react';\nimport { findNodeHandle } from 'react-native';\n\nimport {\n BarCodeScanningResult,\n CameraCapturedPicture,\n CameraMountError,\n CameraNativeProps,\n CameraPictureOptions,\n CameraProps,\n CameraRecordingOptions,\n ConstantsType,\n FaceDetectionResult,\n PermissionExpiration,\n PermissionResponse,\n PermissionStatus,\n VideoCodec,\n} from './Camera.types';\nimport ExponentCamera from './ExponentCamera';\nimport CameraManager from './ExponentCameraManager';\nimport { ConversionTables, ensureNativeProps } from './utils/props';\n\nconst EventThrottleMs = 500;\n\nconst _PICTURE_SAVED_CALLBACKS = {};\n\nlet _GLOBAL_PICTURE_ID = 1;\n\nfunction ensurePictureOptions(options?: CameraPictureOptions): CameraPictureOptions {\n const pictureOptions: CameraPictureOptions =\n !options || typeof options !== 'object' ? {} : options;\n\n if (!pictureOptions.quality) {\n pictureOptions.quality = 1;\n }\n if (pictureOptions.onPictureSaved) {\n const id = _GLOBAL_PICTURE_ID++;\n _PICTURE_SAVED_CALLBACKS[id] = pictureOptions.onPictureSaved;\n pictureOptions.id = id;\n pictureOptions.fastMode = true;\n }\n return pictureOptions;\n}\n\nfunction ensureRecordingOptions(options?: CameraRecordingOptions): CameraRecordingOptions {\n let recordingOptions = options || {};\n\n if (!recordingOptions || typeof recordingOptions !== 'object') {\n recordingOptions = {};\n } else if (typeof recordingOptions.quality === 'string') {\n recordingOptions.quality = Camera.Constants.VideoQuality[recordingOptions.quality];\n }\n\n return recordingOptions;\n}\n\nfunction _onPictureSaved({\n nativeEvent,\n}: {\n nativeEvent: { data: CameraCapturedPicture; id: number };\n}) {\n const { id, data } = nativeEvent;\n const callback = _PICTURE_SAVED_CALLBACKS[id];\n if (callback) {\n callback(data);\n delete _PICTURE_SAVED_CALLBACKS[id];\n }\n}\n\nexport default class Camera extends React.Component<CameraProps> {\n static async isAvailableAsync(): Promise<boolean> {\n if (!CameraManager.isAvailableAsync) {\n throw new UnavailabilityError('expo-camera', 'isAvailableAsync');\n }\n\n return await CameraManager.isAvailableAsync();\n }\n\n static async getAvailableCameraTypesAsync(): Promise<('front' | 'back')[]> {\n if (!CameraManager.getAvailableCameraTypesAsync) {\n throw new UnavailabilityError('expo-camera', 'getAvailableCameraTypesAsync');\n }\n\n return await CameraManager.getAvailableCameraTypesAsync();\n }\n\n static async getAvailableVideoCodecsAsync(): Promise<string[]> {\n if (!CameraManager.getAvailableVideoCodecsAsync) {\n throw new UnavailabilityError('Camera', 'getAvailableVideoCodecsAsync');\n }\n\n return await CameraManager.getAvailableVideoCodecsAsync();\n }\n\n static Constants: ConstantsType = {\n Type: CameraManager.Type,\n FlashMode: CameraManager.FlashMode,\n AutoFocus: CameraManager.AutoFocus,\n WhiteBalance: CameraManager.WhiteBalance,\n VideoQuality: CameraManager.VideoQuality,\n VideoStabilization: CameraManager.VideoStabilization || {},\n VideoCodec: CameraManager.VideoCodec,\n };\n\n // Values under keys from this object will be transformed to native options\n static ConversionTables = ConversionTables;\n\n static defaultProps: CameraProps = {\n zoom: 0,\n ratio: '4:3',\n focusDepth: 0,\n faceDetectorSettings: {},\n type: CameraManager.Type.back,\n autoFocus: CameraManager.AutoFocus.on,\n flashMode: CameraManager.FlashMode.off,\n whiteBalance: CameraManager.WhiteBalance.auto,\n };\n\n /**\n * @deprecated Use `getCameraPermissionsAync` or `getMicrophonePermissionsAsync` instead.\n */\n static async getPermissionsAsync(): Promise<PermissionResponse> {\n console.warn(\n `\"getPermissionsAsync()\" is now deprecated. Please use \"getCameraPermissionsAsync()\" or \"getMicrophonePermissionsAsync()\" instead.`\n );\n return CameraManager.getPermissionsAsync();\n }\n\n /**\n * @deprecated Use `requestCameraPermissionsAsync` or `requestMicrophonePermissionsAsync` instead.\n */\n static async requestPermissionsAsync(): Promise<PermissionResponse> {\n console.warn(\n `\"requestPermissionsAsync()\" is now deprecated. Please use \"requestCameraPermissionsAsync()\" or \"requestMicrophonePermissionsAsync()\" instead.`\n );\n return CameraManager.requestPermissionsAsync();\n }\n\n static async getCameraPermissionsAsync(): Promise<PermissionResponse> {\n return CameraManager.getCameraPermissionsAsync();\n }\n\n static async requestCameraPermissionsAsync(): Promise<PermissionResponse> {\n return CameraManager.requestCameraPermissionsAsync();\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] = Camera.useCameraPermissions();\n * ```\n */\n static useCameraPermissions = createPermissionHook({\n getMethod: Camera.getCameraPermissionsAsync,\n requestMethod: Camera.requestCameraPermissionsAsync,\n });\n\n static async getMicrophonePermissionsAsync(): Promise<PermissionResponse> {\n return CameraManager.getMicrophonePermissionsAsync();\n }\n\n static async requestMicrophonePermissionsAsync(): Promise<PermissionResponse> {\n return CameraManager.requestMicrophonePermissionsAsync();\n }\n\n // @needsAudit\n /**\n * Check or request permissions to access the microphone.\n * This uses both `requestMicrophonePermissionsAsync` and `getMicrophonePermissionsAsync` to interact with the permissions.\n *\n * @example\n * ```ts\n * const [status, requestPermission] = Camera.useMicrophonePermissions();\n * ```\n */\n static useMicrophonePermissions = createPermissionHook({\n getMethod: Camera.getMicrophonePermissionsAsync,\n requestMethod: Camera.requestMicrophonePermissionsAsync,\n });\n\n _cameraHandle?: number | null;\n _cameraRef?: React.Component | null;\n _lastEvents: { [eventName: string]: string } = {};\n _lastEventsTimes: { [eventName: string]: Date } = {};\n\n async takePictureAsync(options?: CameraPictureOptions): Promise<CameraCapturedPicture> {\n const pictureOptions = ensurePictureOptions(options);\n\n return await CameraManager.takePicture(pictureOptions, this._cameraHandle);\n }\n\n async getSupportedRatiosAsync(): Promise<string[]> {\n if (!CameraManager.getSupportedRatios) {\n throw new UnavailabilityError('Camera', 'getSupportedRatiosAsync');\n }\n\n return await CameraManager.getSupportedRatios(this._cameraHandle);\n }\n\n async getAvailablePictureSizesAsync(ratio?: string): Promise<string[]> {\n if (!CameraManager.getAvailablePictureSizes) {\n throw new UnavailabilityError('Camera', 'getAvailablePictureSizesAsync');\n }\n return await CameraManager.getAvailablePictureSizes(ratio, this._cameraHandle);\n }\n\n async recordAsync(\n options?: CameraRecordingOptions\n ): Promise<{ uri: string; codec?: VideoCodec }> {\n if (!CameraManager.record) {\n throw new UnavailabilityError('Camera', 'recordAsync');\n }\n\n const recordingOptions = ensureRecordingOptions(options);\n return await CameraManager.record(recordingOptions, this._cameraHandle);\n }\n\n stopRecording() {\n if (!CameraManager.stopRecording) {\n throw new UnavailabilityError('Camera', 'stopRecording');\n }\n\n CameraManager.stopRecording(this._cameraHandle);\n }\n\n pausePreview() {\n if (!CameraManager.pausePreview) {\n throw new UnavailabilityError('Camera', 'pausePreview');\n }\n\n CameraManager.pausePreview(this._cameraHandle);\n }\n\n resumePreview() {\n if (!CameraManager.resumePreview) {\n throw new UnavailabilityError('Camera', 'resumePreview');\n }\n\n CameraManager.resumePreview(this._cameraHandle);\n }\n\n _onCameraReady = () => {\n if (this.props.onCameraReady) {\n this.props.onCameraReady();\n }\n };\n\n _onMountError = ({ nativeEvent }: { nativeEvent: { message: string } }) => {\n if (this.props.onMountError) {\n this.props.onMountError(nativeEvent);\n }\n };\n\n _onObjectDetected =\n (callback?: Function) =>\n ({ nativeEvent }: { nativeEvent: any }) => {\n const { type } = nativeEvent;\n if (\n this._lastEvents[type] &&\n this._lastEventsTimes[type] &&\n JSON.stringify(nativeEvent) === this._lastEvents[type] &&\n new Date().getTime() - this._lastEventsTimes[type].getTime() < EventThrottleMs\n ) {\n return;\n }\n\n if (callback) {\n callback(nativeEvent);\n this._lastEventsTimes[type] = new Date();\n this._lastEvents[type] = JSON.stringify(nativeEvent);\n }\n };\n\n _setReference = (ref?: React.Component) => {\n if (ref) {\n this._cameraRef = ref;\n // TODO(Bacon): Unify these - perhaps with hooks?\n if (Platform.OS === 'web') {\n this._cameraHandle = ref as any;\n } else {\n this._cameraHandle = findNodeHandle(ref);\n }\n } else {\n this._cameraRef = null;\n this._cameraHandle = null;\n }\n };\n\n render() {\n const nativeProps = ensureNativeProps(this.props);\n\n const onBarCodeScanned = this.props.onBarCodeScanned\n ? this._onObjectDetected(this.props.onBarCodeScanned)\n : undefined;\n const onFacesDetected = this._onObjectDetected(this.props.onFacesDetected);\n\n return (\n <ExponentCamera\n {...nativeProps}\n ref={this._setReference}\n onCameraReady={this._onCameraReady}\n onMountError={this._onMountError}\n onBarCodeScanned={onBarCodeScanned}\n onFacesDetected={onFacesDetected}\n onPictureSaved={_onPictureSaved}\n />\n );\n }\n}\n\nexport const {\n Constants,\n getPermissionsAsync,\n requestPermissionsAsync,\n getCameraPermissionsAsync,\n requestCameraPermissionsAsync,\n getMicrophonePermissionsAsync,\n requestMicrophonePermissionsAsync,\n} = Camera;\n\nexport {\n CameraCapturedPicture,\n CameraNativeProps,\n CameraPictureOptions,\n CameraProps,\n CameraRecordingOptions,\n PermissionResponse,\n PermissionStatus,\n PermissionExpiration,\n BarCodeScanningResult,\n FaceDetectionResult,\n CameraMountError,\n};\n"]}
1
+ {"version":3,"file":"Camera.js","sourceRoot":"","sources":["../src/Camera.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,QAAQ,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxF,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAY9C,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAC9C,OAAO,aAAa,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAEpE,MAAM,eAAe,GAAG,GAAG,CAAC;AAE5B,MAAM,wBAAwB,GAAG,EAAE,CAAC;AAEpC,IAAI,kBAAkB,GAAG,CAAC,CAAC;AAE3B,SAAS,oBAAoB,CAAC,OAA8B;IAC1D,MAAM,cAAc,GAClB,CAAC,OAAO,IAAI,OAAO,OAAO,K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AAG,EAAE,IAAI,CAAC,aAAa,EACvB,aAAa,EAAE,IAAI,CAAC,cAAc,EAClC,YAAY,EAAE,IAAI,CAAC,aAAa,EAChC,gBAAgB,EAAE,gBAAgB,EAClC,eAAe,EAAE,eAAe,EAChC,cAAc,EAAE,eAAe,GAC/B,CACH,CAAC;IACJ,CAAC;;AAGH,MAAM,CAAC,MAAM,EACX,SAAS,EACT,mBAAmB,EACnB,uBAAuB,EACvB,yBAAyB,EACzB,6BAA6B,EAC7B,6BAA6B,EAC7B,iCAAiC,GAClC,GAAG,MAAM,CAAC","sourcesContent":["import { createPermissionHook, Platform, UnavailabilityError } from 'expo-modules-core';\nimport * as React from 'react';\nimport { findNodeHandle } from 'react-native';\n\nimport {\n CameraCapturedPicture,\n CameraPictureOptions,\n CameraProps,\n CameraRecordingOptions,\n CameraType,\n ConstantsType,\n PermissionResponse,\n VideoCodec,\n} from './Camera.types';\nimport ExponentCamera from './ExponentCamera';\nimport CameraManager from './ExponentCameraManager';\nimport { ConversionTables, ensureNativeProps } from './utils/props';\n\nconst EventThrottleMs = 500;\n\nconst _PICTURE_SAVED_CALLBACKS = {};\n\nlet _GLOBAL_PICTURE_ID = 1;\n\nfunction ensurePictureOptions(options?: CameraPictureOptions): CameraPictureOptions {\n const pictureOptions: CameraPictureOptions =\n !options || typeof options !== 'object' ? {} : options;\n\n if (!pictureOptions.quality) {\n pictureOptions.quality = 1;\n }\n if (pictureOptions.onPictureSaved) {\n const id = _GLOBAL_PICTURE_ID++;\n _PICTURE_SAVED_CALLBACKS[id] = pictureOptions.onPictureSaved;\n pictureOptions.id = id;\n pictureOptions.fastMode = true;\n }\n return pictureOptions;\n}\n\nfunction ensureRecordingOptions(options?: CameraRecordingOptions): CameraRecordingOptions {\n let recordingOptions = options || {};\n\n if (!recordingOptions || typeof recordingOptions !== 'object') {\n recordingOptions = {};\n } else if (typeof recordingOptions.quality === 'string') {\n recordingOptions.quality = Camera.Constants.VideoQuality[recordingOptions.quality];\n }\n\n return recordingOptions;\n}\n\nfunction _onPictureSaved({\n nativeEvent,\n}: {\n nativeEvent: { data: CameraCapturedPicture; id: number };\n}) {\n const { id, data } = nativeEvent;\n const callback = _PICTURE_SAVED_CALLBACKS[id];\n if (callback) {\n callback(data);\n delete _PICTURE_SAVED_CALLBACKS[id];\n }\n}\n\nexport default class Camera extends React.Component<CameraProps> {\n /**\n * Check whether the current device has a camera. This is useful for web and simulators cases.\n * This isn't influenced by the Permissions API (all platforms), or HTTP usage (in the browser).\n * You will still need to check if the native permission has been accepted.\n * @platform web\n */\n static async isAvailableAsync(): Promise<boolean> {\n if (!CameraManager.isAvailableAsync) {\n throw new UnavailabilityError('expo-camera', 'isAvailableAsync');\n }\n\n return await CameraManager.isAvailableAsync();\n }\n\n /**\n * Returns a list of camera types `['front', 'back']`. This is useful for desktop browsers which only have front-facing cameras.\n * @platform web\n */\n static async getAvailableCameraTypesAsync(): Promise<CameraType[]> {\n if (!CameraManager.getAvailableCameraTypesAsync) {\n throw new UnavailabilityError('expo-camera', 'getAvailableCameraTypesAsync');\n }\n\n return await CameraManager.getAvailableCameraTypesAsync();\n }\n\n // @needsAudit\n /**\n * Queries the device for the available video codecs that can be used in video recording.\n * @return A promise that resolves to a list of strings that represents available codecs.\n * @platform ios\n */\n static async getAvailableVideoCodecsAsync(): Promise<VideoCodec[]> {\n if (!CameraManager.getAvailableVideoCodecsAsync) {\n throw new UnavailabilityError('Camera', 'getAvailableVideoCodecsAsync');\n }\n\n return await CameraManager.getAvailableVideoCodecsAsync();\n }\n\n static Constants: ConstantsType = {\n Type: CameraManager.Type,\n FlashMode: CameraManager.FlashMode,\n AutoFocus: CameraManager.AutoFocus,\n WhiteBalance: CameraManager.WhiteBalance,\n VideoQuality: CameraManager.VideoQuality,\n VideoStabilization: CameraManager.VideoStabilization || {},\n VideoCodec: CameraManager.VideoCodec,\n };\n\n // Values under keys from this object will be transformed to native options\n static ConversionTables = ConversionTables;\n\n static defaultProps: CameraProps = {\n zoom: 0,\n ratio: '4:3',\n focusDepth: 0,\n faceDetectorSettings: {},\n type: CameraManager.Type.back,\n autoFocus: CameraManager.AutoFocus.on,\n flashMode: CameraManager.FlashMode.off,\n whiteBalance: CameraManager.WhiteBalance.auto,\n };\n\n // @needsAudit\n /**\n * @deprecated Use `getCameraPermissionsAsync` or `getMicrophonePermissionsAsync` instead.\n * Checks user's permissions for accessing camera.\n */\n static async getPermissionsAsync(): Promise<PermissionResponse> {\n console.warn(\n `\"getPermissionsAsync()\" is now deprecated. Please use \"getCameraPermissionsAsync()\" or \"getMicrophonePermissionsAsync()\" instead.`\n );\n return CameraManager.getPermissionsAsync();\n }\n\n // @needsAudit\n /**\n * Asks the user to grant permissions for accessing camera.\n * On iOS this will require apps to specify both `NSCameraUsageDescription` and `NSMicrophoneUsageDescription` entries in the **Info.plist**.\n * @return A promise that resolves to an object of type [PermissionResponse](#permissionresponse).\n * @deprecated Use `requestCameraPermissionsAsync` or `requestMicrophonePermissionsAsync` instead.\n */\n static async requestPermissionsAsync(): Promise<PermissionResponse> {\n console.warn(\n `\"requestPermissionsAsync()\" is now deprecated. Please use \"requestCameraPermissionsAsync()\" or \"requestMicrophonePermissionsAsync()\" instead.`\n );\n return CameraManager.requestPermissionsAsync();\n }\n\n // @needsAudit\n /**\n * Checks user's permissions for accessing camera.\n * @return A promise that resolves to an object of type [PermissionResponse](#permissionresponse).\n */\n static async getCameraPermissionsAsync(): Promise<PermissionResponse> {\n return CameraManager.getCameraPermissionsAsync();\n }\n\n // @needsAudit\n /**\n * Asks the user to grant permissions for accessing camera.\n * On iOS this will require apps to specify an `NSCameraUsageDescription` entry in the **Info.plist**.\n * @return A promise that resolves to an object of type [PermissionResponse](#permissionresponse).\n */\n static async requestCameraPermissionsAsync(): Promise<PermissionResponse> {\n return CameraManager.requestCameraPermissionsAsync();\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] = Camera.useCameraPermissions();\n * ```\n */\n static useCameraPermissions = createPermissionHook({\n getMethod: Camera.getCameraPermissionsAsync,\n requestMethod: Camera.requestCameraPermissionsAsync,\n });\n\n // @needsAudit\n /**\n * Checks user's permissions for accessing microphone.\n * @return A promise that resolves to an object of type [PermissionResponse](#permissionresponse).\n */\n static async getMicrophonePermissionsAsync(): Promise<PermissionResponse> {\n return CameraManager.getMicrophonePermissionsAsync();\n }\n\n // @needsAudit\n /**\n * Asks the user to grant permissions for accessing the microphone.\n * On iOS this will require apps to specify an `NSMicrophoneUsageDescription` entry in the **Info.plist**.\n * @return A promise that resolves to an object of type [PermissionResponse](#permissionresponse).\n */\n static async requestMicrophonePermissionsAsync(): Promise<PermissionResponse> {\n return CameraManager.requestMicrophonePermissionsAsync();\n }\n\n // @needsAudit\n /**\n * Check or request permissions to access the microphone.\n * This uses both `requestMicrophonePermissionsAsync` and `getMicrophonePermissionsAsync` to interact with the permissions.\n *\n * @example\n * ```ts\n * const [status, requestPermission] = Camera.useMicrophonePermissions();\n * ```\n */\n static useMicrophonePermissions = createPermissionHook({\n getMethod: Camera.getMicrophonePermissionsAsync,\n requestMethod: Camera.requestMicrophonePermissionsAsync,\n });\n\n _cameraHandle?: number | null;\n _cameraRef?: React.Component | null;\n _lastEvents: { [eventName: string]: string } = {};\n _lastEventsTimes: { [eventName: string]: Date } = {};\n\n // @needsAudit\n /**\n * Takes a picture and saves it to app's cache directory. Photos are rotated to match device's orientation\n * (if `options.skipProcessing` flag is not enabled) and scaled to match the preview. Anyway on Android it is essential\n * to set ratio prop to get a picture with correct dimensions.\n * > **Note**: Make sure to wait for the [`onCameraReady`](#oncameraready) callback before calling this method.\n * @param options An object in form of `CameraPictureOptions` type.\n * @return Returns a Promise that resolves to `CameraCapturedPicture` object, where `uri` is a URI to the local image file on iOS,\n * Android, and a base64 string on web (usable as the source for an `Image` element). The `width` and `height` properties specify\n * the dimensions of the image. `base64` is included if the `base64` option was truthy, and is a string containing the JPEG data\n * of the image in Base64--prepend that with `'data:image/jpg;base64,'` to get a data URI, which you can use as the source\n * for an `Image` element for example. `exif` is included if the `exif` option was truthy, and is an object containing EXIF\n * data for the image--the names of its properties are EXIF tags and their values are the values for those tags.\n *\n * > On native platforms, the local image URI is temporary. Use [`FileSystem.copyAsync`](filesystem.md#filesystemcopyasyncoptions)\n * > to make a permanent copy of the image.\n *\n * > On web, the `uri` is a base64 representation of the image because file system URLs are not supported in the browser.\n * > The `exif` data returned on web is a partial representation of the [`MediaTrackSettings`](https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackSettings),\n * > if available.\n */\n async takePictureAsync(options?: CameraPictureOptions): Promise<CameraCapturedPicture> {\n const pictureOptions = ensurePictureOptions(options);\n\n return await CameraManager.takePicture(pictureOptions, this._cameraHandle);\n }\n\n /**\n * Get aspect ratios that are supported by the device and can be passed via `ratio` prop.\n * @return Returns a Promise that resolves to an array of strings representing ratios, eg. `['4:3', '1:1']`.\n * @platform android\n */\n async getSupportedRatiosAsync(): Promise<string[]> {\n if (!CameraManager.getSupportedRatios) {\n throw new UnavailabilityError('Camera', 'getSupportedRatiosAsync');\n }\n\n return await CameraManager.getSupportedRatios(this._cameraHandle);\n }\n\n /**\n * Get picture sizes that are supported by the device for given `ratio`.\n * @param ratio A string representing aspect ratio of sizes to be returned.\n * @return Returns a Promise that resolves to an array of strings representing picture sizes that can be passed to `pictureSize` prop.\n * The list varies across Android devices but is the same for every iOS.\n */\n async getAvailablePictureSizesAsync(ratio?: string): Promise<string[]> {\n if (!CameraManager.getAvailablePictureSizes) {\n throw new UnavailabilityError('Camera', 'getAvailablePictureSizesAsync');\n }\n return await CameraManager.getAvailablePictureSizes(ratio, this._cameraHandle);\n }\n\n /**\n * Starts recording a video that will be saved to cache directory. Videos are rotated to match device's orientation.\n * Flipping camera during a recording results in stopping it.\n * @param options A map of `CameraRecordingOptions` type.\n * @return Returns a Promise that resolves to an object containing video file `uri` property and a `codec` property on iOS.\n * The Promise is returned if `stopRecording` was invoked, one of `maxDuration` and `maxFileSize` is reached or camera preview is stopped.\n * @platform android\n * @platform ios\n */\n async recordAsync(options?: CameraRecordingOptions): Promise<{ uri: string }> {\n if (!CameraManager.record) {\n throw new UnavailabilityError('Camera', 'recordAsync');\n }\n\n const recordingOptions = ensureRecordingOptions(options);\n return await CameraManager.record(recordingOptions, this._cameraHandle);\n }\n\n /**\n * Stops recording if any is in progress.\n */\n stopRecording() {\n if (!CameraManager.stopRecording) {\n throw new UnavailabilityError('Camera', 'stopRecording');\n }\n\n CameraManager.stopRecording(this._cameraHandle);\n }\n\n /**\n * Pauses the camera preview. It is not recommended to use `takePictureAsync` when preview is paused.\n */\n pausePreview() {\n if (!CameraManager.pausePreview) {\n throw new UnavailabilityError('Camera', 'pausePreview');\n }\n\n CameraManager.pausePreview(this._cameraHandle);\n }\n\n /**\n * Resumes the camera preview.\n */\n resumePreview() {\n if (!CameraManager.resumePreview) {\n throw new UnavailabilityError('Camera', 'resumePreview');\n }\n\n CameraManager.resumePreview(this._cameraHandle);\n }\n\n _onCameraReady = () => {\n if (this.props.onCameraReady) {\n this.props.onCameraReady();\n }\n };\n\n _onMountError = ({ nativeEvent }: { nativeEvent: { message: string } }) => {\n if (this.props.onMountError) {\n this.props.onMountError(nativeEvent);\n }\n };\n\n _onObjectDetected =\n (callback?: Function) =>\n ({ nativeEvent }: { nativeEvent: any }) => {\n const { type } = nativeEvent;\n if (\n this._lastEvents[type] &&\n this._lastEventsTimes[type] &&\n JSON.stringify(nativeEvent) === this._lastEvents[type] &&\n new Date().getTime() - this._lastEventsTimes[type].getTime() < EventThrottleMs\n ) {\n return;\n }\n\n if (callback) {\n callback(nativeEvent);\n this._lastEventsTimes[type] = new Date();\n this._lastEvents[type] = JSON.stringify(nativeEvent);\n }\n };\n\n _setReference = (ref?: React.Component) => {\n if (ref) {\n this._cameraRef = ref;\n // TODO(Bacon): Unify these - perhaps with hooks?\n if (Platform.OS === 'web') {\n this._cameraHandle = ref as any;\n } else {\n this._cameraHandle = findNodeHandle(ref);\n }\n } else {\n this._cameraRef = null;\n this._cameraHandle = null;\n }\n };\n\n render() {\n const nativeProps = ensureNativeProps(this.props);\n\n const onBarCodeScanned = this.props.onBarCodeScanned\n ? this._onObjectDetected(this.props.onBarCodeScanned)\n : undefined;\n const onFacesDetected = this._onObjectDetected(this.props.onFacesDetected);\n\n return (\n <ExponentCamera\n {...nativeProps}\n ref={this._setReference}\n onCameraReady={this._onCameraReady}\n onMountError={this._onMountError}\n onBarCodeScanned={onBarCodeScanned}\n onFacesDetected={onFacesDetected}\n onPictureSaved={_onPictureSaved}\n />\n );\n }\n}\n\nexport const {\n Constants,\n getPermissionsAsync,\n requestPermissionsAsync,\n getCameraPermissionsAsync,\n requestCameraPermissionsAsync,\n getMicrophonePermissionsAsync,\n requestMicrophonePermissionsAsync,\n} = Camera;\n"]}