react-native-rectangle-doc-scanner 3.45.1 → 3.47.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.
@@ -208,7 +208,7 @@ exports.DocScanner = (0, react_1.forwardRef)(({ onCapture, overlayColor = DEFAUL
208
208
  return (react_1.default.createElement(react_native_1.View, { style: styles.container },
209
209
  react_1.default.createElement(react_native_document_scanner_1.default, { ref: scannerRef, style: styles.scanner, detectionCountBeforeCapture: minStableFrames, overlayColor: overlayColor, enableTorch: enableTorch, quality: normalizedQuality, useBase64: useBase64, manualOnly: !autoCapture, detectionConfig: detectionConfig, onPictureTaken: handlePictureTaken, onError: handleError, onRectangleDetect: handleRectangleDetect }),
210
210
  showGrid && overlayPolygon && (react_1.default.createElement(overlay_1.ScannerOverlay, { active: overlayIsActive, color: gridColor ?? overlayColor, lineWidth: gridLineWidth, polygon: overlayPolygon })),
211
- (showManualCaptureButton || !autoCapture) && (react_1.default.createElement(react_native_1.TouchableOpacity, { style: styles.button, onPress: handleManualCapture })),
211
+ showManualCaptureButton && (react_1.default.createElement(react_native_1.TouchableOpacity, { style: styles.button, onPress: handleManualCapture })),
212
212
  children));
213
213
  });
214
214
  const styles = react_native_1.StyleSheet.create({
@@ -79,6 +79,7 @@ const FullDocScanner = ({ onResult, onClose, detectionConfig, overlayColor = '#3
79
79
  }, [onError]);
80
80
  const openCropper = (0, react_1.useCallback)(async (imagePath) => {
81
81
  try {
82
+ console.log('[FullDocScanner] openCropper called with path:', imagePath);
82
83
  setProcessing(true);
83
84
  const croppedImage = await react_native_image_crop_picker_1.default.openCropper({
84
85
  path: imagePath,
@@ -91,6 +92,10 @@ const FullDocScanner = ({ onResult, onClose, detectionConfig, overlayColor = '#3
91
92
  includeBase64: true,
92
93
  compressImageQuality: 0.9,
93
94
  });
95
+ console.log('[FullDocScanner] Cropper returned:', {
96
+ path: croppedImage.path,
97
+ hasBase64: !!croppedImage.data,
98
+ });
94
99
  setProcessing(false);
95
100
  // Show check_DP confirmation screen
96
101
  setCroppedImageData({
@@ -99,10 +104,14 @@ const FullDocScanner = ({ onResult, onClose, detectionConfig, overlayColor = '#3
99
104
  });
100
105
  }
101
106
  catch (error) {
107
+ console.error('[FullDocScanner] openCropper error:', error);
102
108
  setProcessing(false);
103
109
  if (error?.message !== 'User cancelled image selection') {
104
110
  emitError(error instanceof Error ? error : new Error(String(error)), 'Failed to crop image.');
105
111
  }
112
+ else {
113
+ console.log('[FullDocScanner] User cancelled cropper');
114
+ }
106
115
  }
107
116
  }, [cropWidth, cropHeight, emitError]);
108
117
  const handleCapture = (0, react_1.useCallback)(async (document) => {
@@ -118,16 +127,16 @@ const FullDocScanner = ({ onResult, onClose, detectionConfig, overlayColor = '#3
118
127
  manualCapturePending.current = false;
119
128
  }
120
129
  const normalizedDoc = normalizeCapturedDocument(document);
121
- // Auto-capture: Use already cropped image, skip cropper
122
- if (document.origin === 'auto' && normalizedDoc.croppedPath) {
123
- console.log('[FullDocScanner] Auto-capture: using pre-cropped image', normalizedDoc.croppedPath);
130
+ // If grid detected and cropped image exists, show it directly in check_DP
131
+ if (normalizedDoc.croppedPath) {
132
+ console.log('[FullDocScanner] Grid detected: using pre-cropped image', normalizedDoc.croppedPath);
124
133
  setCroppedImageData({
125
134
  path: normalizedDoc.croppedPath,
126
135
  });
127
136
  }
128
137
  else {
129
- // Manual capture or gallery: Open cropper
130
- console.log('[FullDocScanner] Manual/Gallery capture: opening cropper with', normalizedDoc.path);
138
+ // No grid: open cropper for manual crop
139
+ console.log('[FullDocScanner] No grid detected: opening cropper for manual crop', normalizedDoc.path);
131
140
  await openCropper(normalizedDoc.path);
132
141
  }
133
142
  }, [openCropper]);
@@ -238,7 +247,7 @@ const FullDocScanner = ({ onResult, onClose, detectionConfig, overlayColor = '#3
238
247
  react_1.default.createElement(react_native_1.Text, { style: styles.confirmButtonText }, mergedStrings.retake)),
239
248
  react_1.default.createElement(react_native_1.TouchableOpacity, { style: [styles.confirmButton, styles.confirmButtonPrimary], onPress: handleConfirm, accessibilityLabel: mergedStrings.confirm, accessibilityRole: "button" },
240
249
  react_1.default.createElement(react_native_1.Text, { style: styles.confirmButtonText }, mergedStrings.confirm))))) : (react_1.default.createElement(react_native_1.View, { style: styles.flex },
241
- react_1.default.createElement(DocScanner_1.DocScanner, { ref: docScannerRef, autoCapture: !manualCapture && !isGalleryOpen, overlayColor: overlayColor, showGrid: showGrid, gridColor: resolvedGridColor, gridLineWidth: gridLineWidth, minStableFrames: minStableFrames ?? 6, detectionConfig: detectionConfig, onCapture: handleCapture, onRectangleDetect: handleRectangleDetect, showManualCaptureButton: false },
250
+ react_1.default.createElement(DocScanner_1.DocScanner, { ref: docScannerRef, autoCapture: false, overlayColor: overlayColor, showGrid: showGrid, gridColor: resolvedGridColor, gridLineWidth: gridLineWidth, minStableFrames: minStableFrames ?? 6, detectionConfig: detectionConfig, onCapture: handleCapture, onRectangleDetect: handleRectangleDetect, showManualCaptureButton: false },
242
251
  react_1.default.createElement(react_native_1.View, { style: styles.overlayTop, pointerEvents: "box-none" },
243
252
  react_1.default.createElement(react_native_1.TouchableOpacity, { style: styles.closeButton, onPress: handleClose, accessibilityLabel: mergedStrings.cancel, accessibilityRole: "button" },
244
253
  react_1.default.createElement(react_native_1.Text, { style: styles.closeButtonLabel }, "\u00D7"))),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-rectangle-doc-scanner",
3
- "version": "3.45.1",
3
+ "version": "3.47.0",
4
4
  "description": "Native-backed document scanner for React Native with customizable overlays.",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -317,7 +317,7 @@ export const DocScanner = forwardRef<DocScannerHandle, Props>(
317
317
  polygon={overlayPolygon}
318
318
  />
319
319
  )}
320
- {(showManualCaptureButton || !autoCapture) && (
320
+ {showManualCaptureButton && (
321
321
  <TouchableOpacity style={styles.button} onPress={handleManualCapture} />
322
322
  )}
323
323
  {children}
@@ -114,6 +114,7 @@ export const FullDocScanner: React.FC<FullDocScannerProps> = ({
114
114
  const openCropper = useCallback(
115
115
  async (imagePath: string) => {
116
116
  try {
117
+ console.log('[FullDocScanner] openCropper called with path:', imagePath);
117
118
  setProcessing(true);
118
119
  const croppedImage = await ImageCropPicker.openCropper({
119
120
  path: imagePath,
@@ -127,6 +128,11 @@ export const FullDocScanner: React.FC<FullDocScannerProps> = ({
127
128
  compressImageQuality: 0.9,
128
129
  });
129
130
 
131
+ console.log('[FullDocScanner] Cropper returned:', {
132
+ path: croppedImage.path,
133
+ hasBase64: !!croppedImage.data,
134
+ });
135
+
130
136
  setProcessing(false);
131
137
 
132
138
  // Show check_DP confirmation screen
@@ -135,12 +141,15 @@ export const FullDocScanner: React.FC<FullDocScannerProps> = ({
135
141
  base64: croppedImage.data ?? undefined,
136
142
  });
137
143
  } catch (error) {
144
+ console.error('[FullDocScanner] openCropper error:', error);
138
145
  setProcessing(false);
139
146
  if ((error as any)?.message !== 'User cancelled image selection') {
140
147
  emitError(
141
148
  error instanceof Error ? error : new Error(String(error)),
142
149
  'Failed to crop image.',
143
150
  );
151
+ } else {
152
+ console.log('[FullDocScanner] User cancelled cropper');
144
153
  }
145
154
  }
146
155
  },
@@ -164,15 +173,15 @@ export const FullDocScanner: React.FC<FullDocScannerProps> = ({
164
173
 
165
174
  const normalizedDoc = normalizeCapturedDocument(document);
166
175
 
167
- // Auto-capture: Use already cropped image, skip cropper
168
- if (document.origin === 'auto' && normalizedDoc.croppedPath) {
169
- console.log('[FullDocScanner] Auto-capture: using pre-cropped image', normalizedDoc.croppedPath);
176
+ // If grid detected and cropped image exists, show it directly in check_DP
177
+ if (normalizedDoc.croppedPath) {
178
+ console.log('[FullDocScanner] Grid detected: using pre-cropped image', normalizedDoc.croppedPath);
170
179
  setCroppedImageData({
171
180
  path: normalizedDoc.croppedPath,
172
181
  });
173
182
  } else {
174
- // Manual capture or gallery: Open cropper
175
- console.log('[FullDocScanner] Manual/Gallery capture: opening cropper with', normalizedDoc.path);
183
+ // No grid: open cropper for manual crop
184
+ console.log('[FullDocScanner] No grid detected: opening cropper for manual crop', normalizedDoc.path);
176
185
  await openCropper(normalizedDoc.path);
177
186
  }
178
187
  },
@@ -326,7 +335,7 @@ export const FullDocScanner: React.FC<FullDocScannerProps> = ({
326
335
  <View style={styles.flex}>
327
336
  <DocScanner
328
337
  ref={docScannerRef}
329
- autoCapture={!manualCapture && !isGalleryOpen}
338
+ autoCapture={false}
330
339
  overlayColor={overlayColor}
331
340
  showGrid={showGrid}
332
341
  gridColor={resolvedGridColor}