react-native-rectangle-doc-scanner 3.214.0 → 3.215.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.
@@ -156,6 +156,8 @@ class CameraController(
156
156
  analysisBound = false
157
157
 
158
158
  val rotation = previewView.display?.rotation ?: Surface.ROTATION_0
159
+
160
+ // Build Preview
159
161
  preview = Preview.Builder()
160
162
  .setTargetAspectRatio(AspectRatio.RATIO_4_3)
161
163
  .setTargetRotation(rotation)
@@ -164,35 +166,7 @@ class CameraController(
164
166
  it.setSurfaceProvider(previewView.surfaceProvider)
165
167
  }
166
168
 
167
- val cameraSelector = if (useFrontCamera) {
168
- CameraSelector.DEFAULT_FRONT_CAMERA
169
- } else {
170
- CameraSelector.DEFAULT_BACK_CAMERA
171
- }
172
-
173
- try {
174
- camera = provider.bindToLifecycle(
175
- lifecycleOwner,
176
- cameraSelector,
177
- preview
178
- )
179
- Log.d(TAG, "[CAMERAX] Camera bound successfully")
180
- } catch (e: Exception) {
181
- Log.e(TAG, "[CAMERAX] Failed to bind camera", e)
182
- return
183
- }
184
-
185
- // Bind analysis after preview to avoid session timeouts on some devices.
186
- ContextCompat.getMainExecutor(context).execute {
187
- bindAnalysis(cameraSelector, rotation)
188
- }
189
- }
190
-
191
- private fun bindAnalysis(cameraSelector: CameraSelector, rotation: Int) {
192
- if (analysisBound) {
193
- return
194
- }
195
- val provider = cameraProvider ?: return
169
+ // Build ImageAnalysis
196
170
  imageAnalysis = ImageAnalysis.Builder()
197
171
  .setBackpressureStrategy(ImageAnalysis.STRATEGY_KEEP_ONLY_LATEST)
198
172
  .setTargetRotation(rotation)
@@ -203,6 +177,13 @@ class CameraController(
203
177
  it.setAnalyzer(cameraExecutor, DocumentAnalyzer())
204
178
  }
205
179
 
180
+ val cameraSelector = if (useFrontCamera) {
181
+ CameraSelector.DEFAULT_FRONT_CAMERA
182
+ } else {
183
+ CameraSelector.DEFAULT_BACK_CAMERA
184
+ }
185
+
186
+ // Bind both Preview and ImageAnalysis together in one call
206
187
  try {
207
188
  camera = provider.bindToLifecycle(
208
189
  lifecycleOwner,
@@ -211,9 +192,9 @@ class CameraController(
211
192
  imageAnalysis
212
193
  )
213
194
  analysisBound = true
214
- Log.d(TAG, "[CAMERAX] Analysis bound successfully")
195
+ Log.d(TAG, "[CAMERAX] Camera and analysis bound successfully")
215
196
  } catch (e: Exception) {
216
- Log.e(TAG, "[CAMERAX] Failed to bind analysis; keeping preview only", e)
197
+ Log.e(TAG, "[CAMERAX] Failed to bind camera use cases", e)
217
198
  analysisBound = false
218
199
  }
219
200
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-rectangle-doc-scanner",
3
- "version": "3.214.0",
3
+ "version": "3.215.0",
4
4
  "description": "Native-backed document scanner for React Native with customizable overlays.",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",