@capgo/camera-preview 7.4.0-beta.13 → 7.4.0-beta.15
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 +10 -10
- 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 +177 -19
- package/android/src/main/java/com/ahm/capacitor/camera/preview/CameraXView.java +725 -87
- package/android/src/main/java/com/ahm/capacitor/camera/preview/model/CameraSessionConfiguration.java +9 -0
- package/dist/docs.json +27 -23
- package/dist/esm/definitions.d.ts +13 -10
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/web.d.ts +1 -0
- package/dist/esm/web.js +223 -34
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +223 -34
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +223 -34
- package/dist/plugin.js.map +1 -1
- package/ios/Sources/CapgoCameraPreview/CameraController.swift +373 -65
- package/ios/Sources/CapgoCameraPreview/Plugin.swift +35 -22
- package/package.json +1 -1
|
@@ -84,7 +84,6 @@ public class CameraPreview: CAPPlugin, CAPBridgedPlugin, CLLocationManagerDelega
|
|
|
84
84
|
var toBack: Bool?
|
|
85
85
|
var storeToFile: Bool?
|
|
86
86
|
var enableZoom: Bool?
|
|
87
|
-
var highResolutionOutput: Bool = false
|
|
88
87
|
var disableAudio: Bool = false
|
|
89
88
|
var locationManager: CLLocationManager?
|
|
90
89
|
var currentLocation: CLLocation?
|
|
@@ -412,8 +411,6 @@ public class CameraPreview: CAPPlugin, CAPBridgedPlugin, CLLocationManagerDelega
|
|
|
412
411
|
self.cameraPosition = call.getString("position") ?? "rear"
|
|
413
412
|
let deviceId = call.getString("deviceId")
|
|
414
413
|
let cameraMode = call.getBool("cameraMode") ?? false
|
|
415
|
-
self.highResolutionOutput = call.getBool("enableHighResolution") ?? false
|
|
416
|
-
self.cameraController.highResolutionOutput = self.highResolutionOutput
|
|
417
414
|
|
|
418
415
|
// Set width - use screen width if not provided or if 0
|
|
419
416
|
if let width = call.getInt("width"), width > 0 {
|
|
@@ -453,6 +450,7 @@ public class CameraPreview: CAPPlugin, CAPBridgedPlugin, CLLocationManagerDelega
|
|
|
453
450
|
self.disableAudio = call.getBool("disableAudio") ?? true
|
|
454
451
|
self.aspectRatio = call.getString("aspectRatio")
|
|
455
452
|
self.gridMode = call.getString("gridMode") ?? "none"
|
|
453
|
+
let initialZoomLevel = call.getFloat("initialZoomLevel") ?? 1.0
|
|
456
454
|
if self.aspectRatio != nil && (call.getInt("width") != nil || call.getInt("height") != nil) {
|
|
457
455
|
call.reject("Cannot set both aspectRatio and size (width/height). Use setPreviewSize after start.")
|
|
458
456
|
return
|
|
@@ -471,12 +469,7 @@ public class CameraPreview: CAPPlugin, CAPBridgedPlugin, CLLocationManagerDelega
|
|
|
471
469
|
if self.cameraController.captureSession?.isRunning ?? false {
|
|
472
470
|
call.reject("camera already started")
|
|
473
471
|
} else {
|
|
474
|
-
|
|
475
|
-
if self.cameraController.captureSession == nil {
|
|
476
|
-
self.cameraController.prepareFullSession()
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
self.cameraController.prepare(cameraPosition: self.cameraPosition, deviceId: deviceId, disableAudio: self.disableAudio, cameraMode: cameraMode, aspectRatio: self.aspectRatio) {error in
|
|
472
|
+
self.cameraController.prepare(cameraPosition: self.cameraPosition, deviceId: deviceId, disableAudio: self.disableAudio, cameraMode: cameraMode, aspectRatio: self.aspectRatio, initialZoomLevel: Float(initialZoomLevel)) {error in
|
|
480
473
|
if let error = error {
|
|
481
474
|
print(error)
|
|
482
475
|
call.reject(error.localizedDescription)
|
|
@@ -700,7 +693,13 @@ public class CameraPreview: CAPPlugin, CAPBridgedPlugin, CLLocationManagerDelega
|
|
|
700
693
|
return
|
|
701
694
|
}
|
|
702
695
|
|
|
703
|
-
guard let
|
|
696
|
+
guard let image = image,
|
|
697
|
+
let imageDataWithExif = self.createImageDataWithExif(
|
|
698
|
+
from: image,
|
|
699
|
+
quality: Int(quality),
|
|
700
|
+
location: withExifLocation ? self.currentLocation : nil
|
|
701
|
+
)
|
|
702
|
+
else {
|
|
704
703
|
print("[CameraPreview] Failed to create image data with EXIF")
|
|
705
704
|
call.reject("Failed to create image data with EXIF")
|
|
706
705
|
return
|
|
@@ -1060,9 +1059,10 @@ public class CameraPreview: CAPPlugin, CAPBridgedPlugin, CLLocationManagerDelega
|
|
|
1060
1059
|
}
|
|
1061
1060
|
|
|
1062
1061
|
let ramp = call.getBool("ramp") ?? true
|
|
1062
|
+
let autoFocus = call.getBool("autoFocus") ?? true
|
|
1063
1063
|
|
|
1064
1064
|
do {
|
|
1065
|
-
try self.cameraController.setZoom(level: CGFloat(level), ramp: ramp)
|
|
1065
|
+
try self.cameraController.setZoom(level: CGFloat(level), ramp: ramp, autoFocus: autoFocus)
|
|
1066
1066
|
call.resolve()
|
|
1067
1067
|
} catch {
|
|
1068
1068
|
call.reject("Failed to set zoom: \(error.localizedDescription)")
|
|
@@ -1331,10 +1331,11 @@ public class CameraPreview: CAPPlugin, CAPBridgedPlugin, CLLocationManagerDelega
|
|
|
1331
1331
|
|
|
1332
1332
|
// Handle auto-centering when position is -1
|
|
1333
1333
|
if posX == -1 || posY == -1 {
|
|
1334
|
-
|
|
1334
|
+
// Only override dimensions if aspect ratio is provided and no explicit dimensions given
|
|
1335
|
+
if let aspectRatio = self.aspectRatio, width == UIScreen.main.bounds.size.width && height == UIScreen.main.bounds.size.height {
|
|
1336
|
+
finalWidth = webViewWidth
|
|
1335
1337
|
|
|
1336
|
-
|
|
1337
|
-
if let aspectRatio = self.aspectRatio {
|
|
1338
|
+
// Calculate height based on aspect ratio
|
|
1338
1339
|
let ratioParts = aspectRatio.split(separator: ":").compactMap { Double($0) }
|
|
1339
1340
|
if ratioParts.count == 2 {
|
|
1340
1341
|
// For camera, use portrait orientation: 4:3 becomes 3:4, 16:9 becomes 9:16
|
|
@@ -1343,11 +1344,21 @@ public class CameraPreview: CAPPlugin, CAPBridgedPlugin, CLLocationManagerDelega
|
|
|
1343
1344
|
}
|
|
1344
1345
|
}
|
|
1345
1346
|
|
|
1346
|
-
|
|
1347
|
+
// Center horizontally if x is -1
|
|
1348
|
+
if posX == -1 {
|
|
1349
|
+
finalX = (webViewWidth - finalWidth) / 2
|
|
1350
|
+
} else {
|
|
1351
|
+
finalX = posX
|
|
1352
|
+
}
|
|
1347
1353
|
|
|
1354
|
+
// Center vertically if y is -1
|
|
1348
1355
|
if posY == -1 {
|
|
1349
|
-
|
|
1350
|
-
|
|
1356
|
+
// Use full screen height for centering
|
|
1357
|
+
let screenHeight = UIScreen.main.bounds.size.height
|
|
1358
|
+
finalY = (screenHeight - finalHeight) / 2
|
|
1359
|
+
print("[CameraPreview] Centering vertically: screenHeight=\(screenHeight), finalHeight=\(finalHeight), finalY=\(finalY)")
|
|
1360
|
+
} else {
|
|
1361
|
+
finalY = posY
|
|
1351
1362
|
}
|
|
1352
1363
|
}
|
|
1353
1364
|
|
|
@@ -1456,15 +1467,17 @@ public class CameraPreview: CAPPlugin, CAPBridgedPlugin, CLLocationManagerDelega
|
|
|
1456
1467
|
return
|
|
1457
1468
|
}
|
|
1458
1469
|
|
|
1459
|
-
//
|
|
1460
|
-
|
|
1461
|
-
|
|
1470
|
+
// Reject if values are outside 0-1 range
|
|
1471
|
+
if x < 0 || x > 1 || y < 0 || y > 1 {
|
|
1472
|
+
call.reject("Focus coordinates must be between 0 and 1")
|
|
1473
|
+
return
|
|
1474
|
+
}
|
|
1462
1475
|
|
|
1463
1476
|
DispatchQueue.main.async {
|
|
1464
1477
|
do {
|
|
1465
1478
|
// Convert normalized coordinates to view coordinates
|
|
1466
|
-
let viewX = CGFloat(
|
|
1467
|
-
let viewY = CGFloat(
|
|
1479
|
+
let viewX = CGFloat(x) * self.previewView.bounds.width
|
|
1480
|
+
let viewY = CGFloat(y) * self.previewView.bounds.height
|
|
1468
1481
|
let focusPoint = CGPoint(x: viewX, y: viewY)
|
|
1469
1482
|
|
|
1470
1483
|
// Convert view coordinates to device coordinates
|