@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
package/src/index.tsx CHANGED
@@ -2,6 +2,20 @@ import Trustchex from './Trustchex';
2
2
 
3
3
  export { handleDeepLink } from './Shared/Libs/deeplink.utils';
4
4
  export { analyticsService } from './Shared/Services/AnalyticsService';
5
+ export {
6
+ LogLevel,
7
+ setDebugMode,
8
+ setLogLevel,
9
+ isDebugEnabled,
10
+ getLogLevel,
11
+ traceLog,
12
+ debugLog,
13
+ infoLog,
14
+ debugWarn,
15
+ debugError,
16
+ logError,
17
+ logWarn,
18
+ } from './Shared/Libs/debug.utils';
5
19
  export {
6
20
  trackScreenView,
7
21
  trackScreenExit,
package/src/version.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  // This file is auto-generated. Do not edit manually.
2
2
  // Version is synced from package.json during build.
3
- export const SDK_VERSION = '1.355.1';
3
+ export const SDK_VERSION = '1.357.0';
@@ -1,301 +0,0 @@
1
- package com.trustchex.reactnativesdk.visioncameraplugins.barcodescanner
2
-
3
- import android.graphics.ImageFormat
4
- import android.media.Image
5
- import android.util.Log
6
- import com.google.android.gms.tasks.Tasks
7
- import com.google.mlkit.vision.barcode.BarcodeScanner
8
- import com.google.mlkit.vision.barcode.BarcodeScannerOptions
9
- import com.google.mlkit.vision.barcode.BarcodeScanning
10
- import com.google.mlkit.vision.barcode.common.Barcode
11
- import com.google.mlkit.vision.common.InputImage
12
- import com.mrousavy.camera.core.FrameInvalidError
13
- import com.mrousavy.camera.frameprocessors.Frame
14
- import com.mrousavy.camera.frameprocessors.FrameProcessorPlugin
15
- import com.mrousavy.camera.frameprocessors.VisionCameraProxy
16
- import java.util.concurrent.ExecutionException
17
- import java.util.concurrent.TimeUnit
18
-
19
- class BarcodeScannerFrameProcessorPlugin(
20
- @Suppress("UNUSED_PARAMETER") proxy: VisionCameraProxy,
21
- @Suppress("UNUSED_PARAMETER") options: Map<String, Any>?
22
- ) : FrameProcessorPlugin() {
23
-
24
- companion object {
25
- private const val TAG = "BarcodeScannerFrameProcessorPlugin"
26
- private var barcodeScanner: BarcodeScanner? = null
27
- private var previousBarcodeScannerFormatsBitmap = -1
28
- }
29
-
30
- override fun callback(frame: Frame, arguments: Map<String, Any>?): Any? {
31
- Log.d(TAG, "callback called - Frame size: ${frame.width}x${frame.height}")
32
-
33
- try {
34
- val mediaImage: Image = frame.image
35
-
36
- if (mediaImage.format != ImageFormat.YUV_420_888) {
37
- Log.e(TAG, "Unsupported image format: ${mediaImage.format}. Only YUV_420_888 is supported.")
38
- return emptyList<Map<String, Any>>()
39
- }
40
- } catch (e: FrameInvalidError) {
41
- Log.e(TAG, "Received an invalid frame.")
42
- return emptyList<Map<String, Any>>()
43
- }
44
-
45
- val inputImage = getInputImageFromFrame(frame)
46
- if (inputImage == null) {
47
- return emptyList<Map<String, Any>>()
48
- }
49
-
50
- val scanner = getBarcodeScannerClient(arguments)
51
- val barcodes = mutableListOf<Map<String, Any>>()
52
-
53
- try {
54
- val barcodeList = Tasks.await(scanner.process(inputImage), 1000, TimeUnit.MILLISECONDS)
55
- Log.d(TAG, "ML Kit returned ${barcodeList.size} barcodes")
56
-
57
- barcodeList.forEach { barcode ->
58
- Log.d(TAG, "Processing barcode: ${barcode.rawValue} (format: ${barcode.format})")
59
- barcodes.add(convertBarcode(barcode))
60
- }
61
- } catch (e: ExecutionException) {
62
- Log.e(TAG, "Error processing image for barcodes: ${e.message}")
63
- return emptyList<Map<String, Any>>()
64
- } catch (e: InterruptedException) {
65
- Log.e(TAG, "Error processing image for barcodes: ${e.message}")
66
- return emptyList<Map<String, Any>>()
67
- }
68
-
69
- Log.d(TAG, "Returning ${barcodes.size} processed barcodes")
70
- return barcodes
71
- }
72
-
73
- private fun getInputImageFromFrame(frame: Frame): InputImage? {
74
- return try {
75
- val mediaImage: Image = frame.image
76
- val orientation = getOrientation(frame.orientation)
77
- InputImage.fromMediaImage(mediaImage, orientation)
78
- } catch (e: FrameInvalidError) {
79
- Log.e(TAG, "Received an invalid frame.")
80
- null
81
- }
82
- }
83
-
84
- @Synchronized
85
- private fun getBarcodeScannerClient(arguments: Map<String, Any>?): BarcodeScanner {
86
- val formatsBitmap = getFormatsBitmapFromParams(arguments)
87
-
88
- if (barcodeScanner == null || previousBarcodeScannerFormatsBitmap != formatsBitmap) {
89
- previousBarcodeScannerFormatsBitmap = formatsBitmap
90
- val options = BarcodeScannerOptions.Builder().setBarcodeFormats(formatsBitmap).build()
91
- barcodeScanner = BarcodeScanning.getClient(options)
92
- }
93
-
94
- return barcodeScanner!!
95
- }
96
-
97
- private fun getFormatsBitmapFromParams(arguments: Map<String, Any>?): Int {
98
- if (arguments == null) return Barcode.FORMAT_ALL_FORMATS
99
-
100
- val barcodeFormats = mutableSetOf<Int>()
101
- val barcodeTypesObj = arguments["barcodeTypes"]
102
-
103
- if (barcodeTypesObj is List<*>) {
104
- barcodeTypesObj.forEach { type ->
105
- val format = getFormat(type as? String)
106
- if (format != null) {
107
- barcodeFormats.add(format)
108
- } else {
109
- Log.e(TAG, "Unsupported barcode type: $type")
110
- }
111
- }
112
- }
113
-
114
- return if (barcodeFormats.isEmpty()) {
115
- Barcode.FORMAT_ALL_FORMATS
116
- } else {
117
- barcodeFormatsToBitmap(barcodeFormats)
118
- }
119
- }
120
-
121
- private fun barcodeFormatsToBitmap(barcodeFormats: Set<Int>): Int {
122
- return barcodeFormats.fold(0) { acc, format -> acc or format }
123
- }
124
-
125
- private fun getFormat(type: String?): Int? {
126
- return when (type) {
127
- "code-128" -> Barcode.FORMAT_CODE_128
128
- "code-39" -> Barcode.FORMAT_CODE_39
129
- "code-93" -> Barcode.FORMAT_CODE_93
130
- "data-matrix" -> Barcode.FORMAT_DATA_MATRIX
131
- "ean-13" -> Barcode.FORMAT_EAN_13
132
- "ean-8" -> Barcode.FORMAT_EAN_8
133
- "upc-a" -> Barcode.FORMAT_UPC_A
134
- "upc-e" -> Barcode.FORMAT_UPC_E
135
- "qr" -> Barcode.FORMAT_QR_CODE
136
- "aztec" -> Barcode.FORMAT_AZTEC
137
- "codabar" -> Barcode.FORMAT_CODABAR
138
- "itf" -> Barcode.FORMAT_ITF
139
- "pdf-417" -> Barcode.FORMAT_PDF417
140
- else -> null
141
- }
142
- }
143
-
144
- private fun convertBarcode(barcode: Barcode): Map<String, Any> {
145
- val map = mutableMapOf<String, Any>()
146
-
147
- // Add the main value that JavaScript expects
148
- barcode.rawValue?.let {
149
- map["value"] = it
150
- Log.d(TAG, "Converting barcode with value: $it")
151
- }
152
-
153
- // Add bounding box in the format expected by JavaScript
154
- barcode.boundingBox?.let { bounds ->
155
- Log.d(TAG, "Barcode bounding box: left=${bounds.left}, top=${bounds.top}, right=${bounds.right}, bottom=${bounds.bottom}")
156
- val boundingBoxMap = mutableMapOf<String, Any>()
157
- // Convert Android Rect to JavaScript format (origin + size)
158
- val originMap = mutableMapOf<String, Any>()
159
- originMap["x"] = bounds.left
160
- originMap["y"] = bounds.top
161
- boundingBoxMap["origin"] = originMap
162
-
163
- val sizeMap = mutableMapOf<String, Any>()
164
- sizeMap["width"] = bounds.right - bounds.left
165
- sizeMap["height"] = bounds.bottom - bounds.top
166
- boundingBoxMap["size"] = sizeMap
167
-
168
- map["boundingBox"] = boundingBoxMap
169
- } ?: run {
170
- Log.d(TAG, "Barcode has no bounding box")
171
- }
172
-
173
- // Add corner points
174
- barcode.cornerPoints?.let { corners ->
175
- val cornerPointsList = mutableListOf<Map<String, Any>>()
176
- corners.forEach { point ->
177
- val pointMap = mutableMapOf<String, Any>()
178
- pointMap["x"] = point.x
179
- pointMap["y"] = point.y
180
- cornerPointsList.add(pointMap)
181
- }
182
- map["cornerPoints"] = cornerPointsList
183
- }
184
-
185
- // Add display value
186
- barcode.displayValue?.let { map["displayValue"] = it }
187
-
188
- // Add raw value
189
- barcode.rawValue?.let { map["rawValue"] = it }
190
-
191
- // Add value type and format
192
- map["type"] = barcode.valueType
193
- map["format"] = barcode.format
194
-
195
- // Add content based on value type
196
- map["content"] = convertContent(barcode)
197
-
198
- Log.d(TAG, "Converted barcode map keys: ${map.keys}")
199
- return map
200
- }
201
-
202
- private fun convertContent(barcode: Barcode): Map<String, Any> {
203
- val map = mutableMapOf<String, Any>()
204
- map["type"] = barcode.valueType
205
-
206
- when (barcode.valueType) {
207
- Barcode.TYPE_UNKNOWN, Barcode.TYPE_ISBN, Barcode.TYPE_TEXT -> {
208
- barcode.rawValue?.let { map["data"] = it }
209
- }
210
- Barcode.TYPE_CONTACT_INFO -> {
211
- barcode.contactInfo?.let { contactInfo ->
212
- val contactMap = mutableMapOf<String, Any>()
213
- contactInfo.name?.let { name ->
214
- val nameMap = mutableMapOf<String, Any>()
215
- name.first?.let { nameMap["first"] = it }
216
- name.formattedName?.let { nameMap["formattedName"] = it }
217
- name.last?.let { nameMap["last"] = it }
218
- name.middle?.let { nameMap["middle"] = it }
219
- name.prefix?.let { nameMap["prefix"] = it }
220
- name.pronunciation?.let { nameMap["pronunciation"] = it }
221
- name.suffix?.let { nameMap["suffix"] = it }
222
- contactMap["name"] = nameMap
223
- }
224
- contactInfo.organization?.let { contactMap["organization"] = it }
225
- contactInfo.title?.let { contactMap["title"] = it }
226
- // Add phones, emails, addresses if needed
227
- map["data"] = contactMap
228
- }
229
- }
230
- Barcode.TYPE_EMAIL -> {
231
- barcode.email?.let { email ->
232
- val emailMap = mutableMapOf<String, Any>()
233
- email.address?.let { emailMap["address"] = it }
234
- email.body?.let { emailMap["body"] = it }
235
- email.subject?.let { emailMap["subject"] = it }
236
- emailMap["type"] = email.type
237
- map["data"] = emailMap
238
- }
239
- }
240
- Barcode.TYPE_PHONE -> {
241
- barcode.phone?.let { phone ->
242
- val phoneMap = mutableMapOf<String, Any>()
243
- phone.number?.let { phoneMap["number"] = it }
244
- phoneMap["type"] = phone.type
245
- map["data"] = phoneMap
246
- }
247
- }
248
- Barcode.TYPE_SMS -> {
249
- barcode.sms?.let { sms ->
250
- val smsMap = mutableMapOf<String, Any>()
251
- sms.message?.let { smsMap["message"] = it }
252
- sms.phoneNumber?.let { smsMap["phoneNumber"] = it }
253
- map["data"] = smsMap
254
- }
255
- }
256
- Barcode.TYPE_URL -> {
257
- barcode.url?.let { url ->
258
- val urlMap = mutableMapOf<String, Any>()
259
- url.title?.let { urlMap["title"] = it }
260
- url.url?.let { urlMap["url"] = it }
261
- map["data"] = urlMap
262
- }
263
- }
264
- Barcode.TYPE_WIFI -> {
265
- barcode.wifi?.let { wifi ->
266
- val wifiMap = mutableMapOf<String, Any>()
267
- wifiMap["encryptionType"] = wifi.encryptionType
268
- wifi.password?.let { wifiMap["password"] = it }
269
- wifi.ssid?.let { wifiMap["ssid"] = it }
270
- map["data"] = wifiMap
271
- }
272
- }
273
- Barcode.TYPE_GEO -> {
274
- barcode.geoPoint?.let { geoPoint ->
275
- val geoMap = mutableMapOf<String, Any>()
276
- geoMap["lat"] = geoPoint.lat
277
- geoMap["lng"] = geoPoint.lng
278
- map["data"] = geoMap
279
- }
280
- }
281
- else -> {
282
- barcode.rawValue?.let { map["data"] = it }
283
- }
284
- }
285
-
286
- return map
287
- }
288
-
289
- private fun getOrientation(orientation: com.mrousavy.camera.core.types.Orientation): Int {
290
- return when (orientation) {
291
- // device is landscape left
292
- com.mrousavy.camera.core.types.Orientation.PORTRAIT -> 0
293
- // device is portrait
294
- com.mrousavy.camera.core.types.Orientation.LANDSCAPE_LEFT -> 270
295
- // device is landscape right
296
- com.mrousavy.camera.core.types.Orientation.PORTRAIT_UPSIDE_DOWN -> 180
297
- // device is upside-down
298
- com.mrousavy.camera.core.types.Orientation.LANDSCAPE_RIGHT -> 90
299
- }
300
- }
301
- }
@@ -1,205 +0,0 @@
1
- package com.trustchex.reactnativesdk.visioncameraplugins.cropper
2
-
3
- import android.annotation.TargetApi
4
- import android.graphics.*
5
- import android.media.Image
6
- import android.os.Build
7
- import android.util.Base64
8
- import android.util.Log
9
- import androidx.annotation.RequiresApi
10
- import com.mrousavy.camera.core.FrameInvalidError
11
- import com.mrousavy.camera.core.types.Orientation
12
- import com.mrousavy.camera.frameprocessors.Frame
13
- import java.io.ByteArrayOutputStream
14
- import java.io.File
15
- import java.io.FileOutputStream
16
- import java.nio.ByteBuffer
17
-
18
- /** Utility class for bitmap conversions and operations */
19
- object BitmapUtils {
20
- private const val TAG = "BitmapUtils"
21
-
22
- /** Converts NV21 format byte buffer to bitmap */
23
- fun getBitmap(data: ByteBuffer, metadata: FrameMetadata): Bitmap? {
24
- data.rewind()
25
- val imageInBuffer = ByteArray(data.limit())
26
- data.get(imageInBuffer, 0, imageInBuffer.size)
27
-
28
- return try {
29
- val image = YuvImage(imageInBuffer, ImageFormat.NV21, metadata.width, metadata.height, null)
30
- val stream = ByteArrayOutputStream()
31
- image.compressToJpeg(Rect(0, 0, metadata.width, metadata.height), 80, stream)
32
-
33
- val bmp = BitmapFactory.decodeByteArray(stream.toByteArray(), 0, stream.size())
34
- stream.close()
35
-
36
- rotateBitmap(bmp, metadata.rotation, false, false)
37
- } catch (e: Exception) {
38
- Log.e(TAG, "Error: ${e.message}")
39
- null
40
- }
41
- }
42
-
43
- /** Converts a YUV_420_888 image from Vision Camera API to a bitmap */
44
- @Throws(FrameInvalidError::class)
45
- fun getBitmap(image: Frame): Bitmap {
46
- val degree = getRotationDegreeFromOrientation(image.orientation)
47
- val frameMetadata = FrameMetadata(width = image.width, height = image.height, rotation = degree)
48
-
49
- val nv21Buffer = yuv420ThreePlanesToNV21(image.image.planes, image.width, image.height)
50
- return getBitmap(nv21Buffer, frameMetadata)
51
- ?: throw FrameInvalidError()
52
- }
53
-
54
- fun getRotationDegreeFromOrientation(orientation: Orientation): Int {
55
- return when (orientation) {
56
- Orientation.PORTRAIT -> 0
57
- Orientation.LANDSCAPE_LEFT -> 270
58
- Orientation.LANDSCAPE_RIGHT -> 90
59
- Orientation.PORTRAIT_UPSIDE_DOWN -> 180
60
- }
61
- }
62
-
63
- /** Rotates a bitmap if it is converted from a bytebuffer */
64
- fun rotateBitmap(bitmap: Bitmap, rotationDegrees: Int, flipX: Boolean, flipY: Boolean): Bitmap {
65
- val matrix = Matrix()
66
-
67
- // Rotate the image back to straight
68
- matrix.postRotate(rotationDegrees.toFloat())
69
-
70
- // Mirror the image along the X or Y axis
71
- matrix.postScale(if (flipX) -1.0f else 1.0f, if (flipY) -1.0f else 1.0f)
72
-
73
- val rotatedBitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.width, bitmap.height, matrix, true)
74
-
75
- // Recycle the old bitmap if it has changed
76
- if (rotatedBitmap != bitmap) {
77
- bitmap.recycle()
78
- }
79
-
80
- return rotatedBitmap
81
- }
82
-
83
- /** Converts YUV_420_888 to NV21 bytebuffer */
84
- @RequiresApi(Build.VERSION_CODES.KITKAT)
85
- private fun yuv420ThreePlanesToNV21(
86
- yuv420888planes: Array<Image.Plane>,
87
- width: Int,
88
- height: Int
89
- ): ByteBuffer {
90
- val imageSize = width * height
91
- val out = ByteArray(imageSize + 2 * (imageSize / 4))
92
-
93
- if (areUVPlanesNV21(yuv420888planes, width, height)) {
94
- // Copy the Y values
95
- yuv420888planes[0].buffer.get(out, 0, imageSize)
96
-
97
- val uBuffer = yuv420888planes[1].buffer
98
- val vBuffer = yuv420888planes[2].buffer
99
-
100
- // Get the first V value from the V buffer, since the U buffer does not contain it
101
- vBuffer.get(out, imageSize, 1)
102
- // Copy the first U value and the remaining VU values from the U buffer
103
- uBuffer.get(out, imageSize + 1, 2 * imageSize / 4 - 1)
104
- } else {
105
- // Fallback to copying the UV values one by one, which is slower but also works
106
- // Unpack Y
107
- unpackPlane(yuv420888planes[0], width, height, out, 0, 1)
108
- // Unpack U
109
- unpackPlane(yuv420888planes[1], width, height, out, imageSize + 1, 2)
110
- // Unpack V
111
- unpackPlane(yuv420888planes[2], width, height, out, imageSize, 2)
112
- }
113
-
114
- return ByteBuffer.wrap(out)
115
- }
116
-
117
- /** Checks if the UV plane buffers of a YUV_420_888 image are in the NV21 format */
118
- @RequiresApi(Build.VERSION_CODES.KITKAT)
119
- private fun areUVPlanesNV21(planes: Array<Image.Plane>, width: Int, height: Int): Boolean {
120
- val imageSize = width * height
121
-
122
- val uBuffer = planes[1].buffer
123
- val vBuffer = planes[2].buffer
124
-
125
- // Backup buffer properties
126
- val vBufferPosition = vBuffer.position()
127
- val uBufferLimit = uBuffer.limit()
128
-
129
- // Advance the V buffer by 1 byte, since the U buffer will not contain the first V value
130
- vBuffer.position(vBufferPosition + 1)
131
- // Chop off the last byte of the U buffer, since the V buffer will not contain the last U value
132
- uBuffer.limit(uBufferLimit - 1)
133
-
134
- // Check that the buffers are equal and have the expected number of elements
135
- val areNV21 =
136
- (vBuffer.remaining() == (2 * imageSize / 4 - 2)) && (vBuffer.compareTo(uBuffer) == 0)
137
-
138
- // Restore buffers to their initial state
139
- vBuffer.position(vBufferPosition)
140
- uBuffer.limit(uBufferLimit)
141
-
142
- return areNV21
143
- }
144
-
145
- /** Unpack an image plane into a byte array */
146
- @TargetApi(Build.VERSION_CODES.KITKAT)
147
- private fun unpackPlane(
148
- plane: Image.Plane,
149
- width: Int,
150
- height: Int,
151
- out: ByteArray,
152
- offset: Int,
153
- pixelStride: Int
154
- ) {
155
- val buffer = plane.buffer
156
- buffer.rewind()
157
-
158
- // Compute the size of the current plane
159
- // We assume that it has the aspect ratio as the original image
160
- val numRow = (buffer.limit() + plane.rowStride - 1) / plane.rowStride
161
- if (numRow == 0) {
162
- return
163
- }
164
- val scaleFactor = height / numRow
165
- val numCol = width / scaleFactor
166
-
167
- // Extract the data in the output buffer
168
- var outputPos = offset
169
- var rowStart = 0
170
- for (row in 0 until numRow) {
171
- var inputPos = rowStart
172
- for (col in 0 until numCol) {
173
- out[outputPos] = buffer.get(inputPos)
174
- outputPos += pixelStride
175
- inputPos += plane.pixelStride
176
- }
177
- rowStart += plane.rowStride
178
- }
179
- }
180
-
181
- fun base642Bitmap(base64: String): Bitmap {
182
- val decode = Base64.decode(base64, Base64.DEFAULT)
183
- return BitmapFactory.decodeByteArray(decode, 0, decode.size)
184
- }
185
-
186
- fun bitmap2Base64(bitmap: Bitmap): String {
187
- val outputStream = ByteArrayOutputStream()
188
- bitmap.compress(Bitmap.CompressFormat.JPEG, 100, outputStream)
189
- return Base64.encodeToString(outputStream.toByteArray(), Base64.DEFAULT)
190
- }
191
-
192
- fun saveImage(bmp: Bitmap, dir: File, fileName: String): String {
193
- val file = File(dir, fileName)
194
- return try {
195
- val fos = FileOutputStream(file)
196
- bmp.compress(Bitmap.CompressFormat.JPEG, 100, fos)
197
- fos.flush()
198
- fos.close()
199
- file.absolutePath
200
- } catch (e: Exception) {
201
- e.printStackTrace()
202
- ""
203
- }
204
- }
205
- }
@@ -1,72 +0,0 @@
1
- package com.trustchex.reactnativesdk.visioncameraplugins.cropper
2
-
3
- import android.graphics.Bitmap
4
- import android.util.Log
5
- import com.mrousavy.camera.frameprocessors.Frame
6
- import com.mrousavy.camera.frameprocessors.FrameProcessorPlugin
7
- import com.mrousavy.camera.frameprocessors.VisionCameraProxy
8
-
9
- class CropperPlugin(private val proxy: VisionCameraProxy, options: Map<String, Any>?) :
10
- FrameProcessorPlugin() {
11
-
12
- companion object {
13
- var frameTaken: Bitmap? = null
14
-
15
- fun getBitmap(): Bitmap? {
16
- return try {
17
- frameTaken
18
- } catch (e: Exception) {
19
- null
20
- }
21
- }
22
- }
23
-
24
- override fun callback(frame: Frame, arguments: Map<String, Any>?): HashMap<String, Any?>? {
25
- val result = HashMap<String, Any?>()
26
-
27
- try {
28
- var bitmap = BitmapUtils.getBitmap(frame)
29
-
30
- // Handle crop region if provided
31
- arguments?.get("cropRegion")?.let { cropRegionObj ->
32
- @Suppress("UNCHECKED_CAST")
33
- val cropRegion = cropRegionObj as? Map<String, Any> ?: return@let
34
- val left = ((cropRegion["left"] as? Double ?: 0.0) / 100.0 * bitmap.width).toInt()
35
- val top = ((cropRegion["top"] as? Double ?: 0.0) / 100.0 * bitmap.height).toInt()
36
- val width = ((cropRegion["width"] as? Double ?: 100.0) / 100.0 * bitmap.width).toInt()
37
- val height = ((cropRegion["height"] as? Double ?: 100.0) / 100.0 * bitmap.height).toInt()
38
-
39
- bitmap = Bitmap.createBitmap(bitmap, left, top, width, height, null, false)
40
- }
41
-
42
- // Include base64 if requested
43
- arguments?.get("includeImageBase64")?.let { includeBase64 ->
44
- if (includeBase64 as? Boolean == true) {
45
- result["base64"] = BitmapUtils.bitmap2Base64(bitmap)
46
- }
47
- }
48
-
49
- // Save bitmap in memory if requested
50
- arguments?.get("saveBitmap")?.let { saveBitmap ->
51
- if (saveBitmap as? Boolean == true) {
52
- frameTaken = bitmap
53
- }
54
- }
55
-
56
- // Save as file if requested
57
- arguments?.get("saveAsFile")?.let { saveAsFile ->
58
- if (saveAsFile as? Boolean == true) {
59
- val cacheDir = proxy.context.cacheDir
60
- val fileName = "${System.currentTimeMillis()}.jpg"
61
- val path = BitmapUtils.saveImage(bitmap, cacheDir, fileName)
62
- result["path"] = path
63
- }
64
- }
65
- } catch (e: Exception) {
66
- Log.e("Cropper", "Error processing frame: ${e.message}")
67
- throw RuntimeException(e)
68
- }
69
-
70
- return result
71
- }
72
- }
@@ -1,4 +0,0 @@
1
- package com.trustchex.reactnativesdk.visioncameraplugins.cropper
2
-
3
- /** Data class to hold frame metadata information */
4
- data class FrameMetadata(val width: Int, val height: Int, val rotation: Int)