capacitor-camera-view 2.0.1 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. package/README.md +19 -9
  2. package/android/build.gradle +8 -5
  3. package/android/src/main/java/com/michaelwolz/capacitorcameraview/CameraView.kt +217 -126
  4. package/android/src/main/java/com/michaelwolz/capacitorcameraview/CameraViewPlugin.kt +70 -30
  5. package/android/src/main/java/com/michaelwolz/capacitorcameraview/model/CameraResult.kt +47 -0
  6. package/android/src/main/java/com/michaelwolz/capacitorcameraview/model/CameraSessionConfiguration.kt +11 -1
  7. package/android/src/main/java/com/michaelwolz/capacitorcameraview/utils.kt +94 -5
  8. package/dist/docs.json +81 -0
  9. package/dist/esm/definitions.d.ts +44 -0
  10. package/dist/esm/definitions.js.map +1 -1
  11. package/dist/esm/web.d.ts +7 -1
  12. package/dist/esm/web.js +67 -2
  13. package/dist/esm/web.js.map +1 -1
  14. package/dist/plugin.cjs.js +68 -2
  15. package/dist/plugin.cjs.js.map +1 -1
  16. package/dist/plugin.js +68 -2
  17. package/dist/plugin.js.map +1 -1
  18. package/ios/Sources/CameraViewPlugin/CameraError.swift +97 -2
  19. package/ios/Sources/CameraViewPlugin/CameraEvents.swift +109 -0
  20. package/ios/Sources/CameraViewPlugin/CameraSessionConfiguration.swift +29 -2
  21. package/ios/Sources/CameraViewPlugin/CameraViewManager+BarcodeScan.swift +30 -41
  22. package/ios/Sources/CameraViewPlugin/CameraViewManager+PhotoCapture.swift +45 -13
  23. package/ios/Sources/CameraViewPlugin/CameraViewManager+VideoDataOutput.swift +4 -3
  24. package/ios/Sources/CameraViewPlugin/CameraViewManager.swift +193 -59
  25. package/ios/Sources/CameraViewPlugin/CameraViewPlugin.swift +83 -84
  26. package/ios/Sources/CameraViewPlugin/TempFileManager.swift +181 -0
  27. package/ios/Sources/CameraViewPlugin/Utils.swift +102 -0
  28. package/package.json +17 -17
@@ -12,12 +12,24 @@ import com.getcapacitor.annotation.CapacitorPlugin
12
12
  import com.getcapacitor.annotation.Permission
13
13
  import com.getcapacitor.annotation.PermissionCallback
14
14
  import com.michaelwolz.capacitorcameraview.model.BarcodeDetectionResult
15
+ import kotlinx.coroutines.CoroutineScope
16
+ import kotlinx.coroutines.Dispatchers
17
+ import kotlinx.coroutines.Job
18
+ import kotlinx.coroutines.SupervisorJob
19
+ import kotlinx.coroutines.cancel
20
+ import kotlinx.coroutines.launch
15
21
 
16
22
  @CapacitorPlugin(
17
23
  name = "CameraView",
18
24
  permissions = [Permission(strings = [Manifest.permission.CAMERA], alias = "camera")]
19
25
  )
20
26
  class CameraViewPlugin : Plugin() {
27
+ // Coroutine scope for async operations
28
+ private val pluginScope = CoroutineScope(SupervisorJob() + Dispatchers.Main.immediate)
29
+
30
+ // Job for barcode event subscription
31
+ private var barcodeJob: Job? = null
32
+
21
33
  private val implementation by lazy {
22
34
  CameraView(this)
23
35
  }
@@ -41,26 +53,42 @@ class CameraViewPlugin : Plugin() {
41
53
  }
42
54
 
43
55
  private fun startCamera(call: PluginCall) {
44
- implementation.startSession(
45
- config = sessionConfigFromPluginCall(call),
46
- callback = { error ->
47
- if (error != null) {
48
- call.reject("Failed to start camera preview: ${error.localizedMessage}", error)
49
- } else {
56
+ val config = sessionConfigFromPluginCall(call)
57
+
58
+ pluginScope.launch {
59
+ implementation.startSessionAsync(config).fold(
60
+ onSuccess = {
61
+ // Subscribe to barcode events if detection is enabled
62
+ if (config.enableBarcodeDetection) {
63
+ barcodeJob?.cancel()
64
+ barcodeJob = pluginScope.launch {
65
+ implementation.barcodeEvents.collect { result ->
66
+ notifyBarcodeDetected(result)
67
+ }
68
+ }
69
+ }
50
70
  call.resolve()
71
+ },
72
+ onError = { error ->
73
+ call.reject("Failed to start camera preview: ${error.localizedMessage}", error)
51
74
  }
52
- }
53
- )
75
+ )
76
+ }
54
77
  }
55
78
 
56
79
  @PluginMethod
57
80
  fun stop(call: PluginCall) {
58
- implementation.stopSession { error ->
59
- if (error != null) {
60
- call.reject("Failed to stop camera preview: ${error.localizedMessage}", error)
61
- } else {
62
- call.resolve()
63
- }
81
+ // Cancel barcode subscription
82
+ barcodeJob?.cancel()
83
+ barcodeJob = null
84
+
85
+ pluginScope.launch {
86
+ implementation.stopSessionAsync().fold(
87
+ onSuccess = { call.resolve() },
88
+ onError = { error ->
89
+ call.reject("Failed to stop camera preview: ${error.localizedMessage}", error)
90
+ }
91
+ )
64
92
  }
65
93
  }
66
94
 
@@ -74,7 +102,7 @@ class CameraViewPlugin : Plugin() {
74
102
 
75
103
  @PluginMethod
76
104
  fun capture(call: PluginCall) {
77
- val timeStart = System.currentTimeMillis();
105
+ val timeStart = System.currentTimeMillis()
78
106
  val quality = call.getInt("quality") ?: 90
79
107
  val saveToFile = call.getBoolean("saveToFile") ?: false
80
108
 
@@ -83,19 +111,23 @@ class CameraViewPlugin : Plugin() {
83
111
  return
84
112
  }
85
113
 
86
- implementation.capturePhoto(quality, saveToFile) { result, error ->
87
- when {
88
- error != null -> call.reject("Failed to capture image: ${error.message}", error)
89
- result == null -> call.reject("No image data")
90
- else -> call.resolve(result)
91
- }
92
- Log.d(TAG, "capture took ${System.currentTimeMillis() - timeStart}ms")
114
+ pluginScope.launch {
115
+ implementation.capturePhotoAsync(quality, saveToFile).fold(
116
+ onSuccess = { result ->
117
+ call.resolve(result)
118
+ Log.d(TAG, "capture took ${System.currentTimeMillis() - timeStart}ms")
119
+ },
120
+ onError = { error ->
121
+ call.reject("Failed to capture image: ${error.message}", error)
122
+ Log.d(TAG, "capture failed after ${System.currentTimeMillis() - timeStart}ms")
123
+ }
124
+ )
93
125
  }
94
126
  }
95
127
 
96
128
  @PluginMethod
97
129
  fun captureSample(call: PluginCall) {
98
- val timeStart = System.currentTimeMillis();
130
+ val timeStart = System.currentTimeMillis()
99
131
  val quality = call.getInt("quality") ?: 90
100
132
  val saveToFile = call.getBoolean("saveToFile") ?: false
101
133
 
@@ -104,13 +136,17 @@ class CameraViewPlugin : Plugin() {
104
136
  return
105
137
  }
106
138
 
107
- implementation.captureSampleFromPreview(quality, saveToFile) { result, error ->
108
- when {
109
- error != null -> call.reject("Failed to capture frame: ${error.message}", error)
110
- result == null -> call.reject("No frame data")
111
- else -> call.resolve(result)
112
- }
113
- Log.d(TAG, "captureSample took ${System.currentTimeMillis() - timeStart}ms")
139
+ pluginScope.launch {
140
+ implementation.captureSampleFromPreviewAsync(quality, saveToFile).fold(
141
+ onSuccess = { result ->
142
+ call.resolve(result)
143
+ Log.d(TAG, "captureSample took ${System.currentTimeMillis() - timeStart}ms")
144
+ },
145
+ onError = { error ->
146
+ call.reject("Failed to capture frame: ${error.message}", error)
147
+ Log.d(TAG, "captureSample failed after ${System.currentTimeMillis() - timeStart}ms")
148
+ }
149
+ )
114
150
  }
115
151
  }
116
152
 
@@ -268,6 +304,10 @@ class CameraViewPlugin : Plugin() {
268
304
  }
269
305
 
270
306
  override fun handleOnDestroy() {
307
+ // Cancel barcode subscription and plugin scope
308
+ barcodeJob?.cancel()
309
+ pluginScope.cancel()
310
+
271
311
  implementation.cleanup()
272
312
  super.handleOnDestroy()
273
313
  }
@@ -0,0 +1,47 @@
1
+ package com.michaelwolz.capacitorcameraview.model
2
+
3
+ /**
4
+ * A Result type for consistent error handling throughout camera operations.
5
+ * Provides a functional approach to handling success and error cases.
6
+ */
7
+ sealed class CameraResult<out T> {
8
+ data class Success<T>(val value: T) : CameraResult<T>()
9
+ data class Error(val exception: Exception) : CameraResult<Nothing>()
10
+
11
+ /**
12
+ * Transforms this result using the provided functions.
13
+ */
14
+ inline fun <R> fold(
15
+ onSuccess: (T) -> R,
16
+ onError: (Exception) -> R
17
+ ): R = when (this) {
18
+ is Success -> onSuccess(value)
19
+ is Error -> onError(exception)
20
+ }
21
+
22
+ /**
23
+ * Returns the value if Success, null otherwise.
24
+ */
25
+ fun getOrNull(): T? = when (this) {
26
+ is Success -> value
27
+ is Error -> null
28
+ }
29
+
30
+ /**
31
+ * Returns the exception if Error, null otherwise.
32
+ */
33
+ fun exceptionOrNull(): Exception? = when (this) {
34
+ is Success -> null
35
+ is Error -> exception
36
+ }
37
+
38
+ /**
39
+ * Returns true if this is a Success.
40
+ */
41
+ val isSuccess: Boolean get() = this is Success
42
+
43
+ /**
44
+ * Returns true if this is an Error.
45
+ */
46
+ val isError: Boolean get() = this is Error
47
+ }
@@ -1,9 +1,19 @@
1
1
  package com.michaelwolz.capacitorcameraview.model
2
2
 
3
- /** Configuration for a camera session. */
3
+ /**
4
+ * Configuration for a camera session.
5
+ *
6
+ * @property deviceId Specific device ID to use. Takes precedence over position.
7
+ * @property enableBarcodeDetection Whether to enable barcode detection.
8
+ * @property barcodeTypes Optional list of specific barcode format codes to detect.
9
+ * If null, all supported formats are detected.
10
+ * @property position Camera position to use ("front" or "back").
11
+ * @property zoomFactor Initial zoom factor.
12
+ */
4
13
  data class CameraSessionConfiguration(
5
14
  val deviceId: String? = null,
6
15
  val enableBarcodeDetection: Boolean = false,
16
+ val barcodeTypes: List<Int>? = null,
7
17
  val position: String = "back",
8
18
  val zoomFactor: Float = 1.0f
9
19
  )
@@ -16,6 +16,49 @@ import com.michaelwolz.capacitorcameraview.model.CameraSessionConfiguration
16
16
  import com.michaelwolz.capacitorcameraview.model.WebBoundingRect
17
17
  import java.io.ByteArrayOutputStream
18
18
 
19
+ /**
20
+ * Memory-efficient Base64 encoding utilities.
21
+ * Uses ThreadLocal ByteArrayOutputStream pool to reduce allocation churn.
22
+ */
23
+ object StreamingBase64Encoder {
24
+ // Reusable ByteArrayOutputStream to reduce allocation churn (per-thread)
25
+ private val outputStreamPool = object : ThreadLocal<ByteArrayOutputStream>() {
26
+ override fun initialValue(): ByteArrayOutputStream {
27
+ return ByteArrayOutputStream(256 * 1024) // 256KB initial capacity
28
+ }
29
+ }
30
+
31
+ /**
32
+ * Encodes a bitmap to Base64 with memory optimization.
33
+ * Reuses ByteArrayOutputStream to reduce allocations.
34
+ *
35
+ * @param bitmap The bitmap to encode
36
+ * @param quality JPEG compression quality (0-100)
37
+ * @param format Compression format (default JPEG)
38
+ * @return Base64 encoded string
39
+ */
40
+ fun encodeToBase64(
41
+ bitmap: Bitmap,
42
+ quality: Int,
43
+ format: Bitmap.CompressFormat = Bitmap.CompressFormat.JPEG
44
+ ): String {
45
+ val outputStream = outputStreamPool.get()!!
46
+ outputStream.reset() // Clear previous data
47
+
48
+ bitmap.compress(format, quality, outputStream)
49
+ val byteArray = outputStream.toByteArray()
50
+
51
+ return Base64.encodeToString(byteArray, Base64.NO_WRAP)
52
+ }
53
+
54
+ /**
55
+ * Encodes raw byte array to Base64.
56
+ */
57
+ fun encodeToBase64(bytes: ByteArray): String {
58
+ return Base64.encodeToString(bytes, Base64.NO_WRAP)
59
+ }
60
+ }
61
+
19
62
  /** Converts a barcode format code to a readable string. */
20
63
  fun getBarcodeFormatString(format: Int): String {
21
64
  return when (format) {
@@ -36,6 +79,43 @@ fun getBarcodeFormatString(format: Int): String {
36
79
  }
37
80
  }
38
81
 
82
+ /**
83
+ * Converts a string barcode type from JavaScript to ML Kit Barcode format constant.
84
+ *
85
+ * @param stringType The string barcode type from JavaScript.
86
+ * @return The corresponding ML Kit Barcode format constant, or null if not recognized.
87
+ */
88
+ fun convertToNativeBarcodeFormat(stringType: String): Int? {
89
+ return when (stringType) {
90
+ "qr" -> Barcode.FORMAT_QR_CODE
91
+ "aztec" -> Barcode.FORMAT_AZTEC
92
+ "codabar" -> Barcode.FORMAT_CODABAR
93
+ "code39" -> Barcode.FORMAT_CODE_39
94
+ "code39Mod43" -> Barcode.FORMAT_CODE_39 // ML Kit doesn't distinguish Mod43
95
+ "code93" -> Barcode.FORMAT_CODE_93
96
+ "code128" -> Barcode.FORMAT_CODE_128
97
+ "dataMatrix" -> Barcode.FORMAT_DATA_MATRIX
98
+ "ean8" -> Barcode.FORMAT_EAN_8
99
+ "ean13" -> Barcode.FORMAT_EAN_13
100
+ "interleaved2of5" -> Barcode.FORMAT_ITF
101
+ "itf14" -> Barcode.FORMAT_ITF
102
+ "pdf417" -> Barcode.FORMAT_PDF417
103
+ "upcA" -> Barcode.FORMAT_UPC_A
104
+ "upce" -> Barcode.FORMAT_UPC_E
105
+ else -> null
106
+ }
107
+ }
108
+
109
+ /**
110
+ * Converts an array of string barcode types to ML Kit Barcode format constants.
111
+ *
112
+ * @param stringTypes List of string barcode types from JavaScript.
113
+ * @return List of ML Kit Barcode format constants (invalid types are filtered out).
114
+ */
115
+ fun convertToNativeBarcodeFormats(stringTypes: List<String>): List<Int> {
116
+ return stringTypes.mapNotNull { convertToNativeBarcodeFormat(it) }.distinct()
117
+ }
118
+
39
119
  /**
40
120
  * Converts the bounding box of a barcode detection result to a [WebBoundingRect]
41
121
  * suitable for use in the web view via regular CSS pixels.
@@ -84,9 +164,20 @@ fun calculateTopOffset(webView: View): Int {
84
164
 
85
165
  /** Maps a Capacitor plugin call to a [CameraSessionConfiguration]. */
86
166
  fun sessionConfigFromPluginCall(call: PluginCall): CameraSessionConfiguration {
167
+ // Parse barcode types if provided
168
+ val barcodeTypes: List<Int>? = call.getArray("barcodeTypes")?.let { jsonArray ->
169
+ val stringTypes = mutableListOf<String>()
170
+ for (i in 0 until jsonArray.length()) {
171
+ jsonArray.optString(i)?.let { stringTypes.add(it) }
172
+ }
173
+ val converted = convertToNativeBarcodeFormats(stringTypes)
174
+ if (converted.isNotEmpty()) converted else null
175
+ }
176
+
87
177
  return CameraSessionConfiguration(
88
178
  deviceId = call.getString("deviceId"),
89
179
  enableBarcodeDetection = call.getBoolean("enableBarcodeDetection") ?: false,
180
+ barcodeTypes = barcodeTypes,
90
181
  position = call.getString("position") ?: "back",
91
182
  zoomFactor = call.getFloat("zoomFactor") ?: 1.0f
92
183
  )
@@ -126,6 +217,7 @@ fun calculateImageRotationBasedOnDisplayRotation(
126
217
 
127
218
  /**
128
219
  * Converts an ImageProxy to a Base64 encoded string and applies rotation if necessary.
220
+ * Uses StreamingBase64Encoder for memory-efficient encoding.
129
221
  *
130
222
  * @param image The ImageProxy to convert.
131
223
  * @param quality The JPEG compression quality (0-100).
@@ -152,11 +244,8 @@ fun imageProxyToBase64(image: ImageProxy, quality: Int, rotationDegrees: Int): S
152
244
  bitmap = rotatedBitmap
153
245
  }
154
246
 
155
- val outputStream = ByteArrayOutputStream()
156
- bitmap.compress(Bitmap.CompressFormat.JPEG, quality, outputStream)
157
- val byteArray = outputStream.toByteArray()
158
-
159
- return Base64.encodeToString(byteArray, Base64.NO_WRAP)
247
+ // Use streaming encoder for memory efficiency
248
+ return StreamingBase64Encoder.encodeToBase64(bitmap, quality)
160
249
  } finally {
161
250
  // Ensure bitmap is always recycled
162
251
  bitmap.recycle()
package/dist/docs.json CHANGED
@@ -561,6 +561,28 @@
561
561
  "complexTypes": [],
562
562
  "type": "boolean | undefined"
563
563
  },
564
+ {
565
+ "name": "barcodeTypes",
566
+ "tags": [
567
+ {
568
+ "text": "['qr', 'code128'] // Only detect QR codes and Code 128 barcodes",
569
+ "name": "example"
570
+ },
571
+ {
572
+ "text": "undefined - all supported types are detected",
573
+ "name": "default"
574
+ },
575
+ {
576
+ "text": "2.1.0",
577
+ "name": "since"
578
+ }
579
+ ],
580
+ "docs": "Specific barcode types to detect. If not provided, all supported types are detected.\nSpecifying only the types you need can significantly improve performance and reduce\nbattery consumption, especially on mobile devices.",
581
+ "complexTypes": [
582
+ "BarcodeType"
583
+ ],
584
+ "type": "BarcodeType[] | undefined"
585
+ },
564
586
  {
565
587
  "name": "position",
566
588
  "tags": [
@@ -1028,6 +1050,65 @@
1028
1050
  ],
1029
1051
  "enums": [],
1030
1052
  "typeAliases": [
1053
+ {
1054
+ "name": "BarcodeType",
1055
+ "slug": "barcodetype",
1056
+ "docs": "Supported barcode types for detection.\nSpecifying only the barcode types you need can improve performance\nand reduce battery consumption.",
1057
+ "types": [
1058
+ {
1059
+ "text": "'qr'",
1060
+ "complexTypes": []
1061
+ },
1062
+ {
1063
+ "text": "'code128'",
1064
+ "complexTypes": []
1065
+ },
1066
+ {
1067
+ "text": "'code39'",
1068
+ "complexTypes": []
1069
+ },
1070
+ {
1071
+ "text": "'code39Mod43'",
1072
+ "complexTypes": []
1073
+ },
1074
+ {
1075
+ "text": "'code93'",
1076
+ "complexTypes": []
1077
+ },
1078
+ {
1079
+ "text": "'ean8'",
1080
+ "complexTypes": []
1081
+ },
1082
+ {
1083
+ "text": "'ean13'",
1084
+ "complexTypes": []
1085
+ },
1086
+ {
1087
+ "text": "'interleaved2of5'",
1088
+ "complexTypes": []
1089
+ },
1090
+ {
1091
+ "text": "'itf14'",
1092
+ "complexTypes": []
1093
+ },
1094
+ {
1095
+ "text": "'pdf417'",
1096
+ "complexTypes": []
1097
+ },
1098
+ {
1099
+ "text": "'aztec'",
1100
+ "complexTypes": []
1101
+ },
1102
+ {
1103
+ "text": "'dataMatrix'",
1104
+ "complexTypes": []
1105
+ },
1106
+ {
1107
+ "text": "'upce'",
1108
+ "complexTypes": []
1109
+ }
1110
+ ]
1111
+ },
1031
1112
  {
1032
1113
  "name": "CameraPosition",
1033
1114
  "slug": "cameraposition",
@@ -268,6 +268,40 @@ export type CameraDeviceType =
268
268
  | 'triple'
269
269
  /** builtInTrueDepthCamera - front-facing camera with depth sensing */
270
270
  | 'trueDepth';
271
+ /**
272
+ * Supported barcode types for detection.
273
+ * Specifying only the barcode types you need can improve performance
274
+ * and reduce battery consumption.
275
+ *
276
+ * @since 2.1.0
277
+ */
278
+ export type BarcodeType =
279
+ /** QR Code */
280
+ 'qr'
281
+ /** Code 128 barcode */
282
+ | 'code128'
283
+ /** Code 39 barcode */
284
+ | 'code39'
285
+ /** Code 39 Mod 43 barcode */
286
+ | 'code39Mod43'
287
+ /** Code 93 barcode */
288
+ | 'code93'
289
+ /** EAN-8 barcode */
290
+ | 'ean8'
291
+ /** EAN-13 barcode */
292
+ | 'ean13'
293
+ /** Interleaved 2 of 5 barcode */
294
+ | 'interleaved2of5'
295
+ /** ITF-14 barcode */
296
+ | 'itf14'
297
+ /** PDF417 barcode */
298
+ | 'pdf417'
299
+ /** Aztec code */
300
+ | 'aztec'
301
+ /** Data Matrix code */
302
+ | 'dataMatrix'
303
+ /** UPC-E barcode */
304
+ | 'upce';
271
305
  /**
272
306
  * Configuration options for starting a camera session.
273
307
  *
@@ -279,6 +313,16 @@ export interface CameraSessionConfiguration {
279
313
  * @default false
280
314
  */
281
315
  enableBarcodeDetection?: boolean;
316
+ /**
317
+ * Specific barcode types to detect. If not provided, all supported types are detected.
318
+ * Specifying only the types you need can significantly improve performance and reduce
319
+ * battery consumption, especially on mobile devices.
320
+ *
321
+ * @example ['qr', 'code128'] // Only detect QR codes and Code 128 barcodes
322
+ * @default undefined - all supported types are detected
323
+ * @since 2.1.0
324
+ */
325
+ barcodeTypes?: BarcodeType[];
282
326
  /**
283
327
  * Position of the camera to use
284
328
  * @default 'back'
@@ -1 +1 @@
1
- {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["import type { PermissionState, PluginListenerHandle } from '@capacitor/core';\n\n/**\n * Main plugin interface for Capacitor Camera View functionality.\n *\n * @since 1.0.0\n */\nexport interface CameraViewPlugin {\n /**\n * Start the camera view with optional configuration.\n *\n * @param options - Configuration options for the camera session\n * @returns A promise that resolves when the camera has started\n *\n * @since 1.0.0\n */\n start(options?: CameraSessionConfiguration): Promise<void>;\n\n /**\n * Stop the camera view and release resources.\n *\n * @returns A promise that resolves when the camera has stopped\n *\n * @since 1.0.0\n */\n stop(): Promise<void>;\n\n /**\n * Check if the camera view is currently running.\n *\n * @returns A promise that resolves with an object containing the running state of the camera\n *\n * @since 1.0.0\n */\n isRunning(): Promise<IsRunningResponse>;\n\n /**\n * Capture a photo using the current camera configuration.\n *\n * @param options - Capture configuration options\n * @returns A promise that resolves with an object containing either a base64 encoded string or file path of the captured photo\n *\n * @since 1.0.0\n */\n capture<T extends CaptureOptions>(options: T): Promise<CaptureResponse<T>>;\n\n /**\n * Captures a frame from the current camera preview without using the full camera capture pipeline.\n *\n * Unlike `capture()` which may trigger hardware-level photo capture on native platforms,\n * this method quickly samples the current video stream. This is suitable computer vision or\n * simple snapshots where high fidelity is not required.\n *\n * On web this method does exactly the same as `capture()` as it only captures a frame from the video stream\n * because unfortunately [ImageCapture API](https://developer.mozilla.org/en-US/docs/Web/API/ImageCapture) is\n * not yet well supported on the web.\n *\n * @param options - Capture configuration options\n * @returns A promise that resolves with an object containing either a base64 encoded string or file path of the captured sample\n *\n * @since 1.0.0\n */\n captureSample<T extends CaptureOptions>(options: T): Promise<CaptureResponse<T>>;\n\n /**\n * Switch between front and back camera.\n *\n * @returns A promise that resolves when the camera has been flipped\n *\n * @since 1.0.0\n */\n flipCamera(): Promise<void>;\n\n /**\n * Get available camera devices for capturing photos.\n *\n * @returns A promise that resolves with an object containing an array of available capture devices\n *\n * @since 1.0.0\n */\n getAvailableDevices(): Promise<GetAvailableDevicesResponse>;\n\n /**\n * Get current zoom level information and available range.\n *\n * @remarks\n * Make sure the camera is properly initialized before calling this method. Otherwise, this might\n * lead to returning default values on android.\n *\n * @returns A promise that resolves with an object containing min, max and current zoom levels\n *\n * @since 1.0.0\n */\n getZoom(): Promise<GetZoomResponse>;\n\n /**\n * Set the camera zoom level.\n *\n * @param options - Zoom configuration options\n * @param options.level - The zoom level to set\n * @param options.ramp - Whether to animate the zoom level change, defaults to false (iOS only)\n * @returns A promise that resolves when the zoom level has been set\n *\n * @remarks\n * On web platforms, zoom functionality may be limited by browser support.\n * When native zoom is not available, a CSS-based zoom simulation is applied.\n *\n * @since 1.0.0\n */\n setZoom(options: { level: number; ramp?: boolean }): Promise<void>;\n\n /**\n * Get current flash mode setting.\n *\n * @returns A promise that resolves with an object containing the current flash mode\n *\n * @since 1.0.0\n */\n getFlashMode(): Promise<GetFlashModeResponse>;\n\n /**\n * Get supported flash modes for the current camera.\n *\n * @returns A promise that resolves with an object containing an array of supported flash modes\n *\n * @since 1.0.0\n */\n getSupportedFlashModes(): Promise<GetSupportedFlashModesResponse>;\n\n /**\n * Set the camera flash mode.\n *\n * @param options - Flash mode configuration options\n * @param options.mode - The flash mode to set\n * @returns A promise that resolves when the flash mode has been set\n *\n * @since 1.0.0\n */\n setFlashMode(options: { mode: FlashMode }): Promise<void>;\n\n /**\n * Check if the device supports torch (flashlight) functionality.\n *\n * @remarks\n * **Important**: You must call this method and verify torch availability before using\n * `setTorchMode()` or `getTorchMode()`. Calling torch methods on devices without\n * torch support will throw an exception.\n *\n * @returns A promise that resolves with an object containing torch availability status\n *\n * @since 1.2.0\n */\n isTorchAvailable(): Promise<IsTorchAvailableResponse>;\n\n /**\n * Get the current torch (flashlight) state.\n *\n * @remarks\n * **Important**: Call `isTorchAvailable()` first to ensure the device supports torch\n * functionality. This method will throw an exception if torch is not supported.\n *\n * @returns A promise that resolves with an object containing the current torch state\n *\n * @since 1.2.0\n */\n getTorchMode(): Promise<GetTorchModeResponse>;\n\n /**\n * Set the torch (flashlight) mode and intensity.\n *\n * @remarks\n * **Important**: Call `isTorchAvailable()` first to ensure the device supports torch\n * functionality. This method will throw an exception if torch is not supported.\n *\n * The torch provides continuous illumination, unlike flash which only activates during photo capture.\n * On iOS, you can control the torch intensity level. On Android, the torch is either on or off.\n *\n * @param options - Torch configuration options\n * @param options.enabled - Whether to enable or disable the torch\n * @param options.level - The torch intensity level (0.0 to 1.0, iOS only). Defaults to 1.0 when enabled\n * @returns A promise that resolves when the torch mode has been set\n *\n * @since 1.2.0\n */\n setTorchMode(options: { enabled: boolean; level?: number }): Promise<void>;\n\n /**\n * Check camera permission status without requesting permissions.\n *\n * @returns A promise that resolves with an object containing the camera permission status\n *\n * @since 1.0.0\n */\n checkPermissions(): Promise<PermissionStatus>;\n\n /**\n * Request camera permission from the user.\n *\n * @returns A promise that resolves with an object containing the camera permission status\n *\n * @since 1.0.0\n */\n requestPermissions(): Promise<PermissionStatus>;\n\n /**\n * Listen for barcode detection events.\n * This event is emitted when a barcode is detected in the camera preview.\n *\n * @param eventName - The name of the event to listen for ('barcodeDetected')\n * @param listenerFunc - The callback function to execute when a barcode is detected\n * @returns A promise that resolves with an event subscription\n *\n * @since 1.0.0\n */\n addListener(\n eventName: 'barcodeDetected',\n listenerFunc: (data: BarcodeDetectionData) => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Remove all listeners for this plugin.\n *\n * @param eventName - Optional event name to remove listeners for\n * @returns A promise that resolves when the listeners are removed\n *\n * @since 1.0.0\n */\n removeAllListeners(eventName?: string): Promise<void>;\n}\n\n// ------------------------------------------------------------------------------\n// Camera Configuration Types\n// ------------------------------------------------------------------------------\n\n/**\n * Position options for the camera.\n * - 'front': Front-facing camera\n * - 'back': Rear-facing camera\n *\n * @since 1.0.0\n */\nexport type CameraPosition = 'front' | 'back';\n\n/**\n * Flash mode options for the camera.\n * - 'off': Flash disabled\n * - 'on': Flash always on\n * - 'auto': Flash automatically enabled in low-light conditions\n *\n * @since 1.0.0\n */\nexport type FlashMode = 'off' | 'on' | 'auto';\n\n/**\n * Represents a physical camera device on the device.\n *\n * @since 1.0.0\n */\nexport interface CameraDevice {\n /** The unique identifier of the camera device */\n id: string;\n\n /** The human-readable name of the camera device */\n name: string;\n\n /** The position of the camera device (front or back) */\n position: CameraPosition;\n\n /** The type of the camera device (e.g., wide, ultra-wide, telephoto) - iOS only */\n deviceType?: CameraDeviceType;\n}\n\n/**\n * Available camera device types for iOS.\n * Maps to AVCaptureDevice DeviceTypes in iOS.\n *\n * @see https://developer.apple.com/documentation/avfoundation/avcapturedevice/devicetype-swift.struct\n *\n * @since 1.0.0\n */\nexport type CameraDeviceType =\n /** builtInWideAngleCamera - standard camera */\n | 'wideAngle'\n /** builtInUltraWideCamera - 0.5x zoom level */\n | 'ultraWide'\n /** builtInTelephotoCamera - 2x/3x zoom level */\n | 'telephoto'\n /** builtInDualCamera - wide + telephoto combination */\n | 'dual'\n /** builtInDualWideCamera - wide + ultraWide combination */\n | 'dualWide'\n /** builtInTripleCamera - wide + ultraWide + telephoto */\n | 'triple'\n /** builtInTrueDepthCamera - front-facing camera with depth sensing */\n | 'trueDepth';\n\n/**\n * Configuration options for starting a camera session.\n *\n * @since 1.0.0\n */\nexport interface CameraSessionConfiguration {\n /**\n * Enables the barcode detection functionality\n * @default false\n */\n enableBarcodeDetection?: boolean;\n\n /**\n * Position of the camera to use\n * @default 'back'\n */\n position?: CameraPosition;\n\n /**\n * Specific device ID of the camera to use\n * If provided, takes precedence over position\n */\n deviceId?: string;\n\n /**\n * Whether to use the triple camera if available (iPhone Pro models only)\n * @default false\n */\n useTripleCameraIfAvailable?: boolean;\n\n /**\n * Ordered list of preferred camera device types to use (iOS only).\n * The system will attempt to use the first available camera type in the list.\n * If position is also provided, the system will use the first available camera type\n * that matches the position and is in the list.\n *\n * This will fallback to the default camera type if none of the preferred types are available.\n *\n * @example [CameraDeviceType.WideAngle, CameraDeviceType.UltraWide, CameraDeviceType.Telephoto]\n * @default undefined - system will decide based on position/deviceId\n */\n preferredCameraDeviceTypes?: CameraDeviceType[];\n\n /**\n * The initial zoom factor to use\n * @default 1.0\n */\n zoomFactor?: number;\n\n /**\n * Optional HTML ID of the container element where the camera view should be rendered.\n * If not provided, the camera view will be appended to the document body. Web only.\n * @example 'cameraContainer'\n */\n containerElementId?: string;\n}\n\n/**\n * Configuration options for capturing photos and samples.\n *\n * @since 1.1.0\n */\nexport interface CaptureOptions {\n /**\n * The JPEG quality of the captured photo/sample on a scale of 0-100\n * @since 1.1.0\n */\n quality: number;\n\n /**\n * If true, saves to a temporary file and returns the web path instead of base64.\n * The web path can be used to set the src attribute of an image for efficient loading and rendering.\n * This reduces the data that needs to be transferred over the bridge, which can improve performance\n * especially for high-resolution images.\n * @default false\n * @since 1.1.0\n */\n saveToFile?: boolean;\n}\n\n// ------------------------------------------------------------------------------\n// Response Interfaces\n// ------------------------------------------------------------------------------\n\n/**\n * Response for checking if the camera view is running.\n *\n * @since 1.0.0\n */\nexport interface IsRunningResponse {\n /** Indicates if the camera view is currently active and running */\n isRunning: boolean;\n}\n\n/**\n * Response for capturing a photo\n * This will contain either a base64 encoded string or a web path to the captured photo,\n * depending on the `saveToFile` option in the CaptureOptions.\n * @since 1.0.0\n */\nexport type CaptureResponse<T extends CaptureOptions = CaptureOptions> = T['saveToFile'] extends true\n ? {\n /** The web path to the captured photo that can be used to set the src attribute of an image for efficient loading and rendering (when saveToFile is true) */\n webPath: string;\n }\n : {\n /** The base64 encoded string of the captured photo (when saveToFile is false or undefined) */\n photo: string;\n };\n\n/**\n * Response for getting available camera devices.\n *\n * @since 1.0.0\n */\nexport interface GetAvailableDevicesResponse {\n /** An array of available camera devices */\n devices: CameraDevice[];\n}\n\n/**\n * Response for getting zoom level information.\n *\n * @since 1.0.0\n */\nexport interface GetZoomResponse {\n /** The minimum zoom level supported */\n min: number;\n\n /** The maximum zoom level supported */\n max: number;\n\n /** The current zoom level */\n current: number;\n}\n\n/**\n * Response for getting the current flash mode.\n *\n * @since 1.0.0\n */\nexport interface GetFlashModeResponse {\n /** The current flash mode setting */\n flashMode: FlashMode;\n}\n\n/**\n * Response for getting supported flash modes.\n *\n * @since 1.0.0\n */\nexport interface GetSupportedFlashModesResponse {\n /** An array of flash modes supported by the current camera */\n flashModes: FlashMode[];\n}\n\n/**\n * Response for checking torch availability.\n *\n * @since 1.2.0\n */\nexport interface IsTorchAvailableResponse {\n /** Indicates if the device supports torch (flashlight) functionality */\n available: boolean;\n}\n\n/**\n * Response for getting the current torch mode.\n *\n * @since 1.2.0\n */\nexport interface GetTorchModeResponse {\n /** Indicates if the torch is currently enabled */\n enabled: boolean;\n /** The current torch intensity level (0.0 to 1.0, iOS only). Always 1.0 on Android when enabled */\n level: number;\n}\n\n/**\n * Data for a detected barcode.\n *\n * @since 1.0.0\n */\nexport interface BarcodeDetectionData {\n /** The decoded string value of the barcode */\n value: string;\n\n /** The display value of the barcode (may differ from the raw value) */\n displayValue?: string;\n\n /** The type/format of the barcode (e.g., 'qr', 'code128', etc.) */\n type: string;\n\n /** The bounding rectangle of the barcode in the camera frame. */\n boundingRect: BoundingRect;\n}\n\n/**\n * Rectangle defining the boundary of the barcode in the camera frame.\n * Coordinates are normalized between 0 and 1 relative to the camera frame.\n *\n * @since 1.0.0\n */\nexport interface BoundingRect {\n /** X-coordinate of the top-left corner */\n x: number;\n /** Y-coordinate of the top-left corner */\n y: number;\n /** Width of the bounding rectangle (should match the actual width of the barcode) */\n width: number;\n /** Height of the bounding rectangle (should match the actual height of the barcode) */\n height: number;\n}\n\n/**\n * Response for the camera permission status.\n *\n * @since 1.0.0\n */\nexport interface PermissionStatus {\n /** The state of the camera permission */\n camera: PermissionState;\n}\n"]}
1
+ {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["import type { PermissionState, PluginListenerHandle } from '@capacitor/core';\n\n/**\n * Main plugin interface for Capacitor Camera View functionality.\n *\n * @since 1.0.0\n */\nexport interface CameraViewPlugin {\n /**\n * Start the camera view with optional configuration.\n *\n * @param options - Configuration options for the camera session\n * @returns A promise that resolves when the camera has started\n *\n * @since 1.0.0\n */\n start(options?: CameraSessionConfiguration): Promise<void>;\n\n /**\n * Stop the camera view and release resources.\n *\n * @returns A promise that resolves when the camera has stopped\n *\n * @since 1.0.0\n */\n stop(): Promise<void>;\n\n /**\n * Check if the camera view is currently running.\n *\n * @returns A promise that resolves with an object containing the running state of the camera\n *\n * @since 1.0.0\n */\n isRunning(): Promise<IsRunningResponse>;\n\n /**\n * Capture a photo using the current camera configuration.\n *\n * @param options - Capture configuration options\n * @returns A promise that resolves with an object containing either a base64 encoded string or file path of the captured photo\n *\n * @since 1.0.0\n */\n capture<T extends CaptureOptions>(options: T): Promise<CaptureResponse<T>>;\n\n /**\n * Captures a frame from the current camera preview without using the full camera capture pipeline.\n *\n * Unlike `capture()` which may trigger hardware-level photo capture on native platforms,\n * this method quickly samples the current video stream. This is suitable computer vision or\n * simple snapshots where high fidelity is not required.\n *\n * On web this method does exactly the same as `capture()` as it only captures a frame from the video stream\n * because unfortunately [ImageCapture API](https://developer.mozilla.org/en-US/docs/Web/API/ImageCapture) is\n * not yet well supported on the web.\n *\n * @param options - Capture configuration options\n * @returns A promise that resolves with an object containing either a base64 encoded string or file path of the captured sample\n *\n * @since 1.0.0\n */\n captureSample<T extends CaptureOptions>(options: T): Promise<CaptureResponse<T>>;\n\n /**\n * Switch between front and back camera.\n *\n * @returns A promise that resolves when the camera has been flipped\n *\n * @since 1.0.0\n */\n flipCamera(): Promise<void>;\n\n /**\n * Get available camera devices for capturing photos.\n *\n * @returns A promise that resolves with an object containing an array of available capture devices\n *\n * @since 1.0.0\n */\n getAvailableDevices(): Promise<GetAvailableDevicesResponse>;\n\n /**\n * Get current zoom level information and available range.\n *\n * @remarks\n * Make sure the camera is properly initialized before calling this method. Otherwise, this might\n * lead to returning default values on android.\n *\n * @returns A promise that resolves with an object containing min, max and current zoom levels\n *\n * @since 1.0.0\n */\n getZoom(): Promise<GetZoomResponse>;\n\n /**\n * Set the camera zoom level.\n *\n * @param options - Zoom configuration options\n * @param options.level - The zoom level to set\n * @param options.ramp - Whether to animate the zoom level change, defaults to false (iOS only)\n * @returns A promise that resolves when the zoom level has been set\n *\n * @remarks\n * On web platforms, zoom functionality may be limited by browser support.\n * When native zoom is not available, a CSS-based zoom simulation is applied.\n *\n * @since 1.0.0\n */\n setZoom(options: { level: number; ramp?: boolean }): Promise<void>;\n\n /**\n * Get current flash mode setting.\n *\n * @returns A promise that resolves with an object containing the current flash mode\n *\n * @since 1.0.0\n */\n getFlashMode(): Promise<GetFlashModeResponse>;\n\n /**\n * Get supported flash modes for the current camera.\n *\n * @returns A promise that resolves with an object containing an array of supported flash modes\n *\n * @since 1.0.0\n */\n getSupportedFlashModes(): Promise<GetSupportedFlashModesResponse>;\n\n /**\n * Set the camera flash mode.\n *\n * @param options - Flash mode configuration options\n * @param options.mode - The flash mode to set\n * @returns A promise that resolves when the flash mode has been set\n *\n * @since 1.0.0\n */\n setFlashMode(options: { mode: FlashMode }): Promise<void>;\n\n /**\n * Check if the device supports torch (flashlight) functionality.\n *\n * @remarks\n * **Important**: You must call this method and verify torch availability before using\n * `setTorchMode()` or `getTorchMode()`. Calling torch methods on devices without\n * torch support will throw an exception.\n *\n * @returns A promise that resolves with an object containing torch availability status\n *\n * @since 1.2.0\n */\n isTorchAvailable(): Promise<IsTorchAvailableResponse>;\n\n /**\n * Get the current torch (flashlight) state.\n *\n * @remarks\n * **Important**: Call `isTorchAvailable()` first to ensure the device supports torch\n * functionality. This method will throw an exception if torch is not supported.\n *\n * @returns A promise that resolves with an object containing the current torch state\n *\n * @since 1.2.0\n */\n getTorchMode(): Promise<GetTorchModeResponse>;\n\n /**\n * Set the torch (flashlight) mode and intensity.\n *\n * @remarks\n * **Important**: Call `isTorchAvailable()` first to ensure the device supports torch\n * functionality. This method will throw an exception if torch is not supported.\n *\n * The torch provides continuous illumination, unlike flash which only activates during photo capture.\n * On iOS, you can control the torch intensity level. On Android, the torch is either on or off.\n *\n * @param options - Torch configuration options\n * @param options.enabled - Whether to enable or disable the torch\n * @param options.level - The torch intensity level (0.0 to 1.0, iOS only). Defaults to 1.0 when enabled\n * @returns A promise that resolves when the torch mode has been set\n *\n * @since 1.2.0\n */\n setTorchMode(options: { enabled: boolean; level?: number }): Promise<void>;\n\n /**\n * Check camera permission status without requesting permissions.\n *\n * @returns A promise that resolves with an object containing the camera permission status\n *\n * @since 1.0.0\n */\n checkPermissions(): Promise<PermissionStatus>;\n\n /**\n * Request camera permission from the user.\n *\n * @returns A promise that resolves with an object containing the camera permission status\n *\n * @since 1.0.0\n */\n requestPermissions(): Promise<PermissionStatus>;\n\n /**\n * Listen for barcode detection events.\n * This event is emitted when a barcode is detected in the camera preview.\n *\n * @param eventName - The name of the event to listen for ('barcodeDetected')\n * @param listenerFunc - The callback function to execute when a barcode is detected\n * @returns A promise that resolves with an event subscription\n *\n * @since 1.0.0\n */\n addListener(\n eventName: 'barcodeDetected',\n listenerFunc: (data: BarcodeDetectionData) => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Remove all listeners for this plugin.\n *\n * @param eventName - Optional event name to remove listeners for\n * @returns A promise that resolves when the listeners are removed\n *\n * @since 1.0.0\n */\n removeAllListeners(eventName?: string): Promise<void>;\n}\n\n// ------------------------------------------------------------------------------\n// Camera Configuration Types\n// ------------------------------------------------------------------------------\n\n/**\n * Position options for the camera.\n * - 'front': Front-facing camera\n * - 'back': Rear-facing camera\n *\n * @since 1.0.0\n */\nexport type CameraPosition = 'front' | 'back';\n\n/**\n * Flash mode options for the camera.\n * - 'off': Flash disabled\n * - 'on': Flash always on\n * - 'auto': Flash automatically enabled in low-light conditions\n *\n * @since 1.0.0\n */\nexport type FlashMode = 'off' | 'on' | 'auto';\n\n/**\n * Represents a physical camera device on the device.\n *\n * @since 1.0.0\n */\nexport interface CameraDevice {\n /** The unique identifier of the camera device */\n id: string;\n\n /** The human-readable name of the camera device */\n name: string;\n\n /** The position of the camera device (front or back) */\n position: CameraPosition;\n\n /** The type of the camera device (e.g., wide, ultra-wide, telephoto) - iOS only */\n deviceType?: CameraDeviceType;\n}\n\n/**\n * Available camera device types for iOS.\n * Maps to AVCaptureDevice DeviceTypes in iOS.\n *\n * @see https://developer.apple.com/documentation/avfoundation/avcapturedevice/devicetype-swift.struct\n *\n * @since 1.0.0\n */\nexport type CameraDeviceType =\n /** builtInWideAngleCamera - standard camera */\n | 'wideAngle'\n /** builtInUltraWideCamera - 0.5x zoom level */\n | 'ultraWide'\n /** builtInTelephotoCamera - 2x/3x zoom level */\n | 'telephoto'\n /** builtInDualCamera - wide + telephoto combination */\n | 'dual'\n /** builtInDualWideCamera - wide + ultraWide combination */\n | 'dualWide'\n /** builtInTripleCamera - wide + ultraWide + telephoto */\n | 'triple'\n /** builtInTrueDepthCamera - front-facing camera with depth sensing */\n | 'trueDepth';\n\n/**\n * Supported barcode types for detection.\n * Specifying only the barcode types you need can improve performance\n * and reduce battery consumption.\n *\n * @since 2.1.0\n */\nexport type BarcodeType =\n /** QR Code */\n | 'qr'\n /** Code 128 barcode */\n | 'code128'\n /** Code 39 barcode */\n | 'code39'\n /** Code 39 Mod 43 barcode */\n | 'code39Mod43'\n /** Code 93 barcode */\n | 'code93'\n /** EAN-8 barcode */\n | 'ean8'\n /** EAN-13 barcode */\n | 'ean13'\n /** Interleaved 2 of 5 barcode */\n | 'interleaved2of5'\n /** ITF-14 barcode */\n | 'itf14'\n /** PDF417 barcode */\n | 'pdf417'\n /** Aztec code */\n | 'aztec'\n /** Data Matrix code */\n | 'dataMatrix'\n /** UPC-E barcode */\n | 'upce';\n\n/**\n * Configuration options for starting a camera session.\n *\n * @since 1.0.0\n */\nexport interface CameraSessionConfiguration {\n /**\n * Enables the barcode detection functionality\n * @default false\n */\n enableBarcodeDetection?: boolean;\n\n /**\n * Specific barcode types to detect. If not provided, all supported types are detected.\n * Specifying only the types you need can significantly improve performance and reduce\n * battery consumption, especially on mobile devices.\n *\n * @example ['qr', 'code128'] // Only detect QR codes and Code 128 barcodes\n * @default undefined - all supported types are detected\n * @since 2.1.0\n */\n barcodeTypes?: BarcodeType[];\n\n /**\n * Position of the camera to use\n * @default 'back'\n */\n position?: CameraPosition;\n\n /**\n * Specific device ID of the camera to use\n * If provided, takes precedence over position\n */\n deviceId?: string;\n\n /**\n * Whether to use the triple camera if available (iPhone Pro models only)\n * @default false\n */\n useTripleCameraIfAvailable?: boolean;\n\n /**\n * Ordered list of preferred camera device types to use (iOS only).\n * The system will attempt to use the first available camera type in the list.\n * If position is also provided, the system will use the first available camera type\n * that matches the position and is in the list.\n *\n * This will fallback to the default camera type if none of the preferred types are available.\n *\n * @example [CameraDeviceType.WideAngle, CameraDeviceType.UltraWide, CameraDeviceType.Telephoto]\n * @default undefined - system will decide based on position/deviceId\n */\n preferredCameraDeviceTypes?: CameraDeviceType[];\n\n /**\n * The initial zoom factor to use\n * @default 1.0\n */\n zoomFactor?: number;\n\n /**\n * Optional HTML ID of the container element where the camera view should be rendered.\n * If not provided, the camera view will be appended to the document body. Web only.\n * @example 'cameraContainer'\n */\n containerElementId?: string;\n}\n\n/**\n * Configuration options for capturing photos and samples.\n *\n * @since 1.1.0\n */\nexport interface CaptureOptions {\n /**\n * The JPEG quality of the captured photo/sample on a scale of 0-100\n * @since 1.1.0\n */\n quality: number;\n\n /**\n * If true, saves to a temporary file and returns the web path instead of base64.\n * The web path can be used to set the src attribute of an image for efficient loading and rendering.\n * This reduces the data that needs to be transferred over the bridge, which can improve performance\n * especially for high-resolution images.\n * @default false\n * @since 1.1.0\n */\n saveToFile?: boolean;\n}\n\n// ------------------------------------------------------------------------------\n// Response Interfaces\n// ------------------------------------------------------------------------------\n\n/**\n * Response for checking if the camera view is running.\n *\n * @since 1.0.0\n */\nexport interface IsRunningResponse {\n /** Indicates if the camera view is currently active and running */\n isRunning: boolean;\n}\n\n/**\n * Response for capturing a photo\n * This will contain either a base64 encoded string or a web path to the captured photo,\n * depending on the `saveToFile` option in the CaptureOptions.\n * @since 1.0.0\n */\nexport type CaptureResponse<T extends CaptureOptions = CaptureOptions> = T['saveToFile'] extends true\n ? {\n /** The web path to the captured photo that can be used to set the src attribute of an image for efficient loading and rendering (when saveToFile is true) */\n webPath: string;\n }\n : {\n /** The base64 encoded string of the captured photo (when saveToFile is false or undefined) */\n photo: string;\n };\n\n/**\n * Response for getting available camera devices.\n *\n * @since 1.0.0\n */\nexport interface GetAvailableDevicesResponse {\n /** An array of available camera devices */\n devices: CameraDevice[];\n}\n\n/**\n * Response for getting zoom level information.\n *\n * @since 1.0.0\n */\nexport interface GetZoomResponse {\n /** The minimum zoom level supported */\n min: number;\n\n /** The maximum zoom level supported */\n max: number;\n\n /** The current zoom level */\n current: number;\n}\n\n/**\n * Response for getting the current flash mode.\n *\n * @since 1.0.0\n */\nexport interface GetFlashModeResponse {\n /** The current flash mode setting */\n flashMode: FlashMode;\n}\n\n/**\n * Response for getting supported flash modes.\n *\n * @since 1.0.0\n */\nexport interface GetSupportedFlashModesResponse {\n /** An array of flash modes supported by the current camera */\n flashModes: FlashMode[];\n}\n\n/**\n * Response for checking torch availability.\n *\n * @since 1.2.0\n */\nexport interface IsTorchAvailableResponse {\n /** Indicates if the device supports torch (flashlight) functionality */\n available: boolean;\n}\n\n/**\n * Response for getting the current torch mode.\n *\n * @since 1.2.0\n */\nexport interface GetTorchModeResponse {\n /** Indicates if the torch is currently enabled */\n enabled: boolean;\n /** The current torch intensity level (0.0 to 1.0, iOS only). Always 1.0 on Android when enabled */\n level: number;\n}\n\n/**\n * Data for a detected barcode.\n *\n * @since 1.0.0\n */\nexport interface BarcodeDetectionData {\n /** The decoded string value of the barcode */\n value: string;\n\n /** The display value of the barcode (may differ from the raw value) */\n displayValue?: string;\n\n /** The type/format of the barcode (e.g., 'qr', 'code128', etc.) */\n type: string;\n\n /** The bounding rectangle of the barcode in the camera frame. */\n boundingRect: BoundingRect;\n}\n\n/**\n * Rectangle defining the boundary of the barcode in the camera frame.\n * Coordinates are normalized between 0 and 1 relative to the camera frame.\n *\n * @since 1.0.0\n */\nexport interface BoundingRect {\n /** X-coordinate of the top-left corner */\n x: number;\n /** Y-coordinate of the top-left corner */\n y: number;\n /** Width of the bounding rectangle (should match the actual width of the barcode) */\n width: number;\n /** Height of the bounding rectangle (should match the actual height of the barcode) */\n height: number;\n}\n\n/**\n * Response for the camera permission status.\n *\n * @since 1.0.0\n */\nexport interface PermissionStatus {\n /** The state of the camera permission */\n camera: PermissionState;\n}\n"]}
package/dist/esm/web.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { WebPlugin } from '@capacitor/core';
2
- import type { CameraSessionConfiguration, CameraViewPlugin, GetAvailableDevicesResponse, GetFlashModeResponse, GetSupportedFlashModesResponse, GetTorchModeResponse, GetZoomResponse, IsTorchAvailableResponse, IsRunningResponse, PermissionStatus, CaptureResponse, FlashMode, CaptureOptions } from './definitions';
2
+ import type { CameraSessionConfiguration, CameraViewPlugin, GetAvailableDevicesResponse, GetFlashModeResponse, GetSupportedFlashModesResponse, GetTorchModeResponse, GetZoomResponse, IsTorchAvailableResponse, IsRunningResponse, PermissionStatus, CaptureResponse, FlashMode, CaptureOptions, BarcodeType } from './definitions';
3
+ export declare const BARCODE_TYPE_TO_WEB_FORMAT: Readonly<Record<BarcodeType, BarcodeFormat | null>>;
3
4
  /**
4
5
  * Web implementation of the CameraViewPlugin.
5
6
  * Optimized for performance and battery efficiency.
@@ -101,6 +102,11 @@ export declare class CameraViewWeb extends WebPlugin implements CameraViewPlugin
101
102
  * Check if barcode detection is supported in this browser
102
103
  */
103
104
  private checkBarcodeDetectionSupport;
105
+ /**
106
+ * Configure the barcode detector with requested barcode formats.
107
+ * Unsupported formats are ignored and logged.
108
+ */
109
+ private configureBarcodeDetector;
104
110
  /**
105
111
  * Set up the video element for the camera view
106
112
  */