capacitor-camera-view 2.2.0-rc.1 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -443,7 +443,7 @@ Camera must be running. Throws if already recording.
443
443
  | ------------- | ----------------------------------------------------------------------- | ---------------------------------- |
444
444
  | **`options`** | <code><a href="#videorecordingoptions">VideoRecordingOptions</a></code> | - Optional recording configuration |
445
445
 
446
- **Since:** 2.2.0
446
+ **Since:** 2.3.0
447
447
 
448
448
  --------------------
449
449
 
@@ -459,7 +459,7 @@ Throws if no recording is in progress.
459
459
 
460
460
  **Returns:** <code>Promise&lt;<a href="#videorecordingresponse">VideoRecordingResponse</a>&gt;</code>
461
461
 
462
- **Since:** 2.2.0
462
+ **Since:** 2.3.0
463
463
 
464
464
  --------------------
465
465
 
@@ -737,8 +737,8 @@ Configuration options for video recording.
737
737
 
738
738
  | Prop | Type | Description | Default | Since |
739
739
  | ------------------ | ----------------------------------------------------------------------- | ------------------------------------------------------------------------------------ | ---------------------- | ----- |
740
- | **`enableAudio`** | <code>boolean</code> | Whether to record audio with the video. Requires microphone permission. | <code>false</code> | 2.2.0 |
741
- | **`videoQuality`** | <code><a href="#videorecordingquality">VideoRecordingQuality</a></code> | Video recording quality preset. Native platforms only (iOS/Android). Ignored on web. | <code>'highest'</code> | 2.2.0 |
740
+ | **`enableAudio`** | <code>boolean</code> | Whether to record audio with the video. Requires microphone permission. | <code>false</code> | 2.3.0 |
741
+ | **`videoQuality`** | <code><a href="#videorecordingquality">VideoRecordingQuality</a></code> | Video recording quality preset. Native platforms only (iOS/Android). Ignored on web. | <code>'highest'</code> | 2.3.0 |
742
742
 
743
743
 
744
744
  #### VideoRecordingResponse
@@ -747,7 +747,7 @@ Response from stopping a video recording.
747
747
 
748
748
  | Prop | Type | Description | Since |
749
749
  | ------------- | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ----- |
750
- | **`webPath`** | <code>string</code> | Web-accessible path to the recorded video file. On web, this is a blob URL. On iOS/Android, this is a path accessible via Capacitor's filesystem. | 2.2.0 |
750
+ | **`webPath`** | <code>string</code> | Web-accessible path to the recorded video file. On web, this is a blob URL. On iOS/Android, this is a path accessible via Capacitor's filesystem. | 2.3.0 |
751
751
 
752
752
 
753
753
  #### GetAvailableDevicesResponse
@@ -840,12 +840,13 @@ Response for the camera and microphone permission status.
840
840
 
841
841
  Data for a detected barcode.
842
842
 
843
- | Prop | Type | Description |
844
- | ------------------ | ----------------------------------------------------- | ---------------------------------------------------------------- |
845
- | **`value`** | <code>string</code> | The decoded string value of the barcode |
846
- | **`displayValue`** | <code>string</code> | The display value of the barcode (may differ from the raw value) |
847
- | **`type`** | <code>string</code> | The type/format of the barcode (e.g., 'qr', 'code128', etc.) |
848
- | **`boundingRect`** | <code><a href="#boundingrect">BoundingRect</a></code> | The bounding rectangle of the barcode in the camera frame. |
843
+ | Prop | Type | Description | Since |
844
+ | ------------------ | ----------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----- |
845
+ | **`value`** | <code>string</code> | The decoded string value of the barcode | |
846
+ | **`rawBytes`** | <code>number[]</code> | Raw bytes as they were encoded in the barcode. On Android, this is forwarded from ML Kit. On iOS, this is available for descriptor-backed formats such as QR, Aztec, PDF417, and Data Matrix. On web, this is not available because the Barcode Detection API only exposes the decoded string value. | 2.2.0 |
847
+ | **`displayValue`** | <code>string</code> | The display value of the barcode on Android. This is forwarded from ML Kit and may contain a formatted, human-readable representation that differs from the raw decoded value. iOS and web do not expose a separate display value, so this property is only emitted on Android. | |
848
+ | **`type`** | <code>string</code> | The type/format of the barcode (e.g., 'qr', 'code128', etc.) | |
849
+ | **`boundingRect`** | <code><a href="#boundingrect">BoundingRect</a></code> | The bounding rectangle of the barcode in the camera frame. | |
849
850
 
850
851
 
851
852
  #### BoundingRect
@@ -108,6 +108,9 @@ class CameraView(plugin: Plugin) {
108
108
  // Track the output file for the current recording
109
109
  private var currentRecordingFile: File? = null
110
110
 
111
+ // Enabled CameraX use cases before video recording temporarily changes them.
112
+ private var enabledUseCasesBeforeRecording: Int? = null
113
+
111
114
  // Plugin context
112
115
  private var lifecycleOwner: LifecycleOwner? = null
113
116
  private var pluginDelegate: Plugin = plugin
@@ -409,6 +412,7 @@ class CameraView(plugin: Plugin) {
409
412
  controller.videoCaptureQualitySelector = videoQuality.toQualitySelector()
410
413
 
411
414
  // Enable VIDEO_CAPTURE use case alongside IMAGE_CAPTURE
415
+ enabledUseCasesBeforeRecording = controller.currentEnabledUseCases()
412
416
  controller.setEnabledUseCases(
413
417
  CameraController.IMAGE_CAPTURE or CameraController.VIDEO_CAPTURE
414
418
  )
@@ -419,13 +423,11 @@ class CameraView(plugin: Plugin) {
419
423
  startCameraRecording(controller, outputOptions, audioConfig, continuation)
420
424
  } catch (e: SecurityException) {
421
425
  Log.e(TAG, "Security exception when starting recording. Missing permission?", e)
422
- // Restore normal use cases on permission error
423
- cameraController?.setEnabledUseCases(CameraController.IMAGE_CAPTURE)
426
+ restoreUseCasesAfterRecording()
424
427
  continuation.resume(CameraResult.Error(e))
425
428
  } catch (e: Exception) {
426
429
  Log.e(TAG, "Error starting recording", e)
427
- // Restore normal use cases on error
428
- cameraController?.setEnabledUseCases(CameraController.IMAGE_CAPTURE)
430
+ restoreUseCasesAfterRecording()
429
431
  continuation.resume(CameraResult.Error(e))
430
432
  }
431
433
  }
@@ -543,7 +545,7 @@ class CameraView(plugin: Plugin) {
543
545
  private fun finalizeRecordingAndNotifyStopCallback(event: VideoRecordEvent.Finalize) {
544
546
  mainHandler.post {
545
547
  // CameraX requires use case changes on the main thread.
546
- cameraController?.setEnabledUseCases(CameraController.IMAGE_CAPTURE)
548
+ restoreUseCasesAfterRecording()
547
549
 
548
550
  val callback = pendingStopCallback
549
551
  pendingStopCallback = null
@@ -576,6 +578,26 @@ class CameraView(plugin: Plugin) {
576
578
  }
577
579
  }
578
580
 
581
+ private fun LifecycleCameraController.currentEnabledUseCases(): Int {
582
+ var enabledUseCases = 0
583
+ if (isImageCaptureEnabled) {
584
+ enabledUseCases = enabledUseCases or CameraController.IMAGE_CAPTURE
585
+ }
586
+ if (isImageAnalysisEnabled) {
587
+ enabledUseCases = enabledUseCases or CameraController.IMAGE_ANALYSIS
588
+ }
589
+ if (isVideoCaptureEnabled) {
590
+ enabledUseCases = enabledUseCases or CameraController.VIDEO_CAPTURE
591
+ }
592
+ return enabledUseCases
593
+ }
594
+
595
+ private fun restoreUseCasesAfterRecording() {
596
+ val useCases = enabledUseCasesBeforeRecording ?: CameraController.IMAGE_CAPTURE
597
+ enabledUseCasesBeforeRecording = null
598
+ cameraController?.setEnabledUseCases(useCases)
599
+ }
600
+
579
601
  private fun VideoRecordingQuality.toQualitySelector(): QualitySelector {
580
602
  return when (this) {
581
603
  VideoRecordingQuality.LOWEST -> QualitySelector.from(Quality.LOWEST)
@@ -1007,6 +1029,7 @@ class CameraView(plugin: Plugin) {
1007
1029
  val barcodeResult =
1008
1030
  BarcodeDetectionResult(
1009
1031
  value = barcode.rawValue ?: "",
1032
+ rawBytes = barcode.rawBytes ?: ByteArray(0),
1010
1033
  displayValue = barcode.displayValue ?: "",
1011
1034
  type = getBarcodeFormatString(barcode.format),
1012
1035
  boundingRect = webBoundingRect
@@ -399,8 +399,14 @@ class CameraViewPlugin : Plugin() {
399
399
  * Called by the CameraView when a barcode is detected.
400
400
  */
401
401
  fun notifyBarcodeDetected(result: BarcodeDetectionResult) {
402
+ val rawBytesArray = JSArray().apply {
403
+ result.rawBytes.forEach { put(it.toInt() and 0xFF) }
404
+ }
405
+
402
406
  val jsObject = JSObject().apply {
403
407
  put("value", result.value)
408
+ put("displayValue", result.displayValue)
409
+ put("rawBytes", rawBytesArray)
404
410
  put("type", result.type)
405
411
  put("boundingRect", JSObject().apply {
406
412
  put("x", result.boundingRect.x)
@@ -5,6 +5,7 @@ package com.michaelwolz.capacitorcameraview.model
5
5
  */
6
6
  data class BarcodeDetectionResult(
7
7
  val value: String,
8
+ val rawBytes: ByteArray,
8
9
  val displayValue: String,
9
10
  val type: String,
10
11
  val boundingRect: WebBoundingRect
package/dist/docs.json CHANGED
@@ -169,7 +169,7 @@
169
169
  },
170
170
  {
171
171
  "name": "since",
172
- "text": "2.2.0"
172
+ "text": "2.3.0"
173
173
  }
174
174
  ],
175
175
  "docs": "Start recording video from the current camera.\nCamera must be running. Throws if already recording.",
@@ -190,7 +190,7 @@
190
190
  },
191
191
  {
192
192
  "name": "since",
193
- "text": "2.2.0"
193
+ "text": "2.3.0"
194
194
  }
195
195
  ],
196
196
  "docs": "Stop the current video recording and return the result.\nThrows if no recording is in progress.",
@@ -792,7 +792,7 @@
792
792
  "docs": "Configuration options for video recording.",
793
793
  "tags": [
794
794
  {
795
- "text": "2.2.0",
795
+ "text": "2.3.0",
796
796
  "name": "since"
797
797
  }
798
798
  ],
@@ -806,7 +806,7 @@
806
806
  "name": "default"
807
807
  },
808
808
  {
809
- "text": "2.2.0",
809
+ "text": "2.3.0",
810
810
  "name": "since"
811
811
  }
812
812
  ],
@@ -822,7 +822,7 @@
822
822
  "name": "default"
823
823
  },
824
824
  {
825
- "text": "2.2.0",
825
+ "text": "2.3.0",
826
826
  "name": "since"
827
827
  }
828
828
  ],
@@ -840,7 +840,7 @@
840
840
  "docs": "Response from stopping a video recording.",
841
841
  "tags": [
842
842
  {
843
- "text": "2.2.0",
843
+ "text": "2.3.0",
844
844
  "name": "since"
845
845
  }
846
846
  ],
@@ -850,7 +850,7 @@
850
850
  "name": "webPath",
851
851
  "tags": [
852
852
  {
853
- "text": "2.2.0",
853
+ "text": "2.3.0",
854
854
  "name": "since"
855
855
  }
856
856
  ],
@@ -1126,10 +1126,22 @@
1126
1126
  "complexTypes": [],
1127
1127
  "type": "string"
1128
1128
  },
1129
+ {
1130
+ "name": "rawBytes",
1131
+ "tags": [
1132
+ {
1133
+ "text": "2.2.0",
1134
+ "name": "since"
1135
+ }
1136
+ ],
1137
+ "docs": "Raw bytes as they were encoded in the barcode.\n\nOn Android, this is forwarded from ML Kit.\nOn iOS, this is available for descriptor-backed formats such as QR, Aztec, PDF417, and Data Matrix.\nOn web, this is not available because the Barcode Detection API only exposes the decoded string value.",
1138
+ "complexTypes": [],
1139
+ "type": "number[] | undefined"
1140
+ },
1129
1141
  {
1130
1142
  "name": "displayValue",
1131
1143
  "tags": [],
1132
- "docs": "The display value of the barcode (may differ from the raw value)",
1144
+ "docs": "The display value of the barcode on Android.\n\nThis is forwarded from ML Kit and may contain a formatted, human-readable\nrepresentation that differs from the raw decoded value. iOS and web do not\nexpose a separate display value, so this property is only emitted on Android.",
1133
1145
  "complexTypes": [],
1134
1146
  "type": "string | undefined"
1135
1147
  },
@@ -63,7 +63,7 @@ export interface CameraViewPlugin {
63
63
  * @param options - Optional recording configuration
64
64
  * @returns A promise that resolves when recording has started
65
65
  *
66
- * @since 2.2.0
66
+ * @since 2.3.0
67
67
  */
68
68
  startRecording(options?: VideoRecordingOptions): Promise<void>;
69
69
  /**
@@ -72,7 +72,7 @@ export interface CameraViewPlugin {
72
72
  *
73
73
  * @returns A promise that resolves with the recorded video file path
74
74
  *
75
- * @since 2.2.0
75
+ * @since 2.3.0
76
76
  */
77
77
  stopRecording(): Promise<VideoRecordingResponse>;
78
78
  /**
@@ -262,7 +262,7 @@ export type FlashMode = 'off' | 'on' | 'auto';
262
262
  * On iOS this maps to `AVCaptureSession.Preset` values.
263
263
  * On Android this maps to CameraX `QualitySelector` values.
264
264
  *
265
- * @since 2.2.0
265
+ * @since 2.3.0
266
266
  */
267
267
  export type VideoRecordingQuality = 'lowest' | 'sd' | 'hd' | 'fhd' | 'uhd' | 'highest';
268
268
  /**
@@ -420,34 +420,34 @@ export interface CaptureOptions {
420
420
  }
421
421
  /**
422
422
  * Configuration options for video recording.
423
- * @since 2.2.0
423
+ * @since 2.3.0
424
424
  */
425
425
  export interface VideoRecordingOptions {
426
426
  /**
427
427
  * Whether to record audio with the video.
428
428
  * Requires microphone permission.
429
429
  * @default false
430
- * @since 2.2.0
430
+ * @since 2.3.0
431
431
  */
432
432
  enableAudio?: boolean;
433
433
  /**
434
434
  * Video recording quality preset.
435
435
  * Native platforms only (iOS/Android). Ignored on web.
436
436
  * @default 'highest'
437
- * @since 2.2.0
437
+ * @since 2.3.0
438
438
  */
439
439
  videoQuality?: VideoRecordingQuality;
440
440
  }
441
441
  /**
442
442
  * Response from stopping a video recording.
443
- * @since 2.2.0
443
+ * @since 2.3.0
444
444
  */
445
445
  export interface VideoRecordingResponse {
446
446
  /**
447
447
  * Web-accessible path to the recorded video file.
448
448
  * On web, this is a blob URL.
449
449
  * On iOS/Android, this is a path accessible via Capacitor's filesystem.
450
- * @since 2.2.0
450
+ * @since 2.3.0
451
451
  */
452
452
  webPath: string;
453
453
  }
@@ -541,7 +541,23 @@ export interface GetTorchModeResponse {
541
541
  export interface BarcodeDetectionData {
542
542
  /** The decoded string value of the barcode */
543
543
  value: string;
544
- /** The display value of the barcode (may differ from the raw value) */
544
+ /**
545
+ * Raw bytes as they were encoded in the barcode.
546
+ *
547
+ * On Android, this is forwarded from ML Kit.
548
+ * On iOS, this is available for descriptor-backed formats such as QR, Aztec, PDF417, and Data Matrix.
549
+ * On web, this is not available because the Barcode Detection API only exposes the decoded string value.
550
+ *
551
+ * @since 2.2.0
552
+ */
553
+ rawBytes?: number[];
554
+ /**
555
+ * The display value of the barcode on Android.
556
+ *
557
+ * This is forwarded from ML Kit and may contain a formatted, human-readable
558
+ * representation that differs from the raw decoded value. iOS and web do not
559
+ * expose a separate display value, so this property is only emitted on Android.
560
+ */
545
561
  displayValue?: string;
546
562
  /** The type/format of the barcode (e.g., 'qr', 'code128', etc.) */
547
563
  type: string;
@@ -569,7 +585,7 @@ export interface BoundingRect {
569
585
  * - 'camera': Camera access permission
570
586
  * - 'microphone': Microphone access permission (needed for video recording with audio)
571
587
  *
572
- * @since 2.2.0
588
+ * @since 2.3.0
573
589
  */
574
590
  export type CameraPermissionType = 'camera' | 'microphone';
575
591
  /**
@@ -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 * Start recording video from the current camera.\n * Camera must be running. Throws if already recording.\n *\n * @param options - Optional recording configuration\n * @returns A promise that resolves when recording has started\n *\n * @since 2.2.0\n */\n startRecording(options?: VideoRecordingOptions): Promise<void>;\n\n /**\n * Stop the current video recording and return the result.\n * Throws if no recording is in progress.\n *\n * @returns A promise that resolves with the recorded video file path\n *\n * @since 2.2.0\n */\n stopRecording(): Promise<VideoRecordingResponse>;\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 and microphone permission status without requesting permissions.\n *\n * @returns A promise that resolves with an object containing the camera and microphone permission status\n *\n * @since 1.0.0\n */\n checkPermissions(): Promise<PermissionStatus>;\n\n /**\n * Request camera and/or microphone permissions from the user.\n *\n * By default, only camera permission is requested. To also request microphone\n * permission (needed for video recording with audio), pass `{ permissions: ['camera', 'microphone'] }`.\n *\n * @param options - Optional object specifying which permissions to request\n * @returns A promise that resolves with an object containing the camera and microphone permission status\n *\n * @since 1.0.0\n */\n requestPermissions(options?: { permissions?: CameraPermissionType[] }): 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 * Video recording quality presets.\n *\n * @remarks\n * On iOS this maps to `AVCaptureSession.Preset` values.\n * On Android this maps to CameraX `QualitySelector` values.\n *\n * @since 2.2.0\n */\nexport type VideoRecordingQuality = 'lowest' | 'sd' | 'hd' | 'fhd' | 'uhd' | 'highest';\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 * Configuration options for video recording.\n * @since 2.2.0\n */\nexport interface VideoRecordingOptions {\n /**\n * Whether to record audio with the video.\n * Requires microphone permission.\n * @default false\n * @since 2.2.0\n */\n enableAudio?: boolean;\n\n /**\n * Video recording quality preset.\n * Native platforms only (iOS/Android). Ignored on web.\n * @default 'highest'\n * @since 2.2.0\n */\n videoQuality?: VideoRecordingQuality;\n}\n\n/**\n * Response from stopping a video recording.\n * @since 2.2.0\n */\nexport interface VideoRecordingResponse {\n /**\n * Web-accessible path to the recorded video file.\n * On web, this is a blob URL.\n * On iOS/Android, this is a path accessible via Capacitor's filesystem.\n * @since 2.2.0\n */\n webPath: string;\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 * Permission types that can be requested.\n * - 'camera': Camera access permission\n * - 'microphone': Microphone access permission (needed for video recording with audio)\n *\n * @since 2.2.0\n */\nexport type CameraPermissionType = 'camera' | 'microphone';\n\n/**\n * Response for the camera and microphone permission status.\n *\n * @since 1.0.0\n */\nexport interface PermissionStatus {\n /** The state of the camera permission */\n camera: PermissionState;\n /** The state of the microphone permission */\n microphone: 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 * Start recording video from the current camera.\n * Camera must be running. Throws if already recording.\n *\n * @param options - Optional recording configuration\n * @returns A promise that resolves when recording has started\n *\n * @since 2.3.0\n */\n startRecording(options?: VideoRecordingOptions): Promise<void>;\n\n /**\n * Stop the current video recording and return the result.\n * Throws if no recording is in progress.\n *\n * @returns A promise that resolves with the recorded video file path\n *\n * @since 2.3.0\n */\n stopRecording(): Promise<VideoRecordingResponse>;\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 and microphone permission status without requesting permissions.\n *\n * @returns A promise that resolves with an object containing the camera and microphone permission status\n *\n * @since 1.0.0\n */\n checkPermissions(): Promise<PermissionStatus>;\n\n /**\n * Request camera and/or microphone permissions from the user.\n *\n * By default, only camera permission is requested. To also request microphone\n * permission (needed for video recording with audio), pass `{ permissions: ['camera', 'microphone'] }`.\n *\n * @param options - Optional object specifying which permissions to request\n * @returns A promise that resolves with an object containing the camera and microphone permission status\n *\n * @since 1.0.0\n */\n requestPermissions(options?: { permissions?: CameraPermissionType[] }): 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 * Video recording quality presets.\n *\n * @remarks\n * On iOS this maps to `AVCaptureSession.Preset` values.\n * On Android this maps to CameraX `QualitySelector` values.\n *\n * @since 2.3.0\n */\nexport type VideoRecordingQuality = 'lowest' | 'sd' | 'hd' | 'fhd' | 'uhd' | 'highest';\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 * Configuration options for video recording.\n * @since 2.3.0\n */\nexport interface VideoRecordingOptions {\n /**\n * Whether to record audio with the video.\n * Requires microphone permission.\n * @default false\n * @since 2.3.0\n */\n enableAudio?: boolean;\n\n /**\n * Video recording quality preset.\n * Native platforms only (iOS/Android). Ignored on web.\n * @default 'highest'\n * @since 2.3.0\n */\n videoQuality?: VideoRecordingQuality;\n}\n\n/**\n * Response from stopping a video recording.\n * @since 2.3.0\n */\nexport interface VideoRecordingResponse {\n /**\n * Web-accessible path to the recorded video file.\n * On web, this is a blob URL.\n * On iOS/Android, this is a path accessible via Capacitor's filesystem.\n * @since 2.3.0\n */\n webPath: string;\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 /**\n * Raw bytes as they were encoded in the barcode.\n *\n * On Android, this is forwarded from ML Kit.\n * On iOS, this is available for descriptor-backed formats such as QR, Aztec, PDF417, and Data Matrix.\n * On web, this is not available because the Barcode Detection API only exposes the decoded string value.\n *\n * @since 2.2.0\n */\n rawBytes?: number[];\n\n /**\n * The display value of the barcode on Android.\n *\n * This is forwarded from ML Kit and may contain a formatted, human-readable\n * representation that differs from the raw decoded value. iOS and web do not\n * expose a separate display value, so this property is only emitted on Android.\n */\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 * Permission types that can be requested.\n * - 'camera': Camera access permission\n * - 'microphone': Microphone access permission (needed for video recording with audio)\n *\n * @since 2.3.0\n */\nexport type CameraPermissionType = 'camera' | 'microphone';\n\n/**\n * Response for the camera and microphone permission status.\n *\n * @since 1.0.0\n */\nexport interface PermissionStatus {\n /** The state of the camera permission */\n camera: PermissionState;\n /** The state of the microphone permission */\n microphone: PermissionState;\n}\n"]}
package/dist/esm/web.js CHANGED
@@ -260,6 +260,12 @@ export class CameraViewWeb extends WebPlugin {
260
260
  this.mediaRecorder.start(100); // Collect data in 100ms chunks
261
261
  }
262
262
  catch (err) {
263
+ if (this.recordingAudioTrack) {
264
+ this.recordingAudioTrack.stop();
265
+ this.recordingAudioTrack = null;
266
+ }
267
+ this.mediaRecorder = null;
268
+ this.recordedChunks = [];
263
269
  throw new Error(`Failed to start recording: ${this.formatError(err)}`);
264
270
  }
265
271
  }