react-native-rectangle-doc-scanner 0.14.0 → 0.16.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.
@@ -179,11 +179,13 @@ const DocScanner = ({ onCapture, overlayColor = '#e7a649', autoCapture = true, m
179
179
  // fallback: boundingRect (axis-aligned) so we always have 4 points
180
180
  try {
181
181
  const rect = react_native_fast_opencv_1.OpenCV.invoke('boundingRect', contour);
182
- const rectValue = rect?.value ?? rect;
183
- const rectX = rectValue.x ?? rectValue?.topLeft?.x ?? 0;
184
- const rectY = rectValue.y ?? rectValue?.topLeft?.y ?? 0;
185
- const rectW = rectValue.width ?? rectValue?.size?.width ?? 0;
186
- const rectH = rectValue.height ?? rectValue?.size?.height ?? 0;
182
+ // Convert the rect object to JS value to get actual coordinates
183
+ const rectJS = react_native_fast_opencv_1.OpenCV.toJSValue(rect);
184
+ const rectValue = rectJS?.value ?? rectJS;
185
+ const rectX = rectValue?.x ?? 0;
186
+ const rectY = rectValue?.y ?? 0;
187
+ const rectW = rectValue?.width ?? 0;
188
+ const rectH = rectValue?.height ?? 0;
187
189
  // Validate that we have a valid rectangle
188
190
  if (rectW > 0 && rectH > 0) {
189
191
  approxArray = [
@@ -193,13 +195,13 @@ const DocScanner = ({ onCapture, overlayColor = '#e7a649', autoCapture = true, m
193
195
  { x: rectX, y: rectY + rectH },
194
196
  ];
195
197
  if (__DEV__) {
196
- console.log('[DocScanner] boundingRect fallback', approxArray);
198
+ console.log('[DocScanner] using boundingRect fallback:', approxArray);
197
199
  }
198
200
  }
199
201
  }
200
202
  catch (err) {
201
203
  if (__DEV__) {
202
- console.warn('[DocScanner] boundingRect fallback failed', err);
204
+ console.warn('[DocScanner] boundingRect fallback failed:', err);
203
205
  }
204
206
  }
205
207
  }
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.16.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "repository": {
@@ -208,12 +208,14 @@ export const DocScanner: React.FC<Props> = ({
208
208
  // fallback: boundingRect (axis-aligned) so we always have 4 points
209
209
  try {
210
210
  const rect = OpenCV.invoke('boundingRect', contour);
211
- const rectValue = rect?.value ?? rect;
211
+ // Convert the rect object to JS value to get actual coordinates
212
+ const rectJS = OpenCV.toJSValue(rect);
213
+ const rectValue = rectJS?.value ?? rectJS;
212
214
 
213
- const rectX = rectValue.x ?? rectValue?.topLeft?.x ?? 0;
214
- const rectY = rectValue.y ?? rectValue?.topLeft?.y ?? 0;
215
- const rectW = rectValue.width ?? rectValue?.size?.width ?? 0;
216
- const rectH = rectValue.height ?? rectValue?.size?.height ?? 0;
215
+ const rectX = rectValue?.x ?? 0;
216
+ const rectY = rectValue?.y ?? 0;
217
+ const rectW = rectValue?.width ?? 0;
218
+ const rectH = rectValue?.height ?? 0;
217
219
 
218
220
  // Validate that we have a valid rectangle
219
221
  if (rectW > 0 && rectH > 0) {
@@ -225,12 +227,12 @@ export const DocScanner: React.FC<Props> = ({
225
227
  ];
226
228
 
227
229
  if (__DEV__) {
228
- console.log('[DocScanner] boundingRect fallback', approxArray);
230
+ console.log('[DocScanner] using boundingRect fallback:', approxArray);
229
231
  }
230
232
  }
231
233
  } catch (err) {
232
234
  if (__DEV__) {
233
- console.warn('[DocScanner] boundingRect fallback failed', err);
235
+ console.warn('[DocScanner] boundingRect fallback failed:', err);
234
236
  }
235
237
  }
236
238
  }