react-native-rectangle-doc-scanner 7.0.0 → 7.1.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.
@@ -77,13 +77,15 @@ dependencies {
77
77
  implementation 'androidx.core:core-ktx:1.10.1'
78
78
  implementation 'androidx.appcompat:appcompat:1.6.1'
79
79
 
80
+ // CameraX core is needed for ImageProxy in VisionCamera frame processor
81
+ def camerax_version = "1.3.0"
82
+ implementation "androidx.camera:camera-core:${camerax_version}"
83
+
80
84
  if (hasVisionCamera) {
81
- // VisionCamera mode - only include VisionCamera dependency
85
+ // VisionCamera mode - include VisionCamera dependency
82
86
  implementation project(':react-native-vision-camera')
83
87
  } else {
84
- // Camera2 mode - include CameraX and ML Kit dependencies
85
- def camerax_version = "1.3.0"
86
- implementation "androidx.camera:camera-core:${camerax_version}"
88
+ // Camera2 mode - include additional CameraX and ML Kit dependencies
87
89
  implementation "androidx.camera:camera-camera2:${camerax_version}"
88
90
  implementation "androidx.camera:camera-lifecycle:${camerax_version}"
89
91
  implementation "androidx.camera:camera-view:${camerax_version}"
@@ -43,15 +43,22 @@ class DocumentScannerModule(reactContext: ReactApplicationContext) :
43
43
  try {
44
44
  val view = uiManager.resolveView(tag)
45
45
 
46
- if (view is DocumentScannerView) {
47
- Log.d(TAG, "Found DocumentScannerView, triggering capture with promise")
48
-
49
- // Pass promise to view so it can be resolved when capture completes
50
- // This matches iOS behavior where promise is resolved with actual image data
51
- view.captureWithPromise(promise)
52
- } else {
53
- Log.e(TAG, "View with tag $tag is not DocumentScannerView: ${view?.javaClass?.simpleName}")
54
- promise.reject("INVALID_VIEW", "View is not a DocumentScannerView")
46
+ // Use reflection to avoid compile-time dependency on DocumentScannerView
47
+ try {
48
+ val docScannerViewClass = Class.forName("com.reactnativerectangledocscanner.DocumentScannerView")
49
+ if (docScannerViewClass.isInstance(view)) {
50
+ Log.d(TAG, "Found DocumentScannerView, triggering capture with promise")
51
+
52
+ // Pass promise to view so it can be resolved when capture completes
53
+ val captureMethod = docScannerViewClass.getMethod("captureWithPromise", Promise::class.java)
54
+ captureMethod.invoke(view, promise)
55
+ } else {
56
+ Log.e(TAG, "View with tag $tag is not DocumentScannerView: ${view?.javaClass?.simpleName}")
57
+ promise.reject("INVALID_VIEW", "View is not a DocumentScannerView")
58
+ }
59
+ } catch (e: ClassNotFoundException) {
60
+ Log.e(TAG, "DocumentScannerView not available (VisionCamera mode)", e)
61
+ promise.reject("VIEW_NOT_AVAILABLE", "Camera2 views not available in VisionCamera mode")
55
62
  }
56
63
  } catch (e: Exception) {
57
64
  Log.e(TAG, "Error resolving view", e)
@@ -25,11 +25,21 @@ class DocumentScannerPackage : ReactPackage {
25
25
  // VisionCamera is available, no need to register Camera2 view managers
26
26
  emptyList()
27
27
  } catch (e: ClassNotFoundException) {
28
- // VisionCamera not available, register Camera2 view managers
29
- listOf(
30
- DocumentScannerViewManager(),
31
- CameraViewManager()
32
- )
28
+ // VisionCamera not available, register Camera2 view managers using reflection
29
+ try {
30
+ val viewManagers = mutableListOf<ViewManager<*, *>>()
31
+
32
+ val docScannerViewManagerClass = Class.forName("com.reactnativerectangledocscanner.DocumentScannerViewManager")
33
+ val cameraViewManagerClass = Class.forName("com.reactnativerectangledocscanner.CameraViewManager")
34
+
35
+ viewManagers.add(docScannerViewManagerClass.newInstance() as ViewManager<*, *>)
36
+ viewManagers.add(cameraViewManagerClass.newInstance() as ViewManager<*, *>)
37
+
38
+ viewManagers
39
+ } catch (e: Exception) {
40
+ Log.e(TAG, "Failed to instantiate Camera2 view managers", e)
41
+ emptyList()
42
+ }
33
43
  }
34
44
  }
35
45
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-rectangle-doc-scanner",
3
- "version": "7.0.0",
3
+ "version": "7.1.0",
4
4
  "description": "Native-backed document scanner for React Native with customizable overlays.",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",