@fishjam-cloud/react-native-client 0.24.0 → 0.25.0-rc.1

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 (266) hide show
  1. package/README.md +56 -15
  2. package/dist/index.d.ts +13 -0
  3. package/dist/index.d.ts.map +1 -0
  4. package/dist/index.js +19 -0
  5. package/dist/overrides/RTCPeerConnection.d.ts +8 -0
  6. package/dist/overrides/RTCPeerConnection.d.ts.map +1 -0
  7. package/dist/overrides/RTCPeerConnection.js +16 -0
  8. package/dist/overrides/RTCView.d.ts +11 -0
  9. package/dist/overrides/RTCView.d.ts.map +1 -0
  10. package/dist/overrides/RTCView.js +21 -0
  11. package/dist/polyfills/local-storage.d.ts +10 -0
  12. package/dist/polyfills/local-storage.d.ts.map +1 -0
  13. package/dist/polyfills/local-storage.js +24 -0
  14. package/{build/hooks → dist}/useForegroundService.d.ts +10 -10
  15. package/dist/useForegroundService.d.ts.map +1 -0
  16. package/dist/useForegroundService.js +10 -0
  17. package/dist/webrtc-polyfill.d.ts +2 -0
  18. package/dist/webrtc-polyfill.d.ts.map +1 -0
  19. package/dist/webrtc-polyfill.js +14 -0
  20. package/package.json +44 -92
  21. package/plugin/broadcastExtensionFiles/Atomic.swift +37 -0
  22. package/plugin/broadcastExtensionFiles/DarwinNotificationCenter.swift +29 -0
  23. package/plugin/broadcastExtensionFiles/Info.plist +1 -1
  24. package/plugin/broadcastExtensionFiles/SampleHandler.swift +104 -0
  25. package/plugin/broadcastExtensionFiles/SampleUploader.swift +146 -0
  26. package/plugin/broadcastExtensionFiles/SocketConnection.swift +198 -0
  27. package/plugin/build/types.d.ts +5 -4
  28. package/plugin/build/withFishjam.d.ts +31 -2
  29. package/plugin/build/withFishjam.js +31 -5
  30. package/plugin/build/withFishjamAndroid.d.ts +2 -2
  31. package/plugin/build/withFishjamAndroid.js +48 -40
  32. package/plugin/build/withFishjamIos.d.ts +3 -8
  33. package/plugin/build/withFishjamIos.js +52 -72
  34. package/plugin/src/types.ts +19 -0
  35. package/plugin/src/withFishjam.ts +42 -0
  36. package/plugin/src/withFishjamAndroid.ts +112 -0
  37. package/plugin/src/withFishjamIos.ts +336 -0
  38. package/plugin/tsconfig.json +9 -0
  39. package/plugin/tsconfig.tsbuildinfo +1 -0
  40. package/LICENSE.txt +0 -201
  41. package/android/build.gradle +0 -95
  42. package/android/src/main/AndroidManifest.xml +0 -2
  43. package/android/src/main/java/io/fishjam/reactnative/AudioDeviceKind.kt +0 -34
  44. package/android/src/main/java/io/fishjam/reactnative/AudioSwitchManager.kt +0 -61
  45. package/android/src/main/java/io/fishjam/reactnative/EmitableEvents.kt +0 -126
  46. package/android/src/main/java/io/fishjam/reactnative/Errors.kt +0 -31
  47. package/android/src/main/java/io/fishjam/reactnative/PipContainerView.kt +0 -282
  48. package/android/src/main/java/io/fishjam/reactnative/PipContainerViewModule.kt +0 -41
  49. package/android/src/main/java/io/fishjam/reactnative/PipTrackSelector.kt +0 -98
  50. package/android/src/main/java/io/fishjam/reactnative/PipViewFactory.kt +0 -186
  51. package/android/src/main/java/io/fishjam/reactnative/RNFishjamClient.kt +0 -1001
  52. package/android/src/main/java/io/fishjam/reactnative/RNFishjamClientModule.kt +0 -358
  53. package/android/src/main/java/io/fishjam/reactnative/Utils.kt +0 -11
  54. package/android/src/main/java/io/fishjam/reactnative/VideoPreviewView.kt +0 -40
  55. package/android/src/main/java/io/fishjam/reactnative/VideoPreviewViewModule.kt +0 -22
  56. package/android/src/main/java/io/fishjam/reactnative/VideoRendererView.kt +0 -76
  57. package/android/src/main/java/io/fishjam/reactnative/VideoRendererViewModule.kt +0 -33
  58. package/android/src/main/java/io/fishjam/reactnative/VideoView.kt +0 -257
  59. package/android/src/main/java/io/fishjam/reactnative/extensions/CaptureDevice.kt +0 -17
  60. package/android/src/main/java/io/fishjam/reactnative/foregroundService/FishjamForegroundService.kt +0 -101
  61. package/android/src/main/java/io/fishjam/reactnative/foregroundService/ForegroundServiceManager.kt +0 -118
  62. package/android/src/main/java/io/fishjam/reactnative/foregroundService/ForegroundServiceState.kt +0 -46
  63. package/android/src/main/java/io/fishjam/reactnative/helpers/PictureInPictureHelperFragment.kt +0 -20
  64. package/android/src/main/java/io/fishjam/reactnative/managers/ListenerManager.kt +0 -24
  65. package/android/src/main/java/io/fishjam/reactnative/managers/LocalCameraTracksChangedListenersManager.kt +0 -8
  66. package/android/src/main/java/io/fishjam/reactnative/managers/LocalTracksSwitchListenersManager.kt +0 -17
  67. package/android/src/main/java/io/fishjam/reactnative/managers/TracksUpdateListenersManager.kt +0 -7
  68. package/android/src/main/java/io/fishjam/reactnative/utils/PermissionUtils.kt +0 -45
  69. package/build/RNFishjamClientModule.d.ts +0 -106
  70. package/build/RNFishjamClientModule.d.ts.map +0 -1
  71. package/build/RNFishjamClientModule.js +0 -21
  72. package/build/RNFishjamClientModule.js.map +0 -1
  73. package/build/common/metadata.d.ts +0 -9
  74. package/build/common/metadata.d.ts.map +0 -1
  75. package/build/common/metadata.js +0 -11
  76. package/build/common/metadata.js.map +0 -1
  77. package/build/components/FishjamRoom/GridTrackItem.d.ts +0 -12
  78. package/build/components/FishjamRoom/GridTrackItem.d.ts.map +0 -1
  79. package/build/components/FishjamRoom/GridTrackItem.js +0 -56
  80. package/build/components/FishjamRoom/GridTrackItem.js.map +0 -1
  81. package/build/components/FishjamRoom/VideosGrid.d.ts +0 -3
  82. package/build/components/FishjamRoom/VideosGrid.d.ts.map +0 -1
  83. package/build/components/FishjamRoom/VideosGrid.js +0 -20
  84. package/build/components/FishjamRoom/VideosGrid.js.map +0 -1
  85. package/build/components/FishjamRoom/index.d.ts +0 -33
  86. package/build/components/FishjamRoom/index.d.ts.map +0 -1
  87. package/build/components/FishjamRoom/index.js +0 -52
  88. package/build/components/FishjamRoom/index.js.map +0 -1
  89. package/build/components/FishjamRoom/parsePeersToTracks.d.ts +0 -4
  90. package/build/components/FishjamRoom/parsePeersToTracks.d.ts.map +0 -1
  91. package/build/components/FishjamRoom/parsePeersToTracks.js +0 -37
  92. package/build/components/FishjamRoom/parsePeersToTracks.js.map +0 -1
  93. package/build/components/PipContainerView.d.ts +0 -48
  94. package/build/components/PipContainerView.d.ts.map +0 -1
  95. package/build/components/PipContainerView.js +0 -34
  96. package/build/components/PipContainerView.js.map +0 -1
  97. package/build/components/VideoPreviewView.d.ts +0 -28
  98. package/build/components/VideoPreviewView.d.ts.map +0 -1
  99. package/build/components/VideoPreviewView.js +0 -17
  100. package/build/components/VideoPreviewView.js.map +0 -1
  101. package/build/components/VideoRendererView.d.ts +0 -39
  102. package/build/components/VideoRendererView.d.ts.map +0 -1
  103. package/build/components/VideoRendererView.js +0 -25
  104. package/build/components/VideoRendererView.js.map +0 -1
  105. package/build/consts/index.d.ts +0 -5
  106. package/build/consts/index.d.ts.map +0 -1
  107. package/build/consts/index.js +0 -8
  108. package/build/consts/index.js.map +0 -1
  109. package/build/debug/common/webRTC.d.ts +0 -9
  110. package/build/debug/common/webRTC.d.ts.map +0 -1
  111. package/build/debug/common/webRTC.js +0 -11
  112. package/build/debug/common/webRTC.js.map +0 -1
  113. package/build/debug/index.d.ts +0 -4
  114. package/build/debug/index.d.ts.map +0 -1
  115. package/build/debug/index.js +0 -3
  116. package/build/debug/index.js.map +0 -1
  117. package/build/debug/stats/types.d.ts +0 -55
  118. package/build/debug/stats/types.d.ts.map +0 -1
  119. package/build/debug/stats/types.js +0 -2
  120. package/build/debug/stats/types.js.map +0 -1
  121. package/build/debug/stats/useRTCStatistics.d.ts +0 -9
  122. package/build/debug/stats/useRTCStatistics.d.ts.map +0 -1
  123. package/build/debug/stats/useRTCStatistics.js +0 -79
  124. package/build/debug/stats/useRTCStatistics.js.map +0 -1
  125. package/build/hooks/internal/useFishjamEvent.d.ts +0 -4
  126. package/build/hooks/internal/useFishjamEvent.d.ts.map +0 -1
  127. package/build/hooks/internal/useFishjamEvent.js +0 -38
  128. package/build/hooks/internal/useFishjamEvent.js.map +0 -1
  129. package/build/hooks/internal/useFishjamEventState.d.ts +0 -3
  130. package/build/hooks/internal/useFishjamEventState.d.ts.map +0 -1
  131. package/build/hooks/internal/useFishjamEventState.js +0 -18
  132. package/build/hooks/internal/useFishjamEventState.js.map +0 -1
  133. package/build/hooks/useAppScreenShare.d.ts +0 -18
  134. package/build/hooks/useAppScreenShare.d.ts.map +0 -1
  135. package/build/hooks/useAppScreenShare.js +0 -46
  136. package/build/hooks/useAppScreenShare.js.map +0 -1
  137. package/build/hooks/useAudioSettings.d.ts +0 -49
  138. package/build/hooks/useAudioSettings.d.ts.map +0 -1
  139. package/build/hooks/useAudioSettings.js +0 -70
  140. package/build/hooks/useAudioSettings.js.map +0 -1
  141. package/build/hooks/useBandwidthEstimation.d.ts +0 -14
  142. package/build/hooks/useBandwidthEstimation.d.ts.map +0 -1
  143. package/build/hooks/useBandwidthEstimation.js +0 -19
  144. package/build/hooks/useBandwidthEstimation.js.map +0 -1
  145. package/build/hooks/useCallKit.d.ts +0 -121
  146. package/build/hooks/useCallKit.d.ts.map +0 -1
  147. package/build/hooks/useCallKit.js +0 -142
  148. package/build/hooks/useCallKit.js.map +0 -1
  149. package/build/hooks/useCamera.d.ts +0 -113
  150. package/build/hooks/useCamera.d.ts.map +0 -1
  151. package/build/hooks/useCamera.js +0 -93
  152. package/build/hooks/useCamera.js.map +0 -1
  153. package/build/hooks/useConnection.d.ts +0 -73
  154. package/build/hooks/useConnection.d.ts.map +0 -1
  155. package/build/hooks/useConnection.js +0 -46
  156. package/build/hooks/useConnection.js.map +0 -1
  157. package/build/hooks/useForegroundService.d.ts.map +0 -1
  158. package/build/hooks/useForegroundService.js +0 -66
  159. package/build/hooks/useForegroundService.js.map +0 -1
  160. package/build/hooks/useMicrophone.d.ts +0 -16
  161. package/build/hooks/useMicrophone.d.ts.map +0 -1
  162. package/build/hooks/useMicrophone.js +0 -31
  163. package/build/hooks/useMicrophone.js.map +0 -1
  164. package/build/hooks/usePeerStatus.d.ts +0 -10
  165. package/build/hooks/usePeerStatus.d.ts.map +0 -1
  166. package/build/hooks/usePeerStatus.js +0 -13
  167. package/build/hooks/usePeerStatus.js.map +0 -1
  168. package/build/hooks/usePeers.d.ts +0 -98
  169. package/build/hooks/usePeers.d.ts.map +0 -1
  170. package/build/hooks/usePeers.js +0 -81
  171. package/build/hooks/usePeers.js.map +0 -1
  172. package/build/hooks/usePermissions.d.ts +0 -24
  173. package/build/hooks/usePermissions.d.ts.map +0 -1
  174. package/build/hooks/usePermissions.js +0 -61
  175. package/build/hooks/usePermissions.js.map +0 -1
  176. package/build/hooks/useReconnection.d.ts +0 -11
  177. package/build/hooks/useReconnection.d.ts.map +0 -1
  178. package/build/hooks/useReconnection.js +0 -14
  179. package/build/hooks/useReconnection.js.map +0 -1
  180. package/build/hooks/useSandbox.d.ts +0 -20
  181. package/build/hooks/useSandbox.d.ts.map +0 -1
  182. package/build/hooks/useSandbox.js +0 -54
  183. package/build/hooks/useSandbox.js.map +0 -1
  184. package/build/hooks/useScreenShare.d.ts +0 -36
  185. package/build/hooks/useScreenShare.d.ts.map +0 -1
  186. package/build/hooks/useScreenShare.js +0 -45
  187. package/build/hooks/useScreenShare.js.map +0 -1
  188. package/build/hooks/useUpdatePeerMetadata.d.ts +0 -15
  189. package/build/hooks/useUpdatePeerMetadata.d.ts.map +0 -1
  190. package/build/hooks/useUpdatePeerMetadata.js +0 -21
  191. package/build/hooks/useUpdatePeerMetadata.js.map +0 -1
  192. package/build/index.d.ts +0 -36
  193. package/build/index.d.ts.map +0 -1
  194. package/build/index.js +0 -30
  195. package/build/index.js.map +0 -1
  196. package/build/livestream/components/LivestreamStreamer.d.ts +0 -24
  197. package/build/livestream/components/LivestreamStreamer.d.ts.map +0 -1
  198. package/build/livestream/components/LivestreamStreamer.js +0 -12
  199. package/build/livestream/components/LivestreamStreamer.js.map +0 -1
  200. package/build/livestream/components/LivestreamViewer.d.ts +0 -46
  201. package/build/livestream/components/LivestreamViewer.d.ts.map +0 -1
  202. package/build/livestream/components/LivestreamViewer.js +0 -10
  203. package/build/livestream/components/LivestreamViewer.js.map +0 -1
  204. package/build/livestream/hooks/useLivestreamScreenSharingStreamer.d.ts +0 -49
  205. package/build/livestream/hooks/useLivestreamScreenSharingStreamer.d.ts.map +0 -1
  206. package/build/livestream/hooks/useLivestreamScreenSharingStreamer.js +0 -58
  207. package/build/livestream/hooks/useLivestreamScreenSharingStreamer.js.map +0 -1
  208. package/build/livestream/hooks/useLivestreamStreamer.d.ts +0 -65
  209. package/build/livestream/hooks/useLivestreamStreamer.d.ts.map +0 -1
  210. package/build/livestream/hooks/useLivestreamStreamer.js +0 -71
  211. package/build/livestream/hooks/useLivestreamStreamer.js.map +0 -1
  212. package/build/livestream/hooks/useLivestreamViewer.d.ts +0 -36
  213. package/build/livestream/hooks/useLivestreamViewer.d.ts.map +0 -1
  214. package/build/livestream/hooks/useLivestreamViewer.js +0 -73
  215. package/build/livestream/hooks/useLivestreamViewer.js.map +0 -1
  216. package/build/livestream/index.d.ts +0 -12
  217. package/build/livestream/index.d.ts.map +0 -1
  218. package/build/livestream/index.js +0 -7
  219. package/build/livestream/index.js.map +0 -1
  220. package/build/protos/fishjam/peer_notifications.d.ts +0 -63
  221. package/build/protos/fishjam/peer_notifications.d.ts.map +0 -1
  222. package/build/protos/fishjam/peer_notifications.js +0 -235
  223. package/build/protos/fishjam/peer_notifications.js.map +0 -1
  224. package/build/types.d.ts +0 -34
  225. package/build/types.d.ts.map +0 -1
  226. package/build/types.js +0 -2
  227. package/build/types.js.map +0 -1
  228. package/build/utils/config.d.ts +0 -6
  229. package/build/utils/config.d.ts.map +0 -1
  230. package/build/utils/config.js +0 -10
  231. package/build/utils/config.js.map +0 -1
  232. package/build/utils/errorListener.d.ts +0 -2
  233. package/build/utils/errorListener.d.ts.map +0 -1
  234. package/build/utils/errorListener.js +0 -15
  235. package/build/utils/errorListener.js.map +0 -1
  236. package/build/utils/eventPayloadValidator.d.ts +0 -3
  237. package/build/utils/eventPayloadValidator.d.ts.map +0 -1
  238. package/build/utils/eventPayloadValidator.js +0 -86
  239. package/build/utils/eventPayloadValidator.js.map +0 -1
  240. package/build/utils/getFishjamUrl.d.ts +0 -2
  241. package/build/utils/getFishjamUrl.d.ts.map +0 -1
  242. package/build/utils/getFishjamUrl.js +0 -10
  243. package/build/utils/getFishjamUrl.js.map +0 -1
  244. package/debug/package.json +0 -4
  245. package/expo-module.config.json +0 -19
  246. package/ios/CameraPermissionsRequester.swift +0 -117
  247. package/ios/Events.swift +0 -152
  248. package/ios/PictureInPictureManager.swift +0 -215
  249. package/ios/PipContainerView.swift +0 -56
  250. package/ios/PipContainerViewModule.swift +0 -48
  251. package/ios/RNFishjamClient.podspec +0 -30
  252. package/ios/RNFishjamClient.swift +0 -995
  253. package/ios/RNFishjamClientModule.swift +0 -289
  254. package/ios/RNFishjamProxy.swift +0 -12
  255. package/ios/Utils/PermissionUtils.swift +0 -16
  256. package/ios/Utils.swift +0 -23
  257. package/ios/VideoPreviewView.swift +0 -54
  258. package/ios/VideoPreviewViewModule.swift +0 -21
  259. package/ios/VideoRendererView.swift +0 -98
  260. package/ios/VideoRendererViewModule.swift +0 -23
  261. package/ios/extensions/AVCaptureDevice.swift +0 -20
  262. package/ios/managers/LocalCameraTracksChangedListenersManager.swift +0 -23
  263. package/ios/managers/TracksUpdateListenersManager.swift +0 -21
  264. package/livestream/package.json +0 -4
  265. package/plugin/broadcastExtensionFiles/FishjamBroadcastSampleHandler.swift +0 -50
  266. /package/plugin/broadcastExtensionFiles/{FishjamScreenBroadcastExtension.entitlements → ScreenBroadcastExtension.entitlements} +0 -0
@@ -1,70 +0,0 @@
1
- import { useCallback, useEffect } from 'react';
2
- import { Platform } from 'react-native';
3
- import RNFishjamClientModule, { ReceivableEvents, } from '../RNFishjamClientModule';
4
- import { useFishjamEventState } from './internal/useFishjamEventState';
5
- /**
6
- * This hook manages audio settings.
7
- * @category Devices
8
- * @group Hooks
9
- */
10
- export function useAudioSettings() {
11
- const { selectedDevice: selectedAudioOutputDevice, availableDevices } = useFishjamEventState(ReceivableEvents.AudioDeviceUpdate, {
12
- selectedDevice: null,
13
- availableDevices: [],
14
- });
15
- useEffect(() => {
16
- RNFishjamClientModule.startAudioSwitcher();
17
- return () => {
18
- if (Platform.OS === 'android') {
19
- RNFishjamClientModule.stopAudioSwitcher();
20
- }
21
- };
22
- }, []);
23
- const selectOutputAudioDevice = useCallback(async (device) => {
24
- if (Platform.OS === 'ios') {
25
- throw Error('selectOutputAudioDevice function is supported only on Android. ' +
26
- 'To select an output audio device on iOS use selectAudioSessionMode or showAudioRoutePicker functions');
27
- }
28
- await RNFishjamClientModule.setOutputAudioDevice(device);
29
- }, []);
30
- const selectAudioSessionMode = useCallback(async (audioSessionMode) => {
31
- if (Platform.OS === 'android') {
32
- throw Error('selectAudioSessionMode function is supported only on iOS');
33
- }
34
- await RNFishjamClientModule.selectAudioSessionMode(audioSessionMode);
35
- }, []);
36
- const showAudioRoutePicker = useCallback(async () => {
37
- if (Platform.OS === 'android') {
38
- throw Error('showAudioRoutePicker function is supported only on iOS. ' +
39
- 'To select an output audio device on Android use selectOutputAudioDevice function');
40
- }
41
- await RNFishjamClientModule.showAudioRoutePicker();
42
- }, []);
43
- return {
44
- /**
45
- * currently selected output audio device
46
- */
47
- selectedAudioOutputDevice,
48
- /**
49
- * [Android only] available audio output devices to be set
50
- */
51
- availableDevices,
52
- /**
53
- * [Android only] selects output audio device.
54
- * For detecting and selecting bluettoth devices make sure you have the BLUETOOTH_CONNECT permission.
55
- */
56
- selectOutputAudioDevice,
57
- /**
58
- * [iOS only] selects audio session mode. For more information refer to Apple's documentation:
59
- * https://developer.apple.com/documentation/avfaudio/avaudiosession/mode/
60
- *
61
- */
62
- selectAudioSessionMode,
63
- /**
64
- * [iOS only] Shows a picker modal that allows user to select output audio device. For more
65
- * information refer to Apple's documentation: https://developer.apple.com/documentation/avkit/avroutepickerview
66
- */
67
- showAudioRoutePicker,
68
- };
69
- }
70
- //# sourceMappingURL=useAudioSettings.js.map
@@ -1 +0,0 @@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CAAC,0DAA0D,CAAC,CAAC;QAC1E,CAAC;QACD,MAAM,qBAAqB,CAAC,sBAAsB,CAAC,gBAAgB,CAAC,CAAC;IACvE,CAAC,EACD,EAAE,CACH,CAAC;IAEF,MAAM,oBAAoB,GAAG,WAAW,CAAC,KAAK,IAAI,EAAE;QAClD,IAAI,QAAQ,CAAC,EAAE,KAAK,SAAS,EAAE,CAAC;YAC9B,MAAM,KAAK,CACT,0DAA0D;gBACxD,kFAAkF,CACrF,CAAC;QACJ,CAAC;QACD,MAAM,qBAAqB,CAAC,oBAAoB,EAAE,CAAC;IACrD,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO;QACL;;WAEG;QACH,yBAAyB;QACzB;;WAEG;QACH,gBAAgB;QAChB;;;WAGG;QACH,uBAAuB;QACvB;;;;WAIG;QACH,sBAAsB;QACtB;;;WAGG;QACH,oBAAoB;KACrB,CAAC;AACJ,CAAC","sourcesContent":["import { useCallback, useEffect } from 'react';\nimport { Platform } from 'react-native';\n\nimport RNFishjamClientModule, {\n ReceivableEvents,\n} from '../RNFishjamClientModule';\nimport { useFishjamEventState } from './internal/useFishjamEventState';\n\nexport type AudioOutputDeviceType =\n | 'bluetooth'\n | 'headset'\n | 'speaker'\n | 'earpiece';\n\nexport type AudioSessionMode = 'voiceChat' | 'videoChat';\n\nexport type AudioOutputDevice = {\n type: AudioOutputDeviceType;\n name: string;\n};\n\nexport type OnAudioDeviceEvent = {\n /**\n * Currently selected output audio device.\n * On iOS this property can briefly become null, even if it was previously initialized, when AVAudioSession's .currentRoute is empty.\n */\n selectedDevice: AudioOutputDevice | null;\n /**\n * [Android only] available audio output devices to be set\n */\n availableDevices: AudioOutputDevice[];\n};\n\n/**\n * This hook manages audio settings.\n * @category Devices\n * @group Hooks\n */\nexport function useAudioSettings() {\n const { selectedDevice: selectedAudioOutputDevice, availableDevices } =\n useFishjamEventState(ReceivableEvents.AudioDeviceUpdate, {\n selectedDevice: null,\n availableDevices: [],\n });\n\n useEffect(() => {\n RNFishjamClientModule.startAudioSwitcher();\n return () => {\n if (Platform.OS === 'android') {\n RNFishjamClientModule.stopAudioSwitcher();\n }\n };\n }, []);\n\n const selectOutputAudioDevice = useCallback(\n async (device: AudioOutputDeviceType) => {\n if (Platform.OS === 'ios') {\n throw Error(\n 'selectOutputAudioDevice function is supported only on Android. ' +\n 'To select an output audio device on iOS use selectAudioSessionMode or showAudioRoutePicker functions',\n );\n }\n await RNFishjamClientModule.setOutputAudioDevice(device);\n },\n [],\n );\n\n const selectAudioSessionMode = useCallback(\n async (audioSessionMode: AudioSessionMode) => {\n if (Platform.OS === 'android') {\n throw Error('selectAudioSessionMode function is supported only on iOS');\n }\n await RNFishjamClientModule.selectAudioSessionMode(audioSessionMode);\n },\n [],\n );\n\n const showAudioRoutePicker = useCallback(async () => {\n if (Platform.OS === 'android') {\n throw Error(\n 'showAudioRoutePicker function is supported only on iOS. ' +\n 'To select an output audio device on Android use selectOutputAudioDevice function',\n );\n }\n await RNFishjamClientModule.showAudioRoutePicker();\n }, []);\n\n return {\n /**\n * currently selected output audio device\n */\n selectedAudioOutputDevice,\n /**\n * [Android only] available audio output devices to be set\n */\n availableDevices,\n /**\n * [Android only] selects output audio device.\n * For detecting and selecting bluettoth devices make sure you have the BLUETOOTH_CONNECT permission.\n */\n selectOutputAudioDevice,\n /**\n * [iOS only] selects audio session mode. For more information refer to Apple's documentation:\n * https://developer.apple.com/documentation/avfaudio/avaudiosession/mode/\n *\n */\n selectAudioSessionMode,\n /**\n * [iOS only] Shows a picker modal that allows user to select output audio device. For more\n * information refer to Apple's documentation: https://developer.apple.com/documentation/avkit/avroutepickerview\n */\n showAudioRoutePicker,\n };\n}\n"]}
@@ -1,14 +0,0 @@
1
- /**
2
- * This hook provides current bandwidth estimation
3
- * estimation - client's available incoming bitrate estimated
4
- * by the server. It's measured in bits per second.
5
- * @category Debugging
6
- * @group Hooks
7
- */
8
- export declare function useBandwidthEstimation(): {
9
- /**
10
- * Bandwidth estimation, measured in bits per second
11
- */
12
- estimation: number | null;
13
- };
14
- //# sourceMappingURL=useBandwidthEstimation.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useBandwidthEstimation.d.ts","sourceRoot":"","sources":["../../src/hooks/useBandwidthEstimation.ts"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,wBAAgB,sBAAsB;IAMlC;;OAEG;;EAGN"}
@@ -1,19 +0,0 @@
1
- import { ReceivableEvents } from '../RNFishjamClientModule';
2
- import { useFishjamEventState } from './internal/useFishjamEventState';
3
- /**
4
- * This hook provides current bandwidth estimation
5
- * estimation - client's available incoming bitrate estimated
6
- * by the server. It's measured in bits per second.
7
- * @category Debugging
8
- * @group Hooks
9
- */
10
- export function useBandwidthEstimation() {
11
- const estimation = useFishjamEventState(ReceivableEvents.BandwidthEstimation, null);
12
- return {
13
- /**
14
- * Bandwidth estimation, measured in bits per second
15
- */
16
- estimation,
17
- };
18
- }
19
- //# sourceMappingURL=useBandwidthEstimation.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useBandwidthEstimation.js","sourceRoot":"","sources":["../../src/hooks/useBandwidthEstimation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAEvE;;;;;;GAMG;AACH,MAAM,UAAU,sBAAsB;IACpC,MAAM,UAAU,GAAG,oBAAoB,CACrC,gBAAgB,CAAC,mBAAmB,EACpC,IAAI,CACL,CAAC;IACF,OAAO;QACL;;WAEG;QACH,UAAU;KACX,CAAC;AACJ,CAAC","sourcesContent":["import { ReceivableEvents } from '../RNFishjamClientModule';\nimport { useFishjamEventState } from './internal/useFishjamEventState';\n\n/**\n * This hook provides current bandwidth estimation\n * estimation - client's available incoming bitrate estimated\n * by the server. It's measured in bits per second.\n * @category Debugging\n * @group Hooks\n */\nexport function useBandwidthEstimation() {\n const estimation = useFishjamEventState(\n ReceivableEvents.BandwidthEstimation,\n null,\n );\n return {\n /**\n * Bandwidth estimation, measured in bits per second\n */\n estimation,\n };\n}\n"]}
@@ -1,121 +0,0 @@
1
- export type CallKitAction = {
2
- ['started']: undefined;
3
- ['ended']: undefined;
4
- ['failed']: string;
5
- ['muted']: boolean;
6
- ['held']: boolean;
7
- };
8
- export type UseCallKitResult = {
9
- /**
10
- * Starts a CallKit session for the current call
11
- * @param config - Configuration object containing displayName and isVideo
12
- */
13
- startCallKitSession: (config: CallKitConfig) => Promise<void>;
14
- /**
15
- * Ends the current CallKit session
16
- */
17
- endCallKitSession: () => Promise<void>;
18
- /**
19
- * Returns whether there is currently an active CallKit session
20
- */
21
- getCallKitSessionStatus: () => Promise<boolean>;
22
- };
23
- export type CallKitConfig = {
24
- /**
25
- * The name to display in the CallKit UI
26
- */
27
- displayName: string;
28
- /**
29
- * Whether the should support video
30
- */
31
- isVideo: boolean;
32
- };
33
- declare function useCallKitIos(): UseCallKitResult;
34
- declare const useCallKitServiceIos: (config: CallKitConfig) => void;
35
- declare const useCallKitEventIos: <T extends keyof CallKitAction>(action: T, callback: (event: CallKitAction[T]) => void) => void;
36
- /**
37
- * A hook for listening to CallKit actions on iOS. Does nothing on other platforms.
38
- * This hook allows you to respond to user interactions with the native iOS CallKit interface,
39
- * such as muting/unmuting the call, putting the call on hold, or ending the call from the
40
- * system's phone UI or lock screen controls.
41
- *
42
- * @param {keyof CallKitAction} action - The CallKit action to listen for. Available actions:
43
- * - `'started'` - CallKit session has started
44
- * - `'ended'` - User ended the call from CallKit UI
45
- * - `'failed'` - CallKit session failed to start
46
- * - `'muted'` - User toggled mute from CallKit UI
47
- * - `'held'` - User toggled hold from CallKit UI
48
- *
49
- * @param {Function} callback - Function called when the specified action occurs.
50
- *
51
- * @group Hooks
52
- * @category Connection
53
- *
54
- * @example
55
- * ```typescript
56
- * import { useCallKitEvent } from '@fishjam-cloud/react-native-client';
57
- *
58
- * // Listen for hold state changes
59
- * useCallKitEvent('held', (isOnHold: boolean) => {
60
- * console.log('Call hold state:', isOnHold);
61
- * // Handle hold state in your app
62
- * });
63
- * ```
64
- */
65
- export declare const useCallKitEvent: typeof useCallKitEventIos;
66
- /**
67
- * A hook for managing CallKit sessions on iOS. Does nothing on other platforms.
68
- * CallKit provides a native iOS interface for managing VoIP calls, integrating with the system's
69
- * phone UI and controls. Use this hook when you need fine-grained control over the CallKit session lifecycle.
70
- *
71
- * @returns {UseCallKitResult} An object containing methods to manage CallKit sessions:
72
- * - `startCallKitSession(config: CallKitConfig)` - Starts a CallKit session with the given configuration
73
- * - `endCallKitSession()` - Ends the current CallKit session
74
- * - `getCallKitSessionStatus()` - Returns whether there is currently an active CallKit session
75
- *
76
- * @group Hooks
77
- * @category Connection
78
- *
79
- * @example
80
- * ```typescript
81
- * import { useCallKit } from '@fishjam-cloud/react-native-client';
82
- *
83
- * const { startCallKitSession, endCallKitSession } = useCallKit();
84
- *
85
- * // Start a CallKit session
86
- * await startCallKitSession({ displayName: 'John Doe', isVideo: true });
87
- *
88
- * // Later, end the session
89
- * await endCallKitSession();
90
- * ```
91
- */
92
- export declare const useCallKit: typeof useCallKitIos;
93
- /**
94
- * A convenience hook for automatically managing CallKit session lifecycle on iOS. Does nothing on other platforms.
95
- * This hook automatically starts a CallKit session when the component mounts and ends it when the component unmounts.
96
- * Use this hook when you want CallKit to be active for the entire lifetime of a component (e.g., during a call).
97
- *
98
- * @param {CallKitConfig} config - Configuration object containing:
99
- * - `displayName` - The name to display in the CallKit UI (e.g., username, call title)
100
- * - `isVideo` - Whether the call is video or audio only
101
- *
102
- * @group Hooks
103
- * @category Connection
104
- *
105
- * @example
106
- * ```typescript
107
- * import React from 'react';
108
- * import { useCallKitService } from '@fishjam-cloud/react-native-client';
109
- *
110
- * function CallScreen({ username }: { username: string }) {
111
- * // CallKit session will automatically start when this component mounts
112
- * // and end when it unmounts
113
- * useCallKitService({ displayName: username, isVideo: true });
114
- *
115
- * return null;
116
- * }
117
- * ```
118
- */
119
- export declare const useCallKitService: typeof useCallKitServiceIos;
120
- export {};
121
- //# sourceMappingURL=useCallKit.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useCallKit.d.ts","sourceRoot":"","sources":["../../src/hooks/useCallKit.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,aAAa,GAAG;IAC1B,CAAC,SAAS,CAAC,EAAE,SAAS,CAAC;IACvB,CAAC,OAAO,CAAC,EAAE,SAAS,CAAC;IACrB,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IACnB,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IACnB,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B;;;OAGG;IACH,mBAAmB,EAAE,CAAC,MAAM,EAAE,aAAa,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAE9D;;OAEG;IACH,iBAAiB,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAEvC;;OAEG;IACH,uBAAuB,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;CACjD,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,iBAAS,aAAa,IAAI,gBAAgB,CA+BzC;AAED,QAAA,MAAM,oBAAoB,GAAI,QAAQ,aAAa,SAYlD,CAAC;AAIF,QAAA,MAAM,kBAAkB,GAAI,CAAC,SAAS,MAAM,aAAa,EACvD,QAAQ,CAAC,EACT,UAAU,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,IAAI,SAK5C,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,eAAe,EAGtB,OAAO,kBAAkB,CAAC;AAEhC;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,UAAU,EAGjB,OAAO,aAAa,CAAC;AAE3B;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,iBAAiB,EAGxB,OAAO,oBAAoB,CAAC"}
@@ -1,142 +0,0 @@
1
- import { useCallback, useEffect } from 'react';
2
- import { Platform } from 'react-native';
3
- import RNFishjamClient, { ReceivableEvents } from '../RNFishjamClientModule';
4
- import { useFishjamEvent } from './internal/useFishjamEvent';
5
- function useCallKitIos() {
6
- const startCallKitSession = useCallback(async ({ displayName, isVideo }) => {
7
- try {
8
- await RNFishjamClient.startCallKitSession(displayName, isVideo);
9
- }
10
- catch (error) {
11
- console.error('Failed to start CallKit session:', error);
12
- throw error;
13
- }
14
- }, []);
15
- const endCallKitSession = useCallback(async () => {
16
- try {
17
- await RNFishjamClient.endCallKitSession();
18
- }
19
- catch (error) {
20
- console.error('Failed to end CallKit session:', error);
21
- throw error;
22
- }
23
- }, []);
24
- const getCallKitSessionStatus = useCallback(async () => {
25
- return RNFishjamClient.hasActiveCallKitSession;
26
- }, []);
27
- return {
28
- startCallKitSession,
29
- endCallKitSession,
30
- getCallKitSessionStatus,
31
- };
32
- }
33
- const useCallKitServiceIos = (config) => {
34
- const { displayName, isVideo } = config;
35
- const { startCallKitSession, endCallKitSession } = useCallKitIos();
36
- useEffect(() => {
37
- startCallKitSession({ displayName, isVideo });
38
- return () => {
39
- endCallKitSession();
40
- };
41
- }, [startCallKitSession, endCallKitSession, displayName, isVideo]);
42
- };
43
- const emptyFunction = () => { };
44
- const useCallKitEventIos = (action, callback) => {
45
- useFishjamEvent(ReceivableEvents.CallKitActionPerformed, (event) => {
46
- event[action] && callback(event[action]);
47
- });
48
- };
49
- /**
50
- * A hook for listening to CallKit actions on iOS. Does nothing on other platforms.
51
- * This hook allows you to respond to user interactions with the native iOS CallKit interface,
52
- * such as muting/unmuting the call, putting the call on hold, or ending the call from the
53
- * system's phone UI or lock screen controls.
54
- *
55
- * @param {keyof CallKitAction} action - The CallKit action to listen for. Available actions:
56
- * - `'started'` - CallKit session has started
57
- * - `'ended'` - User ended the call from CallKit UI
58
- * - `'failed'` - CallKit session failed to start
59
- * - `'muted'` - User toggled mute from CallKit UI
60
- * - `'held'` - User toggled hold from CallKit UI
61
- *
62
- * @param {Function} callback - Function called when the specified action occurs.
63
- *
64
- * @group Hooks
65
- * @category Connection
66
- *
67
- * @example
68
- * ```typescript
69
- * import { useCallKitEvent } from '@fishjam-cloud/react-native-client';
70
- *
71
- * // Listen for hold state changes
72
- * useCallKitEvent('held', (isOnHold: boolean) => {
73
- * console.log('Call hold state:', isOnHold);
74
- * // Handle hold state in your app
75
- * });
76
- * ```
77
- */
78
- export const useCallKitEvent = Platform.select({
79
- ios: useCallKitEventIos,
80
- default: emptyFunction,
81
- });
82
- /**
83
- * A hook for managing CallKit sessions on iOS. Does nothing on other platforms.
84
- * CallKit provides a native iOS interface for managing VoIP calls, integrating with the system's
85
- * phone UI and controls. Use this hook when you need fine-grained control over the CallKit session lifecycle.
86
- *
87
- * @returns {UseCallKitResult} An object containing methods to manage CallKit sessions:
88
- * - `startCallKitSession(config: CallKitConfig)` - Starts a CallKit session with the given configuration
89
- * - `endCallKitSession()` - Ends the current CallKit session
90
- * - `getCallKitSessionStatus()` - Returns whether there is currently an active CallKit session
91
- *
92
- * @group Hooks
93
- * @category Connection
94
- *
95
- * @example
96
- * ```typescript
97
- * import { useCallKit } from '@fishjam-cloud/react-native-client';
98
- *
99
- * const { startCallKitSession, endCallKitSession } = useCallKit();
100
- *
101
- * // Start a CallKit session
102
- * await startCallKitSession({ displayName: 'John Doe', isVideo: true });
103
- *
104
- * // Later, end the session
105
- * await endCallKitSession();
106
- * ```
107
- */
108
- export const useCallKit = Platform.select({
109
- ios: useCallKitIos,
110
- default: emptyFunction,
111
- });
112
- /**
113
- * A convenience hook for automatically managing CallKit session lifecycle on iOS. Does nothing on other platforms.
114
- * This hook automatically starts a CallKit session when the component mounts and ends it when the component unmounts.
115
- * Use this hook when you want CallKit to be active for the entire lifetime of a component (e.g., during a call).
116
- *
117
- * @param {CallKitConfig} config - Configuration object containing:
118
- * - `displayName` - The name to display in the CallKit UI (e.g., username, call title)
119
- * - `isVideo` - Whether the call is video or audio only
120
- *
121
- * @group Hooks
122
- * @category Connection
123
- *
124
- * @example
125
- * ```typescript
126
- * import React from 'react';
127
- * import { useCallKitService } from '@fishjam-cloud/react-native-client';
128
- *
129
- * function CallScreen({ username }: { username: string }) {
130
- * // CallKit session will automatically start when this component mounts
131
- * // and end when it unmounts
132
- * useCallKitService({ displayName: username, isVideo: true });
133
- *
134
- * return null;
135
- * }
136
- * ```
137
- */
138
- export const useCallKitService = Platform.select({
139
- ios: useCallKitServiceIos,
140
- default: emptyFunction,
141
- });
142
- //# sourceMappingURL=useCallKit.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useCallKit.js","sourceRoot":"","sources":["../../src/hooks/useCallKit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,eAAe,EAAE,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC7E,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAuC7D,SAAS,aAAa;IACpB,MAAM,mBAAmB,GAAG,WAAW,CACrC,KAAK,EAAE,EAAE,WAAW,EAAE,OAAO,EAAiB,EAAE,EAAE;QAChD,IAAI,CAAC;YACH,MAAM,eAAe,CAAC,mBAAmB,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;QAClE,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,kCAAkC,EAAE,KAAK,CAAC,CAAC;YACzD,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC,EACD,EAAE,CACH,CAAC;IAEF,MAAM,iBAAiB,GAAG,WAAW,CAAC,KAAK,IAAI,EAA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;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,QAAQ,CAAC,MAAM,CAAC;IAC7C,GAAG,EAAE,kBAAkB;IACvB,OAAO,EAAE,aAAa;CACvB,CAA8B,CAAC;AAEhC;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,QAAQ,CAAC,MAAM,CAAC;IACxC,GAAG,EAAE,aAAa;IAClB,OAAO,EAAE,aAAa;CACvB,CAAyB,CAAC;AAE3B;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,QAAQ,CAAC,MAAM,CAAC;IAC/C,GAAG,EAAE,oBAAoB;IACzB,OAAO,EAAE,aAAa;CACvB,CAAgC,CAAC","sourcesContent":["import { useCallback, useEffect } from 'react';\nimport { Platform } from 'react-native';\nimport RNFishjamClient, { ReceivableEvents } from '../RNFishjamClientModule';\nimport { useFishjamEvent } from './internal/useFishjamEvent';\n\nexport type CallKitAction = {\n ['started']: undefined;\n ['ended']: undefined;\n ['failed']: string;\n ['muted']: boolean;\n ['held']: boolean;\n};\n\nexport type UseCallKitResult = {\n /**\n * Starts a CallKit session for the current call\n * @param config - Configuration object containing displayName and isVideo\n */\n startCallKitSession: (config: CallKitConfig) => Promise<void>;\n\n /**\n * Ends the current CallKit session\n */\n endCallKitSession: () => Promise<void>;\n\n /**\n * Returns whether there is currently an active CallKit session\n */\n getCallKitSessionStatus: () => Promise<boolean>;\n};\n\nexport type CallKitConfig = {\n /**\n * The name to display in the CallKit UI\n */\n displayName: string;\n /**\n * Whether the should support video\n */\n isVideo: boolean;\n};\n\nfunction useCallKitIos(): UseCallKitResult {\n const startCallKitSession = useCallback(\n async ({ displayName, isVideo }: CallKitConfig) => {\n try {\n await RNFishjamClient.startCallKitSession(displayName, isVideo);\n } catch (error) {\n console.error('Failed to start CallKit session:', error);\n throw error;\n }\n },\n [],\n );\n\n const endCallKitSession = useCallback(async () => {\n try {\n await RNFishjamClient.endCallKitSession();\n } catch (error) {\n console.error('Failed to end CallKit session:', error);\n throw error;\n }\n }, []);\n\n const getCallKitSessionStatus = useCallback(async () => {\n return RNFishjamClient.hasActiveCallKitSession;\n }, []);\n\n return {\n startCallKitSession,\n endCallKitSession,\n getCallKitSessionStatus,\n };\n}\n\nconst useCallKitServiceIos = (config: CallKitConfig) => {\n const { displayName, isVideo } = config;\n\n const { startCallKitSession, endCallKitSession } = useCallKitIos();\n\n useEffect(() => {\n startCallKitSession({ displayName, isVideo });\n\n return () => {\n endCallKitSession();\n };\n }, [startCallKitSession, endCallKitSession, displayName, isVideo]);\n};\n\nconst emptyFunction = () => {};\n\nconst useCallKitEventIos = <T extends keyof CallKitAction>(\n action: T,\n callback: (event: CallKitAction[T]) => void,\n) => {\n useFishjamEvent(ReceivableEvents.CallKitActionPerformed, (event) => {\n event[action] && callback(event[action]);\n });\n};\n\n/**\n * A hook for listening to CallKit actions on iOS. Does nothing on other platforms.\n * This hook allows you to respond to user interactions with the native iOS CallKit interface,\n * such as muting/unmuting the call, putting the call on hold, or ending the call from the\n * system's phone UI or lock screen controls.\n *\n * @param {keyof CallKitAction} action - The CallKit action to listen for. Available actions:\n * - `'started'` - CallKit session has started\n * - `'ended'` - User ended the call from CallKit UI\n * - `'failed'` - CallKit session failed to start\n * - `'muted'` - User toggled mute from CallKit UI\n * - `'held'` - User toggled hold from CallKit UI\n *\n * @param {Function} callback - Function called when the specified action occurs.\n *\n * @group Hooks\n * @category Connection\n *\n * @example\n * ```typescript\n * import { useCallKitEvent } from '@fishjam-cloud/react-native-client';\n *\n * // Listen for hold state changes\n * useCallKitEvent('held', (isOnHold: boolean) => {\n * console.log('Call hold state:', isOnHold);\n * // Handle hold state in your app\n * });\n * ```\n */\nexport const useCallKitEvent = Platform.select({\n ios: useCallKitEventIos,\n default: emptyFunction,\n}) as typeof useCallKitEventIos;\n\n/**\n * A hook for managing CallKit sessions on iOS. Does nothing on other platforms.\n * CallKit provides a native iOS interface for managing VoIP calls, integrating with the system's\n * phone UI and controls. Use this hook when you need fine-grained control over the CallKit session lifecycle.\n *\n * @returns {UseCallKitResult} An object containing methods to manage CallKit sessions:\n * - `startCallKitSession(config: CallKitConfig)` - Starts a CallKit session with the given configuration\n * - `endCallKitSession()` - Ends the current CallKit session\n * - `getCallKitSessionStatus()` - Returns whether there is currently an active CallKit session\n *\n * @group Hooks\n * @category Connection\n *\n * @example\n * ```typescript\n * import { useCallKit } from '@fishjam-cloud/react-native-client';\n *\n * const { startCallKitSession, endCallKitSession } = useCallKit();\n *\n * // Start a CallKit session\n * await startCallKitSession({ displayName: 'John Doe', isVideo: true });\n *\n * // Later, end the session\n * await endCallKitSession();\n * ```\n */\nexport const useCallKit = Platform.select({\n ios: useCallKitIos,\n default: emptyFunction,\n}) as typeof useCallKitIos;\n\n/**\n * A convenience hook for automatically managing CallKit session lifecycle on iOS. Does nothing on other platforms.\n * This hook automatically starts a CallKit session when the component mounts and ends it when the component unmounts.\n * Use this hook when you want CallKit to be active for the entire lifetime of a component (e.g., during a call).\n *\n * @param {CallKitConfig} config - Configuration object containing:\n * - `displayName` - The name to display in the CallKit UI (e.g., username, call title)\n * - `isVideo` - Whether the call is video or audio only\n *\n * @group Hooks\n * @category Connection\n *\n * @example\n * ```typescript\n * import React from 'react';\n * import { useCallKitService } from '@fishjam-cloud/react-native-client';\n *\n * function CallScreen({ username }: { username: string }) {\n * // CallKit session will automatically start when this component mounts\n * // and end when it unmounts\n * useCallKitService({ displayName: username, isVideo: true });\n *\n * return null;\n * }\n * ```\n */\nexport const useCallKitService = Platform.select({\n ios: useCallKitServiceIos,\n default: emptyFunction,\n}) as typeof useCallKitServiceIos;\n"]}
@@ -1,113 +0,0 @@
1
- import { Brand, SimulcastConfig } from '../types';
2
- export type CameraId = Brand<string, 'CameraId'>;
3
- export type CameraFacingDirection = 'front' | 'back' | 'unspecified';
4
- export type Camera = {
5
- id: CameraId;
6
- name: string;
7
- facingDirection: CameraFacingDirection;
8
- };
9
- export type CurrentCameraChangedType = {
10
- currentCamera: Camera | null;
11
- isCameraOn: boolean;
12
- isCameraInitialized: boolean;
13
- };
14
- export type VideoQuality = 'QVGA169' | 'VGA169' | 'QHD169' | 'HD169' | 'FHD169' | 'QVGA43' | 'VGA43' | 'QHD43' | 'HD43' | 'FHD43';
15
- export type CameraConfigBase = {
16
- /**
17
- * resolution + aspect ratio of local video track, one of: `QVGA_169`, `VGA_169`, `QHD_169`, `HD_169`,
18
- * `FHD_169`, `QVGA_43`, `VGA_43`, `QHD_43`, `HD_43`, `FHD_43`. Note that quality might be worse than
19
- * specified due to device capabilities, internet connection etc.
20
- * @default `VGA_169`
21
- */
22
- quality?: VideoQuality;
23
- /**
24
- * whether to flip the dimensions of the video, that is whether to film in vertical orientation.
25
- * This basically switches width with height and is only used to select closes capture format.
26
- *
27
- * To record horizontal video your phone orientation must be in landscape and your app must support this orientation.
28
- *
29
- * Platform specific capture formats:
30
- * @see [iOS](https://developer.apple.com/documentation/avfoundation/avcapturedevice/format)
31
- * @see [Android](https://github.com/webrtc-sdk/webrtc/blob/cdc3bba5aa38910a55428b919ba45aceac1ad9ad/sdk/android/api/org/webrtc/CameraEnumerationAndroid.java#L50)
32
- *
33
- * WebRTC device orientation handling:
34
- * @see [iOS](https://github.com/webrtc-sdk/webrtc/blob/cdc3bba5aa38910a55428b919ba45aceac1ad9ad/sdk/objc/components/capturer/RTCCameraVideoCapturer.m#L285)
35
- * @see [Android](https://github.com/pristineio/webrtc-mirror/blob/7a5bcdffaab90a05bc1146b2b1ea71c004e54d71/webrtc/sdk/android/src/java/org/webrtc/Camera2Session.java#L347)
36
- *
37
- * @default `true`
38
- */
39
- flipDimensions?: boolean;
40
- /**
41
- * whether the camera track is initially enabled, you can toggle it on/off later with toggleCamera method
42
- * @default `true`
43
- */
44
- cameraEnabled?: boolean;
45
- /**
46
- * id of the camera to start capture with. Get available cameras with `cameras`.
47
- * You can switch the cameras later with `switchCamera` functions.
48
- * @default `the first front camera`
49
- */
50
- cameraId?: CameraId;
51
- };
52
- export type CameraConfig = CameraConfigBase & {
53
- /**
54
- * @deprecated Simulcast is no longer supported
55
- */
56
- simulcastEnabled?: boolean;
57
- };
58
- export type CameraConfigInternal = CameraConfigBase & {
59
- videoTrackMetadata?: {
60
- active: boolean;
61
- type: 'camera';
62
- };
63
- /**
64
- * @deprecated Simulcast is no longer supported
65
- */
66
- simulcastConfig?: SimulcastConfig;
67
- };
68
- export declare function updateCameraConfig(config: Readonly<CameraConfig>): CameraConfigInternal;
69
- /**
70
- * This hook can toggle camera on/off and provides current camera state.
71
- * @category Devices
72
- * @group Hooks
73
- */
74
- export declare function useCamera(): {
75
- /**
76
- * Informs if user camera is streaming video
77
- */
78
- isCameraOn: boolean;
79
- /**
80
- * Which camera is now used for streaming (or will be used as default when camera will be enabled)
81
- */
82
- currentCamera: Camera | null;
83
- /**
84
- * Simulcast configuration
85
- */
86
- simulcastConfig: SimulcastConfig;
87
- /**
88
- * Property that lists cameras available on device.
89
- * @returns A promise that resolves to the list of available cameras.
90
- */
91
- cameras: readonly Camera[];
92
- /**
93
- * A value indicating if camera was already initialized (if `prepareCamera` was called).
94
- */
95
- isInitialized: boolean;
96
- /**
97
- * Enable/disable current camera
98
- */
99
- toggleCamera: () => Promise<void>;
100
- /**
101
- * Prepares camera and starts local video track
102
- * @param config configuration of the camera capture
103
- * @returns A promise that resolves when camera is started.
104
- */
105
- prepareCamera: (config?: Readonly<CameraConfig>) => Promise<boolean>;
106
- /**
107
- * Switches to the specified camera.
108
- * List of available devices can be retrieved from `cameras` variable
109
- * @returns A promise that resolves when camera is switched.
110
- */
111
- switchCamera: (cameraId: CameraId) => Promise<void>;
112
- };
113
- //# sourceMappingURL=useCamera.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useCamera.d.ts","sourceRoot":"","sources":["../../src/hooks/useCamera.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,eAAe,EAA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AY,CAAC,GAC7B,oBAAoB,CAMtB;AAED;;;;GAIG;AACH,wBAAgB,SAAS;IAmDrB;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;;OAGG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;;;OAIG;6BA1DY,QAAQ,CAAC,YAAY,CAAC;IA4DrC;;;;OAIG;6BAxC6C,QAAQ;EA2C3D"}
@@ -1,93 +0,0 @@
1
- import { useCallback, useMemo } from 'react';
2
- import RNFishjamClientModule, { ReceivableEvents, } from '../RNFishjamClientModule';
3
- import { useFishjamEventState } from './internal/useFishjamEventState';
4
- const defaultSimulcastConfig = () => ({
5
- enabled: false,
6
- });
7
- function getSimulcastConfig(simulcastEnabled) {
8
- // TODO FCE-2265: Remove in next major release
9
- return undefined;
10
- }
11
- export function updateCameraConfig(config) {
12
- return {
13
- ...config,
14
- videoTrackMetadata: { active: true, type: 'camera' },
15
- simulcastConfig: getSimulcastConfig(config.simulcastEnabled),
16
- };
17
- }
18
- /**
19
- * This hook can toggle camera on/off and provides current camera state.
20
- * @category Devices
21
- * @group Hooks
22
- */
23
- export function useCamera() {
24
- const simulcastConfig = useFishjamEventState(ReceivableEvents.SimulcastConfigUpdate, defaultSimulcastConfig());
25
- const { currentCamera: currentCameraState, isCameraOn, isCameraInitialized, } = useFishjamEventState(ReceivableEvents.CurrentCameraChanged, {
26
- currentCamera: RNFishjamClientModule.currentCamera,
27
- isCameraOn: RNFishjamClientModule.isCameraOn,
28
- isCameraInitialized: RNFishjamClientModule.isCameraInitialized,
29
- });
30
- // For Android Expo converts null to undefined ¯\_(ツ)_/¯
31
- const currentCamera = currentCameraState ?? null;
32
- const cameras = useMemo(() => RNFishjamClientModule.cameras, []);
33
- const prepareCamera = useCallback(async (config = {}) => {
34
- const camera = RNFishjamClientModule.cameras.find((cam) => config.cameraId
35
- ? cam.id === config.cameraId
36
- : cam.facingDirection === 'front');
37
- const updatedConfig = updateCameraConfig({
38
- ...config,
39
- cameraId: camera?.id,
40
- });
41
- return RNFishjamClientModule.startCamera(updatedConfig);
42
- }, []);
43
- const toggleCamera = useCallback(async () => {
44
- const state = await RNFishjamClientModule.toggleCamera();
45
- await RNFishjamClientModule.updateVideoTrackMetadata({
46
- active: state,
47
- type: 'camera',
48
- });
49
- }, []);
50
- const switchCamera = useCallback(async (cameraId) => {
51
- await RNFishjamClientModule.switchCamera(cameraId);
52
- }, []);
53
- return {
54
- /**
55
- * Informs if user camera is streaming video
56
- */
57
- isCameraOn,
58
- /**
59
- * Which camera is now used for streaming (or will be used as default when camera will be enabled)
60
- */
61
- currentCamera,
62
- /**
63
- * Simulcast configuration
64
- */
65
- simulcastConfig,
66
- /**
67
- * Property that lists cameras available on device.
68
- * @returns A promise that resolves to the list of available cameras.
69
- */
70
- cameras,
71
- /**
72
- * A value indicating if camera was already initialized (if `prepareCamera` was called).
73
- */
74
- isInitialized: isCameraInitialized,
75
- /**
76
- * Enable/disable current camera
77
- */
78
- toggleCamera,
79
- /**
80
- * Prepares camera and starts local video track
81
- * @param config configuration of the camera capture
82
- * @returns A promise that resolves when camera is started.
83
- */
84
- prepareCamera,
85
- /**
86
- * Switches to the specified camera.
87
- * List of available devices can be retrieved from `cameras` variable
88
- * @returns A promise that resolves when camera is switched.
89
- */
90
- switchCamera,
91
- };
92
- }
93
- //# sourceMappingURL=useCamera.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useCamera.js","sourceRoot":"","sources":["../../src/hooks/useCamera.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAE7C,OAAO,qBAAqB,EAAE,EAC5B,gBAAgB,GACjB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAmFvE,MAAM,sBAAsB,GAAG,GAAG,EAAE,CAClC,CAAC;IACC,OAAO,EAAE,KAAK;CACf,CAA2B,CAAC;AAE/B,SAAS,kBAAkB,CACzB,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AAM,EAAE,EAAE;SACrB,CAAC,CAAC;QACH,OAAO,qBAAqB,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC;IAC1D,CAAC,EACD,EAAE,CACH,CAAC;IAEF,MAAM,YAAY,GAAG,WAAW,CAAC,KAAK,IAAI,EAAE;QAC1C,MAAM,KAAK,GAAG,MAAM,qBAAqB,CAAC,YAAY,EAAE,CAAC;QACzD,MAAM,qBAAqB,CAAC,wBAAwB,CAAC;YACnD,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,QAAQ;SACf,CAAC,CAAC;IACL,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,YAAY,GAAG,WAAW,CAAC,KAAK,EAAE,QAAkB,EAAE,EAAE;QAC5D,MAAM,qBAAqB,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;IACrD,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO;QACL;;WAEG;QACH,UAAU;QACV;;WAEG;QACH,aAAa;QACb;;WAEG;QACH,eAAe;QACf;;;WAGG;QACH,OAAO;QACP;;WAEG;QACH,aAAa,EAAE,mBAAmB;QAClC;;WAEG;QACH,YAAY;QACZ;;;;WAIG;QACH,aAAa;QACb;;;;WAIG;QACH,YAAY;KACb,CAAC;AACJ,CAAC","sourcesContent":["import { useCallback, useMemo } from 'react';\nimport { Brand, SimulcastConfig } from '../types';\nimport RNFishjamClientModule, {\n ReceivableEvents,\n} from '../RNFishjamClientModule';\nimport { useFishjamEventState } from './internal/useFishjamEventState';\n\nexport type CameraId = Brand<string, 'CameraId'>;\n\nexport type CameraFacingDirection = 'front' | 'back' | 'unspecified';\n\nexport type Camera = {\n id: CameraId;\n name: string;\n facingDirection: CameraFacingDirection;\n};\n\nexport type CurrentCameraChangedType = {\n currentCamera: Camera | null;\n isCameraOn: boolean;\n isCameraInitialized: boolean;\n};\n\nexport type VideoQuality =\n | 'QVGA169'\n | 'VGA169'\n | 'QHD169'\n | 'HD169'\n | 'FHD169'\n | 'QVGA43'\n | 'VGA43'\n | 'QHD43'\n | 'HD43'\n | 'FHD43';\n\nexport type CameraConfigBase = {\n /**\n * resolution + aspect ratio of local video track, one of: `QVGA_169`, `VGA_169`, `QHD_169`, `HD_169`,\n * `FHD_169`, `QVGA_43`, `VGA_43`, `QHD_43`, `HD_43`, `FHD_43`. Note that quality might be worse than\n * specified due to device capabilities, internet connection etc.\n * @default `VGA_169`\n */\n quality?: VideoQuality;\n /**\n * whether to flip the dimensions of the video, that is whether to film in vertical orientation.\n * This basically switches width with height and is only used to select closes capture format.\n *\n * To record horizontal video your phone orientation must be in landscape and your app must support this orientation.\n *\n * Platform specific capture formats:\n * @see [iOS](https://developer.apple.com/documentation/avfoundation/avcapturedevice/format)\n * @see [Android](https://github.com/webrtc-sdk/webrtc/blob/cdc3bba5aa38910a55428b919ba45aceac1ad9ad/sdk/android/api/org/webrtc/CameraEnumerationAndroid.java#L50)\n *\n * WebRTC device orientation handling:\n * @see [iOS](https://github.com/webrtc-sdk/webrtc/blob/cdc3bba5aa38910a55428b919ba45aceac1ad9ad/sdk/objc/components/capturer/RTCCameraVideoCapturer.m#L285)\n * @see [Android](https://github.com/pristineio/webrtc-mirror/blob/7a5bcdffaab90a05bc1146b2b1ea71c004e54d71/webrtc/sdk/android/src/java/org/webrtc/Camera2Session.java#L347)\n *\n * @default `true`\n */\n flipDimensions?: boolean;\n /**\n * whether the camera track is initially enabled, you can toggle it on/off later with toggleCamera method\n * @default `true`\n */\n cameraEnabled?: boolean;\n /**\n * id of the camera to start capture with. Get available cameras with `cameras`.\n * You can switch the cameras later with `switchCamera` functions.\n * @default `the first front camera`\n */\n cameraId?: CameraId;\n};\n\nexport type CameraConfig = CameraConfigBase & {\n /**\n * @deprecated Simulcast is no longer supported\n */\n simulcastEnabled?: boolean;\n};\n\nexport type CameraConfigInternal = CameraConfigBase & {\n videoTrackMetadata?: { active: boolean; type: 'camera' };\n /**\n * @deprecated Simulcast is no longer supported\n */\n simulcastConfig?: SimulcastConfig;\n};\n\nconst defaultSimulcastConfig = () =>\n ({\n enabled: false,\n }) satisfies SimulcastConfig;\n\nfunction getSimulcastConfig(\n simulcastEnabled: boolean | undefined,\n): SimulcastConfig | undefined {\n // TODO FCE-2265: Remove in next major release\n return undefined;\n}\n\nexport function updateCameraConfig(\n config: Readonly<CameraConfig>,\n): CameraConfigInternal {\n return {\n ...config,\n videoTrackMetadata: { active: true, type: 'camera' },\n simulcastConfig: getSimulcastConfig(config.simulcastEnabled),\n };\n}\n\n/**\n * This hook can toggle camera on/off and provides current camera state.\n * @category Devices\n * @group Hooks\n */\nexport function useCamera() {\n const simulcastConfig = useFishjamEventState(\n ReceivableEvents.SimulcastConfigUpdate,\n defaultSimulcastConfig(), // TODO: Fetch from native\n );\n\n const {\n currentCamera: currentCameraState,\n isCameraOn,\n isCameraInitialized,\n } = useFishjamEventState(ReceivableEvents.CurrentCameraChanged, {\n currentCamera: RNFishjamClientModule.currentCamera,\n isCameraOn: RNFishjamClientModule.isCameraOn,\n isCameraInitialized: RNFishjamClientModule.isCameraInitialized,\n });\n\n // For Android Expo converts null to undefined ¯\\_(ツ)_/¯\n const currentCamera = currentCameraState ?? null;\n\n const cameras = useMemo(() => RNFishjamClientModule.cameras, []);\n\n const prepareCamera = useCallback(\n async (config: Readonly<CameraConfig> = {}) => {\n const camera = RNFishjamClientModule.cameras.find((cam) =>\n config.cameraId\n ? cam.id === config.cameraId\n : cam.facingDirection === 'front',\n );\n\n const updatedConfig = updateCameraConfig({\n ...config,\n cameraId: camera?.id,\n });\n return RNFishjamClientModule.startCamera(updatedConfig);\n },\n [],\n );\n\n const toggleCamera = useCallback(async () => {\n const state = await RNFishjamClientModule.toggleCamera();\n await RNFishjamClientModule.updateVideoTrackMetadata({\n active: state,\n type: 'camera',\n });\n }, []);\n\n const switchCamera = useCallback(async (cameraId: CameraId) => {\n await RNFishjamClientModule.switchCamera(cameraId);\n }, []);\n\n return {\n /**\n * Informs if user camera is streaming video\n */\n isCameraOn,\n /**\n * Which camera is now used for streaming (or will be used as default when camera will be enabled)\n */\n currentCamera,\n /**\n * Simulcast configuration\n */\n simulcastConfig,\n /**\n * Property that lists cameras available on device.\n * @returns A promise that resolves to the list of available cameras.\n */\n cameras,\n /**\n * A value indicating if camera was already initialized (if `prepareCamera` was called).\n */\n isInitialized: isCameraInitialized,\n /**\n * Enable/disable current camera\n */\n toggleCamera,\n /**\n * Prepares camera and starts local video track\n * @param config configuration of the camera capture\n * @returns A promise that resolves when camera is started.\n */\n prepareCamera,\n /**\n * Switches to the specified camera.\n * List of available devices can be retrieved from `cameras` variable\n * @returns A promise that resolves when camera is switched.\n */\n switchCamera,\n };\n}\n"]}