@ethora/chat-component-rn 26.10.5 → 26.10.6

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 (365) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/README.md +15 -0
  3. package/app.plugin.js +2 -0
  4. package/lib/commonjs/assets/icons.js +2 -2
  5. package/lib/commonjs/assets/icons.js.map +1 -1
  6. package/lib/commonjs/components/MainComponents/AlbumGrid.js +152 -0
  7. package/lib/commonjs/components/MainComponents/AlbumGrid.js.map +1 -0
  8. package/lib/commonjs/components/MainComponents/ChatRoom.js +2 -2
  9. package/lib/commonjs/components/MainComponents/ChatRoom.js.map +1 -1
  10. package/lib/commonjs/components/MainComponents/MediaMessage.js +199 -123
  11. package/lib/commonjs/components/MainComponents/MediaMessage.js.map +1 -1
  12. package/lib/commonjs/components/MainComponents/MediaUploadOverlay.js +109 -0
  13. package/lib/commonjs/components/MainComponents/MediaUploadOverlay.js.map +1 -0
  14. package/lib/commonjs/components/MessageBubble/MediaCaption.js +51 -0
  15. package/lib/commonjs/components/MessageBubble/MediaCaption.js.map +1 -0
  16. package/lib/commonjs/components/MessageBubble/Message.js +40 -1
  17. package/lib/commonjs/components/MessageBubble/Message.js.map +1 -1
  18. package/lib/commonjs/components/MessageBubble/MessageInteractions.js +2 -1
  19. package/lib/commonjs/components/MessageBubble/MessageInteractions.js.map +1 -1
  20. package/lib/commonjs/components/Modals/FilePreviewModal/FilePreviewModal.js +75 -0
  21. package/lib/commonjs/components/Modals/FilePreviewModal/FilePreviewModal.js.map +1 -1
  22. package/lib/commonjs/components/RoomComponents/LastMessageItem.js +20 -4
  23. package/lib/commonjs/components/RoomComponents/LastMessageItem.js.map +1 -1
  24. package/lib/commonjs/components/RoomComponents/styled/LastAudioMessage.js +3 -2
  25. package/lib/commonjs/components/RoomComponents/styled/LastAudioMessage.js.map +1 -1
  26. package/lib/commonjs/components/RoomComponents/styled/LastMessageFile.js +3 -2
  27. package/lib/commonjs/components/RoomComponents/styled/LastMessageFile.js.map +1 -1
  28. package/lib/commonjs/components/RoomComponents/styled/LastMessagePhoto.js +3 -2
  29. package/lib/commonjs/components/RoomComponents/styled/LastMessagePhoto.js.map +1 -1
  30. package/lib/commonjs/components/RoomComponents/styled/LastMessageVideo.js +3 -2
  31. package/lib/commonjs/components/RoomComponents/styled/LastMessageVideo.js.map +1 -1
  32. package/lib/commonjs/components/Thread/ThreadWrapper.js +3 -2
  33. package/lib/commonjs/components/Thread/ThreadWrapper.js.map +1 -1
  34. package/lib/commonjs/components/styled/MediaFilePreview.js +60 -47
  35. package/lib/commonjs/components/styled/MediaFilePreview.js.map +1 -1
  36. package/lib/commonjs/components/styled/MessageImage.js +16 -6
  37. package/lib/commonjs/components/styled/MessageImage.js.map +1 -1
  38. package/lib/commonjs/components/styled/SendInput.js +99 -68
  39. package/lib/commonjs/components/styled/SendInput.js.map +1 -1
  40. package/lib/commonjs/components/styled/VideoMessage.js +24 -10
  41. package/lib/commonjs/components/styled/VideoMessage.js.map +1 -1
  42. package/lib/commonjs/context/xmppProvider.js +46 -0
  43. package/lib/commonjs/context/xmppProvider.js.map +1 -1
  44. package/lib/commonjs/e2ee/fileEnvelope.js +6 -0
  45. package/lib/commonjs/e2ee/fileEnvelope.js.map +1 -1
  46. package/lib/commonjs/e2ee/sealedBody.js +32 -2
  47. package/lib/commonjs/e2ee/sealedBody.js.map +1 -1
  48. package/lib/commonjs/helpers/albumLayout.js +150 -0
  49. package/lib/commonjs/helpers/albumLayout.js.map +1 -0
  50. package/lib/commonjs/helpers/attachments.js +255 -0
  51. package/lib/commonjs/helpers/attachments.js.map +1 -0
  52. package/lib/commonjs/helpers/caption.js +214 -0
  53. package/lib/commonjs/helpers/caption.js.map +1 -0
  54. package/lib/commonjs/helpers/createMainMessageForThread.js +5 -1
  55. package/lib/commonjs/helpers/createMainMessageForThread.js.map +1 -1
  56. package/lib/commonjs/helpers/createMessageFromXml.js +19 -5
  57. package/lib/commonjs/helpers/createMessageFromXml.js.map +1 -1
  58. package/lib/commonjs/helpers/fileKind.js +40 -0
  59. package/lib/commonjs/helpers/fileKind.js.map +1 -0
  60. package/lib/commonjs/helpers/getDataFromXml.js +6 -1
  61. package/lib/commonjs/helpers/getDataFromXml.js.map +1 -1
  62. package/lib/commonjs/helpers/mapWithConcurrency.js +41 -0
  63. package/lib/commonjs/helpers/mapWithConcurrency.js.map +1 -0
  64. package/lib/commonjs/helpers/mediaLimits.js +33 -0
  65. package/lib/commonjs/helpers/mediaLimits.js.map +1 -0
  66. package/lib/commonjs/helpers/mediaSendRetry.js +64 -0
  67. package/lib/commonjs/helpers/mediaSendRetry.js.map +1 -0
  68. package/lib/commonjs/helpers/mediaWireData.js +62 -0
  69. package/lib/commonjs/helpers/mediaWireData.js.map +1 -0
  70. package/lib/commonjs/helpers/mentionSpans.js +19 -0
  71. package/lib/commonjs/helpers/mentionSpans.js.map +1 -0
  72. package/lib/commonjs/helpers/mimeToExtension.js +45 -0
  73. package/lib/commonjs/helpers/mimeToExtension.js.map +1 -1
  74. package/lib/commonjs/helpers/readReceipts.js +173 -0
  75. package/lib/commonjs/helpers/readReceipts.js.map +1 -0
  76. package/lib/commonjs/helpers/repairFilenameEncoding.js +79 -0
  77. package/lib/commonjs/helpers/repairFilenameEncoding.js.map +1 -0
  78. package/lib/commonjs/helpers/safeJson.js +18 -0
  79. package/lib/commonjs/helpers/safeJson.js.map +1 -0
  80. package/lib/commonjs/hooks/useSendMessage.js +384 -193
  81. package/lib/commonjs/hooks/useSendMessage.js.map +1 -1
  82. package/lib/commonjs/i18n/strings.js +96 -0
  83. package/lib/commonjs/i18n/strings.js.map +1 -1
  84. package/lib/commonjs/networking/api-requests/auth.api.js +62 -3
  85. package/lib/commonjs/networking/api-requests/auth.api.js.map +1 -1
  86. package/lib/commonjs/networking/stanzaHandlers.js +100 -3
  87. package/lib/commonjs/networking/stanzaHandlers.js.map +1 -1
  88. package/lib/commonjs/networking/xmpp/handleStanzas.xmpp.js +4 -2
  89. package/lib/commonjs/networking/xmpp/handleStanzas.xmpp.js.map +1 -1
  90. package/lib/commonjs/networking/xmpp/sendDisplayedMarker.xmpp.js +28 -0
  91. package/lib/commonjs/networking/xmpp/sendDisplayedMarker.xmpp.js.map +1 -0
  92. package/lib/commonjs/networking/xmpp/sendMediaMessage.xmpp.js +53 -2
  93. package/lib/commonjs/networking/xmpp/sendMediaMessage.xmpp.js.map +1 -1
  94. package/lib/commonjs/networking/xmpp/sendReceivedReceipt.xmpp.js +28 -0
  95. package/lib/commonjs/networking/xmpp/sendReceivedReceipt.xmpp.js.map +1 -0
  96. package/lib/commonjs/networking/xmppClient.js +64 -0
  97. package/lib/commonjs/networking/xmppClient.js.map +1 -1
  98. package/lib/commonjs/roomStore/persistence.js +78 -5
  99. package/lib/commonjs/roomStore/persistence.js.map +1 -1
  100. package/lib/commonjs/roomStore/roomHeapSlice.js +4 -0
  101. package/lib/commonjs/roomStore/roomHeapSlice.js.map +1 -1
  102. package/lib/commonjs/roomStore/roomsSlice.js +114 -1
  103. package/lib/commonjs/roomStore/roomsSlice.js.map +1 -1
  104. package/lib/commonjs/types/models/attachment.model.js +2 -0
  105. package/lib/commonjs/types/models/attachment.model.js.map +1 -0
  106. package/lib/commonjs/version.js +1 -1
  107. package/lib/module/assets/icons.js +1 -1
  108. package/lib/module/assets/icons.js.map +1 -1
  109. package/lib/module/components/MainComponents/AlbumGrid.js +146 -0
  110. package/lib/module/components/MainComponents/AlbumGrid.js.map +1 -0
  111. package/lib/module/components/MainComponents/ChatRoom.js +2 -2
  112. package/lib/module/components/MainComponents/ChatRoom.js.map +1 -1
  113. package/lib/module/components/MainComponents/MediaMessage.js +200 -124
  114. package/lib/module/components/MainComponents/MediaMessage.js.map +1 -1
  115. package/lib/module/components/MainComponents/MediaUploadOverlay.js +104 -0
  116. package/lib/module/components/MainComponents/MediaUploadOverlay.js.map +1 -0
  117. package/lib/module/components/MessageBubble/MediaCaption.js +46 -0
  118. package/lib/module/components/MessageBubble/MediaCaption.js.map +1 -0
  119. package/lib/module/components/MessageBubble/Message.js +44 -5
  120. package/lib/module/components/MessageBubble/Message.js.map +1 -1
  121. package/lib/module/components/MessageBubble/MessageInteractions.js +2 -1
  122. package/lib/module/components/MessageBubble/MessageInteractions.js.map +1 -1
  123. package/lib/module/components/Modals/FilePreviewModal/FilePreviewModal.js +75 -0
  124. package/lib/module/components/Modals/FilePreviewModal/FilePreviewModal.js.map +1 -1
  125. package/lib/module/components/RoomComponents/LastMessageItem.js +20 -4
  126. package/lib/module/components/RoomComponents/LastMessageItem.js.map +1 -1
  127. package/lib/module/components/RoomComponents/styled/LastAudioMessage.js +3 -2
  128. package/lib/module/components/RoomComponents/styled/LastAudioMessage.js.map +1 -1
  129. package/lib/module/components/RoomComponents/styled/LastMessageFile.js +3 -2
  130. package/lib/module/components/RoomComponents/styled/LastMessageFile.js.map +1 -1
  131. package/lib/module/components/RoomComponents/styled/LastMessagePhoto.js +3 -2
  132. package/lib/module/components/RoomComponents/styled/LastMessagePhoto.js.map +1 -1
  133. package/lib/module/components/RoomComponents/styled/LastMessageVideo.js +3 -2
  134. package/lib/module/components/RoomComponents/styled/LastMessageVideo.js.map +1 -1
  135. package/lib/module/components/Thread/ThreadWrapper.js +3 -2
  136. package/lib/module/components/Thread/ThreadWrapper.js.map +1 -1
  137. package/lib/module/components/styled/MediaFilePreview.js +61 -48
  138. package/lib/module/components/styled/MediaFilePreview.js.map +1 -1
  139. package/lib/module/components/styled/MessageImage.js +16 -6
  140. package/lib/module/components/styled/MessageImage.js.map +1 -1
  141. package/lib/module/components/styled/SendInput.js +99 -68
  142. package/lib/module/components/styled/SendInput.js.map +1 -1
  143. package/lib/module/components/styled/VideoMessage.js +24 -10
  144. package/lib/module/components/styled/VideoMessage.js.map +1 -1
  145. package/lib/module/context/xmppProvider.js +46 -0
  146. package/lib/module/context/xmppProvider.js.map +1 -1
  147. package/lib/module/e2ee/fileEnvelope.js +1 -1
  148. package/lib/module/e2ee/fileEnvelope.js.map +1 -1
  149. package/lib/module/e2ee/sealedBody.js +32 -2
  150. package/lib/module/e2ee/sealedBody.js.map +1 -1
  151. package/lib/module/helpers/albumLayout.js +143 -0
  152. package/lib/module/helpers/albumLayout.js.map +1 -0
  153. package/lib/module/helpers/attachments.js +245 -0
  154. package/lib/module/helpers/attachments.js.map +1 -0
  155. package/lib/module/helpers/caption.js +207 -0
  156. package/lib/module/helpers/caption.js.map +1 -0
  157. package/lib/module/helpers/createMainMessageForThread.js +5 -1
  158. package/lib/module/helpers/createMainMessageForThread.js.map +1 -1
  159. package/lib/module/helpers/createMessageFromXml.js +20 -6
  160. package/lib/module/helpers/createMessageFromXml.js.map +1 -1
  161. package/lib/module/helpers/fileKind.js +34 -0
  162. package/lib/module/helpers/fileKind.js.map +1 -0
  163. package/lib/module/helpers/getDataFromXml.js +6 -1
  164. package/lib/module/helpers/getDataFromXml.js.map +1 -1
  165. package/lib/module/helpers/mapWithConcurrency.js +37 -0
  166. package/lib/module/helpers/mapWithConcurrency.js.map +1 -0
  167. package/lib/module/helpers/mediaLimits.js +27 -0
  168. package/lib/module/helpers/mediaLimits.js.map +1 -0
  169. package/lib/module/helpers/mediaSendRetry.js +55 -0
  170. package/lib/module/helpers/mediaSendRetry.js.map +1 -0
  171. package/lib/module/helpers/mediaWireData.js +58 -0
  172. package/lib/module/helpers/mediaWireData.js.map +1 -0
  173. package/lib/module/helpers/mentionSpans.js +14 -0
  174. package/lib/module/helpers/mentionSpans.js.map +1 -0
  175. package/lib/module/helpers/mimeToExtension.js +43 -0
  176. package/lib/module/helpers/mimeToExtension.js.map +1 -1
  177. package/lib/module/helpers/readReceipts.js +160 -0
  178. package/lib/module/helpers/readReceipts.js.map +1 -0
  179. package/lib/module/helpers/repairFilenameEncoding.js +74 -0
  180. package/lib/module/helpers/repairFilenameEncoding.js.map +1 -0
  181. package/lib/module/helpers/safeJson.js +13 -0
  182. package/lib/module/helpers/safeJson.js.map +1 -0
  183. package/lib/module/hooks/useSendMessage.js +387 -195
  184. package/lib/module/hooks/useSendMessage.js.map +1 -1
  185. package/lib/module/i18n/strings.js +96 -0
  186. package/lib/module/i18n/strings.js.map +1 -1
  187. package/lib/module/networking/api-requests/auth.api.js +62 -3
  188. package/lib/module/networking/api-requests/auth.api.js.map +1 -1
  189. package/lib/module/networking/stanzaHandlers.js +97 -4
  190. package/lib/module/networking/stanzaHandlers.js.map +1 -1
  191. package/lib/module/networking/xmpp/handleStanzas.xmpp.js +5 -3
  192. package/lib/module/networking/xmpp/handleStanzas.xmpp.js.map +1 -1
  193. package/lib/module/networking/xmpp/sendDisplayedMarker.xmpp.js +25 -0
  194. package/lib/module/networking/xmpp/sendDisplayedMarker.xmpp.js.map +1 -0
  195. package/lib/module/networking/xmpp/sendMediaMessage.xmpp.js +53 -2
  196. package/lib/module/networking/xmpp/sendMediaMessage.xmpp.js.map +1 -1
  197. package/lib/module/networking/xmpp/sendReceivedReceipt.xmpp.js +25 -0
  198. package/lib/module/networking/xmpp/sendReceivedReceipt.xmpp.js.map +1 -0
  199. package/lib/module/networking/xmppClient.js +64 -0
  200. package/lib/module/networking/xmppClient.js.map +1 -1
  201. package/lib/module/roomStore/persistence.js +78 -5
  202. package/lib/module/roomStore/persistence.js.map +1 -1
  203. package/lib/module/roomStore/roomHeapSlice.js +4 -0
  204. package/lib/module/roomStore/roomHeapSlice.js.map +1 -1
  205. package/lib/module/roomStore/roomsSlice.js +109 -0
  206. package/lib/module/roomStore/roomsSlice.js.map +1 -1
  207. package/lib/module/types/models/attachment.model.js +2 -0
  208. package/lib/module/types/models/attachment.model.js.map +1 -0
  209. package/lib/module/version.js +1 -1
  210. package/lib/typescript/assets/icons.d.ts +6 -1
  211. package/lib/typescript/assets/icons.d.ts.map +1 -1
  212. package/lib/typescript/components/MainComponents/AlbumGrid.d.ts +21 -0
  213. package/lib/typescript/components/MainComponents/AlbumGrid.d.ts.map +1 -0
  214. package/lib/typescript/components/MainComponents/ChatRoom.d.ts.map +1 -1
  215. package/lib/typescript/components/MainComponents/MediaMessage.d.ts.map +1 -1
  216. package/lib/typescript/components/MainComponents/MediaUploadOverlay.d.ts +17 -0
  217. package/lib/typescript/components/MainComponents/MediaUploadOverlay.d.ts.map +1 -0
  218. package/lib/typescript/components/MessageBubble/MediaCaption.d.ts +12 -0
  219. package/lib/typescript/components/MessageBubble/MediaCaption.d.ts.map +1 -0
  220. package/lib/typescript/components/MessageBubble/Message.d.ts.map +1 -1
  221. package/lib/typescript/components/MessageBubble/MessageInteractions.d.ts.map +1 -1
  222. package/lib/typescript/components/Modals/FilePreviewModal/FilePreviewModal.d.ts.map +1 -1
  223. package/lib/typescript/components/RoomComponents/LastMessageItem.d.ts.map +1 -1
  224. package/lib/typescript/components/RoomComponents/styled/LastAudioMessage.d.ts +2 -0
  225. package/lib/typescript/components/RoomComponents/styled/LastAudioMessage.d.ts.map +1 -1
  226. package/lib/typescript/components/RoomComponents/styled/LastMessageFile.d.ts +2 -0
  227. package/lib/typescript/components/RoomComponents/styled/LastMessageFile.d.ts.map +1 -1
  228. package/lib/typescript/components/RoomComponents/styled/LastMessagePhoto.d.ts +2 -0
  229. package/lib/typescript/components/RoomComponents/styled/LastMessagePhoto.d.ts.map +1 -1
  230. package/lib/typescript/components/RoomComponents/styled/LastMessageVideo.d.ts +2 -0
  231. package/lib/typescript/components/RoomComponents/styled/LastMessageVideo.d.ts.map +1 -1
  232. package/lib/typescript/components/Thread/ThreadWrapper.d.ts.map +1 -1
  233. package/lib/typescript/components/styled/MediaFilePreview.d.ts.map +1 -1
  234. package/lib/typescript/components/styled/MessageImage.d.ts +10 -0
  235. package/lib/typescript/components/styled/MessageImage.d.ts.map +1 -1
  236. package/lib/typescript/components/styled/SendInput.d.ts +7 -1
  237. package/lib/typescript/components/styled/SendInput.d.ts.map +1 -1
  238. package/lib/typescript/components/styled/VideoMessage.d.ts +7 -0
  239. package/lib/typescript/components/styled/VideoMessage.d.ts.map +1 -1
  240. package/lib/typescript/context/xmppProvider.d.ts.map +1 -1
  241. package/lib/typescript/e2ee/fileEnvelope.d.ts +1 -1
  242. package/lib/typescript/e2ee/fileEnvelope.d.ts.map +1 -1
  243. package/lib/typescript/e2ee/sealedBody.d.ts +16 -0
  244. package/lib/typescript/e2ee/sealedBody.d.ts.map +1 -1
  245. package/lib/typescript/helpers/albumLayout.d.ts +66 -0
  246. package/lib/typescript/helpers/albumLayout.d.ts.map +1 -0
  247. package/lib/typescript/helpers/attachments.d.ts +55 -0
  248. package/lib/typescript/helpers/attachments.d.ts.map +1 -0
  249. package/lib/typescript/helpers/caption.d.ts +64 -0
  250. package/lib/typescript/helpers/caption.d.ts.map +1 -0
  251. package/lib/typescript/helpers/createMainMessageForThread.d.ts.map +1 -1
  252. package/lib/typescript/helpers/createMessageFromXml.d.ts.map +1 -1
  253. package/lib/typescript/helpers/fileKind.d.ts +20 -0
  254. package/lib/typescript/helpers/fileKind.d.ts.map +1 -0
  255. package/lib/typescript/helpers/getDataFromXml.d.ts.map +1 -1
  256. package/lib/typescript/helpers/mapWithConcurrency.d.ts +9 -0
  257. package/lib/typescript/helpers/mapWithConcurrency.d.ts.map +1 -0
  258. package/lib/typescript/helpers/mediaLimits.d.ts +13 -0
  259. package/lib/typescript/helpers/mediaLimits.d.ts.map +1 -0
  260. package/lib/typescript/helpers/mediaSendRetry.d.ts +26 -0
  261. package/lib/typescript/helpers/mediaSendRetry.d.ts.map +1 -0
  262. package/lib/typescript/helpers/mediaWireData.d.ts +16 -0
  263. package/lib/typescript/helpers/mediaWireData.d.ts.map +1 -0
  264. package/lib/typescript/helpers/mentionSpans.d.ts +8 -0
  265. package/lib/typescript/helpers/mentionSpans.d.ts.map +1 -0
  266. package/lib/typescript/helpers/mimeToExtension.d.ts +7 -0
  267. package/lib/typescript/helpers/mimeToExtension.d.ts.map +1 -1
  268. package/lib/typescript/helpers/readReceipts.d.ts +82 -0
  269. package/lib/typescript/helpers/readReceipts.d.ts.map +1 -0
  270. package/lib/typescript/helpers/repairFilenameEncoding.d.ts +12 -0
  271. package/lib/typescript/helpers/repairFilenameEncoding.d.ts.map +1 -0
  272. package/lib/typescript/helpers/safeJson.d.ts +2 -0
  273. package/lib/typescript/helpers/safeJson.d.ts.map +1 -0
  274. package/lib/typescript/hooks/useSendMessage.d.ts +2 -1
  275. package/lib/typescript/hooks/useSendMessage.d.ts.map +1 -1
  276. package/lib/typescript/i18n/strings.d.ts.map +1 -1
  277. package/lib/typescript/networking/api-requests/auth.api.d.ts +2 -0
  278. package/lib/typescript/networking/api-requests/auth.api.d.ts.map +1 -1
  279. package/lib/typescript/networking/stanzaHandlers.d.ts +7 -3
  280. package/lib/typescript/networking/stanzaHandlers.d.ts.map +1 -1
  281. package/lib/typescript/networking/xmpp/handleStanzas.xmpp.d.ts.map +1 -1
  282. package/lib/typescript/networking/xmpp/sendDisplayedMarker.xmpp.d.ts +3 -0
  283. package/lib/typescript/networking/xmpp/sendDisplayedMarker.xmpp.d.ts.map +1 -0
  284. package/lib/typescript/networking/xmpp/sendMediaMessage.xmpp.d.ts +12 -0
  285. package/lib/typescript/networking/xmpp/sendMediaMessage.xmpp.d.ts.map +1 -1
  286. package/lib/typescript/networking/xmpp/sendReceivedReceipt.xmpp.d.ts +3 -0
  287. package/lib/typescript/networking/xmpp/sendReceivedReceipt.xmpp.d.ts.map +1 -0
  288. package/lib/typescript/networking/xmppClient.d.ts +15 -0
  289. package/lib/typescript/networking/xmppClient.d.ts.map +1 -1
  290. package/lib/typescript/roomStore/persistence.d.ts.map +1 -1
  291. package/lib/typescript/roomStore/roomHeapSlice.d.ts +22 -1
  292. package/lib/typescript/roomStore/roomHeapSlice.d.ts.map +1 -1
  293. package/lib/typescript/roomStore/roomsSlice.d.ts +67 -3
  294. package/lib/typescript/roomStore/roomsSlice.d.ts.map +1 -1
  295. package/lib/typescript/types/models/attachment.model.d.ts +52 -0
  296. package/lib/typescript/types/models/attachment.model.d.ts.map +1 -0
  297. package/lib/typescript/types/models/message.model.d.ts +26 -0
  298. package/lib/typescript/types/models/message.model.d.ts.map +1 -1
  299. package/lib/typescript/types/models/modal.model.d.ts +7 -0
  300. package/lib/typescript/types/models/modal.model.d.ts.map +1 -1
  301. package/lib/typescript/types/models/room.model.d.ts +2 -0
  302. package/lib/typescript/types/models/room.model.d.ts.map +1 -1
  303. package/lib/typescript/types/types.d.ts +29 -1
  304. package/lib/typescript/types/types.d.ts.map +1 -1
  305. package/lib/typescript/version.d.ts +1 -1
  306. package/package.json +4 -1
  307. package/plugins/notification-service/Info.plist +31 -0
  308. package/plugins/notification-service/NotificationService.swift +82 -0
  309. package/plugins/withNotificationServiceExtension.js +137 -0
  310. package/src/assets/icons.tsx +20 -2
  311. package/src/components/MainComponents/AlbumGrid.tsx +183 -0
  312. package/src/components/MainComponents/ChatRoom.tsx +4 -2
  313. package/src/components/MainComponents/MediaMessage.tsx +246 -130
  314. package/src/components/MainComponents/MediaUploadOverlay.tsx +102 -0
  315. package/src/components/MessageBubble/MediaCaption.tsx +45 -0
  316. package/src/components/MessageBubble/Message.tsx +71 -3
  317. package/src/components/MessageBubble/MessageInteractions.tsx +2 -1
  318. package/src/components/Modals/FilePreviewModal/FilePreviewModal.tsx +64 -0
  319. package/src/components/RoomComponents/LastMessageItem.tsx +15 -4
  320. package/src/components/RoomComponents/styled/LastAudioMessage.tsx +6 -3
  321. package/src/components/RoomComponents/styled/LastMessageFile.tsx +6 -2
  322. package/src/components/RoomComponents/styled/LastMessagePhoto.tsx +6 -2
  323. package/src/components/RoomComponents/styled/LastMessageVideo.tsx +6 -2
  324. package/src/components/Thread/ThreadWrapper.tsx +5 -9
  325. package/src/components/styled/MediaFilePreview.tsx +49 -34
  326. package/src/components/styled/MessageImage.tsx +21 -5
  327. package/src/components/styled/SendInput.tsx +101 -87
  328. package/src/components/styled/VideoMessage.tsx +34 -9
  329. package/src/context/xmppProvider.tsx +32 -0
  330. package/src/e2ee/fileEnvelope.ts +1 -1
  331. package/src/e2ee/sealedBody.ts +44 -5
  332. package/src/helpers/albumLayout.ts +207 -0
  333. package/src/helpers/attachments.ts +316 -0
  334. package/src/helpers/caption.ts +283 -0
  335. package/src/helpers/createMainMessageForThread.ts +6 -1
  336. package/src/helpers/createMessageFromXml.ts +21 -5
  337. package/src/helpers/fileKind.ts +38 -0
  338. package/src/helpers/getDataFromXml.ts +5 -1
  339. package/src/helpers/mapWithConcurrency.ts +32 -0
  340. package/src/helpers/mediaLimits.ts +27 -0
  341. package/src/helpers/mediaSendRetry.ts +59 -0
  342. package/src/helpers/mediaWireData.ts +57 -0
  343. package/src/helpers/mentionSpans.ts +17 -0
  344. package/src/helpers/mimeToExtension.ts +51 -0
  345. package/src/helpers/readReceipts.ts +219 -0
  346. package/src/helpers/repairFilenameEncoding.ts +82 -0
  347. package/src/helpers/safeJson.ts +11 -0
  348. package/src/hooks/useSendMessage.tsx +448 -249
  349. package/src/i18n/strings.ts +96 -0
  350. package/src/networking/api-requests/auth.api.ts +60 -3
  351. package/src/networking/stanzaHandlers.ts +91 -2
  352. package/src/networking/xmpp/handleStanzas.xmpp.ts +6 -2
  353. package/src/networking/xmpp/sendDisplayedMarker.xmpp.ts +31 -0
  354. package/src/networking/xmpp/sendMediaMessage.xmpp.ts +60 -3
  355. package/src/networking/xmpp/sendReceivedReceipt.xmpp.ts +31 -0
  356. package/src/networking/xmppClient.ts +48 -0
  357. package/src/roomStore/persistence.ts +94 -3
  358. package/src/roomStore/roomHeapSlice.ts +23 -1
  359. package/src/roomStore/roomsSlice.ts +112 -1
  360. package/src/types/models/attachment.model.ts +51 -0
  361. package/src/types/models/message.model.ts +29 -0
  362. package/src/types/models/modal.model.ts +7 -0
  363. package/src/types/models/room.model.ts +2 -0
  364. package/src/types/types.ts +35 -1
  365. package/src/version.ts +1 -1
@@ -0,0 +1,255 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.toUploadedAttachment = exports.serializeAttachments = exports.parseAttachments = exports.normalizeAttachment = exports.isMediaMessage = exports.getMessageAttachments = exports.getAttachmentName = exports.MAX_ATTACHMENTS_PER_MESSAGE = void 0;
7
+ var _safeJson = require("./safeJson");
8
+ var _repairFilenameEncoding = require("./repairFilenameEncoding");
9
+ var _mimeToExtension = require("./mimeToExtension");
10
+ /** Parses a dimension that may arrive as a number or a numeric string. */
11
+ const parseDimension = value => {
12
+ const n = typeof value === 'string' ? Number.parseFloat(value) : value;
13
+ return typeof n === 'number' && Number.isFinite(n) && n > 0 ? n : undefined;
14
+ };
15
+
16
+ /**
17
+ * Hard ceiling on how many attachments we will serialise into a stanza.
18
+ * The composer caps the picker far below this; this is the parser-side
19
+ * guard so a malformed or hostile stanza cannot make us render an
20
+ * unbounded grid.
21
+ */
22
+ const MAX_ATTACHMENTS_PER_MESSAGE = exports.MAX_ATTACHMENTS_PER_MESSAGE = 10;
23
+ const asOptionalString = value => {
24
+ if (value === null || value === undefined) return undefined;
25
+ if (typeof value === 'string') return value || undefined;
26
+ if (typeof value === 'number') return String(value);
27
+ return undefined;
28
+ };
29
+
30
+ /** A file name from the wire/API, with UTF-8-read-as-Latin-1 mojibake undone. */
31
+ const asOptionalFileName = value => {
32
+ const name = asOptionalString(value);
33
+ return name === undefined ? undefined : (0, _repairFilenameEncoding.repairFilenameEncoding)(name);
34
+ };
35
+ const asOptionalBoolean = value => {
36
+ if (typeof value === 'boolean') return value;
37
+ if (value === 'true') return true;
38
+ if (value === 'false') return false;
39
+ return undefined;
40
+ };
41
+
42
+ /**
43
+ * Turns one raw wire/API object into an `IAttachment`, or null when there is
44
+ * nothing renderable in it. `location` is allowed to be empty: that is what
45
+ * an optimistic (still-uploading) attachment looks like.
46
+ */
47
+ const normalizeAttachment = raw => {
48
+ if (!raw || typeof raw !== 'object') return null;
49
+ const source = raw;
50
+ const location = asOptionalString(source.location) ?? '';
51
+ const originalName = asOptionalFileName(source.originalName) ?? asOptionalFileName(source.originalname);
52
+ const rawMimetype = asOptionalString(source.mimetype);
53
+ const fileName = asOptionalFileName(source.fileName) ?? asOptionalFileName(source.filename);
54
+ const duration = asOptionalString(source.duration) ?? asOptionalString(source.mediaDuration);
55
+ const mimetype = resolveLegacyMimetype(rawMimetype, {
56
+ names: [originalName, fileName, urlPath(location)],
57
+ duration
58
+ });
59
+ if (!location && !originalName && !mimetype && !fileName) {
60
+ return null;
61
+ }
62
+ return {
63
+ attachmentId: asOptionalString(source.attachmentId) ?? asOptionalString(source._id),
64
+ location,
65
+ locationPreview: asOptionalString(source.locationPreview),
66
+ mimetype,
67
+ originalName,
68
+ fileName,
69
+ size: asOptionalString(source.size),
70
+ duration,
71
+ ...optionalDimensions(source),
72
+ ownerKey: asOptionalString(source.ownerKey),
73
+ userId: asOptionalString(source.userId),
74
+ createdAt: asOptionalString(source.createdAt),
75
+ updatedAt: asOptionalString(source.updatedAt),
76
+ expiresAt: asOptionalString(source.expiresAt),
77
+ isVisible: asOptionalBoolean(source.isVisible),
78
+ isPrivate: asOptionalBoolean(source.isPrivate),
79
+ ...normalizeUploadState(source)
80
+ };
81
+ };
82
+
83
+ /** The path part of a URL (no query or fragment), for reading an extension off it. */
84
+ exports.normalizeAttachment = normalizeAttachment;
85
+ const urlPath = url => url ? url.split(/[?#]/)[0] : undefined;
86
+
87
+ /**
88
+ * Older clients and the storage send media with no `mimetype`, or with the
89
+ * "could not sniff" `application/octet-stream`. The extension of any name the
90
+ * file carries tells which picture, video, audio or PDF it is. A nameless or
91
+ * extensionless file with a duration is a recorded voice note (browsers upload
92
+ * those as a `blob`), which is exactly what octet-stream renders as.
93
+ */
94
+ const resolveLegacyMimetype = (mimetype, hints) => {
95
+ if (!(0, _mimeToExtension.isGenericMime)(mimetype)) return mimetype;
96
+ const hasDuration = Number.parseFloat(hints.duration ?? '') > 0;
97
+ // A recorded note keeps its generic type: browsers upload it as a nameless
98
+ // `blob` (and storage may add a `.webm` to the stored name, which is audio
99
+ // here, not video). Only a name that says what it is overrides that.
100
+ if (hasDuration && !(0, _mimeToExtension.inferMimeFromName)(hints.names[0])) return mimetype ?? 'application/octet-stream';
101
+ for (const name of hints.names) {
102
+ const inferred = (0, _mimeToExtension.inferMimeFromName)(name);
103
+ if (inferred) return inferred;
104
+ }
105
+ return mimetype;
106
+ };
107
+
108
+ /** Pixel size, only when the source carries a usable one. */
109
+ const optionalDimensions = source => {
110
+ const width = parseDimension(source.width);
111
+ const height = parseDimension(source.height);
112
+ return {
113
+ ...(width !== undefined ? {
114
+ width
115
+ } : {}),
116
+ ...(height !== undefined ? {
117
+ height
118
+ } : {})
119
+ };
120
+ };
121
+
122
+ /**
123
+ * Local upload state rides along on optimistic attachments only; it is
124
+ * never serialised, so a received attachment never carries it.
125
+ */
126
+ const normalizeUploadState = source => {
127
+ const status = source.uploadStatus === 'uploading' || source.uploadStatus === 'failed' ? source.uploadStatus : undefined;
128
+ if (!status) return {};
129
+ const progress = typeof source.uploadProgress === 'number' && Number.isFinite(source.uploadProgress) ? Math.min(100, Math.max(0, source.uploadProgress)) : 0;
130
+ // Only a file on this device can be the local preview of an outgoing file.
131
+ const localUrl = typeof source.localUrl === 'string' && /^(file|content):\/\//.test(source.localUrl) ? source.localUrl : undefined;
132
+ return {
133
+ uploadStatus: status,
134
+ uploadProgress: progress,
135
+ ...(localUrl ? {
136
+ localUrl
137
+ } : {})
138
+ };
139
+ };
140
+
141
+ /** Accepts the parsed array, the raw JSON string, or junk. Never throws. */
142
+ const parseAttachments = raw => {
143
+ const candidate = typeof raw === 'string' ? (0, _safeJson.safeJsonParse)(raw, []) : raw;
144
+ if (!Array.isArray(candidate)) return [];
145
+ return candidate.slice(0, MAX_ATTACHMENTS_PER_MESSAGE).map(normalizeAttachment).filter(item => item !== null);
146
+ };
147
+
148
+ /**
149
+ * The wire form: a JSON string on the `<data attachments="...">` attribute.
150
+ * Only the fields a receiver renders are sent - the stanza is already wide
151
+ * and every byte here is duplicated per attachment.
152
+ */
153
+ exports.parseAttachments = parseAttachments;
154
+ const serializeAttachments = attachments => JSON.stringify(attachments.slice(0, MAX_ATTACHMENTS_PER_MESSAGE).map(attachment => ({
155
+ attachmentId: attachment.attachmentId,
156
+ location: attachment.location,
157
+ locationPreview: attachment.locationPreview,
158
+ mimetype: attachment.mimetype,
159
+ originalName: attachment.originalName,
160
+ fileName: attachment.fileName,
161
+ size: attachment.size,
162
+ duration: attachment.duration
163
+ })));
164
+
165
+ /**
166
+ * The only supported way to read a media message's files.
167
+ *
168
+ * Order of truth: the multi-attach payload when present, otherwise the flat
169
+ * legacy fields synthesised into a single attachment. Every message that
170
+ * predates this feature - and every message from a client that does not
171
+ * speak it - takes the second path.
172
+ */
173
+ exports.serializeAttachments = serializeAttachments;
174
+ const getMessageAttachments = message => {
175
+ if (!message) return [];
176
+ const parsed = parseAttachments(message.attachments);
177
+ if (parsed.length > 0) return parsed;
178
+
179
+ // Legacy clients may pack several files into the flat fields as a
180
+ // comma separated list of URLs; the other flat fields then list one value
181
+ // each, in the same order, or one value for all.
182
+ const locations = splitUrlList(message.location);
183
+ if (locations.length > 1) {
184
+ const previews = splitUrlList(message.locationPreview);
185
+ const mimetypes = splitList(message.mimetype);
186
+ const names = splitList(message.originalName);
187
+ return locations.slice(0, MAX_ATTACHMENTS_PER_MESSAGE).map((location, index) => normalizeAttachment({
188
+ location,
189
+ locationPreview: previews.length === locations.length ? previews[index] : undefined,
190
+ mimetype: pickNth(mimetypes, index, locations.length),
191
+ originalName: pickNth(names, index, locations.length),
192
+ size: undefined
193
+ })).filter(item => item !== null);
194
+ }
195
+ const legacy = normalizeAttachment({
196
+ location: message.location,
197
+ locationPreview: message.locationPreview,
198
+ mimetype: message.mimetype,
199
+ originalName: message.originalName,
200
+ fileName: message.fileName,
201
+ size: message.size,
202
+ duration: message.duration,
203
+ mediaDuration: message.mediaDuration
204
+ });
205
+ return legacy ? [legacy] : [];
206
+ };
207
+
208
+ /** "https://a/x.jpg, https://a/y.jpg" -> two URLs. A single URL stays whole, commas and all. */
209
+ exports.getMessageAttachments = getMessageAttachments;
210
+ const splitUrlList = value => typeof value === 'string' && /,\s*https?:\/\//i.test(value) ? value.split(/,\s*(?=https?:\/\/)/i).map(item => item.trim()).filter(Boolean) : typeof value === 'string' && value ? [value] : [];
211
+ const splitList = value => typeof value === 'string' && value ? value.split(',').map(item => item.trim()) : [];
212
+
213
+ /** The nth entry of a parallel list, or its only entry when it is shared by all. */
214
+ const pickNth = (list, index, total) => list.length === total ? list[index] : list.length === 1 ? list[0] : undefined;
215
+
216
+ /**
217
+ * True when the message carries a file: flagged `isMediafile`, or (older
218
+ * senders that never set the flag) with a real file URL or attachment. The
219
+ * one test every surface uses for "is this a media bubble".
220
+ */
221
+ const isMediaMessage = message => {
222
+ if (!message || message.isDeleted) return false;
223
+ if (String(message.isMediafile) === 'true') return true;
224
+ return getMessageAttachments(message).some(attachment => Boolean(attachment.location));
225
+ };
226
+
227
+ /**
228
+ * Maps one object from POST /files/ `results` to the attachment a sent
229
+ * message carries. Field names here follow the API's own spelling
230
+ * (`originalname`, `filename`), not the wire attribute names.
231
+ */
232
+ exports.isMediaMessage = isMediaMessage;
233
+ const toUploadedAttachment = raw => ({
234
+ attachmentId: raw?._id,
235
+ location: raw?.location,
236
+ locationPreview: raw?.locationPreview,
237
+ mimetype: raw?.mimetype,
238
+ originalName: typeof raw?.originalname === 'string' ? (0, _repairFilenameEncoding.repairFilenameEncoding)(raw.originalname) : raw?.originalname,
239
+ fileName: typeof raw?.filename === 'string' ? (0, _repairFilenameEncoding.repairFilenameEncoding)(raw.filename) : raw?.filename,
240
+ size: raw?.size?.toString?.() ?? raw?.size,
241
+ duration: raw?.duration,
242
+ ownerKey: raw?.ownerKey,
243
+ userId: raw?.userId,
244
+ createdAt: raw?.createdAt,
245
+ updatedAt: raw?.updatedAt,
246
+ expiresAt: raw?.expiresAt,
247
+ isVisible: raw?.isVisible,
248
+ isPrivate: raw?.isPrivate
249
+ });
250
+
251
+ /** Name to show for an attachment, with the URL tail as the last resort. */
252
+ exports.toUploadedAttachment = toUploadedAttachment;
253
+ const getAttachmentName = attachment => attachment.originalName || attachment.fileName || attachment.location?.split('/')?.pop() || 'MediaFile';
254
+ exports.getAttachmentName = getAttachmentName;
255
+ //# sourceMappingURL=attachments.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_safeJson","require","_repairFilenameEncoding","_mimeToExtension","parseDimension","value","n","Number","parseFloat","isFinite","undefined","MAX_ATTACHMENTS_PER_MESSAGE","exports","asOptionalString","String","asOptionalFileName","name","repairFilenameEncoding","asOptionalBoolean","normalizeAttachment","raw","source","location","originalName","originalname","rawMimetype","mimetype","fileName","filename","duration","mediaDuration","resolveLegacyMimetype","names","urlPath","attachmentId","_id","locationPreview","size","optionalDimensions","ownerKey","userId","createdAt","updatedAt","expiresAt","isVisible","isPrivate","normalizeUploadState","url","split","hints","isGenericMime","hasDuration","inferMimeFromName","inferred","width","height","status","uploadStatus","progress","uploadProgress","Math","min","max","localUrl","test","parseAttachments","candidate","safeJsonParse","Array","isArray","slice","map","filter","item","serializeAttachments","attachments","JSON","stringify","attachment","getMessageAttachments","message","parsed","length","locations","splitUrlList","previews","mimetypes","splitList","index","pickNth","legacy","trim","Boolean","list","total","isMediaMessage","isDeleted","isMediafile","some","toUploadedAttachment","toString","getAttachmentName","pop"],"sourceRoot":"../../../src","sources":["helpers/attachments.ts"],"mappings":";;;;;;AACA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,uBAAA,GAAAD,OAAA;AACA,IAAAE,gBAAA,GAAAF,OAAA;AAEA;AACA,MAAMG,cAAc,GAAIC,KAAc,IAAyB;EAC7D,MAAMC,CAAC,GAAG,OAAOD,KAAK,KAAK,QAAQ,GAAGE,MAAM,CAACC,UAAU,CAACH,KAAK,CAAC,GAAGA,KAAK;EACtE,OAAO,OAAOC,CAAC,KAAK,QAAQ,IAAIC,MAAM,CAACE,QAAQ,CAACH,CAAC,CAAC,IAAIA,CAAC,GAAG,CAAC,GAAGA,CAAC,GAAGI,SAAS;AAC7E,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,2BAA2B,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izeCaptionMentions = exports.normalizeCaptionInput = exports.getMessageCaptionMentions = exports.getMessageCaption = void 0;
7
+ var _safeJson = require("./safeJson");
8
+ var _mentionSpans = require("./mentionSpans");
9
+ var _attachments = require("./attachments");
10
+ /**
11
+ * The text typed with a set of attachments, sent as part of the media
12
+ * message itself (never as a separate text stanza).
13
+ *
14
+ * `mentions` index into `text`, the same way a text message's mention spans
15
+ * index into its body.
16
+ */
17
+
18
+ const isSpanShape = value => {
19
+ if (!value || typeof value !== 'object') return false;
20
+ const span = value;
21
+ return typeof span.jid === 'string' && typeof span.name === 'string' && typeof span.offset === 'number' && Number.isInteger(span.offset) && typeof span.length === 'number' && Number.isInteger(span.length);
22
+ };
23
+
24
+ /**
25
+ * Mention spans for a caption, checked against the caption text: a span that
26
+ * no longer reads "@Name" at its offset is dropped. Undefined when nothing is
27
+ * left, so a caption without mentions carries no empty attribute.
28
+ */
29
+ const normalizeCaptionMentions = (value, caption) => {
30
+ const parsed = typeof value === 'string' ? (0, _safeJson.safeJsonParse)(value, []) : value;
31
+ if (!Array.isArray(parsed)) return undefined;
32
+ const spans = (0, _mentionSpans.validateMentionSpans)(caption, parsed.filter(isSpanShape));
33
+ return spans.length > 0 ? spans : undefined;
34
+ };
35
+
36
+ /**
37
+ * Turns what the composer typed into the caption that travels with the
38
+ * media. Undefined for blank text, which means "no caption".
39
+ */
40
+ exports.normalizeCaptionMentions = normalizeCaptionMentions;
41
+ const normalizeCaptionInput = input => {
42
+ const text = typeof input?.text === 'string' ? input.text : '';
43
+ if (!/\S/.test(text)) return undefined;
44
+ const mentions = normalizeCaptionMentions(input?.mentions, text);
45
+ return mentions ? {
46
+ caption: text,
47
+ mentions
48
+ } : {
49
+ caption: text
50
+ };
51
+ };
52
+
53
+ /** What a media message's text is, and the @-mention spans that index into it. */
54
+ exports.normalizeCaptionInput = normalizeCaptionInput;
55
+ /**
56
+ * Bodies that are not something a person typed: the media placeholder every
57
+ * SDK sends, and the labels apps generate for a file with nothing to say.
58
+ */
59
+ const PLACEHOLDER_BODIES = new Set(['media', 'attachment', 'attachments', 'photo', 'photos', 'image', 'images', 'picture', 'video', 'audio', 'voice', 'voice message', 'voice note', 'file', 'files', 'document', 'blob', 'undefined', 'null', '[object object]']);
60
+
61
+ /** `<data>` attributes older or foreign clients stamp the file's text on. */
62
+ const CAPTION_ALIASES = ['captionText', 'text', 'message', 'description', 'title'];
63
+ const norm = value => typeof value === 'string' ? value.trim().toLowerCase() : '';
64
+ const str = value => typeof value === 'string' ? value : typeof value === 'number' ? String(value) : '';
65
+ const tail = url => {
66
+ const path = url.split(/[?#]/)[0];
67
+ return path.slice(path.lastIndexOf('/') + 1);
68
+ };
69
+ const safeDecode = value => {
70
+ try {
71
+ return decodeURIComponent(value);
72
+ } catch {
73
+ return value;
74
+ }
75
+ };
76
+
77
+ /** Every string a media message's `body` is allowed to merely repeat. */
78
+ const echoCandidates = (message, options) => {
79
+ const out = new Set();
80
+ const add = value => {
81
+ const v = norm(value);
82
+ if (v) out.add(v);
83
+ };
84
+
85
+ // The file itself: its names and its URLs, as sent and as stored.
86
+ const attachments = (0, _attachments.getMessageAttachments)(message);
87
+ for (const attachment of attachments) {
88
+ add((0, _attachments.getAttachmentName)(attachment));
89
+ add(attachment.originalName);
90
+ add(attachment.fileName);
91
+ for (const url of [attachment.location, attachment.locationPreview]) {
92
+ if (!url) continue;
93
+ add(url);
94
+ add(safeDecode(url));
95
+ add(tail(url));
96
+ add(safeDecode(tail(url)));
97
+ }
98
+ }
99
+ add(message.originalName);
100
+ add(message.fileName);
101
+ add(message.location);
102
+ add(message.locationPreview);
103
+
104
+ // The sender: some clients put their own name, e-mail or username in the
105
+ // body next to the file.
106
+ const user = message.user ?? {};
107
+ const first = str(message.senderFirstName) || str(message.firstName) || str(user.firstName);
108
+ const last = str(message.senderLastName) || str(message.lastName) || str(user.lastName);
109
+ add(user.name);
110
+ add(`${first} ${last}`);
111
+ add(first && !last ? first : '');
112
+ add(user.email);
113
+ add(user.username);
114
+ add(message.email);
115
+ add(message.userName);
116
+ add(message.username);
117
+ add(message.senderName);
118
+ const idLocal = str(user.id).split('@')[0];
119
+ add(idLocal);
120
+ add(str(user.id).split('_').pop());
121
+ add(str(message.senderJID).split('/')[0].split('@')[0]);
122
+ for (const name of options.senderNames ?? []) add(name);
123
+ return out;
124
+ };
125
+
126
+ /** "etest etest" is echoed as "etest": every word of the name is the body. */
127
+ const isRepeatedName = (name, text) => Boolean(name && text) && name.split(/\s+/).every(part => part === text);
128
+ const isRealCaptionText = (text, message, options) => {
129
+ const t = text.trim();
130
+ if (!t) return false;
131
+ const n = t.toLowerCase();
132
+ if (PLACEHOLDER_BODIES.has(n)) return false;
133
+ // The key envelope a sealed message carries in its body is never text.
134
+ if (/^\{\s*"v"\s*:\s*\d+\s*,\s*"keys"/.test(t)) return false;
135
+ const candidates = echoCandidates(message, options);
136
+ if (candidates.has(n)) return false;
137
+ for (const name of candidates) if (isRepeatedName(name, n)) return false;
138
+ return true;
139
+ };
140
+ const asRecord = message => message && typeof message === 'object' ? message : undefined;
141
+ const resolveSpans = (message, text, keys) => {
142
+ for (const key of keys) {
143
+ const spans = normalizeCaptionMentions(message[key] ?? message.data?.[key], text);
144
+ if (spans) return spans;
145
+ }
146
+ return undefined;
147
+ };
148
+
149
+ /**
150
+ * The text of a media message, from whichever format carried it. The one
151
+ * place that knows the formats, so every surface (bubble, room list preview,
152
+ * notification, reply quote, copy) agrees:
153
+ *
154
+ * 1. `caption` (+ `captionMentions`): what this SDK sends. The only source
155
+ * for a sealed message, whose caption comes out of the envelope.
156
+ * 2. The caption under another name on `<data>` (`captionText`, `text`,
157
+ * `message`, `description`, `title`) from other clients.
158
+ * 3. A real `body`: older clients and other SDKs put the text in the
159
+ * `<body>` of the media message itself. "media", the file's name or URL,
160
+ * the sender's own name or e-mail and generated labels are not text.
161
+ *
162
+ * Never derived for a sealed message, and never for a message with no file.
163
+ */
164
+ const resolveMessageCaption = (message, options = {}) => {
165
+ const source = asRecord(message);
166
+ if (!source || source.isDeleted) return undefined;
167
+ const explicit = source.caption;
168
+ if (typeof explicit === 'string' && /\S/.test(explicit)) {
169
+ const mentions = normalizeCaptionMentions(source.captionMentions, explicit);
170
+ return mentions ? {
171
+ text: explicit,
172
+ mentions
173
+ } : {
174
+ text: explicit
175
+ };
176
+ }
177
+ const sealed = options.sealed === true || source.clientEncrypted === 'true' || Array.isArray(source.e2eeKeys) && source.e2eeKeys.length > 0;
178
+ if (sealed) return undefined;
179
+ const isMedia = options.isMedia ?? (0, _attachments.isMediaMessage)(source);
180
+ if (!isMedia) return undefined;
181
+ for (const key of CAPTION_ALIASES) {
182
+ const value = str(source[key] ?? source.data?.[key]);
183
+ if (value && isRealCaptionText(value, source, options)) {
184
+ const mentions = resolveSpans(source, value, ['captionMentions']);
185
+ return mentions ? {
186
+ text: value,
187
+ mentions
188
+ } : {
189
+ text: value
190
+ };
191
+ }
192
+ }
193
+ const body = str(source.body);
194
+ if (body && isRealCaptionText(body, source, options)) {
195
+ const mentions = resolveSpans(source, body, ['mentions']);
196
+ return mentions ? {
197
+ text: body,
198
+ mentions
199
+ } : {
200
+ text: body
201
+ };
202
+ }
203
+ return undefined;
204
+ };
205
+
206
+ /** The caption a message carries, or undefined when it has none. */
207
+ exports.resolveMessageCaption = resolveMessageCaption;
208
+ const getMessageCaption = (message, options) => resolveMessageCaption(message, options)?.text;
209
+
210
+ /** The mention spans of `getMessageCaption`'s text. */
211
+ exports.getMessageCaption = getMessageCaption;
212
+ const getMessageCaptionMentions = (message, options) => resolveMessageCaption(message, options)?.mentions;
213
+ exports.getMessageCaptionMentions = getMessageCaptionMentions;
214
+ //# sourceMappingURL=caption.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_safeJson","require","_mentionSpans","_attachments","isSpanShape","value","span","jid","name","offset","Number","isInteger","length","normalizeCaptionMentions","caption","parsed","safeJsonParse","Array","isArray","undefined","spans","validateMentionSpans","filter","exports","normalizeCaptionInput","input","text","test","mentions","PLACEHOLDER_BODIES","Set","CAPTION_ALIASES","norm","trim","toLowerCase","str","String","tail","url","path","split","slice","lastIndexOf","safeDecode","decodeURIComponent","echoCandidates","message","options","out","add","v","attachments","getMessageAttachments","attachment","getAttachmentName","originalName","fileName","location","locationPreview","user","first","senderFirstName","firstName","last","senderLastName","lastName","email","username","userName","senderName","idLocal","id","pop","senderJID","senderNames","isRepeatedName","Boolean","every","part","isRealCaptionText","t","n","has","candidates","asRecord","resolveSpans","keys","key","data","resolveMessageCaption","source","isDeleted","explicit","captionMentions","sealed","clientEncrypted","e2eeKeys","isMedia","isMediaMessage","body","getMessageCaption","getMessageCaptionMentions"],"sourceRoot":"../../../src","sources":["helpers/caption.ts"],"mappings":";;;;;;AACA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAWA,MAAMG,WAAW,GAAIC,KAAc,IAA4B;EAC7D,IAAI,CAACA,KAAK,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE,OAAO,KAAK;EACrD,MAAMC,IAAI,GAAGD,KAAgC;EAC7C,OACE,OAAOC,IAAI,CAACC,GAAG,KAAK,QAAQ,IAC5B,OAAOD,IAAI,CAACE,IAAI,KAAK,QAAQ,IAC7B,OAAOF,IAAI,CAACG,MAAM,KAAK,QAAQ,IAC/BC,MAAM,CAACC,SAAS,CAACL,IAAI,CAACG,MAAM,CAAC,IAC7B,OAAOH,IAAI,CAACM,MAAM,KAAK,QAAQ,IAC/BF,MAAM,CAACC,SAAS,CAACL,IAAI,CAACM,MAAM,CAAC;AAEjC,CAAC;;AAED;AACA;AACA;AACA;AACA;AACO,MAAMC,wBAAwB,GAAGA,CACtCR,KAAc,EACdS,OAAe,KACgB;EAC/B,MAAMC,MAAM,GACV,OAAOV,KAAK,KAAK,QAAQ,GAAG,IAAAW,uBAAa,EAAUX,KAAK,EAAE,EAAE,CAAC,GAAGA,KAA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AC,UAAU,CAAC,CAAC;IACzD,OAAOvE,QAAQ,GAAG;MAAEF,IAAI,EAAEyE,IAAI;MAAEvE;IAAS,CAAC,GAAG;MAAEF,IAAI,EAAEyE;IAAK,CAAC;EAC7D;EACA,OAAOhF,SAAS;AAClB,CAAC;;AAED;AAAAI,OAAA,CAAAkE,qBAAA,GAAAA,qBAAA;AACO,MAAMW,iBAAiB,GAAGA,CAC/BtD,OAAuB,EACvBC,OAAwB,KACD0C,qBAAqB,CAAC3C,OAAO,EAAEC,OAAO,CAAC,EAAErB,IAAI;;AAEtE;AAAAH,OAAA,CAAA6E,iBAAA,GAAAA,iBAAA;AACO,MAAMC,yBAAyB,GAAGA,CACvCvD,OAAuB,EACvBC,OAAwB,KACO0C,qBAAqB,CAAC3C,OAAO,EAAEC,OAAO,CAAC,EAAEnB,QAAQ;AAACL,OAAA,CAAA8E,yBAAA,GAAAA,yBAAA","ignoreList":[]}
@@ -4,9 +4,13 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.createMainMessageForThread = void 0;
7
+ var _caption = require("./caption");
7
8
  const createMainMessageForThread = message => {
9
+ // A media message is quoted by its caption. A sealed one never is: the
10
+ // reply stanza travels in the clear, the caption does not.
11
+ const caption = message.clientEncrypted === 'true' ? undefined : (0, _caption.getMessageCaption)(message);
8
12
  const data = {
9
- text: message.body,
13
+ text: caption ?? message.body,
10
14
  id: message.id,
11
15
  userName: message.user.name,
12
16
  createdAt: message.date,
@@ -1 +1 @@
1
- {"version":3,"names":["createMainMessageForThread","message","data","text","body","id","userName","user","name","createdAt","date","imageLocation","location","imagePreview","locationPreview","mimeType","mimetype","size","duration","waveForm","attachmentId","wrappable","nftActionType","contractAddress","roomJid","nftId","JSON","stringify","exports"],"sourceRoot":"../../../src","sources":["helpers/createMainMessageForThread.ts"],"mappings":";;;;;;AAEO,MAAMA,0BAA0B,GAAIC,OAAiB,IAAa;EACvE,MAAMC,IAAI,GAAG;IACXC,IAAI,EAAEF,OAAO,CAACG,IAAI;IAClBC,EAAE,EAAEJ,OAAO,CAACI,EAAE;IACdC,QAAQ,EAAEL,OAAO,CAACM,IAAI,CAACC,IAAI;IAC3BC,SAAS,EAAER,OAAO,CAACS,IAAI;IACvBC,aAAa,EAAEV,OAAO,CAACW,QAAQ;IAC/BC,YAAY,EAAEZ,OAAO,CAACa,eAAe;IACrCC,QAAQ,EAAEd,OAAO,CAACe,QAAQ;IAC1BC,IAAI,EAAE,EAAE;IACRC,QAAQ,EAAE,EAAE;IACZC,QAAQ,EAAE,EAAE;IACZC,YAAY,EAAE,EAAE;IAChBC,SAAS,EAAE,EAAE;IACbC,aAAa,EAAE,EAAE;IACjBC,eAAe,EAAE,EAAE;IACnBC,OAAO,EAAEvB,OAAO,CAACuB,OAAO;IACxBC,KAAK,EAAE;EACT,CAAC;EACD,OAAOC,IAAI,CAACC,SAAS,CAACzB,IAAI,CAAC;AAC7B,CAAC;AAAC0B,OAAA,CAAA5B,0BAAA,GAAAA,0BAAA","ignoreList":[]}
1
+ {"version":3,"names":["_caption","require","createMainMessageForThread","message","caption","clientEncrypted","undefined","getMessageCaption","data","text","body","id","userName","user","name","createdAt","date","imageLocation","location","imagePreview","locationPreview","mimeType","mimetype","size","duration","waveForm","attachmentId","wrappable","nftActionType","contractAddress","roomJid","nftId","JSON","stringify","exports"],"sourceRoot":"../../../src","sources":["helpers/createMainMessageForThread.ts"],"mappings":";;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AAEO,MAAMC,0BAA0B,GAAIC,OAAiB,IAAa;EACvE;EACA;EACA,MAAMC,OAAO,GACXD,OAAO,CAACE,eAAe,KAAK,MAAM,GAAGC,SAAS,GAAG,IAAAC,0BAAiB,EAACJ,OAAO,CAAC;EAC7E,MAAMK,IAAI,GAAG;IACXC,IAAI,EAAEL,OAAO,IAAID,OAAO,CAACO,IAAI;IAC7BC,EAAE,EAAER,OAAO,CAACQ,EAAE;IACdC,QAAQ,EAAET,OAAO,CAACU,IAAI,CAACC,IAAI;IAC3BC,SAAS,EAAEZ,OAAO,CAACa,IAAI;IACvBC,aAAa,EAAEd,OAAO,CAACe,QAAQ;IAC/BC,YAAY,EAAEhB,OAAO,CAACiB,eAAe;IACrCC,QAAQ,EAAElB,OAAO,CAACmB,QAAQ;IAC1BC,IAAI,EAAE,EAAE;IACRC,QAAQ,EAAE,EAAE;IACZC,QAAQ,EAAE,EAAE;IACZC,YAAY,EAAE,EAAE;IAChBC,SAAS,EAAE,EAAE;IACbC,aAAa,EAAE,EAAE;IACjBC,eAAe,EAAE,EAAE;IACnBC,OAAO,EAAE3B,OAAO,CAAC2B,OAAO;IACxBC,KAAK,EAAE;EACT,CAAC;EACD,OAAOC,IAAI,CAACC,SAAS,CAACzB,IAAI,CAAC;AAC7B,CAAC;AAAC0B,OAAA,CAAAhC,0BAAA,GAAAA,0BAAA","ignoreList":[]}
@@ -7,6 +7,7 @@ exports.createMessageFromXml = void 0;
7
7
  var _e2ee = require("../e2ee");
8
8
  var _displayName = require("./displayName");
9
9
  var _sealedBody = require("../e2ee/sealedBody");
10
+ var _mediaWireData = require("./mediaWireData");
10
11
  /**
11
12
  * Build an IMessage from XML.
12
13
  *
@@ -63,7 +64,9 @@ const createMessageFromXml = async (arg, bodyEl, positionalId, positionalFrom, p
63
64
  delete outerExtras.data;
64
65
  }
65
66
  const merged = {
66
- ...inner,
67
+ // Idempotent: the wrapped path already ran it in getDataFromXml, the
68
+ // positional (MAM catch-up) path hands over the raw attrs.
69
+ ...(0, _mediaWireData.normalizeMediaDataAttrs)(inner),
67
70
  ...outerExtras,
68
71
  isDeleted: !!outerExtras?.deleted || !!arg?.isDeleted
69
72
  };
@@ -114,15 +117,26 @@ const createMessageFromXml = async (arg, bodyEl, positionalId, positionalFrom, p
114
117
  const existingName = String(merged?.user?.name || '').trim();
115
118
  const resolvedName = existingName || composed || fullName || senderLocal || merged?.user?.id || '';
116
119
  const unencrypted = merged.omemoEncrypted !== 'true' && (0, _e2ee.isE2eeRoom)(String(merged.roomJid || ''));
117
- const sealedKeys = merged.clientEncrypted === 'true' ? (0, _sealedBody.parseSealedMediaBody)(merged.body) : undefined;
120
+
121
+ // A sealed media body is `{v:1,keys,caption?,captionMentions?}`. The keys
122
+ // and the caption are lifted next to each other; the caption is the only
123
+ // one a sealed message may show (any open caption attribute was dropped
124
+ // by normalizeMediaDataAttrs).
125
+ const sealed = merged.clientEncrypted === 'true' ? (0, _sealedBody.parseSealedMediaPayload)(merged.body) : undefined;
118
126
  const message = {
119
127
  ...merged,
120
128
  ...(unencrypted ? {
121
129
  unencrypted: true
122
130
  } : {}),
123
- ...(sealedKeys ? {
124
- e2eeKeys: sealedKeys,
125
- body: 'media'
131
+ ...(sealed ? {
132
+ e2eeKeys: sealed.keys,
133
+ body: 'media',
134
+ ...(sealed.caption ? {
135
+ caption: sealed.caption
136
+ } : {}),
137
+ ...(sealed.captionMentions ? {
138
+ captionMentions: sealed.captionMentions
139
+ } : {})
126
140
  } : {}),
127
141
  user: {
128
142
  ...(merged.user || {}),
@@ -1 +1 @@
1
- {"version":3,"names":["_e2ee","require","_displayName","_sealedBody","createMessageFromXml","arg","bodyEl","positionalId","positionalFrom","positionalDeleted","console","log","id","body","date","user","name","roomJid","isPositional","undefined","inner","outerExtras","bodyText","getText","text","split","xmppFrom","deleted","data","merged","isDeleted","numericPart","exec","String","Date","slice","toISOString","now","firstName","senderFirstName","toString","trim","lastName","senderLastName","fullName","senderJID","senderBare","senderResource","includes","senderIsOccupant","test","senderLocal","fromResource","composed","composeName","existingName","resolvedName","unencrypted","omemoEncrypted","isE2eeRoom","sealedKeys","clientEncrypted","parseSealedMediaBody","message","e2eeKeys","exports"],"sourceRoot":"../../../src","sources":["helpers/createMessageFromXml.ts"],"mappings":";;;;;;AACA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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,MAAM,CAACJ,MAAM,CAACZ,OAAO,IAAI,EAAE,CAAC,CAAC;EAE9E,MAAM2C,UAAU,GACd/B,MAAM,CAACgC,eAAe,KAAK,MAAM,GAC7B,IAAAC,gCAAoB,EAACjC,MAAM,CAAChB,IAAI,CAAC,GACjCM,SAAS;EAEf,MAAM4C,OAAiB,GAAG;IACxB,GAAGlC,MAAM;IACT,IAAI4B,WAAW,GAAG;MAAEA,WAAW,EAAE;IAAK,CAAC,GAAG,CAAC,CAAC,CAAC;IAC7C,IAAIG,UAAU,GAAG;MAAEI,QAAQ,EAAEJ,UAAU;MAAE/C,IAAI,EAAE;IAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;IAC9DE,IAAI,EAAE;MACJ,IAAIc,MAAM,CAACd,IAAI,IAAI,CAAC,CAAC,CAAC;MACtBH,EAAE,EAAEiB,MAAM,EAAEd,IAAI,EAAEH,EAAE,IAAIwC,YAAY,IAAID,WAAW;MACnDnC,IAAI,EAAEwC,YAAY;MAClBlB,SAAS,EAAEA,SAAS,IAAIT,MAAM,EAAEd,IAAI,EAAEuB,SAAS;MAC/CI,QAAQ,EAAEA,QAAQ,IAAIb,MAAM,EAAEd,IAAI,EAAE2B;IACtC;EACF,CAAC;EAED,OAAOqB,OAAO;AAChB,CAAC;AAACE,OAAA,CAAA7D,oBAAA,GAAAA,oBAAA","ignoreList":[]}
1
+ {"version":3,"names":["_e2ee","require","_displayName","_sealedBody","_mediaWireData","createMessageFromXml","arg","bodyEl","positionalId","positionalFrom","positionalDeleted","console","log","id","body","date","user","name","roomJid","isPositional","undefined","inner","outerExtras","bodyText","getText","text","split","xmppFrom","deleted","data","merged","normalizeMediaDataAttrs","isDeleted","numericPart","exec","String","Date","slice","toISOString","now","firstName","senderFirstName","toString","trim","lastName","senderLastName","fullName","senderJID","senderBare","senderResource","includes","senderIsOccupant","test","senderLocal","fromResource","composed","composeName","existingName","resolvedName","unencrypted","omemoEncrypted","isE2eeRoom","sealed","clientEncrypted","parseSealedMediaPayload","message","e2eeKeys","keys","caption","captionMentions","exports"],"sourceRoot":"../../../src","sources":["helpers/createMessageFromXml.ts"],"mappings":";;;;;;AACA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,cAAA,GAAAH,OAAA;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMI,oBAAoB,GAAG,MAAAA,CAClCC,GAAwB,EACxBC,MAAY,EACZC,YAAqB,EACrBC,cAAuB,EACvBC,iBAA2B,KACL;EACtB,IAAI,CAACJ,GAAG,EAAE;IACRK,OAAO,CAACC,GAAG,CAAC,wCAAwC,CAAC;IACrD;IACA;IACA,OAAO;MAAEC,EAAE,EAAE,EAAE;MAAEC,IAAI,EAAE,EAAE;MAAEC,IAAI,EAAE,EAAE;MAAEC,IAAI,EAAE;QAAEH,EAAE,EAAE,EAAE;QAAEI,IAAI,EAAE;MAAG,CAAQ;MAAEC,OAAO,EAAE;IAAG,CAAC;EACvF;;EAEA;EACA;EACA;EACA,MAAMC,YAAY,GAAGZ,MAAM,KAAKa,SAAS,IAAIZ,YAAY,KAAKY,SAAS;EAEvE,IAAIC,KAAU,CAAC,CAAC;EAChB,IAAIC,WAAgB,GAAG,CAAC,CAAC;EAEzB,IAAIH,YAAY,EAAE;IAChBE,KAAK,GAAGf,GAAG,CAAC,CAAC;IACb,MAAMiB,QAAQ,GACZ,OAAOhB,MAAM,KAAK,QAAQ,GACtBA,MAAM,GACNA,MAAM,EAAEiB,OAAO,GACbjB,MAAM,CAACiB,OAAO,CAAC,CAAC,GAChBjB,MAAM,EAAEkB,IAAI;IACpBH,WAAW,GAAG;MACZT,EAAE,EAAEL,YAAY;MAChBM,IAAI,EAAES,QAAQ;MACdL,OAAO,EAAE,CAACT,cAAc,IAAI,EAAE,EAAEiB,KAAK,CAAC,GAAG,CAAC,CAAC,CAA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