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,26 @@
1
+ /**
2
+ * 缓存加密工具
3
+ */
4
+ export interface CacheCryptoPayload {
5
+ readonly __enc: true;
6
+ readonly v: 1;
7
+ readonly alg: 'AES-GCM';
8
+ readonly kdf: 'SHA-256';
9
+ readonly iv: string;
10
+ readonly ct: string;
11
+ }
12
+ export interface CacheCryptoAdapter {
13
+ readonly isEnabled: () => boolean;
14
+ readonly encrypt: (plaintext: string) => Promise<string>;
15
+ readonly decrypt: (payload: string) => Promise<string | null>;
16
+ }
17
+ export declare class CacheCrypto implements CacheCryptoAdapter {
18
+ private readonly enabled;
19
+ private readonly keyPromise;
20
+ private getCrypto;
21
+ constructor(appKey: string, userId: string);
22
+ isEnabled(): boolean;
23
+ encrypt(plaintext: string): Promise<string>;
24
+ decrypt(payload: string): Promise<string | null>;
25
+ private deriveKey;
26
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * 缓存淘汰工具
3
+ */
4
+ export interface EvictionResult<T> {
5
+ readonly kept: ReadonlyArray<T>;
6
+ readonly removed: ReadonlyArray<T>;
7
+ }
8
+ export declare const removeExpired: <T extends {
9
+ lastUpdate: number;
10
+ }>(items: ReadonlyArray<T>, // 待处理列表
11
+ ttlMs: number, // TTL 毫秒
12
+ now: number) => EvictionResult<T>;
13
+ export declare const evictByLru: <T extends {
14
+ lastAccess: number;
15
+ }>(items: ReadonlyArray<T>, // 待处理列表
16
+ removeCount: number) => EvictionResult<T>;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * 缓存 key 生成工具
3
+ */
4
+ export declare const CACHE_KEY_PREFIX = "IMSDK";
5
+ export declare const CacheKeyName: {
6
+ readonly CONVERSATIONS: "conversationMap";
7
+ readonly USER_INFO: "userInfoMap";
8
+ readonly GROUP_NAMECARD: "groupNamecardMap";
9
+ readonly CONTACT_RELATIONS: "contactRelationMap";
10
+ readonly CONTACT_VERSION: "contactVersion";
11
+ readonly CONTACT_META: "contactMeta";
12
+ readonly SESSION_LIST: "sessionListMap";
13
+ readonly SESSION_LIST_CHECKPOINT: "sessionListCheckpoint";
14
+ readonly JOINED_GROUP_PREVIEW: "joinedGroupPreview";
15
+ readonly METADATA: "metadata";
16
+ };
17
+ export type CacheKeyName = (typeof CacheKeyName)[keyof typeof CacheKeyName];
18
+ export interface CacheKeyContext {
19
+ readonly appKey: string;
20
+ readonly userId: string;
21
+ readonly schemaVersion: number;
22
+ }
23
+ export declare const buildCacheKey: (context: CacheKeyContext, name: CacheKeyName) => string;
@@ -0,0 +1,254 @@
1
+ /**
2
+ * 缓存管理器
3
+ */
4
+ import type { ContactSnapshot } from '../types/contact';
5
+ import type { UserInfo, UserInfoNotifyPatch } from '../types/user-info';
6
+ import type { JoinedGroupSnapshot } from '../types/group';
7
+ import type { CacheConfig, ContactCacheMeta, ContactRelationRecord, ContactVersionState, ConversationSummary, GroupNamecardCacheRecord, SessionListCheckpoint, UserInfoSummary } from './cache-types';
8
+ import type { ConversationMark, ConversationType, ConversationItem, SessionListRemindType } from '../types/conversation';
9
+ import type { Message } from '../types';
10
+ import { type UserInfoRuntimeMergeResult, type UserInfoRuntimeUpsertRecord } from '../managers/user-info/user-info-runtime-store';
11
+ export interface CacheManagerOptions {
12
+ readonly appKey: string;
13
+ readonly userId: string;
14
+ readonly cacheEncryptionMode?: 'auto' | 'off';
15
+ readonly config?: Partial<CacheConfig>;
16
+ }
17
+ export interface ConversationMergeResult {
18
+ readonly items: ReadonlyArray<ConversationSummary>;
19
+ readonly changed: boolean;
20
+ }
21
+ export interface ConversationMessagePatchResult {
22
+ readonly items: ReadonlyArray<ConversationSummary>;
23
+ readonly changed: boolean;
24
+ }
25
+ export interface SessionListPatchResult {
26
+ readonly items: ReadonlyArray<ConversationItem>;
27
+ readonly changed: boolean;
28
+ }
29
+ export interface ConversationUnreadClearResult extends SessionListPatchResult {
30
+ /** [zh-CN] 本地 conversation 或 session-list 缓存中是否存在目标会话。 [en-US] Whether the target conversation exists in the local conversation or session-list cache. */
31
+ readonly matched: boolean;
32
+ }
33
+ export interface SessionListDisplayRefreshTarget {
34
+ readonly userId: string;
35
+ readonly lastModified?: number;
36
+ }
37
+ export interface SessionListGroupDisplayRefreshTarget {
38
+ readonly groupId: string;
39
+ readonly name?: string;
40
+ readonly avatarUrl?: string;
41
+ readonly remindType?: SessionListRemindType;
42
+ }
43
+ export interface SessionListGroupDisplayRefreshOptions {
44
+ readonly onlyWhenNameMissing?: boolean;
45
+ }
46
+ export interface SessionListBatchApplyResult {
47
+ readonly items: ReadonlyArray<ConversationItem>;
48
+ readonly checkpoint: SessionListCheckpoint;
49
+ }
50
+ export interface ContactSyncApplyResult {
51
+ readonly snapshot: ContactSnapshot;
52
+ readonly changed: boolean;
53
+ }
54
+ export interface ContactLocalPatchResult {
55
+ readonly snapshot: ContactSnapshot;
56
+ readonly changed: boolean;
57
+ }
58
+ export declare class CacheManager {
59
+ private readonly config;
60
+ private readonly userId;
61
+ private readonly store;
62
+ private readonly metadataStore;
63
+ private readonly conversationCache;
64
+ private readonly userInfoCache;
65
+ private readonly groupNamecardCache;
66
+ private readonly sessionListCache;
67
+ private readonly joinedGroupPreviewCache;
68
+ private readonly contactCache;
69
+ private readonly userInfoRuntimeStore;
70
+ private readonly conversationDeletionTimestamps;
71
+ private currentConversation;
72
+ private readonly conversationKey;
73
+ private readonly userInfoKey;
74
+ private readonly groupNamecardKey;
75
+ private readonly sessionListKey;
76
+ private readonly sessionListCheckpointKey;
77
+ private readonly joinedGroupPreviewKey;
78
+ private readonly contactRelationKey;
79
+ private readonly contactVersionKey;
80
+ private readonly contactMetaKey;
81
+ private readonly metadataKey;
82
+ private sessionListCheckpoint;
83
+ private flushTimer;
84
+ private flushIdleHandle;
85
+ private activeFlushPromise;
86
+ private sessionListCommitInProgress;
87
+ private mutationRevision;
88
+ private readonly domainRevisions;
89
+ private pendingDirtyRevisions;
90
+ private readonly loadPromise;
91
+ constructor(options: CacheManagerOptions);
92
+ getConfig(): CacheConfig;
93
+ prepare(): Promise<void>;
94
+ loadConversationSummaries(): ReadonlyArray<ConversationSummary>;
95
+ loadSessionList(): ReadonlyArray<ConversationItem>;
96
+ loadJoinedGroupPreviewSnapshot(): JoinedGroupSnapshot;
97
+ applyJoinedGroupPreviewSnapshot(snapshot: JoinedGroupSnapshot): void;
98
+ /** @internal 在群组全量同步完成后严格提交权威预览,写入失败时不替换内存预览。 */
99
+ commitJoinedGroupPreviewSnapshot(snapshot: JoinedGroupSnapshot): Promise<JoinedGroupSnapshot>;
100
+ /** @internal 删除当前缓存用户的一个已加入群预览,并在返回前刷新持久化记录。 */
101
+ removeJoinedGroupPreview(groupId: string): Promise<JoinedGroupSnapshot>;
102
+ loadSessionListCheckpoint(): SessionListCheckpoint;
103
+ /**
104
+ * @internal
105
+ * [zh-CN] 正常会话结束前持久化待处理缓存域。
106
+ * [en-US] Flushes pending cache domains before a normal session shutdown.
107
+ */
108
+ flushPending(): Promise<void>;
109
+ resetSessionListCheckpoint(): void;
110
+ loadUserInfoSummaries(): ReadonlyArray<UserInfoSummary>;
111
+ loadGroupNamecards(groupId?: string): ReadonlyArray<GroupNamecardCacheRecord>;
112
+ loadContactSnapshot(source?: 'cache' | 'sync'): ContactSnapshot;
113
+ loadContactRelationRecords(): ReadonlyArray<ContactRelationRecord>;
114
+ loadContactVersionState(): ContactVersionState;
115
+ loadContactCacheMeta(): ContactCacheMeta;
116
+ markConversationAccess(targets: ReadonlyArray<{
117
+ conversationId: string;
118
+ type: ConversationType;
119
+ }>): void;
120
+ setCurrentConversation(params: {
121
+ readonly conversationId: string;
122
+ readonly type: ConversationType;
123
+ }): void;
124
+ resetCurrentConversation(): void;
125
+ getCurrentConversation(): {
126
+ readonly conversationId: string;
127
+ readonly type: ConversationType;
128
+ } | null;
129
+ clearConversationUnreadMessageCount(params: {
130
+ readonly conversationId: string;
131
+ readonly type: ConversationType;
132
+ readonly readAt?: number;
133
+ }): ConversationUnreadClearResult;
134
+ clearAllConversationUnreadMessageCount(params?: {
135
+ readonly readAt?: number;
136
+ }): SessionListPatchResult;
137
+ applyConversationPinnedMutation(params: {
138
+ readonly conversationId: string;
139
+ readonly type: ConversationType;
140
+ readonly isPinned: boolean;
141
+ readonly pinnedTime?: number;
142
+ }): SessionListPatchResult;
143
+ deleteConversation(params: {
144
+ readonly conversationId: string;
145
+ readonly type: ConversationType;
146
+ readonly deletedAt?: number;
147
+ }): SessionListPatchResult;
148
+ clearConversations(): SessionListPatchResult;
149
+ applyConversationMarkMutation(params: {
150
+ readonly conversations: ReadonlyArray<{
151
+ readonly conversationId: string;
152
+ readonly conversationType: ConversationType;
153
+ readonly applied: boolean;
154
+ }>;
155
+ readonly mark: ConversationMark;
156
+ readonly operation: 'addMark' | 'removeMark';
157
+ }): SessionListPatchResult;
158
+ replaceSessionList(items: ReadonlyArray<ConversationItem>, checkpoint?: Partial<SessionListCheckpoint>, options?: {
159
+ readonly syncStartedAt?: number;
160
+ }): void;
161
+ mergeSessionListIncremental(items: ReadonlyArray<ConversationItem>, checkpoint?: Partial<SessionListCheckpoint>): void;
162
+ commitSessionListSync(options: {
163
+ readonly items: ReadonlyArray<ConversationItem>;
164
+ readonly mode: 'full' | 'incremental';
165
+ readonly checkpoint: SessionListCheckpoint;
166
+ readonly syncStartedAt?: number;
167
+ }): Promise<SessionListBatchApplyResult>;
168
+ setUserInfoSummaries(items: ReadonlyArray<UserInfoSummary>): void;
169
+ upsertRuntimeUserInfos(items: ReadonlyArray<UserInfoRuntimeUpsertRecord>): void;
170
+ getRuntimeUserInfo(userId: string, updateAccess?: boolean): UserInfo | null;
171
+ applyUserInfoNotifyPatch(patch: UserInfoNotifyPatch): UserInfoRuntimeMergeResult;
172
+ updateUserInfoSummaryFromRuntime(userId: string): void;
173
+ getUserInfoSummaries(userIds: ReadonlyArray<string>, updateAccess: boolean): ReadonlyArray<UserInfoSummary>;
174
+ removeUserInfo(userIds: ReadonlyArray<string>): void;
175
+ getGroupNamecard(groupId: string, userId: string, updateAccess: boolean): GroupNamecardCacheRecord | null;
176
+ setGroupNamecards(items: ReadonlyArray<GroupNamecardCacheRecord>): void;
177
+ removeGroupNamecards(targets: ReadonlyArray<{
178
+ groupId: string;
179
+ userId: string;
180
+ }>): void;
181
+ setContactVersionState(state: ContactVersionState): void;
182
+ markContactCacheIncomplete(reason: ContactCacheMeta['reason']): void;
183
+ applyContactSync(options: {
184
+ mode: 'full' | 'incremental';
185
+ relations: ReadonlyArray<ContactRelationRecord>;
186
+ userInfos: ReadonlyArray<Pick<UserInfoSummary, 'userId' | 'nickname' | 'avatarUrl' | 'sign' | 'ext'>>;
187
+ version: string;
188
+ lastSyncTs: number;
189
+ }): ContactSyncApplyResult;
190
+ refreshSessionListDisplayFromUserInfos(targets: ReadonlyArray<SessionListDisplayRefreshTarget>): SessionListPatchResult;
191
+ refreshSessionListDisplayFromJoinedGroups(groups: ReadonlyArray<SessionListGroupDisplayRefreshTarget>, options?: SessionListGroupDisplayRefreshOptions): SessionListPatchResult;
192
+ removeContact(userId: string): ContactLocalPatchResult;
193
+ updateContactRemark(userId: string, remark: string): ContactLocalPatchResult;
194
+ applyContactRosterNotice(options: {
195
+ readonly action: 'add' | 'remove';
196
+ readonly userId: string;
197
+ readonly rosterVersion?: string;
198
+ }): ContactLocalPatchResult;
199
+ updateConversationsFromServer(items: ReadonlyArray<ConversationSummary>, options?: {
200
+ readonly syncStartedAt?: number;
201
+ }): ConversationMergeResult;
202
+ applyIncomingMessageToConversations(message: Message): ConversationMessagePatchResult;
203
+ applyIncomingMessageToSessionList(message: Message): SessionListPatchResult;
204
+ private loadFromStorage;
205
+ private readDump;
206
+ private readValue;
207
+ private normalizeSessionListCheckpoint;
208
+ private scheduleFlush;
209
+ private markDirty;
210
+ private getDomainRevision;
211
+ private ensureFlushScheduled;
212
+ private takePendingDirtyBatch;
213
+ private restoreDirtyBatch;
214
+ private addQuotaCleanupDomains;
215
+ private flushNow;
216
+ private flushDirtyBatch;
217
+ private writeDirtyDomains;
218
+ private writeDomain;
219
+ private writeSessionListStorageRecord;
220
+ private buildIncrementalSessionListRecords;
221
+ private buildSessionListSyncCandidate;
222
+ private filterItemsAgainstConversationDeletions;
223
+ private getConversationLatestUpdate;
224
+ private handleQuotaExceeded;
225
+ private evictByPolicy;
226
+ private calculateEvictCount;
227
+ private mergeConversationLists;
228
+ private isConversationListEqual;
229
+ private buildConversationSignature;
230
+ private buildConversationKey;
231
+ private areConversationMarksEqual;
232
+ private buildConversationFromMessage;
233
+ private resolveConversationFromMessage;
234
+ private buildMessageSnippet;
235
+ private normalizeMessageBody;
236
+ private buildSessionListRecordFromConversation;
237
+ private resolveSessionListUnreadCount;
238
+ private shouldIncreaseUnreadForMessage;
239
+ private buildSingleSessionDisplayFields;
240
+ private shouldSkipSessionUserDisplayRefresh;
241
+ private hydrateSessionListRecordsFromLocalProfiles;
242
+ private resolveSessionDisplayUserInfo;
243
+ private buildSessionMessageSender;
244
+ private buildSingleChatPeerMessageSender;
245
+ private isSenderEqual;
246
+ private buildGroupSessionDisplayFields;
247
+ private mapJoinedGroupRemindTypeToSession;
248
+ private buildChatRoomSessionDisplayFields;
249
+ private isSessionListEqual;
250
+ private buildSessionListSignature;
251
+ private refreshContactCacheIntegrity;
252
+ private buildContactSnapshotSignature;
253
+ private applyContactLocalPatch;
254
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * 缓存元信息管理
3
+ */
4
+ import type { CacheMetadata } from './cache-types';
5
+ import { CacheStore } from './cache-store';
6
+ export declare class CacheMetadataStore {
7
+ private readonly store;
8
+ private readonly key;
9
+ private readonly schemaVersion;
10
+ constructor(store: CacheStore, key: string, schemaVersion: number);
11
+ load(): Promise<CacheMetadata>;
12
+ save(metadata: CacheMetadata): Promise<void>;
13
+ touchLastFlush(): Promise<CacheMetadata>;
14
+ }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * localStorage 访问封装
3
+ */
4
+ import type { CacheCryptoAdapter } from './cache-crypto';
5
+ export declare class CacheStore {
6
+ private readonly available;
7
+ private readonly cryptoAdapter;
8
+ constructor(cryptoAdapter?: CacheCryptoAdapter);
9
+ static checkAvailable(): boolean;
10
+ readAsync<T>(key: string, fallback: T): Promise<T>;
11
+ writeAsync(key: string, value: unknown): Promise<void>;
12
+ /**
13
+ * Writes a cache record and propagates serialization/storage failures to the caller.
14
+ * 写入缓存记录,并将序列化或存储失败抛给调用方。
15
+ */
16
+ writeStrictAsync(key: string, value: unknown): Promise<void>;
17
+ private writeInternal;
18
+ remove(key: string): void;
19
+ }
@@ -0,0 +1,225 @@
1
+ /**
2
+ * 缓存模块类型定义
3
+ */
4
+ import type { ConversationIdentifier, ConversationItem, ConversationMark, ConversationType } from '../types/conversation';
5
+ import type { MessageModifiedInfo } from '../types';
6
+ import type { JoinedGroupSnapshotMeta, JoinedGroupSummary } from '../types/group';
7
+ /**
8
+ * [zh-CN] 缓存中的消息摘要。
9
+ * [en-US] Message snippet stored in the cache.
10
+ */
11
+ export interface MessageSnippet {
12
+ /** [zh-CN] 消息 ID。 [en-US] Message ID. */
13
+ readonly msgId: string;
14
+ /** [zh-CN] 消息类型。 [en-US] Message type. */
15
+ readonly type: string;
16
+ /** [zh-CN] 消息体摘要。 [en-US] Message body snippet. */
17
+ readonly body: Record<string, unknown>;
18
+ /** [zh-CN] 消息时间戳,单位毫秒。 [en-US] Message timestamp in milliseconds. */
19
+ readonly timestamp: number;
20
+ /** [zh-CN] 用户资料版本,单位秒。 [en-US] User profile version in seconds. */
21
+ readonly userInfoUpdateTime?: number;
22
+ /** [zh-CN] 群名片版本,单位秒。 [en-US] Group name card version in seconds. */
23
+ readonly namecardUpdateTime?: number;
24
+ /** [zh-CN] 消息修改信息。 [en-US] Message modification information. */
25
+ readonly modifiedInfo?: MessageModifiedInfo;
26
+ }
27
+ /**
28
+ * [zh-CN] 缓存中的会话摘要。
29
+ * [en-US] Conversation summary stored in the cache.
30
+ */
31
+ export interface ConversationSummary {
32
+ /** [zh-CN] 会话 ID。 [en-US] Conversation ID. */
33
+ readonly conversationId: string;
34
+ /** [zh-CN] 会话类型。 [en-US] Conversation type. */
35
+ readonly type: ConversationType;
36
+ /** [zh-CN] 最后一条消息摘要。 [en-US] Last message snippet. */
37
+ readonly lastMessage: MessageSnippet | null;
38
+ /** [zh-CN] 未读消息数。 [en-US] Unread message count. */
39
+ readonly unreadCount: number;
40
+ /** [zh-CN] 是否置顶。 [en-US] Whether the conversation is pinned. */
41
+ readonly isPinned?: boolean;
42
+ /** [zh-CN] 置顶时间戳,单位毫秒。 [en-US] Pin timestamp in milliseconds. */
43
+ readonly pinnedTime?: number;
44
+ /** [zh-CN] 会话标记。 [en-US] Conversation marks. */
45
+ readonly marks: ReadonlyArray<ConversationMark>;
46
+ /** [zh-CN] 最近访问时间戳,单位毫秒。 [en-US] Last access timestamp in milliseconds. */
47
+ readonly lastAccess: number;
48
+ /** [zh-CN] 最近更新时间戳,单位毫秒。 [en-US] Last update timestamp in milliseconds. */
49
+ readonly lastUpdate: number;
50
+ }
51
+ /**
52
+ * [zh-CN] 缓存中的用户资料摘要。
53
+ * [en-US] User profile summary stored in the cache.
54
+ */
55
+ export interface UserInfoSummary {
56
+ /** [zh-CN] 用户 ID。 [en-US] User ID. */
57
+ readonly userId: string;
58
+ /** [zh-CN] 用户昵称。 [en-US] User nickname. */
59
+ readonly nickname?: string;
60
+ /** [zh-CN] 用户头像 URL。 [en-US] User avatar URL. */
61
+ readonly avatarUrl?: string;
62
+ /** [zh-CN] 用户签名。 [en-US] User signature. */
63
+ readonly sign?: string;
64
+ /** [zh-CN] 用户扩展信息。 [en-US] User extension data. */
65
+ readonly ext?: string;
66
+ /** [zh-CN] 用户资料版本,单位秒。 [en-US] User profile version in seconds. */
67
+ readonly userInfoUpdateTime?: number;
68
+ /** [zh-CN] 最近同步时间戳,单位毫秒。 [en-US] Last synchronization timestamp in milliseconds. */
69
+ readonly lastSyncAt?: number;
70
+ /** [zh-CN] 最近访问时间戳,单位毫秒。 [en-US] Last access timestamp in milliseconds. */
71
+ readonly lastAccess: number;
72
+ /** [zh-CN] 最近更新时间戳,单位毫秒。 [en-US] Last update timestamp in milliseconds. */
73
+ readonly lastUpdate: number;
74
+ }
75
+ /**
76
+ * [zh-CN] 缓存中的群名片记录。
77
+ * [en-US] Group name card record stored in the cache.
78
+ */
79
+ export interface GroupNamecardCacheRecord {
80
+ /** [zh-CN] 群组 ID。 [en-US] Group ID. */
81
+ readonly groupId: string;
82
+ /** [zh-CN] 用户 ID。 [en-US] User ID. */
83
+ readonly userId: string;
84
+ /** [zh-CN] 群名片。 [en-US] Group name card. */
85
+ readonly namecard: string;
86
+ /** [zh-CN] 群名片版本,单位秒。 [en-US] Group name card version in seconds. */
87
+ readonly namecardUpdateTime?: number;
88
+ /** [zh-CN] 最近同步时间戳,单位毫秒。 [en-US] Last synchronization timestamp in milliseconds. */
89
+ readonly lastSyncAt?: number;
90
+ /** [zh-CN] 最近访问时间戳,单位毫秒。 [en-US] Last access timestamp in milliseconds. */
91
+ readonly lastAccess: number;
92
+ /** [zh-CN] 最近更新时间戳,单位毫秒。 [en-US] Last update timestamp in milliseconds. */
93
+ readonly lastUpdate: number;
94
+ }
95
+ export type ContactCacheIntegrity = 'complete' | 'incomplete';
96
+ export type ContactCacheIncompleteReason = 'quota_exceeded' | 'user_info_missing' | 'corrupted' | 'first_sync_pending' | 'manual_reset';
97
+ export type ContactVersionSource = 'metadata' | 'sync_page' | 'roster_notice';
98
+ export type ContactSyncMode = 'full' | 'incremental' | 'skipped';
99
+ export interface ContactRelationRecord {
100
+ readonly userId: string;
101
+ readonly remark: string;
102
+ readonly sign: string;
103
+ readonly addTs: number;
104
+ readonly updatedAt: number;
105
+ readonly metadataUpdatedAt: number;
106
+ }
107
+ export interface ContactVersionState {
108
+ readonly version: string;
109
+ readonly lastVersionCheckAt: number;
110
+ readonly lastVersionSource: ContactVersionSource;
111
+ }
112
+ export interface ContactCacheMeta {
113
+ readonly cacheIntegrity: ContactCacheIntegrity;
114
+ readonly reason?: ContactCacheIncompleteReason;
115
+ readonly lastSyncTs: number;
116
+ readonly lastSuccessfulVersion: string;
117
+ readonly lastSyncMode: ContactSyncMode;
118
+ }
119
+ /**
120
+ * [zh-CN] 缓存元信息。
121
+ * [en-US] Cache metadata.
122
+ */
123
+ export interface CacheMetadata {
124
+ /** [zh-CN] 缓存结构版本号。 [en-US] Cache schema version. */
125
+ readonly schemaVersion: number;
126
+ /** [zh-CN] 最近一次落盘时间戳,单位毫秒。 [en-US] Last flush timestamp in milliseconds. */
127
+ readonly lastFlush: number;
128
+ }
129
+ /**
130
+ * [zh-CN] 本地缓存配置。
131
+ * [en-US] Local cache configuration.
132
+ */
133
+ export interface CacheConfig {
134
+ /** [zh-CN] 缓存结构版本号。 [en-US] Cache schema version. */
135
+ readonly schemaVersion: number;
136
+ /** [zh-CN] 缓存有效期,单位秒。 [en-US] Cache time to live in seconds. */
137
+ readonly ttlSeconds: number;
138
+ /** [zh-CN] 批量落盘间隔,单位毫秒。 [en-US] Batched flush interval in milliseconds. */
139
+ readonly flushIntervalMs: number;
140
+ /** [zh-CN] 用户资料缓存最大条数。 [en-US] Maximum number of cached user profiles. */
141
+ readonly maxUserInfoCount: number;
142
+ /** [zh-CN] 群名片缓存最大条数。 [en-US] Maximum number of cached group name cards. */
143
+ readonly maxGroupNamecardCount?: number;
144
+ /** [zh-CN] 会话缓存最大条数。 [en-US] Maximum number of cached conversations. */
145
+ readonly maxConversations?: number;
146
+ }
147
+ /**
148
+ * [zh-CN] 会话列表更新原因。
149
+ * - `conversation`:会话列表同步或会话缓存基线变化;
150
+ * - `profile`:好友或用户资料补全导致会话展示信息(例如,昵称或头像)变化;
151
+ * - `message`:收发消息导致最后一条消息、未读数或会话排序发生变化;
152
+ * - `local`:触发了本地会话操作,如置顶、标记、删除会话等。
153
+ * [en-US] The reason for a conversation list update.
154
+ * - `conversation`: Indicates a conversation list synchronization or changes to the baseline cache.
155
+ * - `profile`: Indicates that friend or user profile completion has updated the displayed information (e.g., nicknames or avatars) of the conversation.
156
+ * - `message`: Indicates that sending or receiving messages has updated the last message, unread count, or conversation sorting.
157
+ * - `local`: Indicates local conversation actions, such as pinning, marking, or deleting a conversation.
158
+ */
159
+ export type ConversationListUpdateReason = 'conversation' | 'profile' | 'message' | 'local';
160
+ /**
161
+ * [zh-CN] 会话列表更新补丁。简单的 UI 渲染可以直接使用 `ConversationListUpdatePayload.items`;只有在需要保留业务层自定义本地字段,或进行精细化数据合并时,才需要读取该补丁。
162
+ * [en-US] The patch for a conversation list update. Simple UIs can directly use `ConversationListUpdatePayload.items` for rendering; read this patch only when you need to preserve custom local fields or perform fine-grained data merging.
163
+ */
164
+ export interface ConversationListUpdatePatch {
165
+ /**
166
+ * [zh-CN] 是否为一次整体基线重置。为 `true` 时,表示 SDK 重新建立或替换了会话列表基线(例如登录后加载缓存、服务端全量同步、回退到全量刷新等)。业务层若自行维护带本地自定义字段的列表,此时应将 `items` 视为唯一的权威快照,并按会话 Key 重新挂载本地字段;简单 UI 直接使用 `items` 渲染即可。
167
+ * [en-US] Whether this update is a full baseline reset. When `true`, it indicates that the SDK has rebuilt or replaced the conversation list baseline (e.g., loading cache upon login, full server synchronization, or falling back to a full refresh). If your app maintains a local list with custom fields, you should treat `items` as the current authoritative snapshot and re-bind your local fields by conversation key; simple UIs can directly use `items` for rendering.
168
+ */
169
+ readonly reset: boolean;
170
+ /** [zh-CN] 本次新增或 SDK 字段发生变化的会话。 [en-US] Conversations inserted or changed in SDK-owned fields during this update. */
171
+ readonly upserted: ReadonlyArray<ConversationItem>;
172
+ /** [zh-CN] 本次移除的会话标识。 [en-US] Conversation identifiers removed in this update. */
173
+ readonly removed: ReadonlyArray<ConversationIdentifier>;
174
+ /** [zh-CN] 本次受影响的会话 key,格式为 `${conversationType}:${conversationId}`。 [en-US] Affected conversation keys in `${conversationType}:${conversationId}` format. */
175
+ readonly affectedKeys: ReadonlyArray<string>;
176
+ /**
177
+ * [zh-CN] 本次是否改变了会话列表顺序。可能只有排序变化而没有 `upserted` 内容变化,例如置顶、最后消息时间或服务端排序基线变化。按补丁合并的业务在该值为 `true` 时,应按 `items` 中的顺序重排本地列表;直接使用 `items` 的业务无需额外处理。
178
+ * [en-US] Whether the conversation-list order changed. The order may change even when `upserted` is empty, for example due to pinning, last-message time, or server ordering baseline changes. Patch-merging consumers should reorder their local list according to `items` when this is `true`; consumers using `items` directly need no extra handling.
179
+ */
180
+ readonly orderChanged: boolean;
181
+ }
182
+ /**
183
+ * [zh-CN] `onConversationListUpdate` 事件载荷。`items` 始终是 SDK 当前完整且已排序的 `ConversationItem` 快照;`patch` 用于业务按增量合并并保留自定义本地字段。
184
+ * [en-US] Payload of `onConversationListUpdate`. `items` is always the SDK's current full, ordered `ConversationItem` snapshot; `patch` helps apps merge incrementally while preserving custom local fields.
185
+ */
186
+ export interface ConversationListUpdatePayload {
187
+ /** [zh-CN] 会话列表快照版本号,每次有效派发递增,可用于忽略旧事件。 [en-US] Conversation list snapshot version, incremented for each effective dispatch and useful for ignoring stale events. */
188
+ readonly version: number;
189
+ /** [zh-CN] 当前完整且已排序的会话列表快照。简单 UI 推荐直接用该字段刷新列表。 [en-US] Current full and ordered conversation list snapshot. Simple UIs are recommended to render this field directly. */
190
+ readonly items: ReadonlyArray<ConversationItem>;
191
+ /** [zh-CN] 本次列表更新原因。 [en-US] Reason for this list update. */
192
+ readonly reason: ConversationListUpdateReason;
193
+ /** [zh-CN] 本次变化补丁,便于业务保留本地字段。 [en-US] Patch for this update, useful for preserving app-local fields. */
194
+ readonly patch: ConversationListUpdatePatch;
195
+ }
196
+ /**
197
+ * [zh-CN] 通用缓存落盘结构。
198
+ * [en-US] Generic persisted cache structure.
199
+ */
200
+ export interface CacheDump<T> {
201
+ /** [zh-CN] 缓存项列表。 [en-US] Cached items. */
202
+ readonly items: ReadonlyArray<T>;
203
+ }
204
+ export interface SessionListCacheRecord extends ConversationItem {
205
+ readonly updatedAt: number;
206
+ }
207
+ export interface SessionListCheckpoint {
208
+ readonly lastSyncTime: number;
209
+ readonly lastSyncFinishedTs: number;
210
+ readonly sessionsLastSyncTs: number;
211
+ readonly lastSuccessfulAt: number;
212
+ }
213
+ export interface SessionListStorageRecord {
214
+ readonly items: ReadonlyArray<SessionListCacheRecord>;
215
+ readonly checkpoint?: SessionListCheckpoint;
216
+ }
217
+ export interface JoinedGroupPreviewStorageRecord {
218
+ readonly items: ReadonlyArray<JoinedGroupSummary>;
219
+ readonly meta: JoinedGroupSnapshotMeta;
220
+ }
221
+ export interface SessionListCapabilityState {
222
+ readonly status: 'unknown' | 'available' | 'unsupported' | 'unconfigured';
223
+ readonly determinedAt?: number;
224
+ readonly reason?: string;
225
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * 缓存工具方法
3
+ */
4
+ export declare const isRecord: (value: unknown) => value is Record<string, unknown>;
5
+ export declare const safeJsonParse: <T>(raw: string | null, fallback: T) => T;
6
+ export declare const safeJsonStringify: (value: unknown) => string | null;
7
+ export declare const isQuotaExceededError: (error: unknown) => boolean;
@@ -0,0 +1,35 @@
1
+ /**
2
+ * 联系人关系缓存
3
+ */
4
+ import type { ContactCacheIncompleteReason, ContactCacheMeta, ContactRelationRecord, ContactSyncMode, ContactVersionState, UserInfoSummary } from './cache-types';
5
+ import type { ContactSnapshot, ContactSyncSource } from '../types/contact';
6
+ export declare class ContactCache {
7
+ private readonly items;
8
+ private versionState;
9
+ private meta;
10
+ load(rawItems: ReadonlyArray<ContactRelationRecord>, versionState?: ContactVersionState | null, meta?: ContactCacheMeta | null): void;
11
+ getAll(): ReadonlyArray<ContactRelationRecord>;
12
+ getVersionState(): ContactVersionState;
13
+ getMeta(): ContactCacheMeta;
14
+ getUserIds(): ReadonlyArray<string>;
15
+ replaceAll(items: ReadonlyArray<ContactRelationRecord>): void;
16
+ upsert(items: ReadonlyArray<ContactRelationRecord>): void;
17
+ addByNotice(userId: string, updatedAt: number): boolean;
18
+ remove(userId: string): boolean;
19
+ updateRemark(userId: string, remark: string, updatedAt: number): boolean;
20
+ setVersionState(state: ContactVersionState): void;
21
+ updateVersionFromNotice(version: string, updatedAt: number): boolean;
22
+ setMeta(meta: ContactCacheMeta): void;
23
+ updateMeta(options: {
24
+ cacheIntegrity: 'complete' | 'incomplete';
25
+ reason?: ContactCacheIncompleteReason;
26
+ lastSyncTs?: number;
27
+ lastSuccessfulVersion?: string;
28
+ lastSyncMode?: ContactSyncMode;
29
+ }): void;
30
+ computeIntegrity(userInfos: ReadonlyArray<UserInfoSummary>): ContactCacheMeta;
31
+ buildSnapshot(userInfos: ReadonlyArray<UserInfoSummary>, source: ContactSyncSource): ContactSnapshot;
32
+ private normalizeRecord;
33
+ private normalizeVersionState;
34
+ private normalizeMeta;
35
+ }
@@ -0,0 +1,21 @@
1
+ /**
2
+ * 会话摘要缓存
3
+ */
4
+ import type { ConversationSummary } from './cache-types';
5
+ import type { ConversationType } from '../types/conversation';
6
+ export declare class ConversationCache {
7
+ private items;
8
+ load(rawItems: ReadonlyArray<ConversationSummary>, now: number): void;
9
+ getAll(): ReadonlyArray<ConversationSummary>;
10
+ setAll(items: ReadonlyArray<ConversationSummary>): void;
11
+ updateLastAccess(conversationIds: ReadonlyArray<{
12
+ conversationId: string;
13
+ type: ConversationType;
14
+ }>, now: number): boolean;
15
+ removeExpired(ttlMs: number, now: number): boolean;
16
+ evictByLru(removeCount: number): boolean;
17
+ trimMax(maxCount?: number): boolean;
18
+ private findIndex;
19
+ private normalizeItem;
20
+ private normalizeMessage;
21
+ }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * 群名片缓存
3
+ */
4
+ import type { GroupNamecardCacheRecord } from './cache-types';
5
+ export declare class GroupNamecardCache {
6
+ private readonly items;
7
+ load(rawItems: ReadonlyArray<GroupNamecardCacheRecord>, now: number): void;
8
+ getAll(): ReadonlyArray<GroupNamecardCacheRecord>;
9
+ get(groupId: string, userId: string, now: number, updateAccess: boolean): GroupNamecardCacheRecord | null;
10
+ getByGroupId(groupId: string, now: number, updateAccess: boolean): ReadonlyArray<GroupNamecardCacheRecord>;
11
+ setAll(items: ReadonlyArray<GroupNamecardCacheRecord>, now: number): void;
12
+ remove(targets: ReadonlyArray<{
13
+ groupId: string;
14
+ userId: string;
15
+ }>): void;
16
+ removeExpired(ttlMs: number, now: number, protectedUserIds?: ReadonlySet<string>): boolean;
17
+ evictByLru(removeCount: number, protectedUserIds?: ReadonlySet<string>): boolean;
18
+ trimMax(maxCount: number, protectedUserIds?: ReadonlySet<string>): boolean;
19
+ private normalizeItem;
20
+ }