@capgo/camera-preview 7.3.12 → 7.4.0-beta.10

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 (61) hide show
  1. package/CapgoCameraPreview.podspec +16 -13
  2. package/README.md +467 -73
  3. package/android/.gradle/8.14.2/checksums/checksums.lock +0 -0
  4. package/android/.gradle/8.14.2/checksums/md5-checksums.bin +0 -0
  5. package/android/.gradle/8.14.2/checksums/sha1-checksums.bin +0 -0
  6. package/android/.gradle/8.14.2/executionHistory/executionHistory.bin +0 -0
  7. package/android/.gradle/8.14.2/executionHistory/executionHistory.lock +0 -0
  8. package/android/.gradle/8.14.2/fileChanges/last-build.bin +0 -0
  9. package/android/.gradle/8.14.2/fileHashes/fileHashes.bin +0 -0
  10. package/android/.gradle/8.14.2/fileHashes/fileHashes.lock +0 -0
  11. package/android/.gradle/8.14.2/fileHashes/resourceHashesCache.bin +0 -0
  12. package/android/.gradle/8.14.2/gc.properties +0 -0
  13. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  14. package/android/.gradle/buildOutputCleanup/cache.properties +2 -0
  15. package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
  16. package/android/.gradle/file-system.probe +0 -0
  17. package/android/.gradle/vcs-1/gc.properties +0 -0
  18. package/android/build.gradle +11 -0
  19. package/android/gradle/wrapper/gradle-wrapper.properties +1 -1
  20. package/android/src/main/AndroidManifest.xml +5 -3
  21. package/android/src/main/java/com/ahm/capacitor/camera/preview/CameraPreview.java +472 -541
  22. package/android/src/main/java/com/ahm/capacitor/camera/preview/CameraXView.java +1648 -0
  23. package/android/src/main/java/com/ahm/capacitor/camera/preview/GridOverlayView.java +82 -0
  24. package/android/src/main/java/com/ahm/capacitor/camera/preview/model/CameraDevice.java +54 -0
  25. package/android/src/main/java/com/ahm/capacitor/camera/preview/model/CameraLens.java +70 -0
  26. package/android/src/main/java/com/ahm/capacitor/camera/preview/model/CameraSessionConfiguration.java +79 -0
  27. package/android/src/main/java/com/ahm/capacitor/camera/preview/model/LensInfo.java +34 -0
  28. package/android/src/main/java/com/ahm/capacitor/camera/preview/model/ZoomFactors.java +34 -0
  29. package/dist/docs.json +934 -154
  30. package/dist/esm/definitions.d.ts +445 -83
  31. package/dist/esm/definitions.js +10 -1
  32. package/dist/esm/definitions.js.map +1 -1
  33. package/dist/esm/web.d.ts +73 -3
  34. package/dist/esm/web.js +492 -68
  35. package/dist/esm/web.js.map +1 -1
  36. package/dist/plugin.cjs.js +498 -68
  37. package/dist/plugin.cjs.js.map +1 -1
  38. package/dist/plugin.js +498 -68
  39. package/dist/plugin.js.map +1 -1
  40. package/ios/{Plugin → Sources/CapgoCameraPreview}/CameraController.swift +601 -59
  41. package/ios/Sources/CapgoCameraPreview/GridOverlayView.swift +65 -0
  42. package/ios/Sources/CapgoCameraPreview/Plugin.swift +1369 -0
  43. package/ios/Tests/CameraPreviewPluginTests/CameraPreviewPluginTests.swift +15 -0
  44. package/package.json +1 -1
  45. package/android/src/main/java/com/ahm/capacitor/camera/preview/CameraActivity.java +0 -1279
  46. package/android/src/main/java/com/ahm/capacitor/camera/preview/CustomSurfaceView.java +0 -29
  47. package/android/src/main/java/com/ahm/capacitor/camera/preview/CustomTextureView.java +0 -39
  48. package/android/src/main/java/com/ahm/capacitor/camera/preview/Preview.java +0 -461
  49. package/android/src/main/java/com/ahm/capacitor/camera/preview/TapGestureDetector.java +0 -24
  50. package/ios/Plugin/Info.plist +0 -24
  51. package/ios/Plugin/Plugin.h +0 -10
  52. package/ios/Plugin/Plugin.m +0 -18
  53. package/ios/Plugin/Plugin.swift +0 -511
  54. package/ios/Plugin.xcodeproj/project.pbxproj +0 -593
  55. package/ios/Plugin.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
  56. package/ios/Plugin.xcworkspace/contents.xcworkspacedata +0 -10
  57. package/ios/Plugin.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
  58. package/ios/PluginTests/Info.plist +0 -22
  59. package/ios/PluginTests/PluginTests.swift +0 -83
  60. package/ios/Podfile +0 -13
  61. package/ios/Podfile.lock +0 -23
package/README.md CHANGED
@@ -3,8 +3,8 @@
3
3
  <a href="https://capgo.app/"><img src='https://raw.githubusercontent.com/Cap-go/capgo/main/assets/capgo_banner.png' alt='Capgo - Instant updates for capacitor'/></a>
4
4
 
5
5
  <div align="center">
6
- <h2><a href="https://capgo.app/?ref=plugin"> ➡️ Get Instant updates for your App with Capgo</a></h2>
7
- <h2><a href="https://capgo.app/consulting/?ref=plugin"> Missing a feature? We’ll build the plugin for you 💪</a></h2>
6
+ <h2><a href="https://capgo.app/?ref=plugin"> ➡️ Get Instant updates for your App with Capgo 🚀</a></h2>
7
+ <h2><a href="https://capgo.app/consulting/?ref=plugin"> Fix your annoying bug now, Hire a Capacitor expert 💪</a></h2>
8
8
  </div>
9
9
 
10
10
  <p>
@@ -92,6 +92,52 @@ Then run
92
92
  npx cap sync
93
93
  ```
94
94
 
95
+ ## Optional Configuration
96
+
97
+ To use certain features of this plugin, you will need to add the following permissions/keys to your native project configurations.
98
+
99
+ ### Android
100
+
101
+ In your `android/app/src/main/AndroidManifest.xml`:
102
+
103
+ - **Audio Recording** (`disableAudio: false`):
104
+ ```xml
105
+ <uses-permission android:name="android.permission.RECORD_AUDIO" />
106
+ ```
107
+
108
+ - **Saving to Gallery** (`saveToGallery: true`):
109
+ ```xml
110
+ <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
111
+ ```
112
+
113
+ - **Location in EXIF Data** (`withExifLocation: true`):
114
+ ```xml
115
+ <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
116
+ <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
117
+ ```
118
+
119
+ ### iOS
120
+
121
+ In your `ios/App/App/Info.plist`, you must provide descriptions for the permissions your app requires. The keys are added automatically, but you need to provide the `string` values.
122
+
123
+ - **Audio Recording** (`disableAudio: false`):
124
+ ```xml
125
+ <key>NSMicrophoneUsageDescription</key>
126
+ <string>To record audio with videos</string>
127
+ ```
128
+
129
+ - **Saving to Gallery** (`saveToGallery: true`):
130
+ ```xml
131
+ <key>NSPhotoLibraryUsageDescription</key>
132
+ <string>To save photos to your gallery</string>
133
+ ```
134
+
135
+ - **Location in EXIF Data** (`withExifLocation: true`):
136
+ ```xml
137
+ <key>NSLocationWhenInUseUsageDescription</key>
138
+ <string>To add location data to your photos</string>
139
+ ```
140
+
95
141
  ## Extra Android installation steps
96
142
 
97
143
  **Important** `camera-preview` 3+ requires Gradle 7.
@@ -174,6 +220,10 @@ Documentation for the [uploader](https://github.com/Cap-go/capacitor-uploader)
174
220
  * [`capture(...)`](#capture)
175
221
  * [`captureSample(...)`](#capturesample)
176
222
  * [`getSupportedFlashModes()`](#getsupportedflashmodes)
223
+ * [`setAspectRatio(...)`](#setaspectratio)
224
+ * [`getAspectRatio()`](#getaspectratio)
225
+ * [`setGridMode(...)`](#setgridmode)
226
+ * [`getGridMode()`](#getgridmode)
177
227
  * [`getHorizontalFov()`](#gethorizontalfov)
178
228
  * [`getSupportedPictureSizes()`](#getsupportedpicturesizes)
179
229
  * [`setFlashMode(...)`](#setflashmode)
@@ -181,25 +231,40 @@ Documentation for the [uploader](https://github.com/Cap-go/capacitor-uploader)
181
231
  * [`setOpacity(...)`](#setopacity)
182
232
  * [`stopRecordVideo()`](#stoprecordvideo)
183
233
  * [`startRecordVideo(...)`](#startrecordvideo)
234
+ * [`isRunning()`](#isrunning)
235
+ * [`getAvailableDevices()`](#getavailabledevices)
236
+ * [`getZoom()`](#getzoom)
237
+ * [`setZoom(...)`](#setzoom)
238
+ * [`getFlashMode()`](#getflashmode)
239
+ * [`removeAllListeners()`](#removealllisteners)
240
+ * [`setDeviceId(...)`](#setdeviceid)
241
+ * [`getDeviceId()`](#getdeviceid)
242
+ * [`getPreviewSize()`](#getpreviewsize)
243
+ * [`setPreviewSize(...)`](#setpreviewsize)
184
244
  * [Interfaces](#interfaces)
185
245
  * [Type Aliases](#type-aliases)
246
+ * [Enums](#enums)
186
247
 
187
248
  </docgen-index>
188
249
 
189
250
  <docgen-api>
190
251
  <!--Update the source file JSDoc comments and rerun docgen to update the docs below-->
191
252
 
253
+ The main interface for the CameraPreview plugin.
254
+
192
255
  ### start(...)
193
256
 
194
257
  ```typescript
195
- start(options: CameraPreviewOptions) => Promise<void>
258
+ start(options: CameraPreviewOptions) => Promise<{ width: number; height: number; x: number; y: number; }>
196
259
  ```
197
260
 
198
- Start the camera preview instance.
261
+ Starts the camera preview.
262
+
263
+ | Param | Type | Description |
264
+ | ------------- | --------------------------------------------------------------------- | ------------------------------------------- |
265
+ | **`options`** | <code><a href="#camerapreviewoptions">CameraPreviewOptions</a></code> | - The configuration for the camera preview. |
199
266
 
200
- | Param | Type | Description |
201
- | ------------- | --------------------------------------------------------------------- | -------------------------------------------- |
202
- | **`options`** | <code><a href="#camerapreviewoptions">CameraPreviewOptions</a></code> | the options to start the camera preview with |
267
+ **Returns:** <code>Promise&lt;{ width: number; height: number; x: number; y: number; }&gt;</code>
203
268
 
204
269
  **Since:** 0.0.1
205
270
 
@@ -212,7 +277,7 @@ Start the camera preview instance.
212
277
  stop() => Promise<void>
213
278
  ```
214
279
 
215
- Stop the camera preview instance.
280
+ Stops the camera preview.
216
281
 
217
282
  **Since:** 0.0.1
218
283
 
@@ -222,16 +287,16 @@ Stop the camera preview instance.
222
287
  ### capture(...)
223
288
 
224
289
  ```typescript
225
- capture(options: CameraPreviewPictureOptions) => Promise<{ value: string; }>
290
+ capture(options: CameraPreviewPictureOptions) => Promise<{ value: string; exif: ExifData; }>
226
291
  ```
227
292
 
228
- Switch camera.
293
+ Captures a picture from the camera.
229
294
 
230
- | Param | Type | Description |
231
- | ------------- | ----------------------------------------------------------------------------------- | ------------------------------------- |
232
- | **`options`** | <code><a href="#camerapreviewpictureoptions">CameraPreviewPictureOptions</a></code> | the options to switch the camera with |
295
+ | Param | Type | Description |
296
+ | ------------- | ----------------------------------------------------------------------------------- | ---------------------------------------- |
297
+ | **`options`** | <code><a href="#camerapreviewpictureoptions">CameraPreviewPictureOptions</a></code> | - The options for capturing the picture. |
233
298
 
234
- **Returns:** <code>Promise&lt;{ value: string; }&gt;</code>
299
+ **Returns:** <code>Promise&lt;{ value: string; exif: <a href="#exifdata">ExifData</a>; }&gt;</code>
235
300
 
236
301
  **Since:** 0.0.1
237
302
 
@@ -244,11 +309,11 @@ Switch camera.
244
309
  captureSample(options: CameraSampleOptions) => Promise<{ value: string; }>
245
310
  ```
246
311
 
247
- Capture a sample image.
312
+ Captures a single frame from the camera preview stream.
248
313
 
249
- | Param | Type | Description |
250
- | ------------- | ------------------------------------------------------------------- | -------------------------------------------- |
251
- | **`options`** | <code><a href="#camerasampleoptions">CameraSampleOptions</a></code> | the options to capture the sample image with |
314
+ | Param | Type | Description |
315
+ | ------------- | ------------------------------------------------------------------- | --------------------------------------- |
316
+ | **`options`** | <code><a href="#camerasampleoptions">CameraSampleOptions</a></code> | - The options for capturing the sample. |
252
317
 
253
318
  **Returns:** <code>Promise&lt;{ value: string; }&gt;</code>
254
319
 
@@ -263,7 +328,7 @@ Capture a sample image.
263
328
  getSupportedFlashModes() => Promise<{ result: CameraPreviewFlashMode[]; }>
264
329
  ```
265
330
 
266
- Get supported flash modes.
331
+ Gets the flash modes supported by the active camera.
267
332
 
268
333
  **Returns:** <code>Promise&lt;{ result: CameraPreviewFlashMode[]; }&gt;</code>
269
334
 
@@ -272,15 +337,82 @@ Get supported flash modes.
272
337
  --------------------
273
338
 
274
339
 
340
+ ### setAspectRatio(...)
341
+
342
+ ```typescript
343
+ setAspectRatio(options: { aspectRatio: '4:3' | '16:9'; x?: number; y?: number; }) => Promise<{ width: number; height: number; x: number; y: number; }>
344
+ ```
345
+
346
+ Set the aspect ratio of the camera preview.
347
+
348
+ | Param | Type | Description |
349
+ | ------------- | ---------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
350
+ | **`options`** | <code>{ aspectRatio: '4:3' \| '16:9'; x?: number; y?: number; }</code> | - The desired aspect ratio and optional position. - aspectRatio: The desired aspect ratio ('4:3' or '16:9') - x: Optional x coordinate for positioning. If not provided, view will be auto-centered horizontally. - y: Optional y coordinate for positioning. If not provided, view will be auto-centered vertically. |
351
+
352
+ **Returns:** <code>Promise&lt;{ width: number; height: number; x: number; y: number; }&gt;</code>
353
+
354
+ **Since:** 7.4.0
355
+
356
+ --------------------
357
+
358
+
359
+ ### getAspectRatio()
360
+
361
+ ```typescript
362
+ getAspectRatio() => Promise<{ aspectRatio: '4:3' | '16:9'; }>
363
+ ```
364
+
365
+ Gets the current aspect ratio of the camera preview.
366
+
367
+ **Returns:** <code>Promise&lt;{ aspectRatio: '4:3' | '16:9'; }&gt;</code>
368
+
369
+ **Since:** 7.4.0
370
+
371
+ --------------------
372
+
373
+
374
+ ### setGridMode(...)
375
+
376
+ ```typescript
377
+ setGridMode(options: { gridMode: GridMode; }) => Promise<void>
378
+ ```
379
+
380
+ Sets the grid mode of the camera preview overlay.
381
+
382
+ | Param | Type | Description |
383
+ | ------------- | ------------------------------------------------------------ | -------------------------------------------------- |
384
+ | **`options`** | <code>{ gridMode: <a href="#gridmode">GridMode</a>; }</code> | - The desired grid mode ('none', '3x3', or '4x4'). |
385
+
386
+ **Since:** 8.0.0
387
+
388
+ --------------------
389
+
390
+
391
+ ### getGridMode()
392
+
393
+ ```typescript
394
+ getGridMode() => Promise<{ gridMode: GridMode; }>
395
+ ```
396
+
397
+ Gets the current grid mode of the camera preview overlay.
398
+
399
+ **Returns:** <code>Promise&lt;{ gridMode: <a href="#gridmode">GridMode</a>; }&gt;</code>
400
+
401
+ **Since:** 8.0.0
402
+
403
+ --------------------
404
+
405
+
275
406
  ### getHorizontalFov()
276
407
 
277
408
  ```typescript
278
- getHorizontalFov() => Promise<{ result: any; }>
409
+ getHorizontalFov() => Promise<{ result: number; }>
279
410
  ```
280
411
 
281
- Get horizontal field of view.
412
+ Gets the horizontal field of view (FoV) for the active camera.
413
+ Note: This can be an estimate on some devices.
282
414
 
283
- **Returns:** <code>Promise&lt;{ result: any; }&gt;</code>
415
+ **Returns:** <code>Promise&lt;{ result: number; }&gt;</code>
284
416
 
285
417
  **Since:** 0.0.1
286
418
 
@@ -290,12 +422,14 @@ Get horizontal field of view.
290
422
  ### getSupportedPictureSizes()
291
423
 
292
424
  ```typescript
293
- getSupportedPictureSizes() => Promise<{ supportedPictureSizes: { facing: string; supportedPictureSizes: { width: number; height: number; }[]; }[]; }>
425
+ getSupportedPictureSizes() => Promise<{ supportedPictureSizes: SupportedPictureSizes[]; }>
294
426
  ```
295
427
 
296
- Gets the supported picture sizes for a given device.
428
+ Gets the supported picture sizes for all cameras.
429
+
430
+ **Returns:** <code>Promise&lt;{ supportedPictureSizes: SupportedPictureSizes[]; }&gt;</code>
297
431
 
298
- **Returns:** <code>Promise&lt;{ supportedPictureSizes: { facing: string; supportedPictureSizes: { width: number; height: number; }[]; }[]; }&gt;</code>
432
+ **Since:** 7.4.0
299
433
 
300
434
  --------------------
301
435
 
@@ -306,11 +440,11 @@ Gets the supported picture sizes for a given device.
306
440
  setFlashMode(options: { flashMode: CameraPreviewFlashMode | string; }) => Promise<void>
307
441
  ```
308
442
 
309
- Set flash mode.
443
+ Sets the flash mode for the active camera.
310
444
 
311
- | Param | Type | Description |
312
- | ------------- | ----------------------------------- | -------------------------------------- |
313
- | **`options`** | <code>{ flashMode: string; }</code> | the options to set the flash mode with |
445
+ | Param | Type | Description |
446
+ | ------------- | ----------------------------------- | ------------------------- |
447
+ | **`options`** | <code>{ flashMode: string; }</code> | - The desired flash mode. |
314
448
 
315
449
  **Since:** 0.0.1
316
450
 
@@ -323,7 +457,7 @@ Set flash mode.
323
457
  flip() => Promise<void>
324
458
  ```
325
459
 
326
- Flip camera.
460
+ Toggles between the front and rear cameras.
327
461
 
328
462
  **Since:** 0.0.1
329
463
 
@@ -336,11 +470,11 @@ Flip camera.
336
470
  setOpacity(options: CameraOpacityOptions) => Promise<void>
337
471
  ```
338
472
 
339
- Set opacity.
473
+ Sets the opacity of the camera preview.
340
474
 
341
- | Param | Type | Description |
342
- | ------------- | --------------------------------------------------------------------- | ------------------------------------------ |
343
- | **`options`** | <code><a href="#cameraopacityoptions">CameraOpacityOptions</a></code> | the options to set the camera opacity with |
475
+ | Param | Type | Description |
476
+ | ------------- | --------------------------------------------------------------------- | ---------------------- |
477
+ | **`options`** | <code><a href="#cameraopacityoptions">CameraOpacityOptions</a></code> | - The opacity options. |
344
478
 
345
479
  **Since:** 0.0.1
346
480
 
@@ -353,7 +487,7 @@ Set opacity.
353
487
  stopRecordVideo() => Promise<{ videoFilePath: string; }>
354
488
  ```
355
489
 
356
- Stop recording video.
490
+ Stops an ongoing video recording.
357
491
 
358
492
  **Returns:** <code>Promise&lt;{ videoFilePath: string; }&gt;</code>
359
493
 
@@ -368,72 +502,308 @@ Stop recording video.
368
502
  startRecordVideo(options: CameraPreviewOptions) => Promise<void>
369
503
  ```
370
504
 
371
- Start recording video.
505
+ Starts recording a video.
372
506
 
373
- | Param | Type | Description |
374
- | ------------- | --------------------------------------------------------------------- | ----------------------------------------- |
375
- | **`options`** | <code><a href="#camerapreviewoptions">CameraPreviewOptions</a></code> | the options to start recording video with |
507
+ | Param | Type | Description |
508
+ | ------------- | --------------------------------------------------------------------- | ---------------------------------- |
509
+ | **`options`** | <code><a href="#camerapreviewoptions">CameraPreviewOptions</a></code> | - The options for video recording. |
376
510
 
377
511
  **Since:** 0.0.1
378
512
 
379
513
  --------------------
380
514
 
381
515
 
516
+ ### isRunning()
517
+
518
+ ```typescript
519
+ isRunning() => Promise<{ isRunning: boolean; }>
520
+ ```
521
+
522
+ Checks if the camera preview is currently running.
523
+
524
+ **Returns:** <code>Promise&lt;{ isRunning: boolean; }&gt;</code>
525
+
526
+ **Since:** 7.4.0
527
+
528
+ --------------------
529
+
530
+
531
+ ### getAvailableDevices()
532
+
533
+ ```typescript
534
+ getAvailableDevices() => Promise<{ devices: CameraDevice[]; }>
535
+ ```
536
+
537
+ Gets all available camera devices.
538
+
539
+ **Returns:** <code>Promise&lt;{ devices: CameraDevice[]; }&gt;</code>
540
+
541
+ **Since:** 7.4.0
542
+
543
+ --------------------
544
+
545
+
546
+ ### getZoom()
547
+
548
+ ```typescript
549
+ getZoom() => Promise<{ min: number; max: number; current: number; lens: LensInfo; }>
550
+ ```
551
+
552
+ Gets the current zoom state, including min/max and current lens info.
553
+
554
+ **Returns:** <code>Promise&lt;{ min: number; max: number; current: number; lens: <a href="#lensinfo">LensInfo</a>; }&gt;</code>
555
+
556
+ **Since:** 7.4.0
557
+
558
+ --------------------
559
+
560
+
561
+ ### setZoom(...)
562
+
563
+ ```typescript
564
+ setZoom(options: { level: number; ramp?: boolean; }) => Promise<void>
565
+ ```
566
+
567
+ Sets the camera's zoom level.
568
+
569
+ | Param | Type | Description |
570
+ | ------------- | ----------------------------------------------- | ----------------------------------------------------- |
571
+ | **`options`** | <code>{ level: number; ramp?: boolean; }</code> | - The desired zoom level. `ramp` is currently unused. |
572
+
573
+ **Since:** 7.4.0
574
+
575
+ --------------------
576
+
577
+
578
+ ### getFlashMode()
579
+
580
+ ```typescript
581
+ getFlashMode() => Promise<{ flashMode: FlashMode; }>
582
+ ```
583
+
584
+ Gets the current flash mode.
585
+
586
+ **Returns:** <code>Promise&lt;{ flashMode: <a href="#camerapreviewflashmode">CameraPreviewFlashMode</a>; }&gt;</code>
587
+
588
+ **Since:** 7.4.0
589
+
590
+ --------------------
591
+
592
+
593
+ ### removeAllListeners()
594
+
595
+ ```typescript
596
+ removeAllListeners() => Promise<void>
597
+ ```
598
+
599
+ Removes all registered listeners.
600
+
601
+ **Since:** 7.4.0
602
+
603
+ --------------------
604
+
605
+
606
+ ### setDeviceId(...)
607
+
608
+ ```typescript
609
+ setDeviceId(options: { deviceId: string; }) => Promise<void>
610
+ ```
611
+
612
+ Switches the active camera to the one with the specified `deviceId`.
613
+
614
+ | Param | Type | Description |
615
+ | ------------- | ---------------------------------- | ------------------------------------ |
616
+ | **`options`** | <code>{ deviceId: string; }</code> | - The ID of the device to switch to. |
617
+
618
+ **Since:** 7.4.0
619
+
620
+ --------------------
621
+
622
+
623
+ ### getDeviceId()
624
+
625
+ ```typescript
626
+ getDeviceId() => Promise<{ deviceId: string; }>
627
+ ```
628
+
629
+ Gets the ID of the currently active camera device.
630
+
631
+ **Returns:** <code>Promise&lt;{ deviceId: string; }&gt;</code>
632
+
633
+ **Since:** 7.4.0
634
+
635
+ --------------------
636
+
637
+
638
+ ### getPreviewSize()
639
+
640
+ ```typescript
641
+ getPreviewSize() => Promise<{ x: number; y: number; width: number; height: number; }>
642
+ ```
643
+
644
+ Gets the current preview size and position.
645
+
646
+ **Returns:** <code>Promise&lt;{ x: number; y: number; width: number; height: number; }&gt;</code>
647
+
648
+ --------------------
649
+
650
+
651
+ ### setPreviewSize(...)
652
+
653
+ ```typescript
654
+ setPreviewSize(options: { x: number; y: number; width: number; height: number; }) => Promise<{ width: number; height: number; x: number; y: number; }>
655
+ ```
656
+
657
+ Sets the preview size and position.
658
+
659
+ | Param | Type | Description |
660
+ | ------------- | --------------------------------------------------------------------- | -------------------------------- |
661
+ | **`options`** | <code>{ x: number; y: number; width: number; height: number; }</code> | The new position and dimensions. |
662
+
663
+ **Returns:** <code>Promise&lt;{ width: number; height: number; x: number; y: number; }&gt;</code>
664
+
665
+ --------------------
666
+
667
+
382
668
  ### Interfaces
383
669
 
384
670
 
385
671
  #### CameraPreviewOptions
386
672
 
387
- | Prop | Type | Description |
388
- | ---------------------------------- | -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
389
- | **`parent`** | <code>string</code> | Parent element to attach the video preview element to (applicable to the web platform only) |
390
- | **`className`** | <code>string</code> | Class name to add to the video preview element (applicable to the web platform only) |
391
- | **`width`** | <code>number</code> | The preview width in pixels, default window.screen.width |
392
- | **`height`** | <code>number</code> | The preview height in pixels, default window.screen.height |
393
- | **`x`** | <code>number</code> | The x origin, default 0 (applicable to the android and ios platforms only) |
394
- | **`y`** | <code>number</code> | The y origin, default 0 (applicable to the android and ios platforms only) |
395
- | **`includeSafeAreaInsets`** | <code>boolean</code> | Whether to include safe area insets in y-position calculation, default false (applicable to the ios platform only) |
396
- | **`toBack`** | <code>boolean</code> | Brings your html in front of your preview, default false (applicable to the android only) |
397
- | **`paddingBottom`** | <code>number</code> | The preview bottom padding in pixes. Useful to keep the appropriate preview sizes when orientation changes (applicable to the android and ios platforms only) |
398
- | **`rotateWhenOrientationChanged`** | <code>boolean</code> | Rotate preview when orientation changes (applicable to the ios platforms only; default value is true) |
399
- | **`position`** | <code>string</code> | Choose the camera to use 'front' or 'rear', default 'front' |
400
- | **`storeToFile`** | <code>boolean</code> | Defaults to false - Capture images to a file and return the file path instead of returning base64 encoded data |
401
- | **`disableExifHeaderStripping`** | <code>boolean</code> | Defaults to false - Android Only - Disable automatic rotation of the image, and let the browser deal with it (keep reading on how to achieve it) |
402
- | **`enableHighResolution`** | <code>boolean</code> | Defaults to false - iOS only - Activate high resolution image capture so that output images are from the highest resolution possible on the device * |
403
- | **`disableAudio`** | <code>boolean</code> | Defaults to false - Disables audio stream to prevent permission requests and output switching |
404
- | **`lockAndroidOrientation`** | <code>boolean</code> | Android Only - Locks device orientation when camera is showing. |
405
- | **`enableOpacity`** | <code>boolean</code> | Defaults to false - Android and Web only. Set if camera preview can change opacity. |
406
- | **`enableZoom`** | <code>boolean</code> | Defaults to false - Android only. Set if camera preview will support pinch to zoom. |
407
- | **`cameraMode`** | <code>boolean</code> | default to false - IOS only. Set the CameraPreview to use the video mode preset |
673
+ Defines the configuration options for starting the camera preview.
674
+
675
+ | Prop | Type | Description | Default | Since |
676
+ | ---------------------------------- | --------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------- | ----- |
677
+ | **`parent`** | <code>string</code> | The parent element to attach the video preview to. | | |
678
+ | **`className`** | <code>string</code> | A CSS class name to add to the preview element. | | |
679
+ | **`width`** | <code>number</code> | The width of the preview in pixels. Defaults to the screen width. | | |
680
+ | **`height`** | <code>number</code> | The height of the preview in pixels. Defaults to the screen height. | | |
681
+ | **`x`** | <code>number</code> | The horizontal origin of the preview, in pixels. | | |
682
+ | **`y`** | <code>number</code> | The vertical origin of the preview, in pixels. | | |
683
+ | **`aspectRatio`** | <code>'4:3' \| '16:9' \| 'fill'</code> | The aspect ratio of the camera preview, '4:3' or '16:9' or 'fill'. Cannot be set if width or height is provided, otherwise the call will be rejected. Use setPreviewSize to adjust size after starting. | | 2.0.0 |
684
+ | **`gridMode`** | <code><a href="#gridmode">GridMode</a></code> | The grid overlay to display on the camera preview. | <code>"none"</code> | 2.1.0 |
685
+ | **`includeSafeAreaInsets`** | <code>boolean</code> | Adjusts the y-position to account for safe areas (e.g., notches). | <code>false</code> | |
686
+ | **`toBack`** | <code>boolean</code> | If true, places the preview behind the webview. | <code>true</code> | |
687
+ | **`paddingBottom`** | <code>number</code> | Bottom padding for the preview, in pixels. | | |
688
+ | **`rotateWhenOrientationChanged`** | <code>boolean</code> | Whether to rotate the preview when the device orientation changes. | <code>true</code> | |
689
+ | **`position`** | <code>string</code> | The camera to use. | <code>"rear"</code> | |
690
+ | **`storeToFile`** | <code>boolean</code> | If true, saves the captured image to a file and returns the file path. If false, returns a base64 encoded string. | <code>false</code> | |
691
+ | **`disableExifHeaderStripping`** | <code>boolean</code> | If true, prevents the plugin from rotating the image based on EXIF data. | <code>false</code> | |
692
+ | **`enableHighResolution`** | <code>boolean</code> | If true, enables high-resolution image capture. | <code>false</code> | |
693
+ | **`disableAudio`** | <code>boolean</code> | If true, disables the audio stream, preventing audio permission requests. | <code>true</code> | |
694
+ | **`lockAndroidOrientation`** | <code>boolean</code> | If true, locks the device orientation while the camera is active. | <code>false</code> | |
695
+ | **`enableOpacity`** | <code>boolean</code> | If true, allows the camera preview's opacity to be changed. | <code>false</code> | |
696
+ | **`enableZoom`** | <code>boolean</code> | If true, enables pinch-to-zoom functionality on the preview. | <code>false</code> | |
697
+ | **`enableVideoMode`** | <code>boolean</code> | If true, uses the video-optimized preset for the camera session. | <code>false</code> | |
698
+ | **`deviceId`** | <code>string</code> | The `deviceId` of the camera to use. If provided, `position` is ignored. | | |
699
+
700
+
701
+ #### ExifData
702
+
703
+ Represents EXIF data extracted from an image.
408
704
 
409
705
 
410
706
  #### CameraPreviewPictureOptions
411
707
 
412
- | Prop | Type | Description |
413
- | ------------- | ------------------------------------------------------- | ------------------------------------------------------------------------------------ |
414
- | **`height`** | <code>number</code> | The picture height, optional, default 0 (Device default) |
415
- | **`width`** | <code>number</code> | The picture width, optional, default 0 (Device default) |
416
- | **`quality`** | <code>number</code> | The picture quality, 0 - 100, default 85 |
417
- | **`format`** | <code><a href="#pictureformat">PictureFormat</a></code> | The picture format, jpeg or png, default jpeg on `Web`. quality has no effect on png |
708
+ Defines the options for capturing a picture.
709
+
710
+ | Prop | Type | Description | Default | Since |
711
+ | ---------------------- | ------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ | ------------------- | ----- |
712
+ | **`height`** | <code>number</code> | The desired height of the picture in pixels. If not provided, the device default is used. | | |
713
+ | **`width`** | <code>number</code> | The desired width of the picture in pixels. If not provided, the device default is used. | | |
714
+ | **`quality`** | <code>number</code> | The quality of the captured image, from 0 to 100. Does not apply to `png` format. | <code>85</code> | |
715
+ | **`format`** | <code><a href="#pictureformat">PictureFormat</a></code> | The format of the captured image. | <code>"jpeg"</code> | |
716
+ | **`saveToGallery`** | <code>boolean</code> | If true, the captured image will be saved to the user's gallery. | <code>false</code> | 7.5.0 |
717
+ | **`withExifLocation`** | <code>boolean</code> | If true, the plugin will attempt to add GPS location data to the image's EXIF metadata. This may prompt the user for location permissions. | <code>false</code> | 7.6.0 |
418
718
 
419
719
 
420
720
  #### CameraSampleOptions
421
721
 
422
- | Prop | Type | Description |
423
- | ------------- | ------------------- | ---------------------------------------- |
424
- | **`quality`** | <code>number</code> | The picture quality, 0 - 100, default 85 |
722
+ Defines the options for capturing a sample frame from the camera preview.
723
+
724
+ | Prop | Type | Description | Default |
725
+ | ------------- | ------------------- | -------------------------------------------------- | --------------- |
726
+ | **`quality`** | <code>number</code> | The quality of the captured sample, from 0 to 100. | <code>85</code> |
727
+
728
+
729
+ #### SupportedPictureSizes
730
+
731
+ Represents the supported picture sizes for a camera facing a certain direction.
732
+
733
+ | Prop | Type | Description |
734
+ | --------------------------- | -------------------------- | -------------------------------------------------- |
735
+ | **`facing`** | <code>string</code> | The camera direction ("front" or "rear"). |
736
+ | **`supportedPictureSizes`** | <code>PictureSize[]</code> | A list of supported picture sizes for this camera. |
737
+
738
+
739
+ #### PictureSize
740
+
741
+ Defines a standard picture size with width and height.
742
+
743
+ | Prop | Type | Description |
744
+ | ------------ | ------------------- | ------------------------------------ |
745
+ | **`width`** | <code>number</code> | The width of the picture in pixels. |
746
+ | **`height`** | <code>number</code> | The height of the picture in pixels. |
425
747
 
426
748
 
427
749
  #### CameraOpacityOptions
428
750
 
429
- | Prop | Type | Description |
430
- | ------------- | ------------------- | ----------------------------------------------------- |
431
- | **`opacity`** | <code>number</code> | The percent opacity to set for camera view, default 1 |
751
+ Defines the options for setting the camera preview's opacity.
752
+
753
+ | Prop | Type | Description | Default |
754
+ | ------------- | ------------------- | --------------------------------------------------------------------------- | ---------------- |
755
+ | **`opacity`** | <code>number</code> | The opacity percentage, from 0.0 (fully transparent) to 1.0 (fully opaque). | <code>1.0</code> |
756
+
757
+
758
+ #### CameraDevice
759
+
760
+ Represents a physical camera on the device (e.g., the front-facing camera).
761
+
762
+ | Prop | Type | Description |
763
+ | --------------- | --------------------------------------------------------- | ----------------------------------------------------------------------------------------- |
764
+ | **`deviceId`** | <code>string</code> | A unique identifier for the camera device. |
765
+ | **`label`** | <code>string</code> | A human-readable name for the camera device. |
766
+ | **`position`** | <code><a href="#cameraposition">CameraPosition</a></code> | The physical position of the camera on the device. |
767
+ | **`lenses`** | <code>CameraLens[]</code> | A list of all available lenses for this camera device. |
768
+ | **`minZoom`** | <code>number</code> | The overall minimum zoom factor available across all lenses on this device. |
769
+ | **`maxZoom`** | <code>number</code> | The overall maximum zoom factor available across all lenses on this device. |
770
+ | **`isLogical`** | <code>boolean</code> | Identifies whether the device is a logical camera (composed of multiple physical lenses). |
771
+
772
+
773
+ #### CameraLens
774
+
775
+ Represents a single camera lens on a device. A {@link <a href="#cameradevice">CameraDevice</a>} can have multiple lenses.
776
+
777
+ | Prop | Type | Description |
778
+ | ------------------- | ------------------------------------------------- | ---------------------------------------------------------------------------- |
779
+ | **`label`** | <code>string</code> | A human-readable name for the lens, e.g., "Ultra-Wide". |
780
+ | **`deviceType`** | <code><a href="#devicetype">DeviceType</a></code> | The type of the camera lens. |
781
+ | **`focalLength`** | <code>number</code> | The focal length of the lens in millimeters. |
782
+ | **`baseZoomRatio`** | <code>number</code> | The base zoom factor for this lens (e.g., 0.5 for ultra-wide, 1.0 for wide). |
783
+ | **`minZoom`** | <code>number</code> | The minimum zoom factor supported by this specific lens. |
784
+ | **`maxZoom`** | <code>number</code> | The maximum zoom factor supported by this specific lens. |
785
+
786
+
787
+ #### LensInfo
788
+
789
+ Represents the detailed information of the currently active lens.
790
+
791
+ | Prop | Type | Description |
792
+ | ------------------- | ------------------------------------------------- | ---------------------------------------------------------------- |
793
+ | **`focalLength`** | <code>number</code> | The focal length of the active lens in millimeters. |
794
+ | **`deviceType`** | <code><a href="#devicetype">DeviceType</a></code> | The device type of the active lens. |
795
+ | **`baseZoomRatio`** | <code>number</code> | The base zoom ratio of the active lens (e.g., 0.5x, 1.0x). |
796
+ | **`digitalZoom`** | <code>number</code> | The current digital zoom factor applied on top of the base zoom. |
432
797
 
433
798
 
434
799
  ### Type Aliases
435
800
 
436
801
 
802
+ #### GridMode
803
+
804
+ <code>"none" | "3x3" | "4x4"</code>
805
+
806
+
437
807
  #### CameraPosition
438
808
 
439
809
  <code>"rear" | "front"</code>
@@ -446,6 +816,30 @@ Start recording video.
446
816
 
447
817
  #### CameraPreviewFlashMode
448
818
 
449
- <code>"off" | "on" | "auto" | "red-eye" | "torch"</code>
819
+ The available flash modes for the camera.
820
+ 'torch' is a continuous light mode.
821
+
822
+ <code>"off" | "on" | "auto" | "torch"</code>
823
+
824
+
825
+ #### FlashMode
826
+
827
+ <code><a href="#camerapreviewflashmode">CameraPreviewFlashMode</a></code>
828
+
829
+
830
+ ### Enums
831
+
832
+
833
+ #### DeviceType
834
+
835
+ | Members | Value |
836
+ | ---------------- | ------------------------ |
837
+ | **`ULTRA_WIDE`** | <code>"ultraWide"</code> |
838
+ | **`WIDE_ANGLE`** | <code>"wideAngle"</code> |
839
+ | **`TELEPHOTO`** | <code>"telephoto"</code> |
840
+ | **`TRUE_DEPTH`** | <code>"trueDepth"</code> |
841
+ | **`DUAL`** | <code>"dual"</code> |
842
+ | **`DUAL_WIDE`** | <code>"dualWide"</code> |
843
+ | **`TRIPLE`** | <code>"triple"</code> |
450
844
 
451
845
  </docgen-api>