expo-camera 13.0.0-beta.1 → 13.0.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 +8 -0
- package/android/build.gradle +2 -2
- package/android/src/main/java/expo/modules/camera/CameraViewModule.kt +3 -5
- package/android/src/main/java/expo/modules/camera/Events.kt +3 -1
- package/android/src/main/java/expo/modules/camera/ExpoCameraView.kt +91 -8
- package/android/src/main/java/expo/modules/camera/utils/BarCodeScannerListMappers.kt +13 -0
- package/build/Camera.d.ts.map +1 -1
- package/build/Camera.js.map +1 -1
- package/build/Camera.types.d.ts +34 -1
- package/build/Camera.types.d.ts.map +1 -1
- package/build/Camera.types.js.map +1 -1
- package/build/useWebQRScanner.d.ts.map +1 -1
- package/build/useWebQRScanner.js +2 -0
- package/build/useWebQRScanner.js.map +1 -1
- package/package.json +3 -3
- package/src/Camera.tsx +1 -0
- package/src/Camera.types.ts +36 -1
- package/src/useWebQRScanner.ts +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,12 @@
|
|
|
10
10
|
|
|
11
11
|
### 💡 Others
|
|
12
12
|
|
|
13
|
+
## 13.0.0 — 2022-10-25
|
|
14
|
+
|
|
15
|
+
### 🐛 Bug fixes
|
|
16
|
+
|
|
17
|
+
- Added `bounds` property to the `BarCodeScanningResult`. ([#19519](https://github.com/expo/expo/pull/19519) by [@lukmccall](https://github.com/lukmccall))
|
|
18
|
+
|
|
13
19
|
## 13.0.0-beta.1 — 2022-10-06
|
|
14
20
|
|
|
15
21
|
### 🛠 Breaking changes
|
|
@@ -25,6 +31,8 @@
|
|
|
25
31
|
### 🐛 Bug fixes
|
|
26
32
|
|
|
27
33
|
- Fix error when calling `takePictureAsync()` on Android emulator. ([#18704](https://github.com/expo/expo/pull/18704)) by [@keith-kurak](https://github.com/keith-kurak))
|
|
34
|
+
- Add `cornerPoints` to `onBarCodeScanned` on Android. ([#19357](https://github.com/expo/expo/pull/19357) by [@igoro00](https://github.com/igoro00))
|
|
35
|
+
- Fix error where `takePictureAsync()` saved the photo to a global cache directory that was inaccessible in Expo Go. ([#19205](https://github.com/expo/expo/pull/19205) by [@aleqsio](https://github.com/aleqsio))
|
|
28
36
|
|
|
29
37
|
### 💡 Others
|
|
30
38
|
|
package/android/build.gradle
CHANGED
|
@@ -3,7 +3,7 @@ apply plugin: 'kotlin-android'
|
|
|
3
3
|
apply plugin: 'maven-publish'
|
|
4
4
|
|
|
5
5
|
group = 'host.exp.exponent'
|
|
6
|
-
version = '13.0.0
|
|
6
|
+
version = '13.0.0'
|
|
7
7
|
|
|
8
8
|
buildscript {
|
|
9
9
|
def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
|
|
@@ -74,7 +74,7 @@ android {
|
|
|
74
74
|
minSdkVersion safeExtGet("minSdkVersion", 21)
|
|
75
75
|
targetSdkVersion safeExtGet("targetSdkVersion", 31)
|
|
76
76
|
versionCode 32
|
|
77
|
-
versionName "13.0.0
|
|
77
|
+
versionName "13.0.0"
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
lintOptions {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
package expo.modules.camera
|
|
2
2
|
|
|
3
3
|
import android.Manifest
|
|
4
|
-
import android.content.Context
|
|
5
4
|
import com.google.android.cameraview.AspectRatio
|
|
6
5
|
import com.google.android.cameraview.Size
|
|
7
6
|
import expo.modules.camera.tasks.ResolveTakenPictureAsyncTask
|
|
@@ -14,6 +13,7 @@ import expo.modules.kotlin.exception.Exceptions
|
|
|
14
13
|
import expo.modules.kotlin.functions.Queues
|
|
15
14
|
import expo.modules.kotlin.modules.Module
|
|
16
15
|
import expo.modules.kotlin.modules.ModuleDefinition
|
|
16
|
+
import java.io.File
|
|
17
17
|
|
|
18
18
|
class CameraViewModule : Module() {
|
|
19
19
|
override fun definition() = ModuleDefinition {
|
|
@@ -68,7 +68,6 @@ class CameraViewModule : Module() {
|
|
|
68
68
|
}.runOnQueue(Queues.MAIN)
|
|
69
69
|
|
|
70
70
|
AsyncFunction("takePicture") { options: PictureOptions, viewTag: Int, promise: Promise ->
|
|
71
|
-
val cacheDirectory = reactContext.cacheDir
|
|
72
71
|
val view = findView(viewTag)
|
|
73
72
|
|
|
74
73
|
if (!EmulatorUtilities.isRunningOnEmulator()) {
|
|
@@ -88,7 +87,6 @@ class CameraViewModule : Module() {
|
|
|
88
87
|
throw Exceptions.MissingPermissions(Manifest.permission.RECORD_AUDIO)
|
|
89
88
|
}
|
|
90
89
|
|
|
91
|
-
val cacheDirectory = reactContext.cacheDir
|
|
92
90
|
val view = findView(viewTag)
|
|
93
91
|
|
|
94
92
|
if (!view.cameraView.isCameraOpened) {
|
|
@@ -251,8 +249,8 @@ class CameraViewModule : Module() {
|
|
|
251
249
|
}
|
|
252
250
|
}
|
|
253
251
|
|
|
254
|
-
private val
|
|
255
|
-
get() = appContext.
|
|
252
|
+
private val cacheDirectory: File
|
|
253
|
+
get() = appContext.cacheDirectory
|
|
256
254
|
|
|
257
255
|
private val permissionsManager: Permissions
|
|
258
256
|
get() = appContext.permissions ?: throw Exceptions.PermissionsModuleNotFound()
|
|
@@ -7,7 +7,9 @@ import expo.modules.kotlin.records.Record
|
|
|
7
7
|
data class BarCodeScannedEvent(
|
|
8
8
|
@Field val target: Int,
|
|
9
9
|
@Field val data: String,
|
|
10
|
-
@Field val type: Int
|
|
10
|
+
@Field val type: Int,
|
|
11
|
+
@Field val cornerPoints: ArrayList<Bundle>,
|
|
12
|
+
@Field val boundingBox: Bundle
|
|
11
13
|
) : Record
|
|
12
14
|
|
|
13
15
|
data class CameraMountErrorEvent(
|
|
@@ -30,13 +30,18 @@ import expo.modules.interfaces.facedetector.FaceDetectorInterface
|
|
|
30
30
|
import expo.modules.interfaces.facedetector.FaceDetectorProviderInterface
|
|
31
31
|
import expo.modules.kotlin.AppContext
|
|
32
32
|
import expo.modules.kotlin.Promise
|
|
33
|
-
import expo.modules.kotlin.callbacks.callback
|
|
34
33
|
import expo.modules.kotlin.views.ExpoView
|
|
35
34
|
import java.io.File
|
|
36
35
|
import java.io.IOException
|
|
37
36
|
import java.util.*
|
|
38
37
|
import java.util.concurrent.ConcurrentHashMap
|
|
39
38
|
import java.util.concurrent.ConcurrentLinkedQueue
|
|
39
|
+
import expo.modules.camera.utils.mapX
|
|
40
|
+
import expo.modules.camera.utils.mapY
|
|
41
|
+
import kotlin.math.roundToInt
|
|
42
|
+
import android.view.WindowManager
|
|
43
|
+
import expo.modules.interfaces.barcodescanner.BarCodeScannerResult.BoundingBox
|
|
44
|
+
import expo.modules.kotlin.viewevent.EventDispatcher
|
|
40
45
|
|
|
41
46
|
class ExpoCameraView(
|
|
42
47
|
context: Context,
|
|
@@ -56,9 +61,9 @@ class ExpoCameraView(
|
|
|
56
61
|
private var isPaused = false
|
|
57
62
|
private var isNew = true
|
|
58
63
|
|
|
59
|
-
private val onCameraReady by
|
|
60
|
-
private val onMountError by
|
|
61
|
-
private val onBarCodeScanned by
|
|
64
|
+
private val onCameraReady by EventDispatcher<Unit>()
|
|
65
|
+
private val onMountError by EventDispatcher<CameraMountErrorEvent>()
|
|
66
|
+
private val onBarCodeScanned by EventDispatcher<BarCodeScannedEvent>(
|
|
62
67
|
/**
|
|
63
68
|
* We want every distinct barcode to be reported to the JS listener.
|
|
64
69
|
* If we return some static value as a coalescing key there may be two barcode events
|
|
@@ -68,15 +73,15 @@ class ExpoCameraView(
|
|
|
68
73
|
*/
|
|
69
74
|
coalescingKey = { event -> (event.data.hashCode() % Short.MAX_VALUE).toShort() }
|
|
70
75
|
)
|
|
71
|
-
private val onFacesDetected by
|
|
76
|
+
private val onFacesDetected by EventDispatcher<FacesDetectedEvent>(
|
|
72
77
|
/**
|
|
73
78
|
* Should events about detected faces coalesce, the best strategy will be
|
|
74
79
|
* to ensure that events with different faces count are always being transmitted.
|
|
75
80
|
*/
|
|
76
81
|
coalescingKey = { event -> (event.faces.size % Short.MAX_VALUE).toShort() }
|
|
77
82
|
)
|
|
78
|
-
private val onFaceDetectionError by
|
|
79
|
-
private val onPictureSaved by
|
|
83
|
+
private val onFaceDetectionError by EventDispatcher<FaceDetectionErrorEvent>()
|
|
84
|
+
private val onPictureSaved by EventDispatcher<PictureSavedEvent>(
|
|
80
85
|
coalescingKey = { event ->
|
|
81
86
|
val uriHash = event.data.getString("uri")?.hashCode() ?: -1
|
|
82
87
|
(uriHash % Short.MAX_VALUE).toShort()
|
|
@@ -189,13 +194,91 @@ class ExpoCameraView(
|
|
|
189
194
|
barCodeScanner?.setSettings(settings)
|
|
190
195
|
}
|
|
191
196
|
|
|
197
|
+
// Even = portrait, odd = landscape
|
|
198
|
+
private fun getDeviceOrientation() =
|
|
199
|
+
(context.getSystemService(Context.WINDOW_SERVICE) as WindowManager).defaultDisplay.rotation
|
|
200
|
+
|
|
201
|
+
private fun transformBarCodeScannerResultToViewCoordinates(barCode: BarCodeScannerResult) {
|
|
202
|
+
val cornerPoints = barCode.cornerPoints
|
|
203
|
+
|
|
204
|
+
// For some reason they're swapped, I don't know anymore...
|
|
205
|
+
val cameraWidth = barCode.referenceImageHeight
|
|
206
|
+
val cameraHeight = barCode.referenceImageWidth
|
|
207
|
+
|
|
208
|
+
val facingBack = cameraView.facing == CameraView.FACING_BACK
|
|
209
|
+
val facingFront = cameraView.facing == CameraView.FACING_FRONT
|
|
210
|
+
val portrait = getDeviceOrientation() % 2 == 0
|
|
211
|
+
val landscape = getDeviceOrientation() % 2 == 1
|
|
212
|
+
|
|
213
|
+
if (facingBack && portrait) {
|
|
214
|
+
cornerPoints.mapX { cameraWidth - cornerPoints[it] }
|
|
215
|
+
}
|
|
216
|
+
if (facingBack && landscape) {
|
|
217
|
+
cornerPoints.mapY { cameraHeight - cornerPoints[it] }
|
|
218
|
+
}
|
|
219
|
+
if (facingFront) {
|
|
220
|
+
cornerPoints.mapX { cameraWidth - cornerPoints[it] }
|
|
221
|
+
cornerPoints.mapY { cameraHeight - cornerPoints[it] }
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
val scaleX = width / cameraWidth.toDouble()
|
|
225
|
+
val scaleY = height / cameraHeight.toDouble()
|
|
226
|
+
|
|
227
|
+
cornerPoints.mapX {
|
|
228
|
+
(cornerPoints[it] * scaleX)
|
|
229
|
+
.roundToInt()
|
|
230
|
+
}
|
|
231
|
+
cornerPoints.mapY {
|
|
232
|
+
(cornerPoints[it] * scaleY)
|
|
233
|
+
.roundToInt()
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
barCode.cornerPoints = cornerPoints
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
private fun getCornerPointsAndBoundingBox(cornerPoints: List<Int>, boundingBox: BoundingBox): Pair<ArrayList<Bundle>, Bundle> {
|
|
240
|
+
val density = cameraView.resources.displayMetrics.density
|
|
241
|
+
val convertedCornerPoints = ArrayList<Bundle>()
|
|
242
|
+
for (i in cornerPoints.indices step 2) {
|
|
243
|
+
val y = cornerPoints[i].toFloat() / density
|
|
244
|
+
val x = cornerPoints[i + 1].toFloat() / density
|
|
245
|
+
convertedCornerPoints.add(
|
|
246
|
+
Bundle().apply {
|
|
247
|
+
putFloat("x", x)
|
|
248
|
+
putFloat("y", y)
|
|
249
|
+
}
|
|
250
|
+
)
|
|
251
|
+
}
|
|
252
|
+
val boundingBoxBundle = Bundle().apply {
|
|
253
|
+
putParcelable(
|
|
254
|
+
"origin",
|
|
255
|
+
Bundle().apply {
|
|
256
|
+
putFloat("x", boundingBox.x.toFloat() / density)
|
|
257
|
+
putFloat("y", boundingBox.y.toFloat() / density)
|
|
258
|
+
}
|
|
259
|
+
)
|
|
260
|
+
putParcelable(
|
|
261
|
+
"size",
|
|
262
|
+
Bundle().apply {
|
|
263
|
+
putFloat("width", boundingBox.width.toFloat() / density)
|
|
264
|
+
putFloat("height", boundingBox.height.toFloat() / density)
|
|
265
|
+
}
|
|
266
|
+
)
|
|
267
|
+
}
|
|
268
|
+
return convertedCornerPoints to boundingBoxBundle
|
|
269
|
+
}
|
|
270
|
+
|
|
192
271
|
override fun onBarCodeScanned(barCode: BarCodeScannerResult) {
|
|
193
272
|
if (mShouldScanBarCodes) {
|
|
273
|
+
transformBarCodeScannerResultToViewCoordinates(barCode)
|
|
274
|
+
val (cornerPoints, boundingBox) = getCornerPointsAndBoundingBox(barCode.cornerPoints, barCode.boundingBox)
|
|
194
275
|
onBarCodeScanned(
|
|
195
276
|
BarCodeScannedEvent(
|
|
196
277
|
target = id,
|
|
197
278
|
data = barCode.value,
|
|
198
|
-
type = barCode.type
|
|
279
|
+
type = barCode.type,
|
|
280
|
+
cornerPoints = cornerPoints,
|
|
281
|
+
boundingBox = boundingBox
|
|
199
282
|
)
|
|
200
283
|
)
|
|
201
284
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
package expo.modules.camera.utils
|
|
2
|
+
|
|
3
|
+
inline fun MutableList<Int>.mapY(block: (it: Int) -> Int) {
|
|
4
|
+
for (it in 0 until this.size step 2) {
|
|
5
|
+
this[it] = block(it)
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
inline fun MutableList<Int>.mapX(block: (it: Int) -> Int) {
|
|
10
|
+
for (it in 1 until this.size step 2) {
|
|
11
|
+
this[it] = block(it)
|
|
12
|
+
}
|
|
13
|
+
}
|
package/build/Camera.d.ts.map
CHANGED
|
@@ -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,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,gBAAg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,aAAa,GAAG,CAAC,GAAqB,EAAE,EAAE;QACxC,IAAI,GAAG,EAAE;YACP,IAAI,CAAC,UAAU,GAAG,GAAG,CAAC;YACtB,iDAAiD;YACjD,IAAI,QAAQ,CAAC,EAAE,KAAK,KAAK,EAAE;gBACzB,IAAI,CAAC,aAAa,GAAG,GAAU,CAAC;aACjC;iBAAM;gBACL,IAAI,CAAC,aAAa,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC;aAC1C;SACF;aAAM;YACL,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;YACvB,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;SAC3B;IACH,CAAC,CAAC;IAEF,MAAM;QACJ,MAAM,WAAW,GAAG,iBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAElD,MAAM,gBAAgB,GAAG,IAAI,CAAC,KAAK,CAAC,gBAAgB;YAClD,CAAC,CAAC,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC;YACrD,CAAC,CAAC,SAAS,CAAC;QACd,MAAM,eAAe,GAAG,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;QAE3E,OAAO,CACL,oBAAC,cAAc,OACT,WAAW,EACf,GAAG,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"]}
|
|
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,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;IA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GAAG,GAAG,CAAC;YACtB,iDAAiD;YACjD,IAAI,QAAQ,CAAC,EAAE,KAAK,KAAK,EAAE;gBACzB,IAAI,CAAC,aAAa,GAAG,GAAU,CAAC;aACjC;iBAAM;gBACL,IAAI,CAAC,aAAa,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC;aAC1C;SACF;aAAM;YACL,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;YACvB,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;SAC3B;IACH,CAAC,CAAC;IAEF,MAAM;QACJ,MAAM,WAAW,GAAG,iBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAElD,MAAM,gBAAgB,GAAG,IAAI,CAAC,KAAK,CAAC,gBAAgB;YAClD,CAAC,CAAC,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC;YACrD,CAAC,CAAC,SAAS,CAAC;QAEd,MAAM,eAAe,GAAG,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;QAE3E,OAAO,CACL,oBAAC,cAAc,OACT,WAAW,EACf,GAAG,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\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"]}
|
package/build/Camera.types.d.ts
CHANGED
|
@@ -228,7 +228,31 @@ export declare type Point = {
|
|
|
228
228
|
x: number;
|
|
229
229
|
y: number;
|
|
230
230
|
};
|
|
231
|
+
export declare type BarCodeSize = {
|
|
232
|
+
/**
|
|
233
|
+
* The height value.
|
|
234
|
+
*/
|
|
235
|
+
height: number;
|
|
236
|
+
/**
|
|
237
|
+
* The width value.
|
|
238
|
+
*/
|
|
239
|
+
width: number;
|
|
240
|
+
};
|
|
241
|
+
/**
|
|
242
|
+
* These coordinates are represented in the coordinate space of the camera source (e.g. when you
|
|
243
|
+
* are using the camera view, these values are adjusted to the dimensions of the view).
|
|
244
|
+
*/
|
|
231
245
|
export declare type BarCodePoint = Point;
|
|
246
|
+
export declare type BarCodeBounds = {
|
|
247
|
+
/**
|
|
248
|
+
* The origin point of the bounding box.
|
|
249
|
+
*/
|
|
250
|
+
origin: BarCodePoint;
|
|
251
|
+
/**
|
|
252
|
+
* The size of the bounding box.
|
|
253
|
+
*/
|
|
254
|
+
size: BarCodeSize;
|
|
255
|
+
};
|
|
232
256
|
export declare type BarCodeScanningResult = {
|
|
233
257
|
/**
|
|
234
258
|
* The barcode type.
|
|
@@ -240,8 +264,17 @@ export declare type BarCodeScanningResult = {
|
|
|
240
264
|
data: string;
|
|
241
265
|
/**
|
|
242
266
|
* Corner points of the bounding box.
|
|
267
|
+
* `cornerPoints` is not always available and may be empty. On iOS, for `code39` and `pdf417`
|
|
268
|
+
* you don't get this value.
|
|
269
|
+
*/
|
|
270
|
+
cornerPoints: BarCodePoint[];
|
|
271
|
+
/**
|
|
272
|
+
* The [BarCodeBounds](#barcodebounds) object.
|
|
273
|
+
* `bounds` in some case will be representing an empty rectangle.
|
|
274
|
+
* Moreover, `bounds` doesn't have to bound the whole barcode.
|
|
275
|
+
* For some types, they will represent the area used by the scanner.
|
|
243
276
|
*/
|
|
244
|
-
|
|
277
|
+
bounds: BarCodeBounds;
|
|
245
278
|
};
|
|
246
279
|
export declare type Face = {
|
|
247
280
|
faceID: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Camera.types.d.ts","sourceRoot":"","sources":["../src/Camera.types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,oBAAoB,EACpB,qBAAqB,EACtB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,oBAAY,UAAU;IACpB,KAAK,UAAU;IACf,IAAI,SAAS;CACd;AAED,oBAAY,SAAS;IACnB,EAAE,OAAO;IACT,GAAG,QAAQ;IACX,IAAI,SAAS;IACb,KAAK,UAAU;CAChB;AAED,oBAAY,SAAS;IACnB,EAAE,OAAO;IACT,GAAG,QAAQ;IACX;;OAEG;IACH,IAAI,SAAS;IACb;;OAEG;IACH,UAAU,eAAe;CAC1B;AAED,oBAAY,YAAY;IACtB,IAAI,SAAS;IACb;;;OAGG;IACH,KAAK,UAAU;IACf;;;OAGG;IACH,MAAM,WAAW;IACjB;;;OAGG;IACH,MAAM,WAAW;IACjB;;;OAGG;IACH,YAAY,iBAAiB;IAC7B;;;OAGG;IACH,WAAW,gBAAgB;IAC3B;;OAEG;IACH,UAAU,eAAe;IACzB;;OAEG;IACH,MAAM,WAAW;CAClB;AAED,oBAAY,SAAS;IACnB,GAAG,QAAQ;IACX,GAAG,QAAQ;CACZ;AAED;;;GAGG;AACH,oBAAY,UAAU;IACpB,IAAI,SAAS;IACb,IAAI,SAAS;IACb,IAAI,SAAS;IACb,cAAc,SAAS;IACvB,eAAe,SAAS;CACzB;AAGD,oBAAY,kBAAkB;IAC5B,GAAG,QAAQ;IACX,QAAQ,aAAa;IACrB,SAAS,cAAc;IACvB,IAAI,SAAS;CACd;AAGD,oBAAY,YAAY;IACtB,OAAO,UAAU;IACjB,OAAO,UAAU;IACjB,MAAM,SAAS;IACf,MAAM,SAAS;IACf,KAAK,QAAQ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":3,"file":"Camera.types.d.ts","sourceRoot":"","sources":["../src/Camera.types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,oBAAoB,EACpB,qBAAqB,EACtB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,oBAAY,UAAU;IACpB,KAAK,UAAU;IACf,IAAI,SAAS;CACd;AAED,oBAAY,SAAS;IACnB,EAAE,OAAO;IACT,GAAG,QAAQ;IACX,IAAI,SAAS;IACb,KAAK,UAAU;CAChB;AAED,oBAAY,SAAS;IACnB,EAAE,OAAO;IACT,GAAG,QAAQ;IACX;;OAEG;IACH,IAAI,SAAS;IACb;;OAEG;IACH,UAAU,eAAe;CAC1B;AAED,oBAAY,YAAY;IACtB,IAAI,SAAS;IACb;;;OAGG;IACH,KAAK,UAAU;IACf;;;OAGG;IACH,MAAM,WAAW;IACjB;;;OAGG;IACH,MAAM,WAAW;IACjB;;;OAGG;IACH,YAAY,iBAAiB;IAC7B;;;OAGG;IACH,WAAW,gBAAgB;IAC3B;;OAEG;IACH,UAAU,eAAe;IACzB;;OAEG;IACH,MAAM,WAAW;CAClB;AAED,oBAAY,SAAS;IACnB,GAAG,QAAQ;IACX,GAAG,QAAQ;CACZ;AAED;;;GAGG;AACH,oBAAY,UAAU;IACpB,IAAI,SAAS;IACb,IAAI,SAAS;IACb,IAAI,SAAS;IACb,cAAc,SAAS;IACvB,eAAe,SAAS;CACzB;AAGD,oBAAY,kBAAkB;IAC5B,GAAG,QAAQ;IACX,QAAQ,aAAa;IACrB,SAAS,cAAc;IACvB,IAAI,SAAS;CACd;AAGD,oBAAY,YAAY;IACtB,OAAO,UAAU;IACjB,OAAO,UAAU;IACjB,MAAM,SAAS;IACf,MAAM,SAAS;IACf,KAAK,QAAQ;CACd;AAGD,oBAAY,eAAe,GAAG;IAC5B,SAAS,EAAE,SAAS,CAAC;IACrB,OAAO,EAAE,MAAM,GAAG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;;;GAGG;AACH,MAAM,CAAN,IAAY,UAMX;AAND,WAAY,UAAU;IACpB,2BAAa,CAAA;IACb,2BAAa,CAAA;IACb,2BAAa,CAAA;IACb,qCAAuB,CAAA;IACvB,sCAAwB,CAAA;AAC1B,CAAC,EANW,UAAU,KAAV,UAAU,QAMrB;AAED,cAAc;AACd,MAAM,CAAN,IAAY,kBAKX;AALD,WAAY,kBAAkB;IAC5B,iCAAW,CAAA;IACX,2CAAqB,CAAA;IACrB,6CAAuB,CAAA;IACvB,mCAAa,CAAA;AACf,CAAC,EALW,kBAAkB,KAAlB,kBAAkB,QAK7B;AAED,cAAc;AACd,MAAM,CAAN,IAAY,YAMX;AAND,WAAY,YAAY;IACtB,+BAAiB,CAAA;IACjB,+BAAiB,CAAA;IACjB,6BAAe,CAAA;IACf,6BAAe,CAAA;IACf,2BAAa,CAAA;AACf,CAAC,EANW,YAAY,KAAZ,YAAY,QAMvB;AAyVD,OAAO,EAAsB,gBAAgB,EAA+C,CAAC","sourcesContent":["import {\n PermissionResponse,\n PermissionStatus,\n PermissionExpiration,\n PermissionHookOptions,\n} from 'expo-modules-core';\nimport { ViewProps } from 'react-native';\n\nexport enum CameraType {\n front = 'front',\n back = 'back',\n}\n\nexport enum FlashMode {\n on = 'on',\n off = 'off',\n auto = 'auto',\n torch = 'torch',\n}\n\nexport enum AutoFocus {\n on = 'on',\n off = 'off',\n /**\n * @platform web\n */\n auto = 'auto',\n /**\n * @platform web\n */\n singleShot = 'singleShot',\n}\n\nexport enum WhiteBalance {\n auto = 'auto',\n /**\n * @platform android\n * @platform ios\n */\n sunny = 'sunny',\n /**\n * @platform android\n * @platform ios\n */\n cloudy = 'cloudy',\n /**\n * @platform android\n * @platform ios\n */\n shadow = 'shadow',\n /**\n * @platform android\n * @platform ios\n */\n incandescent = 'incandescent',\n /**\n * @platform android\n * @platform ios\n */\n fluorescent = 'fluorescent',\n /**\n * @platform web\n */\n continuous = 'continuous',\n /**\n * @platform web\n */\n manual = 'manual',\n}\n\nexport enum ImageType {\n png = 'png',\n jpg = 'jpg',\n}\n\n/**\n * This option specifies what codec to use when recording a video.\n * @platform ios\n */\nexport enum VideoCodec {\n H264 = 'avc1',\n HEVC = 'hvc1',\n JPEG = 'jpeg',\n AppleProRes422 = 'apcn',\n AppleProRes4444 = 'ap4h',\n}\n\n// @needsAudit\nexport enum VideoStabilization {\n off = 'off',\n standard = 'standard',\n cinematic = 'cinematic',\n auto = 'auto',\n}\n\n// @needsAudit\nexport enum VideoQuality {\n '2160p' = '2160p',\n '1080p' = '1080p',\n '720p' = '720p',\n '480p' = '480p',\n '4:3' = '4:3',\n}\n\n// @needsAudit\nexport type ImageParameters = {\n imageType: ImageType;\n quality: number | null;\n};\n\nexport type ImageSize = {\n width: number;\n height: number;\n};\n\nexport type WebCameraSettings = Partial<{\n autoFocus: string;\n flashMode: string;\n whiteBalance: string;\n exposureCompensation: number;\n colorTemperature: number;\n iso: number;\n brightness: number;\n contrast: number;\n saturation: number;\n sharpness: number;\n focusDistance: number;\n zoom: number;\n}>;\n\nexport type CameraCapturedPicture = {\n width: number;\n height: number;\n uri: string;\n base64?: string;\n exif?: Partial<MediaTrackSettings> | any;\n};\n\n// @needsAudit @docsMissing\nexport type CameraPictureOptions = {\n /**\n * Specify the quality of compression, from 0 to 1. 0 means compress for small size, 1 means compress for maximum quality.\n */\n quality?: number;\n /**\n * Whether to also include the image data in Base64 format.\n */\n base64?: boolean;\n /**\n * Whether to also include the EXIF data for the image.\n */\n exif?: boolean;\n /**\n * Additional EXIF data to be included for the image. Only useful when `exif` option is set to `true`.\n * @platform android\n * @platform ios\n */\n additionalExif?: { [name: string]: any };\n /**\n * A callback invoked when picture is saved. If set, the promise of this method will resolve immediately with no data after picture is captured.\n * The data that it should contain will be passed to this callback. If displaying or processing a captured photo right after taking it\n * is not your case, this callback lets you skip waiting for it to be saved.\n * @param picture\n */\n onPictureSaved?: (picture: CameraCapturedPicture) => void;\n // TODO(Bacon): Is it possible to implement this in the browser?\n /**\n * If set to `true`, camera skips orientation adjustment and returns an image straight from the device's camera.\n * If enabled, `quality` option is discarded (processing pipeline is skipped as a whole).\n * Although enabling this option reduces image delivery time significantly, it may cause the image to appear in a wrong orientation\n * in the `Image` component (at the time of writing, it does not respect EXIF orientation of the images).\n * > **Note**: Enabling `skipProcessing` would cause orientation uncertainty. `Image` component does not respect EXIF\n * > stored orientation information, that means obtained image would be displayed wrongly (rotated by 90°, 180° or 270°).\n * > Different devices provide different orientations. For example some Sony Xperia or Samsung devices don't provide\n * > correctly oriented images by default. To always obtain correctly oriented image disable `skipProcessing` option.\n */\n skipProcessing?: boolean;\n /**\n * @platform web\n */\n scale?: number;\n /**\n * @platform web\n */\n imageType?: ImageType;\n /**\n * @platform web\n */\n isImageMirror?: boolean;\n /**\n * @hidden\n */\n id?: number;\n /**\n * @hidden\n */\n fastMode?: boolean;\n};\n\n// @needsAudit\nexport type CameraRecordingOptions = {\n /**\n * Maximum video duration in seconds.\n */\n maxDuration?: number;\n /**\n * Maximum video file size in bytes.\n */\n maxFileSize?: number;\n /**\n * Specify the quality of recorded video. Use one of [`VideoQuality.<value>`](#videoquality).\n * Possible values: for 16:9 resolution `2160p`, `1080p`, `720p`, `480p` : `Android only` and for 4:3 `4:3` (the size is 640x480).\n * If the chosen quality is not available for a device, the highest available is chosen.\n */\n quality?: number | string;\n /**\n * If present, video will be recorded with no sound.\n */\n mute?: boolean;\n /**\n * If `true`, the recorded video will be flipped along the vertical axis. iOS flips videos recorded with the front camera by default,\n * but you can reverse that back by setting this to `true`. On Android, this is handled in the user's device settings.\n * @platform ios\n */\n mirror?: boolean;\n /**\n * Only works if `useCamera2Api` is set to `true`. This option specifies a desired video bitrate. For example, `5*1000*1000` would be 5Mbps.\n * @platform android\n */\n videoBitrate?: number;\n /**\n * This option specifies what codec to use when recording the video. See [`VideoCodec`](#videocodec) for the possible values.\n * @platform ios\n */\n codec?: VideoCodec;\n};\n\nexport type PictureSavedListener = (event: {\n nativeEvent: { data: CameraCapturedPicture; id: number };\n}) => void;\n\nexport type CameraReadyListener = () => void;\n\nexport type MountErrorListener = (event: { nativeEvent: CameraMountError }) => void;\n\nexport type CameraMountError = { message: string };\n\nexport type Point = {\n x: number;\n y: number;\n};\n\nexport type BarCodePoint = Point;\n\n// @needsAudit\nexport type BarCodeScanningResult = {\n /**\n * The barcode type.\n */\n type: string;\n /**\n * The information encoded in the bar code.\n */\n data: string;\n /**\n * Corner points of the bounding box.\n */\n cornerPoints?: BarCodePoint[];\n};\n\nexport type Face = {\n faceID: number;\n bounds: {\n origin: Point;\n size: {\n height: number;\n width: number;\n };\n };\n rollAngle: number;\n yawAngle: number;\n smilingProbability: number;\n leftEarPosition: Point;\n rightEarPosition: Point;\n leftEyePosition: Point;\n leftEyeOpenProbability: number;\n rightEyePosition: Point;\n rightEyeOpenProbability: number;\n leftCheekPosition: Point;\n rightCheekPosition: Point;\n mouthPosition: Point;\n leftMouthPosition: Point;\n rightMouthPosition: Point;\n noseBasePosition: Point;\n};\n\nexport type FaceDetectionResult = { faces: Face[] };\n\nexport type ConstantsType = {\n Type: CameraType;\n FlashMode: FlashMode;\n AutoFocus: AutoFocus;\n WhiteBalance: WhiteBalance;\n VideoQuality: VideoQuality;\n VideoStabilization: VideoStabilization;\n VideoCodec: VideoCodec;\n};\n\n// @needsAudit\nexport type CameraProps = ViewProps & {\n /**\n * Camera facing. Use one of `CameraType`. When `CameraType.front`, use the front-facing camera.\n * When `CameraType.back`, use the back-facing camera.\n * @default CameraType.back\n */\n type?: number | CameraType;\n /**\n * Camera flash mode. Use one of [`FlashMode.<value>`](#flashmode-1). When `FlashMode.on`, the flash on your device will\n * turn on when taking a picture, when `FlashMode.off`, it won't. Setting to `FlashMode.auto` will fire flash if required,\n * `FlashMode.torch` turns on flash during the preview.\n * @default FlashMode.off\n */\n flashMode?: number | FlashMode;\n /**\n * Camera white balance. Use one of [`WhiteBalance.<value>`](#whitebalance). If a device does not support any of these values previous one is used.\n * @default WhiteBalance.auto\n */\n whiteBalance?: number | WhiteBalance;\n /**\n * State of camera auto focus. Use one of [`AutoFocus.<value>`](#autofocus-1). When `AutoFocus.on`,\n * auto focus will be enabled, when `AutoFocus.off`, it won't and focus will lock as it was in the moment of change,\n * but it can be adjusted on some devices via `focusDepth` prop.\n * @default AutoFocus.on\n */\n autoFocus?: boolean | number | AutoFocus;\n /**\n * A value between `0` and `1` being a percentage of device's max zoom. `0` - not zoomed, `1` - maximum zoom.\n * @default 0\n */\n zoom?: number;\n /**\n * A string representing aspect ratio of the preview, eg. `4:3`, `16:9`, `1:1`. To check if a ratio is supported\n * by the device use [`getSupportedRatiosAsync`](#getsupportedratiosasync).\n * @default 4:3\n * @platform android\n */\n ratio?: string;\n /**\n * Distance to plane of the sharpest focus. A value between `0` and `1` where: `0` - infinity focus, `1` - focus as close as possible.\n * For Android this is available only for some devices and when `useCamera2Api` is set to `true`.\n * @default 0\n */\n focusDepth?: number;\n /**\n * Callback invoked when camera preview has been set.\n */\n onCameraReady?: () => void;\n /**\n * Whether to use Android's Camera2 API. See `Note` at the top of this page.\n * @platform android\n */\n useCamera2Api?: boolean;\n /**\n * A string representing the size of pictures [`takePictureAsync`](#takepictureasync) will take.\n * Available sizes can be fetched with [`getAvailablePictureSizesAsync`](#getavailablepicturesizesasync).\n */\n pictureSize?: string;\n /**\n * The video stabilization mode used for a video recording. Use one of [`VideoStabilization.<value>`](#videostabilization).\n * You can read more about each stabilization type in [Apple Documentation](https://developer.apple.com/documentation/avfoundation/avcapturevideostabilizationmode).\n * @platform ios\n */\n videoStabilizationMode?: number;\n /**\n * Callback invoked when camera preview could not been started.\n * @param event Error object that contains a `message`.\n */\n onMountError?: (event: CameraMountError) => void;\n /**\n * Settings exposed by [`BarCodeScanner`](bar-code-scanner) module. Supported settings: **barCodeTypes**.\n * @example\n * ```tsx\n * <Camera\n * barCodeScannerSettings={{\n * barCodeTypes: [BarCodeScanner.Constants.BarCodeType.qr],\n * }}\n * />\n * ```\n */\n barCodeScannerSettings?: BarCodeSettings;\n /**\n * Callback that is invoked when a bar code has been successfully scanned. The callback is provided with\n * an object of the [`BarCodeScanningResult`](#barcodescanningresult) shape, where the `type`\n * refers to the bar code type that was scanned and the `data` is the information encoded in the bar code\n * (in this case of QR codes, this is often a URL). See [`BarCodeScanner.Constants.BarCodeType`](bar-code-scanner#supported-formats)\n * for supported values.\n * @param scanningResult\n */\n onBarCodeScanned?: (scanningResult: BarCodeScanningResult) => void;\n /**\n * A settings object passed directly to an underlying module providing face detection features.\n * See [`DetectionOptions`](facedetector/#detectionoptions) in FaceDetector documentation for details.\n */\n faceDetectorSettings?: object;\n /**\n * Callback invoked with results of face detection on the preview. See [FaceDetector documentation](facedetector/#detectionresult) for details.\n * @param faces\n */\n onFacesDetected?: (faces: FaceDetectionResult) => void;\n /**\n * A URL for an image to be shown while the camera is loading.\n * @platform web\n */\n poster?: string;\n};\n\nexport type CameraNativeProps = {\n pointerEvents?: any;\n style?: any;\n ref?: Function;\n onCameraReady?: CameraReadyListener;\n onMountError?: MountErrorListener;\n onBarCodeScanned?: (event: { nativeEvent: BarCodeScanningResult }) => void;\n onFacesDetected?: (event: { nativeEvent: FaceDetectionResult }) => void;\n onFaceDetectionError?: (event: { nativeEvent: Error }) => void;\n onPictureSaved?: PictureSavedListener;\n type?: number | string;\n flashMode?: number | string;\n autoFocus?: string | boolean | number;\n focusDepth?: number;\n zoom?: number;\n whiteBalance?: number | string;\n pictureSize?: string;\n barCodeScannerSettings?: BarCodeSettings;\n faceDetectorSettings?: object;\n barCodeScannerEnabled?: boolean;\n faceDetectorEnabled?: boolean;\n ratio?: string;\n useCamera2Api?: boolean;\n poster?: string;\n};\n\nexport type BarCodeSettings = {\n barCodeTypes: string[];\n interval?: number;\n};\n\nexport { PermissionResponse, PermissionStatus, PermissionExpiration, PermissionHookOptions };\n"]}
|
|
1
|
+
{"version":3,"file":"Camera.types.js","sourceRoot":"","sources":["../src/Camera.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,gBAAgB,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BAAkB;IAC5B,iCAAW,CAAA;IACX,2CAAqB,CAAA;IACrB,6CAAuB,CAAA;IACvB,mCAAa,CAAA;AACf,CAAC,EALW,kBAAkB,KAAlB,kBAAkB,QAK7B;AAED,cAAc;AACd,MAAM,CAAN,IAAY,YAMX;AAND,WAAY,YAAY;IACtB,+BAAiB,CAAA;IACjB,+BAAiB,CAAA;IACjB,6BAAe,CAAA;IACf,6BAAe,CAAA;IACf,2BAAa,CAAA;AACf,CAAC,EANW,YAAY,KAAZ,YAAY,QAMvB;AA4XD,OAAO,EAAsB,gBAAgB,EAA+C,CAAC","sourcesContent":["import {\n PermissionResponse,\n PermissionStatus,\n PermissionExpiration,\n PermissionHookOptions,\n} from 'expo-modules-core';\nimport { ViewProps } from 'react-native';\n\nexport enum CameraType {\n front = 'front',\n back = 'back',\n}\n\nexport enum FlashMode {\n on = 'on',\n off = 'off',\n auto = 'auto',\n torch = 'torch',\n}\n\nexport enum AutoFocus {\n on = 'on',\n off = 'off',\n /**\n * @platform web\n */\n auto = 'auto',\n /**\n * @platform web\n */\n singleShot = 'singleShot',\n}\n\nexport enum WhiteBalance {\n auto = 'auto',\n /**\n * @platform android\n * @platform ios\n */\n sunny = 'sunny',\n /**\n * @platform android\n * @platform ios\n */\n cloudy = 'cloudy',\n /**\n * @platform android\n * @platform ios\n */\n shadow = 'shadow',\n /**\n * @platform android\n * @platform ios\n */\n incandescent = 'incandescent',\n /**\n * @platform android\n * @platform ios\n */\n fluorescent = 'fluorescent',\n /**\n * @platform web\n */\n continuous = 'continuous',\n /**\n * @platform web\n */\n manual = 'manual',\n}\n\nexport enum ImageType {\n png = 'png',\n jpg = 'jpg',\n}\n\n/**\n * This option specifies what codec to use when recording a video.\n * @platform ios\n */\nexport enum VideoCodec {\n H264 = 'avc1',\n HEVC = 'hvc1',\n JPEG = 'jpeg',\n AppleProRes422 = 'apcn',\n AppleProRes4444 = 'ap4h',\n}\n\n// @needsAudit\nexport enum VideoStabilization {\n off = 'off',\n standard = 'standard',\n cinematic = 'cinematic',\n auto = 'auto',\n}\n\n// @needsAudit\nexport enum VideoQuality {\n '2160p' = '2160p',\n '1080p' = '1080p',\n '720p' = '720p',\n '480p' = '480p',\n '4:3' = '4:3',\n}\n\n// @needsAudit\nexport type ImageParameters = {\n imageType: ImageType;\n quality: number | null;\n};\n\nexport type ImageSize = {\n width: number;\n height: number;\n};\n\nexport type WebCameraSettings = Partial<{\n autoFocus: string;\n flashMode: string;\n whiteBalance: string;\n exposureCompensation: number;\n colorTemperature: number;\n iso: number;\n brightness: number;\n contrast: number;\n saturation: number;\n sharpness: number;\n focusDistance: number;\n zoom: number;\n}>;\n\nexport type CameraCapturedPicture = {\n width: number;\n height: number;\n uri: string;\n base64?: string;\n exif?: Partial<MediaTrackSettings> | any;\n};\n\n// @needsAudit @docsMissing\nexport type CameraPictureOptions = {\n /**\n * Specify the quality of compression, from 0 to 1. 0 means compress for small size, 1 means compress for maximum quality.\n */\n quality?: number;\n /**\n * Whether to also include the image data in Base64 format.\n */\n base64?: boolean;\n /**\n * Whether to also include the EXIF data for the image.\n */\n exif?: boolean;\n /**\n * Additional EXIF data to be included for the image. Only useful when `exif` option is set to `true`.\n * @platform android\n * @platform ios\n */\n additionalExif?: { [name: string]: any };\n /**\n * A callback invoked when picture is saved. If set, the promise of this method will resolve immediately with no data after picture is captured.\n * The data that it should contain will be passed to this callback. If displaying or processing a captured photo right after taking it\n * is not your case, this callback lets you skip waiting for it to be saved.\n * @param picture\n */\n onPictureSaved?: (picture: CameraCapturedPicture) => void;\n // TODO(Bacon): Is it possible to implement this in the browser?\n /**\n * If set to `true`, camera skips orientation adjustment and returns an image straight from the device's camera.\n * If enabled, `quality` option is discarded (processing pipeline is skipped as a whole).\n * Although enabling this option reduces image delivery time significantly, it may cause the image to appear in a wrong orientation\n * in the `Image` component (at the time of writing, it does not respect EXIF orientation of the images).\n * > **Note**: Enabling `skipProcessing` would cause orientation uncertainty. `Image` component does not respect EXIF\n * > stored orientation information, that means obtained image would be displayed wrongly (rotated by 90°, 180° or 270°).\n * > Different devices provide different orientations. For example some Sony Xperia or Samsung devices don't provide\n * > correctly oriented images by default. To always obtain correctly oriented image disable `skipProcessing` option.\n */\n skipProcessing?: boolean;\n /**\n * @platform web\n */\n scale?: number;\n /**\n * @platform web\n */\n imageType?: ImageType;\n /**\n * @platform web\n */\n isImageMirror?: boolean;\n /**\n * @hidden\n */\n id?: number;\n /**\n * @hidden\n */\n fastMode?: boolean;\n};\n\n// @needsAudit\nexport type CameraRecordingOptions = {\n /**\n * Maximum video duration in seconds.\n */\n maxDuration?: number;\n /**\n * Maximum video file size in bytes.\n */\n maxFileSize?: number;\n /**\n * Specify the quality of recorded video. Use one of [`VideoQuality.<value>`](#videoquality).\n * Possible values: for 16:9 resolution `2160p`, `1080p`, `720p`, `480p` : `Android only` and for 4:3 `4:3` (the size is 640x480).\n * If the chosen quality is not available for a device, the highest available is chosen.\n */\n quality?: number | string;\n /**\n * If present, video will be recorded with no sound.\n */\n mute?: boolean;\n /**\n * If `true`, the recorded video will be flipped along the vertical axis. iOS flips videos recorded with the front camera by default,\n * but you can reverse that back by setting this to `true`. On Android, this is handled in the user's device settings.\n * @platform ios\n */\n mirror?: boolean;\n /**\n * Only works if `useCamera2Api` is set to `true`. This option specifies a desired video bitrate. For example, `5*1000*1000` would be 5Mbps.\n * @platform android\n */\n videoBitrate?: number;\n /**\n * This option specifies what codec to use when recording the video. See [`VideoCodec`](#videocodec) for the possible values.\n * @platform ios\n */\n codec?: VideoCodec;\n};\n\nexport type PictureSavedListener = (event: {\n nativeEvent: { data: CameraCapturedPicture; id: number };\n}) => void;\n\nexport type CameraReadyListener = () => void;\n\nexport type MountErrorListener = (event: { nativeEvent: CameraMountError }) => void;\n\nexport type CameraMountError = { message: string };\n\nexport type Point = {\n x: number;\n y: number;\n};\n\nexport type BarCodeSize = {\n /**\n * The height value.\n */\n height: number;\n /**\n * The width value.\n */\n width: number;\n};\n\n/**\n * These coordinates are represented in the coordinate space of the camera source (e.g. when you\n * are using the camera view, these values are adjusted to the dimensions of the view).\n */\nexport type BarCodePoint = Point;\n\nexport type BarCodeBounds = {\n /**\n * The origin point of the bounding box.\n */\n origin: BarCodePoint;\n /**\n * The size of the bounding box.\n */\n size: BarCodeSize;\n};\n\n// @needsAudit\nexport type BarCodeScanningResult = {\n /**\n * The barcode type.\n */\n type: string;\n /**\n * The information encoded in the bar code.\n */\n data: string;\n /**\n * Corner points of the bounding box.\n * `cornerPoints` is not always available and may be empty. On iOS, for `code39` and `pdf417`\n * you don't get this value.\n */\n cornerPoints: BarCodePoint[];\n /**\n * The [BarCodeBounds](#barcodebounds) object.\n * `bounds` in some case will be representing an empty rectangle.\n * Moreover, `bounds` doesn't have to bound the whole barcode.\n * For some types, they will represent the area used by the scanner.\n */\n bounds: BarCodeBounds;\n};\n\nexport type Face = {\n faceID: number;\n bounds: {\n origin: Point;\n size: {\n height: number;\n width: number;\n };\n };\n rollAngle: number;\n yawAngle: number;\n smilingProbability: number;\n leftEarPosition: Point;\n rightEarPosition: Point;\n leftEyePosition: Point;\n leftEyeOpenProbability: number;\n rightEyePosition: Point;\n rightEyeOpenProbability: number;\n leftCheekPosition: Point;\n rightCheekPosition: Point;\n mouthPosition: Point;\n leftMouthPosition: Point;\n rightMouthPosition: Point;\n noseBasePosition: Point;\n};\n\nexport type FaceDetectionResult = { faces: Face[] };\n\nexport type ConstantsType = {\n Type: CameraType;\n FlashMode: FlashMode;\n AutoFocus: AutoFocus;\n WhiteBalance: WhiteBalance;\n VideoQuality: VideoQuality;\n VideoStabilization: VideoStabilization;\n VideoCodec: VideoCodec;\n};\n\n// @needsAudit\nexport type CameraProps = ViewProps & {\n /**\n * Camera facing. Use one of `CameraType`. When `CameraType.front`, use the front-facing camera.\n * When `CameraType.back`, use the back-facing camera.\n * @default CameraType.back\n */\n type?: number | CameraType;\n /**\n * Camera flash mode. Use one of [`FlashMode.<value>`](#flashmode-1). When `FlashMode.on`, the flash on your device will\n * turn on when taking a picture, when `FlashMode.off`, it won't. Setting to `FlashMode.auto` will fire flash if required,\n * `FlashMode.torch` turns on flash during the preview.\n * @default FlashMode.off\n */\n flashMode?: number | FlashMode;\n /**\n * Camera white balance. Use one of [`WhiteBalance.<value>`](#whitebalance). If a device does not support any of these values previous one is used.\n * @default WhiteBalance.auto\n */\n whiteBalance?: number | WhiteBalance;\n /**\n * State of camera auto focus. Use one of [`AutoFocus.<value>`](#autofocus-1). When `AutoFocus.on`,\n * auto focus will be enabled, when `AutoFocus.off`, it won't and focus will lock as it was in the moment of change,\n * but it can be adjusted on some devices via `focusDepth` prop.\n * @default AutoFocus.on\n */\n autoFocus?: boolean | number | AutoFocus;\n /**\n * A value between `0` and `1` being a percentage of device's max zoom. `0` - not zoomed, `1` - maximum zoom.\n * @default 0\n */\n zoom?: number;\n /**\n * A string representing aspect ratio of the preview, eg. `4:3`, `16:9`, `1:1`. To check if a ratio is supported\n * by the device use [`getSupportedRatiosAsync`](#getsupportedratiosasync).\n * @default 4:3\n * @platform android\n */\n ratio?: string;\n /**\n * Distance to plane of the sharpest focus. A value between `0` and `1` where: `0` - infinity focus, `1` - focus as close as possible.\n * For Android this is available only for some devices and when `useCamera2Api` is set to `true`.\n * @default 0\n */\n focusDepth?: number;\n /**\n * Callback invoked when camera preview has been set.\n */\n onCameraReady?: () => void;\n /**\n * Whether to use Android's Camera2 API. See `Note` at the top of this page.\n * @platform android\n */\n useCamera2Api?: boolean;\n /**\n * A string representing the size of pictures [`takePictureAsync`](#takepictureasync) will take.\n * Available sizes can be fetched with [`getAvailablePictureSizesAsync`](#getavailablepicturesizesasync).\n */\n pictureSize?: string;\n /**\n * The video stabilization mode used for a video recording. Use one of [`VideoStabilization.<value>`](#videostabilization).\n * You can read more about each stabilization type in [Apple Documentation](https://developer.apple.com/documentation/avfoundation/avcapturevideostabilizationmode).\n * @platform ios\n */\n videoStabilizationMode?: number;\n /**\n * Callback invoked when camera preview could not been started.\n * @param event Error object that contains a `message`.\n */\n onMountError?: (event: CameraMountError) => void;\n /**\n * Settings exposed by [`BarCodeScanner`](bar-code-scanner) module. Supported settings: **barCodeTypes**.\n * @example\n * ```tsx\n * <Camera\n * barCodeScannerSettings={{\n * barCodeTypes: [BarCodeScanner.Constants.BarCodeType.qr],\n * }}\n * />\n * ```\n */\n barCodeScannerSettings?: BarCodeSettings;\n /**\n * Callback that is invoked when a bar code has been successfully scanned. The callback is provided with\n * an object of the [`BarCodeScanningResult`](#barcodescanningresult) shape, where the `type`\n * refers to the bar code type that was scanned and the `data` is the information encoded in the bar code\n * (in this case of QR codes, this is often a URL). See [`BarCodeScanner.Constants.BarCodeType`](bar-code-scanner#supported-formats)\n * for supported values.\n * @param scanningResult\n */\n onBarCodeScanned?: (scanningResult: BarCodeScanningResult) => void;\n /**\n * A settings object passed directly to an underlying module providing face detection features.\n * See [`DetectionOptions`](facedetector/#detectionoptions) in FaceDetector documentation for details.\n */\n faceDetectorSettings?: object;\n /**\n * Callback invoked with results of face detection on the preview. See [FaceDetector documentation](facedetector/#detectionresult) for details.\n * @param faces\n */\n onFacesDetected?: (faces: FaceDetectionResult) => void;\n /**\n * A URL for an image to be shown while the camera is loading.\n * @platform web\n */\n poster?: string;\n};\n\nexport type CameraNativeProps = {\n pointerEvents?: any;\n style?: any;\n ref?: Function;\n onCameraReady?: CameraReadyListener;\n onMountError?: MountErrorListener;\n onBarCodeScanned?: (event: { nativeEvent: BarCodeScanningResult }) => void;\n onFacesDetected?: (event: { nativeEvent: FaceDetectionResult }) => void;\n onFaceDetectionError?: (event: { nativeEvent: Error }) => void;\n onPictureSaved?: PictureSavedListener;\n type?: number | string;\n flashMode?: number | string;\n autoFocus?: string | boolean | number;\n focusDepth?: number;\n zoom?: number;\n whiteBalance?: number | string;\n pictureSize?: string;\n barCodeScannerSettings?: BarCodeSettings;\n faceDetectorSettings?: object;\n barCodeScannerEnabled?: boolean;\n faceDetectorEnabled?: boolean;\n ratio?: string;\n useCamera2Api?: boolean;\n poster?: string;\n};\n\nexport type BarCodeSettings = {\n barCodeTypes: string[];\n interval?: number;\n};\n\nexport { PermissionResponse, PermissionStatus, PermissionExpiration, PermissionHookOptions };\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useWebQRScanner.d.ts","sourceRoot":"","sources":["../src/useWebQRScanner.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"useWebQRScanner.d.ts","sourceRoot":"","sources":["../src/useWebQRScanner.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AA2CjG,wBAAgB,eAAe,CAC7B,KAAK,EAAE,KAAK,CAAC,gBAAgB,CAAC,gBAAgB,GAAG,IAAI,CAAC,EACtD,EACE,SAAS,EACT,cAAc,EACd,QAAQ,EACR,SAAS,EACT,OAAO,GACR,EAAE;IACD,SAAS,EAAE,OAAO,CAAC;IACnB,cAAc,EAAE,IAAI,CAAC,oBAAoB,EAAE,OAAO,GAAG,eAAe,CAAC,CAAC;IACtE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,CAAC,cAAc,EAAE;QAAE,WAAW,EAAE,qBAAqB,CAAA;KAAE,KAAK,IAAI,CAAC;IAC7E,OAAO,CAAC,EAAE,kBAAkB,CAAC;CAC9B,QA8DF"}
|
package/build/useWebQRScanner.js
CHANGED
|
@@ -17,6 +17,8 @@ const qrWorkerMethod = ({ data, width, height }) => {
|
|
|
17
17
|
const nativeEvent = {
|
|
18
18
|
type: 'qr',
|
|
19
19
|
data: parsed.data,
|
|
20
|
+
cornerPoints: [],
|
|
21
|
+
bounds: { origin: { x: 0, y: 0 }, size: { width: 0, height: 0 } },
|
|
20
22
|
};
|
|
21
23
|
if (parsed.location) {
|
|
22
24
|
nativeEvent.cornerPoints = [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useWebQRScanner.js","sourceRoot":"","sources":["../src/useWebQRScanner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpD,MAAM,cAAc,GAAG,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAa,EAAO,EAAE;IACjE,oCAAoC;IACpC,MAAM,OAAO,GAAI,IAAY,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE;QACtD,iBAAiB,EAAE,aAAa;KACjC,CAAC,CAAC;IAEH,IAAI,MAAM,CAAC;IACX,IAAI;QACF,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;KAC9B;IAAC,MAAM;QACN,MAAM,GAAG,OAAO,CAAC;KAClB;IAED,IAAI,MAAM,EAAE,IAAI,EAAE;QAChB,MAAM,WAAW,GAA0B;YACzC,IAAI,EAAE,IAAI;YACV,IAAI,EAAE,MAAM,CAAC,IAAI;
|
|
1
|
+
{"version":3,"file":"useWebQRScanner.js","sourceRoot":"","sources":["../src/useWebQRScanner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpD,MAAM,cAAc,GAAG,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAa,EAAO,EAAE;IACjE,oCAAoC;IACpC,MAAM,OAAO,GAAI,IAAY,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE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IAAI,EAAE,CAAC;SACR;IACH,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC;IAEhB,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,OAAO,GAAG,EAAE;YACV,IAAI,EAAE,CAAC;YACP,WAAW,CAAC,IAAI,EAAE,CAAC;QACrB,CAAC,CAAC;IACJ,CAAC,EAAE,EAAE,CAAC,CAAC;AACT,CAAC","sourcesContent":["import { useWorker } from '@koale/useworker';\nimport * as React from 'react';\n\nimport { BarCodeScanningResult, CameraPictureOptions, MountErrorListener } from './Camera.types';\nimport { captureImageData } from './WebCameraUtils';\n\nconst qrWorkerMethod = ({ data, width, height }: ImageData): any => {\n // eslint-disable-next-line no-undef\n const decoded = (self as any).jsQR(data, width, height, {\n inversionAttempts: 'attemptBoth',\n });\n\n let parsed;\n try {\n parsed = JSON.parse(decoded);\n } catch {\n parsed = decoded;\n }\n\n if (parsed?.data) {\n const nativeEvent: BarCodeScanningResult = {\n type: 'qr',\n data: parsed.data,\n cornerPoints: [],\n bounds: { origin: { x: 0, y: 0 }, size: { width: 0, height: 0 } },\n };\n if (parsed.location) {\n nativeEvent.cornerPoints = [\n parsed.location.topLeftCorner,\n parsed.location.bottomLeftCorner,\n parsed.location.topRightCorner,\n parsed.location.bottomRightCorner,\n ];\n }\n return nativeEvent;\n }\n return parsed;\n};\n\nfunction useRemoteJsQR() {\n return useWorker(qrWorkerMethod, {\n remoteDependencies: ['https://cdn.jsdelivr.net/npm/jsqr@1.2.0/dist/jsQR.min.js'],\n autoTerminate: false,\n });\n}\n\nexport function useWebQRScanner(\n video: React.MutableRefObject<HTMLVideoElement | null>,\n {\n isEnabled,\n captureOptions,\n interval,\n onScanned,\n onError,\n }: {\n isEnabled: boolean;\n captureOptions: Pick<CameraPictureOptions, 'scale' | 'isImageMirror'>;\n interval?: number;\n onScanned?: (scanningResult: { nativeEvent: BarCodeScanningResult }) => void;\n onError?: MountErrorListener;\n }\n) {\n const isRunning = React.useRef<boolean>(false);\n const timeout = React.useRef<number | undefined>(undefined);\n\n const [decode, clearWorker] = useRemoteJsQR();\n\n async function scanAsync() {\n // If interval is 0 then only scan once.\n if (!isRunning.current || !onScanned) {\n stop();\n return;\n }\n try {\n const data = captureImageData(video.current, captureOptions);\n\n if (data) {\n const nativeEvent: BarCodeScanningResult | any = await decode(data);\n if (nativeEvent?.data) {\n onScanned({\n nativeEvent,\n });\n }\n }\n } catch (error) {\n if (onError) {\n onError({ nativeEvent: error });\n }\n } finally {\n // If interval is 0 then only scan once.\n if (interval === 0) {\n stop();\n return;\n }\n const intervalToUse = !interval || interval < 0 ? 16 : interval;\n // @ts-ignore: Type 'Timeout' is not assignable to type 'number'\n timeout.current = setTimeout(() => {\n scanAsync();\n }, intervalToUse);\n }\n }\n\n function stop() {\n isRunning.current = false;\n clearTimeout(timeout.current);\n }\n\n React.useEffect(() => {\n if (isEnabled) {\n isRunning.current = true;\n scanAsync();\n } else {\n stop();\n }\n }, [isEnabled]);\n\n React.useEffect(() => {\n return () => {\n stop();\n clearWorker.kill();\n };\n }, []);\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-camera",
|
|
3
|
-
"version": "13.0.0
|
|
3
|
+
"version": "13.0.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",
|
|
@@ -38,10 +38,10 @@
|
|
|
38
38
|
"invariant": "^2.2.4"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"expo-module-scripts": "^
|
|
41
|
+
"expo-module-scripts": "^3.0.0"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
44
|
"expo": "*"
|
|
45
45
|
},
|
|
46
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "eab2b09c735fb0fc2bf734a3f29a6593adba3838"
|
|
47
47
|
}
|
package/src/Camera.tsx
CHANGED
|
@@ -384,6 +384,7 @@ export default class Camera extends React.Component<CameraProps> {
|
|
|
384
384
|
const onBarCodeScanned = this.props.onBarCodeScanned
|
|
385
385
|
? this._onObjectDetected(this.props.onBarCodeScanned)
|
|
386
386
|
: undefined;
|
|
387
|
+
|
|
387
388
|
const onFacesDetected = this._onObjectDetected(this.props.onFacesDetected);
|
|
388
389
|
|
|
389
390
|
return (
|
package/src/Camera.types.ts
CHANGED
|
@@ -250,8 +250,34 @@ export type Point = {
|
|
|
250
250
|
y: number;
|
|
251
251
|
};
|
|
252
252
|
|
|
253
|
+
export type BarCodeSize = {
|
|
254
|
+
/**
|
|
255
|
+
* The height value.
|
|
256
|
+
*/
|
|
257
|
+
height: number;
|
|
258
|
+
/**
|
|
259
|
+
* The width value.
|
|
260
|
+
*/
|
|
261
|
+
width: number;
|
|
262
|
+
};
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* These coordinates are represented in the coordinate space of the camera source (e.g. when you
|
|
266
|
+
* are using the camera view, these values are adjusted to the dimensions of the view).
|
|
267
|
+
*/
|
|
253
268
|
export type BarCodePoint = Point;
|
|
254
269
|
|
|
270
|
+
export type BarCodeBounds = {
|
|
271
|
+
/**
|
|
272
|
+
* The origin point of the bounding box.
|
|
273
|
+
*/
|
|
274
|
+
origin: BarCodePoint;
|
|
275
|
+
/**
|
|
276
|
+
* The size of the bounding box.
|
|
277
|
+
*/
|
|
278
|
+
size: BarCodeSize;
|
|
279
|
+
};
|
|
280
|
+
|
|
255
281
|
// @needsAudit
|
|
256
282
|
export type BarCodeScanningResult = {
|
|
257
283
|
/**
|
|
@@ -264,8 +290,17 @@ export type BarCodeScanningResult = {
|
|
|
264
290
|
data: string;
|
|
265
291
|
/**
|
|
266
292
|
* Corner points of the bounding box.
|
|
293
|
+
* `cornerPoints` is not always available and may be empty. On iOS, for `code39` and `pdf417`
|
|
294
|
+
* you don't get this value.
|
|
295
|
+
*/
|
|
296
|
+
cornerPoints: BarCodePoint[];
|
|
297
|
+
/**
|
|
298
|
+
* The [BarCodeBounds](#barcodebounds) object.
|
|
299
|
+
* `bounds` in some case will be representing an empty rectangle.
|
|
300
|
+
* Moreover, `bounds` doesn't have to bound the whole barcode.
|
|
301
|
+
* For some types, they will represent the area used by the scanner.
|
|
267
302
|
*/
|
|
268
|
-
|
|
303
|
+
bounds: BarCodeBounds;
|
|
269
304
|
};
|
|
270
305
|
|
|
271
306
|
export type Face = {
|
package/src/useWebQRScanner.ts
CHANGED
|
@@ -21,6 +21,8 @@ const qrWorkerMethod = ({ data, width, height }: ImageData): any => {
|
|
|
21
21
|
const nativeEvent: BarCodeScanningResult = {
|
|
22
22
|
type: 'qr',
|
|
23
23
|
data: parsed.data,
|
|
24
|
+
cornerPoints: [],
|
|
25
|
+
bounds: { origin: { x: 0, y: 0 }, size: { width: 0, height: 0 } },
|
|
24
26
|
};
|
|
25
27
|
if (parsed.location) {
|
|
26
28
|
nativeEvent.cornerPoints = [
|