react-native-rectangle-doc-scanner 3.44.2 → 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.
- package/dist/FullDocScanner.js +35 -15
- package/package.json +1 -1
- package/src/FullDocScanner.tsx +39 -16
package/dist/FullDocScanner.js
CHANGED
|
@@ -108,26 +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
120
|
// Auto-capture: Use already cropped image, skip cropper
|
|
117
121
|
if (document.origin === 'auto' && normalizedDoc.croppedPath) {
|
|
118
|
-
console.log('[FullDocScanner] Auto-capture: using pre-cropped image');
|
|
122
|
+
console.log('[FullDocScanner] Auto-capture: using pre-cropped image', normalizedDoc.croppedPath);
|
|
119
123
|
setCroppedImageData({
|
|
120
124
|
path: normalizedDoc.croppedPath,
|
|
121
125
|
});
|
|
122
126
|
}
|
|
123
127
|
else {
|
|
124
128
|
// Manual capture or gallery: Open cropper
|
|
125
|
-
console.log('[FullDocScanner] Manual capture: opening cropper');
|
|
129
|
+
console.log('[FullDocScanner] Manual/Gallery capture: opening cropper with', normalizedDoc.path);
|
|
126
130
|
await openCropper(normalizedDoc.path);
|
|
127
131
|
}
|
|
128
132
|
}, [openCropper]);
|
|
129
133
|
const triggerManualCapture = (0, react_1.useCallback)(() => {
|
|
130
|
-
console.log('[FullDocScanner] triggerManualCapture called'
|
|
134
|
+
console.log('[FullDocScanner] triggerManualCapture called', {
|
|
135
|
+
processing,
|
|
136
|
+
manualCapturePending: manualCapturePending.current,
|
|
137
|
+
hasRef: !!docScannerRef.current,
|
|
138
|
+
});
|
|
131
139
|
if (processing) {
|
|
132
140
|
console.log('[FullDocScanner] Already processing, skipping manual capture');
|
|
133
141
|
return;
|
|
@@ -136,21 +144,33 @@ const FullDocScanner = ({ onResult, onClose, detectionConfig, overlayColor = '#3
|
|
|
136
144
|
console.log('[FullDocScanner] Manual capture already pending, skipping');
|
|
137
145
|
return;
|
|
138
146
|
}
|
|
139
|
-
|
|
147
|
+
if (!docScannerRef.current) {
|
|
148
|
+
console.error('[FullDocScanner] DocScanner ref not available');
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
console.log('[FullDocScanner] Starting manual capture');
|
|
140
152
|
manualCapturePending.current = true;
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
capturePromise
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
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()');
|
|
148
169
|
manualCapturePending.current = false;
|
|
149
|
-
|
|
150
|
-
});
|
|
170
|
+
}
|
|
151
171
|
}
|
|
152
|
-
|
|
153
|
-
console.
|
|
172
|
+
catch (error) {
|
|
173
|
+
console.error('[FullDocScanner] Exception during capture:', error);
|
|
154
174
|
manualCapturePending.current = false;
|
|
155
175
|
}
|
|
156
176
|
}, [processing]);
|
package/package.json
CHANGED
package/src/FullDocScanner.tsx
CHANGED
|
@@ -151,9 +151,13 @@ 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
|
|
|
@@ -161,13 +165,13 @@ export const FullDocScanner: React.FC<FullDocScannerProps> = ({
|
|
|
161
165
|
|
|
162
166
|
// Auto-capture: Use already cropped image, skip cropper
|
|
163
167
|
if (document.origin === 'auto' && normalizedDoc.croppedPath) {
|
|
164
|
-
console.log('[FullDocScanner] Auto-capture: using pre-cropped image');
|
|
168
|
+
console.log('[FullDocScanner] Auto-capture: using pre-cropped image', normalizedDoc.croppedPath);
|
|
165
169
|
setCroppedImageData({
|
|
166
170
|
path: normalizedDoc.croppedPath,
|
|
167
171
|
});
|
|
168
172
|
} else {
|
|
169
173
|
// Manual capture or gallery: Open cropper
|
|
170
|
-
console.log('[FullDocScanner] Manual capture: opening cropper');
|
|
174
|
+
console.log('[FullDocScanner] Manual/Gallery capture: opening cropper with', normalizedDoc.path);
|
|
171
175
|
await openCropper(normalizedDoc.path);
|
|
172
176
|
}
|
|
173
177
|
},
|
|
@@ -175,31 +179,50 @@ export const FullDocScanner: React.FC<FullDocScannerProps> = ({
|
|
|
175
179
|
);
|
|
176
180
|
|
|
177
181
|
const triggerManualCapture = useCallback(() => {
|
|
178
|
-
console.log('[FullDocScanner] triggerManualCapture called'
|
|
182
|
+
console.log('[FullDocScanner] triggerManualCapture called', {
|
|
183
|
+
processing,
|
|
184
|
+
manualCapturePending: manualCapturePending.current,
|
|
185
|
+
hasRef: !!docScannerRef.current,
|
|
186
|
+
});
|
|
187
|
+
|
|
179
188
|
if (processing) {
|
|
180
189
|
console.log('[FullDocScanner] Already processing, skipping manual capture');
|
|
181
190
|
return;
|
|
182
191
|
}
|
|
192
|
+
|
|
183
193
|
if (manualCapturePending.current) {
|
|
184
194
|
console.log('[FullDocScanner] Manual capture already pending, skipping');
|
|
185
195
|
return;
|
|
186
196
|
}
|
|
187
197
|
|
|
188
|
-
|
|
198
|
+
if (!docScannerRef.current) {
|
|
199
|
+
console.error('[FullDocScanner] DocScanner ref not available');
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
console.log('[FullDocScanner] Starting manual capture');
|
|
189
204
|
manualCapturePending.current = true;
|
|
190
205
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
capturePromise
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
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);
|
|
203
226
|
manualCapturePending.current = false;
|
|
204
227
|
}
|
|
205
228
|
}, [processing]);
|