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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -262,8 +262,10 @@ Documentation for the [uploader](https://github.com/Cap-go/capacitor-uploader)
262
262
  * [`setPreviewSize(...)`](#setpreviewsize)
263
263
  * [`setFocus(...)`](#setfocus)
264
264
  * [`addListener('screenResize', ...)`](#addlistenerscreenresize-)
265
+ * [`addListener('orientationChange', ...)`](#addlistenerorientationchange-)
265
266
  * [`deleteFile(...)`](#deletefile)
266
267
  * [`getSafeAreaInsets()`](#getsafeareainsets)
268
+ * [`getOrientation()`](#getorientation)
267
269
  * [Interfaces](#interfaces)
268
270
  * [Type Aliases](#type-aliases)
269
271
  * [Enums](#enums)
@@ -374,7 +376,7 @@ Set the aspect ratio of the camera preview.
374
376
 
375
377
  **Returns:** <code>Promise&lt;{ width: number; height: number; x: number; y: number; }&gt;</code>
376
378
 
377
- **Since:** 7.4.0
379
+ **Since:** 7.5.0
378
380
 
379
381
  --------------------
380
382
 
@@ -389,7 +391,7 @@ Gets the current aspect ratio of the camera preview.
389
391
 
390
392
  **Returns:** <code>Promise&lt;{ aspectRatio: '4:3' | '16:9'; }&gt;</code>
391
393
 
392
- **Since:** 7.4.0
394
+ **Since:** 7.5.0
393
395
 
394
396
  --------------------
395
397
 
@@ -546,7 +548,7 @@ Checks if the camera preview is currently running.
546
548
 
547
549
  **Returns:** <code>Promise&lt;{ isRunning: boolean; }&gt;</code>
548
550
 
549
- **Since:** 7.4.0
551
+ **Since:** 7.5.0
550
552
 
551
553
  --------------------
552
554
 
@@ -561,7 +563,7 @@ Gets all available camera devices.
561
563
 
562
564
  **Returns:** <code>Promise&lt;{ devices: CameraDevice[]; }&gt;</code>
563
565
 
564
- **Since:** 7.4.0
566
+ **Since:** 7.5.0
565
567
 
566
568
  --------------------
567
569
 
@@ -576,7 +578,7 @@ Gets the current zoom state, including min/max and current lens info.
576
578
 
577
579
  **Returns:** <code>Promise&lt;{ min: number; max: number; current: number; lens: <a href="#lensinfo">LensInfo</a>; }&gt;</code>
578
580
 
579
- **Since:** 7.4.0
581
+ **Since:** 7.5.0
580
582
 
581
583
  --------------------
582
584
 
@@ -593,6 +595,8 @@ Returns zoom button values for quick switching.
593
595
 
594
596
  **Returns:** <code>Promise&lt;{ values: number[]; }&gt;</code>
595
597
 
598
+ **Since:** 7.5.0
599
+
596
600
  --------------------
597
601
 
598
602
 
@@ -608,7 +612,7 @@ Sets the zoom level of the camera.
608
612
  | ------------- | -------------------------------------------------------------------- | ----------------------------------------------------------------------------------- |
609
613
  | **`options`** | <code>{ level: number; ramp?: boolean; autoFocus?: boolean; }</code> | - The desired zoom level. `ramp` is currently unused. `autoFocus` defaults to true. |
610
614
 
611
- **Since:** 7.4.0
615
+ **Since:** 7.5.0
612
616
 
613
617
  --------------------
614
618
 
@@ -623,7 +627,7 @@ Gets the current flash mode.
623
627
 
624
628
  **Returns:** <code>Promise&lt;{ flashMode: <a href="#camerapreviewflashmode">CameraPreviewFlashMode</a>; }&gt;</code>
625
629
 
626
- **Since:** 7.4.0
630
+ **Since:** 7.5.0
627
631
 
628
632
  --------------------
629
633
 
@@ -636,7 +640,7 @@ removeAllListeners() => Promise<void>
636
640
 
637
641
  Removes all registered listeners.
638
642
 
639
- **Since:** 7.4.0
643
+ **Since:** 7.5.0
640
644
 
641
645
  --------------------
642
646
 
@@ -653,7 +657,7 @@ Switches the active camera to the one with the specified `deviceId`.
653
657
  | ------------- | ---------------------------------- | ------------------------------------ |
654
658
  | **`options`** | <code>{ deviceId: string; }</code> | - The ID of the device to switch to. |
655
659
 
656
- **Since:** 7.4.0
660
+ **Since:** 7.5.0
657
661
 
658
662
  --------------------
659
663
 
@@ -668,7 +672,7 @@ Gets the ID of the currently active camera device.
668
672
 
669
673
  **Returns:** <code>Promise&lt;{ deviceId: string; }&gt;</code>
670
674
 
671
- **Since:** 7.4.0
675
+ **Since:** 7.5.0
672
676
 
673
677
  --------------------
674
678
 
@@ -683,6 +687,8 @@ Gets the current preview size and position.
683
687
 
684
688
  **Returns:** <code>Promise&lt;{ x: number; y: number; width: number; height: number; }&gt;</code>
685
689
 
690
+ **Since:** 7.5.0
691
+
686
692
  --------------------
687
693
 
688
694
 
@@ -700,6 +706,8 @@ Sets the preview size and position.
700
706
 
701
707
  **Returns:** <code>Promise&lt;{ width: number; height: number; x: number; y: number; }&gt;</code>
702
708
 
709
+ **Since:** 7.5.0
710
+
703
711
  --------------------
704
712
 
705
713
 
@@ -715,7 +723,7 @@ Sets the camera focus to a specific point in the preview.
715
723
  | ------------- | -------------------------------------- | -------------------- |
716
724
  | **`options`** | <code>{ x: number; y: number; }</code> | - The focus options. |
717
725
 
718
- **Since:** 8.1.0
726
+ **Since:** 7.5.0
719
727
 
720
728
  --------------------
721
729
 
@@ -726,13 +734,37 @@ Sets the camera focus to a specific point in the preview.
726
734
  addListener(eventName: "screenResize", listenerFunc: (data: { width: number; height: number; x: number; y: number; }) => void) => Promise<PluginListenerHandle>
727
735
  ```
728
736
 
729
- | Param | Type |
730
- | ------------------ | ---------------------------------------------------------------------------------------- |
731
- | **`eventName`** | <code>'screenResize'</code> |
732
- | **`listenerFunc`** | <code>(data: { width: number; height: number; x: number; y: number; }) =&gt; void</code> |
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. |
733
743
 
734
744
  **Returns:** <code>Promise&lt;<a href="#pluginlistenerhandle">PluginListenerHandle</a>&gt;</code>
735
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
+
736
768
  --------------------
737
769
 
738
770
 
@@ -752,7 +784,7 @@ On web, this is not supported and will throw.
752
784
 
753
785
  **Returns:** <code>Promise&lt;{ success: boolean; }&gt;</code>
754
786
 
755
- **Since:** 8.2.0
787
+ **Since:** 7.5.0
756
788
 
757
789
  --------------------
758
790
 
@@ -771,6 +803,21 @@ Returns the top and bottom insets in dp and the current orientation.
771
803
  --------------------
772
804
 
773
805
 
806
+ ### getOrientation()
807
+
808
+ ```typescript
809
+ getOrientation() => Promise<{ orientation: DeviceOrientation; }>
810
+ ```
811
+
812
+ Gets the current device orientation in a cross-platform format.
813
+
814
+ **Returns:** <code>Promise&lt;{ orientation: <a href="#deviceorientation">DeviceOrientation</a>; }&gt;</code>
815
+
816
+ **Since:** 7.5.0
817
+
818
+ --------------------
819
+
820
+
774
821
  ### Interfaces
775
822
 
776
823
 
@@ -959,6 +1006,13 @@ The available flash modes for the camera.
959
1006
  <code><a href="#camerapreviewflashmode">CameraPreviewFlashMode</a></code>
960
1007
 
961
1008
 
1009
+ #### DeviceOrientation
1010
+
1011
+ Canonical device orientation values across platforms.
1012
+
1013
+ <code>"portrait" | "landscape" | "landscape-left" | "landscape-right" | "portrait-upside-down" | "unknown"</code>
1014
+
1015
+
962
1016
  ### Enums
963
1017
 
964
1018
 
@@ -77,6 +77,26 @@ public class CameraPreview
77
77
  private OrientationEventListener orientationListener;
78
78
  private int lastOrientation = Configuration.ORIENTATION_UNDEFINED;
79
79
 
80
+ @PluginMethod
81
+ public void getOrientation(PluginCall call) {
82
+ int orientation = getContext()
83
+ .getResources()
84
+ .getConfiguration()
85
+ .orientation;
86
+ String o;
87
+ if (orientation == Configuration.ORIENTATION_PORTRAIT) {
88
+ // We don't distinguish upside-down reliably on Android, report generic portrait
89
+ o = "portrait";
90
+ } else if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
91
+ o = "landscape";
92
+ } else {
93
+ o = "unknown";
94
+ }
95
+ JSObject ret = new JSObject();
96
+ ret.put("orientation", o);
97
+ call.resolve(ret);
98
+ }
99
+
80
100
  @PluginMethod
81
101
  public void start(PluginCall call) {
82
102
  boolean disableAudio = Boolean.TRUE.equals(
@@ -1037,6 +1057,23 @@ public class CameraPreview
1037
1057
  data.put("width", bounds[2]);
1038
1058
  data.put("height", bounds[3]);
1039
1059
  notifyListeners("screenResize", data);
1060
+
1061
+ // Also emit orientationChange with a unified string value
1062
+ int current = getContext()
1063
+ .getResources()
1064
+ .getConfiguration()
1065
+ .orientation;
1066
+ String o;
1067
+ if (current == Configuration.ORIENTATION_PORTRAIT) {
1068
+ o = "portrait";
1069
+ } else if (current == Configuration.ORIENTATION_LANDSCAPE) {
1070
+ o = "landscape";
1071
+ } else {
1072
+ o = "unknown";
1073
+ }
1074
+ JSObject oData = new JSObject();
1075
+ oData.put("orientation", o);
1076
+ notifyListeners("orientationChange", oData);
1040
1077
  });
1041
1078
  });
1042
1079
  }
package/dist/docs.json CHANGED
@@ -161,7 +161,11 @@
161
161
  },
162
162
  {
163
163
  "name": "since",
164
- "text": "7.4.0"
164
+ "text": "7.5.0"
165
+ },
166
+ {
167
+ "name": "platform",
168
+ "text": "android, ios"
165
169
  }
166
170
  ],
167
171
  "docs": "Set the aspect ratio of the camera preview.",
@@ -180,7 +184,11 @@
180
184
  },
181
185
  {
182
186
  "name": "since",
183
- "text": "7.4.0"
187
+ "text": "7.5.0"
188
+ },
189
+ {
190
+ "name": "platform",
191
+ "text": "android, ios"
184
192
  }
185
193
  ],
186
194
  "docs": "Gets the current aspect ratio of the camera preview.",
@@ -422,7 +430,11 @@
422
430
  },
423
431
  {
424
432
  "name": "since",
425
- "text": "7.4.0"
433
+ "text": "7.5.0"
434
+ },
435
+ {
436
+ "name": "platform",
437
+ "text": "android, ios"
426
438
  }
427
439
  ],
428
440
  "docs": "Checks if the camera preview is currently running.",
@@ -441,7 +453,11 @@
441
453
  },
442
454
  {
443
455
  "name": "since",
444
- "text": "7.4.0"
456
+ "text": "7.5.0"
457
+ },
458
+ {
459
+ "name": "platform",
460
+ "text": "android, ios"
445
461
  }
446
462
  ],
447
463
  "docs": "Gets all available camera devices.",
@@ -462,7 +478,11 @@
462
478
  },
463
479
  {
464
480
  "name": "since",
465
- "text": "7.4.0"
481
+ "text": "7.5.0"
482
+ },
483
+ {
484
+ "name": "platform",
485
+ "text": "android, ios"
466
486
  }
467
487
  ],
468
488
  "docs": "Gets the current zoom state, including min/max and current lens info.",
@@ -476,7 +496,16 @@
476
496
  "signature": "() => Promise<{ values: number[]; }>",
477
497
  "parameters": [],
478
498
  "returns": "Promise<{ values: number[]; }>",
479
- "tags": [],
499
+ "tags": [
500
+ {
501
+ "name": "since",
502
+ "text": "7.5.0"
503
+ },
504
+ {
505
+ "name": "platform",
506
+ "text": "android, ios"
507
+ }
508
+ ],
480
509
  "docs": "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",
481
510
  "complexTypes": [],
482
511
  "slug": "getzoombuttonvalues"
@@ -503,7 +532,11 @@
503
532
  },
504
533
  {
505
534
  "name": "since",
506
- "text": "7.4.0"
535
+ "text": "7.5.0"
536
+ },
537
+ {
538
+ "name": "platform",
539
+ "text": "android, ios"
507
540
  }
508
541
  ],
509
542
  "docs": "Sets the zoom level of the camera.",
@@ -522,7 +555,11 @@
522
555
  },
523
556
  {
524
557
  "name": "since",
525
- "text": "7.4.0"
558
+ "text": "7.5.0"
559
+ },
560
+ {
561
+ "name": "platform",
562
+ "text": "android, ios"
526
563
  }
527
564
  ],
528
565
  "docs": "Gets the current flash mode.",
@@ -539,7 +576,11 @@
539
576
  "tags": [
540
577
  {
541
578
  "name": "since",
542
- "text": "7.4.0"
579
+ "text": "7.5.0"
580
+ },
581
+ {
582
+ "name": "platform",
583
+ "text": "android, ios"
543
584
  }
544
585
  ],
545
586
  "docs": "Removes all registered listeners.",
@@ -568,7 +609,11 @@
568
609
  },
569
610
  {
570
611
  "name": "since",
571
- "text": "7.4.0"
612
+ "text": "7.5.0"
613
+ },
614
+ {
615
+ "name": "platform",
616
+ "text": "android, ios"
572
617
  }
573
618
  ],
574
619
  "docs": "Switches the active camera to the one with the specified `deviceId`.",
@@ -587,7 +632,11 @@
587
632
  },
588
633
  {
589
634
  "name": "since",
590
- "text": "7.4.0"
635
+ "text": "7.5.0"
636
+ },
637
+ {
638
+ "name": "platform",
639
+ "text": "android, ios"
591
640
  }
592
641
  ],
593
642
  "docs": "Gets the ID of the currently active camera device.",
@@ -602,6 +651,14 @@
602
651
  "tags": [
603
652
  {
604
653
  "name": "returns"
654
+ },
655
+ {
656
+ "name": "since",
657
+ "text": "7.5.0"
658
+ },
659
+ {
660
+ "name": "platform",
661
+ "text": "android, ios"
605
662
  }
606
663
  ],
607
664
  "docs": "Gets the current preview size and position.",
@@ -627,6 +684,14 @@
627
684
  {
628
685
  "name": "returns",
629
686
  "text": "A promise that resolves with the actual preview dimensions and position."
687
+ },
688
+ {
689
+ "name": "since",
690
+ "text": "7.5.0"
691
+ },
692
+ {
693
+ "name": "platform",
694
+ "text": "android, ios"
630
695
  }
631
696
  ],
632
697
  "docs": "Sets the preview size and position.",
@@ -655,7 +720,11 @@
655
720
  },
656
721
  {
657
722
  "name": "since",
658
- "text": "8.1.0"
723
+ "text": "7.5.0"
724
+ },
725
+ {
726
+ "name": "platform",
727
+ "text": "android, ios"
659
728
  }
660
729
  ],
661
730
  "docs": "Sets the camera focus to a specific point in the preview.",
@@ -668,23 +737,89 @@
668
737
  "parameters": [
669
738
  {
670
739
  "name": "eventName",
671
- "docs": "",
740
+ "docs": "- The event name to listen for.",
672
741
  "type": "'screenResize'"
673
742
  },
674
743
  {
675
744
  "name": "listenerFunc",
676
- "docs": "",
745
+ "docs": "- The function to call when the event is triggered.",
677
746
  "type": "(data: { width: number; height: number; x: number; y: number; }) => void"
678
747
  }
679
748
  ],
680
749
  "returns": "Promise<PluginListenerHandle>",
681
- "tags": [],
682
- "docs": "",
750
+ "tags": [
751
+ {
752
+ "name": "param",
753
+ "text": "eventName - The event name to listen for."
754
+ },
755
+ {
756
+ "name": "param",
757
+ "text": "listenerFunc - The function to call when the event is triggered."
758
+ },
759
+ {
760
+ "name": "returns",
761
+ "text": "A promise that resolves with a handle to the listener."
762
+ },
763
+ {
764
+ "name": "since",
765
+ "text": "7.5.0"
766
+ },
767
+ {
768
+ "name": "platform",
769
+ "text": "android, ios"
770
+ }
771
+ ],
772
+ "docs": "Adds a listener for screen resize events.",
683
773
  "complexTypes": [
684
774
  "PluginListenerHandle"
685
775
  ],
686
776
  "slug": "addlistenerscreenresize-"
687
777
  },
778
+ {
779
+ "name": "addListener",
780
+ "signature": "(eventName: \"orientationChange\", listenerFunc: (data: { orientation: DeviceOrientation; }) => void) => Promise<PluginListenerHandle>",
781
+ "parameters": [
782
+ {
783
+ "name": "eventName",
784
+ "docs": "- The event name to listen for.",
785
+ "type": "'orientationChange'"
786
+ },
787
+ {
788
+ "name": "listenerFunc",
789
+ "docs": "- The function to call when the event is triggered.",
790
+ "type": "(data: { orientation: DeviceOrientation; }) => void"
791
+ }
792
+ ],
793
+ "returns": "Promise<PluginListenerHandle>",
794
+ "tags": [
795
+ {
796
+ "name": "param",
797
+ "text": "eventName - The event name to listen for."
798
+ },
799
+ {
800
+ "name": "param",
801
+ "text": "listenerFunc - The function to call when the event is triggered."
802
+ },
803
+ {
804
+ "name": "returns",
805
+ "text": "A promise that resolves with a handle to the listener."
806
+ },
807
+ {
808
+ "name": "since",
809
+ "text": "7.5.0"
810
+ },
811
+ {
812
+ "name": "platform",
813
+ "text": "android, ios"
814
+ }
815
+ ],
816
+ "docs": "Adds a listener for orientation change events.",
817
+ "complexTypes": [
818
+ "PluginListenerHandle",
819
+ "DeviceOrientation"
820
+ ],
821
+ "slug": "addlistenerorientationchange-"
822
+ },
688
823
  {
689
824
  "name": "deleteFile",
690
825
  "signature": "(options: { path: string; }) => Promise<{ success: boolean; }>",
@@ -699,7 +834,11 @@
699
834
  "tags": [
700
835
  {
701
836
  "name": "since",
702
- "text": "8.2.0"
837
+ "text": "7.5.0"
838
+ },
839
+ {
840
+ "name": "platform",
841
+ "text": "android, ios"
703
842
  }
704
843
  ],
705
844
  "docs": "Deletes a file at the given absolute path on the device.\nUse this to quickly clean up temporary images created with `storeToFile`.\nOn web, this is not supported and will throw.",
@@ -722,6 +861,27 @@
722
861
  "SafeAreaInsets"
723
862
  ],
724
863
  "slug": "getsafeareainsets"
864
+ },
865
+ {
866
+ "name": "getOrientation",
867
+ "signature": "() => Promise<{ orientation: DeviceOrientation; }>",
868
+ "parameters": [],
869
+ "returns": "Promise<{ orientation: DeviceOrientation; }>",
870
+ "tags": [
871
+ {
872
+ "name": "since",
873
+ "text": "7.5.0"
874
+ },
875
+ {
876
+ "name": "platform",
877
+ "text": "android, ios"
878
+ }
879
+ ],
880
+ "docs": "Gets the current device orientation in a cross-platform format.",
881
+ "complexTypes": [
882
+ "DeviceOrientation"
883
+ ],
884
+ "slug": "getorientation"
725
885
  }
726
886
  ],
727
887
  "properties": []
@@ -1630,6 +1790,37 @@
1630
1790
  ]
1631
1791
  }
1632
1792
  ]
1793
+ },
1794
+ {
1795
+ "name": "DeviceOrientation",
1796
+ "slug": "deviceorientation",
1797
+ "docs": "Canonical device orientation values across platforms.",
1798
+ "types": [
1799
+ {
1800
+ "text": "\"portrait\"",
1801
+ "complexTypes": []
1802
+ },
1803
+ {
1804
+ "text": "\"landscape\"",
1805
+ "complexTypes": []
1806
+ },
1807
+ {
1808
+ "text": "\"landscape-left\"",
1809
+ "complexTypes": []
1810
+ },
1811
+ {
1812
+ "text": "\"landscape-right\"",
1813
+ "complexTypes": []
1814
+ },
1815
+ {
1816
+ "text": "\"portrait-upside-down\"",
1817
+ "complexTypes": []
1818
+ },
1819
+ {
1820
+ "text": "\"unknown\"",
1821
+ "complexTypes": []
1822
+ }
1823
+ ]
1633
1824
  }
1634
1825
  ],
1635
1826
  "pluginConfigs": []