react-native-rectangle-doc-scanner 3.39.0 → 3.41.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.
@@ -69,13 +69,13 @@ const FullDocScanner = ({ onResult, onClose, detectionConfig, overlayColor = '#3
69
69
  const processingCaptureRef = (0, react_1.useRef)(false);
70
70
  const cropInitializedRef = (0, react_1.useRef)(false);
71
71
  const mergedStrings = (0, react_1.useMemo)(() => ({
72
- captureHint: strings?.captureHint ?? '',
73
- manualHint: strings?.manualHint ?? '',
74
- cancel: strings?.cancel ?? '',
75
- confirm: strings?.confirm ?? '',
76
- retake: strings?.retake ?? '',
77
- cropTitle: strings?.cropTitle ?? '',
78
- processing: strings?.processing ?? '',
72
+ captureHint: strings?.captureHint,
73
+ manualHint: strings?.manualHint,
74
+ cancel: strings?.cancel,
75
+ confirm: strings?.confirm,
76
+ retake: strings?.retake,
77
+ cropTitle: strings?.cropTitle,
78
+ processing: strings?.processing,
79
79
  }), [strings]);
80
80
  (0, react_1.useEffect)(() => {
81
81
  if (!capturedDoc) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-rectangle-doc-scanner",
3
- "version": "3.39.0",
3
+ "version": "3.41.0",
4
4
  "description": "Native-backed document scanner for React Native with customizable overlays.",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -124,13 +124,13 @@ export const FullDocScanner: React.FC<FullDocScannerProps> = ({
124
124
 
125
125
  const mergedStrings = useMemo(
126
126
  () => ({
127
- captureHint: strings?.captureHint ?? '',
128
- manualHint: strings?.manualHint ?? '',
129
- cancel: strings?.cancel ?? '',
130
- confirm: strings?.confirm ?? '',
131
- retake: strings?.retake ?? '',
132
- cropTitle: strings?.cropTitle ?? '',
133
- processing: strings?.processing ?? '',
127
+ captureHint: strings?.captureHint,
128
+ manualHint: strings?.manualHint,
129
+ cancel: strings?.cancel,
130
+ confirm: strings?.confirm,
131
+ retake: strings?.retake,
132
+ cropTitle: strings?.cropTitle,
133
+ processing: strings?.processing,
134
134
  }),
135
135
  [strings],
136
136
  );
@@ -53,18 +53,34 @@
53
53
  }
54
54
 
55
55
  - (void) didDetectRectangle:(CIRectangleFeature *)rectangle withType:(IPDFRectangeType)type {
56
+ // Handle case where no rectangle is detected
57
+ if (!rectangle) {
58
+ NSLog(@"[DocumentScanner] Rectangle not found, resetting counter");
59
+ self.stableCounter = 0;
60
+ _lastDetectionType = type;
61
+ return;
62
+ }
63
+
56
64
  switch (type) {
57
65
  case IPDFRectangeTypeGood:
58
66
  self.stableCounter ++;
67
+ NSLog(@"[DocumentScanner] Good rectangle detected, stableCounter: %ld/%ld", (long)self.stableCounter, (long)self.detectionCountBeforeCapture);
59
68
  break;
60
- default:
61
- self.stableCounter = 0;
69
+ case IPDFRectangeTypeBadAngle:
70
+ case IPDFRectangeTypeTooFar:
71
+ // For bad rectangles, reduce counter slowly instead of resetting
72
+ if (self.stableCounter > 0) {
73
+ self.stableCounter--;
74
+ }
75
+ NSLog(@"[DocumentScanner] Bad rectangle detected (type: %ld), stableCounter: %ld", (long)type, (long)self.stableCounter);
62
76
  break;
63
77
  }
64
78
 
65
79
  _lastDetectionType = type;
66
80
 
67
- if (self.stableCounter > self.detectionCountBeforeCapture){
81
+ if (self.stableCounter >= self.detectionCountBeforeCapture){
82
+ NSLog(@"[DocumentScanner] Auto-capture triggered! stableCounter: %ld >= threshold: %ld", (long)self.stableCounter, (long)self.detectionCountBeforeCapture);
83
+ self.stableCounter = 0; // Reset to prevent multiple captures
68
84
  [self capture];
69
85
  }
70
86
  }
@@ -101,8 +117,11 @@
101
117
  }
102
118
 
103
119
  - (void) capture {
120
+ NSLog(@"[DocumentScanner] capture called");
104
121
  [self captureImageWithCompletionHander:^(UIImage *croppedImage, UIImage *initialImage, CIRectangleFeature *rectangleFeature) {
122
+ NSLog(@"[DocumentScanner] captureImageWithCompletionHander callback - croppedImage: %@, initialImage: %@", croppedImage ? @"YES" : @"NO", initialImage ? @"YES" : @"NO");
105
123
  if (self.onPictureTaken) {
124
+ NSLog(@"[DocumentScanner] Calling onPictureTaken");
106
125
  // Use maximum JPEG quality (1.0) or user's quality setting, whichever is higher
107
126
  // This ensures no quality loss during compression
108
127
  CGFloat imageQuality = MAX(self.quality, 0.95);
@@ -33,7 +33,7 @@ RCT_EXPORT_VIEW_PROPERTY(brightness, float)
33
33
  RCT_EXPORT_VIEW_PROPERTY(contrast, float)
34
34
 
35
35
  RCT_EXPORT_METHOD(capture) {
36
-
36
+ NSLog(@"[RNPdfScannerManager] capture called, scannerView: %@", _scannerView ? @"YES" : @"NO");
37
37
  [_scannerView capture];
38
38
  }
39
39
 
@@ -26,7 +26,8 @@ class PdfScanner extends React.Component {
26
26
  }
27
27
 
28
28
  capture() {
29
- NativeModules.RNPdfScannerManager.capture();
29
+ console.log('[PdfScanner/ios.js] capture called');
30
+ return NativeModules.RNPdfScannerManager.capture();
30
31
  }
31
32
 
32
33
  render() {