react-native-rectangle-doc-scanner 0.35.0 → 0.36.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.
@@ -91,37 +91,19 @@ const DocScanner = ({ onCapture, overlayColor = '#e7a649', autoCapture = true, m
91
91
  (0, react_1.useEffect)(() => {
92
92
  requestPermission();
93
93
  }, [requestPermission]);
94
- const lastQuadRef = (0, react_1.useRef)(null);
95
- const noQuadFramesRef = (0, react_1.useRef)(0);
96
94
  const updateQuad = (0, react_native_worklets_core_1.useRunOnJS)((value) => {
97
95
  if (__DEV__) {
98
96
  console.log('[DocScanner] quad', value);
99
97
  }
100
- if (value) {
101
- // Found a quad, reset counter and update
102
- noQuadFramesRef.current = 0;
103
- lastQuadRef.current = value;
104
- setQuad(value);
105
- }
106
- else {
107
- // No quad found, keep the last one for a few frames
108
- noQuadFramesRef.current += 1;
109
- // Keep the last quad for up to 3 frames
110
- if (noQuadFramesRef.current > 3) {
111
- lastQuadRef.current = null;
112
- setQuad(null);
113
- }
114
- // Otherwise, keep showing the last quad
115
- }
98
+ // Always update immediately for real-time tracking
99
+ setQuad(value);
116
100
  }, []);
117
101
  const reportError = (0, react_native_worklets_core_1.useRunOnJS)((step, error) => {
118
102
  const message = error instanceof Error ? error.message : `${error}`;
119
103
  console.warn(`[DocScanner] frame error at ${step}: ${message}`);
120
104
  }, []);
121
- const reportStage = (0, react_native_worklets_core_1.useRunOnJS)((stage) => {
122
- if (__DEV__) {
123
- console.log('[DocScanner] stage', stage);
124
- }
105
+ const reportStage = (0, react_native_worklets_core_1.useRunOnJS)((_stage) => {
106
+ // Disabled for performance
125
107
  }, []);
126
108
  const [frameSize, setFrameSize] = (0, react_1.useState)(null);
127
109
  const updateFrameSize = (0, react_native_worklets_core_1.useRunOnJS)((width, height) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-rectangle-doc-scanner",
3
- "version": "0.35.0",
3
+ "version": "0.36.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "repository": {
@@ -96,30 +96,13 @@ export const DocScanner: React.FC<Props> = ({
96
96
  requestPermission();
97
97
  }, [requestPermission]);
98
98
 
99
- const lastQuadRef = useRef<Point[] | null>(null);
100
- const noQuadFramesRef = useRef(0);
101
-
102
99
  const updateQuad = useRunOnJS((value: Point[] | null) => {
103
100
  if (__DEV__) {
104
101
  console.log('[DocScanner] quad', value);
105
102
  }
106
103
 
107
- if (value) {
108
- // Found a quad, reset counter and update
109
- noQuadFramesRef.current = 0;
110
- lastQuadRef.current = value;
111
- setQuad(value);
112
- } else {
113
- // No quad found, keep the last one for a few frames
114
- noQuadFramesRef.current += 1;
115
-
116
- // Keep the last quad for up to 3 frames
117
- if (noQuadFramesRef.current > 3) {
118
- lastQuadRef.current = null;
119
- setQuad(null);
120
- }
121
- // Otherwise, keep showing the last quad
122
- }
104
+ // Always update immediately for real-time tracking
105
+ setQuad(value);
123
106
  }, []);
124
107
 
125
108
  const reportError = useRunOnJS((step: string, error: unknown) => {
@@ -127,10 +110,8 @@ export const DocScanner: React.FC<Props> = ({
127
110
  console.warn(`[DocScanner] frame error at ${step}: ${message}`);
128
111
  }, []);
129
112
 
130
- const reportStage = useRunOnJS((stage: string) => {
131
- if (__DEV__) {
132
- console.log('[DocScanner] stage', stage);
133
- }
113
+ const reportStage = useRunOnJS((_stage: string) => {
114
+ // Disabled for performance
134
115
  }, []);
135
116
 
136
117
  const [frameSize, setFrameSize] = useState<{ width: number; height: number } | null>(null);