@capgo/camera-preview 7.4.0-beta.8 → 7.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +243 -51
- package/android/gradle/wrapper/gradle-wrapper.properties +1 -1
- package/android/src/main/java/com/ahm/capacitor/camera/preview/CameraPreview.java +1249 -143
- package/android/src/main/java/com/ahm/capacitor/camera/preview/CameraXView.java +3400 -1382
- package/android/src/main/java/com/ahm/capacitor/camera/preview/GridOverlayView.java +95 -58
- package/android/src/main/java/com/ahm/capacitor/camera/preview/model/CameraDevice.java +55 -46
- package/android/src/main/java/com/ahm/capacitor/camera/preview/model/CameraLens.java +61 -52
- package/android/src/main/java/com/ahm/capacitor/camera/preview/model/CameraSessionConfiguration.java +160 -72
- package/android/src/main/java/com/ahm/capacitor/camera/preview/model/LensInfo.java +29 -23
- package/android/src/main/java/com/ahm/capacitor/camera/preview/model/ZoomFactors.java +24 -23
- package/dist/docs.json +441 -40
- package/dist/esm/definitions.d.ts +167 -25
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.js +24 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/web.d.ts +23 -3
- package/dist/esm/web.js +463 -65
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +485 -64
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +485 -64
- package/dist/plugin.js.map +1 -1
- package/ios/Sources/{CapgoCameraPreview → CapgoCameraPreviewPlugin}/CameraController.swift +731 -315
- package/ios/Sources/CapgoCameraPreviewPlugin/Plugin.swift +1902 -0
- package/package.json +11 -3
- package/android/.gradle/8.14.2/checksums/checksums.lock +0 -0
- package/android/.gradle/8.14.2/checksums/md5-checksums.bin +0 -0
- package/android/.gradle/8.14.2/checksums/sha1-checksums.bin +0 -0
- package/android/.gradle/8.14.2/executionHistory/executionHistory.bin +0 -0
- package/android/.gradle/8.14.2/executionHistory/executionHistory.lock +0 -0
- package/android/.gradle/8.14.2/fileChanges/last-build.bin +0 -0
- package/android/.gradle/8.14.2/fileHashes/fileHashes.bin +0 -0
- package/android/.gradle/8.14.2/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/8.14.2/fileHashes/resourceHashesCache.bin +0 -0
- package/android/.gradle/8.14.2/gc.properties +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +0 -2
- package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
- package/android/.gradle/file-system.probe +0 -0
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/ios/Sources/CapgoCameraPreview/Plugin.swift +0 -1211
- /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?:
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
*/
|
|
@@ -332,10 +377,11 @@ export interface CameraPreviewPlugin {
|
|
|
332
377
|
* - x: Optional x coordinate for positioning. If not provided, view will be auto-centered horizontally.
|
|
333
378
|
* - y: Optional y coordinate for positioning. If not provided, view will be auto-centered vertically.
|
|
334
379
|
* @returns {Promise<{ width: number; height: number; x: number; y: number }>} A promise that resolves with the actual preview dimensions and position.
|
|
335
|
-
* @since 7.
|
|
380
|
+
* @since 7.5.0
|
|
381
|
+
* @platform android, ios
|
|
336
382
|
*/
|
|
337
383
|
setAspectRatio(options: {
|
|
338
|
-
aspectRatio:
|
|
384
|
+
aspectRatio: "4:3" | "16:9";
|
|
339
385
|
x?: number;
|
|
340
386
|
y?: number;
|
|
341
387
|
}): Promise<{
|
|
@@ -348,10 +394,11 @@ export interface CameraPreviewPlugin {
|
|
|
348
394
|
* Gets the current aspect ratio of the camera preview.
|
|
349
395
|
*
|
|
350
396
|
* @returns {Promise<{ aspectRatio: '4:3' | '16:9' }>} A promise that resolves with the current aspect ratio.
|
|
351
|
-
* @since 7.
|
|
397
|
+
* @since 7.5.0
|
|
398
|
+
* @platform android, ios
|
|
352
399
|
*/
|
|
353
400
|
getAspectRatio(): Promise<{
|
|
354
|
-
aspectRatio:
|
|
401
|
+
aspectRatio: "4:3" | "16:9";
|
|
355
402
|
}>;
|
|
356
403
|
/**
|
|
357
404
|
* Sets the grid mode of the camera preview overlay.
|
|
@@ -437,7 +484,8 @@ export interface CameraPreviewPlugin {
|
|
|
437
484
|
* Checks if the camera preview is currently running.
|
|
438
485
|
*
|
|
439
486
|
* @returns {Promise<{ isRunning: boolean }>} A promise that resolves with the running state.
|
|
440
|
-
* @since 7.
|
|
487
|
+
* @since 7.5.0
|
|
488
|
+
* @platform android, ios
|
|
441
489
|
*/
|
|
442
490
|
isRunning(): Promise<{
|
|
443
491
|
isRunning: boolean;
|
|
@@ -446,7 +494,8 @@ export interface CameraPreviewPlugin {
|
|
|
446
494
|
* Gets all available camera devices.
|
|
447
495
|
*
|
|
448
496
|
* @returns {Promise<{ devices: CameraDevice[] }>} A promise that resolves with the list of available camera devices.
|
|
449
|
-
* @since 7.
|
|
497
|
+
* @since 7.5.0
|
|
498
|
+
* @platform android, ios
|
|
450
499
|
*/
|
|
451
500
|
getAvailableDevices(): Promise<{
|
|
452
501
|
devices: CameraDevice[];
|
|
@@ -455,7 +504,8 @@ export interface CameraPreviewPlugin {
|
|
|
455
504
|
* Gets the current zoom state, including min/max and current lens info.
|
|
456
505
|
*
|
|
457
506
|
* @returns {Promise<{ min: number; max: number; current: number; lens: LensInfo }>} A promise that resolves with the zoom state.
|
|
458
|
-
* @since 7.
|
|
507
|
+
* @since 7.5.0
|
|
508
|
+
* @platform android, ios
|
|
459
509
|
*/
|
|
460
510
|
getZoom(): Promise<{
|
|
461
511
|
min: number;
|
|
@@ -464,21 +514,34 @@ export interface CameraPreviewPlugin {
|
|
|
464
514
|
lens: LensInfo;
|
|
465
515
|
}>;
|
|
466
516
|
/**
|
|
467
|
-
*
|
|
517
|
+
* Returns zoom button values for quick switching.
|
|
518
|
+
* - iOS/Android: includes 0.5 if ultra-wide available; 1 and 2 if wide available; 3 if telephoto available
|
|
519
|
+
* - Web: unsupported
|
|
520
|
+
* @since 7.5.0
|
|
521
|
+
* @platform android, ios
|
|
522
|
+
*/
|
|
523
|
+
getZoomButtonValues(): Promise<{
|
|
524
|
+
values: number[];
|
|
525
|
+
}>;
|
|
526
|
+
/**
|
|
527
|
+
* Sets the zoom level of the camera.
|
|
468
528
|
*
|
|
469
|
-
* @param {{ level: number; ramp?: boolean }} options - The desired zoom level. `ramp` is currently unused.
|
|
529
|
+
* @param {{ level: number; ramp?: boolean; autoFocus?: boolean }} options - The desired zoom level. `ramp` is currently unused. `autoFocus` defaults to true.
|
|
470
530
|
* @returns {Promise<void>} A promise that resolves when the zoom level is set.
|
|
471
|
-
* @since 7.
|
|
531
|
+
* @since 7.5.0
|
|
532
|
+
* @platform android, ios
|
|
472
533
|
*/
|
|
473
534
|
setZoom(options: {
|
|
474
535
|
level: number;
|
|
475
536
|
ramp?: boolean;
|
|
537
|
+
autoFocus?: boolean;
|
|
476
538
|
}): Promise<void>;
|
|
477
539
|
/**
|
|
478
540
|
* Gets the current flash mode.
|
|
479
541
|
*
|
|
480
542
|
* @returns {Promise<{ flashMode: FlashMode }>} A promise that resolves with the current flash mode.
|
|
481
|
-
* @since 7.
|
|
543
|
+
* @since 7.5.0
|
|
544
|
+
* @platform android, ios
|
|
482
545
|
*/
|
|
483
546
|
getFlashMode(): Promise<{
|
|
484
547
|
flashMode: FlashMode;
|
|
@@ -486,7 +549,8 @@ export interface CameraPreviewPlugin {
|
|
|
486
549
|
/**
|
|
487
550
|
* Removes all registered listeners.
|
|
488
551
|
*
|
|
489
|
-
* @since 7.
|
|
552
|
+
* @since 7.5.0
|
|
553
|
+
* @platform android, ios
|
|
490
554
|
*/
|
|
491
555
|
removeAllListeners(): Promise<void>;
|
|
492
556
|
/**
|
|
@@ -494,7 +558,8 @@ export interface CameraPreviewPlugin {
|
|
|
494
558
|
*
|
|
495
559
|
* @param {{ deviceId: string }} options - The ID of the device to switch to.
|
|
496
560
|
* @returns {Promise<void>} A promise that resolves when the camera is switched.
|
|
497
|
-
* @since 7.
|
|
561
|
+
* @since 7.5.0
|
|
562
|
+
* @platform android, ios
|
|
498
563
|
*/
|
|
499
564
|
setDeviceId(options: {
|
|
500
565
|
deviceId: string;
|
|
@@ -503,7 +568,8 @@ export interface CameraPreviewPlugin {
|
|
|
503
568
|
* Gets the ID of the currently active camera device.
|
|
504
569
|
*
|
|
505
570
|
* @returns {Promise<{ deviceId: string }>} A promise that resolves with the current device ID.
|
|
506
|
-
* @since 7.
|
|
571
|
+
* @since 7.5.0
|
|
572
|
+
* @platform android, ios
|
|
507
573
|
*/
|
|
508
574
|
getDeviceId(): Promise<{
|
|
509
575
|
deviceId: string;
|
|
@@ -511,6 +577,8 @@ export interface CameraPreviewPlugin {
|
|
|
511
577
|
/**
|
|
512
578
|
* Gets the current preview size and position.
|
|
513
579
|
* @returns {Promise<{x: number, y: number, width: number, height: number}>}
|
|
580
|
+
* @since 7.5.0
|
|
581
|
+
* @platform android, ios
|
|
514
582
|
*/
|
|
515
583
|
getPreviewSize(): Promise<{
|
|
516
584
|
x: number;
|
|
@@ -522,10 +590,12 @@ export interface CameraPreviewPlugin {
|
|
|
522
590
|
* Sets the preview size and position.
|
|
523
591
|
* @param options The new position and dimensions.
|
|
524
592
|
* @returns {Promise<{ width: number; height: number; x: number; y: number }>} A promise that resolves with the actual preview dimensions and position.
|
|
593
|
+
* @since 7.5.0
|
|
594
|
+
* @platform android, ios
|
|
525
595
|
*/
|
|
526
596
|
setPreviewSize(options: {
|
|
527
|
-
x
|
|
528
|
-
y
|
|
597
|
+
x?: number;
|
|
598
|
+
y?: number;
|
|
529
599
|
width: number;
|
|
530
600
|
height: number;
|
|
531
601
|
}): Promise<{
|
|
@@ -534,4 +604,76 @@ export interface CameraPreviewPlugin {
|
|
|
534
604
|
x: number;
|
|
535
605
|
y: number;
|
|
536
606
|
}>;
|
|
607
|
+
/**
|
|
608
|
+
* Sets the camera focus to a specific point in the preview.
|
|
609
|
+
*
|
|
610
|
+
* @param {Object} options - The focus options.
|
|
611
|
+
* @param {number} options.x - The x coordinate in the preview view to focus on (0-1 normalized).
|
|
612
|
+
* @param {number} options.y - The y coordinate in the preview view to focus on (0-1 normalized).
|
|
613
|
+
* @returns {Promise<void>} A promise that resolves when the focus is set.
|
|
614
|
+
* @since 7.5.0
|
|
615
|
+
* @platform android, ios
|
|
616
|
+
*/
|
|
617
|
+
setFocus(options: {
|
|
618
|
+
x: number;
|
|
619
|
+
y: number;
|
|
620
|
+
}): Promise<void>;
|
|
621
|
+
/**
|
|
622
|
+
* Adds a listener for screen resize events.
|
|
623
|
+
* @param {string} eventName - The event name to listen for.
|
|
624
|
+
* @param {Function} listenerFunc - The function to call when the event is triggered.
|
|
625
|
+
* @returns {Promise<PluginListenerHandle>} A promise that resolves with a handle to the listener.
|
|
626
|
+
* @since 7.5.0
|
|
627
|
+
* @platform android, ios
|
|
628
|
+
*/
|
|
629
|
+
addListener(eventName: "screenResize", listenerFunc: (data: {
|
|
630
|
+
width: number;
|
|
631
|
+
height: number;
|
|
632
|
+
x: number;
|
|
633
|
+
y: number;
|
|
634
|
+
}) => void): Promise<PluginListenerHandle>;
|
|
635
|
+
/**
|
|
636
|
+
* Adds a listener for orientation change events.
|
|
637
|
+
* @param {string} eventName - The event name to listen for.
|
|
638
|
+
* @param {Function} listenerFunc - The function to call when the event is triggered.
|
|
639
|
+
* @returns {Promise<PluginListenerHandle>} A promise that resolves with a handle to the listener.
|
|
640
|
+
* @since 7.5.0
|
|
641
|
+
* @platform android, ios
|
|
642
|
+
*/
|
|
643
|
+
addListener(eventName: "orientationChange", listenerFunc: (data: {
|
|
644
|
+
orientation: DeviceOrientation;
|
|
645
|
+
}) => void): Promise<PluginListenerHandle>;
|
|
646
|
+
/**
|
|
647
|
+
* Deletes a file at the given absolute path on the device.
|
|
648
|
+
* Use this to quickly clean up temporary images created with `storeToFile`.
|
|
649
|
+
* On web, this is not supported and will throw.
|
|
650
|
+
* @since 7.5.0
|
|
651
|
+
* @platform android, ios
|
|
652
|
+
*/
|
|
653
|
+
deleteFile(options: {
|
|
654
|
+
path: string;
|
|
655
|
+
}): Promise<{
|
|
656
|
+
success: boolean;
|
|
657
|
+
}>;
|
|
658
|
+
/**
|
|
659
|
+
* Gets the safe area insets for devices.
|
|
660
|
+
* Returns the orientation-aware notch/camera cutout inset and the current orientation.
|
|
661
|
+
* In portrait mode: returns top inset (notch at top).
|
|
662
|
+
* In landscape mode: returns left inset (notch moved to side).
|
|
663
|
+
* This specifically targets the cutout area (notch, punch hole, etc.) that all modern phones have.
|
|
664
|
+
*
|
|
665
|
+
* Android: Values returned in dp (logical pixels).
|
|
666
|
+
* iOS: Values returned in physical pixels, excluding status bar (only pure notch/cutout size).
|
|
667
|
+
*
|
|
668
|
+
* @platform android, ios
|
|
669
|
+
*/
|
|
670
|
+
getSafeAreaInsets(): Promise<SafeAreaInsets>;
|
|
671
|
+
/**
|
|
672
|
+
* Gets the current device orientation in a cross-platform format.
|
|
673
|
+
* @since 7.5.0
|
|
674
|
+
* @platform android, ios
|
|
675
|
+
*/
|
|
676
|
+
getOrientation(): Promise<{
|
|
677
|
+
orientation: DeviceOrientation;
|
|
678
|
+
}>;
|
|
537
679
|
}
|
|
@@ -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 * @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.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"]}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -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
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;
|
|
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:
|
|
74
|
+
aspectRatio: "4:3" | "16:9";
|
|
64
75
|
}>;
|
|
65
76
|
setAspectRatio(options: {
|
|
66
|
-
aspectRatio:
|
|
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
|
}
|