@azure/communication-react 1.16.0-alpha-202404190012 → 1.16.0-alpha-202404200012
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/communication-react.d.ts +145 -82
- package/dist/dist-cjs/communication-react/{ChatMessageComponentAsRichTextEditBox-WGqg2woK.js → ChatMessageComponentAsRichTextEditBox-DpYUiI1l.js} +3 -3
- package/dist/dist-cjs/communication-react/{ChatMessageComponentAsRichTextEditBox-WGqg2woK.js.map → ChatMessageComponentAsRichTextEditBox-DpYUiI1l.js.map} +1 -1
- package/dist/dist-cjs/communication-react/{index-oaEwmItW.js → index-C2GfkUGz.js} +255 -365
- package/dist/dist-cjs/communication-react/index-C2GfkUGz.js.map +1 -0
- package/dist/dist-cjs/communication-react/index.js +1 -1
- package/dist/dist-esm/acs-ui-common/src/telemetryVersion.js +1 -1
- package/dist/dist-esm/acs-ui-common/src/telemetryVersion.js.map +1 -1
- package/dist/dist-esm/calling-component-bindings/src/baseSelectors.js +0 -7
- package/dist/dist-esm/calling-component-bindings/src/baseSelectors.js.map +1 -1
- package/dist/dist-esm/calling-component-bindings/src/captionsSelector.js +5 -32
- package/dist/dist-esm/calling-component-bindings/src/captionsSelector.js.map +1 -1
- package/dist/dist-esm/calling-component-bindings/src/handlers/createCommonHandlers.js +0 -8
- package/dist/dist-esm/calling-component-bindings/src/handlers/createCommonHandlers.js.map +1 -1
- package/dist/dist-esm/calling-component-bindings/src/index.js +0 -1
- package/dist/dist-esm/calling-component-bindings/src/index.js.map +1 -1
- package/dist/dist-esm/calling-stateful-client/src/CallClientState.js.map +1 -1
- package/dist/dist-esm/calling-stateful-client/src/CallContext.js +22 -24
- package/dist/dist-esm/calling-stateful-client/src/CallContext.js.map +1 -1
- package/dist/dist-esm/calling-stateful-client/src/CallDeclarativeCommon.js +0 -2
- package/dist/dist-esm/calling-stateful-client/src/CallDeclarativeCommon.js.map +1 -1
- package/dist/dist-esm/calling-stateful-client/src/CallSubscriber.js +0 -4
- package/dist/dist-esm/calling-stateful-client/src/CallSubscriber.js.map +1 -1
- package/dist/dist-esm/calling-stateful-client/src/CaptionsSubscriber.d.ts +0 -1
- package/dist/dist-esm/calling-stateful-client/src/CaptionsSubscriber.js +0 -1
- package/dist/dist-esm/calling-stateful-client/src/CaptionsSubscriber.js.map +1 -1
- package/dist/dist-esm/calling-stateful-client/src/Converter.js +0 -2
- package/dist/dist-esm/calling-stateful-client/src/Converter.js.map +1 -1
- package/dist/dist-esm/calling-stateful-client/src/index-public.js.map +1 -1
- package/dist/dist-esm/chat-stateful-client/src/ChatClientState.d.ts +1 -1
- package/dist/dist-esm/chat-stateful-client/src/ChatClientState.js.map +1 -1
- package/dist/dist-esm/communication-react/src/index.d.ts +2 -2
- package/dist/dist-esm/communication-react/src/index.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/AttachmentCard.d.ts +2 -2
- package/dist/dist-esm/react-components/src/components/AttachmentCard.js +2 -2
- package/dist/dist-esm/react-components/src/components/AttachmentCard.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/AttachmentUploadCards.d.ts +3 -4
- package/dist/dist-esm/react-components/src/components/AttachmentUploadCards.js +2 -2
- package/dist/dist-esm/react-components/src/components/AttachmentUploadCards.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/ChatMessage/MessageComponents/ChatMessageComponentAsMessageBubble.js +4 -4
- package/dist/dist-esm/react-components/src/components/ChatMessage/MessageComponents/ChatMessageComponentAsMessageBubble.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/ChatMessage/MyMessageComponents/ChatMessageComponentAsEditBox.js +1 -1
- package/dist/dist-esm/react-components/src/components/ChatMessage/MyMessageComponents/ChatMessageComponentAsEditBox.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/ChatMessage/MyMessageComponents/ChatMessageComponentAsRichTextEditBox.js +1 -1
- package/dist/dist-esm/react-components/src/components/ChatMessage/MyMessageComponents/ChatMessageComponentAsRichTextEditBox.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/ChatMessage/MyMessageComponents/ChatMyMessageComponentAsMessageBubble.js +1 -1
- package/dist/dist-esm/react-components/src/components/ChatMessage/MyMessageComponents/ChatMyMessageComponentAsMessageBubble.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/LocalVideoTile.d.ts +1 -0
- package/dist/dist-esm/react-components/src/components/LocalVideoTile.js +2 -2
- package/dist/dist-esm/react-components/src/components/LocalVideoTile.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/RemoteVideoTile.d.ts +1 -0
- package/dist/dist-esm/react-components/src/components/RemoteVideoTile.js +1 -1
- package/dist/dist-esm/react-components/src/components/RemoteVideoTile.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/RichTextEditor/RichTextEditor.js +11 -4
- package/dist/dist-esm/react-components/src/components/RichTextEditor/RichTextEditor.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/RichTextEditor/RichTextSendBox.d.ts +4 -4
- package/dist/dist-esm/react-components/src/components/RichTextEditor/RichTextSendBox.js +20 -13
- package/dist/dist-esm/react-components/src/components/RichTextEditor/RichTextSendBox.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/RichTextEditor/RichTextSendBoxErrors.d.ts +1 -1
- package/dist/dist-esm/react-components/src/components/RichTextEditor/RichTextSendBoxErrors.js +4 -4
- package/dist/dist-esm/react-components/src/components/RichTextEditor/RichTextSendBoxErrors.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/SendBox.d.ts +4 -4
- package/dist/dist-esm/react-components/src/components/SendBox.js +20 -14
- package/dist/dist-esm/react-components/src/components/SendBox.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/SendBoxErrors.d.ts +1 -1
- package/dist/dist-esm/react-components/src/components/SendBoxErrors.js +6 -6
- package/dist/dist-esm/react-components/src/components/SendBoxErrors.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/StartCaptionsButton.js +0 -4
- package/dist/dist-esm/react-components/src/components/StartCaptionsButton.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/VideoGallery.d.ts +15 -0
- package/dist/dist-esm/react-components/src/components/VideoGallery.js +7 -5
- package/dist/dist-esm/react-components/src/components/VideoGallery.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/VideoTile.d.ts +5 -0
- package/dist/dist-esm/react-components/src/components/VideoTile.js +7 -5
- package/dist/dist-esm/react-components/src/components/VideoTile.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/index.d.ts +2 -2
- package/dist/dist-esm/react-components/src/components/index.js +0 -4
- package/dist/dist-esm/react-components/src/components/index.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/styles/MessageThread.styles.d.ts +1 -1
- package/dist/dist-esm/react-components/src/components/styles/MessageThread.styles.js +4 -1
- package/dist/dist-esm/react-components/src/components/styles/MessageThread.styles.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/styles/VideoTile.styles.d.ts +0 -4
- package/dist/dist-esm/react-components/src/components/styles/VideoTile.styles.js +0 -7
- package/dist/dist-esm/react-components/src/components/styles/VideoTile.styles.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/utils/SendBoxUtils.d.ts +3 -3
- package/dist/dist-esm/react-components/src/components/utils/SendBoxUtils.js +6 -6
- package/dist/dist-esm/react-components/src/components/utils/SendBoxUtils.js.map +1 -1
- package/dist/dist-esm/react-components/src/index.js +0 -1
- package/dist/dist-esm/react-components/src/index.js.map +1 -1
- package/dist/dist-esm/react-components/src/theming/icons.js +0 -6
- package/dist/dist-esm/react-components/src/theming/icons.js.map +1 -1
- package/dist/dist-esm/react-components/src/theming/themes.d.ts +1 -0
- package/dist/dist-esm/react-components/src/theming/themes.js +4 -2
- package/dist/dist-esm/react-components/src/theming/themes.js.map +1 -1
- package/dist/dist-esm/react-components/src/types/Attachment.d.ts +48 -24
- package/dist/dist-esm/react-components/src/types/Attachment.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/CallComposite/CallComposite.d.ts +5 -0
- package/dist/dist-esm/react-composites/src/composites/CallComposite/CallComposite.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/CallComposite/Strings.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/CallComposite/adapter/AzureCommunicationCallAdapter.js +4 -19
- package/dist/dist-esm/react-composites/src/composites/CallComposite/adapter/AzureCommunicationCallAdapter.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/CallComposite/adapter/CallAdapter.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/CallComposite/adapter/OnFetchProfileCallback.d.ts +4 -4
- package/dist/dist-esm/react-composites/src/composites/CallComposite/adapter/OnFetchProfileCallback.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/CallComposite/adapter/index.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/CallComposite/components/CallArrangement.js +5 -23
- package/dist/dist-esm/react-composites/src/composites/CallComposite/components/CallArrangement.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/CallComposite/components/MediaGallery.d.ts +2 -0
- package/dist/dist-esm/react-composites/src/composites/CallComposite/components/MediaGallery.js +4 -3
- package/dist/dist-esm/react-composites/src/composites/CallComposite/components/MediaGallery.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/CallComposite/hooks/useHandlers.js +0 -4
- package/dist/dist-esm/react-composites/src/composites/CallComposite/hooks/useHandlers.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/CallComposite/index.d.ts +2 -1
- package/dist/dist-esm/react-composites/src/composites/CallComposite/index.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/CallComposite/pages/CallPage.js +1 -1
- package/dist/dist-esm/react-composites/src/composites/CallComposite/pages/CallPage.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/CallComposite/selectors/baseSelectors.js +0 -7
- package/dist/dist-esm/react-composites/src/composites/CallComposite/selectors/baseSelectors.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/Strings.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/adapter/AzureCommunicationCallWithChatAdapter.d.ts +5 -3
- package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/adapter/AzureCommunicationCallWithChatAdapter.js +20 -18
- package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/adapter/AzureCommunicationCallWithChatAdapter.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/adapter/CallWithChatAdapter.d.ts +17 -11
- package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/adapter/CallWithChatAdapter.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/adapter/CallWithChatBackedCallAdapter.js +0 -4
- package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/adapter/CallWithChatBackedCallAdapter.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/adapter/CallWithChatBackedChatAdapter.d.ts +4 -3
- package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/adapter/CallWithChatBackedChatAdapter.js +5 -1
- package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/adapter/CallWithChatBackedChatAdapter.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/state/CallWithChatAdapterState.d.ts +4 -4
- package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/state/CallWithChatAdapterState.js +2 -2
- package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/state/CallWithChatAdapterState.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/ChatScreen.js +11 -7
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/ChatScreen.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/adapter/AzureCommunicationAttachmentUploadAdapter.d.ts +14 -13
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/adapter/AzureCommunicationAttachmentUploadAdapter.js +30 -21
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/adapter/AzureCommunicationAttachmentUploadAdapter.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/adapter/AzureCommunicationChatAdapter.d.ts +5 -3
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/adapter/AzureCommunicationChatAdapter.js +26 -2
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/adapter/AzureCommunicationChatAdapter.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/adapter/ChatAdapter.d.ts +10 -5
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/adapter/ChatAdapter.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/adapter/ChatAdapterProvider.d.ts +2 -2
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/adapter/ChatAdapterProvider.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/file-sharing/AttachmentUpload.d.ts +10 -10
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/file-sharing/AttachmentUpload.js +7 -7
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/file-sharing/AttachmentUpload.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/file-sharing/AttachmentUploadButton.js +1 -1
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/file-sharing/AttachmentUploadButton.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/file-sharing/index.d.ts +1 -1
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/file-sharing/index.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/index.d.ts +2 -2
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/index.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/selectors/attachmentUploadsSelector.d.ts +5 -5
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/selectors/baseSelectors.d.ts +2 -2
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/selectors/baseSelectors.js +1 -1
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/selectors/baseSelectors.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/common/CaptionsBanner.js +2 -27
- package/dist/dist-esm/react-composites/src/composites/common/CaptionsBanner.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/common/CaptionsBannerMoreButton.js +0 -20
- package/dist/dist-esm/react-composites/src/composites/common/CaptionsBannerMoreButton.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/common/CaptionsSettingsModal.js +0 -13
- package/dist/dist-esm/react-composites/src/composites/common/CaptionsSettingsModal.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/common/ControlBar/CommonCallControlBar.js +4 -15
- package/dist/dist-esm/react-composites/src/composites/common/ControlBar/CommonCallControlBar.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/common/ControlBar/DesktopMoreButton.js +1 -17
- package/dist/dist-esm/react-composites/src/composites/common/ControlBar/DesktopMoreButton.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/common/Drawer/CaptionLanguageSettingsDrawer.js +0 -9
- package/dist/dist-esm/react-composites/src/composites/common/Drawer/CaptionLanguageSettingsDrawer.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/common/Drawer/MoreDrawer.js +0 -23
- package/dist/dist-esm/react-composites/src/composites/common/Drawer/MoreDrawer.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/common/Drawer/PreparedMoreDrawer.js +0 -3
- package/dist/dist-esm/react-composites/src/composites/common/Drawer/PreparedMoreDrawer.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/common/Drawer/SpokenLanguageSettingsDrawer.js +0 -9
- package/dist/dist-esm/react-composites/src/composites/common/Drawer/SpokenLanguageSettingsDrawer.js.map +1 -1
- package/package.json +3 -3
- package/dist/dist-cjs/communication-react/index-oaEwmItW.js.map +0 -1
- package/dist/dist-esm/react-components/src/components/utils/videoTileStylesUtils.d.ts +0 -6
- package/dist/dist-esm/react-components/src/components/utils/videoTileStylesUtils.js +0 -11
- package/dist/dist-esm/react-components/src/components/utils/videoTileStylesUtils.js.map +0 -1
@@ -13,27 +13,27 @@ class AttachmentUploadContext {
|
|
13
13
|
this.chatContext = chatContext;
|
14
14
|
}
|
15
15
|
getAttachmentUploads() {
|
16
|
-
return this.chatContext.getState().
|
16
|
+
return this.chatContext.getState()._attachmentUploads;
|
17
17
|
}
|
18
18
|
addAttachmentUploads(attachmentUploads) {
|
19
19
|
const attachmentUploadsMap = convertObservableAttachmentUploadToAttachmentUploadsUiState(attachmentUploads);
|
20
20
|
this.chatContext.setState(produce(this.chatContext.getState(), (draft) => {
|
21
|
-
draft.
|
22
|
-
draft.
|
21
|
+
draft._attachmentUploads = draft._attachmentUploads || {};
|
22
|
+
draft._attachmentUploads = Object.assign(Object.assign({}, draft._attachmentUploads), attachmentUploadsMap);
|
23
23
|
}));
|
24
24
|
}
|
25
25
|
clearUploads() {
|
26
26
|
this.chatContext.setState(produce(this.chatContext.getState(), (draft) => {
|
27
|
-
draft.
|
27
|
+
draft._attachmentUploads = {};
|
28
28
|
}));
|
29
29
|
}
|
30
30
|
updateAttachmentUpload(id, data) {
|
31
31
|
this.chatContext.setState(produce(this.chatContext.getState(), (draft) => {
|
32
32
|
var _a, _b, _c, _d;
|
33
|
-
if ((_a = draft.
|
34
|
-
draft.
|
33
|
+
if ((_a = draft._attachmentUploads) === null || _a === void 0 ? void 0 : _a[id]) {
|
34
|
+
draft._attachmentUploads[(_b = data.id) !== null && _b !== void 0 ? _b : id] = Object.assign(Object.assign({}, (_c = draft._attachmentUploads) === null || _c === void 0 ? void 0 : _c[id]), data);
|
35
35
|
if (data.id) {
|
36
|
-
(_d = draft.
|
36
|
+
(_d = draft._attachmentUploads) === null || _d === void 0 ? true : delete _d[id];
|
37
37
|
}
|
38
38
|
}
|
39
39
|
}));
|
@@ -42,10 +42,10 @@ class AttachmentUploadContext {
|
|
42
42
|
this.chatContext.setState(produce(this.chatContext.getState(), (draft) => {
|
43
43
|
ids.forEach((id) => {
|
44
44
|
var _a;
|
45
|
-
const keys = Object.keys((_a = draft === null || draft === void 0 ? void 0 : draft.
|
45
|
+
const keys = Object.keys((_a = draft === null || draft === void 0 ? void 0 : draft._attachmentUploads) !== null && _a !== void 0 ? _a : []).filter((rawID) => { var _a; return ((_a = draft._attachmentUploads) === null || _a === void 0 ? void 0 : _a[rawID].id) === id; });
|
46
46
|
keys.forEach((key) => {
|
47
47
|
var _a;
|
48
|
-
(_a = draft.
|
48
|
+
(_a = draft._attachmentUploads) === null || _a === void 0 ? true : delete _a[key];
|
49
49
|
});
|
50
50
|
});
|
51
51
|
}));
|
@@ -61,16 +61,16 @@ export class AzureCommunicationAttachmentUploadAdapter {
|
|
61
61
|
this.context = new AttachmentUploadContext(chatContext);
|
62
62
|
}
|
63
63
|
findAttachmentUpload(id) {
|
64
|
-
return this.attachmentUploads.find((attachmentUpload) => attachmentUpload.
|
64
|
+
return this.attachmentUploads.find((attachmentUpload) => attachmentUpload.taskId === id);
|
65
65
|
}
|
66
66
|
deleteAttachmentUploads(ids) {
|
67
|
-
this.attachmentUploads = this.attachmentUploads.filter((attachmentUpload) => !ids.includes(attachmentUpload.
|
67
|
+
this.attachmentUploads = this.attachmentUploads.filter((attachmentUpload) => !ids.includes(attachmentUpload.taskId));
|
68
68
|
this.context.deleteAttachmentUploads(ids);
|
69
69
|
}
|
70
70
|
deleteErroneousAttachmentUploads() {
|
71
71
|
const attachmentUploads = this.context.getAttachmentUploads() || {};
|
72
72
|
const ids = Object.values(attachmentUploads)
|
73
|
-
.filter((item) => item.
|
73
|
+
.filter((item) => item.error)
|
74
74
|
.map((item) => item.id);
|
75
75
|
ids.forEach((id) => {
|
76
76
|
const attachmentUpload = this.findAttachmentUpload(id);
|
@@ -109,9 +109,8 @@ export class AzureCommunicationAttachmentUploadAdapter {
|
|
109
109
|
}
|
110
110
|
updateUploadStatusMessage(id, errorMessage) {
|
111
111
|
this.context.updateAttachmentUpload(id, {
|
112
|
-
|
113
|
-
message: errorMessage
|
114
|
-
timestamp: Date.now()
|
112
|
+
error: {
|
113
|
+
message: errorMessage
|
115
114
|
}
|
116
115
|
});
|
117
116
|
}
|
@@ -124,20 +123,30 @@ export class AzureCommunicationAttachmentUploadAdapter {
|
|
124
123
|
extension: metadata.extension
|
125
124
|
});
|
126
125
|
}
|
126
|
+
setAttachmentMetadata(taskId, attachmentId, attachmentUrl) {
|
127
|
+
const attachmentUpload = this.findAttachmentUpload(taskId);
|
128
|
+
this.context.updateAttachmentUpload(taskId, {
|
129
|
+
progress: 1,
|
130
|
+
id: attachmentId,
|
131
|
+
name: attachmentUpload === null || attachmentUpload === void 0 ? void 0 : attachmentUpload.name,
|
132
|
+
url: attachmentUrl,
|
133
|
+
extension: (attachmentUpload === null || attachmentUpload === void 0 ? void 0 : attachmentUpload.name.split('.').pop()) || ''
|
134
|
+
});
|
135
|
+
}
|
127
136
|
subscribeAllEvents(attachmentUpload) {
|
128
137
|
attachmentUpload.on('uploadProgressChange', this.updateUploadProgress.bind(this));
|
129
|
-
attachmentUpload.on('uploadComplete', this.
|
138
|
+
attachmentUpload.on('uploadComplete', this.setAttachmentMetadata.bind(this));
|
130
139
|
attachmentUpload.on('uploadFail', this.updateUploadStatusMessage.bind(this));
|
131
140
|
}
|
132
141
|
unsubscribeAllEvents(attachmentUpload) {
|
133
142
|
attachmentUpload === null || attachmentUpload === void 0 ? void 0 : attachmentUpload.off('uploadProgressChange', this.updateUploadProgress.bind(this));
|
134
|
-
attachmentUpload === null || attachmentUpload === void 0 ? void 0 : attachmentUpload.off('uploadComplete', this.
|
143
|
+
attachmentUpload === null || attachmentUpload === void 0 ? void 0 : attachmentUpload.off('uploadComplete', this.setAttachmentMetadata.bind(this));
|
135
144
|
attachmentUpload === null || attachmentUpload === void 0 ? void 0 : attachmentUpload.off('uploadFail', this.updateUploadStatusMessage.bind(this));
|
136
145
|
}
|
137
146
|
}
|
138
147
|
/* @conditional-compile-remove(attachment-upload) */
|
139
148
|
/**
|
140
|
-
* @param attachmentUploadUiState {@link
|
149
|
+
* @param attachmentUploadUiState {@link _AttachmentUploadsUiState}
|
141
150
|
* @private
|
142
151
|
*/
|
143
152
|
export const convertAttachmentUploadsUiStateToMessageMetadata = (attachmentUploads) => {
|
@@ -145,7 +154,7 @@ export const convertAttachmentUploadsUiStateToMessageMetadata = (attachmentUploa
|
|
145
154
|
const attachmentMetadata = [];
|
146
155
|
Object.keys(attachmentUploads).forEach((key) => {
|
147
156
|
const attachment = attachmentUploads[key];
|
148
|
-
if (attachment && !attachment.
|
157
|
+
if (attachment && !attachment.error) {
|
149
158
|
attachmentMetadata.push({
|
150
159
|
id: attachment.id,
|
151
160
|
name: attachment.name,
|
@@ -167,8 +176,8 @@ export const convertAttachmentUploadsUiStateToMessageMetadata = (attachmentUploa
|
|
167
176
|
*/
|
168
177
|
const convertObservableAttachmentUploadToAttachmentUploadsUiState = (attachmentUploads) => {
|
169
178
|
return attachmentUploads.reduce((map, attachmentUpload) => {
|
170
|
-
map[attachmentUpload.
|
171
|
-
id: attachmentUpload.
|
179
|
+
map[attachmentUpload.taskId] = {
|
180
|
+
id: attachmentUpload.taskId,
|
172
181
|
name: attachmentUpload.name,
|
173
182
|
progress: 0,
|
174
183
|
extension: attachmentUpload.name.split('.').pop() || ''
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"AzureCommunicationAttachmentUploadAdapter.js","sourceRoot":"","sources":["../../../../../../../../react-composites/src/composites/ChatComposite/adapter/AzureCommunicationAttachmentUploadAdapter.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,oDAAoD;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,oDAAoD;AACpD,OAAO,EAAuB,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAyBxE,oDAAoD;AACpD;;GAEG;AACH,MAAM,uBAAuB;IAG3B,YAAY,WAAwB;QAClC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;IAEM,oBAAoB;QACzB,OAAO,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC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AG,CAAC,CAAC;YAC1C,IAAI,UAAU,IAAI,CAAC,UAAU,CAAC,WAAW,EAAE,CAAC;gBAC1C,kBAAkB,CAAC,IAAI,CAAC;oBACtB,EAAE,EAAE,UAAU,CAAC,EAAE;oBACjB,IAAI,EAAE,UAAU,CAAC,IAAI;oBACrB,SAAS,EAAE,UAAU,CAAC,SAAS;oBAC/B,GAAG,EAAE,UAAU,CAAC,GAAG;oBACnB,QAAQ,EAAE,UAAU,CAAC,QAAQ;iBAC9B,CAAC,CAAC;YACL,CAAC;QACH,CAAC,CAAC,CAAC;QACH,IAAI,kBAAkB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAClC,OAAO,EAAE,mBAAmB,EAAE,IAAI,CAAC,SAAS,CAAC,kBAAkB,CAAC,EAAE,CAAC;QACrE,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AAEF,oDAAoD;AACpD;;GAEG;AACH,MAAM,2DAA2D,GAAG,CAClE,iBAAqC,EACX,EAAE;IAC5B,OAAO,iBAAiB,CAAC,MAAM,CAAC,CAAC,GAA6B,EAAE,gBAAgB,EAAE,EAAE;QAClF,GAAG,CAAC,gBAAgB,CAAC,EAAE,CAAC,GAAG;YACzB,EAAE,EAAE,gBAAgB,CAAC,EAAE;YACvB,IAAI,EAAE,gBAAgB,CAAC,IAAI;YAC3B,QAAQ,EAAE,CAAC;YACX,SAAS,EAAE,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE;SACxD,CAAC;QACF,OAAO,GAAG,CAAC;IACb,CAAC,EAAE,EAAE,CAAC,CAAC;AACT,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { AttachmentUploadManager, AttachmentMetadata } from '@internal/react-components';\n/* @conditional-compile-remove(attachment-upload) */\nimport { produce } from 'immer';\n/* @conditional-compile-remove(attachment-upload) */\nimport { FileSharingMetadata, AttachmentUpload } from '../file-sharing';\n/* @conditional-compile-remove(attachment-upload) */\nimport { ChatContext } from './AzureCommunicationChatAdapter';\n/* @conditional-compile-remove(attachment-upload) */\nimport { ChatAdapterState } from './ChatAdapter';\n\n/**\n * A record containing {@link AttachmentMetadata} mapped to unique ids.\n * @beta\n */\nexport type AttachmentUploadsUiState = Record<string, AttachmentMetadata>;\n\n/**\n * @beta\n */\nexport interface AttachmentUploadAdapter {\n registerActiveUploads: (files: File[]) => AttachmentUploadManager[];\n registerCompletedUploads: (metadata: AttachmentMetadata[]) => AttachmentUploadManager[];\n clearUploads: () => void;\n cancelUpload: (id: string) => void;\n updateUploadProgress: (id: string, progress: number) => void;\n updateUploadStatusMessage: (id: string, errorMessage: string) => void;\n updateUploadMetadata: (id: string, metadata: AttachmentMetadata) => void;\n}\n\n/* @conditional-compile-remove(attachment-upload) */\n/**\n * @internal\n */\nclass AttachmentUploadContext {\n private chatContext: ChatContext;\n\n constructor(chatContext: ChatContext) {\n this.chatContext = chatContext;\n }\n\n public getAttachmentUploads(): AttachmentUploadsUiState | undefined {\n return this.chatContext.getState().attachmentUploads;\n }\n\n public addAttachmentUploads(attachmentUploads: AttachmentUpload[]): void {\n const attachmentUploadsMap = convertObservableAttachmentUploadToAttachmentUploadsUiState(attachmentUploads);\n this.chatContext.setState(\n produce(this.chatContext.getState(), (draft) => {\n draft.attachmentUploads = draft.attachmentUploads || {};\n draft.attachmentUploads = { ...draft.attachmentUploads, ...attachmentUploadsMap };\n })\n );\n }\n\n public clearUploads(): void {\n this.chatContext.setState(\n produce(this.chatContext.getState(), (draft: ChatAdapterState) => {\n draft.attachmentUploads = {};\n })\n );\n }\n\n public updateAttachmentUpload(\n id: string,\n data: Partial<Pick<AttachmentMetadata, 'progress' | 'id' | 'name' | 'extension' | 'uploadError' | 'url'>>\n ): void {\n this.chatContext.setState(\n produce(this.chatContext.getState(), (draft: ChatAdapterState) => {\n if (draft.attachmentUploads?.[id]) {\n draft.attachmentUploads[data.id ?? id] = {\n ...draft.attachmentUploads?.[id],\n ...data\n };\n if (data.id) {\n delete draft.attachmentUploads?.[id];\n }\n }\n })\n );\n }\n\n public deleteAttachmentUploads(ids: string[]): void {\n this.chatContext.setState(\n produce(this.chatContext.getState(), (draft: ChatAdapterState) => {\n ids.forEach((id) => {\n const keys = Object.keys(draft?.attachmentUploads ?? []).filter(\n (rawID) => draft.attachmentUploads?.[rawID].id === id\n );\n keys.forEach((key) => {\n delete draft.attachmentUploads?.[key];\n });\n });\n })\n );\n }\n}\n\n/* @conditional-compile-remove(attachment-upload) */\n/**\n * @internal\n */\nexport class AzureCommunicationAttachmentUploadAdapter implements AttachmentUploadAdapter {\n private context: AttachmentUploadContext;\n private attachmentUploads: AttachmentUpload[] = [];\n\n constructor(chatContext: ChatContext) {\n this.context = new AttachmentUploadContext(chatContext);\n }\n\n private findAttachmentUpload(id: string): AttachmentUpload | undefined {\n return this.attachmentUploads.find((attachmentUpload) => attachmentUpload.id === id);\n }\n\n private deleteAttachmentUploads(ids: string[]): void {\n this.attachmentUploads = this.attachmentUploads.filter((attachmentUpload) => !ids.includes(attachmentUpload.id));\n this.context.deleteAttachmentUploads(ids);\n }\n\n private deleteErroneousAttachmentUploads(): void {\n const attachmentUploads = this.context.getAttachmentUploads() || {};\n const ids = Object.values(attachmentUploads)\n .filter((item: AttachmentMetadata) => item.uploadError)\n .map((item: AttachmentMetadata) => item.id);\n\n ids.forEach((id) => {\n const attachmentUpload = this.findAttachmentUpload(id);\n this.unsubscribeAllEvents(attachmentUpload);\n });\n\n this.deleteAttachmentUploads(ids);\n }\n\n private registerAttachmentUploads(files: File[] | AttachmentMetadata[]): AttachmentUploadManager[] {\n this.deleteErroneousAttachmentUploads();\n const attachmentUploads: AttachmentUpload[] = [];\n files.forEach((file) => attachmentUploads.push(new AttachmentUpload(file)));\n attachmentUploads.forEach((attachmentUpload) => this.subscribeAllEvents(attachmentUpload));\n this.attachmentUploads = this.attachmentUploads.concat(attachmentUploads);\n this.context.addAttachmentUploads(attachmentUploads);\n return attachmentUploads;\n }\n\n registerActiveUploads(files: File[]): AttachmentUploadManager[] {\n return this.registerAttachmentUploads(files);\n }\n\n registerCompletedUploads(metadata: AttachmentMetadata[]): AttachmentUploadManager[] {\n return this.registerAttachmentUploads(metadata);\n }\n\n clearUploads(): void {\n this.context.clearUploads();\n this.attachmentUploads.forEach((attachmentUpload) => this.unsubscribeAllEvents(attachmentUpload));\n this.attachmentUploads = [];\n }\n\n cancelUpload(id: string): void {\n this.deleteErroneousAttachmentUploads();\n const attachmentUpload = this.findAttachmentUpload(id);\n this.unsubscribeAllEvents(attachmentUpload);\n this.deleteAttachmentUploads([id]);\n }\n\n updateUploadProgress(id: string, progress: number): void {\n this.context.updateAttachmentUpload(id, { progress });\n }\n\n updateUploadStatusMessage(id: string, errorMessage: string): void {\n this.context.updateAttachmentUpload(id, {\n uploadError: {\n message: errorMessage,\n timestamp: Date.now()\n }\n });\n }\n\n updateUploadMetadata(id: string, metadata: AttachmentMetadata): void {\n this.context.updateAttachmentUpload(id, {\n progress: 1,\n id: metadata.id,\n name: metadata.name,\n url: metadata.url,\n extension: metadata.extension\n });\n }\n\n private subscribeAllEvents(attachmentUpload: AttachmentUpload): void {\n attachmentUpload.on('uploadProgressChange', this.updateUploadProgress.bind(this));\n attachmentUpload.on('uploadComplete', this.updateUploadMetadata.bind(this));\n attachmentUpload.on('uploadFail', this.updateUploadStatusMessage.bind(this));\n }\n\n private unsubscribeAllEvents(attachmentUpload?: AttachmentUpload): void {\n attachmentUpload?.off('uploadProgressChange', this.updateUploadProgress.bind(this));\n attachmentUpload?.off('uploadComplete', this.updateUploadMetadata.bind(this));\n attachmentUpload?.off('uploadFail', this.updateUploadStatusMessage.bind(this));\n }\n}\n\n/* @conditional-compile-remove(attachment-upload) */\n/**\n * @param attachmentUploadUiState {@link AttachmentUploadsUiState}\n * @private\n */\nexport const convertAttachmentUploadsUiStateToMessageMetadata = (\n attachmentUploads?: AttachmentUploadsUiState\n): FileSharingMetadata | undefined => {\n if (attachmentUploads) {\n const attachmentMetadata: AttachmentMetadata[] = [];\n Object.keys(attachmentUploads).forEach((key) => {\n const attachment = attachmentUploads[key];\n if (attachment && !attachment.uploadError) {\n attachmentMetadata.push({\n id: attachment.id,\n name: attachment.name,\n extension: attachment.extension,\n url: attachment.url,\n progress: attachment.progress\n });\n }\n });\n if (attachmentMetadata.length > 0) {\n return { fileSharingMetadata: JSON.stringify(attachmentMetadata) };\n }\n }\n return undefined;\n};\n\n/* @conditional-compile-remove(attachment-upload) */\n/**\n * @private\n */\nconst convertObservableAttachmentUploadToAttachmentUploadsUiState = (\n attachmentUploads: AttachmentUpload[]\n): AttachmentUploadsUiState => {\n return attachmentUploads.reduce((map: AttachmentUploadsUiState, attachmentUpload) => {\n map[attachmentUpload.id] = {\n id: attachmentUpload.id,\n name: attachmentUpload.name,\n progress: 0,\n extension: attachmentUpload.name.split('.').pop() || ''\n };\n return map;\n }, {});\n};\n"]}
|
1
|
+
{"version":3,"file":"AzureCommunicationAttachmentUploadAdapter.js","sourceRoot":"","sources":["../../../../../../../../react-composites/src/composites/ChatComposite/adapter/AzureCommunicationAttachmentUploadAdapter.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,oDAAoD;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,oDAAoD;AACpD,OAAO,EAAuB,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAyBxE,oDAAoD;AACpD;;GAEG;AACH,MAAM,uBAAuB;IAG3B,YAAY,WAAwB;QAClC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;IAEM,oBAAoB;QACzB,OAAO,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC,kBAAkB,CAAC;IACxD,CAAC;IAEM,oBAAoB,CAAC,iBAAqC;QAC/D,MAAM,oBAAoB,GAAG,2DAA2D,CAAC,iBAAiB,CAAC,CAAC;QAC5G,I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C,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE;SACxD,CAAC;QACF,OAAO,GAAG,CAAC;IACb,CAAC,EAAE,EAAE,CAAC,CAAC;AACT,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { AttachmentUploadTask, AttachmentMetadata, AttachmentMetadataWithProgress } from '@internal/react-components';\n/* @conditional-compile-remove(attachment-upload) */\nimport { produce } from 'immer';\n/* @conditional-compile-remove(attachment-upload) */\nimport { FileSharingMetadata, AttachmentUpload } from '../file-sharing';\n/* @conditional-compile-remove(attachment-upload) */\nimport { ChatContext } from './AzureCommunicationChatAdapter';\n/* @conditional-compile-remove(attachment-upload) */\nimport { ChatAdapterState } from './ChatAdapter';\n\n/**\n * A record containing {@link AttachmentMetadata} mapped to unique attachment upload task ids.\n * @internal\n */\nexport type _AttachmentUploadsUiState = Record<string, AttachmentMetadataWithProgress>;\n\n/**\n * @internal\n */\nexport interface _AttachmentUploadAdapter {\n registerActiveUploads: (files: File[]) => AttachmentUploadTask[];\n registerCompletedUploads: (metadata: AttachmentMetadata[]) => AttachmentUploadTask[];\n clearUploads: () => void;\n cancelUpload: (id: string) => void;\n updateUploadProgress: (id: string, progress: number) => void;\n updateUploadStatusMessage: (id: string, errorMessage: string) => void;\n updateUploadMetadata: (id: string, metadata: AttachmentMetadata) => void;\n}\n\n/* @conditional-compile-remove(attachment-upload) */\n/**\n * @internal\n */\nclass AttachmentUploadContext {\n private chatContext: ChatContext;\n\n constructor(chatContext: ChatContext) {\n this.chatContext = chatContext;\n }\n\n public getAttachmentUploads(): _AttachmentUploadsUiState | undefined {\n return this.chatContext.getState()._attachmentUploads;\n }\n\n public addAttachmentUploads(attachmentUploads: AttachmentUpload[]): void {\n const attachmentUploadsMap = convertObservableAttachmentUploadToAttachmentUploadsUiState(attachmentUploads);\n this.chatContext.setState(\n produce(this.chatContext.getState(), (draft) => {\n draft._attachmentUploads = draft._attachmentUploads || {};\n draft._attachmentUploads = { ...draft._attachmentUploads, ...attachmentUploadsMap };\n })\n );\n }\n\n public clearUploads(): void {\n this.chatContext.setState(\n produce(this.chatContext.getState(), (draft: ChatAdapterState) => {\n draft._attachmentUploads = {};\n })\n );\n }\n\n public updateAttachmentUpload(\n id: string,\n data: Partial<Pick<AttachmentMetadataWithProgress, 'progress' | 'id' | 'name' | 'extension' | 'error' | 'url'>>\n ): void {\n this.chatContext.setState(\n produce(this.chatContext.getState(), (draft: ChatAdapterState) => {\n if (draft._attachmentUploads?.[id]) {\n draft._attachmentUploads[data.id ?? id] = {\n ...draft._attachmentUploads?.[id],\n ...data\n };\n if (data.id) {\n delete draft._attachmentUploads?.[id];\n }\n }\n })\n );\n }\n\n public deleteAttachmentUploads(ids: string[]): void {\n this.chatContext.setState(\n produce(this.chatContext.getState(), (draft: ChatAdapterState) => {\n ids.forEach((id) => {\n const keys = Object.keys(draft?._attachmentUploads ?? []).filter(\n (rawID) => draft._attachmentUploads?.[rawID].id === id\n );\n keys.forEach((key) => {\n delete draft._attachmentUploads?.[key];\n });\n });\n })\n );\n }\n}\n\n/* @conditional-compile-remove(attachment-upload) */\n/**\n * @internal\n */\nexport class AzureCommunicationAttachmentUploadAdapter implements _AttachmentUploadAdapter {\n private context: AttachmentUploadContext;\n private attachmentUploads: AttachmentUpload[] = [];\n\n constructor(chatContext: ChatContext) {\n this.context = new AttachmentUploadContext(chatContext);\n }\n\n private findAttachmentUpload(id: string): AttachmentUpload | undefined {\n return this.attachmentUploads.find((attachmentUpload) => attachmentUpload.taskId === id);\n }\n\n private deleteAttachmentUploads(ids: string[]): void {\n this.attachmentUploads = this.attachmentUploads.filter(\n (attachmentUpload) => !ids.includes(attachmentUpload.taskId)\n );\n this.context.deleteAttachmentUploads(ids);\n }\n\n private deleteErroneousAttachmentUploads(): void {\n const attachmentUploads = this.context.getAttachmentUploads() || {};\n const ids = Object.values(attachmentUploads)\n .filter((item: AttachmentMetadataWithProgress) => item.error)\n .map((item: AttachmentMetadataWithProgress) => item.id);\n\n ids.forEach((id) => {\n const attachmentUpload = this.findAttachmentUpload(id);\n this.unsubscribeAllEvents(attachmentUpload);\n });\n\n this.deleteAttachmentUploads(ids);\n }\n\n private registerAttachmentUploads(files: File[] | AttachmentMetadata[]): AttachmentUploadTask[] {\n this.deleteErroneousAttachmentUploads();\n const attachmentUploads: AttachmentUpload[] = [];\n files.forEach((file) => attachmentUploads.push(new AttachmentUpload(file)));\n attachmentUploads.forEach((attachmentUpload) => this.subscribeAllEvents(attachmentUpload));\n this.attachmentUploads = this.attachmentUploads.concat(attachmentUploads);\n this.context.addAttachmentUploads(attachmentUploads);\n return attachmentUploads;\n }\n\n registerActiveUploads(files: File[]): AttachmentUploadTask[] {\n return this.registerAttachmentUploads(files);\n }\n\n registerCompletedUploads(metadata: AttachmentMetadata[]): AttachmentUploadTask[] {\n return this.registerAttachmentUploads(metadata);\n }\n\n clearUploads(): void {\n this.context.clearUploads();\n this.attachmentUploads.forEach((attachmentUpload) => this.unsubscribeAllEvents(attachmentUpload));\n this.attachmentUploads = [];\n }\n\n cancelUpload(id: string): void {\n this.deleteErroneousAttachmentUploads();\n const attachmentUpload = this.findAttachmentUpload(id);\n this.unsubscribeAllEvents(attachmentUpload);\n this.deleteAttachmentUploads([id]);\n }\n\n updateUploadProgress(id: string, progress: number): void {\n this.context.updateAttachmentUpload(id, { progress });\n }\n\n updateUploadStatusMessage(id: string, errorMessage: string): void {\n this.context.updateAttachmentUpload(id, {\n error: {\n message: errorMessage\n }\n });\n }\n\n updateUploadMetadata(id: string, metadata: AttachmentMetadata): void {\n this.context.updateAttachmentUpload(id, {\n progress: 1,\n id: metadata.id,\n name: metadata.name,\n url: metadata.url,\n extension: metadata.extension\n });\n }\n\n setAttachmentMetadata(taskId: string, attachmentId: string, attachmentUrl: string): void {\n const attachmentUpload = this.findAttachmentUpload(taskId);\n this.context.updateAttachmentUpload(taskId, {\n progress: 1,\n id: attachmentId,\n name: attachmentUpload?.name,\n url: attachmentUrl,\n extension: attachmentUpload?.name.split('.').pop() || ''\n });\n }\n\n private subscribeAllEvents(attachmentUpload: AttachmentUpload): void {\n attachmentUpload.on('uploadProgressChange', this.updateUploadProgress.bind(this));\n attachmentUpload.on('uploadComplete', this.setAttachmentMetadata.bind(this));\n attachmentUpload.on('uploadFail', this.updateUploadStatusMessage.bind(this));\n }\n\n private unsubscribeAllEvents(attachmentUpload?: AttachmentUpload): void {\n attachmentUpload?.off('uploadProgressChange', this.updateUploadProgress.bind(this));\n attachmentUpload?.off('uploadComplete', this.setAttachmentMetadata.bind(this));\n attachmentUpload?.off('uploadFail', this.updateUploadStatusMessage.bind(this));\n }\n}\n\n/* @conditional-compile-remove(attachment-upload) */\n/**\n * @param attachmentUploadUiState {@link _AttachmentUploadsUiState}\n * @private\n */\nexport const convertAttachmentUploadsUiStateToMessageMetadata = (\n attachmentUploads?: _AttachmentUploadsUiState\n): FileSharingMetadata | undefined => {\n if (attachmentUploads) {\n const attachmentMetadata: AttachmentMetadataWithProgress[] = [];\n Object.keys(attachmentUploads).forEach((key) => {\n const attachment = attachmentUploads[key];\n if (attachment && !attachment.error) {\n attachmentMetadata.push({\n id: attachment.id,\n name: attachment.name,\n extension: attachment.extension,\n url: attachment.url,\n progress: attachment.progress\n });\n }\n });\n if (attachmentMetadata.length > 0) {\n return { fileSharingMetadata: JSON.stringify(attachmentMetadata) };\n }\n }\n return undefined;\n};\n\n/* @conditional-compile-remove(attachment-upload) */\n/**\n * @private\n */\nconst convertObservableAttachmentUploadToAttachmentUploadsUiState = (\n attachmentUploads: AttachmentUpload[]\n): _AttachmentUploadsUiState => {\n return attachmentUploads.reduce((map: _AttachmentUploadsUiState, attachmentUpload) => {\n map[attachmentUpload.taskId] = {\n id: attachmentUpload.taskId,\n name: attachmentUpload.name,\n progress: 0,\n extension: attachmentUpload.name.split('.').pop() || ''\n };\n return map;\n }, {});\n};\n"]}
|
@@ -6,7 +6,7 @@ import { ChatAdapter, ChatAdapterState, MessageDeletedListener, MessageEditedLis
|
|
6
6
|
import { ResourceDetails } from './ChatAdapter';
|
7
7
|
import { AdapterError } from '../../common/adapters';
|
8
8
|
import { AttachmentMetadata } from "../../../../../react-components/src";
|
9
|
-
import {
|
9
|
+
import { AttachmentUploadTask } from "../../../../../react-components/src";
|
10
10
|
/**
|
11
11
|
* Context of Chat, which is a centralized context for all state updates
|
12
12
|
* @private
|
@@ -41,6 +41,8 @@ export declare class AzureCommunicationChatAdapter implements ChatAdapter {
|
|
41
41
|
onStateChange(handler: (state: ChatAdapterState) => void): void;
|
42
42
|
offStateChange(handler: (state: ChatAdapterState) => void): void;
|
43
43
|
sendMessage(content: string, options?: SendMessageOptions): Promise<void>;
|
44
|
+
/** Send a chat message with attachments. */
|
45
|
+
sendMessageWithAttachments(content: string, attachments: AttachmentMetadata[]): Promise<void>;
|
44
46
|
sendReadReceipt(chatMessageId: string): Promise<void>;
|
45
47
|
sendTypingIndicator(): Promise<void>;
|
46
48
|
removeParticipant(userId: string): Promise<void>;
|
@@ -50,8 +52,8 @@ export declare class AzureCommunicationChatAdapter implements ChatAdapter {
|
|
50
52
|
attachmentMetadata?: AttachmentMetadata[];
|
51
53
|
}): Promise<void>;
|
52
54
|
deleteMessage(messageId: string): Promise<void>;
|
53
|
-
registerActiveUploads(files: File[]):
|
54
|
-
registerCompletedUploads(metadata: AttachmentMetadata[]):
|
55
|
+
registerActiveUploads(files: File[]): AttachmentUploadTask[];
|
56
|
+
registerCompletedUploads(metadata: AttachmentMetadata[]): AttachmentUploadTask[];
|
55
57
|
clearUploads(): void;
|
56
58
|
cancelUpload(id: string): void;
|
57
59
|
updateUploadProgress(id: string, progress: number): void;
|
@@ -73,7 +73,7 @@ export class ChatContext {
|
|
73
73
|
latestErrors: clientState.latestErrors
|
74
74
|
};
|
75
75
|
/* @conditional-compile-remove(attachment-upload) */
|
76
|
-
updatedState = Object.assign(Object.assign({}, updatedState), {
|
76
|
+
updatedState = Object.assign(Object.assign({}, updatedState), { _attachmentUploads: this.state._attachmentUploads });
|
77
77
|
this.setState(updatedState);
|
78
78
|
}
|
79
79
|
}
|
@@ -108,6 +108,8 @@ export class AzureCommunicationChatAdapter {
|
|
108
108
|
this.dispose = this.dispose.bind(this);
|
109
109
|
this.fetchInitialData = this.fetchInitialData.bind(this);
|
110
110
|
this.sendMessage = this.sendMessage.bind(this);
|
111
|
+
/* @conditional-compile-remove(attachment-upload) */
|
112
|
+
this.sendMessageWithAttachments = this.sendMessageWithAttachments.bind(this);
|
111
113
|
this.sendReadReceipt = this.sendReadReceipt.bind(this);
|
112
114
|
this.sendTypingIndicator = this.sendTypingIndicator.bind(this);
|
113
115
|
this.updateMessage = this.updateMessage.bind(this);
|
@@ -180,7 +182,7 @@ export class AzureCommunicationChatAdapter {
|
|
180
182
|
return __awaiter(this, arguments, void 0, function* (content, options = {}) {
|
181
183
|
yield this.asyncTeeErrorToEventEmitter(() => __awaiter(this, void 0, void 0, function* () {
|
182
184
|
/* @conditional-compile-remove(attachment-upload) */
|
183
|
-
options.metadata = Object.assign(Object.assign({}, options.metadata), convertAttachmentUploadsUiStateToMessageMetadata(this.context.getState().
|
185
|
+
options.metadata = Object.assign(Object.assign({}, options.metadata), convertAttachmentUploadsUiStateToMessageMetadata(this.context.getState()._attachmentUploads));
|
184
186
|
/* @conditional-compile-remove(attachment-upload) */
|
185
187
|
/**
|
186
188
|
* All the current uploads need to be clear from the state before a message has been sent.
|
@@ -194,6 +196,28 @@ export class AzureCommunicationChatAdapter {
|
|
194
196
|
}));
|
195
197
|
});
|
196
198
|
}
|
199
|
+
/* @conditional-compile-remove(attachment-upload) */
|
200
|
+
/** Send a chat message with attachments. */
|
201
|
+
sendMessageWithAttachments(content, attachments) {
|
202
|
+
return __awaiter(this, void 0, void 0, function* () {
|
203
|
+
yield this.asyncTeeErrorToEventEmitter(() => __awaiter(this, void 0, void 0, function* () {
|
204
|
+
const fileSharingMetadata = {
|
205
|
+
fileSharingMetadata: JSON.stringify(attachments)
|
206
|
+
};
|
207
|
+
/**
|
208
|
+
* All the current uploads need to be clear from the state before a message has been sent.
|
209
|
+
* This ensures the following behavior:
|
210
|
+
* 1. Attachment Upload cards are removed from sendbox at the same time text in sendbox is removed.
|
211
|
+
* 2. any component rendering these attachment uploads doesn't continue to do so.
|
212
|
+
* 3. Cleans the state for new attachment uploads with a fresh message.
|
213
|
+
*/
|
214
|
+
this.attachmentUploadAdapter.clearUploads();
|
215
|
+
yield this.handlers.onSendMessage(content, {
|
216
|
+
metadata: fileSharingMetadata
|
217
|
+
});
|
218
|
+
}));
|
219
|
+
});
|
220
|
+
}
|
197
221
|
sendReadReceipt(chatMessageId) {
|
198
222
|
return __awaiter(this, void 0, void 0, function* () {
|
199
223
|
yield this.asyncTeeErrorToEventEmitter(() => __awaiter(this, void 0, void 0, function* () {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"AzureCommunicationChatAdapter.js","sourceRoot":"","sources":["../../../../../../../../react-composites/src/composites/ChatComposite/adapter/AzureCommunicationChatAdapter.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;;;;;;;;;;;;;;;;AAElC,OAAO,EACL,8BAA8B,EAI/B,gDAAuC;AACxC,OAAO,EAAgB,yBAAyB,EAAE,mDAA0C;AAY5F,OAAO,EAAE,6BAA6B,EAAgC,yCAAgC;AACtG,OAAO,YAAY,MAAM,QAAQ,CAAC;AAclC,oDAAoD;AACpD,OAAO,EAEL,gDAAgD,EACjD,MAAM,6CAA6C,CAAC;AACrD,oDAAoD;AACpD,OAAO,EAAE,yCAAyC,EAAE,MAAM,6CAA6C,CAAC;AACxG,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,yCAAgC;AAM7D;;;GAGG;AACH,MAAM,OAAO,WAAW;IAKtB,YAAY,WAA4B,EAAE,QAAgB;QAJlD,YAAO,GAAiB,IAAI,YAAY,EAAE,CAAC;QAKj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C,EAAE,CAAC;QACP,CAAC,CAAC;IACJ,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,UAAgB,6CAA6C,CACjE,UAA8B,EAC9B,gBAAkC;;QAElC,OAAO,IAAI,6BAA6B,CAAC,UAAU,EAAE,gBAAgB,CAAC,CAAC;IACzE,CAAC;CAAA;AAED,MAAM,WAAW,GAAG,CAAC,CAAQ,EAAkB,EAAE;IAC/C,OAAO,QAAQ,IAAI,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,KAAK,SAAS,IAAI,YAAY,IAAI,CAAC,IAAI,CAAC,CAAC,YAAY,CAAC,KAAK,SAAS,CAAC;AAC1G,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport {\n _createStatefulChatClientInner,\n ChatClientState,\n ChatError,\n StatefulChatClient\n} from '@internal/chat-stateful-client';\nimport { ChatHandlers, createDefaultChatHandlers } from '@internal/chat-component-bindings';\nimport { ChatMessage, ChatMessageType, ChatThreadClient, SendMessageOptions } from '@azure/communication-chat';\nimport { CommunicationTokenCredential, CommunicationUserIdentifier } from '@azure/communication-common';\nimport type {\n ChatMessageDeletedEvent,\n ChatMessageEditedEvent,\n ChatMessageReceivedEvent,\n ChatThreadPropertiesUpdatedEvent,\n ParticipantsAddedEvent,\n ParticipantsRemovedEvent,\n ReadReceiptReceivedEvent\n} from '@azure/communication-chat';\nimport { toFlatCommunicationIdentifier, _TelemetryImplementationHint } from '@internal/acs-ui-common';\nimport EventEmitter from 'events';\nimport {\n ChatAdapter,\n ChatAdapterState,\n MessageDeletedListener,\n MessageEditedListener,\n MessageReadListener,\n MessageReceivedListener,\n ParticipantsAddedListener,\n ParticipantsRemovedListener,\n TopicChangedListener\n} from './ChatAdapter';\nimport { ResourceDetails } from './ChatAdapter';\nimport { AdapterError } from '../../common/adapters';\n/* @conditional-compile-remove(attachment-upload) */\nimport {\n AttachmentUploadAdapter,\n convertAttachmentUploadsUiStateToMessageMetadata\n} from './AzureCommunicationAttachmentUploadAdapter';\n/* @conditional-compile-remove(attachment-upload) */\nimport { AzureCommunicationAttachmentUploadAdapter } from './AzureCommunicationAttachmentUploadAdapter';\nimport { useEffect, useRef, useState } from 'react';\nimport { _isValidIdentifier } from '@internal/acs-ui-common';\n/* @conditional-compile-remove(attachment-upload) */\nimport { AttachmentMetadata } from '@internal/react-components';\n/* @conditional-compile-remove(attachment-upload) */\nimport { AttachmentUploadManager } from '@internal/react-components';\n\n/**\n * Context of Chat, which is a centralized context for all state updates\n * @private\n */\nexport class ChatContext {\n private emitter: EventEmitter = new EventEmitter();\n private state: ChatAdapterState;\n private threadId: string;\n\n constructor(clientState: ChatClientState, threadId: string) {\n const thread = clientState.threads[threadId];\n this.threadId = threadId;\n if (!thread) {\n throw 'Cannot find threadId, please initialize thread before use!';\n }\n this.state = {\n userId: clientState.userId,\n displayName: clientState.displayName,\n thread,\n latestErrors: clientState.latestErrors\n };\n }\n\n public onStateChange(handler: (_uiState: ChatAdapterState) => void): void {\n this.emitter.on('stateChanged', handler);\n }\n\n public offStateChange(handler: (_uiState: ChatAdapterState) => void): void {\n this.emitter.off('stateChanged', handler);\n }\n\n public setState(state: ChatAdapterState): void {\n this.state = state;\n this.emitter.emit('stateChanged', this.state);\n }\n\n public getState(): ChatAdapterState {\n return this.state;\n }\n\n public setError(error: Error): void {\n this.setState({ ...this.state, error });\n }\n\n public updateClientState(clientState: ChatClientState): void {\n const thread = clientState.threads[this.threadId];\n if (!thread) {\n throw 'Cannot find threadId, please make sure thread state is still in Stateful ChatClient.';\n }\n\n let updatedState: ChatAdapterState = {\n userId: clientState.userId,\n displayName: clientState.displayName,\n thread,\n latestErrors: clientState.latestErrors\n };\n\n /* @conditional-compile-remove(attachment-upload) */\n updatedState = { ...updatedState, attachmentUploads: this.state.attachmentUploads };\n\n this.setState(updatedState);\n }\n}\n\n/**\n * @private\n */\nexport class AzureCommunicationChatAdapter implements ChatAdapter {\n private chatClient: StatefulChatClient;\n private chatThreadClient: ChatThreadClient;\n private context: ChatContext;\n /* @conditional-compile-remove(attachment-upload) */\n private attachmentUploadAdapter: AttachmentUploadAdapter;\n private handlers: ChatHandlers;\n private emitter: EventEmitter = new EventEmitter();\n\n constructor(chatClient: StatefulChatClient, chatThreadClient: ChatThreadClient) {\n this.bindAllPublicMethods();\n this.chatClient = chatClient;\n this.chatThreadClient = chatThreadClient;\n this.context = new ChatContext(chatClient.getState(), chatThreadClient.threadId);\n /* @conditional-compile-remove(attachment-upload) */\n this.attachmentUploadAdapter = new AzureCommunicationAttachmentUploadAdapter(this.context);\n\n const onStateChange = (clientState: ChatClientState): void => {\n // unsubscribe when the instance gets disposed\n if (!this) {\n chatClient.offStateChange(onStateChange);\n return;\n }\n this.context.updateClientState(clientState);\n };\n\n this.handlers = createDefaultChatHandlers(chatClient, chatThreadClient);\n\n this.chatClient.onStateChange(onStateChange);\n this.subscribeAllEvents();\n }\n\n private bindAllPublicMethods(): void {\n this.onStateChange = this.onStateChange.bind(this);\n this.offStateChange = this.offStateChange.bind(this);\n this.getState = this.getState.bind(this);\n this.dispose = this.dispose.bind(this);\n this.fetchInitialData = this.fetchInitialData.bind(this);\n this.sendMessage = this.sendMessage.bind(this);\n this.sendReadReceipt = this.sendReadReceipt.bind(this);\n this.sendTypingIndicator = this.sendTypingIndicator.bind(this);\n this.updateMessage = this.updateMessage.bind(this);\n this.deleteMessage = this.deleteMessage.bind(this);\n this.removeParticipant = this.removeParticipant.bind(this);\n this.setTopic = this.setTopic.bind(this);\n this.loadPreviousChatMessages = this.loadPreviousChatMessages.bind(this);\n this.on = this.on.bind(this);\n this.off = this.off.bind(this);\n /* @conditional-compile-remove(attachment-upload) */\n this.registerActiveUploads = this.registerActiveUploads.bind(this);\n /* @conditional-compile-remove(attachment-upload) */\n this.registerCompletedUploads = this.registerCompletedUploads.bind(this);\n /* @conditional-compile-remove(attachment-upload) */\n this.clearUploads = this.clearUploads.bind(this);\n /* @conditional-compile-remove(attachment-upload) */\n this.cancelUpload = this.cancelUpload.bind(this);\n /* @conditional-compile-remove(attachment-upload) */\n this.updateUploadProgress = this.updateUploadProgress.bind(this);\n /* @conditional-compile-remove(attachment-upload) */\n this.updateUploadStatusMessage = this.updateUploadStatusMessage.bind(this);\n /* @conditional-compile-remove(attachment-upload) */\n this.updateUploadMetadata = this.updateUploadMetadata.bind(this);\n this.downloadResourceToCache = this.downloadResourceToCache.bind(this);\n this.removeResourceFromCache = this.removeResourceFromCache.bind(this);\n }\n\n dispose(): void {\n this.unsubscribeAllEvents();\n this.chatClient.dispose();\n }\n\n async fetchInitialData(): Promise<void> {\n // If get properties fails we dont want to try to get the participants after.\n await this.asyncTeeErrorToEventEmitter(async () => {\n await this.chatThreadClient.getProperties();\n // Fetch all participants who joined before the local user.\n for await (const _page of this.chatThreadClient.listParticipants().byPage({\n // Fetch 100 participants per page by default.\n maxPageSize: 100\n // eslint-disable-next-line curly\n }));\n });\n }\n\n getState(): ChatAdapterState {\n return this.context.getState();\n }\n\n onStateChange(handler: (state: ChatAdapterState) => void): void {\n this.context.onStateChange(handler);\n }\n\n offStateChange(handler: (state: ChatAdapterState) => void): void {\n this.context.offStateChange(handler);\n }\n\n async sendMessage(content: string, options: SendMessageOptions = {}): Promise<void> {\n await this.asyncTeeErrorToEventEmitter(async () => {\n /* @conditional-compile-remove(attachment-upload) */\n options.metadata = {\n ...options.metadata,\n ...convertAttachmentUploadsUiStateToMessageMetadata(this.context.getState().attachmentUploads)\n };\n\n /* @conditional-compile-remove(attachment-upload) */\n /**\n * All the current uploads need to be clear from the state before a message has been sent.\n * This ensures the following behavior:\n * 1. Attachment Upload cards are removed from sendbox at the same time text in sendbox is removed.\n * 2. any component rendering these attachment uploads doesn't continue to do so.\n * 3. Cleans the state for new attachment uploads with a fresh message.\n */\n this.attachmentUploadAdapter.clearUploads();\n\n await this.handlers.onSendMessage(content, options);\n });\n }\n\n async sendReadReceipt(chatMessageId: string): Promise<void> {\n await this.asyncTeeErrorToEventEmitter(async () => {\n await this.handlers.onMessageSeen(chatMessageId);\n });\n }\n\n async sendTypingIndicator(): Promise<void> {\n await this.asyncTeeErrorToEventEmitter(async () => {\n await this.handlers.onTyping();\n });\n }\n\n async removeParticipant(userId: string): Promise<void> {\n await this.asyncTeeErrorToEventEmitter(async () => {\n await this.handlers.onRemoveParticipant(userId);\n });\n }\n\n async setTopic(topicName: string): Promise<void> {\n await this.asyncTeeErrorToEventEmitter(async () => {\n await this.handlers.updateThreadTopicName(topicName);\n });\n }\n\n async loadPreviousChatMessages(messagesToLoad: number): Promise<boolean> {\n return await this.asyncTeeErrorToEventEmitter(async () => {\n return await this.handlers.onLoadPreviousChatMessages(messagesToLoad);\n });\n }\n\n async updateMessage(\n messageId: string,\n content: string,\n metadata?: Record<string, string>,\n options?: {\n /* @conditional-compile-remove(attachment-upload) */\n attachmentMetadata?: AttachmentMetadata[];\n }\n ): Promise<void> {\n return await this.asyncTeeErrorToEventEmitter(async () => {\n /* @conditional-compile-remove(attachment-upload) */\n const updatedOptions = { attachmentMetadata: options?.attachmentMetadata, metadata: metadata };\n /* @conditional-compile-remove(attachment-upload) */\n return await this.handlers.onUpdateMessage(messageId, content, updatedOptions);\n return await this.handlers.onUpdateMessage(messageId, content);\n });\n }\n\n async deleteMessage(messageId: string): Promise<void> {\n return await this.asyncTeeErrorToEventEmitter(async () => {\n return await this.handlers.onDeleteMessage(messageId);\n });\n }\n\n /* @conditional-compile-remove(attachment-upload) */\n registerActiveUploads(files: File[]): AttachmentUploadManager[] {\n return this.attachmentUploadAdapter.registerActiveUploads(files);\n }\n\n /* @conditional-compile-remove(attachment-upload) */\n registerCompletedUploads(metadata: AttachmentMetadata[]): AttachmentUploadManager[] {\n return this.attachmentUploadAdapter.registerCompletedUploads(metadata);\n }\n\n /* @conditional-compile-remove(attachment-upload) */\n clearUploads(): void {\n this.attachmentUploadAdapter.clearUploads();\n }\n\n /* @conditional-compile-remove(attachment-upload) */\n cancelUpload(id: string): void {\n this.attachmentUploadAdapter.cancelUpload(id);\n }\n\n /* @conditional-compile-remove(attachment-upload) */\n updateUploadProgress(id: string, progress: number): void {\n this.attachmentUploadAdapter.updateUploadProgress(id, progress);\n }\n\n /* @conditional-compile-remove(attachment-upload) */\n updateUploadStatusMessage(id: string, errorMessage: string): void {\n this.attachmentUploadAdapter.updateUploadStatusMessage(id, errorMessage);\n }\n\n /* @conditional-compile-remove(attachment-upload) */\n updateUploadMetadata(id: string, metadata: AttachmentMetadata): void {\n this.attachmentUploadAdapter.updateUploadMetadata(id, metadata);\n }\n\n async downloadResourceToCache(resourceDetails: ResourceDetails): Promise<void> {\n this.chatClient.downloadResourceToCache(\n resourceDetails.threadId,\n resourceDetails.messageId,\n resourceDetails.resourceUrl\n );\n }\n\n removeResourceFromCache(resourceDetails: ResourceDetails): void {\n this.chatClient.removeResourceFromCache(\n resourceDetails.threadId,\n resourceDetails.messageId,\n resourceDetails.resourceUrl\n );\n }\n\n private messageReceivedListener(event: ChatMessageReceivedEvent): void {\n const isCurrentChatAdapterThread = event.threadId === this.chatThreadClient.threadId;\n\n if (!isCurrentChatAdapterThread) {\n return;\n }\n\n const message = convertEventToChatMessage(event);\n this.emitter.emit('messageReceived', { message });\n\n const currentUserId = toFlatCommunicationIdentifier(this.chatClient.getState().userId);\n if (message?.sender && toFlatCommunicationIdentifier(message.sender) === currentUserId) {\n this.emitter.emit('messageSent', { message });\n }\n }\n\n private messageEditedListener(event: ChatMessageEditedEvent): void {\n const isCurrentChatAdapterThread = event.threadId === this.chatThreadClient.threadId;\n if (!isCurrentChatAdapterThread) {\n return;\n }\n\n const message = convertEventToChatMessage(event);\n this.emitter.emit('messageEdited', { message });\n }\n\n private messageDeletedListener(event: ChatMessageDeletedEvent): void {\n const isCurrentChatAdapterThread = event.threadId === this.chatThreadClient.threadId;\n if (!isCurrentChatAdapterThread) {\n return;\n }\n\n const message = convertEventToChatMessage(event);\n this.emitter.emit('messageDeleted', { message });\n }\n\n private messageReadListener({ chatMessageId, recipient }: ReadReceiptReceivedEvent): void {\n const message = this.getState().thread.chatMessages[chatMessageId];\n if (message) {\n this.emitter.emit('messageRead', { message, readBy: recipient });\n }\n }\n\n private participantsAddedListener({ addedBy, participantsAdded }: ParticipantsAddedEvent): void {\n this.emitter.emit('participantsAdded', { addedBy, participantsAdded });\n }\n\n private participantsRemovedListener({ removedBy, participantsRemoved }: ParticipantsRemovedEvent): void {\n this.emitter.emit('participantsRemoved', { removedBy, participantsRemoved });\n }\n\n private chatThreadPropertiesUpdatedListener(event: ChatThreadPropertiesUpdatedEvent): void {\n this.emitter.emit('topicChanged', { topic: event.properties.topic });\n }\n\n private subscribeAllEvents(): void {\n this.chatClient.on('chatThreadPropertiesUpdated', this.chatThreadPropertiesUpdatedListener.bind(this));\n this.chatClient.on('participantsAdded', this.participantsAddedListener.bind(this));\n this.chatClient.on('participantsRemoved', this.participantsRemovedListener.bind(this));\n this.chatClient.on('chatMessageReceived', this.messageReceivedListener.bind(this));\n this.chatClient.on('chatMessageEdited', this.messageEditedListener.bind(this));\n this.chatClient.on('chatMessageDeleted', this.messageDeletedListener.bind(this));\n this.chatClient.on('readReceiptReceived', this.messageReadListener.bind(this));\n this.chatClient.on('participantsRemoved', this.participantsRemovedListener.bind(this));\n }\n\n private unsubscribeAllEvents(): void {\n this.chatClient.off('chatThreadPropertiesUpdated', this.chatThreadPropertiesUpdatedListener.bind(this));\n this.chatClient.off('participantsAdded', this.participantsAddedListener.bind(this));\n this.chatClient.off('participantsRemoved', this.participantsRemovedListener.bind(this));\n this.chatClient.off('chatMessageReceived', this.messageReceivedListener.bind(this));\n this.chatClient.off('chatMessageEdited', this.messageEditedListener.bind(this));\n this.chatClient.off('chatMessageDeleted', this.messageDeletedListener.bind(this));\n this.chatClient.off('readReceiptReceived', this.messageReadListener.bind(this));\n this.chatClient.off('participantsRemoved', this.participantsRemovedListener.bind(this));\n }\n\n on(event: 'messageReceived', listener: MessageReceivedListener): void;\n on(event: 'messageEdited', listener: MessageEditedListener): void;\n on(event: 'messageDeleted', listener: MessageDeletedListener): void;\n on(event: 'messageSent', listener: MessageReceivedListener): void;\n on(event: 'messageRead', listener: MessageReadListener): void;\n on(event: 'participantsAdded', listener: ParticipantsAddedListener): void;\n on(event: 'participantsRemoved', listener: ParticipantsRemovedListener): void;\n on(event: 'topicChanged', listener: TopicChangedListener): void;\n on(event: 'error', listener: (e: AdapterError) => void): void;\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n on(event: string, listener: (e: any) => void): void {\n this.emitter.on(event, listener);\n }\n\n off(event: 'messageReceived', listener: MessageReceivedListener): void;\n off(event: 'messageEdited', listener: MessageEditedListener): void;\n off(event: 'messageDeleted', listener: MessageDeletedListener): void;\n off(event: 'messageSent', listener: MessageReceivedListener): void;\n off(event: 'messageRead', listener: MessageReadListener): void;\n off(event: 'participantsAdded', listener: ParticipantsAddedListener): void;\n off(event: 'participantsRemoved', listener: ParticipantsRemovedListener): void;\n off(event: 'topicChanged', listener: TopicChangedListener): void;\n off(event: 'error', listener: (e: AdapterError) => void): void;\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n off(event: string, listener: (e: any) => void): void {\n this.emitter.off(event, listener);\n }\n\n private async asyncTeeErrorToEventEmitter<T>(f: () => Promise<T>): Promise<T> {\n try {\n return await f();\n } catch (error) {\n if (isChatError(error as Error)) {\n this.emitter.emit('error', error as AdapterError);\n }\n throw error;\n }\n }\n}\n\nconst convertEventToChatMessage = (\n event: ChatMessageReceivedEvent | ChatMessageEditedEvent | ChatMessageDeletedEvent\n): ChatMessage => {\n return {\n id: event.id,\n version: event.version,\n content: isChatMessageDeletedEvent(event) ? undefined : { message: event.message },\n type: convertEventType(event.type),\n sender: event.sender,\n senderDisplayName: event.senderDisplayName,\n sequenceId: '',\n createdOn: new Date(event.createdOn),\n editedOn: isChatMessageEditedEvent(event) ? event.editedOn : undefined,\n deletedOn: isChatMessageDeletedEvent(event) ? event.deletedOn : undefined\n };\n};\n\nconst isChatMessageEditedEvent = (\n event: ChatMessageReceivedEvent | ChatMessageEditedEvent | ChatMessageDeletedEvent\n): event is ChatMessageEditedEvent => {\n return 'editedOn' in event;\n};\n\nconst isChatMessageDeletedEvent = (\n event: ChatMessageReceivedEvent | ChatMessageEditedEvent | ChatMessageDeletedEvent\n): event is ChatMessageDeletedEvent => {\n return 'deletedOn' in event;\n};\n\n// only text/html message type will be received from event\nconst convertEventType = (type: string): ChatMessageType => {\n const lowerCaseType = type.toLowerCase();\n if (lowerCaseType === 'richtext/html' || lowerCaseType === 'html') {\n return 'html';\n } else {\n return 'text';\n }\n};\n\n/**\n * Arguments for creating the Azure Communication Services implementation of {@link ChatAdapter}.\n *\n * @public\n */\nexport type AzureCommunicationChatAdapterArgs = {\n endpoint: string;\n userId: CommunicationUserIdentifier;\n displayName: string;\n credential: CommunicationTokenCredential;\n threadId: string;\n};\n\n/**\n * Create a {@link ChatAdapter} backed by Azure Communication Services.\n *\n * This is the default implementation of {@link ChatAdapter} provided by this library.\n *\n * @public\n */\nexport const createAzureCommunicationChatAdapter = async ({\n endpoint: endpointUrl,\n userId,\n displayName,\n credential,\n threadId\n}: AzureCommunicationChatAdapterArgs): Promise<ChatAdapter> => {\n return _createAzureCommunicationChatAdapterInner(endpointUrl, userId, displayName, credential, threadId);\n};\n\n/**\n * This inner function is used to allow injection of TelemetryImplementationHint without changing the public API.\n *\n * @internal\n */\nexport const _createAzureCommunicationChatAdapterInner = async (\n endpoint: string,\n userId: CommunicationUserIdentifier,\n displayName: string,\n credential: CommunicationTokenCredential,\n threadId: string,\n telemetryImplementationHint: _TelemetryImplementationHint = 'Chat'\n): Promise<ChatAdapter> => {\n if (!_isValidIdentifier(userId)) {\n throw new Error('Provided userId is invalid. Please provide valid identifier object.');\n }\n\n const chatClient = _createStatefulChatClientInner(\n {\n userId,\n displayName,\n endpoint,\n credential\n },\n undefined,\n telemetryImplementationHint\n );\n const chatThreadClient = await chatClient.getChatThreadClient(threadId);\n await chatClient.startRealtimeNotifications();\n\n const adapter = await createAzureCommunicationChatAdapterFromClient(chatClient, chatThreadClient);\n\n return adapter;\n};\n\n/**\n * This inner function to create ChatAdapterPromise in case when threadID is not avaialble.\n * ThreadId is a promise to allow for lazy initialization of the adapter.\n * @internal\n */\nexport const _createLazyAzureCommunicationChatAdapterInner = async (\n endpoint: string,\n userId: CommunicationUserIdentifier,\n displayName: string,\n credential: CommunicationTokenCredential,\n threadId: Promise<string>,\n telemetryImplementationHint: _TelemetryImplementationHint = 'Chat'\n): Promise<ChatAdapter> => {\n if (!_isValidIdentifier(userId)) {\n throw new Error('Provided userId is invalid. Please provide valid identifier object.');\n }\n\n const chatClient = _createStatefulChatClientInner(\n {\n userId,\n displayName,\n endpoint,\n credential\n },\n undefined,\n telemetryImplementationHint\n );\n return threadId.then(async (threadId) => {\n const chatThreadClient = await chatClient.getChatThreadClient(threadId);\n await chatClient.startRealtimeNotifications();\n\n const adapter = await createAzureCommunicationChatAdapterFromClient(chatClient, chatThreadClient);\n\n return adapter;\n });\n};\n\n/**\n * A custom React hook to simplify the creation of {@link ChatAdapter}.\n *\n * Similar to {@link createAzureCommunicationChatAdapter}, but takes care of asynchronous\n * creation of the adapter internally.\n *\n * Allows arguments to be undefined so that you can respect the rule-of-hooks and pass in arguments\n * as they are created. The adapter is only created when all arguments are defined.\n *\n * Note that you must memoize the arguments to avoid recreating adapter on each render.\n * See storybook for typical usage examples.\n *\n * @public\n */\nexport const useAzureCommunicationChatAdapter = (\n /**\n * Arguments to be passed to {@link createAzureCommunicationChatAdapter}.\n *\n * Allows arguments to be undefined so that you can respect the rule-of-hooks and pass in arguments\n * as they are created. The adapter is only created when all arguments are defined.\n */\n args: Partial<AzureCommunicationChatAdapterArgs>,\n /**\n * Optional callback to modify the adapter once it is created.\n *\n * If set, must return the modified adapter.\n */\n afterCreate?: (adapter: ChatAdapter) => Promise<ChatAdapter>,\n /**\n * Optional callback called before the adapter is disposed.\n *\n * This is useful for clean up tasks, e.g., leaving any ongoing calls.\n */\n beforeDispose?: (adapter: ChatAdapter) => Promise<void>\n): ChatAdapter | undefined => {\n const { credential, displayName, endpoint, threadId, userId } = args;\n\n // State update needed to rerender the parent component when a new adapter is created.\n const [adapter, setAdapter] = useState<ChatAdapter | undefined>(undefined);\n // Ref needed for cleanup to access the old adapter created asynchronously.\n const adapterRef = useRef<ChatAdapter | undefined>(undefined);\n\n const afterCreateRef = useRef<((adapter: ChatAdapter) => Promise<ChatAdapter>) | undefined>(undefined);\n const beforeDisposeRef = useRef<((adapter: ChatAdapter) => Promise<void>) | undefined>(undefined);\n // These refs are updated on *each* render, so that the latest values\n // are used in the `useEffect` closures below.\n // Using a Ref ensures that new values for the callbacks do not trigger the\n // useEffect blocks, and a new adapter creation / distruction is not triggered.\n afterCreateRef.current = afterCreate;\n beforeDisposeRef.current = beforeDispose;\n\n useEffect(\n () => {\n if (!credential || !displayName || !endpoint || !threadId || !userId) {\n return;\n }\n (async () => {\n if (adapterRef.current) {\n // Dispose the old adapter when a new one is created.\n //\n // This clean up function uses `adapterRef` because `adapter` can not be added to the dependency array of\n // this `useEffect` -- we do not want to trigger a new adapter creation because of the first adapter\n // creation.\n if (beforeDisposeRef.current) {\n await beforeDisposeRef.current(adapterRef.current);\n }\n adapterRef.current.dispose();\n adapterRef.current = undefined;\n }\n\n let newAdapter = await createAzureCommunicationChatAdapter({\n credential,\n displayName,\n endpoint,\n threadId,\n userId\n });\n if (afterCreateRef.current) {\n newAdapter = await afterCreateRef.current(newAdapter);\n }\n adapterRef.current = newAdapter;\n setAdapter(newAdapter);\n })();\n },\n // Explicitly list all arguments so that caller doesn't have to memoize the `args` object.\n [adapterRef, afterCreateRef, beforeDisposeRef, credential, displayName, endpoint, threadId, userId]\n );\n\n // Dispose any existing adapter when the component unmounts.\n useEffect(() => {\n return () => {\n (async () => {\n if (adapterRef.current) {\n if (beforeDisposeRef.current) {\n await beforeDisposeRef.current(adapterRef.current);\n }\n adapterRef.current.dispose();\n adapterRef.current = undefined;\n }\n })();\n };\n }, []);\n\n return adapter;\n};\n\n/**\n * Create a {@link ChatAdapter} using the provided {@link StatefulChatClient}.\n *\n * Useful if you want to keep a reference to {@link StatefulChatClient}.\n * Consider using {@link createAzureCommunicationChatAdapter} for a simpler API.\n *\n * @public\n */\nexport async function createAzureCommunicationChatAdapterFromClient(\n chatClient: StatefulChatClient,\n chatThreadClient: ChatThreadClient\n): Promise<ChatAdapter> {\n return new AzureCommunicationChatAdapter(chatClient, chatThreadClient);\n}\n\nconst isChatError = (e: Error): e is ChatError => {\n return 'target' in e && e['target'] !== undefined && 'innerError' in e && e['innerError'] !== undefined;\n};\n"]}
|
1
|
+
{"version":3,"file":"AzureCommunicationChatAdapter.js","sourceRoot":"","sources":["../../../../../../../../react-composites/src/composites/ChatComposite/adapter/AzureCommunicationChatAdapter.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;;;;;;;;;;;;;;;;AAElC,OAAO,EACL,8BAA8B,EAI/B,gDAAuC;AACxC,OAAO,EAAgB,yBAAyB,EAAE,mDAA0C;AAY5F,OAAO,EAAE,6BAA6B,EAAgC,yCAAgC;AACtG,OAAO,YAAY,MAAM,QAAQ,CAAC;AAclC,oDAAoD;AACpD,OAAO,EAEL,gDAAgD,EACjD,MAAM,6CAA6C,CAAC;AACrD,oDAAoD;AACpD,OAAO,EAAE,yCAAyC,EAAE,MAAM,6CAA6C,CAAC;AACxG,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,yCAAgC;AAQ7D;;;GAGG;AACH,MAAM,OAAO,WAAW;IAKtB,YAAY,WAA4B,EAAE,QAAgB;QAJlD,YAAO,GAAiB,IAAI,YAAY,EAAE,CAAC;QAKjD,MAAM,MAAM,GAAG,WAAW,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QAC7C,IAAI,CAAC,QAAQ,GAAG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EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,CAAC,CACpG,CAAC;IAEF,4DAA4D;IAC5D,SAAS,CAAC,GAAG,EAAE;QACb,OAAO,GAAG,EAAE;YACV,CAAC,GAAS,EAAE;gBACV,IAAI,UAAU,CAAC,OAAO,EAAE,CAAC;oBACvB,IAAI,gBAAgB,CAAC,OAAO,EAAE,CAAC;wBAC7B,MAAM,gBAAgB,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;oBACrD,CAAC;oBACD,UAAU,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;oBAC7B,UAAU,CAAC,OAAO,GAAG,SAAS,CAAC;gBACjC,CAAC;YACH,CAAC,CAAA,CAAC,EAAE,CAAC;QACP,CAAC,CAAC;IACJ,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,UAAgB,6CAA6C,CACjE,UAA8B,EAC9B,gBAAkC;;QAElC,OAAO,IAAI,6BAA6B,CAAC,UAAU,EAAE,gBAAgB,CAAC,CAAC;IACzE,CAAC;CAAA;AAED,MAAM,WAAW,GAAG,CAAC,CAAQ,EAAkB,EAAE;IAC/C,OAAO,QAAQ,IAAI,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,KAAK,SAAS,IAAI,YAAY,IAAI,CAAC,IAAI,CAAC,CAAC,YAAY,CAAC,KAAK,SAAS,CAAC;AAC1G,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport {\n _createStatefulChatClientInner,\n ChatClientState,\n ChatError,\n StatefulChatClient\n} from '@internal/chat-stateful-client';\nimport { ChatHandlers, createDefaultChatHandlers } from '@internal/chat-component-bindings';\nimport { ChatMessage, ChatMessageType, ChatThreadClient, SendMessageOptions } from '@azure/communication-chat';\nimport { CommunicationTokenCredential, CommunicationUserIdentifier } from '@azure/communication-common';\nimport type {\n ChatMessageDeletedEvent,\n ChatMessageEditedEvent,\n ChatMessageReceivedEvent,\n ChatThreadPropertiesUpdatedEvent,\n ParticipantsAddedEvent,\n ParticipantsRemovedEvent,\n ReadReceiptReceivedEvent\n} from '@azure/communication-chat';\nimport { toFlatCommunicationIdentifier, _TelemetryImplementationHint } from '@internal/acs-ui-common';\nimport EventEmitter from 'events';\nimport {\n ChatAdapter,\n ChatAdapterState,\n MessageDeletedListener,\n MessageEditedListener,\n MessageReadListener,\n MessageReceivedListener,\n ParticipantsAddedListener,\n ParticipantsRemovedListener,\n TopicChangedListener\n} from './ChatAdapter';\nimport { ResourceDetails } from './ChatAdapter';\nimport { AdapterError } from '../../common/adapters';\n/* @conditional-compile-remove(attachment-upload) */\nimport {\n _AttachmentUploadAdapter,\n convertAttachmentUploadsUiStateToMessageMetadata\n} from './AzureCommunicationAttachmentUploadAdapter';\n/* @conditional-compile-remove(attachment-upload) */\nimport { AzureCommunicationAttachmentUploadAdapter } from './AzureCommunicationAttachmentUploadAdapter';\nimport { useEffect, useRef, useState } from 'react';\nimport { _isValidIdentifier } from '@internal/acs-ui-common';\n/* @conditional-compile-remove(attachment-upload) */\nimport { AttachmentMetadata } from '@internal/react-components';\n/* @conditional-compile-remove(attachment-upload) */\nimport { AttachmentUploadTask } from '@internal/react-components';\n/* @conditional-compile-remove(attachment-upload) */\nimport { FileSharingMetadata } from '../../ChatComposite/file-sharing';\n\n/**\n * Context of Chat, which is a centralized context for all state updates\n * @private\n */\nexport class ChatContext {\n private emitter: EventEmitter = new EventEmitter();\n private state: ChatAdapterState;\n private threadId: string;\n\n constructor(clientState: ChatClientState, threadId: string) {\n const thread = clientState.threads[threadId];\n this.threadId = threadId;\n if (!thread) {\n throw 'Cannot find threadId, please initialize thread before use!';\n }\n this.state = {\n userId: clientState.userId,\n displayName: clientState.displayName,\n thread,\n latestErrors: clientState.latestErrors\n };\n }\n\n public onStateChange(handler: (_uiState: ChatAdapterState) => void): void {\n this.emitter.on('stateChanged', handler);\n }\n\n public offStateChange(handler: (_uiState: ChatAdapterState) => void): void {\n this.emitter.off('stateChanged', handler);\n }\n\n public setState(state: ChatAdapterState): void {\n this.state = state;\n this.emitter.emit('stateChanged', this.state);\n }\n\n public getState(): ChatAdapterState {\n return this.state;\n }\n\n public setError(error: Error): void {\n this.setState({ ...this.state, error });\n }\n\n public updateClientState(clientState: ChatClientState): void {\n const thread = clientState.threads[this.threadId];\n if (!thread) {\n throw 'Cannot find threadId, please make sure thread state is still in Stateful ChatClient.';\n }\n\n let updatedState: ChatAdapterState = {\n userId: clientState.userId,\n displayName: clientState.displayName,\n thread,\n latestErrors: clientState.latestErrors\n };\n\n /* @conditional-compile-remove(attachment-upload) */\n updatedState = { ...updatedState, _attachmentUploads: this.state._attachmentUploads };\n\n this.setState(updatedState);\n }\n}\n\n/**\n * @private\n */\nexport class AzureCommunicationChatAdapter implements ChatAdapter {\n private chatClient: StatefulChatClient;\n private chatThreadClient: ChatThreadClient;\n private context: ChatContext;\n /* @conditional-compile-remove(attachment-upload) */\n private attachmentUploadAdapter: _AttachmentUploadAdapter;\n private handlers: ChatHandlers;\n private emitter: EventEmitter = new EventEmitter();\n\n constructor(chatClient: StatefulChatClient, chatThreadClient: ChatThreadClient) {\n this.bindAllPublicMethods();\n this.chatClient = chatClient;\n this.chatThreadClient = chatThreadClient;\n this.context = new ChatContext(chatClient.getState(), chatThreadClient.threadId);\n /* @conditional-compile-remove(attachment-upload) */\n this.attachmentUploadAdapter = new AzureCommunicationAttachmentUploadAdapter(this.context);\n\n const onStateChange = (clientState: ChatClientState): void => {\n // unsubscribe when the instance gets disposed\n if (!this) {\n chatClient.offStateChange(onStateChange);\n return;\n }\n this.context.updateClientState(clientState);\n };\n\n this.handlers = createDefaultChatHandlers(chatClient, chatThreadClient);\n\n this.chatClient.onStateChange(onStateChange);\n this.subscribeAllEvents();\n }\n\n private bindAllPublicMethods(): void {\n this.onStateChange = this.onStateChange.bind(this);\n this.offStateChange = this.offStateChange.bind(this);\n this.getState = this.getState.bind(this);\n this.dispose = this.dispose.bind(this);\n this.fetchInitialData = this.fetchInitialData.bind(this);\n this.sendMessage = this.sendMessage.bind(this);\n /* @conditional-compile-remove(attachment-upload) */\n this.sendMessageWithAttachments = this.sendMessageWithAttachments.bind(this);\n this.sendReadReceipt = this.sendReadReceipt.bind(this);\n this.sendTypingIndicator = this.sendTypingIndicator.bind(this);\n this.updateMessage = this.updateMessage.bind(this);\n this.deleteMessage = this.deleteMessage.bind(this);\n this.removeParticipant = this.removeParticipant.bind(this);\n this.setTopic = this.setTopic.bind(this);\n this.loadPreviousChatMessages = this.loadPreviousChatMessages.bind(this);\n this.on = this.on.bind(this);\n this.off = this.off.bind(this);\n /* @conditional-compile-remove(attachment-upload) */\n this.registerActiveUploads = this.registerActiveUploads.bind(this);\n /* @conditional-compile-remove(attachment-upload) */\n this.registerCompletedUploads = this.registerCompletedUploads.bind(this);\n /* @conditional-compile-remove(attachment-upload) */\n this.clearUploads = this.clearUploads.bind(this);\n /* @conditional-compile-remove(attachment-upload) */\n this.cancelUpload = this.cancelUpload.bind(this);\n /* @conditional-compile-remove(attachment-upload) */\n this.updateUploadProgress = this.updateUploadProgress.bind(this);\n /* @conditional-compile-remove(attachment-upload) */\n this.updateUploadStatusMessage = this.updateUploadStatusMessage.bind(this);\n /* @conditional-compile-remove(attachment-upload) */\n this.updateUploadMetadata = this.updateUploadMetadata.bind(this);\n this.downloadResourceToCache = this.downloadResourceToCache.bind(this);\n this.removeResourceFromCache = this.removeResourceFromCache.bind(this);\n }\n\n dispose(): void {\n this.unsubscribeAllEvents();\n this.chatClient.dispose();\n }\n\n async fetchInitialData(): Promise<void> {\n // If get properties fails we dont want to try to get the participants after.\n await this.asyncTeeErrorToEventEmitter(async () => {\n await this.chatThreadClient.getProperties();\n // Fetch all participants who joined before the local user.\n for await (const _page of this.chatThreadClient.listParticipants().byPage({\n // Fetch 100 participants per page by default.\n maxPageSize: 100\n // eslint-disable-next-line curly\n }));\n });\n }\n\n getState(): ChatAdapterState {\n return this.context.getState();\n }\n\n onStateChange(handler: (state: ChatAdapterState) => void): void {\n this.context.onStateChange(handler);\n }\n\n offStateChange(handler: (state: ChatAdapterState) => void): void {\n this.context.offStateChange(handler);\n }\n\n async sendMessage(content: string, options: SendMessageOptions = {}): Promise<void> {\n await this.asyncTeeErrorToEventEmitter(async () => {\n /* @conditional-compile-remove(attachment-upload) */\n options.metadata = {\n ...options.metadata,\n ...convertAttachmentUploadsUiStateToMessageMetadata(this.context.getState()._attachmentUploads)\n };\n\n /* @conditional-compile-remove(attachment-upload) */\n /**\n * All the current uploads need to be clear from the state before a message has been sent.\n * This ensures the following behavior:\n * 1. Attachment Upload cards are removed from sendbox at the same time text in sendbox is removed.\n * 2. any component rendering these attachment uploads doesn't continue to do so.\n * 3. Cleans the state for new attachment uploads with a fresh message.\n */\n this.attachmentUploadAdapter.clearUploads();\n\n await this.handlers.onSendMessage(content, options);\n });\n }\n\n /* @conditional-compile-remove(attachment-upload) */\n /** Send a chat message with attachments. */\n public async sendMessageWithAttachments(content: string, attachments: AttachmentMetadata[]): Promise<void> {\n await this.asyncTeeErrorToEventEmitter(async () => {\n const fileSharingMetadata: FileSharingMetadata = {\n fileSharingMetadata: JSON.stringify(attachments)\n };\n /**\n * All the current uploads need to be clear from the state before a message has been sent.\n * This ensures the following behavior:\n * 1. Attachment Upload cards are removed from sendbox at the same time text in sendbox is removed.\n * 2. any component rendering these attachment uploads doesn't continue to do so.\n * 3. Cleans the state for new attachment uploads with a fresh message.\n */\n this.attachmentUploadAdapter.clearUploads();\n await this.handlers.onSendMessage(content, {\n metadata: fileSharingMetadata\n });\n });\n }\n\n async sendReadReceipt(chatMessageId: string): Promise<void> {\n await this.asyncTeeErrorToEventEmitter(async () => {\n await this.handlers.onMessageSeen(chatMessageId);\n });\n }\n\n async sendTypingIndicator(): Promise<void> {\n await this.asyncTeeErrorToEventEmitter(async () => {\n await this.handlers.onTyping();\n });\n }\n\n async removeParticipant(userId: string): Promise<void> {\n await this.asyncTeeErrorToEventEmitter(async () => {\n await this.handlers.onRemoveParticipant(userId);\n });\n }\n\n async setTopic(topicName: string): Promise<void> {\n await this.asyncTeeErrorToEventEmitter(async () => {\n await this.handlers.updateThreadTopicName(topicName);\n });\n }\n\n async loadPreviousChatMessages(messagesToLoad: number): Promise<boolean> {\n return await this.asyncTeeErrorToEventEmitter(async () => {\n return await this.handlers.onLoadPreviousChatMessages(messagesToLoad);\n });\n }\n\n async updateMessage(\n messageId: string,\n content: string,\n metadata?: Record<string, string>,\n options?: {\n /* @conditional-compile-remove(attachment-upload) */\n attachmentMetadata?: AttachmentMetadata[];\n }\n ): Promise<void> {\n return await this.asyncTeeErrorToEventEmitter(async () => {\n /* @conditional-compile-remove(attachment-upload) */\n const updatedOptions = { attachmentMetadata: options?.attachmentMetadata, metadata: metadata };\n /* @conditional-compile-remove(attachment-upload) */\n return await this.handlers.onUpdateMessage(messageId, content, updatedOptions);\n return await this.handlers.onUpdateMessage(messageId, content);\n });\n }\n\n async deleteMessage(messageId: string): Promise<void> {\n return await this.asyncTeeErrorToEventEmitter(async () => {\n return await this.handlers.onDeleteMessage(messageId);\n });\n }\n\n /* @conditional-compile-remove(attachment-upload) */\n registerActiveUploads(files: File[]): AttachmentUploadTask[] {\n return this.attachmentUploadAdapter.registerActiveUploads(files);\n }\n\n /* @conditional-compile-remove(attachment-upload) */\n registerCompletedUploads(metadata: AttachmentMetadata[]): AttachmentUploadTask[] {\n return this.attachmentUploadAdapter.registerCompletedUploads(metadata);\n }\n\n /* @conditional-compile-remove(attachment-upload) */\n clearUploads(): void {\n this.attachmentUploadAdapter.clearUploads();\n }\n\n /* @conditional-compile-remove(attachment-upload) */\n cancelUpload(id: string): void {\n this.attachmentUploadAdapter.cancelUpload(id);\n }\n\n /* @conditional-compile-remove(attachment-upload) */\n updateUploadProgress(id: string, progress: number): void {\n this.attachmentUploadAdapter.updateUploadProgress(id, progress);\n }\n\n /* @conditional-compile-remove(attachment-upload) */\n updateUploadStatusMessage(id: string, errorMessage: string): void {\n this.attachmentUploadAdapter.updateUploadStatusMessage(id, errorMessage);\n }\n\n /* @conditional-compile-remove(attachment-upload) */\n updateUploadMetadata(id: string, metadata: AttachmentMetadata): void {\n this.attachmentUploadAdapter.updateUploadMetadata(id, metadata);\n }\n\n async downloadResourceToCache(resourceDetails: ResourceDetails): Promise<void> {\n this.chatClient.downloadResourceToCache(\n resourceDetails.threadId,\n resourceDetails.messageId,\n resourceDetails.resourceUrl\n );\n }\n\n removeResourceFromCache(resourceDetails: ResourceDetails): void {\n this.chatClient.removeResourceFromCache(\n resourceDetails.threadId,\n resourceDetails.messageId,\n resourceDetails.resourceUrl\n );\n }\n\n private messageReceivedListener(event: ChatMessageReceivedEvent): void {\n const isCurrentChatAdapterThread = event.threadId === this.chatThreadClient.threadId;\n\n if (!isCurrentChatAdapterThread) {\n return;\n }\n\n const message = convertEventToChatMessage(event);\n this.emitter.emit('messageReceived', { message });\n\n const currentUserId = toFlatCommunicationIdentifier(this.chatClient.getState().userId);\n if (message?.sender && toFlatCommunicationIdentifier(message.sender) === currentUserId) {\n this.emitter.emit('messageSent', { message });\n }\n }\n\n private messageEditedListener(event: ChatMessageEditedEvent): void {\n const isCurrentChatAdapterThread = event.threadId === this.chatThreadClient.threadId;\n if (!isCurrentChatAdapterThread) {\n return;\n }\n\n const message = convertEventToChatMessage(event);\n this.emitter.emit('messageEdited', { message });\n }\n\n private messageDeletedListener(event: ChatMessageDeletedEvent): void {\n const isCurrentChatAdapterThread = event.threadId === this.chatThreadClient.threadId;\n if (!isCurrentChatAdapterThread) {\n return;\n }\n\n const message = convertEventToChatMessage(event);\n this.emitter.emit('messageDeleted', { message });\n }\n\n private messageReadListener({ chatMessageId, recipient }: ReadReceiptReceivedEvent): void {\n const message = this.getState().thread.chatMessages[chatMessageId];\n if (message) {\n this.emitter.emit('messageRead', { message, readBy: recipient });\n }\n }\n\n private participantsAddedListener({ addedBy, participantsAdded }: ParticipantsAddedEvent): void {\n this.emitter.emit('participantsAdded', { addedBy, participantsAdded });\n }\n\n private participantsRemovedListener({ removedBy, participantsRemoved }: ParticipantsRemovedEvent): void {\n this.emitter.emit('participantsRemoved', { removedBy, participantsRemoved });\n }\n\n private chatThreadPropertiesUpdatedListener(event: ChatThreadPropertiesUpdatedEvent): void {\n this.emitter.emit('topicChanged', { topic: event.properties.topic });\n }\n\n private subscribeAllEvents(): void {\n this.chatClient.on('chatThreadPropertiesUpdated', this.chatThreadPropertiesUpdatedListener.bind(this));\n this.chatClient.on('participantsAdded', this.participantsAddedListener.bind(this));\n this.chatClient.on('participantsRemoved', this.participantsRemovedListener.bind(this));\n this.chatClient.on('chatMessageReceived', this.messageReceivedListener.bind(this));\n this.chatClient.on('chatMessageEdited', this.messageEditedListener.bind(this));\n this.chatClient.on('chatMessageDeleted', this.messageDeletedListener.bind(this));\n this.chatClient.on('readReceiptReceived', this.messageReadListener.bind(this));\n this.chatClient.on('participantsRemoved', this.participantsRemovedListener.bind(this));\n }\n\n private unsubscribeAllEvents(): void {\n this.chatClient.off('chatThreadPropertiesUpdated', this.chatThreadPropertiesUpdatedListener.bind(this));\n this.chatClient.off('participantsAdded', this.participantsAddedListener.bind(this));\n this.chatClient.off('participantsRemoved', this.participantsRemovedListener.bind(this));\n this.chatClient.off('chatMessageReceived', this.messageReceivedListener.bind(this));\n this.chatClient.off('chatMessageEdited', this.messageEditedListener.bind(this));\n this.chatClient.off('chatMessageDeleted', this.messageDeletedListener.bind(this));\n this.chatClient.off('readReceiptReceived', this.messageReadListener.bind(this));\n this.chatClient.off('participantsRemoved', this.participantsRemovedListener.bind(this));\n }\n\n on(event: 'messageReceived', listener: MessageReceivedListener): void;\n on(event: 'messageEdited', listener: MessageEditedListener): void;\n on(event: 'messageDeleted', listener: MessageDeletedListener): void;\n on(event: 'messageSent', listener: MessageReceivedListener): void;\n on(event: 'messageRead', listener: MessageReadListener): void;\n on(event: 'participantsAdded', listener: ParticipantsAddedListener): void;\n on(event: 'participantsRemoved', listener: ParticipantsRemovedListener): void;\n on(event: 'topicChanged', listener: TopicChangedListener): void;\n on(event: 'error', listener: (e: AdapterError) => void): void;\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n on(event: string, listener: (e: any) => void): void {\n this.emitter.on(event, listener);\n }\n\n off(event: 'messageReceived', listener: MessageReceivedListener): void;\n off(event: 'messageEdited', listener: MessageEditedListener): void;\n off(event: 'messageDeleted', listener: MessageDeletedListener): void;\n off(event: 'messageSent', listener: MessageReceivedListener): void;\n off(event: 'messageRead', listener: MessageReadListener): void;\n off(event: 'participantsAdded', listener: ParticipantsAddedListener): void;\n off(event: 'participantsRemoved', listener: ParticipantsRemovedListener): void;\n off(event: 'topicChanged', listener: TopicChangedListener): void;\n off(event: 'error', listener: (e: AdapterError) => void): void;\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n off(event: string, listener: (e: any) => void): void {\n this.emitter.off(event, listener);\n }\n\n private async asyncTeeErrorToEventEmitter<T>(f: () => Promise<T>): Promise<T> {\n try {\n return await f();\n } catch (error) {\n if (isChatError(error as Error)) {\n this.emitter.emit('error', error as AdapterError);\n }\n throw error;\n }\n }\n}\n\nconst convertEventToChatMessage = (\n event: ChatMessageReceivedEvent | ChatMessageEditedEvent | ChatMessageDeletedEvent\n): ChatMessage => {\n return {\n id: event.id,\n version: event.version,\n content: isChatMessageDeletedEvent(event) ? undefined : { message: event.message },\n type: convertEventType(event.type),\n sender: event.sender,\n senderDisplayName: event.senderDisplayName,\n sequenceId: '',\n createdOn: new Date(event.createdOn),\n editedOn: isChatMessageEditedEvent(event) ? event.editedOn : undefined,\n deletedOn: isChatMessageDeletedEvent(event) ? event.deletedOn : undefined\n };\n};\n\nconst isChatMessageEditedEvent = (\n event: ChatMessageReceivedEvent | ChatMessageEditedEvent | ChatMessageDeletedEvent\n): event is ChatMessageEditedEvent => {\n return 'editedOn' in event;\n};\n\nconst isChatMessageDeletedEvent = (\n event: ChatMessageReceivedEvent | ChatMessageEditedEvent | ChatMessageDeletedEvent\n): event is ChatMessageDeletedEvent => {\n return 'deletedOn' in event;\n};\n\n// only text/html message type will be received from event\nconst convertEventType = (type: string): ChatMessageType => {\n const lowerCaseType = type.toLowerCase();\n if (lowerCaseType === 'richtext/html' || lowerCaseType === 'html') {\n return 'html';\n } else {\n return 'text';\n }\n};\n\n/**\n * Arguments for creating the Azure Communication Services implementation of {@link ChatAdapter}.\n *\n * @public\n */\nexport type AzureCommunicationChatAdapterArgs = {\n endpoint: string;\n userId: CommunicationUserIdentifier;\n displayName: string;\n credential: CommunicationTokenCredential;\n threadId: string;\n};\n\n/**\n * Create a {@link ChatAdapter} backed by Azure Communication Services.\n *\n * This is the default implementation of {@link ChatAdapter} provided by this library.\n *\n * @public\n */\nexport const createAzureCommunicationChatAdapter = async ({\n endpoint: endpointUrl,\n userId,\n displayName,\n credential,\n threadId\n}: AzureCommunicationChatAdapterArgs): Promise<ChatAdapter> => {\n return _createAzureCommunicationChatAdapterInner(endpointUrl, userId, displayName, credential, threadId);\n};\n\n/**\n * This inner function is used to allow injection of TelemetryImplementationHint without changing the public API.\n *\n * @internal\n */\nexport const _createAzureCommunicationChatAdapterInner = async (\n endpoint: string,\n userId: CommunicationUserIdentifier,\n displayName: string,\n credential: CommunicationTokenCredential,\n threadId: string,\n telemetryImplementationHint: _TelemetryImplementationHint = 'Chat'\n): Promise<ChatAdapter> => {\n if (!_isValidIdentifier(userId)) {\n throw new Error('Provided userId is invalid. Please provide valid identifier object.');\n }\n\n const chatClient = _createStatefulChatClientInner(\n {\n userId,\n displayName,\n endpoint,\n credential\n },\n undefined,\n telemetryImplementationHint\n );\n const chatThreadClient = await chatClient.getChatThreadClient(threadId);\n await chatClient.startRealtimeNotifications();\n\n const adapter = await createAzureCommunicationChatAdapterFromClient(chatClient, chatThreadClient);\n\n return adapter;\n};\n\n/**\n * This inner function to create ChatAdapterPromise in case when threadID is not avaialble.\n * ThreadId is a promise to allow for lazy initialization of the adapter.\n * @internal\n */\nexport const _createLazyAzureCommunicationChatAdapterInner = async (\n endpoint: string,\n userId: CommunicationUserIdentifier,\n displayName: string,\n credential: CommunicationTokenCredential,\n threadId: Promise<string>,\n telemetryImplementationHint: _TelemetryImplementationHint = 'Chat'\n): Promise<ChatAdapter> => {\n if (!_isValidIdentifier(userId)) {\n throw new Error('Provided userId is invalid. Please provide valid identifier object.');\n }\n\n const chatClient = _createStatefulChatClientInner(\n {\n userId,\n displayName,\n endpoint,\n credential\n },\n undefined,\n telemetryImplementationHint\n );\n return threadId.then(async (threadId) => {\n const chatThreadClient = await chatClient.getChatThreadClient(threadId);\n await chatClient.startRealtimeNotifications();\n\n const adapter = await createAzureCommunicationChatAdapterFromClient(chatClient, chatThreadClient);\n\n return adapter;\n });\n};\n\n/**\n * A custom React hook to simplify the creation of {@link ChatAdapter}.\n *\n * Similar to {@link createAzureCommunicationChatAdapter}, but takes care of asynchronous\n * creation of the adapter internally.\n *\n * Allows arguments to be undefined so that you can respect the rule-of-hooks and pass in arguments\n * as they are created. The adapter is only created when all arguments are defined.\n *\n * Note that you must memoize the arguments to avoid recreating adapter on each render.\n * See storybook for typical usage examples.\n *\n * @public\n */\nexport const useAzureCommunicationChatAdapter = (\n /**\n * Arguments to be passed to {@link createAzureCommunicationChatAdapter}.\n *\n * Allows arguments to be undefined so that you can respect the rule-of-hooks and pass in arguments\n * as they are created. The adapter is only created when all arguments are defined.\n */\n args: Partial<AzureCommunicationChatAdapterArgs>,\n /**\n * Optional callback to modify the adapter once it is created.\n *\n * If set, must return the modified adapter.\n */\n afterCreate?: (adapter: ChatAdapter) => Promise<ChatAdapter>,\n /**\n * Optional callback called before the adapter is disposed.\n *\n * This is useful for clean up tasks, e.g., leaving any ongoing calls.\n */\n beforeDispose?: (adapter: ChatAdapter) => Promise<void>\n): ChatAdapter | undefined => {\n const { credential, displayName, endpoint, threadId, userId } = args;\n\n // State update needed to rerender the parent component when a new adapter is created.\n const [adapter, setAdapter] = useState<ChatAdapter | undefined>(undefined);\n // Ref needed for cleanup to access the old adapter created asynchronously.\n const adapterRef = useRef<ChatAdapter | undefined>(undefined);\n\n const afterCreateRef = useRef<((adapter: ChatAdapter) => Promise<ChatAdapter>) | undefined>(undefined);\n const beforeDisposeRef = useRef<((adapter: ChatAdapter) => Promise<void>) | undefined>(undefined);\n // These refs are updated on *each* render, so that the latest values\n // are used in the `useEffect` closures below.\n // Using a Ref ensures that new values for the callbacks do not trigger the\n // useEffect blocks, and a new adapter creation / distruction is not triggered.\n afterCreateRef.current = afterCreate;\n beforeDisposeRef.current = beforeDispose;\n\n useEffect(\n () => {\n if (!credential || !displayName || !endpoint || !threadId || !userId) {\n return;\n }\n (async () => {\n if (adapterRef.current) {\n // Dispose the old adapter when a new one is created.\n //\n // This clean up function uses `adapterRef` because `adapter` can not be added to the dependency array of\n // this `useEffect` -- we do not want to trigger a new adapter creation because of the first adapter\n // creation.\n if (beforeDisposeRef.current) {\n await beforeDisposeRef.current(adapterRef.current);\n }\n adapterRef.current.dispose();\n adapterRef.current = undefined;\n }\n\n let newAdapter = await createAzureCommunicationChatAdapter({\n credential,\n displayName,\n endpoint,\n threadId,\n userId\n });\n if (afterCreateRef.current) {\n newAdapter = await afterCreateRef.current(newAdapter);\n }\n adapterRef.current = newAdapter;\n setAdapter(newAdapter);\n })();\n },\n // Explicitly list all arguments so that caller doesn't have to memoize the `args` object.\n [adapterRef, afterCreateRef, beforeDisposeRef, credential, displayName, endpoint, threadId, userId]\n );\n\n // Dispose any existing adapter when the component unmounts.\n useEffect(() => {\n return () => {\n (async () => {\n if (adapterRef.current) {\n if (beforeDisposeRef.current) {\n await beforeDisposeRef.current(adapterRef.current);\n }\n adapterRef.current.dispose();\n adapterRef.current = undefined;\n }\n })();\n };\n }, []);\n\n return adapter;\n};\n\n/**\n * Create a {@link ChatAdapter} using the provided {@link StatefulChatClient}.\n *\n * Useful if you want to keep a reference to {@link StatefulChatClient}.\n * Consider using {@link createAzureCommunicationChatAdapter} for a simpler API.\n *\n * @public\n */\nexport async function createAzureCommunicationChatAdapterFromClient(\n chatClient: StatefulChatClient,\n chatThreadClient: ChatThreadClient\n): Promise<ChatAdapter> {\n return new AzureCommunicationChatAdapter(chatClient, chatThreadClient);\n}\n\nconst isChatError = (e: Error): e is ChatError => {\n return 'target' in e && e['target'] !== undefined && 'innerError' in e && e['innerError'] !== undefined;\n};\n"]}
|
package/dist/dist-esm/react-composites/src/composites/ChatComposite/adapter/ChatAdapter.d.ts
CHANGED
@@ -2,7 +2,7 @@ import type { ChatMessage, ChatParticipant, SendMessageOptions } from '@azure/co
|
|
2
2
|
import type { CommunicationIdentifierKind, CommunicationUserKind } from '@azure/communication-common';
|
3
3
|
import { ChatThreadClientState } from "../../../../../chat-stateful-client/src";
|
4
4
|
import type { AdapterError, AdapterErrors, AdapterState, Disposable } from '../../common/adapters';
|
5
|
-
import {
|
5
|
+
import { _AttachmentUploadAdapter, _AttachmentUploadsUiState } from './AzureCommunicationAttachmentUploadAdapter';
|
6
6
|
import { AttachmentMetadata } from "../../../../../react-components/src";
|
7
7
|
/**
|
8
8
|
* {@link ChatAdapter} state for pure UI purposes.
|
@@ -14,10 +14,11 @@ export type ChatAdapterUiState = {
|
|
14
14
|
/**
|
15
15
|
* Attachments being uploaded by a user in the current thread.
|
16
16
|
* Should be set to null once the upload is complete.
|
17
|
-
* Array of type {@link
|
18
|
-
*
|
17
|
+
* Array of type {@link _AttachmentUploadsUiState}
|
18
|
+
*
|
19
|
+
* @internal
|
19
20
|
*/
|
20
|
-
|
21
|
+
_attachmentUploads?: _AttachmentUploadsUiState;
|
21
22
|
};
|
22
23
|
/**
|
23
24
|
* {@link ChatAdapter} state inferred from Azure Communication Services backend.
|
@@ -55,6 +56,10 @@ export interface ChatAdapterThreadManagement {
|
|
55
56
|
* Send a message in the thread.
|
56
57
|
*/
|
57
58
|
sendMessage(content: string, options?: SendMessageOptions): Promise<void>;
|
59
|
+
/**
|
60
|
+
* Send a message with attachments in the chat thread.
|
61
|
+
*/
|
62
|
+
sendMessageWithAttachments(content: string, attachments: AttachmentMetadata[]): Promise<void>;
|
58
63
|
/**
|
59
64
|
* Send a read receipt for a message.
|
60
65
|
*/
|
@@ -192,7 +197,7 @@ export interface ChatAdapterSubscribers {
|
|
192
197
|
*
|
193
198
|
* @public
|
194
199
|
*/
|
195
|
-
export type ChatAdapter = ChatAdapterThreadManagement & AdapterState<ChatAdapterState> & Disposable & ChatAdapterSubscribers &
|
200
|
+
export type ChatAdapter = ChatAdapterThreadManagement & AdapterState<ChatAdapterState> & Disposable & ChatAdapterSubscribers & _AttachmentUploadAdapter;
|
196
201
|
/**
|
197
202
|
* Callback for {@link ChatAdapterSubscribers} 'messageReceived' event.
|
198
203
|
*
|
package/dist/dist-esm/react-composites/src/composites/ChatComposite/adapter/ChatAdapter.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ChatAdapter.js","sourceRoot":"","sources":["../../../../../../../../react-composites/src/composites/ChatComposite/adapter/ChatAdapter.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { ChatMessage, ChatParticipant, SendMessageOptions } from '@azure/communication-chat';\nimport type { CommunicationIdentifierKind, CommunicationUserKind } from '@azure/communication-common';\nimport { ChatThreadClientState } from '@internal/chat-stateful-client';\nimport type { AdapterError, AdapterErrors, AdapterState, Disposable } from '../../common/adapters';\n/* @conditional-compile-remove(attachment-upload) */\nimport {
|
1
|
+
{"version":3,"file":"ChatAdapter.js","sourceRoot":"","sources":["../../../../../../../../react-composites/src/composites/ChatComposite/adapter/ChatAdapter.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { ChatMessage, ChatParticipant, SendMessageOptions } from '@azure/communication-chat';\nimport type { CommunicationIdentifierKind, CommunicationUserKind } from '@azure/communication-common';\nimport { ChatThreadClientState } from '@internal/chat-stateful-client';\nimport type { AdapterError, AdapterErrors, AdapterState, Disposable } from '../../common/adapters';\n/* @conditional-compile-remove(attachment-upload) */\nimport { _AttachmentUploadAdapter, _AttachmentUploadsUiState } from './AzureCommunicationAttachmentUploadAdapter';\n/* @conditional-compile-remove(attachment-upload) */\nimport { AttachmentMetadata } from '@internal/react-components';\n\n/**\n * {@link ChatAdapter} state for pure UI purposes.\n *\n * @public\n */\nexport type ChatAdapterUiState = {\n // FIXME(Delete?)\n // Self-contained state for composite\n error?: Error;\n /* @conditional-compile-remove(attachment-upload) */\n /**\n * Attachments being uploaded by a user in the current thread.\n * Should be set to null once the upload is complete.\n * Array of type {@link _AttachmentUploadsUiState}\n *\n * @internal\n */\n _attachmentUploads?: _AttachmentUploadsUiState;\n};\n\n/**\n * {@link ChatAdapter} state inferred from Azure Communication Services backend.\n *\n * @public\n */\nexport type ChatCompositeClientState = {\n userId: CommunicationIdentifierKind;\n displayName: string;\n thread: ChatThreadClientState;\n /**\n * Latest error encountered for each operation performed via the adapter.\n */\n latestErrors: AdapterErrors;\n};\n\n/**\n * {@link ChatAdapter} state.\n *\n * @public\n */\nexport type ChatAdapterState = ChatAdapterUiState & ChatCompositeClientState;\n\n/**\n * Functionality for managing the current chat thread.\n *\n * @public\n */\nexport interface ChatAdapterThreadManagement {\n /**\n * Fetch initial state for the Chat adapter.\n *\n * Performs the minimal fetch necessary for ChatComposite and API methods.\n */\n fetchInitialData(): Promise<void>;\n /**\n * Send a message in the thread.\n */\n sendMessage(content: string, options?: SendMessageOptions): Promise<void>;\n /* @conditional-compile-remove(attachment-upload) */\n /**\n * Send a message with attachments in the chat thread.\n */\n sendMessageWithAttachments(content: string, attachments: AttachmentMetadata[]): Promise<void>;\n /**\n * Send a read receipt for a message.\n */\n sendReadReceipt(chatMessageId: string): Promise<void>;\n /**\n * Send typing indicator in the thread.\n */\n sendTypingIndicator(): Promise<void>;\n /**\n * Remove a participant in the thread.\n */\n removeParticipant(userId: string): Promise<void>;\n /**\n * Set the topic for the thread.\n */\n setTopic(topicName: string): Promise<void>;\n /**\n * Update a message content.\n */\n updateMessage(\n messageId: string,\n content: string,\n metadata?: Record<string, string>,\n /* @conditional-compile-remove(attachment-upload) */\n options?: {\n attachmentMetadata?: AttachmentMetadata[];\n }\n ): Promise<void>;\n /**\n * Delete a message in the thread.\n */\n deleteMessage(messageId: string): Promise<void>;\n /**\n * Load more previous messages in the chat thread history.\n *\n * @remarks\n * This method is usually used to control incremental fetch/infinite scroll\n *\n */\n loadPreviousChatMessages(messagesToLoad: number): Promise<boolean>;\n /**\n * Downloads a resource into the cache for the given message.\n */\n downloadResourceToCache(resourceDetails: ResourceDetails): Promise<void>;\n /**\n * Removes a resource from the cache for the given message.\n */\n removeResourceFromCache(resourceDetails: ResourceDetails): void;\n}\n/**\n * Details required for download a resource to cache.\n *\n * @public\n */\nexport type ResourceDetails = {\n threadId: string;\n messageId: string;\n resourceUrl: string;\n};\n\n/**\n * Chat composite events that can be subscribed to.\n *\n * @public\n */\nexport interface ChatAdapterSubscribers {\n /**\n * Subscribe function for 'messageReceived' event.\n */\n on(event: 'messageReceived', listener: MessageReceivedListener): void;\n /**\n * Subscribe function for 'messageEdited' event.\n */\n on(event: 'messageEdited', listener: MessageEditedListener): void;\n /**\n * Subscribe function for 'messageDeleted' event.\n */\n on(event: 'messageDeleted', listener: MessageDeletedListener): void;\n /**\n * Subscribe function for 'messageSent' event.\n */\n on(event: 'messageSent', listener: MessageSentListener): void;\n /**\n * Subscribe function for 'messageRead' event.\n */\n on(event: 'messageRead', listener: MessageReadListener): void;\n /**\n * Subscribe function for 'participantsAdded' event.\n */\n on(event: 'participantsAdded', listener: ParticipantsAddedListener): void;\n /**\n * Subscribe function for 'participantsRemoved' event.\n */\n on(event: 'participantsRemoved', listener: ParticipantsRemovedListener): void;\n /**\n * Subscribe function for 'topicChanged' event.\n */\n on(event: 'topicChanged', listener: TopicChangedListener): void;\n /**\n * Subscribe function for 'error' event.\n */\n on(event: 'error', listener: (e: AdapterError) => void): void;\n\n /**\n * Unsubscribe function for 'messageReceived' event.\n */\n off(event: 'messageReceived', listener: MessageReceivedListener): void;\n /**\n * Unsubscribe function for 'messageEdited' event.\n */\n off(event: 'messageEdited', listener: MessageEditedListener): void;\n /**\n * Unsubscribe function for 'messageDeleted' event.\n */\n off(event: 'messageDeleted', listener: MessageDeletedListener): void;\n /**\n * Unsubscribe function for 'messageSent' event.\n */\n off(event: 'messageSent', listener: MessageSentListener): void;\n /**\n * Unsubscribe function for 'messageRead' event.\n */\n off(event: 'messageRead', listener: MessageReadListener): void;\n /**\n * Unsubscribe function for 'participantsAdded' event.\n */\n off(event: 'participantsAdded', listener: ParticipantsAddedListener): void;\n /**\n * Unsubscribe function for 'participantsRemoved' event.\n */\n off(event: 'participantsRemoved', listener: ParticipantsRemovedListener): void;\n /**\n * Unsubscribe function for 'topicChanged' event.\n */\n off(event: 'topicChanged', listener: TopicChangedListener): void;\n /**\n * Unsubscribe function for 'error' event.\n */\n off(event: 'error', listener: (e: AdapterError) => void): void;\n}\n\n/**\n * {@link ChatComposite} Adapter interface.\n *\n * @public\n */\nexport type ChatAdapter = ChatAdapterThreadManagement &\n AdapterState<ChatAdapterState> &\n Disposable &\n ChatAdapterSubscribers &\n /* @conditional-compile-remove(attachment-upload) */\n _AttachmentUploadAdapter;\n\n/**\n * Callback for {@link ChatAdapterSubscribers} 'messageReceived' event.\n *\n * @public\n */\nexport type MessageReceivedListener = (event: { message: ChatMessage }) => void;\n\n/**\n * Callback for {@link ChatAdapterSubscribers} 'messageSent' event.\n *\n * @public\n */\nexport type MessageSentListener = MessageReceivedListener;\n\n/**\n * Callback for {@link ChatAdapterSubscribers} 'messageEdited' event.\n *\n * @public\n */\nexport type MessageEditedListener = MessageReceivedListener;\n\n/**\n * Callback for {@link ChatAdapterSubscribers} 'messageDeleted' event.\n *\n * @public\n */\nexport type MessageDeletedListener = MessageReceivedListener;\n\n/**\n * Callback for {@link ChatAdapterSubscribers} 'messageRead' event.\n *\n * @public\n */\nexport type MessageReadListener = (event: { message: ChatMessage; readBy: CommunicationUserKind }) => void;\n\n/**\n * Callback for {@link ChatAdapterSubscribers} 'participantsAdded' event.\n *\n * @public\n */\nexport type ParticipantsAddedListener = (event: {\n participantsAdded: ChatParticipant[];\n addedBy: ChatParticipant;\n}) => void;\n\n/**\n * Callback for {@link ChatAdapterSubscribers} 'participantsRemoved' event.\n *\n * @public\n */\nexport type ParticipantsRemovedListener = (event: {\n participantsRemoved: ChatParticipant[];\n removedBy: ChatParticipant;\n}) => void;\n\n/**\n * Callback for {@link ChatAdapterSubscribers} 'topicChanged' event.\n *\n * @public\n */\nexport type TopicChangedListener = (event: { topic: string }) => void;\n"]}
|