react-native-rectangle-doc-scanner 3.45.1 → 3.46.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.
@@ -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,19 +127,21 @@ 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);
131
- await openCropper(normalizedDoc.path);
138
+ // No grid: show original image in check_DP
139
+ console.log('[FullDocScanner] No grid: using original image', normalizedDoc.path);
140
+ setCroppedImageData({
141
+ path: normalizedDoc.path,
142
+ });
132
143
  }
133
- }, [openCropper]);
144
+ }, []);
134
145
  const triggerManualCapture = (0, react_1.useCallback)(() => {
135
146
  console.log('[FullDocScanner] triggerManualCapture called', {
136
147
  processing,
@@ -238,7 +249,7 @@ const FullDocScanner = ({ onResult, onClose, detectionConfig, overlayColor = '#3
238
249
  react_1.default.createElement(react_native_1.Text, { style: styles.confirmButtonText }, mergedStrings.retake)),
239
250
  react_1.default.createElement(react_native_1.TouchableOpacity, { style: [styles.confirmButton, styles.confirmButtonPrimary], onPress: handleConfirm, accessibilityLabel: mergedStrings.confirm, accessibilityRole: "button" },
240
251
  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 },
252
+ 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
253
  react_1.default.createElement(react_native_1.View, { style: styles.overlayTop, pointerEvents: "box-none" },
243
254
  react_1.default.createElement(react_native_1.TouchableOpacity, { style: styles.closeButton, onPress: handleClose, accessibilityLabel: mergedStrings.cancel, accessibilityRole: "button" },
244
255
  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.46.0",
4
4
  "description": "Native-backed document scanner for React Native with customizable overlays.",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -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,19 +173,21 @@ 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);
176
- await openCropper(normalizedDoc.path);
183
+ // No grid: show original image in check_DP
184
+ console.log('[FullDocScanner] No grid: using original image', normalizedDoc.path);
185
+ setCroppedImageData({
186
+ path: normalizedDoc.path,
187
+ });
177
188
  }
178
189
  },
179
- [openCropper],
190
+ [],
180
191
  );
181
192
 
182
193
  const triggerManualCapture = useCallback(() => {
@@ -326,7 +337,7 @@ export const FullDocScanner: React.FC<FullDocScannerProps> = ({
326
337
  <View style={styles.flex}>
327
338
  <DocScanner
328
339
  ref={docScannerRef}
329
- autoCapture={!manualCapture && !isGalleryOpen}
340
+ autoCapture={false}
330
341
  overlayColor={overlayColor}
331
342
  showGrid={showGrid}
332
343
  gridColor={resolvedGridColor}