@sanctum-key/react-native-sdk 1.0.6 → 1.0.8

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 (206) hide show
  1. package/README.md +3 -3
  2. package/android/build/.transforms/{f62cb96b2d1f78ca96ab35932dd530dc → c9d62bb333688ab562f51958998d5a48}/transformed/classes/classes_dex/classes.dex +0 -0
  3. package/android/build/generated/source/buildConfig/debug/kyc/{transfergratis → SanctumKey}/com/BuildConfig.java +2 -2
  4. package/android/build/intermediates/aapt_friendly_merged_manifests/debug/processDebugManifest/aapt/AndroidManifest.xml +1 -1
  5. package/android/build/intermediates/aapt_friendly_merged_manifests/debug/processDebugManifest/aapt/output-metadata.json +1 -1
  6. package/android/build/intermediates/compile_library_classes_jar/debug/bundleLibCompileToJarDebug/classes.jar +0 -0
  7. package/android/build/intermediates/compile_r_class_jar/debug/generateDebugRFile/R.jar +0 -0
  8. package/android/build/intermediates/incremental/debug/packageDebugResources/compile-file-map.properties +2 -2
  9. package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/kyc/SanctumKey/com/BuildConfig.class +0 -0
  10. package/android/build/intermediates/manifest_merge_blame_file/debug/processDebugManifest/manifest-merger-blame-debug-report.txt +1 -1
  11. package/android/build/intermediates/merged_manifest/debug/processDebugManifest/AndroidManifest.xml +1 -1
  12. package/android/build/intermediates/runtime_library_classes_jar/debug/bundleLibRuntimeToJarDebug/classes.jar +0 -0
  13. package/android/build/intermediates/symbol_list_with_package_name/debug/generateDebugRFile/package-aware-r.txt +1 -1
  14. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab +0 -0
  15. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab.values.at +0 -0
  16. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab +0 -0
  17. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.keystream +0 -0
  18. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.keystream.len +0 -0
  19. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab_i +0 -0
  20. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab +0 -0
  21. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.keystream +0 -0
  22. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.keystream.len +0 -0
  23. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab_i +0 -0
  24. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab +0 -0
  25. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.keystream +0 -0
  26. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.keystream.len +0 -0
  27. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab_i +0 -0
  28. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab +0 -0
  29. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.keystream +0 -0
  30. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.keystream.len +0 -0
  31. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.values.at +0 -0
  32. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab_i +0 -0
  33. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab +0 -0
  34. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab.values.at +0 -0
  35. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab +0 -0
  36. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab.values.at +0 -0
  37. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab +0 -0
  38. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.keystream +0 -0
  39. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.keystream.len +0 -0
  40. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab_i +0 -0
  41. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab +0 -0
  42. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.keystream +0 -0
  43. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.keystream.len +0 -0
  44. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.values.at +0 -0
  45. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab_i +0 -0
  46. package/android/build/kotlin/compileDebugKotlin/cacheable/last-build.bin +0 -0
  47. package/android/build/kotlin/compileDebugKotlin/local-state/build-history.bin +0 -0
  48. package/android/build/outputs/logs/manifest-merger-debug-report.txt +1 -1
  49. package/android/build/tmp/compileDebugJavaWithJavac/previous-compilation-data.bin +0 -0
  50. package/android/build/tmp/kotlin-classes/debug/kyc/SanctumKey/com/SanctumKeySdkModule$definition$1$5$1.class +0 -0
  51. package/android/build/tmp/kotlin-classes/debug/kyc/SanctumKey/com/SanctumKeySdkModule$definition$1$5$2.class +0 -0
  52. package/android/build/tmp/kotlin-classes/debug/kyc/{transfergratis/com/TransfergratisSdkModule$definition$lambda$5$$inlined$AsyncFunction$1.class → SanctumKey/com/SanctumKeySdkModule$definition$lambda$5$$inlined$AsyncFunction$1.class} +0 -0
  53. package/android/build/tmp/kotlin-classes/debug/kyc/{transfergratis/com/TransfergratisSdkModule$definition$lambda$5$$inlined$AsyncFunction$2.class → SanctumKey/com/SanctumKeySdkModule$definition$lambda$5$$inlined$AsyncFunction$2.class} +0 -0
  54. package/android/build/tmp/kotlin-classes/debug/kyc/{transfergratis/com/TransfergratisSdkModule$definition$lambda$5$$inlined$AsyncFunction$3.class → SanctumKey/com/SanctumKeySdkModule$definition$lambda$5$$inlined$AsyncFunction$3.class} +0 -0
  55. package/android/build/tmp/kotlin-classes/debug/kyc/{transfergratis/com/TransfergratisSdkModule$definition$lambda$5$$inlined$AsyncFunction$4.class → SanctumKey/com/SanctumKeySdkModule$definition$lambda$5$$inlined$AsyncFunction$4.class} +0 -0
  56. package/android/build/tmp/kotlin-classes/debug/kyc/{transfergratis/com/TransfergratisSdkModule$definition$lambda$5$$inlined$AsyncFunction$5.class → SanctumKey/com/SanctumKeySdkModule$definition$lambda$5$$inlined$AsyncFunction$5.class} +0 -0
  57. package/android/build/tmp/kotlin-classes/debug/kyc/{transfergratis/com/TransfergratisSdkModule$definition$lambda$5$$inlined$AsyncFunction$6.class → SanctumKey/com/SanctumKeySdkModule$definition$lambda$5$$inlined$AsyncFunction$6.class} +0 -0
  58. package/android/build/tmp/kotlin-classes/debug/kyc/{transfergratis/com/TransfergratisSdkModule$definition$lambda$5$$inlined$AsyncFunctionWithPromise$1.class → SanctumKey/com/SanctumKeySdkModule$definition$lambda$5$$inlined$AsyncFunctionWithPromise$1.class} +0 -0
  59. package/android/build/tmp/kotlin-classes/debug/kyc/{transfergratis/com/TransfergratisSdkModule$definition$lambda$5$$inlined$AsyncFunctionWithPromise$2.class → SanctumKey/com/SanctumKeySdkModule$definition$lambda$5$$inlined$AsyncFunctionWithPromise$2.class} +0 -0
  60. package/android/build/tmp/kotlin-classes/debug/kyc/{transfergratis/com/TransfergratisSdkModule$definition$lambda$5$$inlined$AsyncFunctionWithPromise$3.class → SanctumKey/com/SanctumKeySdkModule$definition$lambda$5$$inlined$AsyncFunctionWithPromise$3.class} +0 -0
  61. package/android/build/tmp/kotlin-classes/debug/kyc/{transfergratis/com/TransfergratisSdkModule$definition$lambda$5$$inlined$AsyncFunctionWithPromise$4.class → SanctumKey/com/SanctumKeySdkModule$definition$lambda$5$$inlined$AsyncFunctionWithPromise$4.class} +0 -0
  62. package/android/build/tmp/kotlin-classes/debug/kyc/SanctumKey/com/SanctumKeySdkModule$definition$lambda$5$$inlined$View$1.class +0 -0
  63. package/android/build/tmp/kotlin-classes/debug/kyc/{transfergratis/com/TransfergratisSdkModule$definition$lambda$5$lambda$4$$inlined$Prop$1.class → SanctumKey/com/SanctumKeySdkModule$definition$lambda$5$lambda$4$$inlined$Prop$1.class} +0 -0
  64. package/android/build/tmp/kotlin-classes/debug/kyc/{transfergratis/com/TransfergratisSdkModule$definition$lambda$5$lambda$4$$inlined$Prop$2.class → SanctumKey/com/SanctumKeySdkModule$definition$lambda$5$lambda$4$$inlined$Prop$2.class} +0 -0
  65. package/android/build/tmp/kotlin-classes/debug/kyc/{transfergratis/com/TransfergratisSdkModule.class → SanctumKey/com/SanctumKeySdkModule.class} +0 -0
  66. package/android/build/tmp/kotlin-classes/debug/kyc/{transfergratis/com/TransfergratisSdkView.class → SanctumKey/com/SanctumKeySdkView.class} +0 -0
  67. package/android/build.gradle +2 -2
  68. package/android/src/main/AndroidManifest.xml +1 -1
  69. package/android/src/main/java/kyc/transfergratis/com/TransfergratisSdkModule.kt +6 -6
  70. package/android/src/main/java/kyc/transfergratis/com/TransfergratisSdkView.kt +2 -2
  71. package/build/package.json +9 -7
  72. package/build/src/App.d.ts +2 -2
  73. package/build/src/App.d.ts.map +1 -1
  74. package/build/src/App.js +2 -2
  75. package/build/src/App.js.map +1 -1
  76. package/build/src/{TransfergratisSdk.types.d.ts → SanctumKeySdk.types.d.ts} +3 -3
  77. package/build/src/SanctumKeySdk.types.d.ts.map +1 -0
  78. package/build/src/SanctumKeySdk.types.js +2 -0
  79. package/build/src/SanctumKeySdk.types.js.map +1 -0
  80. package/build/src/{TransfergratisSdkModule.d.ts → SanctumKeySdkModule.d.ts} +4 -4
  81. package/build/src/SanctumKeySdkModule.d.ts.map +1 -0
  82. package/build/src/{TransfergratisSdkModule.js → SanctumKeySdkModule.js} +2 -2
  83. package/build/src/SanctumKeySdkModule.js.map +1 -0
  84. package/build/src/{TransfergratisSdkModule.web.d.ts → SanctumKeySdkModule.web.d.ts} +4 -4
  85. package/build/src/SanctumKeySdkModule.web.d.ts.map +1 -0
  86. package/build/src/{TransfergratisSdkModule.web.js → SanctumKeySdkModule.web.js} +3 -3
  87. package/build/src/SanctumKeySdkModule.web.js.map +1 -0
  88. package/build/src/SanctumKeySdkView.d.ts +4 -0
  89. package/build/src/SanctumKeySdkView.d.ts.map +1 -0
  90. package/build/src/SanctumKeySdkView.js +7 -0
  91. package/build/src/SanctumKeySdkView.js.map +1 -0
  92. package/build/src/SanctumKeySdkView.web.d.ts +4 -0
  93. package/build/src/SanctumKeySdkView.web.d.ts.map +1 -0
  94. package/build/src/{TransfergratisSdkView.web.js → SanctumKeySdkView.web.js} +2 -2
  95. package/build/src/SanctumKeySdkView.web.js.map +1 -0
  96. package/build/src/api/axios.js +2 -2
  97. package/build/src/api/axios.js.map +1 -1
  98. package/build/src/components/EnhancedCameraView.d.ts.map +1 -1
  99. package/build/src/components/EnhancedCameraView.js +107 -330
  100. package/build/src/components/EnhancedCameraView.js.map +1 -1
  101. package/build/src/components/KYCElements/EmailVerificationTemplate.d.ts.map +1 -1
  102. package/build/src/components/KYCElements/EmailVerificationTemplate.js +114 -15
  103. package/build/src/components/KYCElements/EmailVerificationTemplate.js.map +1 -1
  104. package/build/src/components/KYCElements/IDCardCapture.d.ts.map +1 -1
  105. package/build/src/components/KYCElements/IDCardCapture.js +166 -695
  106. package/build/src/components/KYCElements/IDCardCapture.js.map +1 -1
  107. package/build/src/components/KYCElements/PhoneVerificationTemplate.d.ts.map +1 -1
  108. package/build/src/components/KYCElements/PhoneVerificationTemplate.js +282 -40
  109. package/build/src/components/KYCElements/PhoneVerificationTemplate.js.map +1 -1
  110. package/build/src/components/KYCElements/SelfieCapture.d.ts +1 -1
  111. package/build/src/components/KYCElements/SelfieCapture.d.ts.map +1 -1
  112. package/build/src/components/KYCElements/SelfieCapture.js +130 -192
  113. package/build/src/components/KYCElements/SelfieCapture.js.map +1 -1
  114. package/build/src/components/KYCElements/SelfieCaptureTemplate.d.ts.map +1 -1
  115. package/build/src/components/KYCElements/SelfieCaptureTemplate.js +131 -433
  116. package/build/src/components/KYCElements/SelfieCaptureTemplate.js.map +1 -1
  117. package/build/src/components/NativeCameraView.js +1 -1
  118. package/build/src/components/NativeCameraView.js.map +1 -1
  119. package/build/src/components/OverLay/IdCard.d.ts +3 -2
  120. package/build/src/components/OverLay/IdCard.d.ts.map +1 -1
  121. package/build/src/components/OverLay/IdCard.js +149 -141
  122. package/build/src/components/OverLay/IdCard.js.map +1 -1
  123. package/build/src/components/OverLay/SelfieOverlay.d.ts +2 -1
  124. package/build/src/components/OverLay/SelfieOverlay.d.ts.map +1 -1
  125. package/build/src/components/OverLay/SelfieOverlay.js +37 -95
  126. package/build/src/components/OverLay/SelfieOverlay.js.map +1 -1
  127. package/build/src/components/OverLay/type.d.ts +1 -0
  128. package/build/src/components/OverLay/type.d.ts.map +1 -1
  129. package/build/src/components/OverLay/type.js.map +1 -1
  130. package/build/src/components/Svgs/scanningLine.d.ts +2 -1
  131. package/build/src/components/Svgs/scanningLine.d.ts.map +1 -1
  132. package/build/src/components/Svgs/scanningLine.js +55 -51
  133. package/build/src/components/Svgs/scanningLine.js.map +1 -1
  134. package/build/src/config/KYCConfig.js +1 -1
  135. package/build/src/config/KYCConfig.js.map +1 -1
  136. package/build/src/config/allowedDomains.js +6 -6
  137. package/build/src/config/allowedDomains.js.map +1 -1
  138. package/build/src/hooks/useTemplateKYCFlow.d.ts.map +1 -1
  139. package/build/src/hooks/useTemplateKYCFlow.js +37 -38
  140. package/build/src/hooks/useTemplateKYCFlow.js.map +1 -1
  141. package/build/src/index.d.ts +3 -3
  142. package/build/src/index.d.ts.map +1 -1
  143. package/build/src/index.js +3 -3
  144. package/build/src/index.js.map +1 -1
  145. package/build/src/modules/api/CardAuthentification.d.ts +0 -5
  146. package/build/src/modules/api/CardAuthentification.d.ts.map +1 -1
  147. package/build/src/modules/api/CardAuthentification.js +114 -116
  148. package/build/src/modules/api/CardAuthentification.js.map +1 -1
  149. package/build/src/modules/api/KYCService.d.ts +12 -1
  150. package/build/src/modules/api/KYCService.d.ts.map +1 -1
  151. package/build/src/modules/api/KYCService.js +102 -38
  152. package/build/src/modules/api/KYCService.js.map +1 -1
  153. package/build/src/modules/camera/NativeCameraModule.js +17 -17
  154. package/build/src/modules/camera/NativeCameraModule.js.map +1 -1
  155. package/expo-module.config.json +2 -2
  156. package/ios/TransfergratisSdk.podspec +2 -2
  157. package/ios/TransfergratisSdkModule.swift +12 -12
  158. package/package.json +9 -7
  159. package/src/App.tsx +2 -2
  160. package/src/{TransfergratisSdk.types.ts → SanctumKeySdk.types.ts} +2 -2
  161. package/src/{TransfergratisSdkModule.ts → SanctumKeySdkModule.ts} +3 -3
  162. package/src/{TransfergratisSdkModule.web.ts → SanctumKeySdkModule.web.ts} +3 -3
  163. package/src/SanctumKeySdkView.tsx +11 -0
  164. package/src/{TransfergratisSdkView.web.tsx → SanctumKeySdkView.web.tsx} +2 -2
  165. package/src/api/axios.ts +2 -2
  166. package/src/components/EnhancedCameraView.tsx +131 -385
  167. package/src/components/KYCElements/EmailVerificationTemplate.tsx +141 -26
  168. package/src/components/KYCElements/IDCardCapture.tsx +228 -868
  169. package/src/components/KYCElements/PhoneVerificationTemplate.tsx +342 -60
  170. package/src/components/KYCElements/SelfieCapture.tsx +184 -213
  171. package/src/components/KYCElements/SelfieCaptureTemplate.tsx +330 -662
  172. package/src/components/NativeCameraView.tsx +1 -1
  173. package/src/components/OverLay/IdCard.tsx +218 -217
  174. package/src/components/OverLay/SelfieOverlay.tsx +56 -134
  175. package/src/components/OverLay/type.ts +1 -0
  176. package/src/components/Svgs/scanningLine.tsx +71 -72
  177. package/src/config/KYCConfig.ts +1 -1
  178. package/src/config/allowedDomains.ts +6 -6
  179. package/src/hooks/useTemplateKYCFlow.tsx +45 -39
  180. package/src/i18n/README.md +1 -1
  181. package/src/index.ts +3 -3
  182. package/src/modules/api/CardAuthentification.ts +202 -200
  183. package/src/modules/api/KYCService.ts +169 -53
  184. package/src/modules/camera/NativeCameraModule.ts +17 -17
  185. package/android/build/tmp/kotlin-classes/debug/kyc/transfergratis/com/TransfergratisSdkModule$definition$1$5$1.class +0 -0
  186. package/android/build/tmp/kotlin-classes/debug/kyc/transfergratis/com/TransfergratisSdkModule$definition$1$5$2.class +0 -0
  187. package/android/build/tmp/kotlin-classes/debug/kyc/transfergratis/com/TransfergratisSdkModule$definition$lambda$5$$inlined$View$1.class +0 -0
  188. package/build/src/TransfergratisSdk.types.d.ts.map +0 -1
  189. package/build/src/TransfergratisSdk.types.js +0 -2
  190. package/build/src/TransfergratisSdk.types.js.map +0 -1
  191. package/build/src/TransfergratisSdkModule.d.ts.map +0 -1
  192. package/build/src/TransfergratisSdkModule.js.map +0 -1
  193. package/build/src/TransfergratisSdkModule.web.d.ts.map +0 -1
  194. package/build/src/TransfergratisSdkModule.web.js.map +0 -1
  195. package/build/src/TransfergratisSdkView.d.ts +0 -4
  196. package/build/src/TransfergratisSdkView.d.ts.map +0 -1
  197. package/build/src/TransfergratisSdkView.js +0 -7
  198. package/build/src/TransfergratisSdkView.js.map +0 -1
  199. package/build/src/TransfergratisSdkView.web.d.ts +0 -4
  200. package/build/src/TransfergratisSdkView.web.d.ts.map +0 -1
  201. package/build/src/TransfergratisSdkView.web.js.map +0 -1
  202. package/src/TransfergratisSdkView.tsx +0 -11
  203. /package/android/build/.transforms/{532c0e65d82f446633d0a7dab2772198 → ab90740579f5bd05b27b4343ada2d1c9}/results.bin +0 -0
  204. /package/android/build/.transforms/{532c0e65d82f446633d0a7dab2772198 → ab90740579f5bd05b27b4343ada2d1c9}/transformed/classes/classes_dex/classes.dex +0 -0
  205. /package/android/build/.transforms/{f62cb96b2d1f78ca96ab35932dd530dc → c9d62bb333688ab562f51958998d5a48}/results.bin +0 -0
  206. /package/android/build/{intermediates/javac/debug/compileDebugJavaWithJavac/classes/kyc/transfergratis/com/BuildConfig.class → tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/BuildConfig.class.uniqueId0} +0 -0
@@ -0,0 +1,11 @@
1
+ import { requireNativeView } from 'expo';
2
+ import * as React from 'react';
3
+
4
+ import { SanctumKeySdkViewProps } from './SanctumKeySdk.types';
5
+
6
+ const NativeView: React.ComponentType<SanctumKeySdkViewProps> =
7
+ requireNativeView('SanctumKeySdk');
8
+
9
+ export default function SanctumKeySdkView(props: SanctumKeySdkViewProps) {
10
+ return <NativeView {...props} />;
11
+ }
@@ -1,8 +1,8 @@
1
1
  import * as React from 'react';
2
2
 
3
- import { TransfergratisSdkViewProps } from './TransfergratisSdk.types';
3
+ import { SanctumKeySdkViewProps } from './SanctumKeySdk.types';
4
4
 
5
- export default function TransfergratisSdkView(props: TransfergratisSdkViewProps) {
5
+ export default function SanctumKeySdkView(props: SanctumKeySdkViewProps) {
6
6
  return (
7
7
  <div>
8
8
  {/* <iframe
package/src/api/axios.ts CHANGED
@@ -132,12 +132,12 @@ export default HttpClient;
132
132
 
133
133
  // ml service api
134
134
  export const mlService = new HttpClient({
135
- baseURL: 'https://api.ml.transfergratis.com',
135
+ baseURL: 'https://api.ml.SanctumKey.com',
136
136
  apiKey: 'your-api-key',
137
137
  });
138
138
  // backedn service api
139
139
  export const backendService = new HttpClient({
140
- baseURL: 'https://api.backend.transfergratis.com',
140
+ baseURL: 'https://api.backend.SanctumKey.com',
141
141
  apiKey: 'your-api-key',
142
142
  });
143
143
 
@@ -1,482 +1,228 @@
1
- import React, { useCallback, useEffect, useRef, useState, useMemo } from 'react';
2
- import { View, StyleSheet, TouchableOpacity, Text } from 'react-native';
1
+ import React, { useCallback, useEffect, useRef, useState } from 'react';
2
+ import { View, StyleSheet, Text, AppState, ActivityIndicator } from 'react-native';
3
3
  import { Camera, useCameraDevice } from 'react-native-vision-camera';
4
4
  import VisionCameraModule from '../modules/camera/VisionCameraModule';
5
5
  import { useI18n } from '../hooks/useI18n';
6
6
  import { EnhancedCameraViewProps } from './OverLay/type';
7
7
  import { Button } from './ui/Button';
8
8
 
9
-
10
-
11
-
12
- export const EnhancedCameraView: React.FC<EnhancedCameraViewProps> = ({
9
+ export const EnhancedCameraView: React.FC<EnhancedCameraViewProps> = ({
13
10
  showCamera,
14
11
  cameraType: initialCameraType = 'front',
15
12
  style,
16
- onCapture,
17
13
  onError,
18
- onClose,
19
- enableFlash = false,
20
- enableHdr = false,
21
- quality = 'high',
22
- showCaptureButton = true,
23
- showSwitchCamera = true,
24
- overlayComponent,
25
- bbox,
26
- canFlip = true,
27
- enableVideo = false,
28
- isRecording = false,
29
- onVideoRecordingStart,
30
- onVideoRecordingStop,
31
- videoDuration = 10,
32
14
  onSilentCapture,
33
15
  silentCaptureResult,
16
+ isProcessing = false,
17
+ overlayComponent,
34
18
  }) => {
35
19
  const { t } = useI18n();
36
20
  const camera = useRef<Camera>(null);
37
- const [cameraType, setCameraType] = useState<'front' | 'back'>(initialCameraType);
38
- const [hasPermission, setHasPermission] = useState(false);
21
+
22
+ const isCapturingRef = useRef(false);
23
+ const isProcessingRef = useRef(isProcessing);
24
+
25
+ const [cameraType] = useState<'front' | 'back'>(initialCameraType);
26
+
27
+ const [hasPermission, setHasPermission] = useState<boolean | null>(null);
39
28
  const [isInitialized, setIsInitialized] = useState(false);
40
- const [flash, setFlash] = useState<'off' | 'on' | 'auto'>('off');
41
29
  const [refreshCamera, setRefreshCamera] = useState(false);
30
+
31
+ // 🚨 ADDED: A timeout state to show a refresh button if the camera gets stuck booting
32
+ const [showInitTimeout, setShowInitTimeout] = useState(false);
42
33
 
43
34
  const device = useCameraDevice(cameraType);
44
- console.log({ setCameraType, setFlash });
45
35
 
46
- // Sélectionner le meilleur format disponible pour une qualité maximale
47
- // Prioriser les formats avec une bonne résolution vidéo (pour la prévisualisation) ET photo (pour la capture)
48
- const bestFormat = useMemo(() => {
49
- if (!device || !device.formats || device.formats.length === 0) {
50
- return undefined;
51
- }
52
-
53
- // Trier les formats en combinant la résolution vidéo (pour la prévisualisation) et photo (pour la capture)
54
- // On priorise les formats avec une bonne résolution vidéo car c'est ce qui est affiché en temps réel
55
- const sortedFormats = [...device.formats].sort((a, b) => {
56
- // Résolution vidéo (pour la prévisualisation live)
57
- const videoResolutionA = (a.videoWidth || 0) * (a.videoHeight || 0);
58
- const videoResolutionB = (b.videoWidth || 0) * (b.videoHeight || 0);
59
-
60
- // Résolution photo (pour la capture)
61
- const photoResolutionA = (a.photoWidth || 0) * (a.photoHeight || 0);
62
- const photoResolutionB = (b.photoWidth || 0) * (b.photoHeight || 0);
63
-
64
- // Prioriser d'abord la résolution vidéo (prévisualisation), puis la résolution photo
65
- if (videoResolutionB !== videoResolutionA) {
66
- return videoResolutionB - videoResolutionA;
67
- }
68
- return photoResolutionB - photoResolutionA;
69
- });
70
-
71
- return sortedFormats[0];
72
- }, [device]);
36
+ useEffect(() => {
37
+ isProcessingRef.current = isProcessing;
38
+ }, [isProcessing]);
73
39
 
74
40
  const checkPermissions = async () => {
75
41
  try {
76
42
  const hasAllPermissions = await VisionCameraModule.hasAllPermissions();
77
- console.log('hasAllPermissions', hasAllPermissions);
78
43
  if (!hasAllPermissions) {
79
44
  const granted = await VisionCameraModule.requestAllPermissions();
80
- console.log('granted', granted);
81
45
  if (!granted) {
82
- console.log('permissionRequired', t('camera.permissionRequired'));
46
+ setHasPermission(false);
83
47
  onError?.({ message: t('camera.permissionRequired') });
84
48
  return;
85
49
  }
86
50
  }
87
51
  setHasPermission(true);
88
52
  } catch (error) {
89
- console.error('Error checking permissions:', error);
53
+ setHasPermission(false);
90
54
  onError?.({ message: t('camera.errorOccurred') });
91
55
  }
92
56
  };
93
57
 
94
- // Check permissions on component mount
95
58
  useEffect(() => {
96
59
  if (showCamera) {
60
+ setIsInitialized(false); // Reset init state when checking permissions/refreshing
97
61
  checkPermissions();
98
62
  }
99
63
  }, [showCamera, refreshCamera]);
100
64
 
65
+ useEffect(() => {
66
+ const subscription = AppState.addEventListener('change', nextAppState => {
67
+ if (nextAppState === 'active' && showCamera && hasPermission === false) {
68
+ checkPermissions();
69
+ }
70
+ });
71
+ return () => subscription.remove();
72
+ }, [showCamera, hasPermission]);
73
+
74
+
75
+ useEffect(() => {
76
+ let timer: ReturnType<typeof setTimeout>;
77
+
78
+ if (hasPermission && device && showCamera && !isInitialized) {
79
+ timer = setTimeout(() => setShowInitTimeout(true), 3000);
80
+ } else {
81
+ setShowInitTimeout(false);
82
+ }
101
83
 
84
+ return () => {
85
+ if (timer) clearTimeout(timer);
86
+ };
87
+ }, [hasPermission, device, showCamera, isInitialized]);
102
88
 
103
89
  const onInitialized = useCallback(() => {
104
- console.log('Camera initialized!');
105
90
  setIsInitialized(true);
91
+ setShowInitTimeout(false);
106
92
  }, []);
107
93
 
108
94
  const onCameraError = useCallback((error: any) => {
109
- console.error('Camera error:', error);
110
95
  onError?.({ message: error.message || t('camera.errorOccurred') });
111
96
  }, [onError, t]);
112
97
 
113
98
  const captureSilentPhoto = useCallback(async () => {
114
- if (!camera.current || !isInitialized) {
115
- onError?.({ message: t('camera.notReady') });
116
- return;
117
- }
118
- console.log('silentCaptureResult', silentCaptureResult);
119
- if (silentCaptureResult?.isAnalyzing || silentCaptureResult?.success) {
120
- return;
121
- }
99
+ if (!camera.current || !isInitialized || isProcessingRef.current || isCapturingRef.current) return;
100
+ if (silentCaptureResult?.isAnalyzing) return;
101
+
122
102
  try {
103
+ isCapturingRef.current = true;
123
104
  const photo = await camera.current.takePhoto({
124
- enableShutterSound: true,
125
- flash: enableFlash ? flash : 'off',
105
+ enableShutterSound: false,
106
+ flash: 'off',
126
107
  });
127
-
128
108
  const result = await VisionCameraModule.processPhotoResult(photo);
129
- onSilentCapture?.(result);
130
- } catch (error) {
131
-
132
- }
133
- }, [isInitialized, onError, onSilentCapture, enableFlash, flash, silentCaptureResult]);
134
-
135
- // Automatically take a silent photo every 5 seconds when ready
136
- useEffect(() => {
137
- if (!showCamera || !isInitialized) {
138
- return;
139
- }
140
-
141
- const intervalId = setInterval(() => {
142
- captureSilentPhoto();
143
- }, 2500);
144
-
145
- return () => clearInterval(intervalId);
146
- }, [showCamera, isInitialized, captureSilentPhoto]);
147
-
148
- const capturePhoto = useCallback(async () => {
149
- try {
150
- if (!camera.current || !isInitialized) {
151
- onError?.({ message: t('camera.notReady') });
152
- return;
153
- }
154
- if (silentCaptureResult?.success) {
155
- onCapture?.({
156
- success: true,
157
- path: silentCaptureResult.path,
158
- });
159
- return;
160
- }
161
109
 
162
- const photo = await camera.current.takePhoto({
163
- enableShutterSound: true,
164
- flash: enableFlash ? flash : 'off',
110
+ onSilentCapture?.({
111
+ ...result,
112
+ path: result.path || photo.path,
165
113
  });
166
-
167
- const result = await VisionCameraModule.processPhotoResult(photo);
168
- onCapture?.(result);
169
114
  } catch (error) {
170
- console.error('Error taking photo:', error);
171
- onCapture?.({
172
- success: false,
173
- error: error instanceof Error ? error.message : t('camera.failedToCapture'),
174
- });
115
+ // Silent background fail
116
+ } finally {
117
+ isCapturingRef.current = false;
175
118
  }
176
- }, [isInitialized, quality, flash, enableFlash, onCapture, onError]);
119
+ }, [isInitialized, onSilentCapture, silentCaptureResult]);
177
120
 
178
- const startVideoRecording = useCallback(async () => {
179
- try {
180
- if (!camera.current || !isInitialized) {
181
- onError?.({ message: t('camera.notReady') });
182
- return;
183
- }
121
+ useEffect(() => {
122
+ if (!showCamera || !isInitialized || isProcessing) return;
184
123
 
185
- await camera.current.startRecording({
186
- onRecordingFinished: (video: any) => {
187
- onVideoRecordingStop?.({
188
- success: true,
189
- path: video.path,
190
- });
191
- },
192
- onRecordingError: (error: any) => {
193
- console.error('Recording error:', error);
194
- onVideoRecordingStop?.({
195
- success: false,
196
- error: error.message || t('camera.failedToStartRecording'),
197
- });
198
- },
199
- });
124
+ let isActive = true;
125
+ let intervalId: ReturnType<typeof setInterval>;
200
126
 
201
- onVideoRecordingStart?.();
202
- } catch (error) {
203
- console.error('Error starting video recording:', error);
204
- onVideoRecordingStop?.({
205
- success: false,
206
- error: error instanceof Error ? error.message : t('camera.failedToStartRecording'),
207
- });
208
- }
209
- }, [isInitialized, onVideoRecordingStart, onVideoRecordingStop, onError]);
127
+ const warmupTimer = setTimeout(() => {
128
+ if (!isActive) return;
129
+ intervalId = setInterval(() => {
130
+ captureSilentPhoto();
131
+ }, 1500);
132
+ }, 1000);
210
133
 
211
- const stopVideoRecording = useCallback(async () => {
212
- try {
213
- if (!camera.current) {
214
- onError?.({ message: t('camera.notReady') });
215
- return;
216
- }
134
+ return () => {
135
+ isActive = false;
136
+ clearTimeout(warmupTimer);
137
+ if (intervalId) clearInterval(intervalId);
138
+ };
139
+ }, [showCamera, isInitialized, isProcessing, captureSilentPhoto]);
217
140
 
218
- await camera.current.stopRecording();
219
- } catch (error) {
220
- console.error('Error stopping video recording:', error);
221
- onError?.({ message: t('camera.failedToStopRecording') });
222
- }
223
- }, [onError]);
141
+ // --- RENDERERS ---
224
142
 
225
- // const switchCamera = useCallback(() => {
226
- // setCameraType(current => current === 'front' ? 'back' : 'front');
227
- // }, []);
228
-
229
- // const toggleFlash = useCallback(() => {
230
- // setFlash(current => {
231
- // switch (current) {
232
- // case 'off': return 'on';
233
- // case 'on': return 'auto';
234
- // case 'auto': return 'off';
235
- // default: return 'off';
236
- // }
237
- // });
238
- // }, []);
143
+ if (hasPermission === null) {
144
+ return <View style={[styles.container, style]} />;
145
+ }
239
146
 
240
- if (!hasPermission) {
147
+ if (hasPermission === false) {
241
148
  return (
242
- <View style={[styles.container, style]}>
243
- <Text style={styles.permissionMessage}>
244
- {t('camera.permissionRequired')}
245
- </Text>
246
- <Button title="Refresh Camera" onPress={() => setRefreshCamera(!refreshCamera)} />
149
+ <View style={[styles.container, style, styles.centerContent]}>
150
+ <Text style={styles.permissionMessage}>{t('camera.permissionRequired')}</Text>
151
+ <Button
152
+ title="Refresh Camera"
153
+ onPress={() => setRefreshCamera(prev => !prev)}
154
+ variant="primary"
155
+ />
247
156
  </View>
248
157
  );
249
158
  }
250
159
 
251
- if (!device) {
160
+ // 🚨 FIX: Don't return an invisible blank screen if the device is loading!
161
+ // Give them a UI and a way out.
162
+ if (!device || !showCamera) {
252
163
  return (
253
- <View style={[styles.container, style]}>
254
- <Text style={styles.errorMessage}>
255
- {t('camera.deviceNotAvailable')}
256
- </Text>
257
- </View>
164
+ <View style={[styles.container, style, styles.centerContent]}>
165
+ <ActivityIndicator size="large" color="#2DBD60" style={{ marginBottom: 16 }} />
166
+ <Text style={styles.permissionMessage}>Loading Camera Hardware...</Text>
167
+ <Button
168
+ title="Refresh"
169
+ onPress={() => setRefreshCamera(prev => !prev)}
170
+ variant="outline"
171
+ />
172
+ </View>
258
173
  );
259
174
  }
260
175
 
261
- if (!showCamera) {
262
- return <View style={[styles.container, style]} />;
263
- }
264
-
265
176
  return (
266
177
  <View style={[styles.container, style]}>
267
178
  <Camera
179
+ // 🚨 FIX: This key forces the native component to completely remount
180
+ // when permissions are granted or when manually refreshed.
181
+ key={`cam-${hasPermission}-${refreshCamera ? '1' : '0'}`}
268
182
  ref={camera}
269
183
  style={StyleSheet.absoluteFill}
270
184
  device={device}
271
- isActive={showCamera}
185
+ isActive={showCamera && !isProcessing}
272
186
  photo={true}
273
- video={enableVideo}
274
- audio={enableVideo}
275
- format={bestFormat}
187
+ video={false}
188
+ audio={false}
276
189
  onInitialized={onInitialized}
277
190
  onError={onCameraError}
278
191
  />
279
-
280
- {/* Instructions */}
281
- {/* {instructions && (
282
- <View style={styles.instructionsOverlay}>
283
- <Text style={styles.instructions}>{instructions}</Text>
192
+
193
+ {/* 🚨 FIX: Floating Refresh Button if the hardware freezes on a black screen */}
194
+ {!isInitialized && showInitTimeout && (
195
+ <View style={styles.stuckOverlay}>
196
+ <ActivityIndicator size="large" color="#2DBD60" style={{ marginBottom: 16 }} />
197
+ <Text style={{ color: 'white', marginBottom: 16, fontWeight: 'bold' }}>
198
+ Camera is taking a while to start...
199
+ </Text>
200
+ <Button
201
+ title="Restart Camera"
202
+ onPress={() => {
203
+ setIsInitialized(false);
204
+ setRefreshCamera(prev => !prev);
205
+ }}
206
+ variant="primary"
207
+ />
284
208
  </View>
285
- )} */}
286
-
287
- {/* Custom overlay component */}
288
- {overlayComponent}
289
-
290
- {/* Bounding box overlay */}
291
- {bbox && (
292
- <View style={styles.bboxOverlay}>
293
- <View
294
- style={[
295
- styles.bbox,
296
- {
297
- left: `${bbox.xMin}%`,
298
- top: `${bbox.yMin}%`,
299
- width: `${bbox.xMax - bbox.xMin}%`,
300
- height: `${bbox.yMax - bbox.yMin}%`,
301
- borderColor: bbox.borderColor || '#2DBD60',
302
- borderWidth: bbox.borderWidth || 3,
303
- borderRadius: bbox.cornerRadius || 8,
304
- }
305
- ]}
306
- />
307
- </View>
308
209
  )}
309
210
 
310
-
311
- {/* Camera controls */}
312
- <View style={styles.controlsContainer}>
313
- {/* Flash button */}
314
- {/* {enableFlash && (
315
- <TouchableOpacity style={styles.controlButton} onPress={toggleFlash}>
316
- <Text style={styles.controlButtonText}>
317
- {flash === 'off' ? '⚡' : flash === 'on' ? '⚡️' : '✨'}
318
- </Text>
319
- </TouchableOpacity>
320
- )} */}
321
-
322
- {/* Capture button */}
323
- {showCaptureButton && !enableVideo && silentCaptureResult?.success && (
324
- <TouchableOpacity
325
- style={styles.captureButton}
326
- onPress={capturePhoto}
327
- disabled={!isInitialized}
328
- >
329
- <View style={[
330
- styles.captureButtonInner,
331
- !isInitialized && styles.captureButtonDisabled
332
- ]} />
333
- </TouchableOpacity>
334
- )}
335
-
336
- {/* Video recording button */}
337
- {showCaptureButton && enableVideo && silentCaptureResult?.success && (
338
- <TouchableOpacity
339
- style={[
340
- styles.captureButton,
341
- isRecording && styles.recordingButton
342
- ]}
343
- onPress={isRecording ? stopVideoRecording : startVideoRecording}
344
- disabled={!isInitialized}
345
- >
346
- <View style={[
347
- styles.captureButtonInner,
348
- !isInitialized && styles.captureButtonDisabled,
349
- isRecording && styles.recordingButtonInner
350
- ]} />
351
- </TouchableOpacity>
352
- )}
353
-
354
- {/* Switch camera button */}
355
- {/* {showSwitchCamera && canFlip && (
356
- <TouchableOpacity style={styles.controlButton} onPress={switchCamera}>
357
- <Text style={styles.controlButtonText}>🔄</Text>
358
- </TouchableOpacity>
359
- )} */}
360
-
361
- {silentCaptureResult?.isAnalyzing && (
362
- <View style={{ backgroundColor: 'rgba(0, 0, 0, 0.7)', padding: 10, borderRadius: 10 }}>
363
- <Text style={{ color: 'white', fontSize: 16, fontWeight: 'bold' }}>{t('camera.analyzing')}</Text>
364
- </View>
365
- )}
366
- </View>
211
+ {overlayComponent}
367
212
  </View>
368
213
  );
369
214
  };
370
215
 
371
216
  const styles = StyleSheet.create({
372
- container: {
373
- flex: 1,
374
- backgroundColor: 'black',
375
- },
376
- instructionsOverlay: {
377
- position: 'absolute',
378
- top: 60,
379
- left: 20,
380
- right: 20,
381
- backgroundColor: 'rgba(0, 0, 0, 0.7)',
382
- padding: 15,
383
- // borderRadius: 10,
384
- zIndex: 1,
385
- },
386
- instructions: {
387
- color: 'white',
388
- fontSize: 16,
389
- textAlign: 'center',
390
- fontWeight: '500',
391
- },
392
- closeButton: {
393
- position: 'absolute',
394
- top: 50,
395
- right: 20,
396
- backgroundColor: 'rgba(0, 0, 0, 0.7)',
397
- width: 40,
398
- height: 40,
399
- borderRadius: 20,
400
- justifyContent: 'center',
401
- alignItems: 'center',
402
- zIndex: 2,
403
- },
404
- closeButtonText: {
405
- color: 'white',
406
- fontSize: 20,
407
- fontWeight: 'bold',
408
- },
409
- controlsContainer: {
410
- position: 'absolute',
411
- bottom: 40,
412
- left: 0,
413
- right: 0,
414
- flexDirection: 'row',
415
- justifyContent: 'space-around',
416
- alignItems: 'center',
417
- paddingHorizontal: 40,
418
- zIndex: 1,
419
- },
420
- controlButton: {
421
- backgroundColor: 'rgba(0, 0, 0, 0.7)',
422
- width: 50,
423
- height: 50,
424
- borderRadius: 25,
425
- justifyContent: 'center',
426
- alignItems: 'center',
427
- },
428
- controlButtonText: {
429
- fontSize: 24,
430
- },
431
- captureButton: {
432
- backgroundColor: 'rgba(255, 255, 255, 0.3)',
433
- width: 80,
434
- height: 80,
435
- borderRadius: 40,
436
- justifyContent: 'center',
437
- alignItems: 'center',
438
- borderWidth: 3,
439
- borderColor: 'white',
440
- },
441
- captureButtonInner: {
442
- backgroundColor: 'white',
443
- width: 60,
444
- height: 60,
445
- borderRadius: 30,
446
- },
447
- captureButtonDisabled: {
448
- backgroundColor: 'rgba(255, 255, 255, 0.5)',
449
- },
450
- recordingButton: {
451
- backgroundColor: 'rgba(255, 59, 48, 0.3)',
452
- borderColor: '#FF3B30',
453
- },
454
- recordingButtonInner: {
455
- backgroundColor: '#FF3B30',
456
- },
457
- permissionMessage: {
458
- color: 'white',
459
- fontSize: 16,
460
- textAlign: 'center',
461
- margin: 20,
462
- },
463
- errorMessage: {
464
- color: 'red',
465
- fontSize: 16,
466
- textAlign: 'center',
467
- margin: 20,
468
- },
469
- bboxOverlay: {
470
- position: 'absolute',
471
- top: 0,
472
- left: 0,
473
- right: 0,
474
- bottom: 0,
475
- pointerEvents: 'none',
476
- },
477
- bbox: {
478
- position: 'absolute',
479
- borderStyle: 'solid',
480
- backgroundColor: 'transparent',
481
- },
217
+ container: { flex: 1, backgroundColor: 'black' },
218
+ centerContent: { justifyContent: 'center', alignItems: 'center', padding: 20 },
219
+ permissionMessage: { color: 'white', textAlign: 'center', marginBottom: 20, fontSize: 16, fontWeight: '600' },
220
+ stuckOverlay: {
221
+ ...StyleSheet.absoluteFillObject,
222
+ justifyContent: 'center',
223
+ alignItems: 'center',
224
+ backgroundColor: 'rgba(0,0,0,0.85)',
225
+ zIndex: 1000,
226
+ padding: 20
227
+ }
482
228
  });