@azure/communication-react 1.5.1-alpha-202304180012 → 1.5.1-alpha-202304190014

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.
Files changed (37) hide show
  1. package/dist/communication-react.d.ts +7 -3
  2. package/dist/dist-cjs/communication-react/index.js +94 -29
  3. package/dist/dist-cjs/communication-react/index.js.map +1 -1
  4. package/dist/dist-esm/acs-ui-common/src/telemetryVersion.js +1 -1
  5. package/dist/dist-esm/acs-ui-common/src/telemetryVersion.js.map +1 -1
  6. package/dist/dist-esm/chat-component-bindings/src/messageThreadSelector.js +30 -2
  7. package/dist/dist-esm/chat-component-bindings/src/messageThreadSelector.js.map +1 -1
  8. package/dist/dist-esm/chat-stateful-client/src/EventSubscriber.js +5 -1
  9. package/dist/dist-esm/chat-stateful-client/src/EventSubscriber.js.map +1 -1
  10. package/dist/dist-esm/communication-react/src/index.d.ts +3 -2
  11. package/dist/dist-esm/communication-react/src/index.js.map +1 -1
  12. package/dist/dist-esm/react-components/src/components/GridLayout.js +1 -1
  13. package/dist/dist-esm/react-components/src/components/GridLayout.js.map +1 -1
  14. package/dist/dist-esm/react-components/src/components/MessageThread.d.ts +3 -2
  15. package/dist/dist-esm/react-components/src/components/MessageThread.js +3 -1
  16. package/dist/dist-esm/react-components/src/components/MessageThread.js.map +1 -1
  17. package/dist/dist-esm/react-components/src/components/ModalClone/ModalClone.js +1 -1
  18. package/dist/dist-esm/react-components/src/components/ModalClone/ModalClone.js.map +1 -1
  19. package/dist/dist-esm/react-components/src/components/VideoGallery/FloatingLocalVideo.js +1 -1
  20. package/dist/dist-esm/react-components/src/components/VideoGallery/FloatingLocalVideo.js.map +1 -1
  21. package/dist/dist-esm/react-components/src/types/ChatMessage.js.map +1 -1
  22. package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/adapter/AzureCommunicationCallWithChatAdapter.d.ts +4 -0
  23. package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/adapter/AzureCommunicationCallWithChatAdapter.js +8 -0
  24. package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/adapter/AzureCommunicationCallWithChatAdapter.js.map +1 -1
  25. package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/adapter/CallWithChatAdapter.d.ts +3 -1
  26. package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/adapter/CallWithChatAdapter.js.map +1 -1
  27. package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/adapter/CallWithChatBackedChatAdapter.d.ts +4 -0
  28. package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/adapter/CallWithChatBackedChatAdapter.js +6 -0
  29. package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/adapter/CallWithChatBackedChatAdapter.js.map +1 -1
  30. package/dist/dist-esm/react-composites/src/composites/ChatComposite/ChatScreen.js +11 -1
  31. package/dist/dist-esm/react-composites/src/composites/ChatComposite/ChatScreen.js.map +1 -1
  32. package/dist/dist-esm/react-composites/src/composites/ChatComposite/adapter/AzureCommunicationChatAdapter.d.ts +4 -1
  33. package/dist/dist-esm/react-composites/src/composites/ChatComposite/adapter/AzureCommunicationChatAdapter.js +27 -20
  34. package/dist/dist-esm/react-composites/src/composites/ChatComposite/adapter/AzureCommunicationChatAdapter.js.map +1 -1
  35. package/dist/dist-esm/react-composites/src/composites/ChatComposite/adapter/ChatAdapter.d.ts +3 -1
  36. package/dist/dist-esm/react-composites/src/composites/ChatComposite/adapter/ChatAdapter.js.map +1 -1
  37. package/package.json +10 -11
@@ -2445,7 +2445,9 @@ export declare interface CallWithChatAdapterManagement {
2445
2445
  updateFileUploadErrorMessage: (id: string, errorMessage: string) => void;
2446
2446
  /** @beta */
2447
2447
  updateFileUploadMetadata: (id: string, metadata: FileMetadata) => void;
2448
- downloadAuthenticatedAttachment?: (attachmentUrl: string) => Promise<AttachmentDownloadResult>;
2448
+ downloadAttachments: (options: {
2449
+ attachmentUrls: string[];
2450
+ }) => Promise<AttachmentDownloadResult[]>;
2449
2451
  /**
2450
2452
  * Puts the Call in a Localhold.
2451
2453
  *
@@ -3488,7 +3490,9 @@ export declare interface ChatAdapterThreadManagement {
3488
3490
  *
3489
3491
  */
3490
3492
  loadPreviousChatMessages(messagesToLoad: number): Promise<boolean>;
3491
- downloadAuthenticatedAttachment?: (attachmentUrl: string) => Promise<AttachmentDownloadResult>;
3493
+ downloadAttachments: (options: {
3494
+ attachmentUrls: string[];
3495
+ }) => Promise<AttachmentDownloadResult[]>;
3492
3496
  }
3493
3497
 
3494
3498
  /**
@@ -6728,7 +6732,7 @@ export declare type MessageThreadProps = {
6728
6732
  * @param attachment - FileMetadata object we want to render
6729
6733
  * @beta
6730
6734
  */
6731
- onFetchAttachments?: (attachment: FileMetadata) => Promise<AttachmentDownloadResult>;
6735
+ onFetchAttachments?: (attachment: FileMetadata) => Promise<AttachmentDownloadResult[]>;
6732
6736
  /**
6733
6737
  * Optional callback to edit a message.
6734
6738
  *
@@ -162,7 +162,7 @@ const _toCommunicationIdentifier = (id) => {
162
162
  // Copyright (c) Microsoft Corporation.
163
163
  // Licensed under the MIT license.
164
164
  // GENERATED FILE. DO NOT EDIT MANUALLY.
165
- var telemetryVersion = '1.5.1-alpha-202304180012';
165
+ var telemetryVersion = '1.5.1-alpha-202304190014';
166
166
 
167
167
  // Copyright (c) Microsoft Corporation.
168
168
  /**
@@ -5094,7 +5094,7 @@ const GridLayout = (props) => {
5094
5094
  return calculateGridProps(numberOfChildren, currentWidth, currentHeight);
5095
5095
  }, [numberOfChildren, currentWidth, currentHeight]);
5096
5096
  const cssGridStyles = React.useMemo(() => createGridStyles(numberOfChildren, gridProps), [numberOfChildren, gridProps]);
5097
- return (React__default['default'].createElement("div", { ref: containerRef, className: react.mergeStyles(gridLayoutStyle, cssGridStyles, styles === null || styles === void 0 ? void 0 : styles.root) }, children));
5097
+ return (React__default['default'].createElement("div", { ref: containerRef, className: react.mergeStyles(gridLayoutStyle, cssGridStyles, styles === null || styles === void 0 ? void 0 : styles.root), "data-ui-id": "grid-layout" }, children));
5098
5098
  };
5099
5099
  /**
5100
5100
  * The cell aspect ratio we aim for in a grid
@@ -7840,7 +7840,9 @@ const MessageThread = (props) => {
7840
7840
  return;
7841
7841
  }
7842
7842
  const attachmentDownloadResult = yield onFetchAttachments(attachment);
7843
- setInlineAttachments((prev) => (Object.assign(Object.assign({}, prev), { [attachment.id]: attachmentDownloadResult.blobUrl })));
7843
+ if (attachmentDownloadResult[0]) {
7844
+ setInlineAttachments((prev) => (Object.assign(Object.assign({}, prev), { [attachment.id]: attachmentDownloadResult[0].blobUrl })));
7845
+ }
7844
7846
  }), [inlineAttachments, onFetchAttachments]);
7845
7847
  const isAllChatMessagesLoadedRef = React.useRef(false);
7846
7848
  // isAllChatMessagesLoadedRef needs to be updated every time when a new adapter is set in order to display correct data
@@ -11049,7 +11051,7 @@ const ModalBase = React__namespace.forwardRef((propsWithoutDefaults, ref) => {
11049
11051
  internalState.events.dispose();
11050
11052
  });
11051
11053
  useComponentRef(props, focusTrapZone);
11052
- const modalContent = (React__namespace.createElement(react.FocusTrapZone, { disabled: true, id: focusTrapZoneId, ref: focusTrapZoneElm, componentRef: focusTrapZone, className: classNames.main, elementToFocusOnDismiss: elementToFocusOnDismiss, isClickableOutsideFocusTrap: isModeless || isClickableOutsideFocusTrap || !isBlocking, ignoreExternalFocusing: ignoreExternalFocusing, forceFocusInsideTrap: forceFocusInsideTrap && !isModeless, firstFocusableSelector: firstFocusableSelector, focusPreviouslyFocusedInnerElement: true, onBlur: internalState.isInKeyboardMoveMode ? handleExitKeyboardMoveMode : undefined },
11054
+ const modalContent = (React__namespace.createElement(react.FocusTrapZone, { disabled: true, id: focusTrapZoneId, ref: focusTrapZoneElm, componentRef: focusTrapZone, className: classNames.main, elementToFocusOnDismiss: elementToFocusOnDismiss, isClickableOutsideFocusTrap: isModeless || isClickableOutsideFocusTrap || !isBlocking, ignoreExternalFocusing: ignoreExternalFocusing, forceFocusInsideTrap: forceFocusInsideTrap && !isModeless, firstFocusableSelector: firstFocusableSelector, focusPreviouslyFocusedInnerElement: true, onBlur: internalState.isInKeyboardMoveMode ? handleExitKeyboardMoveMode : undefined, "data-ui-id": props['data-ui-id'] },
11053
11055
  dragOptions && internalState.isInKeyboardMoveMode && (React__namespace.createElement("div", { className: classNames.keyboardMoveIconContainer }, dragOptions.keyboardMoveIconProps ? (React__namespace.createElement(react.Icon, Object.assign({}, dragOptions.keyboardMoveIconProps))) : (React__namespace.createElement(react.Icon, { iconName: "move", className: classNames.keyboardMoveIcon })))),
11054
11056
  React__namespace.createElement("div", { ref: allowScrollOnModal, className: classNames.scrollableContent, "data-is-scrollable": true },
11055
11057
  dragOptions && isModalMenuOpen && (React__namespace.createElement(dragOptions.menu, { items: [
@@ -11485,7 +11487,7 @@ const FloatingLocalVideo = (props) => {
11485
11487
  : undefined, [parentHeight, parentWidth, localVideoSizeRem.width, localVideoSizeRem.height]);
11486
11488
  const modalStyles = React.useMemo(() => floatingLocalVideoModalStyle(theme, localVideoSizeRem), [theme, localVideoSizeRem]);
11487
11489
  const layerProps = React.useMemo(() => ({ hostId: layerHostId }), [layerHostId]);
11488
- return (React__default['default'].createElement(_ModalClone, { isOpen: true, isModeless: true, dragOptions: DRAG_OPTIONS$1, styles: modalStyles, layerProps: layerProps, maxDragPosition: modalMaxDragPosition, minDragPosition: modalMinDragPosition }, localVideoComponent));
11490
+ return (React__default['default'].createElement(_ModalClone, { isOpen: true, isModeless: true, dragOptions: DRAG_OPTIONS$1, styles: modalStyles, layerProps: layerProps, maxDragPosition: modalMaxDragPosition, minDragPosition: modalMinDragPosition, "data-ui-id": "floating-local-video-host" }, localVideoComponent));
11489
11491
  };
11490
11492
 
11491
11493
  // Copyright (c) Microsoft Corporation.
@@ -15194,6 +15196,34 @@ const extractAttachedFilesMetadata = (metadata) => {
15194
15196
  return [];
15195
15197
  }
15196
15198
  };
15199
+ /* @conditional-compile-remove(teams-inline-images) */
15200
+ const extractInlineImageFilesMetadata = (attachments) => {
15201
+ return attachments.map((attachment) => {
15202
+ var _a, _b;
15203
+ return ({
15204
+ attachmentType: attachment.attachmentType,
15205
+ id: attachment.id,
15206
+ name: (_a = attachment.name) !== null && _a !== void 0 ? _a : '',
15207
+ extension: (_b = attachment.contentType) !== null && _b !== void 0 ? _b : '',
15208
+ url: attachment.url,
15209
+ previewUrl: attachment.previewUrl
15210
+ });
15211
+ });
15212
+ };
15213
+ /* @conditional-compile-remove(file-sharing) @conditional-compile-remove(teams-inline-images) */
15214
+ const extractFilesMetadata = (message) => {
15215
+ var _a, _b;
15216
+ let fileMetadata = [];
15217
+ /* @conditional-compile-remove(file-sharing) */
15218
+ if (message.metadata) {
15219
+ fileMetadata = fileMetadata.concat(extractAttachedFilesMetadata(message.metadata));
15220
+ }
15221
+ /* @conditional-compile-remove(teams-inline-images) */
15222
+ if ((_a = message.content) === null || _a === void 0 ? void 0 : _a.attachments) {
15223
+ fileMetadata = fileMetadata.concat(extractInlineImageFilesMetadata((_b = message.content) === null || _b === void 0 ? void 0 : _b.attachments));
15224
+ }
15225
+ return fileMetadata;
15226
+ };
15197
15227
  /* @conditional-compile-remove(data-loss-prevention) */
15198
15228
  const convertToUiBlockedMessage = (message, userId, isSeen, isLargeGroup) => {
15199
15229
  var _a;
@@ -15228,8 +15258,8 @@ const convertToUiChatMessage = (message, userId, isSeen, isLargeGroup) => {
15228
15258
  deletedOn: message.deletedOn,
15229
15259
  mine: messageSenderId === userId,
15230
15260
  metadata: message.metadata,
15231
- /* @conditional-compile-remove(file-sharing) */
15232
- attachedFilesMetadata: extractAttachedFilesMetadata(message.metadata || {})
15261
+ /* @conditional-compile-remove(file-sharing) @conditional-compile-remove(teams-inline-images) */
15262
+ attachedFilesMetadata: extractFilesMetadata(message)
15233
15263
  };
15234
15264
  };
15235
15265
  const convertToUiSystemMessage = (message) => {
@@ -16017,7 +16047,11 @@ class EventSubscriber {
16017
16047
  return convertChatMessage({
16018
16048
  id: event.id,
16019
16049
  version: event.version,
16020
- content: { message: event.message },
16050
+ content: {
16051
+ message: event.message,
16052
+ /* @conditional-compile-remove(teams-inline-images) */
16053
+ attachments: event.attachments
16054
+ },
16021
16055
  type: this.convertEventType(event.type),
16022
16056
  sender: event.sender,
16023
16057
  senderDisplayName: event.senderDisplayName,
@@ -17591,7 +17625,7 @@ class AzureCommunicationChatAdapter {
17591
17625
  /* @conditional-compile-remove(file-sharing) */
17592
17626
  this.updateFileUploadMetadata = this.updateFileUploadMetadata.bind(this);
17593
17627
  /* @conditional-compile-remove(teams-inline-images) */
17594
- this.downloadAuthenticatedAttachment = this.downloadAuthenticatedAttachment.bind(this);
17628
+ this.downloadAttachments = this.downloadAttachments.bind(this);
17595
17629
  }
17596
17630
  dispose() {
17597
17631
  this.unsubscribeAllEvents();
@@ -17729,7 +17763,7 @@ class AzureCommunicationChatAdapter {
17729
17763
  this.fileUploadAdapter.updateFileUploadMetadata(id, metadata);
17730
17764
  }
17731
17765
  /* @conditional-compile-remove(teams-inline-images) */
17732
- downloadAuthenticatedAttachment(attachmentUrl) {
17766
+ downloadAttachments(options) {
17733
17767
  return __awaiter$i(this, void 0, void 0, function* () {
17734
17768
  return this.asyncTeeErrorToEventEmitter(() => __awaiter$i(this, void 0, void 0, function* () {
17735
17769
  if (this.credential === undefined) {
@@ -17745,27 +17779,34 @@ class AzureCommunicationChatAdapter {
17745
17779
  e['innerError'] = new Error('AccessToken is null');
17746
17780
  throw e;
17747
17781
  }
17748
- function fetchWithAuthentication(url, token) {
17749
- return __awaiter$i(this, void 0, void 0, function* () {
17750
- const headers = new Headers();
17751
- headers.append('Authorization', `Bearer ${token}`);
17752
- try {
17753
- return yield fetch(url, { headers });
17754
- }
17755
- catch (err) {
17756
- const e = new Error();
17757
- e['target'] = 'ChatThreadClient.getMessage';
17758
- e['innerError'] = err;
17759
- throw e;
17760
- }
17761
- });
17762
- }
17763
- const response = yield fetchWithAuthentication(attachmentUrl, accessToken.token);
17764
- const blob = yield response.blob();
17765
- return { blobUrl: URL.createObjectURL(blob) };
17782
+ return this.downloadAuthenticatedFile(accessToken.token, options);
17766
17783
  }));
17767
17784
  });
17768
17785
  }
17786
+ /* @conditional-compile-remove(teams-inline-images) */
17787
+ downloadAuthenticatedFile(accessToken, options) {
17788
+ return __awaiter$i(this, void 0, void 0, function* () {
17789
+ function fetchWithAuthentication(url, token) {
17790
+ return __awaiter$i(this, void 0, void 0, function* () {
17791
+ const headers = new Headers();
17792
+ headers.append('Authorization', `Bearer ${token}`);
17793
+ try {
17794
+ return yield fetch(url, { headers });
17795
+ }
17796
+ catch (err) {
17797
+ const e = new Error();
17798
+ e['target'] = 'ChatThreadClient.getMessage';
17799
+ e['innerError'] = err;
17800
+ throw e;
17801
+ }
17802
+ });
17803
+ }
17804
+ const attachmentUrl = options.attachmentUrls[0];
17805
+ const response = yield fetchWithAuthentication(attachmentUrl, accessToken);
17806
+ const blob = yield response.blob();
17807
+ return [{ blobUrl: URL.createObjectURL(blob) }];
17808
+ });
17809
+ }
17769
17810
  messageReceivedListener(event) {
17770
17811
  const message = convertEventToChatMessage(event);
17771
17812
  this.emitter.emit('messageReceived', { message });
@@ -18633,6 +18674,14 @@ const ChatScreen = (props) => {
18633
18674
  const onRenderFileDownloads = React.useCallback((userId, message) => (React__default['default'].createElement(_FileDownloadCards, { userId: userId, fileMetadata: message.attachedFilesMetadata || [], downloadHandler: fileSharing === null || fileSharing === void 0 ? void 0 : fileSharing.downloadHandler, onDownloadErrorMessage: (errorMessage) => {
18634
18675
  setDownloadErrorMessage(errorMessage);
18635
18676
  } })), [fileSharing === null || fileSharing === void 0 ? void 0 : fileSharing.downloadHandler]);
18677
+ /* @conditional-compile-remove(teams-inline-images) */
18678
+ const onRenderInlineAttachment = React.useCallback((attachment) => __awaiter$g(void 0, void 0, void 0, function* () {
18679
+ if (attachment.previewUrl) {
18680
+ const blob = yield adapter.downloadAttachments({ attachmentUrls: [attachment.previewUrl] });
18681
+ return blob;
18682
+ }
18683
+ return [{ blobUrl: '' }];
18684
+ }), [adapter]);
18636
18685
  const AttachFileButton = React.useCallback(() => {
18637
18686
  if (!(fileSharing === null || fileSharing === void 0 ? void 0 : fileSharing.uploadHandler)) {
18638
18687
  return null;
@@ -18650,7 +18699,9 @@ const ChatScreen = (props) => {
18650
18699
  }, []), fileDownloadErrorMessage: downloadErrorMessage || '' }),
18651
18700
  React__default['default'].createElement(MessageThread, Object.assign({}, messageThreadProps, { onRenderAvatar: onRenderAvatarCallback, onRenderMessage: onRenderMessage,
18652
18701
  /* @conditional-compile-remove(file-sharing) */
18653
- onRenderFileDownloads: onRenderFileDownloads, numberOfChatMessagesToReload: defaultNumberOfChatMessagesToReload, styles: messageThreadStyles })),
18702
+ onRenderFileDownloads: onRenderFileDownloads,
18703
+ /* @conditional-compile-remove(teams-inline-images) */
18704
+ onFetchAttachments: onRenderInlineAttachment, numberOfChatMessagesToReload: defaultNumberOfChatMessagesToReload, styles: messageThreadStyles })),
18654
18705
  React__default['default'].createElement(react.Stack, { className: react.mergeStyles(sendboxContainerStyles) },
18655
18706
  React__default['default'].createElement("div", { className: react.mergeStyles(typingIndicatorContainerStyles) }, onRenderTypingIndicator ? (onRenderTypingIndicator(typingIndicatorProps.typingUsers)) : (React__default['default'].createElement(TypingIndicator, Object.assign({}, typingIndicatorProps, { styles: typingIndicatorStyles })))),
18656
18707
  React__default['default'].createElement(react.Stack, { horizontal: formFactor === 'mobile' },
@@ -25411,6 +25462,12 @@ class CallWithChatBackedChatAdapter {
25411
25462
  };
25412
25463
  this.callWithChatAdapter = callWithChatAdapter;
25413
25464
  }
25465
+ /* @conditional-compile-remove(teams-inline-images) */
25466
+ downloadAttachments(options) {
25467
+ return __awaiter$2(this, void 0, void 0, function* () {
25468
+ return yield this.callWithChatAdapter.downloadAttachments(options);
25469
+ });
25470
+ }
25414
25471
  }
25415
25472
  function chatAdapterStateFromCallWithChatAdapterState(callWithChatAdapterState) {
25416
25473
  if (!callWithChatAdapterState.chat) {
@@ -25951,6 +26008,8 @@ class AzureCommunicationCallWithChatAdapter {
25951
26008
  this.updateFileUploadErrorMessage = this.updateFileUploadErrorMessage.bind(this);
25952
26009
  /* @conditional-compile-remove(file-sharing) */
25953
26010
  this.updateFileUploadMetadata = this.updateFileUploadMetadata.bind(this);
26011
+ /* @conditional-compile-remove(teams-inline-images) */
26012
+ this.downloadAttachments = this.downloadAttachments.bind(this);
25954
26013
  /* @conditional-compile-remove(PSTN-calls) */
25955
26014
  this.holdCall.bind(this);
25956
26015
  /* @conditional-compile-remove(PSTN-calls) */
@@ -26158,6 +26217,12 @@ class AzureCommunicationCallWithChatAdapter {
26158
26217
  return yield this.chatAdapter.deleteMessage(messageId);
26159
26218
  });
26160
26219
  }
26220
+ /* @conditional-compile-remove(teams-inline-images) */
26221
+ downloadAttachments(options) {
26222
+ return __awaiter(this, void 0, void 0, function* () {
26223
+ return yield this.chatAdapter.downloadAttachments(options);
26224
+ });
26225
+ }
26161
26226
  /* @conditional-compile-remove(PSTN-calls) */
26162
26227
  holdCall() {
26163
26228
  return __awaiter(this, void 0, void 0, function* () {