expo-camera 13.7.0 → 13.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -10,6 +10,17 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
+ ## 13.8.0 — 2023-10-17
14
+
15
+ ### 🛠 Breaking changes
16
+
17
+ - Dropped support for Android SDK 21 and 22. ([#24201](https://github.com/expo/expo/pull/24201) by [@behenate](https://github.com/behenate))
18
+ - Mark the `ratio` param of `getAvailablePictureSizes` as required because omitting it causes a crash on Android. On iOS, the param has no effect. ([#24234](https://github.com/expo/expo/pull/24234) by [@vonovak](https://github.com/vonovak))
19
+
20
+ ### 💡 Others
21
+
22
+ - Ship untranspiled JSX to support custom handling of `jsx` and `createElement`. ([#24889](https://github.com/expo/expo/pull/24889) by [@EvanBacon](https://github.com/EvanBacon))
23
+
13
24
  ## 13.7.0 — 2023-09-15
14
25
 
15
26
  _This version does not introduce any user-facing changes._
@@ -3,15 +3,20 @@ apply plugin: 'kotlin-android'
3
3
  apply plugin: 'maven-publish'
4
4
 
5
5
  group = 'host.exp.exponent'
6
- version = '13.7.0'
7
-
8
- buildscript {
9
- def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
10
- if (expoModulesCorePlugin.exists()) {
11
- apply from: expoModulesCorePlugin
12
- applyKotlinExpoModulesCorePlugin()
6
+ version = '13.8.0'
7
+
8
+ def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
9
+ if (expoModulesCorePlugin.exists()) {
10
+ apply from: expoModulesCorePlugin
11
+ applyKotlinExpoModulesCorePlugin()
12
+ // Remove this check, but keep the contents after SDK49 support is dropped
13
+ if (safeExtGet("expoProvidesDefaultConfig", false)) {
14
+ useExpoPublishing()
15
+ useCoreDependencies()
13
16
  }
17
+ }
14
18
 
19
+ buildscript {
15
20
  // Simple helper that allows the root project to override versions declared by this library.
16
21
  ext.safeExtGet = { prop, fallback ->
17
22
  rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
@@ -35,23 +40,44 @@ buildscript {
35
40
  }
36
41
  }
37
42
 
38
- afterEvaluate {
39
- publishing {
40
- publications {
41
- release(MavenPublication) {
42
- from components.release
43
+ // Remove this if and it's contents, when support for SDK49 is dropped
44
+ if (!safeExtGet("expoProvidesDefaultConfig", false)) {
45
+ afterEvaluate {
46
+ publishing {
47
+ publications {
48
+ release(MavenPublication) {
49
+ from components.release
50
+ }
43
51
  }
44
- }
45
- repositories {
46
- maven {
47
- url = mavenLocal().url
52
+ repositories {
53
+ maven {
54
+ url = mavenLocal().url
55
+ }
48
56
  }
49
57
  }
50
58
  }
51
59
  }
52
60
 
53
61
  android {
54
- compileSdkVersion safeExtGet("compileSdkVersion", 33)
62
+ // Remove this if and it's contents, when support for SDK49 is dropped
63
+ if (!safeExtGet("expoProvidesDefaultConfig", false)) {
64
+ compileSdkVersion safeExtGet("compileSdkVersion", 33)
65
+
66
+ defaultConfig {
67
+ minSdkVersion safeExtGet("minSdkVersion", 23)
68
+ targetSdkVersion safeExtGet("targetSdkVersion", 33)
69
+ }
70
+
71
+ publishing {
72
+ singleVariant("release") {
73
+ withSourcesJar()
74
+ }
75
+ }
76
+
77
+ lintOptions {
78
+ abortOnError false
79
+ }
80
+ }
55
81
 
56
82
  def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION
57
83
  if (agpVersion.tokenize('.')[0].toInteger() < 8) {
@@ -67,19 +93,8 @@ android {
67
93
 
68
94
  namespace "expo.modules.camera"
69
95
  defaultConfig {
70
- minSdkVersion safeExtGet("minSdkVersion", 21)
71
- targetSdkVersion safeExtGet("targetSdkVersion", 33)
72
96
  versionCode 32
73
- versionName "13.7.0"
74
- }
75
-
76
- lintOptions {
77
- abortOnError false
78
- }
79
- publishing {
80
- singleVariant("release") {
81
- withSourcesJar()
82
- }
97
+ versionName "13.8.0"
83
98
  }
84
99
  }
85
100
 
@@ -91,10 +106,12 @@ repositories {
91
106
  }
92
107
 
93
108
  dependencies {
94
- implementation project(':expo-modules-core')
109
+ // Remove this if and it's contents, when support for SDK49 is dropped
110
+ if (!safeExtGet("expoProvidesDefaultConfig", false)) {
111
+ implementation project(':expo-modules-core')
112
+ implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${getKotlinVersion()}"
113
+ }
95
114
 
96
115
  api "androidx.exifinterface:exifinterface:1.0.0"
97
116
  api 'com.google.android:cameraview:1.0.0'
98
-
99
- implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${getKotlinVersion()}"
100
117
  }
@@ -114,7 +114,7 @@ class CameraViewModule : Module() {
114
114
  return@AsyncFunction view.cameraView.supportedAspectRatios.map { it.toString() }
115
115
  }.runOnQueue(Queues.MAIN)
116
116
 
117
- AsyncFunction("getAvailablePictureSizes") { ratio: String?, viewTag: Int ->
117
+ AsyncFunction("getAvailablePictureSizes") { ratio: String, viewTag: Int ->
118
118
  val view = findView(viewTag)
119
119
 
120
120
  if (!view.cameraView.isCameraOpened) {
package/build/Camera.d.ts CHANGED
@@ -118,7 +118,7 @@ export default class Camera extends React.Component<CameraProps> {
118
118
  * @return Returns a Promise that resolves to an array of strings representing picture sizes that can be passed to `pictureSize` prop.
119
119
  * The list varies across Android devices but is the same for every iOS.
120
120
  */
121
- getAvailablePictureSizesAsync(ratio?: string): Promise<string[]>;
121
+ getAvailablePictureSizesAsync(ratio: string): Promise<string[]>;
122
122
  /**
123
123
  * Starts recording a video that will be saved to cache directory. Videos are rotated to match device's orientation.
124
124
  * Flipping camera during a recording results in stopping it.
@@ -1 +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,iBAAiB,EACjB,oBAAoB,EACpB,WAAW,EACX,sBAAsB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6BAA6B,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAOrE;;;;;;;;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,+BAA+B;qBAGhB;YAAE,aAAa,iBAAiB,CAAA;SAAE;eAK/C;IAEF,iBAAiB,cACH,QAAQ;qBACa,GAAG;eAgBlC;IAEJ,aAAa,SAAU,MAAM,SAAS,UAapC;IAEF,MAAM;CAsBP;AAED,eAAO,MACL,SAAS,iBACT,mBAAmB,qCACnB,uBAAuB,yCACvB,yBAAyB,2CACzB,6BAA6B,+CAC7B,6BAA6B,+CAC7B,iCAAiC,iDACzB,CAAC"}
package/build/Camera.js CHANGED
@@ -318,7 +318,7 @@ export default class Camera extends React.Component {
318
318
  ? this._onObjectDetected(this.props.onBarCodeScanned)
319
319
  : undefined;
320
320
  const onFacesDetected = this._onObjectDetected(this.props.onFacesDetected);
321
- return (React.createElement(ExponentCamera, { ...nativeProps, ref: this._setReference, onCameraReady: this._onCameraReady, onMountError: this._onMountError, onBarCodeScanned: onBarCodeScanned, onFacesDetected: onFacesDetected, onPictureSaved: _onPictureSaved, onResponsiveOrientationChanged: this._onResponsiveOrientationChanged }));
321
+ return (<ExponentCamera {...nativeProps} ref={this._setReference} onCameraReady={this._onCameraReady} onMountError={this._onMountError} onBarCodeScanned={onBarCodeScanned} onFacesDetected={onFacesDetected} onPictureSaved={_onPictureSaved} onResponsiveOrientationChanged={this._onResponsiveOrientationChanged}/>);
322
322
  }
323
323
  }
324
324
  export const { Constants, getPermissionsAsync, requestPermissionsAsync, getCameraPermissionsAsync, requestCameraPermissionsAsync, getMicrophonePermissionsAsync, requestMicrophonePermissionsAsync, } = Camera;
@@ -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;AAa9C,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,OAAO,EAAE;QAC3B,cAAc,CAAC,OAAO,GAAG,CAAC,CAAC;KAC5B;IACD,IAAI,cAAc,CAAC,cAAc,EAAE;QACjC,MAAM,EAAE,GAAG,kBAAkB,EAAE,CAAC;QAChC,wBAAwB,CAAC,EAAE,CAAC,GAAG,cAAc,CAAC,cAAc,CAAC;QAC7D,cAAc,CAAC,EAAE,GAAG,EAAE,CAAC;QACvB,cAAc,CAAC,QAAQ,GAAG,IAAI,CAAC;KAChC;IACD,OAAO,cAAc,CAAC;AACxB,CAAC;AAED,SAAS,sBAAsB,CAAC,OAAgC;IAC9D,IAAI,gBAAgB,GAAG,OAAO,IAAI,EAAE,CAAC;IAErC,IAAI,CAAC,gBAAgB,IAAI,OAAO,gBAAgB,KAAK,Q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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 CameraOrientation,\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 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 _onResponsiveOrientationChanged = ({\n nativeEvent,\n }: {\n nativeEvent: { orientation: CameraOrientation };\n }) => {\n if (this.props.onResponsiveOrientationChanged) {\n this.props.onResponsiveOrientationChanged(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\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 onResponsiveOrientationChanged={this._onResponsiveOrientationChanged}\n />\n );\n }\n}\n\nexport const {\n Constants,\n getPermissionsAsync,\n requestPermissionsAsync,\n getCameraPermissionsAsync,\n requestCameraPermissionsAsync,\n getMicrophonePermissionsAsync,\n requestMicrophonePermissionsAsync,\n} = Camera;\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;AAa9C,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,OAAO,EAAE;QAC3B,cAAc,CAAC,OAAO,GAAG,CAAC,CAAC;KAC5B;IACD,IAAI,cAAc,CAAC,cAAc,EAAE;QACjC,MAAM,EAAE,GAAG,kBAAkB,EAAE,CAAC;QAChC,wBAAwB,CAAC,EAAE,CAAC,GAAG,cAAc,CAAC,cAAc,CAAC;QAC7D,cAAc,CAAC,EAAE,GAAG,EAAE,CAAC;QACvB,cAAc,CAAC,QAAQ,GAA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CAAC,CACnC,eAAe,CAAC,CAAC,eAAe,CAAC,CACjC,cAAc,CAAC,CAAC,eAAe,CAAC,CAChC,8BAA8B,CAAC,CAAC,IAAI,CAAC,+BAA+B,CAAC,EACrE,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 CameraOrientation,\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 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 _onResponsiveOrientationChanged = ({\n nativeEvent,\n }: {\n nativeEvent: { orientation: CameraOrientation };\n }) => {\n if (this.props.onResponsiveOrientationChanged) {\n this.props.onResponsiveOrientationChanged(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\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 onResponsiveOrientationChanged={this._onResponsiveOrientationChanged}\n />\n );\n }\n}\n\nexport const {\n Constants,\n getPermissionsAsync,\n requestPermissionsAsync,\n getCameraPermissionsAsync,\n requestCameraPermissionsAsync,\n getMicrophonePermissionsAsync,\n requestMicrophonePermissionsAsync,\n} = Camera;\n"]}
@@ -83,11 +83,12 @@ const ExponentCamera = React.forwardRef(({ type, pictureSize, poster, ...props }
83
83
  },
84
84
  ];
85
85
  }, [native.type]);
86
- return (React.createElement(View, { pointerEvents: "box-none", style: [styles.videoWrapper, props.style] },
87
- React.createElement(Video, { autoPlay: true, playsInline: true, muted: isMuted, poster: poster,
88
- // webkitPlaysinline
89
- pointerEvents: props.pointerEvents, ref: video, style: style }),
90
- props.children));
86
+ return (<View pointerEvents="box-none" style={[styles.videoWrapper, props.style]}>
87
+ <Video autoPlay playsInline muted={isMuted} poster={poster}
88
+ // webkitPlaysinline
89
+ pointerEvents={props.pointerEvents} ref={video} style={style}/>
90
+ {props.children}
91
+ </View>);
91
92
  });
92
93
  export default ExponentCamera;
93
94
  const Video = React.forwardRef((props, ref) => createElement('video', { ...props, ref }));
@@ -1 +1 @@
1
- {"version":3,"file":"ExponentCamera.web.js","sourceRoot":"","sources":["../src/ExponentCamera.web.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,KAAK,KAAK,MAA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,CACF,CAAC;AAEF,eAAe,cAAc,CAAC;AAE9B,MAAM,KAAK,GAAG,KAAK,CAAC,UAAU,CAC5B,CACE,KAKC,EACD,GAAgC,EAChC,EAAE,CAAC,aAAa,CAAC,OAAO,EAAE,EAAE,GAAG,KAAK,EAAE,GAAG,EAAE,CAAC,CAC/C,CAAC;AAEF,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;IAC/B,YAAY,EAAE;QACZ,IAAI,EAAE,CAAC;QACP,UAAU,EAAE,SAAS;KACtB;IACD,KAAK,EAAE;QACL,KAAK,EAAE,MAAM;QACb,MAAM,EAAE,MAAM;QACd,SAAS,EAAE,OAAO;KACnB;CACF,CAAC,CAAC","sourcesContent":["import { CodedError } from 'expo-modules-core';\nimport * as React from 'react';\nimport { StyleProp, StyleSheet, View, ViewStyle } from 'react-native';\nimport createElement from 'react-native-web/dist/exports/createElement';\n\nimport {\n CameraCapturedPicture,\n CameraNativeProps,\n CameraPictureOptions,\n CameraType,\n} from './Camera.types';\nimport CameraManager from './ExponentCameraManager.web';\nimport { capture } from './WebCameraUtils';\nimport { PictureSizes } from './WebConstants';\nimport { useWebCameraStream } from './useWebCameraStream';\nimport { useWebQRScanner } from './useWebQRScanner';\n\nexport interface ExponentCameraRef {\n getAvailablePictureSizes: (ratio: string) => Promise<string[]>;\n takePicture: (options: CameraPictureOptions) => Promise<CameraCapturedPicture>;\n resumePreview: () => Promise<void>;\n pausePreview: () => Promise<void>;\n}\n\nconst ExponentCamera = React.forwardRef(\n (\n { type, pictureSize, poster, ...props }: CameraNativeProps & { children?: React.ReactNode },\n ref: React.Ref<ExponentCameraRef>\n ) => {\n const video = React.useRef<HTMLVideoElement | null>(null);\n\n const native = useWebCameraStream(video, type as CameraType, props, {\n onCameraReady() {\n if (props.onCameraReady) {\n props.onCameraReady();\n }\n },\n onMountError: props.onMountError,\n });\n\n const isQRScannerEnabled = React.useMemo<boolean>(() => {\n return !!(\n props.barCodeScannerSettings?.barCodeTypes?.includes('qr') && !!props.onBarCodeScanned\n );\n }, [props.barCodeScannerSettings?.barCodeTypes, props.onBarCodeScanned]);\n\n useWebQRScanner(video, {\n interval: props.barCodeScannerSettings?.interval,\n isEnabled: isQRScannerEnabled,\n captureOptions: { scale: 1, isImageMirror: native.type === CameraType.front },\n onScanned(event) {\n if (props.onBarCodeScanned) {\n props.onBarCodeScanned(event);\n }\n },\n // onError: props.onMountError,\n });\n\n // const [pause, setPaused]\n\n React.useImperativeHandle(\n ref,\n () => ({\n async getAvailablePictureSizes(ratio: string): Promise<string[]> {\n return PictureSizes;\n },\n async takePicture(options: CameraPictureOptions): Promise<CameraCapturedPicture> {\n if (!video.current || video.current?.readyState !== video.current?.HAVE_ENOUGH_DATA) {\n throw new CodedError(\n 'ERR_CAMERA_NOT_READY',\n 'HTMLVideoElement does not have enough camera data to construct an image yet.'\n );\n }\n const settings = native.mediaTrackSettings;\n if (!settings) {\n throw new CodedError('ERR_CAMERA_NOT_READY', 'MediaStream is not ready yet.');\n }\n\n return capture(video.current, settings, {\n ...options,\n // This will always be defined, the option gets added to a queue in the upper-level. We should replace the original so it isn't called twice.\n onPictureSaved(picture) {\n if (options.onPictureSaved) {\n options.onPictureSaved(picture);\n }\n if (props.onPictureSaved) {\n props.onPictureSaved({ nativeEvent: { data: picture, id: -1 } });\n }\n },\n });\n },\n async resumePreview(): Promise<void> {\n if (video.current) {\n video.current.play();\n }\n },\n async pausePreview(): Promise<void> {\n if (video.current) {\n video.current.pause();\n }\n },\n }),\n [native.mediaTrackSettings, props.onPictureSaved]\n );\n\n // TODO(Bacon): Create a universal prop, on native the microphone is only used when recording videos.\n // Because we don't support recording video in the browser we don't need the user to give microphone permissions.\n const isMuted = true;\n\n const style = React.useMemo<StyleProp<ViewStyle>>(() => {\n const isFrontFacingCamera = native.type === CameraManager.Type.front;\n return [\n StyleSheet.absoluteFill,\n styles.video,\n {\n // Flip the camera\n transform: isFrontFacingCamera ? [{ scaleX: -1 }] : undefined,\n },\n ];\n }, [native.type]);\n\n return (\n <View pointerEvents=\"box-none\" style={[styles.videoWrapper, props.style]}>\n <Video\n autoPlay\n playsInline\n muted={isMuted}\n poster={poster}\n // webkitPlaysinline\n pointerEvents={props.pointerEvents}\n ref={video}\n style={style}\n />\n {props.children}\n </View>\n );\n }\n);\n\nexport default ExponentCamera;\n\nconst Video = React.forwardRef(\n (\n props: React.ComponentProps<typeof View> & {\n autoPlay?: boolean;\n playsInline?: boolean;\n muted?: boolean;\n poster?: string;\n },\n ref: React.Ref<HTMLVideoElement>\n ) => createElement('video', { ...props, ref })\n);\n\nconst styles = StyleSheet.create({\n videoWrapper: {\n flex: 1,\n alignItems: 'stretch',\n },\n video: {\n width: '100%',\n height: '100%',\n objectFit: 'cover',\n },\n});\n"]}
1
+ {"version":3,"file":"ExponentCamera.web.js","sourceRoot":"","sources":["../src/ExponentCamera.web.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAa,UAAU,EAAE,IAAI,EAAa,MAAM,cAAc,CAAC;AACtE,OAAO,aAAa,MAAM,6CAA6C,CAAC;AAExE,OAAO,EAIL,UAAU,GACX,MAAM,gBAAgB,CAAC;AACxB,OAAO,aAAa,MAAM,6BAA6B,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AASpD,MAAM,cAAc,GAAG,KAAK,CAAC,UAAU,CACrC,CACE,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,GAAG,KAAK,EAAsD,EAC3F,GAAiC,EACjC,EAAE;IACF,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAA0B,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Prop, StyleSheet, View, ViewStyle } from 'react-native';\nimport createElement from 'react-native-web/dist/exports/createElement';\n\nimport {\n CameraCapturedPicture,\n CameraNativeProps,\n CameraPictureOptions,\n CameraType,\n} from './Camera.types';\nimport CameraManager from './ExponentCameraManager.web';\nimport { capture } from './WebCameraUtils';\nimport { PictureSizes } from './WebConstants';\nimport { useWebCameraStream } from './useWebCameraStream';\nimport { useWebQRScanner } from './useWebQRScanner';\n\nexport interface ExponentCameraRef {\n getAvailablePictureSizes: (ratio: string) => Promise<string[]>;\n takePicture: (options: CameraPictureOptions) => Promise<CameraCapturedPicture>;\n resumePreview: () => Promise<void>;\n pausePreview: () => Promise<void>;\n}\n\nconst ExponentCamera = React.forwardRef(\n (\n { type, pictureSize, poster, ...props }: CameraNativeProps & { children?: React.ReactNode },\n ref: React.Ref<ExponentCameraRef>\n ) => {\n const video = React.useRef<HTMLVideoElement | null>(null);\n\n const native = useWebCameraStream(video, type as CameraType, props, {\n onCameraReady() {\n if (props.onCameraReady) {\n props.onCameraReady();\n }\n },\n onMountError: props.onMountError,\n });\n\n const isQRScannerEnabled = React.useMemo<boolean>(() => {\n return !!(\n props.barCodeScannerSettings?.barCodeTypes?.includes('qr') && !!props.onBarCodeScanned\n );\n }, [props.barCodeScannerSettings?.barCodeTypes, props.onBarCodeScanned]);\n\n useWebQRScanner(video, {\n interval: props.barCodeScannerSettings?.interval,\n isEnabled: isQRScannerEnabled,\n captureOptions: { scale: 1, isImageMirror: native.type === CameraType.front },\n onScanned(event) {\n if (props.onBarCodeScanned) {\n props.onBarCodeScanned(event);\n }\n },\n // onError: props.onMountError,\n });\n\n // const [pause, setPaused]\n\n React.useImperativeHandle(\n ref,\n () => ({\n async getAvailablePictureSizes(ratio: string): Promise<string[]> {\n return PictureSizes;\n },\n async takePicture(options: CameraPictureOptions): Promise<CameraCapturedPicture> {\n if (!video.current || video.current?.readyState !== video.current?.HAVE_ENOUGH_DATA) {\n throw new CodedError(\n 'ERR_CAMERA_NOT_READY',\n 'HTMLVideoElement does not have enough camera data to construct an image yet.'\n );\n }\n const settings = native.mediaTrackSettings;\n if (!settings) {\n throw new CodedError('ERR_CAMERA_NOT_READY', 'MediaStream is not ready yet.');\n }\n\n return capture(video.current, settings, {\n ...options,\n // This will always be defined, the option gets added to a queue in the upper-level. We should replace the original so it isn't called twice.\n onPictureSaved(picture) {\n if (options.onPictureSaved) {\n options.onPictureSaved(picture);\n }\n if (props.onPictureSaved) {\n props.onPictureSaved({ nativeEvent: { data: picture, id: -1 } });\n }\n },\n });\n },\n async resumePreview(): Promise<void> {\n if (video.current) {\n video.current.play();\n }\n },\n async pausePreview(): Promise<void> {\n if (video.current) {\n video.current.pause();\n }\n },\n }),\n [native.mediaTrackSettings, props.onPictureSaved]\n );\n\n // TODO(Bacon): Create a universal prop, on native the microphone is only used when recording videos.\n // Because we don't support recording video in the browser we don't need the user to give microphone permissions.\n const isMuted = true;\n\n const style = React.useMemo<StyleProp<ViewStyle>>(() => {\n const isFrontFacingCamera = native.type === CameraManager.Type.front;\n return [\n StyleSheet.absoluteFill,\n styles.video,\n {\n // Flip the camera\n transform: isFrontFacingCamera ? [{ scaleX: -1 }] : undefined,\n },\n ];\n }, [native.type]);\n\n return (\n <View pointerEvents=\"box-none\" style={[styles.videoWrapper, props.style]}>\n <Video\n autoPlay\n playsInline\n muted={isMuted}\n poster={poster}\n // webkitPlaysinline\n pointerEvents={props.pointerEvents}\n ref={video}\n style={style}\n />\n {props.children}\n </View>\n );\n }\n);\n\nexport default ExponentCamera;\n\nconst Video = React.forwardRef(\n (\n props: React.ComponentProps<typeof View> & {\n autoPlay?: boolean;\n playsInline?: boolean;\n muted?: boolean;\n poster?: string;\n },\n ref: React.Ref<HTMLVideoElement>\n ) => createElement('video', { ...props, ref })\n);\n\nconst styles = StyleSheet.create({\n videoWrapper: {\n flex: 1,\n alignItems: 'stretch',\n },\n video: {\n width: '100%',\n height: '100%',\n objectFit: 'cover',\n },\n});\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-camera",
3
- "version": "13.7.0",
3
+ "version": "13.8.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",
@@ -42,5 +42,5 @@
42
42
  "peerDependencies": {
43
43
  "expo": "*"
44
44
  },
45
- "gitHead": "ee2c866ba3c7fbc35ff2a3e896041cf15d3bd7c5"
45
+ "gitHead": "da25937e2a99661cbe5eb60ca1d8d6245fc96a50"
46
46
  }
package/src/Camera.tsx CHANGED
@@ -270,7 +270,7 @@ export default class Camera extends React.Component<CameraProps> {
270
270
  * @return Returns a Promise that resolves to an array of strings representing picture sizes that can be passed to `pictureSize` prop.
271
271
  * The list varies across Android devices but is the same for every iOS.
272
272
  */
273
- async getAvailablePictureSizesAsync(ratio?: string): Promise<string[]> {
273
+ async getAvailablePictureSizesAsync(ratio: string): Promise<string[]> {
274
274
  if (!CameraManager.getAvailablePictureSizes) {
275
275
  throw new UnavailabilityError('Camera', 'getAvailablePictureSizesAsync');
276
276
  }