easemob-websdk 5.1.1 → 5.1.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 (94) hide show
  1. package/bundle/im-sdk-web.iife.js +1 -1
  2. package/chat-client.d.ts +42 -8
  3. package/chunks/{chat-manager-QJCNq-in.cjs → chat-manager-BFd2Z4oY.cjs} +1 -1
  4. package/chunks/{chat-manager-QxcfwVLg.js → chat-manager-CId_M_e5.js} +1 -1
  5. package/chunks/common-BvlDAw4a.js +1 -0
  6. package/chunks/common-tHGz9VBk.cjs +1 -0
  7. package/chunks/event-system-B62vbKqG.js +1 -0
  8. package/chunks/{event-system-COBJFEIq.cjs → event-system-TYhmgy4K.cjs} +1 -1
  9. package/chunks/group-user-info-resolver-B-dyr__b.cjs +1 -0
  10. package/chunks/group-user-info-resolver-DMccCqez.js +1 -0
  11. package/chunks/index-BBFJYOM8.js +1 -0
  12. package/chunks/{index-DIV5mZP8.cjs → index-DJPAjXAp.cjs} +1 -1
  13. package/chunks/index-DtWkVcfb.cjs +1 -0
  14. package/chunks/index-l_BUKi77.js +1 -0
  15. package/chunks/{session-list-query-rynxSxtv.js → session-list-query-Cvr6rlme.js} +1 -1
  16. package/chunks/{session-list-query-C4OQMvPf.cjs → session-list-query-Dslj2k3t.cjs} +1 -1
  17. package/chunks/{user-info-DfbCp80h.js → user-info-AlshAvdy.js} +1 -1
  18. package/chunks/{user-info-DsDDTJrw.cjs → user-info-DH3aE1gm.cjs} +1 -1
  19. package/config/timeouts.d.ts +11 -0
  20. package/core/connection/connection-manager.d.ts +18 -1
  21. package/core/connection/login-deadline.d.ts +22 -0
  22. package/core/events/event-hub.d.ts +1 -0
  23. package/core/index.d.ts +8 -1
  24. package/core/message/attachment-downloader.d.ts +1 -1
  25. package/core/session-list-sync/session-list-sync-controller.d.ts +5 -0
  26. package/index.cjs +1 -1
  27. package/index.d.ts +11 -9
  28. package/index.js +2 -2
  29. package/log.d.ts +27 -0
  30. package/managers/chat/index.cjs +1 -1
  31. package/managers/chat/index.js +1 -1
  32. package/managers/chat-thread/index.cjs +1 -1
  33. package/managers/chat-thread/index.js +1 -1
  34. package/managers/chatroom/chatroom.d.ts +1 -1
  35. package/managers/chatroom/index.cjs +1 -1
  36. package/managers/chatroom/index.js +1 -1
  37. package/managers/chatroom-manager.d.ts +6 -1
  38. package/managers/contact/index.cjs +1 -1
  39. package/managers/contact/index.js +1 -1
  40. package/managers/group/index.cjs +1 -1
  41. package/managers/group/index.js +1 -1
  42. package/managers/presence/index.cjs +1 -1
  43. package/managers/presence/index.js +1 -1
  44. package/managers/push/index.cjs +1 -1
  45. package/managers/push/index.d.ts +2 -0
  46. package/managers/push/index.js +1 -1
  47. package/managers/push/native-push-controller.d.ts +62 -0
  48. package/managers/push/native-push-normalizer.d.ts +15 -0
  49. package/managers/push-manager.d.ts +63 -4
  50. package/managers/user-info/index.cjs +1 -1
  51. package/managers/user-info/index.js +1 -1
  52. package/managers/user-info-manager.d.ts +3 -2
  53. package/message/combine-payload-codec.d.ts +2 -1
  54. package/package.json +1 -1
  55. package/platform/index.d.ts +1 -1
  56. package/platform/request/default-request-adapter.d.ts +7 -0
  57. package/platform/socket/default-socket-adapter.d.ts +6 -0
  58. package/platform/types.d.ts +22 -2
  59. package/platform/upload/legacy-multipart-upload.d.ts +14 -0
  60. package/platform/upload/legacy-simple-upload.d.ts +3 -0
  61. package/protocol/msync/codec.d.ts +5 -0
  62. package/rest/client.d.ts +0 -4
  63. package/rest/contact-management.d.ts +1 -0
  64. package/rest/dns-config.d.ts +6 -1
  65. package/rest/error-maps/chatroom.d.ts +6 -0
  66. package/rest/error-maps/common.d.ts +3 -0
  67. package/rest/error-maps/contact.d.ts +8 -3
  68. package/rest/error-maps/push.d.ts +13 -1
  69. package/rest/error-maps/user-info.d.ts +51 -3
  70. package/rest/service-url.d.ts +6 -0
  71. package/types/chat-client.d.ts +16 -9
  72. package/types/chatroom.d.ts +3 -34
  73. package/types/event-system.d.ts +52 -1
  74. package/types/index.d.ts +5 -7
  75. package/types/log.d.ts +19 -0
  76. package/types/manager.d.ts +31 -0
  77. package/types/push.d.ts +77 -0
  78. package/upload/attachment-uploader.d.ts +1 -5
  79. package/upload/multipart-upload.d.ts +4 -14
  80. package/upload/simple-upload.d.ts +4 -3
  81. package/upload/types.d.ts +2 -1
  82. package/utils/error-codes.generated.d.ts +1 -0
  83. package/utils/log-reporter.d.ts +1 -7
  84. package/utils/logger.d.ts +28 -2
  85. package/validators/chat-client.d.ts +22 -50
  86. package/validators/message-create.d.ts +18 -18
  87. package/chunks/common-BIpcR2uQ.cjs +0 -1
  88. package/chunks/common-D_DfwSd3.js +0 -1
  89. package/chunks/event-system-D6IJA0C4.js +0 -1
  90. package/chunks/group-user-info-resolver-Ds35Z1Uf.cjs +0 -1
  91. package/chunks/group-user-info-resolver-lEtRdWli.js +0 -1
  92. package/chunks/index-Baofxzfc.cjs +0 -1
  93. package/chunks/index-CKbroPac.js +0 -1
  94. package/chunks/index-DPi6gEFw.js +0 -1
@@ -13,6 +13,10 @@ export declare const CONTACT_ERROR_MAP: {
13
13
  readonly code: 110;
14
14
  readonly retryable: false;
15
15
  };
16
+ readonly cannot_add_self: {
17
+ readonly code: 110;
18
+ readonly retryable: false;
19
+ };
16
20
  };
17
21
  };
18
22
  readonly errors: {
@@ -60,6 +64,7 @@ export declare const CONTACT_ERROR_MAP: {
60
64
  readonly code: 204;
61
65
  readonly httpStatus: 404;
62
66
  readonly retryable: false;
67
+ readonly aliases: readonly ["service_resource_not_found"];
63
68
  };
64
69
  };
65
70
  };
@@ -114,7 +119,7 @@ export declare const CONTACT_ERROR_MAP: {
114
119
  };
115
120
  };
116
121
  readonly setContactRemark: {
117
- readonly range: "4,110,223";
122
+ readonly range: "4,110,221";
118
123
  readonly localErrors: {
119
124
  readonly setContactRemark: {
120
125
  readonly validation_invalid: {
@@ -124,8 +129,8 @@ export declare const CONTACT_ERROR_MAP: {
124
129
  };
125
130
  };
126
131
  readonly errors: {
127
- readonly illegal_argument: {
128
- readonly code: 223;
132
+ readonly USER_NOT_ON_ROSTER: {
133
+ readonly code: 221;
129
134
  readonly httpStatus: 400;
130
135
  readonly retryable: false;
131
136
  readonly matchField: "error_description";
@@ -56,7 +56,7 @@ export declare const PUSH_ERROR_MAP: {
56
56
  };
57
57
  };
58
58
  readonly uploadPushToken: {
59
- readonly range: "110,1500";
59
+ readonly range: "110,201,1500";
60
60
  readonly localErrors: {
61
61
  readonly uploadPushToken: {
62
62
  readonly validation_invalid: {
@@ -64,6 +64,18 @@ export declare const PUSH_ERROR_MAP: {
64
64
  readonly retryable: false;
65
65
  };
66
66
  };
67
+ readonly setNativePush: {
68
+ readonly validation_invalid: {
69
+ readonly code: 110;
70
+ readonly retryable: false;
71
+ };
72
+ };
73
+ readonly removePushToken: {
74
+ readonly auth_not_login: {
75
+ readonly code: 201;
76
+ readonly retryable: false;
77
+ };
78
+ };
67
79
  };
68
80
  readonly errors: {
69
81
  readonly TOKEN_UPLOAD_FAILED: {
@@ -2,7 +2,7 @@ export declare const USER_INFO_ERROR_MAP: {
2
2
  readonly common: {};
3
3
  readonly apis: {
4
4
  readonly updateOwnUserInfo: {
5
- readonly range: "4,110,204,901";
5
+ readonly range: "4,110,204,303,505,901";
6
6
  readonly localErrors: {
7
7
  readonly updateOwnInfo: {
8
8
  readonly validation_invalid: {
@@ -18,10 +18,26 @@ export declare const USER_INFO_ERROR_MAP: {
18
18
  };
19
19
  };
20
20
  readonly errors: {
21
+ readonly service_not_enabled: {
22
+ readonly code: 505;
23
+ readonly httpStatus: 403;
24
+ readonly retryable: false;
25
+ readonly matchField: "desc";
26
+ readonly matchPattern: "user metadata service not allow";
27
+ };
21
28
  readonly data_length_exceed: {
22
29
  readonly code: 901;
23
30
  readonly httpStatus: 403;
24
31
  readonly retryable: false;
32
+ readonly matchField: "desc";
33
+ readonly matchPattern: "exceeds";
34
+ };
35
+ readonly concurrent_update_conflict: {
36
+ readonly code: 303;
37
+ readonly httpStatus: 409;
38
+ readonly retryable: true;
39
+ readonly matchField: "desc";
40
+ readonly matchPattern: "Concurrent";
25
41
  };
26
42
  readonly resource_not_found: {
27
43
  readonly code: 204;
@@ -36,7 +52,7 @@ export declare const USER_INFO_ERROR_MAP: {
36
52
  };
37
53
  };
38
54
  readonly updateOwnInfo: {
39
- readonly range: "4,110,204,901";
55
+ readonly range: "4,110,204,303,505,901";
40
56
  readonly localErrors: {
41
57
  readonly updateOwnInfo: {
42
58
  readonly validation_invalid: {
@@ -52,10 +68,26 @@ export declare const USER_INFO_ERROR_MAP: {
52
68
  };
53
69
  };
54
70
  readonly errors: {
71
+ readonly service_not_enabled: {
72
+ readonly code: 505;
73
+ readonly httpStatus: 403;
74
+ readonly retryable: false;
75
+ readonly matchField: "desc";
76
+ readonly matchPattern: "user metadata service not allow";
77
+ };
55
78
  readonly data_length_exceed: {
56
79
  readonly code: 901;
57
80
  readonly httpStatus: 403;
58
81
  readonly retryable: false;
82
+ readonly matchField: "desc";
83
+ readonly matchPattern: "exceeds";
84
+ };
85
+ readonly concurrent_update_conflict: {
86
+ readonly code: 303;
87
+ readonly httpStatus: 409;
88
+ readonly retryable: true;
89
+ readonly matchField: "desc";
90
+ readonly matchPattern: "Concurrent";
59
91
  };
60
92
  readonly resource_not_found: {
61
93
  readonly code: 204;
@@ -70,7 +102,7 @@ export declare const USER_INFO_ERROR_MAP: {
70
102
  };
71
103
  };
72
104
  readonly updateOwnInfoByAttribute: {
73
- readonly range: "4,110,204,901";
105
+ readonly range: "4,110,204,303,505,901";
74
106
  readonly localErrors: {
75
107
  readonly updateOwnInfo: {
76
108
  readonly validation_invalid: {
@@ -86,10 +118,26 @@ export declare const USER_INFO_ERROR_MAP: {
86
118
  };
87
119
  };
88
120
  readonly errors: {
121
+ readonly service_not_enabled: {
122
+ readonly code: 505;
123
+ readonly httpStatus: 403;
124
+ readonly retryable: false;
125
+ readonly matchField: "desc";
126
+ readonly matchPattern: "user metadata service not allow";
127
+ };
89
128
  readonly data_length_exceed: {
90
129
  readonly code: 901;
91
130
  readonly httpStatus: 403;
92
131
  readonly retryable: false;
132
+ readonly matchField: "desc";
133
+ readonly matchPattern: "exceeds";
134
+ };
135
+ readonly concurrent_update_conflict: {
136
+ readonly code: 303;
137
+ readonly httpStatus: 409;
138
+ readonly retryable: true;
139
+ readonly matchField: "desc";
140
+ readonly matchPattern: "Concurrent";
93
141
  };
94
142
  readonly resource_not_found: {
95
143
  readonly code: 204;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * 将 REST 服务地址转换为统一数据同步 WebSocket 地址。
3
+ *
4
+ * @internal
5
+ */
6
+ export declare const deriveSyncWebSocketUrl: (restApiUrl: string) => string;
@@ -12,18 +12,14 @@ import type { CreatePlatformAdapterOptions } from '../platform/types';
12
12
  */
13
13
  export type ConnectionState = ConnectionStatus;
14
14
  /**
15
- * [zh-CN] 固定服务地址配置。
16
- * [en-US] Fixed service endpoint configuration.
15
+ * [zh-CN] 固定服务地址配置。同步 REST 请求复用 `restApiUrl`,同步 WebSocket 地址由 SDK 按 `http→ws`、`https→wss` 自动派生为 `<ws|wss>://<REST host[:port]>/ws`。
16
+ * [en-US] Fixed service endpoint configuration. Sync REST requests reuse `restApiUrl`, and the SDK derives the sync WebSocket URL as `<ws|wss>://<REST host[:port]>/ws`, mapping `http` to `ws` and `https` to `wss`.
17
17
  */
18
18
  export interface ServerUrlsConfig {
19
- /** [zh-CN] REST API 服务的基准地址。 [en-US] The base URL for the REST API service. */
19
+ /** [zh-CN] REST API 服务的基准地址;同步 REST 与同步 WebSocket 也统一以此地址为来源。 [en-US] The base URL for REST APIs; sync REST and sync WebSocket endpoints also use this URL as their source. */
20
20
  readonly restApiUrl?: string;
21
- /** [zh-CN] 消息长连接的 WebSocket 地址。 [en-US] The WebSocket URL for the messaging connection. */
21
+ /** [zh-CN] 消息长连接的 WebSocket 地址;地址未携带路径或仅携带根路径 `/` 时,SDK 会自动补齐 `/websocket`,其他显式路径保持不变。 [en-US] The WebSocket URL for the messaging connection. The SDK appends `/websocket` only when the URL has no path or only the root path `/`; other explicit paths are preserved. */
22
22
  readonly wsUrl?: string;
23
- /** [zh-CN] 会话与好友同步 REST API 服务的基准地址。 [en-US] The base URL for the conversation and friend synchronization REST API service. */
24
- readonly syncRestApiUrl?: string;
25
- /** [zh-CN] 会话与好友同步长连接的 WebSocket 地址。 [en-US] The WebSocket URL for the conversation and friend synchronization connection. */
26
- readonly syncWsUrl?: string;
27
23
  }
28
24
  /**
29
25
  * [zh-CN] 服务接入配置。
@@ -140,6 +136,17 @@ export interface AuthContext {
140
136
  /** [zh-CN] IM 登录 token。 [en-US] IM login token. */
141
137
  token: string;
142
138
  }
139
+ /**
140
+ * [zh-CN] 单次登录选项。
141
+ * [en-US] Options for a single login operation.
142
+ */
143
+ export interface LoginOptions {
144
+ /**
145
+ * [zh-CN] 首次登录端到端总超时,单位毫秒;默认 30000,允许范围 5000~120000。该值不影响登录成功后的断线重连。
146
+ * [en-US] End-to-end timeout for the initial login in milliseconds. Defaults to 30000 and accepts 5000–120000. It does not affect reconnection after login succeeds.
147
+ */
148
+ readonly timeoutMs?: number;
149
+ }
143
150
  /**
144
151
  * [zh-CN] IM token 续期结果。
145
152
  * [en-US] IM token renewal result.
@@ -234,7 +241,7 @@ export interface DnsConfig {
234
241
  'msync-wx': {
235
242
  hosts: DnsHost[];
236
243
  };
237
- /** [zh-CN] 会话/联系人同步 WebSocket 地址集合。 [en-US] Session/contact sync WebSocket host set. */
244
+ /** [zh-CN] 历史会话/联系人同步 WebSocket 地址集合;仅为 DNS 响应结构兼容保留,不参与端点选择。 [en-US] Legacy session/contact sync WebSocket host set retained only for DNS response compatibility; it is not used for endpoint selection. */
238
245
  'sync-ws'?: {
239
246
  hosts: DnsHost[];
240
247
  };
@@ -99,32 +99,6 @@ export interface ChatRoomListResult {
99
99
  */
100
100
  readonly hasMore?: boolean;
101
101
  }
102
- /**
103
- * [zh-CN] 当前用户在聊天室中的状态。
104
- * [en-US] Status of the current user in the chat room.
105
- */
106
- export interface ChatRoomCurrentUserStatus {
107
- /**
108
- * [zh-CN] 当前用户是否在白名单中。
109
- * [en-US] Whether the current user is in the allow list.
110
- */
111
- readonly inAllowlist?: boolean;
112
- /**
113
- * [zh-CN] 当前用户是否处于禁言状态。
114
- * [en-US] Whether the current user is muted.
115
- */
116
- readonly muted?: boolean;
117
- /**
118
- * [zh-CN] 当前用户的禁言到期时间。
119
- * [en-US] Mute expiration time of the current user.
120
- */
121
- readonly muteExpireAt?: number;
122
- /**
123
- * [zh-CN] 当前用户在聊天室中的权限类型。
124
- * [en-US] Permission type of the current user in the chat room.
125
- */
126
- readonly permissionType?: ChatRoomPermissionType;
127
- }
128
102
  /**
129
103
  * [zh-CN] 聊天室详情。
130
104
  * [en-US] Details of the chat room.
@@ -151,20 +125,15 @@ export interface ChatRoomDetail extends ChatRoomSummary {
151
125
  */
152
126
  readonly ext?: string;
153
127
  /**
154
- * [zh-CN] 聊天室公告。
155
- * [en-US] Chat room announcement.
128
+ * [zh-CN] 是否开启全员禁言。该字段映射服务端聊天室详情的 `mute`。
129
+ * [en-US] Whether all-member mute is enabled. This field maps to `mute` in the server chat room detail.
156
130
  */
157
- readonly announcement?: string;
131
+ readonly muteAllMembers?: boolean;
158
132
  /**
159
133
  * [zh-CN] 当前用户在聊天室中的权限类型。
160
134
  * [en-US] Permission type of the current user in the chat room.
161
135
  */
162
136
  readonly permissionType?: ChatRoomPermissionType;
163
- /**
164
- * [zh-CN] 当前用户在聊天室中的状态快照。
165
- * [en-US] Snapshot of the current user's status in the chat room.
166
- */
167
- readonly currentUserStatus?: ChatRoomCurrentUserStatus;
168
137
  }
169
138
  /**
170
139
  * [zh-CN] 基于页码的分页参数。
@@ -11,8 +11,10 @@ import type { ChatRoomAdminAddedEventPayload, ChatRoomAdminRemovedEventPayload,
11
11
  import type { GroupAdminAddedEventPayload, GroupAdminRemovedEventPayload, GroupAllMemberMuteStateChangedEventPayload, GroupAnnouncementChangedEventPayload, GroupAutoAcceptInvitationEventPayload, GroupDestroyedEventPayload, GroupInvitationAcceptedEventPayload, GroupInvitationDeclinedEventPayload, GroupInvitationReceivedEventPayload, GroupMemberAttributeChangedEventPayload, GroupDisabledChangedEventPayload, GroupInfoChangedEventPayload, GroupMembersExitedEventPayload, GroupMembersJoinedEventPayload, GroupMuteListAddedEventPayload, GroupMuteListRemovedEventPayload, GroupOwnerChangedEventPayload, GroupRawNotifyEvent, GroupRequestToJoinAcceptedEventPayload, GroupRequestToJoinDeclinedEventPayload, GroupRequestToJoinReceivedEventPayload, GroupSharedFileAddedEventPayload, GroupSharedFileDeletedEventPayload, GroupUserGroupNamecardUpdatedEventPayload, GroupUserRemovedEventPayload, GroupAllowListAddedEventPayload, GroupAllowListRemovedEventPayload } from './group';
12
12
  import type { PresenceState } from './presence';
13
13
  import type { UserInfo, UserInfoRawNotifyEvent } from './user-info';
14
+ import type { PushTokenBoundEvent, PushTokenOperationFailedEvent } from './push';
14
15
  import type { MessageDeliveredEventPayload, MessageReceiptEventPayload, MessageRecalledEventPayload, MessageUpdatedEventPayload, PinnedMessageChangedEventPayload, ReactionChangedEventPayload } from './chat-manager';
15
16
  import type { MultiDeviceContactEvent, MultiDeviceConversationEvent, MultiDeviceGroupEvent, MultiDeviceMessageRemovedEvent, MultiDeviceThreadEvent } from './multi-device';
17
+ import type { LogEntry } from './log';
16
18
  /**
17
19
  * [zh-CN] 连接事件名称。
18
20
  * [en-US] Connection event name.
@@ -47,6 +49,18 @@ export declare const ChatEventName: {
47
49
  * [en-US] Chat event name.
48
50
  */
49
51
  export type ChatEventName = (typeof ChatEventName)[keyof typeof ChatEventName];
52
+ /**
53
+ * [zh-CN] 日志事件名称常量。
54
+ * [en-US] Log event name constants.
55
+ */
56
+ export declare const LogEventName: {
57
+ readonly LOG: "onLog";
58
+ };
59
+ /**
60
+ * [zh-CN] 日志事件名称。
61
+ * [en-US] Log event name.
62
+ */
63
+ export type LogEventName = (typeof LogEventName)[keyof typeof LogEventName];
50
64
  /**
51
65
  * [zh-CN] 消息话题事件名称常量。
52
66
  * [en-US] Chat thread event name constants.
@@ -132,12 +146,31 @@ export type ChatRoomDispatchEventName = (typeof ChatRoomDispatchEventName)[keyof
132
146
  * [zh-CN] SDK 事件名称联合类型。
133
147
  * [en-US] Union of SDK event names.
134
148
  */
135
- export type EventName = ConnectionEventName | ChatEventName | ChatThreadEventName | InternalEventName | PresenceEventName | ContactEventName | UserInfoEventName | GroupEventName | ChatRoomDispatchEventName;
149
+ export type EventName = ConnectionEventName | ChatEventName | LogEventName | ChatThreadEventName | InternalEventName | PresenceEventName | ContactEventName | UserInfoEventName | GroupEventName | ChatRoomDispatchEventName | PushEventName;
150
+ /** [zh-CN] PushManager 事件名称。 [en-US] PushManager event names. */
151
+ export declare const PushEventName: {
152
+ readonly TOKEN_BOUND: "onPushTokenBound";
153
+ readonly TOKEN_BIND_FAILED: "onPushTokenBindFailed";
154
+ readonly TOKEN_REMOVE_FAILED: "onPushTokenRemoveFailed";
155
+ };
156
+ /** [zh-CN] PushManager 事件名称联合类型。 [en-US] Union of PushManager event names. */
157
+ export type PushEventName = (typeof PushEventName)[keyof typeof PushEventName];
136
158
  /**
137
159
  * [zh-CN] SDK 事件名称到事件载荷的映射。
138
160
  * [en-US] Mapping from SDK event names to event payloads.
139
161
  */
140
162
  export interface EventPayloadMap {
163
+ /** [zh-CN] 原生 Push Token 已成功绑定。 [en-US] Native push token was bound successfully. */
164
+ onPushTokenBound: PushTokenBoundEvent;
165
+ /** [zh-CN] 原生 Push Token 注册或绑定失败。 [en-US] Native push token registration or binding failed. */
166
+ onPushTokenBindFailed: PushTokenOperationFailedEvent;
167
+ /** [zh-CN] 原生 Push Token 自动或手动移除失败。 [en-US] Automatic or manual native push token removal failed. */
168
+ onPushTokenRemoveFailed: PushTokenOperationFailedEvent;
169
+ /**
170
+ * [zh-CN] SDK 产生并完成脱敏的结构化日志。控制台日志关闭后,此事件仍可继续触发。
171
+ * [en-US] A structured, sanitized SDK log. This event can still fire when console logging is disabled.
172
+ */
173
+ onLog: LogEntry;
141
174
  /** [zh-CN] 正在连接到服务器(含自动重连)。 [en-US] Connecting to server (including auto-reconnect). */
142
175
  onConnecting: ConnectionEventPayload;
143
176
  /** [zh-CN] 成功连接到服务器。 [en-US] Successfully connected to server. */
@@ -630,6 +663,18 @@ export type ChatEventPayloadMap = Pick<EventPayloadMap, ChatEventName>;
630
663
  export type ChatEventHandlerMap = Partial<{
631
664
  [K in ChatEventName]: (payload: ChatEventPayloadMap[K]) => EventHandlerResult;
632
665
  }>;
666
+ /**
667
+ * [zh-CN] 日志事件载荷映射。
668
+ * [en-US] Log event payload map.
669
+ */
670
+ export type LogEventPayloadMap = Pick<EventPayloadMap, LogEventName>;
671
+ /**
672
+ * [zh-CN] 日志事件处理器映射。
673
+ * [en-US] Log event handler map.
674
+ */
675
+ export type LogEventHandlerMap = Partial<{
676
+ [K in LogEventName]: (payload: LogEventPayloadMap[K]) => EventHandlerResult;
677
+ }>;
633
678
  /**
634
679
  * [zh-CN] 消息话题事件载荷映射。
635
680
  * [en-US] Chat thread event payload map.
@@ -718,4 +763,10 @@ export type EventHandlerMap = Partial<{
718
763
  * [en-US] Event handler registration ID.
719
764
  */
720
765
  export type EventHandlerId = string;
766
+ /** [zh-CN] PushManager 事件载荷映射。 [en-US] PushManager event payload map. */
767
+ export type PushEventPayloadMap = Pick<EventPayloadMap, PushEventName>;
768
+ /** [zh-CN] PushManager 事件处理器映射。 [en-US] PushManager event handler map. */
769
+ export type PushEventHandlerMap = Partial<{
770
+ [K in PushEventName]: (payload: PushEventPayloadMap[K]) => EventHandlerResult;
771
+ }>;
721
772
  export {};
package/types/index.d.ts CHANGED
@@ -8,9 +8,10 @@ import type { ChatThreadMessageContext, ChatThreadOverview } from './chat-thread
8
8
  import type { ChatConversationType } from './message-conversation';
9
9
  import type { Sender } from './sender';
10
10
  export * from './chat-client';
11
+ export * from './log';
11
12
  export * from './sync-data';
12
13
  export * from './connection';
13
- export { ChatEventName, ChatRoomDispatchEventName, ContactEventName, GroupEventName, PresenceEventName, UserInfoEventName, } from './event-system';
14
+ export { ChatEventName, ChatRoomDispatchEventName, ContactEventName, GroupEventName, LogEventName, PresenceEventName, PushEventName, UserInfoEventName, } from './event-system';
14
15
  export type { ChatEventHandlerMap, // Chat 事件处理器映射
15
16
  ChatEventPayloadMap, // Chat 事件载荷映射
16
17
  ContactEventHandlerMap, // 联系人事件处理器映射
@@ -26,7 +27,9 @@ EventName, // 统一事件名称
26
27
  EventPayloadMap, // 事件载荷映射
27
28
  GroupEventHandlerMap, // 群组事件处理器映射
28
29
  GroupEventPayloadMap, // 群组事件载荷映射
29
- UserInfoEventHandlerMap, // 用户资料事件处理器映射
30
+ LogEventHandlerMap, // 日志事件处理器映射
31
+ LogEventPayloadMap, // 日志事件载荷映射
32
+ PushEventHandlerMap, PushEventPayloadMap, UserInfoEventHandlerMap, // 用户资料事件处理器映射
30
33
  UserInfoEventPayloadMap, } from './event-system';
31
34
  export * from './manager';
32
35
  export * from './message-create';
@@ -108,11 +111,6 @@ export interface MessageModifiedInfo {
108
111
  * 连接状态(联合类型,不使用 enum)
109
112
  * 由 src/types/connection.ts 统一定义
110
113
  */
111
- /**
112
- * [zh-CN] SDK 日志级别。
113
- * [en-US] SDK log level.
114
- */
115
- export type LogLevel = 'DEBUG' | 'WARN' | 'ERROR';
116
114
  /**
117
115
  * [zh-CN] 小程序或 uni-app 本地文件对象。
118
116
  * [en-US] Local file descriptor for Mini Program or uni-app runtimes.
package/types/log.d.ts ADDED
@@ -0,0 +1,19 @@
1
+ /**
2
+ * [zh-CN] SDK 日志级别。
3
+ * [en-US] SDK log level.
4
+ */
5
+ export type LogLevel = 'DEBUG' | 'WARN' | 'ERROR';
6
+ /**
7
+ * [zh-CN] SDK 生成并完成脱敏的结构化日志条目。该对象为只读视图,SDK 不提供运行时深冻结保证。
8
+ * [en-US] A structured log entry generated and sanitized by the SDK. This is a readonly view; the SDK does not guarantee runtime deep freezing.
9
+ */
10
+ export interface LogEntry {
11
+ /** [zh-CN] 日志产生时间,使用 ISO 8601 字符串。 [en-US] The log creation time as an ISO 8601 string. */
12
+ readonly timestamp: string;
13
+ /** [zh-CN] 日志级别。 [en-US] The log level. */
14
+ readonly level: LogLevel;
15
+ /** [zh-CN] SDK 日志正文。 [en-US] The SDK log message. */
16
+ readonly message: string;
17
+ /** [zh-CN] 已按 SDK 日志规则脱敏的附加参数。 [en-US] Additional arguments sanitized according to the SDK logging rules. */
18
+ readonly args: ReadonlyArray<unknown>;
19
+ }
@@ -27,6 +27,31 @@ export type RawNotifyEvent = {
27
27
  readonly type: 'userInfo';
28
28
  readonly payload: unknown;
29
29
  };
30
+ /**
31
+ * [zh-CN] Manager 会话结束原因。
32
+ * [en-US] Reason why a manager session is ending.
33
+ */
34
+ export type ManagerSessionEndReason = 'logout' | 'terminal-disconnect';
35
+ /**
36
+ * [zh-CN] Manager 可使用的当前登录会话标识;不包含鉴权 Token。
37
+ * [en-US] Current login session identity available to managers; authentication tokens are excluded.
38
+ */
39
+ export interface ManagerSessionContext {
40
+ /** [zh-CN] 当前 SDK 实例内单调递增的会话代次。 [en-US] Monotonically increasing session generation within this SDK instance. */
41
+ readonly generation: number;
42
+ /** [zh-CN] 当前登录用户 ID。 [en-US] Current logged-in user ID. */
43
+ readonly userId: string;
44
+ /** [zh-CN] 当前连接的设备资源标识。 [en-US] Device resource identifier for the current connection. */
45
+ readonly clientResource: string;
46
+ }
47
+ /**
48
+ * [zh-CN] Manager 会话结束上下文。
49
+ * [en-US] Context provided when a manager session is ending.
50
+ */
51
+ export interface ManagerSessionEndContext extends ManagerSessionContext {
52
+ /** [zh-CN] 会话结束原因。 [en-US] Session-ending reason. */
53
+ readonly reason: ManagerSessionEndReason;
54
+ }
30
55
  /**
31
56
  * [zh-CN] SDK 绑定管理器时提供的事件上下文。
32
57
  * [en-US] Event context provided when the SDK binds a manager.
@@ -50,6 +75,12 @@ export interface ManagerBase<Client> {
50
75
  bind(client: Client, context?: ManagerEventContext): void;
51
76
  /** [zh-CN] 处理管理器订阅的原始通知。 [en-US] Handles raw notifications subscribed to by the manager. */
52
77
  handleRawNotify?(event: RawNotifyEvent): void | Promise<void>;
78
+ /** [zh-CN] 登录上下文就绪后通知管理器;不得阻塞登录主链路。 [en-US] Notifies the manager after login context becomes ready; it must not block the login path. */
79
+ onSessionReady?(context: ManagerSessionContext): void;
80
+ /** [zh-CN] 鉴权上下文清理前通知管理器结束会话。 [en-US] Notifies the manager before authentication context is cleared. */
81
+ onSessionEnding?(context: ManagerSessionEndContext): void | Promise<void>;
82
+ /** [zh-CN] 清理当前会话运行时状态。 [en-US] Clears current session runtime state. */
83
+ resetSessionRuntime?(): void;
53
84
  }
54
85
  /**
55
86
  * [zh-CN] 带静态注册键的管理器构造器。
package/types/push.d.ts CHANGED
@@ -2,6 +2,83 @@
2
2
  * [zh-CN] PushManager 对外类型定义,供推送 API 调用与文档生成使用。
3
3
  * [en-US] Public type definitions for PushManager, used by push APIs and documentation generation.
4
4
  */
5
+ /** [zh-CN] UTS 插件返回的原生推送通道编码。 [en-US] Native push channel code returned by the UTS plugin. */
6
+ export type NativePushTypeCode = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8;
7
+ /** [zh-CN] SDK 归一化后的原生推送通道。 [en-US] SDK-normalized native push channel. */
8
+ export type NativePushChannel = 'apns' | 'fcm' | 'huawei' | 'xiaomi' | 'meizu' | 'vivo' | 'oppo' | 'honor' | 'normal';
9
+ /**
10
+ * [zh-CN] UTS 插件 Token 注册结果。`push_token` 是敏感信息,不应记录日志。
11
+ * [en-US] Token registration result from the UTS plugin. `push_token` is sensitive and must not be logged.
12
+ */
13
+ export interface NativePushTokenResult {
14
+ /** [zh-CN] 厂商或 APNs Token。 [en-US] Vendor or APNs token. */
15
+ readonly push_token: string;
16
+ /** [zh-CN] 插件通道编码。 [en-US] Plugin channel code. */
17
+ readonly push_type: NativePushTypeCode;
18
+ /** [zh-CN] `200` 表示注册成功。 [en-US] `200` indicates successful registration. */
19
+ readonly code: number;
20
+ /** [zh-CN] 插件错误文本,仅供 SDK 内部判断。 [en-US] Plugin error text for internal SDK classification only. */
21
+ readonly error: string;
22
+ }
23
+ /**
24
+ * [zh-CN] SDK 所需的最小 UTS 原生推送插件接口。
25
+ * [en-US] Minimal UTS native push plugin interface required by the SDK.
26
+ */
27
+ export interface NativePushPlugin {
28
+ /** [zh-CN] 注册并持续监听 Token。 [en-US] Registers and continuously observes token updates. */
29
+ onRegister(callback: (result: NativePushTokenResult) => void): void;
30
+ /** [zh-CN] 结束插件侧注册。 [en-US] Ends plugin-side registration. */
31
+ unRegister(): void;
32
+ }
33
+ /**
34
+ * [zh-CN] 各原生通道在环信控制台中的证书名称。
35
+ * [en-US] Certificate names configured in the Easemob console for native channels.
36
+ */
37
+ export interface NativePushCertificates {
38
+ /** [zh-CN] Apple APNs 证书名称。 [en-US] Apple APNs certificate name. */
39
+ readonly apns?: string;
40
+ /** [zh-CN] Firebase Cloud Messaging 证书名称。 [en-US] Firebase Cloud Messaging certificate name. */
41
+ readonly fcm?: string;
42
+ /** [zh-CN] 华为推送证书名称。 [en-US] Huawei push certificate name. */
43
+ readonly huawei?: string;
44
+ /** [zh-CN] 小米推送证书名称。 [en-US] Xiaomi push certificate name. */
45
+ readonly xiaomi?: string;
46
+ /** [zh-CN] 魅族推送证书名称。 [en-US] Meizu push certificate name. */
47
+ readonly meizu?: string;
48
+ /** [zh-CN] vivo 推送证书名称。 [en-US] vivo push certificate name. */
49
+ readonly vivo?: string;
50
+ /** [zh-CN] OPPO 推送证书名称。 [en-US] OPPO push certificate name. */
51
+ readonly oppo?: string;
52
+ /** [zh-CN] 荣耀推送证书名称。 [en-US] Honor push certificate name. */
53
+ readonly honor?: string;
54
+ }
55
+ /** [zh-CN] 配置原生推送所需参数。 [en-US] Options required to configure native push. */
56
+ export interface SetNativePushOptions {
57
+ /** [zh-CN] 宿主从 UTS 导出函数组装的插件对象。 [en-US] Plugin object assembled from host-imported UTS functions. */
58
+ readonly plugin: NativePushPlugin;
59
+ /** [zh-CN] 通道到环信证书名称的映射,至少配置一项。 [en-US] Channel-to-certificate mapping with at least one entry. */
60
+ readonly certificates: NativePushCertificates;
61
+ }
62
+ /** [zh-CN] 原生 Push Token 成功绑定事件。 [en-US] Native push token bound event. */
63
+ export interface PushTokenBoundEvent {
64
+ /** [zh-CN] 实际绑定的原生推送通道。 [en-US] Native push channel that was bound. */
65
+ readonly channel: Exclude<NativePushChannel, 'normal'>;
66
+ /** [zh-CN] 实际使用的环信证书名称。 [en-US] Easemob certificate name used for binding. */
67
+ readonly notifierName: string;
68
+ }
69
+ /** [zh-CN] 原生 Push Token 操作失败事件。 [en-US] Native push token operation failure event. */
70
+ export interface PushTokenOperationFailedEvent {
71
+ /** [zh-CN] 失败发生的操作阶段。 [en-US] Operation stage where the failure occurred. */
72
+ readonly stage: 'register' | 'bind' | 'remove';
73
+ /** [zh-CN] 已解析出的推送通道。 [en-US] Resolved push channel, when available. */
74
+ readonly channel?: NativePushChannel;
75
+ /** [zh-CN] 已匹配的环信证书名称。 [en-US] Matched Easemob certificate name, when available. */
76
+ readonly notifierName?: string;
77
+ /** [zh-CN] SDK 统一错误码。 [en-US] Unified SDK error code. */
78
+ readonly code?: number;
79
+ /** [zh-CN] 相同操作是否适合重试。 [en-US] Whether retrying the same operation is appropriate. */
80
+ readonly retryable: boolean;
81
+ }
5
82
  /**
6
83
  * [zh-CN] 会话类型常量集合。
7
84
  * [en-US] Conversation type constants.
@@ -1,9 +1,6 @@
1
- import type { UploadAdapter } from '../platform';
2
1
  import type { Message, SendMessageOptions } from '../types';
3
2
  import type { UploadConfig } from './types';
4
- interface AttachmentUploaderConfig extends UploadConfig {
5
- uploadAdapter?: UploadAdapter;
6
- }
3
+ type AttachmentUploaderConfig = UploadConfig;
7
4
  export declare class AttachmentUploader {
8
5
  private config;
9
6
  constructor(config?: AttachmentUploaderConfig);
@@ -24,7 +21,6 @@ export declare class AttachmentUploader {
24
21
  private requestPrecheck;
25
22
  private requestJson;
26
23
  private requestByAdapter;
27
- private requestByFetch;
28
24
  private buildPrecheckedUploadResult;
29
25
  private uploadAttachment;
30
26
  private uploadByAdapter;
@@ -1,14 +1,4 @@
1
- import type { UploadRequest } from './types';
2
- import { buildUploadResult } from './utils';
3
- import type { RequestAdapter } from '../platform/types';
4
- import type { DataReportOperationHandle } from '../data-report/types';
5
- export declare const multipartUpload: (request: UploadRequest) => Promise<ReturnType<typeof buildUploadResult>>;
6
- export declare const multipartAbort: (options: {
7
- restBaseUrl: string;
8
- orgName: string;
9
- appName: string;
10
- token: string;
11
- uuid: string;
12
- requestAdapter?: RequestAdapter;
13
- dataReportOperation?: DataReportOperationHandle;
14
- }) => Promise<void>;
1
+ /**
2
+ * @deprecated 浏览器兼容分片上传入口。实际网络实现位于平台层。
3
+ */
4
+ export { multipartAbort, multipartUpload, } from '../platform/upload/legacy-multipart-upload';
@@ -1,3 +1,4 @@
1
- import type { UploadRequest } from './types';
2
- import { buildUploadResult } from './utils';
3
- export declare const simpleUpload: (request: UploadRequest) => Promise<ReturnType<typeof buildUploadResult>>;
1
+ /**
2
+ * @deprecated 浏览器兼容上传入口。实际网络实现位于平台层。
3
+ */
4
+ export { simpleUpload } from '../platform/upload/legacy-simple-upload';
package/upload/types.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { ChatConversationType, FileUploadProgress, FileUploadResult, ImageType, Message, MessageType, SendMessageOptions, CombineMessageBody, FileMessageBody, ImageMessageBody, VideoMessageBody, VoiceMessageBody } from '../types';
2
- import type { ImageProcessor, NormalizedUploadSource, RequestAdapter } from '../platform';
2
+ import type { ImageProcessor, NormalizedUploadSource, RequestAdapter, UploadAdapter } from '../platform';
3
3
  import type { DataReportOperationHandle } from '../data-report/types';
4
4
  export type AttachmentMessageType = Extract<MessageType, 'image' | 'video' | 'voice' | 'file' | 'combine'>;
5
5
  export type ImagePolicyReason = 'explicit-original' | 'default-large' | 'gif-force-origin' | 'large-fallback-origin';
@@ -14,6 +14,7 @@ export interface UploadConfig {
14
14
  enableMd5Check?: boolean;
15
15
  enableMultipartUpload?: boolean;
16
16
  requestAdapter?: RequestAdapter;
17
+ uploadAdapter?: UploadAdapter;
17
18
  imageProcessor?: ImageProcessor;
18
19
  }
19
20
  export interface UploadRequest {
@@ -11,6 +11,7 @@ export declare const ERROR_CODES: {
11
11
  readonly AUTH_LOGIN_TOO_MANY_DEVICES: number;
12
12
  readonly AUTH_USER_MUTED: number;
13
13
  readonly CONNECTION_TIMEOUT: number;
14
+ readonly CONNECTION_LOGIN_TIMEOUT: number;
14
15
  readonly CONNECTION_WEBSOCKET_ERROR: number;
15
16
  readonly CONNECTION_NOT_CREATED: number;
16
17
  readonly CONNECTION_CLOSED_BEFORE_READY: number;