@sendbird/uikit-react-native 3.0.4-rc.1 → 3.1.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.
Files changed (150) hide show
  1. package/lib/commonjs/components/ChannelInput/SendInput.js +151 -19
  2. package/lib/commonjs/components/ChannelInput/SendInput.js.map +1 -1
  3. package/lib/commonjs/components/ChannelInput/index.js +5 -13
  4. package/lib/commonjs/components/ChannelInput/index.js.map +1 -1
  5. package/lib/commonjs/components/ChannelMessageList/index.js +34 -20
  6. package/lib/commonjs/components/ChannelMessageList/index.js.map +1 -1
  7. package/lib/commonjs/components/ChatFlatList/index.js +1 -1
  8. package/lib/commonjs/components/ChatFlatList/index.js.map +1 -1
  9. package/lib/commonjs/components/GroupChannelMessageRenderer/GroupChannelMessageFocusAnimation.js +4 -1
  10. package/lib/commonjs/components/GroupChannelMessageRenderer/GroupChannelMessageFocusAnimation.js.map +1 -1
  11. package/lib/commonjs/components/GroupChannelMessageRenderer/GroupChannelMessageParentMessage.js +191 -0
  12. package/lib/commonjs/components/GroupChannelMessageRenderer/GroupChannelMessageParentMessage.js.map +1 -0
  13. package/lib/commonjs/components/GroupChannelMessageRenderer/index.js +12 -1
  14. package/lib/commonjs/components/GroupChannelMessageRenderer/index.js.map +1 -1
  15. package/lib/commonjs/components/MessageSearchResultItem.js +2 -8
  16. package/lib/commonjs/components/MessageSearchResultItem.js.map +1 -1
  17. package/lib/commonjs/components/ReactionAddons/BottomSheetReactionAddon.js +8 -7
  18. package/lib/commonjs/components/ReactionAddons/BottomSheetReactionAddon.js.map +1 -1
  19. package/lib/commonjs/containers/GroupChannelPreviewContainer.js +3 -9
  20. package/lib/commonjs/containers/GroupChannelPreviewContainer.js.map +1 -1
  21. package/lib/commonjs/containers/SendbirdUIKitContainer.js +43 -9
  22. package/lib/commonjs/containers/SendbirdUIKitContainer.js.map +1 -1
  23. package/lib/commonjs/contexts/SendbirdChatCtx.js +5 -0
  24. package/lib/commonjs/contexts/SendbirdChatCtx.js.map +1 -1
  25. package/lib/commonjs/domain/groupChannel/component/GroupChannelInput.js +5 -1
  26. package/lib/commonjs/domain/groupChannel/component/GroupChannelInput.js.map +1 -1
  27. package/lib/commonjs/domain/groupChannel/component/GroupChannelMessageList.js +47 -10
  28. package/lib/commonjs/domain/groupChannel/component/GroupChannelMessageList.js.map +1 -1
  29. package/lib/commonjs/domain/groupChannel/module/moduleContext.js +38 -3
  30. package/lib/commonjs/domain/groupChannel/module/moduleContext.js.map +1 -1
  31. package/lib/commonjs/domain/groupChannel/types.js.map +1 -1
  32. package/lib/commonjs/domain/openChannel/types.js.map +1 -1
  33. package/lib/commonjs/fragments/createGroupChannelFragment.js +19 -0
  34. package/lib/commonjs/fragments/createGroupChannelFragment.js.map +1 -1
  35. package/lib/commonjs/hooks/useConnection.js +2 -1
  36. package/lib/commonjs/hooks/useConnection.js.map +1 -1
  37. package/lib/commonjs/hooks/useMentionSuggestion.js +1 -1
  38. package/lib/commonjs/hooks/useMentionSuggestion.js.map +1 -1
  39. package/lib/commonjs/hooks/useMentionTextInput.js +4 -3
  40. package/lib/commonjs/hooks/useMentionTextInput.js.map +1 -1
  41. package/lib/commonjs/libs/MentionManager.js.map +1 -1
  42. package/lib/commonjs/localization/StringSet.type.js.map +1 -1
  43. package/lib/commonjs/localization/createBaseStringSet.js +29 -0
  44. package/lib/commonjs/localization/createBaseStringSet.js.map +1 -1
  45. package/lib/commonjs/platform/createFileService.native.js +4 -1
  46. package/lib/commonjs/platform/createFileService.native.js.map +1 -1
  47. package/lib/commonjs/platform/createMediaService.native.js +1 -1
  48. package/lib/commonjs/platform/createMediaService.native.js.map +1 -1
  49. package/lib/commonjs/platform/types.js.map +1 -1
  50. package/lib/commonjs/utils/pubsub.js +3 -1
  51. package/lib/commonjs/utils/pubsub.js.map +1 -1
  52. package/lib/commonjs/version.js +1 -1
  53. package/lib/commonjs/version.js.map +1 -1
  54. package/lib/module/components/ChannelInput/SendInput.js +153 -21
  55. package/lib/module/components/ChannelInput/SendInput.js.map +1 -1
  56. package/lib/module/components/ChannelInput/index.js +6 -14
  57. package/lib/module/components/ChannelInput/index.js.map +1 -1
  58. package/lib/module/components/ChannelMessageList/index.js +34 -20
  59. package/lib/module/components/ChannelMessageList/index.js.map +1 -1
  60. package/lib/module/components/ChatFlatList/index.js +1 -1
  61. package/lib/module/components/ChatFlatList/index.js.map +1 -1
  62. package/lib/module/components/GroupChannelMessageRenderer/GroupChannelMessageFocusAnimation.js +4 -1
  63. package/lib/module/components/GroupChannelMessageRenderer/GroupChannelMessageFocusAnimation.js.map +1 -1
  64. package/lib/module/components/GroupChannelMessageRenderer/GroupChannelMessageParentMessage.js +182 -0
  65. package/lib/module/components/GroupChannelMessageRenderer/GroupChannelMessageParentMessage.js.map +1 -0
  66. package/lib/module/components/GroupChannelMessageRenderer/index.js +13 -2
  67. package/lib/module/components/GroupChannelMessageRenderer/index.js.map +1 -1
  68. package/lib/module/components/MessageSearchResultItem.js +3 -9
  69. package/lib/module/components/MessageSearchResultItem.js.map +1 -1
  70. package/lib/module/components/ReactionAddons/BottomSheetReactionAddon.js +8 -7
  71. package/lib/module/components/ReactionAddons/BottomSheetReactionAddon.js.map +1 -1
  72. package/lib/module/containers/GroupChannelPreviewContainer.js +4 -10
  73. package/lib/module/containers/GroupChannelPreviewContainer.js.map +1 -1
  74. package/lib/module/containers/SendbirdUIKitContainer.js +43 -9
  75. package/lib/module/containers/SendbirdUIKitContainer.js.map +1 -1
  76. package/lib/module/contexts/SendbirdChatCtx.js +6 -1
  77. package/lib/module/contexts/SendbirdChatCtx.js.map +1 -1
  78. package/lib/module/domain/groupChannel/component/GroupChannelInput.js +5 -1
  79. package/lib/module/domain/groupChannel/component/GroupChannelInput.js.map +1 -1
  80. package/lib/module/domain/groupChannel/component/GroupChannelMessageList.js +50 -13
  81. package/lib/module/domain/groupChannel/component/GroupChannelMessageList.js.map +1 -1
  82. package/lib/module/domain/groupChannel/module/moduleContext.js +39 -4
  83. package/lib/module/domain/groupChannel/module/moduleContext.js.map +1 -1
  84. package/lib/module/domain/groupChannel/types.js.map +1 -1
  85. package/lib/module/domain/openChannel/types.js.map +1 -1
  86. package/lib/module/fragments/createGroupChannelFragment.js +19 -0
  87. package/lib/module/fragments/createGroupChannelFragment.js.map +1 -1
  88. package/lib/module/hooks/useConnection.js +2 -1
  89. package/lib/module/hooks/useConnection.js.map +1 -1
  90. package/lib/module/hooks/useMentionSuggestion.js +1 -1
  91. package/lib/module/hooks/useMentionSuggestion.js.map +1 -1
  92. package/lib/module/hooks/useMentionTextInput.js +4 -3
  93. package/lib/module/hooks/useMentionTextInput.js.map +1 -1
  94. package/lib/module/libs/MentionManager.js.map +1 -1
  95. package/lib/module/localization/StringSet.type.js.map +1 -1
  96. package/lib/module/localization/createBaseStringSet.js +30 -1
  97. package/lib/module/localization/createBaseStringSet.js.map +1 -1
  98. package/lib/module/platform/createFileService.native.js +5 -2
  99. package/lib/module/platform/createFileService.native.js.map +1 -1
  100. package/lib/module/platform/createMediaService.native.js +1 -1
  101. package/lib/module/platform/createMediaService.native.js.map +1 -1
  102. package/lib/module/platform/types.js.map +1 -1
  103. package/lib/module/utils/pubsub.js +3 -1
  104. package/lib/module/utils/pubsub.js.map +1 -1
  105. package/lib/module/version.js +1 -1
  106. package/lib/module/version.js.map +1 -1
  107. package/lib/typescript/src/components/ChannelInput/index.d.ts +2 -0
  108. package/lib/typescript/src/components/ChannelMessageList/index.d.ts +4 -1
  109. package/lib/typescript/src/components/GroupChannelMessageRenderer/GroupChannelMessageParentMessage.d.ts +9 -0
  110. package/lib/typescript/src/components/GroupChannelMessageRenderer/index.d.ts +1 -0
  111. package/lib/typescript/src/components/OpenChannelMessageRenderer/index.d.ts +1 -0
  112. package/lib/typescript/src/containers/SendbirdUIKitContainer.d.ts +4 -2
  113. package/lib/typescript/src/domain/groupChannel/component/GroupChannelMessageList.d.ts +4 -0
  114. package/lib/typescript/src/domain/groupChannel/types.d.ts +6 -2
  115. package/lib/typescript/src/domain/openChannel/component/OpenChannelHeader.d.ts +1 -1
  116. package/lib/typescript/src/domain/openChannel/types.d.ts +1 -2
  117. package/lib/typescript/src/libs/MentionManager.d.ts +1 -4
  118. package/lib/typescript/src/localization/StringSet.type.d.ts +7 -1
  119. package/lib/typescript/src/platform/types.d.ts +10 -11
  120. package/lib/typescript/src/version.d.ts +1 -1
  121. package/package.json +7 -6
  122. package/src/components/ChannelInput/SendInput.tsx +184 -51
  123. package/src/components/ChannelInput/index.tsx +11 -15
  124. package/src/components/ChannelMessageList/index.tsx +45 -27
  125. package/src/components/ChatFlatList/index.tsx +1 -1
  126. package/src/components/GroupChannelMessageRenderer/GroupChannelMessageFocusAnimation.tsx +5 -1
  127. package/src/components/GroupChannelMessageRenderer/GroupChannelMessageParentMessage.tsx +177 -0
  128. package/src/components/GroupChannelMessageRenderer/index.tsx +16 -1
  129. package/src/components/MessageSearchResultItem.tsx +3 -5
  130. package/src/components/ReactionAddons/BottomSheetReactionAddon.tsx +6 -7
  131. package/src/containers/GroupChannelPreviewContainer.tsx +6 -7
  132. package/src/containers/SendbirdUIKitContainer.tsx +40 -10
  133. package/src/contexts/SendbirdChatCtx.tsx +7 -1
  134. package/src/domain/groupChannel/component/GroupChannelInput.tsx +5 -1
  135. package/src/domain/groupChannel/component/GroupChannelMessageList.tsx +46 -13
  136. package/src/domain/groupChannel/module/moduleContext.tsx +38 -3
  137. package/src/domain/groupChannel/types.ts +8 -2
  138. package/src/domain/openChannel/types.ts +1 -2
  139. package/src/fragments/createGroupChannelFragment.tsx +15 -0
  140. package/src/hooks/useConnection.ts +1 -1
  141. package/src/hooks/useMentionSuggestion.ts +2 -1
  142. package/src/hooks/useMentionTextInput.ts +2 -2
  143. package/src/libs/MentionManager.tsx +1 -8
  144. package/src/localization/StringSet.type.ts +11 -0
  145. package/src/localization/createBaseStringSet.ts +30 -0
  146. package/src/platform/createFileService.native.ts +5 -1
  147. package/src/platform/createMediaService.native.tsx +1 -1
  148. package/src/platform/types.ts +9 -9
  149. package/src/utils/pubsub.ts +3 -1
  150. package/src/version.ts +1 -1
@@ -1 +1 @@
1
- {"version":3,"names":["Platform","getFileExtension","getFileExtensionFromMime","getFileExtensionFromUri","getFileType","normalizeFileName","SBUError","nativePermissionGranted","normalizeFile","getAndroidStoragePermissionsByAPILevel","permissionModule","OS","Version","PERMISSIONS","ANDROID","READ_MEDIA_AUDIO","READ_MEDIA_IMAGES","READ_MEDIA_VIDEO","READ_EXTERNAL_STORAGE","WRITE_EXTERNAL_STORAGE","createNativeFileService","_ref","imagePickerModule","documentPickerModule","mediaLibraryModule","fsModule","cameraPermissions","select","ios","IOS","CAMERA","MICROPHONE","android","default","mediaLibraryPermissions","MEDIA_LIBRARY","PHOTO_LIBRARY","NativeFileService","constructor","_defineProperty","options","dirname","Dirs","CacheDir","DocumentDir","context","filename","fileName","extension","fileType","fileUrl","path","buildDownloadPath","FileSystem","fetch","downloadedPath","file","name","type","hasCameraPermission","status","checkMultiple","requestCameraPermission","requestMultiple","hasMediaLibraryPermission","__DEV__","requestMediaLibraryPermission","openCamera","_response$assets","hasPermission","granted","_options$onOpenFailur","onOpenFailure","call","PERMISSIONS_DENIED","response","launchCamera","presentationStyle","cameraType","mediaType","didCancel","errorCode","_options$onOpenFailur2","DEVICE_UNAVAILABLE","Error","errorMessage","fileSize","size","uri","assets","openMediaLibrary","selectionLimit","_options$onOpenFailur3","launchImageLibrary","_options$onOpenFailur4","Promise","all","slice","map","_ref2","openDocument","pickSingle","e","isCancel","isInProgress","_options$onOpenFailur5","UNKNOWN","save","downloadFile","mediaTypeMap","externalDirMap","externalDir","cpExternal"],"sources":["createFileService.native.ts"],"sourcesContent":["import type { CameraRoll } from '@react-native-camera-roll/camera-roll';\nimport { Platform } from 'react-native';\nimport type * as DocumentPicker from 'react-native-document-picker';\nimport type * as FileAccess from 'react-native-file-access';\nimport type * as ImagePicker from 'react-native-image-picker';\nimport type * as Permissions from 'react-native-permissions';\nimport type { Permission } from 'react-native-permissions';\n\nimport {\n getFileExtension,\n getFileExtensionFromMime,\n getFileExtensionFromUri,\n getFileType,\n normalizeFileName,\n} from '@sendbird/uikit-utils';\n\nimport SBUError from '../libs/SBUError';\nimport nativePermissionGranted from '../utils/nativePermissionGranted';\nimport normalizeFile from '../utils/normalizeFile';\nimport type {\n FilePickerResponse,\n FileServiceInterface,\n OpenCameraOptions,\n OpenDocumentOptions,\n OpenMediaLibraryOptions,\n SaveOptions,\n} from './types';\n\nfunction getAndroidStoragePermissionsByAPILevel(permissionModule: typeof Permissions): Permission[] {\n if (Platform.OS !== 'android') return [];\n\n if (Platform.Version > 32) {\n return [\n permissionModule.PERMISSIONS.ANDROID.READ_MEDIA_AUDIO,\n permissionModule.PERMISSIONS.ANDROID.READ_MEDIA_IMAGES,\n permissionModule.PERMISSIONS.ANDROID.READ_MEDIA_VIDEO,\n ];\n }\n\n if (Platform.Version > 28) {\n return [permissionModule.PERMISSIONS.ANDROID.READ_EXTERNAL_STORAGE];\n }\n\n return [\n permissionModule.PERMISSIONS.ANDROID.WRITE_EXTERNAL_STORAGE,\n permissionModule.PERMISSIONS.ANDROID.READ_EXTERNAL_STORAGE,\n ];\n}\n\nconst createNativeFileService = ({\n imagePickerModule,\n documentPickerModule,\n permissionModule,\n mediaLibraryModule,\n fsModule,\n}: {\n imagePickerModule: typeof ImagePicker;\n documentPickerModule: typeof DocumentPicker;\n permissionModule: typeof Permissions;\n mediaLibraryModule: typeof CameraRoll;\n fsModule: typeof FileAccess;\n}): FileServiceInterface => {\n const cameraPermissions: Permission[] = Platform.select({\n ios: [permissionModule.PERMISSIONS.IOS.CAMERA, permissionModule.PERMISSIONS.IOS.MICROPHONE],\n android: [permissionModule.PERMISSIONS.ANDROID.CAMERA],\n default: [],\n });\n const mediaLibraryPermissions: Permission[] = Platform.select({\n ios: [permissionModule.PERMISSIONS.IOS.MEDIA_LIBRARY, permissionModule.PERMISSIONS.IOS.PHOTO_LIBRARY],\n android: getAndroidStoragePermissionsByAPILevel(permissionModule),\n default: [],\n });\n\n class NativeFileService implements FileServiceInterface {\n async hasCameraPermission(): Promise<boolean> {\n const status = await permissionModule.checkMultiple(cameraPermissions);\n return nativePermissionGranted(status);\n }\n async requestCameraPermission(): Promise<boolean> {\n const status = await permissionModule.requestMultiple(cameraPermissions);\n return nativePermissionGranted(status);\n }\n async hasMediaLibraryPermission(): Promise<boolean> {\n const status = await permissionModule.checkMultiple(mediaLibraryPermissions);\n if (\n __DEV__ &&\n Platform.OS === 'ios' &&\n status['ios.permission.MEDIA_LIBRARY'] === 'unavailable' &&\n status['ios.permission.PHOTO_LIBRARY'] === 'granted'\n ) {\n return true;\n }\n return nativePermissionGranted(status);\n }\n async requestMediaLibraryPermission(): Promise<boolean> {\n const status = await permissionModule.requestMultiple(mediaLibraryPermissions);\n return nativePermissionGranted(status);\n }\n\n async openCamera(options?: OpenCameraOptions): Promise<FilePickerResponse> {\n const hasPermission = await this.hasCameraPermission();\n if (!hasPermission) {\n const granted = await this.requestCameraPermission();\n if (!granted) {\n options?.onOpenFailure?.(SBUError.PERMISSIONS_DENIED);\n return null;\n }\n }\n\n const response = await imagePickerModule.launchCamera({\n presentationStyle: 'fullScreen',\n cameraType: options?.cameraType ?? 'back',\n mediaType: (() => {\n switch (options?.mediaType) {\n case 'photo':\n return 'photo';\n case 'video':\n return 'video';\n case 'all':\n return 'mixed';\n default:\n return 'photo';\n }\n })(),\n });\n if (response.didCancel) return null;\n if (response.errorCode === 'camera_unavailable') {\n options?.onOpenFailure?.(SBUError.DEVICE_UNAVAILABLE, new Error(response.errorMessage));\n return null;\n }\n\n const { fileName: name, fileSize: size, type, uri } = response.assets?.[0] ?? {};\n return normalizeFile({ uri, size, name, type });\n }\n async openMediaLibrary(options?: OpenMediaLibraryOptions): Promise<FilePickerResponse[] | null> {\n /**\n * NOTE: options.selectionLimit {@link https://github.com/react-native-image-picker/react-native-image-picker#options}\n * We do not support 0 (any number of files)\n **/\n const selectionLimit = options?.selectionLimit || 1;\n const hasPermission = await this.hasMediaLibraryPermission();\n if (!hasPermission) {\n const granted = await this.requestMediaLibraryPermission();\n if (!granted) {\n options?.onOpenFailure?.(SBUError.PERMISSIONS_DENIED);\n return null;\n }\n }\n\n const response = await imagePickerModule.launchImageLibrary({\n presentationStyle: 'fullScreen',\n selectionLimit,\n mediaType: (() => {\n switch (options?.mediaType) {\n case 'photo':\n return 'photo';\n case 'video':\n return 'video';\n case 'all':\n return 'mixed';\n default:\n return 'photo';\n }\n })(),\n });\n if (response.didCancel) return null;\n if (response.errorCode === 'camera_unavailable') {\n options?.onOpenFailure?.(SBUError.DEVICE_UNAVAILABLE, new Error(response.errorMessage));\n return null;\n }\n\n return Promise.all(\n (response.assets || [])\n .slice(0, selectionLimit)\n .map(({ fileName: name, fileSize: size, type, uri }) => normalizeFile({ uri, size, name, type })),\n );\n }\n async openDocument(options?: OpenDocumentOptions): Promise<FilePickerResponse> {\n try {\n const { uri, size, name, type } = await documentPickerModule.pickSingle();\n return normalizeFile({ uri, size, name, type });\n } catch (e) {\n if (!documentPickerModule.isCancel(e) && documentPickerModule.isInProgress(e)) {\n options?.onOpenFailure?.(SBUError.UNKNOWN, e);\n }\n return null;\n }\n }\n async save(options: SaveOptions): Promise<string> {\n const hasPermission = await this.hasMediaLibraryPermission();\n if (!hasPermission) {\n const granted = await this.requestMediaLibraryPermission();\n if (!granted) throw new Error('Permission not granted');\n }\n\n const { downloadedPath, file } = await this.downloadFile(options);\n\n if (Platform.OS === 'ios') {\n if (file.type === 'image' || file.type === 'video') {\n const mediaTypeMap = { 'image': 'photo', 'video': 'video' } as const;\n const mediaType = mediaTypeMap[file.type];\n await mediaLibraryModule.save(downloadedPath, { type: mediaType });\n }\n }\n\n if (Platform.OS === 'android') {\n const externalDirMap = { 'file': 'downloads', 'audio': 'audio', 'image': 'images', 'video': 'video' } as const;\n const externalDir = externalDirMap[file.type];\n await fsModule.FileSystem.cpExternal(downloadedPath, file.name, externalDir);\n }\n\n return downloadedPath;\n }\n\n private buildDownloadPath = async (options: SaveOptions) => {\n const dirname = Platform.select({ android: fsModule.Dirs.CacheDir, default: fsModule.Dirs.DocumentDir });\n const context = { dirname, filename: options.fileName };\n const extension =\n getFileExtension(options.fileName) ||\n getFileExtensionFromMime(options.fileType) ||\n getFileExtension(options.fileUrl) ||\n (await getFileExtensionFromUri(options.fileUrl));\n\n if (extension) context.filename = normalizeFileName(context.filename, extension);\n\n return { path: `${context.dirname}/${context.filename}`, ...context };\n };\n\n private downloadFile = async (options: SaveOptions) => {\n const { path, filename } = await this.buildDownloadPath(options);\n await fsModule.FileSystem.fetch(options.fileUrl, { path });\n return {\n downloadedPath: path,\n file: {\n name: filename,\n type: getFileType(getFileExtension(path)),\n } as const,\n };\n };\n }\n\n return new NativeFileService();\n};\n\nexport default createNativeFileService;\n"],"mappings":";;;AACA,SAASA,QAAQ,QAAQ,cAAc;AAOvC,SACEC,gBAAgB,EAChBC,wBAAwB,EACxBC,uBAAuB,EACvBC,WAAW,EACXC,iBAAiB,QACZ,uBAAuB;AAE9B,OAAOC,QAAQ,MAAM,kBAAkB;AACvC,OAAOC,uBAAuB,MAAM,kCAAkC;AACtE,OAAOC,aAAa,MAAM,wBAAwB;AAUlD,SAASC,sCAAsCA,CAACC,gBAAoC,EAAgB;EAClG,IAAIV,QAAQ,CAACW,EAAE,KAAK,SAAS,EAAE,OAAO,EAAE;EAExC,IAAIX,QAAQ,CAACY,OAAO,GAAG,EAAE,EAAE;IACzB,OAAO,CACLF,gBAAgB,CAACG,WAAW,CAACC,OAAO,CAACC,gBAAgB,EACrDL,gBAAgB,CAACG,WAAW,CAACC,OAAO,CAACE,iBAAiB,EACtDN,gBAAgB,CAACG,WAAW,CAACC,OAAO,CAACG,gBAAgB,CACtD;EACH;EAEA,IAAIjB,QAAQ,CAACY,OAAO,GAAG,EAAE,EAAE;IACzB,OAAO,CAACF,gBAAgB,CAACG,WAAW,CAACC,OAAO,CAACI,qBAAqB,CAAC;EACrE;EAEA,OAAO,CACLR,gBAAgB,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AAQ,CAAU;UACpE,MAAM9B,SAAS,GAAG8B,YAAY,CAACrD,IAAI,CAACE,IAAI,CAAC;UACzC,MAAMlC,kBAAkB,CAACmF,IAAI,CAACpD,cAAc,EAAE;YAAEG,IAAI,EAAEqB;UAAU,CAAC,CAAC;QACpE;MACF;MAEA,IAAI/E,QAAQ,CAACW,EAAE,KAAK,SAAS,EAAE;QAC7B,MAAMmG,cAAc,GAAG;UAAE,MAAM,EAAE,WAAW;UAAE,OAAO,EAAE,OAAO;UAAE,OAAO,EAAE,QAAQ;UAAE,OAAO,EAAE;QAAQ,CAAU;QAC9G,MAAMC,WAAW,GAAGD,cAAc,CAACtD,IAAI,CAACE,IAAI,CAAC;QAC7C,MAAMjC,QAAQ,CAAC4B,UAAU,CAAC2D,UAAU,CAACzD,cAAc,EAAEC,IAAI,CAACC,IAAI,EAAEsD,WAAW,CAAC;MAC9E;MAEA,OAAOxD,cAAc;IACvB;EA2BF;EAEA,OAAO,IAAIlB,iBAAiB,EAAE;AAChC,CAAC;AAED,eAAejB,uBAAuB"}
1
+ {"version":3,"names":["Platform","Logger","getFileExtension","getFileExtensionFromMime","getFileExtensionFromUri","getFileType","normalizeFileName","SBUError","nativePermissionGranted","normalizeFile","getAndroidStoragePermissionsByAPILevel","permissionModule","OS","Version","PERMISSIONS","ANDROID","READ_MEDIA_AUDIO","READ_MEDIA_IMAGES","READ_MEDIA_VIDEO","READ_EXTERNAL_STORAGE","WRITE_EXTERNAL_STORAGE","createNativeFileService","_ref","imagePickerModule","documentPickerModule","mediaLibraryModule","fsModule","cameraPermissions","select","ios","IOS","CAMERA","MICROPHONE","android","default","mediaLibraryPermissions","MEDIA_LIBRARY","PHOTO_LIBRARY","NativeFileService","constructor","_defineProperty","options","dirname","Dirs","CacheDir","DocumentDir","context","filename","fileName","extension","fileType","fileUrl","path","buildDownloadPath","FileSystem","fetch","downloadedPath","file","name","type","hasCameraPermission","status","checkMultiple","requestCameraPermission","requestMultiple","hasMediaLibraryPermission","__DEV__","requestMediaLibraryPermission","openCamera","_response$assets","hasPermission","granted","_options$onOpenFailur","onOpenFailure","call","PERMISSIONS_DENIED","response","launchCamera","presentationStyle","cameraType","mediaType","didCancel","errorCode","_options$onOpenFailur2","DEVICE_UNAVAILABLE","Error","errorMessage","fileSize","size","uri","assets","openMediaLibrary","selectionLimit","_options$onOpenFailur3","launchImageLibrary","_options$onOpenFailur4","Promise","all","slice","map","_ref2","openDocument","pickSingle","e","isCancel","isInProgress","_options$onOpenFailur5","UNKNOWN","save","downloadFile","mediaTypeMap","externalDirMap","externalDir","cpExternal","catch","error"],"sources":["createFileService.native.ts"],"sourcesContent":["import type { CameraRoll } from '@react-native-camera-roll/camera-roll';\nimport { Platform } from 'react-native';\nimport type * as DocumentPicker from 'react-native-document-picker';\nimport type * as FileAccess from 'react-native-file-access';\nimport type * as ImagePicker from 'react-native-image-picker';\nimport type * as Permissions from 'react-native-permissions';\nimport type { Permission } from 'react-native-permissions';\n\nimport {\n Logger,\n getFileExtension,\n getFileExtensionFromMime,\n getFileExtensionFromUri,\n getFileType,\n normalizeFileName,\n} from '@sendbird/uikit-utils';\n\nimport SBUError from '../libs/SBUError';\nimport nativePermissionGranted from '../utils/nativePermissionGranted';\nimport normalizeFile from '../utils/normalizeFile';\nimport type {\n FilePickerResponse,\n FileServiceInterface,\n OpenCameraOptions,\n OpenDocumentOptions,\n OpenMediaLibraryOptions,\n SaveOptions,\n} from './types';\n\nfunction getAndroidStoragePermissionsByAPILevel(permissionModule: typeof Permissions): Permission[] {\n if (Platform.OS !== 'android') return [];\n\n if (Platform.Version > 32) {\n return [\n permissionModule.PERMISSIONS.ANDROID.READ_MEDIA_AUDIO,\n permissionModule.PERMISSIONS.ANDROID.READ_MEDIA_IMAGES,\n permissionModule.PERMISSIONS.ANDROID.READ_MEDIA_VIDEO,\n ];\n }\n\n if (Platform.Version > 28) {\n return [permissionModule.PERMISSIONS.ANDROID.READ_EXTERNAL_STORAGE];\n }\n\n return [\n permissionModule.PERMISSIONS.ANDROID.WRITE_EXTERNAL_STORAGE,\n permissionModule.PERMISSIONS.ANDROID.READ_EXTERNAL_STORAGE,\n ];\n}\n\nconst createNativeFileService = ({\n imagePickerModule,\n documentPickerModule,\n permissionModule,\n mediaLibraryModule,\n fsModule,\n}: {\n imagePickerModule: typeof ImagePicker;\n documentPickerModule: typeof DocumentPicker;\n permissionModule: typeof Permissions;\n mediaLibraryModule: typeof CameraRoll;\n fsModule: typeof FileAccess;\n}): FileServiceInterface => {\n const cameraPermissions: Permission[] = Platform.select({\n ios: [permissionModule.PERMISSIONS.IOS.CAMERA, permissionModule.PERMISSIONS.IOS.MICROPHONE],\n android: [permissionModule.PERMISSIONS.ANDROID.CAMERA],\n default: [],\n });\n const mediaLibraryPermissions: Permission[] = Platform.select({\n ios: [permissionModule.PERMISSIONS.IOS.MEDIA_LIBRARY, permissionModule.PERMISSIONS.IOS.PHOTO_LIBRARY],\n android: getAndroidStoragePermissionsByAPILevel(permissionModule),\n default: [],\n });\n\n class NativeFileService implements FileServiceInterface {\n async hasCameraPermission(): Promise<boolean> {\n const status = await permissionModule.checkMultiple(cameraPermissions);\n return nativePermissionGranted(status);\n }\n async requestCameraPermission(): Promise<boolean> {\n const status = await permissionModule.requestMultiple(cameraPermissions);\n return nativePermissionGranted(status);\n }\n async hasMediaLibraryPermission(): Promise<boolean> {\n const status = await permissionModule.checkMultiple(mediaLibraryPermissions);\n if (\n __DEV__ &&\n Platform.OS === 'ios' &&\n status['ios.permission.MEDIA_LIBRARY'] === 'unavailable' &&\n status['ios.permission.PHOTO_LIBRARY'] === 'granted'\n ) {\n return true;\n }\n return nativePermissionGranted(status);\n }\n async requestMediaLibraryPermission(): Promise<boolean> {\n const status = await permissionModule.requestMultiple(mediaLibraryPermissions);\n return nativePermissionGranted(status);\n }\n\n async openCamera(options?: OpenCameraOptions): Promise<FilePickerResponse> {\n const hasPermission = await this.hasCameraPermission();\n if (!hasPermission) {\n const granted = await this.requestCameraPermission();\n if (!granted) {\n options?.onOpenFailure?.(SBUError.PERMISSIONS_DENIED);\n return null;\n }\n }\n\n const response = await imagePickerModule.launchCamera({\n presentationStyle: 'fullScreen',\n cameraType: options?.cameraType ?? 'back',\n mediaType: (() => {\n switch (options?.mediaType) {\n case 'photo':\n return 'photo';\n case 'video':\n return 'video';\n case 'all':\n return 'mixed';\n default:\n return 'photo';\n }\n })(),\n });\n if (response.didCancel) return null;\n if (response.errorCode === 'camera_unavailable') {\n options?.onOpenFailure?.(SBUError.DEVICE_UNAVAILABLE, new Error(response.errorMessage));\n return null;\n }\n\n const { fileName: name, fileSize: size, type, uri } = response.assets?.[0] ?? {};\n return normalizeFile({ uri, size, name, type });\n }\n async openMediaLibrary(options?: OpenMediaLibraryOptions): Promise<FilePickerResponse[] | null> {\n /**\n * NOTE: options.selectionLimit {@link https://github.com/react-native-image-picker/react-native-image-picker#options}\n * We do not support 0 (any number of files)\n **/\n const selectionLimit = options?.selectionLimit || 1;\n const hasPermission = await this.hasMediaLibraryPermission();\n if (!hasPermission) {\n const granted = await this.requestMediaLibraryPermission();\n if (!granted) {\n options?.onOpenFailure?.(SBUError.PERMISSIONS_DENIED);\n return null;\n }\n }\n\n const response = await imagePickerModule.launchImageLibrary({\n presentationStyle: 'fullScreen',\n selectionLimit,\n mediaType: (() => {\n switch (options?.mediaType) {\n case 'photo':\n return 'photo';\n case 'video':\n return 'video';\n case 'all':\n return 'mixed';\n default:\n return 'photo';\n }\n })(),\n });\n if (response.didCancel) return null;\n if (response.errorCode === 'camera_unavailable') {\n options?.onOpenFailure?.(SBUError.DEVICE_UNAVAILABLE, new Error(response.errorMessage));\n return null;\n }\n\n return Promise.all(\n (response.assets || [])\n .slice(0, selectionLimit)\n .map(({ fileName: name, fileSize: size, type, uri }) => normalizeFile({ uri, size, name, type })),\n );\n }\n async openDocument(options?: OpenDocumentOptions): Promise<FilePickerResponse> {\n try {\n const { uri, size, name, type } = await documentPickerModule.pickSingle();\n return normalizeFile({ uri, size, name, type });\n } catch (e) {\n if (!documentPickerModule.isCancel(e) && documentPickerModule.isInProgress(e)) {\n options?.onOpenFailure?.(SBUError.UNKNOWN, e);\n }\n return null;\n }\n }\n async save(options: SaveOptions): Promise<string> {\n const hasPermission = await this.hasMediaLibraryPermission();\n if (!hasPermission) {\n const granted = await this.requestMediaLibraryPermission();\n if (!granted) throw new Error('Permission not granted');\n }\n\n const { downloadedPath, file } = await this.downloadFile(options);\n\n if (Platform.OS === 'ios') {\n if (file.type === 'image' || file.type === 'video') {\n const mediaTypeMap = { 'image': 'photo', 'video': 'video' } as const;\n const mediaType = mediaTypeMap[file.type];\n await mediaLibraryModule.save(downloadedPath, { type: mediaType });\n }\n }\n\n if (Platform.OS === 'android') {\n const externalDirMap = { 'file': 'downloads', 'audio': 'audio', 'image': 'images', 'video': 'video' } as const;\n const externalDir = externalDirMap[file.type];\n await fsModule.FileSystem.cpExternal(downloadedPath, file.name, externalDir).catch(() => {\n Logger.error('Failed to save file to external storage. Retry saving to downloads directory instead.');\n return fsModule.FileSystem.cpExternal(downloadedPath, file.name, 'downloads');\n });\n }\n\n return downloadedPath;\n }\n\n private buildDownloadPath = async (options: SaveOptions) => {\n const dirname = Platform.select({ android: fsModule.Dirs.CacheDir, default: fsModule.Dirs.DocumentDir });\n const context = { dirname, filename: options.fileName };\n const extension =\n getFileExtension(options.fileName) ||\n getFileExtensionFromMime(options.fileType) ||\n getFileExtension(options.fileUrl) ||\n (await getFileExtensionFromUri(options.fileUrl));\n\n if (extension) context.filename = normalizeFileName(context.filename, extension);\n\n return { path: `${context.dirname}/${context.filename}`, ...context };\n };\n\n private downloadFile = async (options: SaveOptions) => {\n const { path, filename } = await this.buildDownloadPath(options);\n await fsModule.FileSystem.fetch(options.fileUrl, { path });\n return {\n downloadedPath: path,\n file: {\n name: filename,\n type: getFileType(getFileExtension(path)),\n } as const,\n };\n };\n }\n\n return new NativeFileService();\n};\n\nexport default createNativeFileService;\n"],"mappings":";;;AACA,SAASA,QAAQ,QAAQ,cAAc;A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AI,EAAEsD,WAAW,CAAC,CAACE,KAAK,CAAC,MAAM;UACvFjH,MAAM,CAACkH,KAAK,CAAC,uFAAuF,CAAC;UACrG,OAAOzF,QAAQ,CAAC4B,UAAU,CAAC2D,UAAU,CAACzD,cAAc,EAAEC,IAAI,CAACC,IAAI,EAAE,WAAW,CAAC;QAC/E,CAAC,CAAC;MACJ;MAEA,OAAOF,cAAc;IACvB;EA2BF;EAEA,OAAO,IAAIlB,iBAAiB,EAAE;AAChC,CAAC;AAED,eAAejB,uBAAuB"}
@@ -35,7 +35,7 @@ const createNativeMediaService = _ref => {
35
35
  url,
36
36
  format: 'jpeg',
37
37
  timeStamp: timeMills,
38
- cacheName: hash(url)
38
+ cacheName: hash(url.split('?')[0])
39
39
  });
40
40
  return {
41
41
  path
@@ -1 +1 @@
1
- {"version":3,"names":["React","getDownscaleSize","getFileExtension","hash","SBUUtils","createNativeMediaService","_ref","VideoComponent","thumbnailModule","imageResizerModule","_ref2","source","resizeMode","onLoad","props","createElement","_extends","controls","getVideoThumbnail","_ref3","url","timeMills","path","createThumbnail","format","timeStamp","cacheName","compressImage","_ref4","uri","maxWidth","maxHeight","compressionRate","originSize","getImageSize","width","height","extension","size","resizedSize","compressedURI","default","createResizedImage","Math","min","max"],"sources":["createMediaService.native.tsx"],"sourcesContent":["import type * as RNImageResizer from '@bam.tech/react-native-image-resizer';\nimport React from 'react';\nimport type * as RNCreateThumbnail from 'react-native-create-thumbnail';\nimport type RNVideo from 'react-native-video';\n\nimport { getDownscaleSize, getFileExtension, hash } from '@sendbird/uikit-utils';\n\nimport SBUUtils from '../libs/SBUUtils';\nimport type { MediaServiceInterface } from './types';\n\ntype Modules = {\n VideoComponent: typeof RNVideo;\n thumbnailModule: typeof RNCreateThumbnail;\n imageResizerModule: typeof RNImageResizer;\n};\n\nconst createNativeMediaService = ({\n VideoComponent,\n thumbnailModule,\n imageResizerModule,\n}: Modules): MediaServiceInterface => {\n return {\n VideoComponent({ source, resizeMode, onLoad, ...props }) {\n return <VideoComponent {...props} source={source} resizeMode={resizeMode} onLoad={onLoad} controls />;\n },\n async getVideoThumbnail({ url, timeMills }) {\n try {\n const { path } = await thumbnailModule.createThumbnail({\n url,\n format: 'jpeg',\n timeStamp: timeMills,\n cacheName: hash(url),\n });\n return { path };\n } catch {\n return null;\n }\n },\n async compressImage({ uri, maxWidth, maxHeight, compressionRate = 1 }) {\n const originSize = await SBUUtils.getImageSize(uri);\n const { width, height } = getDownscaleSize(originSize, { width: maxWidth, height: maxHeight });\n const extension = (() => {\n return { 'png': 'PNG', 'jpeg': 'JPEG', 'jpg': 'JPEG' }[getFileExtension(uri)] ?? 'JPEG';\n })() as 'PNG' | 'JPEG';\n\n const { size: resizedSize, uri: compressedURI } = await imageResizerModule.default.createResizedImage(\n uri,\n width,\n height,\n extension,\n Math.min(Math.max(0, compressionRate), 1) * 100,\n );\n\n return { uri: compressedURI, size: resizedSize };\n },\n };\n};\n\nexport default createNativeMediaService;\n"],"mappings":";AACA,OAAOA,KAAK,MAAM,OAAO;AAIzB,SAASC,gBAAgB,EAAEC,gBAAgB,EAAEC,IAAI,QAAQ,uBAAuB;AAEhF,OAAOC,QAAQ,MAAM,kBAAkB;AASvC,MAAMC,wBAAwB,GAAGC,IAAA,IAIK;EAAA,IAJJ;IAChCC,cAAc;IACdC,eAAe;IACfC;EACO,CAAC,GAAAH,IAAA;EACR,OAAO;IACLC,cAAcA,CAAAG,KAAA,EAA2C;MAAA,IAA1C;QAAEC,MAAM;QAAEC,UAAU;QAAEC,MAAM;QAAE,GAAGC;MAAM,CAAC,GAAAJ,KAAA;MACrD,oBAAOV,KAAA,CAAAe,aAAA,CAACR,cAAc,EAAAS,QAAA,KAAKF,KAAK;QAAEH,MAAM,EAAEA,MAAO;QAACC,UAAU,EAAEA,UAAW;QAACC,MAAM,EAAEA,MAAO;QAACI,QAAQ;MAAA,GAAG;IACvG,CAAC;IACD,MAAMC,iBAAiBA,CAAAC,KAAA,EAAqB;MAAA,IAApB;QAA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AEC;MAAY,CAAC;IAClD;EACF,CAAC;AACH,CAAC;AAED,eAAelC,wBAAwB"}
1
+ {"version":3,"names":["React","getDownscaleSize","getFileExtension","hash","SBUUtils","createNativeMediaService","_ref","VideoComponent","thumbnailModule","imageResizerModule","_ref2","source","resizeMode","onLoad","props","createElement","_extends","controls","getVideoThumbnail","_ref3","url","timeMills","path","createThumbnail","format","timeStamp","cacheName","split","compressImage","_ref4","uri","maxWidth","maxHeight","compressionRate","originSize","getImageSize","width","height","extension","size","resizedSize","compressedURI","default","createResizedImage","Math","min","max"],"sources":["createMediaService.native.tsx"],"sourcesContent":["import type * as RNImageResizer from '@bam.tech/react-native-image-resizer';\nimport React from 'react';\nimport type * as RNCreateThumbnail from 'react-native-create-thumbnail';\nimport type RNVideo from 'react-native-video';\n\nimport { getDownscaleSize, getFileExtension, hash } from '@sendbird/uikit-utils';\n\nimport SBUUtils from '../libs/SBUUtils';\nimport type { MediaServiceInterface } from './types';\n\ntype Modules = {\n VideoComponent: typeof RNVideo;\n thumbnailModule: typeof RNCreateThumbnail;\n imageResizerModule: typeof RNImageResizer;\n};\n\nconst createNativeMediaService = ({\n VideoComponent,\n thumbnailModule,\n imageResizerModule,\n}: Modules): MediaServiceInterface => {\n return {\n VideoComponent({ source, resizeMode, onLoad, ...props }) {\n return <VideoComponent {...props} source={source} resizeMode={resizeMode} onLoad={onLoad} controls />;\n },\n async getVideoThumbnail({ url, timeMills }) {\n try {\n const { path } = await thumbnailModule.createThumbnail({\n url,\n format: 'jpeg',\n timeStamp: timeMills,\n cacheName: hash(url.split('?')[0]),\n });\n return { path };\n } catch {\n return null;\n }\n },\n async compressImage({ uri, maxWidth, maxHeight, compressionRate = 1 }) {\n const originSize = await SBUUtils.getImageSize(uri);\n const { width, height } = getDownscaleSize(originSize, { width: maxWidth, height: maxHeight });\n const extension = (() => {\n return { 'png': 'PNG', 'jpeg': 'JPEG', 'jpg': 'JPEG' }[getFileExtension(uri)] ?? 'JPEG';\n })() as 'PNG' | 'JPEG';\n\n const { size: resizedSize, uri: compressedURI } = await imageResizerModule.default.createResizedImage(\n uri,\n width,\n height,\n extension,\n Math.min(Math.max(0, compressionRate), 1) * 100,\n );\n\n return { uri: compressedURI, size: resizedSize };\n },\n };\n};\n\nexport default createNativeMediaService;\n"],"mappings":";AACA,OAAOA,KAAK,MAAM,OAAO;AAIzB,SAASC,gBAAgB,EAAEC,gBAAgB,EAAEC,IAAI,QAAQ,uBAAuB;AAEhF,OAAOC,QAAQ,MAAM,kBAAkB;AASvC,MAAMC,wBAAwB,GAAGC,IAAA,IAIK;EAAA,IAJJ;IAChCC,cAAc;IACdC,eAAe;IACfC;EACO,CAAC,GAAAH,IAAA;EACR,OAAO;IACLC,cAAcA,CAAAG,KAAA,EAA2C;MAAA,IAA1C;QAAEC,MAAM;QAAEC,UAAU;QAAEC,MAAM;QAAE,GAAGC;MAAM,CAAC,GAAAJ,KAAA;MACrD,oBAAOV,KAAA,CAAAe,aAAA,CAACR,cAAc,EAAAS,QAAA,KAAKF,KAAK;QAAEH,MAAM,EAAEA,MAAO;QAACC,UAAU,EAAEA,UAAW;QAACC,MAAM,EAAEA,MAAO;QAACI,QAAQ;MAAA,GAAG;IACvG,CAAC;IACD,MAAMC,iBAAiBA,CAAAC,KAAA,EAAqB;MAAA,IAApB;QAAEC,GAAG;QAAEC;MAAU,CAAC,GAAAF,KAAA;MACxC,IAAI;QACF,MAAM;UAAEG;QAAK,CAAC,GAAG,MAAMd,eAAe,CAACe,eAAe,CAAC;UACrDH,GAAG;UACHI,MAAM,EAAE,MAAM;UACdC,SAAS,EAAEJ,SAAS;UACpBK,SAAS,EAAEvB,IAAI,CAACiB,GAAG,CAACO,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QACnC,CAAC,CAAC;QACF,OAAO;UAAEL;QAAK,CAAC;MACjB,CAAC,CAAC,MAAM;QACN,OAAO,IAAI;MACb;IACF,CAAC;IACD,MAAMM,aAAaA,CAAAC,KAAA,EAAoD;MAAA,IAAnD;QAAEC,GAAG;QAAEC,QAAQ;QAAEC,SAAS;QAAEC,eAAe,GAAG;MAAE,CAAC,GAAAJ,KAAA;MACnE,MAAMK,UAAU,GAAG,MAAM9B,QAAQ,CAAC+B,YAAY,CAACL,GAAG,CAAC;MACnD,MAAM;QAAEM,KAAK;QAAEC;MAAO,CAAC,GAAGpC,gBAAgB,CAACiC,UAAU,EAAE;QAAEE,KAAK,EAAEL,QAAQ;QAAEM,MAAM,EAAEL;MAAU,CAAC,CAAC;MAC9F,MAAMM,SAAS,GAAG,CAAC,MAAM;QACvB,OAAO;UAAE,KAAK,EAAE,KAAK;UAAE,MAAM,EAAE,MAAM;UAAE,KAAK,EAAE;QAAO,CAAC,CAACpC,gBAAgB,CAAC4B,GAAG,CAAC,CAAC,IAAI,MAAM;MACzF,CAAC,GAAqB;MAEtB,MAAM;QAAES,IAAI,EAAEC,WAAW;QAAEV,GAAG,EAAEW;MAAc,CAAC,GAAG,MAAMhC,kBAAkB,CAACiC,OAAO,CAACC,kBAAkB,CACnGb,GAAG,EACHM,KAAK,EACLC,MAAM,EACNC,SAAS,EACTM,IAAI,CAACC,GAAG,CAACD,IAAI,CAACE,GAAG,CAAC,CAAC,EAAEb,eAAe,CAAC,EAAE,CAAC,CAAC,GAAG,GAAG,CAChD;MAED,OAAO;QAAEH,GAAG,EAAEW,aAAa;QAAEF,IAAI,EAAEC;MAAY,CAAC;IAClD;EACF,CAAC;AACH,CAAC;AAED,eAAenC,wBAAwB"}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type SBUError from '../libs/SBUError';\n\nexport type Unsubscribe = () => void | undefined;\nexport type DownloadedPath = string;\nexport type FilePickerResponse = FileType | null;\n\n/**\n * We are following the file format of react-native FormData\n * @see https://github.com/facebook/react-native/blob/main/packages/react-native/Libraries/Network/FormData.js#L37-L41\n * */\nexport type FileType = { name: string; uri: string; size: number; type: string };\n\n// ---------- NotificationService ---------- //\nexport interface NotificationServiceInterface {\n hasPushPermission(): Promise<boolean>;\n requestPushPermission(): Promise<boolean>;\n\n getAPNSToken(): Promise<string | null>;\n getFCMToken(): Promise<string | null>;\n onTokenRefresh(handler: (token: string) => void): Unsubscribe;\n}\n\n// ---------- ClipboardService ---------- //\nexport interface ClipboardServiceInterface {\n setString(text: string): void;\n getString(): Promise<string>;\n}\n\n// ---------- FileService ---------- //\nexport interface FileServiceInterface extends FilePickerServiceInterface, FileSystemServiceInterface {}\n\nexport interface OpenResultListener {\n onOpenFailure?: (error: SBUError, originError?: unknown) => void;\n}\nexport interface OpenMediaLibraryOptions extends OpenResultListener {\n selectionLimit?: number;\n mediaType?: 'photo' | 'video' | 'all';\n}\nexport interface OpenCameraOptions extends OpenResultListener {\n cameraType?: 'front' | 'back';\n mediaType?: 'photo' | 'video' | 'all';\n}\nexport type OpenDocumentOptions = OpenResultListener;\nexport interface SaveOptions {\n fileUrl: string;\n fileName: string;\n fileType?: string | null;\n}\n\nexport interface FilePickerServiceInterface {\n openMediaLibrary(options?: OpenMediaLibraryOptions): Promise<null | FilePickerResponse[]>;\n openCamera(options?: OpenCameraOptions): Promise<FilePickerResponse>;\n openDocument(options?: OpenDocumentOptions): Promise<FilePickerResponse>;\n}\n\nexport interface FileSystemServiceInterface {\n // NOTE: On iOS, You can access the downloaded files by providing options below to info.plist\n // - Supports opening documents in place\n // - Application supports iTunes file sharing\n save(options?: SaveOptions): Promise<DownloadedPath | null>;\n}\n\n// ---------- MediaService ---------- //\ninterface VideoProps {\n source: { uri: string } | number;\n resizeMode?: 'cover' | 'contain' | 'stretch';\n onLoad?: () => void;\n}\ninterface GetVideoThumbnailOptions {\n url: string;\n timeMills?: number;\n quality?: number;\n}\n\ninterface CompressImageOptions {\n /**\n * A uri of image file to compress\n * */\n uri: string;\n\n /**\n * A resize width, apply only to downscale\n * */\n maxWidth?: number;\n\n /**\n * A resize height, apply only to downscale\n * */\n maxHeight?: number;\n\n /**\n * A value in range 0.0 - 1.0 specifying compression level of the result image.\n * 1 means highest quality and 0 the lowest quality.\n * */\n compressionRate?: number;\n}\n\ntype GetVideoThumbnailResult = Promise<{ path: string } | null>;\ntype CompressImageResult = Promise<{ uri: string; size: number } | null>;\n\nexport interface MediaServiceInterface {\n VideoComponent<Props = {}>(props: VideoProps & Props): JSX.Element;\n getVideoThumbnail(options: GetVideoThumbnailOptions): GetVideoThumbnailResult;\n compressImage(options: CompressImageOptions): CompressImageResult;\n}\n"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type SBUError from '../libs/SBUError';\n\nexport type Unsubscribe = () => void | undefined;\nexport type DownloadedPath = string;\nexport type FilePickerResponse = FileType | null;\n\n/**\n * We are following the file format of react-native FormData\n * @see https://github.com/facebook/react-native/blob/main/packages/react-native/Libraries/Network/FormData.js#L37-L41\n * */\nexport type FileType = { name: string; uri: string; size: number; type: string };\n\n// ---------- NotificationService ---------- //\nexport interface NotificationServiceInterface {\n hasPushPermission(): Promise<boolean>;\n requestPushPermission(): Promise<boolean>;\n\n getAPNSToken(): Promise<string | null>;\n getFCMToken(): Promise<string | null>;\n onTokenRefresh(handler: (token: string) => void): Unsubscribe;\n}\n\n// ---------- ClipboardService ---------- //\nexport interface ClipboardServiceInterface {\n setString(text: string): void;\n getString(): Promise<string>;\n}\n\n// ---------- FileService ---------- //\nexport interface FileServiceInterface extends FilePickerServiceInterface, FileSystemServiceInterface {}\n\nexport interface OpenResultListener {\n onOpenFailure?: (error: SBUError, originError?: unknown) => void;\n}\nexport interface OpenMediaLibraryOptions extends OpenResultListener {\n selectionLimit?: number;\n mediaType?: 'photo' | 'video' | 'all';\n}\nexport interface OpenCameraOptions extends OpenResultListener {\n cameraType?: 'front' | 'back';\n mediaType?: 'photo' | 'video' | 'all';\n}\nexport type OpenDocumentOptions = OpenResultListener;\nexport interface SaveOptions {\n fileUrl: string;\n fileName: string;\n fileType?: string | null;\n}\n\nexport interface FilePickerServiceInterface {\n openMediaLibrary(options?: OpenMediaLibraryOptions): Promise<null | FilePickerResponse[]>;\n openCamera(options?: OpenCameraOptions): Promise<FilePickerResponse>;\n openDocument(options?: OpenDocumentOptions): Promise<FilePickerResponse>;\n}\n\nexport interface FileSystemServiceInterface {\n // NOTE: On iOS, You can access the downloaded files by providing options below to info.plist\n // - Supports opening documents in place\n // - Application supports iTunes file sharing\n save(options?: SaveOptions): Promise<DownloadedPath | null>;\n}\n\n// ---------- MediaService ---------- //\nexport type VideoProps = {\n source: { uri: string } | number;\n resizeMode?: 'cover' | 'contain' | 'stretch';\n onLoad?: () => void;\n};\n\nexport type GetVideoThumbnailOptions = {\n url: string;\n timeMills?: number;\n quality?: number;\n};\nexport type GetVideoThumbnailResult = Promise<{ path: string } | null>;\n\nexport type CompressImageOptions = {\n /**\n * A uri of image file to compress\n * */\n uri: string;\n\n /**\n * A resize width, apply only to downscale\n * */\n maxWidth?: number;\n\n /**\n * A resize height, apply only to downscale\n * */\n maxHeight?: number;\n\n /**\n * A value in range 0.0 - 1.0 specifying compression level of the result image.\n * 1 means highest quality and 0 the lowest quality.\n * */\n compressionRate?: number;\n};\nexport type CompressImageResult = Promise<{ uri: string; size: number } | null>;\n\nexport interface MediaServiceInterface {\n VideoComponent<Props = {}>(props: VideoProps & Props): JSX.Element;\n getVideoThumbnail(options: GetVideoThumbnailOptions): GetVideoThumbnailResult;\n compressImage(options: CompressImageOptions): CompressImageResult;\n}\n"],"mappings":""}
@@ -2,7 +2,9 @@ const pubsub = () => {
2
2
  const subscribers = new Set();
3
3
  return {
4
4
  publish: data => {
5
- subscribers.forEach(subscriber => subscriber(data));
5
+ subscribers.forEach(subscriber => {
6
+ setTimeout(() => subscriber(data), 0);
7
+ });
6
8
  },
7
9
  subscribe: subscriber => {
8
10
  subscribers.add(subscriber);
@@ -1 +1 @@
1
- {"version":3,"names":["pubsub","subscribers","Set","publish","data","forEach","subscriber","subscribe","add","delete"],"sources":["pubsub.ts"],"sourcesContent":["export type PubSub<T> = {\n publish: (data: T) => void;\n subscribe: (subscriber: (data: T) => void) => () => void;\n};\n\nconst pubsub = <T>(): PubSub<T> => {\n const subscribers = new Set<Function>();\n\n return {\n publish: (data: unknown) => {\n subscribers.forEach((subscriber) => subscriber(data));\n },\n subscribe: (subscriber: Function) => {\n subscribers.add(subscriber);\n return () => subscribers.delete(subscriber);\n },\n };\n};\n\nexport default pubsub;\n"],"mappings":"AAKA,MAAMA,MAAM,GAAGA,CAAA,KAAoB;EACjC,MAAMC,WAAW,GAAG,IAAIC,GAAG,EAAY;EAEvC,OAAO;IACLC,OAAO,EAAGC,IAAa,IAAK;MAC1BH,WAAW,CAACI,OAAO,CAAEC,UAAU,IAAKA,UAAU,CAACF,IAAI,CAAC,CAAC;IACvD,CAAC;IACDG,SAAS,EAAGD,UAAoB,IAAK;MACnCL,WAAW,CAACO,GAAG,CAACF,UAAU,CAAC;MAC3B,OAAO,MAAML,WAAW,CAACQ,MAAM,CAACH,UAAU,CAAC;IAC7C;EACF,CAAC;AACH,CAAC;AAED,eAAeN,MAAM"}
1
+ {"version":3,"names":["pubsub","subscribers","Set","publish","data","forEach","subscriber","setTimeout","subscribe","add","delete"],"sources":["pubsub.ts"],"sourcesContent":["export type PubSub<T> = {\n publish: (data: T) => void;\n subscribe: (subscriber: (data: T) => void) => () => void;\n};\n\nconst pubsub = <T>(): PubSub<T> => {\n const subscribers = new Set<Function>();\n\n return {\n publish: (data: unknown) => {\n subscribers.forEach((subscriber) => {\n setTimeout(() => subscriber(data), 0);\n });\n },\n subscribe: (subscriber: Function) => {\n subscribers.add(subscriber);\n return () => subscribers.delete(subscriber);\n },\n };\n};\n\nexport default pubsub;\n"],"mappings":"AAKA,MAAMA,MAAM,GAAGA,CAAA,KAAoB;EACjC,MAAMC,WAAW,GAAG,IAAIC,GAAG,EAAY;EAEvC,OAAO;IACLC,OAAO,EAAGC,IAAa,IAAK;MAC1BH,WAAW,CAACI,OAAO,CAAEC,UAAU,IAAK;QAClCC,UAAU,CAAC,MAAMD,UAAU,CAACF,IAAI,CAAC,EAAE,CAAC,CAAC;MACvC,CAAC,CAAC;IACJ,CAAC;IACDI,SAAS,EAAGF,UAAoB,IAAK;MACnCL,WAAW,CAACQ,GAAG,CAACH,UAAU,CAAC;MAC3B,OAAO,MAAML,WAAW,CAACS,MAAM,CAACJ,UAAU,CAAC;IAC7C;EACF,CAAC;AACH,CAAC;AAED,eAAeN,MAAM"}
@@ -1,3 +1,3 @@
1
- const VERSION = '3.0.4-rc.1';
1
+ const VERSION = '3.1.0';
2
2
  export default VERSION;
3
3
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["VERSION"],"sources":["version.ts"],"sourcesContent":["const VERSION = '3.0.4-rc.1';\nexport default VERSION;\n"],"mappings":"AAAA,MAAMA,OAAO,GAAG,YAAY;AAC5B,eAAeA,OAAO"}
1
+ {"version":3,"names":["VERSION"],"sources":["version.ts"],"sourcesContent":["const VERSION = '3.1.0';\nexport default VERSION;\n"],"mappings":"AAAA,MAAMA,OAAO,GAAG,OAAO;AACvB,eAAeA,OAAO"}
@@ -24,6 +24,8 @@ export type ChannelInputProps = {
24
24
  inputDisabled: boolean;
25
25
  messageToEdit: undefined | SendbirdUserMessage | SendbirdFileMessage;
26
26
  setMessageToEdit: (message?: undefined | SendbirdUserMessage | SendbirdFileMessage) => void;
27
+ messageToReply?: undefined | SendbirdUserMessage | SendbirdFileMessage;
28
+ setMessageToReply?: (message?: undefined | SendbirdUserMessage | SendbirdFileMessage) => void;
27
29
  SuggestedMentionList?: (props: SuggestedMentionListProps) => JSX.Element | null;
28
30
  AttachmentsButton?: (props: AttachmentsButtonProps) => JSX.Element | null;
29
31
  };
@@ -21,8 +21,10 @@ export type ChannelMessageListProps<T extends SendbirdGroupChannel | SendbirdOpe
21
21
  onPressNewMessagesButton: (animated?: boolean) => void;
22
22
  onPressScrollToBottomButton: (animated?: boolean) => void;
23
23
  onEditMessage: (message: HandleableMessage) => void;
24
+ onReplyMessage?: (message: HandleableMessage) => void;
24
25
  onDeleteMessage: (message: HandleableMessage) => Promise<void>;
25
26
  onResendFailedMessage: (failedMessage: HandleableMessage) => Promise<void>;
27
+ onPressParentMessage?: (parentMessage: SendbirdMessage) => void;
26
28
  onPressMediaMessage?: (message: SendbirdFileMessage, deleteMessage: () => Promise<void>, uri: string) => void;
27
29
  renderMessage: (props: {
28
30
  focused: boolean;
@@ -31,6 +33,7 @@ export type ChannelMessageListProps<T extends SendbirdGroupChannel | SendbirdOpe
31
33
  nextMessage?: SendbirdMessage;
32
34
  onPress?: () => void;
33
35
  onLongPress?: () => void;
36
+ onPressParentMessage?: ChannelMessageListProps<T>['onPressParentMessage'];
34
37
  onShowUserProfile?: UserProfileContextType['show'];
35
38
  channel: T;
36
39
  currentUserId?: ChannelMessageListProps<T>['currentUserId'];
@@ -49,5 +52,5 @@ export type ChannelMessageListProps<T extends SendbirdGroupChannel | SendbirdOpe
49
52
  } & {
50
53
  ref?: Ref<FlatList<SendbirdMessage>> | undefined;
51
54
  };
52
- declare const _default: <T extends import("@sendbird/chat/openChannel").OpenChannel | import("@sendbird/chat/groupChannel").GroupChannel>({ searchItem, hasNext, channel, onEditMessage, onDeleteMessage, onResendFailedMessage, onPressMediaMessage, currentUserId, renderNewMessagesButton, renderScrollToBottomButton, renderMessage, messages, newMessages, enableMessageGrouping, onScrolledAwayFromBottom, scrolledAwayFromBottom, onBottomReached, onTopReached, flatListProps, onPressNewMessagesButton, onPressScrollToBottomButton, }: ChannelMessageListProps<T>, ref: React.ForwardedRef<FlatList<SendbirdMessage>>) => JSX.Element;
55
+ declare const _default: <T extends import("@sendbird/chat/openChannel").OpenChannel | import("@sendbird/chat/groupChannel").GroupChannel>({ searchItem, hasNext, channel, onEditMessage, onReplyMessage, onDeleteMessage, onResendFailedMessage, onPressMediaMessage, onPressParentMessage, currentUserId, renderNewMessagesButton, renderScrollToBottomButton, renderMessage, messages, newMessages, enableMessageGrouping, onScrolledAwayFromBottom, scrolledAwayFromBottom, onBottomReached, onTopReached, flatListProps, onPressNewMessagesButton, onPressScrollToBottomButton, }: ChannelMessageListProps<T>, ref: React.ForwardedRef<FlatList<SendbirdMessage>>) => JSX.Element;
53
56
  export default _default;
@@ -0,0 +1,9 @@
1
+ import { SendbirdFileMessage, SendbirdMessage, SendbirdUserMessage } from '@sendbird/uikit-utils';
2
+ type Props = {
3
+ variant: 'outgoing' | 'incoming';
4
+ message: SendbirdUserMessage | SendbirdFileMessage;
5
+ childMessage: SendbirdUserMessage | SendbirdFileMessage;
6
+ onPress?: (message: SendbirdMessage) => void;
7
+ };
8
+ declare const GroupChannelMessageParentMessage: ({ variant, message, childMessage, onPress }: Props) => JSX.Element;
9
+ export default GroupChannelMessageParentMessage;
@@ -7,6 +7,7 @@ declare const _default: React.MemoExoticComponent<(props: {
7
7
  nextMessage?: SendbirdMessage | undefined;
8
8
  onPress?: (() => void) | undefined;
9
9
  onLongPress?: (() => void) | undefined;
10
+ onPressParentMessage?: ((parentMessage: SendbirdMessage) => void) | undefined;
10
11
  onShowUserProfile?: ((user: import("@sendbird/chat/groupChannel").Member | import("@sendbird/chat").User, options?: {
11
12
  hideMessageButton?: boolean | undefined;
12
13
  } | undefined) => void) | undefined;
@@ -7,6 +7,7 @@ declare const _default: React.MemoExoticComponent<(props: {
7
7
  nextMessage?: SendbirdMessage | undefined;
8
8
  onPress?: (() => void) | undefined;
9
9
  onLongPress?: (() => void) | undefined;
10
+ onPressParentMessage?: ((parentMessage: SendbirdMessage) => void) | undefined;
10
11
  onShowUserProfile?: ((user: import("@sendbird/chat/groupChannel").Member | import("@sendbird/chat").User, options?: {
11
12
  hideMessageButton?: boolean | undefined;
12
13
  } | undefined) => void) | undefined;
@@ -10,7 +10,7 @@ import type { ClipboardServiceInterface, FileServiceInterface, MediaServiceInter
10
10
  import type { ErrorBoundaryProps, LocalCacheStorage } from '../types';
11
11
  type UnimplementedFeatures = 'enableVoiceMessage' | 'threadReplySelectType' | 'replyType';
12
12
  export declare const SendbirdUIKit: Readonly<{
13
- VERSION: "3.0.4-rc.1";
13
+ VERSION: "3.1.0";
14
14
  PLATFORM: string;
15
15
  DEFAULT: {
16
16
  AUTO_PUSH_TOKEN_REGISTRATION: boolean;
@@ -32,7 +32,9 @@ export type SendbirdUIKitContainerProps = React.PropsWithChildren<{
32
32
  } & Partial<ChatRelatedFeaturesInUIKit>;
33
33
  uikitOptions?: PartialDeep<{
34
34
  common: SBUConfig['common'];
35
- groupChannel: Omit<SBUConfig['groupChannel']['channel'], UnimplementedFeatures>;
35
+ groupChannel: Omit<SBUConfig['groupChannel']['channel'], UnimplementedFeatures> & {
36
+ replyType: Extract<SBUConfig['groupChannel']['channel']['replyType'], 'none' | 'quote_reply'>;
37
+ };
36
38
  groupChannelList: SBUConfig['groupChannel']['channelList'];
37
39
  groupChannelSettings: SBUConfig['groupChannel']['setting'];
38
40
  openChannel: SBUConfig['openChannel']['channel'];
@@ -1,5 +1,9 @@
1
1
  import React from 'react';
2
2
  declare const _default: React.MemoExoticComponent<(props: Pick<import("../../../components/ChannelMessageList").ChannelMessageListProps<import("@sendbird/chat/groupChannel").GroupChannel>, "channel" | "onTopReached" | "onBottomReached" | "onScrolledAwayFromBottom" | "currentUserId" | "enableMessageGrouping" | "searchItem" | "hasNext" | "onDeleteMessage" | "onResendFailedMessage" | "onPressMediaMessage" | "renderNewMessagesButton" | "renderScrollToBottomButton" | "renderMessage" | "messages" | "newMessages" | "scrolledAwayFromBottom" | "flatListProps"> & {
3
3
  onResetMessageList: (callback?: (() => void) | undefined) => void;
4
+ onResetMessageListWithStartingPoint: (startingPoint: number, callback?: (() => void) | undefined) => void;
5
+ onUpdateSearchItem: (searchItem?: {
6
+ startingPoint: number;
7
+ } | undefined) => void;
4
8
  }) => JSX.Element>;
5
9
  export default _default;
@@ -34,6 +34,8 @@ export interface GroupChannelProps {
34
34
  };
35
35
  MessageList: Pick<ChannelMessageListProps<SendbirdGroupChannel>, 'enableMessageGrouping' | 'currentUserId' | 'channel' | 'messages' | 'newMessages' | 'scrolledAwayFromBottom' | 'onScrolledAwayFromBottom' | 'onTopReached' | 'onBottomReached' | 'onResendFailedMessage' | 'onDeleteMessage' | 'onPressMediaMessage' | 'renderMessage' | 'renderNewMessagesButton' | 'renderScrollToBottomButton' | 'flatListProps' | 'hasNext' | 'searchItem'> & {
36
36
  onResetMessageList: (callback?: () => void) => void;
37
+ onResetMessageListWithStartingPoint: (startingPoint: number, callback?: () => void) => void;
38
+ onUpdateSearchItem: (searchItem?: GroupChannelProps['MessageList']['searchItem']) => void;
37
39
  };
38
40
  Input: Pick<ChannelInputProps, 'shouldRenderInput' | 'onPressSendUserMessage' | 'onPressSendFileMessage' | 'onPressUpdateUserMessage' | 'onPressUpdateFileMessage' | 'SuggestedMentionList' | 'AttachmentsButton'>;
39
41
  SuggestedMentionList: SuggestedMentionListProps;
@@ -52,10 +54,12 @@ export interface GroupChannelProps {
52
54
  export interface GroupChannelContextsType {
53
55
  Fragment: React.Context<{
54
56
  headerTitle: string;
57
+ keyboardAvoidOffset?: number;
55
58
  channel: SendbirdGroupChannel;
56
59
  messageToEdit?: SendbirdUserMessage | SendbirdFileMessage;
57
60
  setMessageToEdit: (msg?: SendbirdUserMessage | SendbirdFileMessage) => void;
58
- keyboardAvoidOffset?: number;
61
+ messageToReply?: SendbirdUserMessage | SendbirdFileMessage;
62
+ setMessageToReply: (msg?: SendbirdUserMessage | SendbirdFileMessage) => void;
59
63
  }>;
60
64
  TypingIndicator: React.Context<{
61
65
  typingUsers: SendbirdUser[];
@@ -78,7 +82,7 @@ export type GroupChannelPubSubContextPayload = {
78
82
  message: SendbirdUserMessage | SendbirdFileMessage;
79
83
  };
80
84
  } | {
81
- type: 'MESSAGES_RECEIVED';
85
+ type: 'MESSAGES_RECEIVED' | 'MESSAGES_UPDATED';
82
86
  data: {
83
87
  messages: SendbirdMessage[];
84
88
  };
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  declare const _default: React.MemoExoticComponent<({ onPressHeaderLeft, onPressHeaderRight, rightIconName }: {
3
- rightIconName: "search" | "photo" | "message" | "user" | "document" | "done" | "add" | "chat-hide" | "chat-show" | "archive" | "arrow-left" | "ban" | "broadcast" | "camera" | "channels" | "chat-filled" | "chat" | "checkbox-off" | "checkbox-on" | "chevron-down" | "chevron-right" | "close" | "copy" | "create" | "delete" | "done-all" | "download" | "edit" | "emoji-more" | "error" | "file-audio" | "file-document" | "freeze" | "gif" | "info" | "leave" | "members" | "moderation" | "more" | "mute" | "notifications-filled" | "notifications-off-filled" | "notifications" | "operator" | "play" | "plus" | "question" | "radio-off" | "radio-on" | "refresh" | "remove" | "reply-filled" | "reply" | "send" | "settings-filled" | "spinner" | "streaming" | "supergroup" | "theme" | "thumbnail-none" | "unarchive";
3
+ rightIconName: "search" | "photo" | "user" | "document" | "done" | "message" | "add" | "chat-hide" | "chat-show" | "archive" | "arrow-left" | "ban" | "broadcast" | "camera" | "channels" | "chat-filled" | "chat" | "checkbox-off" | "checkbox-on" | "chevron-down" | "chevron-right" | "close" | "copy" | "create" | "delete" | "done-all" | "download" | "edit" | "emoji-more" | "error" | "file-audio" | "file-document" | "freeze" | "gif" | "info" | "leave" | "members" | "moderation" | "more" | "mute" | "notifications-filled" | "notifications-off-filled" | "notifications" | "operator" | "play" | "plus" | "question" | "radio-off" | "radio-on" | "refresh" | "remove" | "reply-filled" | "reply" | "send" | "settings-filled" | "spinner" | "streaming" | "supergroup" | "theme" | "thumbnail-none" | "unarchive";
4
4
  onPressHeaderLeft: () => void;
5
5
  onPressHeaderRight: () => void;
6
6
  }) => JSX.Element>;
@@ -6,7 +6,6 @@ import type { ChannelInputProps } from '../../components/ChannelInput';
6
6
  import type { ChannelMessageListProps } from '../../components/ChannelMessageList';
7
7
  import type { CommonComponent } from '../../types';
8
8
  import type { PubSub } from '../../utils/pubsub';
9
- import type { GroupChannelPubSubContextPayload } from '../groupChannel/types';
10
9
  export type OpenChannelProps = {
11
10
  Fragment: {
12
11
  channel: SendbirdOpenChannel;
@@ -54,7 +53,7 @@ export type OpenChannelContextsType = {
54
53
  setMessageToEdit: (msg?: SendbirdUserMessage | SendbirdFileMessage) => void;
55
54
  keyboardAvoidOffset?: number;
56
55
  }>;
57
- PubSub: React.Context<PubSub<GroupChannelPubSubContextPayload>>;
56
+ PubSub: React.Context<PubSub<OpenChannelPubSubContextPayload>>;
58
57
  };
59
58
  export interface OpenChannelModule {
60
59
  Provider: CommonComponent<OpenChannelProps['Provider']>;
@@ -52,9 +52,6 @@ declare class MentionManager {
52
52
  mentionedText: string;
53
53
  mentionedUsers: MentionedUser[];
54
54
  };
55
- shouldUseMentionedMessageTemplate: (message?: SendbirdUserMessage | SendbirdFileMessage, mentionEnabled?: boolean) => message is RequiredSpecific<import("@sendbird/chat/message").FileMessage | import("@sendbird/chat/message").UserMessage, "mentionedMessageTemplate" | "mentionedUsers" | "mentionedUserIds" | "mentionType">;
55
+ shouldUseMentionedMessageTemplate: (message?: SendbirdUserMessage | SendbirdFileMessage, mentionEnabled?: boolean) => boolean;
56
56
  }
57
- type RequiredSpecific<T, K extends keyof T> = T & {
58
- [P in K]-?: T[P];
59
- };
60
57
  export default MentionManager;
@@ -1,5 +1,5 @@
1
1
  import type { Locale } from 'date-fns';
2
- import type { SendbirdBaseMessage, SendbirdFileMessage, SendbirdGroupChannel, SendbirdMember, SendbirdMessage, SendbirdOpenChannel, SendbirdParticipant, SendbirdUser } from '@sendbird/uikit-utils';
2
+ import type { SendbirdBaseMessage, SendbirdFileMessage, SendbirdGroupChannel, SendbirdMember, SendbirdMessage, SendbirdOpenChannel, SendbirdParticipant, SendbirdUser, SendbirdUserMessage } from '@sendbird/uikit-utils';
3
3
  /**
4
4
  * StringSet interface
5
5
  * Do not configure over 3 depths (for overrides easy)
@@ -218,6 +218,7 @@ export interface StringSet {
218
218
  USER_NO_NAME: string;
219
219
  CHANNEL_NO_MEMBERS: string;
220
220
  TYPING_INDICATOR_TYPINGS: (users: SendbirdUser[]) => string | undefined;
221
+ REPLY_FROM_SENDER_TO_RECEIVER: (replyMessage: SendbirdUserMessage | SendbirdFileMessage, parentMessage: SendbirdUserMessage | SendbirdFileMessage, currentUserId?: string) => string;
221
222
  USER_BAR_ME_POSTFIX: string;
222
223
  USER_BAR_OPERATOR: string;
223
224
  REGISTER_AS_OPERATOR: string;
@@ -232,6 +233,7 @@ export interface StringSet {
232
233
  CHANNEL_INPUT_PLACEHOLDER_ACTIVE: string;
233
234
  CHANNEL_INPUT_PLACEHOLDER_DISABLED: string;
234
235
  CHANNEL_INPUT_PLACEHOLDER_MUTED: string;
236
+ CHANNEL_INPUT_PLACEHOLDER_REPLY: string;
235
237
  CHANNEL_INPUT_EDIT_OK: string;
236
238
  CHANNEL_INPUT_EDIT_CANCEL: string;
237
239
  /** ChannelInput > Attachments **/
@@ -239,11 +241,14 @@ export interface StringSet {
239
241
  CHANNEL_INPUT_ATTACHMENT_CAMERA_VIDEO: string;
240
242
  CHANNEL_INPUT_ATTACHMENT_PHOTO_LIBRARY: string;
241
243
  CHANNEL_INPUT_ATTACHMENT_FILES: string;
244
+ CHANNEL_INPUT_REPLY_PREVIEW_TITLE: (user: SendbirdUser) => string;
245
+ CHANNEL_INPUT_REPLY_PREVIEW_BODY: (message: SendbirdUserMessage | SendbirdFileMessage) => string;
242
246
  /** Channel > Message **/
243
247
  CHANNEL_MESSAGE_COPY: string;
244
248
  CHANNEL_MESSAGE_EDIT: string;
245
249
  CHANNEL_MESSAGE_SAVE: string;
246
250
  CHANNEL_MESSAGE_DELETE: string;
251
+ CHANNEL_MESSAGE_REPLY: string;
247
252
  /** Channel > Message > Delete confirm **/
248
253
  CHANNEL_MESSAGE_DELETE_CONFIRM_TITLE: string;
249
254
  CHANNEL_MESSAGE_DELETE_CONFIRM_OK: string;
@@ -295,6 +300,7 @@ export interface StringSet {
295
300
  LEAVE_CHANNEL_ERROR: string;
296
301
  UNKNOWN_ERROR: string;
297
302
  GET_CHANNEL_ERROR: string;
303
+ FIND_PARENT_MSG_ERROR: string;
298
304
  };
299
305
  PROFILE_CARD: {
300
306
  BUTTON_MESSAGE: string;
@@ -50,19 +50,22 @@ export interface FilePickerServiceInterface {
50
50
  export interface FileSystemServiceInterface {
51
51
  save(options?: SaveOptions): Promise<DownloadedPath | null>;
52
52
  }
53
- interface VideoProps {
53
+ export type VideoProps = {
54
54
  source: {
55
55
  uri: string;
56
56
  } | number;
57
57
  resizeMode?: 'cover' | 'contain' | 'stretch';
58
58
  onLoad?: () => void;
59
- }
60
- interface GetVideoThumbnailOptions {
59
+ };
60
+ export type GetVideoThumbnailOptions = {
61
61
  url: string;
62
62
  timeMills?: number;
63
63
  quality?: number;
64
- }
65
- interface CompressImageOptions {
64
+ };
65
+ export type GetVideoThumbnailResult = Promise<{
66
+ path: string;
67
+ } | null>;
68
+ export type CompressImageOptions = {
66
69
  /**
67
70
  * A uri of image file to compress
68
71
  * */
@@ -80,11 +83,8 @@ interface CompressImageOptions {
80
83
  * 1 means highest quality and 0 the lowest quality.
81
84
  * */
82
85
  compressionRate?: number;
83
- }
84
- type GetVideoThumbnailResult = Promise<{
85
- path: string;
86
- } | null>;
87
- type CompressImageResult = Promise<{
86
+ };
87
+ export type CompressImageResult = Promise<{
88
88
  uri: string;
89
89
  size: number;
90
90
  } | null>;
@@ -93,4 +93,3 @@ export interface MediaServiceInterface {
93
93
  getVideoThumbnail(options: GetVideoThumbnailOptions): GetVideoThumbnailResult;
94
94
  compressImage(options: CompressImageOptions): CompressImageResult;
95
95
  }
96
- export {};
@@ -1,2 +1,2 @@
1
- declare const VERSION = "3.0.4-rc.1";
1
+ declare const VERSION = "3.1.0";
2
2
  export default VERSION;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sendbird/uikit-react-native",
3
- "version": "3.0.4-rc.1",
3
+ "version": "3.1.0",
4
4
  "description": "Sendbird UIKit for React Native: A feature-rich and customizable chat UI kit with messaging, channel management, and user authentication.",
5
5
  "keywords": [
6
6
  "sendbird",
@@ -58,10 +58,10 @@
58
58
  "access": "public"
59
59
  },
60
60
  "dependencies": {
61
- "@sendbird/uikit-chat-hooks": "3.0.4-rc.1",
62
- "@sendbird/uikit-react-native-foundation": "3.0.4-rc.1",
61
+ "@sendbird/uikit-chat-hooks": "3.1.0",
62
+ "@sendbird/uikit-react-native-foundation": "3.1.0",
63
63
  "@sendbird/uikit-tools": "^0.0.1-alpha.38",
64
- "@sendbird/uikit-utils": "3.0.4-rc.1"
64
+ "@sendbird/uikit-utils": "3.1.0"
65
65
  },
66
66
  "devDependencies": {
67
67
  "@bam.tech/react-native-image-resizer": "^3.0.4",
@@ -105,7 +105,7 @@
105
105
  "@react-native-clipboard/clipboard": ">=1.8.5",
106
106
  "@react-native-community/netinfo": ">=9.3.0",
107
107
  "@react-native-firebase/messaging": ">=14.4.0",
108
- "@sendbird/chat": "^4.9.2",
108
+ "@sendbird/chat": "^4.9.8",
109
109
  "@sendbird/react-native-scrollview-enhancer": "*",
110
110
  "date-fns": ">=2.28.0",
111
111
  "expo-av": ">=12.0.4",
@@ -203,5 +203,6 @@
203
203
  "entryPoint": "./src/index.ts",
204
204
  "readmeFile": "./README.md",
205
205
  "displayName": "@sendbird/uikit-react-native"
206
- }
206
+ },
207
+ "gitHead": "1ff295c9b8df84b188fbc1f477d3e59708b8fb80"
207
208
  }