chat 1.0.8 → 4.0.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 (327) hide show
  1. package/dist/chunk-ACQNDPTB.js +356 -0
  2. package/dist/chunk-ACQNDPTB.js.map +1 -0
  3. package/dist/index.d.ts +1312 -0
  4. package/dist/index.js +1433 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/jsx-runtime-D7zHSnXe.d.ts +349 -0
  7. package/dist/jsx-runtime.d.ts +1 -0
  8. package/dist/jsx-runtime.js +17 -0
  9. package/dist/jsx-runtime.js.map +1 -0
  10. package/package.json +61 -97
  11. package/lib/module/ChatContext/index.js +0 -2
  12. package/lib/module/ChatContext/index.js.map +0 -1
  13. package/lib/module/ChatContext/types.js +0 -2
  14. package/lib/module/ChatContext/types.js.map +0 -1
  15. package/lib/module/classes/Chat/index.js +0 -2
  16. package/lib/module/classes/Chat/index.js.map +0 -1
  17. package/lib/module/classes/Chat/types.js +0 -2
  18. package/lib/module/classes/Chat/types.js.map +0 -1
  19. package/lib/module/classes/Inbox/index.js +0 -2
  20. package/lib/module/classes/Inbox/index.js.map +0 -1
  21. package/lib/module/classes/Inbox/types.js +0 -2
  22. package/lib/module/classes/Inbox/types.js.map +0 -1
  23. package/lib/module/classes/Message/index.js +0 -2
  24. package/lib/module/classes/Message/index.js.map +0 -1
  25. package/lib/module/classes/Message/types.js +0 -2
  26. package/lib/module/classes/Message/types.js.map +0 -1
  27. package/lib/module/classes/Reaction/index.js +0 -2
  28. package/lib/module/classes/Reaction/index.js.map +0 -1
  29. package/lib/module/classes/Reaction/types.js +0 -2
  30. package/lib/module/classes/Reaction/types.js.map +0 -1
  31. package/lib/module/classes/Room/index.js +0 -2
  32. package/lib/module/classes/Room/index.js.map +0 -1
  33. package/lib/module/classes/Room/types.js +0 -2
  34. package/lib/module/classes/Room/types.js.map +0 -1
  35. package/lib/module/classes/index.js +0 -2
  36. package/lib/module/classes/index.js.map +0 -1
  37. package/lib/module/components/Avatar/index.js +0 -2
  38. package/lib/module/components/Avatar/index.js.map +0 -1
  39. package/lib/module/components/Chat/Bubble/index.js +0 -2
  40. package/lib/module/components/Chat/Bubble/index.js.map +0 -1
  41. package/lib/module/components/Chat/Composer/Input/index.js +0 -2
  42. package/lib/module/components/Chat/Composer/Input/index.js.map +0 -1
  43. package/lib/module/components/Chat/Composer/Send/index.js +0 -2
  44. package/lib/module/components/Chat/Composer/Send/index.js.map +0 -1
  45. package/lib/module/components/Chat/Composer/index.js +0 -2
  46. package/lib/module/components/Chat/Composer/index.js.map +0 -1
  47. package/lib/module/components/Chat/Media/Image/index.js +0 -2
  48. package/lib/module/components/Chat/Media/Image/index.js.map +0 -1
  49. package/lib/module/components/Chat/Media/index.js +0 -2
  50. package/lib/module/components/Chat/Media/index.js.map +0 -1
  51. package/lib/module/components/Chat/Message/Swiper/Action/index.js +0 -2
  52. package/lib/module/components/Chat/Message/Swiper/Action/index.js.map +0 -1
  53. package/lib/module/components/Chat/Message/Swiper/index.js +0 -2
  54. package/lib/module/components/Chat/Message/Swiper/index.js.map +0 -1
  55. package/lib/module/components/Chat/Message/Touchable/index.js +0 -2
  56. package/lib/module/components/Chat/Message/Touchable/index.js.map +0 -1
  57. package/lib/module/components/Chat/Message/index.js +0 -2
  58. package/lib/module/components/Chat/Message/index.js.map +0 -1
  59. package/lib/module/components/Chat/SystemMessage/index.js +0 -2
  60. package/lib/module/components/Chat/SystemMessage/index.js.map +0 -1
  61. package/lib/module/components/Chat/TypingFooter/index.js +0 -2
  62. package/lib/module/components/Chat/TypingFooter/index.js.map +0 -1
  63. package/lib/module/components/Chat/index.js +0 -2
  64. package/lib/module/components/Chat/index.js.map +0 -1
  65. package/lib/module/components/Chat/types.js +0 -2
  66. package/lib/module/components/Chat/types.js.map +0 -1
  67. package/lib/module/components/Chat-Old/Bubble/index.js +0 -2
  68. package/lib/module/components/Chat-Old/Bubble/index.js.map +0 -1
  69. package/lib/module/components/Chat-Old/Composer/Input/index.js +0 -2
  70. package/lib/module/components/Chat-Old/Composer/Input/index.js.map +0 -1
  71. package/lib/module/components/Chat-Old/Composer/Send/index.js +0 -2
  72. package/lib/module/components/Chat-Old/Composer/Send/index.js.map +0 -1
  73. package/lib/module/components/Chat-Old/Composer/index.js +0 -2
  74. package/lib/module/components/Chat-Old/Composer/index.js.map +0 -1
  75. package/lib/module/components/Chat-Old/Message/index.js +0 -2
  76. package/lib/module/components/Chat-Old/Message/index.js.map +0 -1
  77. package/lib/module/components/Chat-Old/Swiper/Action/index.js +0 -2
  78. package/lib/module/components/Chat-Old/Swiper/Action/index.js.map +0 -1
  79. package/lib/module/components/Chat-Old/Swiper/index.js +0 -2
  80. package/lib/module/components/Chat-Old/Swiper/index.js.map +0 -1
  81. package/lib/module/components/Chat-Old/SystemMessage/index.js +0 -2
  82. package/lib/module/components/Chat-Old/SystemMessage/index.js.map +0 -1
  83. package/lib/module/components/Chat-Old/index.js +0 -2
  84. package/lib/module/components/Chat-Old/index.js.map +0 -1
  85. package/lib/module/components/Chat-Old/types.js +0 -2
  86. package/lib/module/components/Chat-Old/types.js.map +0 -1
  87. package/lib/module/components/ChatProvider/index.js +0 -2
  88. package/lib/module/components/ChatProvider/index.js.map +0 -1
  89. package/lib/module/components/ChatProvider/types.js +0 -2
  90. package/lib/module/components/ChatProvider/types.js.map +0 -1
  91. package/lib/module/components/Inbox/Item/Circle/index.js +0 -2
  92. package/lib/module/components/Inbox/Item/Circle/index.js.map +0 -1
  93. package/lib/module/components/Inbox/Item/Circle/types.js +0 -2
  94. package/lib/module/components/Inbox/Item/Circle/types.js.map +0 -1
  95. package/lib/module/components/Inbox/Item/Initials/index.js +0 -2
  96. package/lib/module/components/Inbox/Item/Initials/index.js.map +0 -1
  97. package/lib/module/components/Inbox/Item/ItemDate/index.js +0 -2
  98. package/lib/module/components/Inbox/Item/ItemDate/index.js.map +0 -1
  99. package/lib/module/components/Inbox/Item/Separator/index.js +0 -2
  100. package/lib/module/components/Inbox/Item/Separator/index.js.map +0 -1
  101. package/lib/module/components/Inbox/Item/Subtitle/index.js +0 -2
  102. package/lib/module/components/Inbox/Item/Subtitle/index.js.map +0 -1
  103. package/lib/module/components/Inbox/Item/Swipeable/index.js +0 -2
  104. package/lib/module/components/Inbox/Item/Swipeable/index.js.map +0 -1
  105. package/lib/module/components/Inbox/Item/Title/index.js +0 -2
  106. package/lib/module/components/Inbox/Item/Title/index.js.map +0 -1
  107. package/lib/module/components/Inbox/Item/UnreadIndicator/index.js +0 -2
  108. package/lib/module/components/Inbox/Item/UnreadIndicator/index.js.map +0 -1
  109. package/lib/module/components/Inbox/Item/index.js +0 -2
  110. package/lib/module/components/Inbox/Item/index.js.map +0 -1
  111. package/lib/module/components/Inbox/index.js +0 -2
  112. package/lib/module/components/Inbox/index.js.map +0 -1
  113. package/lib/module/components/Inbox/question.md +0 -21
  114. package/lib/module/components/Inbox/readme.md +0 -21
  115. package/lib/module/components/Inbox/types.js +0 -2
  116. package/lib/module/components/Inbox/types.js.map +0 -1
  117. package/lib/module/components/RoomCreator/Content/Footer/Button/index.js +0 -2
  118. package/lib/module/components/RoomCreator/Content/Footer/Button/index.js.map +0 -1
  119. package/lib/module/components/RoomCreator/Content/Footer/Input/index.js +0 -2
  120. package/lib/module/components/RoomCreator/Content/Footer/Input/index.js.map +0 -1
  121. package/lib/module/components/RoomCreator/Content/Footer/index.js +0 -2
  122. package/lib/module/components/RoomCreator/Content/Footer/index.js.map +0 -1
  123. package/lib/module/components/RoomCreator/Content/Item/Icon/index.js +0 -2
  124. package/lib/module/components/RoomCreator/Content/Item/Icon/index.js.map +0 -1
  125. package/lib/module/components/RoomCreator/Content/Item/index.js +0 -2
  126. package/lib/module/components/RoomCreator/Content/Item/index.js.map +0 -1
  127. package/lib/module/components/RoomCreator/Content/index.js +0 -2
  128. package/lib/module/components/RoomCreator/Content/index.js.map +0 -1
  129. package/lib/module/components/RoomCreator/Header/index.js +0 -2
  130. package/lib/module/components/RoomCreator/Header/index.js.map +0 -1
  131. package/lib/module/components/RoomCreator/index.js +0 -2
  132. package/lib/module/components/RoomCreator/index.js.map +0 -1
  133. package/lib/module/components/RoomCreator/types.js +0 -2
  134. package/lib/module/components/RoomCreator/types.js.map +0 -1
  135. package/lib/module/components/TypingIndicator/index.js +0 -2
  136. package/lib/module/components/TypingIndicator/index.js.map +0 -1
  137. package/lib/module/components/index.js +0 -2
  138. package/lib/module/components/index.js.map +0 -1
  139. package/lib/module/helpers/getInitials.js +0 -2
  140. package/lib/module/helpers/getInitials.js.map +0 -1
  141. package/lib/module/helpers/sortByAvatar.js +0 -2
  142. package/lib/module/helpers/sortByAvatar.js.map +0 -1
  143. package/lib/module/hooks/index.js +0 -2
  144. package/lib/module/hooks/index.js.map +0 -1
  145. package/lib/module/hooks/useCreateRoom/index.js +0 -2
  146. package/lib/module/hooks/useCreateRoom/index.js.map +0 -1
  147. package/lib/module/hooks/useCreator/index.js +0 -2
  148. package/lib/module/hooks/useCreator/index.js.map +0 -1
  149. package/lib/module/hooks/useInbox/index.js +0 -2
  150. package/lib/module/hooks/useInbox/index.js.map +0 -1
  151. package/lib/module/hooks/useInbox/types.js +0 -2
  152. package/lib/module/hooks/useInbox/types.js.map +0 -1
  153. package/lib/module/hooks/useMessages/index.js +0 -2
  154. package/lib/module/hooks/useMessages/index.js.map +0 -1
  155. package/lib/module/hooks/useMessages/types.js +0 -2
  156. package/lib/module/hooks/useMessages/types.js.map +0 -1
  157. package/lib/module/hooks/useRoom/index.js +0 -2
  158. package/lib/module/hooks/useRoom/index.js.map +0 -1
  159. package/lib/module/hooks/useRoom/types.js +0 -2
  160. package/lib/module/hooks/useRoom/types.js.map +0 -1
  161. package/lib/module/hooks/useSend/useSendToGroup/index.js +0 -2
  162. package/lib/module/hooks/useSend/useSendToGroup/index.js.map +0 -1
  163. package/lib/module/hooks/useSend/useSendToPeople/index.js +0 -2
  164. package/lib/module/hooks/useSend/useSendToPeople/index.js.map +0 -1
  165. package/lib/module/hooks/useTyping/index.js +0 -2
  166. package/lib/module/hooks/useTyping/index.js.map +0 -1
  167. package/lib/module/hooks/useTypingOLD/index.js +0 -2
  168. package/lib/module/hooks/useTypingOLD/index.js.map +0 -1
  169. package/lib/module/hooks/useTypingOLD/types.js +0 -2
  170. package/lib/module/hooks/useTypingOLD/types.js.map +0 -1
  171. package/lib/module/hooks/useViewMessages/index.js +0 -2
  172. package/lib/module/hooks/useViewMessages/index.js.map +0 -1
  173. package/lib/module/hooks/useViewMessages/types.js +0 -2
  174. package/lib/module/hooks/useViewMessages/types.js.map +0 -1
  175. package/lib/module/hooks/useViewMessagesOld/index.js +0 -2
  176. package/lib/module/hooks/useViewMessagesOld/index.js.map +0 -1
  177. package/lib/module/index.js +0 -2
  178. package/lib/module/index.js.map +0 -1
  179. package/lib/typescript/ChatContext/index.d.ts +0 -2
  180. package/lib/typescript/ChatContext/types.d.ts +0 -4
  181. package/lib/typescript/classes/Chat/index.d.ts +0 -14
  182. package/lib/typescript/classes/Chat/types.d.ts +0 -21
  183. package/lib/typescript/classes/Inbox/types.d.ts +0 -2
  184. package/lib/typescript/classes/Message/index.d.ts +0 -47
  185. package/lib/typescript/classes/Message/types.d.ts +0 -66
  186. package/lib/typescript/classes/Reaction/index.d.ts +0 -17
  187. package/lib/typescript/classes/Reaction/types.d.ts +0 -33
  188. package/lib/typescript/classes/Room/index.d.ts +0 -42
  189. package/lib/typescript/classes/Room/types.d.ts +0 -112
  190. package/lib/typescript/classes/index.d.ts +0 -4
  191. package/lib/typescript/components/Avatar/index.d.ts +0 -4
  192. package/lib/typescript/components/Chat/Bubble/index.d.ts +0 -4
  193. package/lib/typescript/components/Chat/Composer/Input/index.d.ts +0 -7
  194. package/lib/typescript/components/Chat/Composer/Send/index.d.ts +0 -4
  195. package/lib/typescript/components/Chat/Composer/index.d.ts +0 -8
  196. package/lib/typescript/components/Chat/Media/Image/index.d.ts +0 -7
  197. package/lib/typescript/components/Chat/Media/index.d.ts +0 -4
  198. package/lib/typescript/components/Chat/Message/Touchable/index.d.ts +0 -4
  199. package/lib/typescript/components/Chat/Message/index.d.ts +0 -8
  200. package/lib/typescript/components/Chat/SystemMessage/index.d.ts +0 -4
  201. package/lib/typescript/components/Chat/TypingFooter/index.d.ts +0 -4
  202. package/lib/typescript/components/Chat/index.d.ts +0 -8
  203. package/lib/typescript/components/Chat/types.d.ts +0 -843
  204. package/lib/typescript/components/ChatProvider/index.d.ts +0 -10
  205. package/lib/typescript/components/ChatProvider/types.d.ts +0 -7
  206. package/lib/typescript/components/Inbox/Item/Initials/index.d.ts +0 -4
  207. package/lib/typescript/components/Inbox/Item/ItemDate/index.d.ts +0 -4
  208. package/lib/typescript/components/Inbox/Item/Separator/index.d.ts +0 -6
  209. package/lib/typescript/components/Inbox/Item/Subtitle/index.d.ts +0 -3
  210. package/lib/typescript/components/Inbox/Item/Swipeable/index.d.ts +0 -4
  211. package/lib/typescript/components/Inbox/Item/Title/index.d.ts +0 -3
  212. package/lib/typescript/components/Inbox/Item/UnreadIndicator/index.d.ts +0 -4
  213. package/lib/typescript/components/Inbox/Item/index.d.ts +0 -6
  214. package/lib/typescript/components/Inbox/index.d.ts +0 -4
  215. package/lib/typescript/components/Inbox/types.d.ts +0 -304
  216. package/lib/typescript/components/RoomCreator/Content/Footer/Button/index.d.ts +0 -4
  217. package/lib/typescript/components/RoomCreator/Content/Footer/Input/index.d.ts +0 -4
  218. package/lib/typescript/components/RoomCreator/Content/Footer/index.d.ts +0 -3
  219. package/lib/typescript/components/RoomCreator/Content/Item/Icon/index.d.ts +0 -4
  220. package/lib/typescript/components/RoomCreator/Content/Item/index.d.ts +0 -4
  221. package/lib/typescript/components/RoomCreator/Content/index.d.ts +0 -4
  222. package/lib/typescript/components/RoomCreator/Header/index.d.ts +0 -4
  223. package/lib/typescript/components/RoomCreator/index.d.ts +0 -4
  224. package/lib/typescript/components/RoomCreator/types.d.ts +0 -208
  225. package/lib/typescript/components/TypingIndicator/index.d.ts +0 -9
  226. package/lib/typescript/components/index.d.ts +0 -12
  227. package/lib/typescript/helpers/getInitials.d.ts +0 -1
  228. package/lib/typescript/hooks/index.d.ts +0 -8
  229. package/lib/typescript/hooks/useCreator/index.d.ts +0 -27
  230. package/lib/typescript/hooks/useInbox/index.d.ts +0 -29
  231. package/lib/typescript/hooks/useInbox/types.d.ts +0 -5
  232. package/lib/typescript/hooks/useMessages/index.d.ts +0 -24
  233. package/lib/typescript/hooks/useMessages/types.d.ts +0 -5
  234. package/lib/typescript/hooks/useRoom/index.d.ts +0 -26
  235. package/lib/typescript/hooks/useRoom/types.d.ts +0 -5
  236. package/lib/typescript/hooks/useSend/useSendToGroup/index.d.ts +0 -6
  237. package/lib/typescript/hooks/useSend/useSendToPeople/index.d.ts +0 -6
  238. package/lib/typescript/hooks/useTyping/index.d.ts +0 -36
  239. package/lib/typescript/hooks/useViewMessages/index.d.ts +0 -18
  240. package/lib/typescript/hooks/useViewMessages/types.d.ts +0 -20
  241. package/lib/typescript/index.d.ts +0 -11
  242. package/readme.md +0 -201
  243. package/src/ChatContext/index.tsx +0 -9
  244. package/src/ChatContext/types.ts +0 -4
  245. package/src/classes/Chat/index.ts +0 -46
  246. package/src/classes/Chat/types.ts +0 -23
  247. package/src/classes/Inbox/index.ts +0 -12
  248. package/src/classes/Inbox/types.ts +0 -3
  249. package/src/classes/Message/index.ts +0 -310
  250. package/src/classes/Message/types.ts +0 -118
  251. package/src/classes/Reaction/index.ts +0 -108
  252. package/src/classes/Reaction/types.ts +0 -37
  253. package/src/classes/Room/index.ts +0 -323
  254. package/src/classes/Room/types.ts +0 -161
  255. package/src/classes/index.ts +0 -4
  256. package/src/components/Avatar/index.tsx +0 -25
  257. package/src/components/Chat/Bubble/index.tsx +0 -139
  258. package/src/components/Chat/Composer/Input/index.tsx +0 -45
  259. package/src/components/Chat/Composer/Send/index.tsx +0 -51
  260. package/src/components/Chat/Composer/index.tsx +0 -187
  261. package/src/components/Chat/Media/Image/index.tsx +0 -26
  262. package/src/components/Chat/Media/index.tsx +0 -11
  263. package/src/components/Chat/Message/Swiper/Action/index.tsx +0 -7
  264. package/src/components/Chat/Message/Swiper/index.tsx +0 -32
  265. package/src/components/Chat/Message/Touchable/index.tsx +0 -60
  266. package/src/components/Chat/Message/index.tsx +0 -328
  267. package/src/components/Chat/SystemMessage/index.tsx +0 -44
  268. package/src/components/Chat/TypingFooter/index.tsx +0 -48
  269. package/src/components/Chat/index.tsx +0 -596
  270. package/src/components/Chat/types.ts +0 -913
  271. package/src/components/Chat-Old/Bubble/index.tsx +0 -58
  272. package/src/components/Chat-Old/Composer/Input/index.tsx +0 -34
  273. package/src/components/Chat-Old/Composer/Send/index.tsx +0 -37
  274. package/src/components/Chat-Old/Composer/index.tsx +0 -131
  275. package/src/components/Chat-Old/Message/index.tsx +0 -160
  276. package/src/components/Chat-Old/Swiper/Action/index.tsx +0 -7
  277. package/src/components/Chat-Old/Swiper/index.tsx +0 -30
  278. package/src/components/Chat-Old/SystemMessage/index.tsx +0 -44
  279. package/src/components/Chat-Old/index.tsx +0 -356
  280. package/src/components/Chat-Old/types.ts +0 -752
  281. package/src/components/ChatProvider/index.tsx +0 -31
  282. package/src/components/ChatProvider/types.ts +0 -8
  283. package/src/components/Inbox/Item/Circle/index.tsx +0 -47
  284. package/src/components/Inbox/Item/Circle/types.ts +0 -8
  285. package/src/components/Inbox/Item/Initials/index.tsx +0 -41
  286. package/src/components/Inbox/Item/ItemDate/index.tsx +0 -26
  287. package/src/components/Inbox/Item/Separator/index.tsx +0 -13
  288. package/src/components/Inbox/Item/Subtitle/index.tsx +0 -23
  289. package/src/components/Inbox/Item/Swipeable/index.tsx +0 -143
  290. package/src/components/Inbox/Item/Title/index.tsx +0 -23
  291. package/src/components/Inbox/Item/UnreadIndicator/index.tsx +0 -84
  292. package/src/components/Inbox/Item/index.tsx +0 -307
  293. package/src/components/Inbox/index.tsx +0 -315
  294. package/src/components/Inbox/question.md +0 -21
  295. package/src/components/Inbox/readme.md +0 -21
  296. package/src/components/Inbox/types.ts +0 -371
  297. package/src/components/RoomCreator/Content/Footer/Button/index.tsx +0 -55
  298. package/src/components/RoomCreator/Content/Footer/Input/index.tsx +0 -27
  299. package/src/components/RoomCreator/Content/Footer/index.tsx +0 -72
  300. package/src/components/RoomCreator/Content/Item/Icon/index.tsx +0 -16
  301. package/src/components/RoomCreator/Content/Item/index.tsx +0 -87
  302. package/src/components/RoomCreator/Content/index.tsx +0 -75
  303. package/src/components/RoomCreator/Header/index.tsx +0 -74
  304. package/src/components/RoomCreator/index.tsx +0 -177
  305. package/src/components/RoomCreator/types.ts +0 -233
  306. package/src/components/TypingIndicator/index.tsx +0 -169
  307. package/src/components/index.ts +0 -18
  308. package/src/helpers/getInitials.ts +0 -11
  309. package/src/helpers/sortByAvatar.ts +0 -1
  310. package/src/hooks/index.ts +0 -8
  311. package/src/hooks/useCreateRoom/index.ts +0 -34
  312. package/src/hooks/useCreator/index.ts +0 -33
  313. package/src/hooks/useInbox/index.ts +0 -76
  314. package/src/hooks/useInbox/types.ts +0 -6
  315. package/src/hooks/useMessages/index.ts +0 -109
  316. package/src/hooks/useMessages/types.ts +0 -6
  317. package/src/hooks/useRoom/index.ts +0 -82
  318. package/src/hooks/useRoom/types.ts +0 -6
  319. package/src/hooks/useSend/useSendToGroup/index.ts +0 -38
  320. package/src/hooks/useSend/useSendToPeople/index.ts +0 -38
  321. package/src/hooks/useTyping/index.ts +0 -154
  322. package/src/hooks/useTypingOLD/index.ts +0 -67
  323. package/src/hooks/useTypingOLD/types.ts +0 -7
  324. package/src/hooks/useViewMessages/index.ts +0 -61
  325. package/src/hooks/useViewMessages/types.ts +0 -22
  326. package/src/hooks/useViewMessagesOld/index.ts +0 -39
  327. package/src/index.ts +0 -13
@@ -0,0 +1,349 @@
1
+ /**
2
+ * Card elements for cross-platform rich messaging.
3
+ *
4
+ * Provides a builder API for creating rich cards that automatically
5
+ * convert to platform-specific formats:
6
+ * - Slack: Block Kit
7
+ * - Teams: Adaptive Cards
8
+ * - Google Chat: Card v2
9
+ *
10
+ * Supports both function-call and JSX syntax:
11
+ *
12
+ * @example Function API
13
+ * ```ts
14
+ * import { Card, Text, Actions, Button } from "chat";
15
+ *
16
+ * await thread.post(
17
+ * Card({
18
+ * title: "Order #1234",
19
+ * children: [
20
+ * Text("Total: $50.00"),
21
+ * Actions([
22
+ * Button({ id: "approve", label: "Approve", style: "primary" }),
23
+ * Button({ id: "reject", label: "Reject", style: "danger" }),
24
+ * ]),
25
+ * ],
26
+ * })
27
+ * );
28
+ * ```
29
+ *
30
+ * @example JSX API (requires jsxImportSource: "chat" in tsconfig)
31
+ * ```tsx
32
+ * /** @jsxImportSource chat *\/
33
+ * import { Card, Text, Actions, Button } from "chat";
34
+ *
35
+ * await thread.post(
36
+ * <Card title="Order #1234">
37
+ * <Text>Total: $50.00</Text>
38
+ * <Actions>
39
+ * <Button id="approve" style="primary">Approve</Button>
40
+ * <Button id="reject" style="danger">Reject</Button>
41
+ * </Actions>
42
+ * </Card>
43
+ * );
44
+ * ```
45
+ */
46
+ /** Button style options */
47
+ type ButtonStyle = "primary" | "danger" | "default";
48
+ /** Text style options */
49
+ type TextStyle = "plain" | "bold" | "muted";
50
+ /** Button element for interactive actions */
51
+ interface ButtonElement {
52
+ type: "button";
53
+ /** Unique action ID for callback routing */
54
+ id: string;
55
+ /** Button label text */
56
+ label: string;
57
+ /** Visual style */
58
+ style?: ButtonStyle;
59
+ /** Optional payload value sent with action callback */
60
+ value?: string;
61
+ }
62
+ /** Text content element */
63
+ interface TextElement {
64
+ type: "text";
65
+ /** Text content (supports markdown in some platforms) */
66
+ content: string;
67
+ /** Text style */
68
+ style?: TextStyle;
69
+ }
70
+ /** Image element */
71
+ interface ImageElement {
72
+ type: "image";
73
+ /** Image URL */
74
+ url: string;
75
+ /** Alt text for accessibility */
76
+ alt?: string;
77
+ }
78
+ /** Visual divider/separator */
79
+ interface DividerElement {
80
+ type: "divider";
81
+ }
82
+ /** Container for action buttons */
83
+ interface ActionsElement {
84
+ type: "actions";
85
+ /** Button elements */
86
+ children: ButtonElement[];
87
+ }
88
+ /** Section container for grouping elements */
89
+ interface SectionElement {
90
+ type: "section";
91
+ /** Section children */
92
+ children: CardChild[];
93
+ }
94
+ /** Field for key-value display */
95
+ interface FieldElement {
96
+ type: "field";
97
+ /** Field label */
98
+ label: string;
99
+ /** Field value */
100
+ value: string;
101
+ }
102
+ /** Fields container for multi-column layout */
103
+ interface FieldsElement {
104
+ type: "fields";
105
+ /** Field elements */
106
+ children: FieldElement[];
107
+ }
108
+ /** Union of all card child element types */
109
+ type CardChild = TextElement | ImageElement | DividerElement | ActionsElement | SectionElement | FieldsElement;
110
+ /** Union of all element types (including nested children) */
111
+ type AnyCardElement = CardChild | CardElement | ButtonElement | FieldElement;
112
+ /** Root card element */
113
+ interface CardElement {
114
+ type: "card";
115
+ /** Card title */
116
+ title?: string;
117
+ /** Card subtitle */
118
+ subtitle?: string;
119
+ /** Header image URL */
120
+ imageUrl?: string;
121
+ /** Card content */
122
+ children: CardChild[];
123
+ }
124
+ /** Type guard for CardElement */
125
+ declare function isCardElement(value: unknown): value is CardElement;
126
+ /** Options for Card */
127
+ interface CardOptions {
128
+ title?: string;
129
+ subtitle?: string;
130
+ imageUrl?: string;
131
+ children?: CardChild[];
132
+ }
133
+ /**
134
+ * Create a Card element.
135
+ *
136
+ * @example
137
+ * ```ts
138
+ * Card({
139
+ * title: "Welcome",
140
+ * children: [Text("Hello!")],
141
+ * })
142
+ * ```
143
+ */
144
+ declare function Card(options?: CardOptions): CardElement;
145
+ /**
146
+ * Create a Text element.
147
+ *
148
+ * @example
149
+ * ```ts
150
+ * Text("Hello, world!")
151
+ * Text("Important", { style: "bold" })
152
+ * ```
153
+ */
154
+ declare function Text(content: string, options?: {
155
+ style?: TextStyle;
156
+ }): TextElement;
157
+ /**
158
+ * Create an Image element.
159
+ *
160
+ * @example
161
+ * ```ts
162
+ * Image({ url: "https://example.com/image.png", alt: "Description" })
163
+ * ```
164
+ */
165
+ declare function Image(options: {
166
+ url: string;
167
+ alt?: string;
168
+ }): ImageElement;
169
+ /**
170
+ * Create a Divider element.
171
+ *
172
+ * @example
173
+ * ```ts
174
+ * Divider()
175
+ * ```
176
+ */
177
+ declare function Divider(): DividerElement;
178
+ /**
179
+ * Create a Section container.
180
+ *
181
+ * @example
182
+ * ```ts
183
+ * Section([
184
+ * Text("Grouped content"),
185
+ * Image({ url: "..." }),
186
+ * ])
187
+ * ```
188
+ */
189
+ declare function Section(children: CardChild[]): SectionElement;
190
+ /**
191
+ * Create an Actions container for buttons.
192
+ *
193
+ * @example
194
+ * ```ts
195
+ * Actions([
196
+ * Button({ id: "ok", label: "OK" }),
197
+ * Button({ id: "cancel", label: "Cancel" }),
198
+ * ])
199
+ * ```
200
+ */
201
+ declare function Actions(children: ButtonElement[]): ActionsElement;
202
+ /** Options for Button */
203
+ interface ButtonOptions {
204
+ /** Unique action ID for callback routing */
205
+ id: string;
206
+ /** Button label text */
207
+ label: string;
208
+ /** Visual style */
209
+ style?: ButtonStyle;
210
+ /** Optional payload value sent with action callback */
211
+ value?: string;
212
+ }
213
+ /**
214
+ * Create a Button element.
215
+ *
216
+ * @example
217
+ * ```ts
218
+ * Button({ id: "submit", label: "Submit", style: "primary" })
219
+ * Button({ id: "delete", label: "Delete", style: "danger", value: "item-123" })
220
+ * ```
221
+ */
222
+ declare function Button(options: ButtonOptions): ButtonElement;
223
+ /**
224
+ * Create a Field element for key-value display.
225
+ *
226
+ * @example
227
+ * ```ts
228
+ * Field({ label: "Status", value: "Active" })
229
+ * ```
230
+ */
231
+ declare function Field(options: {
232
+ label: string;
233
+ value: string;
234
+ }): FieldElement;
235
+ /**
236
+ * Create a Fields container for multi-column layout.
237
+ *
238
+ * @example
239
+ * ```ts
240
+ * Fields([
241
+ * Field({ label: "Name", value: "John" }),
242
+ * Field({ label: "Email", value: "john@example.com" }),
243
+ * ])
244
+ * ```
245
+ */
246
+ declare function Fields(children: FieldElement[]): FieldsElement;
247
+ /**
248
+ * Convert a React element tree to a CardElement tree.
249
+ * This allows using React's JSX with our card components.
250
+ *
251
+ * @example
252
+ * ```tsx
253
+ * import React from "react";
254
+ * import { Card, Text, fromReactElement } from "chat";
255
+ *
256
+ * const element = (
257
+ * <Card title="Hello">
258
+ * <Text>World</Text>
259
+ * </Card>
260
+ * );
261
+ *
262
+ * const card = fromReactElement(element);
263
+ * await thread.post(card);
264
+ * ```
265
+ */
266
+ declare function fromReactElement(element: unknown): AnyCardElement | null;
267
+
268
+ /**
269
+ * Custom JSX runtime for chat cards.
270
+ *
271
+ * This allows using JSX syntax without React. Configure your bundler:
272
+ *
273
+ * tsconfig.json:
274
+ * {
275
+ * "compilerOptions": {
276
+ * "jsx": "react-jsx",
277
+ * "jsxImportSource": "chat"
278
+ * }
279
+ * }
280
+ *
281
+ * Or per-file:
282
+ * /** @jsxImportSource chat *\/
283
+ *
284
+ * Usage:
285
+ * ```tsx
286
+ * import { Card, Text, Button, Actions } from "chat";
287
+ *
288
+ * const card = (
289
+ * <Card title="Order #1234">
290
+ * <Text>Your order is ready!</Text>
291
+ * <Actions>
292
+ * <Button id="pickup" style="primary">Schedule Pickup</Button>
293
+ * </Actions>
294
+ * </Card>
295
+ * );
296
+ * ```
297
+ */
298
+
299
+ declare const JSX_ELEMENT: unique symbol;
300
+ /**
301
+ * Represents a JSX element from the chat JSX runtime.
302
+ * This is the type returned when using JSX syntax with chat components.
303
+ */
304
+ interface CardJSXElement {
305
+ $$typeof: typeof JSX_ELEMENT;
306
+ type: CardComponentFunction;
307
+ props: Record<string, unknown>;
308
+ children: unknown[];
309
+ }
310
+ type JSXElement = CardJSXElement;
311
+ type CardComponentFunction = (...args: any[]) => CardElement | CardChild;
312
+ /**
313
+ * JSX factory function (used by the JSX transform).
314
+ * Creates a lazy JSX element that will be resolved when needed.
315
+ */
316
+ declare function jsx(type: CardComponentFunction, props: Record<string, unknown>, _key?: string): JSXElement;
317
+ /**
318
+ * JSX factory for elements with multiple children.
319
+ */
320
+ declare function jsxs(type: CardComponentFunction, props: Record<string, unknown>, _key?: string): JSXElement;
321
+ /**
322
+ * Development JSX factory (same as jsx, but called in dev mode).
323
+ */
324
+ declare const jsxDEV: typeof jsx;
325
+ /**
326
+ * Fragment support (flattens children).
327
+ */
328
+ declare function Fragment(props: {
329
+ children?: unknown;
330
+ }): CardChild[];
331
+ /**
332
+ * Convert a JSX element tree to a CardElement.
333
+ * Call this on the root JSX element to get a usable CardElement.
334
+ */
335
+ declare function toCardElement(jsxElement: unknown): CardElement | null;
336
+ /**
337
+ * Check if a value is a JSX element (from our runtime or React).
338
+ */
339
+ declare function isJSX(value: unknown): boolean;
340
+ declare namespace JSX {
341
+ interface Element extends JSXElement {
342
+ }
343
+ type IntrinsicElements = {};
344
+ interface ElementChildrenAttribute {
345
+ children: {};
346
+ }
347
+ }
348
+
349
+ export { Actions as A, Button as B, type CardElement as C, Divider as D, Field as F, Image as I, JSX as J, Section as S, Text as T, type CardJSXElement as a, type CardChild as b, Card as c, Fields as d, isJSX as e, fromReactElement as f, type ActionsElement as g, type ButtonElement as h, isCardElement as i, type ButtonOptions as j, type ButtonStyle as k, type CardOptions as l, type DividerElement as m, type FieldElement as n, type FieldsElement as o, type ImageElement as p, type SectionElement as q, type TextElement as r, type TextStyle as s, toCardElement as t, jsx as u, jsxs as v, jsxDEV as w, Fragment as x };
@@ -0,0 +1 @@
1
+ export { a as CardJSXElement, x as Fragment, J as JSX, e as isJSX, u as jsx, w as jsxDEV, v as jsxs, t as toCardElement } from './jsx-runtime-D7zHSnXe.js';
@@ -0,0 +1,17 @@
1
+ import {
2
+ Fragment,
3
+ isJSX,
4
+ jsx,
5
+ jsxDEV,
6
+ jsxs,
7
+ toCardElement
8
+ } from "./chunk-ACQNDPTB.js";
9
+ export {
10
+ Fragment,
11
+ isJSX,
12
+ jsx,
13
+ jsxDEV,
14
+ jsxs,
15
+ toCardElement
16
+ };
17
+ //# sourceMappingURL=jsx-runtime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
package/package.json CHANGED
@@ -1,98 +1,62 @@
1
1
  {
2
- "name": "chat",
3
- "description": "The best fully-hosted chat solution for React Native/Expo.",
4
- "version": "1.0.8",
5
- "main": "lib/module/index",
6
- "module": "lib/module/index",
7
- "react-native": "lib/module/index",
8
- "types": "lib/typescript/index",
9
- "homepage": "https://github.com/nandorojo/chatjs",
10
- "repository": {
11
- "type": "git",
12
- "url": "https://github.com/nandorojo/chatjs"
13
- },
14
- "scripts": {
15
- "type-check": "tsc --noEmit",
16
- "type-check:watch": "npm run type-check -- --watch",
17
- "build": "npm run build:types && npm run build:js",
18
- "bundle": "babel src --out-file bundle/index.js --extensions \".ts,.tsx\" --source-maps inline",
19
- "build:tsc": "npm run build:types && npm run build:test",
20
- "build:redash:types": "tsc --noEmit",
21
- "build:types": "tsc --emitDeclarationOnly --skipLibCheck",
22
- "build:js": "babel src --out-dir lib --extensions \".ts,.tsx\" --source-maps inline",
23
- "build:test": "rm -R lib && babel src-og --out-dir lib --extensions \".ts,.tsx\" --source-maps inline",
24
- "build:babel": "rm -R lib && babel src --out-dir lib --extensions \".ts,.tsx\" --source-maps inline",
25
- "build:final": "mkdir -p bundle && npm run bundle && npm run build:types",
26
- "prepare": "bob build",
27
- "upload": "yarn prepare && yarn publish",
28
- "docz:dev": "docz dev",
29
- "docz:build": "docz build",
30
- "docz:serve": "docz build && docz serve"
31
- },
32
- "devDependencies": {
33
- "@babel/cli": "^7.2.3",
34
- "@babel/core": "^7.4.0",
35
- "@babel/plugin-proposal-class-properties": "^7.4.0",
36
- "@babel/plugin-proposal-numeric-separator": "^7.2.0",
37
- "@babel/plugin-proposal-object-rest-spread": "^7.4.0",
38
- "@babel/plugin-proposal-optional-chaining": "^7.2.0",
39
- "@babel/preset-env": "^7.4.1",
40
- "@babel/preset-react": "^7.0.0",
41
- "@babel/preset-typescript": "^7.3.3",
42
- "@expo/vector-icons": "^10.0.5",
43
- "@firebase/firestore-types": "^1.4.4",
44
- "@react-native-community/bob": "^0.6.1",
45
- "@types/react": "^16.9.1",
46
- "@types/react-dom": "^16.8.5",
47
- "@types/react-native": "^0.60.4",
48
- "@types/uuid": "^3.4.5",
49
- "@typescript-eslint/eslint-plugin": "^2.1.0",
50
- "@typescript-eslint/parser": "^2.1.0",
51
- "babel-preset-expo": "^8.0.0",
52
- "docz": "^2.2.0",
53
- "eslint": "^6.8.0",
54
- "eslint-config-nando": "^1.0.3",
55
- "eslint-config-prettier": "^6.3.0",
56
- "eslint-config-rallycoding": "^3.2.0",
57
- "eslint-plugin-react": "^7.14.3",
58
- "eslint-plugin-react-hooks": "^1.7.0",
59
- "expo": "^36.0.2",
60
- "firebase": "^6.2.4",
61
- "gatsby-plugin-react-native-web": "^3.0.0-beta.7",
62
- "prettier": "^1.19.1",
63
- "prettier-eslint": "^9.0.0",
64
- "react": "^16.9.0",
65
- "react-art": "^16.12.0",
66
- "react-dom": "^16.12.0",
67
- "react-native": "https://github.com/expo/react-native/archive/sdk-36.0.0.tar.gz",
68
- "react-native-web": "^0.12.2",
69
- "typescript": "^3.8.3"
70
- },
71
- "dependencies": {
72
- "@nandorojo/fuego": "^0.0.24",
73
- "expo-linear-gradient": "^8.0.0",
74
- "moment": "^2.24.0",
75
- "react-native-gesture-handler": "^1.6.0",
76
- "react-native-iphone-x-helper": "^1.2.1",
77
- "react-native-reanimated": "^1.7.0",
78
- "reanimated-bottom-sheet": "^1.0.0-alpha.13",
79
- "uuid": "^3.3.3"
80
- },
81
- "bugs": {
82
- "url": "https://github.com/nandorojo/chatjs/issues"
83
- },
84
- "author": "Fernando Rojo",
85
- "license": "MIT",
86
- "files": [
87
- "lib",
88
- "src"
89
- ],
90
- "@react-native-community/bob": {
91
- "source": "src",
92
- "output": "lib",
93
- "targets": [
94
- "module",
95
- "typescript"
96
- ]
97
- }
98
- }
2
+ "name": "chat",
3
+ "version": "4.0.0",
4
+ "description": "Unified chat abstraction for Slack, Teams, Google Chat, and Discord",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "module": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js"
13
+ },
14
+ "./jsx-runtime": {
15
+ "types": "./dist/jsx-runtime.d.ts",
16
+ "import": "./dist/jsx-runtime.js"
17
+ },
18
+ "./jsx-dev-runtime": {
19
+ "types": "./dist/jsx-runtime.d.ts",
20
+ "import": "./dist/jsx-runtime.js"
21
+ }
22
+ },
23
+ "files": [
24
+ "dist"
25
+ ],
26
+ "dependencies": {
27
+ "unified": "^11.0.5",
28
+ "remark-parse": "^11.0.0",
29
+ "remark-stringify": "^11.0.0",
30
+ "remark-gfm": "^4.0.0",
31
+ "mdast-util-to-string": "^4.0.0"
32
+ },
33
+ "devDependencies": {
34
+ "@types/node": "^22.10.2",
35
+ "@types/mdast": "^4.0.4",
36
+ "tsup": "^8.3.5",
37
+ "typescript": "^5.7.2",
38
+ "vitest": "^2.1.8"
39
+ },
40
+ "peerDependencies": {},
41
+ "publishConfig": {
42
+ "access": "public"
43
+ },
44
+ "keywords": [
45
+ "chat",
46
+ "slack",
47
+ "teams",
48
+ "discord",
49
+ "google-chat",
50
+ "bot"
51
+ ],
52
+ "license": "MIT",
53
+ "scripts": {
54
+ "build": "rm -rf dist && tsup",
55
+ "dev": "tsup --watch",
56
+ "test": "vitest run",
57
+ "test:watch": "vitest",
58
+ "typecheck": "tsc --noEmit",
59
+ "lint": "biome check src",
60
+ "clean": "rm -rf dist"
61
+ }
62
+ }
@@ -1,2 +0,0 @@
1
- import{createContext}from'react';var context=createContext();context.displayName='ChatJS';export default context;
2
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["index.tsx"],"names":["createContext","context","displayName"],"mappings":"AAAA,OAASA,aAAT,KAA8B,OAA9B,CAKA,GAAMC,CAAAA,OAAO,CAAGD,aAAa,EAA7B,CACAC,OAAO,CAACC,WAAR,CAAsB,QAAtB,CAEA,cAAeD,CAAAA,OAAf","sourcesContent":["import { createContext } from 'react'\nimport { ChatContextType } from './types'\n\n// no default necessary with a provider at the top\n// @ts-ignore\nconst context = createContext<ChatContextType>()\ncontext.displayName = 'ChatJS'\n\nexport default context\n"]}
@@ -1,2 +0,0 @@
1
-
2
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
@@ -1,2 +0,0 @@
1
- import _classCallCheck from"@babel/runtime/helpers/classCallCheck";import _createClass from"@babel/runtime/helpers/createClass";var Chat=function(){function Chat(){var chat=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};_classCallCheck(this,Chat);this.chat=chat;}_createClass(Chat,[{key:"roomsCollection",get:function get(){return this.chat.roomsCollection||'rooms';}},{key:"messagesCollection",get:function get(){return this.chat.messagesCollection||'messages';}},{key:"httpCallables",get:function get(){return{sendMessageFromFeed:this.chat.httpCallables&&this.chat.httpCallables.sendMessageFromFeed||'sendMessageFromFeed',sendMessageToPeople:this.chat.httpCallables&&this.chat.httpCallables.sendMessageToPeople||'sendMessageToPeople',sendMessageToGroup:this.chat.httpCallables&&this.chat.httpCallables.sendMessageToGroup||'sendMessageToGroup',createRoom:this.chat.httpCallables&&this.chat.httpCallables.createRoom||'createRoom',sendMessageToRooms:this.chat.httpCallables&&this.chat.httpCallables.sendMessageToRooms||'sendMessageToRooms'};}}]);return Chat;}();export{Chat as default};
2
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["index.ts"],"names":["Chat","chat","roomsCollection","messagesCollection","sendMessageFromFeed","httpCallables","sendMessageToPeople","sendMessageToGroup","createRoom","sendMessageToRooms"],"mappings":"mIAEqBA,CAAAA,I,YAEpB,eAAmC,IAAvBC,CAAAA,IAAuB,2DAAJ,EAAI,4BAClC,KAAKA,IAAL,CAAYA,IAAZ,CAUA,C,4DACqB,CACrB,MAAO,MAAKA,IAAL,CAAUC,eAAV,EAA6B,OAApC,CACA,C,8CACwB,CACxB,MAAO,MAAKD,IAAL,CAAUE,kBAAV,EAAgC,UAAvC,CACA,C,yCACmB,CACnB,MAAO,CACNC,mBAAmB,CACjB,KAAKH,IAAL,CAAUI,aAAV,EACA,KAAKJ,IAAL,CAAUI,aAAV,CAAwBD,mBADzB,EAEA,qBAJK,CAKNE,mBAAmB,CACjB,KAAKL,IAAL,CAAUI,aAAV,EACA,KAAKJ,IAAL,CAAUI,aAAV,CAAwBC,mBADzB,EAEA,qBARK,CASNC,kBAAkB,CAChB,KAAKN,IAAL,CAAUI,aAAV,EACA,KAAKJ,IAAL,CAAUI,aAAV,CAAwBE,kBADzB,EAEA,oBAZK,CAaNC,UAAU,CACR,KAAKP,IAAL,CAAUI,aAAV,EAA2B,KAAKJ,IAAL,CAAUI,aAAV,CAAwBG,UAApD,EACA,YAfK,CAgBNC,kBAAkB,CAChB,KAAKR,IAAL,CAAUI,aAAV,EACA,KAAKJ,IAAL,CAAUI,aAAV,CAAwBI,kBADzB,EAEA,oBAnBK,CAAP,CAqBA,C,2BA1CmBT,I","sourcesContent":["import { ChatConfig } from './types'\n\nexport default class Chat {\n\tprivate chat: ChatConfig\n\tconstructor(chat: ChatConfig = {}) {\n\t\tthis.chat = chat\n\t\t// this.chat = {\n\t\t// \t...chat,\n\t\t// \thttpCallables: {\n\t\t// \t\tsendMessageFromFeed: 'sendMessageFromFeed',\n\t\t// \t\tsendMessageToPeople: 'sendToPeople',\n\t\t// \t\tsendMessageToGroup: 'sendToGroup',\n\t\t// \t\t...(chat.httpCallables || {})\n\t\t// \t}\n\t\t// }\n\t}\n\tget roomsCollection() {\n\t\treturn this.chat.roomsCollection || 'rooms'\n\t}\n\tget messagesCollection() {\n\t\treturn this.chat.messagesCollection || 'messages'\n\t}\n\tget httpCallables() {\n\t\treturn {\n\t\t\tsendMessageFromFeed:\n\t\t\t\t(this.chat.httpCallables &&\n\t\t\t\t\tthis.chat.httpCallables.sendMessageFromFeed) ||\n\t\t\t\t'sendMessageFromFeed',\n\t\t\tsendMessageToPeople:\n\t\t\t\t(this.chat.httpCallables &&\n\t\t\t\t\tthis.chat.httpCallables.sendMessageToPeople) ||\n\t\t\t\t'sendMessageToPeople',\n\t\t\tsendMessageToGroup:\n\t\t\t\t(this.chat.httpCallables &&\n\t\t\t\t\tthis.chat.httpCallables.sendMessageToGroup) ||\n\t\t\t\t'sendMessageToGroup',\n\t\t\tcreateRoom:\n\t\t\t\t(this.chat.httpCallables && this.chat.httpCallables.createRoom) ||\n\t\t\t\t'createRoom',\n\t\t\tsendMessageToRooms:\n\t\t\t\t(this.chat.httpCallables &&\n\t\t\t\t\tthis.chat.httpCallables.sendMessageToRooms) ||\n\t\t\t\t'sendMessageToRooms'\n\t\t}\n\t}\n}\n"]}
@@ -1,2 +0,0 @@
1
-
2
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
@@ -1,2 +0,0 @@
1
- import _classCallCheck from"@babel/runtime/helpers/classCallCheck";import _createClass from"@babel/runtime/helpers/createClass";import{chat}from'../../components/ChatProvider';var _default=function(){function _default(inbox){_classCallCheck(this,_default);this.inbox=inbox;}_createClass(_default,[{key:"path",get:function get(){return chat.messagesCollection;}}]);return _default;}();export{_default as default};
2
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["index.ts"],"names":["chat","inbox","messagesCollection"],"mappings":"gIACA,OAASA,IAAT,KAAqB,+BAArB,C,wBAIC,kBAAYC,KAAZ,CAA+B,gCAC9B,KAAKA,KAAL,CAAaA,KAAb,CACA,C,qDACU,CACV,MAAOD,CAAAA,IAAI,CAACE,kBAAZ,CACA,C","sourcesContent":["import { InboxModel } from './types'\nimport { chat } from '../../components/ChatProvider'\n\nexport default class {\n\tprivate inbox: InboxModel\n\tconstructor(inbox: InboxModel) {\n\t\tthis.inbox = inbox\n\t}\n\tget path() {\n\t\treturn chat.messagesCollection\n\t}\n}\n"]}
@@ -1,2 +0,0 @@
1
-
2
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
@@ -1,2 +0,0 @@
1
- import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";import _regeneratorRuntime from"@babel/runtime/regenerator";import _defineProperty from"@babel/runtime/helpers/defineProperty";import _classCallCheck from"@babel/runtime/helpers/classCallCheck";import _createClass from"@babel/runtime/helpers/createClass";function ownKeys(object,enumerableOnly){var keys=Object.keys(object);if(Object.getOwnPropertySymbols){var symbols=Object.getOwnPropertySymbols(object);if(enumerableOnly)symbols=symbols.filter(function(sym){return Object.getOwnPropertyDescriptor(object,sym).enumerable;});keys.push.apply(keys,symbols);}return keys;}function _objectSpread(target){for(var i=1;i<arguments.length;i++){var source=arguments[i]!=null?arguments[i]:{};if(i%2){ownKeys(Object(source),true).forEach(function(key){_defineProperty(target,key,source[key]);});}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(target,Object.getOwnPropertyDescriptors(source));}else{ownKeys(Object(source)).forEach(function(key){Object.defineProperty(target,key,Object.getOwnPropertyDescriptor(source,key));});}}return target;}import{recipientHasId,recipientHasMembers,isNewMessageModel}from'./types';import{fuego,chat}from'../../components/ChatProvider/index';import Room from'../Room';var _default=function(){function _default(message){_classCallCheck(this,_default);this.message=message;}_createClass(_default,[{key:"sendToRooms",value:function sendToRooms(recipients){var send;return _regeneratorRuntime.async(function sendToRooms$(_context){while(1){switch(_context.prev=_context.next){case 0:_context.prev=0;send=fuego.firebase.functions().httpsCallable(chat.httpCallables.sendMessageToRooms);if(isNewMessageModel(this.message)){_context.next=4;break;}throw new Error('FAILED TO SEND TO ROOMS: message object is not NewMessageModel');case 4:this.message=_objectSpread({},this.message,{createdAt:fuego.firebase.firestore.FieldValue.serverTimestamp()});return _context.abrupt("return",send({message:this.message,recipients:recipients}));case 8:_context.prev=8;_context.t0=_context["catch"](0);console.error(_context.t0);return _context.abrupt("return",{data:null});case 12:case"end":return _context.stop();}}},null,this,[[0,8]]);}},{key:"sendToPeople",value:function sendToPeople(recipients){var send;return _regeneratorRuntime.async(function sendToPeople$(_context2){while(1){switch(_context2.prev=_context2.next){case 0:send=fuego.firebase.functions().httpsCallable(chat.httpCallables.sendMessageToPeople);_context2.prev=1;if(isNewMessageModel(this.message)){_context2.next=4;break;}throw new Error('FAILED TO SEND TO PEOPLE: message object is not NewMessageModel');case 4:this.message=_objectSpread({},this.message,{createdAt:fuego.firebase.firestore.FieldValue.serverTimestamp()});return _context2.abrupt("return",send({message:this.message,recipients:recipients}));case 8:_context2.prev=8;_context2.t0=_context2["catch"](1);console.error(_context2.t0);return _context2.abrupt("return",{data:null});case 12:case"end":return _context2.stop();}}},null,this,[[1,8]]);}},{key:"sendToGroup",value:function sendToGroup(recipients){var send;return _regeneratorRuntime.async(function sendToGroup$(_context3){while(1){switch(_context3.prev=_context3.next){case 0:send=fuego.firebase.functions().httpsCallable(chat.httpCallables.sendMessageToGroup);_context3.prev=1;if(isNewMessageModel(this.message)){_context3.next=4;break;}throw new Error('FAILED TO SEND TO PEOPLE: message object is not NewMessageModel');case 4:this.message=_objectSpread({},this.message,{createdAt:fuego.firebase.firestore.FieldValue.serverTimestamp()});return _context3.abrupt("return",send({message:this.message,recipients:recipients}));case 8:_context3.prev=8;_context3.t0=_context3["catch"](1);console.error(_context3.t0);return _context3.abrupt("return",{data:null});case 12:case"end":return _context3.stop();}}},null,this,[[1,8]]);}},{key:"sendFromFeed",value:function sendFromFeed(to){var _this=this;var batch=fuego.db.batch();var promises=[];to.forEach(function(room){var _ref=_this.message,id=_ref.id,message=_objectWithoutProperties(_ref,["id"]);if(recipientHasId(room)){var _ref2=new Room({id:room.id}),messagesPath=_ref2.messagesPath;var ref=fuego.db.collection(messagesPath).doc(id);batch.set(ref,message);}else if(recipientHasMembers(room)){var peopleInThisRoomOtherThanMe=room.recipients.slice().sort(function(a,b){return a.id>b.id?1:-1;});var addMessage=fuego.firebase.functions().httpsCallable(chat.httpCallables.sendMessageFromFeed);var newMessage=_objectSpread({},message,{recipients:peopleInThisRoomOtherThanMe});promises.push(addMessage(newMessage));}});return Promise.all([batch.commit()].concat(promises));}},{key:"send",value:function send(roomId){this.addToFirebase(roomId);}},{key:"edit",value:function edit(roomId){return this.updateOnFirebase(roomId);}},{key:"formatForRender",value:function formatForRender(){function isDocList(m){return!!m;}function isDocument(m){return!!m;}try{if(isDocList(this.message)){return this.message.map(function(doc){return _objectSpread({},doc,{id:doc.id,createdAt:doc.createdAt.toDate()});})||[];}if(isDocument(this.message))return _objectSpread({},this.message,{id:this.message.id,createdAt:this.message.createdAt.toDate()});throw new Error('Wrong model here.');}catch(e){console.error('wrong model given to format for render in Message class.',e);return null;}}},{key:"formatForSend",value:function formatForSend(){try{var isNew=function isNew(m){return!!m;};if(isNew(this.message)){this.message=this.message.map(function(message){return _objectSpread({},message,{text:message.text&&message.text.trim()||'',createdAt:fuego.firebase.firestore.FieldValue.serverTimestamp()});});return this;}throw new Error('wrong format for formatting for send');}catch(e){console.error(e);return this;}}},{key:"addToFirebase",value:function addToFirebase(roomId){var messages=this.message;var batch=fuego.db.batch();var updateBatch=function updateBatch(roomId){var addToBatch=function addToBatch(message){try{var _ref3=new Room({id:roomId}),messagesPath=_ref3.messagesPath,roomPath=_ref3.path;var ref=fuego.db.collection(messagesPath).doc(message.id);var id=message.id,messageDoc=_objectWithoutProperties(message,["id"]);batch.set(ref,messageDoc);var _ref4=fuego.auth().currentUser,displayName=_ref4.displayName,uid=_ref4.uid;var roomRef=fuego.db.doc(roomPath);var lastMessage={name:displayName||'Name failed',id:uid,system:false,text:message.text,createdAt:message.createdAt};batch.update(roomRef,{lastMessage:lastMessage});}catch(e){console.error('sending message had an error:',e);}};messages.forEach(addToBatch);};if(Array.isArray(roomId)){;roomId.forEach(updateBatch);}else{updateBatch(roomId);}return batch.commit();}},{key:"updateOnFirebase",value:function updateOnFirebase(roomId){var _ref5=new Room({id:roomId}),path=_ref5.path;var _ref6=this.message,id=_ref6.id,message=_objectWithoutProperties(_ref6,["id"]);return fuego.db.collection(path).doc(this.message.id).set(message,{merge:true});}},{key:"getUsersWhoReacted",value:function getUsersWhoReacted(reaction,_ref7){var roomMembers=_ref7.roomMembers;var users=[];if(!isNewMessageModel(this.message)){console.warn('error getting users who reacted. Needs the new message model passed as an argument, but instead it got this:',this.message);}else if(this.message.reactions){this.message.reactions[reaction].forEach(function(uid){return roomMembers[uid]&&users.push(roomMembers[uid]);});}return users;}}]);return _default;}();export{_default as default};
2
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["index.ts"],"names":["recipientHasId","recipientHasMembers","isNewMessageModel","fuego","chat","Room","message","recipients","send","firebase","functions","httpsCallable","httpCallables","sendMessageToRooms","Error","createdAt","firestore","FieldValue","serverTimestamp","console","error","data","sendMessageToPeople","sendMessageToGroup","to","batch","db","promises","forEach","room","id","messagesPath","ref","collection","doc","set","peopleInThisRoomOtherThanMe","slice","sort","a","b","addMessage","sendMessageFromFeed","newMessage","push","Promise","all","commit","roomId","addToFirebase","updateOnFirebase","isDocList","m","isDocument","map","toDate","e","isNew","text","trim","messages","updateBatch","addToBatch","roomPath","path","messageDoc","auth","currentUser","displayName","uid","roomRef","lastMessage","name","system","update","Array","isArray","merge","reaction","roomMembers","users","warn","reactions"],"mappings":"gnCAAA,OAOCA,cAPD,CAQCC,mBARD,CAUCC,iBAVD,KAYO,SAZP,CAaA,OAASC,KAAT,CAAgBC,IAAhB,KAA4B,qCAA5B,CACA,MAAOC,CAAAA,IAAP,KAAiB,SAAjB,C,wBAMC,kBAAYC,OAAZ,CAAmC,gCAClC,KAAKA,OAAL,CAAeA,OAAf,CACA,C,qEAOiBC,U,gJAEVC,I,CAAOL,KAAK,CAACM,QAAN,CACXC,SADW,GAEXC,aAFW,CAEGP,IAAI,CAACQ,aAAL,CAAmBC,kBAFtB,C,IAGRX,iBAAiB,CAAC,KAAKI,OAAN,C,8BACf,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AAKI,OAAN,CAAtB,CAAsC,CACrCa,OAAO,CAAC8D,IAAR,CACC,8GADD,CAEC,KAAK3E,OAFN,EAIA,CALD,IAKO,IAAI,KAAKA,OAAL,CAAa4E,SAAjB,CAA4B,CAClC,KAAK5E,OAAL,CAAa4E,SAAb,CAAuBJ,QAAvB,EAAiClD,OAAjC,CACC,SAAAyC,GAAG,QAAIU,CAAAA,WAAW,CAACV,GAAD,CAAX,EAAoBW,KAAK,CAACpC,IAAN,CAAWmC,WAAW,CAACV,GAAD,CAAtB,CAAxB,EADJ,EAGA,CACD,MAAOW,CAAAA,KAAP,CACA,C","sourcesContent":["import {\n\tMessageModel,\n\tEditMessageModel,\n\tRoomId,\n\tNewMessageModel,\n\tMessageModelDocument,\n\tSendFromFeedRecipients,\n\trecipientHasId,\n\trecipientHasMembers,\n\tSendFromFeedModel,\n\tisNewMessageModel,\n\tNewMessageFormattedForServer\n} from './types'\nimport { fuego, chat } from '../../components/ChatProvider/index'\nimport Room from '../Room'\nimport { LastMessageServer, RoomMembers, RoomMember } from '../Room/types'\nimport { ReactionOption } from '../Reaction/types'\n\nexport default class {\n\tprivate message: MessageModel\n\tconstructor(message: MessageModel) {\n\t\tthis.message = message\n\t}\n\t/**\n\t * A function to send one message to many different existing rooms/group chats separately.\n\t *\n\t * @param recipients An array of rooms ids where this message will be sent to separately\n\t * @returns Promise that returns a room ID if there is only one (or promise that resolves as null if the message object isn't valid)\n\t */\n\tasync sendToRooms(recipients: string[]) {\n\t\ttry {\n\t\t\tconst send = fuego.firebase\n\t\t\t\t.functions()\n\t\t\t\t.httpsCallable(chat.httpCallables.sendMessageToRooms)\n\t\t\tif (!isNewMessageModel(this.message)) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t'FAILED TO SEND TO ROOMS: message object is not NewMessageModel'\n\t\t\t\t)\n\t\t\t}\n\t\t\tthis.message = {\n\t\t\t\t...this.message,\n\t\t\t\tcreatedAt: fuego.firebase.firestore.FieldValue.serverTimestamp()\n\t\t\t} as NewMessageFormattedForServer\n\t\t\treturn send({\n\t\t\t\tmessage: this.message,\n\t\t\t\trecipients\n\t\t\t})\n\t\t} catch (e) {\n\t\t\tconsole.error(e)\n\t\t\treturn {\n\t\t\t\tdata: null\n\t\t\t}\n\t\t}\n\t}\n\t/**\n\t * A function to send one message to many different people individually.\n\t * For each recipient, if a room for them doesn't exist, it will get created and the message will be added to it.\n\t * If the room does exist, the message will be added to it.\n\t *\n\t * @param recipients An array of user ids whom this message will be sent to separately\n\t * @returns Promise that returns a room ID (or promise that resolves as null if the message object isn't valid)\n\t */\n\tasync sendToPeople(recipients: string[]) {\n\t\tconst send = fuego.firebase\n\t\t\t.functions()\n\t\t\t.httpsCallable(chat.httpCallables.sendMessageToPeople)\n\t\ttry {\n\t\t\tif (!isNewMessageModel(this.message)) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t'FAILED TO SEND TO PEOPLE: message object is not NewMessageModel'\n\t\t\t\t)\n\t\t\t}\n\t\t\tthis.message = {\n\t\t\t\t...this.message,\n\t\t\t\tcreatedAt: fuego.firebase.firestore.FieldValue.serverTimestamp()\n\t\t\t} as NewMessageFormattedForServer\n\t\t\treturn send({\n\t\t\t\tmessage: this.message,\n\t\t\t\trecipients\n\t\t\t})\n\t\t} catch (e) {\n\t\t\tconsole.error(e)\n\t\t\treturn {\n\t\t\t\tdata: null\n\t\t\t}\n\t\t}\n\t}\n\t/**\n\t * Sends message to a group. This is useful when you don't have a room id but do have a list of people you want to send a message to. If you want to send the message to them separately, try sendToPeople instead.\n\t * This function will create a group chat with the specified users if one doesn't exist yet. If it does exist already, then it will add to that existing room.\n\t * @param recipients Array of uids for people in the group this message should send to.\n\t * @returns Promise that returns a room ID (or promise that resolves as null if the message object isn't valid)\n\t */\n\tasync sendToGroup(recipients: string[]) {\n\t\tconst send = fuego.firebase\n\t\t\t.functions()\n\t\t\t.httpsCallable(chat.httpCallables.sendMessageToGroup)\n\t\ttry {\n\t\t\tif (!isNewMessageModel(this.message)) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t'FAILED TO SEND TO PEOPLE: message object is not NewMessageModel'\n\t\t\t\t)\n\t\t\t}\n\t\t\tthis.message = {\n\t\t\t\t...this.message,\n\t\t\t\tcreatedAt: fuego.firebase.firestore.FieldValue.serverTimestamp()\n\t\t\t} as NewMessageFormattedForServer\n\t\t\treturn send({\n\t\t\t\tmessage: this.message,\n\t\t\t\trecipients\n\t\t\t})\n\t\t} catch (e) {\n\t\t\tconsole.error(e)\n\t\t\treturn {\n\t\t\t\tdata: null\n\t\t\t}\n\t\t}\n\t}\n\t/**\n\t * deprecated: fuck this function\n\t */\n\tsendFromFeed(to: SendFromFeedRecipients) {\n\t\tconst batch = fuego.db.batch()\n\t\tconst promises: Promise<firebase.functions.HttpsCallableResult>[] = []\n\n\t\t// the to variable is an array of dictionaries\n\t\t// the dictionaries can be EITHER { id: string } or { recipients: Array<recipient> }\n\t\t// example:\n\t\t// you might send a message to five different places\n\t\t// could be 3 people, and 2 existing rooms\n\t\t// this would be an array of 5 items, 3 with recipients, 2 with id\n\t\t// example of the array:\n\t\t// [\n\t\t// 1) send to a room that has these two users\n\t\t// { recipients: [{id: uid, name: username }, {uid: uid2, name: name2 }]},\n\t\t// 2) send to an already existing room (likely pressing a group)\n\t\t// { id: roomId },\n\t\t// 3) send to one person, unaware if this room exists\n\t\t// { recipients: [{id: uid, name: username }]},\n\t\t// ]\n\n\t\t// now, set of people we're sending this to...\n\t\tto.forEach(room => {\n\t\t\tconst { id, ...message } = this.message as NewMessageModel\n\t\t\tif (recipientHasId(room)) {\n\t\t\t\t// if this recipient is a specified room, then send to that\n\t\t\t\tconst { messagesPath } = new Room({ id: room.id })\n\t\t\t\tconst ref = fuego.db.collection(messagesPath).doc(id)\n\t\t\t\tbatch.set(ref, message)\n\t\t\t} else if (recipientHasMembers(room)) {\n\t\t\t\t// otherwise, if you're just sending to a list of ambigious recipients...\n\t\t\t\t// note: this list will often be one person you're choosing from a feed\n\t\t\t\t// list could be: { recipients: [{ name: string, id: string }, { ...otherRecipient }]}\n\t\t\t\tconst peopleInThisRoomOtherThanMe = room.recipients\n\t\t\t\t\t.slice()\n\t\t\t\t\t.sort((a, b) => (a.id > b.id ? 1 : -1))\n\t\t\t\tconst addMessage = fuego.firebase\n\t\t\t\t\t.functions()\n\t\t\t\t\t.httpsCallable(chat.httpCallables.sendMessageFromFeed)\n\t\t\t\tconst newMessage: SendFromFeedModel = {\n\t\t\t\t\t...(message as NewMessageModel),\n\t\t\t\t\trecipients: peopleInThisRoomOtherThanMe\n\t\t\t\t}\n\t\t\t\tpromises.push(addMessage(newMessage))\n\t\t\t}\n\t\t})\n\n\t\treturn Promise.all<any>([batch.commit(), ...promises])\n\n\t\t// return {\n\t\t// \tbatch: () => batch.commit(),\n\t\t// \ttoRecipients: () => Promise.all(promises)\n\t\t// }\n\t}\n\t/**\n\t * Send message by adding it directly to the backend\n\t * @param roomId The id of the room you want to send this to. Could also be an array of ids, if the same message should go to multiple rooms.\n\t */\n\tsend(roomId: RoomId) {\n\t\tthis.addToFirebase(roomId)\n\t}\n\tedit(roomId: string) {\n\t\treturn this.updateOnFirebase(roomId)\n\t}\n\tformatForRender(): NewMessageModel[] | NewMessageModel | null {\n\t\tfunction isDocList(m: MessageModel): m is MessageModelDocument[] {\n\t\t\treturn !!(m as MessageModelDocument[])\n\t\t}\n\t\tfunction isDocument(m: MessageModel): m is MessageModelDocument {\n\t\t\treturn !!(m as MessageModelDocument)\n\t\t}\n\t\ttry {\n\t\t\tif (isDocList(this.message)) {\n\t\t\t\treturn (\n\t\t\t\t\t(this.message as MessageModelDocument[]).map(\n\t\t\t\t\t\t(doc: MessageModelDocument) => ({\n\t\t\t\t\t\t\t...doc,\n\t\t\t\t\t\t\tid: doc.id,\n\t\t\t\t\t\t\tcreatedAt: doc.createdAt.toDate()\n\t\t\t\t\t\t})\n\t\t\t\t\t) || []\n\t\t\t\t)\n\t\t\t}\n\t\t\tif (isDocument(this.message))\n\t\t\t\treturn {\n\t\t\t\t\t...this.message,\n\t\t\t\t\tid: this.message.id,\n\t\t\t\t\tcreatedAt: this.message.createdAt.toDate()\n\t\t\t\t}\n\n\t\t\tthrow new Error('Wrong model here.')\n\t\t} catch (e) {\n\t\t\tconsole.error(\n\t\t\t\t'wrong model given to format for render in Message class.',\n\t\t\t\te\n\t\t\t)\n\t\t\treturn null\n\t\t}\n\t}\n\tformatForSend() {\n\t\ttry {\n\t\t\tconst isNew = (m: MessageModel): m is NewMessageModel[] =>\n\t\t\t\t!!(m as NewMessageModel[])\n\t\t\tif (isNew(this.message)) {\n\t\t\t\tthis.message = (this.message as NewMessageModel[]).map(message => ({\n\t\t\t\t\t...message,\n\t\t\t\t\ttext: (message.text && message.text.trim()) || '',\n\t\t\t\t\tcreatedAt: fuego.firebase.firestore.FieldValue.serverTimestamp()\n\t\t\t\t})) as NewMessageFormattedForServer[]\n\t\t\t\treturn this\n\t\t\t}\n\t\t\tthrow new Error('wrong format for formatting for send')\n\t\t} catch (e) {\n\t\t\tconsole.error(e)\n\t\t\treturn this\n\t\t}\n\t}\n\taddToFirebase(roomId: RoomId) {\n\t\tconst { message: messages } = this\n\n\t\tconst batch = fuego.db.batch()\n\n\t\tconst updateBatch = (roomId: string) => {\n\t\t\t// for each message, add to this batch...\n\t\t\tconst addToBatch = (message: NewMessageFormattedForServer) => {\n\t\t\t\ttry {\n\t\t\t\t\tconst { messagesPath, path: roomPath } = new Room({ id: roomId })\n\t\t\t\t\tconst ref = fuego.db.collection(messagesPath).doc(message.id)\n\n\t\t\t\t\t// remove id from message for single source of truth\n\t\t\t\t\t// it'll be put back again upon format()-ing\n\t\t\t\t\tconst { id, ...messageDoc } = message\n\t\t\t\t\tbatch.set(ref, messageDoc)\n\n\t\t\t\t\t// update the latest message\n\t\t\t\t\tconst { displayName, uid } = fuego.auth().currentUser as firebase.User\n\t\t\t\t\tconst roomRef = fuego.db.doc(roomPath)\n\t\t\t\t\tconst lastMessage: LastMessageServer = {\n\t\t\t\t\t\tname: displayName || 'Name failed',\n\t\t\t\t\t\tid: uid,\n\t\t\t\t\t\tsystem: false,\n\t\t\t\t\t\ttext: message.text,\n\t\t\t\t\t\tcreatedAt: message.createdAt\n\t\t\t\t\t}\n\t\t\t\t\tbatch.update(roomRef, { lastMessage })\n\t\t\t\t} catch (e) {\n\t\t\t\t\tconsole.error('sending message had an error:', e)\n\t\t\t\t}\n\t\t\t}\n\t\t\t;(messages as NewMessageFormattedForServer[]).forEach(addToBatch)\n\t\t}\n\n\t\t// if you're sending these message(s) to multiple rooms, loop through each room...\n\t\tif (Array.isArray(roomId)) {\n\t\t\t;(roomId as string[]).forEach(updateBatch)\n\t\t} else {\n\t\t\t// just send to this room\n\t\t\tupdateBatch(roomId as string)\n\t\t}\n\t\t// once everything has been added to the db batch, commit it\n\t\treturn batch.commit()\n\t}\n\tupdateOnFirebase(roomId: string) {\n\t\tconst { path } = new Room({ id: roomId })\n\t\tconst { id, ...message } = this.message as EditMessageModel\n\t\treturn fuego.db\n\t\t\t.collection(path)\n\t\t\t.doc((this.message as EditMessageModel).id)\n\t\t\t.set(message, { merge: true })\n\t}\n\t// TODO get members through some other method...idk\n\t// eek. what a mess.\n\tgetUsersWhoReacted(\n\t\treaction: ReactionOption,\n\t\t{ roomMembers }: { roomMembers: RoomMembers }\n\t): RoomMember[] {\n\t\tconst users: RoomMember[] = []\n\t\tif (!isNewMessageModel(this.message)) {\n\t\t\tconsole.warn(\n\t\t\t\t'error getting users who reacted. Needs the new message model passed as an argument, but instead it got this:',\n\t\t\t\tthis.message\n\t\t\t)\n\t\t} else if (this.message.reactions) {\n\t\t\tthis.message.reactions[reaction].forEach(\n\t\t\t\tuid => roomMembers[uid] && users.push(roomMembers[uid])\n\t\t\t)\n\t\t}\n\t\treturn users\n\t}\n}\n"]}