@capgo/camera-preview 8.7.1 → 8.8.1

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
@@ -279,6 +279,21 @@ In your `ios/App/App/Info.plist`, you must provide descriptions for the permissi
279
279
  <string>To add location data to your photos</string>
280
280
  ```
281
281
 
282
+ - **Haptics during video recording** (`allowHapticsAndSystemSoundsDuringRecording: true`):
283
+ When recording video with audio enabled (`disableAudio: false`), iOS suppresses haptic feedback by default. Opt in on `startRecordVideo()` to allow haptics while recording, for example to warn users before a time limit expires:
284
+
285
+ ```typescript
286
+ import { Haptics, ImpactStyle } from '@capacitor/haptics';
287
+
288
+ await CameraPreview.startRecordVideo({
289
+ disableAudio: false,
290
+ allowHapticsAndSystemSoundsDuringRecording: true,
291
+ });
292
+
293
+ // Later, while recording:
294
+ await Haptics.impact({ style: ImpactStyle.Medium });
295
+ ```
296
+
282
297
  ## Extra Android installation steps
283
298
 
284
299
  **Important** `camera-preview` 3+ requires Gradle 7.
@@ -762,7 +777,7 @@ startRecordVideo(options: CameraPreviewOptions) => Promise<void>
762
777
 
763
778
  Starts recording a video.
764
779
 
765
- Supports `frameRate`, `videoCodec`, `videoStabilizationMode`, `maxDuration`, `maxFileSize`, and `disableAudio` on each call.
780
+ Supports `frameRate`, `videoCodec`, `videoStabilizationMode`, `maxDuration`, `maxFileSize`, `disableAudio`, and `allowHapticsAndSystemSoundsDuringRecording` on each call.
766
781
 
767
782
  | Param | Type | Description |
768
783
  | ------------- | --------------------------------------------------------------------- | ---------------------------------- |
@@ -1435,41 +1450,42 @@ Get the native Capacitor plugin version
1435
1450
 
1436
1451
  Defines the configuration options for starting the camera preview.
1437
1452
 
1438
- | Prop | Type | Description | Default | Since |
1439
- | ----------------------------------- | ---------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------- | ------ |
1440
- | **`parent`** | <code>string</code> | The parent element to attach the video preview to. | | |
1441
- | **`className`** | <code>string</code> | A CSS class name to add to the preview element. | | |
1442
- | **`width`** | <code>number</code> | The width of the preview in pixels. Defaults to the screen width. | | |
1443
- | **`height`** | <code>number</code> | The height of the preview in pixels. Defaults to the screen height. | | |
1444
- | **`x`** | <code>number</code> | The horizontal origin of the preview, in pixels. | | |
1445
- | **`y`** | <code>number</code> | The vertical origin of the preview, in pixels. | | |
1446
- | **`aspectRatio`** | <code><a href="#camerapreviewaspectratio">CameraPreviewAspectRatio</a></code> | The aspect ratio of the camera preview, '4:3' or '16:9' or 'fill'. Cannot be set if width or height is provided, otherwise the call will be rejected. Use setPreviewSize to adjust size after starting. | | 2.0.0 |
1447
- | **`aspectMode`** | <code>'cover' \| 'contain'</code> | Controls how the camera preview fills the available space. - 'contain': Fits the entire preview within the space, may show letterboxing (default). - 'cover': Fills the entire space, may crop edges of the preview. | <code>"contain"</code> | |
1448
- | **`gridMode`** | <code><a href="#gridmode">GridMode</a></code> | The grid overlay to display on the camera preview. | <code>"none"</code> | 2.1.0 |
1449
- | **`includeSafeAreaInsets`** | <code>boolean</code> | Adjusts the y-position to account for safe areas (e.g., notches). | <code>false</code> | |
1450
- | **`toBack`** | <code>boolean</code> | If true, places the preview behind the webview. | <code>true</code> | |
1451
- | **`paddingBottom`** | <code>number</code> | Bottom padding for the preview, in pixels. | | |
1452
- | **`rotateWhenOrientationChanged`** | <code>boolean</code> | Whether to rotate the preview when the device orientation changes. | <code>true</code> | |
1453
- | **`position`** | <code>string</code> | The camera to use. | <code>"rear"</code> | |
1454
- | **`storeToFile`** | <code>boolean</code> | If true, saves the captured image to a file and returns the file path. If false, returns a base64 encoded string. | <code>false</code> | |
1455
- | **`disableExifHeaderStripping`** | <code>boolean</code> | If true, prevents the plugin from rotating the image based on EXIF data. | <code>false</code> | |
1456
- | **`disableAudio`** | <code>boolean</code> | If true, disables the audio stream, preventing audio permission requests. | <code>true</code> | |
1457
- | **`lockAndroidOrientation`** | <code>boolean</code> | If true, locks the device orientation while the camera is active. | <code>false</code> | |
1458
- | **`enableOpacity`** | <code>boolean</code> | If true, allows the camera preview's opacity to be changed. | <code>false</code> | |
1459
- | **`disableFocusIndicator`** | <code>boolean</code> | If true, disables the visual focus indicator when tapping to focus. | <code>false</code> | |
1460
- | **`deviceId`** | <code>string</code> | The `deviceId` of the camera to use. If provided, `position` is ignored. | | |
1461
- | **`enablePhysicalDeviceSelection`** | <code>boolean</code> | On Android, attempts to bind a physical camera directly when `deviceId` refers to a physical lens. Disabled by default because OEM support is inconsistent; when false, Android keeps the current logical-camera fallback behavior. | <code>false</code> | |
1462
- | **`initialZoomLevel`** | <code>number</code> | The initial zoom level when starting the camera preview. If the requested zoom level is not available, the native plugin will reject. | <code>1.0</code> | 2.2.0 |
1463
- | **`positioning`** | <code><a href="#camerapositioning">CameraPositioning</a></code> | The vertical positioning of the camera preview. | <code>"center"</code> | 2.3.0 |
1464
- | **`enableVideoMode`** | <code>boolean</code> | If true, enables video capture capabilities when the camera starts. | <code>false</code> | 7.11.0 |
1465
- | **`force`** | <code>boolean</code> | If true, forces the camera to start/restart even if it's already running or busy. This will kill the current camera session and start a new one, ignoring all state checks. | <code>false</code> | |
1466
- | **`videoQuality`** | <code><a href="#videoquality">VideoQuality</a></code> | Sets the quality of video for recording. Options: 'low', 'medium', 'high', '2160p', '1080p', '720p', '480p', '4:3' | <code>"high"</code> | |
1467
- | **`maxDuration`** | <code>number</code> | Maximum recording duration in seconds. Recording stops automatically when reached. | | |
1468
- | **`maxFileSize`** | <code>number</code> | Maximum recording file size in bytes. Recording stops automatically when reached. | | |
1469
- | **`videoCodec`** | <code><a href="#videocodec">VideoCodec</a></code> | Preferred video codec for recording. | <code>"avc1"</code> | |
1470
- | **`frameRate`** | <code>number</code> | Target video frame rate in frames per second. Applied when recording starts. Use `getSupportedVideoFrameRates()` to list supported values. | | 8.6.0 |
1471
- | **`videoStabilizationMode`** | <code><a href="#videostabilizationmode">VideoStabilizationMode</a></code> | Preferred video stabilization mode for recording. | <code>"off"</code> | |
1472
- | **`barcodeScanner`** | <code>boolean \| <a href="#barcodescanneroptions">BarcodeScannerOptions</a></code> | Starts barcode scanning together with the camera preview. Set to `true` or pass options to scan all supported formats. Omit this option to keep barcode scanning disabled at startup. | | 8.8.0 |
1453
+ | Prop | Type | Description | Default | Since |
1454
+ | ------------------------------------------------ | ---------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------- | ------ |
1455
+ | **`parent`** | <code>string</code> | The parent element to attach the video preview to. | | |
1456
+ | **`className`** | <code>string</code> | A CSS class name to add to the preview element. | | |
1457
+ | **`width`** | <code>number</code> | The width of the preview in pixels. Defaults to the screen width. | | |
1458
+ | **`height`** | <code>number</code> | The height of the preview in pixels. Defaults to the screen height. | | |
1459
+ | **`x`** | <code>number</code> | The horizontal origin of the preview, in pixels. | | |
1460
+ | **`y`** | <code>number</code> | The vertical origin of the preview, in pixels. | | |
1461
+ | **`aspectRatio`** | <code><a href="#camerapreviewaspectratio">CameraPreviewAspectRatio</a></code> | The aspect ratio of the camera preview, '4:3' or '16:9' or 'fill'. Cannot be set if width or height is provided, otherwise the call will be rejected. Use setPreviewSize to adjust size after starting. | | 2.0.0 |
1462
+ | **`aspectMode`** | <code>'cover' \| 'contain'</code> | Controls how the camera preview fills the available space. - 'contain': Fits the entire preview within the space, may show letterboxing (default). - 'cover': Fills the entire space, may crop edges of the preview. | <code>"contain"</code> | |
1463
+ | **`gridMode`** | <code><a href="#gridmode">GridMode</a></code> | The grid overlay to display on the camera preview. | <code>"none"</code> | 2.1.0 |
1464
+ | **`includeSafeAreaInsets`** | <code>boolean</code> | Adjusts the y-position to account for safe areas (e.g., notches). | <code>false</code> | |
1465
+ | **`toBack`** | <code>boolean</code> | If true, places the preview behind the webview. | <code>true</code> | |
1466
+ | **`paddingBottom`** | <code>number</code> | Bottom padding for the preview, in pixels. | | |
1467
+ | **`rotateWhenOrientationChanged`** | <code>boolean</code> | Whether to rotate the preview when the device orientation changes. | <code>true</code> | |
1468
+ | **`position`** | <code>string</code> | The camera to use. | <code>"rear"</code> | |
1469
+ | **`storeToFile`** | <code>boolean</code> | If true, saves the captured image to a file and returns the file path. If false, returns a base64 encoded string. | <code>false</code> | |
1470
+ | **`disableExifHeaderStripping`** | <code>boolean</code> | If true, prevents the plugin from rotating the image based on EXIF data. | <code>false</code> | |
1471
+ | **`disableAudio`** | <code>boolean</code> | If true, disables the audio stream, preventing audio permission requests. | <code>true</code> | |
1472
+ | **`lockAndroidOrientation`** | <code>boolean</code> | If true, locks the device orientation while the camera is active. | <code>false</code> | |
1473
+ | **`enableOpacity`** | <code>boolean</code> | If true, allows the camera preview's opacity to be changed. | <code>false</code> | |
1474
+ | **`disableFocusIndicator`** | <code>boolean</code> | If true, disables the visual focus indicator when tapping to focus. | <code>false</code> | |
1475
+ | **`deviceId`** | <code>string</code> | The `deviceId` of the camera to use. If provided, `position` is ignored. | | |
1476
+ | **`enablePhysicalDeviceSelection`** | <code>boolean</code> | On Android, attempts to bind a physical camera directly when `deviceId` refers to a physical lens. Disabled by default because OEM support is inconsistent; when false, Android keeps the current logical-camera fallback behavior. | <code>false</code> | |
1477
+ | **`initialZoomLevel`** | <code>number</code> | The initial zoom level when starting the camera preview. If the requested zoom level is not available, the native plugin will reject. | <code>1.0</code> | 2.2.0 |
1478
+ | **`positioning`** | <code><a href="#camerapositioning">CameraPositioning</a></code> | The vertical positioning of the camera preview. | <code>"center"</code> | 2.3.0 |
1479
+ | **`enableVideoMode`** | <code>boolean</code> | If true, enables video capture capabilities when the camera starts. | <code>false</code> | 7.11.0 |
1480
+ | **`force`** | <code>boolean</code> | If true, forces the camera to start/restart even if it's already running or busy. This will kill the current camera session and start a new one, ignoring all state checks. | <code>false</code> | |
1481
+ | **`videoQuality`** | <code><a href="#videoquality">VideoQuality</a></code> | Sets the quality of video for recording. Options: 'low', 'medium', 'high', '2160p', '1080p', '720p', '480p', '4:3' | <code>"high"</code> | |
1482
+ | **`maxDuration`** | <code>number</code> | Maximum recording duration in seconds. Recording stops automatically when reached. | | |
1483
+ | **`maxFileSize`** | <code>number</code> | Maximum recording file size in bytes. Recording stops automatically when reached. | | |
1484
+ | **`videoCodec`** | <code><a href="#videocodec">VideoCodec</a></code> | Preferred video codec for recording. | <code>"avc1"</code> | |
1485
+ | **`frameRate`** | <code>number</code> | Target video frame rate in frames per second. Applied when recording starts. Use `getSupportedVideoFrameRates()` to list supported values. | | 8.6.0 |
1486
+ | **`videoStabilizationMode`** | <code><a href="#videostabilizationmode">VideoStabilizationMode</a></code> | Preferred video stabilization mode for recording. | <code>"off"</code> | |
1487
+ | **`allowHapticsAndSystemSoundsDuringRecording`** | <code>boolean</code> | When `true`, allows haptic feedback and system sounds while recording video with audio. iOS suppresses haptics during audio input recording unless this is enabled. Requires `disableAudio: false`. | <code>false</code> | 8.8.0 |
1488
+ | **`barcodeScanner`** | <code>boolean \| <a href="#barcodescanneroptions">BarcodeScannerOptions</a></code> | Starts barcode scanning together with the camera preview. Set to `true` or pass options to scan all supported formats. Omit this option to keep barcode scanning disabled at startup. | | 8.8.0 |
1473
1489
 
1474
1490
 
1475
1491
  #### BarcodeScannerOptions
package/dist/docs.json CHANGED
@@ -539,7 +539,7 @@
539
539
  "text": "0.0.1"
540
540
  }
541
541
  ],
542
- "docs": "Starts recording a video.\n\nSupports `frameRate`, `videoCodec`, `videoStabilizationMode`, `maxDuration`, `maxFileSize`, and `disableAudio` on each call.",
542
+ "docs": "Starts recording a video.\n\nSupports `frameRate`, `videoCodec`, `videoStabilizationMode`, `maxDuration`, `maxFileSize`, `disableAudio`, and `allowHapticsAndSystemSoundsDuringRecording` on each call.",
543
543
  "complexTypes": [
544
544
  "CameraPreviewOptions"
545
545
  ],
@@ -2078,6 +2078,26 @@
2078
2078
  ],
2079
2079
  "type": "VideoStabilizationMode"
2080
2080
  },
2081
+ {
2082
+ "name": "allowHapticsAndSystemSoundsDuringRecording",
2083
+ "tags": [
2084
+ {
2085
+ "text": "ios",
2086
+ "name": "platform"
2087
+ },
2088
+ {
2089
+ "text": "false",
2090
+ "name": "default"
2091
+ },
2092
+ {
2093
+ "text": "8.8.0",
2094
+ "name": "since"
2095
+ }
2096
+ ],
2097
+ "docs": "When `true`, allows haptic feedback and system sounds while recording video with audio.\niOS suppresses haptics during audio input recording unless this is enabled.\nRequires `disableAudio: false`.",
2098
+ "complexTypes": [],
2099
+ "type": "boolean | undefined"
2100
+ },
2081
2101
  {
2082
2102
  "name": "barcodeScanner",
2083
2103
  "tags": [
@@ -330,6 +330,15 @@ export interface CameraPreviewOptions {
330
330
  * @default "off"
331
331
  */
332
332
  videoStabilizationMode?: VideoStabilizationMode;
333
+ /**
334
+ * When `true`, allows haptic feedback and system sounds while recording video with audio.
335
+ * iOS suppresses haptics during audio input recording unless this is enabled.
336
+ * Requires `disableAudio: false`.
337
+ * @platform ios
338
+ * @default false
339
+ * @since 8.8.0
340
+ */
341
+ allowHapticsAndSystemSoundsDuringRecording?: boolean;
333
342
  /**
334
343
  * Starts barcode scanning together with the camera preview.
335
344
  * Set to `true` or pass options to scan all supported formats.
@@ -678,7 +687,7 @@ export interface CameraPreviewPlugin {
678
687
  /**
679
688
  * Starts recording a video.
680
689
  *
681
- * Supports `frameRate`, `videoCodec`, `videoStabilizationMode`, `maxDuration`, `maxFileSize`, and `disableAudio` on each call.
690
+ * Supports `frameRate`, `videoCodec`, `videoStabilizationMode`, `maxDuration`, `maxFileSize`, `disableAudio`, and `allowHapticsAndSystemSoundsDuringRecording` on each call.
682
691
  *
683
692
  * @param {CameraPreviewOptions} options - The options for video recording.
684
693
  * @returns {Promise<void>} A promise that resolves when video recording starts.
@@ -1 +1 @@
1
- {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AA8EA,MAAM,CAAN,IAAY,UAQX;AARD,WAAY,UAAU;IACpB,sCAAwB,CAAA;IACxB,sCAAwB,CAAA;IACxB,qCAAuB,CAAA;IACvB,sCAAwB,CAAA;IACxB,2BAAa,CAAA;IACb,oCAAsB,CAAA;IACtB,+BAAiB,CAAA;AACnB,CAAC,EARW,UAAU,KAAV,UAAU,QAQrB","sourcesContent":["import type { PermissionState, PluginListenerHandle } from '@capacitor/core';\n\nexport type CameraPosition = 'rear' | 'front';\n\nexport type FlashMode = CameraPreviewFlashMode;\n\nexport type GridMode = 'none' | '3x3' | '4x4';\n\nexport type CameraPositioning = 'center' | 'top' | 'bottom';\n\nexport type CameraPreviewAspectRatio = '4:3' | '16:9' | 'fill';\n\nexport type BarcodeScannerFormat =\n | 'aztec'\n | 'codabar'\n | 'code_39'\n | 'code_93'\n | 'code_128'\n | 'data_matrix'\n | 'ean_8'\n | 'ean_13'\n | 'itf'\n | 'pdf417'\n | 'qr_code'\n | 'upc_a'\n | 'upc_e';\n\nexport type BarcodeFormat = BarcodeScannerFormat | 'unknown';\n\nexport interface BarcodeScannerOptions {\n /**\n * Restricts detection to the given formats. Leaving this empty scans all supported formats.\n * Restricting formats can improve scanning speed.\n */\n formats?: BarcodeScannerFormat[];\n /**\n * Minimum delay between native scan attempts in milliseconds.\n * Lower values scan more often but use more CPU.\n * @default 500\n */\n detectionInterval?: number;\n}\n\nexport interface BarcodeScanResult {\n /** Decoded barcode value. */\n value: string;\n /** Barcode format. */\n format: BarcodeFormat;\n /** Human-readable value when the platform exposes one. */\n displayValue?: string;\n /** Base64-encoded raw bytes when the platform exposes them. */\n rawBytes?: string;\n}\n\nexport interface BarcodeScannedEvent {\n /** Barcodes decoded from the current frame. */\n barcodes: BarcodeScanResult[];\n}\n\nexport interface BarcodeScanErrorEvent {\n /** Native scanner error message. */\n message: string;\n}\n\nexport interface CameraPermissionStatus {\n camera: PermissionState;\n microphone?: PermissionState;\n}\n\nexport interface PermissionRequestOptions {\n disableAudio?: boolean;\n showSettingsAlert?: boolean;\n title?: string;\n message?: string;\n openSettingsButtonTitle?: string;\n cancelButtonTitle?: string;\n}\n\nexport enum DeviceType {\n ULTRA_WIDE = 'ultraWide',\n WIDE_ANGLE = 'wideAngle',\n TELEPHOTO = 'telephoto',\n TRUE_DEPTH = 'trueDepth',\n DUAL = 'dual',\n DUAL_WIDE = 'dualWide',\n TRIPLE = 'triple',\n}\n\n/**\n * Represents a single camera lens on a device. A {@link CameraDevice} can have multiple lenses.\n */\nexport interface CameraLens {\n /** A human-readable name for the lens, e.g., \"Ultra-Wide\". */\n label: string;\n /** The type of the camera lens. */\n deviceType: DeviceType;\n /** The focal length of the lens in millimeters. */\n focalLength: number;\n /** The base zoom factor for this lens (e.g., 0.5 for ultra-wide, 1.0 for wide). */\n baseZoomRatio: number;\n /** The minimum zoom factor supported by this specific lens. */\n minZoom: number;\n /** The maximum zoom factor supported by this specific lens. */\n maxZoom: number;\n}\n\n/**\n * Represents a physical camera on the device (e.g., the front-facing camera).\n */\nexport interface CameraDevice {\n /** A unique identifier for the camera device. */\n deviceId: string;\n /** A human-readable name for the camera device. */\n label: string;\n /** The physical position of the camera on the device. */\n position: CameraPosition;\n /** A list of all available lenses for this camera device. */\n lenses: CameraLens[];\n /** The overall minimum zoom factor available across all lenses on this device. */\n minZoom: number;\n /** The overall maximum zoom factor available across all lenses on this device. */\n maxZoom: number;\n /** Identifies whether the device is a logical camera (composed of multiple physical lenses). */\n isLogical: boolean;\n}\n\n/**\n * Represents the detailed information of the currently active lens.\n */\nexport interface LensInfo {\n /** The focal length of the active lens in millimeters. */\n focalLength: number;\n /** The device type of the active lens. */\n deviceType: DeviceType;\n /** The base zoom ratio of the active lens (e.g., 0.5x, 1.0x). */\n baseZoomRatio: number;\n /** The current digital zoom factor applied on top of the base zoom. */\n digitalZoom: number;\n}\n\nexport type VideoQuality = 'low' | 'medium' | 'high' | '2160p' | '1080p' | '720p' | '480p' | '4:3';\n\n/**\n * Video codec identifiers used when recording.\n * - `avc1`: H.264\n * - `hvc1`: HEVC / H.265\n */\nexport type VideoCodec = 'avc1' | 'hvc1' | 'jpeg' | 'apcn' | 'ap4h';\n\n/**\n * Video stabilization modes used when recording.\n *\n * On Android only `off` and `standard` are supported.\n * On iOS all listed modes may be available when the device supports video stabilization.\n */\nexport type VideoStabilizationMode =\n | 'off'\n | 'standard'\n | 'cinematic'\n | 'cinematicExtended'\n | 'previewOptimized'\n | 'cinematicExtendedEnhanced'\n | 'auto'\n | 'lowLatency';\n\nexport type RecordingFinishedReason = 'manual' | 'maxDuration' | 'maxFileSize';\n\nexport interface RecordingFinishedEvent {\n /**\n * The path to the recorded video file.\n */\n videoFilePath: string;\n /**\n * Why the recording stopped.\n */\n reason: RecordingFinishedReason;\n}\n\n/**\n * Defines the configuration options for starting the camera preview.\n */\nexport interface CameraPreviewOptions {\n /**\n * The parent element to attach the video preview to.\n * @platform web\n */\n parent?: string;\n /**\n * A CSS class name to add to the preview element.\n * @platform web\n */\n className?: string;\n /**\n * The width of the preview in pixels. Defaults to the screen width.\n * @platform android, ios, web\n */\n width?: number;\n /**\n * The height of the preview in pixels. Defaults to the screen height.\n * @platform android, ios, web\n */\n height?: number;\n /**\n * The horizontal origin of the preview, in pixels.\n * @platform android, ios\n */\n x?: number;\n /**\n * The vertical origin of the preview, in pixels.\n * @platform android, ios\n */\n y?: number;\n /**\n * The aspect ratio of the camera preview, '4:3' or '16:9' or 'fill'.\n * Cannot be set if width or height is provided, otherwise the call will be rejected.\n * Use setPreviewSize to adjust size after starting.\n *\n * @since 2.0.0\n */\n aspectRatio?: CameraPreviewAspectRatio;\n /**\n * Controls how the camera preview fills the available space.\n * - 'contain': Fits the entire preview within the space, may show letterboxing (default).\n * - 'cover': Fills the entire space, may crop edges of the preview.\n * @default \"contain\"\n * @platform android, ios, web\n */\n aspectMode?: 'cover' | 'contain';\n /**\n * The grid overlay to display on the camera preview.\n * @default \"none\"\n * @since 2.1.0\n */\n gridMode?: GridMode;\n /**\n * Adjusts the y-position to account for safe areas (e.g., notches).\n * @platform android, ios\n * @default false\n */\n includeSafeAreaInsets?: boolean;\n /**\n * If true, places the preview behind the webview.\n * @platform android\n * @default true\n */\n toBack?: boolean;\n /**\n * Bottom padding for the preview, in pixels.\n * @platform android, ios\n */\n paddingBottom?: number;\n /**\n * Whether to rotate the preview when the device orientation changes.\n * @platform ios\n * @default true\n */\n rotateWhenOrientationChanged?: boolean;\n /**\n * The camera to use.\n * @default \"rear\"\n */\n position?: CameraPosition | string;\n /**\n * If true, saves the captured image to a file and returns the file path.\n * If false, returns a base64 encoded string.\n * @default false\n */\n storeToFile?: boolean;\n /**\n * If true, prevents the plugin from rotating the image based on EXIF data.\n * @platform android\n * @default false\n */\n disableExifHeaderStripping?: boolean;\n /**\n * If true, disables the audio stream, preventing audio permission requests.\n * @default true\n */\n disableAudio?: boolean;\n /**\n * If true, locks the device orientation while the camera is active.\n * @platform android\n * @default false\n */\n lockAndroidOrientation?: boolean;\n /**\n * If true, allows the camera preview's opacity to be changed.\n * @platform android, web\n * @default false\n */\n enableOpacity?: boolean;\n\n /**\n * If true, disables the visual focus indicator when tapping to focus.\n * @platform android, ios\n * @default false\n */\n disableFocusIndicator?: boolean;\n /**\n * The `deviceId` of the camera to use. If provided, `position` is ignored.\n * @platform ios\n */\n deviceId?: string;\n /**\n * On Android, attempts to bind a physical camera directly when `deviceId` refers to a physical lens.\n * Disabled by default because OEM support is inconsistent; when false, Android keeps the current logical-camera fallback behavior.\n * @default false\n * @platform android\n */\n enablePhysicalDeviceSelection?: boolean;\n /**\n * The initial zoom level when starting the camera preview.\n * If the requested zoom level is not available, the native plugin will reject.\n * @default 1.0\n * @platform android, ios\n * @since 2.2.0\n */\n initialZoomLevel?: number;\n /**\n * The vertical positioning of the camera preview.\n * @default \"center\"\n * @platform android, ios, web\n * @since 2.3.0\n */\n positioning?: CameraPositioning;\n /**\n * If true, enables video capture capabilities when the camera starts.\n * @default false\n * @platform android, ios\n * @since 7.11.0\n */\n enableVideoMode?: boolean;\n /**\n * If true, forces the camera to start/restart even if it's already running or busy.\n * This will kill the current camera session and start a new one, ignoring all state checks.\n * @default false\n * @platform android, ios, web\n */\n force?: boolean;\n /**\n * Sets the quality of video for recording.\n * Options: 'low', 'medium', 'high', '2160p', '1080p', '720p', '480p', '4:3'\n * @note On Android requires 'enableVideoMode' to be true\n * @note Will affect the entire preview stream for iOS\n * @platform ios, android\n * @default \"high\"\n */\n videoQuality?: VideoQuality;\n /**\n * Maximum recording duration in seconds. Recording stops automatically when reached.\n * @platform ios, android\n */\n maxDuration?: number;\n /**\n * Maximum recording file size in bytes. Recording stops automatically when reached.\n * @platform ios, android\n */\n maxFileSize?: number;\n /**\n * Preferred video codec for recording.\n * @platform ios, android\n * @default \"avc1\"\n */\n videoCodec?: VideoCodec;\n /**\n * Target video frame rate in frames per second.\n * Applied when recording starts. Use `getSupportedVideoFrameRates()` to list supported values.\n * @platform ios, android\n * @since 8.6.0\n */\n frameRate?: number;\n /**\n * Preferred video stabilization mode for recording.\n * @platform ios, android\n * @default \"off\"\n */\n videoStabilizationMode?: VideoStabilizationMode;\n /**\n * Starts barcode scanning together with the camera preview.\n * Set to `true` or pass options to scan all supported formats.\n * Omit this option to keep barcode scanning disabled at startup.\n * @platform android, ios, web\n * @since 8.8.0\n */\n barcodeScanner?: boolean | BarcodeScannerOptions;\n}\n\n/**\n * Defines the options for capturing a picture.\n */\nexport interface CameraPreviewPictureOptions {\n /**\n * The maximum height of the picture in pixels. The image will be resized to fit within this height while maintaining aspect ratio.\n * If not specified the captured image will match the preview's visible area.\n */\n height?: number;\n /**\n * The maximum width of the picture in pixels. The image will be resized to fit within this width while maintaining aspect ratio.\n * If not specified the captured image will match the preview's visible area.\n */\n width?: number;\n /**\n * The quality of the captured image, from 0 to 100.\n * Does not apply to `png` format.\n * @default 85\n */\n quality?: number;\n /**\n * The format of the captured image.\n * @default \"jpeg\"\n */\n format?: PictureFormat;\n /**\n * If true, the captured image will be saved to the user's gallery.\n * @default false\n * @since 7.5.0\n */\n saveToGallery?: boolean;\n /**\n * If true, the plugin will attempt to add GPS location data to the image's EXIF metadata.\n * This may prompt the user for location permissions.\n * @default false\n * @since 7.6.0\n */\n withExifLocation?: boolean;\n /**\n * If true, the plugin will embed a timestamp in the top-right corner of the image.\n * @default false\n * @since 7.17.0\n */\n embedTimestamp?: boolean;\n /**\n * If true, the plugin will embed the current location in the top-right corner of the image.\n * Requires `withExifLocation` to be enabled.\n * @default false\n * @since 7.18.0\n */\n embedLocation?: boolean;\n /**\n * Sets the priority for photo quality vs. capture speed.\n * - \"speed\": Prioritizes faster capture times, may reduce image quality.\n * - \"balanced\": Aims for a balance between quality and speed.\n * - \"quality\": Prioritizes image quality, may reduce capture speed.\n * See https://developer.apple.com/documentation/avfoundation/avcapturephotosettings/photoqualityprioritization for details.\n *\n * @since 7.21.0\n * @platform ios\n * @default \"speed\"\n */\n photoQualityPrioritization?: 'speed' | 'balanced' | 'quality';\n}\n\n/** Represents EXIF data extracted from an image. */\nexport interface ExifData {\n [key: string]: any;\n}\n\nexport type PictureFormat = 'jpeg' | 'png';\n\n/** Defines a standard picture size with width and height. */\nexport interface PictureSize {\n /** The width of the picture in pixels. */\n width: number;\n /** The height of the picture in pixels. */\n height: number;\n}\n\n/** Represents the supported picture sizes for a camera facing a certain direction. */\nexport interface SupportedPictureSizes {\n /** The camera direction (\"front\" or \"rear\"). */\n facing: string;\n /** A list of supported picture sizes for this camera. */\n supportedPictureSizes: PictureSize[];\n}\n\n/**\n * Defines the options for capturing a sample frame from the camera preview.\n */\nexport interface CameraSampleOptions {\n /**\n * The quality of the captured sample, from 0 to 100.\n * @default 85\n */\n quality?: number;\n}\n\n/**\n * The available flash modes for the camera.\n * 'torch' is a continuous light mode.\n */\nexport type CameraPreviewFlashMode = 'off' | 'on' | 'auto' | 'torch';\n\n/** Reusable exposure mode type for cross-platform support. */\nexport type ExposureMode = 'AUTO' | 'LOCK' | 'CONTINUOUS' | 'CUSTOM';\n\n/**\n * Defines the options for setting the camera preview's opacity.\n */\nexport interface CameraOpacityOptions {\n /**\n * The opacity percentage, from 0.0 (fully transparent) to 1.0 (fully opaque).\n * @default 1.0\n */\n opacity?: number;\n}\n\n/**\n * Represents safe area insets for devices.\n * Android: Values are expressed in logical pixels (dp) to match JS layout units.\n * iOS: Values are expressed in physical pixels and exclude status bar.\n */\nexport interface SafeAreaInsets {\n /** Current device orientation (1 = portrait, 2 = landscape, 0 = unknown). */\n orientation: number;\n /**\n * Orientation-aware notch/camera cutout inset (excluding status bar).\n * In portrait mode: returns top inset (notch at top).\n * In landscape mode: returns left inset (notch at side).\n * Android: Value in dp, iOS: Value in pixels (status bar excluded).\n */\n top: number;\n}\n\n/**\n * Canonical device orientation values across platforms.\n */\nexport type DeviceOrientation = 'portrait' | 'landscape-left' | 'landscape-right' | 'portrait-upside-down' | 'unknown';\n\n/**\n * The main interface for the CameraPreview plugin.\n */\nexport interface CameraPreviewPlugin {\n /**\n * Starts the camera preview.\n *\n * @param {CameraPreviewOptions} options - The configuration for the camera preview.\n * @returns {Promise<{ width: number; height: number; x: number; y: number }>} A promise that resolves with the preview dimensions.\n * @since 0.0.1\n */\n start(options: CameraPreviewOptions): Promise<{\n /** The width of the preview in pixels. */\n width: number;\n /** The height of the preview in pixels. */\n height: number;\n /** The horizontal origin of the preview, in pixels. */\n x: number;\n /** The vertical origin of the preview, in pixels. */\n y: number;\n }>;\n\n /**\n * Stops the camera preview.\n *\n * @param {object} options - Optional configuration for stopping the camera.\n * @param {boolean} options.force - If true, forces the camera to stop even if busy or capturing. Default: false.\n * @returns {Promise<void>} A promise that resolves when the camera preview is stopped.\n * @since 0.0.1\n */\n stop(options?: { force?: boolean }): Promise<void>;\n\n /**\n * Captures a picture from the camera.\n *\n * If `storeToFile` was set to `true` when starting the preview, the returned\n * `value` will be an absolute file path on the device instead of a base64 string. Use getBase64FromFilePath to get the base64 string from the file path.\n *\n * @param {CameraPreviewPictureOptions} options - The options for capturing the picture.\n * @returns {Promise<{ value: string; exif: ExifData }>} Resolves with:\n * - `value`: base64 string, or file path if `storeToFile` is true\n * - `exif`: extracted EXIF metadata when available\n * @since 0.0.1\n */\n capture(options: CameraPreviewPictureOptions): Promise<{ value: string; exif: ExifData }>;\n\n /**\n * Captures a single frame from the camera preview stream.\n *\n * @param {CameraSampleOptions} options - The options for capturing the sample.\n * @returns {Promise<{ value: string }>} A promise that resolves with the sample image as a base64 encoded string.\n * @since 0.0.1\n */\n captureSample(options: CameraSampleOptions): Promise<{ value: string }>;\n\n /**\n * Starts barcode scanning on the active camera preview.\n *\n * The scanner reuses the current camera session and emits `barcodeScanned` events.\n * Call `stopBarcodeScanner()` when scanning is no longer needed.\n *\n * Android uses the lightweight Google Play Services ML Kit model. If the model is not installed yet,\n * first scans may return no result until Google Play Services finishes downloading it.\n *\n * @since 8.8.0\n * @platform android, ios, web\n */\n startBarcodeScanner(options?: BarcodeScannerOptions): Promise<void>;\n\n /**\n * Stops barcode scanning while keeping the camera preview running.\n *\n * @since 8.8.0\n * @platform android, ios, web\n */\n stopBarcodeScanner(): Promise<void>;\n\n /**\n * Gets the flash modes supported by the active camera.\n *\n * @returns {Promise<{ result: CameraPreviewFlashMode[] }>} A promise that resolves with an array of supported flash modes.\n * @since 0.0.1\n */\n getSupportedFlashModes(): Promise<{\n result: CameraPreviewFlashMode[];\n }>;\n\n /**\n * Set the aspect ratio of the camera preview.\n *\n * @param {{ aspectRatio: CameraPreviewAspectRatio; x?: number; y?: number }} options - The desired aspect ratio and optional position.\n * - aspectRatio: The desired aspect ratio ('4:3', '16:9', or 'fill')\n * - x: Optional x coordinate for positioning. If not provided, view will be auto-centered horizontally.\n * - y: Optional y coordinate for positioning. If not provided, view will be auto-centered vertically.\n * @returns {Promise<{ width: number; height: number; x: number; y: number }>} A promise that resolves with the actual preview dimensions and position.\n * @since 7.5.0\n * @platform android, ios\n */\n setAspectRatio(options: { aspectRatio: CameraPreviewAspectRatio; x?: number; y?: number }): Promise<{\n width: number;\n height: number;\n x: number;\n y: number;\n }>;\n\n /**\n * Gets the current aspect ratio of the camera preview.\n *\n * @returns {Promise<{ aspectRatio: CameraPreviewAspectRatio }>} A promise that resolves with the current aspect ratio.\n * @since 7.5.0\n * @platform android, ios\n */\n getAspectRatio(): Promise<{ aspectRatio: CameraPreviewAspectRatio }>;\n\n /**\n * Sets the grid mode of the camera preview overlay.\n *\n * @param {{ gridMode: GridMode }} options - The desired grid mode ('none', '3x3', or '4x4').\n * @returns {Promise<void>} A promise that resolves when the grid mode is set.\n * @since 8.0.0\n */\n setGridMode(options: { gridMode: GridMode }): Promise<void>;\n\n /**\n * Gets the current grid mode of the camera preview overlay.\n *\n * @returns {Promise<{ gridMode: GridMode }>} A promise that resolves with the current grid mode.\n * @since 8.0.0\n */\n getGridMode(): Promise<{ gridMode: GridMode }>;\n\n /**\n * Checks the current camera (and optionally microphone) permission status without prompting the system dialog.\n *\n * @param options Set `disableAudio` to `false` to also include microphone status (defaults to `true`).\n * @returns {Promise<CameraPermissionStatus>} A promise resolving to the current authorization states.\n * @since 8.7.0\n */\n checkPermissions(options?: Pick<PermissionRequestOptions, 'disableAudio'>): Promise<CameraPermissionStatus>;\n\n /**\n * Requests camera (and optional microphone) permissions. If permissions are already granted or denied,\n * the current status is returned without prompting. When `showSettingsAlert` is true and permissions are denied,\n * a platform specific alert guiding the user to the app settings will be presented.\n *\n * @param {PermissionRequestOptions} options - Configuration for the permission request behaviour.\n * @returns {Promise<CameraPermissionStatus>} A promise resolving to the final authorization states.\n * @since 8.7.0\n */\n requestPermissions(options?: PermissionRequestOptions): Promise<CameraPermissionStatus>;\n\n /**\n * Gets the horizontal field of view (FoV) for the active camera.\n * Note: This can be an estimate on some devices.\n *\n * @returns {Promise<{ result: number }>} A promise that resolves with the horizontal field of view in degrees.\n * @since 0.0.1\n */\n getHorizontalFov(): Promise<{\n result: number;\n }>;\n\n /**\n * Gets the supported picture sizes for all cameras.\n *\n * @returns {Promise<{ supportedPictureSizes: SupportedPictureSizes[] }>} A promise that resolves with the list of supported sizes.\n * @since 7.4.0\n */\n getSupportedPictureSizes(): Promise<{\n supportedPictureSizes: SupportedPictureSizes[];\n }>;\n\n /**\n * Sets the flash mode for the active camera.\n *\n * @param {{ flashMode: CameraPreviewFlashMode | string }} options - The desired flash mode.\n * @returns {Promise<void>} A promise that resolves when the flash mode is set.\n * @since 0.0.1\n */\n setFlashMode(options: { flashMode: CameraPreviewFlashMode | string }): Promise<void>;\n\n /**\n * Toggles between the front and rear cameras.\n *\n * @returns {Promise<void>} A promise that resolves when the camera is flipped.\n * @since 0.0.1\n */\n flip(): Promise<void>;\n\n /**\n * Sets the opacity of the camera preview.\n *\n * @param {CameraOpacityOptions} options - The opacity options.\n * @returns {Promise<void>} A promise that resolves when the opacity is set.\n * @since 0.0.1\n */\n setOpacity(options: CameraOpacityOptions): Promise<void>;\n\n /**\n * Stops an ongoing video recording.\n *\n * @returns {Promise<RecordingFinishedEvent>} A promise that resolves with the path to the recorded video file.\n * @since 0.0.1\n */\n stopRecordVideo(): Promise<RecordingFinishedEvent>;\n\n /**\n * Starts recording a video.\n *\n * Supports `frameRate`, `videoCodec`, `videoStabilizationMode`, `maxDuration`, `maxFileSize`, and `disableAudio` on each call.\n *\n * @param {CameraPreviewOptions} options - The options for video recording.\n * @returns {Promise<void>} A promise that resolves when video recording starts.\n * @since 0.0.1\n */\n startRecordVideo(options: CameraPreviewOptions): Promise<void>;\n\n /**\n * Sets the video recording quality for the active camera session.\n *\n * @param {{ quality: VideoQuality }} options - The desired video quality.\n * @returns {Promise<void>} A promise that resolves when the quality is set.\n * @since 8.5.0\n * @platform android, ios\n */\n setVideoQuality(options: { quality: VideoQuality }): Promise<void>;\n\n /**\n * Gets the current video recording quality.\n *\n * @returns {Promise<{ quality: VideoQuality }>} A promise that resolves with the current quality.\n * @since 8.5.0\n * @platform android, ios\n */\n getVideoQuality(): Promise<{ quality: VideoQuality }>;\n\n /**\n * Returns the video qualities supported by the active camera.\n *\n * @returns {Promise<{ qualities: VideoQuality[] }>} A promise that resolves with supported qualities.\n * @since 8.5.0\n * @platform android, ios\n */\n getSupportedVideoQualities(): Promise<{ qualities: VideoQuality[] }>;\n\n /**\n * Sets the video codec used when recording.\n *\n * @param {{ codec: VideoCodec }} options - The desired codec.\n * @returns {Promise<void>} A promise that resolves when the codec is set.\n * @since 8.5.0\n * @platform android, ios\n */\n setVideoCodec(options: { codec: VideoCodec }): Promise<void>;\n\n /**\n * Gets the current video codec used for recording.\n *\n * @returns {Promise<{ codec: VideoCodec }>} A promise that resolves with the current codec.\n * @since 8.5.0\n * @platform android, ios\n */\n getVideoCodec(): Promise<{ codec: VideoCodec }>;\n\n /**\n * Returns the video codecs supported by the active camera.\n *\n * @returns {Promise<{ codecs: VideoCodec[] }>} A promise that resolves with supported codecs.\n * @since 8.5.0\n * @platform android, ios\n */\n getSupportedVideoCodecs(): Promise<{ codecs: VideoCodec[] }>;\n\n /**\n * Checks whether video stabilization is supported by the active camera.\n *\n * @returns {Promise<{ supported: boolean }>} A promise that resolves with the support state.\n * @since 8.5.2\n * @platform android, ios\n */\n isVideoStabilizationSupported(): Promise<{ supported: boolean }>;\n\n /**\n * Returns the video stabilization modes supported by the active camera.\n *\n * @returns {Promise<{ modes: VideoStabilizationMode[] }>} A promise that resolves with supported modes.\n * @since 8.5.2\n * @platform android, ios\n */\n getSupportedVideoStabilizationModes(): Promise<{ modes: VideoStabilizationMode[] }>;\n\n /**\n * Gets the current video stabilization mode.\n *\n * @returns {Promise<{ mode: VideoStabilizationMode }>} A promise that resolves with the current mode.\n * @since 8.5.2\n * @platform android, ios\n */\n getVideoStabilizationMode(): Promise<{ mode: VideoStabilizationMode }>;\n\n /**\n * Sets the video stabilization mode for recording.\n * Cannot be changed while a recording is in progress.\n * You can also pass `videoStabilizationMode` in `startRecordVideo()` options.\n *\n * @param {{ mode: VideoStabilizationMode }} options - The desired stabilization mode.\n * @returns {Promise<void>} A promise that resolves when the mode is set.\n * @since 8.5.2\n * @platform android, ios\n */\n setVideoStabilizationMode(options: { mode: VideoStabilizationMode }): Promise<void>;\n\n /**\n * Checks if the camera preview is currently running.\n *\n * @returns {Promise<{ isRunning: boolean }>} A promise that resolves with the running state.\n * @since 7.5.0\n * @platform android, ios\n */\n isRunning(): Promise<{ isRunning: boolean }>;\n\n /**\n * Gets all available camera devices.\n *\n * @returns {Promise<{ devices: CameraDevice[] }>} A promise that resolves with the list of available camera devices.\n * @since 7.5.0\n * @platform android, ios\n */\n getAvailableDevices(): Promise<{ devices: CameraDevice[] }>;\n\n /**\n * Gets the current zoom state, including min/max and current lens info.\n *\n * @returns {Promise<{ min: number; max: number; current: number; lens: LensInfo }>} A promise that resolves with the zoom state.\n * @since 7.5.0\n * @platform android, ios\n */\n getZoom(): Promise<{\n min: number;\n max: number;\n current: number;\n lens: LensInfo;\n }>;\n\n /**\n * Returns zoom button values for quick switching.\n * - iOS/Android: includes 0.5 if ultra-wide available; 1 and 2 if wide available; 3 if telephoto available\n * - Web: unsupported\n * @since 7.5.0\n * @platform android, ios\n */\n getZoomButtonValues(): Promise<{ values: number[] }>;\n\n /**\n * Sets the zoom level of the camera.\n *\n * @param {{ level: number; ramp?: boolean; autoFocus?: boolean }} options - The desired zoom level. `ramp` is currently unused. `autoFocus` defaults to true.\n * @returns {Promise<void>} A promise that resolves when the zoom level is set.\n * @since 7.5.0\n * @platform android, ios\n */\n setZoom(options: { level: number; ramp?: boolean; autoFocus?: boolean }): Promise<void>;\n\n /**\n * Gets the current flash mode.\n *\n * @returns {Promise<{ flashMode: FlashMode }>} A promise that resolves with the current flash mode.\n * @since 7.5.0\n * @platform android, ios\n */\n getFlashMode(): Promise<{ flashMode: FlashMode }>;\n\n /**\n * Removes all registered listeners.\n *\n * @since 7.5.0\n * @platform android, ios\n */\n removeAllListeners(): Promise<void>;\n\n /**\n * Switches the active camera to the one with the specified `deviceId`.\n *\n * @param {{ deviceId: string }} options - The ID of the device to switch to.\n * @returns {Promise<void>} A promise that resolves when the camera is switched.\n * @since 7.5.0\n * @platform android, ios\n */\n setDeviceId(options: { deviceId: string }): Promise<void>;\n\n /**\n * Gets the ID of the camera device that is currently bound.\n * On Android, if a physical-lens request falls back to a logical camera, this returns the bound logical camera ID.\n *\n * @returns {Promise<{ deviceId: string }>} A promise that resolves with the current device ID.\n * @since 7.5.0\n * @platform android, ios\n */\n getDeviceId(): Promise<{ deviceId: string }>;\n\n /**\n * Gets the current preview size and position.\n * @returns {Promise<{x: number, y: number, width: number, height: number}>}\n * @since 7.5.0\n * @platform android, ios\n */\n getPreviewSize(): Promise<{\n x: number;\n y: number;\n width: number;\n height: number;\n }>;\n /**\n * Sets the preview size and position.\n * @param options The new position and dimensions.\n * @returns {Promise<{ width: number; height: number; x: number; y: number }>} A promise that resolves with the actual preview dimensions and position.\n * @since 7.5.0\n * @platform android, ios\n */\n setPreviewSize(options: { x?: number; y?: number; width: number; height: number }): Promise<{\n width: number;\n height: number;\n x: number;\n y: number;\n }>;\n\n /**\n * Sets the camera focus to a specific point in the preview.\n *\n * Note: The plugin does not attach any native tap-to-focus gesture handlers. Handle taps in\n * your HTML/JS (e.g., on the overlaying UI), then pass normalized coordinates here.\n *\n * @param {Object} options - The focus options.\n * @param {number} options.x - The x coordinate in the preview view to focus on (0-1 normalized).\n * @param {number} options.y - The y coordinate in the preview view to focus on (0-1 normalized).\n * @returns {Promise<void>} A promise that resolves when the focus is set.\n * @since 7.5.0\n * @platform android, ios\n */\n setFocus(options: { x: number; y: number }): Promise<void>;\n\n /**\n * Adds a listener for screen resize events.\n * @param {string} eventName - The event name to listen for.\n * @param {Function} listenerFunc - The function to call when the event is triggered.\n * @returns {Promise<PluginListenerHandle>} A promise that resolves with a handle to the listener.\n * @since 7.5.0\n * @platform android, ios\n */\n addListener(\n eventName: 'screenResize',\n listenerFunc: (data: { width: number; height: number; x: number; y: number }) => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Adds a listener for orientation change events.\n * @param {string} eventName - The event name to listen for.\n * @param {Function} listenerFunc - The function to call when the event is triggered.\n * @returns {Promise<PluginListenerHandle>} A promise that resolves with a handle to the listener.\n * @since 7.5.0\n * @platform android, ios\n */\n addListener(\n eventName: 'orientationChange',\n listenerFunc: (data: { orientation: DeviceOrientation }) => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Adds a listener for barcode scan results.\n *\n * @since 8.8.0\n * @platform android, ios, web\n */\n addListener(\n eventName: 'barcodeScanned',\n listenerFunc: (data: BarcodeScannedEvent) => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Adds a listener for non-fatal barcode scanner errors.\n *\n * @since 8.8.0\n * @platform android, web\n */\n addListener(\n eventName: 'barcodeScanError',\n listenerFunc: (data: BarcodeScanErrorEvent) => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Adds a listener fired when a video recording finishes natively, including automatic stops.\n *\n * @since 8.4.7\n * @platform android, ios\n */\n addListener(\n eventName: 'recordingFinished',\n listenerFunc: (data: RecordingFinishedEvent) => void,\n ): Promise<PluginListenerHandle>;\n /**\n * Deletes a file at the given absolute path on the device.\n * Use this to quickly clean up temporary images created with `storeToFile`.\n * On web, this is not supported and will throw.\n * @since 7.5.0\n * @platform android, ios\n */\n deleteFile(options: { path: string }): Promise<{ success: boolean }>;\n\n /**\n * Gets the safe area insets for devices.\n * Returns the orientation-aware notch/camera cutout inset and the current orientation.\n * In portrait mode: returns top inset (notch at top).\n * In landscape mode: returns left inset (notch moved to side).\n * This specifically targets the cutout area (notch, punch hole, etc.) that all modern phones have.\n *\n * Android: Values returned in dp (logical pixels).\n * iOS: Values returned in physical pixels, excluding status bar (only pure notch/cutout size).\n *\n * @platform android, ios\n */\n getSafeAreaInsets(): Promise<SafeAreaInsets>;\n\n /**\n * Gets the current device orientation in a cross-platform format.\n * @since 7.5.0\n * @platform android, ios\n */\n getOrientation(): Promise<{ orientation: DeviceOrientation }>;\n\n /**\n * Returns the exposure modes supported by the active camera.\n * Modes can include: 'locked', 'auto', 'continuous', 'custom'.\n * @platform android, ios\n */\n getExposureModes(): Promise<{ modes: ExposureMode[] }>;\n\n /**\n * Returns the current exposure mode.\n * @platform android, ios\n */\n getExposureMode(): Promise<{ mode: ExposureMode }>;\n\n /**\n * Sets the exposure mode.\n * @platform android, ios\n */\n setExposureMode(options: { mode: ExposureMode }): Promise<void>;\n\n /**\n * Returns the exposure compensation (EV bias) supported range.\n * @platform ios, android\n */\n getExposureCompensationRange(): Promise<{\n min: number;\n max: number;\n step: number;\n }>;\n\n /**\n * Returns the current exposure compensation (EV bias).\n * @platform ios, android\n */\n getExposureCompensation(): Promise<{ value: number }>;\n\n /**\n * Sets the exposure compensation (EV bias). Value will be clamped to range.\n * @platform ios, android\n */\n setExposureCompensation(options: { value: number }): Promise<void>;\n\n /**\n * Lists the video frame rates supported by the active camera for the current format.\n * Supported values depend on the selected camera, lens, and video quality.\n *\n * @platform android, ios\n * @since 8.6.0\n */\n getSupportedVideoFrameRates(): Promise<{\n frameRates: number[];\n }>;\n\n /**\n * Returns the configured video frame rate for the active camera.\n * On Android the actual recording frame rate can still vary in low light or under thermal pressure.\n *\n * @platform android, ios\n * @since 8.6.0\n */\n getVideoFrameRate(): Promise<{\n frameRate: number;\n }>;\n\n /**\n * Sets the target video frame rate for the active camera session.\n * Prefer passing `frameRate` to `startRecordVideo()` when starting a recording.\n * Rejects unsupported values with a clear error.\n *\n * @platform android, ios\n * @since 8.6.0\n */\n setVideoFrameRate(options: { frameRate: number }): Promise<void>;\n\n /**\n * Get the native Capacitor plugin version\n *\n * @returns {Promise<{ id: string }>} an Promise with version for this device\n * @throws An error if the something went wrong\n */\n getPluginVersion(): Promise<{ version: string }>;\n}\n"]}
1
+ {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AA8EA,MAAM,CAAN,IAAY,UAQX;AARD,WAAY,UAAU;IACpB,sCAAwB,CAAA;IACxB,sCAAwB,CAAA;IACxB,qCAAuB,CAAA;IACvB,sCAAwB,CAAA;IACxB,2BAAa,CAAA;IACb,oCAAsB,CAAA;IACtB,+BAAiB,CAAA;AACnB,CAAC,EARW,UAAU,KAAV,UAAU,QAQrB","sourcesContent":["import type { PermissionState, PluginListenerHandle } from '@capacitor/core';\n\nexport type CameraPosition = 'rear' | 'front';\n\nexport type FlashMode = CameraPreviewFlashMode;\n\nexport type GridMode = 'none' | '3x3' | '4x4';\n\nexport type CameraPositioning = 'center' | 'top' | 'bottom';\n\nexport type CameraPreviewAspectRatio = '4:3' | '16:9' | 'fill';\n\nexport type BarcodeScannerFormat =\n | 'aztec'\n | 'codabar'\n | 'code_39'\n | 'code_93'\n | 'code_128'\n | 'data_matrix'\n | 'ean_8'\n | 'ean_13'\n | 'itf'\n | 'pdf417'\n | 'qr_code'\n | 'upc_a'\n | 'upc_e';\n\nexport type BarcodeFormat = BarcodeScannerFormat | 'unknown';\n\nexport interface BarcodeScannerOptions {\n /**\n * Restricts detection to the given formats. Leaving this empty scans all supported formats.\n * Restricting formats can improve scanning speed.\n */\n formats?: BarcodeScannerFormat[];\n /**\n * Minimum delay between native scan attempts in milliseconds.\n * Lower values scan more often but use more CPU.\n * @default 500\n */\n detectionInterval?: number;\n}\n\nexport interface BarcodeScanResult {\n /** Decoded barcode value. */\n value: string;\n /** Barcode format. */\n format: BarcodeFormat;\n /** Human-readable value when the platform exposes one. */\n displayValue?: string;\n /** Base64-encoded raw bytes when the platform exposes them. */\n rawBytes?: string;\n}\n\nexport interface BarcodeScannedEvent {\n /** Barcodes decoded from the current frame. */\n barcodes: BarcodeScanResult[];\n}\n\nexport interface BarcodeScanErrorEvent {\n /** Native scanner error message. */\n message: string;\n}\n\nexport interface CameraPermissionStatus {\n camera: PermissionState;\n microphone?: PermissionState;\n}\n\nexport interface PermissionRequestOptions {\n disableAudio?: boolean;\n showSettingsAlert?: boolean;\n title?: string;\n message?: string;\n openSettingsButtonTitle?: string;\n cancelButtonTitle?: string;\n}\n\nexport enum DeviceType {\n ULTRA_WIDE = 'ultraWide',\n WIDE_ANGLE = 'wideAngle',\n TELEPHOTO = 'telephoto',\n TRUE_DEPTH = 'trueDepth',\n DUAL = 'dual',\n DUAL_WIDE = 'dualWide',\n TRIPLE = 'triple',\n}\n\n/**\n * Represents a single camera lens on a device. A {@link CameraDevice} can have multiple lenses.\n */\nexport interface CameraLens {\n /** A human-readable name for the lens, e.g., \"Ultra-Wide\". */\n label: string;\n /** The type of the camera lens. */\n deviceType: DeviceType;\n /** The focal length of the lens in millimeters. */\n focalLength: number;\n /** The base zoom factor for this lens (e.g., 0.5 for ultra-wide, 1.0 for wide). */\n baseZoomRatio: number;\n /** The minimum zoom factor supported by this specific lens. */\n minZoom: number;\n /** The maximum zoom factor supported by this specific lens. */\n maxZoom: number;\n}\n\n/**\n * Represents a physical camera on the device (e.g., the front-facing camera).\n */\nexport interface CameraDevice {\n /** A unique identifier for the camera device. */\n deviceId: string;\n /** A human-readable name for the camera device. */\n label: string;\n /** The physical position of the camera on the device. */\n position: CameraPosition;\n /** A list of all available lenses for this camera device. */\n lenses: CameraLens[];\n /** The overall minimum zoom factor available across all lenses on this device. */\n minZoom: number;\n /** The overall maximum zoom factor available across all lenses on this device. */\n maxZoom: number;\n /** Identifies whether the device is a logical camera (composed of multiple physical lenses). */\n isLogical: boolean;\n}\n\n/**\n * Represents the detailed information of the currently active lens.\n */\nexport interface LensInfo {\n /** The focal length of the active lens in millimeters. */\n focalLength: number;\n /** The device type of the active lens. */\n deviceType: DeviceType;\n /** The base zoom ratio of the active lens (e.g., 0.5x, 1.0x). */\n baseZoomRatio: number;\n /** The current digital zoom factor applied on top of the base zoom. */\n digitalZoom: number;\n}\n\nexport type VideoQuality = 'low' | 'medium' | 'high' | '2160p' | '1080p' | '720p' | '480p' | '4:3';\n\n/**\n * Video codec identifiers used when recording.\n * - `avc1`: H.264\n * - `hvc1`: HEVC / H.265\n */\nexport type VideoCodec = 'avc1' | 'hvc1' | 'jpeg' | 'apcn' | 'ap4h';\n\n/**\n * Video stabilization modes used when recording.\n *\n * On Android only `off` and `standard` are supported.\n * On iOS all listed modes may be available when the device supports video stabilization.\n */\nexport type VideoStabilizationMode =\n | 'off'\n | 'standard'\n | 'cinematic'\n | 'cinematicExtended'\n | 'previewOptimized'\n | 'cinematicExtendedEnhanced'\n | 'auto'\n | 'lowLatency';\n\nexport type RecordingFinishedReason = 'manual' | 'maxDuration' | 'maxFileSize';\n\nexport interface RecordingFinishedEvent {\n /**\n * The path to the recorded video file.\n */\n videoFilePath: string;\n /**\n * Why the recording stopped.\n */\n reason: RecordingFinishedReason;\n}\n\n/**\n * Defines the configuration options for starting the camera preview.\n */\nexport interface CameraPreviewOptions {\n /**\n * The parent element to attach the video preview to.\n * @platform web\n */\n parent?: string;\n /**\n * A CSS class name to add to the preview element.\n * @platform web\n */\n className?: string;\n /**\n * The width of the preview in pixels. Defaults to the screen width.\n * @platform android, ios, web\n */\n width?: number;\n /**\n * The height of the preview in pixels. Defaults to the screen height.\n * @platform android, ios, web\n */\n height?: number;\n /**\n * The horizontal origin of the preview, in pixels.\n * @platform android, ios\n */\n x?: number;\n /**\n * The vertical origin of the preview, in pixels.\n * @platform android, ios\n */\n y?: number;\n /**\n * The aspect ratio of the camera preview, '4:3' or '16:9' or 'fill'.\n * Cannot be set if width or height is provided, otherwise the call will be rejected.\n * Use setPreviewSize to adjust size after starting.\n *\n * @since 2.0.0\n */\n aspectRatio?: CameraPreviewAspectRatio;\n /**\n * Controls how the camera preview fills the available space.\n * - 'contain': Fits the entire preview within the space, may show letterboxing (default).\n * - 'cover': Fills the entire space, may crop edges of the preview.\n * @default \"contain\"\n * @platform android, ios, web\n */\n aspectMode?: 'cover' | 'contain';\n /**\n * The grid overlay to display on the camera preview.\n * @default \"none\"\n * @since 2.1.0\n */\n gridMode?: GridMode;\n /**\n * Adjusts the y-position to account for safe areas (e.g., notches).\n * @platform android, ios\n * @default false\n */\n includeSafeAreaInsets?: boolean;\n /**\n * If true, places the preview behind the webview.\n * @platform android\n * @default true\n */\n toBack?: boolean;\n /**\n * Bottom padding for the preview, in pixels.\n * @platform android, ios\n */\n paddingBottom?: number;\n /**\n * Whether to rotate the preview when the device orientation changes.\n * @platform ios\n * @default true\n */\n rotateWhenOrientationChanged?: boolean;\n /**\n * The camera to use.\n * @default \"rear\"\n */\n position?: CameraPosition | string;\n /**\n * If true, saves the captured image to a file and returns the file path.\n * If false, returns a base64 encoded string.\n * @default false\n */\n storeToFile?: boolean;\n /**\n * If true, prevents the plugin from rotating the image based on EXIF data.\n * @platform android\n * @default false\n */\n disableExifHeaderStripping?: boolean;\n /**\n * If true, disables the audio stream, preventing audio permission requests.\n * @default true\n */\n disableAudio?: boolean;\n /**\n * If true, locks the device orientation while the camera is active.\n * @platform android\n * @default false\n */\n lockAndroidOrientation?: boolean;\n /**\n * If true, allows the camera preview's opacity to be changed.\n * @platform android, web\n * @default false\n */\n enableOpacity?: boolean;\n\n /**\n * If true, disables the visual focus indicator when tapping to focus.\n * @platform android, ios\n * @default false\n */\n disableFocusIndicator?: boolean;\n /**\n * The `deviceId` of the camera to use. If provided, `position` is ignored.\n * @platform ios\n */\n deviceId?: string;\n /**\n * On Android, attempts to bind a physical camera directly when `deviceId` refers to a physical lens.\n * Disabled by default because OEM support is inconsistent; when false, Android keeps the current logical-camera fallback behavior.\n * @default false\n * @platform android\n */\n enablePhysicalDeviceSelection?: boolean;\n /**\n * The initial zoom level when starting the camera preview.\n * If the requested zoom level is not available, the native plugin will reject.\n * @default 1.0\n * @platform android, ios\n * @since 2.2.0\n */\n initialZoomLevel?: number;\n /**\n * The vertical positioning of the camera preview.\n * @default \"center\"\n * @platform android, ios, web\n * @since 2.3.0\n */\n positioning?: CameraPositioning;\n /**\n * If true, enables video capture capabilities when the camera starts.\n * @default false\n * @platform android, ios\n * @since 7.11.0\n */\n enableVideoMode?: boolean;\n /**\n * If true, forces the camera to start/restart even if it's already running or busy.\n * This will kill the current camera session and start a new one, ignoring all state checks.\n * @default false\n * @platform android, ios, web\n */\n force?: boolean;\n /**\n * Sets the quality of video for recording.\n * Options: 'low', 'medium', 'high', '2160p', '1080p', '720p', '480p', '4:3'\n * @note On Android requires 'enableVideoMode' to be true\n * @note Will affect the entire preview stream for iOS\n * @platform ios, android\n * @default \"high\"\n */\n videoQuality?: VideoQuality;\n /**\n * Maximum recording duration in seconds. Recording stops automatically when reached.\n * @platform ios, android\n */\n maxDuration?: number;\n /**\n * Maximum recording file size in bytes. Recording stops automatically when reached.\n * @platform ios, android\n */\n maxFileSize?: number;\n /**\n * Preferred video codec for recording.\n * @platform ios, android\n * @default \"avc1\"\n */\n videoCodec?: VideoCodec;\n /**\n * Target video frame rate in frames per second.\n * Applied when recording starts. Use `getSupportedVideoFrameRates()` to list supported values.\n * @platform ios, android\n * @since 8.6.0\n */\n frameRate?: number;\n /**\n * Preferred video stabilization mode for recording.\n * @platform ios, android\n * @default \"off\"\n */\n videoStabilizationMode?: VideoStabilizationMode;\n /**\n * When `true`, allows haptic feedback and system sounds while recording video with audio.\n * iOS suppresses haptics during audio input recording unless this is enabled.\n * Requires `disableAudio: false`.\n * @platform ios\n * @default false\n * @since 8.8.0\n */\n allowHapticsAndSystemSoundsDuringRecording?: boolean;\n /**\n * Starts barcode scanning together with the camera preview.\n * Set to `true` or pass options to scan all supported formats.\n * Omit this option to keep barcode scanning disabled at startup.\n * @platform android, ios, web\n * @since 8.8.0\n */\n barcodeScanner?: boolean | BarcodeScannerOptions;\n}\n\n/**\n * Defines the options for capturing a picture.\n */\nexport interface CameraPreviewPictureOptions {\n /**\n * The maximum height of the picture in pixels. The image will be resized to fit within this height while maintaining aspect ratio.\n * If not specified the captured image will match the preview's visible area.\n */\n height?: number;\n /**\n * The maximum width of the picture in pixels. The image will be resized to fit within this width while maintaining aspect ratio.\n * If not specified the captured image will match the preview's visible area.\n */\n width?: number;\n /**\n * The quality of the captured image, from 0 to 100.\n * Does not apply to `png` format.\n * @default 85\n */\n quality?: number;\n /**\n * The format of the captured image.\n * @default \"jpeg\"\n */\n format?: PictureFormat;\n /**\n * If true, the captured image will be saved to the user's gallery.\n * @default false\n * @since 7.5.0\n */\n saveToGallery?: boolean;\n /**\n * If true, the plugin will attempt to add GPS location data to the image's EXIF metadata.\n * This may prompt the user for location permissions.\n * @default false\n * @since 7.6.0\n */\n withExifLocation?: boolean;\n /**\n * If true, the plugin will embed a timestamp in the top-right corner of the image.\n * @default false\n * @since 7.17.0\n */\n embedTimestamp?: boolean;\n /**\n * If true, the plugin will embed the current location in the top-right corner of the image.\n * Requires `withExifLocation` to be enabled.\n * @default false\n * @since 7.18.0\n */\n embedLocation?: boolean;\n /**\n * Sets the priority for photo quality vs. capture speed.\n * - \"speed\": Prioritizes faster capture times, may reduce image quality.\n * - \"balanced\": Aims for a balance between quality and speed.\n * - \"quality\": Prioritizes image quality, may reduce capture speed.\n * See https://developer.apple.com/documentation/avfoundation/avcapturephotosettings/photoqualityprioritization for details.\n *\n * @since 7.21.0\n * @platform ios\n * @default \"speed\"\n */\n photoQualityPrioritization?: 'speed' | 'balanced' | 'quality';\n}\n\n/** Represents EXIF data extracted from an image. */\nexport interface ExifData {\n [key: string]: any;\n}\n\nexport type PictureFormat = 'jpeg' | 'png';\n\n/** Defines a standard picture size with width and height. */\nexport interface PictureSize {\n /** The width of the picture in pixels. */\n width: number;\n /** The height of the picture in pixels. */\n height: number;\n}\n\n/** Represents the supported picture sizes for a camera facing a certain direction. */\nexport interface SupportedPictureSizes {\n /** The camera direction (\"front\" or \"rear\"). */\n facing: string;\n /** A list of supported picture sizes for this camera. */\n supportedPictureSizes: PictureSize[];\n}\n\n/**\n * Defines the options for capturing a sample frame from the camera preview.\n */\nexport interface CameraSampleOptions {\n /**\n * The quality of the captured sample, from 0 to 100.\n * @default 85\n */\n quality?: number;\n}\n\n/**\n * The available flash modes for the camera.\n * 'torch' is a continuous light mode.\n */\nexport type CameraPreviewFlashMode = 'off' | 'on' | 'auto' | 'torch';\n\n/** Reusable exposure mode type for cross-platform support. */\nexport type ExposureMode = 'AUTO' | 'LOCK' | 'CONTINUOUS' | 'CUSTOM';\n\n/**\n * Defines the options for setting the camera preview's opacity.\n */\nexport interface CameraOpacityOptions {\n /**\n * The opacity percentage, from 0.0 (fully transparent) to 1.0 (fully opaque).\n * @default 1.0\n */\n opacity?: number;\n}\n\n/**\n * Represents safe area insets for devices.\n * Android: Values are expressed in logical pixels (dp) to match JS layout units.\n * iOS: Values are expressed in physical pixels and exclude status bar.\n */\nexport interface SafeAreaInsets {\n /** Current device orientation (1 = portrait, 2 = landscape, 0 = unknown). */\n orientation: number;\n /**\n * Orientation-aware notch/camera cutout inset (excluding status bar).\n * In portrait mode: returns top inset (notch at top).\n * In landscape mode: returns left inset (notch at side).\n * Android: Value in dp, iOS: Value in pixels (status bar excluded).\n */\n top: number;\n}\n\n/**\n * Canonical device orientation values across platforms.\n */\nexport type DeviceOrientation = 'portrait' | 'landscape-left' | 'landscape-right' | 'portrait-upside-down' | 'unknown';\n\n/**\n * The main interface for the CameraPreview plugin.\n */\nexport interface CameraPreviewPlugin {\n /**\n * Starts the camera preview.\n *\n * @param {CameraPreviewOptions} options - The configuration for the camera preview.\n * @returns {Promise<{ width: number; height: number; x: number; y: number }>} A promise that resolves with the preview dimensions.\n * @since 0.0.1\n */\n start(options: CameraPreviewOptions): Promise<{\n /** The width of the preview in pixels. */\n width: number;\n /** The height of the preview in pixels. */\n height: number;\n /** The horizontal origin of the preview, in pixels. */\n x: number;\n /** The vertical origin of the preview, in pixels. */\n y: number;\n }>;\n\n /**\n * Stops the camera preview.\n *\n * @param {object} options - Optional configuration for stopping the camera.\n * @param {boolean} options.force - If true, forces the camera to stop even if busy or capturing. Default: false.\n * @returns {Promise<void>} A promise that resolves when the camera preview is stopped.\n * @since 0.0.1\n */\n stop(options?: { force?: boolean }): Promise<void>;\n\n /**\n * Captures a picture from the camera.\n *\n * If `storeToFile` was set to `true` when starting the preview, the returned\n * `value` will be an absolute file path on the device instead of a base64 string. Use getBase64FromFilePath to get the base64 string from the file path.\n *\n * @param {CameraPreviewPictureOptions} options - The options for capturing the picture.\n * @returns {Promise<{ value: string; exif: ExifData }>} Resolves with:\n * - `value`: base64 string, or file path if `storeToFile` is true\n * - `exif`: extracted EXIF metadata when available\n * @since 0.0.1\n */\n capture(options: CameraPreviewPictureOptions): Promise<{ value: string; exif: ExifData }>;\n\n /**\n * Captures a single frame from the camera preview stream.\n *\n * @param {CameraSampleOptions} options - The options for capturing the sample.\n * @returns {Promise<{ value: string }>} A promise that resolves with the sample image as a base64 encoded string.\n * @since 0.0.1\n */\n captureSample(options: CameraSampleOptions): Promise<{ value: string }>;\n\n /**\n * Starts barcode scanning on the active camera preview.\n *\n * The scanner reuses the current camera session and emits `barcodeScanned` events.\n * Call `stopBarcodeScanner()` when scanning is no longer needed.\n *\n * Android uses the lightweight Google Play Services ML Kit model. If the model is not installed yet,\n * first scans may return no result until Google Play Services finishes downloading it.\n *\n * @since 8.8.0\n * @platform android, ios, web\n */\n startBarcodeScanner(options?: BarcodeScannerOptions): Promise<void>;\n\n /**\n * Stops barcode scanning while keeping the camera preview running.\n *\n * @since 8.8.0\n * @platform android, ios, web\n */\n stopBarcodeScanner(): Promise<void>;\n\n /**\n * Gets the flash modes supported by the active camera.\n *\n * @returns {Promise<{ result: CameraPreviewFlashMode[] }>} A promise that resolves with an array of supported flash modes.\n * @since 0.0.1\n */\n getSupportedFlashModes(): Promise<{\n result: CameraPreviewFlashMode[];\n }>;\n\n /**\n * Set the aspect ratio of the camera preview.\n *\n * @param {{ aspectRatio: CameraPreviewAspectRatio; x?: number; y?: number }} options - The desired aspect ratio and optional position.\n * - aspectRatio: The desired aspect ratio ('4:3', '16:9', or 'fill')\n * - x: Optional x coordinate for positioning. If not provided, view will be auto-centered horizontally.\n * - y: Optional y coordinate for positioning. If not provided, view will be auto-centered vertically.\n * @returns {Promise<{ width: number; height: number; x: number; y: number }>} A promise that resolves with the actual preview dimensions and position.\n * @since 7.5.0\n * @platform android, ios\n */\n setAspectRatio(options: { aspectRatio: CameraPreviewAspectRatio; x?: number; y?: number }): Promise<{\n width: number;\n height: number;\n x: number;\n y: number;\n }>;\n\n /**\n * Gets the current aspect ratio of the camera preview.\n *\n * @returns {Promise<{ aspectRatio: CameraPreviewAspectRatio }>} A promise that resolves with the current aspect ratio.\n * @since 7.5.0\n * @platform android, ios\n */\n getAspectRatio(): Promise<{ aspectRatio: CameraPreviewAspectRatio }>;\n\n /**\n * Sets the grid mode of the camera preview overlay.\n *\n * @param {{ gridMode: GridMode }} options - The desired grid mode ('none', '3x3', or '4x4').\n * @returns {Promise<void>} A promise that resolves when the grid mode is set.\n * @since 8.0.0\n */\n setGridMode(options: { gridMode: GridMode }): Promise<void>;\n\n /**\n * Gets the current grid mode of the camera preview overlay.\n *\n * @returns {Promise<{ gridMode: GridMode }>} A promise that resolves with the current grid mode.\n * @since 8.0.0\n */\n getGridMode(): Promise<{ gridMode: GridMode }>;\n\n /**\n * Checks the current camera (and optionally microphone) permission status without prompting the system dialog.\n *\n * @param options Set `disableAudio` to `false` to also include microphone status (defaults to `true`).\n * @returns {Promise<CameraPermissionStatus>} A promise resolving to the current authorization states.\n * @since 8.7.0\n */\n checkPermissions(options?: Pick<PermissionRequestOptions, 'disableAudio'>): Promise<CameraPermissionStatus>;\n\n /**\n * Requests camera (and optional microphone) permissions. If permissions are already granted or denied,\n * the current status is returned without prompting. When `showSettingsAlert` is true and permissions are denied,\n * a platform specific alert guiding the user to the app settings will be presented.\n *\n * @param {PermissionRequestOptions} options - Configuration for the permission request behaviour.\n * @returns {Promise<CameraPermissionStatus>} A promise resolving to the final authorization states.\n * @since 8.7.0\n */\n requestPermissions(options?: PermissionRequestOptions): Promise<CameraPermissionStatus>;\n\n /**\n * Gets the horizontal field of view (FoV) for the active camera.\n * Note: This can be an estimate on some devices.\n *\n * @returns {Promise<{ result: number }>} A promise that resolves with the horizontal field of view in degrees.\n * @since 0.0.1\n */\n getHorizontalFov(): Promise<{\n result: number;\n }>;\n\n /**\n * Gets the supported picture sizes for all cameras.\n *\n * @returns {Promise<{ supportedPictureSizes: SupportedPictureSizes[] }>} A promise that resolves with the list of supported sizes.\n * @since 7.4.0\n */\n getSupportedPictureSizes(): Promise<{\n supportedPictureSizes: SupportedPictureSizes[];\n }>;\n\n /**\n * Sets the flash mode for the active camera.\n *\n * @param {{ flashMode: CameraPreviewFlashMode | string }} options - The desired flash mode.\n * @returns {Promise<void>} A promise that resolves when the flash mode is set.\n * @since 0.0.1\n */\n setFlashMode(options: { flashMode: CameraPreviewFlashMode | string }): Promise<void>;\n\n /**\n * Toggles between the front and rear cameras.\n *\n * @returns {Promise<void>} A promise that resolves when the camera is flipped.\n * @since 0.0.1\n */\n flip(): Promise<void>;\n\n /**\n * Sets the opacity of the camera preview.\n *\n * @param {CameraOpacityOptions} options - The opacity options.\n * @returns {Promise<void>} A promise that resolves when the opacity is set.\n * @since 0.0.1\n */\n setOpacity(options: CameraOpacityOptions): Promise<void>;\n\n /**\n * Stops an ongoing video recording.\n *\n * @returns {Promise<RecordingFinishedEvent>} A promise that resolves with the path to the recorded video file.\n * @since 0.0.1\n */\n stopRecordVideo(): Promise<RecordingFinishedEvent>;\n\n /**\n * Starts recording a video.\n *\n * Supports `frameRate`, `videoCodec`, `videoStabilizationMode`, `maxDuration`, `maxFileSize`, `disableAudio`, and `allowHapticsAndSystemSoundsDuringRecording` on each call.\n *\n * @param {CameraPreviewOptions} options - The options for video recording.\n * @returns {Promise<void>} A promise that resolves when video recording starts.\n * @since 0.0.1\n */\n startRecordVideo(options: CameraPreviewOptions): Promise<void>;\n\n /**\n * Sets the video recording quality for the active camera session.\n *\n * @param {{ quality: VideoQuality }} options - The desired video quality.\n * @returns {Promise<void>} A promise that resolves when the quality is set.\n * @since 8.5.0\n * @platform android, ios\n */\n setVideoQuality(options: { quality: VideoQuality }): Promise<void>;\n\n /**\n * Gets the current video recording quality.\n *\n * @returns {Promise<{ quality: VideoQuality }>} A promise that resolves with the current quality.\n * @since 8.5.0\n * @platform android, ios\n */\n getVideoQuality(): Promise<{ quality: VideoQuality }>;\n\n /**\n * Returns the video qualities supported by the active camera.\n *\n * @returns {Promise<{ qualities: VideoQuality[] }>} A promise that resolves with supported qualities.\n * @since 8.5.0\n * @platform android, ios\n */\n getSupportedVideoQualities(): Promise<{ qualities: VideoQuality[] }>;\n\n /**\n * Sets the video codec used when recording.\n *\n * @param {{ codec: VideoCodec }} options - The desired codec.\n * @returns {Promise<void>} A promise that resolves when the codec is set.\n * @since 8.5.0\n * @platform android, ios\n */\n setVideoCodec(options: { codec: VideoCodec }): Promise<void>;\n\n /**\n * Gets the current video codec used for recording.\n *\n * @returns {Promise<{ codec: VideoCodec }>} A promise that resolves with the current codec.\n * @since 8.5.0\n * @platform android, ios\n */\n getVideoCodec(): Promise<{ codec: VideoCodec }>;\n\n /**\n * Returns the video codecs supported by the active camera.\n *\n * @returns {Promise<{ codecs: VideoCodec[] }>} A promise that resolves with supported codecs.\n * @since 8.5.0\n * @platform android, ios\n */\n getSupportedVideoCodecs(): Promise<{ codecs: VideoCodec[] }>;\n\n /**\n * Checks whether video stabilization is supported by the active camera.\n *\n * @returns {Promise<{ supported: boolean }>} A promise that resolves with the support state.\n * @since 8.5.2\n * @platform android, ios\n */\n isVideoStabilizationSupported(): Promise<{ supported: boolean }>;\n\n /**\n * Returns the video stabilization modes supported by the active camera.\n *\n * @returns {Promise<{ modes: VideoStabilizationMode[] }>} A promise that resolves with supported modes.\n * @since 8.5.2\n * @platform android, ios\n */\n getSupportedVideoStabilizationModes(): Promise<{ modes: VideoStabilizationMode[] }>;\n\n /**\n * Gets the current video stabilization mode.\n *\n * @returns {Promise<{ mode: VideoStabilizationMode }>} A promise that resolves with the current mode.\n * @since 8.5.2\n * @platform android, ios\n */\n getVideoStabilizationMode(): Promise<{ mode: VideoStabilizationMode }>;\n\n /**\n * Sets the video stabilization mode for recording.\n * Cannot be changed while a recording is in progress.\n * You can also pass `videoStabilizationMode` in `startRecordVideo()` options.\n *\n * @param {{ mode: VideoStabilizationMode }} options - The desired stabilization mode.\n * @returns {Promise<void>} A promise that resolves when the mode is set.\n * @since 8.5.2\n * @platform android, ios\n */\n setVideoStabilizationMode(options: { mode: VideoStabilizationMode }): Promise<void>;\n\n /**\n * Checks if the camera preview is currently running.\n *\n * @returns {Promise<{ isRunning: boolean }>} A promise that resolves with the running state.\n * @since 7.5.0\n * @platform android, ios\n */\n isRunning(): Promise<{ isRunning: boolean }>;\n\n /**\n * Gets all available camera devices.\n *\n * @returns {Promise<{ devices: CameraDevice[] }>} A promise that resolves with the list of available camera devices.\n * @since 7.5.0\n * @platform android, ios\n */\n getAvailableDevices(): Promise<{ devices: CameraDevice[] }>;\n\n /**\n * Gets the current zoom state, including min/max and current lens info.\n *\n * @returns {Promise<{ min: number; max: number; current: number; lens: LensInfo }>} A promise that resolves with the zoom state.\n * @since 7.5.0\n * @platform android, ios\n */\n getZoom(): Promise<{\n min: number;\n max: number;\n current: number;\n lens: LensInfo;\n }>;\n\n /**\n * Returns zoom button values for quick switching.\n * - iOS/Android: includes 0.5 if ultra-wide available; 1 and 2 if wide available; 3 if telephoto available\n * - Web: unsupported\n * @since 7.5.0\n * @platform android, ios\n */\n getZoomButtonValues(): Promise<{ values: number[] }>;\n\n /**\n * Sets the zoom level of the camera.\n *\n * @param {{ level: number; ramp?: boolean; autoFocus?: boolean }} options - The desired zoom level. `ramp` is currently unused. `autoFocus` defaults to true.\n * @returns {Promise<void>} A promise that resolves when the zoom level is set.\n * @since 7.5.0\n * @platform android, ios\n */\n setZoom(options: { level: number; ramp?: boolean; autoFocus?: boolean }): Promise<void>;\n\n /**\n * Gets the current flash mode.\n *\n * @returns {Promise<{ flashMode: FlashMode }>} A promise that resolves with the current flash mode.\n * @since 7.5.0\n * @platform android, ios\n */\n getFlashMode(): Promise<{ flashMode: FlashMode }>;\n\n /**\n * Removes all registered listeners.\n *\n * @since 7.5.0\n * @platform android, ios\n */\n removeAllListeners(): Promise<void>;\n\n /**\n * Switches the active camera to the one with the specified `deviceId`.\n *\n * @param {{ deviceId: string }} options - The ID of the device to switch to.\n * @returns {Promise<void>} A promise that resolves when the camera is switched.\n * @since 7.5.0\n * @platform android, ios\n */\n setDeviceId(options: { deviceId: string }): Promise<void>;\n\n /**\n * Gets the ID of the camera device that is currently bound.\n * On Android, if a physical-lens request falls back to a logical camera, this returns the bound logical camera ID.\n *\n * @returns {Promise<{ deviceId: string }>} A promise that resolves with the current device ID.\n * @since 7.5.0\n * @platform android, ios\n */\n getDeviceId(): Promise<{ deviceId: string }>;\n\n /**\n * Gets the current preview size and position.\n * @returns {Promise<{x: number, y: number, width: number, height: number}>}\n * @since 7.5.0\n * @platform android, ios\n */\n getPreviewSize(): Promise<{\n x: number;\n y: number;\n width: number;\n height: number;\n }>;\n /**\n * Sets the preview size and position.\n * @param options The new position and dimensions.\n * @returns {Promise<{ width: number; height: number; x: number; y: number }>} A promise that resolves with the actual preview dimensions and position.\n * @since 7.5.0\n * @platform android, ios\n */\n setPreviewSize(options: { x?: number; y?: number; width: number; height: number }): Promise<{\n width: number;\n height: number;\n x: number;\n y: number;\n }>;\n\n /**\n * Sets the camera focus to a specific point in the preview.\n *\n * Note: The plugin does not attach any native tap-to-focus gesture handlers. Handle taps in\n * your HTML/JS (e.g., on the overlaying UI), then pass normalized coordinates here.\n *\n * @param {Object} options - The focus options.\n * @param {number} options.x - The x coordinate in the preview view to focus on (0-1 normalized).\n * @param {number} options.y - The y coordinate in the preview view to focus on (0-1 normalized).\n * @returns {Promise<void>} A promise that resolves when the focus is set.\n * @since 7.5.0\n * @platform android, ios\n */\n setFocus(options: { x: number; y: number }): Promise<void>;\n\n /**\n * Adds a listener for screen resize events.\n * @param {string} eventName - The event name to listen for.\n * @param {Function} listenerFunc - The function to call when the event is triggered.\n * @returns {Promise<PluginListenerHandle>} A promise that resolves with a handle to the listener.\n * @since 7.5.0\n * @platform android, ios\n */\n addListener(\n eventName: 'screenResize',\n listenerFunc: (data: { width: number; height: number; x: number; y: number }) => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Adds a listener for orientation change events.\n * @param {string} eventName - The event name to listen for.\n * @param {Function} listenerFunc - The function to call when the event is triggered.\n * @returns {Promise<PluginListenerHandle>} A promise that resolves with a handle to the listener.\n * @since 7.5.0\n * @platform android, ios\n */\n addListener(\n eventName: 'orientationChange',\n listenerFunc: (data: { orientation: DeviceOrientation }) => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Adds a listener for barcode scan results.\n *\n * @since 8.8.0\n * @platform android, ios, web\n */\n addListener(\n eventName: 'barcodeScanned',\n listenerFunc: (data: BarcodeScannedEvent) => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Adds a listener for non-fatal barcode scanner errors.\n *\n * @since 8.8.0\n * @platform android, web\n */\n addListener(\n eventName: 'barcodeScanError',\n listenerFunc: (data: BarcodeScanErrorEvent) => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Adds a listener fired when a video recording finishes natively, including automatic stops.\n *\n * @since 8.4.7\n * @platform android, ios\n */\n addListener(\n eventName: 'recordingFinished',\n listenerFunc: (data: RecordingFinishedEvent) => void,\n ): Promise<PluginListenerHandle>;\n /**\n * Deletes a file at the given absolute path on the device.\n * Use this to quickly clean up temporary images created with `storeToFile`.\n * On web, this is not supported and will throw.\n * @since 7.5.0\n * @platform android, ios\n */\n deleteFile(options: { path: string }): Promise<{ success: boolean }>;\n\n /**\n * Gets the safe area insets for devices.\n * Returns the orientation-aware notch/camera cutout inset and the current orientation.\n * In portrait mode: returns top inset (notch at top).\n * In landscape mode: returns left inset (notch moved to side).\n * This specifically targets the cutout area (notch, punch hole, etc.) that all modern phones have.\n *\n * Android: Values returned in dp (logical pixels).\n * iOS: Values returned in physical pixels, excluding status bar (only pure notch/cutout size).\n *\n * @platform android, ios\n */\n getSafeAreaInsets(): Promise<SafeAreaInsets>;\n\n /**\n * Gets the current device orientation in a cross-platform format.\n * @since 7.5.0\n * @platform android, ios\n */\n getOrientation(): Promise<{ orientation: DeviceOrientation }>;\n\n /**\n * Returns the exposure modes supported by the active camera.\n * Modes can include: 'locked', 'auto', 'continuous', 'custom'.\n * @platform android, ios\n */\n getExposureModes(): Promise<{ modes: ExposureMode[] }>;\n\n /**\n * Returns the current exposure mode.\n * @platform android, ios\n */\n getExposureMode(): Promise<{ mode: ExposureMode }>;\n\n /**\n * Sets the exposure mode.\n * @platform android, ios\n */\n setExposureMode(options: { mode: ExposureMode }): Promise<void>;\n\n /**\n * Returns the exposure compensation (EV bias) supported range.\n * @platform ios, android\n */\n getExposureCompensationRange(): Promise<{\n min: number;\n max: number;\n step: number;\n }>;\n\n /**\n * Returns the current exposure compensation (EV bias).\n * @platform ios, android\n */\n getExposureCompensation(): Promise<{ value: number }>;\n\n /**\n * Sets the exposure compensation (EV bias). Value will be clamped to range.\n * @platform ios, android\n */\n setExposureCompensation(options: { value: number }): Promise<void>;\n\n /**\n * Lists the video frame rates supported by the active camera for the current format.\n * Supported values depend on the selected camera, lens, and video quality.\n *\n * @platform android, ios\n * @since 8.6.0\n */\n getSupportedVideoFrameRates(): Promise<{\n frameRates: number[];\n }>;\n\n /**\n * Returns the configured video frame rate for the active camera.\n * On Android the actual recording frame rate can still vary in low light or under thermal pressure.\n *\n * @platform android, ios\n * @since 8.6.0\n */\n getVideoFrameRate(): Promise<{\n frameRate: number;\n }>;\n\n /**\n * Sets the target video frame rate for the active camera session.\n * Prefer passing `frameRate` to `startRecordVideo()` when starting a recording.\n * Rejects unsupported values with a clear error.\n *\n * @platform android, ios\n * @since 8.6.0\n */\n setVideoFrameRate(options: { frameRate: number }): Promise<void>;\n\n /**\n * Get the native Capacitor plugin version\n *\n * @returns {Promise<{ id: string }>} an Promise with version for this device\n * @throws An error if the something went wrong\n */\n getPluginVersion(): Promise<{ version: string }>;\n}\n"]}
@@ -105,6 +105,10 @@ class CameraController: NSObject {
105
105
 
106
106
  var captureSession: AVCaptureSession?
107
107
  var disableFocusIndicator: Bool = false
108
+ private var focusExposureRestoreGeneration: UInt = 0
109
+ private var focusExposureRestoreTimeoutWorkItem: DispatchWorkItem?
110
+ private let focusExposureRestoreTimeout: TimeInterval = 3.0
111
+ private let focusExposureRestorePollInterval: TimeInterval = 0.05
108
112
 
109
113
  var currentCameraPosition: CameraPosition?
110
114
 
@@ -157,6 +161,8 @@ class CameraController: NSObject {
157
161
  private var configuredVideoFrameRate: Int?
158
162
  var videoCodec: String = "avc1"
159
163
  var videoStabilizationMode: String = "off"
164
+ private var cachedSupportedVideoStabilizationModes: [String] = []
165
+ private var isSupportedVideoStabilizationModesCacheValid = false
160
166
 
161
167
  private static let allVideoQualities = ["low", "medium", "high", "2160p", "1080p", "720p", "480p", "4:3"]
162
168
 
@@ -223,23 +229,10 @@ class CameraController: NSObject {
223
229
  }
224
230
 
225
231
  func getSupportedVideoStabilizationModes() -> [String] {
226
- guard let connection = self.fileVideoOutput?.connection(with: .video),
227
- connection.isVideoStabilizationSupported else {
228
- return ["off"]
232
+ if self.isSupportedVideoStabilizationModesCacheValid {
233
+ return self.cachedSupportedVideoStabilizationModes
229
234
  }
230
-
231
- let savedPreferred = connection.preferredVideoStabilizationMode
232
- var supported: [String] = []
233
-
234
- for candidate in Self.allVideoStabilizationModeCandidates() {
235
- connection.preferredVideoStabilizationMode = candidate.mode
236
- if connection.preferredVideoStabilizationMode == candidate.mode {
237
- supported.append(candidate.name)
238
- }
239
- }
240
-
241
- connection.preferredVideoStabilizationMode = savedPreferred
242
- return supported.isEmpty ? ["off"] : supported
235
+ return self.refreshSupportedVideoStabilizationModesCache()
243
236
  }
244
237
 
245
238
  func getVideoStabilizationMode() -> String {
@@ -257,12 +250,96 @@ class CameraController: NSObject {
257
250
  guard let avMode = self.avVideoStabilizationMode(from: mode) else {
258
251
  throw CameraControllerError.invalidOperation
259
252
  }
253
+
254
+ if self.isVideoStabilizationOutputAttached() {
255
+ try self.validateVideoStabilizationMode(mode)
256
+ }
257
+
258
+ self.videoStabilizationMode = mode
259
+
260
+ guard self.isVideoStabilizationOutputAttached() else {
261
+ return
262
+ }
263
+
264
+ self.configureCaptureSession {
265
+ self.applyVideoStabilizationMode(avMode)
266
+ }
267
+ }
268
+
269
+ @discardableResult
270
+ private func refreshSupportedVideoStabilizationModesCache() -> [String] {
271
+ let modes = self.probeSupportedVideoStabilizationModes()
272
+ self.cachedSupportedVideoStabilizationModes = modes
273
+ self.isSupportedVideoStabilizationModesCacheValid = true
274
+ return modes
275
+ }
276
+
277
+ private func invalidateSupportedVideoStabilizationModesCache() {
278
+ self.isSupportedVideoStabilizationModesCacheValid = false
279
+ self.cachedSupportedVideoStabilizationModes = []
280
+ }
281
+
282
+ private func validateVideoStabilizationMode(_ mode: String) throws {
260
283
  let supportedModes = self.getSupportedVideoStabilizationModes()
261
284
  guard supportedModes.contains(mode) else {
262
285
  throw CameraControllerError.invalidOperation
263
286
  }
264
- self.videoStabilizationMode = mode
265
- self.applyVideoStabilizationMode(avMode)
287
+ }
288
+
289
+ private func isVideoStabilizationOutputAttached() -> Bool {
290
+ guard let captureSession = self.captureSession,
291
+ let fileVideoOutput = self.fileVideoOutput else {
292
+ return false
293
+ }
294
+ return captureSession.outputs.contains(where: { $0 === fileVideoOutput })
295
+ }
296
+
297
+ private func configureCaptureSession(_ block: () -> Void) {
298
+ guard let captureSession = self.captureSession else {
299
+ block()
300
+ return
301
+ }
302
+
303
+ captureSession.beginConfiguration()
304
+ defer { captureSession.commitConfiguration() }
305
+ block()
306
+ }
307
+
308
+ private func activeVideoCaptureDevice() -> AVCaptureDevice? {
309
+ switch self.currentCameraPosition {
310
+ case .front:
311
+ return self.frontCamera
312
+ case .rear:
313
+ return self.rearCamera
314
+ default:
315
+ return nil
316
+ }
317
+ }
318
+
319
+ private func probeSupportedVideoStabilizationModes() -> [String] {
320
+ guard let connection = self.fileVideoOutput?.connection(with: .video),
321
+ connection.isVideoStabilizationSupported,
322
+ let device = self.activeVideoCaptureDevice() else {
323
+ return ["off"]
324
+ }
325
+
326
+ let format = device.activeFormat
327
+ var supported: [String] = ["off"]
328
+
329
+ for candidate in Self.allVideoStabilizationModeCandidates() where candidate.mode != .off {
330
+ if format.isVideoStabilizationModeSupported(candidate.mode) {
331
+ supported.append(candidate.name)
332
+ }
333
+ }
334
+
335
+ return supported
336
+ }
337
+
338
+ private func refreshVideoStabilizationAfterMovieOutputAttached() throws {
339
+ self.invalidateSupportedVideoStabilizationModesCache()
340
+ _ = self.refreshSupportedVideoStabilizationModesCache()
341
+ try self.validateVideoStabilizationMode(self.videoStabilizationMode)
342
+ self.applyVideoStabilizationMode()
266
343
  }
267
344
 
268
345
  private static func allVideoStabilizationModeCandidates() -> [(name: String, mode: AVCaptureVideoStabilizationMode)] {
@@ -649,7 +726,7 @@ extension CameraController {
649
726
  captureSession.addOutput(fileVideoOutput)
650
727
  // Set orientation immediately
651
728
  self.setVideoOrientation(videoOrientation, on: fileVideoOutput.connections)
652
- self.applyVideoStabilizationMode()
729
+ try self.refreshVideoStabilizationAfterMovieOutputAttached()
653
730
  }
654
731
 
655
732
  // Set up preview layer session in the same configuration block
@@ -1122,6 +1199,7 @@ extension CameraController {
1122
1199
  }
1123
1200
 
1124
1201
  func switchCameras() throws {
1202
+ self.cancelPendingFocusExposureRestore()
1125
1203
  configuredVideoFrameRate = nil
1126
1204
  guard let currentCameraPosition = currentCameraPosition,
1127
1205
  let captureSession = self.captureSession else {
@@ -1230,7 +1308,7 @@ extension CameraController {
1230
1308
  captureSession.removeOutput(fileVideoOutput)
1231
1309
  if captureSession.canAddOutput(fileVideoOutput) {
1232
1310
  captureSession.addOutput(fileVideoOutput)
1233
- self.applyVideoStabilizationMode()
1311
+ try self.refreshVideoStabilizationAfterMovieOutputAttached()
1234
1312
  }
1235
1313
  }
1236
1314
 
@@ -2106,46 +2184,116 @@ extension CameraController {
2106
2184
  }
2107
2185
  }
2108
2186
 
2109
- private func triggerAutoFocus() {
2110
- var currentCamera: AVCaptureDevice?
2111
- switch currentCameraPosition {
2112
- case .front:
2113
- currentCamera = self.frontCamera
2114
- case .rear:
2115
- currentCamera = self.rearCamera
2116
- default: break
2187
+
2188
+ private func cancelPendingFocusExposureRestore() {
2189
+ self.focusExposureRestoreGeneration &+= 1
2190
+ self.focusExposureRestoreTimeoutWorkItem?.cancel()
2191
+ self.focusExposureRestoreTimeoutWorkItem = nil
2192
+ }
2193
+
2194
+ private func applyOneShotFocusAndExposure(at point: CGPoint, on device: AVCaptureDevice, adjustExposure: Bool) throws {
2195
+ try device.lockForConfiguration()
2196
+ defer { device.unlockForConfiguration() }
2197
+
2198
+ if device.isFocusModeSupported(.autoFocus) {
2199
+ device.focusMode = .autoFocus
2200
+ } else if device.isFocusModeSupported(.continuousAutoFocus) {
2201
+ device.focusMode = .continuousAutoFocus
2117
2202
  }
2118
2203
 
2119
- guard let device = currentCamera else {
2204
+ if device.isFocusPointOfInterestSupported {
2205
+ device.focusPointOfInterest = point
2206
+ }
2207
+
2208
+ if adjustExposure, device.exposureMode != .locked {
2209
+ if device.isExposurePointOfInterestSupported, device.isExposureModeSupported(.autoExpose) {
2210
+ device.exposureMode = .autoExpose
2211
+ device.setExposureTargetBias(0.0) { _ in }
2212
+ device.exposurePointOfInterest = point
2213
+ }
2214
+ }
2215
+
2216
+ device.isSubjectAreaChangeMonitoringEnabled = true
2217
+ }
2218
+
2219
+ private func scheduleFocusExposureRestore(for device: AVCaptureDevice) {
2220
+ self.focusExposureRestoreGeneration &+= 1
2221
+ let generation = self.focusExposureRestoreGeneration
2222
+
2223
+ self.focusExposureRestoreTimeoutWorkItem?.cancel()
2224
+
2225
+ let timeoutWork = DispatchWorkItem { [weak self] in
2226
+ self?.restoreContinuousFocusAndExposureIfCurrent(on: device, generation: generation)
2227
+ }
2228
+ self.focusExposureRestoreTimeoutWorkItem = timeoutWork
2229
+
2230
+ self.pollFocusExposureAdjustmentCompletion(on: device, generation: generation)
2231
+ DispatchQueue.main.asyncAfter(deadline: .now() + self.focusExposureRestoreTimeout, execute: timeoutWork)
2232
+ }
2233
+
2234
+ private func pollFocusExposureAdjustmentCompletion(on device: AVCaptureDevice, generation: UInt) {
2235
+ guard generation == self.focusExposureRestoreGeneration else { return }
2236
+
2237
+ if device.isAdjustingFocus || device.isAdjustingExposure {
2238
+ DispatchQueue.main.asyncAfter(deadline: .now() + self.focusExposureRestorePollInterval) { [weak self] in
2239
+ self?.pollFocusExposureAdjustmentCompletion(on: device, generation: generation)
2240
+ }
2120
2241
  return
2121
2242
  }
2122
2243
 
2123
- // Focus on the center of the preview (0.5, 0.5)
2124
- let centerPoint = CGPoint(x: 0.5, y: 0.5)
2244
+ self.restoreContinuousFocusAndExposureIfCurrent(on: device, generation: generation)
2245
+ }
2246
+
2247
+ private func restoreContinuousFocusAndExposureIfCurrent(on device: AVCaptureDevice, generation: UInt) {
2248
+ guard generation == self.focusExposureRestoreGeneration else { return }
2249
+
2250
+ self.focusExposureRestoreTimeoutWorkItem?.cancel()
2251
+ self.focusExposureRestoreTimeoutWorkItem = nil
2125
2252
 
2126
2253
  do {
2127
2254
  try device.lockForConfiguration()
2255
+ defer { device.unlockForConfiguration() }
2128
2256
 
2129
- // Set focus mode to auto if supported
2130
- if device.isFocusModeSupported(.autoFocus) {
2131
- device.focusMode = .autoFocus
2132
- if device.isFocusPointOfInterestSupported {
2133
- device.focusPointOfInterest = centerPoint
2134
- }
2135
- } else if device.isFocusModeSupported(.continuousAutoFocus) {
2257
+ let centerPoint = CGPoint(x: 0.5, y: 0.5)
2258
+
2259
+ if device.isFocusModeSupported(.continuousAutoFocus) {
2136
2260
  device.focusMode = .continuousAutoFocus
2137
2261
  if device.isFocusPointOfInterestSupported {
2138
2262
  device.focusPointOfInterest = centerPoint
2139
2263
  }
2140
2264
  }
2141
2265
 
2142
- if device.isExposurePointOfInterestSupported {
2143
- let exposureMode = try getExposureMode()
2144
- if exposureMode == "AUTO" || exposureMode == "CONTINUOUS" {
2145
- device.exposurePointOfInterest = centerPoint
2266
+ if device.exposureMode != .locked {
2267
+ if device.isExposureModeSupported(.continuousAutoExposure) {
2268
+ device.exposureMode = .continuousAutoExposure
2269
+ if device.isExposurePointOfInterestSupported {
2270
+ device.exposurePointOfInterest = centerPoint
2271
+ }
2272
+ device.setExposureTargetBias(0.0) { _ in }
2146
2273
  }
2147
2274
  }
2148
- device.unlockForConfiguration()
2275
+
2276
+ device.isSubjectAreaChangeMonitoringEnabled = false
2277
+ } catch {
2278
+ print("[CameraPreview] Failed to restore continuous focus/exposure: \(error)")
2279
+ }
2280
+ }
2281
+
2282
+ private func triggerAutoFocus() {
2283
+ guard let device = self.activeVideoDevice() else { return }
2284
+
2285
+ let centerPoint = CGPoint(x: 0.5, y: 0.5)
2286
+ let adjustExposure: Bool
2287
+ do {
2288
+ let exposureMode = try self.getExposureMode()
2289
+ adjustExposure = exposureMode == "AUTO" || exposureMode == "CONTINUOUS"
2290
+ } catch {
2291
+ adjustExposure = true
2292
+ }
2293
+
2294
+ do {
2295
+ try self.applyOneShotFocusAndExposure(at: centerPoint, on: device, adjustExposure: adjustExposure)
2296
+ self.scheduleFocusExposureRestore(for: device)
2149
2297
  } catch {
2150
2298
  // Silently ignore errors during autofocus
2151
2299
  }
@@ -2184,33 +2332,8 @@ extension CameraController {
2184
2332
  }
2185
2333
 
2186
2334
  do {
2187
- try device.lockForConfiguration()
2188
-
2189
- // Set focus mode to auto if supported
2190
- if device.isFocusModeSupported(.autoFocus) {
2191
- device.focusMode = .autoFocus
2192
- } else if device.isFocusModeSupported(.continuousAutoFocus) {
2193
- device.focusMode = .continuousAutoFocus
2194
- }
2195
-
2196
- // Set the focus point
2197
- device.focusPointOfInterest = point
2198
-
2199
- // Skip exposure point if exposure locked
2200
- if device.exposureMode != .locked {
2201
-
2202
- // Also set exposure point if supported
2203
- if device.isExposurePointOfInterestSupported && device.isExposureModeSupported(.autoExpose) {
2204
- device.exposureMode = .autoExpose
2205
- device.setExposureTargetBias(0.0) { _ in }
2206
- device.exposurePointOfInterest = point
2207
- }
2208
- }
2209
-
2210
- // Turn on subject area monitor for switch to continuous focus if needed
2211
- device.isSubjectAreaChangeMonitoringEnabled = true
2212
-
2213
- device.unlockForConfiguration()
2335
+ try self.applyOneShotFocusAndExposure(at: point, on: device, adjustExposure: true)
2336
+ self.scheduleFocusExposureRestore(for: device)
2214
2337
  } catch {
2215
2338
  throw CameraControllerError.unknown
2216
2339
  }
@@ -2299,6 +2422,7 @@ extension CameraController {
2299
2422
  }
2300
2423
 
2301
2424
  func swapToDevice(deviceId: String) throws {
2425
+ self.cancelPendingFocusExposureRestore()
2302
2426
  guard let captureSession = self.captureSession else {
2303
2427
  throw CameraControllerError.captureSessionIsMissing
2304
2428
  }
@@ -2372,11 +2496,22 @@ extension CameraController {
2372
2496
  captureSession.addInput(audioInput)
2373
2497
  }
2374
2498
 
2499
+ // Re-attach movie file output so its connection is bound to the new input.
2500
+ if let fileVideoOutput = self.fileVideoOutput,
2501
+ captureSession.outputs.contains(where: { $0 === fileVideoOutput }) {
2502
+ captureSession.removeOutput(fileVideoOutput)
2503
+ if captureSession.canAddOutput(fileVideoOutput) {
2504
+ captureSession.addOutput(fileVideoOutput)
2505
+ try self.refreshVideoStabilizationAfterMovieOutputAttached()
2506
+ }
2507
+ }
2508
+
2375
2509
  // Update video orientation
2376
2510
  self.updateVideoOrientation()
2377
2511
  }
2378
2512
 
2379
2513
  func cleanup() {
2514
+ self.cancelPendingFocusExposureRestore()
2380
2515
  configuredVideoFrameRate = nil
2381
2516
  stopBarcodeScanner()
2382
2517
  if let captureSession = self.captureSession {
@@ -2413,6 +2548,7 @@ extension CameraController {
2413
2548
 
2414
2549
  // Reset output preparation status
2415
2550
  self.outputsPrepared = false
2551
+ self.invalidateSupportedVideoStabilizationModesCache()
2416
2552
 
2417
2553
  // Reset first frame detection
2418
2554
  self.hasReceivedFirstFrame = false
@@ -2708,7 +2844,7 @@ extension CameraController {
2708
2844
  }
2709
2845
  }
2710
2846
 
2711
- func captureVideo(maxDuration: Float? = nil, maxFileSize: Int? = nil) throws {
2847
+ func captureVideo(maxDuration: Float? = nil, maxFileSize: Int? = nil, allowHapticsAndSystemSoundsDuringRecording: Bool = false) throws {
2712
2848
  guard let captureSession = self.captureSession, captureSession.isRunning else {
2713
2849
  throw CameraControllerError.captureSessionIsMissing
2714
2850
  }
@@ -2729,6 +2865,7 @@ extension CameraController {
2729
2865
  let audioSession = AVAudioSession.sharedInstance()
2730
2866
  try audioSession.setCategory(.playAndRecord, mode: .videoRecording, options: [.defaultToSpeaker])
2731
2867
  try audioSession.setActive(true)
2868
+ try audioSession.setAllowHapticsAndSystemSoundsDuringRecording(allowHapticsAndSystemSoundsDuringRecording)
2732
2869
  } catch {
2733
2870
  print("[CameraPreview] Failed to configure AVAudioSession for video recording: \(error)")
2734
2871
  }
@@ -2737,15 +2874,21 @@ extension CameraController {
2737
2874
  // Ensure the movie file output is attached to the active session.
2738
2875
  // If the camera was started without cameraMode=true, the output may not have been added yet.
2739
2876
  if !captureSession.outputs.contains(where: { $0 === fileVideoOutput }) {
2740
- captureSession.beginConfiguration()
2741
- if captureSession.canAddOutput(fileVideoOutput) {
2742
- captureSession.addOutput(fileVideoOutput)
2743
- self.applyVideoStabilizationMode()
2744
- } else {
2745
- captureSession.commitConfiguration()
2877
+ var didAddOutput = false
2878
+ self.configureCaptureSession {
2879
+ if captureSession.canAddOutput(fileVideoOutput) {
2880
+ captureSession.addOutput(fileVideoOutput)
2881
+ do {
2882
+ try self.refreshVideoStabilizationAfterMovieOutputAttached()
2883
+ didAddOutput = true
2884
+ } catch {
2885
+ didAddOutput = false
2886
+ }
2887
+ }
2888
+ }
2889
+ guard didAddOutput else {
2746
2890
  throw CameraControllerError.invalidOperation
2747
2891
  }
2748
- captureSession.commitConfiguration()
2749
2892
  }
2750
2893
 
2751
2894
  if let connection = fileVideoOutput.connection(with: .video) {
@@ -2782,7 +2925,9 @@ extension CameraController {
2782
2925
  fileVideoOutput.setOutputSettings([AVVideoCodecKey: codecType], for: connection)
2783
2926
  }
2784
2927
 
2785
- self.applyVideoStabilizationMode()
2928
+ self.configureCaptureSession {
2929
+ self.applyVideoStabilizationMode()
2930
+ }
2786
2931
 
2787
2932
  // Start recording video
2788
2933
  fileVideoOutput.startRecording(to: fileUrl, recordingDelegate: self)
@@ -2821,38 +2966,16 @@ extension CameraController: UIGestureRecognizerDelegate {
2821
2966
 
2822
2967
  @objc
2823
2968
  func handleTap(_ tap: UITapGestureRecognizer) {
2824
- guard let device = self.currentCameraPosition == .rear ? rearCamera : frontCamera else { return }
2825
-
2826
- let point = tap.location(in: tap.view)
2827
- let devicePoint = self.previewLayer?.captureDevicePointConverted(fromLayerPoint: point)
2828
-
2829
- // Show focus indicator at the tap point if not disabled
2830
- if !self.disableFocusIndicator, let view = tap.view {
2831
- showFocusIndicator(at: point, in: view)
2969
+ guard let devicePoint = self.previewLayer?.captureDevicePointConverted(fromLayerPoint: tap.location(in: tap.view)) else {
2970
+ return
2832
2971
  }
2833
2972
 
2834
2973
  do {
2835
- try device.lockForConfiguration()
2836
- defer { device.unlockForConfiguration() }
2837
-
2838
- let focusMode = AVCaptureDevice.FocusMode.autoFocus
2839
- if device.isFocusPointOfInterestSupported && device.isFocusModeSupported(focusMode) {
2840
- device.focusPointOfInterest = CGPoint(x: CGFloat(devicePoint?.x ?? 0), y: CGFloat(devicePoint?.y ?? 0))
2841
- device.focusMode = focusMode
2842
- }
2843
- // Skip exposure point if locked
2844
- if device.exposureMode != .locked {
2845
- let exposureMode = AVCaptureDevice.ExposureMode.autoExpose
2846
- if device.isExposurePointOfInterestSupported && device.isExposureModeSupported(exposureMode) {
2847
- device.exposurePointOfInterest = CGPoint(x: CGFloat(devicePoint?.x ?? 0), y: CGFloat(devicePoint?.y ?? 0))
2848
- device.exposureMode = exposureMode
2849
- device.setExposureTargetBias(0.0) { _ in }
2850
- }
2851
- }
2852
-
2853
- // Turn on subject area monitor for switch to continuous focus if needed
2854
- device.isSubjectAreaChangeMonitoringEnabled = true
2855
-
2974
+ try self.setFocus(
2975
+ at: devicePoint,
2976
+ showIndicator: !self.disableFocusIndicator,
2977
+ in: tap.view
2978
+ )
2856
2979
  } catch {
2857
2980
  debugPrint(error)
2858
2981
  }
@@ -35,7 +35,7 @@ extension UIWindow {
35
35
  */
36
36
  @objc(CameraPreview)
37
37
  public class CameraPreview: CAPPlugin, CAPBridgedPlugin, CLLocationManagerDelegate {
38
- private let pluginVersion: String = "8.7.1"
38
+ private let pluginVersion: String = "8.8.1"
39
39
  public let identifier = "CameraPreviewPlugin"
40
40
  public let jsName = "CameraPreview"
41
41
  public let pluginMethods: [CAPPluginMethod] = [
@@ -676,6 +676,7 @@ public class CameraPreview: CAPPlugin, CAPBridgedPlugin, CLLocationManagerDelega
676
676
  print(" - disableFocusIndicator: \(call.getBool("disableFocusIndicator") ?? false)")
677
677
  print(" - force: \(call.getBool("force") ?? false)")
678
678
  print(" - videoQuality: \(call.getString("videoQuality") ?? "high")")
679
+ print(" - videoStabilizationMode: \(call.getString("videoStabilizationMode") ?? "off")")
679
680
 
680
681
  let force = call.getBool("force") ?? false
681
682
 
@@ -778,6 +779,7 @@ public class CameraPreview: CAPPlugin, CAPBridgedPlugin, CLLocationManagerDelega
778
779
 
779
780
  // Default to high if not provided
780
781
  let videoQuality = call.getString("videoQuality") ?? "high"
782
+ let videoStabilizationMode = call.getString("videoStabilizationMode")
781
783
  self.pendingStartBarcodeScannerOptions = self.barcodeScannerStartOptions(from: call)
782
784
 
783
785
  let initialZoomLevel = call.getFloat("initialZoomLevel")
@@ -801,6 +803,19 @@ public class CameraPreview: CAPPlugin, CAPBridgedPlugin, CLLocationManagerDelega
801
803
  return
802
804
  }
803
805
 
806
+ if let videoStabilizationMode = videoStabilizationMode {
807
+ do {
808
+ try self.cameraController.setVideoStabilizationMode(videoStabilizationMode)
809
+ } catch {
810
+ DispatchQueue.main.async {
811
+ self.isInitializing = false
812
+ self.pendingStartBarcodeScannerOptions = nil
813
+ call.reject("Failed to set video stabilization mode: \(error.localizedDescription)")
814
+ }
815
+ return
816
+ }
817
+ }
818
+
804
819
  self.cameraController.prepare(cameraPosition: self.cameraPosition, deviceId: deviceId, disableAudio: self.disableAudio, cameraMode: cameraMode, aspectRatio: self.aspectRatio, aspectMode: self.aspectMode, initialZoomLevel: initialZoomLevel, disableFocusIndicator: self.disableFocusIndicator, videoQuality: videoQuality) { error in
805
820
  if let error = error {
806
821
  print(error)
@@ -1699,7 +1714,12 @@ public class CameraPreview: CAPPlugin, CAPBridgedPlugin, CLLocationManagerDelega
1699
1714
  if let frameRate = call.getInt("frameRate") {
1700
1715
  try self.cameraController.setVideoFrameRate(frameRate)
1701
1716
  }
1702
- try self.cameraController.captureVideo(maxDuration: maxDuration, maxFileSize: maxFileSize)
1717
+ let allowHapticsAndSystemSoundsDuringRecording = call.getBool("allowHapticsAndSystemSoundsDuringRecording") ?? false
1718
+ try self.cameraController.captureVideo(
1719
+ maxDuration: maxDuration,
1720
+ maxFileSize: maxFileSize,
1721
+ allowHapticsAndSystemSoundsDuringRecording: allowHapticsAndSystemSoundsDuringRecording
1722
+ )
1703
1723
  call.resolve()
1704
1724
  } catch {
1705
1725
  call.reject(error.localizedDescription)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/camera-preview",
3
- "version": "8.7.1",
3
+ "version": "8.8.1",
4
4
  "description": "Camera preview",
5
5
  "license": "MPL-2.0",
6
6
  "repository": {