react-native-rectangle-doc-scanner 3.73.0 → 3.74.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.
@@ -244,9 +244,9 @@ const FullDocScanner = ({ onResult, onClose, detectionConfig, overlayColor = '#3
244
244
  }
245
245
  const imageUri = result.assets[0].uri;
246
246
  console.log('[FullDocScanner] Gallery image selected:', imageUri);
247
- // Allow the picker dismissal animation to complete before presenting the cropper
248
- await new Promise((resolve) => setTimeout(resolve, 200));
249
- // Open cropper with the selected image
247
+ // Defer cropper presentation until picker dismissal finishes to avoid hierarchy errors
248
+ await new Promise((resolve) => react_native_1.InteractionManager.runAfterInteractions(() => resolve()));
249
+ await new Promise((resolve) => setTimeout(resolve, 150));
250
250
  await openCropper(imageUri);
251
251
  }
252
252
  catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-rectangle-doc-scanner",
3
- "version": "3.73.0",
3
+ "version": "3.74.0",
4
4
  "description": "Native-backed document scanner for React Native with customizable overlays.",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -3,6 +3,7 @@ import {
3
3
  ActivityIndicator,
4
4
  Alert,
5
5
  Image,
6
+ InteractionManager,
6
7
  StyleSheet,
7
8
  Text,
8
9
  TouchableOpacity,
@@ -326,10 +327,12 @@ export const FullDocScanner: React.FC<FullDocScannerProps> = ({
326
327
  const imageUri = result.assets[0].uri;
327
328
  console.log('[FullDocScanner] Gallery image selected:', imageUri);
328
329
 
329
- // Allow the picker dismissal animation to complete before presenting the cropper
330
- await new Promise((resolve) => setTimeout(resolve, 200));
330
+ // Defer cropper presentation until picker dismissal finishes to avoid hierarchy errors
331
+ await new Promise<void>((resolve) =>
332
+ InteractionManager.runAfterInteractions(() => resolve()),
333
+ );
334
+ await new Promise((resolve) => setTimeout(resolve, 150));
331
335
 
332
- // Open cropper with the selected image
333
336
  await openCropper(imageUri);
334
337
  } catch (error) {
335
338
  console.error('[FullDocScanner] Gallery pick error:', error);
@@ -6,6 +6,7 @@ import {
6
6
  Platform,
7
7
  PermissionsAndroid,
8
8
  DeviceEventEmitter,
9
+ findNodeHandle,
9
10
  } from 'react-native';
10
11
  import PropTypes from 'prop-types';
11
12
 
@@ -121,8 +122,31 @@ class PdfScanner extends React.Component {
121
122
  }
122
123
 
123
124
  capture() {
124
- if (this.state.permissionsAuthorized) {
125
- CameraManager.capture();
125
+ if (!this.state.permissionsAuthorized) {
126
+ return Promise.reject(new Error('camera_permissions_not_granted'));
127
+ }
128
+
129
+ if (!CameraManager || typeof CameraManager.capture !== 'function') {
130
+ return Promise.reject(new Error('capture_not_supported'));
131
+ }
132
+
133
+ const nodeHandle = findNodeHandle(this);
134
+
135
+ if (!nodeHandle) {
136
+ return Promise.reject(new Error('scanner_view_not_ready'));
137
+ }
138
+
139
+ try {
140
+ const result = CameraManager.capture(nodeHandle);
141
+
142
+ if (result && typeof result.then === 'function') {
143
+ return result;
144
+ }
145
+
146
+ // Ensure callers always receive a promise even if native side falls back to events
147
+ return Promise.resolve(result);
148
+ } catch (error) {
149
+ return Promise.reject(error);
126
150
  }
127
151
  }
128
152