@azure/communication-react 1.26.0-alpha-202504080017 → 1.26.0-alpha-202504100018
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 +34 -2
- package/dist/dist-cjs/communication-react/{ChatMessageComponentAsRichTextEditBox-B7z_PfOA.js → ChatMessageComponentAsRichTextEditBox-DzVuW5SN.js} +2 -2
- package/dist/dist-cjs/communication-react/{ChatMessageComponentAsRichTextEditBox-B7z_PfOA.js.map → ChatMessageComponentAsRichTextEditBox-DzVuW5SN.js.map} +1 -1
- package/dist/dist-cjs/communication-react/{RichTextSendBoxWrapper-BMVBxfQa.js → RichTextSendBoxWrapper-CWem6AxN.js} +2 -2
- package/dist/dist-cjs/communication-react/{RichTextSendBoxWrapper-BMVBxfQa.js.map → RichTextSendBoxWrapper-CWem6AxN.js.map} +1 -1
- package/dist/dist-cjs/communication-react/{index-BWWxc3Tx.js → index-B61VVYm8.js} +498 -249
- package/dist/dist-cjs/communication-react/index-B61VVYm8.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/react-composites/src/composites/CallWithChatComposite/adapter/AzureCommunicationCallWithChatAdapter.js +16 -4
- package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/adapter/AzureCommunicationCallWithChatAdapter.js.map +1 -1
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/adapter/AzureCommunicationChatAdapter.d.ts +24 -6
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/adapter/AzureCommunicationChatAdapter.js +77 -41
- 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/OnFetchProfileCallback.d.ts +39 -0
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/adapter/OnFetchProfileCallback.js +203 -0
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/adapter/OnFetchProfileCallback.js.map +1 -0
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/index.d.ts +2 -0
- package/dist/dist-esm/react-composites/src/composites/ChatComposite/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/dist-cjs/communication-react/index-BWWxc3Tx.js.map +0 -1
@@ -0,0 +1,203 @@
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
2
|
+
// Licensed under the MIT License.
|
3
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
4
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
5
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
6
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
7
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
8
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
9
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
10
|
+
});
|
11
|
+
};
|
12
|
+
/* @conditional-compile-remove(on-fetch-profile) */
|
13
|
+
/**
|
14
|
+
* @private
|
15
|
+
*/
|
16
|
+
export const createProfileStateModifier = (onFetchProfile, notifyUpdate) => {
|
17
|
+
const cachedDisplayName = {};
|
18
|
+
return (state) => {
|
19
|
+
var _a;
|
20
|
+
const originalParticipants = (_a = state.thread) === null || _a === void 0 ? void 0 : _a.participants;
|
21
|
+
(() => __awaiter(void 0, void 0, void 0, function* () {
|
22
|
+
let shouldNotifyUpdates = false;
|
23
|
+
if (!originalParticipants) {
|
24
|
+
return;
|
25
|
+
}
|
26
|
+
for (const [key, participant] of Object.entries(originalParticipants)) {
|
27
|
+
if (cachedDisplayName[key]) {
|
28
|
+
continue;
|
29
|
+
}
|
30
|
+
const profile = yield onFetchProfile(key, { displayName: participant.displayName });
|
31
|
+
if ((profile === null || profile === void 0 ? void 0 : profile.displayName) && participant.displayName !== (profile === null || profile === void 0 ? void 0 : profile.displayName)) {
|
32
|
+
cachedDisplayName[key] = profile === null || profile === void 0 ? void 0 : profile.displayName;
|
33
|
+
shouldNotifyUpdates = true;
|
34
|
+
}
|
35
|
+
}
|
36
|
+
// notify update only when there is a change, which most likely will trigger modifier and setState again
|
37
|
+
if (shouldNotifyUpdates) {
|
38
|
+
notifyUpdate();
|
39
|
+
}
|
40
|
+
}))();
|
41
|
+
const participantsModifier = createParticipantModifier((id, participant) => {
|
42
|
+
if (cachedDisplayName[id]) {
|
43
|
+
return Object.assign(Object.assign({}, participant), { displayName: cachedDisplayName[id] });
|
44
|
+
}
|
45
|
+
return undefined;
|
46
|
+
});
|
47
|
+
const modifiedParticipantState = participantsModifier(state);
|
48
|
+
const chatMessagesModifier = createChatMessageModifier((id, chatMessage) => {
|
49
|
+
var _a;
|
50
|
+
const originalChatMessage = Object.assign({}, chatMessage);
|
51
|
+
if ((_a = originalChatMessage.content) === null || _a === void 0 ? void 0 : _a.participants) {
|
52
|
+
const newParticipants = originalChatMessage.content.participants.map((participant) => {
|
53
|
+
if (participant.id) {
|
54
|
+
if ('communicationUserId' in participant.id && cachedDisplayName[participant.id.communicationUserId]) {
|
55
|
+
return Object.assign(Object.assign({}, participant), { displayName: cachedDisplayName[participant.id.communicationUserId] });
|
56
|
+
}
|
57
|
+
else if ('microsoftTeamsUserId' in participant.id &&
|
58
|
+
'rawId' in participant.id &&
|
59
|
+
participant.id.rawId &&
|
60
|
+
cachedDisplayName[participant.id.rawId]) {
|
61
|
+
return Object.assign(Object.assign({}, participant), { displayName: cachedDisplayName[participant.id.rawId] });
|
62
|
+
}
|
63
|
+
else if ('teamsAppId' in participant.id &&
|
64
|
+
'rawId' in participant.id &&
|
65
|
+
participant.id.rawId &&
|
66
|
+
cachedDisplayName[participant.id.rawId]) {
|
67
|
+
return Object.assign(Object.assign({}, participant), { displayName: cachedDisplayName[participant.id.rawId] });
|
68
|
+
}
|
69
|
+
else if ('phoneNumber' in participant.id &&
|
70
|
+
'rawId' in participant.id &&
|
71
|
+
participant.id.rawId &&
|
72
|
+
cachedDisplayName[participant.id.rawId]) {
|
73
|
+
return Object.assign(Object.assign({}, participant), { displayName: cachedDisplayName[participant.id.rawId] });
|
74
|
+
}
|
75
|
+
else if ('id' in participant.id && cachedDisplayName[participant.id.id]) {
|
76
|
+
return Object.assign(Object.assign({}, participant), { displayName: cachedDisplayName[participant.id.id] });
|
77
|
+
}
|
78
|
+
else {
|
79
|
+
return participant;
|
80
|
+
}
|
81
|
+
}
|
82
|
+
return participant;
|
83
|
+
});
|
84
|
+
originalChatMessage.content = Object.assign(Object.assign({}, originalChatMessage.content), { participants: newParticipants });
|
85
|
+
}
|
86
|
+
if (originalChatMessage.sender && originalChatMessage.senderDisplayName) {
|
87
|
+
if (originalChatMessage.sender.kind === 'communicationUser' &&
|
88
|
+
originalChatMessage.sender.communicationUserId &&
|
89
|
+
cachedDisplayName[originalChatMessage.sender.communicationUserId]) {
|
90
|
+
originalChatMessage.senderDisplayName = cachedDisplayName[originalChatMessage.sender.communicationUserId];
|
91
|
+
}
|
92
|
+
else if (originalChatMessage.sender.kind === 'microsoftTeamsUser' &&
|
93
|
+
originalChatMessage.sender.rawId &&
|
94
|
+
cachedDisplayName[originalChatMessage.sender.rawId]) {
|
95
|
+
originalChatMessage.senderDisplayName = cachedDisplayName[originalChatMessage.sender.rawId];
|
96
|
+
}
|
97
|
+
else if (originalChatMessage.sender.kind === 'phoneNumber' &&
|
98
|
+
originalChatMessage.sender.phoneNumber &&
|
99
|
+
cachedDisplayName[originalChatMessage.sender.phoneNumber]) {
|
100
|
+
originalChatMessage.senderDisplayName = cachedDisplayName[originalChatMessage.sender.phoneNumber];
|
101
|
+
}
|
102
|
+
else if (originalChatMessage.sender.kind === 'unknown' &&
|
103
|
+
originalChatMessage.sender.id &&
|
104
|
+
cachedDisplayName[originalChatMessage.sender.id]) {
|
105
|
+
originalChatMessage.senderDisplayName = cachedDisplayName[originalChatMessage.sender.id];
|
106
|
+
}
|
107
|
+
else if (originalChatMessage.sender.kind === 'microsoftTeamsApp' &&
|
108
|
+
originalChatMessage.sender.rawId &&
|
109
|
+
cachedDisplayName[originalChatMessage.sender.rawId]) {
|
110
|
+
originalChatMessage.senderDisplayName = cachedDisplayName[originalChatMessage.sender.rawId];
|
111
|
+
}
|
112
|
+
}
|
113
|
+
return Object.assign({}, originalChatMessage);
|
114
|
+
});
|
115
|
+
return chatMessagesModifier(modifiedParticipantState);
|
116
|
+
};
|
117
|
+
};
|
118
|
+
/* @conditional-compile-remove(on-fetch-profile) */
|
119
|
+
/**
|
120
|
+
* @private
|
121
|
+
* This is the util function to create a participant modifier for remote participantList
|
122
|
+
* It memoize previous original participant items and only update the changed participant
|
123
|
+
* It takes in one modifier function to generate one single participant object, it returns undefined if the object keeps unmodified
|
124
|
+
*/
|
125
|
+
export const createParticipantModifier = (createModifiedParticipant) => {
|
126
|
+
let previousParticipantState = undefined;
|
127
|
+
let modifiedParticipants = {};
|
128
|
+
const memoizedParticipants = {};
|
129
|
+
return (state) => {
|
130
|
+
var _a, _b, _c, _d;
|
131
|
+
// if root state is the same, we don't need to update the participants
|
132
|
+
if (((_a = state.thread) === null || _a === void 0 ? void 0 : _a.participants) !== previousParticipantState) {
|
133
|
+
modifiedParticipants = {};
|
134
|
+
const originalParticipants = Object.entries(((_b = state.thread) === null || _b === void 0 ? void 0 : _b.participants) || {});
|
135
|
+
for (const [key, originalParticipant] of originalParticipants) {
|
136
|
+
const modifiedParticipant = createModifiedParticipant(key, originalParticipant);
|
137
|
+
if (modifiedParticipant === undefined) {
|
138
|
+
modifiedParticipants[key] = originalParticipant;
|
139
|
+
continue;
|
140
|
+
}
|
141
|
+
// Generate the new item if original cached item has been changed
|
142
|
+
if (((_c = memoizedParticipants[key]) === null || _c === void 0 ? void 0 : _c.originalRef) !== originalParticipant) {
|
143
|
+
memoizedParticipants[key] = {
|
144
|
+
newParticipant: modifiedParticipant,
|
145
|
+
originalRef: originalParticipant
|
146
|
+
};
|
147
|
+
}
|
148
|
+
// the modified participant is always coming from the memoized cache, whether is was refreshed
|
149
|
+
// from the previous closure or not
|
150
|
+
const memoizedParticipant = memoizedParticipants[key];
|
151
|
+
if (!memoizedParticipant) {
|
152
|
+
throw new Error('Participant modifier encountered an unhandled exception.');
|
153
|
+
}
|
154
|
+
modifiedParticipants[key] = memoizedParticipant.newParticipant;
|
155
|
+
}
|
156
|
+
previousParticipantState = (_d = state.thread) === null || _d === void 0 ? void 0 : _d.participants;
|
157
|
+
}
|
158
|
+
return Object.assign(Object.assign({}, state), { thread: Object.assign(Object.assign({}, state.thread), { participants: modifiedParticipants }) });
|
159
|
+
};
|
160
|
+
};
|
161
|
+
/* @conditional-compile-remove(on-fetch-profile) */
|
162
|
+
/**
|
163
|
+
* @private
|
164
|
+
* This is the util function to create a chat message modifier for remote participantList
|
165
|
+
* It memoize previous original messages and only update the changed sender display name
|
166
|
+
* It takes in one modifier function to generate one single participant object, it returns undefined if the object keeps unmodified
|
167
|
+
*/
|
168
|
+
export const createChatMessageModifier = (createModifiedChatMessage) => {
|
169
|
+
let previousChatMessages;
|
170
|
+
let modifiedChatMessages;
|
171
|
+
const memoizedChatMessages = {};
|
172
|
+
return (state) => {
|
173
|
+
var _a, _b, _c, _d;
|
174
|
+
if (((_a = state.thread) === null || _a === void 0 ? void 0 : _a.chatMessages) !== previousChatMessages) {
|
175
|
+
modifiedChatMessages = {};
|
176
|
+
const originalChatMessages = Object.entries(((_b = state.thread) === null || _b === void 0 ? void 0 : _b.chatMessages) || {});
|
177
|
+
for (const [key, originalChatMessage] of originalChatMessages) {
|
178
|
+
const modifiedChatMessage = createModifiedChatMessage(key, originalChatMessage);
|
179
|
+
if (modifiedChatMessage === undefined) {
|
180
|
+
modifiedChatMessages[key] = originalChatMessage;
|
181
|
+
continue;
|
182
|
+
}
|
183
|
+
// Generate the new item if original cached item has been changed
|
184
|
+
if (((_c = memoizedChatMessages[key]) === null || _c === void 0 ? void 0 : _c.originalRef) !== originalChatMessage) {
|
185
|
+
memoizedChatMessages[key] = {
|
186
|
+
newChatMessage: modifiedChatMessage,
|
187
|
+
originalRef: originalChatMessage
|
188
|
+
};
|
189
|
+
}
|
190
|
+
// the modified chat message is always coming from the memoized cache, whether is was refreshed
|
191
|
+
// from the previous closure or not
|
192
|
+
const memoizedChatMessage = memoizedChatMessages[key];
|
193
|
+
if (!memoizedChatMessage) {
|
194
|
+
throw new Error('Participant modifier encountered an unhandled exception.');
|
195
|
+
}
|
196
|
+
modifiedChatMessages[key] = memoizedChatMessage.newChatMessage;
|
197
|
+
}
|
198
|
+
previousChatMessages = (_d = state.thread) === null || _d === void 0 ? void 0 : _d.chatMessages;
|
199
|
+
}
|
200
|
+
return Object.assign(Object.assign({}, state), { thread: Object.assign(Object.assign({}, state.thread), { chatMessages: modifiedChatMessages }) });
|
201
|
+
};
|
202
|
+
};
|
203
|
+
//# sourceMappingURL=OnFetchProfileCallback.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"OnFetchProfileCallback.js","sourceRoot":"","sources":["../../../../../../../../react-composites/src/composites/ChatComposite/adapter/OnFetchProfileCallback.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;;;;;;;;;AAmClC,mDAAmD;AACnD;;GAEG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,CACxC,cAA0C,EAC1C,YAAwB,EACF,EAAE;IACxB,MAAM,iBAAiB,GAEnB,EAAE,CAAC;IAEP,OAAO,CAAC,KAAuB,EAAE,EAAE;;QACjC,MAAM,oBAAoB,GAAG,MAAA,KAAK,CAAC,MAAM,0CAAE,YAAY,CAAC;QAExD,CAAC,GAAS,EAAE;YACV,IAAI,mBAAmB,GAAG,KAAK,CAAC;YAChC,IAAI,CAAC,oBAAoB,EAAE,CAAC;gBAC1B,OAAO;YACT,CAAC;YAED,KAAK,MAAM,CAAC,GAAG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ACvF,CAAC,CAAC;AACJ,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n/* @conditional-compile-remove(on-fetch-profile) */\nimport { ChatParticipant } from '@azure/communication-chat';\n/* @conditional-compile-remove(on-fetch-profile) */\nimport { AdapterStateModifier } from './AzureCommunicationChatAdapter';\n/* @conditional-compile-remove(on-fetch-profile) */\nimport { ChatAdapterState } from './ChatAdapter';\n/* @conditional-compile-remove(on-fetch-profile) */\nimport { ChatMessageWithStatus } from '@internal/chat-stateful-client';\n\n/* @conditional-compile-remove(on-fetch-profile) */\n/**\n * Callback function used to provide custom data to build profile for a user or bot.\n *\n * @public\n */\nexport type OnFetchChatProfileCallback = (\n userId: string,\n defaultProfile?: ChatProfile\n) => Promise<ChatProfile | undefined>;\n\n/* @conditional-compile-remove(on-fetch-profile) */\n/**\n * The profile of a user or bot.\n *\n * @public\n */\nexport type ChatProfile = {\n /**\n * Primary text to display, usually the name of the person.\n */\n displayName?: string;\n};\n\n/* @conditional-compile-remove(on-fetch-profile) */\n/**\n * @private\n */\nexport const createProfileStateModifier = (\n onFetchProfile: OnFetchChatProfileCallback,\n notifyUpdate: () => void\n): AdapterStateModifier => {\n const cachedDisplayName: {\n [id: string]: string;\n } = {};\n\n return (state: ChatAdapterState) => {\n const originalParticipants = state.thread?.participants;\n\n (async () => {\n let shouldNotifyUpdates = false;\n if (!originalParticipants) {\n return;\n }\n\n for (const [key, participant] of Object.entries(originalParticipants)) {\n if (cachedDisplayName[key]) {\n continue;\n }\n const profile = await onFetchProfile(key, { displayName: participant.displayName });\n if (profile?.displayName && participant.displayName !== profile?.displayName) {\n cachedDisplayName[key] = profile?.displayName;\n shouldNotifyUpdates = true;\n }\n }\n // notify update only when there is a change, which most likely will trigger modifier and setState again\n if (shouldNotifyUpdates) {\n notifyUpdate();\n }\n })();\n\n const participantsModifier = createParticipantModifier(\n (id: string, participant: ChatParticipant): ChatParticipant | undefined => {\n if (cachedDisplayName[id]) {\n return { ...participant, displayName: cachedDisplayName[id] };\n }\n return undefined;\n }\n );\n\n const modifiedParticipantState = participantsModifier(state);\n\n const chatMessagesModifier = createChatMessageModifier(\n (id: string, chatMessage: ChatMessageWithStatus): ChatMessageWithStatus | undefined => {\n const originalChatMessage = { ...chatMessage };\n if (originalChatMessage.content?.participants) {\n const newParticipants = originalChatMessage.content.participants.map((participant: ChatParticipant) => {\n if (participant.id) {\n if ('communicationUserId' in participant.id && cachedDisplayName[participant.id.communicationUserId]) {\n return { ...participant, displayName: cachedDisplayName[participant.id.communicationUserId] };\n } else if (\n 'microsoftTeamsUserId' in participant.id &&\n 'rawId' in participant.id &&\n participant.id.rawId &&\n cachedDisplayName[participant.id.rawId]\n ) {\n return { ...participant, displayName: cachedDisplayName[participant.id.rawId] };\n } else if (\n 'teamsAppId' in participant.id &&\n 'rawId' in participant.id &&\n participant.id.rawId &&\n cachedDisplayName[participant.id.rawId]\n ) {\n return { ...participant, displayName: cachedDisplayName[participant.id.rawId] };\n } else if (\n 'phoneNumber' in participant.id &&\n 'rawId' in participant.id &&\n participant.id.rawId &&\n cachedDisplayName[participant.id.rawId]\n ) {\n return { ...participant, displayName: cachedDisplayName[participant.id.rawId] };\n } else if ('id' in participant.id && cachedDisplayName[participant.id.id]) {\n return { ...participant, displayName: cachedDisplayName[participant.id.id] };\n } else {\n return participant;\n }\n }\n return participant;\n });\n originalChatMessage.content = {\n ...originalChatMessage.content,\n participants: newParticipants\n };\n }\n if (originalChatMessage.sender && originalChatMessage.senderDisplayName) {\n if (\n originalChatMessage.sender.kind === 'communicationUser' &&\n originalChatMessage.sender.communicationUserId &&\n cachedDisplayName[originalChatMessage.sender.communicationUserId]\n ) {\n originalChatMessage.senderDisplayName = cachedDisplayName[originalChatMessage.sender.communicationUserId];\n } else if (\n originalChatMessage.sender.kind === 'microsoftTeamsUser' &&\n originalChatMessage.sender.rawId &&\n cachedDisplayName[originalChatMessage.sender.rawId]\n ) {\n originalChatMessage.senderDisplayName = cachedDisplayName[originalChatMessage.sender.rawId];\n } else if (\n originalChatMessage.sender.kind === 'phoneNumber' &&\n originalChatMessage.sender.phoneNumber &&\n cachedDisplayName[originalChatMessage.sender.phoneNumber]\n ) {\n originalChatMessage.senderDisplayName = cachedDisplayName[originalChatMessage.sender.phoneNumber];\n } else if (\n originalChatMessage.sender.kind === 'unknown' &&\n originalChatMessage.sender.id &&\n cachedDisplayName[originalChatMessage.sender.id]\n ) {\n originalChatMessage.senderDisplayName = cachedDisplayName[originalChatMessage.sender.id];\n } else if (\n originalChatMessage.sender.kind === 'microsoftTeamsApp' &&\n originalChatMessage.sender.rawId &&\n cachedDisplayName[originalChatMessage.sender.rawId]\n ) {\n originalChatMessage.senderDisplayName = cachedDisplayName[originalChatMessage.sender.rawId];\n }\n }\n return { ...originalChatMessage };\n }\n );\n return chatMessagesModifier(modifiedParticipantState);\n };\n};\n\n/* @conditional-compile-remove(on-fetch-profile) */\n/**\n * @private\n * This is the util function to create a participant modifier for remote participantList\n * It memoize previous original participant items and only update the changed participant\n * It takes in one modifier function to generate one single participant object, it returns undefined if the object keeps unmodified\n */\nexport const createParticipantModifier = (\n createModifiedParticipant: (id: string, participant: ChatParticipant) => ChatParticipant | undefined\n): AdapterStateModifier => {\n let previousParticipantState:\n | {\n [keys: string]: ChatParticipant;\n }\n | undefined = undefined;\n let modifiedParticipants: {\n [keys: string]: ChatParticipant;\n } = {};\n const memoizedParticipants: {\n [id: string]: { originalRef: ChatParticipant; newParticipant: ChatParticipant };\n } = {};\n return (state: ChatAdapterState) => {\n // if root state is the same, we don't need to update the participants\n if (state.thread?.participants !== previousParticipantState) {\n modifiedParticipants = {};\n const originalParticipants = Object.entries(state.thread?.participants || {});\n for (const [key, originalParticipant] of originalParticipants) {\n const modifiedParticipant = createModifiedParticipant(key, originalParticipant);\n if (modifiedParticipant === undefined) {\n modifiedParticipants[key] = originalParticipant;\n continue;\n }\n // Generate the new item if original cached item has been changed\n if (memoizedParticipants[key]?.originalRef !== originalParticipant) {\n memoizedParticipants[key] = {\n newParticipant: modifiedParticipant,\n originalRef: originalParticipant\n };\n }\n\n // the modified participant is always coming from the memoized cache, whether is was refreshed\n // from the previous closure or not\n const memoizedParticipant = memoizedParticipants[key];\n if (!memoizedParticipant) {\n throw new Error('Participant modifier encountered an unhandled exception.');\n }\n\n modifiedParticipants[key] = memoizedParticipant.newParticipant;\n }\n\n previousParticipantState = state.thread?.participants;\n }\n return { ...state, thread: { ...state.thread, participants: modifiedParticipants } };\n };\n};\n\n/* @conditional-compile-remove(on-fetch-profile) */\n/**\n * @private\n * This is the util function to create a chat message modifier for remote participantList\n * It memoize previous original messages and only update the changed sender display name\n * It takes in one modifier function to generate one single participant object, it returns undefined if the object keeps unmodified\n */\nexport const createChatMessageModifier = (\n createModifiedChatMessage: (id: string, chatMessage: ChatMessageWithStatus) => ChatMessageWithStatus | undefined\n): AdapterStateModifier => {\n let previousChatMessages: {\n [key: string]: ChatMessageWithStatus;\n };\n let modifiedChatMessages: {\n [keys: string]: ChatMessageWithStatus;\n };\n const memoizedChatMessages: {\n [id: string]: { originalRef: ChatMessageWithStatus; newChatMessage: ChatMessageWithStatus };\n } = {};\n return (state: ChatAdapterState) => {\n if (state.thread?.chatMessages !== previousChatMessages) {\n modifiedChatMessages = {};\n const originalChatMessages = Object.entries(state.thread?.chatMessages || {});\n for (const [key, originalChatMessage] of originalChatMessages) {\n const modifiedChatMessage = createModifiedChatMessage(key, originalChatMessage);\n if (modifiedChatMessage === undefined) {\n modifiedChatMessages[key] = originalChatMessage;\n continue;\n }\n // Generate the new item if original cached item has been changed\n if (memoizedChatMessages[key]?.originalRef !== originalChatMessage) {\n memoizedChatMessages[key] = {\n newChatMessage: modifiedChatMessage,\n originalRef: originalChatMessage\n };\n }\n\n // the modified chat message is always coming from the memoized cache, whether is was refreshed\n // from the previous closure or not\n const memoizedChatMessage = memoizedChatMessages[key];\n if (!memoizedChatMessage) {\n throw new Error('Participant modifier encountered an unhandled exception.');\n }\n\n modifiedChatMessages[key] = memoizedChatMessage.newChatMessage;\n }\n previousChatMessages = state.thread?.chatMessages;\n }\n return { ...state, thread: { ...state.thread, chatMessages: modifiedChatMessages } };\n };\n};\n"]}
|
@@ -1,6 +1,8 @@
|
|
1
1
|
export { createAzureCommunicationChatAdapter, createAzureCommunicationChatAdapterFromClient, useAzureCommunicationChatAdapter } from './adapter/AzureCommunicationChatAdapter';
|
2
2
|
export type { AzureCommunicationChatAdapterArgs } from './adapter/AzureCommunicationChatAdapter';
|
3
|
+
export type { ChatAdapterOptions } from './adapter/AzureCommunicationChatAdapter';
|
3
4
|
export { ChatComposite } from './ChatComposite';
|
5
|
+
export type { OnFetchChatProfileCallback, ChatProfile } from './adapter/OnFetchProfileCallback';
|
4
6
|
export type { ChatCompositeProps, ChatCompositeOptions } from './ChatComposite';
|
5
7
|
export type { ChatAdapter, ChatAdapterSubscribers, ChatAdapterThreadManagement, ChatCompositeClientState, ChatAdapterState, ChatAdapterUiState, MessageReadListener, MessageReceivedListener, MessageSentListener, MessageEditedListener, MessageDeletedListener, ParticipantsAddedListener, ParticipantsRemovedListener, TopicChangedListener } from './adapter/ChatAdapter';
|
6
8
|
export type { ResourceDetails } from './adapter/ChatAdapter';
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../react-composites/src/composites/ChatComposite/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EACL,mCAAmC,EACnC,6CAA6C,EAC7C,gCAAgC,EACjC,MAAM,yCAAyC,CAAC;
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../react-composites/src/composites/ChatComposite/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EACL,mCAAmC,EACnC,6CAA6C,EAC7C,gCAAgC,EACjC,MAAM,yCAAyC,CAAC;AAIjD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAwBhD,cAAc,WAAW,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nexport {\n createAzureCommunicationChatAdapter,\n createAzureCommunicationChatAdapterFromClient,\n useAzureCommunicationChatAdapter\n} from './adapter/AzureCommunicationChatAdapter';\nexport type { AzureCommunicationChatAdapterArgs } from './adapter/AzureCommunicationChatAdapter';\n/* @conditional-compile-remove(on-fetch-profile) */\nexport type { ChatAdapterOptions } from './adapter/AzureCommunicationChatAdapter';\nexport { ChatComposite } from './ChatComposite';\n/* @conditional-compile-remove(on-fetch-profile) */\nexport type { OnFetchChatProfileCallback, ChatProfile } from './adapter/OnFetchProfileCallback';\nexport type { ChatCompositeProps, ChatCompositeOptions } from './ChatComposite';\n\nexport type {\n ChatAdapter,\n ChatAdapterSubscribers,\n ChatAdapterThreadManagement,\n ChatCompositeClientState,\n ChatAdapterState,\n ChatAdapterUiState,\n MessageReadListener,\n MessageReceivedListener,\n MessageSentListener,\n MessageEditedListener,\n MessageDeletedListener,\n ParticipantsAddedListener,\n ParticipantsRemovedListener,\n TopicChangedListener\n} from './adapter/ChatAdapter';\n\nexport type { ResourceDetails } from './adapter/ChatAdapter';\n\nexport * from './Strings';\n\n/* @conditional-compile-remove(file-sharing-acs) */\nexport type { AttachmentOptions, AttachmentMetadata, AttachmentDownloadOptions } from './file-sharing';\n/* @conditional-compile-remove(file-sharing-acs) */\nexport type {\n AttachmentProgressError,\n AttachmentUploadOptions,\n AttachmentSelectionHandler,\n AttachmentActionHandler,\n AttachmentRemovalHandler,\n AttachmentUploadTask\n} from './file-sharing';\n"]}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@azure/communication-react",
|
3
|
-
"version": "1.26.0-alpha-
|
3
|
+
"version": "1.26.0-alpha-202504100018",
|
4
4
|
"sideEffects": false,
|
5
5
|
"description": "React library for building modern communication user experiences utilizing Azure Communication Services",
|
6
6
|
"keywords": [
|