react-native-rectangle-doc-scanner 3.52.0 → 3.53.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.
- package/dist/FullDocScanner.js +20 -5
- package/package.json +1 -1
- package/src/FullDocScanner.tsx +30 -7
package/dist/FullDocScanner.js
CHANGED
|
@@ -122,10 +122,14 @@ const FullDocScanner = ({ onResult, onClose, detectionConfig, overlayColor = '#3
|
|
|
122
122
|
initialPath: document.initialPath,
|
|
123
123
|
captureMode: captureModeRef.current,
|
|
124
124
|
});
|
|
125
|
+
if (document.origin === 'auto') {
|
|
126
|
+
console.log('[FullDocScanner] Ignoring auto capture result');
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
125
129
|
const captureMode = captureModeRef.current;
|
|
126
|
-
// Ignore auto captures - only process manual captures
|
|
127
130
|
if (!captureMode) {
|
|
128
|
-
console.
|
|
131
|
+
console.warn('[FullDocScanner] Missing capture mode for manual capture result');
|
|
132
|
+
captureModeRef.current = null;
|
|
129
133
|
return;
|
|
130
134
|
}
|
|
131
135
|
captureModeRef.current = null;
|
|
@@ -229,9 +233,20 @@ const FullDocScanner = ({ onResult, onClose, detectionConfig, overlayColor = '#3
|
|
|
229
233
|
}
|
|
230
234
|
}, []);
|
|
231
235
|
const handleRectangleDetect = (0, react_1.useCallback)((event) => {
|
|
232
|
-
|
|
233
|
-
const
|
|
234
|
-
|
|
236
|
+
const stableCounter = event.stableCounter ?? 0;
|
|
237
|
+
const hasRectangle = Boolean(event.rectangleOnScreen ?? event.rectangleCoordinates);
|
|
238
|
+
const isGoodRectangle = event.lastDetectionType === 0 && hasRectangle && stableCounter > 0;
|
|
239
|
+
setRectangleDetected((prev) => {
|
|
240
|
+
if (prev !== isGoodRectangle) {
|
|
241
|
+
console.log('[FullDocScanner] Rectangle detection update', {
|
|
242
|
+
lastDetectionType: event.lastDetectionType,
|
|
243
|
+
stableCounter,
|
|
244
|
+
hasRectangle,
|
|
245
|
+
isGoodRectangle,
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
return isGoodRectangle;
|
|
249
|
+
});
|
|
235
250
|
}, []);
|
|
236
251
|
return (react_1.default.createElement(react_native_1.View, { style: styles.container },
|
|
237
252
|
croppedImageData ? (
|
package/package.json
CHANGED
package/src/FullDocScanner.tsx
CHANGED
|
@@ -12,7 +12,12 @@ import { launchImageLibrary } from 'react-native-image-picker';
|
|
|
12
12
|
import ImageCropPicker from 'react-native-image-crop-picker';
|
|
13
13
|
import { DocScanner } from './DocScanner';
|
|
14
14
|
import type { CapturedDocument } from './types';
|
|
15
|
-
import type {
|
|
15
|
+
import type {
|
|
16
|
+
DetectionConfig,
|
|
17
|
+
DocScannerHandle,
|
|
18
|
+
DocScannerCapture,
|
|
19
|
+
RectangleDetectEvent,
|
|
20
|
+
} from './DocScanner';
|
|
16
21
|
|
|
17
22
|
const stripFileUri = (value: string) => value.replace(/^file:\/\//, '');
|
|
18
23
|
|
|
@@ -164,11 +169,16 @@ export const FullDocScanner: React.FC<FullDocScannerProps> = ({
|
|
|
164
169
|
captureMode: captureModeRef.current,
|
|
165
170
|
});
|
|
166
171
|
|
|
172
|
+
if (document.origin === 'auto') {
|
|
173
|
+
console.log('[FullDocScanner] Ignoring auto capture result');
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
|
|
167
177
|
const captureMode = captureModeRef.current;
|
|
168
178
|
|
|
169
|
-
// Ignore auto captures - only process manual captures
|
|
170
179
|
if (!captureMode) {
|
|
171
|
-
console.
|
|
180
|
+
console.warn('[FullDocScanner] Missing capture mode for manual capture result');
|
|
181
|
+
captureModeRef.current = null;
|
|
172
182
|
return;
|
|
173
183
|
}
|
|
174
184
|
|
|
@@ -300,10 +310,23 @@ export const FullDocScanner: React.FC<FullDocScannerProps> = ({
|
|
|
300
310
|
}
|
|
301
311
|
}, []);
|
|
302
312
|
|
|
303
|
-
const handleRectangleDetect = useCallback((event:
|
|
304
|
-
|
|
305
|
-
const
|
|
306
|
-
|
|
313
|
+
const handleRectangleDetect = useCallback((event: RectangleDetectEvent) => {
|
|
314
|
+
const stableCounter = event.stableCounter ?? 0;
|
|
315
|
+
const hasRectangle = Boolean(event.rectangleOnScreen ?? event.rectangleCoordinates);
|
|
316
|
+
const isGoodRectangle = event.lastDetectionType === 0 && hasRectangle && stableCounter > 0;
|
|
317
|
+
|
|
318
|
+
setRectangleDetected((prev) => {
|
|
319
|
+
if (prev !== isGoodRectangle) {
|
|
320
|
+
console.log('[FullDocScanner] Rectangle detection update', {
|
|
321
|
+
lastDetectionType: event.lastDetectionType,
|
|
322
|
+
stableCounter,
|
|
323
|
+
hasRectangle,
|
|
324
|
+
isGoodRectangle,
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
return isGoodRectangle;
|
|
329
|
+
});
|
|
307
330
|
}, []);
|
|
308
331
|
|
|
309
332
|
return (
|