easemob-chat-uikit 2.2.1 → 2.3.0-beta.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.
@@ -1,5 +1,5 @@
1
1
  import { ChatSDK } from '../module/SDK';
2
- export type EventName = 'joinChatRoom' | 'leaveChatRoom' | 'reportMessage' | 'getChatRoomDetails' | 'sendMessage' | 'fetchUserInfoById' | 'translateMessage' | 'recallMessage' | 'deleteConversation' | 'modifyMessage' | 'createChatThread' | 'destroyChatThread' | 'leaveChatThread' | 'setGroupMemberAttributes' | 'muteChatRoomMember' | 'getChatRoomMutelist' | 'unmuteChatRoomMember' | 'removeChatRoomMember' | 'getSilentModeForConversations' | 'setSilentModeForConversation' | 'clearRemindTypeForConversation' | 'getGroupInfo' | 'modifyGroup' | 'destroyGroup' | 'leaveGroup' | 'createGroup' | 'inviteToGroup' | 'removeGroupMembers' | 'changeGroupOwner' | 'pinConversation' | 'getServerPinnedConversations' | 'removeHistoryMessages' | 'addReaction' | 'deleteReaction' | 'getReactionDetail' | 'joinChatThread' | 'getChatThreads' | 'getChatThreadLastMessage' | 'getAllContacts' | 'getJoinedGroups' | 'open' | 'setContactRemark' | 'addContact' | 'deleteContact' | 'getPinnedMessages' | 'pinMessage' | 'unpinMessage' | 'jumpToPinnedMessage' | 'addUsersToBlocklist' | 'removeUserFromBlocklist' | 'publishPresence' | 'getBlockList';
2
+ export type EventName = 'joinChatRoom' | 'leaveChatRoom' | 'reportMessage' | 'getChatRoomDetails' | 'sendMessage' | 'fetchUserInfoById' | 'translateMessage' | 'recallMessage' | 'deleteConversation' | 'modifyMessage' | 'createChatThread' | 'destroyChatThread' | 'leaveChatThread' | 'setGroupMemberAttributes' | 'muteChatRoomMember' | 'getChatRoomMutelist' | 'unmuteChatRoomMember' | 'removeChatRoomMember' | 'getSilentModeForConversations' | 'setSilentModeForConversation' | 'clearRemindTypeForConversation' | 'getGroupInfo' | 'modifyGroup' | 'destroyGroup' | 'leaveGroup' | 'createGroup' | 'inviteToGroup' | 'removeGroupMembers' | 'changeGroupOwner' | 'pinConversation' | 'getServerPinnedConversations' | 'removeHistoryMessages' | 'addReaction' | 'deleteReaction' | 'getReactionDetail' | 'joinChatThread' | 'getChatThreads' | 'getChatThreadLastMessage' | 'getAllContacts' | 'getJoinedGroups' | 'open' | 'setContactRemark' | 'addContact' | 'deleteContact' | 'getPinnedMessages' | 'pinMessage' | 'unpinMessage' | 'jumpToPinnedMessage' | 'addUsersToBlocklist' | 'removeUserFromBlocklist' | 'publishPresence' | 'getBlockList' | 'getConversationlist';
3
3
  export type EventHandlerData = {
4
4
  [key in EventName]?: {
5
5
  success?: () => void;
@@ -1,5 +1,6 @@
1
1
  import React, { ReactNode } from 'react';
2
2
  import { MessageStatusProps } from '../messageStatus';
3
+ import { CustomMessageQuoteRenderer } from '../repliedMessage';
3
4
  import { ChatSDK } from '../SDK';
4
5
  import { ReactionData, ReactionMessageProps } from '../reaction';
5
6
  interface CustomAction {
@@ -65,6 +66,8 @@ export interface BaseMessageProps {
65
66
  reactionConfig?: ReactionMessageProps['reactionConfig'];
66
67
  formatDateTime?: (time: number) => string;
67
68
  onClick?: (message: ChatSDK.MessageBody) => boolean;
69
+ /** 自定义消息被引用时的渲染器 */
70
+ renderCustomMessageQuote?: CustomMessageQuoteRenderer;
68
71
  }
69
72
  declare let BaseMessage: (props: BaseMessageProps) => import("react/jsx-runtime").JSX.Element;
70
73
  export { BaseMessage };
@@ -87,6 +87,7 @@ export interface CallServiceConfig {
87
87
  encoderConfig?: VideoEncoderConfigurationPreset;
88
88
  onRingtoneStart?: (type: 'outgoing' | 'incoming') => void;
89
89
  onRingtoneEnd?: (type: 'outgoing' | 'incoming') => void;
90
+ useRTCToken?: boolean;
90
91
  }
91
92
  export declare class CallService {
92
93
  private client;
@@ -147,6 +148,7 @@ export declare class CallService {
147
148
  private creatingAudioTrack;
148
149
  private UIdToUserIdMap;
149
150
  private enableMic;
151
+ private useRTCToken;
150
152
  constructor(config: CallServiceConfig);
151
153
  setUIdToUserIdMap(uid: string, userId: string): void;
152
154
  getAccessToken(): Promise<string | null>;
@@ -141,6 +141,7 @@ export interface CallKitProps {
141
141
  screenSharing?: boolean;
142
142
  chatClient?: ChatSDK.Connection;
143
143
  enableRealCall?: boolean;
144
+ useRTCToken?: boolean;
144
145
  outgoingRingtoneSrc?: string;
145
146
  incomingRingtoneSrc?: string;
146
147
  enableRingtone?: boolean;
@@ -4,12 +4,27 @@ import { renderUserProfileProps } from '../baseMessage';
4
4
  import { CurrentConversation } from '../store/ConversationStore';
5
5
  import { BaseMessageProps } from '../baseMessage';
6
6
  import { NoticeMessageBody } from '../noticeMessage/NoticeMessage';
7
+ export interface MessageRenderContext {
8
+ message: ChatSDK.MessageBody | NoticeMessageBody;
9
+ style: React.CSSProperties;
10
+ renderUserProfile?: (props: renderUserProfileProps) => React.ReactNode;
11
+ isThread?: boolean;
12
+ messageProps?: BaseMessageProps;
13
+ onOpenThreadPanel?: (threadId: string) => void;
14
+ onRtcInviteMessageClick?: (message: ChatSDK.MessageBody) => void;
15
+ scrollToBottom?: () => void;
16
+ }
17
+ export type MessageType = 'txt' | 'img' | 'audio' | 'video' | 'file' | 'loc' | 'combine' | 'custom' | 'notice' | 'recall';
18
+ export type MessageRenderer = (context: MessageRenderContext) => ReactNode;
7
19
  export interface MsgListProps {
8
20
  prefix?: string;
9
21
  className?: string;
10
22
  style?: React.CSSProperties;
11
23
  isThread?: boolean;
24
+ /** @deprecated 使用 customRenderers 替代,支持按类型自定义 */
12
25
  renderMessage?: (message: ChatSDK.MessageBody | NoticeMessageBody) => ReactNode;
26
+ /** 按消息类型自定义渲染器,只需要传入想自定义的类型即可,其他类型会使用默认渲染 */
27
+ customRenderers?: Partial<Record<MessageType, MessageRenderer>>;
13
28
  renderUserProfile?: (props: renderUserProfileProps) => React.ReactNode;
14
29
  conversation?: CurrentConversation;
15
30
  messageProps?: BaseMessageProps;
@@ -1,6 +1,6 @@
1
1
  import { Chat } from './Chat';
2
2
  import { MessageList } from './MessageList';
3
3
  export type { ChatProps } from './Chat';
4
- export type { MsgListProps } from './MessageList';
4
+ export type { MsgListProps, MessageRenderContext, MessageRenderer, MessageType, } from './MessageList';
5
5
  export { MessageList };
6
6
  export default Chat;
@@ -2,6 +2,7 @@ import React, { ReactNode } from 'react';
2
2
  import { HeaderProps } from '../header';
3
3
  import { MessageInputProps } from '../messageInput';
4
4
  import { MsgListProps } from '../chat/MessageList';
5
+ import { ChatroomMessageActionConfig } from '../chatroomMessage';
5
6
  import { BroadcastProps } from '../../component/broadcast';
6
7
  import { ChatroomInfo } from '../store/AddressStore';
7
8
  export declare let reportType: Record<string, string>;
@@ -25,6 +26,7 @@ export interface ChatroomProps {
25
26
  broadcastProps?: BroadcastProps;
26
27
  chatroomId: string;
27
28
  reportType?: Record<string, string>;
29
+ messageActionConfig?: ChatroomMessageActionConfig;
28
30
  }
29
31
  declare let Chatroom: (props: ChatroomProps) => import("react/jsx-runtime").JSX.Element;
30
32
  export { Chatroom };
@@ -1,5 +1,18 @@
1
- import React from 'react';
1
+ import React, { ReactNode } from 'react';
2
2
  import { ChatSDK } from '../SDK';
3
+ export interface ChatroomMessageActionConfig {
4
+ recall?: boolean;
5
+ translate?: boolean;
6
+ mute?: boolean;
7
+ report?: boolean;
8
+ pin?: boolean;
9
+ customActions?: Array<{
10
+ content: string | ReactNode;
11
+ icon?: ReactNode;
12
+ onClick: (message: ChatSDK.MessageBody) => void;
13
+ visible?: (message: ChatSDK.MessageBody) => boolean;
14
+ }>;
15
+ }
3
16
  export interface ChatroomMessageProps {
4
17
  prefix?: string;
5
18
  className?: string;
@@ -7,6 +20,7 @@ export interface ChatroomMessageProps {
7
20
  message: ChatSDK.MessageBody;
8
21
  targetLanguage?: string;
9
22
  onReport?: (message: ChatSDK.MessageBody) => void;
23
+ actionConfig?: ChatroomMessageActionConfig;
10
24
  }
11
25
  declare const ChatroomMessageOut: ((props: ChatroomMessageProps) => import("react/jsx-runtime").JSX.Element) & {
12
26
  displayName: string;
@@ -1,3 +1,3 @@
1
1
  import ChatroomMessage from './ChatroomMessage';
2
- export type { ChatroomMessageProps } from './ChatroomMessage';
2
+ export type { ChatroomMessageProps, ChatroomMessageActionConfig } from './ChatroomMessage';
3
3
  export default ChatroomMessage;
@@ -12,6 +12,13 @@ export interface ImageMessageProps extends BaseMessageProps {
12
12
  nickName?: string;
13
13
  renderUserProfile?: (props: renderUserProfileProps) => React.ReactNode;
14
14
  imgProps?: React.ImgHTMLAttributes<HTMLImageElement>;
15
+ /** 自定义图片预览组件,用于替换默认的预览弹窗 */
16
+ renderImagePreview?: (props: {
17
+ visible: boolean;
18
+ imageUrl: string;
19
+ onClose: () => void;
20
+ message: ImageMessageType;
21
+ }) => React.ReactNode;
15
22
  }
16
23
  export interface ImagePreviewProps {
17
24
  visible: boolean;
@@ -10,7 +10,7 @@ import MessageStatus, { MessageStatusProps } from './messageStatus';
10
10
  import CombinedMessage, { CombinedMessageProps } from './combinedMessage';
11
11
  import PinnedMessage, { PinnedMessageProps } from './pinnedMessage';
12
12
  import { RepliedMsg, UnsentRepliedMsg, RepliedMsgProps, UnsentRepliedMsgProps } from './repliedMessage';
13
- import Chat, { MessageList, ChatProps, MsgListProps } from './chat';
13
+ import Chat, { MessageList, ChatProps, MsgListProps, MessageRenderContext, MessageRenderer, MessageType } from './chat';
14
14
  import { ConversationList, ConversationItem, ConversationItemProps, ConversationListProps, ConversationData } from './conversation';
15
15
  import MessageInput, { MessageInputProps, MoreActionProps, RecorderProps, EmojiProps, SelectedControlsProps, SuggestListProps, TextareaProps } from './messageInput';
16
16
  import Header, { HeaderProps } from './header';
@@ -44,6 +44,6 @@ import ChatroomMessage from './chatroomMessage';
44
44
  import CallKit from './callkit';
45
45
  import { CallKitProps, CallInfo, CallErrorCode, CallError } from './callkit';
46
46
  import { CallKitRef } from './callkit/types/index';
47
- export type { AudioMessageProps, BaseMessageProps, FileMessageProps, ImageMessageProps, ImagePreviewProps, NoticeMessageProps, TextMessageProps, VideoMessageProps, MessageStatusProps, CombinedMessageProps, PinnedMessageProps, RepliedMsgProps, UnsentRepliedMsgProps, ChatProps, MsgListProps, ConversationItemProps, ConversationListProps, ConversationData, MessageInputProps, MoreActionProps, RecorderProps, EmojiProps, SelectedControlsProps, SuggestListProps, TextareaProps, HeaderProps, EmptyProps, RecalledMessageProps, RootStore, InitConfig, MessageStore, Message, SelectedMessage, Typing, ConversationStore, AT_TYPE, Conversation, CurrentConversation, ById, AddressStore, MemberRole, MemberItem, GroupItem, AppUserInfo, ThreadStore, ThreadData, CurrentThread, ProviderProps, ContextProps, ThreadProps, UserProfileProps, BlocklistProps, ContactListProps, ContactDetailProps, GroupDetailProps, GroupMemberProps, UserCardMessageProps, UserSelectProps, CallKitProps, CallKitRef, CallInfo, CallErrorCode, CallError, };
47
+ export type { AudioMessageProps, BaseMessageProps, FileMessageProps, ImageMessageProps, ImagePreviewProps, NoticeMessageProps, TextMessageProps, VideoMessageProps, MessageStatusProps, CombinedMessageProps, PinnedMessageProps, RepliedMsgProps, UnsentRepliedMsgProps, ChatProps, MsgListProps, ConversationItemProps, ConversationListProps, ConversationData, MessageInputProps, MoreActionProps, RecorderProps, EmojiProps, SelectedControlsProps, SuggestListProps, TextareaProps, HeaderProps, EmptyProps, RecalledMessageProps, RootStore, InitConfig, MessageStore, Message, SelectedMessage, Typing, ConversationStore, AT_TYPE, Conversation, CurrentConversation, ById, AddressStore, MemberRole, MemberItem, GroupItem, AppUserInfo, ThreadStore, ThreadData, CurrentThread, ProviderProps, ContextProps, ThreadProps, UserProfileProps, BlocklistProps, ContactListProps, ContactDetailProps, GroupDetailProps, GroupMemberProps, UserCardMessageProps, UserSelectProps, CallKitProps, CallKitRef, CallInfo, CallErrorCode, CallError, MessageRenderContext, MessageRenderer, MessageType, };
48
48
  declare const UIKitProvider: import("react").NamedExoticComponent<ProviderProps>;
49
49
  export { AudioMessage, BaseMessage, FileMessage, ImageMessage, NoticeMessage, TextMessage, VideoMessage, CombinedMessage, PinnedMessage, RepliedMsg, UnsentRepliedMsg, MessageStatus, Chat, MessageList, ContactList, ConversationList, ConversationItem, MessageInput, Header, Empty, RecalledMessage, rootStore, RootContext, RootProvider, RootConsumer, Provider, UIKitProvider, Thread, UserProfile, Blocklist, useClient, useConversations, usePinnedMessage, useHistoryMessages, useSDK, useIsMobile, useScreen, useConversationContext, useChatContext, useAddressContext, useThreadContext, useChatroomContext, Chatroom, ChatroomMember, ChatroomMessage, ContactItem, ContactDetail, GroupDetail, GroupMember, UserCardMessage, UserSelect, CallKit, };
@@ -1,5 +1,17 @@
1
- import React from 'react';
1
+ import React, { ReactNode } from 'react';
2
+ import { ChatSDK } from '../SDK';
2
3
  import { BaseMessageType } from '../baseMessage/BaseMessage';
4
+ export interface CustomMessageQuoteContext {
5
+ message: ChatSDK.CustomMsgBody;
6
+ msgQuote?: {
7
+ msgID: string;
8
+ msgPreview: string;
9
+ msgSender: string;
10
+ msgType: ChatSDK.MessageBody['type'];
11
+ };
12
+ prefixCls: string;
13
+ }
14
+ export type CustomMessageQuoteRenderer = (context: CustomMessageQuoteContext) => ReactNode;
3
15
  export interface RepliedMsgProps {
4
16
  prefixCls?: string;
5
17
  className?: string;
@@ -7,6 +19,27 @@ export interface RepliedMsgProps {
7
19
  shape?: 'round' | 'square';
8
20
  direction?: 'ltr' | 'rtl';
9
21
  message: BaseMessageType;
22
+ /**
23
+ * 自定义消息被引用时的渲染器
24
+ * 用于渲染用户自定义的 custom 消息在被引用时的展示内容
25
+ *
26
+ * @example
27
+ * ```tsx
28
+ * renderCustomMessageQuote={(context) => {
29
+ * const { message, prefixCls } = context;
30
+ * if (message.customEvent === 'myCustomType') {
31
+ * return (
32
+ * <div className={`${prefixCls}-content-text`}>
33
+ * <Icon type="CUSTOM_ICON" />
34
+ * <span>我的自定义消息: {message.customExts?.title}</span>
35
+ * </div>
36
+ * );
37
+ * }
38
+ * return null; // 返回 null 使用默认渲染
39
+ * }}
40
+ * ```
41
+ */
42
+ renderCustomMessageQuote?: CustomMessageQuoteRenderer;
10
43
  }
11
44
  declare const RepliedMsg: (props: RepliedMsgProps) => import("react/jsx-runtime").JSX.Element | null;
12
45
  export { RepliedMsg };
@@ -2,4 +2,4 @@ import { UnsentRepliedMsg } from './UnsentRepliedMsg';
2
2
  import { RepliedMsg } from './RepliedMsg';
3
3
  export { UnsentRepliedMsg, RepliedMsg };
4
4
  export type { UnsentRepliedMsgProps } from './UnsentRepliedMsg';
5
- export type { RepliedMsgProps } from './RepliedMsg';
5
+ export type { RepliedMsgProps, CustomMessageQuoteRenderer, CustomMessageQuoteContext } from './RepliedMsg';