@capgo/camera-preview 7.4.0-beta.21 → 7.4.0-beta.22
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/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/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/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/file-system.probe +0 -0
- package/android/src/main/java/com/ahm/capacitor/camera/preview/CameraPreview.java +111 -33
- package/android/src/main/java/com/ahm/capacitor/camera/preview/CameraXView.java +79 -38
- package/android/src/main/java/com/ahm/capacitor/camera/preview/GridOverlayView.java +8 -1
- package/dist/docs.json +2 -2
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/web.js +7 -3
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +7 -3
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +7 -3
- package/dist/plugin.js.map +1 -1
- package/ios/Sources/CapgoCameraPreview/CameraController.swift +28 -28
- package/ios/Sources/CapgoCameraPreview/Plugin.swift +10 -10
- package/package.json +1 -1
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -174,7 +174,14 @@ public class CameraPreview
|
|
|
174
174
|
Integer height = call.getInt("height");
|
|
175
175
|
String aspectRatio = call.getString("aspectRatio");
|
|
176
176
|
|
|
177
|
-
cameraXView.capturePhoto(
|
|
177
|
+
cameraXView.capturePhoto(
|
|
178
|
+
quality,
|
|
179
|
+
saveToGallery,
|
|
180
|
+
width,
|
|
181
|
+
height,
|
|
182
|
+
aspectRatio,
|
|
183
|
+
location
|
|
184
|
+
);
|
|
178
185
|
}
|
|
179
186
|
|
|
180
187
|
@PluginMethod
|
|
@@ -493,7 +500,7 @@ public class CameraPreview
|
|
|
493
500
|
);
|
|
494
501
|
final String aspectRatio = call.getString("aspectRatio", "4:3");
|
|
495
502
|
final String gridMode = call.getString("gridMode", "none");
|
|
496
|
-
final String positioning = call.getString("positioning", "
|
|
503
|
+
final String positioning = call.getString("positioning", "top");
|
|
497
504
|
final float initialZoomLevel = call.getFloat("initialZoomLevel", 1.0f);
|
|
498
505
|
|
|
499
506
|
// Check for conflict between aspectRatio and size
|
|
@@ -577,39 +584,82 @@ public class CameraPreview
|
|
|
577
584
|
|
|
578
585
|
// Calculate pixel ratio
|
|
579
586
|
float pixelRatio = metrics.density;
|
|
580
|
-
|
|
587
|
+
|
|
581
588
|
// The key insight: JavaScript coordinates are relative to the WebView's viewport
|
|
582
|
-
// If the WebView is positioned below the status bar (webViewLocationOnScreen[1] > 0),
|
|
589
|
+
// If the WebView is positioned below the status bar (webViewLocationOnScreen[1] > 0),
|
|
583
590
|
// we need to add that offset when placing native views
|
|
584
591
|
int webViewTopInset = webViewLocationOnScreen[1];
|
|
585
592
|
boolean isEdgeToEdgeActive = webViewLocationOnScreen[1] > 0;
|
|
586
|
-
|
|
593
|
+
|
|
587
594
|
// Log all the positioning information for debugging
|
|
588
595
|
Log.d("CameraPreview", "WebView Position Debug:");
|
|
589
596
|
Log.d("CameraPreview", " - webView.getTop(): " + webViewTop);
|
|
590
597
|
Log.d("CameraPreview", " - webView.getLeft(): " + webViewLeft);
|
|
591
|
-
Log.d(
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
598
|
+
Log.d(
|
|
599
|
+
"CameraPreview",
|
|
600
|
+
" - webView locationInWindow: (" +
|
|
601
|
+
webViewLocationInWindow[0] +
|
|
602
|
+
", " +
|
|
603
|
+
webViewLocationInWindow[1] +
|
|
604
|
+
")"
|
|
605
|
+
);
|
|
606
|
+
Log.d(
|
|
607
|
+
"CameraPreview",
|
|
608
|
+
" - webView locationOnScreen: (" +
|
|
609
|
+
webViewLocationOnScreen[0] +
|
|
610
|
+
", " +
|
|
611
|
+
webViewLocationOnScreen[1] +
|
|
612
|
+
")"
|
|
613
|
+
);
|
|
614
|
+
Log.d(
|
|
615
|
+
"CameraPreview",
|
|
616
|
+
" - parent locationInWindow: (" +
|
|
617
|
+
parentLocationInWindow[0] +
|
|
618
|
+
", " +
|
|
619
|
+
parentLocationInWindow[1] +
|
|
620
|
+
")"
|
|
621
|
+
);
|
|
622
|
+
Log.d(
|
|
623
|
+
"CameraPreview",
|
|
624
|
+
" - parent locationOnScreen: (" +
|
|
625
|
+
parentLocationOnScreen[0] +
|
|
626
|
+
", " +
|
|
627
|
+
parentLocationOnScreen[1] +
|
|
628
|
+
")"
|
|
629
|
+
);
|
|
630
|
+
|
|
596
631
|
// Check if WebView has margins
|
|
597
632
|
View webView = getBridge().getWebView();
|
|
598
633
|
ViewGroup.LayoutParams webViewLayoutParams = webView.getLayoutParams();
|
|
599
634
|
if (webViewLayoutParams instanceof ViewGroup.MarginLayoutParams) {
|
|
600
|
-
ViewGroup.MarginLayoutParams marginParams =
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
635
|
+
ViewGroup.MarginLayoutParams marginParams =
|
|
636
|
+
(ViewGroup.MarginLayoutParams) webViewLayoutParams;
|
|
637
|
+
Log.d(
|
|
638
|
+
"CameraPreview",
|
|
639
|
+
" - webView margins: left=" +
|
|
640
|
+
marginParams.leftMargin +
|
|
641
|
+
", top=" +
|
|
642
|
+
marginParams.topMargin +
|
|
643
|
+
", right=" +
|
|
644
|
+
marginParams.rightMargin +
|
|
645
|
+
", bottom=" +
|
|
646
|
+
marginParams.bottomMargin
|
|
647
|
+
);
|
|
605
648
|
}
|
|
606
|
-
|
|
649
|
+
|
|
607
650
|
// Check WebView padding
|
|
608
|
-
Log.d(
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
651
|
+
Log.d(
|
|
652
|
+
"CameraPreview",
|
|
653
|
+
" - webView padding: left=" +
|
|
654
|
+
webView.getPaddingLeft() +
|
|
655
|
+
", top=" +
|
|
656
|
+
webView.getPaddingTop() +
|
|
657
|
+
", right=" +
|
|
658
|
+
webView.getPaddingRight() +
|
|
659
|
+
", bottom=" +
|
|
660
|
+
webView.getPaddingBottom()
|
|
661
|
+
);
|
|
662
|
+
|
|
613
663
|
Log.d("CameraPreview", " - Using webViewTopInset: " + webViewTopInset);
|
|
614
664
|
Log.d("CameraPreview", " - isEdgeToEdgeActive: " + isEdgeToEdgeActive);
|
|
615
665
|
|
|
@@ -628,11 +678,39 @@ public class CameraPreview
|
|
|
628
678
|
|
|
629
679
|
Log.d("CameraPreview", "========================");
|
|
630
680
|
Log.d("CameraPreview", "POSITIONING CALCULATIONS:");
|
|
631
|
-
Log.d(
|
|
681
|
+
Log.d(
|
|
682
|
+
"CameraPreview",
|
|
683
|
+
"1. INPUT - x: " +
|
|
684
|
+
x +
|
|
685
|
+
", y: " +
|
|
686
|
+
y +
|
|
687
|
+
", width: " +
|
|
688
|
+
width +
|
|
689
|
+
", height: " +
|
|
690
|
+
height
|
|
691
|
+
);
|
|
632
692
|
Log.d("CameraPreview", "2. PIXEL RATIO: " + pixelRatio);
|
|
633
|
-
Log.d(
|
|
634
|
-
|
|
635
|
-
|
|
693
|
+
Log.d(
|
|
694
|
+
"CameraPreview",
|
|
695
|
+
"3. SCREEN - width: " +
|
|
696
|
+
metrics.widthPixels +
|
|
697
|
+
", height: " +
|
|
698
|
+
metrics.heightPixels
|
|
699
|
+
);
|
|
700
|
+
Log.d(
|
|
701
|
+
"CameraPreview",
|
|
702
|
+
"4. WEBVIEW - width: " +
|
|
703
|
+
getBridge().getWebView().getWidth() +
|
|
704
|
+
", height: " +
|
|
705
|
+
getBridge().getWebView().getHeight()
|
|
706
|
+
);
|
|
707
|
+
Log.d(
|
|
708
|
+
"CameraPreview",
|
|
709
|
+
"5. COMPUTED DIMENSIONS - width: " +
|
|
710
|
+
computedWidth +
|
|
711
|
+
", height: " +
|
|
712
|
+
computedHeight
|
|
713
|
+
);
|
|
636
714
|
|
|
637
715
|
if (x == -1) {
|
|
638
716
|
// Center horizontally
|
|
@@ -663,14 +741,11 @@ public class CameraPreview
|
|
|
663
741
|
if (y == -1) {
|
|
664
742
|
// Position vertically based on positioning parameter
|
|
665
743
|
int screenHeight = metrics.heightPixels;
|
|
666
|
-
|
|
744
|
+
|
|
667
745
|
switch (positioning) {
|
|
668
746
|
case "top":
|
|
669
747
|
computedY = 0;
|
|
670
|
-
Log.d(
|
|
671
|
-
"CameraPreview",
|
|
672
|
-
"Positioning at top: computedY=0"
|
|
673
|
-
);
|
|
748
|
+
Log.d("CameraPreview", "Positioning at top: computedY=0");
|
|
674
749
|
break;
|
|
675
750
|
case "bottom":
|
|
676
751
|
computedY = screenHeight - computedHeight;
|
|
@@ -726,7 +801,7 @@ public class CameraPreview
|
|
|
726
801
|
Log.d(
|
|
727
802
|
"CameraPreview",
|
|
728
803
|
"Edge-to-edge adjustment: Y position " +
|
|
729
|
-
(int)(y * pixelRatio) +
|
|
804
|
+
(int) (y * pixelRatio) +
|
|
730
805
|
" + inset " +
|
|
731
806
|
webViewTopInset +
|
|
732
807
|
" = " +
|
|
@@ -747,7 +822,10 @@ public class CameraPreview
|
|
|
747
822
|
|
|
748
823
|
Log.d(
|
|
749
824
|
"CameraPreview",
|
|
750
|
-
"2b. EDGE-TO-EDGE - " +
|
|
825
|
+
"2b. EDGE-TO-EDGE - " +
|
|
826
|
+
(isEdgeToEdgeActive
|
|
827
|
+
? "ACTIVE (inset=" + webViewTopInset + ")"
|
|
828
|
+
: "INACTIVE")
|
|
751
829
|
);
|
|
752
830
|
Log.d(
|
|
753
831
|
"CameraPreview",
|
|
@@ -1090,7 +1168,7 @@ public class CameraPreview
|
|
|
1090
1168
|
|
|
1091
1169
|
int x = (xParam != null && xParam > 0) ? (int) (xParam * pixelRatio) : 0;
|
|
1092
1170
|
int y = (yParam != null && yParam > 0) ? (int) (yParam * pixelRatio) : 0;
|
|
1093
|
-
|
|
1171
|
+
|
|
1094
1172
|
// Add edge-to-edge inset to Y if active
|
|
1095
1173
|
if (isEdgeToEdgeActive && y > 0) {
|
|
1096
1174
|
y += webViewTopInset;
|
|
@@ -360,14 +360,21 @@ public class CameraXView implements LifecycleOwner, LifecycleObserver {
|
|
|
360
360
|
Log.d(TAG, "setupPreviewView: Setting grid mode to: " + currentGridMode);
|
|
361
361
|
gridOverlayView.setGridMode(currentGridMode);
|
|
362
362
|
});
|
|
363
|
-
|
|
363
|
+
|
|
364
364
|
// Add a layout listener to update grid bounds when preview view changes size
|
|
365
|
-
previewView.addOnLayoutChangeListener(
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
365
|
+
previewView.addOnLayoutChangeListener(
|
|
366
|
+
(v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) -> {
|
|
367
|
+
if (
|
|
368
|
+
left != oldLeft ||
|
|
369
|
+
top != oldTop ||
|
|
370
|
+
right != oldRight ||
|
|
371
|
+
bottom != oldBottom
|
|
372
|
+
) {
|
|
373
|
+
Log.d(TAG, "PreviewView layout changed, updating grid bounds");
|
|
374
|
+
updateGridOverlayBounds();
|
|
375
|
+
}
|
|
369
376
|
}
|
|
370
|
-
|
|
377
|
+
);
|
|
371
378
|
|
|
372
379
|
ViewGroup parent = (ViewGroup) webView.getParent();
|
|
373
380
|
if (parent != null) {
|
|
@@ -838,12 +845,24 @@ public class CameraXView implements LifecycleOwner, LifecycleObserver {
|
|
|
838
845
|
String aspectRatio,
|
|
839
846
|
Location location
|
|
840
847
|
) {
|
|
841
|
-
Log.d(
|
|
848
|
+
Log.d(
|
|
849
|
+
TAG,
|
|
850
|
+
"capturePhoto: Starting photo capture with quality: " +
|
|
851
|
+
quality +
|
|
852
|
+
", width: " +
|
|
853
|
+
width +
|
|
854
|
+
", height: " +
|
|
855
|
+
height +
|
|
856
|
+
", aspectRatio: " +
|
|
857
|
+
aspectRatio
|
|
858
|
+
);
|
|
842
859
|
|
|
843
860
|
// Check for conflicting parameters
|
|
844
861
|
if (aspectRatio != null && (width != null || height != null)) {
|
|
845
862
|
if (listener != null) {
|
|
846
|
-
listener.onPictureTakenError(
|
|
863
|
+
listener.onPictureTakenError(
|
|
864
|
+
"Cannot set both aspectRatio and size (width/height). Use setPreviewSize after start."
|
|
865
|
+
);
|
|
847
866
|
}
|
|
848
867
|
return;
|
|
849
868
|
}
|
|
@@ -896,36 +915,56 @@ public class CameraXView implements LifecycleOwner, LifecycleObserver {
|
|
|
896
915
|
|
|
897
916
|
// Use the stored aspectRatio if none is provided and no width/height is specified
|
|
898
917
|
String captureAspectRatio = aspectRatio;
|
|
899
|
-
if (
|
|
918
|
+
if (
|
|
919
|
+
width == null &&
|
|
920
|
+
height == null &&
|
|
921
|
+
aspectRatio == null &&
|
|
922
|
+
sessionConfig != null
|
|
923
|
+
) {
|
|
900
924
|
captureAspectRatio = sessionConfig.getAspectRatio();
|
|
901
925
|
// Default to "4:3" if no aspect ratio was set at all
|
|
902
926
|
if (captureAspectRatio == null) {
|
|
903
927
|
captureAspectRatio = "4:3";
|
|
904
928
|
}
|
|
905
|
-
Log.d(
|
|
929
|
+
Log.d(
|
|
930
|
+
TAG,
|
|
931
|
+
"capturePhoto: Using stored aspectRatio: " + captureAspectRatio
|
|
932
|
+
);
|
|
906
933
|
}
|
|
907
|
-
|
|
934
|
+
|
|
908
935
|
// Handle aspect ratio if no width/height specified
|
|
909
|
-
if (
|
|
936
|
+
if (
|
|
937
|
+
width == null &&
|
|
938
|
+
height == null &&
|
|
939
|
+
captureAspectRatio != null &&
|
|
940
|
+
!captureAspectRatio.isEmpty()
|
|
941
|
+
) {
|
|
910
942
|
// Get the original image dimensions
|
|
911
|
-
Bitmap originalBitmap = BitmapFactory.decodeByteArray(
|
|
943
|
+
Bitmap originalBitmap = BitmapFactory.decodeByteArray(
|
|
944
|
+
bytes,
|
|
945
|
+
0,
|
|
946
|
+
bytes.length
|
|
947
|
+
);
|
|
912
948
|
int originalWidth = originalBitmap.getWidth();
|
|
913
949
|
int originalHeight = originalBitmap.getHeight();
|
|
914
|
-
|
|
950
|
+
|
|
915
951
|
// Parse aspect ratio
|
|
916
952
|
String[] ratios = captureAspectRatio.split(":");
|
|
917
953
|
if (ratios.length == 2) {
|
|
918
954
|
try {
|
|
919
955
|
float widthRatio = Float.parseFloat(ratios[0]);
|
|
920
956
|
float heightRatio = Float.parseFloat(ratios[1]);
|
|
921
|
-
|
|
957
|
+
|
|
922
958
|
// For capture in portrait orientation, swap the aspect ratio (16:9 becomes 9:16)
|
|
923
959
|
boolean isPortrait = originalHeight > originalWidth;
|
|
924
|
-
float targetAspectRatio = isPortrait
|
|
925
|
-
|
|
926
|
-
|
|
960
|
+
float targetAspectRatio = isPortrait
|
|
961
|
+
? heightRatio / widthRatio
|
|
962
|
+
: widthRatio / heightRatio;
|
|
963
|
+
float originalAspectRatio =
|
|
964
|
+
(float) originalWidth / originalHeight;
|
|
965
|
+
|
|
927
966
|
int targetWidth, targetHeight;
|
|
928
|
-
|
|
967
|
+
|
|
929
968
|
if (originalAspectRatio > targetAspectRatio) {
|
|
930
969
|
// Original is wider than target - fit by height
|
|
931
970
|
targetHeight = originalHeight;
|
|
@@ -935,11 +974,11 @@ public class CameraXView implements LifecycleOwner, LifecycleObserver {
|
|
|
935
974
|
targetWidth = originalWidth;
|
|
936
975
|
targetHeight = (int) (targetWidth / targetAspectRatio);
|
|
937
976
|
}
|
|
938
|
-
|
|
977
|
+
|
|
939
978
|
// Center crop the image
|
|
940
979
|
int xOffset = (originalWidth - targetWidth) / 2;
|
|
941
980
|
int yOffset = (originalHeight - targetHeight) / 2;
|
|
942
|
-
|
|
981
|
+
|
|
943
982
|
Bitmap croppedBitmap = Bitmap.createBitmap(
|
|
944
983
|
originalBitmap,
|
|
945
984
|
xOffset,
|
|
@@ -947,18 +986,26 @@ public class CameraXView implements LifecycleOwner, LifecycleObserver {
|
|
|
947
986
|
targetWidth,
|
|
948
987
|
targetHeight
|
|
949
988
|
);
|
|
950
|
-
|
|
989
|
+
|
|
951
990
|
ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
|
952
|
-
croppedBitmap.compress(
|
|
991
|
+
croppedBitmap.compress(
|
|
992
|
+
Bitmap.CompressFormat.JPEG,
|
|
993
|
+
quality,
|
|
994
|
+
stream
|
|
995
|
+
);
|
|
953
996
|
bytes = stream.toByteArray();
|
|
954
|
-
|
|
997
|
+
|
|
955
998
|
// Write EXIF data back to cropped image
|
|
956
999
|
bytes = writeExifToImageBytes(bytes, exifInterface);
|
|
957
|
-
|
|
1000
|
+
|
|
958
1001
|
originalBitmap.recycle();
|
|
959
1002
|
croppedBitmap.recycle();
|
|
960
1003
|
} catch (NumberFormatException e) {
|
|
961
|
-
Log.e(
|
|
1004
|
+
Log.e(
|
|
1005
|
+
TAG,
|
|
1006
|
+
"Invalid aspect ratio format: " + captureAspectRatio,
|
|
1007
|
+
e
|
|
1008
|
+
);
|
|
962
1009
|
}
|
|
963
1010
|
}
|
|
964
1011
|
} else if (width != null && height != null) {
|
|
@@ -1616,7 +1663,7 @@ public class CameraXView implements LifecycleOwner, LifecycleObserver {
|
|
|
1616
1663
|
|
|
1617
1664
|
int viewWidth = previewView.getWidth();
|
|
1618
1665
|
int viewHeight = previewView.getHeight();
|
|
1619
|
-
|
|
1666
|
+
|
|
1620
1667
|
if (viewWidth <= 0 || viewHeight <= 0) {
|
|
1621
1668
|
throw new Exception(
|
|
1622
1669
|
"Preview view has invalid dimensions: " + viewWidth + "x" + viewHeight
|
|
@@ -2804,7 +2851,7 @@ public class CameraXView implements LifecycleOwner, LifecycleObserver {
|
|
|
2804
2851
|
finalY +
|
|
2805
2852
|
")"
|
|
2806
2853
|
);
|
|
2807
|
-
|
|
2854
|
+
|
|
2808
2855
|
// Update grid overlay bounds after aspect ratio change
|
|
2809
2856
|
previewContainer.post(() -> updateGridOverlayBounds());
|
|
2810
2857
|
}
|
|
@@ -2863,14 +2910,8 @@ public class CameraXView implements LifecycleOwner, LifecycleObserver {
|
|
|
2863
2910
|
int webViewTopInset = getWebViewTopInset();
|
|
2864
2911
|
int webViewLeftInset = getWebViewLeftInset();
|
|
2865
2912
|
|
|
2866
|
-
int x = Math.max(
|
|
2867
|
-
|
|
2868
|
-
(int) ((actualX - webViewLeftInset) / pixelRatio)
|
|
2869
|
-
);
|
|
2870
|
-
int y = Math.max(
|
|
2871
|
-
0,
|
|
2872
|
-
(int) ((actualY - webViewTopInset) / pixelRatio)
|
|
2873
|
-
);
|
|
2913
|
+
int x = Math.max(0, (int) ((actualX - webViewLeftInset) / pixelRatio));
|
|
2914
|
+
int y = Math.max(0, (int) ((actualY - webViewTopInset) / pixelRatio));
|
|
2874
2915
|
int width = (int) (actualWidth / pixelRatio);
|
|
2875
2916
|
int height = (int) (actualHeight / pixelRatio);
|
|
2876
2917
|
|
|
@@ -2881,10 +2922,10 @@ public class CameraXView implements LifecycleOwner, LifecycleObserver {
|
|
|
2881
2922
|
if (gridOverlayView != null && previewView != null) {
|
|
2882
2923
|
// Get the actual camera bounds
|
|
2883
2924
|
Rect cameraBounds = getActualCameraBounds();
|
|
2884
|
-
|
|
2925
|
+
|
|
2885
2926
|
// Update the grid overlay with the camera bounds
|
|
2886
2927
|
gridOverlayView.setCameraBounds(cameraBounds);
|
|
2887
|
-
|
|
2928
|
+
|
|
2888
2929
|
Log.d(
|
|
2889
2930
|
TAG,
|
|
2890
2931
|
"updateGridOverlayBounds: Updated grid bounds to " +
|
|
@@ -93,7 +93,14 @@ public class GridOverlayView extends View {
|
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
-
private void drawGrid(
|
|
96
|
+
private void drawGrid(
|
|
97
|
+
Canvas canvas,
|
|
98
|
+
int left,
|
|
99
|
+
int top,
|
|
100
|
+
int width,
|
|
101
|
+
int height,
|
|
102
|
+
int divisions
|
|
103
|
+
) {
|
|
97
104
|
float stepX = (float) width / divisions;
|
|
98
105
|
float stepY = (float) height / divisions;
|
|
99
106
|
|
package/dist/docs.json
CHANGED
|
@@ -1018,7 +1018,7 @@
|
|
|
1018
1018
|
"name": "height",
|
|
1019
1019
|
"tags": [
|
|
1020
1020
|
{
|
|
1021
|
-
"text": ",\nThe desired height of the picture in pixels
|
|
1021
|
+
"text": ",\nThe desired height of the picture in pixels.\nIf not specified and no aspectRatio is provided, the captured image will match the preview's visible area.",
|
|
1022
1022
|
"name": "deprecated"
|
|
1023
1023
|
}
|
|
1024
1024
|
],
|
|
@@ -1030,7 +1030,7 @@
|
|
|
1030
1030
|
"name": "width",
|
|
1031
1031
|
"tags": [
|
|
1032
1032
|
{
|
|
1033
|
-
"text": ",\nThe desired width of the picture in pixels
|
|
1033
|
+
"text": ",\nThe desired width of the picture in pixels.\nIf not specified and no aspectRatio is provided, the captured image will match the preview's visible area.",
|
|
1034
1034
|
"name": "deprecated"
|
|
1035
1035
|
}
|
|
1036
1036
|
],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAQA,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 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 * 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: {\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.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 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.4.0\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.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<{\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 */\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 8.1.0\n */\n setFocus(options: { x: number; y: number }): Promise<void>;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAQA,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 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 * 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: {\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.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 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.4.0\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.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<{\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 */\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 8.1.0\n */\n setFocus(options: { x: number; y: number }): Promise<void>;\n}\n"]}
|
package/dist/esm/web.js
CHANGED
|
@@ -27,7 +27,7 @@ export class CameraPreviewWeb extends WebPlugin {
|
|
|
27
27
|
this.isStarted = false;
|
|
28
28
|
const parent = document.getElementById((options === null || options === void 0 ? void 0 : options.parent) || "");
|
|
29
29
|
const gridMode = (options === null || options === void 0 ? void 0 : options.gridMode) || "none";
|
|
30
|
-
const positioning = (options === null || options === void 0 ? void 0 : options.positioning) || "
|
|
30
|
+
const positioning = (options === null || options === void 0 ? void 0 : options.positioning) || "top";
|
|
31
31
|
if (options.position) {
|
|
32
32
|
this.isBackCamera = options.position === "rear";
|
|
33
33
|
}
|
|
@@ -367,11 +367,15 @@ export class CameraPreviewWeb extends WebPlugin {
|
|
|
367
367
|
}
|
|
368
368
|
// Handle aspect ratio if no width/height specified
|
|
369
369
|
if (!options.width && !options.height && options.aspectRatio) {
|
|
370
|
-
const [widthRatio, heightRatio] = options.aspectRatio
|
|
370
|
+
const [widthRatio, heightRatio] = options.aspectRatio
|
|
371
|
+
.split(":")
|
|
372
|
+
.map(Number);
|
|
371
373
|
if (widthRatio && heightRatio) {
|
|
372
374
|
// For capture in portrait orientation, swap the aspect ratio (16:9 becomes 9:16)
|
|
373
375
|
const isPortrait = video.videoHeight > video.videoWidth;
|
|
374
|
-
const targetAspectRatio = isPortrait
|
|
376
|
+
const targetAspectRatio = isPortrait
|
|
377
|
+
? heightRatio / widthRatio
|
|
378
|
+
: widthRatio / heightRatio;
|
|
375
379
|
const videoAspectRatio = video.videoWidth / video.videoHeight;
|
|
376
380
|
if (videoAspectRatio > targetAspectRatio) {
|
|
377
381
|
// Video is wider than target - crop sides
|