easemob-websdk 4.24.1 → 5.0.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 (324) hide show
  1. package/README.md +95 -39
  2. package/bundle/im-sdk-web.iife.js +1 -0
  3. package/cache/cache-crypto.d.ts +26 -0
  4. package/cache/cache-eviction.d.ts +16 -0
  5. package/cache/cache-keys.d.ts +23 -0
  6. package/cache/cache-manager.d.ts +254 -0
  7. package/cache/cache-metadata.d.ts +14 -0
  8. package/cache/cache-store.d.ts +19 -0
  9. package/cache/cache-types.d.ts +225 -0
  10. package/cache/cache-utils.d.ts +7 -0
  11. package/cache/contact-cache.d.ts +35 -0
  12. package/cache/conversation-cache.d.ts +21 -0
  13. package/cache/group-namecard-cache.d.ts +20 -0
  14. package/cache/index.d.ts +24 -0
  15. package/cache/joined-group-preview-cache.d.ts +12 -0
  16. package/cache/session-list-cache.d.ts +10 -0
  17. package/cache/user-info-cache.d.ts +16 -0
  18. package/chat-client.d.ts +558 -0
  19. package/chunks/cache-utils-BwRPIZ7n.js +1 -0
  20. package/chunks/cache-utils-CKbcYPlM.cjs +1 -0
  21. package/chunks/chat-manager-ChdK26ck.cjs +1 -0
  22. package/chunks/chat-manager-DH8a6Qj9.js +2 -0
  23. package/chunks/common-CfAlncj9.cjs +1 -0
  24. package/chunks/common-DN_g4O3n.js +1 -0
  25. package/chunks/event-system-COBJFEIq.cjs +1 -0
  26. package/chunks/event-system-D6IJA0C4.js +1 -0
  27. package/chunks/group-user-info-resolver-C5pdiqox.cjs +1 -0
  28. package/chunks/group-user-info-resolver-FNRqDg18.js +1 -0
  29. package/chunks/index-BKg4EGcI.cjs +1 -0
  30. package/chunks/index-CK3GHdGU.cjs +1 -0
  31. package/chunks/index-CjofwvEQ.js +1 -0
  32. package/chunks/index-uKWbjx-u.js +1 -0
  33. package/chunks/profile-version-DLMz8lqW.js +1 -0
  34. package/chunks/profile-version-njNs7R5-.cjs +1 -0
  35. package/chunks/reflection-proto-codec-64ocOTHU.js +1 -0
  36. package/chunks/reflection-proto-codec-BnQFQdZC.cjs +1 -0
  37. package/chunks/session-list-query-B6dh-b4Y.cjs +1 -0
  38. package/chunks/session-list-query-Dnp2HbpW.js +1 -0
  39. package/chunks/user-info-BfRwS4ZA.js +1 -0
  40. package/chunks/user-info-icpL0Eaw.cjs +1 -0
  41. package/config/cache.d.ts +12 -0
  42. package/config/timeouts.d.ts +34 -0
  43. package/core/connection/connection-manager.d.ts +228 -0
  44. package/core/connection/connection-retry.d.ts +47 -0
  45. package/core/connection/heartbeat.d.ts +68 -0
  46. package/core/contact-sync/contact-roster-event-sidecar.d.ts +3 -0
  47. package/core/contact-sync/roster-sync-client.d.ts +21 -0
  48. package/core/contact-sync/roster-sync-controller.d.ts +20 -0
  49. package/core/contact-sync/roster-sync-session.d.ts +28 -0
  50. package/core/contact-sync/roster-sync-types.d.ts +74 -0
  51. package/core/events/event-hub.d.ts +13 -0
  52. package/core/group-sync/group-sync-client.d.ts +19 -0
  53. package/core/group-sync/group-sync-controller.d.ts +11 -0
  54. package/core/group-sync/group-sync-merge.d.ts +3 -0
  55. package/core/group-sync/group-sync-normalizer.d.ts +4 -0
  56. package/core/group-sync/group-sync-session.d.ts +17 -0
  57. package/core/group-sync/group-sync-types.d.ts +24 -0
  58. package/core/group-sync/index.d.ts +4 -0
  59. package/core/index.d.ts +95 -0
  60. package/core/message/attachment-downloader.d.ts +7 -0
  61. package/core/message/chatroom-operation-types.d.ts +6 -0
  62. package/core/message/combine-message-downloader.d.ts +7 -0
  63. package/core/message/message-action-types.d.ts +22 -0
  64. package/core/message/message-deduplicator.d.ts +11 -0
  65. package/core/message/message-receiver.d.ts +65 -0
  66. package/core/message/message-retry.d.ts +33 -0
  67. package/core/message/message-sender.d.ts +63 -0
  68. package/core/message/profile-sync/group-namecard-hydration-queue.d.ts +33 -0
  69. package/core/message/profile-sync/group-namecard-hydrator.d.ts +8 -0
  70. package/core/message/profile-sync/latest-message-version-projector.d.ts +3 -0
  71. package/core/message/profile-sync/profile-version-sidecar.d.ts +9 -0
  72. package/core/message/profile-sync/profile-version.d.ts +3 -0
  73. package/core/message/profile-sync/user-info-hydration-queue.d.ts +29 -0
  74. package/core/message/profile-sync/user-info-hydrator.d.ts +8 -0
  75. package/core/message/stream-message-cache.d.ts +38 -0
  76. package/core/message/stream-message-handler.d.ts +22 -0
  77. package/core/session-list-sync/session-list-query.d.ts +26 -0
  78. package/core/session-list-sync/session-list-sync-controller.d.ts +17 -0
  79. package/core/session-list-sync/session-list-sync-merge.d.ts +17 -0
  80. package/core/session-list-sync/session-list-sync-normalizer.d.ts +6 -0
  81. package/core/session-list-sync/session-list-sync-runner.d.ts +13 -0
  82. package/core/session-list-sync/session-list-sync-session.d.ts +26 -0
  83. package/core/session-list-sync/session-list-sync-types.d.ts +24 -0
  84. package/core/sync/shared-sync-websocket-session.d.ts +61 -0
  85. package/core/user-info/group-user-info-resolver.d.ts +40 -0
  86. package/data-report/bridge.d.ts +11 -0
  87. package/data-report/constants.d.ts +25 -0
  88. package/data-report/data-reporter.d.ts +21 -0
  89. package/data-report/event-queue.d.ts +38 -0
  90. package/data-report/index.d.ts +3 -0
  91. package/data-report/network-type.d.ts +1 -0
  92. package/data-report/operation-map.d.ts +8 -0
  93. package/data-report/transport.d.ts +17 -0
  94. package/data-report/types.d.ts +61 -0
  95. package/index.cjs +1 -0
  96. package/index.d.ts +134 -0
  97. package/index.js +3 -0
  98. package/managers/chat/index.cjs +1 -0
  99. package/managers/chat/index.d.ts +1 -0
  100. package/managers/chat/index.js +1 -0
  101. package/managers/chat-manager.d.ts +880 -0
  102. package/managers/chat-thread/chat-thread.d.ts +126 -0
  103. package/managers/chat-thread/index.cjs +1 -0
  104. package/managers/chat-thread/index.d.ts +2 -0
  105. package/managers/chat-thread/index.js +1 -0
  106. package/managers/chat-thread-manager.d.ts +257 -0
  107. package/managers/chatroom/chatroom-event-mapper.d.ts +17 -0
  108. package/managers/chatroom/chatroom-event-user-info-resolver.d.ts +15 -0
  109. package/managers/chatroom/chatroom-normalizers.d.ts +23 -0
  110. package/managers/chatroom/chatroom.d.ts +403 -0
  111. package/managers/chatroom/index.cjs +1 -0
  112. package/managers/chatroom/index.d.ts +2 -0
  113. package/managers/chatroom/index.js +1 -0
  114. package/managers/chatroom-manager.d.ts +604 -0
  115. package/managers/contact/contact-user-info-resolver.d.ts +15 -0
  116. package/managers/contact/index.cjs +1 -0
  117. package/managers/contact/index.d.ts +1 -0
  118. package/managers/contact/index.js +1 -0
  119. package/managers/contact-manager.d.ts +215 -0
  120. package/managers/group/group-event-mapper.d.ts +18 -0
  121. package/managers/group/group-event-user-info-resolver.d.ts +15 -0
  122. package/managers/group/group-normalizers.d.ts +15 -0
  123. package/managers/group/group.d.ts +504 -0
  124. package/managers/group/index.cjs +1 -0
  125. package/managers/group/index.d.ts +2 -0
  126. package/managers/group/index.js +1 -0
  127. package/managers/group/internal/group-event-sync.d.ts +13 -0
  128. package/managers/group/internal/group-repository.d.ts +31 -0
  129. package/managers/group/internal/group-snapshot-mapper.d.ts +6 -0
  130. package/managers/group/internal/internal-group.d.ts +24 -0
  131. package/managers/group-manager.d.ts +371 -0
  132. package/managers/presence/index.cjs +1 -0
  133. package/managers/presence/index.d.ts +1 -0
  134. package/managers/presence/index.js +1 -0
  135. package/managers/presence-manager.d.ts +201 -0
  136. package/managers/push/index.cjs +1 -0
  137. package/managers/push/index.d.ts +1 -0
  138. package/managers/push/index.js +1 -0
  139. package/managers/push-manager.d.ts +205 -0
  140. package/managers/user-info/index.cjs +1 -0
  141. package/managers/user-info/index.d.ts +4 -0
  142. package/managers/user-info/index.js +1 -0
  143. package/managers/user-info/user-info-notify-normalizer.d.ts +2 -0
  144. package/managers/user-info/user-info-runtime-store.d.ts +28 -0
  145. package/managers/user-info-manager.d.ts +196 -0
  146. package/message/combine-compatible-text-sidecar.d.ts +4 -0
  147. package/message/combine-message-constraints.d.ts +7 -0
  148. package/message/combine-payload-codec.d.ts +17 -0
  149. package/message/create-message.d.ts +64 -0
  150. package/package.json +64 -16
  151. package/platform/capability-validator.d.ts +7 -0
  152. package/platform/env.d.ts +68 -0
  153. package/platform/factory.d.ts +7 -0
  154. package/platform/image/miniapp-image-processor.d.ts +45 -0
  155. package/platform/image/web-image-processor.d.ts +2 -0
  156. package/platform/index.d.ts +17 -0
  157. package/platform/miniapp/miniapp-adapter.d.ts +3 -0
  158. package/platform/proto/proto-adapter.d.ts +17 -0
  159. package/platform/proto/reflection-proto-codec.d.ts +8 -0
  160. package/platform/proto/static-proto-adapter.d.ts +8 -0
  161. package/platform/request/web-request-adapter.d.ts +9 -0
  162. package/platform/runtime/connection-event-normalizer.d.ts +14 -0
  163. package/platform/runtime/runtime-event-bridge.d.ts +23 -0
  164. package/platform/runtime/web-runtime-adapter.d.ts +26 -0
  165. package/platform/socket/web-socket-adapter.d.ts +8 -0
  166. package/platform/types.d.ts +472 -0
  167. package/platform/upload/react-native-upload-adapter.d.ts +14 -0
  168. package/platform/upload/upload-error-mapper.d.ts +7 -0
  169. package/platform/upload/upload-source.d.ts +20 -0
  170. package/platform/upload/web-upload-adapter.d.ts +10 -0
  171. package/protocol/joined-groups/codec.d.ts +11 -0
  172. package/protocol/joined-groups/gateway.d.ts +2 -0
  173. package/protocol/joined-groups/index.d.ts +2 -0
  174. package/protocol/joined-groups/proto.d.ts +174 -0
  175. package/protocol/joined-groups/types.d.ts +65 -0
  176. package/protocol/msync/codec.d.ts +191 -0
  177. package/protocol/msync/context.d.ts +40 -0
  178. package/protocol/msync/lz4-compressor/index.d.ts +40 -0
  179. package/protocol/msync/lz4-compressor/utils.d.ts +27 -0
  180. package/protocol/msync/multi-device-normalizer.d.ts +75 -0
  181. package/protocol/msync/proto.d.ts +1306 -0
  182. package/protocol/msync/root.d.ts +5 -0
  183. package/protocol/msync/types.d.ts +96 -0
  184. package/protocol/msync/utils.d.ts +26 -0
  185. package/protocol/protobuf/decoder.d.ts +44 -0
  186. package/protocol/protobuf/encoder.d.ts +23 -0
  187. package/protocol/protobuf/types.d.ts +53 -0
  188. package/protocol/roster/codec.d.ts +9 -0
  189. package/protocol/roster/proto.d.ts +205 -0
  190. package/protocol/roster/root.d.ts +5 -0
  191. package/protocol/roster/types.d.ts +83 -0
  192. package/protocol/session-list/codec.d.ts +11 -0
  193. package/protocol/session-list/gateway.d.ts +19 -0
  194. package/protocol/session-list/payload-decoder.d.ts +1 -0
  195. package/protocol/session-list/proto.d.ts +207 -0
  196. package/protocol/session-list/types.d.ts +83 -0
  197. package/rest/chat-management.d.ts +26 -0
  198. package/rest/chat-thread-management.d.ts +14 -0
  199. package/rest/chatroom-management.d.ts +40 -0
  200. package/rest/client.d.ts +86 -0
  201. package/rest/contact-management.d.ts +27 -0
  202. package/rest/contact-metadata.d.ts +11 -0
  203. package/rest/conversation-management.d.ts +11 -0
  204. package/rest/dns-config.d.ts +20 -0
  205. package/rest/error-map-types.d.ts +32 -0
  206. package/rest/error-maps/chat.d.ts +888 -0
  207. package/rest/error-maps/chatroom.d.ts +592 -0
  208. package/rest/error-maps/common.d.ts +208 -0
  209. package/rest/error-maps/contact.d.ts +185 -0
  210. package/rest/error-maps/core.d.ts +21 -0
  211. package/rest/error-maps/group.d.ts +500 -0
  212. package/rest/error-maps/index.d.ts +9 -0
  213. package/rest/error-maps/presence.d.ts +62 -0
  214. package/rest/error-maps/push.d.ts +158 -0
  215. package/rest/error-maps/thread.d.ts +538 -0
  216. package/rest/error-maps/user-info.d.ts +289 -0
  217. package/rest/errors.d.ts +23 -0
  218. package/rest/group-management.d.ts +55 -0
  219. package/rest/rtc-token.d.ts +14 -0
  220. package/rest/speech-helpers.d.ts +24 -0
  221. package/rest/user-info-subscription.d.ts +10 -0
  222. package/rest/user-info.d.ts +34 -0
  223. package/types/chat-client.d.ts +226 -0
  224. package/types/chat-manager.d.ts +641 -0
  225. package/types/chat-thread.d.ts +311 -0
  226. package/types/chatroom.d.ts +1258 -0
  227. package/types/connection.d.ts +111 -0
  228. package/types/contact.d.ts +149 -0
  229. package/types/conversation.d.ts +270 -0
  230. package/types/event-system.d.ts +721 -0
  231. package/types/group.d.ts +980 -0
  232. package/types/index.d.ts +577 -44
  233. package/types/manager.d.ts +99 -0
  234. package/types/message-conversation.d.ts +22 -0
  235. package/types/message-create.d.ts +173 -0
  236. package/types/multi-device.d.ts +275 -0
  237. package/types/presence.d.ts +101 -0
  238. package/types/push.d.ts +296 -0
  239. package/types/sender.d.ts +12 -0
  240. package/types/sync-data.d.ts +54 -0
  241. package/types/user-info.d.ts +178 -0
  242. package/upload/attachment-file-store.d.ts +11 -0
  243. package/upload/attachment-uploader.d.ts +36 -0
  244. package/upload/constants.d.ts +8 -0
  245. package/upload/index.d.ts +2 -0
  246. package/upload/multipart-upload.d.ts +14 -0
  247. package/upload/simple-upload.d.ts +3 -0
  248. package/upload/types.d.ts +79 -0
  249. package/upload/utils.d.ts +71 -0
  250. package/utils/env.d.ts +4 -0
  251. package/utils/error-codes.d.ts +2 -0
  252. package/utils/error-codes.generated.d.ts +145 -0
  253. package/utils/error-sanitizer.d.ts +8 -0
  254. package/utils/errors.d.ts +139 -0
  255. package/utils/log-reporter.d.ts +61 -0
  256. package/utils/log-sanitizer.d.ts +6 -0
  257. package/utils/logger.d.ts +48 -0
  258. package/utils/md5.d.ts +1 -0
  259. package/utils/message-id.d.ts +12 -0
  260. package/utils/provision-error-mapping.d.ts +21 -0
  261. package/utils/retry.d.ts +26 -0
  262. package/utils/runtime-global.d.ts +4 -0
  263. package/utils/trace-id.d.ts +5 -0
  264. package/utils/utf8.d.ts +2 -0
  265. package/validators/chat-client.d.ts +787 -0
  266. package/validators/message-create.d.ts +419 -0
  267. package/validators/search-messages.d.ts +127 -0
  268. package/validators/validator.d.ts +49 -0
  269. package/version.d.ts +2 -0
  270. package/Easemob-chat.d.ts +0 -8457
  271. package/Easemob-chat.js +0 -2
  272. package/chatroom/chatroom.d.ts +0 -649
  273. package/chatroom/chatroom.js +0 -1
  274. package/contact/contact.d.ts +0 -726
  275. package/contact/contact.js +0 -1
  276. package/group/group.d.ts +0 -848
  277. package/group/group.js +0 -1
  278. package/localCache/localCache.d.ts +0 -59
  279. package/localCache/localCache.js +0 -1
  280. package/message/audio.d.ts +0 -183
  281. package/message/channel.d.ts +0 -82
  282. package/message/cmd.d.ts +0 -146
  283. package/message/combine.d.ts +0 -132
  284. package/message/custom.d.ts +0 -135
  285. package/message/delivery.d.ts +0 -77
  286. package/message/file.d.ts +0 -173
  287. package/message/img.d.ts +0 -200
  288. package/message/index.d.ts +0 -211
  289. package/message/location.d.ts +0 -134
  290. package/message/read.d.ts +0 -85
  291. package/message/text.d.ts +0 -149
  292. package/message/video.d.ts +0 -180
  293. package/miniCore/miniCore.d.ts +0 -217
  294. package/miniCore/miniCore.js +0 -2
  295. package/miniProgram/Easemob-chat.js +0 -2
  296. package/miniProgram/miniProgram.zip +0 -0
  297. package/presence/presence.d.ts +0 -69
  298. package/presence/presence.js +0 -1
  299. package/silent/silent.d.ts +0 -128
  300. package/silent/silent.js +0 -1
  301. package/status.d.ts +0 -184
  302. package/thread/thread.d.ts +0 -159
  303. package/thread/thread.js +0 -1
  304. package/translation/translation.d.ts +0 -30
  305. package/translation/translation.js +0 -1
  306. package/types/chatRoomApi.d.ts +0 -226
  307. package/types/common.d.ts +0 -89
  308. package/types/engineCore.d.ts +0 -194
  309. package/types/error.d.ts +0 -13
  310. package/types/eventHandler.d.ts +0 -437
  311. package/types/groupApi.d.ts +0 -306
  312. package/types/indexApi.d.ts +0 -366
  313. package/types/localCache.d.ts +0 -53
  314. package/types/message.d.ts +0 -959
  315. package/types/presenceApi.d.ts +0 -61
  316. package/types/reactionApi.d.ts +0 -74
  317. package/types/restApis.d.ts +0 -6
  318. package/types/silentModeApi.d.ts +0 -109
  319. package/types/threadApi.d.ts +0 -175
  320. package/types/translation.d.ts +0 -25
  321. package/types/utils.d.ts +0 -90
  322. package/uniApp/Easemob-chat.js +0 -2
  323. package/uniApp/uniApp.zip +0 -0
  324. package/websdk.zip +0 -0
@@ -0,0 +1,68 @@
1
+ /**
2
+ * 心跳机制
3
+ *
4
+ * 实现 ping/pong 机制,超时处理
5
+ * 参考:HEARTBEAT_INTERVAL = 30000ms
6
+ */
7
+ import { type SocketLike } from '../../platform';
8
+ /**
9
+ * 心跳配置
10
+ */
11
+ export interface HeartbeatConfig {
12
+ interval?: number;
13
+ timeout?: number;
14
+ }
15
+ /**
16
+ * 心跳管理器
17
+ */
18
+ export declare class HeartbeatManager {
19
+ private config;
20
+ private websocket;
21
+ private heartbeatTimer;
22
+ private timeoutTimer;
23
+ private lastPongTime;
24
+ private onTimeoutCallback;
25
+ private sendPing;
26
+ private probeResolvers;
27
+ private messageDisposer;
28
+ private readonly handlePong;
29
+ constructor(config?: HeartbeatConfig);
30
+ /**
31
+ * 启动心跳
32
+ */
33
+ start(websocket: SocketLike, onTimeout?: () => void, sendPing?: () => void): void;
34
+ /**
35
+ * 停止心跳
36
+ */
37
+ stop(): void;
38
+ /**
39
+ * 发送 ping
40
+ */
41
+ private sendPingInternal;
42
+ /**
43
+ * 处理 pong 消息
44
+ */
45
+ private extractMessageText;
46
+ private parseJson;
47
+ private static isRecord;
48
+ private static readString;
49
+ /**
50
+ * 重置超时定时器
51
+ */
52
+ private resetTimeout;
53
+ /**
54
+ * 标记心跳成功
55
+ */
56
+ markAlive(): void;
57
+ /**
58
+ * 获取最后 pong 时间
59
+ */
60
+ getLastPongTime(): number;
61
+ /**
62
+ * 单次心跳探测
63
+ */
64
+ probeOnce(websocket: SocketLike, timeoutMs?: number): Promise<boolean>;
65
+ private attachWebSocket;
66
+ private resolveProbe;
67
+ private removeProbeResolver;
68
+ }
@@ -0,0 +1,3 @@
1
+ import type { ContactRosterEventPayload } from '../../types/contact';
2
+ export declare const setContactRosterVersionSidecar: (payload: ContactRosterEventPayload, rosterVersion: string | undefined) => void;
3
+ export declare const getContactRosterVersionSidecar: (payload: ContactRosterEventPayload) => string | undefined;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * 联系人同步 websocket 客户端
3
+ */
4
+ import type { SharedSyncWebSocketSession } from '../sync/shared-sync-websocket-session';
5
+ import type { RosterRequest } from '../../protocol/roster/types';
6
+ export declare class RosterSyncClient {
7
+ private readonly codec;
8
+ private readonly sharedSession;
9
+ constructor(sharedSession: SharedSyncWebSocketSession);
10
+ sync(options: {
11
+ urls: ReadonlyArray<string>;
12
+ request: RosterRequest;
13
+ }): Promise<{
14
+ readonly mode: 'full' | 'incremental';
15
+ readonly version: string;
16
+ readonly pages: ReadonlyArray<import('../../protocol/roster/types').RosterResponse>;
17
+ }>;
18
+ cancel(): void;
19
+ private syncWithSharedSession;
20
+ private buildAttemptRequest;
21
+ }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * 联系人同步控制器
3
+ */
4
+ import type { ContactSyncContextState, ContactSyncDependencies, ContactSyncDecisionResult } from './roster-sync-types';
5
+ export declare const decideContactSync: (options: {
6
+ metadata?: {
7
+ readonly version: string;
8
+ readonly requiresSync: boolean;
9
+ };
10
+ metadataFailed?: boolean;
11
+ state: ContactSyncContextState;
12
+ }) => ContactSyncDecisionResult;
13
+ export declare class RosterSyncController {
14
+ private readonly dependencies;
15
+ private running;
16
+ constructor(dependencies: ContactSyncDependencies);
17
+ sync(): Promise<void>;
18
+ cancel(): void;
19
+ private runSync;
20
+ }
@@ -0,0 +1,28 @@
1
+ /**
2
+ * 联系人同步分页会话
3
+ */
4
+ import type { RosterResponse } from '../../protocol/roster/types';
5
+ export declare class RosterSyncSession {
6
+ private readonly requestId;
7
+ private readonly pages;
8
+ private responseType;
9
+ private version;
10
+ private nextCursor;
11
+ private pageCount;
12
+ private completed;
13
+ constructor(requestId: string);
14
+ push(page: RosterResponse): {
15
+ readonly done: boolean;
16
+ readonly nextCursor: number;
17
+ readonly pageCount: number;
18
+ };
19
+ getNextCursor(): number;
20
+ getPageCount(): number;
21
+ hasPages(): boolean;
22
+ isCompleted(): boolean;
23
+ buildResult(): {
24
+ readonly mode: 'full' | 'incremental';
25
+ readonly version: string;
26
+ readonly pages: ReadonlyArray<RosterResponse>;
27
+ };
28
+ }
@@ -0,0 +1,74 @@
1
+ /**
2
+ * 联系人同步内部类型
3
+ */
4
+ import type { ContactCacheMeta, ContactRelationRecord, ContactVersionState } from '../../cache/cache-types';
5
+ import type { ContactSnapshot, ContactSyncDecision, ContactSyncStage } from '../../types/contact';
6
+ import type { ContactMetadataVersionResponse } from '../../rest/contact-metadata';
7
+ import type { RosterRequest, RosterResponse } from '../../protocol/roster/types';
8
+ import type { SharedSyncWebSocketSession } from '../sync/shared-sync-websocket-session';
9
+ export interface ContactSyncDecisionResult {
10
+ readonly decision: ContactSyncDecision;
11
+ readonly version: string;
12
+ }
13
+ export interface ParsedRosterMetadata {
14
+ readonly nickname?: string;
15
+ readonly avatarUrl?: string;
16
+ readonly sign?: string;
17
+ readonly ext?: string;
18
+ }
19
+ export interface ParsedRosterItem {
20
+ readonly relation: ContactRelationRecord;
21
+ readonly userInfo: {
22
+ readonly userId: string;
23
+ readonly nickname?: string;
24
+ readonly avatarUrl?: string;
25
+ readonly sign?: string;
26
+ readonly ext?: string;
27
+ };
28
+ }
29
+ export interface ContactSyncContextState {
30
+ readonly cacheMeta: ContactCacheMeta;
31
+ readonly versionState: ContactVersionState;
32
+ readonly cachedSnapshot: ContactSnapshot;
33
+ }
34
+ export interface ContactSyncFailure {
35
+ readonly code: number;
36
+ readonly stage: ContactSyncStage;
37
+ readonly message: string;
38
+ readonly retryable: boolean;
39
+ }
40
+ export interface RosterSyncExecutionResult {
41
+ readonly mode: 'full' | 'incremental';
42
+ readonly version: string;
43
+ readonly pages: ReadonlyArray<RosterResponse>;
44
+ }
45
+ export interface ContactSyncDependencies {
46
+ readonly getContextState: () => ContactSyncContextState;
47
+ readonly queryMetadata: (currentVersion: string) => Promise<ContactMetadataVersionResponse>;
48
+ readonly getSyncUrls: () => Promise<ReadonlyArray<string>>;
49
+ readonly getSharedSyncSession: () => SharedSyncWebSocketSession;
50
+ readonly buildRosterRequest: (options: {
51
+ decision: ContactSyncDecision;
52
+ version: string;
53
+ }) => RosterRequest;
54
+ readonly applySyncResult: (options: {
55
+ mode: 'full' | 'incremental';
56
+ relations: ReadonlyArray<ContactRelationRecord>;
57
+ userInfos: ReadonlyArray<{
58
+ readonly userId: string;
59
+ readonly nickname?: string;
60
+ readonly avatarUrl?: string;
61
+ readonly sign?: string;
62
+ readonly ext?: string;
63
+ }>;
64
+ version: string;
65
+ lastSyncTs: number;
66
+ }) => {
67
+ readonly snapshot: ContactSnapshot;
68
+ readonly changed: boolean;
69
+ };
70
+ readonly onStart: () => void;
71
+ readonly onFinish: (payload?: {
72
+ readonly error: ContactSyncFailure;
73
+ }) => void;
74
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * 统一事件系统 EventHub
3
+ */
4
+ import type { EventHandlerId, EventHandlerMap, EventName, EventPayloadMap } from '../../types/event-system';
5
+ export declare class EventHub {
6
+ private handlers;
7
+ addEventHandler(id: EventHandlerId, handlers: EventHandlerMap): void;
8
+ removeEventHandler(id: EventHandlerId): void;
9
+ dispatch<K extends EventName>(event: K, payload: EventPayloadMap[K]): void;
10
+ private dispatchToHandlers;
11
+ private invokeHandler;
12
+ private isPromiseLike;
13
+ }
@@ -0,0 +1,19 @@
1
+ import { SDKError } from '../../utils/errors';
2
+ import type { SharedSyncWebSocketSession } from '../sync/shared-sync-websocket-session';
3
+ import type { JoinedGroupsErrorDetail, JoinedGroupsRequest, JoinedGroupsResponse } from '../../protocol/joined-groups/types';
4
+ export declare const mapJoinedGroupsApiError: (detail: JoinedGroupsErrorDetail) => SDKError;
5
+ export declare class GroupSyncClient {
6
+ private readonly codec;
7
+ private readonly sharedSession;
8
+ constructor(sharedSession: SharedSyncWebSocketSession);
9
+ sync(options: {
10
+ readonly urls: ReadonlyArray<string>;
11
+ readonly request: JoinedGroupsRequest;
12
+ }): Promise<{
13
+ readonly batches: ReadonlyArray<JoinedGroupsResponse>;
14
+ readonly lastSyncFinishedTs?: number;
15
+ }>;
16
+ cancel(): void;
17
+ private syncWithSharedSession;
18
+ private buildAttemptRequest;
19
+ }
@@ -0,0 +1,11 @@
1
+ import type { GroupSyncControllerDependencies } from './group-sync-types';
2
+ export declare class GroupSyncController {
3
+ private readonly dependencies;
4
+ private running;
5
+ constructor(dependencies: GroupSyncControllerDependencies);
6
+ sync(): Promise<void>;
7
+ cancel(): void;
8
+ private runSync;
9
+ private hasSameMembership;
10
+ private buildRequest;
11
+ }
@@ -0,0 +1,3 @@
1
+ import type { JoinedGroupSnapshot } from '../../types/group';
2
+ import type { GroupSyncMergeInput } from './group-sync-types';
3
+ export declare const mergeJoinedGroupSnapshot: (input: GroupSyncMergeInput) => JoinedGroupSnapshot;
@@ -0,0 +1,4 @@
1
+ import type { JoinedGroupProtocolItem } from '../../protocol/joined-groups/types';
2
+ import type { JoinedGroupSummary } from '../../types/group';
3
+ export declare const normalizeJoinedGroupItem: (item: JoinedGroupProtocolItem) => JoinedGroupSummary | null;
4
+ export declare const normalizeJoinedGroupItems: (items: ReadonlyArray<JoinedGroupProtocolItem>) => ReadonlyArray<JoinedGroupSummary>;
@@ -0,0 +1,17 @@
1
+ import type { JoinedGroupsResponse } from '../../protocol/joined-groups/types';
2
+ export declare class GroupSyncSession {
3
+ private readonly requestId;
4
+ private readonly batches;
5
+ private latestCursor;
6
+ private done;
7
+ private lastSyncFinishedTs;
8
+ constructor(requestId: string);
9
+ getResumeCursor(): string | undefined;
10
+ push(response: JoinedGroupsResponse): {
11
+ readonly done: boolean;
12
+ };
13
+ buildResult(): {
14
+ readonly batches: ReadonlyArray<JoinedGroupsResponse>;
15
+ readonly lastSyncFinishedTs?: number;
16
+ };
17
+ }
@@ -0,0 +1,24 @@
1
+ import type { CacheManager } from '../../cache/cache-manager';
2
+ import type { JoinedGroupSnapshot, JoinedGroupSummary } from '../../types/group';
3
+ import type { SyncDataError } from '../../types/sync-data';
4
+ import type { RestContext } from '../../types/chat-client';
5
+ import type { SharedSyncWebSocketSession } from '../sync/shared-sync-websocket-session';
6
+ export type GroupSyncStage = 'config' | 'socket_connect' | 'request_send' | 'response_decode' | 'batch_merge' | 'preview_persist' | 'completion_meta' | 'auth' | 'server_limit' | 'cancelled';
7
+ export interface GroupSyncControllerDependencies {
8
+ readonly getRestContext: () => RestContext;
9
+ readonly getSyncUrls: () => Promise<ReadonlyArray<string>>;
10
+ readonly getSharedSyncSession: () => SharedSyncWebSocketSession;
11
+ readonly getCacheManager: () => CacheManager;
12
+ readonly getRuntimeSnapshot: () => JoinedGroupSnapshot | null;
13
+ readonly applyRuntimeSnapshot: (snapshot: JoinedGroupSnapshot) => void;
14
+ readonly onStart: () => void;
15
+ readonly onFinish: (payload: {
16
+ readonly status: 'success' | 'failed';
17
+ readonly error?: SyncDataError;
18
+ }) => void;
19
+ }
20
+ export interface GroupSyncMergeInput {
21
+ readonly existingItems: ReadonlyArray<JoinedGroupSummary>;
22
+ readonly incomingItems: ReadonlyArray<JoinedGroupSummary>;
23
+ readonly lastSyncFinishedTs?: number;
24
+ }
@@ -0,0 +1,4 @@
1
+ export * from './group-sync-controller';
2
+ export * from './group-sync-normalizer';
3
+ export * from './group-sync-merge';
4
+ export * from './group-sync-types';
@@ -0,0 +1,95 @@
1
+ /**
2
+ * 核心模块集成
3
+ *
4
+ * 集成连接和消息组件
5
+ */
6
+ import { EventHub } from './events/event-hub';
7
+ import type { ConnectionStatus, Message, DownloadCombineMessageParams, MessageAttachmentDownloadResult, SendMessageOptions, TokenRenewalResult } from '../types';
8
+ import type { PlatformFactoryResult, SocketAdapter } from '../platform';
9
+ import type { MessageActionRequest, ActionAckResult } from './message/message-action-types';
10
+ import type { ChatRoomOperationRequest } from './message/chatroom-operation-types';
11
+ /**
12
+ * 核心 SDK 类
13
+ */
14
+ export declare class CoreSDK {
15
+ private eventHub;
16
+ private connectionManager;
17
+ private messageSender;
18
+ private messageReceiver;
19
+ private combineMessageDownloader;
20
+ private attachmentDownloader;
21
+ private readonly platformAdapter;
22
+ private runtimeEventBridge;
23
+ private readonly handleOnline;
24
+ private readonly handleOffline;
25
+ private readonly handleForegroundChange;
26
+ constructor(config: {
27
+ serverUrl: string;
28
+ serverUrls?: ReadonlyArray<string>;
29
+ userId: string;
30
+ token: string;
31
+ appKey: string;
32
+ restBaseUrl?: string;
33
+ useCustomAttachmentUpload?: boolean;
34
+ enableMd5Check?: boolean;
35
+ enableMultipartUpload?: boolean;
36
+ heartBeatWait?: number;
37
+ autoReconnectNumMax?: number;
38
+ useReplacedMessageContents?: boolean;
39
+ useFixedDeviceId?: boolean;
40
+ deviceId?: string;
41
+ customDeviceName?: string;
42
+ customOSPlatform?: number;
43
+ uiKitVersion?: string;
44
+ loginExtensionInfo?: string;
45
+ serviceId?: string;
46
+ platformAdapter?: PlatformFactoryResult;
47
+ socketAdapter?: SocketAdapter;
48
+ enableDeliveryReceipt?: boolean;
49
+ }, eventHub: EventHub);
50
+ /**
51
+ * 设置事件处理器
52
+ */
53
+ private setupEventHandlers;
54
+ private registerNetworkListeners;
55
+ private unregisterNetworkListeners;
56
+ private resolveRuntimeAdapter;
57
+ private createBrowserRuntimeAdapter;
58
+ /**
59
+ * 连接
60
+ */
61
+ connect(): Promise<void>;
62
+ /**
63
+ * 断开连接
64
+ */
65
+ disconnect(): Promise<void>;
66
+ /**
67
+ * 获取连接状态
68
+ */
69
+ getConnectionStatus(): ConnectionStatus;
70
+ /**
71
+ * 获取客户端资源标识
72
+ */
73
+ getClientResource(): string;
74
+ /**
75
+ * 更新当前连接与发送链路使用的 IM token。
76
+ * Updates the IM token used by connection and send pipeline.
77
+ */
78
+ renewToken(token: string, expireAt: number): TokenRenewalResult;
79
+ /**
80
+ * 发送消息
81
+ */
82
+ sendMessage(message: Message, options?: SendMessageOptions): Promise<Message>;
83
+ sendMessageAction(action: MessageActionRequest, createAckError?: (statusCode: number, reason?: string) => Error): Promise<ActionAckResult>;
84
+ sendChatRoomOperation(request: ChatRoomOperationRequest, createAckError?: (statusCode: number, reason?: string) => Error): Promise<ActionAckResult>;
85
+ /**
86
+ * 下载并解析合并消息详情
87
+ */
88
+ downloadAndParseCombineMessage(options: DownloadCombineMessageParams): Promise<ReadonlyArray<Message>>;
89
+ downloadAttachment(message: Message, timeoutMs?: number): Promise<MessageAttachmentDownloadResult>;
90
+ decodeServerMessageMeta(metaPayload: Uint8Array): Message | null;
91
+ /**
92
+ * 销毁
93
+ */
94
+ destroy(): void;
95
+ }
@@ -0,0 +1,7 @@
1
+ import type { RequestAdapter } from '../../platform';
2
+ import type { Message, MessageAttachmentDownloadResult } from '../../types';
3
+ export declare class AttachmentDownloader {
4
+ private readonly requestAdapter;
5
+ constructor(requestAdapter?: RequestAdapter);
6
+ download(message: Message, timeoutMs?: number): Promise<MessageAttachmentDownloadResult>;
7
+ }
@@ -0,0 +1,6 @@
1
+ export interface ChatRoomOperationRequest {
2
+ readonly operation: 'join' | 'leave';
3
+ readonly chatRoomId: string;
4
+ readonly ext?: string;
5
+ readonly leaveOtherRooms?: boolean;
6
+ }
@@ -0,0 +1,7 @@
1
+ import type { RequestAdapter } from '../../platform';
2
+ import type { DownloadCombineMessageParams, Message } from '../../types';
3
+ export declare class CombineMessageDownloader {
4
+ private readonly requestAdapter;
5
+ constructor(requestAdapter?: RequestAdapter);
6
+ downloadAndParse(options: DownloadCombineMessageParams): Promise<ReadonlyArray<Message>>;
7
+ }
@@ -0,0 +1,22 @@
1
+ import type { ChatConversationType } from '../../types/chat-manager';
2
+ import type { JoinChatRoomInfo } from '../../types/chatroom';
3
+ import type { Message, MessageBody } from '../../types';
4
+ export interface MessageActionRequest {
5
+ readonly kind: 'clearConversationUnreadMessageCount' | 'clearAllConversationUnreadMessageCount' | 'sendMessageReadReceipts' | 'recall' | 'update' | 'deliveryAck';
6
+ readonly conversationId: string;
7
+ readonly conversationType: ChatConversationType;
8
+ readonly messageId?: string;
9
+ readonly messageIds?: ReadonlyArray<string>;
10
+ readonly sendToPeer?: boolean;
11
+ readonly clearAllUnreadMessageCount?: boolean;
12
+ readonly body?: MessageBody;
13
+ readonly messageType?: Message['type'];
14
+ readonly ext?: Record<string, unknown>;
15
+ }
16
+ export interface ActionAckResult {
17
+ readonly protocolId: string;
18
+ readonly serverId: string;
19
+ readonly statusCode: number;
20
+ readonly reason?: string;
21
+ readonly chatRoomInfo?: JoinChatRoomInfo;
22
+ }
@@ -0,0 +1,11 @@
1
+ /** 普通消息最近 ID 的有界去重器。 */
2
+ export declare class RecentMessageIdDeduper {
3
+ private readonly limit;
4
+ private readonly seenIds;
5
+ private readonly orderedIds;
6
+ constructor(limit?: number);
7
+ /** 返回 true 表示 ID 已在当前窗口内出现。 */
8
+ checkAndRecord(messageId: string): boolean;
9
+ clear(): void;
10
+ size(): number;
11
+ }
@@ -0,0 +1,65 @@
1
+ /**
2
+ * 消息接收器
3
+ *
4
+ * 负责处理下行 SYNC 消息:解析 ACK 与聊天消息,并派发事件。
5
+ */
6
+ import { EventHub } from '../events/event-hub';
7
+ import type { Message } from '../../types';
8
+ import type { MsyncCodec, SyncDecodeResult } from '../../protocol/msync/codec';
9
+ import type { MessageSender } from './message-sender';
10
+ /**
11
+ * 消息接收器
12
+ */
13
+ export declare class MessageReceiver {
14
+ private eventHub;
15
+ private messageSender;
16
+ private msyncCodec;
17
+ private streamMessageHandler;
18
+ private readonly messageContexts;
19
+ private readonly recentMessageIds;
20
+ private enableDeliveryReceipt;
21
+ constructor(msyncCodec: MsyncCodec, messageSender: MessageSender, eventHub: EventHub);
22
+ setDeliveryAckEnabled(enabled: boolean): void;
23
+ rememberSentMessageContext(message: Message): void;
24
+ /**
25
+ * 处理 SYNC payload,分离 ACK 与聊天消息
26
+ */
27
+ handleSyncPayload(payload: Uint8Array): SyncDecodeResult | null;
28
+ /**
29
+ * 处理 ACK 回包
30
+ */
31
+ private handleAck;
32
+ /**
33
+ * 派发消息事件
34
+ */
35
+ private dispatchMessage;
36
+ private sendDeliveryAckIfNeeded;
37
+ private handleNotifies;
38
+ private handleUserInfoNotify;
39
+ private handleContactNotify;
40
+ private handlePresenceNotify;
41
+ private handleGroupNotify;
42
+ private handleChatRoomNotify;
43
+ private handleReactionNotify;
44
+ private handleConversationNotify;
45
+ private handleMultiDeviceNotify;
46
+ private toMessageReceiptPayload;
47
+ private handleMessageDeliveredNotify;
48
+ private handleMessageRecalledNotify;
49
+ private handleMessageUpdatedNotify;
50
+ private normalizeUpdatedMessageBody;
51
+ private handleChatThreadNotify;
52
+ private normalizePresenceStatus;
53
+ /**
54
+ * 销毁接收器
55
+ */
56
+ destroy(): void;
57
+ private rememberMessageContext;
58
+ private resolveMessageReceiptContext;
59
+ private resolveMessageContextId;
60
+ private resolveMessageConversationContext;
61
+ private resolveReactionConversationContext;
62
+ private normalizeReactionList;
63
+ private normalizeReactionOperations;
64
+ private normalizeTimestamp;
65
+ }
@@ -0,0 +1,33 @@
1
+ /**
2
+ * 消息重试逻辑
3
+ *
4
+ * 存储失败消息、重连后重试、最多 3 次尝试
5
+ */
6
+ import { Message } from '../../types';
7
+ /**
8
+ * 失败消息存储
9
+ */
10
+ export declare class MessageRetryManager {
11
+ private failedMessages;
12
+ private maxRetries;
13
+ /**
14
+ * 记录失败消息
15
+ */
16
+ recordFailedMessage(message: Message): void;
17
+ /**
18
+ * 获取所有失败消息
19
+ */
20
+ getFailedMessages(): Message[];
21
+ /**
22
+ * 重试失败消息
23
+ */
24
+ retryFailedMessages(sendMessageFn: (message: Message) => Promise<Message>): Promise<void>;
25
+ /**
26
+ * 清除失败消息
27
+ */
28
+ clearFailedMessages(): void;
29
+ /**
30
+ * 移除特定消息
31
+ */
32
+ removeFailedMessage(msgLocalId: string): void;
33
+ }
@@ -0,0 +1,63 @@
1
+ /**
2
+ * 消息发送器
3
+ *
4
+ * 接收 Message 对象,发送消息、等待 ACK、错误处理
5
+ * 参考:engineCore/mSync.ts
6
+ */
7
+ import type { Message, SendMessageOptions } from '../../types';
8
+ import { MsyncCodec } from '../../protocol/msync/codec';
9
+ import { EventHub } from '../events/event-hub';
10
+ import { AttachmentUploader } from '../../upload/attachment-uploader';
11
+ import { type SocketLike } from '../../platform';
12
+ import type { ActionAckResult, MessageActionRequest } from './message-action-types';
13
+ import type { ChatRoomOperationRequest } from './chatroom-operation-types';
14
+ import type { JoinChatRoomInfo } from '../../types/chatroom';
15
+ /**
16
+ * 消息发送器
17
+ */
18
+ export declare class MessageSender {
19
+ private websocket;
20
+ private pendingMessages;
21
+ private ackTimeout;
22
+ private eventHub;
23
+ private msyncCodec;
24
+ private attachmentUploader;
25
+ private messageReportCount;
26
+ private chatRoomReportCount;
27
+ private messageReportSaturated;
28
+ private chatRoomReportSaturated;
29
+ constructor(msyncCodec: MsyncCodec, websocket: SocketLike | null, eventHub: EventHub, attachmentUploader?: AttachmentUploader);
30
+ updateAuthToken(token: string): void;
31
+ /**
32
+ * 发送消息
33
+ */
34
+ sendMessage(message: Message, options?: SendMessageOptions): Promise<Message>;
35
+ sendAction(action: MessageActionRequest, createAckError?: (statusCode: number, reason?: string) => Error): Promise<ActionAckResult>;
36
+ sendChatRoomOperation(request: ChatRoomOperationRequest, createAckError?: (statusCode: number, reason?: string) => Error): Promise<ActionAckResult>;
37
+ /**
38
+ * 实际发送消息
39
+ */
40
+ private doSendMessage;
41
+ private sendProtocolPayload;
42
+ private prepareCombineMessage;
43
+ /**
44
+ * 处理 ACK
45
+ */
46
+ handleAck(protocolId: string, msgServerId?: string, replacedMessage?: Message, chatRoomInfo?: JoinChatRoomInfo): void;
47
+ private resolveReplacedMessage;
48
+ /**
49
+ * 处理发送失败
50
+ */
51
+ handleSendError(protocolId: string, error: Error): void;
52
+ handleAckFailure(protocolId: string, statusCode: number, reason: string | undefined, error: Error): void;
53
+ /**
54
+ * 更新 WebSocket 实例
55
+ */
56
+ setWebSocket(websocket: SocketLike | null): void;
57
+ /**
58
+ * 销毁消息发送器
59
+ */
60
+ destroy(): void;
61
+ private createPendingDataReport;
62
+ private finishPendingDataReport;
63
+ }