@capgo/camera-preview 7.8.2 → 7.9.1

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
@@ -7,6 +7,14 @@
7
7
  <h2><a href="https://capgo.app/consulting/?ref=plugin"> Missing a feature? We’ll build the plugin for you 💪</a></h2>
8
8
  </div>
9
9
 
10
+
11
+ ![NPM Version](https://img.shields.io/npm/v/%40capgo%2Fcamera-preview)
12
+ ![NPM Downloads](https://img.shields.io/npm/dy/%40capgo%2Fcamera-preview)
13
+ ![GitHub Repo stars](https://img.shields.io/github/stars/Cap-go/capacitor-camera-preview)
14
+ ![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/Cap-go/capacitor-camera-preview/.github%2Fworkflows%2Fbuild.yml)
15
+ ![GitHub License](https://img.shields.io/github/license/Cap-go/capacitor-camera-preview)
16
+ ![Maintenance](https://img.shields.io/maintenance/yes/2025)
17
+
10
18
  <p>
11
19
  Capacitor plugin that allows camera interaction from Javascript and HTML<br>(based on cordova-plugin-camera-preview).
12
20
  </p>
@@ -695,29 +695,32 @@ public class CameraPreview: CAPPlugin, CAPBridgedPlugin, CLLocationManagerDelega
695
695
  return
696
696
  }
697
697
 
698
- // Disable user interaction during flip
699
- self.previewView.isUserInteractionEnabled = false
698
+ // Ensure UI operations happen on main thread
699
+ DispatchQueue.main.async {
700
+ // Disable user interaction during flip
701
+ self.previewView.isUserInteractionEnabled = false
700
702
 
701
- do {
702
- try self.cameraController.switchCameras()
703
+ do {
704
+ try self.cameraController.switchCameras()
703
705
 
704
- // Update preview layer frame without animation
705
- CATransaction.begin()
706
- CATransaction.setDisableActions(true)
707
- self.cameraController.previewLayer?.frame = self.previewView.bounds
708
- self.cameraController.previewLayer?.videoGravity = .resizeAspectFill
709
- CATransaction.commit()
706
+ // Update preview layer frame without animation
707
+ CATransaction.begin()
708
+ CATransaction.setDisableActions(true)
709
+ self.cameraController.previewLayer?.frame = self.previewView.bounds
710
+ self.cameraController.previewLayer?.videoGravity = .resizeAspectFill
711
+ CATransaction.commit()
710
712
 
711
- self.previewView.isUserInteractionEnabled = true
713
+ self.previewView.isUserInteractionEnabled = true
712
714
 
713
- // Ensure webview remains transparent after flip
714
- self.makeWebViewTransparent()
715
+ // Ensure webview remains transparent after flip
716
+ self.makeWebViewTransparent()
715
717
 
716
- call.resolve()
717
- } catch {
718
- self.previewView.isUserInteractionEnabled = true
719
- print("Failed to flip camera: \(error.localizedDescription)")
720
- call.reject("Failed to flip camera: \(error.localizedDescription)")
718
+ call.resolve()
719
+ } catch {
720
+ self.previewView.isUserInteractionEnabled = true
721
+ print("Failed to flip camera: \(error.localizedDescription)")
722
+ call.reject("Failed to flip camera: \(error.localizedDescription)")
723
+ }
721
724
  }
722
725
  }
723
726
 
@@ -1342,28 +1345,31 @@ public class CameraPreview: CAPPlugin, CAPBridgedPlugin, CLLocationManagerDelega
1342
1345
  return
1343
1346
  }
1344
1347
 
1345
- // Disable user interaction during device swap
1346
- self.previewView.isUserInteractionEnabled = false
1348
+ // Ensure UI operations happen on main thread
1349
+ DispatchQueue.main.async {
1350
+ // Disable user interaction during device swap
1351
+ self.previewView.isUserInteractionEnabled = false
1347
1352
 
1348
- do {
1349
- try self.cameraController.swapToDevice(deviceId: deviceId)
1353
+ do {
1354
+ try self.cameraController.swapToDevice(deviceId: deviceId)
1350
1355
 
1351
- // Update preview layer frame without animation
1352
- CATransaction.begin()
1353
- CATransaction.setDisableActions(true)
1354
- self.cameraController.previewLayer?.frame = self.previewView.bounds
1355
- self.cameraController.previewLayer?.videoGravity = .resizeAspectFill
1356
- CATransaction.commit()
1356
+ // Update preview layer frame without animation
1357
+ CATransaction.begin()
1358
+ CATransaction.setDisableActions(true)
1359
+ self.cameraController.previewLayer?.frame = self.previewView.bounds
1360
+ self.cameraController.previewLayer?.videoGravity = .resizeAspectFill
1361
+ CATransaction.commit()
1357
1362
 
1358
- self.previewView.isUserInteractionEnabled = true
1363
+ self.previewView.isUserInteractionEnabled = true
1359
1364
 
1360
- // Ensure webview remains transparent after device switch
1361
- self.makeWebViewTransparent()
1365
+ // Ensure webview remains transparent after device switch
1366
+ self.makeWebViewTransparent()
1362
1367
 
1363
- call.resolve()
1364
- } catch {
1365
- self.previewView.isUserInteractionEnabled = true
1366
- call.reject("Failed to swap to device \(deviceId): \(error.localizedDescription)")
1368
+ call.resolve()
1369
+ } catch {
1370
+ self.previewView.isUserInteractionEnabled = true
1371
+ call.reject("Failed to swap to device \(deviceId): \(error.localizedDescription)")
1372
+ }
1367
1373
  }
1368
1374
  }
1369
1375
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/camera-preview",
3
- "version": "7.8.2",
3
+ "version": "7.9.1",
4
4
  "description": "Camera preview",
5
5
  "license": "MIT",
6
6
  "repository": {