@capgo/camera-preview 7.26.4 → 8.0.2
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/CapgoCameraPreview.podspec +1 -1
- package/android/build.gradle +9 -9
- package/dist/esm/web.js +3 -0
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +0 -1
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +0 -1
- package/dist/plugin.js.map +1 -1
- package/ios/Sources/CapgoCameraPreviewPlugin/CameraController.swift +28 -28
- package/ios/Sources/CapgoCameraPreviewPlugin/GridOverlayView.swift +8 -8
- package/ios/Sources/CapgoCameraPreviewPlugin/Plugin.swift +28 -25
- package/package.json +14 -14
|
@@ -34,7 +34,7 @@ extension UIWindow {
|
|
|
34
34
|
*/
|
|
35
35
|
@objc(CameraPreview)
|
|
36
36
|
public class CameraPreview: CAPPlugin, CAPBridgedPlugin, CLLocationManagerDelegate {
|
|
37
|
-
private let pluginVersion: String = "
|
|
37
|
+
private let pluginVersion: String = "8.0.2"
|
|
38
38
|
public let identifier = "CameraPreviewPlugin"
|
|
39
39
|
public let jsName = "CameraPreview"
|
|
40
40
|
public let pluginMethods: [CAPPluginMethod] = [
|
|
@@ -470,8 +470,8 @@ public class CameraPreview: CAPPlugin, CAPBridgedPlugin, CLLocationManagerDelega
|
|
|
470
470
|
availableHeight = webViewHeight - paddingBottom
|
|
471
471
|
} else {
|
|
472
472
|
// Manual positioning - calculate remaining space
|
|
473
|
-
availableWidth = webViewWidth - self.posX
|
|
474
|
-
availableHeight = webViewHeight - self.posY
|
|
473
|
+
availableWidth = webViewWidth - (self.posX ?? 0)
|
|
474
|
+
availableHeight = webViewHeight - (self.posY ?? 0) - paddingBottom
|
|
475
475
|
}
|
|
476
476
|
|
|
477
477
|
// Parse aspect ratio - convert to portrait orientation for camera use
|
|
@@ -722,20 +722,20 @@ public class CameraPreview: CAPPlugin, CAPBridgedPlugin, CLLocationManagerDelega
|
|
|
722
722
|
}
|
|
723
723
|
|
|
724
724
|
// Set x position - use exact CSS pixel value from web view, or mark for centering
|
|
725
|
-
if let
|
|
726
|
-
self.posX = CGFloat(
|
|
725
|
+
if let xPosition = call.getInt("x") {
|
|
726
|
+
self.posX = CGFloat(xPosition)
|
|
727
727
|
} else {
|
|
728
728
|
self.posX = -1 // Use -1 to indicate auto-centering
|
|
729
729
|
}
|
|
730
730
|
|
|
731
731
|
// Set y position - use exact CSS pixel value from web view, or mark for centering
|
|
732
|
-
if let
|
|
733
|
-
self.posY = CGFloat(
|
|
732
|
+
if let yPosition = call.getInt("y") {
|
|
733
|
+
self.posY = CGFloat(yPosition)
|
|
734
734
|
} else {
|
|
735
735
|
self.posY = -1 // Use -1 to indicate auto-centering
|
|
736
736
|
}
|
|
737
|
-
if call.getInt("paddingBottom")
|
|
738
|
-
self.paddingBottom = CGFloat(
|
|
737
|
+
if let paddingBottomValue = call.getInt("paddingBottom") {
|
|
738
|
+
self.paddingBottom = CGFloat(paddingBottomValue)
|
|
739
739
|
}
|
|
740
740
|
|
|
741
741
|
self.rotateWhenOrientationChanged = call.getBool("rotateWhenOrientationChanged") ?? true
|
|
@@ -823,7 +823,7 @@ public class CameraPreview: CAPPlugin, CAPBridgedPlugin, CLLocationManagerDelega
|
|
|
823
823
|
|
|
824
824
|
// Add preview view to hierarchy first
|
|
825
825
|
self.webView?.addSubview(self.previewView)
|
|
826
|
-
if self.toBack
|
|
826
|
+
if self.toBack == true {
|
|
827
827
|
self.webView?.sendSubviewToBack(self.previewView)
|
|
828
828
|
}
|
|
829
829
|
|
|
@@ -1177,13 +1177,13 @@ public class CameraPreview: CAPPlugin, CAPBridgedPlugin, CLLocationManagerDelega
|
|
|
1177
1177
|
if Thread.isMainThread {
|
|
1178
1178
|
return (self.previewView.frame.width, self.previewView.frame.height)
|
|
1179
1179
|
}
|
|
1180
|
-
var
|
|
1181
|
-
var
|
|
1180
|
+
var width: CGFloat = 0
|
|
1181
|
+
var height: CGFloat = 0
|
|
1182
1182
|
DispatchQueue.main.sync {
|
|
1183
|
-
|
|
1184
|
-
|
|
1183
|
+
width = self.previewView.frame.width
|
|
1184
|
+
height = self.previewView.frame.height
|
|
1185
1185
|
}
|
|
1186
|
-
return (
|
|
1186
|
+
return (width, height)
|
|
1187
1187
|
}()
|
|
1188
1188
|
print("[CameraPreview] Preview dimensions: \(previewWidth)x\(previewHeight)")
|
|
1189
1189
|
|
|
@@ -1398,7 +1398,7 @@ public class CameraPreview: CAPPlugin, CAPBridgedPlugin, CLLocationManagerDelega
|
|
|
1398
1398
|
}
|
|
1399
1399
|
|
|
1400
1400
|
@objc func captureSample(_ call: CAPPluginCall) {
|
|
1401
|
-
let quality: Int
|
|
1401
|
+
let quality: Int = call.getInt("quality") ?? 85
|
|
1402
1402
|
|
|
1403
1403
|
self.cameraController.captureSample { image, error in
|
|
1404
1404
|
guard let image = image else {
|
|
@@ -1410,14 +1410,17 @@ public class CameraPreview: CAPPlugin, CAPBridgedPlugin, CLLocationManagerDelega
|
|
|
1410
1410
|
let imageData: Data?
|
|
1411
1411
|
if self.cameraPosition == "front" {
|
|
1412
1412
|
let flippedImage = image.withHorizontallyFlippedOrientation()
|
|
1413
|
-
imageData = flippedImage.jpegData(compressionQuality: CGFloat(quality
|
|
1413
|
+
imageData = flippedImage.jpegData(compressionQuality: CGFloat(quality)/100)
|
|
1414
1414
|
} else {
|
|
1415
|
-
imageData = image.jpegData(compressionQuality: CGFloat(quality
|
|
1415
|
+
imageData = image.jpegData(compressionQuality: CGFloat(quality)/100)
|
|
1416
1416
|
}
|
|
1417
1417
|
|
|
1418
1418
|
if self.storeToFile == false {
|
|
1419
|
-
let imageBase64 = imageData?.base64EncodedString()
|
|
1420
|
-
|
|
1419
|
+
guard let imageBase64 = imageData?.base64EncodedString() else {
|
|
1420
|
+
call.reject("Failed to encode image to base64")
|
|
1421
|
+
return
|
|
1422
|
+
}
|
|
1423
|
+
call.resolve(["value": imageBase64])
|
|
1421
1424
|
} else {
|
|
1422
1425
|
do {
|
|
1423
1426
|
let fileUrl = self.getTempFilePath()
|
|
@@ -1464,8 +1467,8 @@ public class CameraPreview: CAPPlugin, CAPBridgedPlugin, CLLocationManagerDelega
|
|
|
1464
1467
|
flashModeAsEnum = AVCaptureDevice.FlashMode.auto
|
|
1465
1468
|
default: break
|
|
1466
1469
|
}
|
|
1467
|
-
if
|
|
1468
|
-
try self.cameraController.setFlashMode(flashMode:
|
|
1470
|
+
if let flashModeEnum = flashModeAsEnum {
|
|
1471
|
+
try self.cameraController.setFlashMode(flashMode: flashModeEnum)
|
|
1469
1472
|
} else if flashMode == "torch" {
|
|
1470
1473
|
try self.cameraController.setTorchMode()
|
|
1471
1474
|
} else {
|
|
@@ -1905,12 +1908,12 @@ public class CameraPreview: CAPPlugin, CAPBridgedPlugin, CLLocationManagerDelega
|
|
|
1905
1908
|
}
|
|
1906
1909
|
}
|
|
1907
1910
|
|
|
1908
|
-
private func calculateCameraFrame(
|
|
1911
|
+
private func calculateCameraFrame(xPosition: CGFloat? = nil, yPosition: CGFloat? = nil, width: CGFloat? = nil, height: CGFloat? = nil, aspectRatio: String? = nil) -> CGRect {
|
|
1909
1912
|
// Use provided values or existing ones
|
|
1910
1913
|
let currentWidth = width ?? self.width ?? UIScreen.main.bounds.size.width
|
|
1911
1914
|
let currentHeight = height ?? self.height ?? UIScreen.main.bounds.size.height
|
|
1912
|
-
let currentX =
|
|
1913
|
-
let currentY =
|
|
1915
|
+
let currentX = xPosition ?? self.posX ?? -1
|
|
1916
|
+
let currentY = yPosition ?? self.posY ?? -1
|
|
1914
1917
|
let currentAspectRatio = aspectRatio ?? self.aspectRatio
|
|
1915
1918
|
|
|
1916
1919
|
let paddingBottom = self.paddingBottom ?? 0
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capgo/camera-preview",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.0.2",
|
|
4
4
|
"description": "Camera preview",
|
|
5
5
|
"license": "MPL-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -51,27 +51,27 @@
|
|
|
51
51
|
"prepublishOnly": "npm run build"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
|
-
"@capacitor/android": "^
|
|
55
|
-
"@capacitor/cli": "^
|
|
56
|
-
"@capacitor/core": "^
|
|
57
|
-
"@capacitor/docgen": "^0.3.
|
|
58
|
-
"@capacitor/ios": "^
|
|
54
|
+
"@capacitor/android": "^8.0.0",
|
|
55
|
+
"@capacitor/cli": "^8.0.0",
|
|
56
|
+
"@capacitor/core": "^8.0.0",
|
|
57
|
+
"@capacitor/docgen": "^0.3.1",
|
|
58
|
+
"@capacitor/ios": "^8.0.0",
|
|
59
59
|
"@ionic/eslint-config": "^0.4.0",
|
|
60
60
|
"@ionic/prettier-config": "^4.0.0",
|
|
61
61
|
"@ionic/swiftlint-config": "^2.0.0",
|
|
62
|
-
"@types/node": "^
|
|
63
|
-
"eslint": "^8.57.
|
|
62
|
+
"@types/node": "^24.10.1",
|
|
63
|
+
"eslint": "^8.57.1",
|
|
64
64
|
"eslint-plugin-import": "^2.31.0",
|
|
65
65
|
"husky": "^9.1.7",
|
|
66
|
-
"prettier": "^3.
|
|
67
|
-
"prettier-plugin-java": "^2.
|
|
68
|
-
"rimraf": "^6.0
|
|
69
|
-
"rollup": "^4.
|
|
66
|
+
"prettier": "^3.6.2",
|
|
67
|
+
"prettier-plugin-java": "^2.7.7",
|
|
68
|
+
"rimraf": "^6.1.0",
|
|
69
|
+
"rollup": "^4.53.2",
|
|
70
70
|
"swiftlint": "^2.0.0",
|
|
71
|
-
"typescript": "^5.
|
|
71
|
+
"typescript": "^5.9.3"
|
|
72
72
|
},
|
|
73
73
|
"peerDependencies": {
|
|
74
|
-
"@capacitor/core": ">=
|
|
74
|
+
"@capacitor/core": ">=8.0.0"
|
|
75
75
|
},
|
|
76
76
|
"eslintConfig": {
|
|
77
77
|
"extends": "@ionic/eslint-config/recommended"
|