@azure/communication-react 1.34.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -15,7 +15,7 @@ var uuid = require('uuid');
15
15
  var reactChat = require('@fluentui-contrib/react-chat');
16
16
  var react$1 = require('@griffel/react');
17
17
  var parse = require('html-react-parser');
18
- var Linkify = require('react-linkify');
18
+ var linkifyIt = require('linkify-it');
19
19
  var DOMPurify = require('dompurify');
20
20
  var reactFileTypeIcons = require('@fluentui/react-file-type-icons');
21
21
  var reactHooks = require('@fluentui/react-hooks');
@@ -178,7 +178,7 @@ function getDefaultExportFromCjs (x) {
178
178
  // Copyright (c) Microsoft Corporation.
179
179
  // Licensed under the MIT License.
180
180
  // GENERATED FILE. DO NOT EDIT MANUALLY.
181
- var telemetryVersion = '1.34.0';
181
+ var telemetryVersion = '2.0.0';
182
182
 
183
183
 
184
184
  var telemetryVersion$1 = /*@__PURE__*/getDefaultExportFromCjs(telemetryVersion);
@@ -10799,6 +10799,9 @@ const chatMessageActionMenuProps = (menuProps) => {
10799
10799
 
10800
10800
  // Copyright (c) Microsoft Corporation.
10801
10801
  // Licensed under the MIT License.
10802
+ const linkify = new linkifyIt.LinkifyIt({
10803
+ fuzzyLink: true
10804
+ });
10802
10805
  /** @private */
10803
10806
  const ChatMessageContent = (props) => {
10804
10807
  switch (props.message.contentType) {
@@ -10822,9 +10825,23 @@ const MessageContentAsRichTextHTML = (props) => {
10822
10825
  return React.createElement(MessageContentWithLiveAria, { message: props.message, liveMessage: generateLiveMessage(props), ariaLabel: messageContentAriaText(props), content: processHtmlToReact(props) });
10823
10826
  };
10824
10827
  const MessageContentAsText = (props) => {
10825
- return React.createElement(MessageContentWithLiveAria, { message: props.message, liveMessage: generateLiveMessage(props), ariaLabel: messageContentAriaText(props), className: messageTextContentStyles, content: React.createElement(Linkify, { componentDecorator: (decoratedHref, decoratedText, key) => {
10826
- return React.createElement(react.Link, { target: "_blank", href: decoratedHref, key: key }, decoratedText);
10827
- } }, props.message.content) });
10828
+ var _a;
10829
+ return React.createElement(MessageContentWithLiveAria, { message: props.message, liveMessage: generateLiveMessage(props), ariaLabel: messageContentAriaText(props), className: messageTextContentStyles, content: React.createElement(React.Fragment, null, linkifyMessageContent((_a = props.message.content) !== null && _a !== void 0 ? _a : '')) });
10830
+ };
10831
+ const linkifyMessageContent = (content) => {
10832
+ const matches = linkify.match(content);
10833
+ if (!matches) {
10834
+ return [content];
10835
+ }
10836
+ const contentParts = [];
10837
+ let previousMatchEnd = 0;
10838
+ matches.forEach(match => {
10839
+ contentParts.push(content.slice(previousMatchEnd, match.index));
10840
+ contentParts.push(React.createElement(react.Link, { target: "_blank", href: match.url, key: `${match.index}-${match.lastIndex}` }, match.text));
10841
+ previousMatchEnd = match.lastIndex;
10842
+ });
10843
+ contentParts.push(content.slice(previousMatchEnd));
10844
+ return contentParts;
10828
10845
  };
10829
10846
  const extractContentForAllyMessage = (props) => {
10830
10847
  var _a;
@@ -24333,15 +24350,15 @@ class EventSubscriber {
24333
24350
  this.chatContext.createThreadIfNotExist(event.threadId);
24334
24351
  this.chatContext.setParticipants(event.threadId, participantsToAdd);
24335
24352
  });
24336
- this.fetchLastParticipantMessage(event.threadId, 'participantAdded');
24353
+ this.fetchLastParticipantMessage(event.threadId, 'participantAdded', event.addedOn);
24337
24354
  };
24338
24355
  // This is a temporary fix that no participant message is received for onChatMessageReceived event, which should be handled by JS SDK.
24339
24356
  // Without the temporary fix, there are missing 'participant joined' and 'participant left' system messages in the chat thread.
24340
- this.fetchLastParticipantMessage = (threadId, actionType) => __awaiter$y(this, void 0, void 0, function* () {
24357
+ this.fetchLastParticipantMessage = (threadId, actionType, actionTimestamp) => __awaiter$y(this, void 0, void 0, function* () {
24341
24358
  var _a, e_1, _b, _c;
24342
24359
  try {
24343
24360
  for (var _d = true, _e = __asyncValues$1(this.chatClient.getChatThreadClient(threadId).listMessages({
24344
- startTime: new Date(Date.now() - maxSyncTimeInMs)
24361
+ startTime: new Date(actionTimestamp.getTime() - maxSyncTimeInMs)
24345
24362
  })), _f; _f = yield _e.next(), _a = _f.done, !_a; _d = true) {
24346
24363
  _c = _f.value;
24347
24364
  _d = false;
@@ -24369,7 +24386,7 @@ class EventSubscriber {
24369
24386
  const currentUserId = toFlatCommunicationIdentifier(this.chatContext.getState().userId);
24370
24387
  const wasCurrentUserRemoved = participantIds.find(id => toFlatCommunicationIdentifier(id) === currentUserId);
24371
24388
  if (!wasCurrentUserRemoved) {
24372
- this.fetchLastParticipantMessage(event.threadId, 'participantRemoved');
24389
+ this.fetchLastParticipantMessage(event.threadId, 'participantRemoved', event.removedOn);
24373
24390
  }
24374
24391
  };
24375
24392
  this.onReadReceiptReceived = (event) => {
@@ -24380,9 +24397,10 @@ class EventSubscriber {
24380
24397
  });
24381
24398
  };
24382
24399
  this.onTypingIndicatorReceived = (typingIndicator) => {
24400
+ const receivedTypingIndicator = Object.assign(Object.assign({}, typingIndicator), { receivedOn: new Date() });
24383
24401
  this.chatContext.batch(() => {
24384
24402
  this.chatContext.createThreadIfNotExist(typingIndicator.threadId);
24385
- this.chatContext.addTypingIndicator(typingIndicator.threadId, typingIndicator);
24403
+ this.chatContext.addTypingIndicator(typingIndicator.threadId, receivedTypingIndicator);
24386
24404
  });
24387
24405
  };
24388
24406
  this.onChatThreadCreated = (event) => {