@capgo/camera-preview 7.4.0-alpha.13 → 7.4.0-alpha.17

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
@@ -262,6 +262,8 @@ Documentation for the [uploader](https://github.com/Cap-go/capacitor-uploader)
262
262
  * [`setPreviewSize(...)`](#setpreviewsize)
263
263
  * [`setFocus(...)`](#setfocus)
264
264
  * [`addListener('screenResize', ...)`](#addlistenerscreenresize-)
265
+ * [`deleteFile(...)`](#deletefile)
266
+ * [`getSafeAreaInsets()`](#getsafeareainsets)
265
267
  * [Interfaces](#interfaces)
266
268
  * [Type Aliases](#type-aliases)
267
269
  * [Enums](#enums)
@@ -734,6 +736,41 @@ addListener(eventName: "screenResize", listenerFunc: (data: { width: number; hei
734
736
  --------------------
735
737
 
736
738
 
739
+ ### deleteFile(...)
740
+
741
+ ```typescript
742
+ deleteFile(options: { path: string; }) => Promise<{ success: boolean; }>
743
+ ```
744
+
745
+ Deletes a file at the given absolute path on the device.
746
+ Use this to quickly clean up temporary images created with `storeToFile`.
747
+ On web, this is not supported and will throw.
748
+
749
+ | Param | Type |
750
+ | ------------- | ------------------------------ |
751
+ | **`options`** | <code>{ path: string; }</code> |
752
+
753
+ **Returns:** <code>Promise&lt;{ success: boolean; }&gt;</code>
754
+
755
+ **Since:** 8.2.0
756
+
757
+ --------------------
758
+
759
+
760
+ ### getSafeAreaInsets()
761
+
762
+ ```typescript
763
+ getSafeAreaInsets() => Promise<SafeAreaInsets>
764
+ ```
765
+
766
+ Gets the safe area insets for Android devices.
767
+ Returns the top and bottom insets in dp and the current orientation.
768
+
769
+ **Returns:** <code>Promise&lt;<a href="#safeareainsets">SafeAreaInsets</a>&gt;</code>
770
+
771
+ --------------------
772
+
773
+
737
774
  ### Interfaces
738
775
 
739
776
 
@@ -874,6 +911,18 @@ Represents the detailed information of the currently active lens.
874
911
  | **`remove`** | <code>() =&gt; Promise&lt;void&gt;</code> |
875
912
 
876
913
 
914
+ #### SafeAreaInsets
915
+
916
+ Represents safe area insets on Android.
917
+ Values are expressed in logical pixels (dp) to match JS layout units.
918
+
919
+ | Prop | Type | Description |
920
+ | ----------------- | ------------------- | ---------------------------------------------------------------- |
921
+ | **`orientation`** | <code>number</code> | Current device orientation as reported by Android configuration. |
922
+ | **`top`** | <code>number</code> | Top inset (e.g., status bar or cutout) in dp. |
923
+ | **`bottom`** | <code>number</code> | Bottom inset (e.g., navigation bar) in dp. |
924
+
925
+
877
926
  ### Type Aliases
878
927
 
879
928
 
@@ -5,13 +5,18 @@ import static android.Manifest.permission.RECORD_AUDIO;
5
5
 
6
6
  import android.Manifest;
7
7
  import android.content.pm.ActivityInfo;
8
+ import android.content.res.Configuration;
8
9
  import android.location.Location;
9
10
  import android.util.DisplayMetrics;
10
11
  import android.util.Log;
11
12
  import android.util.Size;
13
+ import android.view.OrientationEventListener;
12
14
  import android.view.View;
13
15
  import android.view.ViewGroup;
14
16
  import android.webkit.WebView;
17
+ import androidx.core.graphics.Insets;
18
+ import androidx.core.view.ViewCompat;
19
+ import androidx.core.view.WindowInsetsCompat;
15
20
  import com.ahm.capacitor.camera.preview.model.CameraDevice;
16
21
  import com.ahm.capacitor.camera.preview.model.CameraSessionConfiguration;
17
22
  import com.ahm.capacitor.camera.preview.model.LensInfo;
@@ -69,6 +74,8 @@ public class CameraPreview
69
74
  private CameraXView cameraXView;
70
75
  private FusedLocationProviderClient fusedLocationClient;
71
76
  private Location lastLocation;
77
+ private OrientationEventListener orientationListener;
78
+ private int lastOrientation = Configuration.ORIENTATION_UNDEFINED;
72
79
 
73
80
  @PluginMethod
74
81
  public void start(PluginCall call) {
@@ -205,6 +212,13 @@ public class CameraPreview
205
212
  .getActivity()
206
213
  .setRequestedOrientation(previousOrientationRequest);
207
214
 
215
+ // Disable and clear orientation listener
216
+ if (orientationListener != null) {
217
+ orientationListener.disable();
218
+ orientationListener = null;
219
+ lastOrientation = Configuration.ORIENTATION_UNDEFINED;
220
+ }
221
+
208
222
  if (cameraXView != null && cameraXView.isRunning()) {
209
223
  cameraXView.stopSession();
210
224
  cameraXView = null;
@@ -215,6 +229,10 @@ public class CameraPreview
215
229
 
216
230
  @PluginMethod
217
231
  public void getSupportedFlashModes(PluginCall call) {
232
+ if (cameraXView == null || !cameraXView.isRunning()) {
233
+ call.reject("Camera is not running");
234
+ return;
235
+ }
218
236
  List<String> supportedFlashModes = cameraXView.getSupportedFlashModes();
219
237
  JSArray jsonFlashModes = new JSArray();
220
238
  for (String mode : supportedFlashModes) {
@@ -268,6 +286,10 @@ public class CameraPreview
268
286
 
269
287
  @PluginMethod
270
288
  public void getZoom(PluginCall call) {
289
+ if (cameraXView == null || !cameraXView.isRunning()) {
290
+ call.reject("Camera is not running");
291
+ return;
292
+ }
271
293
  ZoomFactors zoomFactors = cameraXView.getZoomFactors();
272
294
  JSObject result = new JSObject();
273
295
  result.put("min", zoomFactors.getMin());
@@ -278,6 +300,10 @@ public class CameraPreview
278
300
 
279
301
  @PluginMethod
280
302
  public void getZoomButtonValues(PluginCall call) {
303
+ if (cameraXView == null || !cameraXView.isRunning()) {
304
+ call.reject("Camera is not running");
305
+ return;
306
+ }
281
307
  // Build a sorted set to dedupe and order ascending
282
308
  java.util.Set<Double> sorted = new java.util.TreeSet<>();
283
309
  sorted.add(1.0);
@@ -968,6 +994,50 @@ public class CameraPreview
968
994
  bridge.saveCall(call);
969
995
  cameraStartCallbackId = call.getCallbackId();
970
996
  cameraXView.startSession(config);
997
+
998
+ // Setup orientation listener to mirror iOS screenResize emission
999
+ if (orientationListener == null) {
1000
+ lastOrientation = getContext()
1001
+ .getResources()
1002
+ .getConfiguration()
1003
+ .orientation;
1004
+ orientationListener = new OrientationEventListener(getContext()) {
1005
+ @Override
1006
+ public void onOrientationChanged(int orientation) {
1007
+ if (orientation == ORIENTATION_UNKNOWN) return;
1008
+ int current = getContext()
1009
+ .getResources()
1010
+ .getConfiguration()
1011
+ .orientation;
1012
+ if (current != lastOrientation) {
1013
+ lastOrientation = current;
1014
+ handleOrientationChange();
1015
+ }
1016
+ }
1017
+ };
1018
+ if (orientationListener.canDetectOrientation()) {
1019
+ orientationListener.enable();
1020
+ }
1021
+ }
1022
+ });
1023
+ }
1024
+
1025
+ private void handleOrientationChange() {
1026
+ if (cameraXView == null || !cameraXView.isRunning()) return;
1027
+ getBridge()
1028
+ .getActivity()
1029
+ .runOnUiThread(() -> {
1030
+ // Reapply current aspect ratio to recompute layout, then emit screenResize
1031
+ String ar = cameraXView.getAspectRatio();
1032
+ cameraXView.setAspectRatio(ar, null, null, () -> {
1033
+ int[] bounds = cameraXView.getCurrentPreviewBounds();
1034
+ JSObject data = new JSObject();
1035
+ data.put("x", bounds[0]);
1036
+ data.put("y", bounds[1]);
1037
+ data.put("width", bounds[2]);
1038
+ data.put("height", bounds[3]);
1039
+ notifyListeners("screenResize", data);
1040
+ });
971
1041
  });
972
1042
  }
973
1043
 
@@ -1255,4 +1325,120 @@ public class CameraPreview
1255
1325
  call.reject("Failed to delete file: " + e.getMessage());
1256
1326
  }
1257
1327
  }
1328
+
1329
+ @PluginMethod
1330
+ public void getSafeAreaInsets(PluginCall call) {
1331
+ JSObject ret = new JSObject();
1332
+ int orientation = getContext()
1333
+ .getResources()
1334
+ .getConfiguration()
1335
+ .orientation;
1336
+
1337
+ int topPx = 0;
1338
+ int bottomPx = 0;
1339
+ try {
1340
+ View webView = getBridge().getWebView();
1341
+ if (webView != null) {
1342
+ DisplayMetrics metrics = getBridge()
1343
+ .getActivity()
1344
+ .getResources()
1345
+ .getDisplayMetrics();
1346
+ int screenHeight = metrics.heightPixels;
1347
+ int[] location = new int[2];
1348
+ webView.getLocationOnScreen(location);
1349
+ int webViewTop = location[1];
1350
+ int webViewBottom = webViewTop + webView.getHeight();
1351
+ int webViewBottomGap = Math.max(0, screenHeight - webViewBottom);
1352
+
1353
+ // System insets (status/navigation/cutout)
1354
+ int systemTop = 0;
1355
+ int systemBottom = 0;
1356
+ View decorView = getBridge().getActivity().getWindow().getDecorView();
1357
+ WindowInsetsCompat insets = ViewCompat.getRootWindowInsets(decorView);
1358
+ if (insets != null) {
1359
+ Insets sysBars = insets.getInsets(
1360
+ WindowInsetsCompat.Type.systemBars()
1361
+ );
1362
+ Insets cutout = insets.getInsets(
1363
+ WindowInsetsCompat.Type.displayCutout()
1364
+ );
1365
+ systemTop = Math.max(sysBars.top, cutout.top);
1366
+ systemBottom = Math.max(sysBars.bottom, cutout.bottom);
1367
+ } else {
1368
+ systemTop = getStatusBarHeightPx();
1369
+ systemBottom = getNavigationBarHeightPx();
1370
+ }
1371
+
1372
+ // Top: report the gap between screen and WebView (useful when not edge-to-edge)
1373
+ topPx = Math.max(0, webViewTop);
1374
+
1375
+ // Bottom logic:
1376
+ // - If WebView has a bottom gap equal to the system nav bar height (3-button mode),
1377
+ // it means layout already accounts for it -> return 0 as requested.
1378
+ // - If WebView has no gap (edge-to-edge or overlay), return system bottom inset.
1379
+ // - Otherwise, default to system bottom inset (avoid counting app UI like tab bars).
1380
+ if (
1381
+ webViewBottomGap > 0 && approxEqualPx(webViewBottomGap, systemBottom)
1382
+ ) {
1383
+ bottomPx = 0; // already offset by system nav bar
1384
+ } else if (webViewBottomGap == 0) {
1385
+ bottomPx = systemBottom;
1386
+ } else {
1387
+ bottomPx = systemBottom;
1388
+ }
1389
+ } else {
1390
+ // Fallback if WebView is unavailable
1391
+ View decorView = getBridge().getActivity().getWindow().getDecorView();
1392
+ WindowInsetsCompat insets = ViewCompat.getRootWindowInsets(decorView);
1393
+ if (insets != null) {
1394
+ Insets sysBars = insets.getInsets(
1395
+ WindowInsetsCompat.Type.systemBars()
1396
+ );
1397
+ Insets cutout = insets.getInsets(
1398
+ WindowInsetsCompat.Type.displayCutout()
1399
+ );
1400
+ topPx = Math.max(sysBars.top, cutout.top);
1401
+ bottomPx = Math.max(sysBars.bottom, cutout.bottom);
1402
+ } else {
1403
+ topPx = getStatusBarHeightPx();
1404
+ bottomPx = getNavigationBarHeightPx();
1405
+ }
1406
+ }
1407
+ } catch (Exception e) {
1408
+ topPx = getStatusBarHeightPx();
1409
+ bottomPx = getNavigationBarHeightPx();
1410
+ }
1411
+
1412
+ float density = getContext().getResources().getDisplayMetrics().density;
1413
+ ret.put("orientation", orientation);
1414
+ ret.put("top", topPx / density);
1415
+ ret.put("bottom", bottomPx / density);
1416
+ call.resolve(ret);
1417
+ }
1418
+
1419
+ private boolean approxEqualPx(int a, int b) {
1420
+ return Math.abs(a - b) <= 2; // within 2px tolerance
1421
+ }
1422
+
1423
+ private int getStatusBarHeightPx() {
1424
+ int result = 0;
1425
+ int resourceId = getContext()
1426
+ .getResources()
1427
+ .getIdentifier("status_bar_height", "dimen", "android");
1428
+ if (resourceId > 0) {
1429
+ result = getContext().getResources().getDimensionPixelSize(resourceId);
1430
+ }
1431
+ return result;
1432
+ }
1433
+
1434
+ private int getNavigationBarHeightPx() {
1435
+ int result = 0;
1436
+ int resourceId = getContext()
1437
+ .getResources()
1438
+ .getIdentifier("navigation_bar_height", "dimen", "android");
1439
+ if (resourceId > 0) {
1440
+ result = getContext().getResources().getDimensionPixelSize(resourceId);
1441
+ }
1442
+ return result;
1443
+ }
1258
1444
  }
package/dist/docs.json CHANGED
@@ -684,6 +684,44 @@
684
684
  "PluginListenerHandle"
685
685
  ],
686
686
  "slug": "addlistenerscreenresize-"
687
+ },
688
+ {
689
+ "name": "deleteFile",
690
+ "signature": "(options: { path: string; }) => Promise<{ success: boolean; }>",
691
+ "parameters": [
692
+ {
693
+ "name": "options",
694
+ "docs": "",
695
+ "type": "{ path: string; }"
696
+ }
697
+ ],
698
+ "returns": "Promise<{ success: boolean; }>",
699
+ "tags": [
700
+ {
701
+ "name": "since",
702
+ "text": "8.2.0"
703
+ }
704
+ ],
705
+ "docs": "Deletes a file at the given absolute path on the device.\nUse this to quickly clean up temporary images created with `storeToFile`.\nOn web, this is not supported and will throw.",
706
+ "complexTypes": [],
707
+ "slug": "deletefile"
708
+ },
709
+ {
710
+ "name": "getSafeAreaInsets",
711
+ "signature": "() => Promise<SafeAreaInsets>",
712
+ "parameters": [],
713
+ "returns": "Promise<SafeAreaInsets>",
714
+ "tags": [
715
+ {
716
+ "name": "platform",
717
+ "text": "android"
718
+ }
719
+ ],
720
+ "docs": "Gets the safe area insets for Android devices.\nReturns the top and bottom insets in dp and the current orientation.",
721
+ "complexTypes": [
722
+ "SafeAreaInsets"
723
+ ],
724
+ "slug": "getsafeareainsets"
687
725
  }
688
726
  ],
689
727
  "properties": []
@@ -1406,6 +1444,36 @@
1406
1444
  "type": "() => Promise<void>"
1407
1445
  }
1408
1446
  ]
1447
+ },
1448
+ {
1449
+ "name": "SafeAreaInsets",
1450
+ "slug": "safeareainsets",
1451
+ "docs": "Represents safe area insets on Android.\nValues are expressed in logical pixels (dp) to match JS layout units.",
1452
+ "tags": [],
1453
+ "methods": [],
1454
+ "properties": [
1455
+ {
1456
+ "name": "orientation",
1457
+ "tags": [],
1458
+ "docs": "Current device orientation as reported by Android configuration.",
1459
+ "complexTypes": [],
1460
+ "type": "number"
1461
+ },
1462
+ {
1463
+ "name": "top",
1464
+ "tags": [],
1465
+ "docs": "Top inset (e.g., status bar or cutout) in dp.",
1466
+ "complexTypes": [],
1467
+ "type": "number"
1468
+ },
1469
+ {
1470
+ "name": "bottom",
1471
+ "tags": [],
1472
+ "docs": "Bottom inset (e.g., navigation bar) in dp.",
1473
+ "complexTypes": [],
1474
+ "type": "number"
1475
+ }
1476
+ ]
1409
1477
  }
1410
1478
  ],
1411
1479
  "enums": [
@@ -290,6 +290,18 @@ export interface CameraOpacityOptions {
290
290
  */
291
291
  opacity?: number;
292
292
  }
293
+ /**
294
+ * Represents safe area insets on Android.
295
+ * Values are expressed in logical pixels (dp) to match JS layout units.
296
+ */
297
+ export interface SafeAreaInsets {
298
+ /** Current device orientation as reported by Android configuration. */
299
+ orientation: number;
300
+ /** Top inset (e.g., status bar or cutout) in dp. */
301
+ top: number;
302
+ /** Bottom inset (e.g., navigation bar) in dp. */
303
+ bottom: number;
304
+ }
293
305
  /**
294
306
  * The main interface for the CameraPreview plugin.
295
307
  */
@@ -587,4 +599,22 @@ export interface CameraPreviewPlugin {
587
599
  x: number;
588
600
  y: number;
589
601
  }) => void): Promise<PluginListenerHandle>;
602
+ /**
603
+ * Deletes a file at the given absolute path on the device.
604
+ * Use this to quickly clean up temporary images created with `storeToFile`.
605
+ * On web, this is not supported and will throw.
606
+ * @since 8.2.0
607
+ */
608
+ deleteFile(options: {
609
+ path: string;
610
+ }): Promise<{
611
+ success: boolean;
612
+ }>;
613
+ /**
614
+ * Gets the safe area insets for Android devices.
615
+ * Returns the top and bottom insets in dp and the current orientation.
616
+ *
617
+ * @platform android
618
+ */
619
+ getSafeAreaInsets(): Promise<SafeAreaInsets>;
590
620
  }
@@ -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 * 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\n/**\n * Defines the options for capturing a picture.\n */\nexport interface CameraPreviewPictureOptions {\n /** @deprecated,\n * The desired height of the picture in pixels.\n * If not specified and no aspectRatio is provided, the captured image will match the preview's visible area.\n */\n height?: number;\n /** @deprecated,\n * The desired width of the picture in pixels.\n * If not specified and no aspectRatio is provided, the captured image will match the preview's visible area.\n */\n width?: number;\n /** @deprecated,\n * The desired aspect ratio of the captured image (e.g., '4:3', '16:9').\n * If not specified and no width/height is provided, the aspect ratio from the camera start will be used.\n * If no aspect ratio was set at start, defaults to '4:3'.\n * Cannot be used together with width or height - the capture will be rejected with an error.\n * @since 7.7.0\n */\n aspectRatio?: string;\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/**\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 * 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 * @param {CameraPreviewPictureOptions} options - The options for capturing the picture.\n * @returns {Promise<{ value: string }>} A promise that resolves with the captured image data.\n * The `value` is a base64 encoded string unless `storeToFile` is true, in which case it's a file path.\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.4.0\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.4.0\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.\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.4.0\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.4.0\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.4.0\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 */\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.4.0\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.4.0\n */\n getFlashMode(): Promise<{ flashMode: FlashMode }>;\n\n /**\n * Removes all registered listeners.\n *\n * @since 7.4.0\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.4.0\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.4.0\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 */\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 */\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 8.1.0\n */\n setFocus(options: { x: number; y: number }): Promise<void>;\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"]}
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 * 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\n/**\n * Defines the options for capturing a picture.\n */\nexport interface CameraPreviewPictureOptions {\n /** @deprecated,\n * The desired height of the picture in pixels.\n * If not specified and no aspectRatio is provided, the captured image will match the preview's visible area.\n */\n height?: number;\n /** @deprecated,\n * The desired width of the picture in pixels.\n * If not specified and no aspectRatio is provided, the captured image will match the preview's visible area.\n */\n width?: number;\n /** @deprecated,\n * The desired aspect ratio of the captured image (e.g., '4:3', '16:9').\n * If not specified and no width/height is provided, the aspect ratio from the camera start will be used.\n * If no aspect ratio was set at start, defaults to '4:3'.\n * Cannot be used together with width or height - the capture will be rejected with an error.\n * @since 7.7.0\n */\n aspectRatio?: string;\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/**\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 on Android.\n * Values are expressed in logical pixels (dp) to match JS layout units.\n */\nexport interface SafeAreaInsets {\n /** Current device orientation as reported by Android configuration. */\n orientation: number;\n /** Top inset (e.g., status bar or cutout) in dp. */\n top: number;\n /** Bottom inset (e.g., navigation bar) in dp. */\n bottom: number;\n}\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 * @param {CameraPreviewPictureOptions} options - The options for capturing the picture.\n * @returns {Promise<{ value: string }>} A promise that resolves with the captured image data.\n * The `value` is a base64 encoded string unless `storeToFile` is true, in which case it's a file path.\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.4.0\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.4.0\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.\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.4.0\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.4.0\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.4.0\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 */\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.4.0\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.4.0\n */\n getFlashMode(): Promise<{ flashMode: FlashMode }>;\n\n /**\n * Removes all registered listeners.\n *\n * @since 7.4.0\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.4.0\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.4.0\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 */\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 */\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 8.1.0\n */\n setFocus(options: { x: number; y: number }): Promise<void>;\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 * 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 8.2.0\n */\n deleteFile(options: { path: string }): Promise<{ success: boolean }>;\n\n /**\n * Gets the safe area insets for Android devices.\n * Returns the top and bottom insets in dp and the current orientation.\n *\n * @platform android\n */\n getSafeAreaInsets(): Promise<SafeAreaInsets>;\n}\n"]}
package/dist/esm/web.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { WebPlugin } from "@capacitor/core";
2
- import type { CameraDevice, CameraOpacityOptions, CameraPreviewFlashMode, CameraPreviewOptions, CameraPreviewPictureOptions, CameraPreviewPlugin, CameraSampleOptions, GridMode, FlashMode, LensInfo } from "./definitions";
2
+ import type { CameraDevice, CameraOpacityOptions, CameraPreviewFlashMode, CameraPreviewOptions, CameraPreviewPictureOptions, CameraPreviewPlugin, CameraSampleOptions, GridMode, FlashMode, LensInfo, SafeAreaInsets } from "./definitions";
3
3
  export declare class CameraPreviewWeb extends WebPlugin implements CameraPreviewPlugin {
4
4
  /**
5
5
  * track which camera is used based on start options
@@ -10,6 +10,7 @@ export declare class CameraPreviewWeb extends WebPlugin implements CameraPreview
10
10
  private videoElement;
11
11
  private isStarted;
12
12
  constructor();
13
+ getSafeAreaInsets(): Promise<SafeAreaInsets>;
13
14
  getZoomButtonValues(): Promise<{
14
15
  values: number[];
15
16
  }>;
package/dist/esm/web.js CHANGED
@@ -13,6 +13,9 @@ export class CameraPreviewWeb extends WebPlugin {
13
13
  this.videoElement = null;
14
14
  this.isStarted = false;
15
15
  }
16
+ getSafeAreaInsets() {
17
+ throw new Error("Method not implemented.");
18
+ }
16
19
  async getZoomButtonValues() {
17
20
  throw new Error("getZoomButtonValues not supported under the web platform");
18
21
  }