@capgo/camera-preview 7.4.0-beta.12 → 7.4.0-beta.13
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 +18 -0
- 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 +27 -0
- package/android/src/main/java/com/ahm/capacitor/camera/preview/CameraXView.java +59 -25
- package/dist/docs.json +29 -0
- package/dist/esm/definitions.d.ts +13 -0
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/web.d.ts +4 -0
- package/dist/esm/web.js +33 -0
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +33 -0
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +33 -0
- package/dist/plugin.js.map +1 -1
- package/ios/Sources/CapgoCameraPreview/CameraController.swift +47 -3
- package/ios/Sources/CapgoCameraPreview/Plugin.swift +39 -1
- package/package.json +2 -2
|
@@ -259,7 +259,7 @@ extension CameraController {
|
|
|
259
259
|
|
|
260
260
|
// Update session preset based on aspect ratio if needed
|
|
261
261
|
var targetPreset: AVCaptureSession.Preset = .high // Default to high quality
|
|
262
|
-
|
|
262
|
+
|
|
263
263
|
if let aspectRatio = aspectRatio {
|
|
264
264
|
switch aspectRatio {
|
|
265
265
|
case "16:9":
|
|
@@ -270,7 +270,7 @@ extension CameraController {
|
|
|
270
270
|
targetPreset = .high
|
|
271
271
|
}
|
|
272
272
|
}
|
|
273
|
-
|
|
273
|
+
|
|
274
274
|
// Always try to set the best preset available
|
|
275
275
|
if captureSession.canSetSessionPreset(targetPreset) {
|
|
276
276
|
captureSession.sessionPreset = targetPreset
|
|
@@ -312,7 +312,7 @@ extension CameraController {
|
|
|
312
312
|
// Optimize preview layer for better quality
|
|
313
313
|
self.previewLayer?.connection?.videoOrientation = .portrait
|
|
314
314
|
self.previewLayer?.isOpaque = true
|
|
315
|
-
|
|
315
|
+
|
|
316
316
|
// Set contentsScale for retina display quality
|
|
317
317
|
self.previewLayer?.contentsScale = UIScreen.main.scale
|
|
318
318
|
|
|
@@ -785,6 +785,50 @@ extension CameraController {
|
|
|
785
785
|
}
|
|
786
786
|
}
|
|
787
787
|
|
|
788
|
+
func setFocus(at point: CGPoint) throws {
|
|
789
|
+
var currentCamera: AVCaptureDevice?
|
|
790
|
+
switch currentCameraPosition {
|
|
791
|
+
case .front:
|
|
792
|
+
currentCamera = self.frontCamera
|
|
793
|
+
case .rear:
|
|
794
|
+
currentCamera = self.rearCamera
|
|
795
|
+
default: break
|
|
796
|
+
}
|
|
797
|
+
|
|
798
|
+
guard let device = currentCamera else {
|
|
799
|
+
throw CameraControllerError.noCamerasAvailable
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
guard device.isFocusPointOfInterestSupported else {
|
|
803
|
+
// Device doesn't support focus point of interest
|
|
804
|
+
return
|
|
805
|
+
}
|
|
806
|
+
|
|
807
|
+
do {
|
|
808
|
+
try device.lockForConfiguration()
|
|
809
|
+
|
|
810
|
+
// Set focus mode to auto if supported
|
|
811
|
+
if device.isFocusModeSupported(.autoFocus) {
|
|
812
|
+
device.focusMode = .autoFocus
|
|
813
|
+
} else if device.isFocusModeSupported(.continuousAutoFocus) {
|
|
814
|
+
device.focusMode = .continuousAutoFocus
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
// Set the focus point
|
|
818
|
+
device.focusPointOfInterest = point
|
|
819
|
+
|
|
820
|
+
// Also set exposure point if supported
|
|
821
|
+
if device.isExposurePointOfInterestSupported && device.isExposureModeSupported(.autoExpose) {
|
|
822
|
+
device.exposureMode = .autoExpose
|
|
823
|
+
device.exposurePointOfInterest = point
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
device.unlockForConfiguration()
|
|
827
|
+
} catch {
|
|
828
|
+
throw CameraControllerError.unknown
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
|
|
788
832
|
func getFlashMode() throws -> String {
|
|
789
833
|
switch self.flashMode {
|
|
790
834
|
case .off:
|
|
@@ -64,7 +64,8 @@ public class CameraPreview: CAPPlugin, CAPBridgedPlugin, CLLocationManagerDelega
|
|
|
64
64
|
CAPPluginMethod(name: "setGridMode", returnType: CAPPluginReturnPromise),
|
|
65
65
|
CAPPluginMethod(name: "getGridMode", returnType: CAPPluginReturnPromise),
|
|
66
66
|
CAPPluginMethod(name: "getPreviewSize", returnType: CAPPluginReturnPromise),
|
|
67
|
-
CAPPluginMethod(name: "setPreviewSize", returnType: CAPPluginReturnPromise)
|
|
67
|
+
CAPPluginMethod(name: "setPreviewSize", returnType: CAPPluginReturnPromise),
|
|
68
|
+
CAPPluginMethod(name: "setFocus", returnType: CAPPluginReturnPromise)
|
|
68
69
|
]
|
|
69
70
|
// Camera state tracking
|
|
70
71
|
private var isInitializing: Bool = false
|
|
@@ -1443,4 +1444,41 @@ public class CameraPreview: CAPPlugin, CAPBridgedPlugin, CLLocationManagerDelega
|
|
|
1443
1444
|
call.resolve(result)
|
|
1444
1445
|
}
|
|
1445
1446
|
}
|
|
1447
|
+
|
|
1448
|
+
@objc func setFocus(_ call: CAPPluginCall) {
|
|
1449
|
+
guard isInitialized else {
|
|
1450
|
+
call.reject("Camera not initialized")
|
|
1451
|
+
return
|
|
1452
|
+
}
|
|
1453
|
+
|
|
1454
|
+
guard let x = call.getFloat("x"), let y = call.getFloat("y") else {
|
|
1455
|
+
call.reject("x and y parameters are required")
|
|
1456
|
+
return
|
|
1457
|
+
}
|
|
1458
|
+
|
|
1459
|
+
// Ensure values are between 0 and 1
|
|
1460
|
+
let normalizedX = max(0, min(1, x))
|
|
1461
|
+
let normalizedY = max(0, min(1, y))
|
|
1462
|
+
|
|
1463
|
+
DispatchQueue.main.async {
|
|
1464
|
+
do {
|
|
1465
|
+
// Convert normalized coordinates to view coordinates
|
|
1466
|
+
let viewX = CGFloat(normalizedX) * self.previewView.bounds.width
|
|
1467
|
+
let viewY = CGFloat(normalizedY) * self.previewView.bounds.height
|
|
1468
|
+
let focusPoint = CGPoint(x: viewX, y: viewY)
|
|
1469
|
+
|
|
1470
|
+
// Convert view coordinates to device coordinates
|
|
1471
|
+
guard let previewLayer = self.cameraController.previewLayer else {
|
|
1472
|
+
call.reject("Preview layer not available")
|
|
1473
|
+
return
|
|
1474
|
+
}
|
|
1475
|
+
let devicePoint = previewLayer.captureDevicePointConverted(fromLayerPoint: focusPoint)
|
|
1476
|
+
|
|
1477
|
+
try self.cameraController.setFocus(at: devicePoint)
|
|
1478
|
+
call.resolve()
|
|
1479
|
+
} catch {
|
|
1480
|
+
call.reject("Failed to set focus: \(error.localizedDescription)")
|
|
1481
|
+
}
|
|
1482
|
+
}
|
|
1483
|
+
}
|
|
1446
1484
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capgo/camera-preview",
|
|
3
|
-
"version": "7.4.0-beta.
|
|
3
|
+
"version": "7.4.0-beta.13",
|
|
4
4
|
"description": "Camera preview",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
],
|
|
29
29
|
"scripts": {
|
|
30
30
|
"verify": "npm run verify:ios && npm run verify:android && npm run verify:web",
|
|
31
|
-
"verify:ios": "
|
|
31
|
+
"verify:ios": "xcodebuild -scheme CapgoCameraPreview -destination generic/platform=iOS",
|
|
32
32
|
"verify:android": "cd android && ./gradlew clean build test && cd ..",
|
|
33
33
|
"verify:web": "npm run build",
|
|
34
34
|
"lint": "npm run eslint && npm run prettier -- --check && npm run swiftlint -- lint",
|