@syra.fm/sdk 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (307) hide show
  1. package/lib/commonjs/client.js +268 -0
  2. package/lib/commonjs/client.js.map +1 -0
  3. package/lib/commonjs/errors.js +22 -0
  4. package/lib/commonjs/errors.js.map +1 -0
  5. package/lib/commonjs/index.js +63 -0
  6. package/lib/commonjs/index.js.map +1 -0
  7. package/lib/commonjs/index.native.js +28 -0
  8. package/lib/commonjs/index.native.js.map +1 -0
  9. package/lib/commonjs/live/assets/icons/spaces-icon.js +42 -0
  10. package/lib/commonjs/live/assets/icons/spaces-icon.js.map +1 -0
  11. package/lib/commonjs/live/assets/icons/syra-icon.js +43 -0
  12. package/lib/commonjs/live/assets/icons/syra-icon.js.map +1 -0
  13. package/lib/commonjs/live/components/AnimatedPulse.js +38 -0
  14. package/lib/commonjs/live/components/AnimatedPulse.js.map +1 -0
  15. package/lib/commonjs/live/components/AnimatedSpeakerRing.js +90 -0
  16. package/lib/commonjs/live/components/AnimatedSpeakerRing.js.map +1 -0
  17. package/lib/commonjs/live/components/CreateRoomSheet.js +688 -0
  18. package/lib/commonjs/live/components/CreateRoomSheet.js.map +1 -0
  19. package/lib/commonjs/live/components/InsightsPanel.js +333 -0
  20. package/lib/commonjs/live/components/InsightsPanel.js.map +1 -0
  21. package/lib/commonjs/live/components/LiveRoomSheet.js +1195 -0
  22. package/lib/commonjs/live/components/LiveRoomSheet.js.map +1 -0
  23. package/lib/commonjs/live/components/MiniRoomBar.js +161 -0
  24. package/lib/commonjs/live/components/MiniRoomBar.js.map +1 -0
  25. package/lib/commonjs/live/components/PanelHeader.js +57 -0
  26. package/lib/commonjs/live/components/PanelHeader.js.map +1 -0
  27. package/lib/commonjs/live/components/PodcastStreamPicker.js +1190 -0
  28. package/lib/commonjs/live/components/PodcastStreamPicker.js.map +1 -0
  29. package/lib/commonjs/live/components/RecordingCard.js +192 -0
  30. package/lib/commonjs/live/components/RecordingCard.js.map +1 -0
  31. package/lib/commonjs/live/components/RecordingsPanel.js +304 -0
  32. package/lib/commonjs/live/components/RecordingsPanel.js.map +1 -0
  33. package/lib/commonjs/live/components/RoomCard.js +553 -0
  34. package/lib/commonjs/live/components/RoomCard.js.map +1 -0
  35. package/lib/commonjs/live/components/StreamConfigModal.js +656 -0
  36. package/lib/commonjs/live/components/StreamConfigModal.js.map +1 -0
  37. package/lib/commonjs/live/components/StreamConfigPanel.js +822 -0
  38. package/lib/commonjs/live/components/StreamConfigPanel.js.map +1 -0
  39. package/lib/commonjs/live/context/LiveConfigContext.js +46 -0
  40. package/lib/commonjs/live/context/LiveConfigContext.js.map +1 -0
  41. package/lib/commonjs/live/context/LiveRoomContext.js +195 -0
  42. package/lib/commonjs/live/context/LiveRoomContext.js.map +1 -0
  43. package/lib/commonjs/live/hooks/useActiveSpeakers.js +35 -0
  44. package/lib/commonjs/live/hooks/useActiveSpeakers.js.map +1 -0
  45. package/lib/commonjs/live/hooks/useRoomAudio.js +129 -0
  46. package/lib/commonjs/live/hooks/useRoomAudio.js.map +1 -0
  47. package/lib/commonjs/live/hooks/useRoomConnection.js +177 -0
  48. package/lib/commonjs/live/hooks/useRoomConnection.js.map +1 -0
  49. package/lib/commonjs/live/hooks/useRoomManager.js +37 -0
  50. package/lib/commonjs/live/hooks/useRoomManager.js.map +1 -0
  51. package/lib/commonjs/live/hooks/useRoomUsers.js +52 -0
  52. package/lib/commonjs/live/hooks/useRoomUsers.js.map +1 -0
  53. package/lib/commonjs/live/index.js +310 -0
  54. package/lib/commonjs/live/index.js.map +1 -0
  55. package/lib/commonjs/live/services/livekitService.js +20 -0
  56. package/lib/commonjs/live/services/livekitService.js.map +1 -0
  57. package/lib/commonjs/live/services/spaceSocketService.js +181 -0
  58. package/lib/commonjs/live/services/spaceSocketService.js.map +1 -0
  59. package/lib/commonjs/live/services/spacesService.js +642 -0
  60. package/lib/commonjs/live/services/spacesService.js.map +1 -0
  61. package/lib/commonjs/live/types.js +6 -0
  62. package/lib/commonjs/live/types.js.map +1 -0
  63. package/lib/commonjs/live/validation.js +238 -0
  64. package/lib/commonjs/live/validation.js.map +1 -0
  65. package/lib/commonjs/package.json +1 -0
  66. package/{dist/cjs → lib/commonjs}/schema.js +55 -47
  67. package/lib/commonjs/schema.js.map +1 -0
  68. package/lib/module/client.js +264 -0
  69. package/lib/module/client.js.map +1 -0
  70. package/lib/module/errors.js +17 -0
  71. package/lib/module/errors.js.map +1 -0
  72. package/lib/module/index.js +6 -0
  73. package/lib/module/index.js.map +1 -0
  74. package/lib/module/index.native.js +5 -0
  75. package/lib/module/index.native.js.map +1 -0
  76. package/lib/module/live/assets/icons/spaces-icon.js +34 -0
  77. package/lib/module/live/assets/icons/spaces-icon.js.map +1 -0
  78. package/lib/module/live/assets/icons/syra-icon.js +36 -0
  79. package/lib/module/live/assets/icons/syra-icon.js.map +1 -0
  80. package/lib/module/live/components/AnimatedPulse.js +33 -0
  81. package/lib/module/live/components/AnimatedPulse.js.map +1 -0
  82. package/lib/module/live/components/AnimatedSpeakerRing.js +85 -0
  83. package/lib/module/live/components/AnimatedSpeakerRing.js.map +1 -0
  84. package/lib/module/live/components/CreateRoomSheet.js +682 -0
  85. package/lib/module/live/components/CreateRoomSheet.js.map +1 -0
  86. package/lib/module/live/components/InsightsPanel.js +327 -0
  87. package/lib/module/live/components/InsightsPanel.js.map +1 -0
  88. package/lib/module/live/components/LiveRoomSheet.js +1189 -0
  89. package/lib/module/live/components/LiveRoomSheet.js.map +1 -0
  90. package/lib/module/live/components/MiniRoomBar.js +154 -0
  91. package/lib/module/live/components/MiniRoomBar.js.map +1 -0
  92. package/lib/module/live/components/PanelHeader.js +52 -0
  93. package/lib/module/live/components/PanelHeader.js.map +1 -0
  94. package/lib/module/live/components/PodcastStreamPicker.js +1183 -0
  95. package/lib/module/live/components/PodcastStreamPicker.js.map +1 -0
  96. package/lib/module/live/components/RecordingCard.js +187 -0
  97. package/lib/module/live/components/RecordingCard.js.map +1 -0
  98. package/lib/module/live/components/RecordingsPanel.js +298 -0
  99. package/lib/module/live/components/RecordingsPanel.js.map +1 -0
  100. package/lib/module/live/components/RoomCard.js +548 -0
  101. package/lib/module/live/components/RoomCard.js.map +1 -0
  102. package/lib/module/live/components/StreamConfigModal.js +650 -0
  103. package/lib/module/live/components/StreamConfigModal.js.map +1 -0
  104. package/lib/module/live/components/StreamConfigPanel.js +816 -0
  105. package/lib/module/live/components/StreamConfigPanel.js.map +1 -0
  106. package/lib/module/live/context/LiveConfigContext.js +40 -0
  107. package/lib/module/live/context/LiveConfigContext.js.map +1 -0
  108. package/lib/module/live/context/LiveRoomContext.js +189 -0
  109. package/lib/module/live/context/LiveRoomContext.js.map +1 -0
  110. package/lib/module/live/hooks/useActiveSpeakers.js +31 -0
  111. package/lib/module/live/hooks/useActiveSpeakers.js.map +1 -0
  112. package/lib/module/live/hooks/useRoomAudio.js +125 -0
  113. package/lib/module/live/hooks/useRoomAudio.js.map +1 -0
  114. package/lib/module/live/hooks/useRoomConnection.js +173 -0
  115. package/lib/module/live/hooks/useRoomConnection.js.map +1 -0
  116. package/lib/module/live/hooks/useRoomManager.js +32 -0
  117. package/lib/module/live/hooks/useRoomManager.js.map +1 -0
  118. package/lib/module/live/hooks/useRoomUsers.js +46 -0
  119. package/lib/module/live/hooks/useRoomUsers.js.map +1 -0
  120. package/lib/module/live/index.js +38 -0
  121. package/lib/module/live/index.js.map +1 -0
  122. package/lib/module/live/services/livekitService.js +16 -0
  123. package/lib/module/live/services/livekitService.js.map +1 -0
  124. package/lib/module/live/services/spaceSocketService.js +176 -0
  125. package/lib/module/live/services/spaceSocketService.js.map +1 -0
  126. package/lib/module/live/services/spacesService.js +639 -0
  127. package/lib/module/live/services/spacesService.js.map +1 -0
  128. package/lib/module/live/types.js +4 -0
  129. package/lib/module/live/types.js.map +1 -0
  130. package/lib/module/live/validation.js +229 -0
  131. package/lib/module/live/validation.js.map +1 -0
  132. package/lib/module/package.json +1 -0
  133. package/{dist/esm → lib/module}/schema.js +47 -39
  134. package/lib/module/schema.js.map +1 -0
  135. package/{dist/types → lib/typescript/commonjs}/client.d.ts +1 -0
  136. package/lib/typescript/commonjs/client.d.ts.map +1 -0
  137. package/{dist/types → lib/typescript/commonjs}/errors.d.ts +1 -0
  138. package/lib/typescript/commonjs/errors.d.ts.map +1 -0
  139. package/{dist/types → lib/typescript/commonjs}/index.d.ts +1 -0
  140. package/lib/typescript/commonjs/index.d.ts.map +1 -0
  141. package/lib/typescript/commonjs/index.native.d.ts +3 -0
  142. package/lib/typescript/commonjs/index.native.d.ts.map +1 -0
  143. package/lib/typescript/commonjs/live/assets/icons/spaces-icon.d.ts +13 -0
  144. package/lib/typescript/commonjs/live/assets/icons/spaces-icon.d.ts.map +1 -0
  145. package/lib/typescript/commonjs/live/assets/icons/syra-icon.d.ts +13 -0
  146. package/lib/typescript/commonjs/live/assets/icons/syra-icon.d.ts.map +1 -0
  147. package/lib/typescript/commonjs/live/components/AnimatedPulse.d.ts +8 -0
  148. package/lib/typescript/commonjs/live/components/AnimatedPulse.d.ts.map +1 -0
  149. package/lib/typescript/commonjs/live/components/AnimatedSpeakerRing.d.ts +10 -0
  150. package/lib/typescript/commonjs/live/components/AnimatedSpeakerRing.d.ts.map +1 -0
  151. package/lib/typescript/commonjs/live/components/CreateRoomSheet.d.ts +26 -0
  152. package/lib/typescript/commonjs/live/components/CreateRoomSheet.d.ts.map +1 -0
  153. package/lib/typescript/commonjs/live/components/InsightsPanel.d.ts +11 -0
  154. package/lib/typescript/commonjs/live/components/InsightsPanel.d.ts.map +1 -0
  155. package/lib/typescript/commonjs/live/components/LiveRoomSheet.d.ts +11 -0
  156. package/lib/typescript/commonjs/live/components/LiveRoomSheet.d.ts.map +1 -0
  157. package/lib/typescript/commonjs/live/components/MiniRoomBar.d.ts +15 -0
  158. package/lib/typescript/commonjs/live/components/MiniRoomBar.d.ts.map +1 -0
  159. package/lib/typescript/commonjs/live/components/PanelHeader.d.ts +10 -0
  160. package/lib/typescript/commonjs/live/components/PanelHeader.d.ts.map +1 -0
  161. package/lib/typescript/commonjs/live/components/PodcastStreamPicker.d.ts +54 -0
  162. package/lib/typescript/commonjs/live/components/PodcastStreamPicker.d.ts.map +1 -0
  163. package/lib/typescript/commonjs/live/components/RecordingCard.d.ts +11 -0
  164. package/lib/typescript/commonjs/live/components/RecordingCard.d.ts.map +1 -0
  165. package/lib/typescript/commonjs/live/components/RecordingsPanel.d.ts +12 -0
  166. package/lib/typescript/commonjs/live/components/RecordingsPanel.d.ts.map +1 -0
  167. package/lib/typescript/commonjs/live/components/RoomCard.d.ts +38 -0
  168. package/lib/typescript/commonjs/live/components/RoomCard.d.ts.map +1 -0
  169. package/lib/typescript/commonjs/live/components/StreamConfigModal.d.ts +11 -0
  170. package/lib/typescript/commonjs/live/components/StreamConfigModal.d.ts.map +1 -0
  171. package/lib/typescript/commonjs/live/components/StreamConfigPanel.d.ts +13 -0
  172. package/lib/typescript/commonjs/live/components/StreamConfigPanel.d.ts.map +1 -0
  173. package/lib/typescript/commonjs/live/context/LiveConfigContext.d.ts +78 -0
  174. package/lib/typescript/commonjs/live/context/LiveConfigContext.d.ts.map +1 -0
  175. package/lib/typescript/commonjs/live/context/LiveRoomContext.d.ts +12 -0
  176. package/lib/typescript/commonjs/live/context/LiveRoomContext.d.ts.map +1 -0
  177. package/lib/typescript/commonjs/live/hooks/useActiveSpeakers.d.ts +3 -0
  178. package/lib/typescript/commonjs/live/hooks/useActiveSpeakers.d.ts.map +1 -0
  179. package/lib/typescript/commonjs/live/hooks/useRoomAudio.d.ts +16 -0
  180. package/lib/typescript/commonjs/live/hooks/useRoomAudio.d.ts.map +1 -0
  181. package/lib/typescript/commonjs/live/hooks/useRoomConnection.d.ts +29 -0
  182. package/lib/typescript/commonjs/live/hooks/useRoomConnection.d.ts.map +1 -0
  183. package/lib/typescript/commonjs/live/hooks/useRoomManager.d.ts +11 -0
  184. package/lib/typescript/commonjs/live/hooks/useRoomManager.d.ts.map +1 -0
  185. package/lib/typescript/commonjs/live/hooks/useRoomUsers.d.ts +5 -0
  186. package/lib/typescript/commonjs/live/hooks/useRoomUsers.d.ts.map +1 -0
  187. package/lib/typescript/commonjs/live/index.d.ts +24 -0
  188. package/lib/typescript/commonjs/live/index.d.ts.map +1 -0
  189. package/lib/typescript/commonjs/live/services/livekitService.d.ts +7 -0
  190. package/lib/typescript/commonjs/live/services/livekitService.d.ts.map +1 -0
  191. package/lib/typescript/commonjs/live/services/spaceSocketService.d.ts +69 -0
  192. package/lib/typescript/commonjs/live/services/spaceSocketService.d.ts.map +1 -0
  193. package/lib/typescript/commonjs/live/services/spacesService.d.ts +181 -0
  194. package/lib/typescript/commonjs/live/services/spacesService.d.ts.map +1 -0
  195. package/lib/typescript/commonjs/live/types.d.ts +100 -0
  196. package/lib/typescript/commonjs/live/types.d.ts.map +1 -0
  197. package/lib/typescript/commonjs/live/validation.d.ts +658 -0
  198. package/lib/typescript/commonjs/live/validation.d.ts.map +1 -0
  199. package/lib/typescript/commonjs/package.json +1 -0
  200. package/{dist/types → lib/typescript/commonjs}/schema.d.ts +1 -0
  201. package/lib/typescript/commonjs/schema.d.ts.map +1 -0
  202. package/lib/typescript/module/client.d.ts +141 -0
  203. package/lib/typescript/module/client.d.ts.map +1 -0
  204. package/lib/typescript/module/errors.d.ts +9 -0
  205. package/lib/typescript/module/errors.d.ts.map +1 -0
  206. package/lib/typescript/module/index.d.ts +6 -0
  207. package/lib/typescript/module/index.d.ts.map +1 -0
  208. package/lib/typescript/module/index.native.d.ts +3 -0
  209. package/lib/typescript/module/index.native.d.ts.map +1 -0
  210. package/lib/typescript/module/live/assets/icons/spaces-icon.d.ts +13 -0
  211. package/lib/typescript/module/live/assets/icons/spaces-icon.d.ts.map +1 -0
  212. package/lib/typescript/module/live/assets/icons/syra-icon.d.ts +13 -0
  213. package/lib/typescript/module/live/assets/icons/syra-icon.d.ts.map +1 -0
  214. package/lib/typescript/module/live/components/AnimatedPulse.d.ts +8 -0
  215. package/lib/typescript/module/live/components/AnimatedPulse.d.ts.map +1 -0
  216. package/lib/typescript/module/live/components/AnimatedSpeakerRing.d.ts +10 -0
  217. package/lib/typescript/module/live/components/AnimatedSpeakerRing.d.ts.map +1 -0
  218. package/lib/typescript/module/live/components/CreateRoomSheet.d.ts +26 -0
  219. package/lib/typescript/module/live/components/CreateRoomSheet.d.ts.map +1 -0
  220. package/lib/typescript/module/live/components/InsightsPanel.d.ts +11 -0
  221. package/lib/typescript/module/live/components/InsightsPanel.d.ts.map +1 -0
  222. package/lib/typescript/module/live/components/LiveRoomSheet.d.ts +11 -0
  223. package/lib/typescript/module/live/components/LiveRoomSheet.d.ts.map +1 -0
  224. package/lib/typescript/module/live/components/MiniRoomBar.d.ts +15 -0
  225. package/lib/typescript/module/live/components/MiniRoomBar.d.ts.map +1 -0
  226. package/lib/typescript/module/live/components/PanelHeader.d.ts +10 -0
  227. package/lib/typescript/module/live/components/PanelHeader.d.ts.map +1 -0
  228. package/lib/typescript/module/live/components/PodcastStreamPicker.d.ts +54 -0
  229. package/lib/typescript/module/live/components/PodcastStreamPicker.d.ts.map +1 -0
  230. package/lib/typescript/module/live/components/RecordingCard.d.ts +11 -0
  231. package/lib/typescript/module/live/components/RecordingCard.d.ts.map +1 -0
  232. package/lib/typescript/module/live/components/RecordingsPanel.d.ts +12 -0
  233. package/lib/typescript/module/live/components/RecordingsPanel.d.ts.map +1 -0
  234. package/lib/typescript/module/live/components/RoomCard.d.ts +38 -0
  235. package/lib/typescript/module/live/components/RoomCard.d.ts.map +1 -0
  236. package/lib/typescript/module/live/components/StreamConfigModal.d.ts +11 -0
  237. package/lib/typescript/module/live/components/StreamConfigModal.d.ts.map +1 -0
  238. package/lib/typescript/module/live/components/StreamConfigPanel.d.ts +13 -0
  239. package/lib/typescript/module/live/components/StreamConfigPanel.d.ts.map +1 -0
  240. package/lib/typescript/module/live/context/LiveConfigContext.d.ts +78 -0
  241. package/lib/typescript/module/live/context/LiveConfigContext.d.ts.map +1 -0
  242. package/lib/typescript/module/live/context/LiveRoomContext.d.ts +12 -0
  243. package/lib/typescript/module/live/context/LiveRoomContext.d.ts.map +1 -0
  244. package/lib/typescript/module/live/hooks/useActiveSpeakers.d.ts +3 -0
  245. package/lib/typescript/module/live/hooks/useActiveSpeakers.d.ts.map +1 -0
  246. package/lib/typescript/module/live/hooks/useRoomAudio.d.ts +16 -0
  247. package/lib/typescript/module/live/hooks/useRoomAudio.d.ts.map +1 -0
  248. package/lib/typescript/module/live/hooks/useRoomConnection.d.ts +29 -0
  249. package/lib/typescript/module/live/hooks/useRoomConnection.d.ts.map +1 -0
  250. package/lib/typescript/module/live/hooks/useRoomManager.d.ts +11 -0
  251. package/lib/typescript/module/live/hooks/useRoomManager.d.ts.map +1 -0
  252. package/lib/typescript/module/live/hooks/useRoomUsers.d.ts +5 -0
  253. package/lib/typescript/module/live/hooks/useRoomUsers.d.ts.map +1 -0
  254. package/lib/typescript/module/live/index.d.ts +24 -0
  255. package/lib/typescript/module/live/index.d.ts.map +1 -0
  256. package/lib/typescript/module/live/services/livekitService.d.ts +7 -0
  257. package/lib/typescript/module/live/services/livekitService.d.ts.map +1 -0
  258. package/lib/typescript/module/live/services/spaceSocketService.d.ts +69 -0
  259. package/lib/typescript/module/live/services/spaceSocketService.d.ts.map +1 -0
  260. package/lib/typescript/module/live/services/spacesService.d.ts +181 -0
  261. package/lib/typescript/module/live/services/spacesService.d.ts.map +1 -0
  262. package/lib/typescript/module/live/types.d.ts +100 -0
  263. package/lib/typescript/module/live/types.d.ts.map +1 -0
  264. package/lib/typescript/module/live/validation.d.ts +658 -0
  265. package/lib/typescript/module/live/validation.d.ts.map +1 -0
  266. package/lib/typescript/module/package.json +1 -0
  267. package/lib/typescript/module/schema.d.ts +1072 -0
  268. package/lib/typescript/module/schema.d.ts.map +1 -0
  269. package/package.json +133 -21
  270. package/src/index.native.ts +2 -0
  271. package/src/live/assets/icons/spaces-icon.tsx +15 -0
  272. package/src/live/assets/icons/syra-icon.tsx +13 -0
  273. package/src/live/assets/sounds/intro.mp3 +0 -0
  274. package/src/live/components/AnimatedPulse.tsx +52 -0
  275. package/src/live/components/AnimatedSpeakerRing.tsx +101 -0
  276. package/src/live/components/CreateRoomSheet.tsx +654 -0
  277. package/src/live/components/InsightsPanel.tsx +202 -0
  278. package/src/live/components/LiveRoomSheet.tsx +969 -0
  279. package/src/live/components/MiniRoomBar.tsx +166 -0
  280. package/src/live/components/PanelHeader.tsx +36 -0
  281. package/src/live/components/PodcastStreamPicker.tsx +1155 -0
  282. package/src/live/components/RecordingCard.tsx +154 -0
  283. package/src/live/components/RecordingsPanel.tsx +251 -0
  284. package/src/live/components/RoomCard.tsx +494 -0
  285. package/src/live/components/StreamConfigModal.tsx +600 -0
  286. package/src/live/components/StreamConfigPanel.tsx +729 -0
  287. package/src/live/context/LiveConfigContext.tsx +96 -0
  288. package/src/live/context/LiveRoomContext.tsx +235 -0
  289. package/src/live/hooks/useActiveSpeakers.ts +39 -0
  290. package/src/live/hooks/useRoomAudio.ts +103 -0
  291. package/src/live/hooks/useRoomConnection.ts +162 -0
  292. package/src/live/hooks/useRoomManager.ts +17 -0
  293. package/src/live/hooks/useRoomUsers.ts +52 -0
  294. package/src/live/index.ts +92 -0
  295. package/src/live/services/livekitService.ts +11 -0
  296. package/src/live/services/spaceSocketService.ts +136 -0
  297. package/src/live/services/spacesService.ts +692 -0
  298. package/src/live/types.ts +119 -0
  299. package/src/live/validation.ts +279 -0
  300. package/dist/cjs/client.js +0 -244
  301. package/dist/cjs/errors.js +0 -16
  302. package/dist/cjs/index.js +0 -15
  303. package/dist/cjs/package.json +0 -3
  304. package/dist/esm/client.js +0 -240
  305. package/dist/esm/errors.js +0 -12
  306. package/dist/esm/index.js +0 -3
  307. package/dist/esm/package.json +0 -3
@@ -0,0 +1,600 @@
1
+ import React, { useState } from 'react';
2
+ import {
3
+ View,
4
+ Text,
5
+ Modal,
6
+ StyleSheet,
7
+ TouchableOpacity,
8
+ TextInput,
9
+ Image,
10
+ ActivityIndicator,
11
+ Platform,
12
+ ScrollView,
13
+ KeyboardAvoidingView,
14
+ } from 'react-native';
15
+ import MaterialCommunityIcons from '@expo/vector-icons/MaterialCommunityIcons';
16
+ import { useAuth } from '@oxyhq/services';
17
+ import * as ImagePicker from 'expo-image-picker';
18
+
19
+ import { useLiveConfig } from '../context/LiveConfigContext';
20
+
21
+ interface StreamConfigModalProps {
22
+ visible: boolean;
23
+ onClose: () => void;
24
+ roomId: string;
25
+ initialStreamUrl?: string;
26
+ onStreamStarted: () => void;
27
+ }
28
+
29
+ type StreamMode = 'url' | 'rtmp';
30
+
31
+ export function StreamConfigModal({ visible, onClose, roomId, initialStreamUrl, onStreamStarted }: StreamConfigModalProps) {
32
+ const { useTheme, roomsService, toast } = useLiveConfig();
33
+ const theme = useTheme();
34
+ const { oxyServices } = useAuth();
35
+
36
+ const initialUrl = initialStreamUrl?.trim() ?? '';
37
+ const isEditingUrlStream = initialUrl.length > 0;
38
+ const [mode, setMode] = useState<StreamMode>('url');
39
+ const [loading, setLoading] = useState(false);
40
+
41
+ const [streamUrl, setStreamUrl] = useState(initialUrl);
42
+
43
+ const [rtmpUrl, setRtmpUrl] = useState<string | null>(null);
44
+ const [streamKey, setStreamKey] = useState<string | null>(null);
45
+ const [generatingKey, setGeneratingKey] = useState(false);
46
+
47
+ const [title, setTitle] = useState('');
48
+ const [description, setDescription] = useState('');
49
+ const [imageFileId, setImageFileId] = useState<string | null>(null);
50
+ const [imagePreviewUri, setImagePreviewUri] = useState<string | null>(null);
51
+ const [uploadingImage, setUploadingImage] = useState(false);
52
+
53
+ const resetState = () => {
54
+ setStreamUrl('');
55
+ setRtmpUrl(null);
56
+ setStreamKey(null);
57
+ setTitle('');
58
+ setDescription('');
59
+ setImageFileId(null);
60
+ setImagePreviewUri(null);
61
+ setMode('url');
62
+ };
63
+
64
+ const handleClose = () => {
65
+ onClose();
66
+ };
67
+
68
+ const handlePickImage = async () => {
69
+ try {
70
+ const result = await ImagePicker.launchImageLibraryAsync({
71
+ mediaTypes: ['images'],
72
+ quality: 0.8,
73
+ allowsEditing: true,
74
+ aspect: [16, 9],
75
+ });
76
+
77
+ if (result.canceled || !result.assets?.[0]) return;
78
+
79
+ const asset = result.assets[0];
80
+ setImagePreviewUri(asset.uri);
81
+ setUploadingImage(true);
82
+
83
+ try {
84
+ let file: File | Blob;
85
+
86
+ if (Platform.OS === 'web') {
87
+ const response = await fetch(asset.uri);
88
+ const blob = await response.blob();
89
+ file = new File([blob], 'stream-cover.jpg', { type: asset.mimeType || 'image/jpeg' });
90
+ } else {
91
+ const response = await fetch(asset.uri);
92
+ file = await response.blob();
93
+ }
94
+
95
+ if (!oxyServices) {
96
+ toast.error('File uploads are unavailable');
97
+ setImagePreviewUri(null);
98
+ return;
99
+ }
100
+
101
+ const uploadResponse = await oxyServices.uploadRawFile(file, 'public');
102
+
103
+ const fileId = uploadResponse?.file?.key || uploadResponse?.file?.id || uploadResponse?.id || uploadResponse?.fileId || uploadResponse?.data?.id;
104
+
105
+ if (fileId) {
106
+ setImageFileId(fileId);
107
+ } else {
108
+ console.error('Upload response missing file ID:', JSON.stringify(uploadResponse, null, 2));
109
+ toast.error('Failed to upload image');
110
+ setImagePreviewUri(null);
111
+ }
112
+ } catch (err) {
113
+ console.error('Image upload error:', err);
114
+ toast.error('Failed to upload image');
115
+ setImagePreviewUri(null);
116
+ } finally {
117
+ setUploadingImage(false);
118
+ }
119
+ } catch (err) {
120
+ console.error('Image picker error:', err);
121
+ toast.error('Could not open image picker');
122
+ }
123
+ };
124
+
125
+ const handleStartUrlStream = async () => {
126
+ if (!streamUrl.trim() || loading) return;
127
+ setLoading(true);
128
+ try {
129
+ const result = await roomsService.startStream(roomId, {
130
+ url: streamUrl.trim(),
131
+ title: title.trim() || undefined,
132
+ image: imageFileId || undefined,
133
+ description: description.trim() || undefined,
134
+ });
135
+ if (result) {
136
+ toast.success('Stream started');
137
+ resetState();
138
+ onStreamStarted();
139
+ onClose();
140
+ } else {
141
+ toast.error('Failed to start stream');
142
+ }
143
+ } catch {
144
+ toast.error('Failed to start stream');
145
+ } finally {
146
+ setLoading(false);
147
+ }
148
+ };
149
+
150
+ const handleGenerateKey = async () => {
151
+ if (generatingKey) return;
152
+ setGeneratingKey(true);
153
+ try {
154
+ const result = await roomsService.generateStreamKey(roomId, {
155
+ title: title.trim() || undefined,
156
+ image: imageFileId || undefined,
157
+ description: description.trim() || undefined,
158
+ });
159
+ if (result?.rtmpUrl && result?.streamKey) {
160
+ setRtmpUrl(result.rtmpUrl);
161
+ setStreamKey(result.streamKey);
162
+ toast.success('Stream key generated');
163
+ onStreamStarted();
164
+ } else {
165
+ console.error('Generate stream key response:', JSON.stringify(result, null, 2));
166
+ toast.error('Failed to generate stream key');
167
+ }
168
+ } catch (err: unknown) {
169
+ console.error('Generate stream key error:', err);
170
+ const msg = err instanceof Error ? err.message : 'Unknown error';
171
+ toast.error(`Stream key error: ${msg}`);
172
+ } finally {
173
+ setGeneratingKey(false);
174
+ }
175
+ };
176
+
177
+ const handleUpdateMetadata = async () => {
178
+ if (loading) return;
179
+ const trimmedUrl = streamUrl.trim();
180
+ if (mode === 'url' && !trimmedUrl) {
181
+ toast.error('Stream URL is required');
182
+ return;
183
+ }
184
+ setLoading(true);
185
+ try {
186
+ const success = await roomsService.updateStreamMetadata(roomId, {
187
+ ...(mode === 'url' ? { url: trimmedUrl } : {}),
188
+ title: title.trim() || undefined,
189
+ image: imageFileId || undefined,
190
+ description: description.trim() || undefined,
191
+ });
192
+ if (success) {
193
+ toast.success('Stream info updated');
194
+ onStreamStarted();
195
+ } else {
196
+ toast.error('Failed to update stream info');
197
+ }
198
+ } catch {
199
+ toast.error('Failed to update stream info');
200
+ } finally {
201
+ setLoading(false);
202
+ }
203
+ };
204
+
205
+ const copyToClipboard = async (text: string, label: string) => {
206
+ try {
207
+ if (Platform.OS === 'web') {
208
+ await navigator.clipboard.writeText(text);
209
+ } else {
210
+ const { Clipboard } = require('react-native');
211
+ Clipboard.setString(text);
212
+ }
213
+ toast.success(`${label} copied`);
214
+ } catch {
215
+ toast.error('Failed to copy');
216
+ }
217
+ };
218
+
219
+ return (
220
+ <Modal
221
+ visible={visible}
222
+ animationType="slide"
223
+ presentationStyle="pageSheet"
224
+ onRequestClose={handleClose}
225
+ >
226
+ <KeyboardAvoidingView
227
+ style={[styles.container, { backgroundColor: theme.colors.background }]}
228
+ behavior={Platform.OS === 'ios' ? 'padding' : undefined}
229
+ >
230
+ <View style={[styles.header, { borderBottomColor: theme.colors.border }]}>
231
+ <TouchableOpacity onPress={handleClose} style={styles.closeBtn}>
232
+ <MaterialCommunityIcons name="close" size={24} color={theme.colors.text} />
233
+ </TouchableOpacity>
234
+ <Text style={[styles.headerTitle, { color: theme.colors.text }]}>Stream Setup</Text>
235
+ <View style={styles.closeBtn} />
236
+ </View>
237
+
238
+ <ScrollView style={styles.scrollContent} keyboardShouldPersistTaps="handled">
239
+ <View style={styles.modeSelector}>
240
+ <TouchableOpacity
241
+ style={[
242
+ styles.modeTab,
243
+ { borderColor: theme.colors.border },
244
+ mode === 'url' && { backgroundColor: theme.colors.primary, borderColor: theme.colors.primary },
245
+ ]}
246
+ onPress={() => setMode('url')}
247
+ >
248
+ <MaterialCommunityIcons name="link" size={16} color={mode === 'url' ? '#FFFFFF' : theme.colors.text} />
249
+ <Text style={[styles.modeTabText, { color: mode === 'url' ? '#FFFFFF' : theme.colors.text }]}>
250
+ Stream URL
251
+ </Text>
252
+ </TouchableOpacity>
253
+ <TouchableOpacity
254
+ style={[
255
+ styles.modeTab,
256
+ { borderColor: theme.colors.border },
257
+ mode === 'rtmp' && { backgroundColor: theme.colors.primary, borderColor: theme.colors.primary },
258
+ ]}
259
+ onPress={() => setMode('rtmp')}
260
+ >
261
+ <MaterialCommunityIcons name="key" size={16} color={mode === 'rtmp' ? '#FFFFFF' : theme.colors.text} />
262
+ <Text style={[styles.modeTabText, { color: mode === 'rtmp' ? '#FFFFFF' : theme.colors.text }]}>
263
+ External App
264
+ </Text>
265
+ </TouchableOpacity>
266
+ </View>
267
+
268
+ {mode === 'url' && (
269
+ <View style={styles.section}>
270
+ <TextInput
271
+ style={[styles.input, { backgroundColor: theme.colors.card, borderColor: theme.colors.border, color: theme.colors.text }]}
272
+ placeholder="Stream URL (m3u8, Icecast, etc.)"
273
+ placeholderTextColor={theme.colors.textSecondary}
274
+ value={streamUrl}
275
+ onChangeText={setStreamUrl}
276
+ autoCapitalize="none"
277
+ autoCorrect={false}
278
+ keyboardType="url"
279
+ />
280
+ </View>
281
+ )}
282
+
283
+ {mode === 'rtmp' && (
284
+ <View style={styles.section}>
285
+ {!rtmpUrl ? (
286
+ <TouchableOpacity
287
+ style={[styles.generateBtn, { backgroundColor: theme.colors.primary, opacity: generatingKey ? 0.6 : 1 }]}
288
+ onPress={handleGenerateKey}
289
+ disabled={generatingKey}
290
+ >
291
+ {generatingKey ? (
292
+ <ActivityIndicator size="small" color="#FFFFFF" />
293
+ ) : (
294
+ <MaterialCommunityIcons name="key" size={18} color="#FFFFFF" />
295
+ )}
296
+ <Text style={styles.generateBtnText}>
297
+ {generatingKey ? 'Generating...' : 'Generate Stream Key'}
298
+ </Text>
299
+ </TouchableOpacity>
300
+ ) : (
301
+ <View style={styles.credentialsBox}>
302
+ <Text style={[styles.credLabel, { color: theme.colors.textSecondary }]}>RTMP URL</Text>
303
+ <View style={[styles.credRow, { backgroundColor: theme.colors.card, borderColor: theme.colors.border }]}>
304
+ <Text style={[styles.credValue, { color: theme.colors.text }]} numberOfLines={1}>
305
+ {rtmpUrl}
306
+ </Text>
307
+ <TouchableOpacity onPress={() => copyToClipboard(rtmpUrl, 'RTMP URL')} style={styles.copyBtn}>
308
+ <MaterialCommunityIcons name="content-copy" size={18} color={theme.colors.primary} />
309
+ </TouchableOpacity>
310
+ </View>
311
+
312
+ <Text style={[styles.credLabel, { color: theme.colors.textSecondary, marginTop: 12 }]}>Stream Key</Text>
313
+ <View style={[styles.credRow, { backgroundColor: theme.colors.card, borderColor: theme.colors.border }]}>
314
+ <Text style={[styles.credValue, { color: theme.colors.text }]} numberOfLines={1}>
315
+ {streamKey}
316
+ </Text>
317
+ <TouchableOpacity
318
+ onPress={() => {
319
+ if (streamKey) copyToClipboard(streamKey, 'Stream key');
320
+ }}
321
+ style={styles.copyBtn}
322
+ >
323
+ <MaterialCommunityIcons name="content-copy" size={18} color={theme.colors.primary} />
324
+ </TouchableOpacity>
325
+ </View>
326
+
327
+ <View style={styles.infoRow}>
328
+ <MaterialCommunityIcons name="information" size={16} color={theme.colors.textSecondary} />
329
+ <Text style={[styles.infoText, { color: theme.colors.textSecondary }]}>
330
+ Use these in OBS or your streaming app. Audio will play in the room once you start streaming.
331
+ </Text>
332
+ </View>
333
+ </View>
334
+ )}
335
+ </View>
336
+ )}
337
+
338
+ <View style={styles.section}>
339
+ <Text style={[styles.sectionLabel, { color: theme.colors.textSecondary }]}>
340
+ Stream Info (optional)
341
+ </Text>
342
+
343
+ <TextInput
344
+ style={[styles.input, { backgroundColor: theme.colors.card, borderColor: theme.colors.border, color: theme.colors.text }]}
345
+ placeholder="Title"
346
+ placeholderTextColor={theme.colors.textSecondary}
347
+ value={title}
348
+ onChangeText={setTitle}
349
+ maxLength={200}
350
+ />
351
+
352
+ <TouchableOpacity
353
+ style={[styles.imagePicker, { backgroundColor: theme.colors.card, borderColor: theme.colors.border }]}
354
+ onPress={handlePickImage}
355
+ disabled={uploadingImage}
356
+ >
357
+ {imagePreviewUri ? (
358
+ <Image source={{ uri: imagePreviewUri }} style={styles.imagePreview} />
359
+ ) : (
360
+ <View style={styles.imagePickerPlaceholder}>
361
+ <MaterialCommunityIcons name="image" size={24} color={theme.colors.textSecondary} />
362
+ <Text style={[styles.imagePickerText, { color: theme.colors.textSecondary }]}>
363
+ Cover image
364
+ </Text>
365
+ </View>
366
+ )}
367
+ {uploadingImage && (
368
+ <View style={styles.imageOverlay}>
369
+ <ActivityIndicator size="small" color="#FFFFFF" />
370
+ </View>
371
+ )}
372
+ </TouchableOpacity>
373
+
374
+ <TextInput
375
+ style={[styles.input, styles.inputMultiline, { backgroundColor: theme.colors.card, borderColor: theme.colors.border, color: theme.colors.text }]}
376
+ placeholder="Description"
377
+ placeholderTextColor={theme.colors.textSecondary}
378
+ value={description}
379
+ onChangeText={setDescription}
380
+ maxLength={500}
381
+ multiline
382
+ numberOfLines={2}
383
+ />
384
+ </View>
385
+
386
+ <View style={styles.footer}>
387
+ {mode === 'url' && (
388
+ <TouchableOpacity
389
+ style={[
390
+ styles.startBtn,
391
+ {
392
+ backgroundColor: streamUrl.trim() ? theme.colors.primary : theme.colors.backgroundSecondary,
393
+ opacity: loading ? 0.6 : 1,
394
+ },
395
+ ]}
396
+ onPress={isEditingUrlStream ? handleUpdateMetadata : handleStartUrlStream}
397
+ disabled={!streamUrl.trim() || loading}
398
+ >
399
+ {loading ? (
400
+ <ActivityIndicator size="small" color="#FFFFFF" />
401
+ ) : isEditingUrlStream ? (
402
+ <MaterialCommunityIcons
403
+ name="content-save"
404
+ size={18}
405
+ color={streamUrl.trim() ? '#FFFFFF' : theme.colors.textSecondary}
406
+ />
407
+ ) : (
408
+ <MaterialCommunityIcons
409
+ name="play"
410
+ size={18}
411
+ color={streamUrl.trim() ? '#FFFFFF' : theme.colors.textSecondary}
412
+ />
413
+ )}
414
+ <Text style={{ color: streamUrl.trim() ? '#FFFFFF' : theme.colors.textSecondary, fontWeight: '600', fontSize: 16 }}>
415
+ {isEditingUrlStream ? 'Save Stream Info' : 'Start Stream'}
416
+ </Text>
417
+ </TouchableOpacity>
418
+ )}
419
+
420
+ {mode === 'rtmp' && rtmpUrl && (
421
+ <TouchableOpacity
422
+ style={[styles.startBtn, { backgroundColor: theme.colors.primary, opacity: loading ? 0.6 : 1 }]}
423
+ onPress={handleUpdateMetadata}
424
+ disabled={loading}
425
+ >
426
+ {loading ? (
427
+ <ActivityIndicator size="small" color="#FFFFFF" />
428
+ ) : (
429
+ <MaterialCommunityIcons name="content-save" size={18} color="#FFFFFF" />
430
+ )}
431
+ <Text style={{ color: '#FFFFFF', fontWeight: '600', fontSize: 16 }}>
432
+ Save Stream Info
433
+ </Text>
434
+ </TouchableOpacity>
435
+ )}
436
+ </View>
437
+ </ScrollView>
438
+ </KeyboardAvoidingView>
439
+ </Modal>
440
+ );
441
+ }
442
+
443
+ const styles = StyleSheet.create({
444
+ container: {
445
+ flex: 1,
446
+ },
447
+ scrollContent: {
448
+ flex: 1,
449
+ },
450
+ header: {
451
+ flexDirection: 'row',
452
+ alignItems: 'center',
453
+ justifyContent: 'space-between',
454
+ paddingHorizontal: 16,
455
+ paddingVertical: 14,
456
+ borderBottomWidth: 1,
457
+ },
458
+ closeBtn: {
459
+ width: 40,
460
+ alignItems: 'center',
461
+ },
462
+ headerTitle: {
463
+ fontSize: 17,
464
+ fontWeight: '600',
465
+ },
466
+ modeSelector: {
467
+ flexDirection: 'row',
468
+ gap: 10,
469
+ paddingHorizontal: 16,
470
+ paddingTop: 16,
471
+ paddingBottom: 8,
472
+ },
473
+ modeTab: {
474
+ flex: 1,
475
+ flexDirection: 'row',
476
+ alignItems: 'center',
477
+ justifyContent: 'center',
478
+ gap: 6,
479
+ paddingVertical: 10,
480
+ borderRadius: 10,
481
+ borderWidth: 1,
482
+ },
483
+ modeTabText: {
484
+ fontSize: 14,
485
+ fontWeight: '600',
486
+ },
487
+ section: {
488
+ paddingHorizontal: 16,
489
+ paddingTop: 12,
490
+ gap: 10,
491
+ },
492
+ sectionLabel: {
493
+ fontSize: 13,
494
+ fontWeight: '600',
495
+ textTransform: 'uppercase',
496
+ letterSpacing: 0.5,
497
+ marginBottom: 2,
498
+ },
499
+ input: {
500
+ borderWidth: 1,
501
+ borderRadius: 10,
502
+ paddingHorizontal: 14,
503
+ paddingVertical: 12,
504
+ fontSize: 15,
505
+ },
506
+ inputMultiline: {
507
+ minHeight: 60,
508
+ textAlignVertical: 'top',
509
+ },
510
+ imagePicker: {
511
+ borderWidth: 1,
512
+ borderRadius: 10,
513
+ overflow: 'hidden',
514
+ height: 100,
515
+ },
516
+ imagePreview: {
517
+ width: '100%',
518
+ height: '100%',
519
+ resizeMode: 'cover',
520
+ },
521
+ imagePickerPlaceholder: {
522
+ flex: 1,
523
+ alignItems: 'center',
524
+ justifyContent: 'center',
525
+ gap: 4,
526
+ },
527
+ imagePickerText: {
528
+ fontSize: 13,
529
+ fontWeight: '500',
530
+ },
531
+ imageOverlay: {
532
+ ...StyleSheet.absoluteFill,
533
+ backgroundColor: 'rgba(0,0,0,0.4)',
534
+ alignItems: 'center',
535
+ justifyContent: 'center',
536
+ },
537
+ generateBtn: {
538
+ flexDirection: 'row',
539
+ alignItems: 'center',
540
+ justifyContent: 'center',
541
+ gap: 8,
542
+ paddingVertical: 14,
543
+ borderRadius: 10,
544
+ },
545
+ generateBtnText: {
546
+ color: '#FFFFFF',
547
+ fontSize: 16,
548
+ fontWeight: '600',
549
+ },
550
+ credentialsBox: {
551
+ gap: 4,
552
+ },
553
+ credLabel: {
554
+ fontSize: 12,
555
+ fontWeight: '600',
556
+ textTransform: 'uppercase',
557
+ letterSpacing: 0.5,
558
+ },
559
+ credRow: {
560
+ flexDirection: 'row',
561
+ alignItems: 'center',
562
+ borderWidth: 1,
563
+ borderRadius: 10,
564
+ paddingLeft: 14,
565
+ paddingRight: 4,
566
+ paddingVertical: 4,
567
+ },
568
+ credValue: {
569
+ flex: 1,
570
+ fontSize: 13,
571
+ fontFamily: Platform.OS === 'ios' ? 'Menlo' : 'monospace',
572
+ },
573
+ copyBtn: {
574
+ padding: 10,
575
+ },
576
+ infoRow: {
577
+ flexDirection: 'row',
578
+ alignItems: 'flex-start',
579
+ gap: 6,
580
+ marginTop: 10,
581
+ },
582
+ infoText: {
583
+ flex: 1,
584
+ fontSize: 13,
585
+ lineHeight: 18,
586
+ },
587
+ footer: {
588
+ paddingHorizontal: 16,
589
+ paddingTop: 20,
590
+ paddingBottom: 40,
591
+ },
592
+ startBtn: {
593
+ flexDirection: 'row',
594
+ alignItems: 'center',
595
+ justifyContent: 'center',
596
+ gap: 8,
597
+ paddingVertical: 14,
598
+ borderRadius: 12,
599
+ },
600
+ });