@trustchex/react-native-sdk 1.355.1 → 1.357.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.
- package/README.md +2 -9
- package/TrustchexSDK.podspec +5 -4
- package/android/build.gradle +6 -4
- package/android/src/main/AndroidManifest.xml +1 -1
- package/android/src/main/java/com/trustchex/reactnativesdk/TrustchexSDKPackage.kt +45 -25
- package/android/src/main/java/com/trustchex/reactnativesdk/camera/TrustchexCameraManager.kt +168 -0
- package/android/src/main/java/com/trustchex/reactnativesdk/camera/TrustchexCameraView.kt +871 -0
- package/android/src/main/java/com/trustchex/reactnativesdk/mlkit/MLKitModule.kt +245 -0
- package/android/src/main/java/com/trustchex/reactnativesdk/mrz/MRZValidationModule.kt +785 -0
- package/android/src/main/java/com/trustchex/reactnativesdk/mrz/MRZValidator.kt +419 -0
- package/android/src/main/java/com/trustchex/reactnativesdk/opencv/OpenCVModule.kt +818 -0
- package/ios/Camera/TrustchexCameraManager.m +37 -0
- package/ios/Camera/TrustchexCameraManager.swift +125 -0
- package/ios/Camera/TrustchexCameraView.swift +1176 -0
- package/ios/MLKit/MLKitModule.m +23 -0
- package/ios/MLKit/MLKitModule.swift +250 -0
- package/ios/MRZValidation.m +39 -0
- package/ios/MRZValidation.swift +802 -0
- package/ios/MRZValidator.swift +466 -0
- package/ios/OpenCV/OpenCVModule.h +4 -0
- package/ios/OpenCV/OpenCVModule.mm +810 -0
- package/lib/module/Screens/Dynamic/IdentityDocumentEIDScanningScreen.js +2 -3
- package/lib/module/Screens/Dynamic/IdentityDocumentScanningScreen.js +1 -2
- package/lib/module/Screens/Dynamic/LivenessDetectionScreen.js +418 -193
- package/lib/module/Screens/Static/OTPVerificationScreen.js +11 -11
- package/lib/module/Screens/Static/QrCodeScanningScreen.js +5 -1
- package/lib/module/Screens/Static/ResultScreen.js +25 -2
- package/lib/module/Screens/Static/VerificationSessionCheckScreen.js +25 -7
- package/lib/module/Shared/Components/DebugNavigationPanel.js +234 -24
- package/lib/module/Shared/Components/EIDScanner.js +99 -9
- package/lib/module/Shared/Components/FaceCamera.js +170 -179
- package/lib/module/Shared/Components/IdentityDocumentCamera.js +2151 -771
- package/lib/module/Shared/Components/QrCodeScannerCamera.js +109 -107
- package/lib/module/Shared/Components/TrustchexCamera.js +122 -0
- package/lib/module/Shared/EIDReader/tlv/tlv.helpers.js +91 -0
- package/lib/module/Shared/EIDReader/tlv/tlv.utils.js +2 -124
- package/lib/module/Shared/EIDReader/tlv/tlvInputStream.js +4 -4
- package/lib/module/Shared/EIDReader/tlv/tlvOutputState.js +4 -4
- package/lib/module/Shared/EIDReader/tlv/tlvOutputStream.js +4 -4
- package/lib/module/Shared/Libs/analytics.utils.js +2 -2
- package/lib/module/Shared/Libs/debug.utils.js +132 -0
- package/lib/module/Shared/Libs/deeplink.utils.js +6 -5
- package/lib/module/Shared/Libs/demo.utils.js +13 -3
- package/lib/module/Shared/Libs/mrz.utils.js +1 -175
- package/lib/module/Shared/Libs/native-device-info.utils.js +12 -6
- package/lib/module/Shared/Libs/tts.utils.js +40 -6
- package/lib/module/Shared/Services/AnalyticsService.js +9 -8
- package/lib/module/Shared/Types/mrzFields.js +1 -0
- package/lib/module/Translation/Resources/en.js +87 -88
- package/lib/module/Translation/Resources/tr.js +84 -85
- package/lib/module/Trustchex.js +9 -2
- package/lib/module/index.js +1 -0
- package/lib/module/version.js +1 -1
- package/lib/typescript/src/Screens/Dynamic/IdentityDocumentEIDScanningScreen.d.ts.map +1 -1
- package/lib/typescript/src/Screens/Dynamic/IdentityDocumentScanningScreen.d.ts.map +1 -1
- package/lib/typescript/src/Screens/Dynamic/LivenessDetectionScreen.d.ts.map +1 -1
- package/lib/typescript/src/Screens/Static/OTPVerificationScreen.d.ts.map +1 -1
- package/lib/typescript/src/Screens/Static/QrCodeScanningScreen.d.ts.map +1 -1
- package/lib/typescript/src/Screens/Static/ResultScreen.d.ts.map +1 -1
- package/lib/typescript/src/Screens/Static/VerificationSessionCheckScreen.d.ts.map +1 -1
- package/lib/typescript/src/Shared/Components/DebugNavigationPanel.d.ts.map +1 -1
- package/lib/typescript/src/Shared/Components/EIDScanner.d.ts +2 -2
- package/lib/typescript/src/Shared/Components/EIDScanner.d.ts.map +1 -1
- package/lib/typescript/src/Shared/Components/FaceCamera.d.ts +18 -4
- package/lib/typescript/src/Shared/Components/FaceCamera.d.ts.map +1 -1
- package/lib/typescript/src/Shared/Components/IdentityDocumentCamera.d.ts +3 -4
- package/lib/typescript/src/Shared/Components/IdentityDocumentCamera.d.ts.map +1 -1
- package/lib/typescript/src/Shared/Components/QrCodeScannerCamera.d.ts +2 -1
- package/lib/typescript/src/Shared/Components/QrCodeScannerCamera.d.ts.map +1 -1
- package/lib/typescript/src/Shared/Components/TrustchexCamera.d.ts +124 -0
- package/lib/typescript/src/Shared/Components/TrustchexCamera.d.ts.map +1 -0
- package/lib/typescript/src/Shared/EIDReader/tlv/tlv.helpers.d.ts +11 -0
- package/lib/typescript/src/Shared/EIDReader/tlv/tlv.helpers.d.ts.map +1 -0
- package/lib/typescript/src/Shared/EIDReader/tlv/tlv.utils.d.ts +2 -39
- package/lib/typescript/src/Shared/EIDReader/tlv/tlv.utils.d.ts.map +1 -1
- package/lib/typescript/src/Shared/Libs/analytics.utils.d.ts.map +1 -1
- package/lib/typescript/src/Shared/Libs/debug.utils.d.ts +42 -0
- package/lib/typescript/src/Shared/Libs/debug.utils.d.ts.map +1 -0
- package/lib/typescript/src/Shared/Libs/deeplink.utils.d.ts.map +1 -1
- package/lib/typescript/src/Shared/Libs/demo.utils.d.ts.map +1 -1
- package/lib/typescript/src/Shared/Libs/http-client.d.ts.map +1 -1
- package/lib/typescript/src/Shared/Libs/mrz.utils.d.ts +0 -4
- package/lib/typescript/src/Shared/Libs/mrz.utils.d.ts.map +1 -1
- package/lib/typescript/src/Shared/Libs/native-device-info.utils.d.ts.map +1 -1
- package/lib/typescript/src/Shared/Libs/tts.utils.d.ts +4 -3
- package/lib/typescript/src/Shared/Libs/tts.utils.d.ts.map +1 -1
- package/lib/typescript/src/Shared/Services/AnalyticsService.d.ts.map +1 -1
- package/lib/typescript/src/Shared/Types/identificationInfo.d.ts +2 -2
- package/lib/typescript/src/Shared/Types/identificationInfo.d.ts.map +1 -1
- package/lib/typescript/src/Shared/Types/mrzFields.d.ts +11 -0
- package/lib/typescript/src/Shared/Types/mrzFields.d.ts.map +1 -0
- package/lib/typescript/src/Translation/Resources/en.d.ts +4 -5
- package/lib/typescript/src/Translation/Resources/en.d.ts.map +1 -1
- package/lib/typescript/src/Translation/Resources/tr.d.ts +4 -5
- package/lib/typescript/src/Translation/Resources/tr.d.ts.map +1 -1
- package/lib/typescript/src/Trustchex.d.ts +2 -0
- package/lib/typescript/src/Trustchex.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +1 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/version.d.ts +1 -1
- package/package.json +4 -35
- package/src/Screens/Dynamic/ContractAcceptanceScreen.tsx +1 -1
- package/src/Screens/Dynamic/IdentityDocumentEIDScanningScreen.tsx +7 -5
- package/src/Screens/Dynamic/IdentityDocumentScanningScreen.tsx +2 -3
- package/src/Screens/Dynamic/LivenessDetectionScreen.tsx +498 -216
- package/src/Screens/Static/OTPVerificationScreen.tsx +37 -31
- package/src/Screens/Static/QrCodeScanningScreen.tsx +8 -1
- package/src/Screens/Static/ResultScreen.tsx +136 -88
- package/src/Screens/Static/VerificationSessionCheckScreen.tsx +46 -13
- package/src/Shared/Components/DebugNavigationPanel.tsx +290 -34
- package/src/Shared/Components/EIDScanner.tsx +94 -16
- package/src/Shared/Components/FaceCamera.tsx +236 -203
- package/src/Shared/Components/IdentityDocumentCamera.tsx +3073 -1030
- package/src/Shared/Components/QrCodeScannerCamera.tsx +133 -127
- package/src/Shared/Components/TrustchexCamera.tsx +289 -0
- package/src/Shared/Config/camera-enhancement.config.ts +2 -2
- package/src/Shared/EIDReader/tlv/tlv.helpers.ts +96 -0
- package/src/Shared/EIDReader/tlv/tlv.utils.ts +2 -125
- package/src/Shared/EIDReader/tlv/tlvInputStream.ts +4 -4
- package/src/Shared/EIDReader/tlv/tlvOutputState.ts +4 -4
- package/src/Shared/EIDReader/tlv/tlvOutputStream.ts +4 -4
- package/src/Shared/Libs/analytics.utils.ts +48 -20
- package/src/Shared/Libs/debug.utils.ts +149 -0
- package/src/Shared/Libs/deeplink.utils.ts +7 -5
- package/src/Shared/Libs/demo.utils.ts +4 -0
- package/src/Shared/Libs/http-client.ts +12 -8
- package/src/Shared/Libs/mrz.utils.ts +1 -163
- package/src/Shared/Libs/native-device-info.utils.ts +12 -6
- package/src/Shared/Libs/tts.utils.ts +48 -6
- package/src/Shared/Services/AnalyticsService.ts +69 -24
- package/src/Shared/Types/identificationInfo.ts +2 -2
- package/src/Shared/Types/mrzFields.ts +29 -0
- package/src/Translation/Resources/en.ts +90 -100
- package/src/Translation/Resources/tr.ts +89 -97
- package/src/Translation/index.ts +1 -1
- package/src/Trustchex.tsx +21 -4
- package/src/index.tsx +14 -0
- package/src/version.ts +1 -1
- package/android/src/main/java/com/trustchex/reactnativesdk/visioncameraplugins/barcodescanner/BarcodeScannerFrameProcessorPlugin.kt +0 -301
- package/android/src/main/java/com/trustchex/reactnativesdk/visioncameraplugins/cropper/BitmapUtils.kt +0 -205
- package/android/src/main/java/com/trustchex/reactnativesdk/visioncameraplugins/cropper/CropperPlugin.kt +0 -72
- package/android/src/main/java/com/trustchex/reactnativesdk/visioncameraplugins/cropper/FrameMetadata.kt +0 -4
- package/android/src/main/java/com/trustchex/reactnativesdk/visioncameraplugins/facedetector/FaceDetectorFrameProcessorPlugin.kt +0 -303
- package/android/src/main/java/com/trustchex/reactnativesdk/visioncameraplugins/textrecognition/TextRecognitionFrameProcessorPlugin.kt +0 -115
- package/ios/VisionCameraPlugins/BarcodeScanner/BarcodeScannerFrameProcessorPlugin-Bridging-Header.h +0 -9
- package/ios/VisionCameraPlugins/BarcodeScanner/BarcodeScannerFrameProcessorPlugin.mm +0 -22
- package/ios/VisionCameraPlugins/BarcodeScanner/BarcodeScannerFrameProcessorPlugin.swift +0 -188
- package/ios/VisionCameraPlugins/Cropper/Cropper-Bridging-Header.h +0 -13
- package/ios/VisionCameraPlugins/Cropper/Cropper.h +0 -20
- package/ios/VisionCameraPlugins/Cropper/Cropper.mm +0 -22
- package/ios/VisionCameraPlugins/Cropper/Cropper.swift +0 -145
- package/ios/VisionCameraPlugins/Cropper/CropperUtils.swift +0 -49
- package/ios/VisionCameraPlugins/FaceDetector/FaceDetectorFrameProcessorPlugin-Bridging-Header.h +0 -4
- package/ios/VisionCameraPlugins/FaceDetector/FaceDetectorFrameProcessorPlugin.mm +0 -22
- package/ios/VisionCameraPlugins/FaceDetector/FaceDetectorFrameProcessorPlugin.swift +0 -320
- package/ios/VisionCameraPlugins/TextRecognition/TextRecognitionFrameProcessorPlugin-Bridging-Header.h +0 -4
- package/ios/VisionCameraPlugins/TextRecognition/TextRecognitionFrameProcessorPlugin.mm +0 -27
- package/ios/VisionCameraPlugins/TextRecognition/TextRecognitionFrameProcessorPlugin.swift +0 -144
- package/lib/module/Shared/Libs/camera.utils.js +0 -308
- package/lib/module/Shared/Libs/frame-enhancement.utils.js +0 -133
- package/lib/module/Shared/Libs/opencv.utils.js +0 -21
- package/lib/module/Shared/Libs/worklet.utils.js +0 -68
- package/lib/module/Shared/VisionCameraPlugins/BarcodeScanner/hooks/useBarcodeScanner.js +0 -46
- package/lib/module/Shared/VisionCameraPlugins/BarcodeScanner/hooks/useCameraPermissions.js +0 -35
- package/lib/module/Shared/VisionCameraPlugins/BarcodeScanner/index.js +0 -19
- package/lib/module/Shared/VisionCameraPlugins/BarcodeScanner/scanCodes.js +0 -26
- package/lib/module/Shared/VisionCameraPlugins/BarcodeScanner/types.js +0 -3
- package/lib/module/Shared/VisionCameraPlugins/BarcodeScanner/utils/convert.js +0 -197
- package/lib/module/Shared/VisionCameraPlugins/BarcodeScanner/utils/geometry.js +0 -101
- package/lib/module/Shared/VisionCameraPlugins/BarcodeScanner/utils/highlights.js +0 -60
- package/lib/module/Shared/VisionCameraPlugins/Cropper/index.js +0 -47
- package/lib/module/Shared/VisionCameraPlugins/FaceDetector/Camera.js +0 -42
- package/lib/module/Shared/VisionCameraPlugins/FaceDetector/detectFaces.js +0 -35
- package/lib/module/Shared/VisionCameraPlugins/FaceDetector/index.js +0 -4
- package/lib/module/Shared/VisionCameraPlugins/FaceDetector/types.js +0 -3
- package/lib/module/Shared/VisionCameraPlugins/TextRecognition/Camera.js +0 -56
- package/lib/module/Shared/VisionCameraPlugins/TextRecognition/PhotoRecognizer.js +0 -20
- package/lib/module/Shared/VisionCameraPlugins/TextRecognition/RemoveLanguageModel.js +0 -9
- package/lib/module/Shared/VisionCameraPlugins/TextRecognition/index.js +0 -6
- package/lib/module/Shared/VisionCameraPlugins/TextRecognition/scanText.js +0 -20
- package/lib/module/Shared/VisionCameraPlugins/TextRecognition/translateText.js +0 -19
- package/lib/module/Shared/VisionCameraPlugins/TextRecognition/types.js +0 -3
- package/lib/typescript/src/Shared/Libs/camera.utils.d.ts +0 -87
- package/lib/typescript/src/Shared/Libs/camera.utils.d.ts.map +0 -1
- package/lib/typescript/src/Shared/Libs/frame-enhancement.utils.d.ts +0 -25
- package/lib/typescript/src/Shared/Libs/frame-enhancement.utils.d.ts.map +0 -1
- package/lib/typescript/src/Shared/Libs/opencv.utils.d.ts +0 -3
- package/lib/typescript/src/Shared/Libs/opencv.utils.d.ts.map +0 -1
- package/lib/typescript/src/Shared/Libs/worklet.utils.d.ts +0 -9
- package/lib/typescript/src/Shared/Libs/worklet.utils.d.ts.map +0 -1
- package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/hooks/useBarcodeScanner.d.ts +0 -13
- package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/hooks/useBarcodeScanner.d.ts.map +0 -1
- package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/hooks/useCameraPermissions.d.ts +0 -6
- package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/hooks/useCameraPermissions.d.ts.map +0 -1
- package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/index.d.ts +0 -12
- package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/index.d.ts.map +0 -1
- package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/scanCodes.d.ts +0 -3
- package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/scanCodes.d.ts.map +0 -1
- package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/types.d.ts +0 -52
- package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/types.d.ts.map +0 -1
- package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/utils/convert.d.ts +0 -62
- package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/utils/convert.d.ts.map +0 -1
- package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/utils/geometry.d.ts +0 -34
- package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/utils/geometry.d.ts.map +0 -1
- package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/utils/highlights.d.ts +0 -32
- package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/utils/highlights.d.ts.map +0 -1
- package/lib/typescript/src/Shared/VisionCameraPlugins/Cropper/index.d.ts +0 -23
- package/lib/typescript/src/Shared/VisionCameraPlugins/Cropper/index.d.ts.map +0 -1
- package/lib/typescript/src/Shared/VisionCameraPlugins/FaceDetector/Camera.d.ts +0 -9
- package/lib/typescript/src/Shared/VisionCameraPlugins/FaceDetector/Camera.d.ts.map +0 -1
- package/lib/typescript/src/Shared/VisionCameraPlugins/FaceDetector/detectFaces.d.ts +0 -3
- package/lib/typescript/src/Shared/VisionCameraPlugins/FaceDetector/detectFaces.d.ts.map +0 -1
- package/lib/typescript/src/Shared/VisionCameraPlugins/FaceDetector/index.d.ts +0 -3
- package/lib/typescript/src/Shared/VisionCameraPlugins/FaceDetector/index.d.ts.map +0 -1
- package/lib/typescript/src/Shared/VisionCameraPlugins/FaceDetector/types.d.ts +0 -79
- package/lib/typescript/src/Shared/VisionCameraPlugins/FaceDetector/types.d.ts.map +0 -1
- package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/Camera.d.ts +0 -6
- package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/Camera.d.ts.map +0 -1
- package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/PhotoRecognizer.d.ts +0 -3
- package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/PhotoRecognizer.d.ts.map +0 -1
- package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/RemoveLanguageModel.d.ts +0 -3
- package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/RemoveLanguageModel.d.ts.map +0 -1
- package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/index.d.ts +0 -5
- package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/index.d.ts.map +0 -1
- package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/scanText.d.ts +0 -3
- package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/scanText.d.ts.map +0 -1
- package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/translateText.d.ts +0 -3
- package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/translateText.d.ts.map +0 -1
- package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/types.d.ts +0 -67
- package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/types.d.ts.map +0 -1
- package/src/Shared/Libs/camera.utils.ts +0 -345
- package/src/Shared/Libs/frame-enhancement.utils.ts +0 -217
- package/src/Shared/Libs/opencv.utils.ts +0 -40
- package/src/Shared/Libs/worklet.utils.ts +0 -72
- package/src/Shared/VisionCameraPlugins/BarcodeScanner/hooks/useBarcodeScanner.ts +0 -79
- package/src/Shared/VisionCameraPlugins/BarcodeScanner/hooks/useCameraPermissions.ts +0 -46
- package/src/Shared/VisionCameraPlugins/BarcodeScanner/index.ts +0 -60
- package/src/Shared/VisionCameraPlugins/BarcodeScanner/scanCodes.ts +0 -32
- package/src/Shared/VisionCameraPlugins/BarcodeScanner/types.ts +0 -82
- package/src/Shared/VisionCameraPlugins/BarcodeScanner/utils/convert.ts +0 -195
- package/src/Shared/VisionCameraPlugins/BarcodeScanner/utils/geometry.ts +0 -135
- package/src/Shared/VisionCameraPlugins/BarcodeScanner/utils/highlights.ts +0 -84
- package/src/Shared/VisionCameraPlugins/Cropper/index.ts +0 -78
- package/src/Shared/VisionCameraPlugins/FaceDetector/Camera.tsx +0 -63
- package/src/Shared/VisionCameraPlugins/FaceDetector/detectFaces.ts +0 -44
- package/src/Shared/VisionCameraPlugins/FaceDetector/index.ts +0 -3
- package/src/Shared/VisionCameraPlugins/FaceDetector/types.ts +0 -99
- package/src/Shared/VisionCameraPlugins/TextRecognition/Camera.tsx +0 -76
- package/src/Shared/VisionCameraPlugins/TextRecognition/PhotoRecognizer.ts +0 -18
- package/src/Shared/VisionCameraPlugins/TextRecognition/RemoveLanguageModel.ts +0 -7
- package/src/Shared/VisionCameraPlugins/TextRecognition/index.ts +0 -7
- package/src/Shared/VisionCameraPlugins/TextRecognition/scanText.ts +0 -27
- package/src/Shared/VisionCameraPlugins/TextRecognition/translateText.ts +0 -21
- package/src/Shared/VisionCameraPlugins/TextRecognition/types.ts +0 -141
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import { useCallback, useState } from 'react';
|
|
4
|
-
import { createBarcodeScannerPlugin } from "../scanCodes.js";
|
|
5
|
-
let barcodeScannerPlugin = null;
|
|
6
|
-
export const useBarcodeScanner = (options = {}) => {
|
|
7
|
-
const [barcodes, setBarcodes] = useState([]);
|
|
8
|
-
const [isScanning, setIsScanning] = useState(false);
|
|
9
|
-
const scanBarcodes = useCallback(frame => {
|
|
10
|
-
'worklet';
|
|
11
|
-
|
|
12
|
-
if (!barcodeScannerPlugin) {
|
|
13
|
-
try {
|
|
14
|
-
barcodeScannerPlugin = createBarcodeScannerPlugin();
|
|
15
|
-
} catch (error) {
|
|
16
|
-
console.warn('useBarcodeScanner: Failed to initialize plugin:', error);
|
|
17
|
-
options.onError?.(error);
|
|
18
|
-
return [];
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
setIsScanning(true);
|
|
22
|
-
try {
|
|
23
|
-
const scanOptions = {
|
|
24
|
-
barcodeTypes: options.barcodeTypes,
|
|
25
|
-
regionOfInterest: options.regionOfInterest
|
|
26
|
-
};
|
|
27
|
-
const detectedBarcodes = barcodeScannerPlugin.scanCodes(frame, scanOptions);
|
|
28
|
-
setBarcodes(detectedBarcodes);
|
|
29
|
-
if (detectedBarcodes.length > 0) {
|
|
30
|
-
options.onBarcodeScanned?.(detectedBarcodes);
|
|
31
|
-
}
|
|
32
|
-
return detectedBarcodes;
|
|
33
|
-
} catch (error) {
|
|
34
|
-
console.warn('useBarcodeScanner: Scan failed:', error);
|
|
35
|
-
options.onError?.(error);
|
|
36
|
-
return [];
|
|
37
|
-
} finally {
|
|
38
|
-
setIsScanning(false);
|
|
39
|
-
}
|
|
40
|
-
}, [options]);
|
|
41
|
-
return {
|
|
42
|
-
scanBarcodes,
|
|
43
|
-
barcodes,
|
|
44
|
-
isScanning
|
|
45
|
-
};
|
|
46
|
-
};
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import { useEffect, useState } from 'react';
|
|
4
|
-
import { Alert, Linking } from 'react-native';
|
|
5
|
-
import { useCameraPermission } from 'react-native-vision-camera';
|
|
6
|
-
export const useCameraPermissions = () => {
|
|
7
|
-
const {
|
|
8
|
-
hasPermission: cameraPermission,
|
|
9
|
-
requestPermission: requestCameraPermission
|
|
10
|
-
} = useCameraPermission();
|
|
11
|
-
const [hasPermission, setHasPermission] = useState(cameraPermission);
|
|
12
|
-
useEffect(() => {
|
|
13
|
-
setHasPermission(cameraPermission);
|
|
14
|
-
}, [cameraPermission]);
|
|
15
|
-
const requestPermission = async () => {
|
|
16
|
-
const permission = await requestCameraPermission();
|
|
17
|
-
if (!permission) {
|
|
18
|
-
// Camera permission denied by user - their choice, not actionable
|
|
19
|
-
Alert.alert('Camera Permission Required', 'This app needs camera access to scan barcodes. Please enable camera permissions in your device settings.', [{
|
|
20
|
-
text: 'Cancel',
|
|
21
|
-
style: 'cancel'
|
|
22
|
-
}, {
|
|
23
|
-
text: 'Open Settings',
|
|
24
|
-
onPress: () => Linking.openSettings()
|
|
25
|
-
}]);
|
|
26
|
-
return false;
|
|
27
|
-
}
|
|
28
|
-
setHasPermission(permission);
|
|
29
|
-
return permission;
|
|
30
|
-
};
|
|
31
|
-
return {
|
|
32
|
-
hasPermission,
|
|
33
|
-
requestPermission
|
|
34
|
-
};
|
|
35
|
-
};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
// Main plugin function
|
|
4
|
-
export { createBarcodeScannerPlugin } from "./scanCodes.js";
|
|
5
|
-
|
|
6
|
-
// Create default plugin instance and export scanCodes function
|
|
7
|
-
import { createBarcodeScannerPlugin } from "./scanCodes.js";
|
|
8
|
-
const defaultPlugin = createBarcodeScannerPlugin();
|
|
9
|
-
export const scanCodes = defaultPlugin.scanCodes;
|
|
10
|
-
|
|
11
|
-
// Types
|
|
12
|
-
|
|
13
|
-
// Hooks
|
|
14
|
-
export { useBarcodeScanner } from "./hooks/useBarcodeScanner.js";
|
|
15
|
-
export { useCameraPermissions } from "./hooks/useCameraPermissions.js";
|
|
16
|
-
// Utilities
|
|
17
|
-
export { convertFrameToScreen, convertScreenToFrame, convertBarcodeToScreen, getRectCenter, getCornerPointsCenter, getBoundsFromCornerPoints } from "./utils/geometry.js";
|
|
18
|
-
export { boundingBoxToHighlight, barcodesToHighlights, getHighlightStyle, cornerPointsToPath, cornerPointsToPolygonPoints } from "./utils/highlights.js";
|
|
19
|
-
export { barcodeTypeToAndroidFormat, barcodeTypeToIOSSymbology, androidFormatToBarcodeType, iosSymbologyToBarcodeType, AndroidBarcodeFormat, IOSBarcodeSymbology } from "./utils/convert.js";
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import { VisionCameraProxy } from 'react-native-vision-camera';
|
|
4
|
-
const LINKING_ERROR = `Can't load plugin scanCodes. Try cleaning cache or reinstall plugin.`;
|
|
5
|
-
export function createBarcodeScannerPlugin() {
|
|
6
|
-
const plugin = VisionCameraProxy.initFrameProcessorPlugin('scanCodes', {});
|
|
7
|
-
if (!plugin) {
|
|
8
|
-
throw new Error(LINKING_ERROR);
|
|
9
|
-
}
|
|
10
|
-
return {
|
|
11
|
-
scanCodes: (frame, options) => {
|
|
12
|
-
'worklet';
|
|
13
|
-
|
|
14
|
-
try {
|
|
15
|
-
// @ts-ignore
|
|
16
|
-
const result = plugin.call(frame, options);
|
|
17
|
-
|
|
18
|
-
// iOS now handles coordinate conversion, so return results directly
|
|
19
|
-
return result || [];
|
|
20
|
-
} catch (error) {
|
|
21
|
-
console.warn('scanCodes: Plugin call failed:', error);
|
|
22
|
-
return [];
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
}
|
|
@@ -1,197 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* ML Kit Android barcode format constants
|
|
5
|
-
*/
|
|
6
|
-
export const AndroidBarcodeFormat = {
|
|
7
|
-
UNKNOWN: -1,
|
|
8
|
-
ALL_FORMATS: 0,
|
|
9
|
-
CODE_128: 1,
|
|
10
|
-
CODE_39: 2,
|
|
11
|
-
CODE_93: 4,
|
|
12
|
-
CODABAR: 8,
|
|
13
|
-
DATA_MATRIX: 16,
|
|
14
|
-
EAN_13: 32,
|
|
15
|
-
EAN_8: 64,
|
|
16
|
-
ITF: 128,
|
|
17
|
-
QR_CODE: 256,
|
|
18
|
-
UPC_A: 512,
|
|
19
|
-
UPC_E: 1024,
|
|
20
|
-
PDF417: 2048,
|
|
21
|
-
AZTEC: 4096
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* iOS Vision framework barcode symbology constants
|
|
26
|
-
*/
|
|
27
|
-
export const IOSBarcodeSymbology = {
|
|
28
|
-
aztec: 'VNBarcodeSymbologyAztec',
|
|
29
|
-
code128: 'VNBarcodeSymbologyCode128',
|
|
30
|
-
code39: 'VNBarcodeSymbologyCode39',
|
|
31
|
-
code39Checksum: 'VNBarcodeSymbologyCode39Checksum',
|
|
32
|
-
code39FullASCII: 'VNBarcodeSymbologyCode39FullASCII',
|
|
33
|
-
code39FullASCIIChecksum: 'VNBarcodeSymbologyCode39FullASCIIChecksum',
|
|
34
|
-
code93: 'VNBarcodeSymbologyCode93',
|
|
35
|
-
code93i: 'VNBarcodeSymbologyCode93i',
|
|
36
|
-
dataMatrix: 'VNBarcodeSymbologyDataMatrix',
|
|
37
|
-
ean13: 'VNBarcodeSymbologyEAN13',
|
|
38
|
-
ean8: 'VNBarcodeSymbologyEAN8',
|
|
39
|
-
face: 'VNBarcodeSymbologyFace',
|
|
40
|
-
i2of5: 'VNBarcodeSymbologyI2of5',
|
|
41
|
-
i2of5Checksum: 'VNBarcodeSymbologyI2of5Checksum',
|
|
42
|
-
itf14: 'VNBarcodeSymbologyITF14',
|
|
43
|
-
pdf417: 'VNBarcodeSymbologyPDF417',
|
|
44
|
-
qr: 'VNBarcodeSymbologyQR',
|
|
45
|
-
upce: 'VNBarcodeSymbologyUPCE',
|
|
46
|
-
codabar: 'VNBarcodeSymbologyCodabar'
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Convert our BarcodeType to Android ML Kit format
|
|
51
|
-
*/
|
|
52
|
-
export const barcodeTypeToAndroidFormat = type => {
|
|
53
|
-
switch (type) {
|
|
54
|
-
case 'aztec':
|
|
55
|
-
return AndroidBarcodeFormat.AZTEC;
|
|
56
|
-
case 'codabar':
|
|
57
|
-
return AndroidBarcodeFormat.CODABAR;
|
|
58
|
-
case 'code-128':
|
|
59
|
-
return AndroidBarcodeFormat.CODE_128;
|
|
60
|
-
case 'code-39':
|
|
61
|
-
return AndroidBarcodeFormat.CODE_39;
|
|
62
|
-
case 'code-93':
|
|
63
|
-
return AndroidBarcodeFormat.CODE_93;
|
|
64
|
-
case 'data-matrix':
|
|
65
|
-
return AndroidBarcodeFormat.DATA_MATRIX;
|
|
66
|
-
case 'ean-13':
|
|
67
|
-
return AndroidBarcodeFormat.EAN_13;
|
|
68
|
-
case 'ean-8':
|
|
69
|
-
return AndroidBarcodeFormat.EAN_8;
|
|
70
|
-
case 'itf':
|
|
71
|
-
return AndroidBarcodeFormat.ITF;
|
|
72
|
-
case 'pdf-417':
|
|
73
|
-
return AndroidBarcodeFormat.PDF417;
|
|
74
|
-
case 'qr':
|
|
75
|
-
return AndroidBarcodeFormat.QR_CODE;
|
|
76
|
-
case 'upc-a':
|
|
77
|
-
return AndroidBarcodeFormat.UPC_A;
|
|
78
|
-
case 'upc-e':
|
|
79
|
-
return AndroidBarcodeFormat.UPC_E;
|
|
80
|
-
default:
|
|
81
|
-
return AndroidBarcodeFormat.UNKNOWN;
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Convert our BarcodeType to iOS Vision framework symbology
|
|
87
|
-
*/
|
|
88
|
-
export const barcodeTypeToIOSSymbology = type => {
|
|
89
|
-
switch (type) {
|
|
90
|
-
case 'aztec':
|
|
91
|
-
return IOSBarcodeSymbology.aztec;
|
|
92
|
-
case 'codabar':
|
|
93
|
-
return IOSBarcodeSymbology.codabar;
|
|
94
|
-
case 'code-128':
|
|
95
|
-
return IOSBarcodeSymbology.code128;
|
|
96
|
-
case 'code-39':
|
|
97
|
-
return IOSBarcodeSymbology.code39;
|
|
98
|
-
case 'code-93':
|
|
99
|
-
return IOSBarcodeSymbology.code93;
|
|
100
|
-
case 'data-matrix':
|
|
101
|
-
return IOSBarcodeSymbology.dataMatrix;
|
|
102
|
-
case 'ean-13':
|
|
103
|
-
return IOSBarcodeSymbology.ean13;
|
|
104
|
-
case 'ean-8':
|
|
105
|
-
return IOSBarcodeSymbology.ean8;
|
|
106
|
-
case 'itf':
|
|
107
|
-
return IOSBarcodeSymbology.i2of5;
|
|
108
|
-
case 'pdf-417':
|
|
109
|
-
return IOSBarcodeSymbology.pdf417;
|
|
110
|
-
case 'qr':
|
|
111
|
-
return IOSBarcodeSymbology.qr;
|
|
112
|
-
case 'upc-a':
|
|
113
|
-
return IOSBarcodeSymbology.ean13;
|
|
114
|
-
// UPC-A is subset of EAN-13
|
|
115
|
-
case 'upc-e':
|
|
116
|
-
return IOSBarcodeSymbology.upce;
|
|
117
|
-
default:
|
|
118
|
-
return IOSBarcodeSymbology.qr;
|
|
119
|
-
// Default fallback
|
|
120
|
-
}
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* Convert Android ML Kit format to our BarcodeType
|
|
125
|
-
*/
|
|
126
|
-
export const androidFormatToBarcodeType = format => {
|
|
127
|
-
switch (format) {
|
|
128
|
-
case AndroidBarcodeFormat.AZTEC:
|
|
129
|
-
return 'aztec';
|
|
130
|
-
case AndroidBarcodeFormat.CODABAR:
|
|
131
|
-
return 'codabar';
|
|
132
|
-
case AndroidBarcodeFormat.CODE_128:
|
|
133
|
-
return 'code-128';
|
|
134
|
-
case AndroidBarcodeFormat.CODE_39:
|
|
135
|
-
return 'code-39';
|
|
136
|
-
case AndroidBarcodeFormat.CODE_93:
|
|
137
|
-
return 'code-93';
|
|
138
|
-
case AndroidBarcodeFormat.DATA_MATRIX:
|
|
139
|
-
return 'data-matrix';
|
|
140
|
-
case AndroidBarcodeFormat.EAN_13:
|
|
141
|
-
return 'ean-13';
|
|
142
|
-
case AndroidBarcodeFormat.EAN_8:
|
|
143
|
-
return 'ean-8';
|
|
144
|
-
case AndroidBarcodeFormat.ITF:
|
|
145
|
-
return 'itf';
|
|
146
|
-
case AndroidBarcodeFormat.PDF417:
|
|
147
|
-
return 'pdf-417';
|
|
148
|
-
case AndroidBarcodeFormat.QR_CODE:
|
|
149
|
-
return 'qr';
|
|
150
|
-
case AndroidBarcodeFormat.UPC_A:
|
|
151
|
-
return 'upc-a';
|
|
152
|
-
case AndroidBarcodeFormat.UPC_E:
|
|
153
|
-
return 'upc-e';
|
|
154
|
-
default:
|
|
155
|
-
return 'unknown';
|
|
156
|
-
}
|
|
157
|
-
};
|
|
158
|
-
|
|
159
|
-
/**
|
|
160
|
-
* Convert iOS Vision framework symbology to our BarcodeType
|
|
161
|
-
*/
|
|
162
|
-
export const iosSymbologyToBarcodeType = symbology => {
|
|
163
|
-
switch (symbology) {
|
|
164
|
-
case IOSBarcodeSymbology.aztec:
|
|
165
|
-
return 'aztec';
|
|
166
|
-
case IOSBarcodeSymbology.codabar:
|
|
167
|
-
return 'codabar';
|
|
168
|
-
case IOSBarcodeSymbology.code128:
|
|
169
|
-
return 'code-128';
|
|
170
|
-
case IOSBarcodeSymbology.code39:
|
|
171
|
-
case IOSBarcodeSymbology.code39Checksum:
|
|
172
|
-
case IOSBarcodeSymbology.code39FullASCII:
|
|
173
|
-
case IOSBarcodeSymbology.code39FullASCIIChecksum:
|
|
174
|
-
return 'code-39';
|
|
175
|
-
case IOSBarcodeSymbology.code93:
|
|
176
|
-
case IOSBarcodeSymbology.code93i:
|
|
177
|
-
return 'code-93';
|
|
178
|
-
case IOSBarcodeSymbology.dataMatrix:
|
|
179
|
-
return 'data-matrix';
|
|
180
|
-
case IOSBarcodeSymbology.ean13:
|
|
181
|
-
return 'ean-13';
|
|
182
|
-
case IOSBarcodeSymbology.ean8:
|
|
183
|
-
return 'ean-8';
|
|
184
|
-
case IOSBarcodeSymbology.i2of5:
|
|
185
|
-
case IOSBarcodeSymbology.i2of5Checksum:
|
|
186
|
-
case IOSBarcodeSymbology.itf14:
|
|
187
|
-
return 'itf';
|
|
188
|
-
case IOSBarcodeSymbology.pdf417:
|
|
189
|
-
return 'pdf-417';
|
|
190
|
-
case IOSBarcodeSymbology.qr:
|
|
191
|
-
return 'qr';
|
|
192
|
-
case IOSBarcodeSymbology.upce:
|
|
193
|
-
return 'upc-e';
|
|
194
|
-
default:
|
|
195
|
-
return 'unknown';
|
|
196
|
-
}
|
|
197
|
-
};
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Convert frame coordinates to screen coordinates
|
|
5
|
-
*/
|
|
6
|
-
export const convertFrameToScreen = (point, frameDimensions, screenDimensions) => {
|
|
7
|
-
const scaleX = screenDimensions.width / frameDimensions.width;
|
|
8
|
-
const scaleY = screenDimensions.height / frameDimensions.height;
|
|
9
|
-
return {
|
|
10
|
-
x: point.x * scaleX,
|
|
11
|
-
y: point.y * scaleY
|
|
12
|
-
};
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Convert screen coordinates to frame coordinates
|
|
17
|
-
*/
|
|
18
|
-
export const convertScreenToFrame = (point, frameDimensions, screenDimensions) => {
|
|
19
|
-
const scaleX = frameDimensions.width / screenDimensions.width;
|
|
20
|
-
const scaleY = frameDimensions.height / screenDimensions.height;
|
|
21
|
-
return {
|
|
22
|
-
x: point.x * scaleX,
|
|
23
|
-
y: point.y * scaleY
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Convert barcode corner points to screen coordinates
|
|
29
|
-
*/
|
|
30
|
-
export const convertBarcodeToScreen = (barcode, frameDimensions, screenDimensions) => {
|
|
31
|
-
const convertedCornerPoints = barcode.cornerPoints?.map(point => convertFrameToScreen(point, frameDimensions, screenDimensions));
|
|
32
|
-
const convertedBoundingBox = barcode.boundingBox ? {
|
|
33
|
-
origin: convertFrameToScreen(barcode.boundingBox.origin, frameDimensions, screenDimensions),
|
|
34
|
-
size: {
|
|
35
|
-
width: barcode.boundingBox.size.width * screenDimensions.width / frameDimensions.width,
|
|
36
|
-
height: barcode.boundingBox.size.height * screenDimensions.height / frameDimensions.height
|
|
37
|
-
}
|
|
38
|
-
} : barcode.boundingBox;
|
|
39
|
-
return {
|
|
40
|
-
...barcode,
|
|
41
|
-
cornerPoints: convertedCornerPoints,
|
|
42
|
-
boundingBox: convertedBoundingBox
|
|
43
|
-
};
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Calculate center point of a rectangle
|
|
48
|
-
*/
|
|
49
|
-
export const getRectCenter = rect => {
|
|
50
|
-
return {
|
|
51
|
-
x: rect.x + rect.width / 2,
|
|
52
|
-
y: rect.y + rect.height / 2
|
|
53
|
-
};
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Calculate center point from corner points
|
|
58
|
-
*/
|
|
59
|
-
export const getCornerPointsCenter = cornerPoints => {
|
|
60
|
-
if (cornerPoints.length === 0) {
|
|
61
|
-
return {
|
|
62
|
-
x: 0,
|
|
63
|
-
y: 0
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
const sum = cornerPoints.reduce((acc, point) => ({
|
|
67
|
-
x: acc.x + point.x,
|
|
68
|
-
y: acc.y + point.y
|
|
69
|
-
}), {
|
|
70
|
-
x: 0,
|
|
71
|
-
y: 0
|
|
72
|
-
});
|
|
73
|
-
return {
|
|
74
|
-
x: sum.x / cornerPoints.length,
|
|
75
|
-
y: sum.y / cornerPoints.length
|
|
76
|
-
};
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Calculate bounding rectangle from corner points
|
|
81
|
-
*/
|
|
82
|
-
export const getBoundsFromCornerPoints = cornerPoints => {
|
|
83
|
-
if (cornerPoints.length === 0) {
|
|
84
|
-
return {
|
|
85
|
-
x: 0,
|
|
86
|
-
y: 0,
|
|
87
|
-
width: 0,
|
|
88
|
-
height: 0
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
const minX = Math.min(...cornerPoints.map(p => p.x));
|
|
92
|
-
const maxX = Math.max(...cornerPoints.map(p => p.x));
|
|
93
|
-
const minY = Math.min(...cornerPoints.map(p => p.y));
|
|
94
|
-
const maxY = Math.max(...cornerPoints.map(p => p.y));
|
|
95
|
-
return {
|
|
96
|
-
x: minX,
|
|
97
|
-
y: minY,
|
|
98
|
-
width: maxX - minX,
|
|
99
|
-
height: maxY - minY
|
|
100
|
-
};
|
|
101
|
-
};
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import { convertBarcodeToScreen } from "./geometry.js";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Convert a BoundingBox to a Highlight with a key
|
|
7
|
-
*/
|
|
8
|
-
export const boundingBoxToHighlight = (boundingBox, key) => {
|
|
9
|
-
return {
|
|
10
|
-
...boundingBox,
|
|
11
|
-
key
|
|
12
|
-
};
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Convert barcodes to highlights for rendering
|
|
17
|
-
*/
|
|
18
|
-
export const barcodesToHighlights = (barcodes, frameDimensions, screenDimensions) => {
|
|
19
|
-
return barcodes.map((barcode, index) => {
|
|
20
|
-
const convertedBarcode = convertBarcodeToScreen(barcode, frameDimensions, screenDimensions);
|
|
21
|
-
return boundingBoxToHighlight(convertedBarcode.boundingBox, barcode.value || `barcode-${index}`);
|
|
22
|
-
});
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Get highlight styles for rendering overlay
|
|
27
|
-
*/
|
|
28
|
-
export const getHighlightStyle = (highlight, color = '#00FF00', borderWidth = 2) => {
|
|
29
|
-
return {
|
|
30
|
-
position: 'absolute',
|
|
31
|
-
left: highlight.origin.x,
|
|
32
|
-
top: highlight.origin.y,
|
|
33
|
-
width: highlight.size.width,
|
|
34
|
-
height: highlight.size.height,
|
|
35
|
-
borderColor: color,
|
|
36
|
-
borderWidth,
|
|
37
|
-
backgroundColor: 'transparent'
|
|
38
|
-
};
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Create polygon path from corner points for more precise highlighting
|
|
43
|
-
*/
|
|
44
|
-
export const cornerPointsToPath = cornerPoints => {
|
|
45
|
-
if (cornerPoints.length === 0) {
|
|
46
|
-
return '';
|
|
47
|
-
}
|
|
48
|
-
const pathCommands = cornerPoints.map((point, index) => {
|
|
49
|
-
const command = index === 0 ? 'M' : 'L';
|
|
50
|
-
return `${command} ${point.x} ${point.y}`;
|
|
51
|
-
});
|
|
52
|
-
return `${pathCommands.join(' ')} Z`;
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Get SVG polygon points string from corner points
|
|
57
|
-
*/
|
|
58
|
-
export const cornerPointsToPolygonPoints = cornerPoints => {
|
|
59
|
-
return cornerPoints.map(point => `${point.x},${point.y}`).join(' ');
|
|
60
|
-
};
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import { VisionCameraProxy } from 'react-native-vision-camera';
|
|
4
|
-
const LINKING_ERROR = `Can't load plugin crop. Try cleaning cache or reinstall plugin.`;
|
|
5
|
-
export function createCropperPlugin() {
|
|
6
|
-
const plugin = VisionCameraProxy.initFrameProcessorPlugin('crop', {});
|
|
7
|
-
if (!plugin) {
|
|
8
|
-
throw new Error(LINKING_ERROR);
|
|
9
|
-
}
|
|
10
|
-
return {
|
|
11
|
-
crop: (frame, config) => {
|
|
12
|
-
'worklet';
|
|
13
|
-
|
|
14
|
-
if (config) {
|
|
15
|
-
const record = {};
|
|
16
|
-
if (config.includeImageBase64 !== undefined && config.includeImageBase64 !== null) {
|
|
17
|
-
record.includeImageBase64 = config.includeImageBase64;
|
|
18
|
-
}
|
|
19
|
-
if (config.saveAsFile !== undefined && config.saveAsFile !== null) {
|
|
20
|
-
record.saveAsFile = config.saveAsFile;
|
|
21
|
-
}
|
|
22
|
-
if (config.saveBitmap !== undefined && config.saveBitmap !== null) {
|
|
23
|
-
record.saveBitmap = config.saveBitmap;
|
|
24
|
-
}
|
|
25
|
-
if (config.cropRegion) {
|
|
26
|
-
const cropRegionRecord = {};
|
|
27
|
-
cropRegionRecord.left = config.cropRegion.left;
|
|
28
|
-
cropRegionRecord.top = config.cropRegion.top;
|
|
29
|
-
cropRegionRecord.width = config.cropRegion.width;
|
|
30
|
-
cropRegionRecord.height = config.cropRegion.height;
|
|
31
|
-
record.cropRegion = cropRegionRecord;
|
|
32
|
-
}
|
|
33
|
-
return plugin.call(frame, record);
|
|
34
|
-
} else {
|
|
35
|
-
return plugin.call(frame);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// Create default plugin instance and export crop function
|
|
42
|
-
const defaultPlugin = createCropperPlugin();
|
|
43
|
-
export const crop = defaultPlugin.crop;
|
|
44
|
-
|
|
45
|
-
// Types
|
|
46
|
-
|
|
47
|
-
// The value is in percentage
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import React, { forwardRef, useMemo } from 'react';
|
|
4
|
-
import { Camera as VisionCamera, useFrameProcessor } from 'react-native-vision-camera';
|
|
5
|
-
import { createFaceDetectorPlugin } from "./detectFaces.js";
|
|
6
|
-
import { useRunOnJS } from 'react-native-worklets-core';
|
|
7
|
-
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
8
|
-
export const Camera = /*#__PURE__*/forwardRef(function Camera(props, ref) {
|
|
9
|
-
const {
|
|
10
|
-
device,
|
|
11
|
-
callback,
|
|
12
|
-
options,
|
|
13
|
-
...p
|
|
14
|
-
} = props;
|
|
15
|
-
const {
|
|
16
|
-
detectFaces
|
|
17
|
-
} = useFaceDetector(options);
|
|
18
|
-
const runOnJS = useRunOnJS(data => {
|
|
19
|
-
callback(data);
|
|
20
|
-
}, [options]);
|
|
21
|
-
const frameProcessor = useFrameProcessor(frame => {
|
|
22
|
-
'worklet';
|
|
23
|
-
|
|
24
|
-
const faces = detectFaces(frame);
|
|
25
|
-
runOnJS(faces);
|
|
26
|
-
}, []);
|
|
27
|
-
return /*#__PURE__*/_jsx(_Fragment, {
|
|
28
|
-
children: !!device && /*#__PURE__*/_jsx(VisionCamera, {
|
|
29
|
-
pixelFormat: "yuv",
|
|
30
|
-
ref: ref,
|
|
31
|
-
frameProcessor: frameProcessor,
|
|
32
|
-
device: device,
|
|
33
|
-
...p
|
|
34
|
-
})
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
export function useFaceDetector(options) {
|
|
38
|
-
return useMemo(() => {
|
|
39
|
-
const plugin = createFaceDetectorPlugin(options);
|
|
40
|
-
return plugin;
|
|
41
|
-
}, [options]);
|
|
42
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import { VisionCameraProxy } from 'react-native-vision-camera';
|
|
4
|
-
const LINKING_ERROR = `Can't load plugin detectFaces. Try cleaning cache or reinstall plugin.`;
|
|
5
|
-
export function createFaceDetectorPlugin(options) {
|
|
6
|
-
const plugin = VisionCameraProxy.initFrameProcessorPlugin('detectFaces', {
|
|
7
|
-
performanceMode: 'accurate',
|
|
8
|
-
landmarkMode: 'none',
|
|
9
|
-
contourMode: 'none',
|
|
10
|
-
classificationMode: 'none',
|
|
11
|
-
minFaceSize: 0.1,
|
|
12
|
-
trackingEnabled: false,
|
|
13
|
-
autoScale: true,
|
|
14
|
-
windowWidth: 1.0,
|
|
15
|
-
windowHeight: 1.0,
|
|
16
|
-
...options
|
|
17
|
-
});
|
|
18
|
-
if (!plugin) {
|
|
19
|
-
throw new Error(LINKING_ERROR);
|
|
20
|
-
}
|
|
21
|
-
return {
|
|
22
|
-
detectFaces: frame => {
|
|
23
|
-
'worklet';
|
|
24
|
-
|
|
25
|
-
try {
|
|
26
|
-
// @ts-ignore
|
|
27
|
-
const result = plugin.call(frame);
|
|
28
|
-
return result || [];
|
|
29
|
-
} catch (error) {
|
|
30
|
-
console.warn('detectFaces: Plugin call failed:', error);
|
|
31
|
-
return [];
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import React, { forwardRef, useMemo } from 'react';
|
|
4
|
-
import { Camera as VisionCamera, useFrameProcessor } from 'react-native-vision-camera';
|
|
5
|
-
import { createTextRecognitionPlugin } from "./scanText.js";
|
|
6
|
-
import { useRunOnJS } from 'react-native-worklets-core';
|
|
7
|
-
import { createTranslatorPlugin } from "./translateText.js";
|
|
8
|
-
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
9
|
-
export const Camera = /*#__PURE__*/forwardRef(function Camera(props, ref) {
|
|
10
|
-
const {
|
|
11
|
-
device,
|
|
12
|
-
callback,
|
|
13
|
-
options,
|
|
14
|
-
mode,
|
|
15
|
-
...p
|
|
16
|
-
} = props;
|
|
17
|
-
let plugin;
|
|
18
|
-
if (mode === 'translate') {
|
|
19
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
20
|
-
const {
|
|
21
|
-
translate
|
|
22
|
-
} = useTranslate(options);
|
|
23
|
-
plugin = translate;
|
|
24
|
-
} else {
|
|
25
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
26
|
-
const {
|
|
27
|
-
scanText
|
|
28
|
-
} = useTextRecognition(options);
|
|
29
|
-
plugin = scanText;
|
|
30
|
-
}
|
|
31
|
-
const runOnJS = useRunOnJS(data => {
|
|
32
|
-
callback(data);
|
|
33
|
-
}, [options]);
|
|
34
|
-
const frameProcessor = useFrameProcessor(frame => {
|
|
35
|
-
'worklet';
|
|
36
|
-
|
|
37
|
-
const data = plugin(frame);
|
|
38
|
-
// @ts-ignore
|
|
39
|
-
runOnJS(data);
|
|
40
|
-
}, []);
|
|
41
|
-
return /*#__PURE__*/_jsx(_Fragment, {
|
|
42
|
-
children: !!device && /*#__PURE__*/_jsx(VisionCamera, {
|
|
43
|
-
pixelFormat: "yuv",
|
|
44
|
-
ref: ref,
|
|
45
|
-
frameProcessor: frameProcessor,
|
|
46
|
-
device: device,
|
|
47
|
-
...p
|
|
48
|
-
})
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
export function useTextRecognition(options) {
|
|
52
|
-
return useMemo(() => createTextRecognitionPlugin(options), [options]);
|
|
53
|
-
}
|
|
54
|
-
export function useTranslate(options) {
|
|
55
|
-
return useMemo(() => createTranslatorPlugin(options), [options]);
|
|
56
|
-
}
|