@capgo/camera-preview 7.4.0-alpha.3 → 7.4.0-alpha.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -37,7 +37,7 @@ Take into account that this will make transparent all ion-content on application
37
37
  ```
38
38
 
39
39
  If the camera preview is not displaying after applying the above styles, apply transparent background color to the root div element of the parent component
40
- Ex: VueJS >> App.vue component
40
+ Ex: VueJS >> App.vue component
41
41
  ```html
42
42
  <template>
43
43
  <ion-app id="app">
@@ -76,6 +76,24 @@ Video and photo taken with the plugin are never removed, so do not forget to rem
76
76
  use https://capacitorjs.com/docs/apis/filesystem#deletefile for that
77
77
 
78
78
 
79
+ ## Fast base64 from file path (no bridge)
80
+
81
+ When using `storeToFile: true`, you can avoid sending large base64 strings over the Capacitor bridge:
82
+
83
+ ```ts
84
+ import { CameraPreview, getBase64FromFilePath } from '@capgo/camera-preview'
85
+
86
+ // Take a picture and get a file path
87
+ const { value: filePath } = await CameraPreview.capture({ quality: 85, storeToFile: true })
88
+
89
+ // Convert the file to base64 entirely on the JS side (fast, no bridge)
90
+ const base64 = await getBase64FromFilePath(filePath)
91
+
92
+ // Optionally cleanup the temp file natively
93
+ await CameraPreview.deleteFile({ path: filePath })
94
+ ```
95
+
96
+
79
97
  # Installation
80
98
 
81
99
  ```
@@ -234,6 +252,7 @@ Documentation for the [uploader](https://github.com/Cap-go/capacitor-uploader)
234
252
  * [`isRunning()`](#isrunning)
235
253
  * [`getAvailableDevices()`](#getavailabledevices)
236
254
  * [`getZoom()`](#getzoom)
255
+ * [`getZoomButtonValues()`](#getzoombuttonvalues)
237
256
  * [`setZoom(...)`](#setzoom)
238
257
  * [`getFlashMode()`](#getflashmode)
239
258
  * [`removeAllListeners()`](#removealllisteners)
@@ -242,6 +261,11 @@ Documentation for the [uploader](https://github.com/Cap-go/capacitor-uploader)
242
261
  * [`getPreviewSize()`](#getpreviewsize)
243
262
  * [`setPreviewSize(...)`](#setpreviewsize)
244
263
  * [`setFocus(...)`](#setfocus)
264
+ * [`addListener('screenResize', ...)`](#addlistenerscreenresize-)
265
+ * [`addListener('orientationChange', ...)`](#addlistenerorientationchange-)
266
+ * [`deleteFile(...)`](#deletefile)
267
+ * [`getSafeAreaInsets()`](#getsafeareainsets)
268
+ * [`getOrientation()`](#getorientation)
245
269
  * [Interfaces](#interfaces)
246
270
  * [Type Aliases](#type-aliases)
247
271
  * [Enums](#enums)
@@ -352,7 +376,7 @@ Set the aspect ratio of the camera preview.
352
376
 
353
377
  **Returns:** <code>Promise&lt;{ width: number; height: number; x: number; y: number; }&gt;</code>
354
378
 
355
- **Since:** 7.4.0
379
+ **Since:** 7.5.0
356
380
 
357
381
  --------------------
358
382
 
@@ -367,7 +391,7 @@ Gets the current aspect ratio of the camera preview.
367
391
 
368
392
  **Returns:** <code>Promise&lt;{ aspectRatio: '4:3' | '16:9'; }&gt;</code>
369
393
 
370
- **Since:** 7.4.0
394
+ **Since:** 7.5.0
371
395
 
372
396
  --------------------
373
397
 
@@ -524,7 +548,7 @@ Checks if the camera preview is currently running.
524
548
 
525
549
  **Returns:** <code>Promise&lt;{ isRunning: boolean; }&gt;</code>
526
550
 
527
- **Since:** 7.4.0
551
+ **Since:** 7.5.0
528
552
 
529
553
  --------------------
530
554
 
@@ -539,7 +563,7 @@ Gets all available camera devices.
539
563
 
540
564
  **Returns:** <code>Promise&lt;{ devices: CameraDevice[]; }&gt;</code>
541
565
 
542
- **Since:** 7.4.0
566
+ **Since:** 7.5.0
543
567
 
544
568
  --------------------
545
569
 
@@ -554,7 +578,24 @@ Gets the current zoom state, including min/max and current lens info.
554
578
 
555
579
  **Returns:** <code>Promise&lt;{ min: number; max: number; current: number; lens: <a href="#lensinfo">LensInfo</a>; }&gt;</code>
556
580
 
557
- **Since:** 7.4.0
581
+ **Since:** 7.5.0
582
+
583
+ --------------------
584
+
585
+
586
+ ### getZoomButtonValues()
587
+
588
+ ```typescript
589
+ getZoomButtonValues() => Promise<{ values: number[]; }>
590
+ ```
591
+
592
+ Returns zoom button values for quick switching.
593
+ - iOS/Android: includes 0.5 if ultra-wide available; 1 and 2 if wide available; 3 if telephoto available
594
+ - Web: unsupported
595
+
596
+ **Returns:** <code>Promise&lt;{ values: number[]; }&gt;</code>
597
+
598
+ **Since:** 7.5.0
558
599
 
559
600
  --------------------
560
601
 
@@ -571,7 +612,7 @@ Sets the zoom level of the camera.
571
612
  | ------------- | -------------------------------------------------------------------- | ----------------------------------------------------------------------------------- |
572
613
  | **`options`** | <code>{ level: number; ramp?: boolean; autoFocus?: boolean; }</code> | - The desired zoom level. `ramp` is currently unused. `autoFocus` defaults to true. |
573
614
 
574
- **Since:** 7.4.0
615
+ **Since:** 7.5.0
575
616
 
576
617
  --------------------
577
618
 
@@ -586,7 +627,7 @@ Gets the current flash mode.
586
627
 
587
628
  **Returns:** <code>Promise&lt;{ flashMode: <a href="#camerapreviewflashmode">CameraPreviewFlashMode</a>; }&gt;</code>
588
629
 
589
- **Since:** 7.4.0
630
+ **Since:** 7.5.0
590
631
 
591
632
  --------------------
592
633
 
@@ -599,7 +640,7 @@ removeAllListeners() => Promise<void>
599
640
 
600
641
  Removes all registered listeners.
601
642
 
602
- **Since:** 7.4.0
643
+ **Since:** 7.5.0
603
644
 
604
645
  --------------------
605
646
 
@@ -616,7 +657,7 @@ Switches the active camera to the one with the specified `deviceId`.
616
657
  | ------------- | ---------------------------------- | ------------------------------------ |
617
658
  | **`options`** | <code>{ deviceId: string; }</code> | - The ID of the device to switch to. |
618
659
 
619
- **Since:** 7.4.0
660
+ **Since:** 7.5.0
620
661
 
621
662
  --------------------
622
663
 
@@ -631,7 +672,7 @@ Gets the ID of the currently active camera device.
631
672
 
632
673
  **Returns:** <code>Promise&lt;{ deviceId: string; }&gt;</code>
633
674
 
634
- **Since:** 7.4.0
675
+ **Since:** 7.5.0
635
676
 
636
677
  --------------------
637
678
 
@@ -646,6 +687,8 @@ Gets the current preview size and position.
646
687
 
647
688
  **Returns:** <code>Promise&lt;{ x: number; y: number; width: number; height: number; }&gt;</code>
648
689
 
690
+ **Since:** 7.5.0
691
+
649
692
  --------------------
650
693
 
651
694
 
@@ -663,6 +706,8 @@ Sets the preview size and position.
663
706
 
664
707
  **Returns:** <code>Promise&lt;{ width: number; height: number; x: number; y: number; }&gt;</code>
665
708
 
709
+ **Since:** 7.5.0
710
+
666
711
  --------------------
667
712
 
668
713
 
@@ -678,7 +723,103 @@ Sets the camera focus to a specific point in the preview.
678
723
  | ------------- | -------------------------------------- | -------------------- |
679
724
  | **`options`** | <code>{ x: number; y: number; }</code> | - The focus options. |
680
725
 
681
- **Since:** 8.1.0
726
+ **Since:** 7.5.0
727
+
728
+ --------------------
729
+
730
+
731
+ ### addListener('screenResize', ...)
732
+
733
+ ```typescript
734
+ addListener(eventName: "screenResize", listenerFunc: (data: { width: number; height: number; x: number; y: number; }) => void) => Promise<PluginListenerHandle>
735
+ ```
736
+
737
+ Adds a listener for screen resize events.
738
+
739
+ | Param | Type | Description |
740
+ | ------------------ | ---------------------------------------------------------------------------------------- | --------------------------------------------------- |
741
+ | **`eventName`** | <code>'screenResize'</code> | - The event name to listen for. |
742
+ | **`listenerFunc`** | <code>(data: { width: number; height: number; x: number; y: number; }) =&gt; void</code> | - The function to call when the event is triggered. |
743
+
744
+ **Returns:** <code>Promise&lt;<a href="#pluginlistenerhandle">PluginListenerHandle</a>&gt;</code>
745
+
746
+ **Since:** 7.5.0
747
+
748
+ --------------------
749
+
750
+
751
+ ### addListener('orientationChange', ...)
752
+
753
+ ```typescript
754
+ addListener(eventName: "orientationChange", listenerFunc: (data: { orientation: DeviceOrientation; }) => void) => Promise<PluginListenerHandle>
755
+ ```
756
+
757
+ Adds a listener for orientation change events.
758
+
759
+ | Param | Type | Description |
760
+ | ------------------ | ---------------------------------------------------------------------------------------------------- | --------------------------------------------------- |
761
+ | **`eventName`** | <code>'orientationChange'</code> | - The event name to listen for. |
762
+ | **`listenerFunc`** | <code>(data: { orientation: <a href="#deviceorientation">DeviceOrientation</a>; }) =&gt; void</code> | - The function to call when the event is triggered. |
763
+
764
+ **Returns:** <code>Promise&lt;<a href="#pluginlistenerhandle">PluginListenerHandle</a>&gt;</code>
765
+
766
+ **Since:** 7.5.0
767
+
768
+ --------------------
769
+
770
+
771
+ ### deleteFile(...)
772
+
773
+ ```typescript
774
+ deleteFile(options: { path: string; }) => Promise<{ success: boolean; }>
775
+ ```
776
+
777
+ Deletes a file at the given absolute path on the device.
778
+ Use this to quickly clean up temporary images created with `storeToFile`.
779
+ On web, this is not supported and will throw.
780
+
781
+ | Param | Type |
782
+ | ------------- | ------------------------------ |
783
+ | **`options`** | <code>{ path: string; }</code> |
784
+
785
+ **Returns:** <code>Promise&lt;{ success: boolean; }&gt;</code>
786
+
787
+ **Since:** 7.5.0
788
+
789
+ --------------------
790
+
791
+
792
+ ### getSafeAreaInsets()
793
+
794
+ ```typescript
795
+ getSafeAreaInsets() => Promise<SafeAreaInsets>
796
+ ```
797
+
798
+ Gets the safe area insets for devices.
799
+ Returns the orientation-aware notch/camera cutout inset and the current orientation.
800
+ In portrait mode: returns top inset (notch at top).
801
+ In landscape mode: returns left inset (notch moved to side).
802
+ This specifically targets the cutout area (notch, punch hole, etc.) that all modern phones have.
803
+
804
+ Android: Values returned in dp (logical pixels).
805
+ iOS: Values returned in physical pixels, excluding status bar (only pure notch/cutout size).
806
+
807
+ **Returns:** <code>Promise&lt;<a href="#safeareainsets">SafeAreaInsets</a>&gt;</code>
808
+
809
+ --------------------
810
+
811
+
812
+ ### getOrientation()
813
+
814
+ ```typescript
815
+ getOrientation() => Promise<{ orientation: DeviceOrientation; }>
816
+ ```
817
+
818
+ Gets the current device orientation in a cross-platform format.
819
+
820
+ **Returns:** <code>Promise&lt;{ orientation: <a href="#deviceorientation">DeviceOrientation</a>; }&gt;</code>
821
+
822
+ **Since:** 7.5.0
682
823
 
683
824
  --------------------
684
825
 
@@ -816,6 +957,25 @@ Represents the detailed information of the currently active lens.
816
957
  | **`digitalZoom`** | <code>number</code> | The current digital zoom factor applied on top of the base zoom. |
817
958
 
818
959
 
960
+ #### PluginListenerHandle
961
+
962
+ | Prop | Type |
963
+ | ------------ | ----------------------------------------- |
964
+ | **`remove`** | <code>() =&gt; Promise&lt;void&gt;</code> |
965
+
966
+
967
+ #### SafeAreaInsets
968
+
969
+ Represents safe area insets for devices.
970
+ Android: Values are expressed in logical pixels (dp) to match JS layout units.
971
+ iOS: Values are expressed in physical pixels and exclude status bar.
972
+
973
+ | Prop | Type | Description |
974
+ | ----------------- | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
975
+ | **`orientation`** | <code>number</code> | Current device orientation (1 = portrait, 2 = landscape, 0 = unknown). |
976
+ | **`top`** | <code>number</code> | Orientation-aware notch/camera cutout inset (excluding status bar). In portrait mode: returns top inset (notch at top). In landscape mode: returns left inset (notch at side). Android: Value in dp, iOS: Value in pixels (status bar excluded). |
977
+
978
+
819
979
  ### Type Aliases
820
980
 
821
981
 
@@ -852,6 +1012,13 @@ The available flash modes for the camera.
852
1012
  <code><a href="#camerapreviewflashmode">CameraPreviewFlashMode</a></code>
853
1013
 
854
1014
 
1015
+ #### DeviceOrientation
1016
+
1017
+ Canonical device orientation values across platforms.
1018
+
1019
+ <code>"portrait" | "landscape" | "landscape-left" | "landscape-right" | "portrait-upside-down" | "unknown"</code>
1020
+
1021
+
855
1022
  ### Enums
856
1023
 
857
1024