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

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 (66) hide show
  1. package/android/.gradle/7.4/checksums/checksums.lock +0 -0
  2. package/android/.gradle/7.4/fileChanges/last-build.bin +0 -0
  3. package/android/.gradle/7.4/fileHashes/fileHashes.lock +0 -0
  4. package/android/.gradle/7.4/gc.properties +0 -0
  5. package/android/.gradle/vcs-1/gc.properties +0 -0
  6. package/android/build.gradle +23 -89
  7. package/android/gradle.properties +5 -5
  8. package/android/src/main/java/com/reactnativecometchatuikit/CometChatSoundModule.java +5 -1
  9. package/android/src/main/java/com/reactnativecometchatuikit/FileManager.java +52 -0
  10. package/android/src/main/java/com/reactnativecometchatuikit/RichTextEditorView.kt +17 -4
  11. package/ios/FileManager.m +77 -3
  12. package/ios/RichTextEditorView.swift +9 -1
  13. package/package.json +4 -4
  14. package/react-native-cometchat-ui-kit.podspec +5 -19
  15. package/src/CometChatCompactMessageComposer/CometChatCompactMessageComposer.tsx +31 -27
  16. package/src/CometChatConversations/CometChatConversations.tsx +4 -0
  17. package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +35 -28
  18. package/src/CometChatMessageList/CometChatMessageList.tsx +20 -18
  19. package/src/CometChatRichTextEditor/index.tsx +2 -1
  20. package/src/CometChatSearch/CometChatSearch.tsx +10 -5
  21. package/src/calls/CometChatOngoingCall/CometChatOngoingCall.tsx +56 -17
  22. package/src/calls/CometChatOutgoingCall/CometChatOutgoingCall.tsx +12 -9
  23. package/src/extensions/LinkPreview/LinkPreviewBubble.tsx +13 -10
  24. package/src/extensions/LinkPreview/LinkPreviewExtensionDecorator.tsx +34 -27
  25. package/src/extensions/Polls/Polls.tsx +7 -7
  26. package/src/extensions/Polls/PollsBubble.tsx +2 -2
  27. package/src/globals.d.ts +6 -0
  28. package/src/shared/constants/textPatterns.ts +20 -2
  29. package/src/shared/formatters/CometChatMentionsFormatter/CometChatMentionsFormatter.tsx +22 -11
  30. package/src/shared/formatters/CometChatRichTextFormatter/index.tsx +26 -14
  31. package/src/shared/formatters/CometChatUrlsFormatter/index.tsx +8 -0
  32. package/src/shared/formatters/codeElements.ts +21 -0
  33. package/src/shared/helper/types/index.ts +5 -0
  34. package/src/shared/libs/ImageZoom/ReactNativeZoomableView.tsx +4 -4
  35. package/src/shared/libs/ImageZoom/types/index.ts +2 -0
  36. package/src/shared/resources/CometChatSoundManager/sound.js +2 -3
  37. package/src/shared/services/UploadQueueService.ts +7 -0
  38. package/src/shared/utils/CometChatMessageHelper/index.ts +3 -0
  39. package/src/shared/utils/MarkdownUtils.ts +11 -4
  40. package/src/shared/utils/MessageUtils.tsx +7 -5
  41. package/src/shared/utils/groupMemberAddedRows.ts +28 -0
  42. package/src/shared/utils/linkPreviewSelection.ts +109 -0
  43. package/src/shared/utils/mentionTokens.ts +77 -0
  44. package/src/shared/utils/runAfterInteractions.ts +26 -0
  45. package/src/shared/utils/stripRichText.ts +2 -1
  46. package/src/shared/utils/tapGesture.ts +23 -0
  47. package/src/shared/utils/videoThumbnail.ts +74 -0
  48. package/src/shared/views/CometChatAttachmentPreview/CometChatAttachmentTile.tsx +21 -13
  49. package/src/shared/views/CometChatAudioBubble/CometChatAudioBubble.tsx +13 -15
  50. package/src/shared/views/CometChatEmojiKeyboard/CometChatEmojiKeyboard.tsx +1 -1
  51. package/src/shared/views/CometChatFileBubble/CometChatFileBubble.tsx +2 -1
  52. package/src/shared/views/CometChatFilesBubble/CometChatFilesBubble.tsx +2 -1
  53. package/src/shared/views/CometChatImagesBubble/CometChatImagesBubble.tsx +3 -26
  54. package/src/shared/views/CometChatInlineAudioRecorder/useAudioRecorder.ts +4 -2
  55. package/src/shared/views/CometChatList/Header.tsx +1 -1
  56. package/src/shared/views/CometChatMediaRecorder/CometChatAudioPreview/CometChatAudioPreview.tsx +2 -1
  57. package/src/shared/views/CometChatMediaViewer/CometChatMediaViewer.tsx +28 -8
  58. package/src/shared/views/CometChatMessageInput/CometChatMessageInput.tsx +3 -4
  59. package/src/shared/views/CometChatTextBubble/CometChatTextBubble.tsx +36 -4
  60. package/src/shared/views/CometChatVideoBubble/CometChatVideoBubble.tsx +2 -1
  61. package/src/shared/views/CometChatVideosBubble/CometChatVideosBubble.tsx +57 -30
  62. package/src/CometChatMessageList/PERFORMANCE_ARCHITECTURE.md +0 -478
  63. package/src/CometChatMessageList/SEARCH_NAV_PERF_PLAN.md +0 -613
  64. package/src/CometChatMessageList/SEARCH_NAV_SLOWNESS_FINDINGS_AND_FIX.md +0 -313
  65. package/src/shared/CometChatUiKit/CometChatUIKit.changes.md +0 -76
  66. package/src/shared/CometChatUiKit/checkAuthSettings-review.md +0 -211
File without changes
File without changes
@@ -1,21 +1,19 @@
1
- buildscript {
2
- repositories {
3
- google()
4
- mavenCentral()
5
- }
6
-
7
- dependencies {
8
- classpath 'com.android.tools.build:gradle:4.2.0'
9
- classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.22"
10
- }
11
- }
1
+ // AGP and the Kotlin Gradle plugin come from the host app's root project (as in every RN
2
+ // template since 0.71). Pinning them here via a `buildscript` block fights the app's own
3
+ // versions — AGP 9 / Gradle 9 (RN 0.87) will not build with the old pins at all.
12
4
 
13
5
  def isNewArchitectureEnabled() {
14
6
  return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
15
7
  }
16
8
 
17
9
  apply plugin: 'com.android.library'
18
- apply plugin: 'kotlin-android'
10
+
11
+ // AGP 9 can compile Kotlin itself ("built-in Kotlin"), and applying kotlin-android on top of
12
+ // that fails. Apply it only when nothing has registered the `kotlin` extension yet, so this
13
+ // works both on AGP 9 and on the AGP 8 apps of older RN versions.
14
+ if (project.extensions.findByName("kotlin") == null) {
15
+ apply plugin: 'org.jetbrains.kotlin.android'
16
+ }
19
17
 
20
18
  if (isNewArchitectureEnabled()) {
21
19
  apply plugin: 'com.facebook.react'
@@ -30,6 +28,7 @@ def getExtOrIntegerDefault(name) {
30
28
  }
31
29
 
32
30
  android {
31
+ namespace "com.reactnativecometchatuikit"
33
32
  compileSdkVersion getExtOrIntegerDefault('compileSdkVersion')
34
33
 
35
34
  defaultConfig {
@@ -37,102 +36,37 @@ android {
37
36
  targetSdkVersion getExtOrIntegerDefault('targetSdkVersion')
38
37
  buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
39
38
  }
39
+
40
+ buildFeatures {
41
+ buildConfig true
42
+ }
43
+
40
44
  buildTypes {
41
45
  release {
42
46
  minifyEnabled false
43
47
  }
44
48
  }
45
49
 
46
- lintOptions {
50
+ lint {
47
51
  disable 'GradleCompatible'
48
52
  }
49
53
 
50
54
  compileOptions {
51
- sourceCompatibility JavaVersion.VERSION_1_8
52
- targetCompatibility JavaVersion.VERSION_1_8
55
+ sourceCompatibility JavaVersion.VERSION_17
56
+ targetCompatibility JavaVersion.VERSION_17
53
57
  }
54
-
55
-
56
58
  }
57
59
 
58
60
  repositories {
59
61
  mavenCentral()
60
62
  google()
61
-
62
- def found = false
63
- def defaultDir = null
64
- def androidSourcesName = 'React Native sources'
65
-
66
- if (rootProject.ext.has('reactNativeAndroidRoot')) {
67
- defaultDir = rootProject.ext.get('reactNativeAndroidRoot')
68
- } else {
69
- defaultDir = new File(
70
- projectDir,
71
- '/../../../node_modules/react-native/android'
72
- )
73
- }
74
-
75
- if (defaultDir.exists()) {
76
- maven {
77
- url defaultDir.toString()
78
- name androidSourcesName
79
- }
80
-
81
- logger.info(":${project.name}:reactNativeAndroidRoot ${defaultDir.canonicalPath}")
82
- found = true
83
- } else {
84
- def parentDir = rootProject.projectDir
85
-
86
- 1.upto(5, {
87
- if (found) return true
88
- parentDir = parentDir.parentFile
89
-
90
- def androidSourcesDir = new File(
91
- parentDir,
92
- 'node_modules/react-native'
93
- )
94
-
95
- def androidPrebuiltBinaryDir = new File(
96
- parentDir,
97
- 'node_modules/react-native/android'
98
- )
99
-
100
- if (androidPrebuiltBinaryDir.exists()) {
101
- maven {
102
- url androidPrebuiltBinaryDir.toString()
103
- name androidSourcesName
104
- }
105
-
106
- logger.info(":${project.name}:reactNativeAndroidRoot ${androidPrebuiltBinaryDir.canonicalPath}")
107
- found = true
108
- } else if (androidSourcesDir.exists()) {
109
- maven {
110
- url androidSourcesDir.toString()
111
- name androidSourcesName
112
- }
113
-
114
- logger.info(":${project.name}:reactNativeAndroidRoot ${androidSourcesDir.canonicalPath}")
115
- found = true
116
- }
117
- })
118
- }
119
-
120
- if (!found) {
121
- throw new GradleException(
122
- "${project.name}: unable to locate React Native android sources. " +
123
- "Ensure you have you installed React Native as a dependency in your project and try again."
124
- )
125
- }
126
63
  }
127
64
 
128
-
129
65
  dependencies {
130
- //noinspection GradleDynamicVersion
131
- implementation "com.facebook.react:react-native:+"
132
- implementation 'androidx.appcompat:appcompat:1.4.1'
133
- implementation 'com.google.android.material:material:1.5.0'
134
- implementation "org.jetbrains.kotlin:kotlin-stdlib:1.9.22"
135
- // From node_modules
66
+ // Version is supplied by the React Native Gradle Plugin of the host app.
67
+ implementation "com.facebook.react:react-android"
68
+ implementation 'androidx.appcompat:appcompat:1.7.1'
69
+ implementation 'com.google.android.material:material:1.12.0'
136
70
  }
137
71
 
138
72
  if (isNewArchitectureEnabled()) {
@@ -1,5 +1,5 @@
1
- CometchatUiKit_kotlinVersion=1.7.0
2
- CometchatUiKit_minSdkVersion=21
3
- CometchatUiKit_targetSdkVersion=31
4
- CometchatUiKit_compileSdkVersion=31
5
- CometchatUiKit_ndkversion=21.4.7075529
1
+ CometchatUiKit_kotlinVersion=2.2.0
2
+ CometchatUiKit_minSdkVersion=24
3
+ CometchatUiKit_targetSdkVersion=36
4
+ CometchatUiKit_compileSdkVersion=36
5
+ CometchatUiKit_ndkversion=27.1.12297006
@@ -397,8 +397,12 @@ public class CometChatSoundModule
397
397
  }
398
398
  }
399
399
 
400
+ // `invalidate()`, not the deprecated onCatalystInstanceDestroy(): bridgeless RN (0.82+ is
401
+ // New-Architecture-only) tears modules down through invalidate(), so the old hook can be
402
+ // skipped and every pooled MediaPlayer would leak.
400
403
  @Override
401
- public void onCatalystInstanceDestroy() {
404
+ public void invalidate() {
405
+ super.invalidate();
402
406
  java.util.Iterator it = this.playerPool.entrySet().iterator();
403
407
  while (it.hasNext()) {
404
408
  Map.Entry entry = (Map.Entry) it.next();
@@ -18,6 +18,7 @@ import android.graphics.Bitmap;
18
18
  import android.graphics.BitmapFactory;
19
19
  import android.graphics.Matrix;
20
20
  import android.media.ExifInterface;
21
+ import android.media.MediaMetadataRetriever;
21
22
  import android.media.MediaPlayer;
22
23
  import android.media.MediaRecorder;
23
24
  import android.net.Uri;
@@ -725,6 +726,57 @@ public class FileManager extends ReactContextBaseJavaModule {
725
726
  }
726
727
  }
727
728
 
729
+ // Small JPEG of a local video's first frame, so a picked/sent video has a thumbnail without waiting
730
+ // for the server's thumbnail-generation extension (which publishes its URL before the image exists).
731
+ // Cached in cacheDir by source uri, so repeat calls for the same file are instant.
732
+ @ReactMethod
733
+ public void getVideoThumbnail(String uri, double maxSize, Promise promise) {
734
+ Executors.newSingleThreadExecutor().execute(() -> {
735
+ MediaMetadataRetriever retriever = new MediaMetadataRetriever();
736
+ try {
737
+ int side = maxSize > 0 ? (int) maxSize : 320;
738
+ File dir = new File(getReactApplicationContext().getCacheDir(), "cometchat-video-thumbnails");
739
+ if (!dir.exists()) dir.mkdirs();
740
+ File thumb = new File(dir, Integer.toHexString(uri.hashCode()) + "_" + uri.length() + "_" + side + ".jpg");
741
+ if (thumb.exists()) {
742
+ promise.resolve(Uri.fromFile(thumb).toString());
743
+ return;
744
+ }
745
+
746
+ Uri source = uri.startsWith("/") ? Uri.fromFile(new File(uri)) : Uri.parse(uri);
747
+ retriever.setDataSource(getReactApplicationContext(), source);
748
+ Bitmap frame;
749
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) {
750
+ frame = retriever.getScaledFrameAtTime(100_000, MediaMetadataRetriever.OPTION_CLOSEST_SYNC, side, side);
751
+ } else {
752
+ Bitmap full = retriever.getFrameAtTime(100_000, MediaMetadataRetriever.OPTION_CLOSEST_SYNC);
753
+ frame = full == null ? null : scaleToFit(full, side);
754
+ }
755
+ if (frame == null) {
756
+ promise.reject("thumbnail_failed", "Could not read a video frame");
757
+ return;
758
+ }
759
+ try (FileOutputStream out = new FileOutputStream(thumb)) {
760
+ frame.compress(Bitmap.CompressFormat.JPEG, 80, out);
761
+ }
762
+ frame.recycle();
763
+ promise.resolve(Uri.fromFile(thumb).toString());
764
+ } catch (Exception e) {
765
+ promise.reject("thumbnail_failed", e.getMessage(), e);
766
+ } finally {
767
+ try { retriever.release(); } catch (Exception ignored) { }
768
+ }
769
+ });
770
+ }
771
+
772
+ private static Bitmap scaleToFit(Bitmap source, int side) {
773
+ float scale = Math.min(1f, side / (float) Math.max(source.getWidth(), source.getHeight()));
774
+ if (scale >= 1f) return source;
775
+ Bitmap scaled = Bitmap.createScaledBitmap(source, Math.round(source.getWidth() * scale), Math.round(source.getHeight() * scale), true);
776
+ source.recycle();
777
+ return scaled;
778
+ }
779
+
728
780
  @ReactMethod
729
781
  public void pauseRecording(Promise promise) {
730
782
  if (audioRecorder != null) {
@@ -383,9 +383,14 @@ class RichTextEditorView(context: Context) : androidx.appcompat.widget.AppCompat
383
383
  changeStart = start
384
384
  removedCount = count
385
385
  addedCount = after
386
- // Save selected text for URL-paste-over-selection detection.
387
- // When count > 0 and after > 0, it's a replace (paste over selection).
388
- if (count > 0 && after > 0 && s != null && start + count <= s.length) {
386
+ // Save selected text for URL-paste-over-selection detection: a replace counts only when
387
+ // the user had exactly that text highlighted. Keyboards also replace text while typing
388
+ // (rewriting "www" -> "Www.", autocorrect) but with a bare cursor, and those must not
389
+ // become links. No clipboard read here: Android 12+ toasts on every read.
390
+ val selStart = minOf(selectionStart, selectionEnd)
391
+ val selEnd = maxOf(selectionStart, selectionEnd)
392
+ if (count > 0 && after > 0 && s != null && start + count <= s.length &&
393
+ selStart != selEnd && selStart == start && selEnd == start + count) {
389
394
  savedSelectedTextForPaste = s.subSequence(start, start + count).toString()
390
395
  } else {
391
396
  savedSelectedTextForPaste = null
@@ -2924,8 +2929,16 @@ class RichTextEditorView(context: Context) : androidx.appcompat.widget.AppCompat
2924
2929
  if (j >= chars.size) return null
2925
2930
  if (j + 1 >= chars.size || chars[j + 1] != '(') return null
2926
2931
  val urlStart = j + 2
2932
+ // Balanced: `(planet)` inside the address is kept and only an unmatched `)` closes the
2933
+ // link. Stopping at the first `)` turned a pasted [Mercury](…/Mercury_(planet)) into
2934
+ // "Mercury" linking to …/Mercury_(planet plus a stray ")".
2927
2935
  var k = urlStart
2928
- while (k < chars.size && chars[k] != ')') k++
2936
+ var depth = 0
2937
+ while (k < chars.size) {
2938
+ if (chars[k] == '(') depth++
2939
+ else if (chars[k] == ')') { if (depth == 0) break; depth-- }
2940
+ k++
2941
+ }
2929
2942
  if (k >= chars.size) return null
2930
2943
  val linkText = String(chars, from + 1, j - from - 1)
2931
2944
  val linkURL = String(chars, urlStart, k - urlStart)
package/ios/FileManager.m CHANGED
@@ -53,6 +53,16 @@ static NSString *const FIELD_SIZE = @"size";
53
53
  hasListeners = YES;
54
54
  }
55
55
 
56
+ // The pickers share one `callback` slot, so a picker must TAKE it the moment it finishes (and clear the
57
+ // slot) rather than read it later. Otherwise a slow pick (PHPicker loading several videos) fires whatever
58
+ // callback a NEWER pick stored in the meantime — invoking that block twice, which RN aborts on
59
+ // ("Callback arg cannot be called more than once").
60
+ - (RCTResponseSenderBlock)takeCallback {
61
+ RCTResponseSenderBlock cb = callback;
62
+ callback = nil;
63
+ return cb;
64
+ }
65
+
56
66
  - (void)stopObserving {
57
67
  hasListeners = NO;
58
68
  }
@@ -372,6 +382,52 @@ RCT_EXPORT_METHOD(openFileChooser:(NSString *)type callback:(RCTResponseSenderBl
372
382
  }
373
383
 
374
384
 
385
+ // Small JPEG of a local video's first frame, so a picked/sent video has a thumbnail without waiting for
386
+ // the server's thumbnail-generation extension (which publishes its URL before the image exists).
387
+ // Cached in Caches/ by source path, so repeat calls for the same file are instant.
388
+ RCT_EXPORT_METHOD(getVideoThumbnail:(NSString *)uri maxSize:(nonnull NSNumber *)maxSize resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
389
+ dispatch_async(dispatch_get_global_queue(QOS_CLASS_USER_INITIATED, 0), ^{
390
+ NSURL *videoURL = [uri hasPrefix:@"/"] ? [NSURL fileURLWithPath:uri] : [NSURL URLWithString:uri];
391
+ if (!videoURL) {
392
+ reject(@"invalid_uri", @"Invalid video uri", nil);
393
+ return;
394
+ }
395
+ NSString *dir = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES).firstObject
396
+ stringByAppendingPathComponent:@"cometchat-video-thumbnails"];
397
+ [[NSFileManager defaultManager] createDirectoryAtPath:dir withIntermediateDirectories:YES attributes:nil error:nil];
398
+ NSString *key = [NSString stringWithFormat:@"%lu_%lu_%@", (unsigned long)videoURL.path.hash,
399
+ (unsigned long)videoURL.path.length, maxSize];
400
+ NSString *thumbPath = [dir stringByAppendingPathComponent:[key stringByAppendingPathExtension:@"jpg"]];
401
+ if ([[NSFileManager defaultManager] fileExistsAtPath:thumbPath]) {
402
+ resolve([NSURL fileURLWithPath:thumbPath].absoluteString);
403
+ return;
404
+ }
405
+
406
+ AVURLAsset *asset = [AVURLAsset URLAssetWithURL:videoURL options:nil];
407
+ AVAssetImageGenerator *generator = [[AVAssetImageGenerator alloc] initWithAsset:asset];
408
+ generator.appliesPreferredTrackTransform = YES; // keep portrait videos upright
409
+ CGFloat side = maxSize.doubleValue > 0 ? maxSize.doubleValue : 320;
410
+ generator.maximumSize = CGSizeMake(side, side);
411
+ // Nearest keyframe is fine for a preview and much faster than an exact frame.
412
+ generator.requestedTimeToleranceBefore = kCMTimePositiveInfinity;
413
+ generator.requestedTimeToleranceAfter = kCMTimePositiveInfinity;
414
+
415
+ NSError *error = nil;
416
+ CGImageRef cgImage = [generator copyCGImageAtTime:CMTimeMakeWithSeconds(0.1, 600) actualTime:NULL error:&error];
417
+ if (!cgImage) {
418
+ reject(@"thumbnail_failed", error.localizedDescription ?: @"Could not read a video frame", error);
419
+ return;
420
+ }
421
+ NSData *jpeg = UIImageJPEGRepresentation([UIImage imageWithCGImage:cgImage], 0.8);
422
+ CGImageRelease(cgImage);
423
+ if (![jpeg writeToFile:thumbPath atomically:YES]) {
424
+ reject(@"thumbnail_failed", @"Could not write the thumbnail", nil);
425
+ return;
426
+ }
427
+ resolve([NSURL fileURLWithPath:thumbPath].absoluteString);
428
+ });
429
+ }
430
+
375
431
  RCT_EXPORT_METHOD(openFileChooserMulti:(NSString *)type maxSelection:(nonnull NSNumber *)maxSelection callback:(RCTResponseSenderBlock)call) {
376
432
  callback = call;
377
433
  UIViewController *presentedViewController = RCTPresentedViewController();
@@ -1104,6 +1160,11 @@ RCT_EXPORT_METHOD(clearSegments:(RCTResponseSenderBlock)callback) {
1104
1160
 
1105
1161
  - (void)imagePickerController:(UIImagePickerController *)picker
1106
1162
  didFinishPickingMediaWithInfo:(NSDictionary<UIImagePickerControllerInfoKey, id> *)info {
1163
+ RCTResponseSenderBlock callback = [self takeCallback];
1164
+ if (!callback) {
1165
+ [picker dismissViewControllerAnimated:TRUE completion:nil];
1166
+ return;
1167
+ }
1107
1168
  switch (picker.sourceType) {
1108
1169
  case UIImagePickerControllerSourceTypeCamera: {
1109
1170
  UIImage *image = [info valueForKey:UIImagePickerControllerOriginalImage];
@@ -1180,7 +1241,12 @@ didFinishPickingMediaWithInfo:(NSDictionary<UIImagePickerControllerInfoKey, id>
1180
1241
  // PHPickerViewControllerDelegate — handles multi-select from Photos library (images and videos)
1181
1242
  - (void)picker:(PHPickerViewController *)picker didFinishPicking:(NSArray<PHPickerResult *> *)results {
1182
1243
  [picker dismissViewControllerAnimated:YES completion:nil];
1244
+ RCTResponseSenderBlock callback = [self takeCallback];
1245
+ if (!callback) {
1246
+ return;
1247
+ }
1183
1248
  if (results.count == 0) {
1249
+ callback(@[@[]]);
1184
1250
  return;
1185
1251
  }
1186
1252
 
@@ -1229,9 +1295,7 @@ didFinishPickingMediaWithInfo:(NSDictionary<UIImagePickerControllerInfoKey, id>
1229
1295
  }
1230
1296
 
1231
1297
  dispatch_group_notify(group, dispatch_get_main_queue(), ^{
1232
- if (fileInfoArray.count > 0) {
1233
- callback(@[fileInfoArray]);
1234
- }
1298
+ callback(@[fileInfoArray]);
1235
1299
  });
1236
1300
  }
1237
1301
 
@@ -1248,6 +1312,11 @@ didFinishPickingMediaWithInfo:(NSDictionary<UIImagePickerControllerInfoKey, id>
1248
1312
  }
1249
1313
 
1250
1314
  - (void)documentPicker:(UIDocumentPickerViewController *)controller didPickDocumentsAtURLs:(NSArray<NSURL *> *)urls {
1315
+ RCTResponseSenderBlock callback = [self takeCallback];
1316
+ if (!callback) {
1317
+ _multipleSelection = NO;
1318
+ return;
1319
+ }
1251
1320
  if (_multipleSelection) {
1252
1321
  _multipleSelection = NO;
1253
1322
  NSMutableArray *results = [NSMutableArray array];
@@ -1273,6 +1342,11 @@ didFinishPickingMediaWithInfo:(NSDictionary<UIImagePickerControllerInfoKey, id>
1273
1342
 
1274
1343
  - (void)documentPickerWasCancelled:(UIDocumentPickerViewController *)controller {
1275
1344
  NSLog(@"document pick cancelled");
1345
+ if (_multipleSelection) {
1346
+ _multipleSelection = NO;
1347
+ RCTResponseSenderBlock callback = [self takeCallback];
1348
+ if (callback) callback(@[@[]]);
1349
+ }
1276
1350
  [controller dismissViewControllerAnimated:TRUE completion:nil];
1277
1351
  }
1278
1352
 
@@ -6323,8 +6323,16 @@ class RichTextEditorView: UIView, UITextViewDelegate, UIGestureRecognizerDelegat
6323
6323
  guard j < chars.count else { return nil }
6324
6324
  guard j + 1 < chars.count && chars[j + 1] == "(" else { return nil }
6325
6325
  let urlStart = j + 2
6326
+ // Balanced: `(planet)` inside the address is kept and only an unmatched `)` closes the
6327
+ // link. Stopping at the first `)` turned a pasted [Mercury](…/Mercury_(planet)) into
6328
+ // "Mercury" linking to …/Mercury_(planet plus a stray ")".
6326
6329
  var k = urlStart
6327
- while k < chars.count && chars[k] != ")" { k += 1 }
6330
+ var depth = 0
6331
+ while k < chars.count {
6332
+ if chars[k] == "(" { depth += 1 }
6333
+ else if chars[k] == ")" { if depth == 0 { break }; depth -= 1 }
6334
+ k += 1
6335
+ }
6328
6336
  guard k < chars.count else { return nil }
6329
6337
  let linkText = String(chars[(from + 1)..<j])
6330
6338
  let linkURL = String(chars[urlStart..<k])
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cometchat/chat-uikit-react-native",
3
- "version": "5.5.1",
3
+ "version": "5.5.2",
4
4
  "description": "Ready-to-use Chat UI Components for React Native",
5
5
  "main": "src/index",
6
6
  "module": "src/index",
@@ -51,8 +51,8 @@
51
51
  },
52
52
  "devDependencies": {
53
53
  "@babel/eslint-parser": "^7.27.0",
54
- "@react-native/eslint-config": "0.79.2",
55
- "@react-native/jest-preset": "^0.86.0",
54
+ "@react-native/eslint-config": "0.87.1",
55
+ "@react-native/jest-preset": "0.87.1",
56
56
  "@types/jest": "^29.5.13",
57
57
  "@types/react": "*",
58
58
  "commitlint": "^17.0.2",
@@ -87,7 +87,7 @@
87
87
  "react-native-video": "*"
88
88
  },
89
89
  "jest": {
90
- "preset": "react-native",
90
+ "preset": "@react-native/jest-preset",
91
91
  "modulePathIgnorePatterns": [
92
92
  "<rootDir>/lib/"
93
93
  ],
@@ -2,8 +2,6 @@ require "json"
2
2
 
3
3
  package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4
4
 
5
- folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
6
-
7
5
  Pod::Spec.new do |s|
8
6
  s.name = "react-native-cometchat-ui-kit"
9
7
  s.version = package["version"]
@@ -12,14 +10,13 @@ Pod::Spec.new do |s|
12
10
  s.license = package["license"]
13
11
  s.authors = package["author"].is_a?(Hash) ? [package["author"]] : package["author"]
14
12
 
15
- s.platforms = { :ios => "11.0" }
13
+ s.platforms = { :ios => min_ios_version_supported }
16
14
  s.source = { :git => "https://github.com/cometchat/cometchat-uikit-react-native.git", :tag => "#{s.version}" }
17
15
 
18
16
  s.source_files = "ios/**/*.{h,m,mm,swift}"
19
17
 
20
18
  s.static_framework = true # Set static_framework for the main spec if needed
21
19
  s.frameworks = ["PhotosUI"]
22
- s.dependency "React-Core"
23
20
 
24
21
  s.subspec "Video" do |ss|
25
22
  ss.source_files = "ios/Video/*.{h,m}"
@@ -33,19 +30,8 @@ Pod::Spec.new do |s|
33
30
  ss.source_files = "ios/VideoCaching/**/*.{h,m}"
34
31
  end
35
32
 
36
- # Conditional compiler flags and dependencies for the new architecture
37
- if ENV['RCT_NEW_ARCH_ENABLED'] == '1'
38
- s.compiler_flags = "#{folly_compiler_flags} -DRCT_NEW_ARCH_ENABLED=1"
39
- s.pod_target_xcconfig = {
40
- "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/Header/Public/**\"",
41
- "CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
42
- }
43
-
44
- # s.dependency "React-Codegen"
45
- # s.dependency "RCT-Folly"
46
- # s.dependency "RCTRequired"
47
- # s.dependency "RCTTypeSafety"
48
- # s.dependency "ReactCommon/turbomodule/core"
49
- # s.dependency "RCTSlider"
50
- end
33
+ # React Native's own helper wires up React-Core and the New Architecture
34
+ # dependencies and flags (RN 0.71+). It replaces the hand-rolled
35
+ # RCT_NEW_ARCH_ENABLED block, which stopped meaning anything in RN 0.82.
36
+ install_modules_dependencies(s)
51
37
  end
@@ -18,12 +18,12 @@ import {
18
18
  Dimensions,
19
19
  ImageSourcePropType,
20
20
  ImageStyle,
21
- InteractionManager,
22
21
  Keyboard,
23
22
  ColorValue,
24
23
  TouchableWithoutFeedbackProps,
25
24
  ScrollView,
26
25
  StyleSheet,
26
+ StatusBar,
27
27
  } from 'react-native';
28
28
  import { JSX } from 'react';
29
29
  import RichTextEditor, {
@@ -111,6 +111,7 @@ import {
111
111
  getUnixTimestampInMilliseconds,
112
112
  messageStatus,
113
113
  } from '../shared/utils/CometChatMessageHelper';
114
+ import { runAfterInteractions } from '../shared/utils/runAfterInteractions';
114
115
  import { MessageTypeConstants, ReceiverTypeConstants, ConversationOptionConstants, MentionsVisibility, MentionsTargetElement, ViewAlignment, EnterKeyBehavior, DISABLED_BUTTON_OPACITY } from '../shared/constants/UIKitConstants';
115
116
  import { MessageEvents } from '../shared/events';
116
117
  import { CometChatUIEventHandler } from '../shared/events/CometChatUIEventHandler/CometChatUIEventHandler';
@@ -118,6 +119,7 @@ import { CometChatMessageEvents } from '../shared/events/CometChatMessageEvents'
118
119
  import { ICONS } from './resources';
119
120
  import { CommonUtils } from '../shared/utils/CommonUtils';
120
121
  import { isCursorWithinMentionRange, getMentionRangeAtCursor } from '../shared/utils/MentionUtils';
122
+ import { escapeTypedMentionTokens, insertMentionTokens } from '../shared/utils/mentionTokens';
121
123
  import { stripMarkdown } from '../shared/utils/MarkdownUtils';
122
124
  import { commonVars } from '../shared/base/vars';
123
125
  import { permissionUtil } from '../shared/utils/PermissionUtil';
@@ -3042,7 +3044,7 @@ export const CometChatCompactMessageComposer = React.forwardRef(
3042
3044
  // Update cursor position to the start of the first deleted mention
3043
3045
  const firstStart = overlaps[0].start;
3044
3046
  ignoreSelectionUntil.current = Date.now() + 500;
3045
- InteractionManager.runAfterInteractions(() => {
3047
+ runAfterInteractions(() => {
3046
3048
  inputRef.current?.setSelection?.(firstStart);
3047
3049
  setSelectionPosition({ start: firstStart, end: firstStart });
3048
3050
  syncMentionRanges();
@@ -3198,7 +3200,7 @@ export const CometChatCompactMessageComposer = React.forwardRef(
3198
3200
  targetPosition = mentionRange.end;
3199
3201
  }
3200
3202
  if (targetPosition !== cursorPos) {
3201
- InteractionManager.runAfterInteractions(() => {
3203
+ runAfterInteractions(() => {
3202
3204
  inputRef.current?.setSelection?.(targetPosition);
3203
3205
  setSelectionPosition({ start: targetPosition, end: targetPosition });
3204
3206
  });
@@ -3437,24 +3439,9 @@ export const CometChatCompactMessageComposer = React.forwardRef(
3437
3439
  * Convert mentions to underlying text format for sending
3438
3440
  * Iterates through mentionMap and replaces prompt text with underlying text
3439
3441
  */
3440
- const getRegexString = (str: string): string => {
3441
- // Get an array of the entries in the map using the spread operator
3442
- const entries = [...mentionMap.current.entries()].reverse();
3443
-
3444
- let uidInput = str;
3445
-
3446
- // Iterate over the array in reverse order
3447
- entries.forEach(([key, value]) => {
3448
- const [start, end] = key.split('_').map(Number);
3449
-
3450
- const pre = uidInput.substring(0, start);
3451
- const post = uidInput.substring(end);
3452
-
3453
- uidInput = pre + value.underlyingText + post;
3454
- });
3455
-
3456
- return uidInput;
3457
- };
3442
+ const getRegexString = (str: string): string =>
3443
+ // Token-looking text the user typed is escaped so it is stored as text, not a live mention.
3444
+ insertMentionTokens(str, mentionMap.current.entries());
3458
3445
 
3459
3446
  /**
3460
3447
  * Replace mention display names with underlying tokens in the given text.
@@ -3464,11 +3451,14 @@ export const CometChatCompactMessageComposer = React.forwardRef(
3464
3451
  * when the same display name appears multiple times.
3465
3452
  */
3466
3453
  const replaceMentionsWithTokens = (text: string): string => {
3467
- if (mentionMap.current.size === 0) return text;
3454
+ // Escape token-looking text the user typed first; the picked mentions inserted below are
3455
+ // the only real tokens.
3456
+ const typed = escapeTypedMentionTokens(text);
3457
+ if (mentionMap.current.size === 0) return typed;
3468
3458
  const entries = [...mentionMap.current.entries()].sort((a, b) => {
3469
3459
  return parseInt(a[0].split('_')[0]) - parseInt(b[0].split('_')[0]);
3470
3460
  });
3471
- let result = text;
3461
+ let result = typed;
3472
3462
  let offset = 0;
3473
3463
  for (const [, value] of entries) {
3474
3464
  const displayName = value.promptText || '';
@@ -3514,8 +3504,10 @@ export const CometChatCompactMessageComposer = React.forwardRef(
3514
3504
  itemLookup.set(item.id, item);
3515
3505
  }
3516
3506
 
3517
- // Single-pass: collect matches, build resolved text via array join
3518
- const mentionRegex = /<@(?:uid|all):(.*?)>/g;
3507
+ // Single-pass: collect matches, build resolved text via array join. The second
3508
+ // alternative is token text the user TYPED, stored escaped (`&lt;@all:…`); it goes back
3509
+ // into the editor as the literal `<@all:…` they typed, never as a mention.
3510
+ const mentionRegex = /<@(?:uid|all):(.*?)>|&lt;(@(?:uid|all):)/g;
3519
3511
  let match: RegExpExecArray | null;
3520
3512
  const segments: string[] = [];
3521
3513
  let lastIndex = 0;
@@ -3528,6 +3520,13 @@ export const CometChatCompactMessageComposer = React.forwardRef(
3528
3520
  segments.push(before);
3529
3521
  resolvedLength += before.length;
3530
3522
 
3523
+ if (match[2] !== undefined) {
3524
+ segments.push("<" + match[2]);
3525
+ resolvedLength += match[2].length + 1;
3526
+ lastIndex = match.index + match[0].length;
3527
+ continue;
3528
+ }
3529
+
3531
3530
  const item = itemLookup.get(match[1]);
3532
3531
  const displayText = item?.promptText ?? `@${match[1]}`;
3533
3532
  segments.push(displayText);
@@ -4991,8 +4990,13 @@ export const CometChatCompactMessageComposer = React.forwardRef(
4991
4990
  {/* KeyboardAvoidingView wrapper */}
4992
4991
  <KeyboardAvoidingView
4993
4992
  key={id}
4994
- behavior={Platform.OS === 'ios' ? 'padding' : 'height'}
4995
- keyboardVerticalOffset={Platform.select({ ios: kbOffset })}
4993
+ // "padding" on Android too: with edge-to-edge (always on from RN 0.87 / targetSdk 36) the window no
4994
+ // longer resizes for the keyboard, and "height" squashes this composer instead of lifting it.
4995
+ // When the window does resize (adjustResize), the keyboard overlap is 0 and padding adds nothing.
4996
+ behavior='padding'
4997
+ // The view is measured from its parent, the keyboard from the top of the screen: offset by
4998
+ // what sits above the parent — the top safe area on iOS, the status bar on Android.
4999
+ keyboardVerticalOffset={Platform.select({ ios: kbOffset, android: StatusBar.currentHeight ?? 0 })}
4996
5000
  {...keyboardAvoidingViewProps}
4997
5001
  >
4998
5002
  {/* Outer wrapper with padding (matches Figma: Message Composer) */}