react-native-rectangle-doc-scanner 3.48.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.
- package/dist/FullDocScanner.js +10 -35
- package/package.json +1 -1
- package/src/FullDocScanner.tsx +14 -37
package/dist/FullDocScanner.js
CHANGED
|
@@ -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,
|
|
@@ -122,11 +121,6 @@ const FullDocScanner = ({ onResult, onClose, detectionConfig, overlayColor = '#3
|
|
|
122
121
|
initialPath: document.initialPath,
|
|
123
122
|
});
|
|
124
123
|
const normalizedDoc = normalizeCapturedDocument(document);
|
|
125
|
-
// Reset manual capture pending flag BEFORE processing
|
|
126
|
-
if (manualCapturePending.current) {
|
|
127
|
-
console.log('[FullDocScanner] Resetting manualCapturePending');
|
|
128
|
-
manualCapturePending.current = false;
|
|
129
|
-
}
|
|
130
124
|
// If grid detected and cropped image exists, show it directly in check_DP
|
|
131
125
|
if (normalizedDoc.croppedPath) {
|
|
132
126
|
console.log('[FullDocScanner] Grid detected: using pre-cropped image', 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
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
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
|
-
|
|
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
package/src/FullDocScanner.tsx
CHANGED
|
@@ -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
|
() => ({
|
|
@@ -167,12 +166,6 @@ export const FullDocScanner: React.FC<FullDocScannerProps> = ({
|
|
|
167
166
|
|
|
168
167
|
const normalizedDoc = normalizeCapturedDocument(document);
|
|
169
168
|
|
|
170
|
-
// Reset manual capture pending flag BEFORE processing
|
|
171
|
-
if (manualCapturePending.current) {
|
|
172
|
-
console.log('[FullDocScanner] Resetting manualCapturePending');
|
|
173
|
-
manualCapturePending.current = false;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
169
|
// If grid detected and cropped image exists, show it directly in check_DP
|
|
177
170
|
if (normalizedDoc.croppedPath) {
|
|
178
171
|
console.log('[FullDocScanner] Grid detected: using pre-cropped image', normalizedDoc.croppedPath);
|
|
@@ -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
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
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');
|