@azure/communication-react 1.13.0-alpha-202402070012 → 1.13.0-alpha-202402090012
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 +20 -0
- package/dist/dist-cjs/communication-react/index.js +125 -58
- package/dist/dist-cjs/communication-react/index.js.map +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-stateful-client/src/Converter.js +1 -1
- package/dist/dist-esm/calling-stateful-client/src/Converter.js.map +1 -1
- package/dist/dist-esm/chat-stateful-client/src/ChatContext.d.ts +6 -2
- package/dist/dist-esm/chat-stateful-client/src/ChatContext.js +57 -8
- package/dist/dist-esm/chat-stateful-client/src/ChatContext.js.map +1 -1
- package/dist/dist-esm/chat-stateful-client/src/ResourceDownloadQueue.d.ts +11 -3
- package/dist/dist-esm/chat-stateful-client/src/ResourceDownloadQueue.js +41 -9
- package/dist/dist-esm/chat-stateful-client/src/ResourceDownloadQueue.js.map +1 -1
- package/dist/dist-esm/chat-stateful-client/src/StatefulChatClient.d.ts +20 -0
- package/dist/dist-esm/chat-stateful-client/src/StatefulChatClient.js +15 -0
- package/dist/dist-esm/chat-stateful-client/src/StatefulChatClient.js.map +1 -1
- package/dist/dist-esm/chat-stateful-client/src/index.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/ChatMessage/ChatMessageComponentAsEditBox.js +4 -4
- package/dist/dist-esm/react-components/src/components/ChatMessage/ChatMessageComponentAsEditBox.js.map +1 -1
- package/dist/dist-esm/react-components/src/components/styles/ChatMessageComponent.styles.d.ts +1 -1
- package/dist/dist-esm/react-components/src/components/styles/ChatMessageComponent.styles.js +12 -5
- package/dist/dist-esm/react-components/src/components/styles/ChatMessageComponent.styles.js.map +1 -1
- package/package.json +1 -1
@@ -10044,6 +10044,10 @@ export declare type StatefulCallClientOptions = {
|
|
10044
10044
|
* @public
|
10045
10045
|
*/
|
10046
10046
|
export declare interface StatefulChatClient extends ChatClient {
|
10047
|
+
/**
|
10048
|
+
* Cleans up the resource cache from the chat thread client.
|
10049
|
+
*/
|
10050
|
+
dispose(): void;
|
10047
10051
|
/**
|
10048
10052
|
* Holds all the state that we could proxy from ChatClient {@Link @azure/communication-chat#ChatClient} as
|
10049
10053
|
* ChatClientState {@Link ChatClientState}.
|
@@ -10061,6 +10065,22 @@ export declare interface StatefulChatClient extends ChatClient {
|
|
10061
10065
|
* @param handler - Original callback to be unsubscribed.
|
10062
10066
|
*/
|
10063
10067
|
offStateChange(handler: (state: ChatClientState) => void): void;
|
10068
|
+
/**
|
10069
|
+
* Downloads a resource for specific message and caches it.
|
10070
|
+
*
|
10071
|
+
* @param threadId - The thread id of the chat thread.
|
10072
|
+
* @param messageId - The message id of the chat message.
|
10073
|
+
* @param resourceUrl - The resource url to fetch and cache.
|
10074
|
+
*/
|
10075
|
+
downloadResourceToCache(threadId: string, messageId: string, resourceUrl: string): void;
|
10076
|
+
/**
|
10077
|
+
* Removes a resource from cache for a specific message.
|
10078
|
+
*
|
10079
|
+
* @param threadId - The thread id of the chat thread.
|
10080
|
+
* @param messageId - The message id of the chat message.
|
10081
|
+
* @param resourceUrl - The resource url to remove from cache.
|
10082
|
+
*/
|
10083
|
+
removeResourceFromCache(threadId: string, messageId: string, resourceUrl: string): void;
|
10064
10084
|
}
|
10065
10085
|
|
10066
10086
|
/**
|
@@ -173,7 +173,7 @@ function getDefaultExportFromCjs (x) {
|
|
173
173
|
// Copyright (c) Microsoft Corporation.
|
174
174
|
// Licensed under the MIT License.
|
175
175
|
// GENERATED FILE. DO NOT EDIT MANUALLY.
|
176
|
-
var telemetryVersion = '1.13.0-alpha-
|
176
|
+
var telemetryVersion = '1.13.0-alpha-202402090012';
|
177
177
|
|
178
178
|
|
179
179
|
var telemetryVersion$1 = /*@__PURE__*/getDefaultExportFromCjs(telemetryVersion);
|
@@ -1809,7 +1809,7 @@ function convertSdkCallToDeclarativeCall(call) {
|
|
1809
1809
|
},
|
1810
1810
|
/* @conditional-compile-remove(hide-attendee-name) */
|
1811
1811
|
// TODO: Replace this once the SDK supports hide attendee name
|
1812
|
-
hideAttendeeNames:
|
1812
|
+
hideAttendeeNames: false
|
1813
1813
|
};
|
1814
1814
|
}
|
1815
1815
|
/**
|
@@ -10122,12 +10122,19 @@ const chatMessageMenuStyle = react.mergeStyles({
|
|
10122
10122
|
* @private
|
10123
10123
|
*/
|
10124
10124
|
const useChatMessageEditContainerStyles = reactComponents.makeStyles({
|
10125
|
-
|
10126
|
-
paddingTop: '1.25rem' //height of the menu button + marginBottom
|
10127
|
-
},
|
10128
|
-
body: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, reactComponents.shorthands.padding(0)), { backgroundColor: 'transparent', boxSizing: 'border-box' }), reactComponents.shorthands.border(`${defaultSendBoxInactiveBorderThicknessREM}rem`, 'solid')), reactComponents.shorthands.borderRadius(reactComponents.tokens.borderRadiusMedium)), reactComponents.shorthands.margin(`${defaultSendBoxActiveBorderThicknessREM - defaultSendBoxInactiveBorderThicknessREM}rem`)), {
|
10125
|
+
body: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, reactComponents.shorthands.padding(0)), { backgroundColor: 'transparent', boxSizing: 'border-box' }), reactComponents.shorthands.border(`${defaultSendBoxInactiveBorderThicknessREM}rem`, 'solid')), reactComponents.shorthands.borderRadius(reactComponents.tokens.borderRadiusMedium)), reactComponents.shorthands.margin('21px', '1px', '1px', '1px')), {
|
10129
10126
|
// Width should be updated on hover to include the border width change
|
10130
|
-
width: `calc(100% - ${defaultSendBoxActiveBorderThicknessREM}rem)`, '&:hover, &:active, &:focus, &:focus-within': Object.assign(Object.assign(Object.assign({}, reactComponents.shorthands.
|
10127
|
+
width: `calc(100% - ${defaultSendBoxActiveBorderThicknessREM}rem)`, '&:hover, &:active, &:focus, &:focus-within': Object.assign(Object.assign(Object.assign({}, reactComponents.shorthands.borderWidth(`${defaultSendBoxActiveBorderThicknessREM}rem`)), reactComponents.shorthands.margin('20px', 0, 0, 0)), { width: '100%' }) }),
|
10128
|
+
bodyAttached: {
|
10129
|
+
marginBottom: '1px',
|
10130
|
+
marginTop: '3px',
|
10131
|
+
// Width should be updated on hover to include the border width change
|
10132
|
+
width: `calc(100% - ${defaultSendBoxActiveBorderThicknessREM}rem)`,
|
10133
|
+
'&:hover, &:active, &:focus, &:focus-within': {
|
10134
|
+
marginTop: '2px',
|
10135
|
+
marginBottom: 0
|
10136
|
+
}
|
10137
|
+
},
|
10131
10138
|
bodyError: Object.assign({}, reactComponents.shorthands.borderColor(errorTextColor)),
|
10132
10139
|
bodyDefault: Object.assign(Object.assign({}, reactComponents.shorthands.borderColor(reactComponents.tokens.colorNeutralStrokeAccessible)), { '&:hover, &:active, &:focus, &:focus-within': Object.assign({}, reactComponents.shorthands.borderColor(reactComponents.tokens.colorCompoundBrandStroke)) })
|
10133
10140
|
});
|
@@ -10259,11 +10266,11 @@ const ChatMessageComponentAsEditBox = (props) => {
|
|
10259
10266
|
}, id: 'submitIconWrapper' }))), /* @conditional-compile-remove(file-sharing) */
|
10260
10267
|
onRenderFileUploads()));
|
10261
10268
|
};
|
10262
|
-
const
|
10263
|
-
return (React.createElement(reactChat.ChatMyMessage, { root: {
|
10264
|
-
className:
|
10269
|
+
const attached = message.attached === true ? 'center' : message.attached === 'bottom' ? 'bottom' : 'top';
|
10270
|
+
return (React.createElement(reactChat.ChatMyMessage, { attached: attached, root: {
|
10271
|
+
className: chatMyMessageStyles.root
|
10265
10272
|
}, body: {
|
10266
|
-
className:
|
10273
|
+
className: reactComponents.mergeClasses(editContainerStyles.body, message.failureReason !== undefined ? editContainerStyles.bodyError : editContainerStyles.bodyDefault, attached !== 'top' ? editContainerStyles.bodyAttached : undefined)
|
10267
10274
|
} }, getContent()));
|
10268
10275
|
};
|
10269
10276
|
const isMessageTooLong = (messageText) => messageText.length > MAXIMUM_LENGTH_OF_MESSAGE;
|
@@ -21687,24 +21694,28 @@ class ResourceDownloadQueue {
|
|
21687
21694
|
const copy = Object.assign({}, message);
|
21688
21695
|
this._messagesNeedingResourceRetrieval.push(copy);
|
21689
21696
|
}
|
21690
|
-
startQueue(threadId, operation) {
|
21697
|
+
startQueue(threadId, operation, options) {
|
21691
21698
|
return __awaiter$t(this, void 0, void 0, function* () {
|
21692
21699
|
if (this.isActive) {
|
21693
21700
|
return;
|
21694
21701
|
}
|
21695
21702
|
while (this._messagesNeedingResourceRetrieval.length > 0) {
|
21696
21703
|
this.isActive = true;
|
21697
|
-
|
21704
|
+
let message = this._messagesNeedingResourceRetrieval.shift();
|
21698
21705
|
if (!message) {
|
21699
21706
|
this.isActive = false;
|
21700
21707
|
continue;
|
21701
21708
|
}
|
21702
21709
|
try {
|
21703
|
-
|
21704
|
-
|
21705
|
-
this.
|
21706
|
-
this._context.setChatMessage(threadId, newMessage);
|
21710
|
+
if (options) {
|
21711
|
+
const singleUrl = options.singleUrl;
|
21712
|
+
message = yield this.downloadSingleUrl(message, singleUrl, operation);
|
21707
21713
|
}
|
21714
|
+
else {
|
21715
|
+
message = yield this.downloadAllPreviewUrls(message, operation);
|
21716
|
+
}
|
21717
|
+
this.isActive = false;
|
21718
|
+
this._context.setChatMessage(threadId, message);
|
21708
21719
|
}
|
21709
21720
|
catch (error) {
|
21710
21721
|
console.log('Downloading Resource error: ', error);
|
@@ -21712,37 +21723,39 @@ class ResourceDownloadQueue {
|
|
21712
21723
|
}
|
21713
21724
|
});
|
21714
21725
|
}
|
21715
|
-
|
21716
|
-
|
21717
|
-
|
21718
|
-
|
21719
|
-
|
21720
|
-
const
|
21721
|
-
|
21722
|
-
|
21723
|
-
|
21724
|
-
|
21725
|
-
|
21726
|
-
|
21727
|
-
|
21728
|
-
|
21729
|
-
|
21730
|
-
|
21731
|
-
|
21732
|
-
message.resourceCache[previewUrl] = src;
|
21726
|
+
downloadSingleUrl(message, resourceUrl, operation) {
|
21727
|
+
return __awaiter$t(this, void 0, void 0, function* () {
|
21728
|
+
if (message.resourceCache === undefined) {
|
21729
|
+
message.resourceCache = {};
|
21730
|
+
}
|
21731
|
+
const blobUrl = yield operation(resourceUrl, this._credential);
|
21732
|
+
message.resourceCache[resourceUrl] = blobUrl;
|
21733
|
+
return message;
|
21734
|
+
});
|
21735
|
+
}
|
21736
|
+
downloadAllPreviewUrls(message, operation) {
|
21737
|
+
var _a;
|
21738
|
+
return __awaiter$t(this, void 0, void 0, function* () {
|
21739
|
+
const attachments = (_a = message.content) === null || _a === void 0 ? void 0 : _a.attachments;
|
21740
|
+
if (message.type === 'html' && attachments) {
|
21741
|
+
if (message.resourceCache === undefined) {
|
21742
|
+
message.resourceCache = {};
|
21733
21743
|
}
|
21734
|
-
|
21735
|
-
|
21744
|
+
for (const attachment of attachments) {
|
21745
|
+
if (attachment.previewUrl) {
|
21746
|
+
const blobUrl = yield operation(attachment.previewUrl, this._credential);
|
21747
|
+
message.resourceCache[attachment.previewUrl] = blobUrl;
|
21748
|
+
}
|
21736
21749
|
}
|
21737
21750
|
}
|
21738
|
-
|
21751
|
+
return message;
|
21752
|
+
});
|
21739
21753
|
}
|
21740
|
-
|
21741
|
-
|
21754
|
+
}
|
21755
|
+
/* @conditional-compile-remove(teams-inline-images-and-file-sharing) */
|
21742
21756
|
/**
|
21743
21757
|
* @private
|
21744
21758
|
*/
|
21745
|
-
/* @conditional-compile-remove(teams-inline-images-and-file-sharing) */
|
21746
21759
|
const fetchImageSource = (src, credential) => __awaiter$t(void 0, void 0, void 0, function* () {
|
21747
21760
|
function fetchWithAuthentication(url, token) {
|
21748
21761
|
return __awaiter$t(this, void 0, void 0, function* () {
|
@@ -21761,16 +21774,6 @@ const fetchImageSource = (src, credential) => __awaiter$t(void 0, void 0, void 0
|
|
21761
21774
|
const blob = yield response.blob();
|
21762
21775
|
return URL.createObjectURL(blob);
|
21763
21776
|
});
|
21764
|
-
/* @conditional-compile-remove(teams-inline-images-and-file-sharing) */
|
21765
|
-
/**
|
21766
|
-
* @private
|
21767
|
-
*/
|
21768
|
-
class ResourceDownloadError extends Error {
|
21769
|
-
constructor(chatMessageWithStatus) {
|
21770
|
-
super();
|
21771
|
-
this.chatMessageWithStatus = chatMessageWithStatus;
|
21772
|
-
}
|
21773
|
-
}
|
21774
21777
|
|
21775
21778
|
// Copyright (c) Microsoft Corporation.
|
21776
21779
|
// Licensed under the MIT License.
|
@@ -21787,7 +21790,7 @@ immer.enableMapSet();
|
|
21787
21790
|
// Needed to generate state diff for verbose logging.
|
21788
21791
|
immer.enablePatches();
|
21789
21792
|
/**
|
21790
|
-
* @
|
21793
|
+
* @internal
|
21791
21794
|
*/
|
21792
21795
|
let ChatContext$1 = class ChatContext {
|
21793
21796
|
constructor(maxListeners,
|
@@ -21801,12 +21804,15 @@ let ChatContext$1 = class ChatContext {
|
|
21801
21804
|
this._batchMode = false;
|
21802
21805
|
this.typingIndicatorInterval = undefined;
|
21803
21806
|
/* @conditional-compile-remove(teams-inline-images-and-file-sharing) */
|
21804
|
-
this.
|
21807
|
+
this._inlineImageQueue = undefined;
|
21808
|
+
/* @conditional-compile-remove(teams-inline-images-and-file-sharing) */
|
21809
|
+
this._fullsizeImageQueue = undefined;
|
21805
21810
|
this._logger = logger.createClientLogger('communication-react:chat-context');
|
21806
21811
|
this._emitter = new EventEmitter();
|
21807
21812
|
/* @conditional-compile-remove(teams-inline-images-and-file-sharing) */
|
21808
21813
|
if (credential) {
|
21809
|
-
this.
|
21814
|
+
this._inlineImageQueue = new ResourceDownloadQueue(this, credential);
|
21815
|
+
this._fullsizeImageQueue = new ResourceDownloadQueue(this, credential);
|
21810
21816
|
}
|
21811
21817
|
if (maxListeners) {
|
21812
21818
|
this._emitter.setMaxListeners(maxListeners);
|
@@ -21827,6 +21833,52 @@ let ChatContext$1 = class ChatContext {
|
|
21827
21833
|
this._emitter.emit('stateChanged', this._state);
|
21828
21834
|
}
|
21829
21835
|
}
|
21836
|
+
/* @conditional-compile-remove(teams-inline-images-and-file-sharing) */
|
21837
|
+
dispose() {
|
21838
|
+
this.modifyState((draft) => {
|
21839
|
+
Object.keys(draft.threads).forEach((threadId) => {
|
21840
|
+
const thread = draft.threads[threadId];
|
21841
|
+
Object.keys(thread.chatMessages).forEach((messageId) => {
|
21842
|
+
const cache = thread.chatMessages[messageId].resourceCache;
|
21843
|
+
if (cache) {
|
21844
|
+
Object.keys(cache).forEach((resourceUrl) => {
|
21845
|
+
const blobUrl = cache[resourceUrl];
|
21846
|
+
URL.revokeObjectURL(blobUrl);
|
21847
|
+
});
|
21848
|
+
}
|
21849
|
+
thread.chatMessages[messageId].resourceCache = undefined;
|
21850
|
+
});
|
21851
|
+
});
|
21852
|
+
});
|
21853
|
+
// Any item in queue should be removed.
|
21854
|
+
}
|
21855
|
+
/* @conditional-compile-remove(teams-inline-images-and-file-sharing) */
|
21856
|
+
downloadResourceToCache(threadId, messageId, resourceUrl) {
|
21857
|
+
this.modifyState((draft) => {
|
21858
|
+
var _a;
|
21859
|
+
const message = (_a = draft.threads[threadId]) === null || _a === void 0 ? void 0 : _a.chatMessages[messageId];
|
21860
|
+
if (message && this._fullsizeImageQueue) {
|
21861
|
+
if (!message.resourceCache) {
|
21862
|
+
message.resourceCache = {};
|
21863
|
+
}
|
21864
|
+
// Need to discuss retry logic in case of failure
|
21865
|
+
this._fullsizeImageQueue.addMessage(message);
|
21866
|
+
this._fullsizeImageQueue.startQueue(threadId, fetchImageSource, { singleUrl: resourceUrl });
|
21867
|
+
}
|
21868
|
+
});
|
21869
|
+
}
|
21870
|
+
/* @conditional-compile-remove(teams-inline-images-and-file-sharing) */
|
21871
|
+
removeResourceFromCache(threadId, messageId, resourceUrl) {
|
21872
|
+
this.modifyState((draft) => {
|
21873
|
+
var _a;
|
21874
|
+
const message = (_a = draft.threads[threadId]) === null || _a === void 0 ? void 0 : _a.chatMessages[messageId];
|
21875
|
+
if (message && message.resourceCache) {
|
21876
|
+
const blobUrl = message.resourceCache[resourceUrl];
|
21877
|
+
URL.revokeObjectURL(blobUrl);
|
21878
|
+
delete message.resourceCache[resourceUrl];
|
21879
|
+
}
|
21880
|
+
});
|
21881
|
+
}
|
21830
21882
|
setThread(threadId, threadState) {
|
21831
21883
|
this.modifyState((draft) => {
|
21832
21884
|
draft.threads[threadId] = threadState;
|
@@ -22054,12 +22106,12 @@ let ChatContext$1 = class ChatContext {
|
|
22054
22106
|
var _a;
|
22055
22107
|
const attachments = (_a = message.content) === null || _a === void 0 ? void 0 : _a.attachments;
|
22056
22108
|
if (message.type === 'html' && attachments && attachments.length > 0) {
|
22057
|
-
if (this.
|
22058
|
-
!this.
|
22109
|
+
if (this._inlineImageQueue &&
|
22110
|
+
!this._inlineImageQueue.containsMessageWithSameAttachments(message) &&
|
22059
22111
|
message.resourceCache === undefined) {
|
22060
22112
|
// Need to discuss retry logic in case of failure
|
22061
|
-
this.
|
22062
|
-
this.
|
22113
|
+
this._inlineImageQueue.addMessage(message);
|
22114
|
+
this._inlineImageQueue.startQueue(threadId, fetchImageSource);
|
22063
22115
|
}
|
22064
22116
|
}
|
22065
22117
|
}
|
@@ -22774,6 +22826,21 @@ const _createStatefulChatClientWithDeps = (chatClient, args, options) => {
|
|
22774
22826
|
eventSubscriber = val;
|
22775
22827
|
}
|
22776
22828
|
});
|
22829
|
+
/* @conditional-compile-remove(teams-inline-images-and-file-sharing) */
|
22830
|
+
Object.defineProperty(proxy, 'dispose', {
|
22831
|
+
configurable: false,
|
22832
|
+
value: () => context === null || context === void 0 ? void 0 : context.dispose()
|
22833
|
+
});
|
22834
|
+
/* @conditional-compile-remove(teams-inline-images-and-file-sharing) */
|
22835
|
+
Object.defineProperty(proxy, 'downloadResourceToCache', {
|
22836
|
+
configurable: false,
|
22837
|
+
value: (threadId, messageId, resourceUrl) => context === null || context === void 0 ? void 0 : context.downloadResourceToCache(threadId, messageId, resourceUrl)
|
22838
|
+
});
|
22839
|
+
/* @conditional-compile-remove(teams-inline-images-and-file-sharing) */
|
22840
|
+
Object.defineProperty(proxy, 'removeResourceFromCache', {
|
22841
|
+
configurable: false,
|
22842
|
+
value: (threadId, messageId, resourceUrl) => context === null || context === void 0 ? void 0 : context.removeResourceFromCache(threadId, messageId, resourceUrl)
|
22843
|
+
});
|
22777
22844
|
Object.defineProperty(proxy, 'getState', {
|
22778
22845
|
configurable: false,
|
22779
22846
|
value: () => context === null || context === void 0 ? void 0 : context.getState()
|