react-native-rectangle-doc-scanner 3.44.1 → 3.44.3

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.
@@ -108,16 +108,34 @@ const FullDocScanner = ({ onResult, onClose, detectionConfig, overlayColor = '#3
108
108
  console.log('[FullDocScanner] handleCapture called:', {
109
109
  origin: document.origin,
110
110
  path: document.path,
111
+ croppedPath: document.croppedPath,
112
+ initialPath: document.initialPath,
111
113
  });
114
+ // Reset manual capture pending flag
112
115
  if (manualCapturePending.current) {
116
+ console.log('[FullDocScanner] Resetting manualCapturePending');
113
117
  manualCapturePending.current = false;
114
118
  }
115
119
  const normalizedDoc = normalizeCapturedDocument(document);
116
- // Open cropper with the captured image
117
- await openCropper(normalizedDoc.path);
120
+ // Auto-capture: Use already cropped image, skip cropper
121
+ if (document.origin === 'auto' && normalizedDoc.croppedPath) {
122
+ console.log('[FullDocScanner] Auto-capture: using pre-cropped image', normalizedDoc.croppedPath);
123
+ setCroppedImageData({
124
+ path: normalizedDoc.croppedPath,
125
+ });
126
+ }
127
+ else {
128
+ // Manual capture or gallery: Open cropper
129
+ console.log('[FullDocScanner] Manual/Gallery capture: opening cropper with', normalizedDoc.path);
130
+ await openCropper(normalizedDoc.path);
131
+ }
118
132
  }, [openCropper]);
119
133
  const triggerManualCapture = (0, react_1.useCallback)(() => {
120
- console.log('[FullDocScanner] triggerManualCapture called');
134
+ console.log('[FullDocScanner] triggerManualCapture called', {
135
+ processing,
136
+ manualCapturePending: manualCapturePending.current,
137
+ hasRef: !!docScannerRef.current,
138
+ });
121
139
  if (processing) {
122
140
  console.log('[FullDocScanner] Already processing, skipping manual capture');
123
141
  return;
@@ -126,21 +144,33 @@ const FullDocScanner = ({ onResult, onClose, detectionConfig, overlayColor = '#3
126
144
  console.log('[FullDocScanner] Manual capture already pending, skipping');
127
145
  return;
128
146
  }
129
- console.log('[FullDocScanner] Setting manualCapturePending to true');
147
+ if (!docScannerRef.current) {
148
+ console.error('[FullDocScanner] DocScanner ref not available');
149
+ return;
150
+ }
151
+ console.log('[FullDocScanner] Starting manual capture');
130
152
  manualCapturePending.current = true;
131
- const capturePromise = docScannerRef.current?.capture();
132
- if (capturePromise && typeof capturePromise.then === 'function') {
133
- capturePromise
134
- .then(() => {
135
- console.log('[FullDocScanner] Capture success');
136
- })
137
- .catch((error) => {
153
+ try {
154
+ const capturePromise = docScannerRef.current.capture();
155
+ console.log('[FullDocScanner] Capture promise:', capturePromise);
156
+ if (capturePromise && typeof capturePromise.then === 'function') {
157
+ capturePromise
158
+ .then((result) => {
159
+ console.log('[FullDocScanner] Manual capture success:', result);
160
+ manualCapturePending.current = false;
161
+ })
162
+ .catch((error) => {
163
+ console.error('[FullDocScanner] Manual capture failed:', error);
164
+ manualCapturePending.current = false;
165
+ });
166
+ }
167
+ else {
168
+ console.warn('[FullDocScanner] No promise returned from capture()');
138
169
  manualCapturePending.current = false;
139
- console.warn('[FullDocScanner] manual capture failed', error);
140
- });
170
+ }
141
171
  }
142
- else if (!capturePromise) {
143
- console.warn('[FullDocScanner] No capture promise returned');
172
+ catch (error) {
173
+ console.error('[FullDocScanner] Exception during capture:', error);
144
174
  manualCapturePending.current = false;
145
175
  }
146
176
  }, [processing]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-rectangle-doc-scanner",
3
- "version": "3.44.1",
3
+ "version": "3.44.3",
4
4
  "description": "Native-backed document scanner for React Native with customizable overlays.",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -151,46 +151,78 @@ export const FullDocScanner: React.FC<FullDocScannerProps> = ({
151
151
  console.log('[FullDocScanner] handleCapture called:', {
152
152
  origin: document.origin,
153
153
  path: document.path,
154
+ croppedPath: document.croppedPath,
155
+ initialPath: document.initialPath,
154
156
  });
155
157
 
158
+ // Reset manual capture pending flag
156
159
  if (manualCapturePending.current) {
160
+ console.log('[FullDocScanner] Resetting manualCapturePending');
157
161
  manualCapturePending.current = false;
158
162
  }
159
163
 
160
164
  const normalizedDoc = normalizeCapturedDocument(document);
161
165
 
162
- // Open cropper with the captured image
163
- await openCropper(normalizedDoc.path);
166
+ // Auto-capture: Use already cropped image, skip cropper
167
+ if (document.origin === 'auto' && normalizedDoc.croppedPath) {
168
+ console.log('[FullDocScanner] Auto-capture: using pre-cropped image', normalizedDoc.croppedPath);
169
+ setCroppedImageData({
170
+ path: normalizedDoc.croppedPath,
171
+ });
172
+ } else {
173
+ // Manual capture or gallery: Open cropper
174
+ console.log('[FullDocScanner] Manual/Gallery capture: opening cropper with', normalizedDoc.path);
175
+ await openCropper(normalizedDoc.path);
176
+ }
164
177
  },
165
178
  [openCropper],
166
179
  );
167
180
 
168
181
  const triggerManualCapture = useCallback(() => {
169
- console.log('[FullDocScanner] triggerManualCapture called');
182
+ console.log('[FullDocScanner] triggerManualCapture called', {
183
+ processing,
184
+ manualCapturePending: manualCapturePending.current,
185
+ hasRef: !!docScannerRef.current,
186
+ });
187
+
170
188
  if (processing) {
171
189
  console.log('[FullDocScanner] Already processing, skipping manual capture');
172
190
  return;
173
191
  }
192
+
174
193
  if (manualCapturePending.current) {
175
194
  console.log('[FullDocScanner] Manual capture already pending, skipping');
176
195
  return;
177
196
  }
178
197
 
179
- console.log('[FullDocScanner] Setting manualCapturePending to true');
198
+ if (!docScannerRef.current) {
199
+ console.error('[FullDocScanner] DocScanner ref not available');
200
+ return;
201
+ }
202
+
203
+ console.log('[FullDocScanner] Starting manual capture');
180
204
  manualCapturePending.current = true;
181
205
 
182
- const capturePromise = docScannerRef.current?.capture();
183
- if (capturePromise && typeof capturePromise.then === 'function') {
184
- capturePromise
185
- .then(() => {
186
- console.log('[FullDocScanner] Capture success');
187
- })
188
- .catch((error: unknown) => {
189
- manualCapturePending.current = false;
190
- console.warn('[FullDocScanner] manual capture failed', error);
191
- });
192
- } else if (!capturePromise) {
193
- console.warn('[FullDocScanner] No capture promise returned');
206
+ try {
207
+ const capturePromise = docScannerRef.current.capture();
208
+ console.log('[FullDocScanner] Capture promise:', capturePromise);
209
+
210
+ if (capturePromise && typeof capturePromise.then === 'function') {
211
+ capturePromise
212
+ .then((result) => {
213
+ console.log('[FullDocScanner] Manual capture success:', result);
214
+ manualCapturePending.current = false;
215
+ })
216
+ .catch((error: unknown) => {
217
+ console.error('[FullDocScanner] Manual capture failed:', error);
218
+ manualCapturePending.current = false;
219
+ });
220
+ } else {
221
+ console.warn('[FullDocScanner] No promise returned from capture()');
222
+ manualCapturePending.current = false;
223
+ }
224
+ } catch (error) {
225
+ console.error('[FullDocScanner] Exception during capture:', error);
194
226
  manualCapturePending.current = false;
195
227
  }
196
228
  }, [processing]);