@ethora/chat-component-rn 26.10.5 → 26.10.7

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 (426) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/README.md +18 -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/helpers/secureStoreRuntime.js +10 -1
  81. package/lib/commonjs/helpers/secureStoreRuntime.js.map +1 -1
  82. package/lib/commonjs/hooks/useSendMessage.js +384 -193
  83. package/lib/commonjs/hooks/useSendMessage.js.map +1 -1
  84. package/lib/commonjs/i18n/strings.js +96 -0
  85. package/lib/commonjs/i18n/strings.js.map +1 -1
  86. package/lib/commonjs/main.js +81 -0
  87. package/lib/commonjs/main.js.map +1 -1
  88. package/lib/commonjs/networking/api-requests/auth.api.js +62 -3
  89. package/lib/commonjs/networking/api-requests/auth.api.js.map +1 -1
  90. package/lib/commonjs/networking/api-requests/push.api.js +22 -7
  91. package/lib/commonjs/networking/api-requests/push.api.js.map +1 -1
  92. package/lib/commonjs/networking/stanzaHandlers.js +100 -3
  93. package/lib/commonjs/networking/stanzaHandlers.js.map +1 -1
  94. package/lib/commonjs/networking/xmpp/handleStanzas.xmpp.js +4 -2
  95. package/lib/commonjs/networking/xmpp/handleStanzas.xmpp.js.map +1 -1
  96. package/lib/commonjs/networking/xmpp/sendDisplayedMarker.xmpp.js +28 -0
  97. package/lib/commonjs/networking/xmpp/sendDisplayedMarker.xmpp.js.map +1 -0
  98. package/lib/commonjs/networking/xmpp/sendMediaMessage.xmpp.js +53 -2
  99. package/lib/commonjs/networking/xmpp/sendMediaMessage.xmpp.js.map +1 -1
  100. package/lib/commonjs/networking/xmpp/sendReceivedReceipt.xmpp.js +28 -0
  101. package/lib/commonjs/networking/xmpp/sendReceivedReceipt.xmpp.js.map +1 -0
  102. package/lib/commonjs/networking/xmppClient.js +64 -0
  103. package/lib/commonjs/networking/xmppClient.js.map +1 -1
  104. package/lib/commonjs/push/pushKeyStore.js +169 -0
  105. package/lib/commonjs/push/pushKeyStore.js.map +1 -0
  106. package/lib/commonjs/push/sealedBox.js +106 -0
  107. package/lib/commonjs/push/sealedBox.js.map +1 -0
  108. package/lib/commonjs/push/sealedPush.js +124 -0
  109. package/lib/commonjs/push/sealedPush.js.map +1 -0
  110. package/lib/commonjs/push/sealedPushTask.js +195 -0
  111. package/lib/commonjs/push/sealedPushTask.js.map +1 -0
  112. package/lib/commonjs/roomStore/persistence.js +78 -5
  113. package/lib/commonjs/roomStore/persistence.js.map +1 -1
  114. package/lib/commonjs/roomStore/roomHeapSlice.js +4 -0
  115. package/lib/commonjs/roomStore/roomHeapSlice.js.map +1 -1
  116. package/lib/commonjs/roomStore/roomsSlice.js +114 -1
  117. package/lib/commonjs/roomStore/roomsSlice.js.map +1 -1
  118. package/lib/commonjs/services/pushRegistration.js +12 -7
  119. package/lib/commonjs/services/pushRegistration.js.map +1 -1
  120. package/lib/commonjs/types/models/attachment.model.js +2 -0
  121. package/lib/commonjs/types/models/attachment.model.js.map +1 -0
  122. package/lib/commonjs/version.js +1 -1
  123. package/lib/module/assets/icons.js +1 -1
  124. package/lib/module/assets/icons.js.map +1 -1
  125. package/lib/module/components/MainComponents/AlbumGrid.js +146 -0
  126. package/lib/module/components/MainComponents/AlbumGrid.js.map +1 -0
  127. package/lib/module/components/MainComponents/ChatRoom.js +2 -2
  128. package/lib/module/components/MainComponents/ChatRoom.js.map +1 -1
  129. package/lib/module/components/MainComponents/MediaMessage.js +200 -124
  130. package/lib/module/components/MainComponents/MediaMessage.js.map +1 -1
  131. package/lib/module/components/MainComponents/MediaUploadOverlay.js +104 -0
  132. package/lib/module/components/MainComponents/MediaUploadOverlay.js.map +1 -0
  133. package/lib/module/components/MessageBubble/MediaCaption.js +46 -0
  134. package/lib/module/components/MessageBubble/MediaCaption.js.map +1 -0
  135. package/lib/module/components/MessageBubble/Message.js +44 -5
  136. package/lib/module/components/MessageBubble/Message.js.map +1 -1
  137. package/lib/module/components/MessageBubble/MessageInteractions.js +2 -1
  138. package/lib/module/components/MessageBubble/MessageInteractions.js.map +1 -1
  139. package/lib/module/components/Modals/FilePreviewModal/FilePreviewModal.js +75 -0
  140. package/lib/module/components/Modals/FilePreviewModal/FilePreviewModal.js.map +1 -1
  141. package/lib/module/components/RoomComponents/LastMessageItem.js +20 -4
  142. package/lib/module/components/RoomComponents/LastMessageItem.js.map +1 -1
  143. package/lib/module/components/RoomComponents/styled/LastAudioMessage.js +3 -2
  144. package/lib/module/components/RoomComponents/styled/LastAudioMessage.js.map +1 -1
  145. package/lib/module/components/RoomComponents/styled/LastMessageFile.js +3 -2
  146. package/lib/module/components/RoomComponents/styled/LastMessageFile.js.map +1 -1
  147. package/lib/module/components/RoomComponents/styled/LastMessagePhoto.js +3 -2
  148. package/lib/module/components/RoomComponents/styled/LastMessagePhoto.js.map +1 -1
  149. package/lib/module/components/RoomComponents/styled/LastMessageVideo.js +3 -2
  150. package/lib/module/components/RoomComponents/styled/LastMessageVideo.js.map +1 -1
  151. package/lib/module/components/Thread/ThreadWrapper.js +3 -2
  152. package/lib/module/components/Thread/ThreadWrapper.js.map +1 -1
  153. package/lib/module/components/styled/MediaFilePreview.js +61 -48
  154. package/lib/module/components/styled/MediaFilePreview.js.map +1 -1
  155. package/lib/module/components/styled/MessageImage.js +16 -6
  156. package/lib/module/components/styled/MessageImage.js.map +1 -1
  157. package/lib/module/components/styled/SendInput.js +99 -68
  158. package/lib/module/components/styled/SendInput.js.map +1 -1
  159. package/lib/module/components/styled/VideoMessage.js +24 -10
  160. package/lib/module/components/styled/VideoMessage.js.map +1 -1
  161. package/lib/module/context/xmppProvider.js +46 -0
  162. package/lib/module/context/xmppProvider.js.map +1 -1
  163. package/lib/module/e2ee/fileEnvelope.js +1 -1
  164. package/lib/module/e2ee/fileEnvelope.js.map +1 -1
  165. package/lib/module/e2ee/sealedBody.js +32 -2
  166. package/lib/module/e2ee/sealedBody.js.map +1 -1
  167. package/lib/module/helpers/albumLayout.js +143 -0
  168. package/lib/module/helpers/albumLayout.js.map +1 -0
  169. package/lib/module/helpers/attachments.js +245 -0
  170. package/lib/module/helpers/attachments.js.map +1 -0
  171. package/lib/module/helpers/caption.js +207 -0
  172. package/lib/module/helpers/caption.js.map +1 -0
  173. package/lib/module/helpers/createMainMessageForThread.js +5 -1
  174. package/lib/module/helpers/createMainMessageForThread.js.map +1 -1
  175. package/lib/module/helpers/createMessageFromXml.js +20 -6
  176. package/lib/module/helpers/createMessageFromXml.js.map +1 -1
  177. package/lib/module/helpers/fileKind.js +34 -0
  178. package/lib/module/helpers/fileKind.js.map +1 -0
  179. package/lib/module/helpers/getDataFromXml.js +6 -1
  180. package/lib/module/helpers/getDataFromXml.js.map +1 -1
  181. package/lib/module/helpers/mapWithConcurrency.js +37 -0
  182. package/lib/module/helpers/mapWithConcurrency.js.map +1 -0
  183. package/lib/module/helpers/mediaLimits.js +27 -0
  184. package/lib/module/helpers/mediaLimits.js.map +1 -0
  185. package/lib/module/helpers/mediaSendRetry.js +55 -0
  186. package/lib/module/helpers/mediaSendRetry.js.map +1 -0
  187. package/lib/module/helpers/mediaWireData.js +58 -0
  188. package/lib/module/helpers/mediaWireData.js.map +1 -0
  189. package/lib/module/helpers/mentionSpans.js +14 -0
  190. package/lib/module/helpers/mentionSpans.js.map +1 -0
  191. package/lib/module/helpers/mimeToExtension.js +43 -0
  192. package/lib/module/helpers/mimeToExtension.js.map +1 -1
  193. package/lib/module/helpers/readReceipts.js +160 -0
  194. package/lib/module/helpers/readReceipts.js.map +1 -0
  195. package/lib/module/helpers/repairFilenameEncoding.js +74 -0
  196. package/lib/module/helpers/repairFilenameEncoding.js.map +1 -0
  197. package/lib/module/helpers/safeJson.js +13 -0
  198. package/lib/module/helpers/safeJson.js.map +1 -0
  199. package/lib/module/helpers/secureStoreRuntime.js +10 -1
  200. package/lib/module/helpers/secureStoreRuntime.js.map +1 -1
  201. package/lib/module/hooks/useSendMessage.js +387 -195
  202. package/lib/module/hooks/useSendMessage.js.map +1 -1
  203. package/lib/module/i18n/strings.js +96 -0
  204. package/lib/module/i18n/strings.js.map +1 -1
  205. package/lib/module/main.js +6 -0
  206. package/lib/module/main.js.map +1 -1
  207. package/lib/module/networking/api-requests/auth.api.js +62 -3
  208. package/lib/module/networking/api-requests/auth.api.js.map +1 -1
  209. package/lib/module/networking/api-requests/push.api.js +21 -6
  210. package/lib/module/networking/api-requests/push.api.js.map +1 -1
  211. package/lib/module/networking/stanzaHandlers.js +97 -4
  212. package/lib/module/networking/stanzaHandlers.js.map +1 -1
  213. package/lib/module/networking/xmpp/handleStanzas.xmpp.js +5 -3
  214. package/lib/module/networking/xmpp/handleStanzas.xmpp.js.map +1 -1
  215. package/lib/module/networking/xmpp/sendDisplayedMarker.xmpp.js +25 -0
  216. package/lib/module/networking/xmpp/sendDisplayedMarker.xmpp.js.map +1 -0
  217. package/lib/module/networking/xmpp/sendMediaMessage.xmpp.js +53 -2
  218. package/lib/module/networking/xmpp/sendMediaMessage.xmpp.js.map +1 -1
  219. package/lib/module/networking/xmpp/sendReceivedReceipt.xmpp.js +25 -0
  220. package/lib/module/networking/xmpp/sendReceivedReceipt.xmpp.js.map +1 -0
  221. package/lib/module/networking/xmppClient.js +64 -0
  222. package/lib/module/networking/xmppClient.js.map +1 -1
  223. package/lib/module/push/pushKeyStore.js +159 -0
  224. package/lib/module/push/pushKeyStore.js.map +1 -0
  225. package/lib/module/push/sealedBox.js +97 -0
  226. package/lib/module/push/sealedBox.js.map +1 -0
  227. package/lib/module/push/sealedPush.js +117 -0
  228. package/lib/module/push/sealedPush.js.map +1 -0
  229. package/lib/module/push/sealedPushTask.js +187 -0
  230. package/lib/module/push/sealedPushTask.js.map +1 -0
  231. package/lib/module/roomStore/persistence.js +78 -5
  232. package/lib/module/roomStore/persistence.js.map +1 -1
  233. package/lib/module/roomStore/roomHeapSlice.js +4 -0
  234. package/lib/module/roomStore/roomHeapSlice.js.map +1 -1
  235. package/lib/module/roomStore/roomsSlice.js +109 -0
  236. package/lib/module/roomStore/roomsSlice.js.map +1 -1
  237. package/lib/module/services/pushRegistration.js +12 -7
  238. package/lib/module/services/pushRegistration.js.map +1 -1
  239. package/lib/module/types/models/attachment.model.js +2 -0
  240. package/lib/module/types/models/attachment.model.js.map +1 -0
  241. package/lib/module/version.js +1 -1
  242. package/lib/typescript/assets/icons.d.ts +6 -1
  243. package/lib/typescript/assets/icons.d.ts.map +1 -1
  244. package/lib/typescript/components/MainComponents/AlbumGrid.d.ts +21 -0
  245. package/lib/typescript/components/MainComponents/AlbumGrid.d.ts.map +1 -0
  246. package/lib/typescript/components/MainComponents/ChatRoom.d.ts.map +1 -1
  247. package/lib/typescript/components/MainComponents/MediaMessage.d.ts.map +1 -1
  248. package/lib/typescript/components/MainComponents/MediaUploadOverlay.d.ts +17 -0
  249. package/lib/typescript/components/MainComponents/MediaUploadOverlay.d.ts.map +1 -0
  250. package/lib/typescript/components/MessageBubble/MediaCaption.d.ts +12 -0
  251. package/lib/typescript/components/MessageBubble/MediaCaption.d.ts.map +1 -0
  252. package/lib/typescript/components/MessageBubble/Message.d.ts.map +1 -1
  253. package/lib/typescript/components/MessageBubble/MessageInteractions.d.ts.map +1 -1
  254. package/lib/typescript/components/Modals/FilePreviewModal/FilePreviewModal.d.ts.map +1 -1
  255. package/lib/typescript/components/RoomComponents/LastMessageItem.d.ts.map +1 -1
  256. package/lib/typescript/components/RoomComponents/styled/LastAudioMessage.d.ts +2 -0
  257. package/lib/typescript/components/RoomComponents/styled/LastAudioMessage.d.ts.map +1 -1
  258. package/lib/typescript/components/RoomComponents/styled/LastMessageFile.d.ts +2 -0
  259. package/lib/typescript/components/RoomComponents/styled/LastMessageFile.d.ts.map +1 -1
  260. package/lib/typescript/components/RoomComponents/styled/LastMessagePhoto.d.ts +2 -0
  261. package/lib/typescript/components/RoomComponents/styled/LastMessagePhoto.d.ts.map +1 -1
  262. package/lib/typescript/components/RoomComponents/styled/LastMessageVideo.d.ts +2 -0
  263. package/lib/typescript/components/RoomComponents/styled/LastMessageVideo.d.ts.map +1 -1
  264. package/lib/typescript/components/Thread/ThreadWrapper.d.ts.map +1 -1
  265. package/lib/typescript/components/styled/MediaFilePreview.d.ts.map +1 -1
  266. package/lib/typescript/components/styled/MessageImage.d.ts +10 -0
  267. package/lib/typescript/components/styled/MessageImage.d.ts.map +1 -1
  268. package/lib/typescript/components/styled/SendInput.d.ts +7 -1
  269. package/lib/typescript/components/styled/SendInput.d.ts.map +1 -1
  270. package/lib/typescript/components/styled/VideoMessage.d.ts +7 -0
  271. package/lib/typescript/components/styled/VideoMessage.d.ts.map +1 -1
  272. package/lib/typescript/context/xmppProvider.d.ts.map +1 -1
  273. package/lib/typescript/e2ee/fileEnvelope.d.ts +1 -1
  274. package/lib/typescript/e2ee/fileEnvelope.d.ts.map +1 -1
  275. package/lib/typescript/e2ee/sealedBody.d.ts +16 -0
  276. package/lib/typescript/e2ee/sealedBody.d.ts.map +1 -1
  277. package/lib/typescript/helpers/albumLayout.d.ts +66 -0
  278. package/lib/typescript/helpers/albumLayout.d.ts.map +1 -0
  279. package/lib/typescript/helpers/attachments.d.ts +55 -0
  280. package/lib/typescript/helpers/attachments.d.ts.map +1 -0
  281. package/lib/typescript/helpers/caption.d.ts +64 -0
  282. package/lib/typescript/helpers/caption.d.ts.map +1 -0
  283. package/lib/typescript/helpers/createMainMessageForThread.d.ts.map +1 -1
  284. package/lib/typescript/helpers/createMessageFromXml.d.ts.map +1 -1
  285. package/lib/typescript/helpers/fileKind.d.ts +20 -0
  286. package/lib/typescript/helpers/fileKind.d.ts.map +1 -0
  287. package/lib/typescript/helpers/getDataFromXml.d.ts.map +1 -1
  288. package/lib/typescript/helpers/mapWithConcurrency.d.ts +9 -0
  289. package/lib/typescript/helpers/mapWithConcurrency.d.ts.map +1 -0
  290. package/lib/typescript/helpers/mediaLimits.d.ts +13 -0
  291. package/lib/typescript/helpers/mediaLimits.d.ts.map +1 -0
  292. package/lib/typescript/helpers/mediaSendRetry.d.ts +26 -0
  293. package/lib/typescript/helpers/mediaSendRetry.d.ts.map +1 -0
  294. package/lib/typescript/helpers/mediaWireData.d.ts +16 -0
  295. package/lib/typescript/helpers/mediaWireData.d.ts.map +1 -0
  296. package/lib/typescript/helpers/mentionSpans.d.ts +8 -0
  297. package/lib/typescript/helpers/mentionSpans.d.ts.map +1 -0
  298. package/lib/typescript/helpers/mimeToExtension.d.ts +7 -0
  299. package/lib/typescript/helpers/mimeToExtension.d.ts.map +1 -1
  300. package/lib/typescript/helpers/readReceipts.d.ts +82 -0
  301. package/lib/typescript/helpers/readReceipts.d.ts.map +1 -0
  302. package/lib/typescript/helpers/repairFilenameEncoding.d.ts +12 -0
  303. package/lib/typescript/helpers/repairFilenameEncoding.d.ts.map +1 -0
  304. package/lib/typescript/helpers/safeJson.d.ts +2 -0
  305. package/lib/typescript/helpers/safeJson.d.ts.map +1 -0
  306. package/lib/typescript/helpers/secureStoreRuntime.d.ts +17 -3
  307. package/lib/typescript/helpers/secureStoreRuntime.d.ts.map +1 -1
  308. package/lib/typescript/hooks/useSendMessage.d.ts +2 -1
  309. package/lib/typescript/hooks/useSendMessage.d.ts.map +1 -1
  310. package/lib/typescript/i18n/strings.d.ts.map +1 -1
  311. package/lib/typescript/main.d.ts +6 -0
  312. package/lib/typescript/main.d.ts.map +1 -1
  313. package/lib/typescript/networking/api-requests/auth.api.d.ts +2 -0
  314. package/lib/typescript/networking/api-requests/auth.api.d.ts.map +1 -1
  315. package/lib/typescript/networking/api-requests/push.api.d.ts +14 -2
  316. package/lib/typescript/networking/api-requests/push.api.d.ts.map +1 -1
  317. package/lib/typescript/networking/stanzaHandlers.d.ts +7 -3
  318. package/lib/typescript/networking/stanzaHandlers.d.ts.map +1 -1
  319. package/lib/typescript/networking/xmpp/handleStanzas.xmpp.d.ts.map +1 -1
  320. package/lib/typescript/networking/xmpp/sendDisplayedMarker.xmpp.d.ts +3 -0
  321. package/lib/typescript/networking/xmpp/sendDisplayedMarker.xmpp.d.ts.map +1 -0
  322. package/lib/typescript/networking/xmpp/sendMediaMessage.xmpp.d.ts +12 -0
  323. package/lib/typescript/networking/xmpp/sendMediaMessage.xmpp.d.ts.map +1 -1
  324. package/lib/typescript/networking/xmpp/sendReceivedReceipt.xmpp.d.ts +3 -0
  325. package/lib/typescript/networking/xmpp/sendReceivedReceipt.xmpp.d.ts.map +1 -0
  326. package/lib/typescript/networking/xmppClient.d.ts +15 -0
  327. package/lib/typescript/networking/xmppClient.d.ts.map +1 -1
  328. package/lib/typescript/push/pushKeyStore.d.ts +35 -0
  329. package/lib/typescript/push/pushKeyStore.d.ts.map +1 -0
  330. package/lib/typescript/push/sealedBox.d.ts +24 -0
  331. package/lib/typescript/push/sealedBox.d.ts.map +1 -0
  332. package/lib/typescript/push/sealedPush.d.ts +61 -0
  333. package/lib/typescript/push/sealedPush.d.ts.map +1 -0
  334. package/lib/typescript/push/sealedPushTask.d.ts +33 -0
  335. package/lib/typescript/push/sealedPushTask.d.ts.map +1 -0
  336. package/lib/typescript/roomStore/persistence.d.ts.map +1 -1
  337. package/lib/typescript/roomStore/roomHeapSlice.d.ts +22 -1
  338. package/lib/typescript/roomStore/roomHeapSlice.d.ts.map +1 -1
  339. package/lib/typescript/roomStore/roomsSlice.d.ts +67 -3
  340. package/lib/typescript/roomStore/roomsSlice.d.ts.map +1 -1
  341. package/lib/typescript/services/pushRegistration.d.ts +8 -0
  342. package/lib/typescript/services/pushRegistration.d.ts.map +1 -1
  343. package/lib/typescript/types/models/attachment.model.d.ts +52 -0
  344. package/lib/typescript/types/models/attachment.model.d.ts.map +1 -0
  345. package/lib/typescript/types/models/message.model.d.ts +26 -0
  346. package/lib/typescript/types/models/message.model.d.ts.map +1 -1
  347. package/lib/typescript/types/models/modal.model.d.ts +7 -0
  348. package/lib/typescript/types/models/modal.model.d.ts.map +1 -1
  349. package/lib/typescript/types/models/room.model.d.ts +2 -0
  350. package/lib/typescript/types/models/room.model.d.ts.map +1 -1
  351. package/lib/typescript/types/types.d.ts +35 -1
  352. package/lib/typescript/types/types.d.ts.map +1 -1
  353. package/lib/typescript/version.d.ts +1 -1
  354. package/package.json +14 -1
  355. package/plugins/notification-service/Info.plist +31 -0
  356. package/plugins/notification-service/NotificationService.swift +195 -0
  357. package/plugins/notification-service/SealedBox.swift +355 -0
  358. package/plugins/notification-service/check/gen-vectors.mjs +24 -0
  359. package/plugins/notification-service/check/main.swift +37 -0
  360. package/plugins/notification-service/check/run.sh +12 -0
  361. package/plugins/notification-service/check/vectors.json +1 -0
  362. package/plugins/withNotificationServiceExtension.js +189 -0
  363. package/src/assets/icons.tsx +20 -2
  364. package/src/components/MainComponents/AlbumGrid.tsx +183 -0
  365. package/src/components/MainComponents/ChatRoom.tsx +4 -2
  366. package/src/components/MainComponents/MediaMessage.tsx +246 -130
  367. package/src/components/MainComponents/MediaUploadOverlay.tsx +102 -0
  368. package/src/components/MessageBubble/MediaCaption.tsx +45 -0
  369. package/src/components/MessageBubble/Message.tsx +71 -3
  370. package/src/components/MessageBubble/MessageInteractions.tsx +2 -1
  371. package/src/components/Modals/FilePreviewModal/FilePreviewModal.tsx +64 -0
  372. package/src/components/RoomComponents/LastMessageItem.tsx +15 -4
  373. package/src/components/RoomComponents/styled/LastAudioMessage.tsx +6 -3
  374. package/src/components/RoomComponents/styled/LastMessageFile.tsx +6 -2
  375. package/src/components/RoomComponents/styled/LastMessagePhoto.tsx +6 -2
  376. package/src/components/RoomComponents/styled/LastMessageVideo.tsx +6 -2
  377. package/src/components/Thread/ThreadWrapper.tsx +5 -9
  378. package/src/components/styled/MediaFilePreview.tsx +49 -34
  379. package/src/components/styled/MessageImage.tsx +21 -5
  380. package/src/components/styled/SendInput.tsx +101 -87
  381. package/src/components/styled/VideoMessage.tsx +34 -9
  382. package/src/context/xmppProvider.tsx +32 -0
  383. package/src/e2ee/fileEnvelope.ts +1 -1
  384. package/src/e2ee/sealedBody.ts +44 -5
  385. package/src/helpers/albumLayout.ts +207 -0
  386. package/src/helpers/attachments.ts +316 -0
  387. package/src/helpers/caption.ts +283 -0
  388. package/src/helpers/createMainMessageForThread.ts +6 -1
  389. package/src/helpers/createMessageFromXml.ts +21 -5
  390. package/src/helpers/fileKind.ts +38 -0
  391. package/src/helpers/getDataFromXml.ts +5 -1
  392. package/src/helpers/mapWithConcurrency.ts +32 -0
  393. package/src/helpers/mediaLimits.ts +27 -0
  394. package/src/helpers/mediaSendRetry.ts +59 -0
  395. package/src/helpers/mediaWireData.ts +57 -0
  396. package/src/helpers/mentionSpans.ts +17 -0
  397. package/src/helpers/mimeToExtension.ts +51 -0
  398. package/src/helpers/readReceipts.ts +219 -0
  399. package/src/helpers/repairFilenameEncoding.ts +82 -0
  400. package/src/helpers/safeJson.ts +11 -0
  401. package/src/helpers/secureStoreRuntime.ts +21 -3
  402. package/src/hooks/useSendMessage.tsx +448 -249
  403. package/src/i18n/strings.ts +96 -0
  404. package/src/main.ts +30 -0
  405. package/src/networking/api-requests/auth.api.ts +60 -3
  406. package/src/networking/api-requests/push.api.ts +29 -4
  407. package/src/networking/stanzaHandlers.ts +91 -2
  408. package/src/networking/xmpp/handleStanzas.xmpp.ts +6 -2
  409. package/src/networking/xmpp/sendDisplayedMarker.xmpp.ts +31 -0
  410. package/src/networking/xmpp/sendMediaMessage.xmpp.ts +60 -3
  411. package/src/networking/xmpp/sendReceivedReceipt.xmpp.ts +31 -0
  412. package/src/networking/xmppClient.ts +48 -0
  413. package/src/push/pushKeyStore.ts +163 -0
  414. package/src/push/sealedBox.ts +104 -0
  415. package/src/push/sealedPush.ts +127 -0
  416. package/src/push/sealedPushTask.ts +175 -0
  417. package/src/roomStore/persistence.ts +94 -3
  418. package/src/roomStore/roomHeapSlice.ts +23 -1
  419. package/src/roomStore/roomsSlice.ts +112 -1
  420. package/src/services/pushRegistration.ts +25 -5
  421. package/src/types/models/attachment.model.ts +51 -0
  422. package/src/types/models/message.model.ts +29 -0
  423. package/src/types/models/modal.model.ts +7 -0
  424. package/src/types/models/room.model.ts +2 -0
  425. package/src/types/types.ts +41 -1
  426. package/src/version.ts +1 -1
@@ -0,0 +1,245 @@
1
+ "use strict";
2
+
3
+ import { safeJsonParse } from './safeJson';
4
+ import { repairFilenameEncoding } from './repairFilenameEncoding';
5
+ import { inferMimeFromName, isGenericMime } from './mimeToExtension';
6
+
7
+ /** Parses a dimension that may arrive as a number or a numeric string. */
8
+ const parseDimension = value => {
9
+ const n = typeof value === 'string' ? Number.parseFloat(value) : value;
10
+ return typeof n === 'number' && Number.isFinite(n) && n > 0 ? n : undefined;
11
+ };
12
+
13
+ /**
14
+ * Hard ceiling on how many attachments we will serialise into a stanza.
15
+ * The composer caps the picker far below this; this is the parser-side
16
+ * guard so a malformed or hostile stanza cannot make us render an
17
+ * unbounded grid.
18
+ */
19
+ export const MAX_ATTACHMENTS_PER_MESSAGE = 10;
20
+ const asOptionalString = value => {
21
+ if (value === null || value === undefined) return undefined;
22
+ if (typeof value === 'string') return value || undefined;
23
+ if (typeof value === 'number') return String(value);
24
+ return undefined;
25
+ };
26
+
27
+ /** A file name from the wire/API, with UTF-8-read-as-Latin-1 mojibake undone. */
28
+ const asOptionalFileName = value => {
29
+ const name = asOptionalString(value);
30
+ return name === undefined ? undefined : repairFilenameEncoding(name);
31
+ };
32
+ const asOptionalBoolean = value => {
33
+ if (typeof value === 'boolean') return value;
34
+ if (value === 'true') return true;
35
+ if (value === 'false') return false;
36
+ return undefined;
37
+ };
38
+
39
+ /**
40
+ * Turns one raw wire/API object into an `IAttachment`, or null when there is
41
+ * nothing renderable in it. `location` is allowed to be empty: that is what
42
+ * an optimistic (still-uploading) attachment looks like.
43
+ */
44
+ export const normalizeAttachment = raw => {
45
+ if (!raw || typeof raw !== 'object') return null;
46
+ const source = raw;
47
+ const location = asOptionalString(source.location) ?? '';
48
+ const originalName = asOptionalFileName(source.originalName) ?? asOptionalFileName(source.originalname);
49
+ const rawMimetype = asOptionalString(source.mimetype);
50
+ const fileName = asOptionalFileName(source.fileName) ?? asOptionalFileName(source.filename);
51
+ const duration = asOptionalString(source.duration) ?? asOptionalString(source.mediaDuration);
52
+ const mimetype = resolveLegacyMimetype(rawMimetype, {
53
+ names: [originalName, fileName, urlPath(location)],
54
+ duration
55
+ });
56
+ if (!location && !originalName && !mimetype && !fileName) {
57
+ return null;
58
+ }
59
+ return {
60
+ attachmentId: asOptionalString(source.attachmentId) ?? asOptionalString(source._id),
61
+ location,
62
+ locationPreview: asOptionalString(source.locationPreview),
63
+ mimetype,
64
+ originalName,
65
+ fileName,
66
+ size: asOptionalString(source.size),
67
+ duration,
68
+ ...optionalDimensions(source),
69
+ ownerKey: asOptionalString(source.ownerKey),
70
+ userId: asOptionalString(source.userId),
71
+ createdAt: asOptionalString(source.createdAt),
72
+ updatedAt: asOptionalString(source.updatedAt),
73
+ expiresAt: asOptionalString(source.expiresAt),
74
+ isVisible: asOptionalBoolean(source.isVisible),
75
+ isPrivate: asOptionalBoolean(source.isPrivate),
76
+ ...normalizeUploadState(source)
77
+ };
78
+ };
79
+
80
+ /** The path part of a URL (no query or fragment), for reading an extension off it. */
81
+ const urlPath = url => url ? url.split(/[?#]/)[0] : undefined;
82
+
83
+ /**
84
+ * Older clients and the storage send media with no `mimetype`, or with the
85
+ * "could not sniff" `application/octet-stream`. The extension of any name the
86
+ * file carries tells which picture, video, audio or PDF it is. A nameless or
87
+ * extensionless file with a duration is a recorded voice note (browsers upload
88
+ * those as a `blob`), which is exactly what octet-stream renders as.
89
+ */
90
+ const resolveLegacyMimetype = (mimetype, hints) => {
91
+ if (!isGenericMime(mimetype)) return mimetype;
92
+ const hasDuration = Number.parseFloat(hints.duration ?? '') > 0;
93
+ // A recorded note keeps its generic type: browsers upload it as a nameless
94
+ // `blob` (and storage may add a `.webm` to the stored name, which is audio
95
+ // here, not video). Only a name that says what it is overrides that.
96
+ if (hasDuration && !inferMimeFromName(hints.names[0])) return mimetype ?? 'application/octet-stream';
97
+ for (const name of hints.names) {
98
+ const inferred = inferMimeFromName(name);
99
+ if (inferred) return inferred;
100
+ }
101
+ return mimetype;
102
+ };
103
+
104
+ /** Pixel size, only when the source carries a usable one. */
105
+ const optionalDimensions = source => {
106
+ const width = parseDimension(source.width);
107
+ const height = parseDimension(source.height);
108
+ return {
109
+ ...(width !== undefined ? {
110
+ width
111
+ } : {}),
112
+ ...(height !== undefined ? {
113
+ height
114
+ } : {})
115
+ };
116
+ };
117
+
118
+ /**
119
+ * Local upload state rides along on optimistic attachments only; it is
120
+ * never serialised, so a received attachment never carries it.
121
+ */
122
+ const normalizeUploadState = source => {
123
+ const status = source.uploadStatus === 'uploading' || source.uploadStatus === 'failed' ? source.uploadStatus : undefined;
124
+ if (!status) return {};
125
+ const progress = typeof source.uploadProgress === 'number' && Number.isFinite(source.uploadProgress) ? Math.min(100, Math.max(0, source.uploadProgress)) : 0;
126
+ // Only a file on this device can be the local preview of an outgoing file.
127
+ const localUrl = typeof source.localUrl === 'string' && /^(file|content):\/\//.test(source.localUrl) ? source.localUrl : undefined;
128
+ return {
129
+ uploadStatus: status,
130
+ uploadProgress: progress,
131
+ ...(localUrl ? {
132
+ localUrl
133
+ } : {})
134
+ };
135
+ };
136
+
137
+ /** Accepts the parsed array, the raw JSON string, or junk. Never throws. */
138
+ export const parseAttachments = raw => {
139
+ const candidate = typeof raw === 'string' ? safeJsonParse(raw, []) : raw;
140
+ if (!Array.isArray(candidate)) return [];
141
+ return candidate.slice(0, MAX_ATTACHMENTS_PER_MESSAGE).map(normalizeAttachment).filter(item => item !== null);
142
+ };
143
+
144
+ /**
145
+ * The wire form: a JSON string on the `<data attachments="...">` attribute.
146
+ * Only the fields a receiver renders are sent - the stanza is already wide
147
+ * and every byte here is duplicated per attachment.
148
+ */
149
+ export const serializeAttachments = attachments => JSON.stringify(attachments.slice(0, MAX_ATTACHMENTS_PER_MESSAGE).map(attachment => ({
150
+ attachmentId: attachment.attachmentId,
151
+ location: attachment.location,
152
+ locationPreview: attachment.locationPreview,
153
+ mimetype: attachment.mimetype,
154
+ originalName: attachment.originalName,
155
+ fileName: attachment.fileName,
156
+ size: attachment.size,
157
+ duration: attachment.duration
158
+ })));
159
+
160
+ /**
161
+ * The only supported way to read a media message's files.
162
+ *
163
+ * Order of truth: the multi-attach payload when present, otherwise the flat
164
+ * legacy fields synthesised into a single attachment. Every message that
165
+ * predates this feature - and every message from a client that does not
166
+ * speak it - takes the second path.
167
+ */
168
+ export const getMessageAttachments = message => {
169
+ if (!message) return [];
170
+ const parsed = parseAttachments(message.attachments);
171
+ if (parsed.length > 0) return parsed;
172
+
173
+ // Legacy clients may pack several files into the flat fields as a
174
+ // comma separated list of URLs; the other flat fields then list one value
175
+ // each, in the same order, or one value for all.
176
+ const locations = splitUrlList(message.location);
177
+ if (locations.length > 1) {
178
+ const previews = splitUrlList(message.locationPreview);
179
+ const mimetypes = splitList(message.mimetype);
180
+ const names = splitList(message.originalName);
181
+ return locations.slice(0, MAX_ATTACHMENTS_PER_MESSAGE).map((location, index) => normalizeAttachment({
182
+ location,
183
+ locationPreview: previews.length === locations.length ? previews[index] : undefined,
184
+ mimetype: pickNth(mimetypes, index, locations.length),
185
+ originalName: pickNth(names, index, locations.length),
186
+ size: undefined
187
+ })).filter(item => item !== null);
188
+ }
189
+ const legacy = normalizeAttachment({
190
+ location: message.location,
191
+ locationPreview: message.locationPreview,
192
+ mimetype: message.mimetype,
193
+ originalName: message.originalName,
194
+ fileName: message.fileName,
195
+ size: message.size,
196
+ duration: message.duration,
197
+ mediaDuration: message.mediaDuration
198
+ });
199
+ return legacy ? [legacy] : [];
200
+ };
201
+
202
+ /** "https://a/x.jpg, https://a/y.jpg" -> two URLs. A single URL stays whole, commas and all. */
203
+ 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] : [];
204
+ const splitList = value => typeof value === 'string' && value ? value.split(',').map(item => item.trim()) : [];
205
+
206
+ /** The nth entry of a parallel list, or its only entry when it is shared by all. */
207
+ const pickNth = (list, index, total) => list.length === total ? list[index] : list.length === 1 ? list[0] : undefined;
208
+
209
+ /**
210
+ * True when the message carries a file: flagged `isMediafile`, or (older
211
+ * senders that never set the flag) with a real file URL or attachment. The
212
+ * one test every surface uses for "is this a media bubble".
213
+ */
214
+ export const isMediaMessage = message => {
215
+ if (!message || message.isDeleted) return false;
216
+ if (String(message.isMediafile) === 'true') return true;
217
+ return getMessageAttachments(message).some(attachment => Boolean(attachment.location));
218
+ };
219
+
220
+ /**
221
+ * Maps one object from POST /files/ `results` to the attachment a sent
222
+ * message carries. Field names here follow the API's own spelling
223
+ * (`originalname`, `filename`), not the wire attribute names.
224
+ */
225
+ export const toUploadedAttachment = raw => ({
226
+ attachmentId: raw?._id,
227
+ location: raw?.location,
228
+ locationPreview: raw?.locationPreview,
229
+ mimetype: raw?.mimetype,
230
+ originalName: typeof raw?.originalname === 'string' ? repairFilenameEncoding(raw.originalname) : raw?.originalname,
231
+ fileName: typeof raw?.filename === 'string' ? repairFilenameEncoding(raw.filename) : raw?.filename,
232
+ size: raw?.size?.toString?.() ?? raw?.size,
233
+ duration: raw?.duration,
234
+ ownerKey: raw?.ownerKey,
235
+ userId: raw?.userId,
236
+ createdAt: raw?.createdAt,
237
+ updatedAt: raw?.updatedAt,
238
+ expiresAt: raw?.expiresAt,
239
+ isVisible: raw?.isVisible,
240
+ isPrivate: raw?.isPrivate
241
+ });
242
+
243
+ /** Name to show for an attachment, with the URL tail as the last resort. */
244
+ export const getAttachmentName = attachment => attachment.originalName || attachment.fileName || attachment.location?.split('/')?.pop() || 'MediaFile';
245
+ //# sourceMappingURL=attachments.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["safeJsonParse","repairFilenameEncoding","inferMimeFromName","isGenericMime","parseDimension","value","n","Number","parseFloat","isFinite","undefined","MAX_ATTACHMENTS_PER_MESSAGE","asOptionalString","String","asOptionalFileName","name","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","hasDuration","inferred","width","height","status","uploadStatus","progress","uploadProgress","Math","min","max","localUrl","test","parseAttachments","candidate","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,SAASA,aAAa,QAAQ,YAAY;AAC1C,SAASC,sBAAsB,QAAQ,0BAA0B;AACjE,SAASC,iBAAiB,EAAEC,aAAa,QAAQ,mBAAmB;;AAEpE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AQ,KAAmB;EAC9Dc,YAAY,EAAEd,GAAG,EAAEe,GAAG;EACtBb,QAAQ,EAAEF,GAAG,EAAEE,QAAQ;EACvBc,eAAe,EAAEhB,GAAG,EAAEgB,eAAe;EACrCV,QAAQ,EAAEN,GAAG,EAAEM,QAAQ;EACvBH,YAAY,EACV,OAAOH,GAAG,EAAEI,YAAY,KAAK,QAAQ,GACjCrB,sBAAsB,CAACiB,GAAG,CAACI,YAAY,CAAC,GACxCJ,GAAG,EAAEI,YAAY;EACvBG,QAAQ,EACN,OAAOP,GAAG,EAAEQ,QAAQ,KAAK,QAAQ,GAC7BzB,sBAAsB,CAACiB,GAAG,CAACQ,QAAQ,CAAC,GACpCR,GAAG,EAAEQ,QAAQ;EACnBS,IAAI,EAAEjB,GAAG,EAAEiB,IAAI,EAAE4D,QAAQ,GAAG,CAAC,IAAI7E,GAAG,EAAEiB,IAAI;EAC1CR,QAAQ,EAAET,GAAG,EAAES,QAAQ;EACvBU,QAAQ,EAAEnB,GAAG,EAAEmB,QAAQ;EACvBC,MAAM,EAAEpB,GAAG,EAAEoB,MAAM;EACnBC,SAAS,EAAErB,GAAG,EAAEqB,SAAS;EACzBC,SAAS,EAAEtB,GAAG,EAAEsB,SAAS;EACzBC,SAAS,EAAEvB,GAAG,EAAEuB,SAAS;EACzBC,SAAS,EAAExB,GAAG,EAAEwB,SAAS;EACzBC,SAAS,EAAEzB,GAAG,EAAEyB;AAClB,CAAC,CAAC;;AAEF;AACA,OAAO,MAAMqD,iBAAiB,GAAIvB,UAAuB,IACvDA,UAAU,CAACpD,YAAY,IACvBoD,UAAU,CAAChD,QAAQ,IACnBgD,UAAU,CAACrD,QAAQ,EAAE0B,KAAK,CAAC,GAAG,CAAC,EAAEmD,GAAG,CAAC,CAAC,IACtC,WAAW","ignoreList":[]}
@@ -0,0 +1,207 @@
1
+ "use strict";
2
+
3
+ import { safeJsonParse } from './safeJson';
4
+ import { validateMentionSpans } from './mentionSpans';
5
+ import { getAttachmentName, getMessageAttachments, isMediaMessage } from './attachments';
6
+
7
+ /**
8
+ * The text typed with a set of attachments, sent as part of the media
9
+ * message itself (never as a separate text stanza).
10
+ *
11
+ * `mentions` index into `text`, the same way a text message's mention spans
12
+ * index into its body.
13
+ */
14
+
15
+ const isSpanShape = value => {
16
+ if (!value || typeof value !== 'object') return false;
17
+ const span = value;
18
+ 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);
19
+ };
20
+
21
+ /**
22
+ * Mention spans for a caption, checked against the caption text: a span that
23
+ * no longer reads "@Name" at its offset is dropped. Undefined when nothing is
24
+ * left, so a caption without mentions carries no empty attribute.
25
+ */
26
+ export const normalizeCaptionMentions = (value, caption) => {
27
+ const parsed = typeof value === 'string' ? safeJsonParse(value, []) : value;
28
+ if (!Array.isArray(parsed)) return undefined;
29
+ const spans = validateMentionSpans(caption, parsed.filter(isSpanShape));
30
+ return spans.length > 0 ? spans : undefined;
31
+ };
32
+
33
+ /**
34
+ * Turns what the composer typed into the caption that travels with the
35
+ * media. Undefined for blank text, which means "no caption".
36
+ */
37
+ export const normalizeCaptionInput = input => {
38
+ const text = typeof input?.text === 'string' ? input.text : '';
39
+ if (!/\S/.test(text)) return undefined;
40
+ const mentions = normalizeCaptionMentions(input?.mentions, text);
41
+ return mentions ? {
42
+ caption: text,
43
+ mentions
44
+ } : {
45
+ caption: text
46
+ };
47
+ };
48
+
49
+ /** What a media message's text is, and the @-mention spans that index into it. */
50
+
51
+ /**
52
+ * Bodies that are not something a person typed: the media placeholder every
53
+ * SDK sends, and the labels apps generate for a file with nothing to say.
54
+ */
55
+ 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]']);
56
+
57
+ /** `<data>` attributes older or foreign clients stamp the file's text on. */
58
+ const CAPTION_ALIASES = ['captionText', 'text', 'message', 'description', 'title'];
59
+ const norm = value => typeof value === 'string' ? value.trim().toLowerCase() : '';
60
+ const str = value => typeof value === 'string' ? value : typeof value === 'number' ? String(value) : '';
61
+ const tail = url => {
62
+ const path = url.split(/[?#]/)[0];
63
+ return path.slice(path.lastIndexOf('/') + 1);
64
+ };
65
+ const safeDecode = value => {
66
+ try {
67
+ return decodeURIComponent(value);
68
+ } catch {
69
+ return value;
70
+ }
71
+ };
72
+
73
+ /** Every string a media message's `body` is allowed to merely repeat. */
74
+ const echoCandidates = (message, options) => {
75
+ const out = new Set();
76
+ const add = value => {
77
+ const v = norm(value);
78
+ if (v) out.add(v);
79
+ };
80
+
81
+ // The file itself: its names and its URLs, as sent and as stored.
82
+ const attachments = getMessageAttachments(message);
83
+ for (const attachment of attachments) {
84
+ add(getAttachmentName(attachment));
85
+ add(attachment.originalName);
86
+ add(attachment.fileName);
87
+ for (const url of [attachment.location, attachment.locationPreview]) {
88
+ if (!url) continue;
89
+ add(url);
90
+ add(safeDecode(url));
91
+ add(tail(url));
92
+ add(safeDecode(tail(url)));
93
+ }
94
+ }
95
+ add(message.originalName);
96
+ add(message.fileName);
97
+ add(message.location);
98
+ add(message.locationPreview);
99
+
100
+ // The sender: some clients put their own name, e-mail or username in the
101
+ // body next to the file.
102
+ const user = message.user ?? {};
103
+ const first = str(message.senderFirstName) || str(message.firstName) || str(user.firstName);
104
+ const last = str(message.senderLastName) || str(message.lastName) || str(user.lastName);
105
+ add(user.name);
106
+ add(`${first} ${last}`);
107
+ add(first && !last ? first : '');
108
+ add(user.email);
109
+ add(user.username);
110
+ add(message.email);
111
+ add(message.userName);
112
+ add(message.username);
113
+ add(message.senderName);
114
+ const idLocal = str(user.id).split('@')[0];
115
+ add(idLocal);
116
+ add(str(user.id).split('_').pop());
117
+ add(str(message.senderJID).split('/')[0].split('@')[0]);
118
+ for (const name of options.senderNames ?? []) add(name);
119
+ return out;
120
+ };
121
+
122
+ /** "etest etest" is echoed as "etest": every word of the name is the body. */
123
+ const isRepeatedName = (name, text) => Boolean(name && text) && name.split(/\s+/).every(part => part === text);
124
+ const isRealCaptionText = (text, message, options) => {
125
+ const t = text.trim();
126
+ if (!t) return false;
127
+ const n = t.toLowerCase();
128
+ if (PLACEHOLDER_BODIES.has(n)) return false;
129
+ // The key envelope a sealed message carries in its body is never text.
130
+ if (/^\{\s*"v"\s*:\s*\d+\s*,\s*"keys"/.test(t)) return false;
131
+ const candidates = echoCandidates(message, options);
132
+ if (candidates.has(n)) return false;
133
+ for (const name of candidates) if (isRepeatedName(name, n)) return false;
134
+ return true;
135
+ };
136
+ const asRecord = message => message && typeof message === 'object' ? message : undefined;
137
+ const resolveSpans = (message, text, keys) => {
138
+ for (const key of keys) {
139
+ const spans = normalizeCaptionMentions(message[key] ?? message.data?.[key], text);
140
+ if (spans) return spans;
141
+ }
142
+ return undefined;
143
+ };
144
+
145
+ /**
146
+ * The text of a media message, from whichever format carried it. The one
147
+ * place that knows the formats, so every surface (bubble, room list preview,
148
+ * notification, reply quote, copy) agrees:
149
+ *
150
+ * 1. `caption` (+ `captionMentions`): what this SDK sends. The only source
151
+ * for a sealed message, whose caption comes out of the envelope.
152
+ * 2. The caption under another name on `<data>` (`captionText`, `text`,
153
+ * `message`, `description`, `title`) from other clients.
154
+ * 3. A real `body`: older clients and other SDKs put the text in the
155
+ * `<body>` of the media message itself. "media", the file's name or URL,
156
+ * the sender's own name or e-mail and generated labels are not text.
157
+ *
158
+ * Never derived for a sealed message, and never for a message with no file.
159
+ */
160
+ export const resolveMessageCaption = (message, options = {}) => {
161
+ const source = asRecord(message);
162
+ if (!source || source.isDeleted) return undefined;
163
+ const explicit = source.caption;
164
+ if (typeof explicit === 'string' && /\S/.test(explicit)) {
165
+ const mentions = normalizeCaptionMentions(source.captionMentions, explicit);
166
+ return mentions ? {
167
+ text: explicit,
168
+ mentions
169
+ } : {
170
+ text: explicit
171
+ };
172
+ }
173
+ const sealed = options.sealed === true || source.clientEncrypted === 'true' || Array.isArray(source.e2eeKeys) && source.e2eeKeys.length > 0;
174
+ if (sealed) return undefined;
175
+ const isMedia = options.isMedia ?? isMediaMessage(source);
176
+ if (!isMedia) return undefined;
177
+ for (const key of CAPTION_ALIASES) {
178
+ const value = str(source[key] ?? source.data?.[key]);
179
+ if (value && isRealCaptionText(value, source, options)) {
180
+ const mentions = resolveSpans(source, value, ['captionMentions']);
181
+ return mentions ? {
182
+ text: value,
183
+ mentions
184
+ } : {
185
+ text: value
186
+ };
187
+ }
188
+ }
189
+ const body = str(source.body);
190
+ if (body && isRealCaptionText(body, source, options)) {
191
+ const mentions = resolveSpans(source, body, ['mentions']);
192
+ return mentions ? {
193
+ text: body,
194
+ mentions
195
+ } : {
196
+ text: body
197
+ };
198
+ }
199
+ return undefined;
200
+ };
201
+
202
+ /** The caption a message carries, or undefined when it has none. */
203
+ export const getMessageCaption = (message, options) => resolveMessageCaption(message, options)?.text;
204
+
205
+ /** The mention spans of `getMessageCaption`'s text. */
206
+ export const getMessageCaptionMentions = (message, options) => resolveMessageCaption(message, options)?.mentions;
207
+ //# sourceMappingURL=caption.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["safeJsonParse","validateMentionSpans","getAttachmentName","getMessageAttachments","isMediaMessage","isSpanShape","value","span","jid","name","offset","Number","isInteger","length","normalizeCaptionMentions","caption","parsed","Array","isArray","undefined","spans","filter","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","attachment","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","body","getMessageCaption","getMessageCaptionMentions"],"sourceRoot":"../../../src","sources":["helpers/caption.ts"],"mappings":";;AACA,SAASA,aAAa,QAAQ,YAAY;AAC1C,SAASC,oBAAoB,QAAQ,gBAAgB;AACrD,SAASC,iBAAiB,EAAEC,qBAAqB,EAAEC,cAAc,QAAQ,eAAe;;AAExF;AACA;AACA;AACA;AACA;AACA;AACA;;AAWA,MAAMC,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;AACA,OAAO,MAAMC,wBAAwB,GAAGA,CACtCR,KAAc,EACdS,OAAe,KACgB;EAC/B,MAAMC,MAAM,GACV,OAAOV,KAAK,KAAK,QAAQ,GAAGN,aAAa,CAAUM,KAAK,EAAE,EAAE,CAAC,GAAGA,KAAK;EACvE,IAAI,CAACW,KAAK,CAACC,OAAO,CAACF,MAAM,CAAC,EAAE,OAAOG,SAAS;EAC5C,MAAMC,KAAK,GAAGnB,oBAAoB,CAACc,OAAO,EAAEC,MAAM,CAACK,MAAM,CAAChB,WAAW,CAAC,CAAC;EACvE,OAAOe,KAAK,CAACP,MAAM,GAAG,CAAC,GAAGO,KAAK,GAAGD,SAAS;AAC7C,CAAC;;AAED;AACA;AACA;AACA;AACA,OAAO,MAAMG,qBAAqB,GAChCC,KAA2B,IACO;EAClC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,OAAO,CAAC,EAAEnB,QAAQ","ignoreList":[]}
@@ -1,8 +1,12 @@
1
1
  "use strict";
2
2
 
3
+ import { getMessageCaption } from './caption';
3
4
  export const createMainMessageForThread = message => {
5
+ // A media message is quoted by its caption. A sealed one never is: the
6
+ // reply stanza travels in the clear, the caption does not.
7
+ const caption = message.clientEncrypted === 'true' ? undefined : getMessageCaption(message);
4
8
  const data = {
5
- text: message.body,
9
+ text: caption ?? message.body,
6
10
  id: message.id,
7
11
  userName: message.user.name,
8
12
  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"],"sourceRoot":"../../../src","sources":["helpers/createMainMessageForThread.ts"],"mappings":";;AAEA,OAAO,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","ignoreList":[]}
1
+ {"version":3,"names":["getMessageCaption","createMainMessageForThread","message","caption","clientEncrypted","undefined","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"],"sourceRoot":"../../../src","sources":["helpers/createMainMessageForThread.ts"],"mappings":";;AACA,SAASA,iBAAiB,QAAQ,WAAW;AAE7C,OAAO,MAAMC,0BAA0B,GAAIC,OAAiB,IAAa;EACvE;EACA;EACA,MAAMC,OAAO,GACXD,OAAO,CAACE,eAAe,KAAK,MAAM,GAAGC,SAAS,GAAGL,iBAAiB,CAACE,OAAO,CAAC;EAC7E,MAAMI,IAAI,GAAG;IACXC,IAAI,EAAEJ,OAAO,IAAID,OAAO,CAACM,IAAI;IAC7BC,EAAE,EAAEP,OAAO,CAACO,EAAE;IACdC,QAAQ,EAAER,OAAO,CAACS,IAAI,CAACC,IAAI;IAC3BC,SAAS,EAAEX,OAAO,CAACY,IAAI;IACvBC,aAAa,EAAEb,OAAO,CAACc,QAAQ;IAC/BC,YAAY,EAAEf,OAAO,CAACgB,eAAe;IACrCC,QAAQ,EAAEjB,OAAO,CAACkB,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,EAAE1B,OAAO,CAAC0B,OAAO;IACxBC,KAAK,EAAE;EACT,CAAC;EACD,OAAOC,IAAI,CAACC,SAAS,CAACzB,IAAI,CAAC;AAC7B,CAAC","ignoreList":[]}
@@ -2,7 +2,8 @@
2
2
 
3
3
  import { isE2eeRoom } from '../e2ee';
4
4
  import { composeName } from './displayName';
5
- import { parseSealedMediaBody } from '../e2ee/sealedBody';
5
+ import { parseSealedMediaPayload } from '../e2ee/sealedBody';
6
+ import { normalizeMediaDataAttrs } from './mediaWireData';
6
7
  /**
7
8
  * Build an IMessage from XML.
8
9
  *
@@ -59,7 +60,9 @@ export const createMessageFromXml = async (arg, bodyEl, positionalId, positional
59
60
  delete outerExtras.data;
60
61
  }
61
62
  const merged = {
62
- ...inner,
63
+ // Idempotent: the wrapped path already ran it in getDataFromXml, the
64
+ // positional (MAM catch-up) path hands over the raw attrs.
65
+ ...normalizeMediaDataAttrs(inner),
63
66
  ...outerExtras,
64
67
  isDeleted: !!outerExtras?.deleted || !!arg?.isDeleted
65
68
  };
@@ -110,15 +113,26 @@ export const createMessageFromXml = async (arg, bodyEl, positionalId, positional
110
113
  const existingName = String(merged?.user?.name || '').trim();
111
114
  const resolvedName = existingName || composed || fullName || senderLocal || merged?.user?.id || '';
112
115
  const unencrypted = merged.omemoEncrypted !== 'true' && isE2eeRoom(String(merged.roomJid || ''));
113
- const sealedKeys = merged.clientEncrypted === 'true' ? parseSealedMediaBody(merged.body) : undefined;
116
+
117
+ // A sealed media body is `{v:1,keys,caption?,captionMentions?}`. The keys
118
+ // and the caption are lifted next to each other; the caption is the only
119
+ // one a sealed message may show (any open caption attribute was dropped
120
+ // by normalizeMediaDataAttrs).
121
+ const sealed = merged.clientEncrypted === 'true' ? parseSealedMediaPayload(merged.body) : undefined;
114
122
  const message = {
115
123
  ...merged,
116
124
  ...(unencrypted ? {
117
125
  unencrypted: true
118
126
  } : {}),
119
- ...(sealedKeys ? {
120
- e2eeKeys: sealedKeys,
121
- body: 'media'
127
+ ...(sealed ? {
128
+ e2eeKeys: sealed.keys,
129
+ body: 'media',
130
+ ...(sealed.caption ? {
131
+ caption: sealed.caption
132
+ } : {}),
133
+ ...(sealed.captionMentions ? {
134
+ captionMentions: sealed.captionMentions
135
+ } : {})
122
136
  } : {}),
123
137
  user: {
124
138
  ...(merged.user || {}),
@@ -1 +1 @@
1
- {"version":3,"names":["isE2eeRoom","composeName","parseSealedMediaBody","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","existingName","resolvedName","unencrypted","omemoEncrypted","sealedKeys","clientEncrypted","message","e2eeKeys"],"sourceRoot":"../../../src","sources":["helpers/createMessageFromXml.ts"],"mappings":";;AACA,SAASA,UAAU,QAAQ,SAAS;AACpC,SAASC,WAAW,QAAQ,eAAe;AAC3C,SAASC,oBAAoB,QAAQ,oBAAoB;AAMzD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,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,OAA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F,CAAC;EAED,OAAOkB,OAAO;AAChB,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["isE2eeRoom","composeName","parseSealedMediaPayload","normalizeMediaDataAttrs","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","existingName","resolvedName","unencrypted","omemoEncrypted","sealed","clientEncrypted","message","e2eeKeys","keys","caption","captionMentions"],"sourceRoot":"../../../src","sources":["helpers/createMessageFromXml.ts"],"mappings":";;AACA,SAASA,UAAU,QAAQ,SAAS;AACpC,SAASC,WAAW,QAAQ,eAAe;AAC3C,SAASC,uBAAuB,QAAQ,oBAAoB;AAC5D,SAASC,uBAAuB,QAAQ,iBAAiB;AAMzD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,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,IAA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tD,IAAIL,MAAM,CAACM,eAAe,GACtB;QAAEA,eAAe,EAAEN,MAAM,CAACM;MAAgB,CAAC,GAC3C,CAAC,CAAC;IACR,CAAC,GACD,CAAC,CAAC,CAAC;IACPjD,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,EAAEuC,YAAY;MAClBjB,SAAS,EAAEA,SAAS,IAAIT,MAAM,EAAEd,IAAI,EAAEuB,SAAS;MAC/CI,QAAQ,EAAEA,QAAQ,IAAIb,MAAM,EAAEd,IAAI,EAAE2B;IACtC;EACF,CAAC;EAED,OAAOkB,OAAO;AAChB,CAAC","ignoreList":[]}
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+
3
+ import { filenameFromUrl, isLikelyAudio } from './mimeToExtension';
4
+ /**
5
+ * Which card a file gets in a bubble. Mirrors the branches MediaMessage has
6
+ * always used for a single file (image, video, audio, octet-stream as a voice
7
+ * note, then the voice-message heuristics) so an album, a card stack and a
8
+ * lone file all agree on what a given file is.
9
+ */
10
+ export const getFileKind = input => {
11
+ const mime = (input.mimetype || '').toLowerCase();
12
+ if (mime.startsWith('image/')) {
13
+ return 'image';
14
+ }
15
+ if (mime.startsWith('video/')) {
16
+ return 'video';
17
+ }
18
+ if (mime.startsWith('audio/')) {
19
+ return 'audio';
20
+ }
21
+ if (mime.includes('application/octet-stream')) {
22
+ return 'audio';
23
+ }
24
+ const name = input.name || filenameFromUrl(input.url);
25
+ return isLikelyAudio(mime, name, input.url, {
26
+ duration: input.duration,
27
+ waveForm: input.waveForm,
28
+ originalName: input.originalName
29
+ }) ? 'audio' : 'file';
30
+ };
31
+
32
+ /** True for the kinds that sit in the picture/video album. */
33
+ export const isAlbumKind = kind => kind === 'image' || kind === 'video';
34
+ //# sourceMappingURL=fileKind.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["filenameFromUrl","isLikelyAudio","getFileKind","input","mime","mimetype","toLowerCase","startsWith","includes","name","url","duration","waveForm","originalName","isAlbumKind","kind"],"sourceRoot":"../../../src","sources":["helpers/fileKind.ts"],"mappings":";;AAAA,SAASA,eAAe,EAAEC,aAAa,QAAQ,mBAAmB;AAalE;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,WAAW,GAAIC,KAAoB,IAAe;EAC7D,MAAMC,IAAI,GAAG,CAACD,KAAK,CAACE,QAAQ,IAAI,EAAE,EAAEC,WAAW,CAAC,CAAC;EACjD,IAAIF,IAAI,CAACG,UAAU,CAAC,QAAQ,CAAC,EAAE;IAAC,OAAO,OAAO;EAAC;EAC/C,IAAIH,IAAI,CAACG,UAAU,CAAC,QAAQ,CAAC,EAAE;IAAC,OAAO,OAAO;EAAC;EAC/C,IAAIH,IAAI,CAACG,UAAU,CAAC,QAAQ,CAAC,EAAE;IAAC,OAAO,OAAO;EAAC;EAC/C,IAAIH,IAAI,CAACI,QAAQ,CAAC,0BAA0B,CAAC,EAAE;IAAC,OAAO,OAAO;EAAC;EAC/D,MAAMC,IAAI,GAAGN,KAAK,CAACM,IAAI,IAAIT,eAAe,CAACG,KAAK,CAACO,GAAG,CAAC;EACrD,OAAOT,aAAa,CAACG,IAAI,EAAEK,IAAI,EAAEN,KAAK,CAACO,GAAG,EAAE;IAC1CC,QAAQ,EAAER,KAAK,CAACQ,QAAQ;IACxBC,QAAQ,EAAET,KAAK,CAACS,QAAQ;IACxBC,YAAY,EAAEV,KAAK,CAACU;EACtB,CAAC,CAAC,GACE,OAAO,GACP,MAAM;AACZ,CAAC;;AAED;AACA,OAAO,MAAMC,WAAW,GAAIC,IAAc,IACxCA,IAAI,KAAK,OAAO,IAAIA,IAAI,KAAK,OAAO","ignoreList":[]}