react-native-rectangle-doc-scanner 3.65.0 → 3.66.0
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/package.json
CHANGED
|
@@ -153,7 +153,16 @@
|
|
|
153
153
|
[session addOutput:self.photoOutput];
|
|
154
154
|
NSLog(@"[IPDFCamera] Using AVCapturePhotoOutput (modern API)");
|
|
155
155
|
} else {
|
|
156
|
-
NSLog(@"[IPDFCamera]
|
|
156
|
+
NSLog(@"[IPDFCamera] WARNING: Cannot add AVCapturePhotoOutput, falling back to AVCaptureStillImageOutput");
|
|
157
|
+
self.photoOutput = nil;
|
|
158
|
+
// Fallback to legacy API
|
|
159
|
+
self.stillImageOutput = [[AVCaptureStillImageOutput alloc] init];
|
|
160
|
+
if ([session canAddOutput:self.stillImageOutput]) {
|
|
161
|
+
[session addOutput:self.stillImageOutput];
|
|
162
|
+
NSLog(@"[IPDFCamera] Fallback successful: Using AVCaptureStillImageOutput");
|
|
163
|
+
} else {
|
|
164
|
+
NSLog(@"[IPDFCamera] CRITICAL ERROR: Cannot add any capture output!");
|
|
165
|
+
}
|
|
157
166
|
}
|
|
158
167
|
} else {
|
|
159
168
|
// Fallback for older iOS versions (< iOS 10)
|
|
@@ -464,19 +473,19 @@
|
|
|
464
473
|
|
|
465
474
|
// Use modern AVCapturePhotoOutput API (iOS 10+)
|
|
466
475
|
if (@available(iOS 10.0, *)) {
|
|
467
|
-
if (
|
|
468
|
-
NSLog(@"[IPDFCameraViewController]
|
|
469
|
-
|
|
470
|
-
self.
|
|
471
|
-
[weakSelf hideGLKView:NO completion:nil];
|
|
476
|
+
if (self.photoOutput) {
|
|
477
|
+
NSLog(@"[IPDFCameraViewController] Using AVCapturePhotoOutput to capture");
|
|
478
|
+
AVCapturePhotoSettings *settings = [AVCapturePhotoSettings photoSettings];
|
|
479
|
+
[self.photoOutput capturePhotoWithSettings:settings delegate:self];
|
|
472
480
|
return;
|
|
473
481
|
}
|
|
474
482
|
|
|
475
|
-
NSLog(@"[IPDFCameraViewController]
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
483
|
+
NSLog(@"[IPDFCameraViewController] photoOutput is nil, trying fallback to stillImageOutput");
|
|
484
|
+
// Fallback to legacy API if photoOutput is not available
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
// Fallback: Use legacy AVCaptureStillImageOutput (iOS < 10 or when photoOutput failed)
|
|
488
|
+
{
|
|
480
489
|
if (!self.stillImageOutput) {
|
|
481
490
|
NSLog(@"[IPDFCameraViewController] ERROR: stillImageOutput is nil");
|
|
482
491
|
_isCapturing = NO;
|
|
@@ -527,6 +536,7 @@
|
|
|
527
536
|
return;
|
|
528
537
|
}
|
|
529
538
|
|
|
539
|
+
// iOS 11+ uses fileDataRepresentation
|
|
530
540
|
NSData *imageData = [photo fileDataRepresentation];
|
|
531
541
|
if (!imageData) {
|
|
532
542
|
NSLog(@"[IPDFCameraViewController] ERROR: Failed to get image data from photo");
|
|
@@ -536,17 +546,48 @@
|
|
|
536
546
|
return;
|
|
537
547
|
}
|
|
538
548
|
|
|
549
|
+
NSLog(@"[IPDFCameraViewController] Got image data from AVCapturePhoto, size: %lu bytes", (unsigned long)imageData.length);
|
|
539
550
|
[self processImageData:imageData];
|
|
540
551
|
}
|
|
541
552
|
|
|
542
553
|
// AVCapturePhotoCaptureDelegate method for iOS 10
|
|
543
554
|
- (void)captureOutput:(AVCapturePhotoOutput *)output didFinishProcessingPhotoSampleBuffer:(CMSampleBufferRef)photoSampleBuffer previewPhotoSampleBuffer:(CMSampleBufferRef)previewPhotoSampleBuffer resolvedSettings:(AVCaptureResolvedPhotoSettings *)resolvedSettings bracketSettings:(AVCaptureBracketedStillImageSettings *)bracketSettings error:(NSError *)error API_DEPRECATED("Use -captureOutput:didFinishProcessingPhoto:error: instead.", ios(10.0, 11.0)) {
|
|
544
555
|
NSLog(@"[IPDFCameraViewController] didFinishProcessingPhotoSampleBuffer called (iOS 10)");
|
|
545
|
-
|
|
556
|
+
|
|
557
|
+
if (error) {
|
|
558
|
+
NSLog(@"[IPDFCameraViewController] ERROR in didFinishProcessingPhotoSampleBuffer: %@", error);
|
|
559
|
+
_isCapturing = NO;
|
|
560
|
+
self.captureCompletionHandler = nil;
|
|
561
|
+
[self hideGLKView:NO completion:nil];
|
|
562
|
+
return;
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
if (!photoSampleBuffer) {
|
|
566
|
+
NSLog(@"[IPDFCameraViewController] ERROR: photoSampleBuffer is nil");
|
|
567
|
+
_isCapturing = NO;
|
|
568
|
+
self.captureCompletionHandler = nil;
|
|
569
|
+
[self hideGLKView:NO completion:nil];
|
|
570
|
+
return;
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
// iOS 10: Use AVCapturePhotoOutput's method for converting sample buffer
|
|
574
|
+
NSData *imageData = [AVCapturePhotoOutput JPEGPhotoDataRepresentationForJPEGSampleBuffer:photoSampleBuffer previewPhotoSampleBuffer:previewPhotoSampleBuffer];
|
|
575
|
+
|
|
576
|
+
if (!imageData) {
|
|
577
|
+
NSLog(@"[IPDFCameraViewController] ERROR: Failed to create JPEG data from photo sample buffer");
|
|
578
|
+
_isCapturing = NO;
|
|
579
|
+
self.captureCompletionHandler = nil;
|
|
580
|
+
[self hideGLKView:NO completion:nil];
|
|
581
|
+
return;
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
NSLog(@"[IPDFCameraViewController] Got image data from photo sample buffer (iOS 10), size: %lu bytes", (unsigned long)imageData.length);
|
|
585
|
+
[self processImageData:imageData];
|
|
546
586
|
}
|
|
547
587
|
|
|
588
|
+
// Helper method for legacy AVCaptureStillImageOutput (iOS < 10)
|
|
548
589
|
- (void)handleCapturedImageData:(CMSampleBufferRef)sampleBuffer error:(NSError *)error {
|
|
549
|
-
NSLog(@"[IPDFCameraViewController] handleCapturedImageData called, error=%@, buffer=%@", error, sampleBuffer ? @"YES" : @"NO");
|
|
590
|
+
NSLog(@"[IPDFCameraViewController] handleCapturedImageData called (legacy), error=%@, buffer=%@", error, sampleBuffer ? @"YES" : @"NO");
|
|
550
591
|
|
|
551
592
|
if (error) {
|
|
552
593
|
NSLog(@"[IPDFCameraViewController] ERROR capturing image: %@", error);
|
|
@@ -564,16 +605,18 @@
|
|
|
564
605
|
return;
|
|
565
606
|
}
|
|
566
607
|
|
|
608
|
+
// iOS < 10: Use AVCaptureStillImageOutput's method
|
|
567
609
|
NSData *imageData = [AVCaptureStillImageOutput jpegStillImageNSDataRepresentation:sampleBuffer];
|
|
568
610
|
|
|
569
611
|
if (!imageData) {
|
|
570
|
-
NSLog(@"[IPDFCameraViewController] ERROR: Failed to create image data from sample buffer");
|
|
612
|
+
NSLog(@"[IPDFCameraViewController] ERROR: Failed to create image data from sample buffer (legacy)");
|
|
571
613
|
_isCapturing = NO;
|
|
572
614
|
self.captureCompletionHandler = nil;
|
|
573
615
|
[self hideGLKView:NO completion:nil];
|
|
574
616
|
return;
|
|
575
617
|
}
|
|
576
618
|
|
|
619
|
+
NSLog(@"[IPDFCameraViewController] Got image data from still image output (legacy), size: %lu bytes", (unsigned long)imageData.length);
|
|
577
620
|
[self processImageData:imageData];
|
|
578
621
|
}
|
|
579
622
|
|
|
@@ -34,8 +34,22 @@ RCT_EXPORT_VIEW_PROPERTY(quality, float)
|
|
|
34
34
|
RCT_EXPORT_VIEW_PROPERTY(brightness, float)
|
|
35
35
|
RCT_EXPORT_VIEW_PROPERTY(contrast, float)
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
// Main capture method - uses the last created scanner view
|
|
38
|
+
RCT_EXPORT_METHOD(capture) {
|
|
39
|
+
NSLog(@"[RNPdfScannerManager] capture called, scannerView: %@", _scannerView ? @"YES" : @"NO");
|
|
40
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
41
|
+
if (!self->_scannerView) {
|
|
42
|
+
NSLog(@"[RNPdfScannerManager] ERROR: No scanner view available");
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
NSLog(@"[RNPdfScannerManager] Calling capture on view: %@", self->_scannerView);
|
|
46
|
+
[self->_scannerView capture];
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Alternative method that takes reactTag - for future use
|
|
51
|
+
RCT_EXPORT_METHOD(captureWithTag:(nonnull NSNumber *)reactTag) {
|
|
52
|
+
NSLog(@"[RNPdfScannerManager] captureWithTag called with reactTag: %@", reactTag);
|
|
39
53
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
40
54
|
UIView *view = [self.bridge.uiManager viewForReactTag:reactTag];
|
|
41
55
|
if (!view || ![view isKindOfClass:[DocumentScannerView class]]) {
|
|
@@ -48,12 +62,6 @@ RCT_EXPORT_METHOD(capture:(nonnull NSNumber *)reactTag) {
|
|
|
48
62
|
});
|
|
49
63
|
}
|
|
50
64
|
|
|
51
|
-
// Deprecated - kept for backward compatibility
|
|
52
|
-
RCT_EXPORT_METHOD(captureGlobal) {
|
|
53
|
-
NSLog(@"[RNPdfScannerManager] captureGlobal called (deprecated), scannerView: %@", _scannerView ? @"YES" : @"NO");
|
|
54
|
-
[_scannerView capture];
|
|
55
|
-
}
|
|
56
|
-
|
|
57
65
|
- (UIView*) view {
|
|
58
66
|
_scannerView = [[DocumentScannerView alloc] init];
|
|
59
67
|
// Force layout update
|