react-native-rectangle-doc-scanner 0.14.0 → 0.15.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.
@@ -177,13 +177,22 @@ const DocScanner = ({ onCapture, overlayColor = '#e7a649', autoCapture = true, m
177
177
  }
178
178
  if (approxArray.length !== 4) {
179
179
  // fallback: boundingRect (axis-aligned) so we always have 4 points
180
+ if (__DEV__) {
181
+ console.log('[DocScanner] attempting boundingRect fallback, current length:', approxArray.length);
182
+ }
180
183
  try {
181
184
  const rect = react_native_fast_opencv_1.OpenCV.invoke('boundingRect', contour);
182
185
  const rectValue = rect?.value ?? rect;
186
+ if (__DEV__) {
187
+ console.log('[DocScanner] boundingRect result:', JSON.stringify(rectValue));
188
+ }
183
189
  const rectX = rectValue.x ?? rectValue?.topLeft?.x ?? 0;
184
190
  const rectY = rectValue.y ?? rectValue?.topLeft?.y ?? 0;
185
191
  const rectW = rectValue.width ?? rectValue?.size?.width ?? 0;
186
192
  const rectH = rectValue.height ?? rectValue?.size?.height ?? 0;
193
+ if (__DEV__) {
194
+ console.log('[DocScanner] parsed rect:', { x: rectX, y: rectY, w: rectW, h: rectH });
195
+ }
187
196
  // Validate that we have a valid rectangle
188
197
  if (rectW > 0 && rectH > 0) {
189
198
  approxArray = [
@@ -193,13 +202,18 @@ const DocScanner = ({ onCapture, overlayColor = '#e7a649', autoCapture = true, m
193
202
  { x: rectX, y: rectY + rectH },
194
203
  ];
195
204
  if (__DEV__) {
196
- console.log('[DocScanner] boundingRect fallback', approxArray);
205
+ console.log('[DocScanner] boundingRect fallback success', approxArray);
206
+ }
207
+ }
208
+ else {
209
+ if (__DEV__) {
210
+ console.warn('[DocScanner] boundingRect has invalid dimensions');
197
211
  }
198
212
  }
199
213
  }
200
214
  catch (err) {
201
215
  if (__DEV__) {
202
- console.warn('[DocScanner] boundingRect fallback failed', err);
216
+ console.warn('[DocScanner] boundingRect fallback exception', err);
203
217
  }
204
218
  }
205
219
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-rectangle-doc-scanner",
3
- "version": "0.14.0",
3
+ "version": "0.15.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "repository": {
@@ -206,15 +206,26 @@ export const DocScanner: React.FC<Props> = ({
206
206
 
207
207
  if (approxArray.length !== 4) {
208
208
  // fallback: boundingRect (axis-aligned) so we always have 4 points
209
+ if (__DEV__) {
210
+ console.log('[DocScanner] attempting boundingRect fallback, current length:', approxArray.length);
211
+ }
209
212
  try {
210
213
  const rect = OpenCV.invoke('boundingRect', contour);
211
214
  const rectValue = rect?.value ?? rect;
212
215
 
216
+ if (__DEV__) {
217
+ console.log('[DocScanner] boundingRect result:', JSON.stringify(rectValue));
218
+ }
219
+
213
220
  const rectX = rectValue.x ?? rectValue?.topLeft?.x ?? 0;
214
221
  const rectY = rectValue.y ?? rectValue?.topLeft?.y ?? 0;
215
222
  const rectW = rectValue.width ?? rectValue?.size?.width ?? 0;
216
223
  const rectH = rectValue.height ?? rectValue?.size?.height ?? 0;
217
224
 
225
+ if (__DEV__) {
226
+ console.log('[DocScanner] parsed rect:', { x: rectX, y: rectY, w: rectW, h: rectH });
227
+ }
228
+
218
229
  // Validate that we have a valid rectangle
219
230
  if (rectW > 0 && rectH > 0) {
220
231
  approxArray = [
@@ -225,12 +236,16 @@ export const DocScanner: React.FC<Props> = ({
225
236
  ];
226
237
 
227
238
  if (__DEV__) {
228
- console.log('[DocScanner] boundingRect fallback', approxArray);
239
+ console.log('[DocScanner] boundingRect fallback success', approxArray);
240
+ }
241
+ } else {
242
+ if (__DEV__) {
243
+ console.warn('[DocScanner] boundingRect has invalid dimensions');
229
244
  }
230
245
  }
231
246
  } catch (err) {
232
247
  if (__DEV__) {
233
- console.warn('[DocScanner] boundingRect fallback failed', err);
248
+ console.warn('[DocScanner] boundingRect fallback exception', err);
234
249
  }
235
250
  }
236
251
  }