@capgo/camera-preview 7.4.0-beta.9 → 7.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/README.md +246 -50
  2. package/android/gradle/wrapper/gradle-wrapper.properties +1 -1
  3. package/android/src/main/java/com/ahm/capacitor/camera/preview/CameraPreview.java +1249 -143
  4. package/android/src/main/java/com/ahm/capacitor/camera/preview/CameraXView.java +3400 -1432
  5. package/android/src/main/java/com/ahm/capacitor/camera/preview/GridOverlayView.java +95 -58
  6. package/android/src/main/java/com/ahm/capacitor/camera/preview/model/CameraDevice.java +55 -46
  7. package/android/src/main/java/com/ahm/capacitor/camera/preview/model/CameraLens.java +61 -52
  8. package/android/src/main/java/com/ahm/capacitor/camera/preview/model/CameraSessionConfiguration.java +160 -72
  9. package/android/src/main/java/com/ahm/capacitor/camera/preview/model/LensInfo.java +29 -23
  10. package/android/src/main/java/com/ahm/capacitor/camera/preview/model/ZoomFactors.java +24 -23
  11. package/dist/docs.json +443 -42
  12. package/dist/esm/definitions.d.ts +173 -27
  13. package/dist/esm/definitions.js.map +1 -1
  14. package/dist/esm/index.d.ts +2 -0
  15. package/dist/esm/index.js +24 -1
  16. package/dist/esm/index.js.map +1 -1
  17. package/dist/esm/web.d.ts +23 -3
  18. package/dist/esm/web.js +463 -65
  19. package/dist/esm/web.js.map +1 -1
  20. package/dist/plugin.cjs.js +485 -64
  21. package/dist/plugin.cjs.js.map +1 -1
  22. package/dist/plugin.js +485 -64
  23. package/dist/plugin.js.map +1 -1
  24. package/ios/Sources/{CapgoCameraPreview → CapgoCameraPreviewPlugin}/CameraController.swift +731 -315
  25. package/ios/Sources/CapgoCameraPreviewPlugin/Plugin.swift +1902 -0
  26. package/package.json +11 -3
  27. package/android/.gradle/8.14.2/checksums/checksums.lock +0 -0
  28. package/android/.gradle/8.14.2/checksums/md5-checksums.bin +0 -0
  29. package/android/.gradle/8.14.2/checksums/sha1-checksums.bin +0 -0
  30. package/android/.gradle/8.14.2/executionHistory/executionHistory.bin +0 -0
  31. package/android/.gradle/8.14.2/executionHistory/executionHistory.lock +0 -0
  32. package/android/.gradle/8.14.2/fileChanges/last-build.bin +0 -0
  33. package/android/.gradle/8.14.2/fileHashes/fileHashes.bin +0 -0
  34. package/android/.gradle/8.14.2/fileHashes/fileHashes.lock +0 -0
  35. package/android/.gradle/8.14.2/fileHashes/resourceHashesCache.bin +0 -0
  36. package/android/.gradle/8.14.2/gc.properties +0 -0
  37. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  38. package/android/.gradle/buildOutputCleanup/cache.properties +0 -2
  39. package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
  40. package/android/.gradle/file-system.probe +0 -0
  41. package/android/.gradle/vcs-1/gc.properties +0 -0
  42. package/ios/Sources/CapgoCameraPreview/Plugin.swift +0 -1369
  43. /package/ios/Sources/{CapgoCameraPreview → CapgoCameraPreviewPlugin}/GridOverlayView.swift +0 -0
@@ -1,6 +1,8 @@
1
+ import type { PluginListenerHandle } from "@capacitor/core";
1
2
  export type CameraPosition = "rear" | "front";
2
3
  export type FlashMode = CameraPreviewFlashMode;
3
4
  export type GridMode = "none" | "3x3" | "4x4";
5
+ export type CameraPositioning = "center" | "top" | "bottom";
4
6
  export declare enum DeviceType {
5
7
  ULTRA_WIDE = "ultraWide",
6
8
  WIDE_ANGLE = "wideAngle",
@@ -100,7 +102,7 @@ export interface CameraPreviewOptions {
100
102
  *
101
103
  * @since 2.0.0
102
104
  */
103
- aspectRatio?: '4:3' | '16:9' | 'fill';
105
+ aspectRatio?: "4:3" | "16:9";
104
106
  /**
105
107
  * The grid overlay to display on the camera preview.
106
108
  * @default "none"
@@ -147,12 +149,6 @@ export interface CameraPreviewOptions {
147
149
  * @default false
148
150
  */
149
151
  disableExifHeaderStripping?: boolean;
150
- /**
151
- * If true, enables high-resolution image capture.
152
- * @platform ios
153
- * @default false
154
- */
155
- enableHighResolution?: boolean;
156
152
  /**
157
153
  * If true, disables the audio stream, preventing audio permission requests.
158
154
  * @default true
@@ -187,15 +183,44 @@ export interface CameraPreviewOptions {
187
183
  * @platform ios
188
184
  */
189
185
  deviceId?: string;
186
+ /**
187
+ * The initial zoom level when starting the camera preview.
188
+ * If the requested zoom level is not available, the native plugin will reject.
189
+ * @default 1.0
190
+ * @platform android, ios
191
+ * @since 2.2.0
192
+ */
193
+ initialZoomLevel?: number;
194
+ /**
195
+ * The vertical positioning of the camera preview.
196
+ * @default "center"
197
+ * @platform android, ios, web
198
+ * @since 2.3.0
199
+ */
200
+ positioning?: CameraPositioning;
190
201
  }
191
202
  /**
192
203
  * Defines the options for capturing a picture.
193
204
  */
194
205
  export interface CameraPreviewPictureOptions {
195
- /** The desired height of the picture in pixels. If not provided, the device default is used. */
206
+ /** @deprecated,
207
+ * The desired height of the picture in pixels.
208
+ * If not specified and no aspectRatio is provided, the captured image will match the preview's visible area.
209
+ */
196
210
  height?: number;
197
- /** The desired width of the picture in pixels. If not provided, the device default is used. */
211
+ /** @deprecated,
212
+ * The desired width of the picture in pixels.
213
+ * If not specified and no aspectRatio is provided, the captured image will match the preview's visible area.
214
+ */
198
215
  width?: number;
216
+ /** @deprecated,
217
+ * The desired aspect ratio of the captured image (e.g., '4:3', '16:9').
218
+ * If not specified and no width/height is provided, the aspect ratio from the camera start will be used.
219
+ * If no aspect ratio was set at start, defaults to '4:3'.
220
+ * Cannot be used together with width or height - the capture will be rejected with an error.
221
+ * @since 7.7.0
222
+ */
223
+ aspectRatio?: string;
199
224
  /**
200
225
  * The quality of the captured image, from 0 to 100.
201
226
  * Does not apply to `png` format.
@@ -265,6 +290,26 @@ export interface CameraOpacityOptions {
265
290
  */
266
291
  opacity?: number;
267
292
  }
293
+ /**
294
+ * Represents safe area insets for devices.
295
+ * Android: Values are expressed in logical pixels (dp) to match JS layout units.
296
+ * iOS: Values are expressed in physical pixels and exclude status bar.
297
+ */
298
+ export interface SafeAreaInsets {
299
+ /** Current device orientation (1 = portrait, 2 = landscape, 0 = unknown). */
300
+ orientation: number;
301
+ /**
302
+ * Orientation-aware notch/camera cutout inset (excluding status bar).
303
+ * In portrait mode: returns top inset (notch at top).
304
+ * In landscape mode: returns left inset (notch at side).
305
+ * Android: Value in dp, iOS: Value in pixels (status bar excluded).
306
+ */
307
+ top: number;
308
+ }
309
+ /**
310
+ * Canonical device orientation values across platforms.
311
+ */
312
+ export type DeviceOrientation = "portrait" | "landscape" | "landscape-left" | "landscape-right" | "portrait-upside-down" | "unknown";
268
313
  /**
269
314
  * The main interface for the CameraPreview plugin.
270
315
  */
@@ -296,9 +341,13 @@ export interface CameraPreviewPlugin {
296
341
  /**
297
342
  * Captures a picture from the camera.
298
343
  *
344
+ * If `storeToFile` was set to `true` when starting the preview, the returned
345
+ * `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.
346
+ *
299
347
  * @param {CameraPreviewPictureOptions} options - The options for capturing the picture.
300
- * @returns {Promise<{ value: string }>} A promise that resolves with the captured image data.
301
- * The `value` is a base64 encoded string unless `storeToFile` is true, in which case it's a file path.
348
+ * @returns {Promise<{ value: string; exif: ExifData }>} Resolves with:
349
+ * - `value`: base64 string, or file path if `storeToFile` is true
350
+ * - `exif`: extracted EXIF metadata when available
302
351
  * @since 0.0.1
303
352
  */
304
353
  capture(options: CameraPreviewPictureOptions): Promise<{
@@ -332,10 +381,11 @@ export interface CameraPreviewPlugin {
332
381
  * - x: Optional x coordinate for positioning. If not provided, view will be auto-centered horizontally.
333
382
  * - y: Optional y coordinate for positioning. If not provided, view will be auto-centered vertically.
334
383
  * @returns {Promise<{ width: number; height: number; x: number; y: number }>} A promise that resolves with the actual preview dimensions and position.
335
- * @since 7.4.0
384
+ * @since 7.5.0
385
+ * @platform android, ios
336
386
  */
337
387
  setAspectRatio(options: {
338
- aspectRatio: '4:3' | '16:9';
388
+ aspectRatio: "4:3" | "16:9";
339
389
  x?: number;
340
390
  y?: number;
341
391
  }): Promise<{
@@ -348,10 +398,11 @@ export interface CameraPreviewPlugin {
348
398
  * Gets the current aspect ratio of the camera preview.
349
399
  *
350
400
  * @returns {Promise<{ aspectRatio: '4:3' | '16:9' }>} A promise that resolves with the current aspect ratio.
351
- * @since 7.4.0
401
+ * @since 7.5.0
402
+ * @platform android, ios
352
403
  */
353
404
  getAspectRatio(): Promise<{
354
- aspectRatio: '4:3' | '16:9';
405
+ aspectRatio: "4:3" | "16:9";
355
406
  }>;
356
407
  /**
357
408
  * Sets the grid mode of the camera preview overlay.
@@ -437,7 +488,8 @@ export interface CameraPreviewPlugin {
437
488
  * Checks if the camera preview is currently running.
438
489
  *
439
490
  * @returns {Promise<{ isRunning: boolean }>} A promise that resolves with the running state.
440
- * @since 7.4.0
491
+ * @since 7.5.0
492
+ * @platform android, ios
441
493
  */
442
494
  isRunning(): Promise<{
443
495
  isRunning: boolean;
@@ -446,7 +498,8 @@ export interface CameraPreviewPlugin {
446
498
  * Gets all available camera devices.
447
499
  *
448
500
  * @returns {Promise<{ devices: CameraDevice[] }>} A promise that resolves with the list of available camera devices.
449
- * @since 7.4.0
501
+ * @since 7.5.0
502
+ * @platform android, ios
450
503
  */
451
504
  getAvailableDevices(): Promise<{
452
505
  devices: CameraDevice[];
@@ -455,7 +508,8 @@ export interface CameraPreviewPlugin {
455
508
  * Gets the current zoom state, including min/max and current lens info.
456
509
  *
457
510
  * @returns {Promise<{ min: number; max: number; current: number; lens: LensInfo }>} A promise that resolves with the zoom state.
458
- * @since 7.4.0
511
+ * @since 7.5.0
512
+ * @platform android, ios
459
513
  */
460
514
  getZoom(): Promise<{
461
515
  min: number;
@@ -464,21 +518,34 @@ export interface CameraPreviewPlugin {
464
518
  lens: LensInfo;
465
519
  }>;
466
520
  /**
467
- * Sets the camera's zoom level.
521
+ * Returns zoom button values for quick switching.
522
+ * - iOS/Android: includes 0.5 if ultra-wide available; 1 and 2 if wide available; 3 if telephoto available
523
+ * - Web: unsupported
524
+ * @since 7.5.0
525
+ * @platform android, ios
526
+ */
527
+ getZoomButtonValues(): Promise<{
528
+ values: number[];
529
+ }>;
530
+ /**
531
+ * Sets the zoom level of the camera.
468
532
  *
469
- * @param {{ level: number; ramp?: boolean }} options - The desired zoom level. `ramp` is currently unused.
533
+ * @param {{ level: number; ramp?: boolean; autoFocus?: boolean }} options - The desired zoom level. `ramp` is currently unused. `autoFocus` defaults to true.
470
534
  * @returns {Promise<void>} A promise that resolves when the zoom level is set.
471
- * @since 7.4.0
535
+ * @since 7.5.0
536
+ * @platform android, ios
472
537
  */
473
538
  setZoom(options: {
474
539
  level: number;
475
540
  ramp?: boolean;
541
+ autoFocus?: boolean;
476
542
  }): Promise<void>;
477
543
  /**
478
544
  * Gets the current flash mode.
479
545
  *
480
546
  * @returns {Promise<{ flashMode: FlashMode }>} A promise that resolves with the current flash mode.
481
- * @since 7.4.0
547
+ * @since 7.5.0
548
+ * @platform android, ios
482
549
  */
483
550
  getFlashMode(): Promise<{
484
551
  flashMode: FlashMode;
@@ -486,7 +553,8 @@ export interface CameraPreviewPlugin {
486
553
  /**
487
554
  * Removes all registered listeners.
488
555
  *
489
- * @since 7.4.0
556
+ * @since 7.5.0
557
+ * @platform android, ios
490
558
  */
491
559
  removeAllListeners(): Promise<void>;
492
560
  /**
@@ -494,7 +562,8 @@ export interface CameraPreviewPlugin {
494
562
  *
495
563
  * @param {{ deviceId: string }} options - The ID of the device to switch to.
496
564
  * @returns {Promise<void>} A promise that resolves when the camera is switched.
497
- * @since 7.4.0
565
+ * @since 7.5.0
566
+ * @platform android, ios
498
567
  */
499
568
  setDeviceId(options: {
500
569
  deviceId: string;
@@ -503,7 +572,8 @@ export interface CameraPreviewPlugin {
503
572
  * Gets the ID of the currently active camera device.
504
573
  *
505
574
  * @returns {Promise<{ deviceId: string }>} A promise that resolves with the current device ID.
506
- * @since 7.4.0
575
+ * @since 7.5.0
576
+ * @platform android, ios
507
577
  */
508
578
  getDeviceId(): Promise<{
509
579
  deviceId: string;
@@ -511,6 +581,8 @@ export interface CameraPreviewPlugin {
511
581
  /**
512
582
  * Gets the current preview size and position.
513
583
  * @returns {Promise<{x: number, y: number, width: number, height: number}>}
584
+ * @since 7.5.0
585
+ * @platform android, ios
514
586
  */
515
587
  getPreviewSize(): Promise<{
516
588
  x: number;
@@ -522,10 +594,12 @@ export interface CameraPreviewPlugin {
522
594
  * Sets the preview size and position.
523
595
  * @param options The new position and dimensions.
524
596
  * @returns {Promise<{ width: number; height: number; x: number; y: number }>} A promise that resolves with the actual preview dimensions and position.
597
+ * @since 7.5.0
598
+ * @platform android, ios
525
599
  */
526
600
  setPreviewSize(options: {
527
- x: number;
528
- y: number;
601
+ x?: number;
602
+ y?: number;
529
603
  width: number;
530
604
  height: number;
531
605
  }): Promise<{
@@ -534,4 +608,76 @@ export interface CameraPreviewPlugin {
534
608
  x: number;
535
609
  y: number;
536
610
  }>;
611
+ /**
612
+ * Sets the camera focus to a specific point in the preview.
613
+ *
614
+ * @param {Object} options - The focus options.
615
+ * @param {number} options.x - The x coordinate in the preview view to focus on (0-1 normalized).
616
+ * @param {number} options.y - The y coordinate in the preview view to focus on (0-1 normalized).
617
+ * @returns {Promise<void>} A promise that resolves when the focus is set.
618
+ * @since 7.5.0
619
+ * @platform android, ios
620
+ */
621
+ setFocus(options: {
622
+ x: number;
623
+ y: number;
624
+ }): Promise<void>;
625
+ /**
626
+ * Adds a listener for screen resize events.
627
+ * @param {string} eventName - The event name to listen for.
628
+ * @param {Function} listenerFunc - The function to call when the event is triggered.
629
+ * @returns {Promise<PluginListenerHandle>} A promise that resolves with a handle to the listener.
630
+ * @since 7.5.0
631
+ * @platform android, ios
632
+ */
633
+ addListener(eventName: "screenResize", listenerFunc: (data: {
634
+ width: number;
635
+ height: number;
636
+ x: number;
637
+ y: number;
638
+ }) => void): Promise<PluginListenerHandle>;
639
+ /**
640
+ * Adds a listener for orientation change events.
641
+ * @param {string} eventName - The event name to listen for.
642
+ * @param {Function} listenerFunc - The function to call when the event is triggered.
643
+ * @returns {Promise<PluginListenerHandle>} A promise that resolves with a handle to the listener.
644
+ * @since 7.5.0
645
+ * @platform android, ios
646
+ */
647
+ addListener(eventName: "orientationChange", listenerFunc: (data: {
648
+ orientation: DeviceOrientation;
649
+ }) => void): Promise<PluginListenerHandle>;
650
+ /**
651
+ * Deletes a file at the given absolute path on the device.
652
+ * Use this to quickly clean up temporary images created with `storeToFile`.
653
+ * On web, this is not supported and will throw.
654
+ * @since 7.5.0
655
+ * @platform android, ios
656
+ */
657
+ deleteFile(options: {
658
+ path: string;
659
+ }): Promise<{
660
+ success: boolean;
661
+ }>;
662
+ /**
663
+ * Gets the safe area insets for devices.
664
+ * Returns the orientation-aware notch/camera cutout inset and the current orientation.
665
+ * In portrait mode: returns top inset (notch at top).
666
+ * In landscape mode: returns left inset (notch moved to side).
667
+ * This specifically targets the cutout area (notch, punch hole, etc.) that all modern phones have.
668
+ *
669
+ * Android: Values returned in dp (logical pixels).
670
+ * iOS: Values returned in physical pixels, excluding status bar (only pure notch/cutout size).
671
+ *
672
+ * @platform android, ios
673
+ */
674
+ getSafeAreaInsets(): Promise<SafeAreaInsets>;
675
+ /**
676
+ * Gets the current device orientation in a cross-platform format.
677
+ * @since 7.5.0
678
+ * @platform android, ios
679
+ */
680
+ getOrientation(): Promise<{
681
+ orientation: DeviceOrientation;
682
+ }>;
537
683
  }
@@ -1 +1 @@
1
- {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAMA,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":["export type CameraPosition = \"rear\" | \"front\";\n\nexport type FlashMode = CameraPreviewFlashMode;\n\nexport type GridMode = \"none\" | \"3x3\" | \"4x4\";\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' | 'fill';\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, enables high-resolution image capture.\n * @platform ios\n * @default false\n */\n enableHighResolution?: 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\n/**\n * Defines the options for capturing a picture.\n */\nexport interface CameraPreviewPictureOptions {\n /** The desired height of the picture in pixels. If not provided, the device default is used. */\n height?: number;\n /** The desired width of the picture in pixels. If not provided, the device default is used. */\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 =\n | \"off\"\n | \"on\"\n | \"auto\"\n | \"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: { aspectRatio: '4:3' | '16:9'; x?: number; y?: number }): Promise<{\n width: number;\n height: number;\n x: number;\n y: number;\n }>;\n\n /**\n * Gets the current aspect ratio of the camera preview.\n *\n * @returns {Promise<{ aspectRatio: '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 * Sets the camera's zoom level.\n *\n * @param {{ level: number; ramp?: boolean }} options - The desired zoom level. `ramp` is currently unused.\n * @returns {Promise<void>} A promise that resolves when the zoom level is set.\n * @since 7.4.0\n */\n setZoom(options: { level: number; ramp?: boolean }): Promise<void>;\n\n /**\n * Gets the current flash mode.\n *\n * @returns {Promise<{ flashMode: FlashMode }>} A promise that resolves with the current flash mode.\n * @since 7.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<{x: number, y: number, width: number, height: number}>;\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: {x: number, y: number, width: number, height: number}): Promise<{\n width: number;\n height: number;\n x: number;\n y: number;\n }>;\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 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.\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"]}
@@ -2,3 +2,5 @@ import type { CameraPreviewPlugin } from "./definitions";
2
2
  declare const CameraPreview: CameraPreviewPlugin;
3
3
  export * from "./definitions";
4
4
  export { CameraPreview };
5
+ export declare function getBase64FromFilePath(filePath: string): Promise<string>;
6
+ export declare function deleteFile(path: string): Promise<boolean>;
package/dist/esm/index.js CHANGED
@@ -1,7 +1,30 @@
1
- import { registerPlugin } from "@capacitor/core";
1
+ import { Capacitor, registerPlugin } from "@capacitor/core";
2
2
  const CameraPreview = registerPlugin("CameraPreview", {
3
3
  web: () => import("./web").then((m) => new m.CameraPreviewWeb()),
4
4
  });
5
5
  export * from "./definitions";
6
6
  export { CameraPreview };
7
+ export async function getBase64FromFilePath(filePath) {
8
+ const url = Capacitor.convertFileSrc(filePath);
9
+ const response = await fetch(url);
10
+ if (!response.ok) {
11
+ throw new Error(`Failed to read file at path: ${filePath} (status ${response.status})`);
12
+ }
13
+ const blob = await response.blob();
14
+ return await new Promise((resolve, reject) => {
15
+ const reader = new FileReader();
16
+ reader.onloadend = () => {
17
+ const dataUrl = reader.result;
18
+ const commaIndex = dataUrl.indexOf(",");
19
+ resolve(commaIndex >= 0 ? dataUrl.substring(commaIndex + 1) : dataUrl);
20
+ };
21
+ reader.onerror = () => reject(reader.error);
22
+ reader.readAsDataURL(blob);
23
+ });
24
+ }
25
+ export async function deleteFile(path) {
26
+ // Use native bridge to delete file to handle platform-specific permissions/URIs
27
+ const { success } = await CameraPreview.deleteFile({ path });
28
+ return !!success;
29
+ }
7
30
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIjD,MAAM,aAAa,GAAG,cAAc,CAAsB,eAAe,EAAE;IACzE,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,gBAAgB,EAAE,CAAC;CACjE,CAAC,CAAC;AAEH,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAE,CAAC","sourcesContent":["import { registerPlugin } from \"@capacitor/core\";\n\nimport type { CameraPreviewPlugin } from \"./definitions\";\n\nconst CameraPreview = registerPlugin<CameraPreviewPlugin>(\"CameraPreview\", {\n web: () => import(\"./web\").then((m) => new m.CameraPreviewWeb()),\n});\n\nexport * from \"./definitions\";\nexport { CameraPreview };\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAI5D,MAAM,aAAa,GAAG,cAAc,CAAsB,eAAe,EAAE;IACzE,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,gBAAgB,EAAE,CAAC;CACjE,CAAC,CAAC;AAEH,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAE,CAAC;AAEzB,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAC,QAAgB;IAC1D,MAAM,GAAG,GAAG,SAAS,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;IAC/C,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC;IAClC,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CACb,gCAAgC,QAAQ,YAAY,QAAQ,CAAC,MAAM,GAAG,CACvE,CAAC;IACJ,CAAC;IACD,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;IACnC,OAAO,MAAM,IAAI,OAAO,CAAS,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACnD,MAAM,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;QAChC,MAAM,CAAC,SAAS,GAAG,GAAG,EAAE;YACtB,MAAM,OAAO,GAAG,MAAM,CAAC,MAAgB,CAAC;YACxC,MAAM,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;YACxC,OAAO,CAAC,UAAU,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;QACzE,CAAC,CAAC;QACF,MAAM,CAAC,OAAO,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC5C,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,IAAY;IAC3C,gFAAgF;IAChF,MAAM,EAAE,OAAO,EAAE,GAAG,MAAO,aAAqB,CAAC,UAAU,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;IACtE,OAAO,CAAC,CAAC,OAAO,CAAC;AACnB,CAAC","sourcesContent":["import { Capacitor, registerPlugin } from \"@capacitor/core\";\n\nimport type { CameraPreviewPlugin } from \"./definitions\";\n\nconst CameraPreview = registerPlugin<CameraPreviewPlugin>(\"CameraPreview\", {\n web: () => import(\"./web\").then((m) => new m.CameraPreviewWeb()),\n});\n\nexport * from \"./definitions\";\nexport { CameraPreview };\n\nexport async function getBase64FromFilePath(filePath: string): Promise<string> {\n const url = Capacitor.convertFileSrc(filePath);\n const response = await fetch(url);\n if (!response.ok) {\n throw new Error(\n `Failed to read file at path: ${filePath} (status ${response.status})`,\n );\n }\n const blob = await response.blob();\n return await new Promise<string>((resolve, reject) => {\n const reader = new FileReader();\n reader.onloadend = () => {\n const dataUrl = reader.result as string;\n const commaIndex = dataUrl.indexOf(\",\");\n resolve(commaIndex >= 0 ? dataUrl.substring(commaIndex + 1) : dataUrl);\n };\n reader.onerror = () => reject(reader.error);\n reader.readAsDataURL(blob);\n });\n}\n\nexport async function deleteFile(path: string): Promise<boolean> {\n // Use native bridge to delete file to handle platform-specific permissions/URIs\n const { success } = await (CameraPreview as any).deleteFile({ path });\n return !!success;\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, DeviceOrientation, 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
@@ -9,7 +9,17 @@ export declare class CameraPreviewWeb extends WebPlugin implements CameraPreview
9
9
  private currentDeviceId;
10
10
  private videoElement;
11
11
  private isStarted;
12
+ private orientationListenerBound;
12
13
  constructor();
14
+ private getCurrentOrientation;
15
+ private ensureOrientationListener;
16
+ getOrientation(): Promise<{
17
+ orientation: DeviceOrientation;
18
+ }>;
19
+ getSafeAreaInsets(): Promise<SafeAreaInsets>;
20
+ getZoomButtonValues(): Promise<{
21
+ values: number[];
22
+ }>;
13
23
  getSupportedPictureSizes(): Promise<any>;
14
24
  start(options: CameraPreviewOptions): Promise<{
15
25
  width: number;
@@ -49,6 +59,7 @@ export declare class CameraPreviewWeb extends WebPlugin implements CameraPreview
49
59
  setZoom(options: {
50
60
  level: number;
51
61
  ramp?: boolean;
62
+ autoFocus?: boolean;
52
63
  }): Promise<void>;
53
64
  getFlashMode(): Promise<{
54
65
  flashMode: FlashMode;
@@ -60,10 +71,10 @@ export declare class CameraPreviewWeb extends WebPlugin implements CameraPreview
60
71
  deviceId: string;
61
72
  }): Promise<void>;
62
73
  getAspectRatio(): Promise<{
63
- aspectRatio: '4:3' | '16:9';
74
+ aspectRatio: "4:3" | "16:9";
64
75
  }>;
65
76
  setAspectRatio(options: {
66
- aspectRatio: '4:3' | '16:9';
77
+ aspectRatio: "4:3" | "16:9";
67
78
  x?: number;
68
79
  y?: number;
69
80
  }): Promise<{
@@ -96,4 +107,13 @@ export declare class CameraPreviewWeb extends WebPlugin implements CameraPreview
96
107
  x: number;
97
108
  y: number;
98
109
  }>;
110
+ setFocus(options: {
111
+ x: number;
112
+ y: number;
113
+ }): Promise<void>;
114
+ deleteFile(_options: {
115
+ path: string;
116
+ }): Promise<{
117
+ success: boolean;
118
+ }>;
99
119
  }