@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 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../src/Shared/VisionCameraPlugins/FaceDetector/types.ts"],"names":[],"mappings":"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"}
@@ -1,6 +0,0 @@
1
- import React from 'react';
2
- import type { CameraTypes, TextRecognitionPlugin, TranslatorPlugin, TextRecognitionOptions, TranslatorOptions } from './types';
3
- export declare const Camera: React.ForwardRefExoticComponent<CameraTypes & React.RefAttributes<any>>;
4
- export declare function useTextRecognition(options?: TextRecognitionOptions): TextRecognitionPlugin;
5
- export declare function useTranslate(options?: TranslatorOptions): TranslatorPlugin;
6
- //# sourceMappingURL=Camera.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Camera.d.ts","sourceRoot":"","sources":["../../../../../../src/Shared/VisionCameraPlugins/TextRecognition/Camera.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAiD,MAAM,OAAO,CAAC;AAOtE,OAAO,KAAK,EACV,WAAW,EAIX,qBAAqB,EACrB,gBAAgB,EAChB,sBAAsB,EACtB,iBAAiB,EAClB,MAAM,SAAS,CAAC;AAGjB,eAAO,MAAM,MAAM,yEA8CjB,CAAC;AAEH,wBAAgB,kBAAkB,CAChC,OAAO,CAAC,EAAE,sBAAsB,GAC/B,qBAAqB,CAEvB;AAED,wBAAgB,YAAY,CAAC,OAAO,CAAC,EAAE,iBAAiB,GAAG,gBAAgB,CAE1E"}
@@ -1,3 +0,0 @@
1
- import type { PhotoOptions, Text } from './types';
2
- export declare function PhotoRecognizer(options: PhotoOptions): Promise<Text>;
3
- //# sourceMappingURL=PhotoRecognizer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PhotoRecognizer.d.ts","sourceRoot":"","sources":["../../../../../../src/Shared/VisionCameraPlugins/TextRecognition/PhotoRecognizer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAElD,wBAAsB,eAAe,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAc1E"}
@@ -1,3 +0,0 @@
1
- import type { Languages } from './types';
2
- export declare function RemoveLanguageModel(code: Languages): Promise<boolean>;
3
- //# sourceMappingURL=RemoveLanguageModel.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"RemoveLanguageModel.d.ts","sourceRoot":"","sources":["../../../../../../src/Shared/VisionCameraPlugins/TextRecognition/RemoveLanguageModel.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEzC,wBAAsB,mBAAmB,CAAC,IAAI,EAAE,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC,CAG3E"}
@@ -1,5 +0,0 @@
1
- export { Camera, useTranslate, useTextRecognition } from './Camera';
2
- export { RemoveLanguageModel } from './RemoveLanguageModel';
3
- export { PhotoRecognizer } from './PhotoRecognizer';
4
- export * from './types';
5
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/Shared/VisionCameraPlugins/TextRecognition/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAEpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,cAAc,SAAS,CAAC"}
@@ -1,3 +0,0 @@
1
- import type { TextRecognitionPlugin, TextRecognitionOptions } from './types';
2
- export declare function createTextRecognitionPlugin(options?: TextRecognitionOptions): TextRecognitionPlugin;
3
- //# sourceMappingURL=scanText.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"scanText.d.ts","sourceRoot":"","sources":["../../../../../../src/Shared/VisionCameraPlugins/TextRecognition/scanText.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,qBAAqB,EACrB,sBAAsB,EAEvB,MAAM,SAAS,CAAC;AAIjB,wBAAgB,2BAA2B,CACzC,OAAO,CAAC,EAAE,sBAAsB,GAC/B,qBAAqB,CAcvB"}
@@ -1,3 +0,0 @@
1
- import type { TranslatorPlugin, TranslatorOptions } from './types';
2
- export declare function createTranslatorPlugin(options?: TranslatorOptions): TranslatorPlugin;
3
- //# sourceMappingURL=translateText.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"translateText.d.ts","sourceRoot":"","sources":["../../../../../../src/Shared/VisionCameraPlugins/TextRecognition/translateText.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAS,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAK1E,wBAAgB,sBAAsB,CACpC,OAAO,CAAC,EAAE,iBAAiB,GAC1B,gBAAgB,CAalB"}
@@ -1,67 +0,0 @@
1
- export type { Frame, ReadonlyFrameProcessor, FrameProcessorPlugin, FrameInternal, CameraProps, CameraDevice, } from 'react-native-vision-camera';
2
- export type { ForwardedRef } from 'react';
3
- import type { CameraProps, Frame } from 'react-native-vision-camera';
4
- export type Languages = 'af' | 'sq' | 'ar' | 'be' | 'bn' | 'bg' | 'ca' | 'zh' | 'cs' | 'da' | 'nl' | 'en' | 'eo' | 'et' | 'fi' | 'fr' | 'gl' | 'ka' | 'de' | 'el' | 'gu' | 'ht' | 'he' | 'hi' | 'hu' | 'is' | 'id' | 'ga' | 'it' | 'ja' | 'kn' | 'ko' | 'lv' | 'lt' | 'mk' | 'ms' | 'mt' | 'mr' | 'no' | 'fa' | 'pl' | 'pt' | 'ro' | 'ru' | 'sk' | 'sl' | 'es' | 'sw' | 'tl' | 'ta' | 'te' | 'th' | 'tr' | 'uk' | 'ur' | 'vi' | 'cy';
5
- export type TextRecognitionOptions = {
6
- language: 'latin' | 'chinese' | 'devanagari' | 'japanese' | 'korean';
7
- };
8
- export type TranslatorOptions = {
9
- from: Languages;
10
- to: Languages;
11
- };
12
- export type CameraTypes = {
13
- callback: (data: string | Text[]) => void;
14
- mode: 'translate' | 'recognize';
15
- } & CameraProps & ({
16
- mode: 'recognize';
17
- options: TextRecognitionOptions;
18
- } | {
19
- mode: 'translate';
20
- options: TranslatorOptions;
21
- });
22
- export type TextRecognitionPlugin = {
23
- scanText: (frame: Frame) => Text[];
24
- };
25
- export type TranslatorPlugin = {
26
- translate: (frame: Frame) => string;
27
- };
28
- export type Text = {
29
- blocks: BlocksData;
30
- resultText: string;
31
- };
32
- type BlocksData = [
33
- blockFrame: FrameType,
34
- blockCornerPoints: CornerPointsType,
35
- lines: LinesData,
36
- blockLanguages: string[] | [],
37
- blockText: string
38
- ];
39
- type CornerPointsType = [{
40
- x: number;
41
- y: number;
42
- }];
43
- type FrameType = {
44
- boundingCenterX: number;
45
- boundingCenterY: number;
46
- height: number;
47
- width: number;
48
- x: number;
49
- y: number;
50
- };
51
- type LinesData = [
52
- lineCornerPoints: CornerPointsType,
53
- elements: ElementsData,
54
- lineFrame: FrameType,
55
- lineLanguages: string[] | [],
56
- lineText: string
57
- ];
58
- type ElementsData = [
59
- elementCornerPoints: CornerPointsType,
60
- elementFrame: FrameType,
61
- elementText: string
62
- ];
63
- export type PhotoOptions = {
64
- uri: string;
65
- orientation?: 'landscapeRight' | 'portrait' | 'portraitUpsideDown' | 'landscapeLeft';
66
- };
67
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../src/Shared/VisionCameraPlugins/TextRecognition/types.ts"],"names":[],"mappings":"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"}
@@ -1,345 +0,0 @@
1
- import type { Frame } from 'react-native-vision-camera';
2
-
3
- interface Rect {
4
- minX: number;
5
- minY: number;
6
- width: number;
7
- height: number;
8
- }
9
-
10
- /**
11
- * Check if frame is blurry using Laplacian variance
12
- * Uses both horizontal and vertical gradients for more accurate blur detection
13
- * Lower variance indicates a blurrier image
14
- * @param frame - The camera frame to analyze
15
- * @param threshold - Variance threshold below which image is considered blurry (default: 10)
16
- * @returns true if image is blurry, false otherwise
17
- */
18
- const isBlurry = (frame: Frame, threshold: number = 10): boolean => {
19
- 'worklet';
20
- const buffer = frame.toArrayBuffer();
21
- const data = new Uint8Array(buffer);
22
- const width = frame.width;
23
- const height = frame.height;
24
-
25
- let sum = 0;
26
- let sumSq = 0;
27
- let count = 0;
28
-
29
- // Sample central 50% region (matching Flutter algorithm)
30
- const startY = Math.floor(height / 4);
31
- const endY = Math.floor((3 * height) / 4) - 1;
32
- const startX = Math.floor(width / 4);
33
- const endX = Math.floor((3 * width) / 4) - 1;
34
-
35
- // Sample at 5-pixel intervals for better accuracy (matching Flutter)
36
- for (let y = startY; y < endY; y += 5) {
37
- for (let x = startX; x < endX; x += 5) {
38
- const idx = y * width + x;
39
- const idxRight = idx + 1;
40
- const idxDown = idx + width;
41
-
42
- // Check bounds for both horizontal and vertical neighbors
43
- if (idxRight < data.length && idxDown < data.length &&
44
- data[idx] !== undefined && data[idxRight] !== undefined && data[idxDown] !== undefined) {
45
- // Horizontal gradient
46
- const diffH = Math.abs(data[idx] - data[idxRight]);
47
- // Vertical gradient
48
- const diffV = Math.abs(data[idx] - data[idxDown]);
49
- // Combined Laplacian-like measure
50
- const laplacian = diffH + diffV;
51
-
52
- sum += laplacian;
53
- sumSq += laplacian * laplacian;
54
- count++;
55
- }
56
- }
57
- }
58
-
59
- if (count === 0) return false;
60
-
61
- // Calculate variance: E[X²] - E[X]²
62
- const mean = sum / count;
63
- const variance = sumSq / count - mean * mean;
64
-
65
- return variance < threshold;
66
- };
67
-
68
- /**
69
- * Get average brightness for entire frame (center area)
70
- */
71
- const getAverageBrightness = (frame: Frame): number => {
72
- 'worklet';
73
- const buffer = frame.toArrayBuffer();
74
- const data = new Uint8Array(buffer);
75
- const width = frame.width;
76
- const height = frame.height;
77
- const centerX = Math.floor(width / 2);
78
- const centerY = Math.floor(height / 2);
79
- const halfSizeX = Math.floor(width / 2);
80
- const halfSizeY = Math.floor(height / 2);
81
- let luminanceSum = 0;
82
- let pixelCount = 0;
83
-
84
- for (let y = centerY - halfSizeY; y < centerY + halfSizeY; y++) {
85
- for (let x = centerX - halfSizeX; x < centerX + halfSizeX; x++) {
86
- const index = y * width + x;
87
- if (data[index] !== undefined) {
88
- luminanceSum += data[index];
89
- pixelCount++;
90
- }
91
- }
92
- }
93
-
94
- return luminanceSum / pixelCount;
95
- };
96
-
97
- /**
98
- * Get average brightness for a specific circular region (for face detection)
99
- * Calculates brightness only for pixels inside the circle defined by centerX, centerY, and radius
100
- */
101
- const getCircularRegionBrightness = (
102
- frame: Frame,
103
- circleRect: Rect
104
- ): number => {
105
- 'worklet';
106
- const buffer = frame.toArrayBuffer();
107
- const data = new Uint8Array(buffer);
108
- const width = frame.width;
109
- const height = frame.height;
110
-
111
- // Calculate circle parameters from rect
112
- const centerX = Math.floor(circleRect.minX + circleRect.width / 2);
113
- const centerY = Math.floor(circleRect.minY + circleRect.height / 2);
114
- const radius = Math.floor(Math.min(circleRect.width, circleRect.height) / 2);
115
-
116
- let luminanceSum = 0;
117
- let pixelCount = 0;
118
-
119
- // Calculate bounding box for the circle to optimize iteration
120
- const minX = Math.max(0, centerX - radius);
121
- const maxX = Math.min(width - 1, centerX + radius);
122
- const minY = Math.max(0, centerY - radius);
123
- const maxY = Math.min(height - 1, centerY + radius);
124
-
125
- // Iterate only over pixels in the bounding box
126
- for (let y = minY; y <= maxY; y++) {
127
- for (let x = minX; x <= maxX; x++) {
128
- // Check if pixel is inside the circle
129
- const dx = x - centerX;
130
- const dy = y - centerY;
131
- const distanceSquared = dx * dx + dy * dy;
132
-
133
- if (distanceSquared <= radius * radius) {
134
- const index = y * width + x;
135
- if (data[index] !== undefined) {
136
- luminanceSum += data[index];
137
- pixelCount++;
138
- }
139
- }
140
- }
141
- }
142
-
143
- return pixelCount > 0 ? luminanceSum / pixelCount : 0;
144
- };
145
-
146
- const isFrameBright = (frame: Frame): boolean => {
147
- 'worklet';
148
- return getAverageBrightness(frame) > 60;
149
- };
150
-
151
- /**
152
- * Check if a circular region in the frame is bright enough
153
- */
154
- const isCircularRegionBright = (frame: Frame, circleRect: Rect, threshold: number = 60): boolean => {
155
- 'worklet';
156
- return getCircularRegionBrightness(frame, circleRect) > threshold;
157
- };
158
-
159
- /**
160
- * Get average brightness for a specific rectangular region
161
- */
162
- const getRegionBrightness = (frame: Frame, bounds: Rect): number => {
163
- 'worklet';
164
- const buffer = frame.toArrayBuffer();
165
- const data = new Uint8Array(buffer);
166
- const width = frame.width;
167
- const height = frame.height;
168
-
169
- const minX = Math.max(0, Math.floor(bounds.minX));
170
- const maxX = Math.min(width - 1, Math.floor(bounds.minX + bounds.width));
171
- const minY = Math.max(0, Math.floor(bounds.minY));
172
- const maxY = Math.min(height - 1, Math.floor(bounds.minY + bounds.height));
173
-
174
- let luminanceSum = 0;
175
- let pixelCount = 0;
176
-
177
- for (let y = minY; y <= maxY; y++) {
178
- for (let x = minX; x <= maxX; x++) {
179
- const index = y * width + x;
180
- if (data[index] !== undefined) {
181
- luminanceSum += data[index];
182
- pixelCount++;
183
- }
184
- }
185
- }
186
-
187
- return pixelCount > 0 ? luminanceSum / pixelCount : 0;
188
- };
189
-
190
- /**
191
- * Calculate adaptive exposure step based on distance from target brightness
192
- * Uses smooth scaling to prevent abrupt exposure changes that could cause dark frames
193
- */
194
- const calculateExposureStep = (currentBrightness: number, targetBrightness: number): number => {
195
- 'worklet';
196
- const difference = Math.abs(targetBrightness - currentBrightness);
197
- // Use smaller steps for smoother transitions: max 2, min 1
198
- // Use floor + 1 to ensure at least step of 1 and prevent over-correction
199
- const step = Math.min(2, Math.max(1, Math.floor(difference / 25)));
200
- return step;
201
- };
202
-
203
- /**
204
- * Get the center point of the scan area
205
- * Scan area is typically 36%-64% of vertical space
206
- */
207
- const getScanAreaCenterPoint = (width: number, height: number): { x: number; y: number } => {
208
- const scanAreaTop = height * 0.36;
209
- const scanAreaBottom = height * 0.64;
210
- const scanAreaCenterY = (scanAreaTop + scanAreaBottom) / 2;
211
- const scanAreaCenterX = width / 2;
212
-
213
- return {
214
- x: scanAreaCenterX,
215
- y: scanAreaCenterY,
216
- };
217
- };
218
-
219
- /**
220
- * Document dimensions (in mm) for reference
221
- */
222
- const DOCUMENT_DIMENSIONS = {
223
- ID_CARD: { width: 85.6, height: 53.98, ratio: 1.586 },
224
- PASSPORT: { width: 125, height: 88, ratio: 1.42 },
225
- };
226
-
227
- /**
228
- * Detected document information
229
- */
230
- export interface DetectedDocument {
231
- type: 'ID_CARD' | 'PASSPORT' | 'UNKNOWN';
232
- size: 'TOO_SMALL' | 'TOO_LARGE' | 'GOOD';
233
- aspectRatio: number;
234
- confidence: number; // 0-1, how confident we are in the detection
235
- framePercentage: number; // How much of frame the document occupies
236
- }
237
-
238
- /**
239
- * Detect document contours and estimate document type based on aspect ratio
240
- * This is a simplified detection that looks for rectangular contours in the scan area
241
- * @param frame - The camera frame to analyze
242
- * @param scanAreaBounds - The bounds of the scan area {x, y, width, height}
243
- * @returns Detected document info or null if no document detected
244
- */
245
- const detectDocumentInFrame = (
246
- frame: Frame,
247
- scanAreaBounds: { x: number; y: number; width: number; height: number }
248
- ): DetectedDocument | null => {
249
- 'worklet';
250
-
251
- // For now, we'll use a simple edge-based detection
252
- // In production, this would integrate with OpenCV findContours
253
- // This is a placeholder that estimates based on brightness patterns
254
-
255
- const buffer = frame.toArrayBuffer();
256
- const data = new Uint8Array(buffer);
257
- const frameWidth = frame.width;
258
- const frameHeight = frame.height;
259
-
260
- // Sample edges of scan area to detect document boundaries
261
- const scanX = Math.floor(scanAreaBounds.x * frameWidth);
262
- const scanY = Math.floor(scanAreaBounds.y * frameHeight);
263
- const scanWidth = Math.floor(scanAreaBounds.width * frameWidth);
264
- const scanHeight = Math.floor(scanAreaBounds.height * frameHeight);
265
-
266
- // Calculate average brightness in scan area to detect presence of document
267
- // Documents typically have good contrast against backgrounds
268
- let totalBrightness = 0;
269
- let sampleCount = 0;
270
- const sampleStep = 20; // Sample every 20 pixels for performance
271
-
272
- // Sample brightness across the scan area
273
- for (let y = scanY; y < scanY + scanHeight; y += sampleStep) {
274
- for (let x = scanX; x < scanX + scanWidth; x += sampleStep) {
275
- const idx = y * frameWidth + x;
276
- if (idx >= 0 && idx < data.length) {
277
- totalBrightness += data[idx];
278
- sampleCount++;
279
- }
280
- }
281
- }
282
-
283
- const avgBrightness = sampleCount > 0 ? totalBrightness / sampleCount : 0;
284
-
285
- // Calculate standard deviation to measure contrast
286
- let variance = 0;
287
- for (let y = scanY; y < scanY + scanHeight; y += sampleStep) {
288
- for (let x = scanX; x < scanX + scanWidth; x += sampleStep) {
289
- const idx = y * frameWidth + x;
290
- if (idx >= 0 && idx < data.length) {
291
- const diff = data[idx] - avgBrightness;
292
- variance += diff * diff;
293
- }
294
- }
295
- }
296
- const stdDev = sampleCount > 0 ? Math.sqrt(variance / sampleCount) : 0;
297
-
298
- // Document is present if there's ANY reasonable content in scan area
299
- // Lower threshold: stdDev > 10 indicates some content (not blank surface)
300
- // Brightness between 20-240 covers most lighting conditions
301
- const documentPresent = stdDev > 10 && avgBrightness > 20 && avgBrightness < 240;
302
-
303
- if (!documentPresent) {
304
- return null;
305
- }
306
-
307
- // Default to ID_CARD since scan area matches ID card proportions
308
- // Passport detection would require actual contour detection
309
- const type: 'ID_CARD' | 'PASSPORT' | 'UNKNOWN' = 'ID_CARD';
310
- const confidence = Math.min(1, stdDev / 50);
311
-
312
- // Calculate how much of frame the document occupies
313
- const framePercentage = (scanWidth * scanHeight) / (frameWidth * frameHeight);
314
- const aspectRatio = scanWidth / scanHeight;
315
-
316
- // Determine size feedback based on contrast level
317
- // Higher contrast usually means document is closer/larger
318
- let size: 'TOO_SMALL' | 'TOO_LARGE' | 'GOOD' = 'GOOD';
319
- if (stdDev < 25) {
320
- size = 'TOO_SMALL'; // Low contrast - probably far away
321
- } else if (stdDev > 80) {
322
- size = 'TOO_LARGE'; // Very high contrast - probably too close
323
- }
324
-
325
- return {
326
- type,
327
- size,
328
- aspectRatio,
329
- confidence: Math.min(1, confidence),
330
- framePercentage,
331
- };
332
- };
333
-
334
- export {
335
- isBlurry,
336
- isFrameBright,
337
- getAverageBrightness,
338
- getCircularRegionBrightness,
339
- isCircularRegionBright,
340
- getRegionBrightness,
341
- calculateExposureStep,
342
- getScanAreaCenterPoint,
343
- detectDocumentInFrame,
344
- DOCUMENT_DIMENSIONS,
345
- };