@ethora/chat-component-rn 26.10.4 → 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.
- package/CHANGELOG.md +8 -0
- package/README.md +15 -0
- package/app.plugin.js +2 -0
- package/lib/commonjs/assets/icons.js +2 -2
- package/lib/commonjs/assets/icons.js.map +1 -1
- package/lib/commonjs/components/MainComponents/AlbumGrid.js +152 -0
- package/lib/commonjs/components/MainComponents/AlbumGrid.js.map +1 -0
- package/lib/commonjs/components/MainComponents/ChatRoom.js +2 -2
- package/lib/commonjs/components/MainComponents/ChatRoom.js.map +1 -1
- package/lib/commonjs/components/MainComponents/MediaMessage.js +199 -123
- package/lib/commonjs/components/MainComponents/MediaMessage.js.map +1 -1
- package/lib/commonjs/components/MainComponents/MediaUploadOverlay.js +109 -0
- package/lib/commonjs/components/MainComponents/MediaUploadOverlay.js.map +1 -0
- package/lib/commonjs/components/MessageBubble/MediaCaption.js +51 -0
- package/lib/commonjs/components/MessageBubble/MediaCaption.js.map +1 -0
- package/lib/commonjs/components/MessageBubble/Message.js +40 -1
- package/lib/commonjs/components/MessageBubble/Message.js.map +1 -1
- package/lib/commonjs/components/MessageBubble/MessageInteractions.js +2 -1
- package/lib/commonjs/components/MessageBubble/MessageInteractions.js.map +1 -1
- package/lib/commonjs/components/Modals/FilePreviewModal/FilePreviewModal.js +75 -0
- package/lib/commonjs/components/Modals/FilePreviewModal/FilePreviewModal.js.map +1 -1
- package/lib/commonjs/components/RoomComponents/LastMessageItem.js +20 -4
- package/lib/commonjs/components/RoomComponents/LastMessageItem.js.map +1 -1
- package/lib/commonjs/components/RoomComponents/styled/LastAudioMessage.js +3 -2
- package/lib/commonjs/components/RoomComponents/styled/LastAudioMessage.js.map +1 -1
- package/lib/commonjs/components/RoomComponents/styled/LastMessageFile.js +3 -2
- package/lib/commonjs/components/RoomComponents/styled/LastMessageFile.js.map +1 -1
- package/lib/commonjs/components/RoomComponents/styled/LastMessagePhoto.js +3 -2
- package/lib/commonjs/components/RoomComponents/styled/LastMessagePhoto.js.map +1 -1
- package/lib/commonjs/components/RoomComponents/styled/LastMessageVideo.js +3 -2
- package/lib/commonjs/components/RoomComponents/styled/LastMessageVideo.js.map +1 -1
- package/lib/commonjs/components/Thread/ThreadWrapper.js +3 -2
- package/lib/commonjs/components/Thread/ThreadWrapper.js.map +1 -1
- package/lib/commonjs/components/VideoCalls/ActiveCallBar.js +61 -16
- package/lib/commonjs/components/VideoCalls/ActiveCallBar.js.map +1 -1
- package/lib/commonjs/components/VideoCalls/CallIcons.js +41 -16
- package/lib/commonjs/components/VideoCalls/CallIcons.js.map +1 -1
- package/lib/commonjs/components/VideoCalls/VideoCallOverlay.js +183 -9
- package/lib/commonjs/components/VideoCalls/VideoCallOverlay.js.map +1 -1
- package/lib/commonjs/components/VideoCalls/VideoCallSession.js +40 -15
- package/lib/commonjs/components/VideoCalls/VideoCallSession.js.map +1 -1
- package/lib/commonjs/components/VideoCalls/callSessionController.js +49 -26
- package/lib/commonjs/components/VideoCalls/callSessionController.js.map +1 -1
- package/lib/commonjs/components/VideoCalls/callUiStore.js +33 -4
- package/lib/commonjs/components/VideoCalls/callUiStore.js.map +1 -1
- package/lib/commonjs/components/VideoCalls/livekitRuntime.js +9 -1
- package/lib/commonjs/components/VideoCalls/livekitRuntime.js.map +1 -1
- package/lib/commonjs/components/VideoCalls/useCallKeep.js +197 -28
- package/lib/commonjs/components/VideoCalls/useCallKeep.js.map +1 -1
- package/lib/commonjs/components/VideoCalls/useOngoingCallNotification.js +88 -0
- package/lib/commonjs/components/VideoCalls/useOngoingCallNotification.js.map +1 -0
- package/lib/commonjs/components/VideoCalls/usePipTile.js +232 -0
- package/lib/commonjs/components/VideoCalls/usePipTile.js.map +1 -0
- package/lib/commonjs/components/styled/MediaFilePreview.js +60 -47
- package/lib/commonjs/components/styled/MediaFilePreview.js.map +1 -1
- package/lib/commonjs/components/styled/MessageImage.js +16 -6
- package/lib/commonjs/components/styled/MessageImage.js.map +1 -1
- package/lib/commonjs/components/styled/SendInput.js +99 -68
- package/lib/commonjs/components/styled/SendInput.js.map +1 -1
- package/lib/commonjs/components/styled/VideoMessage.js +24 -10
- package/lib/commonjs/components/styled/VideoMessage.js.map +1 -1
- package/lib/commonjs/context/xmppProvider.js +46 -0
- package/lib/commonjs/context/xmppProvider.js.map +1 -1
- package/lib/commonjs/e2ee/fileEnvelope.js +6 -0
- package/lib/commonjs/e2ee/fileEnvelope.js.map +1 -1
- package/lib/commonjs/e2ee/sealedBody.js +32 -2
- package/lib/commonjs/e2ee/sealedBody.js.map +1 -1
- package/lib/commonjs/helpers/albumLayout.js +150 -0
- package/lib/commonjs/helpers/albumLayout.js.map +1 -0
- package/lib/commonjs/helpers/attachments.js +255 -0
- package/lib/commonjs/helpers/attachments.js.map +1 -0
- package/lib/commonjs/helpers/caption.js +214 -0
- package/lib/commonjs/helpers/caption.js.map +1 -0
- package/lib/commonjs/helpers/createMainMessageForThread.js +5 -1
- package/lib/commonjs/helpers/createMainMessageForThread.js.map +1 -1
- package/lib/commonjs/helpers/createMessageFromXml.js +19 -5
- package/lib/commonjs/helpers/createMessageFromXml.js.map +1 -1
- package/lib/commonjs/helpers/fileKind.js +40 -0
- package/lib/commonjs/helpers/fileKind.js.map +1 -0
- package/lib/commonjs/helpers/getDataFromXml.js +6 -1
- package/lib/commonjs/helpers/getDataFromXml.js.map +1 -1
- package/lib/commonjs/helpers/mapWithConcurrency.js +41 -0
- package/lib/commonjs/helpers/mapWithConcurrency.js.map +1 -0
- package/lib/commonjs/helpers/mediaLimits.js +33 -0
- package/lib/commonjs/helpers/mediaLimits.js.map +1 -0
- package/lib/commonjs/helpers/mediaSendRetry.js +64 -0
- package/lib/commonjs/helpers/mediaSendRetry.js.map +1 -0
- package/lib/commonjs/helpers/mediaWireData.js +62 -0
- package/lib/commonjs/helpers/mediaWireData.js.map +1 -0
- package/lib/commonjs/helpers/mentionSpans.js +19 -0
- package/lib/commonjs/helpers/mentionSpans.js.map +1 -0
- package/lib/commonjs/helpers/mimeToExtension.js +45 -0
- package/lib/commonjs/helpers/mimeToExtension.js.map +1 -1
- package/lib/commonjs/helpers/readReceipts.js +173 -0
- package/lib/commonjs/helpers/readReceipts.js.map +1 -0
- package/lib/commonjs/helpers/repairFilenameEncoding.js +79 -0
- package/lib/commonjs/helpers/repairFilenameEncoding.js.map +1 -0
- package/lib/commonjs/helpers/safeJson.js +18 -0
- package/lib/commonjs/helpers/safeJson.js.map +1 -0
- package/lib/commonjs/helpers/updateMessagesTillLast.js +3 -1
- package/lib/commonjs/helpers/updateMessagesTillLast.js.map +1 -1
- package/lib/commonjs/hooks/useSendMessage.js +384 -193
- package/lib/commonjs/hooks/useSendMessage.js.map +1 -1
- package/lib/commonjs/i18n/strings.js +144 -0
- package/lib/commonjs/i18n/strings.js.map +1 -1
- package/lib/commonjs/main.js.map +1 -1
- package/lib/commonjs/networking/api-requests/auth.api.js +62 -3
- package/lib/commonjs/networking/api-requests/auth.api.js.map +1 -1
- package/lib/commonjs/networking/stanzaHandlers.js +100 -3
- package/lib/commonjs/networking/stanzaHandlers.js.map +1 -1
- package/lib/commonjs/networking/xmpp/handleStanzas.xmpp.js +4 -2
- package/lib/commonjs/networking/xmpp/handleStanzas.xmpp.js.map +1 -1
- package/lib/commonjs/networking/xmpp/sendDisplayedMarker.xmpp.js +28 -0
- package/lib/commonjs/networking/xmpp/sendDisplayedMarker.xmpp.js.map +1 -0
- package/lib/commonjs/networking/xmpp/sendMediaMessage.xmpp.js +53 -2
- package/lib/commonjs/networking/xmpp/sendMediaMessage.xmpp.js.map +1 -1
- package/lib/commonjs/networking/xmpp/sendReceivedReceipt.xmpp.js +28 -0
- package/lib/commonjs/networking/xmpp/sendReceivedReceipt.xmpp.js.map +1 -0
- package/lib/commonjs/networking/xmppClient.js +64 -0
- package/lib/commonjs/networking/xmppClient.js.map +1 -1
- package/lib/commonjs/roomStore/persistence.js +78 -5
- package/lib/commonjs/roomStore/persistence.js.map +1 -1
- package/lib/commonjs/roomStore/roomHeapSlice.js +4 -0
- package/lib/commonjs/roomStore/roomHeapSlice.js.map +1 -1
- package/lib/commonjs/roomStore/roomsSlice.js +114 -1
- package/lib/commonjs/roomStore/roomsSlice.js.map +1 -1
- package/lib/commonjs/types/models/attachment.model.js +2 -0
- package/lib/commonjs/types/models/attachment.model.js.map +1 -0
- package/lib/commonjs/version.js +1 -1
- package/lib/module/assets/icons.js +1 -1
- package/lib/module/assets/icons.js.map +1 -1
- package/lib/module/components/MainComponents/AlbumGrid.js +146 -0
- package/lib/module/components/MainComponents/AlbumGrid.js.map +1 -0
- package/lib/module/components/MainComponents/ChatRoom.js +2 -2
- package/lib/module/components/MainComponents/ChatRoom.js.map +1 -1
- package/lib/module/components/MainComponents/MediaMessage.js +200 -124
- package/lib/module/components/MainComponents/MediaMessage.js.map +1 -1
- package/lib/module/components/MainComponents/MediaUploadOverlay.js +104 -0
- package/lib/module/components/MainComponents/MediaUploadOverlay.js.map +1 -0
- package/lib/module/components/MessageBubble/MediaCaption.js +46 -0
- package/lib/module/components/MessageBubble/MediaCaption.js.map +1 -0
- package/lib/module/components/MessageBubble/Message.js +44 -5
- package/lib/module/components/MessageBubble/Message.js.map +1 -1
- package/lib/module/components/MessageBubble/MessageInteractions.js +2 -1
- package/lib/module/components/MessageBubble/MessageInteractions.js.map +1 -1
- package/lib/module/components/Modals/FilePreviewModal/FilePreviewModal.js +75 -0
- package/lib/module/components/Modals/FilePreviewModal/FilePreviewModal.js.map +1 -1
- package/lib/module/components/RoomComponents/LastMessageItem.js +20 -4
- package/lib/module/components/RoomComponents/LastMessageItem.js.map +1 -1
- package/lib/module/components/RoomComponents/styled/LastAudioMessage.js +3 -2
- package/lib/module/components/RoomComponents/styled/LastAudioMessage.js.map +1 -1
- package/lib/module/components/RoomComponents/styled/LastMessageFile.js +3 -2
- package/lib/module/components/RoomComponents/styled/LastMessageFile.js.map +1 -1
- package/lib/module/components/RoomComponents/styled/LastMessagePhoto.js +3 -2
- package/lib/module/components/RoomComponents/styled/LastMessagePhoto.js.map +1 -1
- package/lib/module/components/RoomComponents/styled/LastMessageVideo.js +3 -2
- package/lib/module/components/RoomComponents/styled/LastMessageVideo.js.map +1 -1
- package/lib/module/components/Thread/ThreadWrapper.js +3 -2
- package/lib/module/components/Thread/ThreadWrapper.js.map +1 -1
- package/lib/module/components/VideoCalls/ActiveCallBar.js +63 -18
- package/lib/module/components/VideoCalls/ActiveCallBar.js.map +1 -1
- package/lib/module/components/VideoCalls/CallIcons.js +38 -15
- package/lib/module/components/VideoCalls/CallIcons.js.map +1 -1
- package/lib/module/components/VideoCalls/VideoCallOverlay.js +185 -11
- package/lib/module/components/VideoCalls/VideoCallOverlay.js.map +1 -1
- package/lib/module/components/VideoCalls/VideoCallSession.js +41 -16
- package/lib/module/components/VideoCalls/VideoCallSession.js.map +1 -1
- package/lib/module/components/VideoCalls/callSessionController.js +46 -24
- package/lib/module/components/VideoCalls/callSessionController.js.map +1 -1
- package/lib/module/components/VideoCalls/callUiStore.js +30 -3
- package/lib/module/components/VideoCalls/callUiStore.js.map +1 -1
- package/lib/module/components/VideoCalls/livekitRuntime.js +9 -1
- package/lib/module/components/VideoCalls/livekitRuntime.js.map +1 -1
- package/lib/module/components/VideoCalls/useCallKeep.js +198 -29
- package/lib/module/components/VideoCalls/useCallKeep.js.map +1 -1
- package/lib/module/components/VideoCalls/useOngoingCallNotification.js +84 -0
- package/lib/module/components/VideoCalls/useOngoingCallNotification.js.map +1 -0
- package/lib/module/components/VideoCalls/usePipTile.js +228 -0
- package/lib/module/components/VideoCalls/usePipTile.js.map +1 -0
- package/lib/module/components/styled/MediaFilePreview.js +61 -48
- package/lib/module/components/styled/MediaFilePreview.js.map +1 -1
- package/lib/module/components/styled/MessageImage.js +16 -6
- package/lib/module/components/styled/MessageImage.js.map +1 -1
- package/lib/module/components/styled/SendInput.js +99 -68
- package/lib/module/components/styled/SendInput.js.map +1 -1
- package/lib/module/components/styled/VideoMessage.js +24 -10
- package/lib/module/components/styled/VideoMessage.js.map +1 -1
- package/lib/module/context/xmppProvider.js +46 -0
- package/lib/module/context/xmppProvider.js.map +1 -1
- package/lib/module/e2ee/fileEnvelope.js +1 -1
- package/lib/module/e2ee/fileEnvelope.js.map +1 -1
- package/lib/module/e2ee/sealedBody.js +32 -2
- package/lib/module/e2ee/sealedBody.js.map +1 -1
- package/lib/module/helpers/albumLayout.js +143 -0
- package/lib/module/helpers/albumLayout.js.map +1 -0
- package/lib/module/helpers/attachments.js +245 -0
- package/lib/module/helpers/attachments.js.map +1 -0
- package/lib/module/helpers/caption.js +207 -0
- package/lib/module/helpers/caption.js.map +1 -0
- package/lib/module/helpers/createMainMessageForThread.js +5 -1
- package/lib/module/helpers/createMainMessageForThread.js.map +1 -1
- package/lib/module/helpers/createMessageFromXml.js +20 -6
- package/lib/module/helpers/createMessageFromXml.js.map +1 -1
- package/lib/module/helpers/fileKind.js +34 -0
- package/lib/module/helpers/fileKind.js.map +1 -0
- package/lib/module/helpers/getDataFromXml.js +6 -1
- package/lib/module/helpers/getDataFromXml.js.map +1 -1
- package/lib/module/helpers/mapWithConcurrency.js +37 -0
- package/lib/module/helpers/mapWithConcurrency.js.map +1 -0
- package/lib/module/helpers/mediaLimits.js +27 -0
- package/lib/module/helpers/mediaLimits.js.map +1 -0
- package/lib/module/helpers/mediaSendRetry.js +55 -0
- package/lib/module/helpers/mediaSendRetry.js.map +1 -0
- package/lib/module/helpers/mediaWireData.js +58 -0
- package/lib/module/helpers/mediaWireData.js.map +1 -0
- package/lib/module/helpers/mentionSpans.js +14 -0
- package/lib/module/helpers/mentionSpans.js.map +1 -0
- package/lib/module/helpers/mimeToExtension.js +43 -0
- package/lib/module/helpers/mimeToExtension.js.map +1 -1
- package/lib/module/helpers/readReceipts.js +160 -0
- package/lib/module/helpers/readReceipts.js.map +1 -0
- package/lib/module/helpers/repairFilenameEncoding.js +74 -0
- package/lib/module/helpers/repairFilenameEncoding.js.map +1 -0
- package/lib/module/helpers/safeJson.js +13 -0
- package/lib/module/helpers/safeJson.js.map +1 -0
- package/lib/module/helpers/updateMessagesTillLast.js +3 -1
- package/lib/module/helpers/updateMessagesTillLast.js.map +1 -1
- package/lib/module/hooks/useSendMessage.js +387 -195
- package/lib/module/hooks/useSendMessage.js.map +1 -1
- package/lib/module/i18n/strings.js +144 -0
- package/lib/module/i18n/strings.js.map +1 -1
- package/lib/module/main.js.map +1 -1
- package/lib/module/networking/api-requests/auth.api.js +62 -3
- package/lib/module/networking/api-requests/auth.api.js.map +1 -1
- package/lib/module/networking/stanzaHandlers.js +97 -4
- package/lib/module/networking/stanzaHandlers.js.map +1 -1
- package/lib/module/networking/xmpp/handleStanzas.xmpp.js +5 -3
- package/lib/module/networking/xmpp/handleStanzas.xmpp.js.map +1 -1
- package/lib/module/networking/xmpp/sendDisplayedMarker.xmpp.js +25 -0
- package/lib/module/networking/xmpp/sendDisplayedMarker.xmpp.js.map +1 -0
- package/lib/module/networking/xmpp/sendMediaMessage.xmpp.js +53 -2
- package/lib/module/networking/xmpp/sendMediaMessage.xmpp.js.map +1 -1
- package/lib/module/networking/xmpp/sendReceivedReceipt.xmpp.js +25 -0
- package/lib/module/networking/xmpp/sendReceivedReceipt.xmpp.js.map +1 -0
- package/lib/module/networking/xmppClient.js +64 -0
- package/lib/module/networking/xmppClient.js.map +1 -1
- package/lib/module/roomStore/persistence.js +78 -5
- package/lib/module/roomStore/persistence.js.map +1 -1
- package/lib/module/roomStore/roomHeapSlice.js +4 -0
- package/lib/module/roomStore/roomHeapSlice.js.map +1 -1
- package/lib/module/roomStore/roomsSlice.js +109 -0
- package/lib/module/roomStore/roomsSlice.js.map +1 -1
- package/lib/module/types/models/attachment.model.js +2 -0
- package/lib/module/types/models/attachment.model.js.map +1 -0
- package/lib/module/version.js +1 -1
- package/lib/typescript/assets/icons.d.ts +6 -1
- package/lib/typescript/assets/icons.d.ts.map +1 -1
- package/lib/typescript/components/MainComponents/AlbumGrid.d.ts +21 -0
- package/lib/typescript/components/MainComponents/AlbumGrid.d.ts.map +1 -0
- package/lib/typescript/components/MainComponents/ChatRoom.d.ts.map +1 -1
- package/lib/typescript/components/MainComponents/MediaMessage.d.ts.map +1 -1
- package/lib/typescript/components/MainComponents/MediaUploadOverlay.d.ts +17 -0
- package/lib/typescript/components/MainComponents/MediaUploadOverlay.d.ts.map +1 -0
- package/lib/typescript/components/MessageBubble/MediaCaption.d.ts +12 -0
- package/lib/typescript/components/MessageBubble/MediaCaption.d.ts.map +1 -0
- package/lib/typescript/components/MessageBubble/Message.d.ts.map +1 -1
- package/lib/typescript/components/MessageBubble/MessageInteractions.d.ts.map +1 -1
- package/lib/typescript/components/Modals/FilePreviewModal/FilePreviewModal.d.ts.map +1 -1
- package/lib/typescript/components/RoomComponents/LastMessageItem.d.ts.map +1 -1
- package/lib/typescript/components/RoomComponents/styled/LastAudioMessage.d.ts +2 -0
- package/lib/typescript/components/RoomComponents/styled/LastAudioMessage.d.ts.map +1 -1
- package/lib/typescript/components/RoomComponents/styled/LastMessageFile.d.ts +2 -0
- package/lib/typescript/components/RoomComponents/styled/LastMessageFile.d.ts.map +1 -1
- package/lib/typescript/components/RoomComponents/styled/LastMessagePhoto.d.ts +2 -0
- package/lib/typescript/components/RoomComponents/styled/LastMessagePhoto.d.ts.map +1 -1
- package/lib/typescript/components/RoomComponents/styled/LastMessageVideo.d.ts +2 -0
- package/lib/typescript/components/RoomComponents/styled/LastMessageVideo.d.ts.map +1 -1
- package/lib/typescript/components/Thread/ThreadWrapper.d.ts.map +1 -1
- package/lib/typescript/components/VideoCalls/ActiveCallBar.d.ts +9 -3
- package/lib/typescript/components/VideoCalls/ActiveCallBar.d.ts.map +1 -1
- package/lib/typescript/components/VideoCalls/CallIcons.d.ts +9 -0
- package/lib/typescript/components/VideoCalls/CallIcons.d.ts.map +1 -1
- package/lib/typescript/components/VideoCalls/VideoCallOverlay.d.ts.map +1 -1
- package/lib/typescript/components/VideoCalls/VideoCallSession.d.ts.map +1 -1
- package/lib/typescript/components/VideoCalls/callSessionController.d.ts +7 -0
- package/lib/typescript/components/VideoCalls/callSessionController.d.ts.map +1 -1
- package/lib/typescript/components/VideoCalls/callUiStore.d.ts +13 -0
- package/lib/typescript/components/VideoCalls/callUiStore.d.ts.map +1 -1
- package/lib/typescript/components/VideoCalls/livekitRuntime.d.ts +5 -0
- package/lib/typescript/components/VideoCalls/livekitRuntime.d.ts.map +1 -1
- package/lib/typescript/components/VideoCalls/useCallKeep.d.ts +12 -0
- package/lib/typescript/components/VideoCalls/useCallKeep.d.ts.map +1 -1
- package/lib/typescript/components/VideoCalls/useOngoingCallNotification.d.ts +10 -0
- package/lib/typescript/components/VideoCalls/useOngoingCallNotification.d.ts.map +1 -0
- package/lib/typescript/components/VideoCalls/usePipTile.d.ts +46 -0
- package/lib/typescript/components/VideoCalls/usePipTile.d.ts.map +1 -0
- package/lib/typescript/components/styled/MediaFilePreview.d.ts.map +1 -1
- package/lib/typescript/components/styled/MessageImage.d.ts +10 -0
- package/lib/typescript/components/styled/MessageImage.d.ts.map +1 -1
- package/lib/typescript/components/styled/SendInput.d.ts +7 -1
- package/lib/typescript/components/styled/SendInput.d.ts.map +1 -1
- package/lib/typescript/components/styled/VideoMessage.d.ts +7 -0
- package/lib/typescript/components/styled/VideoMessage.d.ts.map +1 -1
- package/lib/typescript/context/xmppProvider.d.ts.map +1 -1
- package/lib/typescript/e2ee/fileEnvelope.d.ts +1 -1
- package/lib/typescript/e2ee/fileEnvelope.d.ts.map +1 -1
- package/lib/typescript/e2ee/sealedBody.d.ts +16 -0
- package/lib/typescript/e2ee/sealedBody.d.ts.map +1 -1
- package/lib/typescript/helpers/albumLayout.d.ts +66 -0
- package/lib/typescript/helpers/albumLayout.d.ts.map +1 -0
- package/lib/typescript/helpers/attachments.d.ts +55 -0
- package/lib/typescript/helpers/attachments.d.ts.map +1 -0
- package/lib/typescript/helpers/caption.d.ts +64 -0
- package/lib/typescript/helpers/caption.d.ts.map +1 -0
- package/lib/typescript/helpers/createMainMessageForThread.d.ts.map +1 -1
- package/lib/typescript/helpers/createMessageFromXml.d.ts.map +1 -1
- package/lib/typescript/helpers/fileKind.d.ts +20 -0
- package/lib/typescript/helpers/fileKind.d.ts.map +1 -0
- package/lib/typescript/helpers/getDataFromXml.d.ts.map +1 -1
- package/lib/typescript/helpers/mapWithConcurrency.d.ts +9 -0
- package/lib/typescript/helpers/mapWithConcurrency.d.ts.map +1 -0
- package/lib/typescript/helpers/mediaLimits.d.ts +13 -0
- package/lib/typescript/helpers/mediaLimits.d.ts.map +1 -0
- package/lib/typescript/helpers/mediaSendRetry.d.ts +26 -0
- package/lib/typescript/helpers/mediaSendRetry.d.ts.map +1 -0
- package/lib/typescript/helpers/mediaWireData.d.ts +16 -0
- package/lib/typescript/helpers/mediaWireData.d.ts.map +1 -0
- package/lib/typescript/helpers/mentionSpans.d.ts +8 -0
- package/lib/typescript/helpers/mentionSpans.d.ts.map +1 -0
- package/lib/typescript/helpers/mimeToExtension.d.ts +7 -0
- package/lib/typescript/helpers/mimeToExtension.d.ts.map +1 -1
- package/lib/typescript/helpers/readReceipts.d.ts +82 -0
- package/lib/typescript/helpers/readReceipts.d.ts.map +1 -0
- package/lib/typescript/helpers/repairFilenameEncoding.d.ts +12 -0
- package/lib/typescript/helpers/repairFilenameEncoding.d.ts.map +1 -0
- package/lib/typescript/helpers/safeJson.d.ts +2 -0
- package/lib/typescript/helpers/safeJson.d.ts.map +1 -0
- package/lib/typescript/helpers/updateMessagesTillLast.d.ts.map +1 -1
- package/lib/typescript/hooks/useSendMessage.d.ts +2 -1
- package/lib/typescript/hooks/useSendMessage.d.ts.map +1 -1
- package/lib/typescript/i18n/strings.d.ts.map +1 -1
- package/lib/typescript/main.d.ts +1 -1
- package/lib/typescript/main.d.ts.map +1 -1
- package/lib/typescript/networking/api-requests/auth.api.d.ts +2 -0
- package/lib/typescript/networking/api-requests/auth.api.d.ts.map +1 -1
- package/lib/typescript/networking/stanzaHandlers.d.ts +7 -3
- package/lib/typescript/networking/stanzaHandlers.d.ts.map +1 -1
- package/lib/typescript/networking/xmpp/handleStanzas.xmpp.d.ts.map +1 -1
- package/lib/typescript/networking/xmpp/sendDisplayedMarker.xmpp.d.ts +3 -0
- package/lib/typescript/networking/xmpp/sendDisplayedMarker.xmpp.d.ts.map +1 -0
- package/lib/typescript/networking/xmpp/sendMediaMessage.xmpp.d.ts +12 -0
- package/lib/typescript/networking/xmpp/sendMediaMessage.xmpp.d.ts.map +1 -1
- package/lib/typescript/networking/xmpp/sendReceivedReceipt.xmpp.d.ts +3 -0
- package/lib/typescript/networking/xmpp/sendReceivedReceipt.xmpp.d.ts.map +1 -0
- package/lib/typescript/networking/xmppClient.d.ts +15 -0
- package/lib/typescript/networking/xmppClient.d.ts.map +1 -1
- package/lib/typescript/roomStore/persistence.d.ts.map +1 -1
- package/lib/typescript/roomStore/roomHeapSlice.d.ts +22 -1
- package/lib/typescript/roomStore/roomHeapSlice.d.ts.map +1 -1
- package/lib/typescript/roomStore/roomsSlice.d.ts +67 -3
- package/lib/typescript/roomStore/roomsSlice.d.ts.map +1 -1
- package/lib/typescript/types/models/attachment.model.d.ts +52 -0
- package/lib/typescript/types/models/attachment.model.d.ts.map +1 -0
- package/lib/typescript/types/models/message.model.d.ts +26 -0
- package/lib/typescript/types/models/message.model.d.ts.map +1 -1
- package/lib/typescript/types/models/modal.model.d.ts +7 -0
- package/lib/typescript/types/models/modal.model.d.ts.map +1 -1
- package/lib/typescript/types/models/room.model.d.ts +2 -0
- package/lib/typescript/types/models/room.model.d.ts.map +1 -1
- package/lib/typescript/types/types.d.ts +69 -1
- package/lib/typescript/types/types.d.ts.map +1 -1
- package/lib/typescript/version.d.ts +1 -1
- package/package.json +4 -1
- package/plugins/notification-service/Info.plist +31 -0
- package/plugins/notification-service/NotificationService.swift +82 -0
- package/plugins/withNotificationServiceExtension.js +137 -0
- package/src/assets/icons.tsx +20 -2
- package/src/components/MainComponents/AlbumGrid.tsx +183 -0
- package/src/components/MainComponents/ChatRoom.tsx +4 -2
- package/src/components/MainComponents/MediaMessage.tsx +246 -130
- package/src/components/MainComponents/MediaUploadOverlay.tsx +102 -0
- package/src/components/MessageBubble/MediaCaption.tsx +45 -0
- package/src/components/MessageBubble/Message.tsx +71 -3
- package/src/components/MessageBubble/MessageInteractions.tsx +2 -1
- package/src/components/Modals/FilePreviewModal/FilePreviewModal.tsx +64 -0
- package/src/components/RoomComponents/LastMessageItem.tsx +15 -4
- package/src/components/RoomComponents/styled/LastAudioMessage.tsx +6 -3
- package/src/components/RoomComponents/styled/LastMessageFile.tsx +6 -2
- package/src/components/RoomComponents/styled/LastMessagePhoto.tsx +6 -2
- package/src/components/RoomComponents/styled/LastMessageVideo.tsx +6 -2
- package/src/components/Thread/ThreadWrapper.tsx +5 -9
- package/src/components/VideoCalls/ActiveCallBar.tsx +56 -10
- package/src/components/VideoCalls/CallIcons.tsx +36 -12
- package/src/components/VideoCalls/VideoCallOverlay.tsx +205 -8
- package/src/components/VideoCalls/VideoCallSession.tsx +45 -13
- package/src/components/VideoCalls/callSessionController.ts +51 -20
- package/src/components/VideoCalls/callUiStore.ts +33 -3
- package/src/components/VideoCalls/livekitRuntime.ts +13 -0
- package/src/components/VideoCalls/useCallKeep.ts +204 -33
- package/src/components/VideoCalls/useOngoingCallNotification.ts +113 -0
- package/src/components/VideoCalls/usePipTile.ts +214 -0
- package/src/components/styled/MediaFilePreview.tsx +49 -34
- package/src/components/styled/MessageImage.tsx +21 -5
- package/src/components/styled/SendInput.tsx +101 -87
- package/src/components/styled/VideoMessage.tsx +34 -9
- package/src/context/xmppProvider.tsx +32 -0
- package/src/e2ee/fileEnvelope.ts +1 -1
- package/src/e2ee/sealedBody.ts +44 -5
- package/src/helpers/albumLayout.ts +207 -0
- package/src/helpers/attachments.ts +316 -0
- package/src/helpers/caption.ts +283 -0
- package/src/helpers/createMainMessageForThread.ts +6 -1
- package/src/helpers/createMessageFromXml.ts +21 -5
- package/src/helpers/fileKind.ts +38 -0
- package/src/helpers/getDataFromXml.ts +5 -1
- package/src/helpers/mapWithConcurrency.ts +32 -0
- package/src/helpers/mediaLimits.ts +27 -0
- package/src/helpers/mediaSendRetry.ts +59 -0
- package/src/helpers/mediaWireData.ts +57 -0
- package/src/helpers/mentionSpans.ts +17 -0
- package/src/helpers/mimeToExtension.ts +51 -0
- package/src/helpers/readReceipts.ts +219 -0
- package/src/helpers/repairFilenameEncoding.ts +82 -0
- package/src/helpers/safeJson.ts +11 -0
- package/src/helpers/updateMessagesTillLast.tsx +2 -1
- package/src/hooks/useSendMessage.tsx +448 -249
- package/src/i18n/strings.ts +144 -0
- package/src/main.ts +3 -0
- package/src/networking/api-requests/auth.api.ts +60 -3
- package/src/networking/stanzaHandlers.ts +91 -2
- package/src/networking/xmpp/handleStanzas.xmpp.ts +6 -2
- package/src/networking/xmpp/sendDisplayedMarker.xmpp.ts +31 -0
- package/src/networking/xmpp/sendMediaMessage.xmpp.ts +60 -3
- package/src/networking/xmpp/sendReceivedReceipt.xmpp.ts +31 -0
- package/src/networking/xmppClient.ts +48 -0
- package/src/roomStore/persistence.ts +94 -3
- package/src/roomStore/roomHeapSlice.ts +23 -1
- package/src/roomStore/roomsSlice.ts +112 -1
- package/src/types/models/attachment.model.ts +51 -0
- package/src/types/models/message.model.ts +29 -0
- package/src/types/models/modal.model.ts +7 -0
- package/src/types/models/room.model.ts +2 -0
- package/src/types/types.ts +83 -1
- package/src/version.ts +1 -1
- package/lib/commonjs/components/VideoCalls/useDraggable.js +0 -59
- package/lib/commonjs/components/VideoCalls/useDraggable.js.map +0 -1
- package/lib/module/components/VideoCalls/useDraggable.js +0 -55
- package/lib/module/components/VideoCalls/useDraggable.js.map +0 -1
- package/lib/typescript/components/VideoCalls/useDraggable.d.ts +0 -19
- package/lib/typescript/components/VideoCalls/useDraggable.d.ts.map +0 -1
- package/src/components/VideoCalls/useDraggable.ts +0 -46
|
@@ -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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E;IAAS,CAAC,GAAG;MAAEF,IAAI,EAAEsE;IAAK,CAAC;EAC7D;EACA,OAAO3E,SAAS;AAClB,CAAC;;AAED;AACA,OAAO,MAAM4E,iBAAiB,GAAGA,CAC/BnD,OAAuB,EACvBC,OAAwB,KACDwC,qBAAqB,CAACzC,OAAO,EAAEC,OAAO,CAAC,EAAErB,IAAI;;AAEtE;AACA,OAAO,MAAMwE,yBAAyB,GAAGA,CACvCpD,OAAuB,EACvBC,OAAwB,KACOwC,qBAAqB,CAACzC,OAAO,EAAEC,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":";;
|
|
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 {
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
...(
|
|
120
|
-
e2eeKeys:
|
|
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","
|
|
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,IAAIC,WAAgB,GAAG,CAAC,CAAC;EAEzB,IAAIH,YAAY,EAAE;IAChBE,K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ACM;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":[]}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { transformArrayToObject } from './transformTranslatations';
|
|
4
4
|
import { normalizeXmppUsername } from './xmppUsername';
|
|
5
|
+
import { normalizeMediaDataAttrs } from './mediaWireData';
|
|
5
6
|
const getLocalpartFromJid = jid => {
|
|
6
7
|
const value = String(jid || '').trim();
|
|
7
8
|
if (!value) {
|
|
@@ -74,7 +75,11 @@ export const getDataFromXml = async stanza => {
|
|
|
74
75
|
id: userWallet,
|
|
75
76
|
photoURL
|
|
76
77
|
};
|
|
77
|
-
|
|
78
|
+
|
|
79
|
+
// `attachments` and `caption` ride on <data> as strings; decode them here
|
|
80
|
+
// so every consumer sees the typed values (sealed captions are lifted from
|
|
81
|
+
// the encrypted body later, see createMessageFromXml).
|
|
82
|
+
const dataAttrs = normalizeMediaDataAttrs(data?.attrs || {});
|
|
78
83
|
return {
|
|
79
84
|
data: dataAttrs,
|
|
80
85
|
id,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["transformArrayToObject","normalizeXmppUsername","getLocalpartFromJid","jid","value","String","trim","undefined","split","safeJsonParse","fallback","JSON","parse","normalizeTranslations","Array","isArray","filter","item","translatedText","language","languageName","extractTimestamp","str","stanza","console","log","toString","timestamp","slice","getDataFromXml","fullData","getChild","xmppId","attrs","id","xmppFrom","from","roomJid","userWalletFromResource","Date","now","body","getText","deleted","translationPayload","translations","translates","langSource","source","numericPart","exec","date","toISOString","data","photoURL","photo","rawUserWallet","senderJID","userWallet","user","dataAttrs"],"sourceRoot":"../../../src","sources":["helpers/getDataFromXml.ts"],"mappings":";;AAEA,SAASA,sBAAsB,QAAQ,2BAA2B;AAClE,SAASC,qBAAqB,QAAQ,gBAAgB;
|
|
1
|
+
{"version":3,"names":["transformArrayToObject","normalizeXmppUsername","normalizeMediaDataAttrs","getLocalpartFromJid","jid","value","String","trim","undefined","split","safeJsonParse","fallback","JSON","parse","normalizeTranslations","Array","isArray","filter","item","translatedText","language","languageName","extractTimestamp","str","stanza","console","log","toString","timestamp","slice","getDataFromXml","fullData","getChild","xmppId","attrs","id","xmppFrom","from","roomJid","userWalletFromResource","Date","now","body","getText","deleted","translationPayload","translations","translates","langSource","source","numericPart","exec","date","toISOString","data","photoURL","photo","rawUserWallet","senderJID","userWallet","user","dataAttrs"],"sourceRoot":"../../../src","sources":["helpers/getDataFromXml.ts"],"mappings":";;AAEA,SAASA,sBAAsB,QAAQ,2BAA2B;AAClE,SAASC,qBAAqB,QAAQ,gBAAgB;AACtD,SAASC,uBAAuB,QAAQ,iBAAiB;AAEzD,MAAMC,mBAAmB,GAAIC,GAAY,IAAyB;EAChE,MAAMC,KAAK,GAAGC,MAAM,CAACF,GAAG,IAAI,EAAE,CAAC,CAACG,IAAI,CAAC,CAAC;EACtC,IAAI,CAACF,KAAK,EAAE;IAAC,OAAOG,SAAS;EAAC;EAC9B,OAAOH,KAAK,CAACI,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAID,SAAS;AACzC,CAAC;;AAED;AACA;AACA;AACA,MAAME,aAAa,GAAGA,CAAKL,KAAc,EAAEM,QAAW,KAAQ;EAC5D,IAAI,OAAON,KAAK,KAAK,QAAQ,IAAI,CAACA,KAAK,EAAE;IAAC,OAAOM,QAAQ;EAAC;EAC1D,IAAI;IACF,OAAOC,IAAI,CAACC,KAAK,CAACR,KAAK,CAAC;EAC1B,CAAC,CAAC,MAAM;IACN,OAAOM,QAAQ;EACjB;AACF,CAAC;;AAED;AACA;AACA,MAAMG,qBAAqB,GAAIT,KAAc,IAC3CU,KAAK,CAACC,OAAO,CAACX,KAAK,CAAC,GAChBA,KAAK,CAACY,MAAM,CAERC,IAAI,IAMJ,CAAC,CAACA,IAAI,IACN,OAAOA,IAAI,KAAK,QAAQ,IACxB,OAAQA,IAAI,CAAS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C3ClD,SAAS;EACX,MAAMmD,UAAU,GAAG1D,qBAAqB,CAACwD,aAAa,CAAC,IAAIA,aAAa;EAExE,MAAMG,IAAI,GAAG;IACXzB,EAAE,EAAEwB,UAAU;IACdJ;EACF,CAAQ;;EAER;EACA;EACA;EACA,MAAMM,SAAS,GAAG3D,uBAAuB,CAACoD,IAAI,EAAEpB,KAAK,IAAI,CAAC,CAAC,CAAC;EAE5D,OAAO;IACLoB,IAAI,EAAEO,SAAS;IACf1B,EAAE;IACFO,IAAI;IACJJ,OAAO;IACPc,IAAI;IACJQ,IAAI;IACJhB,OAAO;IACPE,YAAY;IACZE,UAAU;IACVf,MAAM;IACNG;EACF,CAAC;AACH,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Runs `worker` over `items` with at most `limit` calls in flight, and
|
|
5
|
+
* resolves with the results in INPUT order, whatever order the calls finish
|
|
6
|
+
* in. Workers that throw are reported as rejected entries instead of
|
|
7
|
+
* aborting the rest of the batch, so one failed upload never stops its
|
|
8
|
+
* siblings.
|
|
9
|
+
*/
|
|
10
|
+
export async function mapWithConcurrency(items, limit, worker) {
|
|
11
|
+
const results = new Array(items.length);
|
|
12
|
+
const width = Math.max(1, Math.min(Math.floor(limit) || 1, items.length));
|
|
13
|
+
let next = 0;
|
|
14
|
+
const lane = async () => {
|
|
15
|
+
while (next < items.length) {
|
|
16
|
+
const index = next;
|
|
17
|
+
next += 1;
|
|
18
|
+
try {
|
|
19
|
+
const value = await worker(items[index], index);
|
|
20
|
+
results[index] = {
|
|
21
|
+
status: 'fulfilled',
|
|
22
|
+
value
|
|
23
|
+
};
|
|
24
|
+
} catch (reason) {
|
|
25
|
+
results[index] = {
|
|
26
|
+
status: 'rejected',
|
|
27
|
+
reason
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
await Promise.all(Array.from({
|
|
33
|
+
length: width
|
|
34
|
+
}, () => lane()));
|
|
35
|
+
return results;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=mapWithConcurrency.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["mapWithConcurrency","items","limit","worker","results","Array","length","width","Math","max","min","floor","next","lane","index","value","status","reason","Promise","all","from"],"sourceRoot":"../../../src","sources":["helpers/mapWithConcurrency.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeA,kBAAkBA,CACtCC,KAAmB,EACnBC,KAAa,EACbC,MAA8C,EACV;EACpC,MAAMC,OAAkC,GAAG,IAAIC,KAAK,CAACJ,KAAK,CAACK,MAAM,CAAC;EAClE,MAAMC,KAAK,GAAGC,IAAI,CAACC,GAAG,CAAC,CAAC,EAAED,IAAI,CAACE,GAAG,CAACF,IAAI,CAACG,KAAK,CAACT,KAAK,CAAC,IAAI,CAAC,EAAED,KAAK,CAACK,MAAM,CAAC,CAAC;EACzE,IAAIM,IAAI,GAAG,CAAC;EAEZ,MAAMC,IAAI,GAAG,MAAAA,CAAA,KAA2B;IACtC,OAAOD,IAAI,GAAGX,KAAK,CAACK,MAAM,EAAE;MAC1B,MAAMQ,KAAK,GAAGF,IAAI;MAClBA,IAAI,IAAI,CAAC;MACT,IAAI;QACF,MAAMG,KAAK,GAAG,MAAMZ,MAAM,CAACF,KAAK,CAACa,KAAK,CAAC,EAAGA,KAAK,CAAC;QAChDV,OAAO,CAACU,KAAK,CAAC,GAAG;UAAEE,MAAM,EAAE,WAAW;UAAED;QAAM,CAAC;MACjD,CAAC,CAAC,OAAOE,MAAM,EAAE;QACfb,OAAO,CAACU,KAAK,CAAC,GAAG;UAAEE,MAAM,EAAE,UAAU;UAAEC;QAAO,CAAC;MACjD;IACF;EACF,CAAC;EAED,MAAMC,OAAO,CAACC,GAAG,CAACd,KAAK,CAACe,IAAI,CAAC;IAAEd,MAAM,EAAEC;EAAM,CAAC,EAAE,MAAMM,IAAI,CAAC,CAAC,CAAC,CAAC;EAC9D,OAAOT,OAAO;AAChB","ignoreList":[]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/** Hard client-side cap on a single upload. Mirrors the backend's body limit. */
|
|
4
|
+
export const MAX_MEDIA_BYTES = 50 * 1024 * 1024;
|
|
5
|
+
|
|
6
|
+
/** The most files one message may carry (also the parser-side ceiling). */
|
|
7
|
+
export const MAX_MEDIA_FILES = 10;
|
|
8
|
+
|
|
9
|
+
/** Files per message the host allows: `attachments.maxFiles`, clamped to 1-10. */
|
|
10
|
+
export const mediaFileCap = config => {
|
|
11
|
+
const configured = Number(config?.attachments?.maxFiles);
|
|
12
|
+
if (!Number.isFinite(configured)) {
|
|
13
|
+
return MAX_MEDIA_FILES;
|
|
14
|
+
}
|
|
15
|
+
return Math.min(MAX_MEDIA_FILES, Math.max(1, Math.floor(configured)));
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Bytes allowed per file: the 50 MB upload cap, lowered by
|
|
20
|
+
* `attachments.maxSizeMB` when the host sets a smaller one.
|
|
21
|
+
*/
|
|
22
|
+
export const mediaSizeLimit = (config, override) => {
|
|
23
|
+
const base = typeof override === 'number' && override > 0 ? Math.min(override, MAX_MEDIA_BYTES) : MAX_MEDIA_BYTES;
|
|
24
|
+
const mb = Number(config?.attachments?.maxSizeMB);
|
|
25
|
+
return Number.isFinite(mb) && mb > 0 ? Math.min(base, mb * 1024 * 1024) : base;
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=mediaLimits.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["MAX_MEDIA_BYTES","MAX_MEDIA_FILES","mediaFileCap","config","configured","Number","attachments","maxFiles","isFinite","Math","min","max","floor","mediaSizeLimit","override","base","mb","maxSizeMB"],"sourceRoot":"../../../src","sources":["helpers/mediaLimits.ts"],"mappings":";;AAEA;AACA,OAAO,MAAMA,eAAe,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI;;AAE/C;AACA,OAAO,MAAMC,eAAe,GAAG,EAAE;;AAEjC;AACA,OAAO,MAAMC,YAAY,GAAIC,MAA4C,IAAa;EACpF,MAAMC,UAAU,GAAGC,MAAM,CAACF,MAAM,EAAEG,WAAW,EAAEC,QAAQ,CAAC;EACxD,IAAI,CAACF,MAAM,CAACG,QAAQ,CAACJ,UAAU,CAAC,EAAE;IAAC,OAAOH,eAAe;EAAC;EAC1D,OAAOQ,IAAI,CAACC,GAAG,CAACT,eAAe,EAAEQ,IAAI,CAACE,GAAG,CAAC,CAAC,EAAEF,IAAI,CAACG,KAAK,CAACR,UAAU,CAAC,CAAC,CAAC;AACvE,CAAC;;AAED;AACA;AACA;AACA;AACA,OAAO,MAAMS,cAAc,GAAGA,CAC5BV,MAA4C,EAC5CW,QAAiB,KACN;EACX,MAAMC,IAAI,GAAG,OAAOD,QAAQ,KAAK,QAAQ,IAAIA,QAAQ,GAAG,CAAC,GAAGL,IAAI,CAACC,GAAG,CAACI,QAAQ,EAAEd,eAAe,CAAC,GAAGA,eAAe;EACjH,MAAMgB,EAAE,GAAGX,MAAM,CAACF,MAAM,EAAEG,WAAW,EAAEW,SAAS,CAAC;EACjD,OAAOZ,MAAM,CAACG,QAAQ,CAACQ,EAAE,CAAC,IAAIA,EAAE,GAAG,CAAC,GAAGP,IAAI,CAACC,GAAG,CAACK,IAAI,EAAEC,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC,GAAGD,IAAI;AAChF,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Retry hooks for media messages whose uploads did not all land.
|
|
5
|
+
*
|
|
6
|
+
* The send closure lives inside useSendMessage, but the bubble that shows
|
|
7
|
+
* "Retry" on a tile is somewhere else in the tree and has no access to it.
|
|
8
|
+
* The send registers its retry runner under the message id while the
|
|
9
|
+
* message is unsent, and the bubble looks it up here. The runner is removed
|
|
10
|
+
* as soon as the message is delivered.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
const runners = new Map();
|
|
14
|
+
export const registerMediaRetry = (messageId, runner) => {
|
|
15
|
+
runners.set(messageId, runner);
|
|
16
|
+
};
|
|
17
|
+
export const unregisterMediaRetry = messageId => {
|
|
18
|
+
runners.delete(messageId);
|
|
19
|
+
};
|
|
20
|
+
export const hasMediaRetry = messageId => runners.has(messageId);
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Re-runs the uploads still missing for `messageId` (only `index` / `indices`
|
|
24
|
+
* when given), then sends the message once every file is in. Resolves to
|
|
25
|
+
* false when nothing is registered or the attempt did not deliver.
|
|
26
|
+
*/
|
|
27
|
+
export const retryMediaSend = async (messageId, index) => {
|
|
28
|
+
const runner = runners.get(messageId);
|
|
29
|
+
if (!runner) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
const indices = index === undefined ? undefined : Array.isArray(index) ? index : [index];
|
|
33
|
+
return runner(indices);
|
|
34
|
+
};
|
|
35
|
+
const pendingRetryIndices = new Map();
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Asks for one file of `messageId` to be retried. Requests made in the same
|
|
39
|
+
* tick are merged into one run: the runner takes a single run at a time, so
|
|
40
|
+
* a separate call per tile would drop every retry after the first.
|
|
41
|
+
*/
|
|
42
|
+
export const requestMediaRetry = (messageId, index) => {
|
|
43
|
+
const batch = pendingRetryIndices.get(messageId);
|
|
44
|
+
if (batch) {
|
|
45
|
+
batch.add(index);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
const next = new Set([index]);
|
|
49
|
+
pendingRetryIndices.set(messageId, next);
|
|
50
|
+
queueMicrotask(() => {
|
|
51
|
+
pendingRetryIndices.delete(messageId);
|
|
52
|
+
retryMediaSend(messageId, [...next]).catch(() => false);
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
//# sourceMappingURL=mediaSendRetry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["runners","Map","registerMediaRetry","messageId","runner","set","unregisterMediaRetry","delete","hasMediaRetry","has","retryMediaSend","index","get","indices","undefined","Array","isArray","pendingRetryIndices","requestMediaRetry","batch","add","next","Set","queueMicrotask","catch"],"sourceRoot":"../../../src","sources":["helpers/mediaSendRetry.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,MAAMA,OAAO,GAAG,IAAIC,GAAG,CAA2B,CAAC;AAEnD,OAAO,MAAMC,kBAAkB,GAAGA,CAACC,SAAiB,EAAEC,MAAwB,KAAW;EACvFJ,OAAO,CAACK,GAAG,CAACF,SAAS,EAAEC,MAAM,CAAC;AAChC,CAAC;AAED,OAAO,MAAME,oBAAoB,GAAIH,SAAiB,IAAW;EAC/DH,OAAO,CAACO,MAAM,CAACJ,SAAS,CAAC;AAC3B,CAAC;AAED,OAAO,MAAMK,aAAa,GAAIL,SAAiB,IAAcH,OAAO,CAACS,GAAG,CAACN,SAAS,CAAC;;AAEnF;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMO,cAAc,GAAG,MAAAA,CAC5BP,SAAiB,EACjBQ,KAAyB,KACJ;EACrB,MAAMP,MAAM,GAAGJ,OAAO,CAACY,GAAG,CAACT,SAAS,CAAC;EACrC,IAAI,CAACC,MAAM,EAAE;IAAC,OAAO,KAAK;EAAC;EAC3B,MAAMS,OAAO,GAAGF,KAAK,KAAKG,SAAS,GAAGA,SAAS,GAAGC,KAAK,CAACC,OAAO,CAACL,KAAK,CAAC,GAAGA,KAAK,GAAG,CAACA,KAAK,CAAC;EACxF,OAAOP,MAAM,CAACS,OAAO,CAAC;AACxB,CAAC;AAED,MAAMI,mBAAmB,GAAG,IAAIhB,GAAG,CAAsB,CAAC;;AAE1D;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMiB,iBAAiB,GAAGA,CAACf,SAAiB,EAAEQ,KAAa,KAAW;EAC3E,MAAMQ,KAAK,GAAGF,mBAAmB,CAACL,GAAG,CAACT,SAAS,CAAC;EAChD,IAAIgB,KAAK,EAAE;IACTA,KAAK,CAACC,GAAG,CAACT,KAAK,CAAC;IAChB;EACF;EACA,MAAMU,IAAI,GAAG,IAAIC,GAAG,CAAS,CAACX,KAAK,CAAC,CAAC;EACrCM,mBAAmB,CAACZ,GAAG,CAACF,SAAS,EAAEkB,IAAI,CAAC;EACxCE,cAAc,CAAC,MAAM;IACnBN,mBAAmB,CAACV,MAAM,CAACJ,SAAS,CAAC;IACrCO,cAAc,CAACP,SAAS,EAAE,CAAC,GAAGkB,IAAI,CAAC,CAAC,CAACG,KAAK,CAAC,MAAM,KAAK,CAAC;EACzD,CAAC,CAAC;AACJ,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { parseAttachments } from './attachments';
|
|
4
|
+
import { getMessageCaption, normalizeCaptionMentions } from './caption';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Normalises the media parts of a message's flat `<data>` attributes:
|
|
8
|
+
*
|
|
9
|
+
* - `attachments` (a JSON string on the wire) becomes the typed array, or is
|
|
10
|
+
* dropped when it decodes to nothing so the flat legacy fields win;
|
|
11
|
+
* - `caption` is kept only when it holds text, with `captionMentions` (JSON
|
|
12
|
+
* on the wire) checked against it;
|
|
13
|
+
* - in a sealed message (`clientEncrypted`) the caption attributes are
|
|
14
|
+
* always dropped: the only caption such a message may show is the one
|
|
15
|
+
* inside its encrypted body, which the caller lifts afterwards.
|
|
16
|
+
*
|
|
17
|
+
* Safe to apply twice, so the wrapped and the positional parsers can both
|
|
18
|
+
* call it.
|
|
19
|
+
*/
|
|
20
|
+
export const normalizeMediaDataAttrs = attrs => {
|
|
21
|
+
const out = {
|
|
22
|
+
...attrs
|
|
23
|
+
};
|
|
24
|
+
if ('attachments' in out) {
|
|
25
|
+
const attachments = parseAttachments(out.attachments);
|
|
26
|
+
if (attachments.length > 0) {
|
|
27
|
+
out.attachments = attachments;
|
|
28
|
+
} else {
|
|
29
|
+
delete out.attachments;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
if (out.clientEncrypted === 'true') {
|
|
33
|
+
delete out.caption;
|
|
34
|
+
delete out.captionMentions;
|
|
35
|
+
return out;
|
|
36
|
+
}
|
|
37
|
+
if ('caption' in out) {
|
|
38
|
+
const caption = getMessageCaption({
|
|
39
|
+
caption: out.caption
|
|
40
|
+
});
|
|
41
|
+
if (caption) {
|
|
42
|
+
out.caption = caption;
|
|
43
|
+
const spans = normalizeCaptionMentions(out.captionMentions, caption);
|
|
44
|
+
if (spans) {
|
|
45
|
+
out.captionMentions = spans;
|
|
46
|
+
} else {
|
|
47
|
+
delete out.captionMentions;
|
|
48
|
+
}
|
|
49
|
+
} else {
|
|
50
|
+
delete out.caption;
|
|
51
|
+
delete out.captionMentions;
|
|
52
|
+
}
|
|
53
|
+
} else if ('captionMentions' in out) {
|
|
54
|
+
delete out.captionMentions;
|
|
55
|
+
}
|
|
56
|
+
return out;
|
|
57
|
+
};
|
|
58
|
+
//# sourceMappingURL=mediaWireData.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["parseAttachments","getMessageCaption","normalizeCaptionMentions","normalizeMediaDataAttrs","attrs","out","attachments","length","clientEncrypted","caption","captionMentions","spans"],"sourceRoot":"../../../src","sources":["helpers/mediaWireData.ts"],"mappings":";;AAAA,SAASA,gBAAgB,QAAQ,eAAe;AAChD,SAASC,iBAAiB,EAAEC,wBAAwB,QAAQ,WAAW;;AAEvE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,uBAAuB,GAClCC,KAA0B,IACF;EACxB,MAAMC,GAAwB,GAAG;IAAE,GAAGD;EAAM,CAAC;EAE7C,IAAI,aAAa,IAAIC,GAAG,EAAE;IACxB,MAAMC,WAAW,GAAGN,gBAAgB,CAACK,GAAG,CAACC,WAAW,CAAC;IACrD,IAAIA,WAAW,CAACC,MAAM,GAAG,CAAC,EAAE;MAC1BF,GAAG,CAACC,WAAW,GAAGA,WAAW;IAC/B,CAAC,MAAM;MACL,OAAOD,GAAG,CAACC,WAAW;IACxB;EACF;EAEA,IAAID,GAAG,CAACG,eAAe,KAAK,MAAM,EAAE;IAClC,OAAOH,GAAG,CAACI,OAAO;IAClB,OAAOJ,GAAG,CAACK,eAAe;IAC1B,OAAOL,GAAG;EACZ;EAEA,IAAI,SAAS,IAAIA,GAAG,EAAE;IACpB,MAAMI,OAAO,GAAGR,iBAAiB,CAAC;MAAEQ,OAAO,EAAEJ,GAAG,CAACI;IAAQ,CAAC,CAAC;IAC3D,IAAIA,OAAO,EAAE;MACXJ,GAAG,CAACI,OAAO,GAAGA,OAAO;MACrB,MAAME,KAAK,GAAGT,wBAAwB,CAACG,GAAG,CAACK,eAAe,EAAED,OAAO,CAAC;MACpE,IAAIE,KAAK,EAAE;QACTN,GAAG,CAACK,eAAe,GAAGC,KAAK;MAC7B,CAAC,MAAM;QACL,OAAON,GAAG,CAACK,eAAe;MAC5B;IACF,CAAC,MAAM;MACL,OAAOL,GAAG,CAACI,OAAO;MAClB,OAAOJ,GAAG,CAACK,eAAe;IAC5B;EACF,CAAC,MAAM,IAAI,iBAAiB,IAAIL,GAAG,EAAE;IACnC,OAAOA,GAAG,CAACK,eAAe;EAC5B;EAEA,OAAOL,GAAG;AACZ,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Keeps only the spans that still read "@Name" at their offset in `text`.
|
|
5
|
+
* RN does not render mentions; a caption's spans are stored (and checked) so
|
|
6
|
+
* they survive a round trip to a client that does.
|
|
7
|
+
*/
|
|
8
|
+
export const validateMentionSpans = (text, spans) => spans.filter(span => {
|
|
9
|
+
if (span.offset < 0 || span.offset + span.length > text.length) {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
return text.slice(span.offset, span.offset + span.length) === `@${span.name}`;
|
|
13
|
+
});
|
|
14
|
+
//# sourceMappingURL=mentionSpans.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["validateMentionSpans","text","spans","filter","span","offset","length","slice","name"],"sourceRoot":"../../../src","sources":["helpers/mentionSpans.ts"],"mappings":";;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMA,oBAAoB,GAAGA,CAClCC,IAAY,EACZC,KAAqB,KAErBA,KAAK,CAACC,MAAM,CAAEC,IAAI,IAAK;EACrB,IAAIA,IAAI,CAACC,MAAM,GAAG,CAAC,IAAID,IAAI,CAACC,MAAM,GAAGD,IAAI,CAACE,MAAM,GAAGL,IAAI,CAACK,MAAM,EAAE;IAC9D,OAAO,KAAK;EACd;EACA,OAAOL,IAAI,CAACM,KAAK,CAACH,IAAI,CAACC,MAAM,EAAED,IAAI,CAACC,MAAM,GAAGD,IAAI,CAACE,MAAM,CAAC,KAAK,IAAIF,IAAI,CAACI,IAAI,EAAE;AAC/E,CAAC,CAAC","ignoreList":[]}
|