react-native-rectangle-doc-scanner 4.17.0 → 6.0.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.
@@ -47,7 +47,8 @@ class CameraView(context: Context) : FrameLayout(context), LifecycleOwner {
47
47
  // Callback for detected rectangles
48
48
  var onRectangleDetected: ((Rectangle?) -> Unit)? = null
49
49
 
50
- override fun getLifecycle(): Lifecycle = lifecycleRegistry
50
+ override val lifecycle: Lifecycle
51
+ get() = lifecycleRegistry
51
52
 
52
53
  init {
53
54
  // Create preview view
@@ -66,7 +66,8 @@ class DocumentScannerView(context: ThemedReactContext) : FrameLayout(context), L
66
66
  private const val TAG = "DocumentScannerView"
67
67
  }
68
68
 
69
- override fun getLifecycle(): Lifecycle = lifecycleRegistry
69
+ override val lifecycle: Lifecycle
70
+ get() = lifecycleRegistry
70
71
 
71
72
  init {
72
73
  Log.d(TAG, "╔════════════════════════════════════════╗")
@@ -422,10 +422,7 @@ const VisionCameraScanner = (0, react_1.forwardRef)(({ onCapture, overlayColor =
422
422
  showManualCaptureButton && (react_1.default.createElement(react_native_1.TouchableOpacity, { style: styles.button, onPress: () => captureVision('manual') })),
423
423
  children));
424
424
  });
425
- exports.DocScanner = (0, react_1.forwardRef)(({ onCapture, overlayColor = DEFAULT_OVERLAY_COLOR, autoCapture = true, minStableFrames = 8, enableTorch = false, quality = 90, useBase64 = false, children, showGrid = true, gridColor, gridLineWidth, detectionConfig, onRectangleDetect, showManualCaptureButton = false, }, ref) => {
426
- if (hasVisionCamera) {
427
- return (react_1.default.createElement(VisionCameraScanner, { ref: ref, onCapture: onCapture, overlayColor: overlayColor, autoCapture: autoCapture, minStableFrames: minStableFrames, enableTorch: enableTorch, quality: quality, useBase64: useBase64, showGrid: showGrid, gridColor: gridColor, gridLineWidth: gridLineWidth, detectionConfig: detectionConfig, onRectangleDetect: onRectangleDetect, showManualCaptureButton: showManualCaptureButton }, children));
428
- }
425
+ const NativeScanner = (0, react_1.forwardRef)(({ onCapture, overlayColor = DEFAULT_OVERLAY_COLOR, autoCapture = true, minStableFrames = 8, enableTorch = false, quality = 90, useBase64 = false, children, showGrid = true, gridColor, gridLineWidth, detectionConfig, onRectangleDetect, showManualCaptureButton = false, }, ref) => {
429
426
  const scannerRef = (0, react_1.useRef)(null);
430
427
  const captureResolvers = (0, react_1.useRef)(null);
431
428
  const [isAutoCapturing, setIsAutoCapturing] = (0, react_1.useState)(false);
@@ -701,6 +698,26 @@ exports.DocScanner = (0, react_1.forwardRef)(({ onCapture, overlayColor = DEFAUL
701
698
  showManualCaptureButton && (react_1.default.createElement(react_native_1.TouchableOpacity, { style: styles.button, onPress: handleManualCapture })),
702
699
  children));
703
700
  });
701
+ exports.DocScanner = (0, react_1.forwardRef)((props, ref) => {
702
+ (0, react_1.useEffect)(() => {
703
+ if (react_native_1.Platform.OS !== 'android') {
704
+ return;
705
+ }
706
+ if (hasVisionCamera) {
707
+ console.log('[DocScanner] Using VisionCamera pipeline');
708
+ }
709
+ else {
710
+ console.warn('[DocScanner] VisionCamera pipeline unavailable, falling back to native view.', {
711
+ hasVisionCameraModule: Boolean(visionCameraModule),
712
+ hasReanimated: Boolean(reanimatedModule),
713
+ });
714
+ }
715
+ }, []);
716
+ if (hasVisionCamera) {
717
+ return react_1.default.createElement(VisionCameraScanner, { ref: ref, ...props });
718
+ }
719
+ return react_1.default.createElement(NativeScanner, { ref: ref, ...props });
720
+ });
704
721
  const styles = react_native_1.StyleSheet.create({
705
722
  container: {
706
723
  flex: 1,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-rectangle-doc-scanner",
3
- "version": "4.17.0",
3
+ "version": "6.0.0",
4
4
  "description": "Native-backed document scanner for React Native with customizable overlays.",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -611,7 +611,7 @@ const VisionCameraScanner = forwardRef<DocScannerHandle, Props>(
611
611
  },
612
612
  );
613
613
 
614
- export const DocScanner = forwardRef<DocScannerHandle, Props>(
614
+ const NativeScanner = forwardRef<DocScannerHandle, Props>(
615
615
  (
616
616
  {
617
617
  onCapture,
@@ -631,29 +631,6 @@ export const DocScanner = forwardRef<DocScannerHandle, Props>(
631
631
  },
632
632
  ref,
633
633
  ) => {
634
- if (hasVisionCamera) {
635
- return (
636
- <VisionCameraScanner
637
- ref={ref}
638
- onCapture={onCapture}
639
- overlayColor={overlayColor}
640
- autoCapture={autoCapture}
641
- minStableFrames={minStableFrames}
642
- enableTorch={enableTorch}
643
- quality={quality}
644
- useBase64={useBase64}
645
- showGrid={showGrid}
646
- gridColor={gridColor}
647
- gridLineWidth={gridLineWidth}
648
- detectionConfig={detectionConfig}
649
- onRectangleDetect={onRectangleDetect}
650
- showManualCaptureButton={showManualCaptureButton}
651
- >
652
- {children}
653
- </VisionCameraScanner>
654
- );
655
- }
656
-
657
634
  const scannerRef = useRef<any>(null);
658
635
  const captureResolvers = useRef<{
659
636
  resolve: (value: PictureEvent) => void;
@@ -1013,6 +990,28 @@ export const DocScanner = forwardRef<DocScannerHandle, Props>(
1013
990
  },
1014
991
  );
1015
992
 
993
+ export const DocScanner = forwardRef<DocScannerHandle, Props>((props, ref) => {
994
+ useEffect(() => {
995
+ if (Platform.OS !== 'android') {
996
+ return;
997
+ }
998
+ if (hasVisionCamera) {
999
+ console.log('[DocScanner] Using VisionCamera pipeline');
1000
+ } else {
1001
+ console.warn('[DocScanner] VisionCamera pipeline unavailable, falling back to native view.', {
1002
+ hasVisionCameraModule: Boolean(visionCameraModule),
1003
+ hasReanimated: Boolean(reanimatedModule),
1004
+ });
1005
+ }
1006
+ }, []);
1007
+
1008
+ if (hasVisionCamera) {
1009
+ return <VisionCameraScanner ref={ref} {...props} />;
1010
+ }
1011
+
1012
+ return <NativeScanner ref={ref} {...props} />;
1013
+ });
1014
+
1016
1015
  const styles = StyleSheet.create({
1017
1016
  container: {
1018
1017
  flex: 1,