@cometchat/chat-uikit-react-native 5.5.1 → 5.5.3

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 (61) hide show
  1. package/android/build.gradle +35 -89
  2. package/android/gradle.properties +5 -5
  3. package/android/src/main/java/com/reactnativecometchatuikit/CometChatSoundModule.java +5 -1
  4. package/android/src/main/java/com/reactnativecometchatuikit/FileManager.java +52 -0
  5. package/android/src/main/java/com/reactnativecometchatuikit/RichTextEditorView.kt +235 -4
  6. package/ios/FileManager.m +77 -3
  7. package/ios/RichTextEditorView.swift +234 -24
  8. package/package.json +7 -4
  9. package/react-native-cometchat-ui-kit.podspec +5 -19
  10. package/src/CometChatCompactMessageComposer/CometChatCompactMessageComposer.tsx +31 -27
  11. package/src/CometChatConversations/CometChatConversations.tsx +4 -0
  12. package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +35 -28
  13. package/src/CometChatMessageList/CometChatMessageList.tsx +20 -18
  14. package/src/CometChatRichTextEditor/index.tsx +2 -1
  15. package/src/CometChatSearch/CometChatSearch.tsx +10 -5
  16. package/src/calls/CometChatOngoingCall/CometChatOngoingCall.tsx +56 -17
  17. package/src/calls/CometChatOutgoingCall/CometChatOutgoingCall.tsx +12 -9
  18. package/src/extensions/LinkPreview/LinkPreviewBubble.tsx +13 -10
  19. package/src/extensions/LinkPreview/LinkPreviewExtensionDecorator.tsx +34 -27
  20. package/src/extensions/Polls/Polls.tsx +7 -7
  21. package/src/extensions/Polls/PollsBubble.tsx +2 -2
  22. package/src/globals.d.ts +6 -0
  23. package/src/shared/constants/textPatterns.ts +20 -2
  24. package/src/shared/formatters/CometChatMentionsFormatter/CometChatMentionsFormatter.tsx +22 -11
  25. package/src/shared/formatters/CometChatRichTextFormatter/index.tsx +26 -14
  26. package/src/shared/formatters/CometChatUrlsFormatter/index.tsx +8 -0
  27. package/src/shared/formatters/codeElements.ts +21 -0
  28. package/src/shared/helper/types/index.ts +5 -0
  29. package/src/shared/libs/ImageZoom/ReactNativeZoomableView.tsx +4 -4
  30. package/src/shared/libs/ImageZoom/types/index.ts +2 -0
  31. package/src/shared/resources/CometChatSoundManager/sound.js +2 -3
  32. package/src/shared/services/UploadQueueService.ts +7 -0
  33. package/src/shared/utils/CometChatMessageHelper/index.ts +3 -0
  34. package/src/shared/utils/MarkdownUtils.ts +11 -4
  35. package/src/shared/utils/MessageUtils.tsx +7 -5
  36. package/src/shared/utils/groupMemberAddedRows.ts +28 -0
  37. package/src/shared/utils/linkPreviewSelection.ts +109 -0
  38. package/src/shared/utils/mentionTokens.ts +77 -0
  39. package/src/shared/utils/runAfterInteractions.ts +26 -0
  40. package/src/shared/utils/stripRichText.ts +2 -1
  41. package/src/shared/utils/tapGesture.ts +23 -0
  42. package/src/shared/utils/videoThumbnail.ts +74 -0
  43. package/src/shared/views/CometChatAttachmentPreview/CometChatAttachmentTile.tsx +21 -13
  44. package/src/shared/views/CometChatAudioBubble/CometChatAudioBubble.tsx +13 -15
  45. package/src/shared/views/CometChatEmojiKeyboard/CometChatEmojiKeyboard.tsx +1 -1
  46. package/src/shared/views/CometChatFileBubble/CometChatFileBubble.tsx +2 -1
  47. package/src/shared/views/CometChatFilesBubble/CometChatFilesBubble.tsx +2 -1
  48. package/src/shared/views/CometChatImagesBubble/CometChatImagesBubble.tsx +3 -26
  49. package/src/shared/views/CometChatInlineAudioRecorder/useAudioRecorder.ts +4 -2
  50. package/src/shared/views/CometChatList/Header.tsx +1 -1
  51. package/src/shared/views/CometChatMediaRecorder/CometChatAudioPreview/CometChatAudioPreview.tsx +2 -1
  52. package/src/shared/views/CometChatMediaViewer/CometChatMediaViewer.tsx +28 -8
  53. package/src/shared/views/CometChatMessageInput/CometChatMessageInput.tsx +3 -4
  54. package/src/shared/views/CometChatTextBubble/CometChatTextBubble.tsx +36 -4
  55. package/src/shared/views/CometChatVideoBubble/CometChatVideoBubble.tsx +2 -1
  56. package/src/shared/views/CometChatVideosBubble/CometChatVideosBubble.tsx +57 -30
  57. package/src/CometChatMessageList/PERFORMANCE_ARCHITECTURE.md +0 -478
  58. package/src/CometChatMessageList/SEARCH_NAV_PERF_PLAN.md +0 -613
  59. package/src/CometChatMessageList/SEARCH_NAV_SLOWNESS_FINDINGS_AND_FIX.md +0 -313
  60. package/src/shared/CometChatUiKit/CometChatUIKit.changes.md +0 -76
  61. package/src/shared/CometChatUiKit/checkAuthSettings-review.md +0 -211
@@ -1,5 +1,6 @@
1
1
  import { CometChat } from "@cometchat/chat-sdk-react-native";
2
2
  import React, { JSX } from "react";
3
+ import { View } from "react-native";
3
4
  import { AdditionalParams, MessageBubbleAlignmentType } from "../../shared/base/Types";
4
5
  import { DataSource, DataSourceDecorator } from "../../shared/framework";
5
6
  import { BubbleStyles, CometChatTheme } from "../../theme/type";
@@ -8,6 +9,7 @@ import { getExtensionData } from "../ExtensionModerator";
8
9
  import { LinkPreviewBubble } from "./LinkPreviewBubble";
9
10
  import { CometChatUIKit } from "../../shared";
10
11
  import { DeepPartial } from "../../shared/helper/types";
12
+ import { previewImage, selectLinkPreviews, trimStrayParens } from "../../shared/utils/linkPreviewSelection";
11
13
 
12
14
  /**
13
15
  * Extension decorator for rendering link preview messages.
@@ -60,35 +62,40 @@ export class LinkPreviewExtensionDecorator extends DataSourceDecorator {
60
62
  ): JSX.Element {
61
63
  const loggedInUser = CometChatUIKit.loggedInUser;
62
64
  const linkData = getExtensionData(message, ExtensionConstants.linkPreview);
65
+ // One card per link the text goes TO (not every address the server scanned) — like React UI Kit.
66
+ const previews = selectLinkPreviews(linkData?.links, message.getText());
63
67
 
64
- if (!linkData || linkData.links.length === 0) {
68
+ if (previews.length === 0) {
65
69
  return super.getTextMessageContentView(message, alignment, theme, additionalParams);
66
- } else {
67
- const _style: DeepPartial<BubbleStyles["linkPreviewBubbleStyles"]> =
68
- message.getSender()?.getUid() === loggedInUser?.getUid()
69
- ? theme.messageListStyles?.outgoingMessageBubbleStyles?.linkPreviewBubbleStyles
70
- : theme.messageListStyles?.incomingMessageBubbleStyles?.linkPreviewBubbleStyles;
71
- const { image, favicon, title, url, description } = linkData.links[0];
72
- const img = image.length === 0 || image === favicon ? "" : image;
73
- return (
74
- <LinkPreviewBubble
75
- link={url}
76
- description={description}
77
- image={img}
78
- favicon={favicon}
79
- ChildView={() =>
80
- super.getTextMessageBubble(
81
- (message as CometChat.TextMessage).getText(),
82
- message as CometChat.TextMessage,
83
- alignment,
84
- theme,
85
- additionalParams
86
- )
87
- }
88
- title={title}
89
- style={_style as CometChatTheme["linkPreviewBubbleStyles"]}
90
- />
91
- );
92
70
  }
71
+ const _style: DeepPartial<BubbleStyles["linkPreviewBubbleStyles"]> =
72
+ message.getSender()?.getUid() === loggedInUser?.getUid()
73
+ ? theme.messageListStyles?.outgoingMessageBubbleStyles?.linkPreviewBubbleStyles
74
+ : theme.messageListStyles?.incomingMessageBubbleStyles?.linkPreviewBubbleStyles;
75
+ const textView = () =>
76
+ super.getTextMessageBubble(
77
+ (message as CometChat.TextMessage).getText(),
78
+ message as CometChat.TextMessage,
79
+ alignment,
80
+ theme,
81
+ additionalParams
82
+ );
83
+ // Cards stack in link order with a small gap; the message text sits under the last one.
84
+ return (
85
+ <View style={{ gap: theme.spacing.padding.p2 }}>
86
+ {previews.map(({ image, favicon, title, url, description }, i) => (
87
+ <LinkPreviewBubble
88
+ key={`${i}-${url}`}
89
+ link={trimStrayParens(url)}
90
+ description={description}
91
+ image={previewImage(image, favicon)}
92
+ favicon={favicon}
93
+ ChildView={i === previews.length - 1 ? textView : undefined}
94
+ title={title}
95
+ style={_style as CometChatTheme["linkPreviewBubbleStyles"]}
96
+ />
97
+ ))}
98
+ </View>
99
+ );
93
100
  }
94
101
  }
@@ -2,7 +2,6 @@ import React, { useEffect, useLayoutEffect, useRef, useState } from "react";
2
2
  import {
3
3
  ActivityIndicator,
4
4
  FlatList,
5
- InteractionManager,
6
5
  Keyboard,
7
6
  KeyboardAvoidingView,
8
7
  NativeModules,
@@ -21,6 +20,7 @@ import { useCometChatTranslation } from "../../shared/resources/CometChatLocaliz
21
20
  import { SafeAreaView, useSafeAreaInsets } from "react-native-safe-area-context";
22
21
  import { CometChatMessageEvents } from "../../shared/events/CometChatMessageEvents";
23
22
  import { messageStatus } from "../../shared/utils/CometChatMessageHelper";
23
+ import { runAfterInteractions } from "../../shared/utils/runAfterInteractions";
24
24
 
25
25
  const { CommonUtil } = NativeModules;
26
26
 
@@ -147,7 +147,7 @@ export const CometChatCreatePoll = (props: CometChatCreatePollInterface) => {
147
147
  const loggedInUser = useRef<CometChat.User | null>(null);
148
148
  const theme = useTheme();
149
149
  const { t } = useCometChatTranslation();
150
- const answerRefs = useRef<(TextInput | null)[]>([]);
150
+ const answerRefs = useRef<(React.ComponentRef<typeof TextInput> | null)[]>([]);
151
151
  const [lastRemovedIndex, setLastRemovedIndex] = useState<number | null>(null);
152
152
  const [newlyAddedIndex, setNewlyAddedIndex] = useState<number | null>(null);
153
153
  const flatListRef = useRef<FlatList>(null);
@@ -425,7 +425,7 @@ export const CometChatCreatePoll = (props: CometChatCreatePollInterface) => {
425
425
 
426
426
  useEffect(() => {
427
427
  if (answers.length) {
428
- InteractionManager.runAfterInteractions(() => {
428
+ runAfterInteractions(() => {
429
429
  flatListRef.current?.scrollToEnd({ animated: true });
430
430
  });
431
431
  }
@@ -588,10 +588,10 @@ export const CometChatCreatePoll = (props: CometChatCreatePollInterface) => {
588
588
  style={{
589
589
  paddingHorizontal: 20,
590
590
  backgroundColor: theme.color.background1,
591
- paddingBottom: Platform.select({
592
- ios: Math.max(insets.bottom, 10),
593
- android: 10,
594
- }),
591
+ // Both platforms: an edge-to-edge Android window (RN 0.86+ Modals, targetSdk 35+)
592
+ // draws under the navigation bar, so the fixed 10 left Create hidden behind it.
593
+ // Non-edge-to-edge Android reports a 0 inset, so this stays 10 there.
594
+ paddingBottom: Math.max(insets.bottom, 10),
595
595
  }}
596
596
  >
597
597
  {error && <ErrorView />}
@@ -227,10 +227,10 @@ export const PollsBubble = (props: PollsBubbleInterface) => {
227
227
  const secondavatarStyle = voteravatarStyle;
228
228
  const thirdavatarStyle = voteravatarStyle;
229
229
  if (secondavatarStyle && secondavatarStyle.containerStyle) {
230
- secondavatarStyle.containerStyle.marginLeft = -10;
230
+ Object.assign(secondavatarStyle.containerStyle, { marginLeft: -10 });
231
231
  }
232
232
  if (thirdavatarStyle && thirdavatarStyle.containerStyle) {
233
- thirdavatarStyle.containerStyle.marginLeft = -10;
233
+ Object.assign(thirdavatarStyle.containerStyle, { marginLeft: -10 });
234
234
  }
235
235
  // Ensure value is a string for rendering
236
236
  let optionText = typeof value === 'string' ? value : (value && value.value ? value.value : String(value));
@@ -0,0 +1,6 @@
1
+ /**
2
+ * `__DEV__` is injected by the React Native runtime. React Native's own typings declare it,
3
+ * but only when `react-native` resolves to its generated typings; declare it here so the
4
+ * package's own type-check does not depend on how `react-native` gets resolved.
5
+ */
6
+ declare const __DEV__: boolean;
@@ -16,11 +16,29 @@ export const wordBoundary = {
16
16
  export const emailPattern =
17
17
  wordBoundary.start + `[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,6}` + wordBoundary.end;
18
18
 
19
+ // A URL character, excluding parentheses — those only count in balanced pairs (below).
20
+ const urlChar = `[-\\w;/?:@&=+$\\|\\_.!~*\\|'\\[\\]%#,☺]`;
21
+ const urlParens = `\\(${urlChar}*\\)`;
22
+ // A URL path: ends on a word char, `/`, `#`, or a balanced `(…)`. A lone `)` could never be the
23
+ // last character, so https://en.wikipedia.org/wiki/Mercury_(planet) linked without its `)` and
24
+ // opened a page that does not exist — while "(see https://example.com/page)" must still leave
25
+ // the sentence's own `)` outside the link. Balanced pairs satisfy both.
26
+ const urlPath = `(?:${urlChar}|${urlParens})*(?:[\\w/#]|${urlParens})`;
27
+
19
28
  export const urlPattern =
20
- `((https?://|ftp://|www\\.|pic\\.)[-\\w;/?:@&=+$\\|\\_.!~*\\|'()\\[\\]%#,☺]+[\\w/#](\\(\\))?` +
21
- `|[a-zA-Z][a-zA-Z0-9]*[-a-zA-Z0-9]*(?:\\.[a-zA-Z0-9][-a-zA-Z0-9]*)*\\.[a-zA-Z]{2,}(?:[:/][-\\w;/?:@&=+$\\|\\_.!~*\\|'()\\[\\]%#,☺]*[\\w/#](\\(\\))?)?)` +
29
+ `((https?://|ftp://|www\\.|pic\\.)${urlPath}` +
30
+ `|[a-zA-Z][a-zA-Z0-9]*[-a-zA-Z0-9]*(?:\\.[a-zA-Z0-9][-a-zA-Z0-9]*)*\\.[a-zA-Z]{2,}(?:[:/]${urlPath})?)` +
22
31
  wordBoundary.end;
23
32
 
33
+ /**
34
+ * A markdown link `[label](address)`. Group 1 is the label, group 2 the address.
35
+ *
36
+ * The address may contain one level of balanced parentheses, so a Wikipedia-style
37
+ * `[Mercury](https://en.wikipedia.org/wiki/Mercury_(planet))` keeps its `(planet)` and only the
38
+ * final `)` closes the link. The old `[^)]+` stopped at the first `)`, opening `…Mercury_(planet`.
39
+ */
40
+ export const markdownLinkPattern = `\\[([^\\]]+)\\]\\(((?:[^()]|\\([^()]*\\))+)\\)`;
41
+
24
42
  export const phoneNumPattern =
25
43
  wordBoundary.start +
26
44
  `(?:\\+?(\\d{1,3}))?([-. (]*(\\d{3})[-. )]*)?((\\d{3})[-. ]*(\\d{2,4})(?:[-.x ]*(\\d+))?)` +
@@ -12,6 +12,7 @@ import { SuggestionItem } from "../../views/CometChatSuggestionList";
12
12
  import { CometChatTextFormatter } from "../CometChatTextFormatter";
13
13
  import { CometChatTheme } from "../../../theme/type";
14
14
  import { deepMerge } from "../../helper/helperFunctions";
15
+ import { unescapeTypedMentionTokensInTree } from "../../utils/mentionTokens";
15
16
  import { getCometChatTranslation } from "../../resources/CometChatLocalizeNew/LocalizationManager";
16
17
 
17
18
  const t = getCometChatTranslation();
@@ -544,7 +545,8 @@ export class CometChatMentionsFormatter extends CometChatTextFormatter {
544
545
  return "";
545
546
  }
546
547
  let formattedText = this.addMentionsView(inputText, textStyle);
547
- return formattedText;
548
+ // Only now, with every real mention resolved, may escaped typed text read as `<@all:…>`.
549
+ return unescapeTypedMentionTokensInTree(formattedText);
548
550
  }
549
551
 
550
552
  temp!: Function;
@@ -604,8 +606,10 @@ export class CometChatMentionsFormatter extends CometChatTextFormatter {
604
606
  segments.push(inputText.slice(lastIndex, match.index));
605
607
  }
606
608
 
607
- // Add UID segment
608
- segments.push(match[1]);
609
+ // Add the whole token; it is resolved to its id below. Pushing only the id rendered an
610
+ // unresolved `<@uid:someone>` as just "someone", and let plain text that happened to
611
+ // equal a mentioned uid become a chip.
612
+ segments.push(match[0]);
609
613
 
610
614
  // Update lastIndex
611
615
  lastIndex = match.index + match[0].length;
@@ -618,12 +622,19 @@ export class CometChatMentionsFormatter extends CometChatTextFormatter {
618
622
 
619
623
  // Now create an array of JSX elements from the segments
620
624
  const elements = segments.map((segment, index) => {
621
- // Check if segment is a UID
622
- if (userRegistry.hasOwnProperty(segment)) {
625
+ // A token segment resolves to its id; anything else is plain text.
626
+ const token = /^<@(?:uid|all):(.*?)>$/.exec(segment);
627
+ const id = token ? token[1] : undefined;
628
+ // `<@all:x>` resolves only to an @all alias and `<@uid:x>` only to a user.
629
+ if (
630
+ id !== undefined &&
631
+ userRegistry.hasOwnProperty(id) &&
632
+ aliasIdSet.has(id) === segment.startsWith("<@all:")
633
+ ) {
623
634
  let _loggedInUser = this.loggedInUser || CometChatUIKit.loggedInUser;
624
635
 
625
- const isAlias = aliasIdSet.has(segment);
626
- const isSelf = isAlias || _loggedInUser?.getUid() === segment;
636
+ const isAlias = aliasIdSet.has(id);
637
+ const isSelf = isAlias || _loggedInUser?.getUid() === id;
627
638
 
628
639
  const isOutgoing =
629
640
  this.messageObject?.getSender()?.getUid() === _loggedInUser?.getUid();
@@ -636,7 +647,7 @@ export class CometChatMentionsFormatter extends CometChatTextFormatter {
636
647
 
637
648
  let onPressProp =
638
649
  this.temp && !isAlias
639
- ? { onPress: (event: any) => this.onMentionClick(event, segment) }
650
+ ? { onPress: (event: any) => this.onMentionClick(event, id) }
640
651
  : {}; // still suppress click for alias
641
652
 
642
653
  const mentionContainerStyle = backgroundColor ? {
@@ -648,20 +659,20 @@ export class CometChatMentionsFormatter extends CometChatTextFormatter {
648
659
  if (this.target === MentionsTargetElement.textbubble) {
649
660
  return (
650
661
  <Text suppressHighlighting={true} key={index} {...onPressProp} style={[textStyle, mentionContainerStyle]}>
651
- {userRegistry[segment]}
662
+ {userRegistry[id]}
652
663
  </Text>
653
664
  );
654
665
  }
655
666
 
656
667
  return (
657
668
  <Text suppressHighlighting={true} key={index} {...onPressProp} style={[textStyle, mentionContainerStyle]}>
658
- {userRegistry[segment]}
669
+ {userRegistry[id]}
659
670
  </Text>
660
671
  );
661
672
  } else {
662
673
  // Handle group-wide alias formatting if present
663
674
  const aliasItem = this.SuggestionItems.find(
664
- (it) => it.underlyingText === `<@all:${segment}>`
675
+ (it) => token !== null && it.underlyingText === segment
665
676
  );
666
677
  if (aliasItem) {
667
678
  const { textStyle: styleResolved, backgroundColor } = this.resolveStyle(true);
@@ -3,8 +3,9 @@ import React, { JSX } from "react";
3
3
  import { Text, TextStyle, ViewStyle, Platform, Linking, View } from "react-native";
4
4
  import { CometChatTextFormatter } from "../CometChatTextFormatter";
5
5
  import { COLOR_OPEN_TAG, HEX_COLOR_REGEX, findColorTag, stripColorTags } from "../richTextWireFormat";
6
+ import { markCode } from "../codeElements";
6
7
  import { isTextElement, isViewElement } from "../../utils/elementType";
7
- import { urlPattern, emailPattern } from "../../constants/textPatterns";
8
+ import { urlPattern, emailPattern, markdownLinkPattern } from "../../constants/textPatterns";
8
9
 
9
10
  /**
10
11
  * Style configuration for rich text formatting
@@ -30,7 +31,9 @@ export interface RichTextStyle {
30
31
  // Pre-compiled regex patterns — avoids recompilation on every call
31
32
  const ORDERED_LIST_REGEX = /^(\d+)\.(?:\s(.*))?$/;
32
33
  const ORDERED_LIST_DETECT_REGEX = /^\d+\.(\s|$)/;
33
- const LINK_REGEX = /\[([^\]]+)\]\(([^)]+)\)/;
34
+ const LINK_REGEX = new RegExp(markdownLinkPattern);
35
+ // Global form, for stashing each half of every markdown link before URLs are stashed.
36
+ const LINK_REGEX_GLOBAL = new RegExp(markdownLinkPattern, "g");
34
37
  const URL_PROTOCOL_REGEX = /^(https?|mailto|tel):/i;
35
38
  // Patterns for detecting list items inside blockquote content (ENG-31998)
36
39
  const QUOTE_BULLET_REGEX = /^- (.*)$/;
@@ -289,7 +292,7 @@ export class CometChatRichTextFormatter extends CometChatTextFormatter {
289
292
  style here — but it must never reach the reader as literal markup either.
290
293
  Messages sent before the serializer fix still carry the token inside the
291
294
  fence, so strip rather than render (ENG-38253). */}
292
- <Text style={[this.style.codeBlockStyle]}>{stripColorTags(content)}</Text>
295
+ {markCode(<Text style={[this.style.codeBlockStyle]}>{stripColorTags(content)}</Text>)}
293
296
  </View>
294
297
  );
295
298
  lineIndex++;
@@ -333,13 +336,15 @@ export class CometChatRichTextFormatter extends CometChatTextFormatter {
333
336
  this.style.codeBlockContainerStyle,
334
337
  ]}
335
338
  >
336
- <Text
337
- style={[
338
- this.style.codeBlockStyle,
339
- ]}
340
- >
341
- {stripColorTags(codeLines.join("\n"))}
342
- </Text>
339
+ {markCode(
340
+ <Text
341
+ style={[
342
+ this.style.codeBlockStyle,
343
+ ]}
344
+ >
345
+ {stripColorTags(codeLines.join("\n"))}
346
+ </Text>
347
+ )}
343
348
  </View>
344
349
  );
345
350
  if (lineIndex < lines.length) {
@@ -580,6 +585,13 @@ export class CometChatRichTextFormatter extends CometChatTextFormatter {
580
585
  };
581
586
  let sanitized = text.replace(MENTION_PATTERN_REGEX, stash);
582
587
  try {
588
+ // Markdown links first, one half at a time. The url pattern accepts `[ ] ( )`, so on a
589
+ // link whose label is itself an address — `[https://x/p](https://x/p)`, what a pasted or
590
+ // copied link is stored as — it matched `https://x/p](https://x/p` as ONE url. That hid
591
+ // the `](`, findLink never saw a link, and the bubble showed the raw markdown.
592
+ sanitized = sanitized.replace(LINK_REGEX_GLOBAL, (_m, label: string, url: string) =>
593
+ `[${label.replace(URL_PATTERN_REGEX, stash)}](${stash(url)})`
594
+ );
583
595
  sanitized = sanitized.replace(EMAIL_PATTERN_REGEX, stash);
584
596
  sanitized = sanitized.replace(URL_PATTERN_REGEX, stash);
585
597
  } catch {
@@ -644,19 +656,19 @@ export class CometChatRichTextFormatter extends CometChatTextFormatter {
644
656
  // Use a single Text element (not View) so inline code stays on the
645
657
  // same text baseline as surrounding content (mentions, plain text).
646
658
  // Text supports backgroundColor, borderRadius, and padding in RN.
647
- elements.push(
659
+ elements.push(markCode(
648
660
  <Text key={`fmt-${keyCounter++}`} style={[this.style.inlineCodeContainerStyle, this.style.inlineCodeStyle]}>{innerContent}</Text>
649
- );
661
+ ));
650
662
  } else if (match.type === "codeBlock") {
651
663
  // Inline ```text``` — render identically to single-backtick inline code
652
664
  // (compact pill with background, no block-level padding).
653
665
  // Block-level code block rendering with View container is handled in renderMarkdown.
654
- elements.push(
666
+ elements.push(markCode(
655
667
  <Text
656
668
  key={`fmt-${keyCounter++}`}
657
669
  style={[this.style.inlineCodeContainerStyle, this.style.inlineCodeStyle]}
658
670
  >{restoredContent}</Text>
659
- );
671
+ ));
660
672
  } else if (match.type === "textColor" && match.color) {
661
673
  // Re-validate at render time: the hex reaching here came off the wire, and an
662
674
  // unparseable value must fall back to the base style rather than reach RN.
@@ -3,6 +3,7 @@ import React, { JSX } from "react";
3
3
  import { ColorValue, Linking, Text, TextStyle } from "react-native";
4
4
  import { emailPattern, phoneNumPattern, urlPattern } from "../../constants/UIKitConstants";
5
5
  import { CometChatTextFormatter } from "../CometChatTextFormatter";
6
+ import { isCode } from "../codeElements";
6
7
 
7
8
  export class CometChatUrlsFormatter extends CometChatTextFormatter {
8
9
  protected style: {
@@ -117,6 +118,13 @@ export class CometChatUrlsFormatter extends CometChatTextFormatter {
117
118
  return <Text>{str}</Text>;
118
119
  } else if (React.isValidElement(str)) {
119
120
  // str is a React element
121
+ if ((str as React.ReactElement<any>).props.onPress || isCode(str)) {
122
+ // Already a link (a markdown `[label](url)` from the rich-text formatter). Linkifying its
123
+ // label again nests a second link inside it, and the inner one wins the tap: the label
124
+ // of `[www.google.com](https://drive…)` opened google.com instead of the Drive address.
125
+ // Code is literal: an address inside `backticks` stays text.
126
+ return str;
127
+ }
120
128
  if ((str as React.ReactElement<any>).props.children) {
121
129
  // If the React element have children, we map over these children
122
130
  // and call addMentionsSpan recursively for each child.
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Elements the rich-text formatter rendered as code (inline code and code blocks).
3
+ *
4
+ * Code is literal: `` `https://google.com` `` must stay monospace text, but the urls formatter,
5
+ * which runs after the rich-text formatter, walked into the code element and made the address
6
+ * a link anyway. The rich-text formatter marks what it renders as code; the urls formatter
7
+ * leaves marked elements alone.
8
+ *
9
+ * The mark is a prop, not a registry: it survives the `cloneElement` calls later formatters make,
10
+ * and it cannot be split across two copies of this module (a symlinked kit can be bundled twice).
11
+ * React Native only forwards a host component's known attributes, so the prop never reaches native.
12
+ */
13
+ import React from "react";
14
+
15
+ const CODE_PROP = "ccRichTextCode";
16
+
17
+ export const markCode = (element: React.ReactElement<any>): React.ReactElement<any> =>
18
+ React.cloneElement(element, { [CODE_PROP]: true });
19
+
20
+ export const isCode = (element: unknown): boolean =>
21
+ React.isValidElement(element) && (element.props as any)?.[CODE_PROP] === true;
@@ -5,6 +5,7 @@ import {
5
5
  ImageSourcePropType,
6
6
  ImageStyle,
7
7
  ImageURISource,
8
+ StyleProp,
8
9
  TextStyle,
9
10
  ViewStyle,
10
11
  } from "react-native";
@@ -38,6 +39,10 @@ type DoNotPartial =
38
39
  | ViewStyle
39
40
  | ImageURISource
40
41
  | ImageStyle
42
+ // StyleProp is a recursive alias (ReadonlyArray<StyleProp<T>>); mapping over it never terminates
43
+ | StyleProp<TextStyle>
44
+ | StyleProp<ViewStyle>
45
+ | StyleProp<ImageStyle>
41
46
  | ColorValue
42
47
  | DimensionValue
43
48
  | ImageSourcePropType
@@ -3,7 +3,6 @@ import {
3
3
  Animated,
4
4
  Easing,
5
5
  GestureResponderEvent,
6
- InteractionManager,
7
6
  PanResponder,
8
7
  PanResponderGestureState,
9
8
  StyleSheet,
@@ -18,6 +17,7 @@ import {
18
17
  ZoomableViewEvent,
19
18
  } from './types';
20
19
  import { applyPanBoundariesToOffset, calcGestureTouchDistance, calcNewScaledOffsetForZoomCentering, getBoundaryCrossedAnim, getPanMomentumDecayAnim, getZoomToAnimation } from './helper';
20
+ import { runAfterInteractions } from "../../utils/runAfterInteractions";
21
21
 
22
22
 
23
23
  const initialState = {
@@ -54,7 +54,7 @@ class ReactNativeZoomableView extends Component<
54
54
  ReactNativeZoomableViewProps,
55
55
  ReactNativeZoomableViewState
56
56
  > {
57
- zoomSubjectWrapperRef: RefObject<View | null>;
57
+ zoomSubjectWrapperRef: RefObject<React.ComponentRef<typeof View> | null>;
58
58
  gestureHandlers: any;
59
59
  doubleTapFirstTapReleaseTimestamp!: number | any;
60
60
 
@@ -152,7 +152,7 @@ class ReactNativeZoomableView extends Component<
152
152
  this.props.onMoveShouldSetPanResponderCapture?.(evt, gestureState),
153
153
  });
154
154
 
155
- this.zoomSubjectWrapperRef = createRef<View>();
155
+ this.zoomSubjectWrapperRef = createRef<React.ComponentRef<typeof View>>();
156
156
 
157
157
  if (this.props.zoomAnimatedValue)
158
158
  this.zoomAnim = this.props.zoomAnimatedValue;
@@ -332,7 +332,7 @@ class ReactNativeZoomableView extends Component<
332
332
  */
333
333
  private grabZoomSubjectOriginalMeasurements = () => {
334
334
  // make sure we measure after animations are complete
335
- InteractionManager.runAfterInteractions(() => {
335
+ runAfterInteractions(() => {
336
336
  // this setTimeout is here to fix a weird issue on iOS where the measurements are all `0`
337
337
  // when navigating back (react-navigation stack) from another view
338
338
  // while closing the keyboard at the same time
@@ -1,3 +1,4 @@
1
+ import type { ReactNode } from "react";
1
2
  import { Animated, GestureResponderEvent, PanResponderGestureState, ViewProps } from "react-native";
2
3
 
3
4
  export enum SwipeDirection {
@@ -18,6 +19,7 @@ export interface ZoomableViewEvent {
18
19
  }
19
20
 
20
21
  export interface ReactNativeZoomableViewProps extends ViewProps {
22
+ children?: ReactNode;
21
23
  // options
22
24
  zoomEnabled?: boolean;
23
25
  panEnabled?: boolean;
@@ -1,8 +1,7 @@
1
- import { NativeModules, NativeEventEmitter } from 'react-native';
1
+ import { Image, NativeModules, NativeEventEmitter } from 'react-native';
2
2
  const {CometChatSoundModule} = NativeModules ;
3
3
  var IsAndroid = CometChatSoundModule.IsAndroid;
4
4
  var IsWindows = CometChatSoundModule.IsWindows;
5
- import resolveAssetSource from "react-native/Libraries/Image/resolveAssetSource";
6
5
  var eventEmitter = new NativeEventEmitter(CometChatSoundModule);
7
6
 
8
7
  var nextKey = 0;
@@ -36,7 +35,7 @@ function setAndroidVolumes(sound) {
36
35
 
37
36
  class Sound {
38
37
  constructor(filename, basePath, onError, options) {
39
- var asset = resolveAssetSource(filename);
38
+ var asset = Image.resolveAssetSource(filename);
40
39
  if (asset) {
41
40
  this._filename = asset.uri;
42
41
  onError = basePath;
@@ -1,5 +1,6 @@
1
1
  import { CometChat } from '@cometchat/chat-sdk-react-native';
2
2
  import { SelectedAttachment } from '../modals/SelectedAttachment';
3
+ import { linkUploadedVideo } from '../utils/videoThumbnail';
3
4
 
4
5
  type CometChatException = InstanceType<typeof CometChat.CometChatException>;
5
6
 
@@ -52,6 +53,8 @@ export class UploadQueueService {
52
53
  private request: CometChat.UploadFileRequest | null = null;
53
54
  // Successes only — the set the send button reads. Keyed by tile id (== SDK fileId).
54
55
  private completed = new Map<string, CometChat.Attachment>();
56
+ // Local uri of each enqueued VIDEO, so its upload can be linked to a local thumbnail.
57
+ private localVideoUris = new Map<string, string>();
55
58
 
56
59
  // Kept for signature compatibility; the request API no longer exposes a presign buffer knob.
57
60
  constructor(callbacks: UploadQueueCallbacks, _opts?: { presignBufferMs?: number }) {
@@ -63,6 +66,7 @@ export class UploadQueueService {
63
66
  },
64
67
  onFileUploaded: (fileId: string, att: CometChat.Attachment) => {
65
68
  this.completed.set(fileId, att);
69
+ linkUploadedVideo(att?.getUrl?.(), this.localVideoUris.get(fileId));
66
70
  this.callbacks.onFileComplete(fileId, att);
67
71
  },
68
72
  onFileFailure: (fileId: string, error: CometChatException) => {
@@ -94,6 +98,7 @@ export class UploadQueueService {
94
98
  */
95
99
  enqueue(attachment: SelectedAttachment, target?: { receiver?: string; receiverType?: string }): void {
96
100
  const { fileId, file } = attachment;
101
+ if (file.type?.startsWith('video/')) this.localVideoUris.set(fileId, file.uri);
97
102
  if (!this.request) {
98
103
  this.request = CometChat.createUploadFileRequest(target?.receiver ?? '', target?.receiverType ?? '');
99
104
  this.request.setConcurrency(UPLOAD_CONCURRENCY);
@@ -111,6 +116,7 @@ export class UploadQueueService {
111
116
  // Aborts an in-flight upload or drops an already-uploaded file — either way its slot frees.
112
117
  this.request?.removeAttachment(tileId);
113
118
  this.completed.delete(tileId);
119
+ this.localVideoUris.delete(tileId);
114
120
  }
115
121
 
116
122
  retry(tileId: string, file: SelectedAttachment): void {
@@ -127,6 +133,7 @@ export class UploadQueueService {
127
133
  this.request?.clearAll();
128
134
  this.request = null;
129
135
  this.completed.clear();
136
+ this.localVideoUris.clear();
130
137
  }
131
138
 
132
139
  get completedAttachments(): CometChat.Attachment[] {
@@ -48,6 +48,9 @@ export const getUnixTimestampInMilliseconds = () => {
48
48
  return Math.round(+new Date());
49
49
  };
50
50
 
51
+ /** A muid that stays unique for messages created in the same second (or millisecond). */
52
+ export const uniqueMuid = () => `${getUnixTimestampInMilliseconds()}${ID()}`;
53
+
51
54
  export const formatBytes = (bytes: number, decimals = 2) => {
52
55
  if (bytes === 0) return "0 Bytes";
53
56
 
@@ -2,7 +2,7 @@
2
2
  * Utility functions for markdown text processing.
3
3
  */
4
4
  import { stripColorTags } from "../formatters/richTextWireFormat";
5
- import { urlPattern, emailPattern } from "../constants/textPatterns";
5
+ import { urlPattern, emailPattern, markdownLinkPattern } from "../constants/textPatterns";
6
6
 
7
7
  /**
8
8
  * Strips markdown syntax characters from text, returning clean readable content.
@@ -39,9 +39,16 @@ export function stripMarkdown(text: string, keepColorTags = false): string {
39
39
  protectedUrls.push(match);
40
40
  return `\x00U${protectedUrls.length - 1}\x00`;
41
41
  };
42
- // Emails first — the url pattern matches only an address's domain, leaving the local
42
+ // Markdown links first, each half on its own — see CometChatRichTextFormatter. The url
43
+ // pattern accepts `[ ] ( )`, so `[https://x/p](https://x/p)` was stashed as ONE url and
44
+ // step 1.5 never saw a link: the conversation row showed the raw markdown.
45
+ const urlRegex = new RegExp(urlPattern, "gi");
46
+ staged = text.replace(new RegExp(markdownLinkPattern, "g"), (_m, label: string, url: string) =>
47
+ `[${label.replace(urlRegex, keep)}](${keep(url)})`
48
+ );
49
+ // Emails next — the url pattern matches only an address's domain, leaving the local
43
50
  // part's underscores exposed to the markdown rules below.
44
- staged = text.replace(new RegExp(emailPattern, "gi"), keep);
51
+ staged = staged.replace(new RegExp(emailPattern, "gi"), keep);
45
52
  staged = staged.replace(new RegExp(urlPattern, "gi"), keep);
46
53
  } catch {
47
54
  // A bad pattern must not cost the caller their text; fall back to stripping unprotected.
@@ -58,7 +65,7 @@ export function stripMarkdown(text: string, keepColorTags = false): string {
58
65
  });
59
66
 
60
67
  // 1.5. Convert markdown links [text](url) → text
61
- result = result.replace(/\[([^\]]+)\]\([^)]+\)/g, '$1');
68
+ result = result.replace(new RegExp(markdownLinkPattern, "g"), '$1');
62
69
 
63
70
  // 2. Remove inline code backticks (normal and escaped)
64
71
  result = result.replace(/\\`([^`]*?)\\`/g, '$1'); // escaped \`code\`
@@ -24,6 +24,7 @@ import { useCometChatTranslation } from "../resources/CometChatLocalizeNew";
24
24
  import { getCometChatTranslation } from "../resources/CometChatLocalizeNew/LocalizationManager";
25
25
  import { useTheme } from "../../theme";
26
26
  import { isPinned, isSaved } from "./PinSaveHelper";
27
+ import { unescapeTypedMentionTokensInTree } from "./mentionTokens";
27
28
 
28
29
  /** Module-scope translator — getStatusInfoView is a plain function, not a component. */
29
30
  const translate = getCometChatTranslation();
@@ -75,9 +76,9 @@ const getOverridenBubbleStyles = (theme: CometChatTheme) => {
75
76
  * copies of this map are a standing hazard.
76
77
  */
77
78
  const fileIncoming = deepMerge(incomingBubbleStyles, incomingBubbleStyles.fileBubbleStyles ?? {});
78
- if (fileIncoming.containerStyle) fileIncoming.containerStyle.height = undefined;
79
+ if (fileIncoming.containerStyle) Object.assign(fileIncoming.containerStyle, { height: undefined });
79
80
  const fileOutgoing = deepMerge(outgoingBubbleStyles, outgoingBubbleStyles.fileBubbleStyles ?? {});
80
- if (fileOutgoing.containerStyle) fileOutgoing.containerStyle.height = undefined;
81
+ if (fileOutgoing.containerStyle) Object.assign(fileOutgoing.containerStyle, { height: undefined });
81
82
 
82
83
  styleCache.set(MessageTypeConstants.file, {
83
84
  incoming: fileIncoming,
@@ -88,12 +89,12 @@ const getOverridenBubbleStyles = (theme: CometChatTheme) => {
88
89
  incomingBubbleStyles,
89
90
  incomingBubbleStyles.audioBubbleStyles ?? {}
90
91
  );
91
- if (audioIncoming.containerStyle) audioIncoming.containerStyle.height = undefined;
92
+ if (audioIncoming.containerStyle) Object.assign(audioIncoming.containerStyle, { height: undefined });
92
93
  const audioOutgoing = deepMerge(
93
94
  outgoingBubbleStyles,
94
95
  outgoingBubbleStyles.audioBubbleStyles ?? {}
95
96
  );
96
- if (audioOutgoing.containerStyle) audioOutgoing.containerStyle.height = undefined;
97
+ if (audioOutgoing.containerStyle) Object.assign(audioOutgoing.containerStyle, { height: undefined });
97
98
 
98
99
  styleCache.set(MessageTypeConstants.audio, {
99
100
  incoming: audioIncoming,
@@ -480,7 +481,8 @@ export const applyMentionsFormatting = (
480
481
  ): string | JSX.Element => {
481
482
  const containsAllAlias = /<@all:(.*?)>/.test(rawText);
482
483
  if (!message.getMentionedUsers?.().length && !containsAllAlias) {
483
- return content;
484
+ // No real mentions to resolve, but typed token text (stored escaped) still reads as typed.
485
+ return unescapeTypedMentionTokensInTree(content);
484
486
  }
485
487
 
486
488
  try {