@sanctum-key/react-native-sdk 1.0.53 → 1.0.56
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.
- package/README.md +7 -2
- package/android/build/.transforms/3db9b15041d4285a820fc84462995ea1/results.bin +1 -0
- package/android/build/.transforms/3db9b15041d4285a820fc84462995ea1/transformed/classes/classes_dex/classes.dex +0 -0
- package/android/build/intermediates/compile_library_classes_jar/debug/bundleLibCompileToJarDebug/classes.jar +0 -0
- package/android/build/intermediates/runtime_library_classes_jar/debug/bundleLibRuntimeToJarDebug/classes.jar +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/counters.tab +1 -1
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/last-build.bin +0 -0
- package/android/build/kotlin/compileDebugKotlin/classpath-snapshot/shrunk-classpath-snapshot.bin +0 -0
- package/android/build/kotlin/compileDebugKotlin/local-state/build-history.bin +0 -0
- package/android/build/tmp/compileDebugJavaWithJavac/previous-compilation-data.bin +0 -0
- package/android/build/tmp/kotlin-classes/debug/kyc/sanctumkey/com/SanctumKeySdkModule$BarcodeRegion.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/kyc/sanctumkey/com/SanctumKeySdkModule$Companion.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/kyc/sanctumkey/com/{SanctumKeySdkModule$definition$1$5$1.class → SanctumKeySdkModule$definition$1$6$1.class} +0 -0
- package/android/build/tmp/kotlin-classes/debug/kyc/sanctumkey/com/{SanctumKeySdkModule$definition$1$5$2.class → SanctumKeySdkModule$definition$1$6$2.class} +0 -0
- package/android/build/tmp/kotlin-classes/debug/kyc/sanctumkey/com/{SanctumKeySdkModule$definition$lambda$5$$inlined$AsyncFunction$1.class → SanctumKeySdkModule$definition$lambda$16$$inlined$AsyncFunction$1.class} +0 -0
- package/android/build/tmp/kotlin-classes/debug/kyc/sanctumkey/com/{SanctumKeySdkModule$definition$lambda$5$$inlined$AsyncFunction$5.class → SanctumKeySdkModule$definition$lambda$16$$inlined$AsyncFunction$2.class} +0 -0
- package/android/build/tmp/kotlin-classes/debug/kyc/sanctumkey/com/{SanctumKeySdkModule$definition$lambda$5$$inlined$AsyncFunction$3.class → SanctumKeySdkModule$definition$lambda$16$$inlined$AsyncFunction$3.class} +0 -0
- package/android/build/tmp/kotlin-classes/debug/kyc/sanctumkey/com/{SanctumKeySdkModule$definition$lambda$5$$inlined$AsyncFunction$4.class → SanctumKeySdkModule$definition$lambda$16$$inlined$AsyncFunction$4.class} +0 -0
- package/android/build/tmp/kotlin-classes/debug/kyc/sanctumkey/com/{SanctumKeySdkModule$definition$lambda$5$$inlined$AsyncFunction$2.class → SanctumKeySdkModule$definition$lambda$16$$inlined$AsyncFunction$5.class} +0 -0
- package/android/build/tmp/kotlin-classes/debug/kyc/sanctumkey/com/{SanctumKeySdkModule$definition$lambda$5$$inlined$AsyncFunction$6.class → SanctumKeySdkModule$definition$lambda$16$$inlined$AsyncFunction$6.class} +0 -0
- package/android/build/tmp/kotlin-classes/debug/kyc/sanctumkey/com/{SanctumKeySdkModule$definition$lambda$5$$inlined$AsyncFunctionWithPromise$1.class → SanctumKeySdkModule$definition$lambda$16$$inlined$AsyncFunctionWithPromise$1.class} +0 -0
- package/android/build/tmp/kotlin-classes/debug/kyc/sanctumkey/com/{SanctumKeySdkModule$definition$lambda$5$$inlined$AsyncFunctionWithPromise$3.class → SanctumKeySdkModule$definition$lambda$16$$inlined$AsyncFunctionWithPromise$2.class} +0 -0
- package/android/build/tmp/kotlin-classes/debug/kyc/sanctumkey/com/SanctumKeySdkModule$definition$lambda$16$$inlined$AsyncFunctionWithPromise$3.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/kyc/sanctumkey/com/SanctumKeySdkModule$definition$lambda$16$$inlined$AsyncFunctionWithPromise$4.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/kyc/sanctumkey/com/{SanctumKeySdkModule$definition$lambda$5$$inlined$AsyncFunctionWithPromise$2.class → SanctumKeySdkModule$definition$lambda$16$$inlined$AsyncFunctionWithPromise$5.class} +0 -0
- package/android/build/tmp/kotlin-classes/debug/kyc/sanctumkey/com/SanctumKeySdkModule$definition$lambda$16$$inlined$AsyncFunctionWithPromise$6.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/kyc/sanctumkey/com/{SanctumKeySdkModule$definition$lambda$5$$inlined$AsyncFunctionWithPromise$4.class → SanctumKeySdkModule$definition$lambda$16$$inlined$AsyncFunctionWithPromise$7.class} +0 -0
- package/android/build/tmp/kotlin-classes/debug/kyc/sanctumkey/com/{SanctumKeySdkModule$definition$lambda$5$$inlined$View$1.class → SanctumKeySdkModule$definition$lambda$16$$inlined$View$1.class} +0 -0
- package/android/build/tmp/kotlin-classes/debug/kyc/sanctumkey/com/{SanctumKeySdkModule$definition$lambda$5$lambda$4$$inlined$Prop$1.class → SanctumKeySdkModule$definition$lambda$16$lambda$15$$inlined$Prop$1.class} +0 -0
- package/android/build/tmp/kotlin-classes/debug/kyc/sanctumkey/com/{SanctumKeySdkModule$definition$lambda$5$lambda$4$$inlined$Prop$2.class → SanctumKeySdkModule$definition$lambda$16$lambda$15$$inlined$Prop$2.class} +0 -0
- package/android/build/tmp/kotlin-classes/debug/kyc/sanctumkey/com/SanctumKeySdkModule.class +0 -0
- package/android/build.gradle +7 -0
- package/android/src/main/java/kyc/sanctumkey/com/SanctumKeySdkModule.kt +428 -1
- package/build/package.json +3 -1
- package/build/src/SanctumKeySdkModule.d.ts +1 -0
- package/build/src/SanctumKeySdkModule.d.ts.map +1 -1
- package/build/src/SanctumKeySdkModule.js.map +1 -1
- package/build/src/components/EnhancedCameraView.d.ts.map +1 -1
- package/build/src/components/EnhancedCameraView.js +50 -41
- package/build/src/components/EnhancedCameraView.js.map +1 -1
- package/build/src/components/EnhancedCameraView.web.d.ts +2 -0
- package/build/src/components/EnhancedCameraView.web.d.ts.map +1 -1
- package/build/src/components/EnhancedCameraView.web.js +11 -6
- package/build/src/components/EnhancedCameraView.web.js.map +1 -1
- package/build/src/components/KYCElements/IDCardCapture.d.ts.map +1 -1
- package/build/src/components/KYCElements/IDCardCapture.js +499 -78
- package/build/src/components/KYCElements/IDCardCapture.js.map +1 -1
- package/build/src/components/TemplateKYCExample.d.ts.map +1 -1
- package/build/src/components/TemplateKYCExample.js +3 -9
- package/build/src/components/TemplateKYCExample.js.map +1 -1
- package/build/src/components/TemplateKYCFlowRefactored.d.ts.map +1 -1
- package/build/src/components/TemplateKYCFlowRefactored.js +0 -2
- package/build/src/components/TemplateKYCFlowRefactored.js.map +1 -1
- package/build/src/components/WebBarcodeScanner.d.ts +2 -0
- package/build/src/components/WebBarcodeScanner.d.ts.map +1 -1
- package/build/src/components/WebBarcodeScanner.js +99 -85
- package/build/src/components/WebBarcodeScanner.js.map +1 -1
- package/build/src/modules/api/KYCService.d.ts +1 -0
- package/build/src/modules/api/KYCService.d.ts.map +1 -1
- package/build/src/modules/api/KYCService.js +1 -1
- package/build/src/modules/api/KYCService.js.map +1 -1
- package/build/src/modules/api/types.d.ts +1 -0
- package/build/src/modules/api/types.d.ts.map +1 -1
- package/build/src/modules/api/types.js.map +1 -1
- package/build/src/web/WebKYCEntry.d.ts.map +1 -1
- package/build/src/web/WebKYCEntry.js +50 -32
- package/build/src/web/WebKYCEntry.js.map +1 -1
- package/package.json +3 -1
- package/plugin/build/withVisionCamera.d.ts +1 -0
- package/plugin/build/withVisionCamera.js +13 -1
- package/plugin/src/withVisionCamera.js +18 -2
- package/plugin/src/withVisionCamera.ts +19 -2
- package/src/SanctumKeySdkModule.ts +1 -0
- package/src/components/EnhancedCameraView.tsx +52 -41
- package/src/components/EnhancedCameraView.web.tsx +15 -5
- package/src/components/KYCElements/IDCardCapture.tsx +552 -75
- package/src/components/TemplateKYCExample.tsx +6 -14
- package/src/components/TemplateKYCFlowRefactored.tsx +0 -2
- package/src/components/WebBarcodeScanner.tsx +147 -198
- package/src/modules/api/KYCService.ts +3 -3
- package/src/modules/api/types.ts +1 -0
- package/src/web/WebKYCEntry.tsx +89 -50
|
@@ -4,12 +4,14 @@ import { Camera, useCameraDevice, useCodeScanner } from 'react-native-vision-cam
|
|
|
4
4
|
import VisionCameraModule from '../modules/camera/VisionCameraModule';
|
|
5
5
|
import { useI18n } from '../hooks/useI18n';
|
|
6
6
|
import { WebBarcodeScanner } from './WebBarcodeScanner';
|
|
7
|
-
export const EnhancedCameraView = ({ showCamera, cameraType: initialCameraType = 'front', style, onError, onSilentCapture, silentCaptureResult, isProcessing = false, overlayComponent, isScanningBarcode = false, onBarcodeScanned, barcodeTypes }) => {
|
|
7
|
+
export const EnhancedCameraView = ({ showCamera, cameraType: initialCameraType = 'front', style, onError, onSilentCapture, silentCaptureResult, isProcessing = false, overlayComponent, captureStabilizationDelayMs = 4000, isScanningBarcode = false, onBarcodeScanned, barcodeTypes }) => {
|
|
8
8
|
const { t } = useI18n();
|
|
9
9
|
const camera = useRef(null);
|
|
10
10
|
const webVideoRef = useRef(null);
|
|
11
11
|
const isCapturingRef = useRef(false);
|
|
12
12
|
const isProcessingRef = useRef(isProcessing);
|
|
13
|
+
const isScanningBarcodeRef = useRef(isScanningBarcode);
|
|
14
|
+
const onBarcodeScannedRef = useRef(onBarcodeScanned);
|
|
13
15
|
// Ref-tracked isAnalyzing so captureSilentPhoto always reads the latest
|
|
14
16
|
// value — the prop-based closure goes stale on iOS between renders.
|
|
15
17
|
const isAnalyzingRef = useRef(silentCaptureResult?.isAnalyzing ?? false);
|
|
@@ -18,12 +20,17 @@ export const EnhancedCameraView = ({ showCamera, cameraType: initialCameraType =
|
|
|
18
20
|
const [isInitialized, setIsInitialized] = useState(false);
|
|
19
21
|
const [refreshCamera] = useState(false);
|
|
20
22
|
const [isVideoFound, setIsVideoFound] = useState(false);
|
|
21
|
-
const scannedBarcodeRef = useRef(null);
|
|
23
|
+
const scannedBarcodeRef = useRef({ value: null, emittedAt: 0 });
|
|
22
24
|
const containerRef = useRef(null);
|
|
23
25
|
const [appState, setAppState] = useState(AppState.currentState);
|
|
24
26
|
const device = useCameraDevice(cameraType);
|
|
25
27
|
useEffect(() => { isProcessingRef.current = isProcessing; }, [isProcessing]);
|
|
28
|
+
useEffect(() => { isScanningBarcodeRef.current = isScanningBarcode; }, [isScanningBarcode]);
|
|
29
|
+
useEffect(() => { onBarcodeScannedRef.current = onBarcodeScanned; }, [onBarcodeScanned]);
|
|
26
30
|
useEffect(() => { isAnalyzingRef.current = silentCaptureResult?.isAnalyzing ?? false; }, [silentCaptureResult?.isAnalyzing]);
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
scannedBarcodeRef.current = { value: null, emittedAt: 0 };
|
|
33
|
+
}, [isScanningBarcode]);
|
|
27
34
|
useEffect(() => {
|
|
28
35
|
const subscription = AppState.addEventListener('change', nextAppState => {
|
|
29
36
|
setAppState(nextAppState);
|
|
@@ -68,7 +75,12 @@ export const EnhancedCameraView = ({ showCamera, cameraType: initialCameraType =
|
|
|
68
75
|
if (showCamera)
|
|
69
76
|
checkPermissions();
|
|
70
77
|
}, [showCamera, refreshCamera]);
|
|
71
|
-
const onInitialized = useCallback(() =>
|
|
78
|
+
const onInitialized = useCallback(() => {
|
|
79
|
+
setIsInitialized(true);
|
|
80
|
+
if (isScanningBarcodeRef.current) {
|
|
81
|
+
console.log('📷 Barcode camera initialized');
|
|
82
|
+
}
|
|
83
|
+
}, []);
|
|
72
84
|
const onCameraError = useCallback((error) => {
|
|
73
85
|
console.warn("🎥 [Vision Camera Error Caught]:", error);
|
|
74
86
|
onError?.({
|
|
@@ -80,11 +92,15 @@ export const EnhancedCameraView = ({ showCamera, cameraType: initialCameraType =
|
|
|
80
92
|
const codeScanner = useCodeScanner({
|
|
81
93
|
codeTypes: barcodeTypes || ['pdf-417', 'qr', 'code-128', 'code-39'],
|
|
82
94
|
onCodeScanned: (codes) => {
|
|
83
|
-
if (!isProcessingRef.current &&
|
|
95
|
+
if (!isProcessingRef.current && isScanningBarcodeRef.current) {
|
|
84
96
|
for (const code of codes) {
|
|
85
|
-
if (code.value
|
|
86
|
-
|
|
87
|
-
|
|
97
|
+
if (!code.value)
|
|
98
|
+
continue;
|
|
99
|
+
const now = Date.now();
|
|
100
|
+
const previous = scannedBarcodeRef.current;
|
|
101
|
+
if (previous.value !== code.value || now - previous.emittedAt > 1500) {
|
|
102
|
+
scannedBarcodeRef.current = { value: code.value, emittedAt: now };
|
|
103
|
+
onBarcodeScannedRef.current?.(code.value);
|
|
88
104
|
break;
|
|
89
105
|
}
|
|
90
106
|
}
|
|
@@ -101,8 +117,8 @@ export const EnhancedCameraView = ({ showCamera, cameraType: initialCameraType =
|
|
|
101
117
|
// Web handles its own stream via WebBarcodeScanner; do not run native camera methods on web.
|
|
102
118
|
if (Platform.OS === 'web')
|
|
103
119
|
return;
|
|
104
|
-
//
|
|
105
|
-
//
|
|
120
|
+
// The scheduling effect waits for camera initialization and a positioning
|
|
121
|
+
// grace period before this function can run.
|
|
106
122
|
if (!camera.current || isProcessingRef.current || isCapturingRef.current)
|
|
107
123
|
return;
|
|
108
124
|
if (isAnalyzingRef.current)
|
|
@@ -112,8 +128,14 @@ export const EnhancedCameraView = ({ showCamera, cameraType: initialCameraType =
|
|
|
112
128
|
const photo = await camera.current.takePhoto({
|
|
113
129
|
enableShutterSound: false,
|
|
114
130
|
flash: 'off',
|
|
115
|
-
|
|
116
|
-
|
|
131
|
+
...(Platform.OS === 'ios'
|
|
132
|
+
? {
|
|
133
|
+
photoCodec: 'jpeg',
|
|
134
|
+
// Barcode stills are decoded off the live path, so preserve the
|
|
135
|
+
// fine PDF417 modules instead of favoring capture speed.
|
|
136
|
+
qualityPrioritization: isScanningBarcodeRef.current ? 'quality' : 'balanced',
|
|
137
|
+
}
|
|
138
|
+
: {})
|
|
117
139
|
});
|
|
118
140
|
// 3. CROSS-PLATFORM PATH NORMALIZATION
|
|
119
141
|
let finalPath = photo.path;
|
|
@@ -134,7 +156,7 @@ export const EnhancedCameraView = ({ showCamera, cameraType: initialCameraType =
|
|
|
134
156
|
onSilentCaptureRef.current?.({
|
|
135
157
|
success: captureSuccess,
|
|
136
158
|
path: finalPath,
|
|
137
|
-
barcode: scannedBarcodeRef.current
|
|
159
|
+
barcode: scannedBarcodeRef.current.value
|
|
138
160
|
});
|
|
139
161
|
}
|
|
140
162
|
catch (error) {
|
|
@@ -147,44 +169,26 @@ export const EnhancedCameraView = ({ showCamera, cameraType: initialCameraType =
|
|
|
147
169
|
}, []); // <-- EMPTY ARRAY GUARANTEES STABILITY
|
|
148
170
|
// 5. THE UNBREAKABLE INTERVAL
|
|
149
171
|
useEffect(() => {
|
|
150
|
-
//
|
|
151
|
-
//
|
|
152
|
-
|
|
153
|
-
if (!showCamera || isProcessing || Platform.OS === 'web')
|
|
154
|
-
return;
|
|
155
|
-
let active = true;
|
|
156
|
-
let id;
|
|
157
|
-
const timer = setTimeout(() => {
|
|
158
|
-
if (!active)
|
|
159
|
-
return;
|
|
160
|
-
const intervalDelay = isScanningBarcode ? 3000 : 1500;
|
|
161
|
-
id = setInterval(captureSilentPhoto, intervalDelay);
|
|
162
|
-
}, 1500);
|
|
163
|
-
return () => {
|
|
164
|
-
active = false;
|
|
165
|
-
clearTimeout(timer);
|
|
166
|
-
if (id)
|
|
167
|
-
clearInterval(id);
|
|
168
|
-
};
|
|
169
|
-
}, [showCamera, isProcessing, isScanningBarcode, captureSilentPhoto]);
|
|
170
|
-
useEffect(() => {
|
|
171
|
-
if (!showCamera || !isInitialized || isProcessing)
|
|
172
|
+
// Give autofocus/exposure and the user time to settle before the first
|
|
173
|
+
// automatic capture. A remount creates a fresh grace period for each side.
|
|
174
|
+
if (!showCamera || !isInitialized || isProcessing || Platform.OS === 'web')
|
|
172
175
|
return;
|
|
173
176
|
let active = true;
|
|
174
177
|
let id;
|
|
175
178
|
const timer = setTimeout(() => {
|
|
176
179
|
if (!active)
|
|
177
180
|
return;
|
|
178
|
-
|
|
181
|
+
captureSilentPhoto();
|
|
182
|
+
const intervalDelay = isScanningBarcode ? 4500 : 3000;
|
|
179
183
|
id = setInterval(captureSilentPhoto, intervalDelay);
|
|
180
|
-
},
|
|
184
|
+
}, Math.max(0, captureStabilizationDelayMs));
|
|
181
185
|
return () => {
|
|
182
186
|
active = false;
|
|
183
187
|
clearTimeout(timer);
|
|
184
188
|
if (id)
|
|
185
189
|
clearInterval(id);
|
|
186
190
|
};
|
|
187
|
-
}, [showCamera, isInitialized, isProcessing,
|
|
191
|
+
}, [showCamera, isInitialized, isProcessing, isScanningBarcode, captureStabilizationDelayMs, captureSilentPhoto]);
|
|
188
192
|
useEffect(() => {
|
|
189
193
|
if (Platform.OS !== 'web' || !showCamera)
|
|
190
194
|
return;
|
|
@@ -209,8 +213,8 @@ export const EnhancedCameraView = ({ showCamera, cameraType: initialCameraType =
|
|
|
209
213
|
return () => clearTimeout(timeoutId);
|
|
210
214
|
}, [showCamera]);
|
|
211
215
|
const handleWebBarcodeScanned = useCallback((value) => {
|
|
212
|
-
if (!isProcessingRef.current && value !== scannedBarcodeRef.current) {
|
|
213
|
-
scannedBarcodeRef.current = value;
|
|
216
|
+
if (!isProcessingRef.current && value !== scannedBarcodeRef.current.value) {
|
|
217
|
+
scannedBarcodeRef.current = { value, emittedAt: Date.now() };
|
|
214
218
|
onBarcodeScanned?.(value);
|
|
215
219
|
}
|
|
216
220
|
}, [onBarcodeScanned]);
|
|
@@ -236,8 +240,13 @@ export const EnhancedCameraView = ({ showCamera, cameraType: initialCameraType =
|
|
|
236
240
|
if (!device || !showCamera)
|
|
237
241
|
return <View style={[styles.container, style]}/>;
|
|
238
242
|
return (<View ref={containerRef} style={[styles.container, style]}>
|
|
239
|
-
<Camera ref={camera} style={StyleSheet.absoluteFill} device={device} resizeMode="cover" isActive={showCamera && !isProcessing && appState === 'active'} photo={true} video={false} audio={false} onInitialized={onInitialized} onError={onCameraError}
|
|
240
|
-
|
|
243
|
+
<Camera ref={camera} style={StyleSheet.absoluteFill} device={device} resizeMode="cover" isActive={showCamera && !isProcessing && appState === 'active'} photo={true} photoQualityBalance={isScanningBarcode ? 'quality' : 'balanced'} video={false} audio={false} onInitialized={onInitialized} onError={onCameraError}
|
|
244
|
+
// Some Android camera levels cannot configure Preview + ImageCapture +
|
|
245
|
+
// ImageAnalysis together and fail with invalid-output-configuration.
|
|
246
|
+
// Android barcodes use the bundled full-resolution ML Kit/ZXing still
|
|
247
|
+
// decoder; iOS can retain Vision Camera's low-latency live scanner.
|
|
248
|
+
codeScanner={Platform.OS === 'ios' && isScanningBarcode ? codeScanner : undefined}/>
|
|
249
|
+
{Platform.OS === 'web' && isScanningBarcode && isVideoFound && (<WebBarcodeScanner videoRef={webVideoRef} onBarcodeScanned={handleWebBarcodeScanned} formats={barcodeTypes} active={!isProcessingRef.current}/>)}
|
|
241
250
|
{overlayComponent}
|
|
242
251
|
</View>);
|
|
243
252
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EnhancedCameraView.js","sourceRoot":"","sources":["../../../src/components/EnhancedCameraView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACxE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAkB,MAAM,cAAc,CAAC;AAC1F,OAAO,EAAE,MAAM,EAAY,eAAe,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC/F,OAAO,kBAAkB,MAAM,sCAAsC,CAAC;AACtE,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AASxD,MAAM,CAAC,MAAM,kBAAkB,GAAkC,CAAC,EAChE,UAAU,EACV,UAAU,EAAE,iBAAiB,GAAG,OAAO,EACvC,KAAK,EACL,OAAO,EACP,eAAe,EACf,mBAAmB,EACnB,YAAY,GAAG,KAAK,EACpB,gBAAgB,EAChB,iBAAiB,GAAG,KAAK,EACzB,gBAAgB,EAChB,YAAY,EACb,EAAE,EAAE;IACH,MAAM,EAAE,CAAC,EAAE,GAAG,OAAO,EAAE,CAAC;IACxB,MAAM,MAAM,GAAG,MAAM,CAAS,IAAI,CAAC,CAAC;IACpC,MAAM,WAAW,GAAG,MAAM,CAA0B,IAAI,CAAC,CAAC;IAE1D,MAAM,cAAc,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IACrC,MAAM,eAAe,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC;IAC7C,wEAAwE;IACxE,oEAAoE;IACpE,MAAM,cAAc,GAAG,MAAM,CAAC,mBAAmB,EAAE,WAAW,IAAI,KAAK,CAAC,CAAC;IAEzE,MAAM,CAAC,UAAU,CAAC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AM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;IAC/B,SAAS,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,eAAe,EAAE,OAAO,EAAE;IAChD,iBAAiB,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE;CACrF,CAAC,CAAC","sourcesContent":["import React, { useCallback, useEffect, useRef, useState } from 'react';\nimport { View, StyleSheet, Text, Platform, AppState, AppStateStatus } from 'react-native';\nimport { Camera, CodeType, useCameraDevice, useCodeScanner } from 'react-native-vision-camera';\nimport VisionCameraModule from '../modules/camera/VisionCameraModule';\nimport { useI18n } from '../hooks/useI18n';\nimport { EnhancedCameraViewProps } from './OverLay/type';\nimport { WebBarcodeScanner } from './WebBarcodeScanner';\n\nexport interface ExtendedCameraProps extends Omit<EnhancedCameraViewProps, 'onError'> {\n isScanningBarcode?: boolean;\n onBarcodeScanned?: (data: string) => void;\n barcodeTypes?: CodeType[];\n onError?: (error: { message: string; name?: string; code?: string }) => void; \n}\n\nexport const EnhancedCameraView: React.FC<ExtendedCameraProps> = ({\n showCamera,\n cameraType: initialCameraType = 'front',\n style,\n onError,\n onSilentCapture,\n silentCaptureResult,\n isProcessing = false,\n overlayComponent,\n isScanningBarcode = false,\n onBarcodeScanned,\n barcodeTypes\n}) => {\n const { t } = useI18n();\n const camera = useRef<Camera>(null);\n const webVideoRef = useRef<HTMLVideoElement | null>(null);\n \n const isCapturingRef = useRef(false);\n const isProcessingRef = useRef(isProcessing);\n // Ref-tracked isAnalyzing so captureSilentPhoto always reads the latest\n // value — the prop-based closure goes stale on iOS between renders.\n const isAnalyzingRef = useRef(silentCaptureResult?.isAnalyzing ?? false);\n \n const [cameraType] = useState<'front' | 'back'>(initialCameraType);\n const [hasPermission, setHasPermission] = useState<boolean | null>(null);\n const [isInitialized, setIsInitialized] = useState(false);\n const [refreshCamera] = useState(false);\n \n const [isVideoFound, setIsVideoFound] = useState(false);\n const scannedBarcodeRef = useRef<string | null>(null);\n const containerRef = useRef<any>(null);\n\n const [appState, setAppState] = useState<AppStateStatus>(AppState.currentState);\n\n const device = useCameraDevice(cameraType);\n\n useEffect(() => { isProcessingRef.current = isProcessing; }, [isProcessing]);\n useEffect(() => { isAnalyzingRef.current = silentCaptureResult?.isAnalyzing ?? false; }, [silentCaptureResult?.isAnalyzing]);\n\n useEffect(() => {\n const subscription = AppState.addEventListener('change', nextAppState => {\n setAppState(nextAppState);\n });\n return () => {\n subscription.remove();\n };\n }, []);\n\n const checkPermissions = async () => {\n try {\n // getCameraPermissionStatus is synchronous — no await\n const cameraStatus = Camera.getCameraPermissionStatus();\n\n if (cameraStatus === 'granted') {\n setHasPermission(true);\n return;\n }\n\n if (cameraStatus === 'not-determined') {\n const result = await Camera.requestCameraPermission();\n if (result === 'granted') {\n setHasPermission(true);\n return;\n }\n }\n\n // 'denied' or 'restricted' — user must enable in Settings\n setHasPermission(false);\n onError?.({\n message: t('camera.permissionRequired'),\n name: 'NotAllowedError',\n code: 'permission-denied'\n });\n } catch (e: any) {\n setHasPermission(false);\n onError?.({\n message: e.message || t('camera.errorOccurred'),\n name: e.name || 'UnknownError',\n code: e.code || 'unknown'\n });\n }\n };\n\n useEffect(() => {\n if (showCamera) checkPermissions();\n }, [showCamera, refreshCamera]);\n\n const onInitialized = useCallback(() => setIsInitialized(true), []);\n\n const onCameraError = useCallback((error: any) => {\n console.warn(\"🎥 [Vision Camera Error Caught]:\", error);\n onError?.({ \n message: error.message || t('camera.errorOccurred'),\n code: error.code, // Contains specific RNVC codes (e.g., 'session/camera-in-use')\n name: error.name // Contains Web standard names (e.g., 'NotReadableError')\n });\n }, [onError, t]);\n\n const codeScanner = useCodeScanner({\n codeTypes: barcodeTypes || ['pdf-417', 'qr', 'code-128', 'code-39'],\n onCodeScanned: (codes) => {\n if (!isProcessingRef.current && isScanningBarcode) {\n for (const code of codes) {\n if (code.value && scannedBarcodeRef.current !== code.value) {\n scannedBarcodeRef.current = code.value;\n onBarcodeScanned?.(code.value);\n break;\n }\n }\n }\n }\n });\n\n // 1. ISOLATE THE CALLBACK: This breaks the dependency death spiral for all platforms.\n const onSilentCaptureRef = useRef(onSilentCapture);\n useEffect(() => {\n onSilentCaptureRef.current = onSilentCapture;\n }, [onSilentCapture]);\n\n // 2. THE CAPTURE FUNCTION: Zero dependencies. Immune to re-renders.\n const captureSilentPhoto = useCallback(async () => {\n // Web handles its own stream via WebBarcodeScanner; do not run native camera methods on web.\n if (Platform.OS === 'web') return; \n \n // We intentionally ignore `isInitialized`. If AVFoundation (iOS) or CameraX (Android) \n // aren't ready, the try/catch will handle it gracefully.\n if (!camera.current || isProcessingRef.current || isCapturingRef.current) return;\n if (isAnalyzingRef.current) return;\n\n try {\n isCapturingRef.current = true;\n \n const photo = await camera.current.takePhoto({\n enableShutterSound: false,\n flash: 'off',\n // iOS requires aggressive compression to prevent RAM crashes during interval captures\n ...(Platform.OS === 'ios' ? { photoCodec: 'jpeg', qualityPrioritization: 'speed' } : {})\n });\n\n // 3. CROSS-PLATFORM PATH NORMALIZATION\n let finalPath = photo.path;\n let captureSuccess = true;\n\n // 4. DEFENSIVE NATIVE MODULE EXECUTION\n if (VisionCameraModule && VisionCameraModule.processPhotoResult) {\n try {\n const moduleResult = await VisionCameraModule.processPhotoResult(photo);\n if (moduleResult) {\n captureSuccess = moduleResult.success ?? true;\n finalPath = moduleResult.path || photo.path;\n }\n } catch (nativeError) {\n console.warn(\"⚠️ Native module failed, falling back to raw device path\");\n }\n }\n\n onSilentCaptureRef.current?.({\n success: captureSuccess,\n path: finalPath,\n barcode: scannedBarcodeRef.current\n });\n \n } catch (error: any) {\n // 📸 Silent fail: The camera is busy, focusing, or warming up. Just wait for the next tick.\n console.log(`📸 Frame dropped (${Platform.OS}):`, error?.message);\n } finally {\n isCapturingRef.current = false;\n }\n }, []); // <-- EMPTY ARRAY GUARANTEES STABILITY\n\n // 5. THE UNBREAKABLE INTERVAL\n useEffect(() => {\n // If we shouldn't scan, or if web (web handles its own stream), abort.\n // We intentionally don't require `isInitialized` here, the try/catch inside \n // captureSilentPhoto handles unready cameras gracefully without breaking the loop.\n if (!showCamera || isProcessing || Platform.OS === 'web') return; \n\n let active = true;\n let id: ReturnType<typeof setInterval>;\n\n const timer = setTimeout(() => {\n if (!active) return;\n const intervalDelay = isScanningBarcode ? 3000 : 1500;\n id = setInterval(captureSilentPhoto, intervalDelay);\n }, 1500);\n\n return () => {\n active = false;\n clearTimeout(timer);\n if (id) clearInterval(id);\n };\n }, [showCamera, isProcessing, isScanningBarcode, captureSilentPhoto]);\n\n\n useEffect(() => {\n if (!showCamera || !isInitialized || isProcessing) return;\n let active = true;\n let id: ReturnType<typeof setInterval>;\n \n const timer = setTimeout(() => {\n if (!active) return;\n const intervalDelay = isScanningBarcode ? 3000 : 1500;\n id = setInterval(captureSilentPhoto, intervalDelay);\n }, 1500);\n\n return () => {\n active = false;\n clearTimeout(timer);\n if (id) clearInterval(id);\n };\n }, [showCamera, isInitialized, isProcessing, captureSilentPhoto, isScanningBarcode]);\n\n useEffect(() => {\n if (Platform.OS !== 'web' || !showCamera) return;\n \n let timeoutId: ReturnType<typeof setTimeout>;\n \n const findVideo = () => {\n let video: HTMLVideoElement | null = null;\n if (containerRef.current?.querySelector) {\n video = containerRef.current.querySelector('video');\n }\n if (!video) {\n video = document.querySelector('video');\n }\n \n if (video) {\n webVideoRef.current = video;\n setIsVideoFound(true);\n } else {\n timeoutId = setTimeout(findVideo, 500);\n }\n };\n \n findVideo();\n return () => clearTimeout(timeoutId);\n }, [showCamera]);\n\n const handleWebBarcodeScanned = useCallback((value: string) => {\n if (!isProcessingRef.current && value !== scannedBarcodeRef.current) {\n scannedBarcodeRef.current = value;\n onBarcodeScanned?.(value);\n }\n }, [onBarcodeScanned]);\n\n if (hasPermission === null) return <View style={[styles.container, style]} />;\n \n if (hasPermission === false) return (\n <View style={[styles.container, style]}>\n <Text style={styles.permissionMessage}>{t('camera.permissionRequired')}</Text>\n </View>\n );\n\n if (!device && showCamera) {\n // We delay the missing device error slightly to account for the camera mounting delay\n setTimeout(() => {\n if (!device) {\n onError?.({ \n message: \"No camera detected\", \n name: \"NotFoundError\", \n code: \"device/not-found\" \n });\n }\n }, 1000);\n return <View style={[styles.container, style]} />;\n }\n\n if (!device || !showCamera) return <View style={[styles.container, style]} />;\n\n return (\n <View ref={containerRef} style={[styles.container, style]}>\n <Camera\n ref={camera}\n style={StyleSheet.absoluteFill}\n device={device}\n resizeMode=\"cover\"\n isActive={showCamera && !isProcessing && appState === 'active'}\n photo={true}\n video={false}\n audio={false}\n onInitialized={onInitialized}\n onError={onCameraError}\n codeScanner={Platform.OS !== 'web' && isScanningBarcode ? codeScanner : undefined}\n />\n {Platform.OS === 'web' && isScanningBarcode && isVideoFound && (\n <WebBarcodeScanner\n videoRef={webVideoRef as React.RefObject<HTMLVideoElement>}\n onBarcodeScanned={handleWebBarcodeScanned}\n active={!isProcessingRef.current}\n />\n )}\n {overlayComponent}\n </View>\n );\n};\n\nconst styles = StyleSheet.create({\n container: { flex: 1, backgroundColor: 'black' },\n permissionMessage: { color: 'white', textAlign: 'center', margin: 20, fontSize: 16 },\n});"]}
|
|
1
|
+
{"version":3,"file":"EnhancedCameraView.js","sourceRoot":"","sources":["../../../src/components/EnhancedCameraView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACxE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAkB,MAAM,cAAc,CAAC;AAC1F,OAAO,EAAE,MAAM,EAAY,eAAe,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC/F,OAAO,kBAAkB,MAAM,sCAAsC,CAAC;AACtE,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C,OAAO,E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AC3D,gBAAgB,CAAC,CAAC,uBAAuB,CAAC,CAC1C,OAAO,CAAC,CAAC,YAAY,CAAC,CACtB,MAAM,CAAC,CAAC,CAAC,eAAe,CAAC,OAAO,CAAC,EACjC,CACH,CACD;MAAA,CAAC,gBAAgB,CACnB;IAAA,EAAE,IAAI,CAAC,CACR,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;IAC/B,SAAS,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,eAAe,EAAE,OAAO,EAAE;IAChD,iBAAiB,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE;CACrF,CAAC,CAAC","sourcesContent":["import React, { useCallback, useEffect, useRef, useState } from 'react';\nimport { View, StyleSheet, Text, Platform, AppState, AppStateStatus } from 'react-native';\nimport { Camera, CodeType, useCameraDevice, useCodeScanner } from 'react-native-vision-camera';\nimport VisionCameraModule from '../modules/camera/VisionCameraModule';\nimport { useI18n } from '../hooks/useI18n';\nimport { EnhancedCameraViewProps } from './OverLay/type';\nimport { WebBarcodeScanner } from './WebBarcodeScanner';\n\nexport interface ExtendedCameraProps extends Omit<EnhancedCameraViewProps, 'onError'> {\n isScanningBarcode?: boolean;\n onBarcodeScanned?: (data: string) => void;\n barcodeTypes?: CodeType[];\n onError?: (error: { message: string; name?: string; code?: string }) => void; \n}\n\nexport const EnhancedCameraView: React.FC<ExtendedCameraProps> = ({\n showCamera,\n cameraType: initialCameraType = 'front',\n style,\n onError,\n onSilentCapture,\n silentCaptureResult,\n isProcessing = false,\n overlayComponent,\n captureStabilizationDelayMs = 4000,\n isScanningBarcode = false,\n onBarcodeScanned,\n barcodeTypes\n}) => {\n const { t } = useI18n();\n const camera = useRef<Camera>(null);\n const webVideoRef = useRef<HTMLVideoElement | null>(null);\n \n const isCapturingRef = useRef(false);\n const isProcessingRef = useRef(isProcessing);\n const isScanningBarcodeRef = useRef(isScanningBarcode);\n const onBarcodeScannedRef = useRef(onBarcodeScanned);\n // Ref-tracked isAnalyzing so captureSilentPhoto always reads the latest\n // value — the prop-based closure goes stale on iOS between renders.\n const isAnalyzingRef = useRef(silentCaptureResult?.isAnalyzing ?? false);\n \n const [cameraType] = useState<'front' | 'back'>(initialCameraType);\n const [hasPermission, setHasPermission] = useState<boolean | null>(null);\n const [isInitialized, setIsInitialized] = useState(false);\n const [refreshCamera] = useState(false);\n \n const [isVideoFound, setIsVideoFound] = useState(false);\n const scannedBarcodeRef = useRef<{ value: string | null; emittedAt: number }>({ value: null, emittedAt: 0 });\n const containerRef = useRef<any>(null);\n\n const [appState, setAppState] = useState<AppStateStatus>(AppState.currentState);\n\n const device = useCameraDevice(cameraType);\n\n useEffect(() => { isProcessingRef.current = isProcessing; }, [isProcessing]);\n useEffect(() => { isScanningBarcodeRef.current = isScanningBarcode; }, [isScanningBarcode]);\n useEffect(() => { onBarcodeScannedRef.current = onBarcodeScanned; }, [onBarcodeScanned]);\n useEffect(() => { isAnalyzingRef.current = silentCaptureResult?.isAnalyzing ?? false; }, [silentCaptureResult?.isAnalyzing]);\n\n useEffect(() => {\n scannedBarcodeRef.current = { value: null, emittedAt: 0 };\n }, [isScanningBarcode]);\n\n useEffect(() => {\n const subscription = AppState.addEventListener('change', nextAppState => {\n setAppState(nextAppState);\n });\n return () => {\n subscription.remove();\n };\n }, []);\n\n const checkPermissions = async () => {\n try {\n // getCameraPermissionStatus is synchronous — no await\n const cameraStatus = Camera.getCameraPermissionStatus();\n\n if (cameraStatus === 'granted') {\n setHasPermission(true);\n return;\n }\n\n if (cameraStatus === 'not-determined') {\n const result = await Camera.requestCameraPermission();\n if (result === 'granted') {\n setHasPermission(true);\n return;\n }\n }\n\n // 'denied' or 'restricted' — user must enable in Settings\n setHasPermission(false);\n onError?.({\n message: t('camera.permissionRequired'),\n name: 'NotAllowedError',\n code: 'permission-denied'\n });\n } catch (e: any) {\n setHasPermission(false);\n onError?.({\n message: e.message || t('camera.errorOccurred'),\n name: e.name || 'UnknownError',\n code: e.code || 'unknown'\n });\n }\n };\n\n useEffect(() => {\n if (showCamera) checkPermissions();\n }, [showCamera, refreshCamera]);\n\n const onInitialized = useCallback(() => {\n setIsInitialized(true);\n if (isScanningBarcodeRef.current) {\n console.log('📷 Barcode camera initialized');\n }\n }, []);\n\n const onCameraError = useCallback((error: any) => {\n console.warn(\"🎥 [Vision Camera Error Caught]:\", error);\n onError?.({ \n message: error.message || t('camera.errorOccurred'),\n code: error.code, // Contains specific RNVC codes (e.g., 'session/camera-in-use')\n name: error.name // Contains Web standard names (e.g., 'NotReadableError')\n });\n }, [onError, t]);\n\n const codeScanner = useCodeScanner({\n codeTypes: barcodeTypes || ['pdf-417', 'qr', 'code-128', 'code-39'],\n onCodeScanned: (codes) => {\n if (!isProcessingRef.current && isScanningBarcodeRef.current) {\n for (const code of codes) {\n if (!code.value) continue;\n\n const now = Date.now();\n const previous = scannedBarcodeRef.current;\n if (previous.value !== code.value || now - previous.emittedAt > 1500) {\n scannedBarcodeRef.current = { value: code.value, emittedAt: now };\n onBarcodeScannedRef.current?.(code.value);\n break;\n }\n }\n }\n }\n });\n\n // 1. ISOLATE THE CALLBACK: This breaks the dependency death spiral for all platforms.\n const onSilentCaptureRef = useRef(onSilentCapture);\n useEffect(() => {\n onSilentCaptureRef.current = onSilentCapture;\n }, [onSilentCapture]);\n\n // 2. THE CAPTURE FUNCTION: Zero dependencies. Immune to re-renders.\n const captureSilentPhoto = useCallback(async () => {\n // Web handles its own stream via WebBarcodeScanner; do not run native camera methods on web.\n if (Platform.OS === 'web') return; \n \n // The scheduling effect waits for camera initialization and a positioning\n // grace period before this function can run.\n if (!camera.current || isProcessingRef.current || isCapturingRef.current) return;\n if (isAnalyzingRef.current) return;\n\n try {\n isCapturingRef.current = true;\n \n const photo = await camera.current.takePhoto({\n enableShutterSound: false,\n flash: 'off',\n ...(Platform.OS === 'ios'\n ? {\n photoCodec: 'jpeg' as const,\n // Barcode stills are decoded off the live path, so preserve the\n // fine PDF417 modules instead of favoring capture speed.\n qualityPrioritization: isScanningBarcodeRef.current ? 'quality' as const : 'balanced' as const,\n }\n : {})\n });\n\n // 3. CROSS-PLATFORM PATH NORMALIZATION\n let finalPath = photo.path;\n let captureSuccess = true;\n\n // 4. DEFENSIVE NATIVE MODULE EXECUTION\n if (VisionCameraModule && VisionCameraModule.processPhotoResult) {\n try {\n const moduleResult = await VisionCameraModule.processPhotoResult(photo);\n if (moduleResult) {\n captureSuccess = moduleResult.success ?? true;\n finalPath = moduleResult.path || photo.path;\n }\n } catch (nativeError) {\n console.warn(\"⚠️ Native module failed, falling back to raw device path\");\n }\n }\n\n onSilentCaptureRef.current?.({\n success: captureSuccess,\n path: finalPath,\n barcode: scannedBarcodeRef.current.value\n });\n \n } catch (error: any) {\n // 📸 Silent fail: The camera is busy, focusing, or warming up. Just wait for the next tick.\n console.log(`📸 Frame dropped (${Platform.OS}):`, error?.message);\n } finally {\n isCapturingRef.current = false;\n }\n }, []); // <-- EMPTY ARRAY GUARANTEES STABILITY\n\n // 5. THE UNBREAKABLE INTERVAL\n useEffect(() => {\n // Give autofocus/exposure and the user time to settle before the first\n // automatic capture. A remount creates a fresh grace period for each side.\n if (!showCamera || !isInitialized || isProcessing || Platform.OS === 'web') return;\n\n let active = true;\n let id: ReturnType<typeof setInterval>;\n\n const timer = setTimeout(() => {\n if (!active) return;\n captureSilentPhoto();\n const intervalDelay = isScanningBarcode ? 4500 : 3000;\n id = setInterval(captureSilentPhoto, intervalDelay);\n }, Math.max(0, captureStabilizationDelayMs));\n\n return () => {\n active = false;\n clearTimeout(timer);\n if (id) clearInterval(id);\n };\n }, [showCamera, isInitialized, isProcessing, isScanningBarcode, captureStabilizationDelayMs, captureSilentPhoto]);\n\n useEffect(() => {\n if (Platform.OS !== 'web' || !showCamera) return;\n \n let timeoutId: ReturnType<typeof setTimeout>;\n \n const findVideo = () => {\n let video: HTMLVideoElement | null = null;\n if (containerRef.current?.querySelector) {\n video = containerRef.current.querySelector('video');\n }\n if (!video) {\n video = document.querySelector('video');\n }\n \n if (video) {\n webVideoRef.current = video;\n setIsVideoFound(true);\n } else {\n timeoutId = setTimeout(findVideo, 500);\n }\n };\n \n findVideo();\n return () => clearTimeout(timeoutId);\n }, [showCamera]);\n\n const handleWebBarcodeScanned = useCallback((value: string) => {\n if (!isProcessingRef.current && value !== scannedBarcodeRef.current.value) {\n scannedBarcodeRef.current = { value, emittedAt: Date.now() };\n onBarcodeScanned?.(value);\n }\n }, [onBarcodeScanned]);\n\n if (hasPermission === null) return <View style={[styles.container, style]} />;\n \n if (hasPermission === false) return (\n <View style={[styles.container, style]}>\n <Text style={styles.permissionMessage}>{t('camera.permissionRequired')}</Text>\n </View>\n );\n\n if (!device && showCamera) {\n // We delay the missing device error slightly to account for the camera mounting delay\n setTimeout(() => {\n if (!device) {\n onError?.({ \n message: \"No camera detected\", \n name: \"NotFoundError\", \n code: \"device/not-found\" \n });\n }\n }, 1000);\n return <View style={[styles.container, style]} />;\n }\n\n if (!device || !showCamera) return <View style={[styles.container, style]} />;\n\n return (\n <View ref={containerRef} style={[styles.container, style]}>\n <Camera\n ref={camera}\n style={StyleSheet.absoluteFill}\n device={device}\n resizeMode=\"cover\"\n isActive={showCamera && !isProcessing && appState === 'active'}\n photo={true}\n photoQualityBalance={isScanningBarcode ? 'quality' : 'balanced'}\n video={false}\n audio={false}\n onInitialized={onInitialized}\n onError={onCameraError}\n // Some Android camera levels cannot configure Preview + ImageCapture +\n // ImageAnalysis together and fail with invalid-output-configuration.\n // Android barcodes use the bundled full-resolution ML Kit/ZXing still\n // decoder; iOS can retain Vision Camera's low-latency live scanner.\n codeScanner={Platform.OS === 'ios' && isScanningBarcode ? codeScanner : undefined}\n />\n {Platform.OS === 'web' && isScanningBarcode && isVideoFound && (\n <WebBarcodeScanner\n videoRef={webVideoRef as React.RefObject<HTMLVideoElement>}\n onBarcodeScanned={handleWebBarcodeScanned}\n formats={barcodeTypes}\n active={!isProcessingRef.current}\n />\n )}\n {overlayComponent}\n </View>\n );\n};\n\nconst styles = StyleSheet.create({\n container: { flex: 1, backgroundColor: 'black' },\n permissionMessage: { color: 'white', textAlign: 'center', margin: 20, fontSize: 16 },\n});\n"]}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { EnhancedCameraViewProps } from './OverLay/type';
|
|
3
|
+
import type { CodeType } from 'react-native-vision-camera';
|
|
3
4
|
export interface ExtendedCameraProps extends EnhancedCameraViewProps {
|
|
4
5
|
isScanningBarcode?: boolean;
|
|
5
6
|
onBarcodeScanned?: (data: string) => void;
|
|
7
|
+
barcodeTypes?: CodeType[];
|
|
6
8
|
}
|
|
7
9
|
export declare const EnhancedCameraView: React.FC<ExtendedCameraProps>;
|
|
8
10
|
//# sourceMappingURL=EnhancedCameraView.web.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EnhancedCameraView.web.d.ts","sourceRoot":"","sources":["../../../src/components/EnhancedCameraView.web.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmD,MAAM,OAAO,CAAC;AAExE,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"EnhancedCameraView.web.d.ts","sourceRoot":"","sources":["../../../src/components/EnhancedCameraView.web.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmD,MAAM,OAAO,CAAC;AAExE,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAEzD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAK3D,MAAM,WAAW,mBAAoB,SAAQ,uBAAuB;IAClE,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,gBAAgB,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1C,YAAY,CAAC,EAAE,QAAQ,EAAE,CAAC;CAC3B;AAED,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CAwU5D,CAAC"}
|
|
@@ -3,9 +3,9 @@ import { View, StyleSheet, TouchableOpacity, Text, Platform } from 'react-native
|
|
|
3
3
|
import { useI18n } from '../hooks/useI18n';
|
|
4
4
|
// 🚨 Import the WebBarcodeScanner we built earlier
|
|
5
5
|
import { WebBarcodeScanner } from './WebBarcodeScanner';
|
|
6
|
-
export const EnhancedCameraView = ({ instructions = 'Position yourself in the frame and tap the capture button', showCamera, cameraType: initialCameraType = 'front', style, onCapture, onError, onClose, enableFlash = false, enableHdr = false, quality = 'high', showCaptureButton = true, showSwitchCamera = true, overlayComponent, bbox, canFlip = true, enableVideo = false, isRecording = false, onVideoRecordingStart, onVideoRecordingStop, videoDuration = 10, onSilentCapture, silentCaptureResult, captureStabilizationDelayMs =
|
|
6
|
+
export const EnhancedCameraView = ({ instructions = 'Position yourself in the frame and tap the capture button', showCamera, cameraType: initialCameraType = 'front', style, onCapture, onError, onClose, enableFlash = false, enableHdr = false, quality = 'high', showCaptureButton = true, showSwitchCamera = true, overlayComponent, bbox, canFlip = true, enableVideo = false, isRecording = false, onVideoRecordingStart, onVideoRecordingStop, videoDuration = 10, onSilentCapture, silentCaptureResult, captureStabilizationDelayMs = 4000,
|
|
7
7
|
// 🚨 New props for barcode support
|
|
8
|
-
isScanningBarcode = false, onBarcodeScanned, }) => {
|
|
8
|
+
isScanningBarcode = false, onBarcodeScanned, barcodeTypes, }) => {
|
|
9
9
|
const { t } = useI18n();
|
|
10
10
|
// Platform check
|
|
11
11
|
if (Platform.OS !== 'web') {
|
|
@@ -24,10 +24,13 @@ isScanningBarcode = false, onBarcodeScanned, }) => {
|
|
|
24
24
|
// const [recordedChunks, setRecordedChunks] = useState<Blob[]>([]);
|
|
25
25
|
// 🚨 New Refs for Barcode Logic
|
|
26
26
|
const isProcessingRef = useRef(silentCaptureResult?.isAnalyzing || false);
|
|
27
|
-
const scannedBarcodeRef = useRef(null);
|
|
27
|
+
const scannedBarcodeRef = useRef({ value: null, emittedAt: 0 });
|
|
28
28
|
useEffect(() => {
|
|
29
29
|
isProcessingRef.current = silentCaptureResult?.isAnalyzing || false;
|
|
30
30
|
}, [silentCaptureResult?.isAnalyzing]);
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
scannedBarcodeRef.current = { value: null, emittedAt: 0 };
|
|
33
|
+
}, [isScanningBarcode]);
|
|
31
34
|
useEffect(() => {
|
|
32
35
|
if (showCamera) {
|
|
33
36
|
checkPermissions();
|
|
@@ -183,8 +186,10 @@ isScanningBarcode = false, onBarcodeScanned, }) => {
|
|
|
183
186
|
// 🚨 Memoized Callback for Barcode Decoding
|
|
184
187
|
const handleWebBarcodeScanned = useCallback((value) => {
|
|
185
188
|
console.log(`🎉 [WEB SCANNER] SUCCESS! Decoded value:`, value);
|
|
186
|
-
|
|
187
|
-
|
|
189
|
+
const now = Date.now();
|
|
190
|
+
const previous = scannedBarcodeRef.current;
|
|
191
|
+
if (!isProcessingRef.current && (value !== previous.value || now - previous.emittedAt > 1500)) {
|
|
192
|
+
scannedBarcodeRef.current = { value, emittedAt: now };
|
|
188
193
|
onBarcodeScanned?.(value);
|
|
189
194
|
}
|
|
190
195
|
}, [onBarcodeScanned]);
|
|
@@ -226,7 +231,7 @@ isScanningBarcode = false, onBarcodeScanned, }) => {
|
|
|
226
231
|
top: '-9999px',
|
|
227
232
|
}}/>
|
|
228
233
|
|
|
229
|
-
{isScanningBarcode && isInitialized && (<WebBarcodeScanner videoRef={videoRef} onBarcodeScanned={handleWebBarcodeScanned}
|
|
234
|
+
{isScanningBarcode && isInitialized && (<WebBarcodeScanner videoRef={videoRef} onBarcodeScanned={handleWebBarcodeScanned} formats={barcodeTypes}
|
|
230
235
|
// Use silentCaptureResult.isAnalyzing (state) not the ref so
|
|
231
236
|
// React re-renders with the correct active value
|
|
232
237
|
active={isScanningBarcode && isInitialized && !(silentCaptureResult?.isAnalyzing ?? false)}/>)}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EnhancedCameraView.web.js","sourceRoot":"","sources":["../../../src/components/EnhancedCameraView.web.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACxE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,gBAAgB,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAElF,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,mDAAmD;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAQxD,MAAM,CAAC,MAAM,kBAAkB,GAAkC,CAAC,EAChE,YAAY,GAAG,2DAA2D,EAC1E,UAAU,EACV,UAAU,EAAE,iBAAiB,GAAG,OAAO,EACvC,KAAK,EACL,SAAS,EACT,OAAO,EACP,OAAO,EACP,WAAW,GAAG,KAAK,EACnB,SAAS,GAAG,KAAK,EACjB,OAAO,GAAG,MAAM,EAChB,iBAAiB,GAAG,IAAI,EACxB,gBAAgB,GAAG,IAAI,EACvB,gBAAgB,EAChB,IAAI,EACJ,OAAO,GAAG,IAAI,EACd,WAAW,GAAG,KAAK,EACnB,WAAW,GAAG,KAAK,EACnB,qBAAqB,EACrB,oBAAoB,EACpB,aAAa,GAAG,EAAE,EAClB,eAAe,EACf,mBAAmB,EACnB,2BAA2B,GAAG,IAAI;AAClC,mCAAmC;AACnC,iBAAiB,GAAG,KAAK,EACzB,gBAAgB,GACjB,EAAE,EAAE;IACH,MAAM,EAAE,CAAC,EAAE,GAAG,OAAO,EAAE,CAAC;IAExB,iBAAiB;IACjB,IAAI,QAAQ,CAAC,EAAE,KAAK,KAAK,EAAE,CAAC;QAC1B,OAAO,CAAC,IAAI,CAAC,gEAAgE,CAAC,CAAC;QAC/E,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,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AAO,EAAE,QAAQ,EAAE,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE;IACpF,YAAY,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE;IAC7E,WAAW,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,aAAa,EAAE,MAAM,EAAE;IAClG,IAAI,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,WAAW,EAAE,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE;IACpF,kBAAkB,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,QAAQ,EAAE,eAAe,EAAE,oBAAoB,EAAE,OAAO,EAAE,EAAE,EAAE,YAAY,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE;IAClK,aAAa,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE;CACpE,CAAC,CAAC","sourcesContent":["import React, { useCallback, useEffect, useRef, useState } from 'react';\nimport { View, StyleSheet, TouchableOpacity, Text, Platform } from 'react-native';\nimport { EnhancedCameraViewProps } from './OverLay/type';\nimport { useI18n } from '../hooks/useI18n';\n// 🚨 Import the WebBarcodeScanner we built earlier\nimport { WebBarcodeScanner } from './WebBarcodeScanner';\n\n// Add the specific properties needed for barcode scanning to the existing props\nexport interface ExtendedCameraProps extends EnhancedCameraViewProps {\n isScanningBarcode?: boolean;\n onBarcodeScanned?: (data: string) => void;\n}\n\nexport const EnhancedCameraView: React.FC<ExtendedCameraProps> = ({\n instructions = 'Position yourself in the frame and tap the capture button',\n showCamera,\n cameraType: initialCameraType = 'front',\n style,\n onCapture,\n onError,\n onClose,\n enableFlash = false,\n enableHdr = false,\n quality = 'high',\n showCaptureButton = true,\n showSwitchCamera = true,\n overlayComponent,\n bbox,\n canFlip = true,\n enableVideo = false,\n isRecording = false,\n onVideoRecordingStart,\n onVideoRecordingStop,\n videoDuration = 10,\n onSilentCapture,\n silentCaptureResult,\n captureStabilizationDelayMs = 2500,\n // 🚨 New props for barcode support\n isScanningBarcode = false,\n onBarcodeScanned,\n}) => {\n const { t } = useI18n();\n\n // Platform check\n if (Platform.OS !== 'web') {\n console.warn('EnhancedCameraView.web.tsx should only be used on web platform');\n return null;\n }\n\n const videoRef = useRef<HTMLVideoElement>(null);\n const canvasRef = useRef<HTMLCanvasElement>(null);\n\n const [cameraType, setCameraType] = useState<'front' | 'back'>(initialCameraType);\n const [hasPermission, setHasPermission] = useState(false);\n const [isInitialized, setIsInitialized] = useState(false);\n // const [flash, setFlash] = useState<'off' | 'on' | 'auto'>('off');\n const [stream, setStream] = useState<MediaStream | null>(null);\n // const [isRecordingVideo, setIsRecordingVideo] = useState(false);\n // const [mediaRecorder, setMediaRecorder] = useState<MediaRecorder | null>(null);\n // const [recordedChunks, setRecordedChunks] = useState<Blob[]>([]);\n\n // 🚨 New Refs for Barcode Logic\n const isProcessingRef = useRef(silentCaptureResult?.isAnalyzing || false);\n const scannedBarcodeRef = useRef<string | null>(null);\n\n useEffect(() => {\n isProcessingRef.current = silentCaptureResult?.isAnalyzing || false;\n }, [silentCaptureResult?.isAnalyzing]);\n\n useEffect(() => {\n if (showCamera) {\n checkPermissions();\n }\n }, [showCamera]);\n\n useEffect(() => {\n return () => {\n if (stream) {\n stream.getTracks().forEach(track => track.stop());\n }\n };\n }, [stream]);\n\n const getVideoConstraints = useCallback((): MediaTrackConstraints => {\n const isHigh = quality === 'high';\n const isMedium = quality === 'medium';\n return {\n facingMode: cameraType === 'front' ? 'user' : 'environment',\n width: {\n min: isHigh ? 1280 : isMedium ? 960 : 640,\n ideal: isHigh ? 2560 : isMedium ? 1280 : 640,\n },\n height: {\n min: isHigh ? 720 : isMedium ? 540 : 480,\n ideal: isHigh ? 1440 : isMedium ? 720 : 480,\n },\n };\n }, [cameraType, quality]);\n\n const checkPermissions = async () => {\n try {\n if (!navigator.mediaDevices || !navigator.mediaDevices.getUserMedia) {\n onError?.({ message: 'Camera not supported in this browser' });\n return;\n }\n const tempStream = await navigator.mediaDevices.getUserMedia({\n video: getVideoConstraints(),\n audio: enableVideo,\n });\n tempStream.getTracks().forEach(track => track.stop());\n setHasPermission(true);\n await startCamera();\n } catch (error) {\n console.error('Error checking permissions:', error);\n onError?.({ message: 'Camera permissions not granted' });\n }\n };\n\n const startCamera = async () => {\n try {\n if (stream) {\n stream.getTracks().forEach(track => track.stop());\n }\n const constraints: MediaStreamConstraints = {\n video: getVideoConstraints(),\n audio: enableVideo,\n };\n let newStream: MediaStream;\n try {\n newStream = await navigator.mediaDevices.getUserMedia(constraints);\n } catch (err) {\n const name = err instanceof Error ? err.name : '';\n if (name === 'OverconstrainedError') {\n const fallbackConstraints: MediaStreamConstraints = {\n video: {\n facingMode: cameraType === 'front' ? 'user' : 'environment',\n width: { ideal: quality === 'high' ? 2560 : quality === 'medium' ? 1280 : 640 },\n height: { ideal: quality === 'high' ? 1440 : quality === 'medium' ? 720 : 480 },\n },\n audio: enableVideo,\n };\n newStream = await navigator.mediaDevices.getUserMedia(fallbackConstraints);\n } else {\n throw err;\n }\n }\n setStream(newStream);\n if (videoRef.current) {\n videoRef.current.srcObject = newStream;\n // 🚨 CRUCIAL FIX: Wait for the video to actually have metadata before saying it's initialized\n videoRef.current.onloadedmetadata = () => {\n console.log('✅ [WEB ENGINE] Camera stream loaded metadata. Initializing.');\n setIsInitialized(true);\n };\n }\n } catch (error) {\n console.error('Error starting camera:', error);\n onError?.({ message: 'Failed to start camera' });\n }\n };\n\n // const capturePhoto = useCallback(async () => {\n // try {\n // onCapture && onCapture({ success: true });\n // } catch (error) {\n // console.error('Error taking photo:', error);\n // onCapture?.({\n // success: false,\n // error: error instanceof Error ? error.message : 'Failed to capture photo',\n // });\n // }\n // }, [isInitialized, onCapture, onError]);\n\n const captureSilentPhoto = useCallback(async () => {\n try {\n // During barcode phase, we still need to take a photo to give\n // handleSilentCapture the image path for pendingCAImage.\n // IDCardCapture gates further processing via scanPhase state.\n if (!videoRef.current || !canvasRef.current || !isInitialized) {\n return; // Fail silently, no need to throw errors in a loop\n }\n const video = videoRef.current;\n const canvas = canvasRef.current;\n const context = canvas.getContext('2d');\n if (!context) {\n return;\n }\n canvas.width = video.videoWidth;\n canvas.height = video.videoHeight;\n if (cameraType === 'front') {\n context.save();\n context.translate(canvas.width, 0);\n context.scale(-1, 1);\n context.drawImage(video, 0, 0);\n context.restore();\n } else {\n context.drawImage(video, 0, 0);\n }\n const imageDataUrl = canvas.toDataURL('image/jpeg', 0.95);\n onSilentCapture?.({ success: true, path: imageDataUrl, barcode: null });\n } catch (error) {\n console.error('Error taking silent photo:', error);\n }\n }, [isInitialized, cameraType, onSilentCapture, isScanningBarcode]);\n\n useEffect(() => {\n if (!showCamera || !isInitialized || silentCaptureResult?.success) {\n return;\n }\n const delayMs = Math.max(0, captureStabilizationDelayMs);\n const intervalMs = 5000;\n let intervalId: ReturnType<typeof setInterval> | null = null;\n const timeoutId = setTimeout(() => {\n captureSilentPhoto();\n intervalId = setInterval(captureSilentPhoto, intervalMs);\n }, delayMs);\n return () => {\n clearTimeout(timeoutId);\n if (intervalId) clearInterval(intervalId);\n };\n }, [showCamera, isInitialized, captureStabilizationDelayMs, captureSilentPhoto, silentCaptureResult?.success]);\n\n // 🚨 Memoized Callback for Barcode Decoding\n const handleWebBarcodeScanned = useCallback((value: string) => {\n console.log(`🎉 [WEB SCANNER] SUCCESS! Decoded value:`, value);\n if (!isProcessingRef.current && value !== scannedBarcodeRef.current) {\n scannedBarcodeRef.current = value;\n onBarcodeScanned?.(value);\n }\n }, [onBarcodeScanned]);\n\n // Video recording logic...\n // const startVideoRecording = useCallback(async () => {\n // /* ... Keep original logic ... */\n // }, [isInitialized, stream, videoDuration, onVideoRecordingStart, onVideoRecordingStop, onError]);\n\n // const stopVideoRecording = useCallback(async () => {\n // /* ... Keep original logic ... */\n // }, [mediaRecorder, onError]);\n\n const switchCamera = useCallback(async () => {\n setCameraType(current => current === 'front' ? 'back' : 'front');\n await startCamera();\n }, [cameraType]);\n\n // const toggleFlash = useCallback(() => {\n // /* ... Keep original logic ... */\n // }, []);\n\n if (!hasPermission) {\n return (\n <View style={[styles.container, style]}>\n <Text style={styles.permissionMessage}>\n Camera permission required. Please grant permission to continue.\n </Text>\n </View>\n );\n }\n\n if (!showCamera) {\n return <View style={[styles.container, style]} />;\n }\n\n return (\n <View style={[styles.container, style]}>\n <video\n ref={videoRef}\n style={{\n position: 'absolute',\n width: '100%',\n height: '100%',\n objectFit: 'cover',\n transform: cameraType === 'front' ? 'scaleX(-1)' : undefined,\n }}\n autoPlay\n playsInline\n muted\n />\n <canvas\n ref={canvasRef}\n style={{\n position: 'absolute',\n left: '-9999px',\n top: '-9999px',\n }}\n />\n\n {isScanningBarcode && isInitialized && (\n <WebBarcodeScanner\n videoRef={videoRef}\n onBarcodeScanned={handleWebBarcodeScanned}\n // Use silentCaptureResult.isAnalyzing (state) not the ref so\n // React re-renders with the correct active value\n active={isScanningBarcode && isInitialized && !(silentCaptureResult?.isAnalyzing ?? false)}\n />\n )}\n\n {overlayComponent}\n\n {bbox && (\n <View style={styles.bboxOverlay}>\n <View\n style={[\n styles.bbox,\n {\n left: `${bbox.xMin}%`,\n top: `${bbox.yMin}%`,\n width: `${bbox.xMax - bbox.xMin}%`,\n height: `${bbox.yMax - bbox.yMin}%`,\n borderColor: bbox.borderColor || '#2DBD60',\n borderWidth: bbox.borderWidth || 3,\n borderRadius: bbox.cornerRadius || 8,\n },\n ]}\n />\n </View>\n )}\n\n {silentCaptureResult?.isAnalyzing && (\n <View style={styles.analyzingContainer}>\n <Text style={styles.analyzingText}>{t('camera.analyzing')}</Text>\n </View>\n )}\n\n <View style={styles.controlsContainer}>\n {showSwitchCamera && canFlip && (\n <TouchableOpacity style={styles.controlButton} onPress={switchCamera}>\n <Text style={styles.controlButtonText}>🔄</Text>\n </TouchableOpacity>\n )}\n </View>\n </View>\n );\n};\n\nconst styles = StyleSheet.create({\n // ... Keep all your original styles exactly as they are\n container: { flex: 1, backgroundColor: 'black' },\n instructionsOverlay: { position: 'absolute', top: 60, left: 20, right: 20, backgroundColor: 'rgba(0, 0, 0, 0.7)', padding: 15, borderRadius: 10, zIndex: 1 },\n instructions: { color: 'white', fontSize: 16, textAlign: 'center', fontWeight: '500' },\n closeButton: { position: 'absolute', top: 50, right: 20, backgroundColor: 'rgba(0, 0, 0, 0.7)', width: 40, height: 40, borderRadius: 20, justifyContent: 'center', alignItems: 'center', zIndex: 2 },\n closeButtonText: { color: 'white', fontSize: 20, fontWeight: 'bold' },\n controlsContainer: { position: 'absolute', bottom: 40, left: 0, right: 0, flexDirection: 'row', justifyContent: 'space-around', alignItems: 'center', paddingHorizontal: 40, zIndex: 1 },\n controlButton: { backgroundColor: 'rgba(0, 0, 0, 0.7)', width: 50, height: 50, borderRadius: 25, justifyContent: 'center', alignItems: 'center' },\n controlButtonText: { fontSize: 24 },\n captureButton: { backgroundColor: 'rgba(255, 255, 255, 0.3)', width: 80, height: 80, borderRadius: 40, justifyContent: 'center', alignItems: 'center', borderWidth: 3, borderColor: 'white' },\n captureButtonInner: { backgroundColor: 'white', width: 60, height: 60, borderRadius: 30 },\n captureButtonDisabled: { backgroundColor: 'rgba(255, 255, 255, 0.5)' },\n recordingButton: { backgroundColor: 'rgba(255, 59, 48, 0.3)', borderColor: '#FF3B30' },\n recordingButtonInner: { backgroundColor: '#FF3B30' },\n permissionMessage: { color: 'white', fontSize: 16, textAlign: 'center', margin: 20 },\n errorMessage: { color: 'red', fontSize: 16, textAlign: 'center', margin: 20 },\n bboxOverlay: { position: 'absolute', top: 0, left: 0, right: 0, bottom: 0, pointerEvents: 'none' },\n bbox: { position: 'absolute', borderStyle: 'solid', backgroundColor: 'transparent' },\n analyzingContainer: { position: 'absolute', bottom: 100, alignSelf: 'center', backgroundColor: 'rgba(0, 0, 0, 0.7)', padding: 10, borderRadius: 10, zIndex: 1000 },\n analyzingText: { color: 'white', fontSize: 16, fontWeight: 'bold' },\n});"]}
|
|
1
|
+
{"version":3,"file":"EnhancedCameraView.web.js","sourceRoot":"","sources":["../../../src/components/EnhancedCameraView.web.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACxE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,gBAAgB,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAElF,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C,mDAAmD;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AASxD,MAAM,CAAC,MAAM,kBAAkB,GAAkC,CAAC,EAChE,YAAY,GAAG,2DAA2D,EAC1E,UAAU,EACV,UAAU,EAAE,iBAAiB,GAAG,OAAO,EACvC,KAAK,EACL,SAAS,EACT,OAAO,EACP,OAAO,EACP,WAAW,GAAG,KAAK,EACnB,SAAS,GAAG,KAAK,EACjB,OAAO,GAAG,MAAM,EAChB,iBAAiB,GAAG,IAAI,EACxB,gBAAgB,GAAG,IAAI,EACvB,gBAAgB,EAChB,IAAI,EACJ,OAAO,GAAG,IAAI,EACd,WAAW,GAAG,KAAK,EACnB,WAAW,GAAG,KAAK,EACnB,qBAAqB,EACrB,oBAAoB,EACpB,aAAa,GAAG,EAAE,EAClB,eAAe,EACf,mBAAmB,EACnB,2BAA2B,GAAG,IAAI;AAClC,mCAAmC;AACnC,iBAAiB,GAAG,KAAK,EACzB,gBAAgB,EAChB,YAAY,GACb,EAAE,EAAE;IACH,MAAM,EAAE,CAAC,EAAE,GAAG,OAAO,EAAE,CAAC;IA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OAAO,EAAE,EAAE,EAAE,YAAY,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE;IAClK,aAAa,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE;CACpE,CAAC,CAAC","sourcesContent":["import React, { useCallback, useEffect, useRef, useState } from 'react';\nimport { View, StyleSheet, TouchableOpacity, Text, Platform } from 'react-native';\nimport { EnhancedCameraViewProps } from './OverLay/type';\nimport { useI18n } from '../hooks/useI18n';\nimport type { CodeType } from 'react-native-vision-camera';\n// 🚨 Import the WebBarcodeScanner we built earlier\nimport { WebBarcodeScanner } from './WebBarcodeScanner';\n\n// Add the specific properties needed for barcode scanning to the existing props\nexport interface ExtendedCameraProps extends EnhancedCameraViewProps {\n isScanningBarcode?: boolean;\n onBarcodeScanned?: (data: string) => void;\n barcodeTypes?: CodeType[];\n}\n\nexport const EnhancedCameraView: React.FC<ExtendedCameraProps> = ({\n instructions = 'Position yourself in the frame and tap the capture button',\n showCamera,\n cameraType: initialCameraType = 'front',\n style,\n onCapture,\n onError,\n onClose,\n enableFlash = false,\n enableHdr = false,\n quality = 'high',\n showCaptureButton = true,\n showSwitchCamera = true,\n overlayComponent,\n bbox,\n canFlip = true,\n enableVideo = false,\n isRecording = false,\n onVideoRecordingStart,\n onVideoRecordingStop,\n videoDuration = 10,\n onSilentCapture,\n silentCaptureResult,\n captureStabilizationDelayMs = 4000,\n // 🚨 New props for barcode support\n isScanningBarcode = false,\n onBarcodeScanned,\n barcodeTypes,\n}) => {\n const { t } = useI18n();\n\n // Platform check\n if (Platform.OS !== 'web') {\n console.warn('EnhancedCameraView.web.tsx should only be used on web platform');\n return null;\n }\n\n const videoRef = useRef<HTMLVideoElement>(null);\n const canvasRef = useRef<HTMLCanvasElement>(null);\n\n const [cameraType, setCameraType] = useState<'front' | 'back'>(initialCameraType);\n const [hasPermission, setHasPermission] = useState(false);\n const [isInitialized, setIsInitialized] = useState(false);\n // const [flash, setFlash] = useState<'off' | 'on' | 'auto'>('off');\n const [stream, setStream] = useState<MediaStream | null>(null);\n // const [isRecordingVideo, setIsRecordingVideo] = useState(false);\n // const [mediaRecorder, setMediaRecorder] = useState<MediaRecorder | null>(null);\n // const [recordedChunks, setRecordedChunks] = useState<Blob[]>([]);\n\n // 🚨 New Refs for Barcode Logic\n const isProcessingRef = useRef(silentCaptureResult?.isAnalyzing || false);\n const scannedBarcodeRef = useRef<{ value: string | null; emittedAt: number }>({ value: null, emittedAt: 0 });\n\n useEffect(() => {\n isProcessingRef.current = silentCaptureResult?.isAnalyzing || false;\n }, [silentCaptureResult?.isAnalyzing]);\n\n useEffect(() => {\n scannedBarcodeRef.current = { value: null, emittedAt: 0 };\n }, [isScanningBarcode]);\n\n useEffect(() => {\n if (showCamera) {\n checkPermissions();\n }\n }, [showCamera]);\n\n useEffect(() => {\n return () => {\n if (stream) {\n stream.getTracks().forEach(track => track.stop());\n }\n };\n }, [stream]);\n\n const getVideoConstraints = useCallback((): MediaTrackConstraints => {\n const isHigh = quality === 'high';\n const isMedium = quality === 'medium';\n return {\n facingMode: cameraType === 'front' ? 'user' : 'environment',\n width: {\n min: isHigh ? 1280 : isMedium ? 960 : 640,\n ideal: isHigh ? 2560 : isMedium ? 1280 : 640,\n },\n height: {\n min: isHigh ? 720 : isMedium ? 540 : 480,\n ideal: isHigh ? 1440 : isMedium ? 720 : 480,\n },\n };\n }, [cameraType, quality]);\n\n const checkPermissions = async () => {\n try {\n if (!navigator.mediaDevices || !navigator.mediaDevices.getUserMedia) {\n onError?.({ message: 'Camera not supported in this browser' });\n return;\n }\n const tempStream = await navigator.mediaDevices.getUserMedia({\n video: getVideoConstraints(),\n audio: enableVideo,\n });\n tempStream.getTracks().forEach(track => track.stop());\n setHasPermission(true);\n await startCamera();\n } catch (error) {\n console.error('Error checking permissions:', error);\n onError?.({ message: 'Camera permissions not granted' });\n }\n };\n\n const startCamera = async () => {\n try {\n if (stream) {\n stream.getTracks().forEach(track => track.stop());\n }\n const constraints: MediaStreamConstraints = {\n video: getVideoConstraints(),\n audio: enableVideo,\n };\n let newStream: MediaStream;\n try {\n newStream = await navigator.mediaDevices.getUserMedia(constraints);\n } catch (err) {\n const name = err instanceof Error ? err.name : '';\n if (name === 'OverconstrainedError') {\n const fallbackConstraints: MediaStreamConstraints = {\n video: {\n facingMode: cameraType === 'front' ? 'user' : 'environment',\n width: { ideal: quality === 'high' ? 2560 : quality === 'medium' ? 1280 : 640 },\n height: { ideal: quality === 'high' ? 1440 : quality === 'medium' ? 720 : 480 },\n },\n audio: enableVideo,\n };\n newStream = await navigator.mediaDevices.getUserMedia(fallbackConstraints);\n } else {\n throw err;\n }\n }\n setStream(newStream);\n if (videoRef.current) {\n videoRef.current.srcObject = newStream;\n // 🚨 CRUCIAL FIX: Wait for the video to actually have metadata before saying it's initialized\n videoRef.current.onloadedmetadata = () => {\n console.log('✅ [WEB ENGINE] Camera stream loaded metadata. Initializing.');\n setIsInitialized(true);\n };\n }\n } catch (error) {\n console.error('Error starting camera:', error);\n onError?.({ message: 'Failed to start camera' });\n }\n };\n\n // const capturePhoto = useCallback(async () => {\n // try {\n // onCapture && onCapture({ success: true });\n // } catch (error) {\n // console.error('Error taking photo:', error);\n // onCapture?.({\n // success: false,\n // error: error instanceof Error ? error.message : 'Failed to capture photo',\n // });\n // }\n // }, [isInitialized, onCapture, onError]);\n\n const captureSilentPhoto = useCallback(async () => {\n try {\n // During barcode phase, we still need to take a photo to give\n // handleSilentCapture the image path for pendingCAImage.\n // IDCardCapture gates further processing via scanPhase state.\n if (!videoRef.current || !canvasRef.current || !isInitialized) {\n return; // Fail silently, no need to throw errors in a loop\n }\n const video = videoRef.current;\n const canvas = canvasRef.current;\n const context = canvas.getContext('2d');\n if (!context) {\n return;\n }\n canvas.width = video.videoWidth;\n canvas.height = video.videoHeight;\n if (cameraType === 'front') {\n context.save();\n context.translate(canvas.width, 0);\n context.scale(-1, 1);\n context.drawImage(video, 0, 0);\n context.restore();\n } else {\n context.drawImage(video, 0, 0);\n }\n const imageDataUrl = canvas.toDataURL('image/jpeg', 0.95);\n onSilentCapture?.({ success: true, path: imageDataUrl, barcode: null });\n } catch (error) {\n console.error('Error taking silent photo:', error);\n }\n }, [isInitialized, cameraType, onSilentCapture, isScanningBarcode]);\n\n useEffect(() => {\n if (!showCamera || !isInitialized || silentCaptureResult?.success) {\n return;\n }\n const delayMs = Math.max(0, captureStabilizationDelayMs);\n const intervalMs = 5000;\n let intervalId: ReturnType<typeof setInterval> | null = null;\n const timeoutId = setTimeout(() => {\n captureSilentPhoto();\n intervalId = setInterval(captureSilentPhoto, intervalMs);\n }, delayMs);\n return () => {\n clearTimeout(timeoutId);\n if (intervalId) clearInterval(intervalId);\n };\n }, [showCamera, isInitialized, captureStabilizationDelayMs, captureSilentPhoto, silentCaptureResult?.success]);\n\n // 🚨 Memoized Callback for Barcode Decoding\n const handleWebBarcodeScanned = useCallback((value: string) => {\n console.log(`🎉 [WEB SCANNER] SUCCESS! Decoded value:`, value);\n const now = Date.now();\n const previous = scannedBarcodeRef.current;\n if (!isProcessingRef.current && (value !== previous.value || now - previous.emittedAt > 1500)) {\n scannedBarcodeRef.current = { value, emittedAt: now };\n onBarcodeScanned?.(value);\n }\n }, [onBarcodeScanned]);\n\n // Video recording logic...\n // const startVideoRecording = useCallback(async () => {\n // /* ... Keep original logic ... */\n // }, [isInitialized, stream, videoDuration, onVideoRecordingStart, onVideoRecordingStop, onError]);\n\n // const stopVideoRecording = useCallback(async () => {\n // /* ... Keep original logic ... */\n // }, [mediaRecorder, onError]);\n\n const switchCamera = useCallback(async () => {\n setCameraType(current => current === 'front' ? 'back' : 'front');\n await startCamera();\n }, [cameraType]);\n\n // const toggleFlash = useCallback(() => {\n // /* ... Keep original logic ... */\n // }, []);\n\n if (!hasPermission) {\n return (\n <View style={[styles.container, style]}>\n <Text style={styles.permissionMessage}>\n Camera permission required. Please grant permission to continue.\n </Text>\n </View>\n );\n }\n\n if (!showCamera) {\n return <View style={[styles.container, style]} />;\n }\n\n return (\n <View style={[styles.container, style]}>\n <video\n ref={videoRef}\n style={{\n position: 'absolute',\n width: '100%',\n height: '100%',\n objectFit: 'cover',\n transform: cameraType === 'front' ? 'scaleX(-1)' : undefined,\n }}\n autoPlay\n playsInline\n muted\n />\n <canvas\n ref={canvasRef}\n style={{\n position: 'absolute',\n left: '-9999px',\n top: '-9999px',\n }}\n />\n\n {isScanningBarcode && isInitialized && (\n <WebBarcodeScanner\n videoRef={videoRef}\n onBarcodeScanned={handleWebBarcodeScanned}\n formats={barcodeTypes}\n // Use silentCaptureResult.isAnalyzing (state) not the ref so\n // React re-renders with the correct active value\n active={isScanningBarcode && isInitialized && !(silentCaptureResult?.isAnalyzing ?? false)}\n />\n )}\n\n {overlayComponent}\n\n {bbox && (\n <View style={styles.bboxOverlay}>\n <View\n style={[\n styles.bbox,\n {\n left: `${bbox.xMin}%`,\n top: `${bbox.yMin}%`,\n width: `${bbox.xMax - bbox.xMin}%`,\n height: `${bbox.yMax - bbox.yMin}%`,\n borderColor: bbox.borderColor || '#2DBD60',\n borderWidth: bbox.borderWidth || 3,\n borderRadius: bbox.cornerRadius || 8,\n },\n ]}\n />\n </View>\n )}\n\n {silentCaptureResult?.isAnalyzing && (\n <View style={styles.analyzingContainer}>\n <Text style={styles.analyzingText}>{t('camera.analyzing')}</Text>\n </View>\n )}\n\n <View style={styles.controlsContainer}>\n {showSwitchCamera && canFlip && (\n <TouchableOpacity style={styles.controlButton} onPress={switchCamera}>\n <Text style={styles.controlButtonText}>🔄</Text>\n </TouchableOpacity>\n )}\n </View>\n </View>\n );\n};\n\nconst styles = StyleSheet.create({\n // ... Keep all your original styles exactly as they are\n container: { flex: 1, backgroundColor: 'black' },\n instructionsOverlay: { position: 'absolute', top: 60, left: 20, right: 20, backgroundColor: 'rgba(0, 0, 0, 0.7)', padding: 15, borderRadius: 10, zIndex: 1 },\n instructions: { color: 'white', fontSize: 16, textAlign: 'center', fontWeight: '500' },\n closeButton: { position: 'absolute', top: 50, right: 20, backgroundColor: 'rgba(0, 0, 0, 0.7)', width: 40, height: 40, borderRadius: 20, justifyContent: 'center', alignItems: 'center', zIndex: 2 },\n closeButtonText: { color: 'white', fontSize: 20, fontWeight: 'bold' },\n controlsContainer: { position: 'absolute', bottom: 40, left: 0, right: 0, flexDirection: 'row', justifyContent: 'space-around', alignItems: 'center', paddingHorizontal: 40, zIndex: 1 },\n controlButton: { backgroundColor: 'rgba(0, 0, 0, 0.7)', width: 50, height: 50, borderRadius: 25, justifyContent: 'center', alignItems: 'center' },\n controlButtonText: { fontSize: 24 },\n captureButton: { backgroundColor: 'rgba(255, 255, 255, 0.3)', width: 80, height: 80, borderRadius: 40, justifyContent: 'center', alignItems: 'center', borderWidth: 3, borderColor: 'white' },\n captureButtonInner: { backgroundColor: 'white', width: 60, height: 60, borderRadius: 30 },\n captureButtonDisabled: { backgroundColor: 'rgba(255, 255, 255, 0.5)' },\n recordingButton: { backgroundColor: 'rgba(255, 59, 48, 0.3)', borderColor: '#FF3B30' },\n recordingButtonInner: { backgroundColor: '#FF3B30' },\n permissionMessage: { color: 'white', fontSize: 16, textAlign: 'center', margin: 20 },\n errorMessage: { color: 'red', fontSize: 16, textAlign: 'center', margin: 20 },\n bboxOverlay: { position: 'absolute', top: 0, left: 0, right: 0, bottom: 0, pointerEvents: 'none' },\n bbox: { position: 'absolute', borderStyle: 'solid', backgroundColor: 'transparent' },\n analyzingContainer: { position: 'absolute', bottom: 100, alignSelf: 'center', backgroundColor: 'rgba(0, 0, 0, 0.7)', padding: 10, borderRadius: 10, zIndex: 1000 },\n analyzingText: { color: 'white', fontSize: 16, fontWeight: 'bold' },\n});\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IDCardCapture.d.ts","sourceRoot":"","sources":["../../../../src/components/KYCElements/IDCardCapture.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA+C,MAAM,OAAO,CAAC;AAIpE,OAAO,EAAE,iBAAiB,EAAoI,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"IDCardCapture.d.ts","sourceRoot":"","sources":["../../../../src/components/KYCElements/IDCardCapture.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA+C,MAAM,OAAO,CAAC;AAIpE,OAAO,EAAE,iBAAiB,EAAoI,MAAM,uBAAuB,CAAC;AAyB5L,UAAU,cAAc;IACtB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAmED,UAAU,kBAAkB;IAC1B,SAAS,EAAE,iBAAiB,CAAC;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IACvC,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,GAAG,MAAM,CAAC,KAAK,IAAI,CAAC;IACxE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AA+CD,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAu1CtD,CAAC"}
|