isometrik-plugin-chat-sdk 1.3.18 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/app-globals-61a8bfde.js +38 -0
- package/dist/cjs/app-globals-61a8bfde.js.map +1 -0
- package/dist/cjs/attachment-preview_22.cjs.entry.js +122 -44
- package/dist/cjs/attachment-preview_22.cjs.entry.js.map +1 -1
- package/dist/cjs/audio-bubble_4.cjs.entry.js +38 -8
- package/dist/cjs/audio-bubble_4.cjs.entry.js.map +1 -1
- package/dist/cjs/chat-app.cjs.entry.js +2 -2
- package/dist/cjs/chat-app.cjs.entry.js.map +1 -1
- package/dist/cjs/{chat-creds-cf537d4b.js → chat-creds-2dbc4087.js} +3 -3
- package/dist/cjs/chat-creds-2dbc4087.js.map +1 -0
- package/dist/cjs/chat-document-message-bubble.cjs.entry.js +1 -1
- package/dist/cjs/chat-image-message-bubble.cjs.entry.js +1 -1
- package/dist/cjs/chat-video-message-bubble.cjs.entry.js +1 -1
- package/dist/cjs/client-80851676.js +482 -0
- package/dist/cjs/client-80851676.js.map +1 -0
- package/dist/cjs/{contracts-31632812.js → contracts-dfc84075.js} +2 -2
- package/dist/cjs/contracts-dfc84075.js.map +1 -0
- package/dist/cjs/destroy-chat-7ae8fc99.js +24 -0
- package/dist/cjs/destroy-chat-7ae8fc99.js.map +1 -0
- package/dist/cjs/doublecheck-c2461adc.js +36 -0
- package/dist/cjs/doublecheck-c2461adc.js.map +1 -0
- package/dist/cjs/{drawer-28cc94a4.js → drawer-811d2ce8.js} +2 -2
- package/dist/cjs/{drawer-28cc94a4.js.map → drawer-811d2ce8.js.map} +1 -1
- package/dist/cjs/forward-memebers.cjs.entry.js +2 -2
- package/dist/cjs/forward-message.cjs.entry.js +2 -2
- package/dist/cjs/group-chat-contacts.cjs.entry.js +2 -2
- package/dist/cjs/{group-members-73ad1074.js → group-members-5a82ec8a.js} +1 -125
- package/dist/cjs/group-members-5a82ec8a.js.map +1 -0
- package/dist/cjs/{helpers-8061ec7d.js → helpers-154861e9.js} +2 -2
- package/dist/cjs/{helpers-8061ec7d.js.map → helpers-154861e9.js.map} +1 -1
- package/dist/cjs/{index-1a26d11d.js → index-66f98408.js} +2 -2
- package/dist/cjs/index-66f98408.js.map +1 -0
- package/dist/cjs/index.cjs.js +55 -182
- package/dist/cjs/index.cjs.js.map +1 -1
- package/dist/cjs/isometrik-webchat.cjs.js +10 -2
- package/dist/cjs/isometrik-webchat.cjs.js.map +1 -1
- package/dist/cjs/loader.cjs.js +10 -2
- package/dist/cjs/loader.cjs.js.map +1 -1
- package/dist/cjs/login-page_3.cjs.entry.js +708 -376
- package/dist/cjs/login-page_3.cjs.entry.js.map +1 -1
- package/dist/cjs/media-gallery.cjs.entry.js +1 -1
- package/dist/cjs/media-limits-eba42629.js +165 -0
- package/dist/cjs/media-limits-eba42629.js.map +1 -0
- package/dist/cjs/member-add.cjs.entry.js +3 -3
- package/dist/cjs/message-bubble.cjs.entry.js +30 -8
- package/dist/cjs/message-bubble.cjs.entry.js.map +1 -1
- package/dist/cjs/my-component.cjs.entry.js +1 -1
- package/dist/cjs/new-chat-sidebar.cjs.entry.js +2 -2
- package/dist/cjs/reaction-container.cjs.entry.js +4 -4
- package/dist/cjs/runtime-controls-201c71ba.js +650 -0
- package/dist/cjs/runtime-controls-201c71ba.js.map +1 -0
- package/dist/cjs/send-media-14908d4b.js +375 -0
- package/dist/cjs/send-media-14908d4b.js.map +1 -0
- package/dist/cjs/signup-page.cjs.entry.js +1 -1
- package/dist/cjs/{toast-0bf1e688.js → toast-f810e550.js} +8 -8
- package/dist/cjs/toast-f810e550.js.map +1 -0
- package/dist/collection/collection-manifest.json +2 -1
- package/dist/collection/components/ChatUIComponent/ChatDocumentMessageBubble.js +1 -1
- package/dist/collection/components/ChatUIComponent/ChatImageMessageBubble.js +1 -1
- package/dist/collection/components/ChatUIComponent/ChatVideoMessageBubble.js +1 -1
- package/dist/collection/components/ChatUIComponent/Footer/ChatFooter.js +61 -14
- package/dist/collection/components/ChatUIComponent/Footer/ChatFooter.js.map +1 -1
- package/dist/collection/components/ChatUIComponent/ReactionContainer.js +2 -2
- package/dist/collection/components/ChatUIComponent/WebChatBody/WebChatBody.js +7 -6
- package/dist/collection/components/ChatUIComponent/WebChatBody/WebChatBody.js.map +1 -1
- package/dist/collection/components/ChatUIComponent/shared/attachment-preview/attachment-preview.js +39 -8
- package/dist/collection/components/ChatUIComponent/shared/attachment-preview/attachment-preview.js.map +1 -1
- package/dist/collection/components/ChatUIComponent/shared/document-message/document-message.js +53 -3
- package/dist/collection/components/ChatUIComponent/shared/document-message/document-message.js.map +1 -1
- package/dist/collection/components/ChatUIComponent/shared/forward-message/forward-message.js +2 -2
- package/dist/collection/components/ChatUIComponent/shared/image-message/image-message.js +19 -1
- package/dist/collection/components/ChatUIComponent/shared/image-message/image-message.js.map +1 -1
- package/dist/collection/components/ChatUIComponent/shared/incoming-text-message-bubble/incoming-text-message-bubble.js +1 -1
- package/dist/collection/components/ChatUIComponent/shared/message-bubble/message-bubble.js +47 -7
- package/dist/collection/components/ChatUIComponent/shared/message-bubble/message-bubble.js.map +1 -1
- package/dist/collection/components/ChatUIComponent/shared/message-date-pill/message-date-pill.js +1 -1
- package/dist/collection/components/ChatUIComponent/shared/new chat/new-chat.stories.js +1 -1
- package/dist/collection/components/ChatUIComponent/shared/outgoing-text-message-bubble/outgoing-text-message-bubble.js +19 -1
- package/dist/collection/components/ChatUIComponent/shared/outgoing-text-message-bubble/outgoing-text-message-bubble.js.map +1 -1
- package/dist/collection/components/ChatUIComponent/shared/reply-message-container/reply-message-container.js +1 -1
- package/dist/collection/components/ChatUIComponent/shared/video-message/video-message.js +20 -2
- package/dist/collection/components/ChatUIComponent/shared/video-message/video-message.js.map +1 -1
- package/dist/collection/components/my-component/my-component.js +1 -1
- package/dist/collection/components/my-component/web-chat/FLOW.js +1 -1
- package/dist/collection/components/my-component/web-chat/FLOW.js.map +1 -1
- package/dist/collection/components/my-component/web-chat/WebChat.js +113 -12
- package/dist/collection/components/my-component/web-chat/WebChat.js.map +1 -1
- package/dist/collection/components/my-component/web-chat/bootstrap.js +7 -0
- package/dist/collection/components/my-component/web-chat/bootstrap.js.map +1 -1
- package/dist/collection/components/my-component/web-chat/data-fetch.js +14 -5
- package/dist/collection/components/my-component/web-chat/data-fetch.js.map +1 -1
- package/dist/collection/components/my-component/web-chat/mqtt-host.js +152 -41
- package/dist/collection/components/my-component/web-chat/mqtt-host.js.map +1 -1
- package/dist/collection/components/my-component/web-chat/offline-host.js +212 -0
- package/dist/collection/components/my-component/web-chat/offline-host.js.map +1 -0
- package/dist/collection/components/my-component/web-chat/public-send.js +96 -21
- package/dist/collection/components/my-component/web-chat/public-send.js.map +1 -1
- package/dist/collection/components/my-component/web-chat/shell-render.js +47 -28
- package/dist/collection/components/my-component/web-chat/shell-render.js.map +1 -1
- package/dist/collection/components/theme-provider.js +114 -45
- package/dist/collection/components/theme-provider.js.map +1 -1
- package/dist/collection/constants/chat-creds.js +2 -2
- package/dist/collection/demos/custom-ui-demo-elements.js +2 -2
- package/dist/collection/demos/custom-ui-demo-elements.js.map +1 -1
- package/dist/collection/global/expose-sdk.js +29 -0
- package/dist/collection/global/expose-sdk.js.map +1 -0
- package/dist/collection/index.js +10 -141
- package/dist/collection/index.js.map +1 -1
- package/dist/collection/lib/chat/index.js +3 -0
- package/dist/collection/lib/chat/index.js.map +1 -1
- package/dist/collection/lib/chat/media-limits.js +21 -0
- package/dist/collection/lib/chat/media-limits.js.map +1 -0
- package/dist/collection/lib/chat/media-outbox.js +43 -0
- package/dist/collection/lib/chat/media-outbox.js.map +1 -0
- package/dist/collection/lib/chat/preview-kind.js +41 -0
- package/dist/collection/lib/chat/preview-kind.js.map +1 -0
- package/dist/collection/lib/chat/send-media.js +5 -2
- package/dist/collection/lib/chat/send-media.js.map +1 -1
- package/dist/collection/lib/custom-ui/contracts.js +1 -1
- package/dist/collection/lib/custom-ui/contracts.js.map +1 -1
- package/dist/collection/lib/custom-ui/index.js +1 -1
- package/dist/collection/lib/custom-ui/index.js.map +1 -1
- package/dist/collection/lib/custom-ui/public-api.js +1 -0
- package/dist/collection/lib/custom-ui/public-api.js.map +1 -1
- package/dist/collection/lib/destroy-chat.js +15 -16
- package/dist/collection/lib/destroy-chat.js.map +1 -0
- package/dist/collection/lib/mqtt/inbound-queue.js +17 -0
- package/dist/collection/lib/mqtt/inbound-queue.js.map +1 -0
- package/dist/collection/lib/mqtt/index.js +2 -1
- package/dist/collection/lib/mqtt/index.js.map +1 -1
- package/dist/collection/lib/mqtt/session.js +50 -6
- package/dist/collection/lib/mqtt/session.js.map +1 -1
- package/dist/collection/lib/offline/client.js +167 -0
- package/dist/collection/lib/offline/client.js.map +1 -0
- package/dist/collection/lib/offline/idb.js +181 -0
- package/dist/collection/lib/offline/idb.js.map +1 -0
- package/dist/collection/lib/offline/index.js +10 -0
- package/dist/collection/lib/offline/index.js.map +1 -0
- package/dist/collection/lib/offline/memory-db.js +64 -0
- package/dist/collection/lib/offline/memory-db.js.map +1 -0
- package/dist/collection/lib/offline/merge.js +24 -0
- package/dist/collection/lib/offline/merge.js.map +1 -0
- package/dist/collection/lib/offline/multitab.js +47 -0
- package/dist/collection/lib/offline/multitab.js.map +1 -0
- package/dist/collection/lib/offline/types.js +2 -0
- package/dist/collection/lib/offline/types.js.map +1 -0
- package/dist/collection/lib/toast.js +6 -6
- package/dist/collection/lib/toast.js.map +1 -1
- package/dist/collection/sdk/api.js +4 -0
- package/dist/collection/sdk/api.js.map +1 -0
- package/dist/collection/sdk/composition.js +43 -0
- package/dist/collection/sdk/composition.js.map +1 -0
- package/dist/collection/sdk/headless-api.js +37 -0
- package/dist/collection/sdk/headless-api.js.map +1 -0
- package/dist/collection/sdk/index.js +11 -0
- package/dist/collection/sdk/index.js.map +1 -0
- package/dist/collection/sdk/init.js +207 -0
- package/dist/collection/sdk/init.js.map +1 -0
- package/dist/collection/sdk/instance.js +63 -0
- package/dist/collection/sdk/instance.js.map +1 -0
- package/dist/collection/sdk/react-bridge.js +145 -0
- package/dist/collection/sdk/react-bridge.js.map +1 -0
- package/dist/collection/sdk/runtime-controls.js +54 -0
- package/dist/collection/sdk/runtime-controls.js.map +1 -0
- package/dist/collection/sdk/slots.js +57 -0
- package/dist/collection/sdk/slots.js.map +1 -0
- package/dist/collection/sdk/theme-tokens.js +99 -0
- package/dist/collection/sdk/theme-tokens.js.map +1 -0
- package/dist/collection/sdk/webchat-api.js +36 -0
- package/dist/collection/sdk/webchat-api.js.map +1 -0
- package/dist/collection/testing/chat-assets-mock.js +45 -0
- package/dist/collection/testing/chat-creds-mock.js +18 -0
- package/dist/collection/testing/emoji-picker-mock.js +2 -0
- package/dist/collection/testing/file-mock.js +1 -0
- package/dist/collection/testing/groupcast-mock.js +7 -0
- package/dist/collection/testing/helpers-mock.js +4 -0
- package/dist/collection/testing/iso-chat-sdk-mock.js +19 -0
- package/dist/collection/testing/toast-mock.js +2 -0
- package/dist/components/ChatFooter.js +62 -15
- package/dist/components/ChatFooter.js.map +1 -1
- package/dist/components/ChatSidebar.js +1 -1
- package/dist/components/{GroupCast.js → GroupCast2.js} +2 -2
- package/dist/components/GroupCast2.js.map +1 -0
- package/dist/components/WebChat.js +643 -312
- package/dist/components/WebChat.js.map +1 -1
- package/dist/components/WebChatBody.js +8 -7
- package/dist/components/WebChatBody.js.map +1 -1
- package/dist/components/attachment-preview2.js +40 -9
- package/dist/components/attachment-preview2.js.map +1 -1
- package/dist/components/chat-app.js +3 -3
- package/dist/components/chat-app.js.map +1 -1
- package/dist/components/chat-assets.js +1 -1
- package/dist/components/chat-creds.js +2 -2
- package/dist/components/chat-creds.js.map +1 -1
- package/dist/components/chat-document-message-bubble.js +1 -1
- package/dist/components/chat-image-message-bubble.js +1 -1
- package/dist/components/chat-tile2.js +1 -1
- package/dist/components/chat-video-message-bubble.js +1 -1
- package/dist/components/client.js +728 -0
- package/dist/components/client.js.map +1 -0
- package/dist/components/contact-info2.js +2 -117
- package/dist/components/contact-info2.js.map +1 -1
- package/dist/components/contracts.js +1 -1
- package/dist/components/contracts.js.map +1 -1
- package/dist/components/destroy-chat.js +14 -16
- package/dist/components/destroy-chat.js.map +1 -1
- package/dist/components/document-message2.js +35 -5
- package/dist/components/document-message2.js.map +1 -1
- package/dist/components/forward-message.js +2 -2
- package/dist/components/group-cast.js +1 -1
- package/dist/components/{groupcast2.js → groupcast.js} +1 -1
- package/dist/components/groupcast.js.map +1 -0
- package/dist/components/image-message2.js +3 -1
- package/dist/components/image-message2.js.map +1 -1
- package/dist/components/incoming-text-message-bubble2.js +1 -1
- package/dist/components/index.js +551 -60
- package/dist/components/index.js.map +1 -1
- package/dist/components/index2.js +1 -1
- package/dist/components/index2.js.map +1 -1
- package/dist/components/media-limits.js +24 -0
- package/dist/components/media-limits.js.map +1 -0
- package/dist/components/member-add.js +1 -1
- package/dist/components/message-bubble2.js +31 -7
- package/dist/components/message-bubble2.js.map +1 -1
- package/dist/components/message-date-pill2.js +1 -1
- package/dist/components/messages.js +131 -0
- package/dist/components/messages.js.map +1 -0
- package/dist/components/my-component.js +1 -1
- package/dist/components/outgoing-text-message-bubble2.js +3 -1
- package/dist/components/outgoing-text-message-bubble2.js.map +1 -1
- package/dist/components/preview-kind.js +30 -0
- package/dist/components/preview-kind.js.map +1 -0
- package/dist/components/reaction-container.js +2 -2
- package/dist/components/reply-message-container2.js +1 -1
- package/dist/components/theme-provider2.js +56 -44
- package/dist/components/theme-provider2.js.map +1 -1
- package/dist/components/theme-tokens.js +102 -0
- package/dist/components/theme-tokens.js.map +1 -0
- package/dist/components/toast.js +6 -6
- package/dist/components/toast.js.map +1 -1
- package/dist/components/video-message2.js +4 -2
- package/dist/components/video-message2.js.map +1 -1
- package/dist/esm/app-globals-2beecb81.js +36 -0
- package/dist/esm/app-globals-2beecb81.js.map +1 -0
- package/dist/esm/attachment-preview_22.entry.js +120 -42
- package/dist/esm/attachment-preview_22.entry.js.map +1 -1
- package/dist/esm/audio-bubble_4.entry.js +39 -9
- package/dist/esm/audio-bubble_4.entry.js.map +1 -1
- package/dist/esm/chat-app.entry.js +2 -2
- package/dist/esm/chat-app.entry.js.map +1 -1
- package/dist/esm/{chat-assets-e3173222.js → chat-assets-bb056958.js} +2 -2
- package/dist/esm/{chat-assets-e3173222.js.map → chat-assets-bb056958.js.map} +1 -1
- package/dist/esm/{chat-creds-5d0982fc.js → chat-creds-aafad4d0.js} +3 -3
- package/dist/esm/chat-creds-aafad4d0.js.map +1 -0
- package/dist/esm/chat-document-message-bubble.entry.js +1 -1
- package/dist/esm/chat-image-message-bubble.entry.js +1 -1
- package/dist/esm/chat-tile_3.entry.js +1 -1
- package/dist/esm/chat-video-message-bubble.entry.js +1 -1
- package/dist/esm/client-4a3e00da.js +477 -0
- package/dist/esm/client-4a3e00da.js.map +1 -0
- package/dist/esm/{contracts-614be4db.js → contracts-50f4ddae.js} +2 -2
- package/dist/esm/contracts-50f4ddae.js.map +1 -0
- package/dist/esm/destroy-chat-d0ee28d6.js +22 -0
- package/dist/esm/destroy-chat-d0ee28d6.js.map +1 -0
- package/dist/esm/doublecheck-261763ef.js +32 -0
- package/dist/esm/doublecheck-261763ef.js.map +1 -0
- package/dist/esm/{drawer-8f721119.js → drawer-74c188f1.js} +2 -2
- package/dist/esm/{drawer-8f721119.js.map → drawer-74c188f1.js.map} +1 -1
- package/dist/esm/forward-memebers.entry.js +3 -3
- package/dist/esm/forward-message.entry.js +2 -2
- package/dist/esm/group-chat-contacts.entry.js +2 -2
- package/dist/esm/{group-members-806fd7a2.js → group-members-05414da2.js} +2 -118
- package/dist/esm/group-members-05414da2.js.map +1 -0
- package/dist/esm/{groupcast-2ce7187f.js → groupcast-9c7d2a32.js} +2 -2
- package/dist/esm/{groupcast-2ce7187f.js.map → groupcast-9c7d2a32.js.map} +1 -1
- package/dist/esm/{helpers-4c6d09a7.js → helpers-f33b895c.js} +2 -2
- package/dist/esm/{helpers-4c6d09a7.js.map → helpers-f33b895c.js.map} +1 -1
- package/dist/esm/{index-beb184c6.js → index-4c865e34.js} +2 -2
- package/dist/esm/index-4c865e34.js.map +1 -0
- package/dist/esm/index.js +17 -171
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/isometrik-webchat.js +10 -2
- package/dist/esm/isometrik-webchat.js.map +1 -1
- package/dist/esm/loader.js +10 -2
- package/dist/esm/loader.js.map +1 -1
- package/dist/esm/login-page_3.entry.js +691 -359
- package/dist/esm/login-page_3.entry.js.map +1 -1
- package/dist/esm/media-gallery.entry.js +1 -1
- package/dist/esm/media-limits-3fa07c09.js +152 -0
- package/dist/esm/media-limits-3fa07c09.js.map +1 -0
- package/dist/esm/member-add.entry.js +5 -5
- package/dist/esm/message-bubble.entry.js +30 -8
- package/dist/esm/message-bubble.entry.js.map +1 -1
- package/dist/esm/my-component.entry.js +1 -1
- package/dist/esm/new-chat-sidebar.entry.js +3 -3
- package/dist/esm/reaction-container.entry.js +4 -4
- package/dist/esm/runtime-controls-cf599fe2.js +623 -0
- package/dist/esm/runtime-controls-cf599fe2.js.map +1 -0
- package/dist/esm/send-media-917dcc2f.js +353 -0
- package/dist/esm/send-media-917dcc2f.js.map +1 -0
- package/dist/esm/signup-page.entry.js +1 -1
- package/dist/esm/{toast-d8ea763c.js → toast-533dd183.js} +8 -8
- package/dist/esm/toast-533dd183.js.map +1 -0
- package/dist/isometrik-webchat/index.esm.js +1 -1
- package/dist/isometrik-webchat/index.esm.js.map +1 -1
- package/dist/isometrik-webchat/isometrik-webchat.css +1 -1
- package/dist/isometrik-webchat/isometrik-webchat.esm.js +1 -1
- package/dist/isometrik-webchat/isometrik-webchat.esm.js.map +1 -1
- package/dist/isometrik-webchat/p-0731d488.js +2 -0
- package/dist/isometrik-webchat/p-0731d488.js.map +1 -0
- package/dist/isometrik-webchat/{p-a15092d9.entry.js → p-1854b156.entry.js} +2 -2
- package/dist/isometrik-webchat/p-1854b156.entry.js.map +1 -0
- package/dist/isometrik-webchat/{p-5fea3fd2.entry.js → p-2d3e8cd4.entry.js} +2 -2
- package/dist/isometrik-webchat/p-315eee9a.js +2 -0
- package/dist/isometrik-webchat/p-315eee9a.js.map +1 -0
- package/dist/isometrik-webchat/{p-e7f58d3f.entry.js → p-39b626ed.entry.js} +2 -2
- package/dist/isometrik-webchat/{p-eb1f3118.entry.js → p-3c70c22c.entry.js} +2 -2
- package/dist/isometrik-webchat/p-4cb54460.js +2 -0
- package/dist/isometrik-webchat/p-4cb54460.js.map +1 -0
- package/dist/isometrik-webchat/{p-f24cdbbb.js → p-5162774c.js} +1 -1
- package/dist/isometrik-webchat/p-5162774c.js.map +1 -0
- package/dist/isometrik-webchat/p-53ee98a7.entry.js +2 -0
- package/dist/isometrik-webchat/p-53ee98a7.entry.js.map +1 -0
- package/dist/isometrik-webchat/{p-5cbc1a16.entry.js → p-586f6978.entry.js} +2 -2
- package/dist/isometrik-webchat/{p-5f7eebbf.entry.js → p-5d243250.entry.js} +2 -2
- package/dist/isometrik-webchat/{p-23df1c24.js → p-5d98a8a0.js} +2 -2
- package/dist/isometrik-webchat/p-7f415f28.js +2 -0
- package/dist/isometrik-webchat/p-7f415f28.js.map +1 -0
- package/dist/isometrik-webchat/{p-d386acfe.js → p-7fd2c1ad.js} +1 -1
- package/dist/isometrik-webchat/p-7fd2c1ad.js.map +1 -0
- package/dist/isometrik-webchat/{p-e5884258.js → p-9982fa21.js} +2 -2
- package/dist/isometrik-webchat/{p-4db39c93.js → p-a5707f12.js} +2 -2
- package/dist/isometrik-webchat/{p-af775c83.entry.js → p-a876991d.entry.js} +2 -2
- package/dist/isometrik-webchat/{p-7b80b0b2.js → p-adc45831.js} +1 -1
- package/dist/isometrik-webchat/p-adc45831.js.map +1 -0
- package/dist/isometrik-webchat/p-ae168135.js +2 -0
- package/dist/isometrik-webchat/p-ae168135.js.map +1 -0
- package/dist/isometrik-webchat/{p-a6897edc.js → p-b1330793.js} +1 -1
- package/dist/isometrik-webchat/p-b1330793.js.map +1 -0
- package/dist/isometrik-webchat/p-b61d6c0c.entry.js +2 -0
- package/dist/isometrik-webchat/p-b61d6c0c.entry.js.map +1 -0
- package/dist/isometrik-webchat/p-b667a9fc.js +2 -0
- package/dist/isometrik-webchat/p-b667a9fc.js.map +1 -0
- package/dist/isometrik-webchat/p-b857775d.entry.js +2 -0
- package/dist/isometrik-webchat/p-bdcdf1c5.js +2 -0
- package/dist/isometrik-webchat/p-bdcdf1c5.js.map +1 -0
- package/dist/isometrik-webchat/p-c0c19621.entry.js +2 -0
- package/dist/isometrik-webchat/{p-064d6200.entry.js → p-ca47d693.entry.js} +2 -2
- package/dist/isometrik-webchat/p-d720cf14.entry.js +2 -0
- package/dist/isometrik-webchat/{p-53695fc6.entry.js.map → p-d720cf14.entry.js.map} +1 -1
- package/dist/isometrik-webchat/{p-5c22ee37.entry.js → p-d892b4d4.entry.js} +2 -2
- package/dist/isometrik-webchat/{p-7eb12da3.js → p-dd62bd69.js} +2 -2
- package/dist/isometrik-webchat/p-eb54f75d.js +2 -0
- package/dist/isometrik-webchat/p-eb54f75d.js.map +1 -0
- package/dist/isometrik-webchat/p-f1fbf3be.entry.js +2 -0
- package/dist/isometrik-webchat/p-f1fbf3be.entry.js.map +1 -0
- package/dist/isometrik-webchat/p-fb705915.entry.js +2 -0
- package/dist/isometrik-webchat/p-fb705915.entry.js.map +1 -0
- package/dist/isometrik-webchat/{p-2f6bb0a4.entry.js → p-fd6ce589.entry.js} +2 -2
- package/dist/isometrik-webchat/p-fdd327f5.entry.js +2 -0
- package/dist/types/components/ChatUIComponent/Footer/ChatFooter.d.ts +1 -0
- package/dist/types/components/ChatUIComponent/shared/attachment-preview/attachment-preview.d.ts +2 -0
- package/dist/types/components/ChatUIComponent/shared/document-message/document-message.d.ts +5 -0
- package/dist/types/components/ChatUIComponent/shared/image-message/image-message.d.ts +1 -0
- package/dist/types/components/ChatUIComponent/shared/message-bubble/message-bubble.d.ts +3 -0
- package/dist/types/components/ChatUIComponent/shared/outgoing-text-message-bubble/outgoing-text-message-bubble.d.ts +1 -0
- package/dist/types/components/ChatUIComponent/shared/video-message/video-message.d.ts +1 -0
- package/dist/types/components/my-component/web-chat/FLOW.d.ts +1 -1
- package/dist/types/components/my-component/web-chat/mqtt-host.d.ts +13 -0
- package/dist/types/components/my-component/web-chat/offline-host.d.ts +22 -0
- package/dist/types/components/theme-provider.d.ts +22 -27
- package/dist/types/components.d.ts +84 -11
- package/dist/types/demos/custom-ui-demo-elements.d.ts +1 -1
- package/dist/types/global/expose-sdk.d.ts +1 -0
- package/dist/types/index.d.ts +3 -44
- package/dist/types/lib/chat/index.d.ts +3 -0
- package/dist/types/lib/chat/media-limits.d.ts +11 -0
- package/dist/types/lib/chat/media-outbox.d.ts +8 -0
- package/dist/types/lib/chat/preview-kind.d.ts +30 -0
- package/dist/types/lib/custom-ui/contracts.d.ts +1 -1
- package/dist/types/lib/custom-ui/index.d.ts +1 -1
- package/dist/types/lib/custom-ui/public-api.d.ts +1 -1
- package/dist/types/lib/destroy-chat.d.ts +2 -0
- package/dist/types/lib/mqtt/inbound-queue.d.ts +7 -0
- package/dist/types/lib/mqtt/index.d.ts +2 -1
- package/dist/types/lib/mqtt/session.d.ts +22 -0
- package/dist/types/lib/offline/client.d.ts +44 -0
- package/dist/types/lib/offline/idb.d.ts +36 -0
- package/dist/types/lib/offline/index.d.ts +10 -0
- package/dist/types/lib/offline/memory-db.d.ts +20 -0
- package/dist/types/lib/offline/merge.d.ts +3 -0
- package/dist/types/lib/offline/multitab.d.ts +13 -0
- package/dist/types/lib/offline/types.d.ts +63 -0
- package/dist/types/sdk/api.d.ts +3 -0
- package/dist/types/sdk/composition.d.ts +32 -0
- package/dist/types/sdk/headless-api.d.ts +37 -0
- package/dist/types/sdk/index.d.ts +10 -0
- package/dist/types/sdk/init.d.ts +87 -0
- package/dist/types/sdk/instance.d.ts +15 -0
- package/dist/types/sdk/react-bridge.d.ts +64 -0
- package/dist/types/sdk/runtime-controls.d.ts +14 -0
- package/dist/types/sdk/slots.d.ts +15 -0
- package/dist/types/sdk/theme-tokens.d.ts +22 -0
- package/dist/types/sdk/webchat-api.d.ts +22 -0
- package/docs/ARCHITECTURE.md +272 -0
- package/docs/CUSTOMIZATION.md +236 -0
- package/docs/INTEGRATION.md +286 -0
- package/docs/RELIABILITY.md +51 -0
- package/docs/theme-tokens.template.css +72 -0
- package/package.json +8 -2
- package/readme.md +38 -17
- package/dist/cjs/app-globals-3a1e7e63.js +0 -7
- package/dist/cjs/app-globals-3a1e7e63.js.map +0 -1
- package/dist/cjs/chat-creds-cf537d4b.js.map +0 -1
- package/dist/cjs/contracts-31632812.js.map +0 -1
- package/dist/cjs/destroy-chat-be25dec7.js +0 -26
- package/dist/cjs/destroy-chat-be25dec7.js.map +0 -1
- package/dist/cjs/doublecheck-997afc94.js +0 -7
- package/dist/cjs/doublecheck-997afc94.js.map +0 -1
- package/dist/cjs/group-members-73ad1074.js.map +0 -1
- package/dist/cjs/index-1a26d11d.js.map +0 -1
- package/dist/cjs/toast-0bf1e688.js.map +0 -1
- package/dist/components/GroupCast.js.map +0 -1
- package/dist/components/groupcast2.js.map +0 -1
- package/dist/esm/app-globals-0f993ce5.js +0 -5
- package/dist/esm/app-globals-0f993ce5.js.map +0 -1
- package/dist/esm/chat-creds-5d0982fc.js.map +0 -1
- package/dist/esm/contracts-614be4db.js.map +0 -1
- package/dist/esm/destroy-chat-e2ebe165.js +0 -24
- package/dist/esm/destroy-chat-e2ebe165.js.map +0 -1
- package/dist/esm/doublecheck-5e208ef0.js +0 -5
- package/dist/esm/doublecheck-5e208ef0.js.map +0 -1
- package/dist/esm/group-members-806fd7a2.js.map +0 -1
- package/dist/esm/index-beb184c6.js.map +0 -1
- package/dist/esm/toast-d8ea763c.js.map +0 -1
- package/dist/isometrik-webchat/p-01fd0eb4.entry.js +0 -2
- package/dist/isometrik-webchat/p-01fd0eb4.entry.js.map +0 -1
- package/dist/isometrik-webchat/p-09fc122b.entry.js +0 -2
- package/dist/isometrik-webchat/p-09fc122b.entry.js.map +0 -1
- package/dist/isometrik-webchat/p-1c53e658.js +0 -2
- package/dist/isometrik-webchat/p-1c53e658.js.map +0 -1
- package/dist/isometrik-webchat/p-1df58381.entry.js +0 -2
- package/dist/isometrik-webchat/p-1df58381.entry.js.map +0 -1
- package/dist/isometrik-webchat/p-3c690532.entry.js +0 -2
- package/dist/isometrik-webchat/p-3c690532.entry.js.map +0 -1
- package/dist/isometrik-webchat/p-3c8cbd5f.js +0 -2
- package/dist/isometrik-webchat/p-3c8cbd5f.js.map +0 -1
- package/dist/isometrik-webchat/p-4e762019.js +0 -2
- package/dist/isometrik-webchat/p-4e762019.js.map +0 -1
- package/dist/isometrik-webchat/p-53695fc6.entry.js +0 -2
- package/dist/isometrik-webchat/p-7b80b0b2.js.map +0 -1
- package/dist/isometrik-webchat/p-9924b1bf.entry.js +0 -2
- package/dist/isometrik-webchat/p-a15092d9.entry.js.map +0 -1
- package/dist/isometrik-webchat/p-a6897edc.js.map +0 -1
- package/dist/isometrik-webchat/p-b2bf55b1.entry.js +0 -2
- package/dist/isometrik-webchat/p-bfecfa97.entry.js +0 -2
- package/dist/isometrik-webchat/p-d386acfe.js.map +0 -1
- package/dist/isometrik-webchat/p-e1255160.js +0 -2
- package/dist/isometrik-webchat/p-e1255160.js.map +0 -1
- package/dist/isometrik-webchat/p-f24cdbbb.js.map +0 -1
- /package/dist/isometrik-webchat/{p-5fea3fd2.entry.js.map → p-2d3e8cd4.entry.js.map} +0 -0
- /package/dist/isometrik-webchat/{p-e7f58d3f.entry.js.map → p-39b626ed.entry.js.map} +0 -0
- /package/dist/isometrik-webchat/{p-eb1f3118.entry.js.map → p-3c70c22c.entry.js.map} +0 -0
- /package/dist/isometrik-webchat/{p-5cbc1a16.entry.js.map → p-586f6978.entry.js.map} +0 -0
- /package/dist/isometrik-webchat/{p-5f7eebbf.entry.js.map → p-5d243250.entry.js.map} +0 -0
- /package/dist/isometrik-webchat/{p-23df1c24.js.map → p-5d98a8a0.js.map} +0 -0
- /package/dist/isometrik-webchat/{p-e5884258.js.map → p-9982fa21.js.map} +0 -0
- /package/dist/isometrik-webchat/{p-4db39c93.js.map → p-a5707f12.js.map} +0 -0
- /package/dist/isometrik-webchat/{p-af775c83.entry.js.map → p-a876991d.entry.js.map} +0 -0
- /package/dist/isometrik-webchat/{p-bfecfa97.entry.js.map → p-b857775d.entry.js.map} +0 -0
- /package/dist/isometrik-webchat/{p-9924b1bf.entry.js.map → p-c0c19621.entry.js.map} +0 -0
- /package/dist/isometrik-webchat/{p-064d6200.entry.js.map → p-ca47d693.entry.js.map} +0 -0
- /package/dist/isometrik-webchat/{p-5c22ee37.entry.js.map → p-d892b4d4.entry.js.map} +0 -0
- /package/dist/isometrik-webchat/{p-7eb12da3.js.map → p-dd62bd69.js.map} +0 -0
- /package/dist/isometrik-webchat/{p-2f6bb0a4.entry.js.map → p-fd6ce589.entry.js.map} +0 -0
- /package/dist/isometrik-webchat/{p-b2bf55b1.entry.js.map → p-fdd327f5.entry.js.map} +0 -0
|
@@ -1,111 +1,174 @@
|
|
|
1
1
|
import { r as registerInstance, h, g as getElement, F as Fragment, a as createEvent } from './index-bc463197.js';
|
|
2
|
-
import {
|
|
2
|
+
import { M as MQTT_CREDS, i as isometrikFlutterAppSecrets, C as CHAT_CREDS } from './chat-creds-aafad4d0.js';
|
|
3
3
|
import { i as isometrikLogo } from './IsometrikLogo-36cb0542.js';
|
|
4
4
|
import { W as WEB_CONTENT } from './content-fb138a93.js';
|
|
5
|
-
import { b as ChatBg, L as Login_banner } from './chat-assets-
|
|
6
|
-
import { d as
|
|
7
|
-
import {
|
|
5
|
+
import { b as ChatBg, L as Login_banner } from './chat-assets-bb056958.js';
|
|
6
|
+
import { k as applyThemeObjectToElement, n as normalizeThemeObject, p as prepareMediaAttachments, u as uploadAndPostMediaMessage, i as initializeChatSdk, f as fetchUserDetails, a as fetchConversationsPage, m as mergeUniqueConversations, c as fetchGroupcastDetails, b as fetchConversationDetails, d as fetchGroupcastMembersPage, e as fetchGroupcastContactsPage, q as buildLocalMediaAttachments, h as customTypeFromMime, j as buildReplyMetaData, s as sortConversationsByLatestMessage, l as resolveRegionMode } from './send-media-917dcc2f.js';
|
|
7
|
+
import { d as drawerDialogService } from './drawer-74c188f1.js';
|
|
8
|
+
import { a as getDeviceID, b as getGroupcastUrlQuery } from './helpers-f33b895c.js';
|
|
8
9
|
import { M } from './index.m-8c70037f.js';
|
|
9
|
-
import { c as createStore,
|
|
10
|
-
import {
|
|
11
|
-
import { s as
|
|
10
|
+
import { c as createStore, g as groupMembersStore } from './group-members-05414da2.js';
|
|
11
|
+
import { d as getGroupcastMessage, r as removeGroupcastMember, e as deleteGroupCast } from './groupcast-9c7d2a32.js';
|
|
12
|
+
import { t as takeMediaFiles, M as MAX_MEDIA_PER_MESSAGE, f as fetchMessagesPage, s as searchMessages, a as fetchLinkMessages, b as fetchMediaCount, c as fetchMediaAttachments, m as mediaLimitToastMessage } from './media-limits-3fa07c09.js';
|
|
13
|
+
import { g as getOfflineClient, m as mergeMessagesById, i as isBrowserOnline } from './client-4a3e00da.js';
|
|
14
|
+
import { s as showToast } from './toast-533dd183.js';
|
|
12
15
|
import { r as removeConversationMember, g as getConversationEligibleMembers } from './group-members-d603f29f.js';
|
|
13
|
-
import { h as hasNamedSlot } from './index-
|
|
14
|
-
import './destroy-chat-
|
|
16
|
+
import { h as hasNamedSlot } from './index-4c865e34.js';
|
|
17
|
+
import './destroy-chat-d0ee28d6.js';
|
|
18
|
+
|
|
19
|
+
const MAX_OUTBOX_MEDIA_BYTES = 12 * 1024 * 1024;
|
|
20
|
+
function arrayBufferToBase64(buf) {
|
|
21
|
+
const bytes = new Uint8Array(buf);
|
|
22
|
+
const chunk = 0x8000;
|
|
23
|
+
let binary = '';
|
|
24
|
+
for (let i = 0; i < bytes.length; i += chunk) {
|
|
25
|
+
binary += String.fromCharCode(...bytes.subarray(i, i + chunk));
|
|
26
|
+
}
|
|
27
|
+
return btoa(binary);
|
|
28
|
+
}
|
|
29
|
+
function base64ToUint8(base64) {
|
|
30
|
+
const binary = atob(base64);
|
|
31
|
+
const out = new Uint8Array(binary.length);
|
|
32
|
+
for (let i = 0; i < binary.length; i++)
|
|
33
|
+
out[i] = binary.charCodeAt(i);
|
|
34
|
+
return out;
|
|
35
|
+
}
|
|
36
|
+
async function filesToOutboxMedia(files) {
|
|
37
|
+
const accepted = takeMediaFiles(files, 0).accepted;
|
|
38
|
+
let total = 0;
|
|
39
|
+
const out = [];
|
|
40
|
+
for (const file of accepted) {
|
|
41
|
+
// Skip oversized; keep packing remaining files that still fit
|
|
42
|
+
if (total + file.size > MAX_OUTBOX_MEDIA_BYTES)
|
|
43
|
+
continue;
|
|
44
|
+
const base64 = arrayBufferToBase64(await file.arrayBuffer());
|
|
45
|
+
out.push({
|
|
46
|
+
name: file.name,
|
|
47
|
+
mimeType: file.type || 'application/octet-stream',
|
|
48
|
+
size: file.size,
|
|
49
|
+
base64,
|
|
50
|
+
});
|
|
51
|
+
total += file.size;
|
|
52
|
+
}
|
|
53
|
+
return out;
|
|
54
|
+
}
|
|
55
|
+
function outboxMediaToFiles(mediaFiles) {
|
|
56
|
+
if (!(mediaFiles === null || mediaFiles === void 0 ? void 0 : mediaFiles.length))
|
|
57
|
+
return [];
|
|
58
|
+
return mediaFiles.slice(0, MAX_MEDIA_PER_MESSAGE).map(m => new File([base64ToUint8(m.base64)], m.name, { type: m.mimeType || 'application/octet-stream' }));
|
|
59
|
+
}
|
|
15
60
|
|
|
16
61
|
const ThemeProvider = class {
|
|
17
62
|
constructor(hostRef) {
|
|
18
63
|
registerInstance(this, hostRef);
|
|
64
|
+
this.stylesheetId = `isometrik-theme-stylesheet-${Math.random().toString(36).slice(2, 9)}`;
|
|
19
65
|
this.themePath = undefined;
|
|
20
66
|
this.mode = 'light';
|
|
67
|
+
this.themeObject = undefined;
|
|
68
|
+
this.mirrorToDocument = false;
|
|
21
69
|
this.styleElement = null;
|
|
22
70
|
}
|
|
23
|
-
/**
|
|
24
|
-
* Watch for changes to the theme path and update the stylesheet
|
|
25
|
-
*/
|
|
26
71
|
handleThemePathChange(newPath) {
|
|
27
72
|
if (newPath) {
|
|
28
73
|
this.loadThemeFromPath(newPath);
|
|
29
74
|
}
|
|
30
75
|
}
|
|
31
|
-
/**
|
|
32
|
-
* Watch for changes to theme mode
|
|
33
|
-
*/
|
|
34
76
|
handleModeChange(newMode) {
|
|
35
77
|
this.updateThemeClass(newMode);
|
|
36
78
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
79
|
+
handleThemeObjectChange(next) {
|
|
80
|
+
this.applyThemeObject(next);
|
|
81
|
+
}
|
|
82
|
+
handleMirrorChange() {
|
|
83
|
+
this.updateThemeClass(this.mode);
|
|
84
|
+
}
|
|
40
85
|
componentDidLoad() {
|
|
41
|
-
// Load theme from path if provided
|
|
42
86
|
if (this.themePath) {
|
|
43
87
|
this.loadThemeFromPath(this.themePath);
|
|
44
88
|
}
|
|
45
|
-
// Set initial theme class
|
|
46
89
|
this.updateThemeClass(this.mode);
|
|
90
|
+
this.applyThemeObject(this.themeObject);
|
|
47
91
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
92
|
+
disconnectedCallback() {
|
|
93
|
+
var _a;
|
|
94
|
+
if ((_a = this.styleElement) === null || _a === void 0 ? void 0 : _a.parentNode) {
|
|
95
|
+
this.styleElement.parentNode.removeChild(this.styleElement);
|
|
96
|
+
this.styleElement = null;
|
|
97
|
+
}
|
|
98
|
+
if (this.mirrorToDocument) {
|
|
99
|
+
document.documentElement.classList.remove('theme-light', 'theme-dark');
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
applyThemeObject(theme) {
|
|
103
|
+
applyThemeObjectToElement(this.hostElement, theme || null);
|
|
104
|
+
}
|
|
105
|
+
/** Mode class on this host only — CSS vars inherit into <web-chat> shadow. */
|
|
51
106
|
updateThemeClass(mode) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
107
|
+
this.hostElement.classList.remove('theme-light', 'theme-dark');
|
|
108
|
+
this.hostElement.classList.add(`theme-${mode}`);
|
|
109
|
+
if (this.mirrorToDocument) {
|
|
110
|
+
document.documentElement.classList.remove('theme-light', 'theme-dark');
|
|
111
|
+
document.documentElement.classList.add(`theme-${mode}`);
|
|
112
|
+
}
|
|
113
|
+
this.hostElement.dispatchEvent(new CustomEvent('themechange', {
|
|
114
|
+
detail: { mode, scoped: !this.mirrorToDocument },
|
|
59
115
|
bubbles: true,
|
|
60
|
-
composed: true
|
|
61
|
-
});
|
|
62
|
-
this.hostElement.dispatchEvent(themeChangeEvent);
|
|
116
|
+
composed: true,
|
|
117
|
+
}));
|
|
63
118
|
}
|
|
64
|
-
/**
|
|
65
|
-
* Load a theme from a CSS file path
|
|
66
|
-
*/
|
|
67
119
|
loadThemeFromPath(path) {
|
|
68
|
-
|
|
69
|
-
if (this.styleElement) {
|
|
70
|
-
|
|
120
|
+
var _a;
|
|
121
|
+
if ((_a = this.styleElement) === null || _a === void 0 ? void 0 : _a.parentNode) {
|
|
122
|
+
this.styleElement.parentNode.removeChild(this.styleElement);
|
|
71
123
|
}
|
|
72
|
-
// Create a new link element for the CSS file
|
|
73
124
|
this.styleElement = document.createElement('link');
|
|
74
125
|
this.styleElement.rel = 'stylesheet';
|
|
75
126
|
this.styleElement.href = path;
|
|
76
|
-
|
|
77
|
-
this.styleElement.
|
|
78
|
-
// Append the stylesheet to the document head
|
|
127
|
+
this.styleElement.id = this.stylesheetId;
|
|
128
|
+
this.styleElement.setAttribute('data-isometrik-theme', '1');
|
|
79
129
|
document.head.appendChild(this.styleElement);
|
|
80
130
|
}
|
|
81
|
-
/**
|
|
82
|
-
* Public method to toggle between light and dark themes
|
|
83
|
-
*/
|
|
84
131
|
async toggleTheme() {
|
|
85
132
|
this.mode = this.mode === 'light' ? 'dark' : 'light';
|
|
86
133
|
return this.mode;
|
|
87
134
|
}
|
|
88
|
-
/**
|
|
89
|
-
* Public method to set theme explicitly
|
|
90
|
-
*/
|
|
91
135
|
async setTheme(mode) {
|
|
92
136
|
this.mode = mode;
|
|
93
137
|
return this.mode;
|
|
94
138
|
}
|
|
139
|
+
async setThemeObject(theme) {
|
|
140
|
+
const normalized = normalizeThemeObject(theme || undefined);
|
|
141
|
+
applyThemeObjectToElement(this.hostElement, normalized);
|
|
142
|
+
return normalized;
|
|
143
|
+
}
|
|
95
144
|
render() {
|
|
96
|
-
return (h("div", { key: '
|
|
145
|
+
return (h("div", { key: 'eda588f5d70658cdbb4d2c112b87e967e26851f4', class: `theme-provider-container theme-${this.mode}` }, h("slot", { key: '1c0c507b5f4380353fb5af4332f1873eecd84d5c' })));
|
|
97
146
|
}
|
|
98
147
|
get hostElement() { return getElement(this); }
|
|
99
148
|
static get watchers() { return {
|
|
100
149
|
"themePath": ["handleThemePathChange"],
|
|
101
|
-
"mode": ["handleModeChange"]
|
|
150
|
+
"mode": ["handleModeChange"],
|
|
151
|
+
"themeObject": ["handleThemeObjectChange"],
|
|
152
|
+
"mirrorToDocument": ["handleMirrorChange"]
|
|
102
153
|
}; }
|
|
103
154
|
};
|
|
104
155
|
|
|
105
156
|
/**
|
|
106
157
|
* Thin MQTT lifecycle helper around test-iso-chat-sdk's mqtt client.
|
|
107
158
|
* Keeps connect/subscribe/teardown idempotent so remounts don't stack listeners.
|
|
159
|
+
*
|
|
160
|
+
* Supports mqtt.js reconnect: on each `connect` (including after reconnect)
|
|
161
|
+
* call `resubscribe()` so the user topic is always live.
|
|
108
162
|
*/
|
|
163
|
+
/** Sensible mqtt.js reconnect defaults (ms). */
|
|
164
|
+
const MQTT_RECONNECT_PERIOD_MS = 2000;
|
|
165
|
+
const MQTT_CONNECT_TIMEOUT_MS = 12000;
|
|
166
|
+
function applyMqttReconnectOptions(rawClient) {
|
|
167
|
+
if (!(rawClient === null || rawClient === void 0 ? void 0 : rawClient.options))
|
|
168
|
+
return;
|
|
169
|
+
rawClient.options.reconnectPeriod = MQTT_RECONNECT_PERIOD_MS;
|
|
170
|
+
rawClient.options.connectTimeout = MQTT_CONNECT_TIMEOUT_MS;
|
|
171
|
+
}
|
|
109
172
|
function removeClientListener(client, event, handler) {
|
|
110
173
|
if (typeof client.removeListener === 'function') {
|
|
111
174
|
client.removeListener(event, handler);
|
|
@@ -120,14 +183,18 @@ class MqttSession {
|
|
|
120
183
|
this.handlers = {};
|
|
121
184
|
this.boundConnect = null;
|
|
122
185
|
this.boundDisconnect = null;
|
|
186
|
+
this.boundOffline = null;
|
|
187
|
+
this.boundReconnect = null;
|
|
123
188
|
this.boundError = null;
|
|
124
189
|
this.boundMessage = null;
|
|
190
|
+
/** Last successfully subscribed topic. */
|
|
125
191
|
this.subscribedTopic = null;
|
|
192
|
+
/** Topic we want — used to force resubscribe after reconnect. */
|
|
193
|
+
this.desiredTopic = null;
|
|
126
194
|
this.listenersAttached = false;
|
|
127
195
|
this.messageListenerAttached = false;
|
|
128
196
|
}
|
|
129
197
|
attach(mqtt, handlers) {
|
|
130
|
-
// Teardown previous bindings if re-attaching to same or new client
|
|
131
198
|
this.detachListenersOnly();
|
|
132
199
|
this.mqtt = mqtt;
|
|
133
200
|
this.handlers = handlers;
|
|
@@ -139,6 +206,14 @@ class MqttSession {
|
|
|
139
206
|
var _a, _b;
|
|
140
207
|
(_b = (_a = this.handlers).onDisconnect) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
141
208
|
};
|
|
209
|
+
this.boundOffline = () => {
|
|
210
|
+
var _a, _b;
|
|
211
|
+
(_b = (_a = this.handlers).onOffline) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
212
|
+
};
|
|
213
|
+
this.boundReconnect = () => {
|
|
214
|
+
var _a, _b;
|
|
215
|
+
(_b = (_a = this.handlers).onReconnect) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
216
|
+
};
|
|
142
217
|
this.boundError = (error) => {
|
|
143
218
|
var _a, _b;
|
|
144
219
|
(_b = (_a = this.handlers).onError) === null || _b === void 0 ? void 0 : _b.call(_a, error);
|
|
@@ -147,14 +222,18 @@ class MqttSession {
|
|
|
147
222
|
var _a, _b;
|
|
148
223
|
void ((_b = (_a = this.handlers).onMessage) === null || _b === void 0 ? void 0 : _b.call(_a, topic, payload));
|
|
149
224
|
};
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
225
|
+
const { client } = mqtt;
|
|
226
|
+
client.on('connect', this.boundConnect);
|
|
227
|
+
client.on('disconnect', this.boundDisconnect);
|
|
228
|
+
client.on('offline', this.boundOffline);
|
|
229
|
+
client.on('reconnect', this.boundReconnect);
|
|
230
|
+
client.on('error', this.boundError);
|
|
153
231
|
this.listenersAttached = true;
|
|
154
232
|
}
|
|
155
233
|
subscribe(topic) {
|
|
156
234
|
if (!this.mqtt)
|
|
157
235
|
return;
|
|
236
|
+
this.desiredTopic = topic;
|
|
158
237
|
if (this.subscribedTopic === topic) {
|
|
159
238
|
this.ensureMessageListener();
|
|
160
239
|
return;
|
|
@@ -164,7 +243,7 @@ class MqttSession {
|
|
|
164
243
|
this.mqtt.client.unsubscribe(this.subscribedTopic);
|
|
165
244
|
}
|
|
166
245
|
catch (_a) {
|
|
167
|
-
|
|
246
|
+
/* ignore */
|
|
168
247
|
}
|
|
169
248
|
}
|
|
170
249
|
this.mqtt.client.subscribe(topic, err => {
|
|
@@ -176,6 +255,16 @@ class MqttSession {
|
|
|
176
255
|
});
|
|
177
256
|
this.ensureMessageListener();
|
|
178
257
|
}
|
|
258
|
+
/** After reconnect, force subscribe again even if topic string is unchanged. */
|
|
259
|
+
resubscribe() {
|
|
260
|
+
if (!this.desiredTopic)
|
|
261
|
+
return;
|
|
262
|
+
this.subscribedTopic = null;
|
|
263
|
+
this.subscribe(this.desiredTopic);
|
|
264
|
+
}
|
|
265
|
+
getDesiredTopic() {
|
|
266
|
+
return this.desiredTopic;
|
|
267
|
+
}
|
|
179
268
|
ensureMessageListener() {
|
|
180
269
|
if (!this.mqtt || this.messageListenerAttached || !this.boundMessage)
|
|
181
270
|
return;
|
|
@@ -193,6 +282,10 @@ class MqttSession {
|
|
|
193
282
|
removeClientListener(client, 'connect', this.boundConnect);
|
|
194
283
|
if (this.boundDisconnect)
|
|
195
284
|
removeClientListener(client, 'disconnect', this.boundDisconnect);
|
|
285
|
+
if (this.boundOffline)
|
|
286
|
+
removeClientListener(client, 'offline', this.boundOffline);
|
|
287
|
+
if (this.boundReconnect)
|
|
288
|
+
removeClientListener(client, 'reconnect', this.boundReconnect);
|
|
196
289
|
if (this.boundError)
|
|
197
290
|
removeClientListener(client, 'error', this.boundError);
|
|
198
291
|
if (this.boundMessage && this.messageListenerAttached) {
|
|
@@ -209,7 +302,7 @@ class MqttSession {
|
|
|
209
302
|
this.mqtt.client.unsubscribe(this.subscribedTopic);
|
|
210
303
|
}
|
|
211
304
|
catch (_a) {
|
|
212
|
-
|
|
305
|
+
/* ignore */
|
|
213
306
|
}
|
|
214
307
|
}
|
|
215
308
|
this.detachListenersOnly();
|
|
@@ -218,6 +311,7 @@ class MqttSession {
|
|
|
218
311
|
this.mqtt.disconnect();
|
|
219
312
|
}
|
|
220
313
|
else if (typeof this.mqtt.client.end === 'function') {
|
|
314
|
+
// force end — do not leave zombie reconnect loops after unmount
|
|
221
315
|
this.mqtt.client.end(true);
|
|
222
316
|
}
|
|
223
317
|
}
|
|
@@ -226,6 +320,7 @@ class MqttSession {
|
|
|
226
320
|
}
|
|
227
321
|
this.mqtt = null;
|
|
228
322
|
this.subscribedTopic = null;
|
|
323
|
+
this.desiredTopic = null;
|
|
229
324
|
this.handlers = {};
|
|
230
325
|
}
|
|
231
326
|
}
|
|
@@ -796,211 +891,234 @@ async function dispatchMqttMessage(parsedMessage, ctx) {
|
|
|
796
891
|
}
|
|
797
892
|
}
|
|
798
893
|
|
|
799
|
-
/**
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
});
|
|
815
|
-
}
|
|
816
|
-
function mergeUniqueConversations(existing, incoming) {
|
|
817
|
-
const list = Array.isArray(existing) ? existing : [];
|
|
818
|
-
const next = Array.isArray(incoming) ? incoming : [];
|
|
819
|
-
return [
|
|
820
|
-
...list,
|
|
821
|
-
...next.filter(newConv => !list.some(existingConv => existingConv.conversationId === newConv.conversationId)),
|
|
822
|
-
];
|
|
823
|
-
}
|
|
824
|
-
async function fetchConversationsPage(opts) {
|
|
825
|
-
var _a, _b, _c;
|
|
826
|
-
const query = {
|
|
827
|
-
limit: (_a = opts.limit) !== null && _a !== void 0 ? _a : 20,
|
|
828
|
-
skip: (_b = opts.skip) !== null && _b !== void 0 ? _b : 0,
|
|
829
|
-
includeMembers: (_c = opts.includeMembers) !== null && _c !== void 0 ? _c : true,
|
|
830
|
-
};
|
|
831
|
-
if (opts.searchTag)
|
|
832
|
-
query.searchTag = opts.searchTag;
|
|
833
|
-
const res = await M.getInstance().Conversation.getConversations(query);
|
|
834
|
-
return (res === null || res === void 0 ? void 0 : res.conversations) || [];
|
|
835
|
-
}
|
|
836
|
-
async function fetchConversationDetails(conversationId, includeMembers = true) {
|
|
837
|
-
const res = await M.getInstance().Conversation.getConversationDetails({ conversationId, includeMembers }, conversationId);
|
|
838
|
-
return res === null || res === void 0 ? void 0 : res.conversationDetails;
|
|
894
|
+
/**
|
|
895
|
+
* Serialize inbound MQTT handling per host so rapid messages don't race @State updates.
|
|
896
|
+
*/
|
|
897
|
+
const tails = new WeakMap();
|
|
898
|
+
/** Run `task` after any prior MQTT tasks for this host have finished. */
|
|
899
|
+
function enqueueMqttTask(host, task) {
|
|
900
|
+
const prev = tails.get(host) || Promise.resolve();
|
|
901
|
+
const next = prev
|
|
902
|
+
.then(() => task())
|
|
903
|
+
.catch(err => {
|
|
904
|
+
console.error('MQTT inbound task failed:', err);
|
|
905
|
+
})
|
|
906
|
+
.then(() => undefined);
|
|
907
|
+
tails.set(host, next);
|
|
908
|
+
return next;
|
|
839
909
|
}
|
|
840
910
|
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
licenseKey: config.licenseKey || isometrikFlutterAppSecrets.licenseKey,
|
|
846
|
-
appSecret: config.appSecret || isometrikFlutterAppSecrets.appSecret,
|
|
847
|
-
userSecret: config.userSecret || isometrikFlutterAppSecrets.userSecret,
|
|
848
|
-
userToken: config.userToken,
|
|
849
|
-
});
|
|
850
|
-
}
|
|
851
|
-
/** Normalize getUserDetails API response into the shape WebChat stores. */
|
|
852
|
-
async function fetchUserDetails() {
|
|
853
|
-
var _a, _b, _c;
|
|
854
|
-
const res = await M.getInstance().user.getUserDetails();
|
|
855
|
-
return {
|
|
856
|
-
userId: (res === null || res === void 0 ? void 0 : res.userId) || '',
|
|
857
|
-
userIdentifier: (res === null || res === void 0 ? void 0 : res.userIdentifier) || '',
|
|
858
|
-
firstName: ((_a = res === null || res === void 0 ? void 0 : res.metaData) === null || _a === void 0 ? void 0 : _a.firstName) || '',
|
|
859
|
-
lastName: ((_b = res === null || res === void 0 ? void 0 : res.metaData) === null || _b === void 0 ? void 0 : _b.lastName) || '',
|
|
860
|
-
updatedAt: (res === null || res === void 0 ? void 0 : res.updatedAt) || '',
|
|
861
|
-
userName: (res === null || res === void 0 ? void 0 : res.userName) || '',
|
|
862
|
-
online: (res === null || res === void 0 ? void 0 : res.online) || '',
|
|
863
|
-
userProfileImageUrl: (res === null || res === void 0 ? void 0 : res.userProfileImageUrl) || '',
|
|
864
|
-
profilePic: ((_c = res === null || res === void 0 ? void 0 : res.metaData) === null || _c === void 0 ? void 0 : _c.profilePic) || '',
|
|
865
|
-
};
|
|
866
|
-
}
|
|
911
|
+
const getTotalUnreadConversationsCount = async () => {
|
|
912
|
+
const response = await M.getInstance().Conversation.getConversationUnreadCount();
|
|
913
|
+
return response?.count;
|
|
914
|
+
};
|
|
867
915
|
|
|
868
|
-
|
|
916
|
+
/**
|
|
917
|
+
* Wire OfflineClient into <web-chat> lifecycle.
|
|
918
|
+
*/
|
|
919
|
+
function userIdOf(host) {
|
|
869
920
|
var _a;
|
|
870
|
-
|
|
871
|
-
|
|
921
|
+
return ((_a = host.userMetaData) === null || _a === void 0 ? void 0 : _a.userId) || host.isometrikUserId || host.isometrikUserIdFromCookie || null;
|
|
922
|
+
}
|
|
923
|
+
function hostInitOffline(host) {
|
|
924
|
+
const client = getOfflineClient();
|
|
925
|
+
const uid = userIdOf(host);
|
|
926
|
+
if (uid)
|
|
927
|
+
client.setUser(uid);
|
|
928
|
+
client.startTabSync(event => {
|
|
929
|
+
var _a;
|
|
930
|
+
if (event.type === 'messages' && event.conversationId === host.selectedConversationId) {
|
|
931
|
+
host.allMessages = mergeMessagesById(host.allMessages || [], event.messages || []);
|
|
932
|
+
}
|
|
933
|
+
if (event.type === 'conversations') {
|
|
934
|
+
// Prefer newer network list; only fill gaps from peer tab
|
|
935
|
+
const incoming = event.conversations || [];
|
|
936
|
+
if (!((_a = host.allConversationList) === null || _a === void 0 ? void 0 : _a.length) && incoming.length) {
|
|
937
|
+
host.allConversationList = incoming;
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
});
|
|
941
|
+
if (typeof window !== 'undefined') {
|
|
942
|
+
host._onOnline = () => {
|
|
943
|
+
void hostFlushOutbox(host);
|
|
944
|
+
};
|
|
945
|
+
window.addEventListener('online', host._onOnline);
|
|
946
|
+
}
|
|
872
947
|
}
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
948
|
+
function hostTeardownOffline(host) {
|
|
949
|
+
getOfflineClient().stopTabSync();
|
|
950
|
+
if (typeof window !== 'undefined' && host._onOnline) {
|
|
951
|
+
window.removeEventListener('online', host._onOnline);
|
|
952
|
+
host._onOnline = null;
|
|
953
|
+
}
|
|
876
954
|
}
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
const
|
|
880
|
-
|
|
955
|
+
/** Paint cached conversations immediately (before network). */
|
|
956
|
+
async function hostHydrateConversationsFromCache(host) {
|
|
957
|
+
const uid = userIdOf(host);
|
|
958
|
+
if (!uid)
|
|
959
|
+
return;
|
|
960
|
+
try {
|
|
961
|
+
const cached = await getOfflineClient().loadConversations(uid);
|
|
962
|
+
if (cached.length && (!host.allConversationList || host.allConversationList.length === 0)) {
|
|
963
|
+
host.allConversationList = cached;
|
|
964
|
+
}
|
|
965
|
+
}
|
|
966
|
+
catch (e) {
|
|
967
|
+
console.error('offline hydrate conversations failed', e);
|
|
968
|
+
}
|
|
881
969
|
}
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
return 3;
|
|
897
|
-
}
|
|
898
|
-
function customTypeFromMime(mime) {
|
|
899
|
-
if (!mime)
|
|
900
|
-
return 'AttachmentMessage:Multiple';
|
|
901
|
-
if (mime.startsWith('image/'))
|
|
902
|
-
return 'AttachmentMessage:Image';
|
|
903
|
-
if (mime.startsWith('video/'))
|
|
904
|
-
return 'AttachmentMessage:Video';
|
|
905
|
-
if (mime.startsWith('audio/'))
|
|
906
|
-
return 'AttachmentMessage:Audio';
|
|
907
|
-
if (mime.startsWith('application/'))
|
|
908
|
-
return 'AttachmentMessage:Doc';
|
|
909
|
-
return 'AttachmentMessage:Multiple';
|
|
910
|
-
}
|
|
911
|
-
function buildReplyMetaData(replyMessage, caption) {
|
|
912
|
-
var _a, _b, _c;
|
|
913
|
-
if (!replyMessage && !(caption === null || caption === void 0 ? void 0 : caption.trim()))
|
|
914
|
-
return {};
|
|
915
|
-
return Object.assign(Object.assign({}, (replyMessage && Object.assign({ parentMessageId: replyMessage.messageId, parentMessage: replyMessage.body, parentMessageTime: replyMessage.sentAt, parentMessageSenderId: ((_a = replyMessage.senderInfo) === null || _a === void 0 ? void 0 : _a.userId) || replyMessage.senderId, parentMessageSenderName: ((_b = replyMessage.senderInfo) === null || _b === void 0 ? void 0 : _b.userName) || replyMessage.userName }, (((_c = replyMessage === null || replyMessage === void 0 ? void 0 : replyMessage.attachments) === null || _c === void 0 ? void 0 : _c[0]) && {
|
|
916
|
-
parentMessageName: replyMessage.attachments[0].name,
|
|
917
|
-
parentMessageMediaUrl: replyMessage.attachments[0].mediaUrl,
|
|
918
|
-
parentMessageType: replyMessage.attachments[0].mimeType,
|
|
919
|
-
})))), ((caption === null || caption === void 0 ? void 0 : caption.trim()) && { captionMessage: caption.trim() }));
|
|
920
|
-
}
|
|
921
|
-
function prepareMediaAttachments(files) {
|
|
922
|
-
return files.map(file => ({
|
|
923
|
-
nameWithExtension: file.name,
|
|
924
|
-
mediaType: mediaTypeFromMime(file.type),
|
|
925
|
-
mediaId: String(file.lastModified || Date.now()),
|
|
926
|
-
mimeType: file.type || 'application/octet-stream',
|
|
927
|
-
size: file.size,
|
|
928
|
-
file,
|
|
929
|
-
}));
|
|
970
|
+
async function hostHydrateMessagesFromCache(host, conversationId) {
|
|
971
|
+
const uid = userIdOf(host);
|
|
972
|
+
const id = conversationId || host.selectedConversationId;
|
|
973
|
+
if (!uid || !id)
|
|
974
|
+
return;
|
|
975
|
+
try {
|
|
976
|
+
const cached = await getOfflineClient().loadMessages(uid, id);
|
|
977
|
+
if (cached.length) {
|
|
978
|
+
host.allMessages = mergeMessagesById(host.allMessages || [], cached);
|
|
979
|
+
}
|
|
980
|
+
}
|
|
981
|
+
catch (e) {
|
|
982
|
+
console.error('offline hydrate messages failed', e);
|
|
983
|
+
}
|
|
930
984
|
}
|
|
931
|
-
function
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
}
|
|
985
|
+
async function hostPersistConversations(host) {
|
|
986
|
+
var _a;
|
|
987
|
+
const uid = userIdOf(host);
|
|
988
|
+
if (!uid || !((_a = host.allConversationList) === null || _a === void 0 ? void 0 : _a.length))
|
|
989
|
+
return;
|
|
990
|
+
try {
|
|
991
|
+
await getOfflineClient().persistConversations(uid, host.allConversationList);
|
|
992
|
+
}
|
|
993
|
+
catch (e) {
|
|
994
|
+
console.error('offline persist conversations failed', e);
|
|
995
|
+
}
|
|
939
996
|
}
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
const
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
997
|
+
async function hostPersistMessages(host, conversationId) {
|
|
998
|
+
var _a;
|
|
999
|
+
const uid = userIdOf(host);
|
|
1000
|
+
const id = conversationId || host.selectedConversationId;
|
|
1001
|
+
if (!uid || !id || !((_a = host.allMessages) === null || _a === void 0 ? void 0 : _a.length))
|
|
1002
|
+
return;
|
|
1003
|
+
try {
|
|
1004
|
+
await getOfflineClient().persistMessages(uid, id, host.allMessages);
|
|
1005
|
+
const last = host.allMessages[host.allMessages.length - 1];
|
|
1006
|
+
const cursor = (last === null || last === void 0 ? void 0 : last.sentAt) || (last === null || last === void 0 ? void 0 : last.updatedAt) || Date.now();
|
|
1007
|
+
await getOfflineClient().setCursor(uid, id, cursor);
|
|
1008
|
+
}
|
|
1009
|
+
catch (e) {
|
|
1010
|
+
console.error('offline persist messages failed', e);
|
|
1011
|
+
}
|
|
1012
|
+
}
|
|
1013
|
+
async function hostEnqueueFailedText(host, opts) {
|
|
1014
|
+
var _a, _b, _c;
|
|
1015
|
+
const uid = userIdOf(host);
|
|
1016
|
+
if (!uid)
|
|
1017
|
+
return;
|
|
1018
|
+
const reply = host.replyMessage;
|
|
1019
|
+
await getOfflineClient().enqueueText({
|
|
1020
|
+
localId: opts.localId,
|
|
1021
|
+
userId: uid,
|
|
1022
|
+
conversationId: opts.conversationId,
|
|
1023
|
+
body: opts.body,
|
|
1024
|
+
metaData: (_a = opts.localMessage) === null || _a === void 0 ? void 0 : _a.metaData,
|
|
1025
|
+
messageType: (_c = (_b = opts.localMessage) === null || _b === void 0 ? void 0 : _b.messageType) !== null && _c !== void 0 ? _c : 0,
|
|
1026
|
+
parentMessageId: reply === null || reply === void 0 ? void 0 : reply.messageId,
|
|
1027
|
+
customType: opts.body.match(/(https?:\/\/[^\s]+)/g)
|
|
1028
|
+
? 'AttachmentMessage:Link'
|
|
1029
|
+
: 'AttachmentMessage:Text',
|
|
1030
|
+
searchableTags: opts.body.split(/\s+/).filter(Boolean).slice(0, 20),
|
|
948
1031
|
});
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
1032
|
+
// Mark bubble as pending/outbox so UI can show retry state
|
|
1033
|
+
host.allMessages = (host.allMessages || []).map((m) => m.messageId === opts.localId
|
|
1034
|
+
? Object.assign(Object.assign({}, m), { deliveredToAll: 'pending', deliveryStatus: 'outbox', outbox: true }) : m);
|
|
1035
|
+
await hostPersistMessages(host, opts.conversationId);
|
|
1036
|
+
}
|
|
1037
|
+
async function hostEnqueueFailedMedia(host, opts) {
|
|
1038
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1039
|
+
const uid = userIdOf(host);
|
|
1040
|
+
if (!uid)
|
|
1041
|
+
return;
|
|
1042
|
+
const mediaFiles = await filesToOutboxMedia(opts.files);
|
|
1043
|
+
if (!mediaFiles.length)
|
|
1044
|
+
return;
|
|
1045
|
+
const reply = host.replyMessage;
|
|
1046
|
+
await getOfflineClient().enqueueMedia({
|
|
1047
|
+
localId: opts.localId,
|
|
1048
|
+
userId: uid,
|
|
1049
|
+
conversationId: opts.conversationId,
|
|
1050
|
+
body: ((_a = opts.caption) === null || _a === void 0 ? void 0 : _a.trim()) || ((_b = opts.localMessage) === null || _b === void 0 ? void 0 : _b.body) || 'AttachmentMessage:Multiple',
|
|
1051
|
+
caption: opts.caption,
|
|
1052
|
+
mediaFiles,
|
|
1053
|
+
metaData: (_c = opts.localMessage) === null || _c === void 0 ? void 0 : _c.metaData,
|
|
1054
|
+
messageType: (_e = (_d = opts.localMessage) === null || _d === void 0 ? void 0 : _d.messageType) !== null && _e !== void 0 ? _e : 0,
|
|
1055
|
+
parentMessageId: reply === null || reply === void 0 ? void 0 : reply.messageId,
|
|
1056
|
+
customType: ((_f = opts.localMessage) === null || _f === void 0 ? void 0 : _f.customType) || 'AttachmentMessage:Multiple',
|
|
1057
|
+
});
|
|
1058
|
+
host.allMessages = (host.allMessages || []).map((m) => m.messageId === opts.localId
|
|
1059
|
+
? Object.assign(Object.assign({}, m), { deliveredToAll: 'pending', deliveryStatus: 'outbox', outbox: true }) : m);
|
|
1060
|
+
await hostPersistMessages(host, opts.conversationId);
|
|
1061
|
+
}
|
|
1062
|
+
async function sendOutboxItem(host, item) {
|
|
1063
|
+
var _a;
|
|
1064
|
+
const deviceId = host.deviceId || (await getDeviceID());
|
|
1065
|
+
if (item.kind === 'media') {
|
|
1066
|
+
const files = outboxMediaToFiles(item.mediaFiles);
|
|
1067
|
+
if (!files.length)
|
|
1068
|
+
throw new Error('Media outbox item has no files');
|
|
1069
|
+
const attachments = prepareMediaAttachments(files);
|
|
1070
|
+
const apiId = await uploadAndPostMediaMessage({
|
|
1071
|
+
conversationId: item.conversationId,
|
|
1072
|
+
deviceId,
|
|
1073
|
+
attachments,
|
|
1074
|
+
caption: item.caption || item.body,
|
|
1075
|
+
replyMessage: item.parentMessageId
|
|
1076
|
+
? { messageId: item.parentMessageId }
|
|
1077
|
+
: null,
|
|
979
1078
|
});
|
|
980
|
-
|
|
981
|
-
|
|
1079
|
+
if (apiId && item.conversationId === host.selectedConversationId) {
|
|
1080
|
+
host.allMessages = (host.allMessages || []).map((m) => m.messageId === item.localId
|
|
1081
|
+
? Object.assign(Object.assign({}, m), { messageId: apiId, deliveredToAll: false, outbox: false, deliveryStatus: 'sent' }) : m);
|
|
1082
|
+
await hostPersistMessages(host, item.conversationId);
|
|
1083
|
+
}
|
|
1084
|
+
return apiId || null;
|
|
1085
|
+
}
|
|
982
1086
|
const payload = {
|
|
983
1087
|
showInConversation: true,
|
|
984
|
-
messageType:
|
|
985
|
-
parentMessageId:
|
|
1088
|
+
messageType: (_a = item.messageType) !== null && _a !== void 0 ? _a : 0,
|
|
1089
|
+
parentMessageId: item.parentMessageId,
|
|
1090
|
+
searchableTags: item.searchableTags || [],
|
|
986
1091
|
encrypted: false,
|
|
987
|
-
conversationId,
|
|
988
|
-
body: (caption === null || caption === void 0 ? void 0 : caption.trim()) || 'AttachmentMessage:Multiple',
|
|
989
|
-
customType,
|
|
990
|
-
attachments: allPayloads,
|
|
1092
|
+
conversationId: item.conversationId,
|
|
991
1093
|
deviceId,
|
|
992
|
-
|
|
1094
|
+
customType: item.customType || 'AttachmentMessage:Text',
|
|
1095
|
+
body: item.body,
|
|
1096
|
+
metaData: item.metaData || {},
|
|
993
1097
|
};
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
1098
|
+
const res = await M.getInstance().message.postMessages(payload);
|
|
1099
|
+
const apiId = res === null || res === void 0 ? void 0 : res.messageId;
|
|
1100
|
+
if (apiId && item.conversationId === host.selectedConversationId) {
|
|
1101
|
+
host.allMessages = (host.allMessages || []).map((m) => m.messageId === item.localId
|
|
1102
|
+
? Object.assign(Object.assign({}, m), { messageId: apiId, deliveredToAll: false, outbox: false, deliveryStatus: 'sent' }) : m);
|
|
1103
|
+
await hostPersistMessages(host, item.conversationId);
|
|
1104
|
+
}
|
|
1105
|
+
return apiId || null;
|
|
1106
|
+
}
|
|
1107
|
+
async function hostFlushOutbox(host) {
|
|
1108
|
+
var _a;
|
|
1109
|
+
const uid = userIdOf(host);
|
|
1110
|
+
if (!uid || !isBrowserOnline())
|
|
1111
|
+
return;
|
|
1112
|
+
try {
|
|
1113
|
+
const result = await getOfflineClient().flushOutbox(uid, item => sendOutboxItem(host, item));
|
|
1114
|
+
if (result.sent > 0) {
|
|
1115
|
+
void Promise.resolve((_a = host.getConversations) === null || _a === void 0 ? void 0 : _a.call(host, 0)).catch(() => undefined);
|
|
1116
|
+
}
|
|
1117
|
+
}
|
|
1118
|
+
catch (e) {
|
|
1119
|
+
console.error('outbox flush failed', e);
|
|
1120
|
+
}
|
|
998
1121
|
}
|
|
999
|
-
|
|
1000
|
-
const getTotalUnreadConversationsCount = async () => {
|
|
1001
|
-
const response = await M.getInstance().Conversation.getConversationUnreadCount();
|
|
1002
|
-
return response?.count;
|
|
1003
|
-
};
|
|
1004
1122
|
|
|
1005
1123
|
/**
|
|
1006
1124
|
* Ordered startup for <web-chat>.
|
|
@@ -1018,6 +1136,9 @@ const getTotalUnreadConversationsCount = async () => {
|
|
|
1018
1136
|
*/
|
|
1019
1137
|
async function bootstrapWebChat(host, generation) {
|
|
1020
1138
|
try {
|
|
1139
|
+
hostInitOffline(host);
|
|
1140
|
+
// Instant paint from IndexedDB while network warms up
|
|
1141
|
+
void hostHydrateConversationsFromCache(host);
|
|
1021
1142
|
try {
|
|
1022
1143
|
host.updateLoading(10, 'Preparing secure session…');
|
|
1023
1144
|
const deviceId = await getDeviceID();
|
|
@@ -1056,6 +1177,8 @@ async function bootstrapWebChat(host, generation) {
|
|
|
1056
1177
|
try {
|
|
1057
1178
|
host.updateLoading(55, 'Fetching users…');
|
|
1058
1179
|
await host.getUserDetails();
|
|
1180
|
+
hostInitOffline(host); // re-bind userId after profile load
|
|
1181
|
+
void hostHydrateConversationsFromCache(host);
|
|
1059
1182
|
}
|
|
1060
1183
|
catch (userError) {
|
|
1061
1184
|
console.error('Failed to get user details:', userError);
|
|
@@ -1110,6 +1233,7 @@ async function bootstrapWebChat(host, generation) {
|
|
|
1110
1233
|
host.checkMobileView();
|
|
1111
1234
|
window.addEventListener('resize', host.boundCheckMobileView);
|
|
1112
1235
|
host.updateLoading(100, 'Almost ready…');
|
|
1236
|
+
void hostFlushOutbox(host);
|
|
1113
1237
|
}
|
|
1114
1238
|
catch (error) {
|
|
1115
1239
|
console.error('Critical initialization error:', error);
|
|
@@ -1182,6 +1306,7 @@ async function hostGetConversations(host, skip = 0, searchTag = null, showLoader
|
|
|
1182
1306
|
try {
|
|
1183
1307
|
const conversations = await fetchConversationsPage({ skip, searchTag });
|
|
1184
1308
|
host.allConversationList = mergeUniqueConversations(host.allConversationList, conversations);
|
|
1309
|
+
void hostPersistConversations(host);
|
|
1185
1310
|
}
|
|
1186
1311
|
catch (error) {
|
|
1187
1312
|
console.error('getConversations fetching error', error);
|
|
@@ -1225,17 +1350,23 @@ async function hostGetMessages(host, skip, conversationId) {
|
|
|
1225
1350
|
conversationId: conversationId || host.selectedConversationId,
|
|
1226
1351
|
skip,
|
|
1227
1352
|
});
|
|
1353
|
+
const targetId = conversationId || host.selectedConversationId;
|
|
1228
1354
|
if (skip == 0) {
|
|
1229
|
-
if (conversationId)
|
|
1230
|
-
host.selectConversationMessages = [
|
|
1231
|
-
|
|
1232
|
-
|
|
1355
|
+
if (conversationId) {
|
|
1356
|
+
host.selectConversationMessages = mergeMessagesById(host.selectConversationMessages || [], messages);
|
|
1357
|
+
}
|
|
1358
|
+
else {
|
|
1359
|
+
// Merge with any optimistic/outbox rows already on screen
|
|
1360
|
+
host.allMessages = mergeMessagesById(host.allMessages || [], messages);
|
|
1361
|
+
}
|
|
1233
1362
|
}
|
|
1234
1363
|
else {
|
|
1235
|
-
host.allMessages =
|
|
1364
|
+
host.allMessages = mergeMessagesById(messages, host.allMessages || []);
|
|
1236
1365
|
}
|
|
1237
1366
|
// API 404s a page past the end; a short page means this page is the last.
|
|
1238
1367
|
host.isMessageLimitEnd = messages.length < 20;
|
|
1368
|
+
if (targetId)
|
|
1369
|
+
void hostPersistMessages(host, targetId);
|
|
1239
1370
|
}
|
|
1240
1371
|
catch (error) {
|
|
1241
1372
|
if ((error === null || error === void 0 ? void 0 : error.status) === 404 || (error === null || error === void 0 ? void 0 : error.statusCode) === 404) {
|
|
@@ -1371,7 +1502,7 @@ async function hostSendText(host, body, conversationId) {
|
|
|
1371
1502
|
const deviceId = host.deviceId || (await getDeviceID());
|
|
1372
1503
|
const localId = `localId${Date.now()}${Math.random() * 100}`;
|
|
1373
1504
|
const reply = host.replyMessage;
|
|
1374
|
-
const localMessage = Object.assign({ body: text, messageId: localId, deliveredToAll: 'pending', senderId: (_a = host.userMetaData) === null || _a === void 0 ? void 0 : _a.userId, messageType: reply ? 2 : 0, sentAt: Date.now() }, (reply && {
|
|
1505
|
+
const localMessage = Object.assign({ body: text, messageId: localId, deliveredToAll: 'pending', deliveryStatus: 'sending', senderId: (_a = host.userMetaData) === null || _a === void 0 ? void 0 : _a.userId, messageType: reply ? 2 : 0, sentAt: Date.now() }, (reply && {
|
|
1375
1506
|
parentMessageId: reply.messageId,
|
|
1376
1507
|
metaData: {
|
|
1377
1508
|
parentMessageId: reply.messageId,
|
|
@@ -1384,6 +1515,26 @@ async function hostSendText(host, body, conversationId) {
|
|
|
1384
1515
|
host.allMessages = [...host.allMessages, localMessage];
|
|
1385
1516
|
host.isMessageSending = true;
|
|
1386
1517
|
host.isScrollToBottom = true;
|
|
1518
|
+
const bumpConversationPreview = () => {
|
|
1519
|
+
host.allConversationList = sortConversationsByLatestMessage(host.allConversationList.map(c => {
|
|
1520
|
+
var _a;
|
|
1521
|
+
return c.conversationId === id
|
|
1522
|
+
? Object.assign(Object.assign({}, c), { lastMessageDetails: Object.assign(Object.assign({}, c.lastMessageDetails), { body: text, updatedAt: Date.now(), senderId: (_a = host.userMetaData) === null || _a === void 0 ? void 0 : _a.userId }) }) : c;
|
|
1523
|
+
}));
|
|
1524
|
+
};
|
|
1525
|
+
// Offline → optimistic bubble + outbox (sent when back online)
|
|
1526
|
+
if (!isBrowserOnline()) {
|
|
1527
|
+
await hostEnqueueFailedText(host, { localId, conversationId: id, body: text, localMessage });
|
|
1528
|
+
bumpConversationPreview();
|
|
1529
|
+
host.replyMessage = null;
|
|
1530
|
+
host.isMessageSending = false;
|
|
1531
|
+
showToast({
|
|
1532
|
+
message: 'You’re offline — message queued',
|
|
1533
|
+
type: 'warning',
|
|
1534
|
+
position: 'bottom-right',
|
|
1535
|
+
});
|
|
1536
|
+
return localId;
|
|
1537
|
+
}
|
|
1387
1538
|
try {
|
|
1388
1539
|
const payload = {
|
|
1389
1540
|
showInConversation: true,
|
|
@@ -1400,21 +1551,26 @@ async function hostSendText(host, body, conversationId) {
|
|
|
1400
1551
|
const res = await M.getInstance().message.postMessages(payload);
|
|
1401
1552
|
const apiId = res === null || res === void 0 ? void 0 : res.messageId;
|
|
1402
1553
|
if (apiId) {
|
|
1403
|
-
host.allMessages = host.allMessages.map(m => m.messageId === localId
|
|
1554
|
+
host.allMessages = host.allMessages.map(m => m.messageId === localId
|
|
1555
|
+
? Object.assign(Object.assign({}, m), { messageId: apiId, deliveredToAll: false, deliveryStatus: 'sent' }) : m);
|
|
1404
1556
|
}
|
|
1405
|
-
|
|
1406
|
-
var _a;
|
|
1407
|
-
return c.conversationId === id
|
|
1408
|
-
? Object.assign(Object.assign({}, c), { lastMessageDetails: Object.assign(Object.assign({}, c.lastMessageDetails), { body: text, updatedAt: Date.now(), senderId: (_a = host.userMetaData) === null || _a === void 0 ? void 0 : _a.userId }) }) : c;
|
|
1409
|
-
}));
|
|
1557
|
+
bumpConversationPreview();
|
|
1410
1558
|
host.replyMessage = null;
|
|
1559
|
+
void hostPersistMessages(host, id);
|
|
1411
1560
|
return apiId || localId;
|
|
1412
1561
|
}
|
|
1413
1562
|
catch (error) {
|
|
1414
1563
|
console.error('web-chat sendText failed', error);
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1564
|
+
// Keep bubble + queue for retry (network blip / server error)
|
|
1565
|
+
await hostEnqueueFailedText(host, { localId, conversationId: id, body: text, localMessage });
|
|
1566
|
+
bumpConversationPreview();
|
|
1567
|
+
host.emitChatError('sendText', (error === null || error === void 0 ? void 0 : error.message) || 'Failed to send — queued for retry', error);
|
|
1568
|
+
showToast({
|
|
1569
|
+
message: (error === null || error === void 0 ? void 0 : error.message) || 'Send failed — queued for retry',
|
|
1570
|
+
type: 'warning',
|
|
1571
|
+
position: 'bottom-right',
|
|
1572
|
+
});
|
|
1573
|
+
return localId;
|
|
1418
1574
|
}
|
|
1419
1575
|
finally {
|
|
1420
1576
|
host.isMessageSending = false;
|
|
@@ -1422,22 +1578,59 @@ async function hostSendText(host, body, conversationId) {
|
|
|
1422
1578
|
}
|
|
1423
1579
|
async function hostSendMedia(host, files, conversationId, caption) {
|
|
1424
1580
|
var _a;
|
|
1425
|
-
const
|
|
1581
|
+
const raw = Array.from(files || []).filter(Boolean);
|
|
1582
|
+
const { accepted: list, rejected } = takeMediaFiles(raw, 0);
|
|
1426
1583
|
const id = conversationId || host.selectedConversationId;
|
|
1427
|
-
if (!
|
|
1584
|
+
if (!raw.length || !id) {
|
|
1428
1585
|
host.emitChatError('sendMedia', 'Missing files or conversationId');
|
|
1429
1586
|
return null;
|
|
1430
1587
|
}
|
|
1588
|
+
if (rejected > 0) {
|
|
1589
|
+
showToast({
|
|
1590
|
+
message: mediaLimitToastMessage(rejected, MAX_MEDIA_PER_MESSAGE),
|
|
1591
|
+
type: 'warning',
|
|
1592
|
+
position: 'bottom-right',
|
|
1593
|
+
});
|
|
1594
|
+
}
|
|
1595
|
+
if (!list.length) {
|
|
1596
|
+
host.emitChatError('sendMedia', `Max ${MAX_MEDIA_PER_MESSAGE} files per message`);
|
|
1597
|
+
return null;
|
|
1598
|
+
}
|
|
1431
1599
|
const deviceId = host.deviceId || (await getDeviceID());
|
|
1432
1600
|
const reply = host.replyMessage;
|
|
1433
1601
|
const localId = `${Date.now()}${Math.random() * 100}`;
|
|
1434
1602
|
const attachments = prepareMediaAttachments(list);
|
|
1435
1603
|
const localAttachments = buildLocalMediaAttachments(list);
|
|
1436
1604
|
const body = (caption || '').trim() || 'AttachmentMessage:Multiple';
|
|
1437
|
-
const localMessage = Object.assign({ body, messageId: localId, deliveredToAll: 'pending', senderId: (_a = host.userMetaData) === null || _a === void 0 ? void 0 : _a.userId, messageType: reply ? 2 : 0, sentAt: Date.now(), attachments: localAttachments, customType: list.length === 1 ? customTypeFromMime(list[0].type) : 'AttachmentMessage:Multiple', metaData: buildReplyMetaData(reply, caption) }, (reply && { parentMessageId: reply.messageId }));
|
|
1605
|
+
const localMessage = Object.assign({ body, messageId: localId, deliveredToAll: 'pending', deliveryStatus: 'sending', senderId: (_a = host.userMetaData) === null || _a === void 0 ? void 0 : _a.userId, messageType: reply ? 2 : 0, sentAt: Date.now(), attachments: localAttachments, customType: list.length === 1 ? customTypeFromMime(list[0].type) : 'AttachmentMessage:Multiple', metaData: buildReplyMetaData(reply, caption) }, (reply && { parentMessageId: reply.messageId }));
|
|
1438
1606
|
host.allMessages = [...host.allMessages, localMessage];
|
|
1439
1607
|
host.isMessageSending = true;
|
|
1440
1608
|
host.isScrollToBottom = true;
|
|
1609
|
+
const bumpConversationPreview = () => {
|
|
1610
|
+
host.allConversationList = sortConversationsByLatestMessage(host.allConversationList.map(c => {
|
|
1611
|
+
var _a;
|
|
1612
|
+
return c.conversationId === id
|
|
1613
|
+
? Object.assign(Object.assign({}, c), { lastMessageDetails: Object.assign(Object.assign({}, c.lastMessageDetails), { body: localMessage.customType || body, updatedAt: Date.now(), senderId: (_a = host.userMetaData) === null || _a === void 0 ? void 0 : _a.userId }) }) : c;
|
|
1614
|
+
}));
|
|
1615
|
+
};
|
|
1616
|
+
if (!isBrowserOnline()) {
|
|
1617
|
+
await hostEnqueueFailedMedia(host, {
|
|
1618
|
+
localId,
|
|
1619
|
+
conversationId: id,
|
|
1620
|
+
files: list,
|
|
1621
|
+
caption,
|
|
1622
|
+
localMessage,
|
|
1623
|
+
});
|
|
1624
|
+
bumpConversationPreview();
|
|
1625
|
+
host.replyMessage = null;
|
|
1626
|
+
host.isMessageSending = false;
|
|
1627
|
+
showToast({
|
|
1628
|
+
message: 'You’re offline — media queued',
|
|
1629
|
+
type: 'warning',
|
|
1630
|
+
position: 'bottom-right',
|
|
1631
|
+
});
|
|
1632
|
+
return localId;
|
|
1633
|
+
}
|
|
1441
1634
|
try {
|
|
1442
1635
|
const apiId = await uploadAndPostMediaMessage({
|
|
1443
1636
|
conversationId: id,
|
|
@@ -1447,21 +1640,31 @@ async function hostSendMedia(host, files, conversationId, caption) {
|
|
|
1447
1640
|
caption,
|
|
1448
1641
|
});
|
|
1449
1642
|
if (apiId) {
|
|
1450
|
-
host.allMessages = host.allMessages.map(m => m.messageId === localId
|
|
1643
|
+
host.allMessages = host.allMessages.map(m => m.messageId === localId
|
|
1644
|
+
? Object.assign(Object.assign({}, m), { messageId: apiId, deliveredToAll: false, deliveryStatus: 'sent' }) : m);
|
|
1451
1645
|
}
|
|
1452
|
-
|
|
1453
|
-
var _a;
|
|
1454
|
-
return c.conversationId === id
|
|
1455
|
-
? Object.assign(Object.assign({}, c), { lastMessageDetails: Object.assign(Object.assign({}, c.lastMessageDetails), { body: localMessage.customType || body, updatedAt: Date.now(), senderId: (_a = host.userMetaData) === null || _a === void 0 ? void 0 : _a.userId }) }) : c;
|
|
1456
|
-
}));
|
|
1646
|
+
bumpConversationPreview();
|
|
1457
1647
|
host.replyMessage = null;
|
|
1648
|
+
void hostPersistMessages(host, id);
|
|
1458
1649
|
return apiId || localId;
|
|
1459
1650
|
}
|
|
1460
1651
|
catch (error) {
|
|
1461
1652
|
console.error('web-chat sendMedia failed', error);
|
|
1653
|
+
await hostEnqueueFailedMedia(host, {
|
|
1654
|
+
localId,
|
|
1655
|
+
conversationId: id,
|
|
1656
|
+
files: list,
|
|
1657
|
+
caption,
|
|
1658
|
+
localMessage,
|
|
1659
|
+
});
|
|
1660
|
+
bumpConversationPreview();
|
|
1462
1661
|
host.emitChatError('sendMedia', (error === null || error === void 0 ? void 0 : error.message) || 'Failed to send media', error);
|
|
1463
|
-
showToast({
|
|
1464
|
-
|
|
1662
|
+
showToast({
|
|
1663
|
+
message: (error === null || error === void 0 ? void 0 : error.message) || 'Send failed — media queued for retry',
|
|
1664
|
+
type: 'warning',
|
|
1665
|
+
position: 'bottom-right',
|
|
1666
|
+
});
|
|
1667
|
+
return localId;
|
|
1465
1668
|
}
|
|
1466
1669
|
finally {
|
|
1467
1670
|
host.isMessageSending = false;
|
|
@@ -1568,18 +1771,39 @@ function createMqttContext(host) {
|
|
|
1568
1771
|
|
|
1569
1772
|
/**
|
|
1570
1773
|
* MQTT connect / subscribe / forward for <web-chat>.
|
|
1774
|
+
*
|
|
1775
|
+
* Butter path:
|
|
1776
|
+
* - mqtt.js auto-reconnect (bounded period)
|
|
1777
|
+
* - on every connect → resubscribe + gap-fill (soft merge, no UI wipe)
|
|
1778
|
+
* - while offline → light REST poll for open thread only
|
|
1779
|
+
* - inbound messages processed on a per-host serial queue
|
|
1571
1780
|
*/
|
|
1781
|
+
const OFFLINE_POLL_MS = 15000;
|
|
1572
1782
|
function hostAppendInboundMessage(host, parsedMessage) {
|
|
1573
1783
|
host.allMessages = appendUniqueById(host.allMessages, parsedMessage);
|
|
1784
|
+
void hostPersistMessages(host);
|
|
1574
1785
|
}
|
|
1786
|
+
/**
|
|
1787
|
+
* Build MQTT dispatch context from the live <web-chat> host.
|
|
1788
|
+
*
|
|
1789
|
+
* Do NOT `{...host}` / `Object.assign({}, host)` — Stencil `@State` (e.g.
|
|
1790
|
+
* `allConversationList`) lives behind prototype getters. A plain snapshot
|
|
1791
|
+
* drops them → `undefined.some` on `chatMessageSent` and realtime dies
|
|
1792
|
+
* even though MQTT is connected.
|
|
1793
|
+
*/
|
|
1575
1794
|
function hostCreateMqttContext(host) {
|
|
1576
|
-
return createMqttContext(Object.assign(
|
|
1795
|
+
return createMqttContext(Object.assign(host, {
|
|
1796
|
+
handleForwardMessage: (msg) => hostHandleForwardMessage(host, msg),
|
|
1797
|
+
appendInboundMessage: (msg) => hostAppendInboundMessage(host, msg),
|
|
1798
|
+
}));
|
|
1577
1799
|
}
|
|
1578
1800
|
async function hostHandleMqttMessage(host, message) {
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1801
|
+
return enqueueMqttTask(host, async () => {
|
|
1802
|
+
const parsedMessage = parseMqttPayload(message);
|
|
1803
|
+
if (!parsedMessage)
|
|
1804
|
+
return;
|
|
1805
|
+
await dispatchMqttMessage(parsedMessage, hostCreateMqttContext(host));
|
|
1806
|
+
});
|
|
1583
1807
|
}
|
|
1584
1808
|
function hostSubscribeToMqtt(host) {
|
|
1585
1809
|
const userId = host.isometrikUserId || host.isometrikUserIdFromCookie;
|
|
@@ -1594,8 +1818,111 @@ function hostSubscribeToMqtt(host) {
|
|
|
1594
1818
|
host.isSubscribedToTopic = true;
|
|
1595
1819
|
host.isMessageListenerAttached = true;
|
|
1596
1820
|
}
|
|
1821
|
+
function clearOfflinePoll(host) {
|
|
1822
|
+
if (host.mqttRefetchInterval) {
|
|
1823
|
+
clearInterval(host.mqttRefetchInterval);
|
|
1824
|
+
host.mqttRefetchInterval = null;
|
|
1825
|
+
}
|
|
1826
|
+
}
|
|
1827
|
+
/** While MQTT is down, lightly refresh the open conversation (not a full wipe). */
|
|
1828
|
+
function startOfflinePoll(host) {
|
|
1829
|
+
if (host.mqttRefetchInterval)
|
|
1830
|
+
return;
|
|
1831
|
+
host.mqttRefetchInterval = setInterval(() => {
|
|
1832
|
+
if (host.isMqttConnected) {
|
|
1833
|
+
clearOfflinePoll(host);
|
|
1834
|
+
return;
|
|
1835
|
+
}
|
|
1836
|
+
void hostGapFillMessages(host);
|
|
1837
|
+
}, OFFLINE_POLL_MS);
|
|
1838
|
+
}
|
|
1839
|
+
/**
|
|
1840
|
+
* Soft gap-fill: fetch latest page and merge by messageId — no clearing the thread
|
|
1841
|
+
* (avoids flicker after reconnect).
|
|
1842
|
+
*/
|
|
1843
|
+
async function hostGapFillMessages(host) {
|
|
1844
|
+
const conversationId = host.selectedConversationId;
|
|
1845
|
+
if (!conversationId || typeof host.getMessages !== 'function')
|
|
1846
|
+
return;
|
|
1847
|
+
try {
|
|
1848
|
+
const page = await fetchMessagesPage({ conversationId, skip: 0 });
|
|
1849
|
+
if (!Array.isArray(page) || page.length === 0)
|
|
1850
|
+
return;
|
|
1851
|
+
const existing = Array.isArray(host.allMessages) ? host.allMessages : [];
|
|
1852
|
+
const byId = new Map();
|
|
1853
|
+
existing.forEach((m) => {
|
|
1854
|
+
if (m === null || m === void 0 ? void 0 : m.messageId)
|
|
1855
|
+
byId.set(m.messageId, m);
|
|
1856
|
+
});
|
|
1857
|
+
page.forEach((m) => {
|
|
1858
|
+
if (m === null || m === void 0 ? void 0 : m.messageId)
|
|
1859
|
+
byId.set(m.messageId, m);
|
|
1860
|
+
});
|
|
1861
|
+
const merged = Array.from(byId.values()).sort((a, b) => {
|
|
1862
|
+
var _a, _b, _c, _d;
|
|
1863
|
+
const ta = (_b = (_a = a === null || a === void 0 ? void 0 : a.sentAt) !== null && _a !== void 0 ? _a : a === null || a === void 0 ? void 0 : a.updatedAt) !== null && _b !== void 0 ? _b : 0;
|
|
1864
|
+
const tb = (_d = (_c = b === null || b === void 0 ? void 0 : b.sentAt) !== null && _c !== void 0 ? _c : b === null || b === void 0 ? void 0 : b.updatedAt) !== null && _d !== void 0 ? _d : 0;
|
|
1865
|
+
return ta - tb;
|
|
1866
|
+
});
|
|
1867
|
+
// Only write if something new arrived
|
|
1868
|
+
if (merged.length !== existing.length || page.some((m) => (m === null || m === void 0 ? void 0 : m.messageId) && !existing.some((e) => (e === null || e === void 0 ? void 0 : e.messageId) === m.messageId))) {
|
|
1869
|
+
host.allMessages = merged;
|
|
1870
|
+
}
|
|
1871
|
+
}
|
|
1872
|
+
catch (e) {
|
|
1873
|
+
console.error('MQTT gap-fill failed:', e);
|
|
1874
|
+
}
|
|
1875
|
+
}
|
|
1876
|
+
async function onMqttConnected(host) {
|
|
1877
|
+
var _a, _b;
|
|
1878
|
+
const wasReconnect = (host.mqttConnectCount || 0) > 0;
|
|
1879
|
+
host.mqttConnectCount = (host.mqttConnectCount || 0) + 1;
|
|
1880
|
+
host.mqttInitialized = true;
|
|
1881
|
+
host.isMqttConnected = true;
|
|
1882
|
+
hostSubscribeToMqtt(host);
|
|
1883
|
+
host.mqttSession.resubscribe();
|
|
1884
|
+
clearOfflinePoll(host);
|
|
1885
|
+
if (host.selectedConversationId) {
|
|
1886
|
+
if (!host.isInitialCallDone) {
|
|
1887
|
+
try {
|
|
1888
|
+
await M.getInstance().message.putRead({ conversationId: host.selectedConversationId });
|
|
1889
|
+
}
|
|
1890
|
+
catch (_c) {
|
|
1891
|
+
/* non-fatal */
|
|
1892
|
+
}
|
|
1893
|
+
host.isInitialCallDone = true;
|
|
1894
|
+
}
|
|
1895
|
+
if (wasReconnect) {
|
|
1896
|
+
await hostGapFillMessages(host);
|
|
1897
|
+
void hostPersistMessages(host);
|
|
1898
|
+
// Refresh sidebar previews without blocking UI
|
|
1899
|
+
void Promise.resolve((_a = host.getConversations) === null || _a === void 0 ? void 0 : _a.call(host, 0)).catch(() => undefined);
|
|
1900
|
+
}
|
|
1901
|
+
// Drain any text messages queued while offline / failed
|
|
1902
|
+
void hostFlushOutbox(host);
|
|
1903
|
+
}
|
|
1904
|
+
else if (wasReconnect) {
|
|
1905
|
+
void Promise.resolve((_b = host.getConversations) === null || _b === void 0 ? void 0 : _b.call(host, 0)).catch(() => undefined);
|
|
1906
|
+
void hostFlushOutbox(host);
|
|
1907
|
+
}
|
|
1908
|
+
else {
|
|
1909
|
+
void hostFlushOutbox(host);
|
|
1910
|
+
}
|
|
1911
|
+
}
|
|
1912
|
+
function onMqttUnavailable(host, reason, error) {
|
|
1913
|
+
host.isMqttConnected = false;
|
|
1914
|
+
if (reason === 'error') {
|
|
1915
|
+
host.mqttInitialized = false;
|
|
1916
|
+
const msg = String((error === null || error === void 0 ? void 0 : error.message) || error || '');
|
|
1917
|
+
if (/not authorized/i.test(msg)) {
|
|
1918
|
+
// Auth failure — do not spin reconnect poll forever
|
|
1919
|
+
clearOfflinePoll(host);
|
|
1920
|
+
return;
|
|
1921
|
+
}
|
|
1922
|
+
}
|
|
1923
|
+
startOfflinePoll(host);
|
|
1924
|
+
}
|
|
1597
1925
|
async function hostSetupMqttClient(host) {
|
|
1598
|
-
var _a;
|
|
1599
1926
|
const deviceID = await getDeviceID();
|
|
1600
1927
|
const clientId = host.isometrikUserId || host.isometrikUserIdFromCookie;
|
|
1601
1928
|
const mqttClient = M.getInstance().initializeMqtt({
|
|
@@ -1608,44 +1935,28 @@ async function hostSetupMqttClient(host) {
|
|
|
1608
1935
|
deviceId: deviceID,
|
|
1609
1936
|
});
|
|
1610
1937
|
const raw = mqttClient.client;
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
if (raw === null || raw === void 0 ? void 0 : raw.reconnectTimer) {
|
|
1614
|
-
clearInterval(raw.reconnectTimer);
|
|
1615
|
-
raw.reconnectTimer = null;
|
|
1616
|
-
}
|
|
1617
|
-
(_a = raw === null || raw === void 0 ? void 0 : raw.removeAllListeners) === null || _a === void 0 ? void 0 : _a.call(raw, 'error');
|
|
1938
|
+
// Enable mqtt.js reconnect (was previously forced to 0).
|
|
1939
|
+
applyMqttReconnectOptions(raw);
|
|
1618
1940
|
host.mqttClient = mqttClient;
|
|
1619
1941
|
host.isMqttConnected = false;
|
|
1942
|
+
host.mqttConnectCount = host.mqttConnectCount || 0;
|
|
1620
1943
|
host.mqttSession.attach(mqttClient, {
|
|
1621
1944
|
onConnect: async () => {
|
|
1622
|
-
host
|
|
1623
|
-
host.isMqttConnected = true;
|
|
1624
|
-
hostSubscribeToMqtt(host);
|
|
1625
|
-
if (host.mqttRefetchInterval) {
|
|
1626
|
-
clearInterval(host.mqttRefetchInterval);
|
|
1627
|
-
host.mqttRefetchInterval = null;
|
|
1628
|
-
}
|
|
1629
|
-
if (!host.isInitialCallDone && host.selectedConversationId) {
|
|
1630
|
-
await M.getInstance().message.putRead({ conversationId: host.selectedConversationId });
|
|
1631
|
-
host.refetchMessages();
|
|
1632
|
-
host.isInitialCallDone = true;
|
|
1633
|
-
}
|
|
1945
|
+
await onMqttConnected(host);
|
|
1634
1946
|
},
|
|
1635
1947
|
onDisconnect: () => {
|
|
1948
|
+
onMqttUnavailable(host, 'disconnect');
|
|
1949
|
+
},
|
|
1950
|
+
onOffline: () => {
|
|
1951
|
+
onMqttUnavailable(host, 'offline');
|
|
1952
|
+
},
|
|
1953
|
+
onReconnect: () => {
|
|
1954
|
+
// mqtt.js is attempting reconnect — keep poll until connect succeeds
|
|
1636
1955
|
host.isMqttConnected = false;
|
|
1637
1956
|
},
|
|
1638
1957
|
onError: (error) => {
|
|
1639
1958
|
console.error('MQTT connection error:', error);
|
|
1640
|
-
host
|
|
1641
|
-
host.isMqttConnected = false;
|
|
1642
|
-
if (/not authorized/i.test(String((error === null || error === void 0 ? void 0 : error.message) || error)))
|
|
1643
|
-
return;
|
|
1644
|
-
if (!host.mqttRefetchInterval) {
|
|
1645
|
-
host.mqttRefetchInterval = setInterval(() => {
|
|
1646
|
-
host.refetchMessages();
|
|
1647
|
-
}, 30000);
|
|
1648
|
-
}
|
|
1959
|
+
onMqttUnavailable(host, 'error', error);
|
|
1649
1960
|
},
|
|
1650
1961
|
onMessage: async (_topic, message) => {
|
|
1651
1962
|
await hostHandleMqttMessage(host, message);
|
|
@@ -1653,9 +1964,10 @@ async function hostSetupMqttClient(host) {
|
|
|
1653
1964
|
});
|
|
1654
1965
|
}
|
|
1655
1966
|
async function hostHandleForwardMessage(host, parsedMessage) {
|
|
1656
|
-
var _a, _b;
|
|
1967
|
+
var _a, _b, _c;
|
|
1657
1968
|
try {
|
|
1658
|
-
const
|
|
1969
|
+
const list = (_a = host.allConversationList) !== null && _a !== void 0 ? _a : [];
|
|
1970
|
+
const conversationExists = list.some((conversation) => conversation.conversationId === parsedMessage.conversationId);
|
|
1659
1971
|
if (!conversationExists) {
|
|
1660
1972
|
const conversationDetails = await host.getUserConversationDetails(parsedMessage.conversationId);
|
|
1661
1973
|
const newConversation = {
|
|
@@ -1663,19 +1975,19 @@ async function hostHandleForwardMessage(host, parsedMessage) {
|
|
|
1663
1975
|
lastMessageDetails: {
|
|
1664
1976
|
body: parsedMessage.body,
|
|
1665
1977
|
updatedAt: parsedMessage.updatedAt || Date.now(),
|
|
1666
|
-
userName: (
|
|
1667
|
-
userProfileImageUrl: (
|
|
1978
|
+
userName: (_b = conversationDetails === null || conversationDetails === void 0 ? void 0 : conversationDetails.opponentDetails) === null || _b === void 0 ? void 0 : _b.userName,
|
|
1979
|
+
userProfileImageUrl: (_c = conversationDetails === null || conversationDetails === void 0 ? void 0 : conversationDetails.opponentDetails) === null || _c === void 0 ? void 0 : _c.userProfileImageUrl,
|
|
1668
1980
|
},
|
|
1669
1981
|
unreadMessagesCount: 0,
|
|
1670
1982
|
};
|
|
1671
1983
|
host.allConversationList = host.sortConversationsByLatestMessage([
|
|
1672
1984
|
newConversation,
|
|
1673
|
-
...
|
|
1985
|
+
...list,
|
|
1674
1986
|
]);
|
|
1675
1987
|
await host.getAllAttachments(newConversation.conversationId);
|
|
1676
1988
|
}
|
|
1677
1989
|
else {
|
|
1678
|
-
host.allConversationList = host.sortConversationsByLatestMessage(
|
|
1990
|
+
host.allConversationList = host.sortConversationsByLatestMessage(list.map((conversation) => {
|
|
1679
1991
|
if (conversation.conversationId === parsedMessage.conversationId) {
|
|
1680
1992
|
return Object.assign(Object.assign({}, conversation), { lastMessageDetails: Object.assign(Object.assign({}, conversation.lastMessageDetails), { body: parsedMessage.body, updatedAt: parsedMessage.updatedAt || Date.now() }), isGroup: conversation.isGroup, conversationTitle: conversation.conversationTitle, conversationImageUrl: conversation.conversationImageUrl, opponentDetails: conversation.opponentDetails });
|
|
1681
1993
|
}
|
|
@@ -2156,16 +2468,26 @@ const selectChatPlaceholderSvg = `
|
|
|
2156
2468
|
`;
|
|
2157
2469
|
|
|
2158
2470
|
/** Presentational shell tree for <web-chat> — keeps WebChat.tsx thin. */
|
|
2471
|
+
/** show / custom-slot / default matrix for any named region. */
|
|
2472
|
+
function renderRegion(host, slotName, show, renderDefault) {
|
|
2473
|
+
const mode = resolveRegionMode({
|
|
2474
|
+
show,
|
|
2475
|
+
hasCustomSlot: hasNamedSlot(host.el, slotName),
|
|
2476
|
+
});
|
|
2477
|
+
if (mode === 'hidden')
|
|
2478
|
+
return null;
|
|
2479
|
+
if (mode === 'custom')
|
|
2480
|
+
return h("slot", { name: slotName });
|
|
2481
|
+
return renderDefault();
|
|
2482
|
+
}
|
|
2159
2483
|
function renderBootLoader(host) {
|
|
2160
|
-
return (h("div", { class: "boot-loader-shell" },
|
|
2161
|
-
h("slot", { name: "boot-loader" },
|
|
2162
|
-
h("chat-loading-placeholder", { progress: host.loadingProgress, loadingStatus: host.loadingStatus }))));
|
|
2484
|
+
return (h("div", { class: "boot-loader-shell" }, renderRegion(host, 'boot-loader', true, () => (h("chat-loading-placeholder", { progress: host.loadingProgress, loadingStatus: host.loadingStatus })))));
|
|
2163
2485
|
}
|
|
2164
2486
|
function renderBusyOverlay(host) {
|
|
2165
2487
|
if (!host.isConversationLoading)
|
|
2166
2488
|
return null;
|
|
2167
2489
|
return (h("div", { class: "loaderoverlay" },
|
|
2168
|
-
h("spinner-loader", { height: "30px", width: "30px", spinTime: "1s", spinnerPrimaryColor: "var(--bg-primary
|
|
2490
|
+
h("spinner-loader", { height: "30px", width: "30px", spinTime: "1s", spinnerPrimaryColor: "var(--bg-primary)", spinnerSecondaryColor: "var(--text-primary)", spinnerBorderWidth: "2px" })));
|
|
2169
2491
|
}
|
|
2170
2492
|
function renderDefaultConversationList(host) {
|
|
2171
2493
|
var _a;
|
|
@@ -2183,47 +2505,50 @@ function renderDefaultConversationList(host) {
|
|
|
2183
2505
|
marginBottom: '10px',
|
|
2184
2506
|
}, filterTab: {
|
|
2185
2507
|
padding: '10px 15px',
|
|
2186
|
-
border: '1px solid var(--
|
|
2508
|
+
border: '1px solid var(--brand-soft)',
|
|
2187
2509
|
borderRadius: '25px',
|
|
2188
2510
|
backgroundColor: 'transparent',
|
|
2189
2511
|
cursor: 'pointer',
|
|
2190
2512
|
transition: 'background-color 0.3s',
|
|
2191
|
-
color: 'var(--text-tertiary
|
|
2513
|
+
color: 'var(--text-tertiary)',
|
|
2192
2514
|
fontSize: '12px',
|
|
2193
2515
|
textTransform: 'uppercase',
|
|
2194
2516
|
}, filterTabHover: {
|
|
2195
|
-
backgroundColor: 'var(--
|
|
2517
|
+
backgroundColor: 'var(--brand-soft)',
|
|
2196
2518
|
}, isSidebarHeaderLabel: host.isSidebarHeaderLabel, isSidebarHeaderSearch: host.isSidebarHeaderSearch, sidebarHeaderLabel: host.sidebarHeaderLabel, sidebarColor: host.sidebarColor, sidebarSelectedColor: host.sidebarSelectedColor, onGroupExited: (e) => host.handleGroupExited(e), handleSearchData: (searchTag) => host.getConversations(0, searchTag, true), allMessages: host.allMessages, isConversationLoading: host.isLoadingConversationList }));
|
|
2197
2519
|
}
|
|
2198
2520
|
function renderSidebarTab(host) {
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
}
|
|
2211
|
-
return
|
|
2521
|
+
const groupcastOn = host.groupcastEnabled !== false;
|
|
2522
|
+
const tab = host.activeTab === 'GroupCast' && !groupcastOn ? 'Chat' : host.activeTab;
|
|
2523
|
+
if (tab === 'GroupCast') {
|
|
2524
|
+
return renderRegion(host, 'group-cast', true, () => (h("group-cast", { isLoadingMore: host.isLoadingMoreGroupcast, groupCastData: host.allGroupCastContacts, userMetaData: host.userMetaData, onGroupcastTileSelected: (e) => host.handleChatSelect(e.detail), onCreated: (g) => {
|
|
2525
|
+
if (!(g === null || g === void 0 ? void 0 : g.groupcastId))
|
|
2526
|
+
return;
|
|
2527
|
+
host.allGroupCastContacts = [g, ...(host.allGroupCastContacts || [])];
|
|
2528
|
+
} })));
|
|
2529
|
+
}
|
|
2530
|
+
if (tab === 'Profile') {
|
|
2531
|
+
return renderRegion(host, 'profile-page', true, () => (h("profile-page", { getUserDetails: host.getUserDetails, name: host.userMetaData.userName, profilePhotoUrl: host.userMetaData.userProfileImageUrl, closeDrawer: () => (host.activeTab = 'Chat'), toggleTheme: host.toggleTheme, defaultTheme: host.defaultTheme })));
|
|
2532
|
+
}
|
|
2533
|
+
return renderRegion(host, 'conversation-list', host.showConversationList, () => renderDefaultConversationList(host));
|
|
2534
|
+
}
|
|
2535
|
+
function renderProfileRail(host) {
|
|
2536
|
+
return renderRegion(host, 'profile-rail', host.showProfileRail, () => (h("profile-sidebar", { userMetaData: host.userMetaData, activeTab: host.activeTab, openChat: () => (host.activeTab = 'Chat'), openProfile: () => (host.activeTab = 'Profile'), openGroupCast: () => {
|
|
2537
|
+
if (host.groupcastEnabled === false)
|
|
2538
|
+
return;
|
|
2539
|
+
host.getGroupCastContacts();
|
|
2540
|
+
}, unreadConversationsCount: host.unreadConversationsCount })));
|
|
2212
2541
|
}
|
|
2213
2542
|
function renderDefaultSidebar(host) {
|
|
2214
|
-
// Hosts can pass showProfileRail={false} — no DOM poke / empty slots needed.
|
|
2215
|
-
const showRail = host.showProfileRail !== false;
|
|
2216
2543
|
return (h(Fragment, null,
|
|
2217
|
-
|
|
2218
|
-
h("profile-sidebar", { userMetaData: host.userMetaData, activeTab: host.activeTab, openChat: () => (host.activeTab = 'Chat'), openProfile: () => (host.activeTab = 'Profile'), openGroupCast: () => host.getGroupCastContacts(), unreadConversationsCount: host.unreadConversationsCount }))) : null,
|
|
2544
|
+
renderProfileRail(host),
|
|
2219
2545
|
h("div", { class: "sidebar-tab" }, renderSidebarTab(host))));
|
|
2220
2546
|
}
|
|
2221
2547
|
function renderLeftRail(host) {
|
|
2222
2548
|
return (h("div", { class: {
|
|
2223
2549
|
'chat-sidebar-container': true,
|
|
2224
2550
|
'hidden': host.isMobileView && !host.showSidebar,
|
|
2225
|
-
} },
|
|
2226
|
-
h("slot", { name: "sidebar" }, renderDefaultSidebar(host))));
|
|
2551
|
+
} }, renderRegion(host, 'sidebar', true, () => renderDefaultSidebar(host))));
|
|
2227
2552
|
}
|
|
2228
2553
|
function renderDefaultComposer(host) {
|
|
2229
2554
|
var _a;
|
|
@@ -2231,9 +2556,9 @@ function renderDefaultComposer(host) {
|
|
|
2231
2556
|
return (h("div", { style: {
|
|
2232
2557
|
padding: '1rem',
|
|
2233
2558
|
textAlign: 'center',
|
|
2234
|
-
backgroundColor: 'var(--bg-secondary
|
|
2235
|
-
color: 'var(--text-primary
|
|
2236
|
-
borderTop: '1px solid var(--bg-secondary
|
|
2559
|
+
backgroundColor: 'var(--bg-secondary)',
|
|
2560
|
+
color: 'var(--text-primary)',
|
|
2561
|
+
borderTop: '1px solid var(--bg-secondary)',
|
|
2237
2562
|
} }, "You are no longer a member of this group"));
|
|
2238
2563
|
}
|
|
2239
2564
|
if (host.isBlocked === 'loading') {
|
|
@@ -2242,9 +2567,6 @@ function renderDefaultComposer(host) {
|
|
|
2242
2567
|
if ((_a = host.conversationMetaData) === null || _a === void 0 ? void 0 : _a.messagingDisabled) {
|
|
2243
2568
|
return h("p", { class: "blockMessageContainer" }, WEB_CONTENT.BLOCK_CHAT_MESSAGE);
|
|
2244
2569
|
}
|
|
2245
|
-
// Only re-project when the host actually filled the slot. An empty
|
|
2246
|
-
// <slot slot="composer-input"> still counts as assigned content and
|
|
2247
|
-
// suppresses chat-footer's default <my-test-footer-ui> fallback.
|
|
2248
2570
|
const el = host.el;
|
|
2249
2571
|
return (h("chat-footer", { userMetaData: host.userMetaData, updateAllMessages: host.updateAllMessages, changeMessageSendingState: host.changeMessageSendingState, changeScrollToBottomState: host.changeScrollToBottomState, refetchMessages: host.refetchMessages, allMessages: host.allMessages, selectedConversationId: host.selectedConversationId, replyMessage: host.replyMessage, handleremoveReplyMessage: host.handleremoveReplyMessage, conversationDetails: host.conversationMetaData, allConversationList: host.allConversationList, updateConversationListProp: host.updateConversationList },
|
|
2250
2572
|
hasNamedSlot(el, 'reply-preview') ? h("slot", { name: "reply-preview", slot: "reply-preview" }) : null,
|
|
@@ -2253,10 +2575,10 @@ function renderDefaultComposer(host) {
|
|
|
2253
2575
|
}
|
|
2254
2576
|
/** slot="composer" replaces whole footer; else reply-preview / attachment-preview / composer-input */
|
|
2255
2577
|
function renderComposerOrBanner(host) {
|
|
2256
|
-
return
|
|
2578
|
+
return renderRegion(host, 'composer', host.showComposer, () => renderDefaultComposer(host));
|
|
2257
2579
|
}
|
|
2258
2580
|
function renderDefaultEmptyChat(_host) {
|
|
2259
|
-
return (h("div", { style: { backgroundColor: 'var(--bg-secondary
|
|
2581
|
+
return (h("div", { style: { backgroundColor: 'var(--bg-secondary)', color: 'var(--text-tertiary)' }, class: "noChatSelectedPlaceholder" },
|
|
2260
2582
|
h("div", { innerHTML: selectChatPlaceholderSvg }),
|
|
2261
2583
|
h("span", null, "\"Start a Conversation\""),
|
|
2262
2584
|
h("span", null,
|
|
@@ -2266,23 +2588,23 @@ function renderDefaultEmptyChat(_host) {
|
|
|
2266
2588
|
}
|
|
2267
2589
|
function renderDefaultHeader(host) {
|
|
2268
2590
|
var _a, _b;
|
|
2269
|
-
return (h("web-chat-header", { searchedMessageDetails: host.searchedMessageDetails, onSearchHandler: (text) => host.getMessagesByQuery(text), onSearchResultClick: host.handleSearchResultClick, headerBgColor: "var(--bg-primary
|
|
2591
|
+
return (h("web-chat-header", { searchedMessageDetails: host.searchedMessageDetails, onSearchHandler: (text) => host.getMessagesByQuery(text), onSearchResultClick: host.handleSearchResultClick, headerBgColor: "var(--bg-primary)", headerLastSeenColor: "var(--text-secondary)", headerSvgColor: "var(--text-primary)", headerUsernameColor: "var(--text-primary)", onClearConversation: () => host.clearConversation(), conversationDetails: host.conversationMetaData, isTyping: host.isTyping && host.selectedConversationId === host.typingConversationId, typingUserName: host.typingUserName, chatBodyRef: host.chatBodyRef, onTextClick: () => host.getAllAttachments(host.selectedConversationId), allAttachments: host.allAttachments, lastSeen: (_b = (_a = host.conversationMetaData) === null || _a === void 0 ? void 0 : _a.opponentDetails) === null || _b === void 0 ? void 0 : _b.lastSeen, userMetaData: host.userMetaData, selectedConversationId: host.selectedConversationId, messageAction: host.messageAction, eligibleMembers: host.eligibleMembers, hasMoreEligibleMembers: host.hasMoreEligibleMembers, handleCloseChat: () => host.handleCloseChat(), typingConversationId: host.typingConversationId, isBlocked: host.isBlocked, onBackButtonClick: () => host.handleBackButton() }));
|
|
2270
2592
|
}
|
|
2271
2593
|
function renderDefaultMessages(host) {
|
|
2272
2594
|
var _a;
|
|
2273
2595
|
return (h("web-chat-body", { ref: el => (host.chatBodyRef = el), allAttachments: host.allAttachments, isMessagesLoading: host.isMessagesLoading, updateSkip: host.updateSkip, isMessageLimitEnd: host.isMessageLimitEnd, allMessages: host.allMessages, userMetaData: host.userMetaData, skip: host.skip, isScrollToBottom: host.isScrollToBottom, changeScrollToBottomState: host.changeScrollToBottomState, isMessageSending: host.isMessageSending, isScrollToTop: host.isScrollToTop, changeScrollToTopState: host.changeScrollToTopState, deleteForSelf: host.deleteMessageFromSelf, deleteForAll: host.deleteMeassageFromEveryOne, isChatClosed: host.isChatClosed, isChatMinimized: host.isChatMinimized, updateAllMessages: host.updateAllMessages, selectedConversationId: host.selectedConversationId, highlightedMessageId: host.highlightedMessageId, onMediaClick: () => host.getAllAttachments(host.selectedConversationId), onReplyMessageDetails: host.handleReplyMessage, conversationList: host.allConversationList, newMessageNotification: host.newMessageNotification, onNewMessageCountReset: () => host.resetNewMessageNotification(), conversationDetails: host.conversationMetaData, loadingMediaGallery: host.loadingMediaGallery, customParts: (_a = host.customParts) !== null && _a !== void 0 ? _a : {} }, hasNamedSlot(host.el, 'message-info') ? h("slot", { name: "message-info", slot: "message-info" }) : null));
|
|
2274
2596
|
}
|
|
2275
2597
|
function renderActiveChat(host) {
|
|
2276
|
-
const info = host.
|
|
2598
|
+
const info = host.messageInfoView;
|
|
2277
2599
|
return (h("div", { class: { 'chat-pane-row': true, 'info-open': !!(info === null || info === void 0 ? void 0 : info.open) } },
|
|
2278
2600
|
h("div", { class: "chat-main-stack" },
|
|
2279
|
-
|
|
2280
|
-
|
|
2601
|
+
renderRegion(host, 'header', host.showHeader, () => renderDefaultHeader(host)),
|
|
2602
|
+
renderRegion(host, 'messages', true, () => renderDefaultMessages(host)),
|
|
2281
2603
|
renderComposerOrBanner(host)),
|
|
2282
2604
|
(info === null || info === void 0 ? void 0 : info.open) ? (h("div", { class: "message-info-dock" }, info.isLoading ? (h("div", { class: "message-info-loading" },
|
|
2283
2605
|
h("spinner-loader", { height: "20px", width: "20px", spinTime: "1s", spinnerPrimaryColor: "var(--brand, #2563eb)", spinnerSecondaryColor: "var(--border, #e5e7eb)", spinnerBorderWidth: "2px" }))) : (h("message-info", { selectedMessage: info.selectedMessage, messageDeliveryTime: info.messageDeliveryTime, messageReadTime: info.messageReadTime, readUserList: info.readUserList || [], deliveryUserList: info.deliveryUserList || [], isGroup: info.isGroup, pendingReadCount: info.pendingReadCount, pendingDeliveryCount: info.pendingDeliveryCount, allAttachments: host.allAttachments, onMediaClick: () => host.getAllAttachments(host.selectedConversationId), closePopup: () => {
|
|
2284
2606
|
var _a, _b;
|
|
2285
|
-
host.
|
|
2607
|
+
host.messageInfoView = null;
|
|
2286
2608
|
(_b = (_a = host.chatBodyRef) === null || _a === void 0 ? void 0 : _a.closeMessageInfo) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
2287
2609
|
} })))) : null));
|
|
2288
2610
|
}
|
|
@@ -2300,7 +2622,7 @@ function renderChatPane(host) {
|
|
|
2300
2622
|
}
|
|
2301
2623
|
: host.selectedConversationId
|
|
2302
2624
|
? { background: 'var(--bg-tertiary, #f4f4f5)' }
|
|
2303
|
-
: undefined }, host.selectedConversationId ? (renderActiveChat(host)) : (
|
|
2625
|
+
: undefined }, host.selectedConversationId ? (renderActiveChat(host)) : (renderRegion(host, 'empty', host.showEmptyState, () => renderDefaultEmptyChat()))));
|
|
2304
2626
|
}
|
|
2305
2627
|
function renderDefaultRightPanel(host) {
|
|
2306
2628
|
return (h("web-chat-right-sidebar", { conversationMetaData: host.isProfileInfoOpen ? host.selctConversationMetaData : host.conversationMetaData, selectedConversationId: host.selectedConversationId, hasMoreEligibleMembers: host.hasMoreEligibleMembers, eligibleMembers: host.eligibleMembers, allAttachments: host.isProfileInfoOpen ? host.selectConverSationAttachments : host.allAttachments, userMetaData: host.userMetaData, messageAction: host.messageAction, searchedMessageDetails: host.searchedMessageDetails, onSearchHandler: (text) => host.getMessagesByQuery(text), onSearchResultClick: host.handleSearchResultClick, isContactInfoOpen: host.isContactInfoOpen, isProfileInfoOpen: host.isProfileInfoOpen, isOpenSearchBar: host.isOpenSearchBar, chatBodyRef: host.chatBodyRef, isLoadingMessage: host.isLoadingMessage, conversationIdFromContactinfo: host.conversationIdFromContactinfo, openOwnProfile: () => (host.activeTab = 'Profile'), handleChatSelect: conversationId => host.handleChatSelect(conversationId), allLinks: host.allLinks, allLinksCount: host.allLinksCount, isBlocked: host.isBlocked, groupcastMembers: host.groupcastMembers },
|
|
@@ -2309,10 +2631,11 @@ function renderDefaultRightPanel(host) {
|
|
|
2309
2631
|
hasNamedSlot(host.el, 'message-search') ? h("slot", { name: "message-search", slot: "message-search" }) : null));
|
|
2310
2632
|
}
|
|
2311
2633
|
function renderRightRail(host) {
|
|
2634
|
+
if (host.showRightPanel === false)
|
|
2635
|
+
return null;
|
|
2312
2636
|
if (!host.showRightSideBar)
|
|
2313
2637
|
return null;
|
|
2314
|
-
return (h("div", { class: "chat-sidebar-right" },
|
|
2315
|
-
h("slot", { name: "right-panel" }, renderDefaultRightPanel(host))));
|
|
2638
|
+
return (h("div", { class: "chat-sidebar-right" }, renderRegion(host, 'right-panel', true, () => renderDefaultRightPanel(host))));
|
|
2316
2639
|
}
|
|
2317
2640
|
|
|
2318
2641
|
const webChatCss = ":host{display:flex;flex:1;width:var(--w-full);min-height:100dvh;height:var(--h-full)}web-chat{display:flex;flex:1;width:var(--w-full);min-height:100dvh;height:var(--h-full)}.boot-loader-shell{display:flex;flex:1;width:var(--w-full);min-height:100dvh;height:var(--h-full);align-items:stretch;justify-content:stretch}.boot-loader-shell>chat-loading-placeholder,.boot-loader-shell>slot[name='boot-loader']{display:flex;flex:1;width:var(--w-full);min-height:100dvh}.isometrik-quickchat{box-shadow:0 0 1.25rem 1px color-mix(in srgb, var(--brand) 15%, transparent);display:flex;height:100dvh;width:var(--w-full)}.chat-sidebar-container{width:30%;min-width:var(--sidebar-width);transition:all 0.3s ease;border-right:1px solid var(--border);display:flex;flex-direction:row;background-color:var(--bg-primary);overflow:hidden;min-height:0}profile-sidebar,profile-sidebar-ui{display:flex;height:var(--h-full);flex-shrink:0}.chat-sidebar-right{width:30%;min-width:var(--sidebar-width);transition:all 0.3s ease;border-left:1px solid var(--border);background-color:var(--bg-primary)}.loaderoverlay{width:var(--w-full);position:absolute;margin:auto;background:var(--overlay);z-index:1400}.sidebar-tab{flex:1;min-width:0;height:var(--h-full);min-height:0;background-color:var(--bg-primary);display:flex;flex-direction:column;overflow:hidden}.sidebar-tab>*{flex:1;min-height:0;min-width:0;width:var(--w-full);max-width:var(--w-full)}.chat-body-container{flex:1;display:flex;flex-direction:column;transition:all 0.3s ease;background-color:var(--bg-secondary);position:relative;min-height:0;min-width:0}.chat-pane-row{flex:1;min-height:0;min-width:0;display:flex;flex-direction:row;align-items:stretch;overflow:hidden}.chat-main-stack{flex:1;min-width:0;min-height:0;display:flex;flex-direction:column;overflow:hidden}.message-info-dock{flex:0 0 clamp(280px, 36%, 380px);height:var(--h-full);min-height:0;display:flex;flex-direction:column;background:var(--bg-primary);border-left:1px solid var(--border);overflow:hidden}.message-info-dock message-info{flex:1;min-height:0;height:var(--h-full);display:block}.message-info-loading{flex:1;display:flex;align-items:center;justify-content:center}.chat-sidebar-container>slot[name='sidebar'],.chat-sidebar-container slot[name='profile-rail'],.sidebar-tab>slot[name='conversation-list'],.sidebar-tab>slot[name='profile-page'],.sidebar-tab>slot[name='group-cast'],.chat-body-container>slot[name='empty'],.chat-main-stack>slot[name='header'],.chat-main-stack>slot[name='messages'],.chat-main-stack>slot[name='composer'],.chat-sidebar-right>slot[name='right-panel']{display:contents}::slotted([slot='sidebar']),::slotted([slot='profile-rail']),::slotted([slot='conversation-list']),::slotted([slot='profile-page']),::slotted([slot='group-cast']),::slotted([slot='empty']),::slotted([slot='messages']),::slotted([slot='right-panel']),::slotted([slot='contact-info']),::slotted([slot='profile-info']),::slotted([slot='message-search']),::slotted([slot='boot-loader']){display:flex;flex-direction:column;flex:1;min-height:0;width:var(--w-full);height:var(--h-full)}::slotted([slot='header']),::slotted([slot='composer']),::slotted([slot='composer-input']),::slotted([slot='reply-preview']),::slotted([slot='attachment-preview']){display:block;width:var(--w-full);flex-shrink:0}.noChatSelectedPlaceholder{height:var(--h-full);width:var(--w-full);display:flex;align-items:center;justify-content:center;font-size:var(--text-20);flex-direction:column;gap:var(--gap-4);color:var(--text-primary)}.noChatSelectedPlaceholder span:nth-child(2){font-size:var(--text-24);font-weight:var(--fw-700);margin-top:var(--space-16)}.noChatSelectedPlaceholder span:nth-child(3){font-size:var(--text-18);text-align:center;color:var(--text-secondary)}.loadingPlaceholder{height:var(--h-full);width:var(--w-full);z-index:12839283}.back-button{display:none;padding:0;background:none;border:none;cursor:pointer;align-items:center;gap:var(--gap-4)}spinner-loader{display:flex;height:100dvh}.blockMessageContainer{text-align:center;padding:var(--space-16) 0;margin:0;background-color:var(--bg-secondary);color:var(--text-secondary)}@media (max-width: 768px){.isometrik-quickchat{position:relative;overflow:hidden}.chat-sidebar-right{width:var(--w-full);height:var(--h-full);min-width:100% !important;position:absolute;left:0;top:0;z-index:20;display:flex;flex-direction:column;background-color:var(--bg-primary);transition:all 0.3s ease;border:none}.chat-sidebar-right>*{flex:1;min-height:0;width:var(--w-full);height:var(--h-full)}.chat-sidebar-container{width:var(--w-full);height:var(--h-full);position:absolute;left:0;top:0;transform:translateX(0);transition:transform 0.3s ease;z-index:2;min-width:100% !important}.chat-sidebar-container.hidden{transform:translateX(-100%)}.chat-body-container{width:var(--w-full);height:var(--h-full);position:absolute;left:0;top:0;transform:translateX(100%);transition:transform 0.3s ease;z-index:1}.chat-body-container.hidden{transform:translateX(0)}.chat-body-container.show{transform:translateX(0);z-index:3}.back-button{display:flex;align-items:center;justify-content:center;position:absolute;right:var(--rail-width);z-index:10;top:var(--space-16)}}";
|
|
@@ -2335,6 +2658,8 @@ const WebChat = class {
|
|
|
2335
2658
|
this.mqttSession = new MqttSession();
|
|
2336
2659
|
this.boundCheckMobileView = () => this.checkMobileView();
|
|
2337
2660
|
this.mqttRefetchInterval = null;
|
|
2661
|
+
/** How many successful MQTT connects this mount (0 = first, >0 = reconnect). Used by mqtt-host. */
|
|
2662
|
+
this.mqttConnectCount = 0;
|
|
2338
2663
|
this.typingClearTimeout = null;
|
|
2339
2664
|
this.initGeneration = 0;
|
|
2340
2665
|
this.chatReadyEmitted = false;
|
|
@@ -2427,9 +2752,8 @@ const WebChat = class {
|
|
|
2427
2752
|
this.skip += 20;
|
|
2428
2753
|
}
|
|
2429
2754
|
}
|
|
2430
|
-
const chatBody =
|
|
2431
|
-
if (chatBody) {
|
|
2432
|
-
// @ts-ignore
|
|
2755
|
+
const chatBody = this.chatBodyRef;
|
|
2756
|
+
if (chatBody === null || chatBody === void 0 ? void 0 : chatBody.scrollToMessage) {
|
|
2433
2757
|
chatBody.scrollToMessage(messageId);
|
|
2434
2758
|
}
|
|
2435
2759
|
};
|
|
@@ -2460,9 +2784,14 @@ const WebChat = class {
|
|
|
2460
2784
|
this.accountId = undefined;
|
|
2461
2785
|
this.conversationId = undefined;
|
|
2462
2786
|
this.hostUrl = undefined;
|
|
2463
|
-
this.groupcastEnabled =
|
|
2787
|
+
this.groupcastEnabled = true;
|
|
2464
2788
|
this.showProfileRail = true;
|
|
2465
2789
|
this.showChatWallpaper = true;
|
|
2790
|
+
this.showHeader = true;
|
|
2791
|
+
this.showComposer = true;
|
|
2792
|
+
this.showEmptyState = true;
|
|
2793
|
+
this.showConversationList = true;
|
|
2794
|
+
this.showRightPanel = true;
|
|
2466
2795
|
this.unreadConversations = [];
|
|
2467
2796
|
this.allLinks = undefined;
|
|
2468
2797
|
this.allLinksCount = undefined;
|
|
@@ -2515,8 +2844,8 @@ const WebChat = class {
|
|
|
2515
2844
|
this.isSidebarHeaderLabel = true;
|
|
2516
2845
|
this.sidebarHeaderLabel = 'Chats';
|
|
2517
2846
|
this.isSidebarHeaderSearch = true;
|
|
2518
|
-
this.sidebarColor = 'var(--bg-primary
|
|
2519
|
-
this.sidebarSelectedColor = 'var(--
|
|
2847
|
+
this.sidebarColor = 'var(--bg-primary)';
|
|
2848
|
+
this.sidebarSelectedColor = 'var(--brand-soft)';
|
|
2520
2849
|
this.messageSearchText = '';
|
|
2521
2850
|
this.searchedMessageDetails = [];
|
|
2522
2851
|
this.initialConversationIdFromURL = '';
|
|
@@ -2702,6 +3031,7 @@ const WebChat = class {
|
|
|
2702
3031
|
clearTimeout(this.typingClearTimeout);
|
|
2703
3032
|
this.typingClearTimeout = null;
|
|
2704
3033
|
}
|
|
3034
|
+
hostTeardownOffline(this);
|
|
2705
3035
|
this.mqttSession.teardown();
|
|
2706
3036
|
this.mqttClient = null;
|
|
2707
3037
|
this.isMqttConnected = false;
|
|
@@ -2720,6 +3050,8 @@ const WebChat = class {
|
|
|
2720
3050
|
this.isContactInfoOpen = false;
|
|
2721
3051
|
this.isOpenSearchBar = false;
|
|
2722
3052
|
this.conversationMetaData = metaFromConversationList(this.allConversationList, conversationId);
|
|
3053
|
+
// Show cached thread instantly while network fetch runs
|
|
3054
|
+
void hostHydrateMessagesFromCache(this, conversationId);
|
|
2723
3055
|
if (typeof param === 'string') {
|
|
2724
3056
|
this.getAllAttachments(conversationId);
|
|
2725
3057
|
pushConversationUrl(conversationId || null);
|