react-native-rectangle-doc-scanner 3.47.0 → 3.49.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.
@@ -60,7 +60,6 @@ const FullDocScanner = ({ onResult, onClose, detectionConfig, overlayColor = '#3
60
60
  const [rectangleDetected, setRectangleDetected] = (0, react_1.useState)(false);
61
61
  const resolvedGridColor = gridColor ?? overlayColor;
62
62
  const docScannerRef = (0, react_1.useRef)(null);
63
- const manualCapturePending = (0, react_1.useRef)(false);
64
63
  const mergedStrings = (0, react_1.useMemo)(() => ({
65
64
  captureHint: strings?.captureHint,
66
65
  manualHint: strings?.manualHint,
@@ -121,11 +120,6 @@ const FullDocScanner = ({ onResult, onClose, detectionConfig, overlayColor = '#3
121
120
  croppedPath: document.croppedPath,
122
121
  initialPath: document.initialPath,
123
122
  });
124
- // Reset manual capture pending flag
125
- if (manualCapturePending.current) {
126
- console.log('[FullDocScanner] Resetting manualCapturePending');
127
- manualCapturePending.current = false;
128
- }
129
123
  const normalizedDoc = normalizeCapturedDocument(document);
130
124
  // If grid detected and cropped image exists, show it directly in check_DP
131
125
  if (normalizedDoc.croppedPath) {
@@ -143,47 +137,28 @@ const FullDocScanner = ({ onResult, onClose, detectionConfig, overlayColor = '#3
143
137
  const triggerManualCapture = (0, react_1.useCallback)(() => {
144
138
  console.log('[FullDocScanner] triggerManualCapture called', {
145
139
  processing,
146
- manualCapturePending: manualCapturePending.current,
147
140
  hasRef: !!docScannerRef.current,
148
141
  });
149
142
  if (processing) {
150
143
  console.log('[FullDocScanner] Already processing, skipping manual capture');
151
144
  return;
152
145
  }
153
- if (manualCapturePending.current) {
154
- console.log('[FullDocScanner] Manual capture already pending, skipping');
155
- return;
156
- }
157
146
  if (!docScannerRef.current) {
158
147
  console.error('[FullDocScanner] DocScanner ref not available');
159
148
  return;
160
149
  }
161
150
  console.log('[FullDocScanner] Starting manual capture');
162
- manualCapturePending.current = true;
163
- try {
164
- const capturePromise = docScannerRef.current.capture();
165
- console.log('[FullDocScanner] Capture promise:', capturePromise);
166
- if (capturePromise && typeof capturePromise.then === 'function') {
167
- capturePromise
168
- .then((result) => {
169
- console.log('[FullDocScanner] Manual capture success:', result);
170
- manualCapturePending.current = false;
171
- })
172
- .catch((error) => {
173
- console.error('[FullDocScanner] Manual capture failed:', error);
174
- manualCapturePending.current = false;
175
- });
176
- }
177
- else {
178
- console.warn('[FullDocScanner] No promise returned from capture()');
179
- manualCapturePending.current = false;
151
+ docScannerRef.current.capture()
152
+ .then((result) => {
153
+ console.log('[FullDocScanner] Manual capture success:', result);
154
+ })
155
+ .catch((error) => {
156
+ console.error('[FullDocScanner] Manual capture failed:', error);
157
+ if (error instanceof Error && error.message !== 'capture_in_progress') {
158
+ emitError(error, 'Failed to capture image.');
180
159
  }
181
- }
182
- catch (error) {
183
- console.error('[FullDocScanner] Exception during capture:', error);
184
- manualCapturePending.current = false;
185
- }
186
- }, [processing]);
160
+ });
161
+ }, [processing, emitError]);
187
162
  const handleGalleryPick = (0, react_1.useCallback)(async () => {
188
163
  console.log('[FullDocScanner] handleGalleryPick called');
189
164
  if (processing || isGalleryOpen) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-rectangle-doc-scanner",
3
- "version": "3.47.0",
3
+ "version": "3.49.0",
4
4
  "description": "Native-backed document scanner for React Native with customizable overlays.",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -85,7 +85,6 @@ export const FullDocScanner: React.FC<FullDocScannerProps> = ({
85
85
  const [rectangleDetected, setRectangleDetected] = useState(false);
86
86
  const resolvedGridColor = gridColor ?? overlayColor;
87
87
  const docScannerRef = useRef<DocScannerHandle | null>(null);
88
- const manualCapturePending = useRef(false);
89
88
 
90
89
  const mergedStrings = useMemo(
91
90
  () => ({
@@ -165,12 +164,6 @@ export const FullDocScanner: React.FC<FullDocScannerProps> = ({
165
164
  initialPath: document.initialPath,
166
165
  });
167
166
 
168
- // Reset manual capture pending flag
169
- if (manualCapturePending.current) {
170
- console.log('[FullDocScanner] Resetting manualCapturePending');
171
- manualCapturePending.current = false;
172
- }
173
-
174
167
  const normalizedDoc = normalizeCapturedDocument(document);
175
168
 
176
169
  // If grid detected and cropped image exists, show it directly in check_DP
@@ -191,7 +184,6 @@ export const FullDocScanner: React.FC<FullDocScannerProps> = ({
191
184
  const triggerManualCapture = useCallback(() => {
192
185
  console.log('[FullDocScanner] triggerManualCapture called', {
193
186
  processing,
194
- manualCapturePending: manualCapturePending.current,
195
187
  hasRef: !!docScannerRef.current,
196
188
  });
197
189
 
@@ -200,42 +192,27 @@ export const FullDocScanner: React.FC<FullDocScannerProps> = ({
200
192
  return;
201
193
  }
202
194
 
203
- if (manualCapturePending.current) {
204
- console.log('[FullDocScanner] Manual capture already pending, skipping');
205
- return;
206
- }
207
-
208
195
  if (!docScannerRef.current) {
209
196
  console.error('[FullDocScanner] DocScanner ref not available');
210
197
  return;
211
198
  }
212
199
 
213
200
  console.log('[FullDocScanner] Starting manual capture');
214
- manualCapturePending.current = true;
215
201
 
216
- try {
217
- const capturePromise = docScannerRef.current.capture();
218
- console.log('[FullDocScanner] Capture promise:', capturePromise);
219
-
220
- if (capturePromise && typeof capturePromise.then === 'function') {
221
- capturePromise
222
- .then((result) => {
223
- console.log('[FullDocScanner] Manual capture success:', result);
224
- manualCapturePending.current = false;
225
- })
226
- .catch((error: unknown) => {
227
- console.error('[FullDocScanner] Manual capture failed:', error);
228
- manualCapturePending.current = false;
229
- });
230
- } else {
231
- console.warn('[FullDocScanner] No promise returned from capture()');
232
- manualCapturePending.current = false;
233
- }
234
- } catch (error) {
235
- console.error('[FullDocScanner] Exception during capture:', error);
236
- manualCapturePending.current = false;
237
- }
238
- }, [processing]);
202
+ docScannerRef.current.capture()
203
+ .then((result) => {
204
+ console.log('[FullDocScanner] Manual capture success:', result);
205
+ })
206
+ .catch((error: unknown) => {
207
+ console.error('[FullDocScanner] Manual capture failed:', error);
208
+ if (error instanceof Error && error.message !== 'capture_in_progress') {
209
+ emitError(
210
+ error,
211
+ 'Failed to capture image.',
212
+ );
213
+ }
214
+ });
215
+ }, [processing, emitError]);
239
216
 
240
217
  const handleGalleryPick = useCallback(async () => {
241
218
  console.log('[FullDocScanner] handleGalleryPick called');