@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.
Files changed (254) hide show
  1. package/README.md +2 -9
  2. package/TrustchexSDK.podspec +5 -4
  3. package/android/build.gradle +6 -4
  4. package/android/src/main/AndroidManifest.xml +1 -1
  5. package/android/src/main/java/com/trustchex/reactnativesdk/TrustchexSDKPackage.kt +45 -25
  6. package/android/src/main/java/com/trustchex/reactnativesdk/camera/TrustchexCameraManager.kt +168 -0
  7. package/android/src/main/java/com/trustchex/reactnativesdk/camera/TrustchexCameraView.kt +871 -0
  8. package/android/src/main/java/com/trustchex/reactnativesdk/mlkit/MLKitModule.kt +245 -0
  9. package/android/src/main/java/com/trustchex/reactnativesdk/mrz/MRZValidationModule.kt +785 -0
  10. package/android/src/main/java/com/trustchex/reactnativesdk/mrz/MRZValidator.kt +419 -0
  11. package/android/src/main/java/com/trustchex/reactnativesdk/opencv/OpenCVModule.kt +818 -0
  12. package/ios/Camera/TrustchexCameraManager.m +37 -0
  13. package/ios/Camera/TrustchexCameraManager.swift +125 -0
  14. package/ios/Camera/TrustchexCameraView.swift +1176 -0
  15. package/ios/MLKit/MLKitModule.m +23 -0
  16. package/ios/MLKit/MLKitModule.swift +250 -0
  17. package/ios/MRZValidation.m +39 -0
  18. package/ios/MRZValidation.swift +802 -0
  19. package/ios/MRZValidator.swift +466 -0
  20. package/ios/OpenCV/OpenCVModule.h +4 -0
  21. package/ios/OpenCV/OpenCVModule.mm +810 -0
  22. package/lib/module/Screens/Dynamic/IdentityDocumentEIDScanningScreen.js +2 -3
  23. package/lib/module/Screens/Dynamic/IdentityDocumentScanningScreen.js +1 -2
  24. package/lib/module/Screens/Dynamic/LivenessDetectionScreen.js +418 -193
  25. package/lib/module/Screens/Static/OTPVerificationScreen.js +11 -11
  26. package/lib/module/Screens/Static/QrCodeScanningScreen.js +5 -1
  27. package/lib/module/Screens/Static/ResultScreen.js +25 -2
  28. package/lib/module/Screens/Static/VerificationSessionCheckScreen.js +25 -7
  29. package/lib/module/Shared/Components/DebugNavigationPanel.js +234 -24
  30. package/lib/module/Shared/Components/EIDScanner.js +99 -9
  31. package/lib/module/Shared/Components/FaceCamera.js +170 -179
  32. package/lib/module/Shared/Components/IdentityDocumentCamera.js +2151 -771
  33. package/lib/module/Shared/Components/QrCodeScannerCamera.js +109 -107
  34. package/lib/module/Shared/Components/TrustchexCamera.js +122 -0
  35. package/lib/module/Shared/EIDReader/tlv/tlv.helpers.js +91 -0
  36. package/lib/module/Shared/EIDReader/tlv/tlv.utils.js +2 -124
  37. package/lib/module/Shared/EIDReader/tlv/tlvInputStream.js +4 -4
  38. package/lib/module/Shared/EIDReader/tlv/tlvOutputState.js +4 -4
  39. package/lib/module/Shared/EIDReader/tlv/tlvOutputStream.js +4 -4
  40. package/lib/module/Shared/Libs/analytics.utils.js +2 -2
  41. package/lib/module/Shared/Libs/debug.utils.js +132 -0
  42. package/lib/module/Shared/Libs/deeplink.utils.js +6 -5
  43. package/lib/module/Shared/Libs/demo.utils.js +13 -3
  44. package/lib/module/Shared/Libs/mrz.utils.js +1 -175
  45. package/lib/module/Shared/Libs/native-device-info.utils.js +12 -6
  46. package/lib/module/Shared/Libs/tts.utils.js +40 -6
  47. package/lib/module/Shared/Services/AnalyticsService.js +9 -8
  48. package/lib/module/Shared/Types/mrzFields.js +1 -0
  49. package/lib/module/Translation/Resources/en.js +87 -88
  50. package/lib/module/Translation/Resources/tr.js +84 -85
  51. package/lib/module/Trustchex.js +9 -2
  52. package/lib/module/index.js +1 -0
  53. package/lib/module/version.js +1 -1
  54. package/lib/typescript/src/Screens/Dynamic/IdentityDocumentEIDScanningScreen.d.ts.map +1 -1
  55. package/lib/typescript/src/Screens/Dynamic/IdentityDocumentScanningScreen.d.ts.map +1 -1
  56. package/lib/typescript/src/Screens/Dynamic/LivenessDetectionScreen.d.ts.map +1 -1
  57. package/lib/typescript/src/Screens/Static/OTPVerificationScreen.d.ts.map +1 -1
  58. package/lib/typescript/src/Screens/Static/QrCodeScanningScreen.d.ts.map +1 -1
  59. package/lib/typescript/src/Screens/Static/ResultScreen.d.ts.map +1 -1
  60. package/lib/typescript/src/Screens/Static/VerificationSessionCheckScreen.d.ts.map +1 -1
  61. package/lib/typescript/src/Shared/Components/DebugNavigationPanel.d.ts.map +1 -1
  62. package/lib/typescript/src/Shared/Components/EIDScanner.d.ts +2 -2
  63. package/lib/typescript/src/Shared/Components/EIDScanner.d.ts.map +1 -1
  64. package/lib/typescript/src/Shared/Components/FaceCamera.d.ts +18 -4
  65. package/lib/typescript/src/Shared/Components/FaceCamera.d.ts.map +1 -1
  66. package/lib/typescript/src/Shared/Components/IdentityDocumentCamera.d.ts +3 -4
  67. package/lib/typescript/src/Shared/Components/IdentityDocumentCamera.d.ts.map +1 -1
  68. package/lib/typescript/src/Shared/Components/QrCodeScannerCamera.d.ts +2 -1
  69. package/lib/typescript/src/Shared/Components/QrCodeScannerCamera.d.ts.map +1 -1
  70. package/lib/typescript/src/Shared/Components/TrustchexCamera.d.ts +124 -0
  71. package/lib/typescript/src/Shared/Components/TrustchexCamera.d.ts.map +1 -0
  72. package/lib/typescript/src/Shared/EIDReader/tlv/tlv.helpers.d.ts +11 -0
  73. package/lib/typescript/src/Shared/EIDReader/tlv/tlv.helpers.d.ts.map +1 -0
  74. package/lib/typescript/src/Shared/EIDReader/tlv/tlv.utils.d.ts +2 -39
  75. package/lib/typescript/src/Shared/EIDReader/tlv/tlv.utils.d.ts.map +1 -1
  76. package/lib/typescript/src/Shared/Libs/analytics.utils.d.ts.map +1 -1
  77. package/lib/typescript/src/Shared/Libs/debug.utils.d.ts +42 -0
  78. package/lib/typescript/src/Shared/Libs/debug.utils.d.ts.map +1 -0
  79. package/lib/typescript/src/Shared/Libs/deeplink.utils.d.ts.map +1 -1
  80. package/lib/typescript/src/Shared/Libs/demo.utils.d.ts.map +1 -1
  81. package/lib/typescript/src/Shared/Libs/http-client.d.ts.map +1 -1
  82. package/lib/typescript/src/Shared/Libs/mrz.utils.d.ts +0 -4
  83. package/lib/typescript/src/Shared/Libs/mrz.utils.d.ts.map +1 -1
  84. package/lib/typescript/src/Shared/Libs/native-device-info.utils.d.ts.map +1 -1
  85. package/lib/typescript/src/Shared/Libs/tts.utils.d.ts +4 -3
  86. package/lib/typescript/src/Shared/Libs/tts.utils.d.ts.map +1 -1
  87. package/lib/typescript/src/Shared/Services/AnalyticsService.d.ts.map +1 -1
  88. package/lib/typescript/src/Shared/Types/identificationInfo.d.ts +2 -2
  89. package/lib/typescript/src/Shared/Types/identificationInfo.d.ts.map +1 -1
  90. package/lib/typescript/src/Shared/Types/mrzFields.d.ts +11 -0
  91. package/lib/typescript/src/Shared/Types/mrzFields.d.ts.map +1 -0
  92. package/lib/typescript/src/Translation/Resources/en.d.ts +4 -5
  93. package/lib/typescript/src/Translation/Resources/en.d.ts.map +1 -1
  94. package/lib/typescript/src/Translation/Resources/tr.d.ts +4 -5
  95. package/lib/typescript/src/Translation/Resources/tr.d.ts.map +1 -1
  96. package/lib/typescript/src/Trustchex.d.ts +2 -0
  97. package/lib/typescript/src/Trustchex.d.ts.map +1 -1
  98. package/lib/typescript/src/index.d.ts +1 -0
  99. package/lib/typescript/src/index.d.ts.map +1 -1
  100. package/lib/typescript/src/version.d.ts +1 -1
  101. package/package.json +4 -35
  102. package/src/Screens/Dynamic/ContractAcceptanceScreen.tsx +1 -1
  103. package/src/Screens/Dynamic/IdentityDocumentEIDScanningScreen.tsx +7 -5
  104. package/src/Screens/Dynamic/IdentityDocumentScanningScreen.tsx +2 -3
  105. package/src/Screens/Dynamic/LivenessDetectionScreen.tsx +498 -216
  106. package/src/Screens/Static/OTPVerificationScreen.tsx +37 -31
  107. package/src/Screens/Static/QrCodeScanningScreen.tsx +8 -1
  108. package/src/Screens/Static/ResultScreen.tsx +136 -88
  109. package/src/Screens/Static/VerificationSessionCheckScreen.tsx +46 -13
  110. package/src/Shared/Components/DebugNavigationPanel.tsx +290 -34
  111. package/src/Shared/Components/EIDScanner.tsx +94 -16
  112. package/src/Shared/Components/FaceCamera.tsx +236 -203
  113. package/src/Shared/Components/IdentityDocumentCamera.tsx +3073 -1030
  114. package/src/Shared/Components/QrCodeScannerCamera.tsx +133 -127
  115. package/src/Shared/Components/TrustchexCamera.tsx +289 -0
  116. package/src/Shared/Config/camera-enhancement.config.ts +2 -2
  117. package/src/Shared/EIDReader/tlv/tlv.helpers.ts +96 -0
  118. package/src/Shared/EIDReader/tlv/tlv.utils.ts +2 -125
  119. package/src/Shared/EIDReader/tlv/tlvInputStream.ts +4 -4
  120. package/src/Shared/EIDReader/tlv/tlvOutputState.ts +4 -4
  121. package/src/Shared/EIDReader/tlv/tlvOutputStream.ts +4 -4
  122. package/src/Shared/Libs/analytics.utils.ts +48 -20
  123. package/src/Shared/Libs/debug.utils.ts +149 -0
  124. package/src/Shared/Libs/deeplink.utils.ts +7 -5
  125. package/src/Shared/Libs/demo.utils.ts +4 -0
  126. package/src/Shared/Libs/http-client.ts +12 -8
  127. package/src/Shared/Libs/mrz.utils.ts +1 -163
  128. package/src/Shared/Libs/native-device-info.utils.ts +12 -6
  129. package/src/Shared/Libs/tts.utils.ts +48 -6
  130. package/src/Shared/Services/AnalyticsService.ts +69 -24
  131. package/src/Shared/Types/identificationInfo.ts +2 -2
  132. package/src/Shared/Types/mrzFields.ts +29 -0
  133. package/src/Translation/Resources/en.ts +90 -100
  134. package/src/Translation/Resources/tr.ts +89 -97
  135. package/src/Translation/index.ts +1 -1
  136. package/src/Trustchex.tsx +21 -4
  137. package/src/index.tsx +14 -0
  138. package/src/version.ts +1 -1
  139. package/android/src/main/java/com/trustchex/reactnativesdk/visioncameraplugins/barcodescanner/BarcodeScannerFrameProcessorPlugin.kt +0 -301
  140. package/android/src/main/java/com/trustchex/reactnativesdk/visioncameraplugins/cropper/BitmapUtils.kt +0 -205
  141. package/android/src/main/java/com/trustchex/reactnativesdk/visioncameraplugins/cropper/CropperPlugin.kt +0 -72
  142. package/android/src/main/java/com/trustchex/reactnativesdk/visioncameraplugins/cropper/FrameMetadata.kt +0 -4
  143. package/android/src/main/java/com/trustchex/reactnativesdk/visioncameraplugins/facedetector/FaceDetectorFrameProcessorPlugin.kt +0 -303
  144. package/android/src/main/java/com/trustchex/reactnativesdk/visioncameraplugins/textrecognition/TextRecognitionFrameProcessorPlugin.kt +0 -115
  145. package/ios/VisionCameraPlugins/BarcodeScanner/BarcodeScannerFrameProcessorPlugin-Bridging-Header.h +0 -9
  146. package/ios/VisionCameraPlugins/BarcodeScanner/BarcodeScannerFrameProcessorPlugin.mm +0 -22
  147. package/ios/VisionCameraPlugins/BarcodeScanner/BarcodeScannerFrameProcessorPlugin.swift +0 -188
  148. package/ios/VisionCameraPlugins/Cropper/Cropper-Bridging-Header.h +0 -13
  149. package/ios/VisionCameraPlugins/Cropper/Cropper.h +0 -20
  150. package/ios/VisionCameraPlugins/Cropper/Cropper.mm +0 -22
  151. package/ios/VisionCameraPlugins/Cropper/Cropper.swift +0 -145
  152. package/ios/VisionCameraPlugins/Cropper/CropperUtils.swift +0 -49
  153. package/ios/VisionCameraPlugins/FaceDetector/FaceDetectorFrameProcessorPlugin-Bridging-Header.h +0 -4
  154. package/ios/VisionCameraPlugins/FaceDetector/FaceDetectorFrameProcessorPlugin.mm +0 -22
  155. package/ios/VisionCameraPlugins/FaceDetector/FaceDetectorFrameProcessorPlugin.swift +0 -320
  156. package/ios/VisionCameraPlugins/TextRecognition/TextRecognitionFrameProcessorPlugin-Bridging-Header.h +0 -4
  157. package/ios/VisionCameraPlugins/TextRecognition/TextRecognitionFrameProcessorPlugin.mm +0 -27
  158. package/ios/VisionCameraPlugins/TextRecognition/TextRecognitionFrameProcessorPlugin.swift +0 -144
  159. package/lib/module/Shared/Libs/camera.utils.js +0 -308
  160. package/lib/module/Shared/Libs/frame-enhancement.utils.js +0 -133
  161. package/lib/module/Shared/Libs/opencv.utils.js +0 -21
  162. package/lib/module/Shared/Libs/worklet.utils.js +0 -68
  163. package/lib/module/Shared/VisionCameraPlugins/BarcodeScanner/hooks/useBarcodeScanner.js +0 -46
  164. package/lib/module/Shared/VisionCameraPlugins/BarcodeScanner/hooks/useCameraPermissions.js +0 -35
  165. package/lib/module/Shared/VisionCameraPlugins/BarcodeScanner/index.js +0 -19
  166. package/lib/module/Shared/VisionCameraPlugins/BarcodeScanner/scanCodes.js +0 -26
  167. package/lib/module/Shared/VisionCameraPlugins/BarcodeScanner/types.js +0 -3
  168. package/lib/module/Shared/VisionCameraPlugins/BarcodeScanner/utils/convert.js +0 -197
  169. package/lib/module/Shared/VisionCameraPlugins/BarcodeScanner/utils/geometry.js +0 -101
  170. package/lib/module/Shared/VisionCameraPlugins/BarcodeScanner/utils/highlights.js +0 -60
  171. package/lib/module/Shared/VisionCameraPlugins/Cropper/index.js +0 -47
  172. package/lib/module/Shared/VisionCameraPlugins/FaceDetector/Camera.js +0 -42
  173. package/lib/module/Shared/VisionCameraPlugins/FaceDetector/detectFaces.js +0 -35
  174. package/lib/module/Shared/VisionCameraPlugins/FaceDetector/index.js +0 -4
  175. package/lib/module/Shared/VisionCameraPlugins/FaceDetector/types.js +0 -3
  176. package/lib/module/Shared/VisionCameraPlugins/TextRecognition/Camera.js +0 -56
  177. package/lib/module/Shared/VisionCameraPlugins/TextRecognition/PhotoRecognizer.js +0 -20
  178. package/lib/module/Shared/VisionCameraPlugins/TextRecognition/RemoveLanguageModel.js +0 -9
  179. package/lib/module/Shared/VisionCameraPlugins/TextRecognition/index.js +0 -6
  180. package/lib/module/Shared/VisionCameraPlugins/TextRecognition/scanText.js +0 -20
  181. package/lib/module/Shared/VisionCameraPlugins/TextRecognition/translateText.js +0 -19
  182. package/lib/module/Shared/VisionCameraPlugins/TextRecognition/types.js +0 -3
  183. package/lib/typescript/src/Shared/Libs/camera.utils.d.ts +0 -87
  184. package/lib/typescript/src/Shared/Libs/camera.utils.d.ts.map +0 -1
  185. package/lib/typescript/src/Shared/Libs/frame-enhancement.utils.d.ts +0 -25
  186. package/lib/typescript/src/Shared/Libs/frame-enhancement.utils.d.ts.map +0 -1
  187. package/lib/typescript/src/Shared/Libs/opencv.utils.d.ts +0 -3
  188. package/lib/typescript/src/Shared/Libs/opencv.utils.d.ts.map +0 -1
  189. package/lib/typescript/src/Shared/Libs/worklet.utils.d.ts +0 -9
  190. package/lib/typescript/src/Shared/Libs/worklet.utils.d.ts.map +0 -1
  191. package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/hooks/useBarcodeScanner.d.ts +0 -13
  192. package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/hooks/useBarcodeScanner.d.ts.map +0 -1
  193. package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/hooks/useCameraPermissions.d.ts +0 -6
  194. package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/hooks/useCameraPermissions.d.ts.map +0 -1
  195. package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/index.d.ts +0 -12
  196. package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/index.d.ts.map +0 -1
  197. package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/scanCodes.d.ts +0 -3
  198. package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/scanCodes.d.ts.map +0 -1
  199. package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/types.d.ts +0 -52
  200. package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/types.d.ts.map +0 -1
  201. package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/utils/convert.d.ts +0 -62
  202. package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/utils/convert.d.ts.map +0 -1
  203. package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/utils/geometry.d.ts +0 -34
  204. package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/utils/geometry.d.ts.map +0 -1
  205. package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/utils/highlights.d.ts +0 -32
  206. package/lib/typescript/src/Shared/VisionCameraPlugins/BarcodeScanner/utils/highlights.d.ts.map +0 -1
  207. package/lib/typescript/src/Shared/VisionCameraPlugins/Cropper/index.d.ts +0 -23
  208. package/lib/typescript/src/Shared/VisionCameraPlugins/Cropper/index.d.ts.map +0 -1
  209. package/lib/typescript/src/Shared/VisionCameraPlugins/FaceDetector/Camera.d.ts +0 -9
  210. package/lib/typescript/src/Shared/VisionCameraPlugins/FaceDetector/Camera.d.ts.map +0 -1
  211. package/lib/typescript/src/Shared/VisionCameraPlugins/FaceDetector/detectFaces.d.ts +0 -3
  212. package/lib/typescript/src/Shared/VisionCameraPlugins/FaceDetector/detectFaces.d.ts.map +0 -1
  213. package/lib/typescript/src/Shared/VisionCameraPlugins/FaceDetector/index.d.ts +0 -3
  214. package/lib/typescript/src/Shared/VisionCameraPlugins/FaceDetector/index.d.ts.map +0 -1
  215. package/lib/typescript/src/Shared/VisionCameraPlugins/FaceDetector/types.d.ts +0 -79
  216. package/lib/typescript/src/Shared/VisionCameraPlugins/FaceDetector/types.d.ts.map +0 -1
  217. package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/Camera.d.ts +0 -6
  218. package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/Camera.d.ts.map +0 -1
  219. package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/PhotoRecognizer.d.ts +0 -3
  220. package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/PhotoRecognizer.d.ts.map +0 -1
  221. package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/RemoveLanguageModel.d.ts +0 -3
  222. package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/RemoveLanguageModel.d.ts.map +0 -1
  223. package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/index.d.ts +0 -5
  224. package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/index.d.ts.map +0 -1
  225. package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/scanText.d.ts +0 -3
  226. package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/scanText.d.ts.map +0 -1
  227. package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/translateText.d.ts +0 -3
  228. package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/translateText.d.ts.map +0 -1
  229. package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/types.d.ts +0 -67
  230. package/lib/typescript/src/Shared/VisionCameraPlugins/TextRecognition/types.d.ts.map +0 -1
  231. package/src/Shared/Libs/camera.utils.ts +0 -345
  232. package/src/Shared/Libs/frame-enhancement.utils.ts +0 -217
  233. package/src/Shared/Libs/opencv.utils.ts +0 -40
  234. package/src/Shared/Libs/worklet.utils.ts +0 -72
  235. package/src/Shared/VisionCameraPlugins/BarcodeScanner/hooks/useBarcodeScanner.ts +0 -79
  236. package/src/Shared/VisionCameraPlugins/BarcodeScanner/hooks/useCameraPermissions.ts +0 -46
  237. package/src/Shared/VisionCameraPlugins/BarcodeScanner/index.ts +0 -60
  238. package/src/Shared/VisionCameraPlugins/BarcodeScanner/scanCodes.ts +0 -32
  239. package/src/Shared/VisionCameraPlugins/BarcodeScanner/types.ts +0 -82
  240. package/src/Shared/VisionCameraPlugins/BarcodeScanner/utils/convert.ts +0 -195
  241. package/src/Shared/VisionCameraPlugins/BarcodeScanner/utils/geometry.ts +0 -135
  242. package/src/Shared/VisionCameraPlugins/BarcodeScanner/utils/highlights.ts +0 -84
  243. package/src/Shared/VisionCameraPlugins/Cropper/index.ts +0 -78
  244. package/src/Shared/VisionCameraPlugins/FaceDetector/Camera.tsx +0 -63
  245. package/src/Shared/VisionCameraPlugins/FaceDetector/detectFaces.ts +0 -44
  246. package/src/Shared/VisionCameraPlugins/FaceDetector/index.ts +0 -3
  247. package/src/Shared/VisionCameraPlugins/FaceDetector/types.ts +0 -99
  248. package/src/Shared/VisionCameraPlugins/TextRecognition/Camera.tsx +0 -76
  249. package/src/Shared/VisionCameraPlugins/TextRecognition/PhotoRecognizer.ts +0 -18
  250. package/src/Shared/VisionCameraPlugins/TextRecognition/RemoveLanguageModel.ts +0 -7
  251. package/src/Shared/VisionCameraPlugins/TextRecognition/index.ts +0 -7
  252. package/src/Shared/VisionCameraPlugins/TextRecognition/scanText.ts +0 -27
  253. package/src/Shared/VisionCameraPlugins/TextRecognition/translateText.ts +0 -21
  254. package/src/Shared/VisionCameraPlugins/TextRecognition/types.ts +0 -141
@@ -1,217 +0,0 @@
1
- import type { Frame } from 'react-native-vision-camera';
2
- import {
3
- ColorConversionCodes,
4
- DataTypes,
5
- type Mat,
6
- ObjectType,
7
- OpenCV,
8
- } from 'react-native-fast-opencv';
9
- import { ENHANCEMENT_CONFIG } from '../Config/camera-enhancement.config';
10
-
11
- // Cast OpenCV for methods not in type definitions
12
- const OpenCVAny = OpenCV as any;
13
-
14
- /**
15
- * Convert YUV frame to BGR Mat for OpenCV processing
16
- */
17
- const convertYUVToBGR = (frame: Frame): Mat => {
18
- 'worklet';
19
-
20
- const buffer = frame.toArrayBuffer();
21
- const data = new Uint8Array(buffer);
22
- const width = frame.width;
23
- const height = frame.height;
24
-
25
- // Create YUV Mat from frame buffer
26
- const yuvMat = OpenCV.createObject(
27
- ObjectType.Mat,
28
- height + height / 2,
29
- width,
30
- DataTypes.CV_8UC1
31
- );
32
-
33
- // Copy frame data to YUV Mat
34
- OpenCVAny.invoke('matSetData', yuvMat, data);
35
-
36
- // Convert YUV to BGR
37
- const bgrMat = OpenCV.createObject(
38
- ObjectType.Mat,
39
- height,
40
- width,
41
- DataTypes.CV_8UC3
42
- );
43
-
44
- OpenCV.invoke(
45
- 'cvtColor',
46
- yuvMat,
47
- bgrMat,
48
- ColorConversionCodes.COLOR_YUV2BGR_NV21
49
- );
50
-
51
- return bgrMat;
52
- };
53
-
54
- /**
55
- * Apply CLAHE (Contrast Limited Adaptive Histogram Equalization) to enhance frame
56
- * This improves text and face recognition in varying lighting conditions
57
- */
58
- const enhanceFrameForOCR = (
59
- frame: Frame,
60
- options?: {
61
- clipLimit?: number;
62
- tileGridSize?: number;
63
- }
64
- ): Mat => {
65
- 'worklet';
66
-
67
- const clipLimit = options?.clipLimit ?? ENHANCEMENT_CONFIG.contrast.clahe.clipLimit;
68
- const tileGridSize = options?.tileGridSize ?? ENHANCEMENT_CONFIG.contrast.clahe.tileGridSize[0];
69
-
70
- try {
71
- // 1. Convert YUV to BGR
72
- const bgrMat = convertYUVToBGR(frame);
73
-
74
- // 2. Convert BGR to LAB color space (better for luminance enhancement)
75
- const labMat = OpenCV.createObject(
76
- ObjectType.Mat,
77
- frame.height,
78
- frame.width,
79
- DataTypes.CV_8UC3
80
- );
81
-
82
- OpenCV.invoke('cvtColor', bgrMat, labMat, ColorConversionCodes.COLOR_BGR2Lab);
83
-
84
- // 3. Split LAB channels
85
- const channels = OpenCVAny.invoke('split', labMat);
86
- const lChannel = channels[0]; // Luminance channel
87
- const aChannel = channels[1]; // a channel
88
- const bChannel = channels[2]; // b channel
89
-
90
- // 4. Apply CLAHE to L channel
91
- const clahe = OpenCVAny.invoke('createCLAHE', clipLimit, [
92
- tileGridSize,
93
- tileGridSize,
94
- ]);
95
-
96
- const enhancedL = OpenCV.createObject(
97
- ObjectType.Mat,
98
- frame.height,
99
- frame.width,
100
- DataTypes.CV_8UC1
101
- );
102
-
103
- OpenCVAny.invoke('apply', clahe, lChannel, enhancedL);
104
-
105
- // 5. Merge enhanced L channel with original a and b channels
106
- const enhancedLab = OpenCVAny.invoke('merge', [enhancedL, aChannel, bChannel]);
107
-
108
- // 6. Convert back to BGR
109
- const enhancedBGR = OpenCV.createObject(
110
- ObjectType.Mat,
111
- frame.height,
112
- frame.width,
113
- DataTypes.CV_8UC3
114
- );
115
-
116
- OpenCV.invoke(
117
- 'cvtColor',
118
- enhancedLab,
119
- enhancedBGR,
120
- ColorConversionCodes.COLOR_Lab2BGR
121
- );
122
-
123
- // Cleanup intermediate Mats
124
- OpenCVAny.invoke('delete', bgrMat);
125
- OpenCVAny.invoke('delete', labMat);
126
- OpenCVAny.invoke('delete', lChannel);
127
- OpenCVAny.invoke('delete', aChannel);
128
- OpenCVAny.invoke('delete', bChannel);
129
- OpenCVAny.invoke('delete', enhancedL);
130
- OpenCVAny.invoke('delete', enhancedLab);
131
-
132
- return enhancedBGR;
133
- } catch (error) {
134
- console.warn('Error enhancing frame:', error);
135
- // Return original frame converted to BGR if enhancement fails
136
- return convertYUVToBGR(frame);
137
- }
138
- };
139
-
140
- /**
141
- * Apply sharpening to enhance text clarity
142
- * Uses unsharp mask technique
143
- */
144
- const sharpenForText = (mat: Mat, amount: number = 1.5): Mat => {
145
- 'worklet';
146
-
147
- try {
148
- const blurred = OpenCV.createObject(
149
- ObjectType.Mat,
150
- 0,
151
- 0,
152
- DataTypes.CV_8UC3
153
- );
154
-
155
- // Apply Gaussian blur
156
- OpenCVAny.invoke('GaussianBlur', mat, blurred, [0, 0], 3.0);
157
-
158
- // Create sharpened image: original * (1 + amount) - blurred * amount
159
- const sharpened = OpenCV.createObject(
160
- ObjectType.Mat,
161
- 0,
162
- 0,
163
- DataTypes.CV_8UC3
164
- );
165
-
166
- OpenCV.invoke('addWeighted', mat, 1.0 + amount, blurred, -amount, 0, sharpened);
167
-
168
- // Cleanup
169
- OpenCVAny.invoke('delete', blurred);
170
-
171
- return sharpened;
172
- } catch (error) {
173
- console.warn('Error sharpening frame:', error);
174
- return mat;
175
- }
176
- };
177
-
178
- /**
179
- * Determine if frame should be enhanced based on current scanning state
180
- */
181
- const shouldEnhanceFrame = (
182
- nextStep: string,
183
- detectedFaces: number,
184
- mrzRetryCount: number
185
- ): boolean => {
186
- 'worklet';
187
-
188
- const config = ENHANCEMENT_CONFIG.contrast.applyWhen;
189
-
190
- // Always enhance for document back side (MRZ scanning)
191
- if (config.documentBackSide && nextStep === 'SCAN_ID_BACK') {
192
- return true;
193
- }
194
-
195
- // Enhance if faces are failing to detect on front/passport
196
- if (
197
- config.faceFailing &&
198
- nextStep === 'SCAN_ID_FRONT_OR_PASSPORT' &&
199
- detectedFaces === 0
200
- ) {
201
- return true;
202
- }
203
-
204
- // Enhance if MRZ detection is failing
205
- if (config.mrzFailing && mrzRetryCount >= config.retryThreshold) {
206
- return true;
207
- }
208
-
209
- return false;
210
- };
211
-
212
- export {
213
- convertYUVToBGR,
214
- enhanceFrameForOCR,
215
- sharpenForText,
216
- shouldEnhanceFrame,
217
- };
@@ -1,40 +0,0 @@
1
- import {
2
- ColorConversionCodes,
3
- DataTypes,
4
- ObjectType,
5
- OpenCV,
6
- } from 'react-native-fast-opencv';
7
-
8
- const isImageBright = (
9
- width: number,
10
- height: number,
11
- frameBuffer: Uint8Array
12
- ) => {
13
- 'worklet';
14
- try {
15
- const imageMat = OpenCV.frameBufferToMat(height, width, 3, frameBuffer);
16
- const grayMat = OpenCV.createObject(ObjectType.Mat, 0, 0, DataTypes.CV_8U);
17
- OpenCV.invoke(
18
- 'cvtColor',
19
- imageMat,
20
- grayMat,
21
- ColorConversionCodes.COLOR_BGR2GRAY
22
- );
23
- const meanMat = OpenCV.createObject(ObjectType.Mat, 0, 0, DataTypes.CV_64F);
24
- const stdDevMat = OpenCV.createObject(
25
- ObjectType.Mat,
26
- 0,
27
- 0,
28
- DataTypes.CV_64F
29
- );
30
- OpenCV.invoke('meanStdDev', grayMat, meanMat, stdDevMat);
31
- const minMax = OpenCV.invoke('minMaxLoc', meanMat);
32
- return minMax.maxVal >= 90;
33
- } catch (e) {
34
- // console.log('error', e);
35
- }
36
-
37
- return false;
38
- };
39
-
40
- export { isImageBright };
@@ -1,72 +0,0 @@
1
- import type { Frame, FrameInternal } from 'react-native-vision-camera';
2
- import { Worklets } from 'react-native-worklets-core';
3
-
4
- /**
5
- * A synchronized Shared Value to indicate whether the async context is currently executing
6
- */
7
- let isAsyncContextBusy: { value: boolean };
8
-
9
- /**
10
- * Runs the given function on the async context, and sets isAsyncContextBusy to false after it finished executing.
11
- */
12
- let runOnAsyncContext: (frame: Frame, func: () => void) => void;
13
-
14
- try {
15
- isAsyncContextBusy = Worklets.createSharedValue(false);
16
-
17
- const asyncContext = Worklets.defaultContext;
18
-
19
- runOnAsyncContext = asyncContext.createRunAsync(
20
- (frame: Frame, func: () => void) => {
21
- 'worklet';
22
- try {
23
- // Call long-running function
24
- func();
25
- } catch (e) {
26
- // Re-throw error on JS Thread
27
- throw e;
28
- } finally {
29
- // Potentially delete Frame if we were the last ref
30
- const internal = frame as FrameInternal;
31
- internal.decrementRefCount();
32
-
33
- // free up async context again, new calls can be made
34
- isAsyncContextBusy.value = false;
35
- }
36
- }
37
- );
38
- } catch (e) {
39
- // react-native-worklets-core is not installed!
40
- // Just use dummy implementations that will throw when the user tries to use Frame Processors.
41
- isAsyncContextBusy = { value: false };
42
- runOnAsyncContext = () => {
43
- throw new Error(
44
- 'react-native-worklets-core is not installed! Please install it to use Frame Processors.'
45
- );
46
- };
47
- }
48
-
49
- /**
50
- * Runs the given func asynchronously on a separate thread,
51
- * allowing the Frame Processor to continue executing without dropping a Frame.
52
- *
53
- * @note This is a custom implementation. For most cases, use runAsync from react-native-vision-camera.
54
- */
55
- export function runAsync(frame: Frame, func: () => void): void {
56
- 'worklet';
57
-
58
- if (isAsyncContextBusy.value) {
59
- // async context is currently busy, we cannot schedule new work in time.
60
- // drop this frame/runAsync call.
61
- return;
62
- }
63
-
64
- // Increment ref count by one
65
- const internal = frame as FrameInternal;
66
- internal.incrementRefCount();
67
-
68
- isAsyncContextBusy.value = true;
69
-
70
- // Call in separate background context
71
- runOnAsyncContext(frame, func);
72
- }
@@ -1,79 +0,0 @@
1
- import { useCallback, useState } from 'react';
2
- import type { Frame } from 'react-native-vision-camera';
3
- import { createBarcodeScannerPlugin } from '../scanCodes';
4
- import type { Barcode, ScanBarcodesOptions } from '../types';
5
-
6
- export interface UseBarcodeScannerOptions extends ScanBarcodesOptions {
7
- onBarcodeScanned?: (barcodes: Barcode[]) => void;
8
- onError?: (error: Error) => void;
9
- }
10
-
11
- export interface UseBarcodeScannerResult {
12
- scanBarcodes: (frame: Frame) => Barcode[];
13
- barcodes: Barcode[];
14
- isScanning: boolean;
15
- }
16
-
17
- let barcodeScannerPlugin: ReturnType<typeof createBarcodeScannerPlugin> | null =
18
- null;
19
-
20
- export const useBarcodeScanner = (
21
- options: UseBarcodeScannerOptions = {}
22
- ): UseBarcodeScannerResult => {
23
- const [barcodes, setBarcodes] = useState<Barcode[]>([]);
24
- const [isScanning, setIsScanning] = useState(false);
25
-
26
- const scanBarcodes = useCallback(
27
- (frame: Frame): Barcode[] => {
28
- 'worklet';
29
-
30
- if (!barcodeScannerPlugin) {
31
- try {
32
- barcodeScannerPlugin = createBarcodeScannerPlugin();
33
- } catch (error) {
34
- console.warn(
35
- 'useBarcodeScanner: Failed to initialize plugin:',
36
- error
37
- );
38
- options.onError?.(error as Error);
39
- return [];
40
- }
41
- }
42
-
43
- setIsScanning(true);
44
-
45
- try {
46
- const scanOptions: ScanBarcodesOptions = {
47
- barcodeTypes: options.barcodeTypes,
48
- regionOfInterest: options.regionOfInterest,
49
- };
50
-
51
- const detectedBarcodes = barcodeScannerPlugin.scanCodes(
52
- frame,
53
- scanOptions
54
- );
55
-
56
- setBarcodes(detectedBarcodes);
57
-
58
- if (detectedBarcodes.length > 0) {
59
- options.onBarcodeScanned?.(detectedBarcodes);
60
- }
61
-
62
- return detectedBarcodes;
63
- } catch (error) {
64
- console.warn('useBarcodeScanner: Scan failed:', error);
65
- options.onError?.(error as Error);
66
- return [];
67
- } finally {
68
- setIsScanning(false);
69
- }
70
- },
71
- [options]
72
- );
73
-
74
- return {
75
- scanBarcodes,
76
- barcodes,
77
- isScanning,
78
- };
79
- };
@@ -1,46 +0,0 @@
1
- import { useEffect, useState } from 'react';
2
- import { Alert, Linking } from 'react-native';
3
- import { useCameraPermission } from 'react-native-vision-camera';
4
-
5
- export interface UseCameraPermissionResult {
6
- hasPermission: boolean;
7
- requestPermission: () => Promise<boolean>;
8
- }
9
-
10
- export const useCameraPermissions = (): UseCameraPermissionResult => {
11
- const {
12
- hasPermission: cameraPermission,
13
- requestPermission: requestCameraPermission,
14
- } = useCameraPermission();
15
-
16
- const [hasPermission, setHasPermission] = useState(cameraPermission);
17
-
18
- useEffect(() => {
19
- setHasPermission(cameraPermission);
20
- }, [cameraPermission]);
21
-
22
- const requestPermission = async (): Promise<boolean> => {
23
- const permission = await requestCameraPermission();
24
-
25
- if (!permission) {
26
- // Camera permission denied by user - their choice, not actionable
27
- Alert.alert(
28
- 'Camera Permission Required',
29
- 'This app needs camera access to scan barcodes. Please enable camera permissions in your device settings.',
30
- [
31
- { text: 'Cancel', style: 'cancel' },
32
- { text: 'Open Settings', onPress: () => Linking.openSettings() },
33
- ]
34
- );
35
- return false;
36
- }
37
-
38
- setHasPermission(permission);
39
- return permission;
40
- };
41
-
42
- return {
43
- hasPermission,
44
- requestPermission,
45
- };
46
- };
@@ -1,60 +0,0 @@
1
- // Main plugin function
2
- export { createBarcodeScannerPlugin } from './scanCodes';
3
-
4
- // Create default plugin instance and export scanCodes function
5
- import { createBarcodeScannerPlugin } from './scanCodes';
6
- const defaultPlugin = createBarcodeScannerPlugin();
7
- export const scanCodes = defaultPlugin.scanCodes;
8
-
9
- // Types
10
- export type {
11
- BarcodeType,
12
- Barcode,
13
- ScanBarcodesOptions,
14
- Point,
15
- Size,
16
- Rect,
17
- BoundingBox,
18
- CornerPoints,
19
- Highlight,
20
- FrameProcessorPlugin,
21
- BarcodeScannerPlugin,
22
- BarcodeScannerOptions,
23
- } from './types';
24
-
25
- // Hooks
26
- export { useBarcodeScanner } from './hooks/useBarcodeScanner';
27
- export { useCameraPermissions } from './hooks/useCameraPermissions';
28
- export type {
29
- UseBarcodeScannerOptions,
30
- UseBarcodeScannerResult,
31
- } from './hooks/useBarcodeScanner';
32
- export type { UseCameraPermissionResult } from './hooks/useCameraPermissions';
33
-
34
- // Utilities
35
- export {
36
- convertFrameToScreen,
37
- convertScreenToFrame,
38
- convertBarcodeToScreen,
39
- getRectCenter,
40
- getCornerPointsCenter,
41
- getBoundsFromCornerPoints,
42
- } from './utils/geometry';
43
- export type { FrameDimensions, ScreenDimensions } from './utils/geometry';
44
-
45
- export {
46
- boundingBoxToHighlight,
47
- barcodesToHighlights,
48
- getHighlightStyle,
49
- cornerPointsToPath,
50
- cornerPointsToPolygonPoints,
51
- } from './utils/highlights';
52
-
53
- export {
54
- barcodeTypeToAndroidFormat,
55
- barcodeTypeToIOSSymbology,
56
- androidFormatToBarcodeType,
57
- iosSymbologyToBarcodeType,
58
- AndroidBarcodeFormat,
59
- IOSBarcodeSymbology,
60
- } from './utils/convert';
@@ -1,32 +0,0 @@
1
- import { VisionCameraProxy, type Frame } from 'react-native-vision-camera';
2
- import type {
3
- ScanBarcodesOptions,
4
- Barcode,
5
- BarcodeScannerPlugin,
6
- } from './types';
7
-
8
- const LINKING_ERROR = `Can't load plugin scanCodes. Try cleaning cache or reinstall plugin.`;
9
-
10
- export function createBarcodeScannerPlugin(): BarcodeScannerPlugin {
11
- const plugin = VisionCameraProxy.initFrameProcessorPlugin('scanCodes', {});
12
-
13
- if (!plugin) {
14
- throw new Error(LINKING_ERROR);
15
- }
16
-
17
- return {
18
- scanCodes: (frame: Frame, options?: ScanBarcodesOptions): Barcode[] => {
19
- 'worklet';
20
- try {
21
- // @ts-ignore
22
- const result = plugin.call(frame, options) as Barcode[];
23
-
24
- // iOS now handles coordinate conversion, so return results directly
25
- return result || [];
26
- } catch (error) {
27
- console.warn('scanCodes: Plugin call failed:', error);
28
- return [];
29
- }
30
- },
31
- };
32
- }
@@ -1,82 +0,0 @@
1
- import type { Frame } from 'react-native-vision-camera';
2
-
3
- export type Point = {
4
- x: number;
5
- y: number;
6
- };
7
-
8
- export type Size = {
9
- width: number;
10
- height: number;
11
- };
12
-
13
- export type Rect = Point & Size;
14
-
15
- export type Key = string | number | bigint;
16
-
17
- export type BoundingBox = {
18
- origin: Point;
19
- size: Size;
20
- };
21
-
22
- export type CornerPoints = Point[];
23
- export type Highlight = BoundingBox & { key: Key };
24
-
25
- export type BarcodeType =
26
- | 'aztec'
27
- | 'codabar'
28
- | 'code-128'
29
- | 'code-39'
30
- | 'code-93'
31
- | 'data-matrix'
32
- | 'ean-13'
33
- | 'ean-8'
34
- | 'gs1-databar'
35
- | 'itf'
36
- | 'msi-plessey'
37
- | 'pdf-417'
38
- | 'qr'
39
- | 'upc-a'
40
- | 'upc-e'
41
- | 'unknown';
42
-
43
- export type Barcode = {
44
- value: string | null;
45
- type: BarcodeType;
46
- boundingBox: BoundingBox;
47
- cornerPoints: Point[];
48
- native?: any;
49
- };
50
-
51
- export type ScanBarcodesOptions = {
52
- barcodeTypes?: BarcodeType[];
53
- regionOfInterest?: [number, number, number, number];
54
- };
55
-
56
- export type BasicParameterType = string | number | boolean | undefined;
57
- export type ParameterType =
58
- | BasicParameterType
59
- | BasicParameterType[]
60
- | Record<string, BasicParameterType | undefined>;
61
-
62
- export interface FrameProcessorPlugin {
63
- call: (
64
- frame: Frame,
65
- options?: Record<string, ParameterType>
66
- ) => ParameterType;
67
- }
68
-
69
- export interface BarcodeScannerPlugin {
70
- scanCodes: (frame: Frame, options?: ScanBarcodesOptions) => Barcode[];
71
- }
72
-
73
- export type BarcodeScannerOptions = {
74
- barcodeTypes?: BarcodeType[];
75
- regionOfInterest?: Rect;
76
- fps?: number;
77
- onBarcodeScanned: (barcodes: Barcode[], frame: Frame) => void;
78
- disableHighlighting?: boolean;
79
- resizeMode?: 'cover' | 'contain';
80
- scanMode?: 'continuous' | 'once';
81
- isMountedRef?: { value: boolean };
82
- };