@arfuhad/react-native-smart-camera 0.1.2 → 0.1.5

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 (265) hide show
  1. package/CHANGELOG.md +75 -3
  2. package/README.md +259 -206
  3. package/android/build.gradle +14 -39
  4. package/android/src/main/java/com/smartcamera/FaceDetectorFrameProcessorPlugin.kt +324 -0
  5. package/android/src/main/java/com/smartcamera/SmartCameraPackage.kt +28 -0
  6. package/build/detection/blinkProcessor.js +2 -1
  7. package/build/detection/blinkProcessor.js.map +1 -1
  8. package/build/detection/faceDetector.d.ts +4 -4
  9. package/build/detection/faceDetector.d.ts.map +1 -1
  10. package/build/detection/faceDetector.js +31 -11
  11. package/build/detection/faceDetector.js.map +1 -1
  12. package/build/detection/index.d.ts +1 -1
  13. package/build/detection/index.d.ts.map +1 -1
  14. package/build/detection/index.js +1 -1
  15. package/build/detection/index.js.map +1 -1
  16. package/build/detection/staticImageDetector.d.ts +11 -11
  17. package/build/detection/staticImageDetector.d.ts.map +1 -1
  18. package/build/detection/staticImageDetector.js +19 -23
  19. package/build/detection/staticImageDetector.js.map +1 -1
  20. package/build/hooks/index.d.ts +6 -0
  21. package/build/hooks/index.d.ts.map +1 -1
  22. package/build/hooks/index.js +8 -0
  23. package/build/hooks/index.js.map +1 -1
  24. package/build/hooks/useBlinkDetection.d.ts +27 -16
  25. package/build/hooks/useBlinkDetection.d.ts.map +1 -1
  26. package/build/hooks/useBlinkDetection.js +63 -37
  27. package/build/hooks/useBlinkDetection.js.map +1 -1
  28. package/build/hooks/useFaceDetection.js +3 -2
  29. package/build/hooks/useFaceDetection.js.map +1 -1
  30. package/build/hooks/useFaceDetector.d.ts +123 -0
  31. package/build/hooks/useFaceDetector.d.ts.map +1 -0
  32. package/build/hooks/useFaceDetector.js +133 -0
  33. package/build/hooks/useFaceDetector.js.map +1 -0
  34. package/build/hooks/useSmartCamera.js.map +1 -1
  35. package/build/hooks/useSmartCameraWebRTC.d.ts +3 -5
  36. package/build/hooks/useSmartCameraWebRTC.d.ts.map +1 -1
  37. package/build/hooks/useSmartCameraWebRTC.js +19 -87
  38. package/build/hooks/useSmartCameraWebRTC.js.map +1 -1
  39. package/build/hooks/useWebRTC.d.ts +88 -0
  40. package/build/hooks/useWebRTC.d.ts.map +1 -0
  41. package/build/hooks/useWebRTC.js +394 -0
  42. package/build/hooks/useWebRTC.js.map +1 -0
  43. package/build/hooks/useWebRTCWithDetection.d.ts +89 -0
  44. package/build/hooks/useWebRTCWithDetection.d.ts.map +1 -0
  45. package/build/hooks/useWebRTCWithDetection.js +131 -0
  46. package/build/hooks/useWebRTCWithDetection.js.map +1 -0
  47. package/build/index.d.ts +24 -10
  48. package/build/index.d.ts.map +1 -1
  49. package/build/index.js +38 -13
  50. package/build/index.js.map +1 -1
  51. package/build/types.d.ts +28 -12
  52. package/build/types.d.ts.map +1 -1
  53. package/build/types.js.map +1 -1
  54. package/build/utils/index.js.map +1 -1
  55. package/build/webrtc/WebRTCBridge.d.ts +3 -0
  56. package/build/webrtc/WebRTCBridge.d.ts.map +1 -1
  57. package/build/webrtc/WebRTCBridge.js +12 -15
  58. package/build/webrtc/WebRTCBridge.js.map +1 -1
  59. package/build/webrtc/WebRTCManager.d.ts +148 -0
  60. package/build/webrtc/WebRTCManager.d.ts.map +1 -0
  61. package/build/webrtc/WebRTCManager.js +383 -0
  62. package/build/webrtc/WebRTCManager.js.map +1 -0
  63. package/build/webrtc/index.d.ts +3 -1
  64. package/build/webrtc/index.d.ts.map +1 -1
  65. package/build/webrtc/index.js +5 -0
  66. package/build/webrtc/index.js.map +1 -1
  67. package/build/webrtc/types.d.ts +212 -4
  68. package/build/webrtc/types.d.ts.map +1 -1
  69. package/build/webrtc/types.js +34 -1
  70. package/build/webrtc/types.js.map +1 -1
  71. package/ios/FaceDetectorFrameProcessorPlugin.m +11 -0
  72. package/ios/FaceDetectorFrameProcessorPlugin.swift +304 -0
  73. package/package.json +11 -11
  74. package/react-native-smart-camera.podspec +32 -0
  75. package/src/detection/blinkProcessor.ts +127 -0
  76. package/src/detection/faceDetector.ts +78 -0
  77. package/src/detection/index.ts +3 -0
  78. package/src/detection/staticImageDetector.ts +53 -0
  79. package/src/hooks/index.ts +26 -0
  80. package/src/hooks/useBlinkDetection.ts +127 -0
  81. package/src/hooks/useFaceDetection.ts +105 -0
  82. package/src/hooks/useFaceDetector.ts +191 -0
  83. package/src/hooks/useSmartCamera.ts +83 -0
  84. package/src/hooks/useSmartCameraWebRTC.ts +120 -0
  85. package/src/hooks/useWebRTC.ts +453 -0
  86. package/src/hooks/useWebRTCWithDetection.ts +181 -0
  87. package/src/index.ts +170 -0
  88. package/src/types.ts +636 -0
  89. package/src/utils/index.ts +355 -0
  90. package/src/webrtc/WebRTCBridge.ts +127 -0
  91. package/src/webrtc/WebRTCManager.ts +453 -0
  92. package/src/webrtc/index.ts +50 -0
  93. package/src/webrtc/types.ts +361 -0
  94. package/android/build/.transforms/e0a0b120a9ccc3a8de4f5784bc36b161/results.bin +0 -1
  95. package/android/build/.transforms/e0a0b120a9ccc3a8de4f5784bc36b161/transformed/classes/classes_dex/classes.dex +0 -0
  96. package/android/build/generated/source/buildConfig/debug/expo/modules/smartcamera/BuildConfig.java +0 -10
  97. package/android/build/intermediates/aapt_friendly_merged_manifests/debug/aapt/AndroidManifest.xml +0 -7
  98. package/android/build/intermediates/aapt_friendly_merged_manifests/debug/aapt/output-metadata.json +0 -18
  99. package/android/build/intermediates/aar_metadata/debug/aar-metadata.properties +0 -6
  100. package/android/build/intermediates/annotation_processor_list/debug/annotationProcessors.json +0 -1
  101. package/android/build/intermediates/compile_library_classes_jar/debug/classes.jar +0 -0
  102. package/android/build/intermediates/compile_r_class_jar/debug/R.jar +0 -0
  103. package/android/build/intermediates/compile_symbol_list/debug/R.txt +0 -0
  104. package/android/build/intermediates/incremental/debug/packageDebugResources/compile-file-map.properties +0 -1
  105. package/android/build/intermediates/incremental/debug/packageDebugResources/merger.xml +0 -2
  106. package/android/build/intermediates/java_res/debug/out/META-INF/arfuhad-react-native-smart-camera_debug.kotlin_module +0 -0
  107. package/android/build/intermediates/javac/debug/classes/expo/modules/smartcamera/BuildConfig.class +0 -0
  108. package/android/build/intermediates/local_only_symbol_list/debug/R-def.txt +0 -2
  109. package/android/build/intermediates/manifest_merge_blame_file/debug/manifest-merger-blame-debug-report.txt +0 -7
  110. package/android/build/intermediates/merged_manifest/debug/AndroidManifest.xml +0 -7
  111. package/android/build/intermediates/navigation_json/debug/navigation.json +0 -1
  112. package/android/build/intermediates/runtime_library_classes_jar/debug/classes.jar +0 -0
  113. package/android/build/intermediates/symbol_list_with_package_name/debug/package-aware-r.txt +0 -1
  114. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab +0 -0
  115. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab.keystream +0 -0
  116. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab.keystream.len +0 -0
  117. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab.len +0 -0
  118. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab.values.at +0 -0
  119. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab_i +0 -0
  120. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab_i.len +0 -0
  121. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab +0 -0
  122. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.keystream +0 -0
  123. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.keystream.len +0 -0
  124. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.len +0 -0
  125. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.values.at +0 -0
  126. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab_i +0 -0
  127. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab_i.len +0 -0
  128. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab +0 -0
  129. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.keystream +0 -0
  130. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.keystream.len +0 -0
  131. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.len +0 -0
  132. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.values.at +0 -0
  133. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab_i +0 -0
  134. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab_i.len +0 -0
  135. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab +0 -0
  136. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.keystream +0 -0
  137. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.keystream.len +0 -0
  138. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.len +0 -0
  139. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.values.at +0 -0
  140. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab_i +0 -0
  141. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab_i.len +0 -0
  142. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/package-parts.tab +0 -0
  143. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/package-parts.tab.keystream +0 -0
  144. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/package-parts.tab.keystream.len +0 -0
  145. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/package-parts.tab.len +0 -0
  146. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/package-parts.tab.values.at +0 -0
  147. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/package-parts.tab_i +0 -0
  148. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/package-parts.tab_i.len +0 -0
  149. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab +0 -0
  150. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.keystream +0 -0
  151. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.keystream.len +0 -0
  152. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.len +0 -0
  153. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.values.at +0 -0
  154. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab_i +0 -0
  155. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab_i.len +0 -0
  156. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab +0 -0
  157. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab.keystream +0 -0
  158. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab.keystream.len +0 -0
  159. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab.len +0 -0
  160. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab.values.at +0 -0
  161. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab_i +0 -0
  162. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab_i.len +0 -0
  163. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab +0 -0
  164. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab.keystream +0 -0
  165. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab.keystream.len +0 -0
  166. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab.len +0 -0
  167. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab.values.at +0 -0
  168. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab_i +0 -0
  169. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab_i.len +0 -0
  170. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab +0 -0
  171. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.keystream +0 -0
  172. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.keystream.len +0 -0
  173. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.len +0 -0
  174. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.values.at +0 -0
  175. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab_i +0 -0
  176. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab_i.len +0 -0
  177. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/counters.tab +0 -2
  178. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab +0 -0
  179. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab.keystream +0 -0
  180. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab.keystream.len +0 -0
  181. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab.len +0 -0
  182. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab.values.at +0 -0
  183. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab_i +0 -0
  184. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab_i.len +0 -0
  185. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab +0 -0
  186. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.keystream +0 -0
  187. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.keystream.len +0 -0
  188. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.len +0 -0
  189. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.values.at +0 -0
  190. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab_i +0 -0
  191. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab_i.len +0 -0
  192. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab +0 -0
  193. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.keystream +0 -0
  194. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.keystream.len +0 -0
  195. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.len +0 -0
  196. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.values.at +0 -0
  197. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab_i +0 -0
  198. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab_i.len +0 -0
  199. package/android/build/kotlin/compileDebugKotlin/cacheable/last-build.bin +0 -0
  200. package/android/build/kotlin/compileDebugKotlin/classpath-snapshot/shrunk-classpath-snapshot.bin +0 -0
  201. package/android/build/kotlin/compileDebugKotlin/local-state/build-history.bin +0 -0
  202. package/android/build/outputs/logs/manifest-merger-debug-report.txt +0 -16
  203. package/android/build/tmp/compileDebugJavaWithJavac/previous-compilation-data.bin +0 -0
  204. package/android/build/tmp/kotlin-classes/debug/META-INF/arfuhad-react-native-smart-camera_debug.kotlin_module +0 -0
  205. package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/DetectedFace.class +0 -0
  206. package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/FaceBounds.class +0 -0
  207. package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/FaceContoursData.class +0 -0
  208. package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/FaceDetectionOptions.class +0 -0
  209. package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/FaceLandmarksData.class +0 -0
  210. package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/ImageLoader$Companion.class +0 -0
  211. package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/ImageLoader$loadImage$2.class +0 -0
  212. package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/ImageLoader.class +0 -0
  213. package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/MLKitFaceDetector$detectFaces$2$1.class +0 -0
  214. package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/MLKitFaceDetector$detectFaces$2$2.class +0 -0
  215. package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/MLKitFaceDetector.class +0 -0
  216. package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/MLKitFaceDetectorKt$sam$com_google_android_gms_tasks_OnSuccessListener$0.class +0 -0
  217. package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/MLKitFaceDetectorKt.class +0 -0
  218. package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/PointData.class +0 -0
  219. package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/SmartCameraModule$Companion.class +0 -0
  220. package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/SmartCameraModule$definition$1$1$1.class +0 -0
  221. package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/SmartCameraModule$definition$1$3$1.class +0 -0
  222. package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/SmartCameraModule$definition$1$4$1.class +0 -0
  223. package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/SmartCameraModule$definition$lambda$10$$inlined$AsyncFunction$1.class +0 -0
  224. package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/SmartCameraModule$definition$lambda$10$$inlined$AsyncFunction$2.class +0 -0
  225. package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/SmartCameraModule$definition$lambda$10$$inlined$AsyncFunction$3.class +0 -0
  226. package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/SmartCameraModule$definition$lambda$10$$inlined$AsyncFunctionWithPromise$1.class +0 -0
  227. package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/SmartCameraModule$definition$lambda$10$$inlined$AsyncFunctionWithPromise$2.class +0 -0
  228. package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/SmartCameraModule$definition$lambda$10$$inlined$AsyncFunctionWithPromise$3.class +0 -0
  229. package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/SmartCameraModule$definition$lambda$10$$inlined$AsyncFunctionWithPromise$4.class +0 -0
  230. package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/SmartCameraModule$definition$lambda$10$$inlined$Function$1.class +0 -0
  231. package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/SmartCameraModule$definition$lambda$10$$inlined$Function$2.class +0 -0
  232. package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/SmartCameraModule$definition$lambda$10$$inlined$Function$3.class +0 -0
  233. package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/SmartCameraModule$definition$lambda$10$$inlined$Function$4.class +0 -0
  234. package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/SmartCameraModule$definition$lambda$10$$inlined$FunctionWithoutArgs$1.class +0 -0
  235. package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/SmartCameraModule$definition$lambda$10$$inlined$FunctionWithoutArgs$2.class +0 -0
  236. package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/SmartCameraModule$definition$lambda$10$$inlined$OnActivityEntersBackground$1.class +0 -0
  237. package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/SmartCameraModule$definition$lambda$10$$inlined$OnActivityEntersForeground$1.class +0 -0
  238. package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/SmartCameraModule$definition$lambda$10$$inlined$OnDestroy$1.class +0 -0
  239. package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/SmartCameraModule.class +0 -0
  240. package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/SmartCameraView.class +0 -0
  241. package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/WebRTCFrameBridge$Companion.class +0 -0
  242. package/android/build/tmp/kotlin-classes/debug/expo/modules/smartcamera/WebRTCFrameBridge.class +0 -0
  243. package/android/src/main/java/expo/modules/smartcamera/ImageLoader.kt +0 -106
  244. package/android/src/main/java/expo/modules/smartcamera/MLKitFaceDetector.kt +0 -273
  245. package/android/src/main/java/expo/modules/smartcamera/SmartCameraModule.kt +0 -205
  246. package/android/src/main/java/expo/modules/smartcamera/SmartCameraView.kt +0 -153
  247. package/android/src/main/java/expo/modules/smartcamera/WebRTCFrameBridge.kt +0 -184
  248. package/build/SmartCamera.d.ts +0 -17
  249. package/build/SmartCamera.d.ts.map +0 -1
  250. package/build/SmartCamera.js +0 -270
  251. package/build/SmartCamera.js.map +0 -1
  252. package/build/SmartCameraModule.d.ts +0 -112
  253. package/build/SmartCameraModule.d.ts.map +0 -1
  254. package/build/SmartCameraModule.js +0 -121
  255. package/build/SmartCameraModule.js.map +0 -1
  256. package/build/SmartCameraView.d.ts +0 -8
  257. package/build/SmartCameraView.d.ts.map +0 -1
  258. package/build/SmartCameraView.js +0 -7
  259. package/build/SmartCameraView.js.map +0 -1
  260. package/expo-module.config.json +0 -9
  261. package/ios/MLKitFaceDetector.swift +0 -310
  262. package/ios/SmartCamera.podspec +0 -33
  263. package/ios/SmartCameraModule.swift +0 -225
  264. package/ios/SmartCameraView.swift +0 -146
  265. package/ios/WebRTCFrameBridge.swift +0 -150
@@ -0,0 +1,53 @@
1
+ import type { Face, StaticImageOptions } from '../types';
2
+
3
+ /**
4
+ * Default options for static image face detection
5
+ */
6
+ const DEFAULT_OPTIONS: Partial<StaticImageOptions> = {
7
+ performanceMode: 'accurate',
8
+ landmarkMode: 'none',
9
+ contourMode: 'none',
10
+ classificationMode: 'none',
11
+ minFaceSize: 0.15,
12
+ trackingEnabled: false,
13
+ };
14
+
15
+ /**
16
+ * Detect faces in a static image
17
+ *
18
+ * NOTE: Static image detection is currently not supported in the frame processor-only version.
19
+ * This feature requires native module implementation.
20
+ * For real-time face detection, use the `detectFaces` function with VisionCamera frame processor.
21
+ *
22
+ * @param options - Image source and detection options
23
+ * @returns Promise resolving to array of detected faces
24
+ *
25
+ * @example
26
+ * ```tsx
27
+ * // This feature is not yet implemented
28
+ * // For real-time detection, use:
29
+ * import { detectFaces } from '@arfuhad/react-native-smart-camera';
30
+ *
31
+ * const frameProcessor = useFrameProcessor((frame) => {
32
+ * 'worklet';
33
+ * const faces = detectFaces(frame);
34
+ * }, []);
35
+ * ```
36
+ */
37
+ export async function detectFacesInImage(options: StaticImageOptions): Promise<Face[]> {
38
+ const mergedOptions: StaticImageOptions = {
39
+ ...DEFAULT_OPTIONS,
40
+ ...options,
41
+ };
42
+
43
+ // TODO: Implement static image detection
44
+ // This requires either:
45
+ // 1. A separate native module for static image processing
46
+ // 2. Using react-native-ml-kit directly
47
+ console.warn(
48
+ '[SmartCamera] Static image detection is not yet implemented. ' +
49
+ 'For real-time face detection, use the detectFaces function with VisionCamera frame processor.'
50
+ );
51
+
52
+ return [];
53
+ }
@@ -0,0 +1,26 @@
1
+ // Camera management
2
+ export { useSmartCamera, getAvailableCameras } from './useSmartCamera';
3
+
4
+ // Face detection
5
+ export { useFaceDetection, type UseFaceDetectionOptions } from './useFaceDetection';
6
+ export {
7
+ useFaceDetector,
8
+ useFaceDetectorWithCallback,
9
+ type UseFaceDetectorOptions,
10
+ type UseFaceDetectorResult,
11
+ type UseFaceDetectorWithCallbackOptions,
12
+ type FaceDetectionCallback,
13
+ } from './useFaceDetector';
14
+
15
+ // Eye/Blink detection
16
+ export { useBlinkDetection, type UseBlinkDetectionOptions } from './useBlinkDetection';
17
+
18
+ // WebRTC video calling
19
+ export { useWebRTC } from './useWebRTC';
20
+ export type { UseWebRTCOptions, UseWebRTCResult } from './useWebRTC';
21
+ export { useWebRTCWithDetection } from './useWebRTCWithDetection';
22
+ export type { UseWebRTCWithDetectionOptions } from './useWebRTCWithDetection';
23
+ export type { UseWebRTCWithDetectionResult } from './useWebRTCWithDetection';
24
+
25
+ // Legacy WebRTC hook (deprecated, use useWebRTC instead)
26
+ export { useSmartCameraWebRTC, type UseSmartCameraWebRTCOptions } from './useSmartCameraWebRTC';
@@ -0,0 +1,127 @@
1
+ import { useState, useCallback, useRef, useEffect } from 'react';
2
+ import type { Face, EyeStatusResult, UseBlinkDetectionResult } from '../types';
3
+
4
+ /**
5
+ * Options for useBlinkDetection hook
6
+ */
7
+ export interface UseBlinkDetectionOptions {
8
+ /** Whether eye tracking is enabled. Default: true */
9
+ enabled?: boolean;
10
+
11
+ /** Threshold below which an eye is considered closed (0-1). Default: 0.5 */
12
+ eyeClosedThreshold?: number;
13
+
14
+ /** Callback when eye status changes */
15
+ onEyeStatusChange?: (status: EyeStatusResult) => void;
16
+ }
17
+
18
+ /**
19
+ * Hook for tracking eye status from detected faces
20
+ *
21
+ * This hook provides real-time eye open/closed status based on face detection results.
22
+ * The user can set their own threshold for determining when an eye is considered closed.
23
+ *
24
+ * @param options - Eye tracking options
25
+ * @returns Eye status and controls
26
+ *
27
+ * @example
28
+ * ```tsx
29
+ * function EyeTracker() {
30
+ * const { eyeStatus, processEyeStatus } = useBlinkDetection({
31
+ * eyeClosedThreshold: 0.3, // Consider eye closed when probability < 0.3
32
+ * onEyeStatusChange: (status) => {
33
+ * // Handle blink detection yourself based on status
34
+ * if (status.leftEye.isClosed && status.rightEye.isClosed) {
35
+ * console.log('Both eyes closed!');
36
+ * }
37
+ * },
38
+ * });
39
+ *
40
+ * // In your face detection callback:
41
+ * const handleFaces = (faces: Face[]) => {
42
+ * processEyeStatus(faces);
43
+ * };
44
+ *
45
+ * return (
46
+ * <View>
47
+ * <Text>Left Eye: {eyeStatus?.leftEye.openProbability.toFixed(2)}</Text>
48
+ * <Text>Right Eye: {eyeStatus?.rightEye.openProbability.toFixed(2)}</Text>
49
+ * </View>
50
+ * );
51
+ * }
52
+ * ```
53
+ */
54
+ export function useBlinkDetection(
55
+ options: UseBlinkDetectionOptions = {}
56
+ ): UseBlinkDetectionResult {
57
+ const {
58
+ enabled = true,
59
+ eyeClosedThreshold = 0.5,
60
+ onEyeStatusChange
61
+ } = options;
62
+
63
+ const [eyeStatus, setEyeStatus] = useState<EyeStatusResult | null>(null);
64
+ const callbackRef = useRef(onEyeStatusChange);
65
+
66
+ // Keep callback ref updated
67
+ useEffect(() => {
68
+ callbackRef.current = onEyeStatusChange;
69
+ }, [onEyeStatusChange]);
70
+
71
+ // Process faces to get eye status (call this from JS thread with detected faces)
72
+ const processEyeStatus = useCallback((faces: Face[]) => {
73
+ if (!enabled || faces.length === 0) {
74
+ return;
75
+ }
76
+
77
+ // Use the first face (most prominent)
78
+ const face = faces[0];
79
+
80
+ // Ensure we have eye classification data
81
+ if (
82
+ face.leftEyeOpenProbability === undefined ||
83
+ face.rightEyeOpenProbability === undefined
84
+ ) {
85
+ return;
86
+ }
87
+
88
+ const leftOpenProbability = face.leftEyeOpenProbability;
89
+ const rightOpenProbability = face.rightEyeOpenProbability;
90
+ const now = Date.now();
91
+
92
+ const status: EyeStatusResult = {
93
+ leftEye: {
94
+ openProbability: leftOpenProbability,
95
+ isClosed: leftOpenProbability < eyeClosedThreshold,
96
+ },
97
+ rightEye: {
98
+ openProbability: rightOpenProbability,
99
+ isClosed: rightOpenProbability < eyeClosedThreshold,
100
+ },
101
+ faceId: face.trackingId,
102
+ timestamp: now,
103
+ };
104
+
105
+ setEyeStatus(status);
106
+ callbackRef.current?.(status);
107
+ }, [enabled, eyeClosedThreshold]);
108
+
109
+ // Reset eye status
110
+ const reset = useCallback(() => {
111
+ setEyeStatus(null);
112
+ }, []);
113
+
114
+ // Reset on disable
115
+ useEffect(() => {
116
+ if (!enabled) {
117
+ reset();
118
+ }
119
+ }, [enabled, reset]);
120
+
121
+ return {
122
+ eyeStatus,
123
+ processEyeStatus,
124
+ reset,
125
+ };
126
+ }
127
+
@@ -0,0 +1,105 @@
1
+ import { useState, useCallback, useRef, useEffect } from 'react';
2
+ import type { Face, FaceDetectionOptions, UseFaceDetectionResult } from '../types';
3
+
4
+ /**
5
+ * Options for useFaceDetection hook
6
+ */
7
+ export interface UseFaceDetectionOptions extends FaceDetectionOptions {
8
+ /** Whether detection is enabled. Default: true */
9
+ enabled?: boolean;
10
+
11
+ /** Maximum number of faces to track. Default: 5 */
12
+ maxFaces?: number;
13
+
14
+ /** Callback when faces change */
15
+ onFacesChanged?: (faces: Face[]) => void;
16
+ }
17
+
18
+ /**
19
+ * Hook for managing face detection state
20
+ *
21
+ * Use this hook to get face detection results outside of the SmartCamera component.
22
+ *
23
+ * @param options - Face detection options
24
+ * @returns Face detection state
25
+ *
26
+ * @example
27
+ * ```tsx
28
+ * function FaceTracker() {
29
+ * const { faces, isDetecting } = useFaceDetection({
30
+ * performanceMode: 'fast',
31
+ * classificationMode: 'all',
32
+ * onFacesChanged: (faces) => {
33
+ * console.log('Detected faces:', faces.length);
34
+ * },
35
+ * });
36
+ *
37
+ * return (
38
+ * <View>
39
+ * <Text>Faces detected: {faces.length}</Text>
40
+ * {faces.map((face, i) => (
41
+ * <Text key={i}>
42
+ * Smiling: {(face.smilingProbability ?? 0) * 100}%
43
+ * </Text>
44
+ * ))}
45
+ * </View>
46
+ * );
47
+ * }
48
+ * ```
49
+ */
50
+ export function useFaceDetection(options: UseFaceDetectionOptions = {}): UseFaceDetectionResult {
51
+ const { enabled = true, maxFaces = 5, onFacesChanged } = options;
52
+
53
+ const [faces, setFaces] = useState<Face[]>([]);
54
+ const [isDetecting, setIsDetecting] = useState(false);
55
+ const facesRef = useRef<Face[]>([]);
56
+ const callbackRef = useRef(onFacesChanged);
57
+
58
+ // Keep callback ref updated
59
+ useEffect(() => {
60
+ callbackRef.current = onFacesChanged;
61
+ }, [onFacesChanged]);
62
+
63
+ // Update faces (called from frame processor via native bridge)
64
+ const updateFaces = useCallback((newFaces: Face[]) => {
65
+ // Limit number of faces
66
+ const limitedFaces = newFaces.slice(0, maxFaces);
67
+
68
+ // Only update if faces changed
69
+ const facesChanged =
70
+ limitedFaces.length !== facesRef.current.length ||
71
+ limitedFaces.some((face, i) => face.trackingId !== facesRef.current[i]?.trackingId);
72
+
73
+ if (facesChanged) {
74
+ facesRef.current = limitedFaces;
75
+ setFaces(limitedFaces);
76
+ callbackRef.current?.(limitedFaces);
77
+ }
78
+ }, [maxFaces]);
79
+
80
+ // Detection state management
81
+ const startDetecting = useCallback(() => {
82
+ setIsDetecting(true);
83
+ }, []);
84
+
85
+ const stopDetecting = useCallback(() => {
86
+ setIsDetecting(false);
87
+ setFaces([]);
88
+ facesRef.current = [];
89
+ }, []);
90
+
91
+ // Effect to manage detection state based on enabled prop
92
+ useEffect(() => {
93
+ if (enabled) {
94
+ startDetecting();
95
+ } else {
96
+ stopDetecting();
97
+ }
98
+ }, [enabled, startDetecting, stopDetecting]);
99
+
100
+ return {
101
+ faces,
102
+ isDetecting,
103
+ };
104
+ }
105
+
@@ -0,0 +1,191 @@
1
+ import { useCallback, useRef, useEffect, useState } from 'react';
2
+ import { useRunOnJS } from 'react-native-worklets-core';
3
+ import type { Frame } from 'react-native-vision-camera';
4
+ import { detectFaces } from '../detection/faceDetector';
5
+ import type { Face, FaceDetectionOptions, CameraFacing } from '../types';
6
+
7
+ /**
8
+ * Face detection options for useFaceDetector hook
9
+ * Matches the API of react-native-vision-camera-face-detector
10
+ */
11
+ export interface UseFaceDetectorOptions extends FaceDetectionOptions {
12
+ /**
13
+ * Current active camera
14
+ * @default 'front'
15
+ */
16
+ cameraFacing?: CameraFacing;
17
+
18
+ /**
19
+ * Should handle auto scale on native side?
20
+ * If disabled, results are relative to frame coordinates, not screen/preview.
21
+ * Don't use this if you want to draw with Skia Frame Processor.
22
+ * @default false
23
+ */
24
+ autoMode?: boolean;
25
+
26
+ /**
27
+ * Screen width for coordinate scaling (required when autoMode is true)
28
+ * @default 1.0
29
+ */
30
+ windowWidth?: number;
31
+
32
+ /**
33
+ * Screen height for coordinate scaling (required when autoMode is true)
34
+ * @default 1.0
35
+ */
36
+ windowHeight?: number;
37
+ }
38
+
39
+ /**
40
+ * Return type for useFaceDetector hook
41
+ */
42
+ export interface UseFaceDetectorResult {
43
+ /**
44
+ * Detect faces in a frame (for use in frame processor)
45
+ */
46
+ detectFaces: (frame: Frame) => Face[];
47
+ }
48
+
49
+ /**
50
+ * Hook for face detection in VisionCamera frame processors.
51
+ *
52
+ * This hook provides a `detectFaces` function that can be used directly
53
+ * in a frame processor to detect faces in each frame.
54
+ *
55
+ * @param options - Face detection options
56
+ * @returns Object with detectFaces function
57
+ *
58
+ * @example
59
+ * ```tsx
60
+ * import { useFaceDetector } from '@arfuhad/react-native-smart-camera';
61
+ * import { useFrameProcessor } from 'react-native-vision-camera';
62
+ * import Worklets from 'react-native-worklets-core';
63
+ *
64
+ * function FaceDetectionCamera() {
65
+ * const { detectFaces } = useFaceDetector({
66
+ * performanceMode: 'fast',
67
+ * classificationMode: 'all', // Required for blink detection
68
+ * });
69
+ *
70
+ * const handleFaces = Worklets.createRunOnJS((faces: Face[]) => {
71
+ * console.log('Detected faces:', faces.length);
72
+ * // Check for blinks using leftEyeOpenProbability / rightEyeOpenProbability
73
+ * });
74
+ *
75
+ * const frameProcessor = useFrameProcessor((frame) => {
76
+ * 'worklet';
77
+ * const faces = detectFaces(frame);
78
+ * handleFaces(faces);
79
+ * }, [detectFaces, handleFaces]);
80
+ *
81
+ * return <Camera frameProcessor={frameProcessor} />;
82
+ * }
83
+ * ```
84
+ */
85
+ export function useFaceDetector(options: UseFaceDetectorOptions = {}): UseFaceDetectorResult {
86
+ const optionsRef = useRef(options);
87
+
88
+ // Keep options ref updated
89
+ useEffect(() => {
90
+ optionsRef.current = options;
91
+ }, [options]);
92
+
93
+ // Create detect function that uses current options
94
+ const detect = useCallback((frame: Frame): Face[] => {
95
+ 'worklet';
96
+ return detectFaces(frame, {
97
+ performanceMode: optionsRef.current.performanceMode,
98
+ landmarkMode: optionsRef.current.landmarkMode,
99
+ contourMode: optionsRef.current.contourMode,
100
+ classificationMode: optionsRef.current.classificationMode,
101
+ minFaceSize: optionsRef.current.minFaceSize,
102
+ trackingEnabled: optionsRef.current.trackingEnabled,
103
+ cameraFacing: optionsRef.current.cameraFacing,
104
+ autoMode: optionsRef.current.autoMode,
105
+ windowWidth: optionsRef.current.windowWidth,
106
+ windowHeight: optionsRef.current.windowHeight,
107
+ });
108
+ }, []);
109
+
110
+ return {
111
+ detectFaces: detect,
112
+ };
113
+ }
114
+
115
+ /**
116
+ * Callback type for face detection
117
+ */
118
+ export type FaceDetectionCallback = (faces: Face[]) => void;
119
+
120
+ /**
121
+ * Options for useFaceDetectorWithCallback hook
122
+ */
123
+ export interface UseFaceDetectorWithCallbackOptions extends UseFaceDetectorOptions {
124
+ /**
125
+ * Callback when faces are detected
126
+ */
127
+ onFacesDetected?: FaceDetectionCallback;
128
+ }
129
+
130
+ /**
131
+ * Hook for face detection with automatic callback handling
132
+ *
133
+ * This is a convenience hook that wraps useFaceDetector and automatically
134
+ * calls your callback function when faces are detected.
135
+ *
136
+ * @param options - Face detection options with callback
137
+ * @returns Object with detectFaces function for use in frame processor
138
+ *
139
+ * @example
140
+ * ```tsx
141
+ * import { useFaceDetectorWithCallback } from '@arfuhad/react-native-smart-camera';
142
+ *
143
+ * function FaceDetectionCamera() {
144
+ * const [faces, setFaces] = useState<Face[]>([]);
145
+ *
146
+ * const { detectFaces } = useFaceDetectorWithCallback({
147
+ * classificationMode: 'all',
148
+ * onFacesDetected: (detectedFaces) => {
149
+ * setFaces(detectedFaces);
150
+ * },
151
+ * });
152
+ *
153
+ * const frameProcessor = useFrameProcessor((frame) => {
154
+ * 'worklet';
155
+ * detectFaces(frame); // Automatically calls onFacesDetected
156
+ * }, [detectFaces]);
157
+ *
158
+ * return <Camera frameProcessor={frameProcessor} />;
159
+ * }
160
+ * ```
161
+ */
162
+ export function useFaceDetectorWithCallback(
163
+ options: UseFaceDetectorWithCallbackOptions = {}
164
+ ): UseFaceDetectorResult {
165
+ const { onFacesDetected, ...detectorOptions } = options;
166
+ const { detectFaces: baseDet } = useFaceDetector(detectorOptions);
167
+ const callbackRef = useRef(onFacesDetected);
168
+
169
+ useEffect(() => {
170
+ callbackRef.current = onFacesDetected;
171
+ }, [onFacesDetected]);
172
+
173
+ // Create runOnJS callback
174
+ const handleFacesDetected = useRunOnJS((faces: Face[]) => {
175
+ callbackRef.current?.(faces);
176
+ }, []);
177
+
178
+ const detectWithCallback = useCallback((frame: Frame): Face[] => {
179
+ 'worklet';
180
+ const faces = baseDet(frame);
181
+ if (faces.length > 0 || callbackRef.current) {
182
+ handleFacesDetected(faces);
183
+ }
184
+ return faces;
185
+ }, [baseDet, handleFacesDetected]);
186
+
187
+ return {
188
+ detectFaces: detectWithCallback,
189
+ };
190
+ }
191
+
@@ -0,0 +1,83 @@
1
+ import { useState, useCallback, useMemo } from 'react';
2
+ import { useCameraDevice, useCameraPermission, Camera } from 'react-native-vision-camera';
3
+ import type { CameraFacing, UseSmartCameraResult, CameraDevice } from '../types';
4
+
5
+ /**
6
+ * Hook for managing SmartCamera state and permissions
7
+ *
8
+ * @returns Camera state, permission handlers, and device info
9
+ *
10
+ * @example
11
+ * ```tsx
12
+ * function CameraScreen() {
13
+ * const {
14
+ * hasPermission,
15
+ * requestPermission,
16
+ * device,
17
+ * switchCamera,
18
+ * currentCamera
19
+ * } = useSmartCamera();
20
+ *
21
+ * if (!hasPermission) {
22
+ * return <Button onPress={requestPermission} title="Grant Permission" />;
23
+ * }
24
+ *
25
+ * return <SmartCamera camera={currentCamera} />;
26
+ * }
27
+ * ```
28
+ */
29
+ export function useSmartCamera(): UseSmartCameraResult {
30
+ const [currentCamera, setCurrentCamera] = useState<CameraFacing>('front');
31
+ const { hasPermission, requestPermission: requestCameraPermission } = useCameraPermission();
32
+ const nativeDevice = useCameraDevice(currentCamera);
33
+
34
+ // Map native device to our CameraDevice type
35
+ const device: CameraDevice | undefined = useMemo(() => {
36
+ if (!nativeDevice) return undefined;
37
+
38
+ return {
39
+ id: nativeDevice.id,
40
+ name: nativeDevice.name,
41
+ position: nativeDevice.position === 'front' ? 'front' : 'back',
42
+ hasFlash: nativeDevice.hasFlash,
43
+ hasTorch: nativeDevice.hasTorch,
44
+ supportsLowLightBoost: nativeDevice.supportsLowLightBoost,
45
+ };
46
+ }, [nativeDevice]);
47
+
48
+ // Request camera permission
49
+ const requestPermission = useCallback(async (): Promise<boolean> => {
50
+ const result = await requestCameraPermission();
51
+ return result;
52
+ }, [requestCameraPermission]);
53
+
54
+ // Switch between front and back camera
55
+ const switchCamera = useCallback(() => {
56
+ setCurrentCamera((prev) => (prev === 'front' ? 'back' : 'front'));
57
+ }, []);
58
+
59
+ return {
60
+ hasPermission,
61
+ requestPermission,
62
+ device,
63
+ switchCamera,
64
+ currentCamera,
65
+ };
66
+ }
67
+
68
+ /**
69
+ * Get all available camera devices
70
+ */
71
+ export async function getAvailableCameras(): Promise<CameraDevice[]> {
72
+ const devices = await Camera.getAvailableCameraDevices();
73
+
74
+ return devices.map((device) => ({
75
+ id: device.id,
76
+ name: device.name,
77
+ position: device.position === 'front' ? 'front' : 'back',
78
+ hasFlash: device.hasFlash,
79
+ hasTorch: device.hasTorch,
80
+ supportsLowLightBoost: device.supportsLowLightBoost,
81
+ }));
82
+ }
83
+
@@ -0,0 +1,120 @@
1
+ import { useState, useCallback, useRef, useEffect } from 'react';
2
+ import type { WebRTCConfig, UseSmartCameraWebRTCResult, CameraFacing } from '../types';
3
+
4
+ /**
5
+ * Options for useSmartCameraWebRTC hook
6
+ */
7
+ export interface UseSmartCameraWebRTCOptions extends Omit<WebRTCConfig, 'enabled'> {
8
+ /** Initial camera facing. Default: 'front' */
9
+ initialCamera?: CameraFacing;
10
+
11
+ /** Callback when streaming state changes */
12
+ onStreamingStateChange?: (isStreaming: boolean) => void;
13
+
14
+ /** Callback when an error occurs */
15
+ onError?: (error: Error) => void;
16
+ }
17
+
18
+ /**
19
+ * Hook for managing WebRTC streaming with SmartCamera
20
+ *
21
+ * NOTE: This is a stub implementation. WebRTC functionality is not yet implemented.
22
+ * The hook provides the interface but does not perform actual streaming.
23
+ *
24
+ * @param options - WebRTC configuration options
25
+ * @returns WebRTC streaming controls and state
26
+ *
27
+ * @example
28
+ * ```tsx
29
+ * function VideoCall() {
30
+ * const peerConnection = useRef(new RTCPeerConnection(config)).current;
31
+ *
32
+ * const {
33
+ * videoTrack,
34
+ * isStreaming,
35
+ * startStreaming,
36
+ * stopStreaming,
37
+ * switchCamera,
38
+ * } = useSmartCameraWebRTC({
39
+ * peerConnection,
40
+ * mode: 'call',
41
+ * videoConstraints: {
42
+ * width: 1280,
43
+ * height: 720,
44
+ * frameRate: 30,
45
+ * },
46
+ * });
47
+ *
48
+ * return (
49
+ * <View>
50
+ * <Camera device={device} isActive={true} />
51
+ * <Button
52
+ * onPress={isStreaming ? stopStreaming : startStreaming}
53
+ * title={isStreaming ? 'End Call' : 'Start Call'}
54
+ * />
55
+ * </View>
56
+ * );
57
+ * }
58
+ * ```
59
+ */
60
+ export function useSmartCameraWebRTC(
61
+ options: UseSmartCameraWebRTCOptions = {}
62
+ ): UseSmartCameraWebRTCResult {
63
+ const {
64
+ initialCamera = 'front',
65
+ onStreamingStateChange,
66
+ onError,
67
+ } = options;
68
+
69
+ const [videoTrack, setVideoTrack] = useState<MediaStreamTrack | null>(null);
70
+ const [isStreaming, setIsStreaming] = useState(false);
71
+ const [currentCamera, setCurrentCamera] = useState<CameraFacing>(initialCamera);
72
+
73
+ const callbacksRef = useRef({ onStreamingStateChange, onError });
74
+ const isMounted = useRef(true);
75
+
76
+ // Keep refs updated
77
+ useEffect(() => {
78
+ callbacksRef.current = { onStreamingStateChange, onError };
79
+ }, [onStreamingStateChange, onError]);
80
+
81
+ // Track mounted state
82
+ useEffect(() => {
83
+ isMounted.current = true;
84
+ return () => {
85
+ isMounted.current = false;
86
+ };
87
+ }, []);
88
+
89
+ // Start streaming (stub)
90
+ const startStreaming = useCallback(async (): Promise<void> => {
91
+ console.warn('[SmartCamera] WebRTC streaming is not yet implemented');
92
+
93
+ if (isMounted.current) {
94
+ setIsStreaming(true);
95
+ callbacksRef.current.onStreamingStateChange?.(true);
96
+ }
97
+ }, []);
98
+
99
+ // Stop streaming (stub)
100
+ const stopStreaming = useCallback((): void => {
101
+ if (isMounted.current) {
102
+ setVideoTrack(null);
103
+ setIsStreaming(false);
104
+ callbacksRef.current.onStreamingStateChange?.(false);
105
+ }
106
+ }, []);
107
+
108
+ // Switch camera
109
+ const switchCamera = useCallback((): void => {
110
+ setCurrentCamera((prev) => (prev === 'front' ? 'back' : 'front'));
111
+ }, []);
112
+
113
+ return {
114
+ videoTrack,
115
+ isStreaming,
116
+ startStreaming,
117
+ stopStreaming,
118
+ switchCamera,
119
+ };
120
+ }