@capgo/camera-preview 7.13.0 → 7.13.4

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
@@ -1001,11 +1001,10 @@ Defines the configuration options for starting the camera preview.
1001
1001
  | **`enableOpacity`** | <code>boolean</code> | If true, allows the camera preview's opacity to be changed. | <code>false</code> | |
1002
1002
  | **`enableZoom`** | <code>boolean</code> | If true, enables pinch-to-zoom functionality on the preview. | <code>false</code> | |
1003
1003
  | **`disableFocusIndicator`** | <code>boolean</code> | If true, disables the visual focus indicator when tapping to focus. | <code>false</code> | |
1004
- | **`enableVideoMode`** | <code>boolean</code> | If true, uses the video-optimized preset for the camera session. | <code>false</code> | |
1005
1004
  | **`deviceId`** | <code>string</code> | The `deviceId` of the camera to use. If provided, `position` is ignored. | | |
1006
1005
  | **`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 |
1007
1006
  | **`positioning`** | <code><a href="#camerapositioning">CameraPositioning</a></code> | The vertical positioning of the camera preview. | <code>"center"</code> | 2.3.0 |
1008
- | **`preloadVideo`** | <code>boolean</code> | If true, preloads video capture capabilities when the camera starts. If false, video capture is only initialized when startRecordVideo is called. | <code>false</code> | 7.11.0 |
1007
+ | **`enableVideoMode`** | <code>boolean</code> | If true, enables video capture capabilities when the camera starts. | <code>false</code> | 7.11.0 |
1009
1008
 
1010
1009
 
1011
1010
  #### ExifData
@@ -62,6 +62,41 @@ public class CameraPreview
62
62
  extends Plugin
63
63
  implements CameraXView.CameraXViewListener {
64
64
 
65
+ @Override
66
+ protected void handleOnPause() {
67
+ super.handleOnPause();
68
+ if (cameraXView != null && cameraXView.isRunning()) {
69
+ // Store the current configuration before stopping
70
+ lastSessionConfig = cameraXView.getSessionConfig();
71
+ cameraXView.stopSession();
72
+ }
73
+ }
74
+
75
+ @Override
76
+ protected void handleOnResume() {
77
+ super.handleOnResume();
78
+ if (lastSessionConfig != null) {
79
+ // Recreate camera with last known configuration
80
+ if (cameraXView == null) {
81
+ cameraXView = new CameraXView(getContext(), getBridge().getWebView());
82
+ cameraXView.setListener(this);
83
+ }
84
+ cameraXView.startSession(lastSessionConfig);
85
+ }
86
+ }
87
+
88
+ @Override
89
+ protected void handleOnDestroy() {
90
+ super.handleOnDestroy();
91
+ if (cameraXView != null) {
92
+ cameraXView.stopSession();
93
+ cameraXView = null;
94
+ }
95
+ lastSessionConfig = null;
96
+ }
97
+
98
+ private CameraSessionConfiguration lastSessionConfig;
99
+
65
100
  private static final String TAG = "CameraPreview CameraXView";
66
101
 
67
102
  static final String CAMERA_WITH_AUDIO_PERMISSION_ALIAS = "cameraWithAudio";
@@ -700,8 +735,8 @@ public class CameraPreview
700
735
  "disableFocusIndicator",
701
736
  false
702
737
  );
703
- final boolean preloadVideo = Boolean.TRUE.equals(
704
- call.getBoolean("preloadVideo", false)
738
+ final boolean enableVideoMode = Boolean.TRUE.equals(
739
+ call.getBoolean("enableVideoMode", false)
705
740
  );
706
741
 
707
742
  // Check for conflict between aspectRatio and size
@@ -1117,7 +1152,7 @@ public class CameraPreview
1117
1152
  aspectRatio,
1118
1153
  gridMode,
1119
1154
  disableFocusIndicator,
1120
- preloadVideo
1155
+ enableVideoMode
1121
1156
  );
1122
1157
  config.setTargetZoom(finalTargetZoom);
1123
1158
  config.setCentered(isCentered);
@@ -161,6 +161,10 @@ public class CameraXView implements LifecycleOwner, LifecycleObserver {
161
161
  return lifecycleRegistry;
162
162
  }
163
163
 
164
+ public CameraSessionConfiguration getSessionConfig() {
165
+ return sessionConfig;
166
+ }
167
+
164
168
  public void setListener(CameraXViewListener listener) {
165
169
  this.listener = listener;
166
170
  }
@@ -260,6 +264,7 @@ public class CameraXView implements LifecycleOwner, LifecycleObserver {
260
264
  currentFocusFuture = null;
261
265
 
262
266
  mainExecutor.execute(() -> {
267
+ lifecycleRegistry.setCurrentState(Lifecycle.State.DESTROYED);
263
268
  if (cameraProvider != null) {
264
269
  cameraProvider.unbindAll();
265
270
  }
@@ -748,8 +753,8 @@ public class CameraXView implements LifecycleOwner, LifecycleObserver {
748
753
  .build();
749
754
  sampleImageCapture = imageCapture;
750
755
 
751
- // Only setup VideoCapture if preloadVideo is true
752
- if (sessionConfig.isPreloadVideo()) {
756
+ // Only setup VideoCapture if enableVideoMode is true
757
+ if (sessionConfig.isVideoModeEnabled()) {
753
758
  QualitySelector qualitySelector = QualitySelector.fromOrderedList(
754
759
  Arrays.asList(Quality.FHD, Quality.HD, Quality.SD),
755
760
  FallbackStrategy.higherQualityOrLowerThan(Quality.FHD)
@@ -764,8 +769,8 @@ public class CameraXView implements LifecycleOwner, LifecycleObserver {
764
769
  // Unbind any existing use cases and bind new ones
765
770
  cameraProvider.unbindAll();
766
771
 
767
- // Bind with or without video capture based on preloadVideo
768
- if (sessionConfig.isPreloadVideo() && videoCapture != null) {
772
+ // Bind with or without video capture based on enableVideoMode
773
+ if (sessionConfig.isVideoModeEnabled() && videoCapture != null) {
769
774
  camera = cameraProvider.bindToLifecycle(
770
775
  this,
771
776
  currentCameraSelector,
@@ -1905,14 +1910,15 @@ public class CameraXView implements LifecycleOwner, LifecycleObserver {
1905
1910
  .build();
1906
1911
 
1907
1912
  try {
1908
- currentFocusFuture = camera
1913
+ final ListenableFuture<FocusMeteringResult> future = camera
1909
1914
  .getCameraControl()
1910
1915
  .startFocusAndMetering(action);
1916
+ currentFocusFuture = future;
1911
1917
 
1912
- currentFocusFuture.addListener(
1918
+ future.addListener(
1913
1919
  () -> {
1914
1920
  try {
1915
- FocusMeteringResult result = currentFocusFuture.get();
1921
+ FocusMeteringResult result = future.get();
1916
1922
  } catch (Exception e) {
1917
1923
  // Handle cancellation gracefully - this is expected when rapid taps occur
1918
1924
  if (
@@ -1934,8 +1940,7 @@ public class CameraXView implements LifecycleOwner, LifecycleObserver {
1934
1940
  Log.e(TAG, "Error during focus: " + e.getMessage());
1935
1941
  }
1936
1942
  } finally {
1937
- // Clear the reference if this is still the current operation
1938
- if (currentFocusFuture != null && currentFocusFuture.isDone()) {
1943
+ if (currentFocusFuture == future && currentFocusFuture.isDone()) {
1939
1944
  currentFocusFuture = null;
1940
1945
  }
1941
1946
  }
@@ -2298,7 +2303,7 @@ public class CameraXView implements LifecycleOwner, LifecycleObserver {
2298
2303
  try {
2299
2304
  // For static method, we can return common flash modes
2300
2305
  // Most modern cameras support these modes
2301
- return Arrays.asList("off", "on", "auto");
2306
+ return Arrays.asList("off", "on", "auto", "torch");
2302
2307
  } catch (Exception e) {
2303
2308
  Log.e(TAG, "getSupportedFlashModesStatic: Error getting flash modes", e);
2304
2309
  return Collections.singletonList("off");
@@ -2441,7 +2446,7 @@ public class CameraXView implements LifecycleOwner, LifecycleObserver {
2441
2446
  sessionConfig.getAspectRatio(), // aspectRatio
2442
2447
  sessionConfig.getGridMode(), // gridMode
2443
2448
  sessionConfig.getDisableFocusIndicator(), // disableFocusIndicator
2444
- sessionConfig.isPreloadVideo() // preloadVideo
2449
+ sessionConfig.isVideoModeEnabled() // enableVideoMode
2445
2450
  );
2446
2451
 
2447
2452
  // Clear current device ID to force position-based selection
@@ -2601,7 +2606,7 @@ public class CameraXView implements LifecycleOwner, LifecycleObserver {
2601
2606
  aspectRatio,
2602
2607
  currentGridMode,
2603
2608
  sessionConfig.getDisableFocusIndicator(),
2604
- sessionConfig.isPreloadVideo()
2609
+ sessionConfig.isVideoModeEnabled()
2605
2610
  );
2606
2611
  sessionConfig.setCentered(true);
2607
2612
 
@@ -2705,7 +2710,7 @@ public class CameraXView implements LifecycleOwner, LifecycleObserver {
2705
2710
  aspectRatio,
2706
2711
  currentGridMode,
2707
2712
  sessionConfig.getDisableFocusIndicator(),
2708
- sessionConfig.isPreloadVideo()
2713
+ sessionConfig.isVideoModeEnabled()
2709
2714
  );
2710
2715
  sessionConfig.setCentered(true);
2711
2716
 
@@ -2781,7 +2786,7 @@ public class CameraXView implements LifecycleOwner, LifecycleObserver {
2781
2786
  sessionConfig.getAspectRatio(),
2782
2787
  gridMode,
2783
2788
  sessionConfig.getDisableFocusIndicator(),
2784
- sessionConfig.isPreloadVideo()
2789
+ sessionConfig.isVideoModeEnabled()
2785
2790
  );
2786
2791
 
2787
2792
  // Update the grid overlay immediately
@@ -3165,7 +3170,7 @@ public class CameraXView implements LifecycleOwner, LifecycleObserver {
3165
3170
  calculatedAspectRatio,
3166
3171
  sessionConfig.getGridMode(),
3167
3172
  sessionConfig.getDisableFocusIndicator(),
3168
- sessionConfig.isPreloadVideo()
3173
+ sessionConfig.isVideoModeEnabled()
3169
3174
  );
3170
3175
 
3171
3176
  // If aspect ratio changed due to size update, rebind camera
@@ -22,7 +22,7 @@ public class CameraSessionConfiguration {
22
22
  private final String aspectRatio;
23
23
  private final String gridMode;
24
24
  private final boolean disableFocusIndicator;
25
- private final boolean preloadVideo;
25
+ private final boolean enableVideoMode;
26
26
  private float targetZoom = 1.0f;
27
27
  private boolean isCentered = false;
28
28
 
@@ -44,7 +44,7 @@ public class CameraSessionConfiguration {
44
44
  String aspectRatio,
45
45
  String gridMode,
46
46
  boolean disableFocusIndicator,
47
- boolean preloadVideo
47
+ boolean enableVideoMode
48
48
  ) {
49
49
  this.deviceId = deviceId;
50
50
  this.position = position;
@@ -63,7 +63,7 @@ public class CameraSessionConfiguration {
63
63
  this.aspectRatio = aspectRatio;
64
64
  this.gridMode = gridMode != null ? gridMode : "none";
65
65
  this.disableFocusIndicator = disableFocusIndicator;
66
- this.preloadVideo = preloadVideo;
66
+ this.enableVideoMode = enableVideoMode;
67
67
  }
68
68
 
69
69
  public void setTargetZoom(float zoom) {
@@ -175,11 +175,11 @@ public class CameraSessionConfiguration {
175
175
  return disableFocusIndicator;
176
176
  }
177
177
 
178
- public boolean isPreloadVideo() {
179
- return preloadVideo;
178
+ public boolean isVideoModeEnabled() {
179
+ return enableVideoMode;
180
180
  }
181
181
 
182
- public boolean getPreloadVideo() {
183
- return preloadVideo;
182
+ public boolean getEnableVideoMode() {
183
+ return enableVideoMode;
184
184
  }
185
185
  }
package/dist/docs.json CHANGED
@@ -1282,22 +1282,6 @@
1282
1282
  "complexTypes": [],
1283
1283
  "type": "boolean | undefined"
1284
1284
  },
1285
- {
1286
- "name": "enableVideoMode",
1287
- "tags": [
1288
- {
1289
- "text": "ios",
1290
- "name": "platform"
1291
- },
1292
- {
1293
- "text": "false",
1294
- "name": "default"
1295
- }
1296
- ],
1297
- "docs": "If true, uses the video-optimized preset for the camera session.",
1298
- "complexTypes": [],
1299
- "type": "boolean | undefined"
1300
- },
1301
1285
  {
1302
1286
  "name": "deviceId",
1303
1287
  "tags": [
@@ -1353,7 +1337,7 @@
1353
1337
  "type": "CameraPositioning"
1354
1338
  },
1355
1339
  {
1356
- "name": "preloadVideo",
1340
+ "name": "enableVideoMode",
1357
1341
  "tags": [
1358
1342
  {
1359
1343
  "text": "false",
@@ -1368,7 +1352,7 @@
1368
1352
  "name": "since"
1369
1353
  }
1370
1354
  ],
1371
- "docs": "If true, preloads video capture capabilities when the camera starts.\nIf false, video capture is only initialized when startRecordVideo is called.",
1355
+ "docs": "If true, enables video capture capabilities when the camera starts.",
1372
1356
  "complexTypes": [],
1373
1357
  "type": "boolean | undefined"
1374
1358
  }
@@ -178,12 +178,6 @@ export interface CameraPreviewOptions {
178
178
  * @default false
179
179
  */
180
180
  disableFocusIndicator?: boolean;
181
- /**
182
- * If true, uses the video-optimized preset for the camera session.
183
- * @platform ios
184
- * @default false
185
- */
186
- enableVideoMode?: boolean;
187
181
  /**
188
182
  * The `deviceId` of the camera to use. If provided, `position` is ignored.
189
183
  * @platform ios
@@ -205,13 +199,12 @@ export interface CameraPreviewOptions {
205
199
  */
206
200
  positioning?: CameraPositioning;
207
201
  /**
208
- * If true, preloads video capture capabilities when the camera starts.
209
- * If false, video capture is only initialized when startRecordVideo is called.
202
+ * If true, enables video capture capabilities when the camera starts.
210
203
  * @default false
211
204
  * @platform android
212
205
  * @since 7.11.0
213
206
  */
214
- preloadVideo?: boolean;
207
+ enableVideoMode?: boolean;
215
208
  }
216
209
  /**
217
210
  * Defines the options for capturing a picture.
@@ -1 +1 @@
1
- {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAUA,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 { 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 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\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?: \"4:3\" | \"16:9\";\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 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 * If true, enables pinch-to-zoom functionality on the preview.\n * @platform android\n * @default false\n */\n enableZoom?: 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 * If true, uses the video-optimized preset for the camera session.\n * @platform ios\n * @default false\n */\n enableVideoMode?: boolean;\n /**\n * The `deviceId` of the camera to use. If provided, `position` is ignored.\n * @platform ios\n */\n deviceId?: string;\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, preloads video capture capabilities when the camera starts.\n * If false, video capture is only initialized when startRecordVideo is called.\n * @default false\n * @platform android\n * @since 7.11.0\n */\n preloadVideo?: boolean;\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\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 =\n | \"portrait\"\n | \"landscape\"\n | \"landscape-left\"\n | \"landscape-right\"\n | \"portrait-upside-down\"\n | \"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 * @returns {Promise<void>} A promise that resolves when the camera preview is stopped.\n * @since 0.0.1\n */\n stop(): 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(\n options: CameraPreviewPictureOptions,\n ): 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 * 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: '4:3' | '16:9'; x?: number; y?: number }} options - The desired aspect ratio and optional position.\n * - aspectRatio: The desired aspect ratio ('4:3' or '16:9')\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: {\n aspectRatio: \"4:3\" | \"16:9\";\n x?: number;\n y?: number;\n }): 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: '4:3' | '16:9' }>} A promise that resolves with the current aspect ratio.\n * @since 7.5.0\n * @platform android, ios\n */\n getAspectRatio(): Promise<{ aspectRatio: \"4:3\" | \"16:9\" }>;\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 * 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: {\n flashMode: CameraPreviewFlashMode | string;\n }): 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<{ videoFilePath: string }>} A promise that resolves with the path to the recorded video file.\n * @since 0.0.1\n */\n stopRecordVideo(): Promise<{ videoFilePath: string }>;\n\n /**\n * Starts recording a video.\n *\n * @param {CameraPreviewOptions} options - The options for video recording. Only iOS.\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 * 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: {\n level: number;\n ramp?: boolean;\n autoFocus?: boolean;\n }): 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 currently active camera device.\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: {\n x?: number;\n y?: number;\n width: number;\n height: number;\n }): 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 * @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: {\n width: number;\n height: number;\n x: number;\n y: number;\n }) => 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 * 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\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\n */\n getExposureCompensation(): Promise<{ value: number }>;\n\n /**\n * Sets the exposure compensation (EV bias). Value will be clamped to range.\n * @platform ios\n */\n setExposureCompensation(options: { value: number }): Promise<void>;\n}\n"]}
1
+ {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAUA,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 { 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 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\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?: \"4:3\" | \"16:9\";\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 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 * If true, enables pinch-to-zoom functionality on the preview.\n * @platform android\n * @default false\n */\n enableZoom?: 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 * 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\n * @since 7.11.0\n */\n enableVideoMode?: boolean;\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\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 =\n | \"portrait\"\n | \"landscape\"\n | \"landscape-left\"\n | \"landscape-right\"\n | \"portrait-upside-down\"\n | \"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 * @returns {Promise<void>} A promise that resolves when the camera preview is stopped.\n * @since 0.0.1\n */\n stop(): 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(\n options: CameraPreviewPictureOptions,\n ): 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 * 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: '4:3' | '16:9'; x?: number; y?: number }} options - The desired aspect ratio and optional position.\n * - aspectRatio: The desired aspect ratio ('4:3' or '16:9')\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: {\n aspectRatio: \"4:3\" | \"16:9\";\n x?: number;\n y?: number;\n }): 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: '4:3' | '16:9' }>} A promise that resolves with the current aspect ratio.\n * @since 7.5.0\n * @platform android, ios\n */\n getAspectRatio(): Promise<{ aspectRatio: \"4:3\" | \"16:9\" }>;\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 * 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: {\n flashMode: CameraPreviewFlashMode | string;\n }): 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<{ videoFilePath: string }>} A promise that resolves with the path to the recorded video file.\n * @since 0.0.1\n */\n stopRecordVideo(): Promise<{ videoFilePath: string }>;\n\n /**\n * Starts recording a video.\n *\n * @param {CameraPreviewOptions} options - The options for video recording. Only iOS.\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 * 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: {\n level: number;\n ramp?: boolean;\n autoFocus?: boolean;\n }): 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 currently active camera device.\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: {\n x?: number;\n y?: number;\n width: number;\n height: number;\n }): 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 * @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: {\n width: number;\n height: number;\n x: number;\n y: number;\n }) => 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 * 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\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\n */\n getExposureCompensation(): Promise<{ value: number }>;\n\n /**\n * Sets the exposure compensation (EV bias). Value will be clamped to range.\n * @platform ios\n */\n setExposureCompensation(options: { value: number }): Promise<void>;\n}\n"]}
@@ -706,7 +706,7 @@ public class CameraPreview: CAPPlugin, CAPBridgedPlugin, CLLocationManagerDelega
706
706
  // Update preview layer frame without animation
707
707
  CATransaction.begin()
708
708
  CATransaction.setDisableActions(true)
709
-
709
+
710
710
  // Preserve aspect ratio if it was set
711
711
  if let aspectRatio = self.cameraController.requestedAspectRatio,
712
712
  let previewLayer = self.cameraController.previewLayer {
@@ -714,7 +714,7 @@ public class CameraPreview: CAPPlugin, CAPBridgedPlugin, CLLocationManagerDelega
714
714
  let frame = self.cameraController.calculateAspectRatioFrame(for: aspectRatio, in: self.previewView.bounds)
715
715
  previewLayer.frame = frame
716
716
  previewLayer.videoGravity = .resizeAspectFill
717
-
717
+
718
718
  // Keep grid overlay in sync with preview if it exists
719
719
  self.cameraController.gridOverlayView?.frame = frame
720
720
  } else {
@@ -722,7 +722,7 @@ public class CameraPreview: CAPPlugin, CAPBridgedPlugin, CLLocationManagerDelega
722
722
  self.cameraController.previewLayer?.frame = self.previewView.bounds
723
723
  self.cameraController.previewLayer?.videoGravity = .resizeAspectFill
724
724
  }
725
-
725
+
726
726
  CATransaction.commit()
727
727
 
728
728
  self.previewView.isUserInteractionEnabled = true
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/camera-preview",
3
- "version": "7.13.0",
3
+ "version": "7.13.4",
4
4
  "description": "Camera preview",
5
5
  "license": "MIT",
6
6
  "repository": {