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.
- package/README.md +95 -39
- package/bundle/im-sdk-web.iife.js +1 -0
- package/cache/cache-crypto.d.ts +26 -0
- package/cache/cache-eviction.d.ts +16 -0
- package/cache/cache-keys.d.ts +23 -0
- package/cache/cache-manager.d.ts +254 -0
- package/cache/cache-metadata.d.ts +14 -0
- package/cache/cache-store.d.ts +19 -0
- package/cache/cache-types.d.ts +225 -0
- package/cache/cache-utils.d.ts +7 -0
- package/cache/contact-cache.d.ts +35 -0
- package/cache/conversation-cache.d.ts +21 -0
- package/cache/group-namecard-cache.d.ts +20 -0
- package/cache/index.d.ts +24 -0
- package/cache/joined-group-preview-cache.d.ts +12 -0
- package/cache/session-list-cache.d.ts +10 -0
- package/cache/user-info-cache.d.ts +16 -0
- package/chat-client.d.ts +558 -0
- package/chunks/cache-utils-BwRPIZ7n.js +1 -0
- package/chunks/cache-utils-CKbcYPlM.cjs +1 -0
- package/chunks/chat-manager-ChdK26ck.cjs +1 -0
- package/chunks/chat-manager-DH8a6Qj9.js +2 -0
- package/chunks/common-CfAlncj9.cjs +1 -0
- package/chunks/common-DN_g4O3n.js +1 -0
- package/chunks/event-system-COBJFEIq.cjs +1 -0
- package/chunks/event-system-D6IJA0C4.js +1 -0
- package/chunks/group-user-info-resolver-C5pdiqox.cjs +1 -0
- package/chunks/group-user-info-resolver-FNRqDg18.js +1 -0
- package/chunks/index-BKg4EGcI.cjs +1 -0
- package/chunks/index-CK3GHdGU.cjs +1 -0
- package/chunks/index-CjofwvEQ.js +1 -0
- package/chunks/index-uKWbjx-u.js +1 -0
- package/chunks/profile-version-DLMz8lqW.js +1 -0
- package/chunks/profile-version-njNs7R5-.cjs +1 -0
- package/chunks/reflection-proto-codec-64ocOTHU.js +1 -0
- package/chunks/reflection-proto-codec-BnQFQdZC.cjs +1 -0
- package/chunks/session-list-query-B6dh-b4Y.cjs +1 -0
- package/chunks/session-list-query-Dnp2HbpW.js +1 -0
- package/chunks/user-info-BfRwS4ZA.js +1 -0
- package/chunks/user-info-icpL0Eaw.cjs +1 -0
- package/config/cache.d.ts +12 -0
- package/config/timeouts.d.ts +34 -0
- package/core/connection/connection-manager.d.ts +228 -0
- package/core/connection/connection-retry.d.ts +47 -0
- package/core/connection/heartbeat.d.ts +68 -0
- package/core/contact-sync/contact-roster-event-sidecar.d.ts +3 -0
- package/core/contact-sync/roster-sync-client.d.ts +21 -0
- package/core/contact-sync/roster-sync-controller.d.ts +20 -0
- package/core/contact-sync/roster-sync-session.d.ts +28 -0
- package/core/contact-sync/roster-sync-types.d.ts +74 -0
- package/core/events/event-hub.d.ts +13 -0
- package/core/group-sync/group-sync-client.d.ts +19 -0
- package/core/group-sync/group-sync-controller.d.ts +11 -0
- package/core/group-sync/group-sync-merge.d.ts +3 -0
- package/core/group-sync/group-sync-normalizer.d.ts +4 -0
- package/core/group-sync/group-sync-session.d.ts +17 -0
- package/core/group-sync/group-sync-types.d.ts +24 -0
- package/core/group-sync/index.d.ts +4 -0
- package/core/index.d.ts +95 -0
- package/core/message/attachment-downloader.d.ts +7 -0
- package/core/message/chatroom-operation-types.d.ts +6 -0
- package/core/message/combine-message-downloader.d.ts +7 -0
- package/core/message/message-action-types.d.ts +22 -0
- package/core/message/message-deduplicator.d.ts +11 -0
- package/core/message/message-receiver.d.ts +65 -0
- package/core/message/message-retry.d.ts +33 -0
- package/core/message/message-sender.d.ts +63 -0
- package/core/message/profile-sync/group-namecard-hydration-queue.d.ts +33 -0
- package/core/message/profile-sync/group-namecard-hydrator.d.ts +8 -0
- package/core/message/profile-sync/latest-message-version-projector.d.ts +3 -0
- package/core/message/profile-sync/profile-version-sidecar.d.ts +9 -0
- package/core/message/profile-sync/profile-version.d.ts +3 -0
- package/core/message/profile-sync/user-info-hydration-queue.d.ts +29 -0
- package/core/message/profile-sync/user-info-hydrator.d.ts +8 -0
- package/core/message/stream-message-cache.d.ts +38 -0
- package/core/message/stream-message-handler.d.ts +22 -0
- package/core/session-list-sync/session-list-query.d.ts +26 -0
- package/core/session-list-sync/session-list-sync-controller.d.ts +17 -0
- package/core/session-list-sync/session-list-sync-merge.d.ts +17 -0
- package/core/session-list-sync/session-list-sync-normalizer.d.ts +6 -0
- package/core/session-list-sync/session-list-sync-runner.d.ts +13 -0
- package/core/session-list-sync/session-list-sync-session.d.ts +26 -0
- package/core/session-list-sync/session-list-sync-types.d.ts +24 -0
- package/core/sync/shared-sync-websocket-session.d.ts +61 -0
- package/core/user-info/group-user-info-resolver.d.ts +40 -0
- package/data-report/bridge.d.ts +11 -0
- package/data-report/constants.d.ts +25 -0
- package/data-report/data-reporter.d.ts +21 -0
- package/data-report/event-queue.d.ts +38 -0
- package/data-report/index.d.ts +3 -0
- package/data-report/network-type.d.ts +1 -0
- package/data-report/operation-map.d.ts +8 -0
- package/data-report/transport.d.ts +17 -0
- package/data-report/types.d.ts +61 -0
- package/index.cjs +1 -0
- package/index.d.ts +134 -0
- package/index.js +3 -0
- package/managers/chat/index.cjs +1 -0
- package/managers/chat/index.d.ts +1 -0
- package/managers/chat/index.js +1 -0
- package/managers/chat-manager.d.ts +880 -0
- package/managers/chat-thread/chat-thread.d.ts +126 -0
- package/managers/chat-thread/index.cjs +1 -0
- package/managers/chat-thread/index.d.ts +2 -0
- package/managers/chat-thread/index.js +1 -0
- package/managers/chat-thread-manager.d.ts +257 -0
- package/managers/chatroom/chatroom-event-mapper.d.ts +17 -0
- package/managers/chatroom/chatroom-event-user-info-resolver.d.ts +15 -0
- package/managers/chatroom/chatroom-normalizers.d.ts +23 -0
- package/managers/chatroom/chatroom.d.ts +403 -0
- package/managers/chatroom/index.cjs +1 -0
- package/managers/chatroom/index.d.ts +2 -0
- package/managers/chatroom/index.js +1 -0
- package/managers/chatroom-manager.d.ts +604 -0
- package/managers/contact/contact-user-info-resolver.d.ts +15 -0
- package/managers/contact/index.cjs +1 -0
- package/managers/contact/index.d.ts +1 -0
- package/managers/contact/index.js +1 -0
- package/managers/contact-manager.d.ts +215 -0
- package/managers/group/group-event-mapper.d.ts +18 -0
- package/managers/group/group-event-user-info-resolver.d.ts +15 -0
- package/managers/group/group-normalizers.d.ts +15 -0
- package/managers/group/group.d.ts +504 -0
- package/managers/group/index.cjs +1 -0
- package/managers/group/index.d.ts +2 -0
- package/managers/group/index.js +1 -0
- package/managers/group/internal/group-event-sync.d.ts +13 -0
- package/managers/group/internal/group-repository.d.ts +31 -0
- package/managers/group/internal/group-snapshot-mapper.d.ts +6 -0
- package/managers/group/internal/internal-group.d.ts +24 -0
- package/managers/group-manager.d.ts +371 -0
- package/managers/presence/index.cjs +1 -0
- package/managers/presence/index.d.ts +1 -0
- package/managers/presence/index.js +1 -0
- package/managers/presence-manager.d.ts +201 -0
- package/managers/push/index.cjs +1 -0
- package/managers/push/index.d.ts +1 -0
- package/managers/push/index.js +1 -0
- package/managers/push-manager.d.ts +205 -0
- package/managers/user-info/index.cjs +1 -0
- package/managers/user-info/index.d.ts +4 -0
- package/managers/user-info/index.js +1 -0
- package/managers/user-info/user-info-notify-normalizer.d.ts +2 -0
- package/managers/user-info/user-info-runtime-store.d.ts +28 -0
- package/managers/user-info-manager.d.ts +196 -0
- package/message/combine-compatible-text-sidecar.d.ts +4 -0
- package/message/combine-message-constraints.d.ts +7 -0
- package/message/combine-payload-codec.d.ts +17 -0
- package/message/create-message.d.ts +64 -0
- package/package.json +64 -16
- package/platform/capability-validator.d.ts +7 -0
- package/platform/env.d.ts +68 -0
- package/platform/factory.d.ts +7 -0
- package/platform/image/miniapp-image-processor.d.ts +45 -0
- package/platform/image/web-image-processor.d.ts +2 -0
- package/platform/index.d.ts +17 -0
- package/platform/miniapp/miniapp-adapter.d.ts +3 -0
- package/platform/proto/proto-adapter.d.ts +17 -0
- package/platform/proto/reflection-proto-codec.d.ts +8 -0
- package/platform/proto/static-proto-adapter.d.ts +8 -0
- package/platform/request/web-request-adapter.d.ts +9 -0
- package/platform/runtime/connection-event-normalizer.d.ts +14 -0
- package/platform/runtime/runtime-event-bridge.d.ts +23 -0
- package/platform/runtime/web-runtime-adapter.d.ts +26 -0
- package/platform/socket/web-socket-adapter.d.ts +8 -0
- package/platform/types.d.ts +472 -0
- package/platform/upload/react-native-upload-adapter.d.ts +14 -0
- package/platform/upload/upload-error-mapper.d.ts +7 -0
- package/platform/upload/upload-source.d.ts +20 -0
- package/platform/upload/web-upload-adapter.d.ts +10 -0
- package/protocol/joined-groups/codec.d.ts +11 -0
- package/protocol/joined-groups/gateway.d.ts +2 -0
- package/protocol/joined-groups/index.d.ts +2 -0
- package/protocol/joined-groups/proto.d.ts +174 -0
- package/protocol/joined-groups/types.d.ts +65 -0
- package/protocol/msync/codec.d.ts +191 -0
- package/protocol/msync/context.d.ts +40 -0
- package/protocol/msync/lz4-compressor/index.d.ts +40 -0
- package/protocol/msync/lz4-compressor/utils.d.ts +27 -0
- package/protocol/msync/multi-device-normalizer.d.ts +75 -0
- package/protocol/msync/proto.d.ts +1306 -0
- package/protocol/msync/root.d.ts +5 -0
- package/protocol/msync/types.d.ts +96 -0
- package/protocol/msync/utils.d.ts +26 -0
- package/protocol/protobuf/decoder.d.ts +44 -0
- package/protocol/protobuf/encoder.d.ts +23 -0
- package/protocol/protobuf/types.d.ts +53 -0
- package/protocol/roster/codec.d.ts +9 -0
- package/protocol/roster/proto.d.ts +205 -0
- package/protocol/roster/root.d.ts +5 -0
- package/protocol/roster/types.d.ts +83 -0
- package/protocol/session-list/codec.d.ts +11 -0
- package/protocol/session-list/gateway.d.ts +19 -0
- package/protocol/session-list/payload-decoder.d.ts +1 -0
- package/protocol/session-list/proto.d.ts +207 -0
- package/protocol/session-list/types.d.ts +83 -0
- package/rest/chat-management.d.ts +26 -0
- package/rest/chat-thread-management.d.ts +14 -0
- package/rest/chatroom-management.d.ts +40 -0
- package/rest/client.d.ts +86 -0
- package/rest/contact-management.d.ts +27 -0
- package/rest/contact-metadata.d.ts +11 -0
- package/rest/conversation-management.d.ts +11 -0
- package/rest/dns-config.d.ts +20 -0
- package/rest/error-map-types.d.ts +32 -0
- package/rest/error-maps/chat.d.ts +888 -0
- package/rest/error-maps/chatroom.d.ts +592 -0
- package/rest/error-maps/common.d.ts +208 -0
- package/rest/error-maps/contact.d.ts +185 -0
- package/rest/error-maps/core.d.ts +21 -0
- package/rest/error-maps/group.d.ts +500 -0
- package/rest/error-maps/index.d.ts +9 -0
- package/rest/error-maps/presence.d.ts +62 -0
- package/rest/error-maps/push.d.ts +158 -0
- package/rest/error-maps/thread.d.ts +538 -0
- package/rest/error-maps/user-info.d.ts +289 -0
- package/rest/errors.d.ts +23 -0
- package/rest/group-management.d.ts +55 -0
- package/rest/rtc-token.d.ts +14 -0
- package/rest/speech-helpers.d.ts +24 -0
- package/rest/user-info-subscription.d.ts +10 -0
- package/rest/user-info.d.ts +34 -0
- package/types/chat-client.d.ts +226 -0
- package/types/chat-manager.d.ts +641 -0
- package/types/chat-thread.d.ts +311 -0
- package/types/chatroom.d.ts +1258 -0
- package/types/connection.d.ts +111 -0
- package/types/contact.d.ts +149 -0
- package/types/conversation.d.ts +270 -0
- package/types/event-system.d.ts +721 -0
- package/types/group.d.ts +980 -0
- package/types/index.d.ts +577 -44
- package/types/manager.d.ts +99 -0
- package/types/message-conversation.d.ts +22 -0
- package/types/message-create.d.ts +173 -0
- package/types/multi-device.d.ts +275 -0
- package/types/presence.d.ts +101 -0
- package/types/push.d.ts +296 -0
- package/types/sender.d.ts +12 -0
- package/types/sync-data.d.ts +54 -0
- package/types/user-info.d.ts +178 -0
- package/upload/attachment-file-store.d.ts +11 -0
- package/upload/attachment-uploader.d.ts +36 -0
- package/upload/constants.d.ts +8 -0
- package/upload/index.d.ts +2 -0
- package/upload/multipart-upload.d.ts +14 -0
- package/upload/simple-upload.d.ts +3 -0
- package/upload/types.d.ts +79 -0
- package/upload/utils.d.ts +71 -0
- package/utils/env.d.ts +4 -0
- package/utils/error-codes.d.ts +2 -0
- package/utils/error-codes.generated.d.ts +145 -0
- package/utils/error-sanitizer.d.ts +8 -0
- package/utils/errors.d.ts +139 -0
- package/utils/log-reporter.d.ts +61 -0
- package/utils/log-sanitizer.d.ts +6 -0
- package/utils/logger.d.ts +48 -0
- package/utils/md5.d.ts +1 -0
- package/utils/message-id.d.ts +12 -0
- package/utils/provision-error-mapping.d.ts +21 -0
- package/utils/retry.d.ts +26 -0
- package/utils/runtime-global.d.ts +4 -0
- package/utils/trace-id.d.ts +5 -0
- package/utils/utf8.d.ts +2 -0
- package/validators/chat-client.d.ts +787 -0
- package/validators/message-create.d.ts +419 -0
- package/validators/search-messages.d.ts +127 -0
- package/validators/validator.d.ts +49 -0
- package/version.d.ts +2 -0
- package/Easemob-chat.d.ts +0 -8457
- package/Easemob-chat.js +0 -2
- package/chatroom/chatroom.d.ts +0 -649
- package/chatroom/chatroom.js +0 -1
- package/contact/contact.d.ts +0 -726
- package/contact/contact.js +0 -1
- package/group/group.d.ts +0 -848
- package/group/group.js +0 -1
- package/localCache/localCache.d.ts +0 -59
- package/localCache/localCache.js +0 -1
- package/message/audio.d.ts +0 -183
- package/message/channel.d.ts +0 -82
- package/message/cmd.d.ts +0 -146
- package/message/combine.d.ts +0 -132
- package/message/custom.d.ts +0 -135
- package/message/delivery.d.ts +0 -77
- package/message/file.d.ts +0 -173
- package/message/img.d.ts +0 -200
- package/message/index.d.ts +0 -211
- package/message/location.d.ts +0 -134
- package/message/read.d.ts +0 -85
- package/message/text.d.ts +0 -149
- package/message/video.d.ts +0 -180
- package/miniCore/miniCore.d.ts +0 -217
- package/miniCore/miniCore.js +0 -2
- package/miniProgram/Easemob-chat.js +0 -2
- package/miniProgram/miniProgram.zip +0 -0
- package/presence/presence.d.ts +0 -69
- package/presence/presence.js +0 -1
- package/silent/silent.d.ts +0 -128
- package/silent/silent.js +0 -1
- package/status.d.ts +0 -184
- package/thread/thread.d.ts +0 -159
- package/thread/thread.js +0 -1
- package/translation/translation.d.ts +0 -30
- package/translation/translation.js +0 -1
- package/types/chatRoomApi.d.ts +0 -226
- package/types/common.d.ts +0 -89
- package/types/engineCore.d.ts +0 -194
- package/types/error.d.ts +0 -13
- package/types/eventHandler.d.ts +0 -437
- package/types/groupApi.d.ts +0 -306
- package/types/indexApi.d.ts +0 -366
- package/types/localCache.d.ts +0 -53
- package/types/message.d.ts +0 -959
- package/types/presenceApi.d.ts +0 -61
- package/types/reactionApi.d.ts +0 -74
- package/types/restApis.d.ts +0 -6
- package/types/silentModeApi.d.ts +0 -109
- package/types/threadApi.d.ts +0 -175
- package/types/translation.d.ts +0 -25
- package/types/utils.d.ts +0 -90
- package/uniApp/Easemob-chat.js +0 -2
- package/uniApp/uniApp.zip +0 -0
- package/websdk.zip +0 -0
package/cache/index.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 缓存模块导出
|
|
3
|
+
*/
|
|
4
|
+
export { CacheManager } from './cache-manager';
|
|
5
|
+
export { GroupNamecardCache } from './group-namecard-cache';
|
|
6
|
+
export { SessionListCache } from './session-list-cache';
|
|
7
|
+
export type { CacheConfig, // 缓存配置
|
|
8
|
+
CacheMetadata, // 缓存元信息
|
|
9
|
+
CacheDump, // 缓存落盘结构
|
|
10
|
+
ContactCacheIntegrity, // 联系人缓存完整性
|
|
11
|
+
ContactCacheIncompleteReason, // 联系人缓存不完整原因
|
|
12
|
+
ContactCacheMeta, // 联系人缓存元信息
|
|
13
|
+
ContactRelationRecord, // 联系人关系记录
|
|
14
|
+
ContactSyncMode, // 联系人同步模式
|
|
15
|
+
ContactVersionSource, // 联系人版本来源
|
|
16
|
+
ContactVersionState, // 联系人版本状态
|
|
17
|
+
ConversationSummary, // 会话摘要
|
|
18
|
+
ConversationListUpdatePayload, // 会话列表更新载荷
|
|
19
|
+
ConversationListUpdatePatch, // 会话列表更新补丁
|
|
20
|
+
ConversationListUpdateReason, // 会话列表更新原因
|
|
21
|
+
GroupNamecardCacheRecord, // 群名片缓存
|
|
22
|
+
MessageSnippet, // 消息摘要
|
|
23
|
+
SessionListCacheRecord, SessionListCapabilityState, SessionListCheckpoint, UserInfoSummary, } from './cache-types';
|
|
24
|
+
export type { ConversationType } from '../types/conversation';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { JoinedGroupSnapshot } from '../types/group';
|
|
2
|
+
import type { JoinedGroupPreviewStorageRecord } from './cache-types';
|
|
3
|
+
export declare const JOINED_GROUP_PREVIEW_STORAGE_LIMIT = 100;
|
|
4
|
+
export declare const JOINED_GROUP_SERVER_LIMIT = 3000;
|
|
5
|
+
export declare class JoinedGroupPreviewCache {
|
|
6
|
+
private items;
|
|
7
|
+
private meta;
|
|
8
|
+
load(record: JoinedGroupPreviewStorageRecord | null | undefined): void;
|
|
9
|
+
setSnapshot(snapshot: JoinedGroupSnapshot): void;
|
|
10
|
+
getSnapshot(): JoinedGroupSnapshot;
|
|
11
|
+
exportRecord(): JoinedGroupPreviewStorageRecord;
|
|
12
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ConversationItem } from '../types/conversation';
|
|
2
|
+
import type { SessionListCacheRecord } from './cache-types';
|
|
3
|
+
export declare class SessionListCache {
|
|
4
|
+
private items;
|
|
5
|
+
load(rawItems: ReadonlyArray<SessionListCacheRecord>, now: number): void;
|
|
6
|
+
getAll(): ReadonlyArray<SessionListCacheRecord>;
|
|
7
|
+
setAll(items: ReadonlyArray<SessionListCacheRecord>): void;
|
|
8
|
+
exportItems(): ReadonlyArray<ConversationItem>;
|
|
9
|
+
private normalizeItem;
|
|
10
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 用户信息缓存
|
|
3
|
+
*/
|
|
4
|
+
import type { UserInfoSummary } from './cache-types';
|
|
5
|
+
export declare class UserInfoCache {
|
|
6
|
+
private readonly items;
|
|
7
|
+
load(rawItems: ReadonlyArray<UserInfoSummary>, now: number): void;
|
|
8
|
+
getAll(): ReadonlyArray<UserInfoSummary>;
|
|
9
|
+
getByIds(userIds: ReadonlyArray<string>, now: number, updateAccess: boolean): ReadonlyArray<UserInfoSummary>;
|
|
10
|
+
setAll(items: ReadonlyArray<UserInfoSummary>, now: number): void;
|
|
11
|
+
remove(userIds: ReadonlyArray<string>): void;
|
|
12
|
+
removeExpired(ttlMs: number, now: number, protectedUserIds?: ReadonlySet<string>): boolean;
|
|
13
|
+
evictByLru(removeCount: number, protectedUserIds?: ReadonlySet<string>): boolean;
|
|
14
|
+
trimMax(maxCount: number, protectedUserIds?: ReadonlySet<string>): boolean;
|
|
15
|
+
private normalizeItem;
|
|
16
|
+
}
|
package/chat-client.d.ts
ADDED
|
@@ -0,0 +1,558 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* [zh-CN] ChatClient 实现。
|
|
3
|
+
* [en-US] ChatClient implementation.
|
|
4
|
+
*/
|
|
5
|
+
import { CacheManager } from './cache';
|
|
6
|
+
import { SharedSyncWebSocketSession } from './core/sync/shared-sync-websocket-session';
|
|
7
|
+
import type { RequestAdapter, UploadAdapter } from './platform';
|
|
8
|
+
import type { AuthContext, ConnectionState, GetRTCTokenInfoParams, InitConfig, RestContext, SelfIdsOnOtherPlatform, RTCTokenInfo, RTCUidUserIdMap, ServerUrlsConfig, TokenRenewalResult } from './types/chat-client';
|
|
9
|
+
import type { EventHandlerMap, EventHandlerId } from './types/event-system';
|
|
10
|
+
import type { ConversationListUpdateReason } from './cache/cache-types';
|
|
11
|
+
import type { ConversationItem, ConversationType } from './types/conversation';
|
|
12
|
+
import type { ContactSnapshot } from './types/contact';
|
|
13
|
+
import type { SyncDataFinishedPayload, SyncDataType } from './types/sync-data';
|
|
14
|
+
import type { ManagerBase, ManagerCapability, ManagerConstructor, ManagerRegistration, WithManager, WithManagers } from './types/manager';
|
|
15
|
+
import type { // 连接事件载荷
|
|
16
|
+
DownloadCombineMessageParams, // 下载并解析合并消息详情入参
|
|
17
|
+
MessageAttachmentDownloadResult, Message, // 消息类型
|
|
18
|
+
SendMessageOptions } from './types';
|
|
19
|
+
import type { MessageActionRequest, ActionAckResult } from './core/message/message-action-types';
|
|
20
|
+
import type { ChatRoomOperationRequest } from './core/message/chatroom-operation-types';
|
|
21
|
+
import type { UserInfo } from './types/user-info';
|
|
22
|
+
import type { RefreshSessionListParams } from './types/conversation';
|
|
23
|
+
/**
|
|
24
|
+
* [zh-CN] ChatClient 是 SDK 的主入口,负责连接生命周期管理、消息发送、事件分发、缓存访问和管理器注册。
|
|
25
|
+
* [en-US] ChatClient is the main entry point for the SDK, responsible for connection lifecycle management, message sending, event dispatch, cache access, and manager registration.
|
|
26
|
+
*/
|
|
27
|
+
export declare class ChatClient {
|
|
28
|
+
private static instance;
|
|
29
|
+
private config;
|
|
30
|
+
private core;
|
|
31
|
+
private cacheManager;
|
|
32
|
+
private cacheUserId;
|
|
33
|
+
private state;
|
|
34
|
+
private loginAttempt;
|
|
35
|
+
private eventHub;
|
|
36
|
+
private currentUserId;
|
|
37
|
+
private logReportEnabled;
|
|
38
|
+
private readonly managerRegistry;
|
|
39
|
+
private readonly managerCapabilities;
|
|
40
|
+
private readonly managerEventContext;
|
|
41
|
+
private restBaseUrl;
|
|
42
|
+
private authToken;
|
|
43
|
+
private clientResource;
|
|
44
|
+
private platformAdapter;
|
|
45
|
+
private contactSyncController;
|
|
46
|
+
private groupSyncController;
|
|
47
|
+
private syncConversationListConfigController;
|
|
48
|
+
private syncWebSocketSession;
|
|
49
|
+
private contactSyncWsUrls;
|
|
50
|
+
private syncConversationListConfigWsUrls;
|
|
51
|
+
private contactSyncDnsResolved;
|
|
52
|
+
private readonly userInfoHydrationQueue;
|
|
53
|
+
private readonly groupNamecardHydrationQueue;
|
|
54
|
+
private conversationListVersion;
|
|
55
|
+
private conversationListSnapshot;
|
|
56
|
+
private readonly activeIncomingStreamMessageIds;
|
|
57
|
+
private constructor();
|
|
58
|
+
/**
|
|
59
|
+
* [zh-CN] 初始化 ChatClient 单例。首次调用时创建实例;后续若使用相同配置调用,将复用该实例,并支持追加注册管理器。
|
|
60
|
+
* [en-US] Initializes the ChatClient singleton. The first call creates the instance. Subsequent calls with the same configuration will reuse the existing instance and allow registering additional managers.
|
|
61
|
+
*
|
|
62
|
+
* @example [zh-CN] 初始化并注册管理器 [en-US] Initialize and register managers.
|
|
63
|
+
* ```ts
|
|
64
|
+
* const client = ChatClient.init({
|
|
65
|
+
* appKey: 'org#app',
|
|
66
|
+
* managers: [ChatManager, GroupManager],
|
|
67
|
+
* });
|
|
68
|
+
* ```
|
|
69
|
+
* @param config - [zh-CN] 初始化配置,包含 App Key、服务接入参数以及可选的管理器列表。 [en-US] Initialization configuration, including App Key, service access parameters, and an optional list of managers.
|
|
70
|
+
* @returns {WithManagers<ChatClient, Managers>} [zh-CN] 返回带已注册管理器类型增强的 ChatClient 实例。 [en-US] Returns the ChatClient instance enhanced with with the types of the registered managers.
|
|
71
|
+
*/
|
|
72
|
+
static init<Managers extends ReadonlyArray<ManagerRegistration<ChatClient>> = []>(config: Omit<InitConfig, 'managers'> & {
|
|
73
|
+
managers?: Managers;
|
|
74
|
+
}): WithManagers<ChatClient, Managers>;
|
|
75
|
+
/**
|
|
76
|
+
* [zh-CN] 登录并建立到消息服务的长连接。登录成功后会恢复本地缓存、同步会话列表,并按配置触发好友列表与用户属性同步。
|
|
77
|
+
* [en-US] Logs in and establishes a persistent connection to the messaging service. Upon successful login, it automatically restores the local cache, synchronizes the conversation list, and triggers the synchronization of the friend list and user attributes based on the configuration.
|
|
78
|
+
*
|
|
79
|
+
* @example [zh-CN] 登录 SDK [en-US] Log in to the SDK.
|
|
80
|
+
* ```ts
|
|
81
|
+
* await client.login({
|
|
82
|
+
* userId: 'alice',
|
|
83
|
+
* token: 'your-im-token',
|
|
84
|
+
* });
|
|
85
|
+
* ```
|
|
86
|
+
*
|
|
87
|
+
* @param params - [zh-CN] 登录参数,包含用户 ID 和 Token。 [en-US] Login parameters, including the user ID and token.
|
|
88
|
+
* @returns {Promise<void>} [zh-CN] 登录成功时 resolve;该 Promise 不携带任何返回值。 [en-US] Resolves when the login succeeds. This Promise carries no return value.
|
|
89
|
+
*/
|
|
90
|
+
login(params: AuthContext): Promise<void>;
|
|
91
|
+
/**
|
|
92
|
+
* [zh-CN] 登出并关闭当前连接,同时清理登录态、运行时缓存引用与日志上报状态。
|
|
93
|
+
* [en-US] Logs out and disconnects the current connection, while clearing the login state, runtime cache references, and log reporting status.
|
|
94
|
+
*
|
|
95
|
+
* @example [zh-CN] 登出 SDK [en-US] Log out of the SDK.
|
|
96
|
+
* ```ts
|
|
97
|
+
* await client.logout();
|
|
98
|
+
* ```
|
|
99
|
+
* @returns {Promise<void>} [zh-CN] 登出成功时 resolve;该 Promise 不携带任何返回值。 [en-US] Resolves when the logout succeeds. This Promise carries no return value.
|
|
100
|
+
*/
|
|
101
|
+
logout(): Promise<void>;
|
|
102
|
+
/**
|
|
103
|
+
* [zh-CN] 获取当前连接状态。
|
|
104
|
+
* [en-US] Gets the current connection state.
|
|
105
|
+
*
|
|
106
|
+
* @example [zh-CN] 读取连接状态。 [en-US] Read the connection state.
|
|
107
|
+
* ```ts
|
|
108
|
+
* const state = client.getConnectionState();
|
|
109
|
+
* ```
|
|
110
|
+
* @returns {ConnectionState} [zh-CN] 返回当前连接状态枚举值。 [en-US] Returns the enum value of the current connection state.
|
|
111
|
+
*/
|
|
112
|
+
getConnectionState(): ConnectionState;
|
|
113
|
+
/**
|
|
114
|
+
* [zh-CN] 获取当前登录用户 ID。
|
|
115
|
+
* [en-US] Gets the current logged-in user ID.
|
|
116
|
+
*
|
|
117
|
+
* @example [zh-CN] 读取当前登录用户 [en-US] Read the current logged-in user.
|
|
118
|
+
* ```ts
|
|
119
|
+
* const userId = client.getCurrentUserId();
|
|
120
|
+
* ```
|
|
121
|
+
* @returns {string | null} [zh-CN] 返回当前登录用户 ID;未登录时返回 `null`。 [en-US] Returns the current logged-in user ID, or `null` when the user is not logged in.
|
|
122
|
+
*/
|
|
123
|
+
getCurrentUserId(): string | null;
|
|
124
|
+
/**
|
|
125
|
+
* [zh-CN] 获取当前连接的设备资源标识。
|
|
126
|
+
* [en-US] Gets the resource identifier of the currently connected device.
|
|
127
|
+
*
|
|
128
|
+
* @example [zh-CN] 读取当前设备资源标识 [en-US] Read the resource identifier of the currently connected device.
|
|
129
|
+
* ```ts
|
|
130
|
+
* const clientResource = client.getClientResource();
|
|
131
|
+
* ```
|
|
132
|
+
* @returns {string | null} [zh-CN] 返回当前连接的设备资源标识;若未连接或尚未完成登录握手,则返回 `null`。 [en-US] Returns the resource identifier of the currently connected device, or `null` if the SDK is disconnected or the login handshake is incomplete.
|
|
133
|
+
*/
|
|
134
|
+
getClientResource(): string | null;
|
|
135
|
+
/**
|
|
136
|
+
* @internal
|
|
137
|
+
* [zh-CN] 提供消息创建包装层需要的内部配置。
|
|
138
|
+
* [en-US] Provides the internal configuration required by the message creation wrapper layer.
|
|
139
|
+
*/
|
|
140
|
+
getMessageCreationOptions(): {
|
|
141
|
+
readonly useCustomAttachmentUpload: boolean;
|
|
142
|
+
};
|
|
143
|
+
/**
|
|
144
|
+
* [zh-CN] 获取当前登录会话的 REST 访问上下文,供 SDK 公开模块或扩展能力复用统一鉴权与地址信息。
|
|
145
|
+
* [en-US] Gets the REST access context for the current login session, allowing public modules or extension capabilities of the SDK to reuse unified authentication and routing information.
|
|
146
|
+
*
|
|
147
|
+
* @example [zh-CN] 读取 REST 上下文。 [en-US] Read the REST context.
|
|
148
|
+
* ```ts
|
|
149
|
+
* const context = client.getRestContext();
|
|
150
|
+
* ```
|
|
151
|
+
* @returns {RestContext} [zh-CN] 返回当前登录会话对应的 REST 上下文。 [en-US] Returns the REST context of the current logged-in session.
|
|
152
|
+
*/
|
|
153
|
+
getRestContext(): RestContext;
|
|
154
|
+
/**
|
|
155
|
+
* [zh-CN] 更新当前登录会话的 IM token,并重置 token 生命周期提醒。
|
|
156
|
+
* [en-US] Updates the IM token for the current login session and resets the token lifecycle alerts.
|
|
157
|
+
*
|
|
158
|
+
* @example [zh-CN] 续期 IM 登录 Token [en-US] Renew the login token.
|
|
159
|
+
* ```ts
|
|
160
|
+
* const result = await client.renewToken(newToken);
|
|
161
|
+
* ```
|
|
162
|
+
* @param token - [zh-CN] 新的 IM Token。该参数必传。 [en-US] The new token. This parameter is required.
|
|
163
|
+
* @returns {Promise<TokenRenewalResult>} [zh-CN] 返回已应用的新 Token 和过期时间。 [en-US] Returns the newly applied token and its expiration time.
|
|
164
|
+
*/
|
|
165
|
+
renewToken(token: string): Promise<TokenRenewalResult>;
|
|
166
|
+
/**
|
|
167
|
+
* [zh-CN] 获取当前用户的 RTC token 信息。
|
|
168
|
+
* [en-US] Gets RTC token of the current user.
|
|
169
|
+
*
|
|
170
|
+
* @example [zh-CN] 查询 RTC token [en-US] Query the RTC token.
|
|
171
|
+
* ```ts
|
|
172
|
+
* const rtc = await client.getRTCTokenInfo({ channelName: 'demo' });
|
|
173
|
+
* ```
|
|
174
|
+
* @param params - [zh-CN] RTC Token 查询参数。可选。若传入 channelName,则返回该特定频道的 Token。 [en-US] RTC token query parameters. This parameter is optional. If `channelName` is provided, the SDK returns the token of the specific channel.
|
|
175
|
+
* @returns {Promise<RTCTokenInfo>} [zh-CN] 返回 RTC App ID、Token、频道名、UID 和过期时间。 [en-US] Returns the app ID, token, channel name, UID, and expiration time of RTC.
|
|
176
|
+
*/
|
|
177
|
+
getRTCTokenInfo(params?: GetRTCTokenInfoParams): Promise<RTCTokenInfo>;
|
|
178
|
+
/**
|
|
179
|
+
* [zh-CN] 批量查询映射到 RTC UID 的 IM 用户 ID。
|
|
180
|
+
* [en-US] Batch queries Chat user IDs mapped to RTC UIDs.
|
|
181
|
+
*
|
|
182
|
+
* @example [zh-CN] 查询 RTC UID 映射 [en-US] Query Chat user IDs mapped to RTC UIDs.
|
|
183
|
+
* ```ts
|
|
184
|
+
* const users = await client.getUserIdsWithRTCUids([123456]);
|
|
185
|
+
* ```
|
|
186
|
+
* @param rtcUids - [zh-CN] RTC UID 列表。该参数必传,列表中的元素必须为合法数字。 [en-US] An array of RTC UIDs, where all elements must be valid numbers. This parameter is required.
|
|
187
|
+
* @returns {Promise<RTCUidUserIdMap>} [zh-CN] 返回 RTC UID 到 IM user ID 的映射;未命中的 UID 不会出现在结果中。 [en-US] Returns the mapping from RTC UIDs to IM user IDs. Unmatched UIDs are omitted.
|
|
188
|
+
*/
|
|
189
|
+
getUserIdsWithRTCUids(rtcUids: ReadonlyArray<number>): Promise<RTCUidUserIdMap>;
|
|
190
|
+
/**
|
|
191
|
+
* [zh-CN] 获取当前用户在其他已登录设备上的登录 ID 列表。登录 ID 由 user ID + "/" + resource (设备的识别号)组成。
|
|
192
|
+
* [en-US] Gets the list of login IDs of other devices where the current user is logged in. The login ID is in the format of "user ID + "/" + resource (device ID)".
|
|
193
|
+
*
|
|
194
|
+
* @example [zh-CN] 查询其他平台登录 ID [en-US] Query the login IDs of devices on other platforms where the current account is logged in.
|
|
195
|
+
* ```ts
|
|
196
|
+
* const ids = await client.getSelfIdsOnOtherPlatform();
|
|
197
|
+
* ```
|
|
198
|
+
* @returns {Promise<SelfIdsOnOtherPlatform>} [zh-CN] 返回当前用户在其他设备上的 `userId/resource` 列表;当前设备会被自动过滤。 [en-US] Returns an array of `userId/resource` strings from other logged-in devices, automatically excluding the current device.
|
|
199
|
+
*/
|
|
200
|
+
getSelfIdsOnOtherPlatform(): Promise<SelfIdsOnOtherPlatform>;
|
|
201
|
+
/**
|
|
202
|
+
* [zh-CN] 获取当前登录会话绑定的缓存管理器实例。
|
|
203
|
+
* [en-US] Gets the cache manager instance bound to the current login session.
|
|
204
|
+
*
|
|
205
|
+
* @example [zh-CN] 读取缓存管理器 [en-US] Read cache manager.
|
|
206
|
+
* ```ts
|
|
207
|
+
* const cacheManager = client.getCacheManager();
|
|
208
|
+
* ```
|
|
209
|
+
* @returns {CacheManager | null} [zh-CN] 返回缓存管理器;未登录或缓存未初始化时返回 `null`。 [en-US] Returns the cache manager, or `null` when the user is not logged in or the cache is not initialized.
|
|
210
|
+
*/
|
|
211
|
+
getCacheManager(): CacheManager | null;
|
|
212
|
+
/**
|
|
213
|
+
* @internal
|
|
214
|
+
* [zh-CN] 按能力查询已注册 Manager。该方法仅返回显式注册的能力,不会隐式创建管理器。
|
|
215
|
+
* [en-US] Gets a registered manager by capability. This method only returns explicitly registered capabilities and will not implicitly create any managers.
|
|
216
|
+
*/
|
|
217
|
+
getManagerByCapability(capability: ManagerCapability): ManagerBase<ChatClient> | undefined;
|
|
218
|
+
/**
|
|
219
|
+
* [zh-CN] 获取当前平台适配层暴露的上传适配器。
|
|
220
|
+
* [en-US] Gets the upload adapter exposed by the current platform adapter.
|
|
221
|
+
*
|
|
222
|
+
* @example [zh-CN] 读取上传适配器 [en-US] Read the upload adapter.
|
|
223
|
+
* ```ts
|
|
224
|
+
* const uploadAdapter = client.getUploadAdapter();
|
|
225
|
+
* ```
|
|
226
|
+
* @returns {UploadAdapter | null} [zh-CN] 返回上传适配器;当前平台未提供时返回 `null`。 [en-US] Returns the upload adapter, or `null` when the current platform does not provide one.
|
|
227
|
+
*/
|
|
228
|
+
getUploadAdapter(): UploadAdapter | null;
|
|
229
|
+
/** @internal */
|
|
230
|
+
getRequestAdapter(): RequestAdapter | undefined;
|
|
231
|
+
/**
|
|
232
|
+
* @internal
|
|
233
|
+
* [zh-CN] 向内部事件总线注入事件,仅供 SDK 内部桥接使用。
|
|
234
|
+
* [en-US] Dispatches an event into the internal event bus and is intended for SDK-internal bridging only.
|
|
235
|
+
*/
|
|
236
|
+
addInternalEvent<K extends keyof import('./types/event-system').EventPayloadMap>(eventName: K, payload: import('./types/event-system').EventPayloadMap[K]): void;
|
|
237
|
+
/**
|
|
238
|
+
* @internal
|
|
239
|
+
* [zh-CN] 主动刷新会话列表。SDK 会根据当前能力状态决定走新同步链路还是兼容回退链路。
|
|
240
|
+
* [en-US] Actively refreshes the session list. The SDK chooses the new sync path or the compatibility fallback path based on current capability state.
|
|
241
|
+
*
|
|
242
|
+
* @example [zh-CN] 刷新会话列表 [en-US] Refresh session list
|
|
243
|
+
* ```ts
|
|
244
|
+
* const sessions = await client.refreshSessionList({
|
|
245
|
+
* includeEmpty: false,
|
|
246
|
+
* });
|
|
247
|
+
* ```
|
|
248
|
+
* @param params - [zh-CN] 刷新参数,控制是否拉取空会话;会话标记会始终同步。 [en-US] Refresh options that control whether empty conversations are requested. Conversation marks are always synced.
|
|
249
|
+
* @returns {Promise<ReadonlyArray<ConversationItem>>} [zh-CN] 返回刷新后的会话列表;当前未登录或缓存未初始化时返回空数组。 [en-US] Returns the refreshed conversation list. If the user is not logged in or the cache is not initialized, an empty array is returned.
|
|
250
|
+
*/
|
|
251
|
+
refreshSessionList(params?: RefreshSessionListParams): Promise<ReadonlyArray<ConversationItem>>;
|
|
252
|
+
/**
|
|
253
|
+
* [zh-CN] 获取当前固定的服务地址配置;仅在初始化时传入了 `serviceConfig.serverUrls` 才会返回有效值。
|
|
254
|
+
* [en-US] Gets the current fixed server address configuration. This returns a value only if the SDK was initialized with `serviceConfig.serverUrls`.
|
|
255
|
+
*
|
|
256
|
+
* @example [zh-CN] 读取固定的服务地址配置 [en-US] Read the current fixed server address configuration.
|
|
257
|
+
* ```ts
|
|
258
|
+
* const serverUrls = client.getServerUrlsConfig();
|
|
259
|
+
* ```
|
|
260
|
+
* @returns {ServerUrlsConfig | undefined} [zh-CN] 返回固定服务地址配置;若未配置返回 `undefined`。 [en-US] Returns the fixed server configuration, or `undefined` when not configured.
|
|
261
|
+
*/
|
|
262
|
+
getServerUrlsConfig(): ServerUrlsConfig | undefined;
|
|
263
|
+
/**
|
|
264
|
+
* @internal
|
|
265
|
+
* [zh-CN] 获取带鉴权参数的会话列表同步 WebSocket 地址列表。
|
|
266
|
+
* [en-US] Gets session-list sync WebSocket URLs with authentication parameters attached.
|
|
267
|
+
*/
|
|
268
|
+
getSessionListSyncWsUrls(): ReadonlyArray<string>;
|
|
269
|
+
/**
|
|
270
|
+
* @internal
|
|
271
|
+
* [zh-CN] 获取登录会话内共享的数据同步 WebSocket 会话。
|
|
272
|
+
* [en-US] Gets the shared WebSocket connection for data synchronization within the login session.
|
|
273
|
+
*/
|
|
274
|
+
getSharedSyncWebSocketSession(): SharedSyncWebSocketSession;
|
|
275
|
+
/**
|
|
276
|
+
* @internal
|
|
277
|
+
* [zh-CN] 判断当前会话列表能力是否允许进行 DNS 探测。
|
|
278
|
+
* [en-US] Indicates whether session-list capability probing through DNS is available.
|
|
279
|
+
*/
|
|
280
|
+
isSessionListDnsProbeAvailable(): boolean;
|
|
281
|
+
/**
|
|
282
|
+
* @internal
|
|
283
|
+
* [zh-CN] 获取会话列表同步能力状态。
|
|
284
|
+
* [en-US] Gets the session-list sync capability state.
|
|
285
|
+
*/
|
|
286
|
+
getSessionListSyncCapabilityState(): import('./cache/cache-types').SessionListCapabilityState | null;
|
|
287
|
+
/**
|
|
288
|
+
* @internal
|
|
289
|
+
* [zh-CN] 标记指定会话被访问,用于缓存层更新访问时间。
|
|
290
|
+
* [en-US] Marks specified conversations as accessed so the cache layer can update access timestamps.
|
|
291
|
+
*/
|
|
292
|
+
markConversationAccess(targets: ReadonlyArray<{
|
|
293
|
+
conversationId: string;
|
|
294
|
+
type: ConversationType;
|
|
295
|
+
}>): void;
|
|
296
|
+
private handleIncomingConversationMessage;
|
|
297
|
+
private handleIncomingConversationStreamMessage;
|
|
298
|
+
private applyIncomingConversationMessagePatch;
|
|
299
|
+
private handleOutgoingConversationMessage;
|
|
300
|
+
private handleMultiDeviceConversationEvent;
|
|
301
|
+
/**
|
|
302
|
+
* @internal
|
|
303
|
+
* [zh-CN] 在群组解散后按初始化配置清理对应的本地群会话,并派发会话列表更新。
|
|
304
|
+
* [en-US] Cleans up the corresponding local group conversation after group destruction according to the initialization option and emits a conversation-list update.
|
|
305
|
+
*/
|
|
306
|
+
handleGroupDestroyedConversation(groupId: string): Promise<void>;
|
|
307
|
+
private handleMultiDeviceContactEvent;
|
|
308
|
+
/**
|
|
309
|
+
* [zh-CN] 获取当前好友快照缓存。
|
|
310
|
+
* [en-US] Gets the cached friend snapshot.
|
|
311
|
+
*
|
|
312
|
+
* @example [zh-CN] 读取好友快照 [en-US] Read the friend snapshot.
|
|
313
|
+
* ```ts
|
|
314
|
+
* const snapshot = client.getContactSnapshot();
|
|
315
|
+
* ```
|
|
316
|
+
* @returns {ContactSnapshot | null} [zh-CN] 返回好友快照;若缓存未初始化则返回 `null`。 [en-US] Returns the friend snapshot, or `null` when the cache is uninitialized.
|
|
317
|
+
*/
|
|
318
|
+
getContactSnapshot(): ContactSnapshot | null;
|
|
319
|
+
private handleIncomingContactRosterEvent;
|
|
320
|
+
private resolveContactRosterTargetUserId;
|
|
321
|
+
private hydrateContactRosterPayload;
|
|
322
|
+
private fetchContactEventUserInfos;
|
|
323
|
+
private isMessageProfileSyncEnabled;
|
|
324
|
+
/**
|
|
325
|
+
* @internal
|
|
326
|
+
* [zh-CN] 判断是否启用了用户资料同步增强能力。
|
|
327
|
+
* [en-US] Indicates whether enhanced user-profile sync is enabled.
|
|
328
|
+
*/
|
|
329
|
+
isUserInfoSyncEnabled(): boolean;
|
|
330
|
+
private syncSelfUserInfoAfterLogin;
|
|
331
|
+
private handleIncomingMessageProfileSync;
|
|
332
|
+
private attachOutgoingMessageProfileVersions;
|
|
333
|
+
private resolveCurrentUserInfoUpdateTime;
|
|
334
|
+
private resolveCurrentGroupNamecardUpdateTime;
|
|
335
|
+
private shouldHydrateUserInfo;
|
|
336
|
+
private shouldHydrateGroupNamecard;
|
|
337
|
+
private flushUserInfoHydrationTargets;
|
|
338
|
+
private flushGroupNamecardHydrationBatch;
|
|
339
|
+
/**
|
|
340
|
+
* @internal
|
|
341
|
+
* [zh-CN] 受控刷新好友快照,复用 024 好友同步控制器。
|
|
342
|
+
* [en-US] Refreshes the friend snapshot in a controlled way by reusing the 024 friend sync controller.
|
|
343
|
+
*/
|
|
344
|
+
refreshContactSnapshot(): Promise<void>;
|
|
345
|
+
/**
|
|
346
|
+
* [zh-CN] 注册 ChatClient 事件处理器,用于监听连接、消息、好友、群组等 SDK 公开事件。
|
|
347
|
+
* [en-US] Registers a ChatClient event handler to listen for public SDK events such as connection state, messages, friends, and groups.
|
|
348
|
+
*
|
|
349
|
+
* @example [zh-CN] 监听连接状态变化 [en-US] Listen for connection state changes.
|
|
350
|
+
* ```ts
|
|
351
|
+
* client.addEventHandler('client-events', {
|
|
352
|
+
* onConnected: () => console.log('connected'),
|
|
353
|
+
* });
|
|
354
|
+
* ```
|
|
355
|
+
* @param id - [zh-CN] 事件处理器唯一 ID,用于后续移除。`id` 区分大小写。 [en-US] The unique handler ID, used for subsequent removal. `id` is case-sensitive.
|
|
356
|
+
* @param handlers - [zh-CN] 事件处理器对象,按需实现对应的回调函数。 [en-US] The event handler object. Implement only the callbacks you need.
|
|
357
|
+
* @returns {void} [zh-CN] 注册成功后无返回值。 [en-US] This method carries no return value after successful registration.
|
|
358
|
+
*/
|
|
359
|
+
addEventHandler(id: EventHandlerId, handlers: EventHandlerMap): void;
|
|
360
|
+
/**
|
|
361
|
+
* [zh-CN] 移除指定的 ChatClient 事件处理器。
|
|
362
|
+
* [en-US] Removes the specified ChatClient event handler set.
|
|
363
|
+
*
|
|
364
|
+
* @example [zh-CN] 移除事件处理器 [en-US] Remove event handlers.
|
|
365
|
+
* ```ts
|
|
366
|
+
* client.removeEventHandler('client-events');
|
|
367
|
+
* ```
|
|
368
|
+
* @param id - [zh-CN] 待移除的事件处理器 ID。 [en-US] The ID of the handler to remove.
|
|
369
|
+
* @returns {void} [zh-CN] 移除完成后无返回值。 [en-US] This method does not return a value.
|
|
370
|
+
*/
|
|
371
|
+
removeEventHandler(id: EventHandlerId): void;
|
|
372
|
+
/**
|
|
373
|
+
* [zh-CN] 注册一个管理器构造器,并返回带该管理器类型增强的 ChatClient 实例。
|
|
374
|
+
* [en-US] Registers a manager constructor and returns the ChatClient instance enhanced with that manager typing.
|
|
375
|
+
*
|
|
376
|
+
* @example [zh-CN] 手动注册管理器 [en-US] Register a manager manually
|
|
377
|
+
* ```ts
|
|
378
|
+
* const client = ChatClient.init({ appKey: 'org#app' }).use(ChatManager);
|
|
379
|
+
* ```
|
|
380
|
+
* @param ManagerCtor - [zh-CN] 管理器构造器。该参数必传。 [en-US] The manager constructor. This parameter is required.
|
|
381
|
+
* @returns {WithManager<this, Key, Manager>} [zh-CN] 返回带管理器类型增强的当前 ChatClient 实例。 [en-US] Returns the current ChatClient instance enhanced with the manager typing.
|
|
382
|
+
*/
|
|
383
|
+
use<Manager extends ManagerBase<ChatClient>, Key extends string>(ManagerCtor: ManagerConstructor<ChatClient, Manager, Key>): WithManager<this, Key, Manager>;
|
|
384
|
+
/**
|
|
385
|
+
* [zh-CN] 发送消息。消息通常应通过 `ChatManager` 或 `create*Message` 系列方法先构造,再交给此方法发送。
|
|
386
|
+
* [en-US] Sends a message. The message is typically be constructed first via `ChatManager` or the `create*Message` family of methods before being passed to this method for transmission.
|
|
387
|
+
*
|
|
388
|
+
* @example [zh-CN] 发送消息 [en-US] Send a message.
|
|
389
|
+
* ```ts
|
|
390
|
+
* const sent = await client.sendMessage(message);
|
|
391
|
+
* ```
|
|
392
|
+
* @param message - [zh-CN] 必传。待发送的消息对象。`message.sender.userId` 必须与当前登录用户 ID 一致。 [en-US] Required. The message object to send. `message.sender.userId` must match the current logged-in user ID.
|
|
393
|
+
* @param options - [zh-CN] 可选。发送配置项,例如进度回调函数。[en-US] Optional. Sending configuration options, such as progress callbacks.
|
|
394
|
+
* @returns {Promise<Message>} [zh-CN] 返回经过发送流程处理后的消息对象。 [en-US] Returns the message object after the sending pipeline completes.
|
|
395
|
+
*/
|
|
396
|
+
sendMessage(message: Message, options?: SendMessageOptions): Promise<Message>;
|
|
397
|
+
/**
|
|
398
|
+
* @internal
|
|
399
|
+
* [zh-CN] 派发当前用户资料更新事件。
|
|
400
|
+
* [en-US] Dispatches the current-user profile updated event.
|
|
401
|
+
*/
|
|
402
|
+
dispatchOwnInfoUpdated(userInfo: UserInfo): void;
|
|
403
|
+
/**
|
|
404
|
+
* @internal
|
|
405
|
+
* [zh-CN] 派发批量用户资料更新事件。
|
|
406
|
+
* [en-US] Dispatches the batch user-profile updated event.
|
|
407
|
+
*/
|
|
408
|
+
dispatchUserInfoUpdated(userInfos: ReadonlyArray<UserInfo>): void;
|
|
409
|
+
/**
|
|
410
|
+
* @internal
|
|
411
|
+
* [zh-CN] 根据用户资料变化刷新本地会话列表展示字段。
|
|
412
|
+
* [en-US] Refreshes local conversation-list display fields from user-profile changes.
|
|
413
|
+
*/
|
|
414
|
+
refreshConversationDisplayFromUserInfos(targets: ReadonlyArray<{
|
|
415
|
+
readonly userId: string;
|
|
416
|
+
readonly lastModified?: number;
|
|
417
|
+
}>, reason?: ConversationListUpdateReason): void;
|
|
418
|
+
/**
|
|
419
|
+
* @internal
|
|
420
|
+
* [zh-CN] 根据已加入群组同步结果刷新本地群会话展示字段。
|
|
421
|
+
* [en-US] Refreshes local group-conversation display fields from joined-group sync results.
|
|
422
|
+
*/
|
|
423
|
+
refreshConversationDisplayFromJoinedGroups(groups: ReadonlyArray<import('./types/group').JoinedGroupSummary>, reason?: ConversationListUpdateReason, options?: {
|
|
424
|
+
readonly onlyWhenNameMissing?: boolean;
|
|
425
|
+
}): void;
|
|
426
|
+
private enqueueMissingGroupSessionSenderUserInfos;
|
|
427
|
+
/**
|
|
428
|
+
* @internal
|
|
429
|
+
* [zh-CN] 派发用户群名片更新事件。
|
|
430
|
+
* [en-US] Dispatches the user group-namecard updated event.
|
|
431
|
+
*/
|
|
432
|
+
dispatchUserGroupNamecardUpdated(groupId: string, userId: string, namecard: string): void;
|
|
433
|
+
protected downloadAndParseCombinePayload(params: DownloadCombineMessageParams): Promise<ReadonlyArray<Message>>;
|
|
434
|
+
/**
|
|
435
|
+
* @internal
|
|
436
|
+
* [zh-CN] 发送消息 action 请求,例如已读、Reaction、Thread 相关的 ACK 驱动操作。
|
|
437
|
+
* [en-US] Sends a message-action request such as ACK-driven operations for read state, reactions, or threads.
|
|
438
|
+
*
|
|
439
|
+
* @example [zh-CN] 发送消息 action [en-US] Send a message action
|
|
440
|
+
* ```ts
|
|
441
|
+
* const result = await client.sendMessageAction(actionRequest);
|
|
442
|
+
* ```
|
|
443
|
+
* @param action - [zh-CN] 消息 action 请求体。该参数必传。 [en-US] The message action request payload. This parameter is required.
|
|
444
|
+
* @param createAckError - [zh-CN] 可选 ACK 错误构造器,用于自定义 ACK 失败错误。 [en-US] Optional ACK error factory for customizing ACK failure errors.
|
|
445
|
+
* @returns {Promise<ActionAckResult>} [zh-CN] 返回消息 action 的 ACK 结果。 [en-US] Returns the ACK result of the message action.
|
|
446
|
+
*/
|
|
447
|
+
sendMessageAction(action: MessageActionRequest, createAckError?: (statusCode: number, reason?: string) => Error): Promise<ActionAckResult>;
|
|
448
|
+
/**
|
|
449
|
+
* @internal
|
|
450
|
+
* [zh-CN] 发送聊天室 action 请求,用于聊天室内的 ACK 驱动操作。
|
|
451
|
+
* [en-US] Sends a chatroom-action request for ACK-driven operations within a chat room.
|
|
452
|
+
*
|
|
453
|
+
* @example [zh-CN] 发送聊天室 action [en-US] Send a chatroom action
|
|
454
|
+
* ```ts
|
|
455
|
+
* const result = await client.sendChatRoomOperation(request);
|
|
456
|
+
* ```
|
|
457
|
+
* @param request - [zh-CN] 聊天室 action 请求体。该参数必传。 [en-US] The chat room action request payload. This parameter is required.
|
|
458
|
+
* @param createAckError - [zh-CN] 可选 ACK 错误构造器,用于自定义 ACK 失败错误。 [en-US] Optional ACK error factory for customizing ACK failure errors.
|
|
459
|
+
* @returns {Promise<ActionAckResult>} [zh-CN] 返回聊天室 action 的 ACK 结果。 [en-US] Returns the ACK result of the chat room action.
|
|
460
|
+
*/
|
|
461
|
+
sendChatRoomOperation(request: ChatRoomOperationRequest, createAckError?: (statusCode: number, reason?: string) => Error): Promise<ActionAckResult>;
|
|
462
|
+
/**
|
|
463
|
+
* @internal
|
|
464
|
+
* [zh-CN] 下载消息附件。
|
|
465
|
+
* [en-US] Downloads the attachment of a message.
|
|
466
|
+
*
|
|
467
|
+
* @example [zh-CN] 下载消息附件 [en-US] Download a message attachment
|
|
468
|
+
* ```ts
|
|
469
|
+
* const file = await client.downloadAttachment(message);
|
|
470
|
+
* ```
|
|
471
|
+
* @param message - [zh-CN] 包含附件信息的消息对象。该参数必传。 [en-US] The message object containing attachment metadata. This parameter is required.
|
|
472
|
+
* @returns {Promise<MessageAttachmentDownloadResult>} [zh-CN] 返回附件下载结果。 [en-US] Returns the attachment download result.
|
|
473
|
+
*/
|
|
474
|
+
downloadAttachment(message: Message): Promise<MessageAttachmentDownloadResult>;
|
|
475
|
+
/**
|
|
476
|
+
* @internal
|
|
477
|
+
* [zh-CN] 解析服务端消息元数据载荷为标准消息对象。
|
|
478
|
+
* [en-US] Decodes server message metadata payload into a normalized message object.
|
|
479
|
+
*
|
|
480
|
+
* @example [zh-CN] 解析服务端消息元数据 [en-US] Decode server message metadata
|
|
481
|
+
* ```ts
|
|
482
|
+
* const message = client.decodeServerMessageMeta(metaPayload);
|
|
483
|
+
* ```
|
|
484
|
+
* @param metaPayload - [zh-CN] 服务端下发的消息元数据二进制载荷。该参数必传。 [en-US] The binary payload of server-delivered message metadata. This parameter is required.
|
|
485
|
+
* @returns {Message | null} [zh-CN] 返回解析后的消息对象;无法解析时返回 `null`。 [en-US] Returns the decoded message object, or `null` if decoding fails.
|
|
486
|
+
*/
|
|
487
|
+
decodeServerMessageMeta(metaPayload: Uint8Array): Message | null;
|
|
488
|
+
private registerManagers;
|
|
489
|
+
private registerManagerInput;
|
|
490
|
+
private registerManagerConstructor;
|
|
491
|
+
private registerManagerInstance;
|
|
492
|
+
private registerManagerCapabilities;
|
|
493
|
+
private dispatchRawNotifyToCapability;
|
|
494
|
+
private getUserInfoReadCapability;
|
|
495
|
+
private getGroupNamecardHydrationCapability;
|
|
496
|
+
private validateOptionalCapabilityDependencies;
|
|
497
|
+
private hasUserInfoReadCapability;
|
|
498
|
+
private hasGroupNamecardHydrationCapability;
|
|
499
|
+
private buildMissingCapabilityError;
|
|
500
|
+
private resolveManagerKey;
|
|
501
|
+
private getManagerKeyFromConstructor;
|
|
502
|
+
private getManagerKeyFromInstance;
|
|
503
|
+
private attachManager;
|
|
504
|
+
private isValidManagerKey;
|
|
505
|
+
private getManagerNameFromConstructor;
|
|
506
|
+
private getManagerNameFromInstance;
|
|
507
|
+
private buildManagerValidationError;
|
|
508
|
+
private buildManagerConflictError;
|
|
509
|
+
private static isManagerConstructor;
|
|
510
|
+
private updateState;
|
|
511
|
+
private initCacheManager;
|
|
512
|
+
private loadCachedConversations;
|
|
513
|
+
private loadCachedUserInfo;
|
|
514
|
+
/**
|
|
515
|
+
* @internal
|
|
516
|
+
* [zh-CN] 根据当前缓存快照派发会话列表更新事件。
|
|
517
|
+
* [en-US] Dispatches a conversation list update from the current cache snapshot.
|
|
518
|
+
*/
|
|
519
|
+
emitConversationListUpdate(reason: ConversationListUpdateReason, reset?: boolean): void;
|
|
520
|
+
private buildConversationListPatch;
|
|
521
|
+
private buildConversationListKey;
|
|
522
|
+
private isConversationListItemEqual;
|
|
523
|
+
private triggerContactSync;
|
|
524
|
+
private triggerConfiguredSyncDataAfterLogin;
|
|
525
|
+
private triggerGroupSync;
|
|
526
|
+
private ensureSessionListSyncController;
|
|
527
|
+
private ensureContactSyncController;
|
|
528
|
+
private ensureGroupSyncController;
|
|
529
|
+
/**
|
|
530
|
+
* @internal
|
|
531
|
+
* [zh-CN] 派发统一数据同步开始事件。
|
|
532
|
+
* [en-US] Emits the unified data-sync start event.
|
|
533
|
+
*/
|
|
534
|
+
emitSyncDataStart(dataType: SyncDataType): void;
|
|
535
|
+
/**
|
|
536
|
+
* @internal
|
|
537
|
+
* [zh-CN] 派发统一数据同步完成事件。
|
|
538
|
+
* [en-US] Emits the unified data-sync finished event.
|
|
539
|
+
*/
|
|
540
|
+
emitSyncDataFinished(payload: SyncDataFinishedPayload): void;
|
|
541
|
+
private requireCacheManager;
|
|
542
|
+
private resolveContactSyncUrls;
|
|
543
|
+
private buildAuthenticatedContactSyncUrls;
|
|
544
|
+
private buildAuthenticatedSessionListSyncUrls;
|
|
545
|
+
private requireContactSyncToken;
|
|
546
|
+
private buildContactSyncSocketUrl;
|
|
547
|
+
private shuffleContactSyncUrls;
|
|
548
|
+
private buildContactRosterRequest;
|
|
549
|
+
private resetCore;
|
|
550
|
+
private resetManagerSessionRuntimes;
|
|
551
|
+
private getContactSyncRestContext;
|
|
552
|
+
private static isSameConfig;
|
|
553
|
+
private static normalizeServiceConfig;
|
|
554
|
+
private static normalizeSyncDataTypes;
|
|
555
|
+
private static isSameStringArray;
|
|
556
|
+
private static isSameServiceConfig;
|
|
557
|
+
private static isSameServerUrls;
|
|
558
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),r=(e,r)=>{if(!e)return r;try{return JSON.parse(e)}catch{return r}},t=e=>{try{return JSON.stringify(e)}catch{return null}},n=e=>!!e&&("undefined"!=typeof DOMException&&e instanceof DOMException?"QuotaExceededError"===e.name||"NS_ERROR_DOM_QUOTA_REACHED"===e.name:e instanceof Error&&("QuotaExceededError"===e.name||e.message.includes("quota")));export{t as a,n as b,e as i,r as s};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";exports.isQuotaExceededError=e=>!!e&&("undefined"!=typeof DOMException&&e instanceof DOMException?"QuotaExceededError"===e.name||"NS_ERROR_DOM_QUOTA_REACHED"===e.name:e instanceof Error&&("QuotaExceededError"===e.name||e.message.includes("quota"))),exports.isRecord=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),exports.safeJsonParse=(e,r)=>{if(!e)return r;try{return JSON.parse(e)}catch{return r}},exports.safeJsonStringify=e=>{try{return JSON.stringify(e)}catch{return null}};
|