react-native-rectangle-doc-scanner 3.50.0 → 3.52.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.
@@ -27,7 +27,6 @@ export interface FullDocScannerProps {
27
27
  gridLineWidth?: number;
28
28
  showGrid?: boolean;
29
29
  strings?: FullDocScannerStrings;
30
- manualCapture?: boolean;
31
30
  minStableFrames?: number;
32
31
  onError?: (error: Error) => void;
33
32
  enableGallery?: boolean;
@@ -53,7 +53,7 @@ const normalizeCapturedDocument = (document) => {
53
53
  croppedPath: document.croppedPath ? stripFileUri(document.croppedPath) : null,
54
54
  };
55
55
  };
56
- const FullDocScanner = ({ onResult, onClose, detectionConfig, overlayColor = '#3170f3', gridColor, gridLineWidth, showGrid, strings, manualCapture = false, minStableFrames, onError, enableGallery = true, cropWidth = 1200, cropHeight = 1600, }) => {
56
+ const FullDocScanner = ({ onResult, onClose, detectionConfig, overlayColor = '#3170f3', gridColor, gridLineWidth, showGrid, strings, minStableFrames, onError, enableGallery = true, cropWidth = 1200, cropHeight = 1600, }) => {
57
57
  const [processing, setProcessing] = (0, react_1.useState)(false);
58
58
  const [croppedImageData, setCroppedImageData] = (0, react_1.useState)(null);
59
59
  const [isGalleryOpen, setIsGalleryOpen] = (0, react_1.useState)(false);
@@ -120,8 +120,14 @@ const FullDocScanner = ({ onResult, onClose, detectionConfig, overlayColor = '#3
120
120
  path: document.path,
121
121
  croppedPath: document.croppedPath,
122
122
  initialPath: document.initialPath,
123
+ captureMode: captureModeRef.current,
123
124
  });
124
125
  const captureMode = captureModeRef.current;
126
+ // Ignore auto captures - only process manual captures
127
+ if (!captureMode) {
128
+ console.log('[FullDocScanner] Ignoring auto capture - only manual captures allowed');
129
+ return;
130
+ }
125
131
  captureModeRef.current = null;
126
132
  const normalizedDoc = normalizeCapturedDocument(document);
127
133
  if (captureMode === 'no-grid') {
@@ -144,16 +150,22 @@ const FullDocScanner = ({ onResult, onClose, detectionConfig, overlayColor = '#3
144
150
  processing,
145
151
  hasRef: !!docScannerRef.current,
146
152
  rectangleDetected,
153
+ currentCaptureMode: captureModeRef.current,
147
154
  });
148
155
  if (processing) {
149
156
  console.log('[FullDocScanner] Already processing, skipping manual capture');
150
157
  return;
151
158
  }
159
+ // Check if capture is already in progress
160
+ if (captureModeRef.current !== null) {
161
+ console.log('[FullDocScanner] Capture already in progress, skipping');
162
+ return;
163
+ }
152
164
  if (!docScannerRef.current) {
153
165
  console.error('[FullDocScanner] DocScanner ref not available');
154
166
  return;
155
167
  }
156
- console.log('[FullDocScanner] Starting manual capture');
168
+ console.log('[FullDocScanner] Starting manual capture, grid detected:', rectangleDetected);
157
169
  captureModeRef.current = rectangleDetected ? 'grid' : 'no-grid';
158
170
  docScannerRef.current.capture()
159
171
  .then((result) => {
@@ -231,7 +243,7 @@ const FullDocScanner = ({ onResult, onClose, detectionConfig, overlayColor = '#3
231
243
  react_1.default.createElement(react_native_1.Text, { style: styles.confirmButtonText }, mergedStrings.retake)),
232
244
  react_1.default.createElement(react_native_1.TouchableOpacity, { style: [styles.confirmButton, styles.confirmButtonPrimary], onPress: handleConfirm, accessibilityLabel: mergedStrings.confirm, accessibilityRole: "button" },
233
245
  react_1.default.createElement(react_native_1.Text, { style: styles.confirmButtonText }, mergedStrings.confirm))))) : (react_1.default.createElement(react_native_1.View, { style: styles.flex },
234
- 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 },
246
+ react_1.default.createElement(DocScanner_1.DocScanner, { ref: docScannerRef, autoCapture: true, overlayColor: overlayColor, showGrid: showGrid, gridColor: resolvedGridColor, gridLineWidth: gridLineWidth, minStableFrames: minStableFrames ?? 6, detectionConfig: detectionConfig, onCapture: handleCapture, onRectangleDetect: handleRectangleDetect, showManualCaptureButton: false },
235
247
  react_1.default.createElement(react_native_1.View, { style: styles.overlayTop, pointerEvents: "box-none" },
236
248
  react_1.default.createElement(react_native_1.TouchableOpacity, { style: styles.closeButton, onPress: handleClose, accessibilityLabel: mergedStrings.cancel, accessibilityRole: "button" },
237
249
  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.50.0",
3
+ "version": "3.52.0",
4
4
  "description": "Native-backed document scanner for React Native with customizable overlays.",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -55,7 +55,6 @@ export interface FullDocScannerProps {
55
55
  gridLineWidth?: number;
56
56
  showGrid?: boolean;
57
57
  strings?: FullDocScannerStrings;
58
- manualCapture?: boolean;
59
58
  minStableFrames?: number;
60
59
  onError?: (error: Error) => void;
61
60
  enableGallery?: boolean;
@@ -72,7 +71,6 @@ export const FullDocScanner: React.FC<FullDocScannerProps> = ({
72
71
  gridLineWidth,
73
72
  showGrid,
74
73
  strings,
75
- manualCapture = false,
76
74
  minStableFrames,
77
75
  onError,
78
76
  enableGallery = true,
@@ -163,9 +161,17 @@ export const FullDocScanner: React.FC<FullDocScannerProps> = ({
163
161
  path: document.path,
164
162
  croppedPath: document.croppedPath,
165
163
  initialPath: document.initialPath,
164
+ captureMode: captureModeRef.current,
166
165
  });
167
166
 
168
167
  const captureMode = captureModeRef.current;
168
+
169
+ // Ignore auto captures - only process manual captures
170
+ if (!captureMode) {
171
+ console.log('[FullDocScanner] Ignoring auto capture - only manual captures allowed');
172
+ return;
173
+ }
174
+
169
175
  captureModeRef.current = null;
170
176
 
171
177
  const normalizedDoc = normalizeCapturedDocument(document);
@@ -195,6 +201,7 @@ export const FullDocScanner: React.FC<FullDocScannerProps> = ({
195
201
  processing,
196
202
  hasRef: !!docScannerRef.current,
197
203
  rectangleDetected,
204
+ currentCaptureMode: captureModeRef.current,
198
205
  });
199
206
 
200
207
  if (processing) {
@@ -202,12 +209,18 @@ export const FullDocScanner: React.FC<FullDocScannerProps> = ({
202
209
  return;
203
210
  }
204
211
 
212
+ // Check if capture is already in progress
213
+ if (captureModeRef.current !== null) {
214
+ console.log('[FullDocScanner] Capture already in progress, skipping');
215
+ return;
216
+ }
217
+
205
218
  if (!docScannerRef.current) {
206
219
  console.error('[FullDocScanner] DocScanner ref not available');
207
220
  return;
208
221
  }
209
222
 
210
- console.log('[FullDocScanner] Starting manual capture');
223
+ console.log('[FullDocScanner] Starting manual capture, grid detected:', rectangleDetected);
211
224
 
212
225
  captureModeRef.current = rectangleDetected ? 'grid' : 'no-grid';
213
226
 
@@ -326,7 +339,7 @@ export const FullDocScanner: React.FC<FullDocScannerProps> = ({
326
339
  <View style={styles.flex}>
327
340
  <DocScanner
328
341
  ref={docScannerRef}
329
- autoCapture={false}
342
+ autoCapture={true}
330
343
  overlayColor={overlayColor}
331
344
  showGrid={showGrid}
332
345
  gridColor={resolvedGridColor}