react-native-rectangle-doc-scanner 3.34.0 → 3.35.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.
@@ -120,13 +120,16 @@ const FullDocScanner = ({ onResult, onClose, detectionConfig, overlayColor = '#3
120
120
  }
121
121
  }, [onError]);
122
122
  const processAutoCapture = (0, react_1.useCallback)(async (document) => {
123
+ console.log('[FullDocScanner] processAutoCapture started');
123
124
  manualCapturePending.current = false;
124
125
  const normalizedDoc = normalizeCapturedDocument(document);
125
126
  const cropManager = react_native_1.NativeModules.CustomCropManager;
126
127
  if (!cropManager?.crop) {
128
+ console.error('[FullDocScanner] CustomCropManager.crop is not available');
127
129
  emitError(new Error('CustomCropManager.crop is not available'));
128
130
  return;
129
131
  }
132
+ console.log('[FullDocScanner] Setting processing to true');
130
133
  setProcessing(true);
131
134
  try {
132
135
  const size = await resolveImageSize(normalizedDoc.path, normalizedDoc.width, normalizedDoc.height);
@@ -144,6 +147,11 @@ const FullDocScanner = ({ onResult, onClose, detectionConfig, overlayColor = '#3
144
147
  ? (0, coordinate_1.scaleRectangle)(rectangleBase, baseWidth || targetWidth, baseHeight || targetHeight, targetWidth, targetHeight)
145
148
  : null;
146
149
  const rectangleToUse = scaledRectangle ?? (0, coordinate_1.createFullImageRectangle)(targetWidth, targetHeight);
150
+ console.log('[FullDocScanner] Calling CustomCropManager.crop with:', {
151
+ rectangle: rectangleToUse,
152
+ imageUri: ensureFileUri(normalizedDoc.path),
153
+ targetSize: { width: targetWidth, height: targetHeight },
154
+ });
147
155
  const base64 = await new Promise((resolve, reject) => {
148
156
  cropManager.crop({
149
157
  topLeft: rectangleToUse.topLeft,
@@ -154,9 +162,11 @@ const FullDocScanner = ({ onResult, onClose, detectionConfig, overlayColor = '#3
154
162
  height: targetHeight,
155
163
  }, ensureFileUri(normalizedDoc.path), (error, result) => {
156
164
  if (error) {
165
+ console.error('[FullDocScanner] CustomCropManager.crop error:', error);
157
166
  reject(error instanceof Error ? error : new Error('Crop failed'));
158
167
  return;
159
168
  }
169
+ console.log('[FullDocScanner] CustomCropManager.crop success, base64 length:', result.image?.length);
160
170
  resolve(result.image);
161
171
  });
162
172
  });
@@ -164,11 +174,13 @@ const FullDocScanner = ({ onResult, onClose, detectionConfig, overlayColor = '#3
164
174
  ...normalizedDoc,
165
175
  rectangle: rectangleToUse,
166
176
  };
177
+ console.log('[FullDocScanner] Calling onResult with base64 length:', base64?.length);
167
178
  onResult({
168
179
  original: finalDoc,
169
180
  rectangle: rectangleToUse,
170
181
  base64,
171
182
  });
183
+ console.log('[FullDocScanner] Resetting state');
172
184
  resetState();
173
185
  }
174
186
  catch (error) {
@@ -180,12 +192,27 @@ const FullDocScanner = ({ onResult, onClose, detectionConfig, overlayColor = '#3
180
192
  }
181
193
  }, [emitError, onResult, resetState]);
182
194
  const handleCapture = (0, react_1.useCallback)((document) => {
195
+ console.log('[FullDocScanner] handleCapture called:', {
196
+ origin: document.origin,
197
+ path: document.path,
198
+ width: document.width,
199
+ height: document.height,
200
+ hasQuad: !!document.quad,
201
+ hasRectangle: !!document.rectangle,
202
+ });
183
203
  if (processingCaptureRef.current) {
204
+ console.log('[FullDocScanner] Already processing, skipping');
184
205
  return;
185
206
  }
186
207
  const normalizedDoc = normalizeCapturedDocument(document);
187
208
  const wantsManualFlow = manualCapture || manualCapturePending.current || document.origin === 'manual';
209
+ console.log('[FullDocScanner] wantsManualFlow:', wantsManualFlow, {
210
+ manualCapture,
211
+ manualCapturePending: manualCapturePending.current,
212
+ origin: document.origin,
213
+ });
188
214
  if (wantsManualFlow) {
215
+ console.log('[FullDocScanner] Starting manual flow - showing crop editor');
189
216
  manualCapturePending.current = false;
190
217
  processingCaptureRef.current = false;
191
218
  cropInitializedRef.current = false;
@@ -195,6 +222,7 @@ const FullDocScanner = ({ onResult, onClose, detectionConfig, overlayColor = '#3
195
222
  setScreen('crop');
196
223
  return;
197
224
  }
225
+ console.log('[FullDocScanner] Starting auto flow - processing capture');
198
226
  processingCaptureRef.current = true;
199
227
  processAutoCapture(document);
200
228
  }, [manualCapture, processAutoCapture]);
@@ -202,11 +230,15 @@ const FullDocScanner = ({ onResult, onClose, detectionConfig, overlayColor = '#3
202
230
  setCropRectangle(rectangle);
203
231
  }, []);
204
232
  const triggerManualCapture = (0, react_1.useCallback)(() => {
233
+ console.log('[FullDocScanner] triggerManualCapture called');
205
234
  if (processingCaptureRef.current) {
235
+ console.log('[FullDocScanner] Already processing, skipping manual capture');
206
236
  return;
207
237
  }
238
+ console.log('[FullDocScanner] Setting manualCapturePending to true');
208
239
  manualCapturePending.current = true;
209
240
  const capturePromise = docScannerRef.current?.capture();
241
+ console.log('[FullDocScanner] capturePromise:', !!capturePromise);
210
242
  if (capturePromise && typeof capturePromise.catch === 'function') {
211
243
  capturePromise.catch((error) => {
212
244
  manualCapturePending.current = false;
@@ -214,6 +246,7 @@ const FullDocScanner = ({ onResult, onClose, detectionConfig, overlayColor = '#3
214
246
  });
215
247
  }
216
248
  else if (!capturePromise) {
249
+ console.warn('[FullDocScanner] No capture promise returned');
217
250
  manualCapturePending.current = false;
218
251
  }
219
252
  }, []);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-rectangle-doc-scanner",
3
- "version": "3.34.0",
3
+ "version": "3.35.0",
4
4
  "description": "Native-backed document scanner for React Native with customizable overlays.",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -208,15 +208,18 @@ export const FullDocScanner: React.FC<FullDocScannerProps> = ({
208
208
 
209
209
  const processAutoCapture = useCallback(
210
210
  async (document: DocScannerCapture) => {
211
+ console.log('[FullDocScanner] processAutoCapture started');
211
212
  manualCapturePending.current = false;
212
213
  const normalizedDoc = normalizeCapturedDocument(document);
213
214
  const cropManager = NativeModules.CustomCropManager as CustomCropManagerType | undefined;
214
215
 
215
216
  if (!cropManager?.crop) {
217
+ console.error('[FullDocScanner] CustomCropManager.crop is not available');
216
218
  emitError(new Error('CustomCropManager.crop is not available'));
217
219
  return;
218
220
  }
219
221
 
222
+ console.log('[FullDocScanner] Setting processing to true');
220
223
  setProcessing(true);
221
224
 
222
225
  try {
@@ -250,6 +253,12 @@ export const FullDocScanner: React.FC<FullDocScannerProps> = ({
250
253
 
251
254
  const rectangleToUse = scaledRectangle ?? createFullImageRectangle(targetWidth, targetHeight);
252
255
 
256
+ console.log('[FullDocScanner] Calling CustomCropManager.crop with:', {
257
+ rectangle: rectangleToUse,
258
+ imageUri: ensureFileUri(normalizedDoc.path),
259
+ targetSize: { width: targetWidth, height: targetHeight },
260
+ });
261
+
253
262
  const base64 = await new Promise<string>((resolve, reject) => {
254
263
  cropManager.crop(
255
264
  {
@@ -263,9 +272,11 @@ export const FullDocScanner: React.FC<FullDocScannerProps> = ({
263
272
  ensureFileUri(normalizedDoc.path),
264
273
  (error: unknown, result: { image: string }) => {
265
274
  if (error) {
275
+ console.error('[FullDocScanner] CustomCropManager.crop error:', error);
266
276
  reject(error instanceof Error ? error : new Error('Crop failed'));
267
277
  return;
268
278
  }
279
+ console.log('[FullDocScanner] CustomCropManager.crop success, base64 length:', result.image?.length);
269
280
  resolve(result.image);
270
281
  },
271
282
  );
@@ -276,12 +287,14 @@ export const FullDocScanner: React.FC<FullDocScannerProps> = ({
276
287
  rectangle: rectangleToUse,
277
288
  };
278
289
 
290
+ console.log('[FullDocScanner] Calling onResult with base64 length:', base64?.length);
279
291
  onResult({
280
292
  original: finalDoc,
281
293
  rectangle: rectangleToUse,
282
294
  base64,
283
295
  });
284
296
 
297
+ console.log('[FullDocScanner] Resetting state');
285
298
  resetState();
286
299
  } catch (error) {
287
300
  setProcessing(false);
@@ -295,7 +308,17 @@ export const FullDocScanner: React.FC<FullDocScannerProps> = ({
295
308
 
296
309
  const handleCapture = useCallback(
297
310
  (document: DocScannerCapture) => {
311
+ console.log('[FullDocScanner] handleCapture called:', {
312
+ origin: document.origin,
313
+ path: document.path,
314
+ width: document.width,
315
+ height: document.height,
316
+ hasQuad: !!document.quad,
317
+ hasRectangle: !!document.rectangle,
318
+ });
319
+
298
320
  if (processingCaptureRef.current) {
321
+ console.log('[FullDocScanner] Already processing, skipping');
299
322
  return;
300
323
  }
301
324
 
@@ -303,7 +326,14 @@ export const FullDocScanner: React.FC<FullDocScannerProps> = ({
303
326
  const wantsManualFlow =
304
327
  manualCapture || manualCapturePending.current || document.origin === 'manual';
305
328
 
329
+ console.log('[FullDocScanner] wantsManualFlow:', wantsManualFlow, {
330
+ manualCapture,
331
+ manualCapturePending: manualCapturePending.current,
332
+ origin: document.origin,
333
+ });
334
+
306
335
  if (wantsManualFlow) {
336
+ console.log('[FullDocScanner] Starting manual flow - showing crop editor');
307
337
  manualCapturePending.current = false;
308
338
  processingCaptureRef.current = false;
309
339
  cropInitializedRef.current = false;
@@ -314,6 +344,7 @@ export const FullDocScanner: React.FC<FullDocScannerProps> = ({
314
344
  return;
315
345
  }
316
346
 
347
+ console.log('[FullDocScanner] Starting auto flow - processing capture');
317
348
  processingCaptureRef.current = true;
318
349
  processAutoCapture(document);
319
350
  },
@@ -325,17 +356,22 @@ export const FullDocScanner: React.FC<FullDocScannerProps> = ({
325
356
  }, []);
326
357
 
327
358
  const triggerManualCapture = useCallback(() => {
359
+ console.log('[FullDocScanner] triggerManualCapture called');
328
360
  if (processingCaptureRef.current) {
361
+ console.log('[FullDocScanner] Already processing, skipping manual capture');
329
362
  return;
330
363
  }
364
+ console.log('[FullDocScanner] Setting manualCapturePending to true');
331
365
  manualCapturePending.current = true;
332
366
  const capturePromise = docScannerRef.current?.capture();
367
+ console.log('[FullDocScanner] capturePromise:', !!capturePromise);
333
368
  if (capturePromise && typeof capturePromise.catch === 'function') {
334
369
  capturePromise.catch((error: unknown) => {
335
370
  manualCapturePending.current = false;
336
371
  console.warn('[FullDocScanner] manual capture failed', error);
337
372
  });
338
373
  } else if (!capturePromise) {
374
+ console.warn('[FullDocScanner] No capture promise returned');
339
375
  manualCapturePending.current = false;
340
376
  }
341
377
  }, []);