@momo-kits/camerakit 0.158.1-beta.2 → 0.158.1-sp.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.
|
@@ -84,11 +84,13 @@ public class CameraView: UIView {
|
|
|
84
84
|
private func setupCamera() {
|
|
85
85
|
if hasPropBeenSetup && hasPermissionBeenGranted && !hasCameraBeenSetup {
|
|
86
86
|
hasCameraBeenSetup = true
|
|
87
|
+
// Always pass supportedBarcodeType when scanBarcode is enabled.
|
|
88
|
+
// onReadCode may arrive in a later prop batch (common when package is consumed externally),
|
|
89
|
+
// and the barcode callback in isBarcodeScannerEnabled resolves onReadCode at detection time.
|
|
87
90
|
#if targetEnvironment(macCatalyst)
|
|
88
|
-
|
|
89
|
-
camera.setup(cameraType: .front, supportedBarcodeType: scanBarcode && onReadCode != nil ? supportedBarcodeType : [])
|
|
91
|
+
camera.setup(cameraType: .front, supportedBarcodeType: scanBarcode ? supportedBarcodeType : [])
|
|
90
92
|
#else
|
|
91
|
-
camera.setup(cameraType: cameraType, supportedBarcodeType: scanBarcode
|
|
93
|
+
camera.setup(cameraType: cameraType, supportedBarcodeType: scanBarcode ? supportedBarcodeType : [])
|
|
92
94
|
#endif
|
|
93
95
|
}
|
|
94
96
|
}
|
|
@@ -518,7 +518,10 @@ class RealCamera: NSObject, CameraProtocol, AVCaptureMetadataOutputObjectsDelega
|
|
|
518
518
|
onBarcodeRead: ((_ barcode: String,_ codeFormat:CodeFormat) -> Void)?) {
|
|
519
519
|
sessionQueue.async {
|
|
520
520
|
self.onBarcodeRead = onBarcodeRead
|
|
521
|
-
|
|
521
|
+
|
|
522
|
+
// Skip if session hasn't been set up yet — setup() will configure barcode types
|
|
523
|
+
guard self.setupResult == .success else { return }
|
|
524
|
+
|
|
522
525
|
let availableTypes = self.metadataOutput.availableMetadataObjectTypes
|
|
523
526
|
let newTypes: [AVMetadataObject.ObjectType]
|
|
524
527
|
if isEnabled && onBarcodeRead != nil {
|
|
@@ -587,7 +590,16 @@ class RealCamera: NSObject, CameraProtocol, AVCaptureMetadataOutputObjectsDelega
|
|
|
587
590
|
self.videoDataOutput.videoSettings = [
|
|
588
591
|
kCVPixelBufferPixelFormatTypeKey as String: kCVPixelFormatType_420YpCbCr8BiPlanarFullRange
|
|
589
592
|
]
|
|
590
|
-
|
|
593
|
+
|
|
594
|
+
// Add videoDataOutput to session if not already added (handles late prop arrival)
|
|
595
|
+
if self.setupResult == .success && !self.session.outputs.contains(self.videoDataOutput) {
|
|
596
|
+
self.session.beginConfiguration()
|
|
597
|
+
if self.session.canAddOutput(self.videoDataOutput) {
|
|
598
|
+
self.session.addOutput(self.videoDataOutput)
|
|
599
|
+
}
|
|
600
|
+
self.session.commitConfiguration()
|
|
601
|
+
}
|
|
602
|
+
|
|
591
603
|
} else {
|
|
592
604
|
self.textRequest = nil
|
|
593
605
|
}
|