@easemob-community/uikit-sdk-websdk5 1.3.4
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/dist/__tests__/adapter-injected-client.test.d.ts +2 -0
- package/dist/__tests__/adapter-injected-client.test.d.ts.map +1 -0
- package/dist/__tests__/contact-notification.test.d.ts +2 -0
- package/dist/__tests__/contact-notification.test.d.ts.map +1 -0
- package/dist/adapter/contact-adapter.d.ts +10 -0
- package/dist/adapter/contact-adapter.d.ts.map +1 -0
- package/dist/adapter/conversation-adapter.d.ts +14 -0
- package/dist/adapter/conversation-adapter.d.ts.map +1 -0
- package/dist/adapter/group-adapter.d.ts +16 -0
- package/dist/adapter/group-adapter.d.ts.map +1 -0
- package/dist/adapter/message-adapter.d.ts +36 -0
- package/dist/adapter/message-adapter.d.ts.map +1 -0
- package/dist/adapter.d.ts +82 -0
- package/dist/adapter.d.ts.map +1 -0
- package/dist/client.d.ts +86 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/domain/__tests__/persistence-hooks.test.d.ts +2 -0
- package/dist/domain/__tests__/persistence-hooks.test.d.ts.map +1 -0
- package/dist/domain/__tests__/repository-injection.test.d.ts +2 -0
- package/dist/domain/__tests__/repository-injection.test.d.ts.map +1 -0
- package/dist/domain/__tests__/user-info-fetch-batching.test.d.ts +2 -0
- package/dist/domain/__tests__/user-info-fetch-batching.test.d.ts.map +1 -0
- package/dist/domain/contact-domain.d.ts +66 -0
- package/dist/domain/contact-domain.d.ts.map +1 -0
- package/dist/domain/conversation-domain.d.ts +98 -0
- package/dist/domain/conversation-domain.d.ts.map +1 -0
- package/dist/domain/group-domain.d.ts +155 -0
- package/dist/domain/group-domain.d.ts.map +1 -0
- package/dist/domain/message-domain.d.ts +145 -0
- package/dist/domain/message-domain.d.ts.map +1 -0
- package/dist/domain/presence-domain.d.ts +43 -0
- package/dist/domain/presence-domain.d.ts.map +1 -0
- package/dist/domain/user-info-domain.d.ts +88 -0
- package/dist/domain/user-info-domain.d.ts.map +1 -0
- package/dist/easemob-uikit-sdk-websdk5.js +3657 -0
- package/dist/easemob-uikit-sdk-websdk5.umd.cjs +1 -0
- package/dist/event/__tests__/chat-persistence.test.d.ts +2 -0
- package/dist/event/__tests__/chat-persistence.test.d.ts.map +1 -0
- package/dist/event/__tests__/connection-events.test.d.ts +2 -0
- package/dist/event/__tests__/connection-events.test.d.ts.map +1 -0
- package/dist/event/chat-events.d.ts +15 -0
- package/dist/event/chat-events.d.ts.map +1 -0
- package/dist/event/connection-events.d.ts +35 -0
- package/dist/event/connection-events.d.ts.map +1 -0
- package/dist/event/contact-events.d.ts +8 -0
- package/dist/event/contact-events.d.ts.map +1 -0
- package/dist/event/deps.d.ts +62 -0
- package/dist/event/deps.d.ts.map +1 -0
- package/dist/event/group-events.d.ts +6 -0
- package/dist/event/group-events.d.ts.map +1 -0
- package/dist/event/presence-events.d.ts +8 -0
- package/dist/event/presence-events.d.ts.map +1 -0
- package/dist/event/registry.d.ts +13 -0
- package/dist/event/registry.d.ts.map +1 -0
- package/dist/event/resolve-display-name.d.ts +15 -0
- package/dist/event/resolve-display-name.d.ts.map +1 -0
- package/dist/event/types.d.ts +175 -0
- package/dist/event/types.d.ts.map +1 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/notification-engine.d.ts +31 -0
- package/dist/notification-engine.d.ts.map +1 -0
- package/dist/sdk-types.d.ts +8 -0
- package/dist/sdk-types.d.ts.map +1 -0
- package/dist/use-sync-status.d.ts +32 -0
- package/dist/use-sync-status.d.ts.map +1 -0
- package/dist/utils/sdk-error.d.ts +30 -0
- package/dist/utils/sdk-error.d.ts.map +1 -0
- package/dist/utils/sdk-log-capture.d.ts +16 -0
- package/dist/utils/sdk-log-capture.d.ts.map +1 -0
- package/package.json +39 -0
|
@@ -0,0 +1,3657 @@
|
|
|
1
|
+
import { ChatClient as Je, isSDKError as Ne, ChatManager as ke, ChatRoomManager as Qe, UserInfoManager as xe, ContactManager as $e, GroupManager as ze, PresenceManager as Ye, PushManager as Xe } from "easemob-websdk";
|
|
2
|
+
import { log as ve, customEventPreviewMap as Ze, mergeMessagePreviewLabels as Oe, isTextBody as et, isImageBody as tt, isVoiceBody as Pe, isVideoBody as nt, isFileBody as st, isLocationBody as rt, isCustomBody as ot, isCmdBody as it, isCombineBody as Fe, MESSAGE_TYPE as S, CONVERSATION_TYPE as M, normalizeUserId as A, MESSAGE_STATUS as k, createLogger as R, toMessageRecord as Ie, formatConversationPreview as Be, GROUP_MEMBER_ROLE as _, PRESENCE_STATUS as W, isKickErrorCode as at, resolveLastMessageText as ct, isStreamActive as ut, toConversationRecord as Ae, NOTICE_EVENT_TYPE as G, SDK_CONTRACT_VERSION as dt } from "@easemob-community/uikit-sdk-contract";
|
|
3
|
+
import { normalizeUserId as xn } from "@easemob-community/uikit-sdk-contract";
|
|
4
|
+
import { markRaw as lt, computed as ue, reactive as gt } from "vue";
|
|
5
|
+
let te = null;
|
|
6
|
+
function yn(s) {
|
|
7
|
+
te = s;
|
|
8
|
+
}
|
|
9
|
+
function mt(s) {
|
|
10
|
+
te == null || te(s);
|
|
11
|
+
}
|
|
12
|
+
const ft = /^%c\[Chat\]\[(DEBUG|WARN|ERROR)\]\[[^\]]*\]/, pt = {
|
|
13
|
+
DEBUG: "debug",
|
|
14
|
+
WARN: "warn",
|
|
15
|
+
ERROR: "error"
|
|
16
|
+
};
|
|
17
|
+
let V = !1, Q = null, H = null, ne = null, Me = !1, se = null;
|
|
18
|
+
function ht(s) {
|
|
19
|
+
se = s;
|
|
20
|
+
}
|
|
21
|
+
function re(s, e, t) {
|
|
22
|
+
V && mt({
|
|
23
|
+
level: pt[s],
|
|
24
|
+
source: "sdk",
|
|
25
|
+
message: typeof e == "string" ? e : String(e),
|
|
26
|
+
args: t
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
function de(s, e, t) {
|
|
30
|
+
const n = H ?? console.log, o = (/* @__PURE__ */ new Date()).toISOString().slice(11, 23);
|
|
31
|
+
n.call(
|
|
32
|
+
console,
|
|
33
|
+
`%c[Chat][${s}][${o}]`,
|
|
34
|
+
"color: rgb(0, 157, 255); font-weight: bold;",
|
|
35
|
+
e,
|
|
36
|
+
...t
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
function vt() {
|
|
40
|
+
H || (H = console.log, console.log = (...s) => {
|
|
41
|
+
try {
|
|
42
|
+
const e = s[0];
|
|
43
|
+
if (typeof e == "string") {
|
|
44
|
+
const t = e.match(ft);
|
|
45
|
+
t && re(t[1], s[2], s.slice(3));
|
|
46
|
+
}
|
|
47
|
+
} catch {
|
|
48
|
+
}
|
|
49
|
+
H.apply(console, s);
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
function It() {
|
|
53
|
+
H && (console.log = H, H = null);
|
|
54
|
+
}
|
|
55
|
+
async function Sn() {
|
|
56
|
+
if (!V) {
|
|
57
|
+
V = !0;
|
|
58
|
+
try {
|
|
59
|
+
const s = await import("easemob-websdk");
|
|
60
|
+
typeof s.setLogLevel == "function" && (s.setLogLevel("DEBUG"), Me = !0), typeof s.setLogger == "function" ? (ne = typeof s.getLogger == "function" ? s.getLogger() : null, s.setLogger({
|
|
61
|
+
debug: (e, ...t) => {
|
|
62
|
+
re("DEBUG", e, t), de("DEBUG", e, t);
|
|
63
|
+
},
|
|
64
|
+
warn: (e, ...t) => {
|
|
65
|
+
re("WARN", e, t), de("WARN", e, t);
|
|
66
|
+
},
|
|
67
|
+
error: (e, ...t) => {
|
|
68
|
+
re("ERROR", e, t), de("ERROR", e, t);
|
|
69
|
+
}
|
|
70
|
+
}), Q = "inject") : (vt(), Q = "console");
|
|
71
|
+
} catch (s) {
|
|
72
|
+
V = !1, console.warn("[UIKit:SdkLogCapture] failed to enable SDK log capture", s);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
async function Gn() {
|
|
77
|
+
if (V) {
|
|
78
|
+
V = !1;
|
|
79
|
+
try {
|
|
80
|
+
Q === "console" && It();
|
|
81
|
+
const s = await import("easemob-websdk");
|
|
82
|
+
Q === "inject" && typeof s.setLogger == "function" && ne && s.setLogger(ne), Me && !(se != null && se()) && typeof s.setLogLevel == "function" && s.setLogLevel("WARN");
|
|
83
|
+
} catch {
|
|
84
|
+
} finally {
|
|
85
|
+
Q = null, ne = null, Me = !1;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
let Se = !1;
|
|
90
|
+
function An() {
|
|
91
|
+
return Se;
|
|
92
|
+
}
|
|
93
|
+
let He = null;
|
|
94
|
+
function Mt(s) {
|
|
95
|
+
const e = He;
|
|
96
|
+
if (!e)
|
|
97
|
+
return s;
|
|
98
|
+
if (s.appKey !== e.appKey)
|
|
99
|
+
throw new Error(
|
|
100
|
+
`[UIKit] ClientConfig.appKey(${s.appKey})与已初始化的 SDK 单例(${e.appKey})不一致:同一应用内多个 UIKit 场景包必须使用同一个 appKey(SDK 连接与事件总线是全局单例)。`
|
|
101
|
+
);
|
|
102
|
+
const { managers: t, ...n } = s, o = [];
|
|
103
|
+
for (const a of Object.keys(n))
|
|
104
|
+
JSON.stringify(n[a]) !== JSON.stringify(e[a]) && o.push(a);
|
|
105
|
+
return o.length > 0 && ve(
|
|
106
|
+
"[UIKit] SDK 已初始化,本次 init 配置以首次初始化为准(忽略字段:%s)。",
|
|
107
|
+
o.join(", ")
|
|
108
|
+
), { ...e, managers: t };
|
|
109
|
+
}
|
|
110
|
+
ht(() => Se);
|
|
111
|
+
class bt {
|
|
112
|
+
constructor(e) {
|
|
113
|
+
var i;
|
|
114
|
+
const { debug: t, clientName: n = "UIKit", clientVersion: o, ...a } = e;
|
|
115
|
+
if (!((i = a.managers) != null && i.length))
|
|
116
|
+
throw new Error(
|
|
117
|
+
"[UIKit] ClientConfig.managers 未注入:SDK manager 列表由 adapter 负责传入"
|
|
118
|
+
);
|
|
119
|
+
const r = Mt({
|
|
120
|
+
...a,
|
|
121
|
+
enableUserInfoSync: a.enableUserInfoSync ?? !0,
|
|
122
|
+
managers: a.managers
|
|
123
|
+
});
|
|
124
|
+
this._deleteConversationOnGroupDestroyed = r.deleteConversationOnGroupDestroyed ?? !0, this._client = Je.init(r), He = r, t && (Se = !0, import("easemob-websdk").then(({ setLogLevel: u }) => {
|
|
125
|
+
u("DEBUG");
|
|
126
|
+
})), o ? ve(
|
|
127
|
+
"%c[Easemob] SDK version: %s, %s version: %s, Adapter version: %s",
|
|
128
|
+
"color: green; font-weight: bold;",
|
|
129
|
+
"5.0.0",
|
|
130
|
+
n,
|
|
131
|
+
o,
|
|
132
|
+
"1.3.4"
|
|
133
|
+
) : ve(
|
|
134
|
+
"%c[Easemob] SDK version: %s, Adapter version: %s",
|
|
135
|
+
"color: green; font-weight: bold;",
|
|
136
|
+
"5.0.0",
|
|
137
|
+
"1.3.4"
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
get chatManager() {
|
|
141
|
+
return this._client.chatManager;
|
|
142
|
+
}
|
|
143
|
+
get chatRoomManager() {
|
|
144
|
+
return this._client.chatRoomManager;
|
|
145
|
+
}
|
|
146
|
+
get contactManager() {
|
|
147
|
+
return this._client.contactManager;
|
|
148
|
+
}
|
|
149
|
+
get groupManager() {
|
|
150
|
+
return this._client.groupManager;
|
|
151
|
+
}
|
|
152
|
+
get presenceManager() {
|
|
153
|
+
return this._client.presenceManager;
|
|
154
|
+
}
|
|
155
|
+
get pushManager() {
|
|
156
|
+
return this._client.pushManager;
|
|
157
|
+
}
|
|
158
|
+
get userInfoManager() {
|
|
159
|
+
return this._client.userInfoManager;
|
|
160
|
+
}
|
|
161
|
+
get connectionState() {
|
|
162
|
+
return this._client.getConnectionState();
|
|
163
|
+
}
|
|
164
|
+
get isConnected() {
|
|
165
|
+
return this._client.getConnectionState() === "connected";
|
|
166
|
+
}
|
|
167
|
+
get deleteConversationOnGroupDestroyed() {
|
|
168
|
+
return this._deleteConversationOnGroupDestroyed;
|
|
169
|
+
}
|
|
170
|
+
get currentUserId() {
|
|
171
|
+
return this._client.getCurrentUserId();
|
|
172
|
+
}
|
|
173
|
+
addEventHandler(e, t) {
|
|
174
|
+
this._client.addEventHandler(e, t);
|
|
175
|
+
}
|
|
176
|
+
removeEventHandler(e) {
|
|
177
|
+
this._client.removeEventHandler(e);
|
|
178
|
+
}
|
|
179
|
+
async login(e, t) {
|
|
180
|
+
return this._client.login({ userId: e, token: t });
|
|
181
|
+
}
|
|
182
|
+
async logout() {
|
|
183
|
+
return this._client.logout();
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
function wt(s) {
|
|
187
|
+
return new bt(s);
|
|
188
|
+
}
|
|
189
|
+
const Ct = R("UIKit:MessageAdapter"), Ge = {
|
|
190
|
+
image: "[图片]",
|
|
191
|
+
sticker: "[表情]",
|
|
192
|
+
voice: "[语音]",
|
|
193
|
+
video: "[视频]",
|
|
194
|
+
file: "[文件]",
|
|
195
|
+
location: "[位置]",
|
|
196
|
+
combine: "[聊天记录]",
|
|
197
|
+
custom: Ze,
|
|
198
|
+
customFallback: "[自定义]",
|
|
199
|
+
unknown: ""
|
|
200
|
+
};
|
|
201
|
+
function Ee(s) {
|
|
202
|
+
if (s.event && typeof s.event == "string")
|
|
203
|
+
return s.event;
|
|
204
|
+
const e = s.params;
|
|
205
|
+
if (e && typeof e == "object") {
|
|
206
|
+
const t = e.event;
|
|
207
|
+
if (typeof t == "string")
|
|
208
|
+
return t;
|
|
209
|
+
}
|
|
210
|
+
return "";
|
|
211
|
+
}
|
|
212
|
+
function x(s, e) {
|
|
213
|
+
e || Ct.warn("[toUiMessage] currentUserId is empty, isSelf may be inaccurate", {
|
|
214
|
+
from: s.from,
|
|
215
|
+
conversationId: s.conversationId,
|
|
216
|
+
type: s.type
|
|
217
|
+
});
|
|
218
|
+
const t = A(s.from) === A(e), n = {
|
|
219
|
+
...s,
|
|
220
|
+
isSelf: t,
|
|
221
|
+
localId: s.msgLocalId,
|
|
222
|
+
status: t && s.isPeerRead === !0 ? k.READ : s.sendStatus ?? k.SENT
|
|
223
|
+
};
|
|
224
|
+
return Fe(n.body) && n.body.messageList && (n.body = {
|
|
225
|
+
...n.body,
|
|
226
|
+
messageList: lt([...n.body.messageList])
|
|
227
|
+
}), n;
|
|
228
|
+
}
|
|
229
|
+
function En(s, e) {
|
|
230
|
+
return s.map((t) => x(t, e));
|
|
231
|
+
}
|
|
232
|
+
function Rn(s, e) {
|
|
233
|
+
if (!s)
|
|
234
|
+
return "";
|
|
235
|
+
const t = Oe({ ...Ge, ...e }), { body: n } = s;
|
|
236
|
+
return et(n) ? n.content || "" : tt(n) ? t.image : Pe(n) ? t.voice : nt(n) ? t.video : st(n) ? n.filename || t.file : rt(n) ? t.location : ot(n) ? t.custom[n.event || ""] || t.customFallback : it(n) ? "[命令]" : Fe(n) ? n.summary || t.combine : "";
|
|
237
|
+
}
|
|
238
|
+
function yt(s, e) {
|
|
239
|
+
if (!s)
|
|
240
|
+
return "";
|
|
241
|
+
const t = Oe({ ...Ge, ...e }), n = s.body || {};
|
|
242
|
+
switch (s.type) {
|
|
243
|
+
case S.TEXT:
|
|
244
|
+
return n.content || n.summary || "";
|
|
245
|
+
case S.IMAGE:
|
|
246
|
+
return t.image;
|
|
247
|
+
case S.VOICE:
|
|
248
|
+
return t.voice;
|
|
249
|
+
case S.VIDEO:
|
|
250
|
+
return t.video;
|
|
251
|
+
case S.FILE:
|
|
252
|
+
return n.filename || t.file;
|
|
253
|
+
case S.LOCATION:
|
|
254
|
+
return t.location;
|
|
255
|
+
case S.CUSTOM: {
|
|
256
|
+
const o = Ee(n);
|
|
257
|
+
return t.custom[o] || t.customFallback;
|
|
258
|
+
}
|
|
259
|
+
case S.CMD:
|
|
260
|
+
return "[命令]";
|
|
261
|
+
case S.COMBINE:
|
|
262
|
+
return n.summary || t.combine;
|
|
263
|
+
default: {
|
|
264
|
+
const o = Ee(n);
|
|
265
|
+
return o ? t.custom[o] || t.customFallback : n.content || n.summary || n.msg || "";
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
function Tn(s, e, t) {
|
|
270
|
+
return s.conversationId === e && s.conversationType === t;
|
|
271
|
+
}
|
|
272
|
+
function Un(s, e) {
|
|
273
|
+
return s.conversationType === M.GROUPCHAT || A(s.from) === A(e) ? s.to : s.from;
|
|
274
|
+
}
|
|
275
|
+
function E(s) {
|
|
276
|
+
return Ne(s) ? s.toJSON() : s;
|
|
277
|
+
}
|
|
278
|
+
const St = {
|
|
279
|
+
// 连接 / 网络
|
|
280
|
+
1: "error.unknown",
|
|
281
|
+
2: "error.network",
|
|
282
|
+
300: "error.notConnected",
|
|
283
|
+
301: "error.timeout",
|
|
284
|
+
302: "error.serverBusy",
|
|
285
|
+
303: "error.serverError",
|
|
286
|
+
304: "error.network",
|
|
287
|
+
305: "error.serviceNotEnabled",
|
|
288
|
+
// 认证 / 权限 / 被踢 / 禁言
|
|
289
|
+
100: "error.unauthorized",
|
|
290
|
+
107: "error.invalidConversation",
|
|
291
|
+
108: "error.tokenExpired",
|
|
292
|
+
110: "error.validation",
|
|
293
|
+
111: "error.unsupported",
|
|
294
|
+
200: "error.unauthorized",
|
|
295
|
+
201: "error.unauthorized",
|
|
296
|
+
202: "error.unauthorized",
|
|
297
|
+
204: "error.notFound",
|
|
298
|
+
210: "error.forbidden",
|
|
299
|
+
213: "error.kicked",
|
|
300
|
+
214: "error.loginTooManyDevices",
|
|
301
|
+
215: "error.userMuted",
|
|
302
|
+
216: "error.kicked",
|
|
303
|
+
217: "error.kicked",
|
|
304
|
+
218: "error.kicked",
|
|
305
|
+
219: "error.userMutedByAdmin",
|
|
306
|
+
220: "error.deviceChanged",
|
|
307
|
+
221: "error.notOnRoster",
|
|
308
|
+
222: "error.messageBlockedByRecipient",
|
|
309
|
+
// 文件 / 附件 / 上传
|
|
310
|
+
400: "error.fileNotFound",
|
|
311
|
+
401: "error.fileInvalid",
|
|
312
|
+
402: "error.uploadFailed",
|
|
313
|
+
403: "error.fileDownloadFailed",
|
|
314
|
+
405: "error.fileTooLarge",
|
|
315
|
+
406: "error.fileContentImproper",
|
|
316
|
+
407: "error.fileExpired",
|
|
317
|
+
410: "error.fileNotFound",
|
|
318
|
+
411: "error.fileTooLarge",
|
|
319
|
+
// 消息相关
|
|
320
|
+
500: "error.internalError",
|
|
321
|
+
501: "error.illegalContent",
|
|
322
|
+
502: "error.trafficLimit",
|
|
323
|
+
504: "message.recall.timeLimit",
|
|
324
|
+
505: "error.serviceNotEnabled",
|
|
325
|
+
506: "error.messageExpired",
|
|
326
|
+
510: "error.messageSizeLimit",
|
|
327
|
+
// 群组
|
|
328
|
+
600: "error.groupInvalid",
|
|
329
|
+
601: "error.groupAlreadyJoined",
|
|
330
|
+
602: "error.groupNotJoined",
|
|
331
|
+
603: "error.groupPermissionDenied",
|
|
332
|
+
604: "error.groupMembersFull",
|
|
333
|
+
606: "error.groupNotExist",
|
|
334
|
+
607: "error.groupDisabled",
|
|
335
|
+
613: "error.groupUserInBlocklist",
|
|
336
|
+
// 聊天室
|
|
337
|
+
700: "error.chatroomInvalid",
|
|
338
|
+
702: "error.chatroomNotJoined",
|
|
339
|
+
703: "error.chatroomPermissionDenied",
|
|
340
|
+
704: "error.chatroomMembersFull",
|
|
341
|
+
705: "error.chatroomNotExist",
|
|
342
|
+
// 用户属性
|
|
343
|
+
900: "error.userInfoCountExceed",
|
|
344
|
+
901: "error.userInfoDataLengthExceed",
|
|
345
|
+
// 联系人
|
|
346
|
+
1e3: "error.contactAlreadyFriend",
|
|
347
|
+
1001: "error.contactReachLimit",
|
|
348
|
+
1002: "error.contactReachLimitPeer",
|
|
349
|
+
// 翻译
|
|
350
|
+
1110: "error.validation",
|
|
351
|
+
1111: "message.translate.serviceUnavailable",
|
|
352
|
+
1112: "error.translateUsageLimit",
|
|
353
|
+
1113: "error.translateFailed",
|
|
354
|
+
// 内容审核 / Reaction
|
|
355
|
+
1200: "error.moderationFailed",
|
|
356
|
+
1299: "error.moderationFailed",
|
|
357
|
+
1300: "error.reactionReachLimit",
|
|
358
|
+
1301: "error.reactionAlreadyOperated",
|
|
359
|
+
1302: "error.reactionOperationIllegal",
|
|
360
|
+
// 推送 / 在线状态订阅
|
|
361
|
+
1500: "error.pushFailed",
|
|
362
|
+
1600: "error.userInfoSubscriptionLimitExceeded",
|
|
363
|
+
1601: "error.userInfoSubscriptionTargetLimitExceeded"
|
|
364
|
+
};
|
|
365
|
+
function Gt(s) {
|
|
366
|
+
return Ne(s) ? St[s.code] ?? null : null;
|
|
367
|
+
}
|
|
368
|
+
function At(s) {
|
|
369
|
+
return s instanceof Error ? s.message : typeof s == "string" ? s : s && typeof s == "object" && "reason" in s && typeof s.reason == "string" ? s.reason : String(s);
|
|
370
|
+
}
|
|
371
|
+
function Et(s) {
|
|
372
|
+
const e = s.toLowerCase();
|
|
373
|
+
return e.includes("not connected") || e.includes("disconnected") || e.includes("connection is closed") || e.includes("chatclient is not connected") ? "error.notConnected" : e.includes("network") || e.includes("net::err") || e.includes("failed to fetch") || e.includes("network request failed") ? "error.network" : e.includes("timeout") || e.includes("timed out") ? "error.timeout" : "error.unknown";
|
|
374
|
+
}
|
|
375
|
+
function Ln(s, e, t) {
|
|
376
|
+
const n = Gt(s);
|
|
377
|
+
if (n) {
|
|
378
|
+
const r = t(n);
|
|
379
|
+
if (r && r !== n)
|
|
380
|
+
return r;
|
|
381
|
+
}
|
|
382
|
+
const o = At(s), a = Et(o);
|
|
383
|
+
return a !== "error.unknown" ? t(a) || t(e) || o : t(n || e) || o || "";
|
|
384
|
+
}
|
|
385
|
+
const le = R("Combine"), ge = R("History"), D = R("MessageDomain"), Rt = 150;
|
|
386
|
+
function Tt(s) {
|
|
387
|
+
return new Promise((e) => {
|
|
388
|
+
if (typeof document > "u" || typeof URL.createObjectURL != "function") {
|
|
389
|
+
e(void 0);
|
|
390
|
+
return;
|
|
391
|
+
}
|
|
392
|
+
const t = URL.createObjectURL(s), n = document.createElement("video");
|
|
393
|
+
n.muted = !0, n.playsInline = !0, n.preload = "metadata", n.src = t;
|
|
394
|
+
let o = !1;
|
|
395
|
+
const a = (r) => {
|
|
396
|
+
o || (o = !0, URL.revokeObjectURL(t), n.removeAttribute("src"), e(r));
|
|
397
|
+
};
|
|
398
|
+
n.addEventListener("loadedmetadata", () => {
|
|
399
|
+
const { videoWidth: r, videoHeight: i } = n;
|
|
400
|
+
a(r > 0 && i > 0 ? { width: r, height: i } : void 0);
|
|
401
|
+
}), n.addEventListener("error", () => a(void 0)), setTimeout(() => a(void 0), 5e3);
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
const B = /* @__PURE__ */ new Set(), Ut = 5e3;
|
|
405
|
+
function Lt(s) {
|
|
406
|
+
for (const e of s)
|
|
407
|
+
if (B.add(e), B.size > Ut) {
|
|
408
|
+
const t = B.values().next().value;
|
|
409
|
+
t !== void 0 && B.delete(t);
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
function z(s) {
|
|
413
|
+
Promise.resolve().then(s).catch((e) => D.warn("persistence 钩子执行失败(已忽略):", e));
|
|
414
|
+
}
|
|
415
|
+
function Dt(s, e) {
|
|
416
|
+
const t = A(s.from) === A(e);
|
|
417
|
+
return {
|
|
418
|
+
...s,
|
|
419
|
+
isSelf: t,
|
|
420
|
+
localId: s.msgLocalId,
|
|
421
|
+
status: t && s.isPeerRead === !0 ? k.READ : s.sendStatus ?? k.SENT
|
|
422
|
+
};
|
|
423
|
+
}
|
|
424
|
+
class _t {
|
|
425
|
+
constructor(e, t, n = {}) {
|
|
426
|
+
this.client = e, this.store = t, this.options = n;
|
|
427
|
+
}
|
|
428
|
+
// ===== 发送消息 =====
|
|
429
|
+
async sendText(e, t, n, o, a) {
|
|
430
|
+
const r = this.client.chatManager.createTextMessage({
|
|
431
|
+
conversationId: e,
|
|
432
|
+
conversationType: t,
|
|
433
|
+
content: n,
|
|
434
|
+
ext: o,
|
|
435
|
+
needReadReceipt: a
|
|
436
|
+
});
|
|
437
|
+
return this._send(r);
|
|
438
|
+
}
|
|
439
|
+
async sendImage(e, t, n, o, a) {
|
|
440
|
+
const r = typeof n == "string" ? /\.gif(?:$|\?)/i.test(n) : n.type === "image/gif" || /\.gif$/i.test(n.name), i = this.client.chatManager.createImageMessage({
|
|
441
|
+
conversationId: e,
|
|
442
|
+
conversationType: t,
|
|
443
|
+
ext: o,
|
|
444
|
+
needReadReceipt: a,
|
|
445
|
+
...typeof n == "string" ? { originalUrl: n } : { data: n },
|
|
446
|
+
...r ? { isGif: !0 } : {}
|
|
447
|
+
});
|
|
448
|
+
return this._send(i);
|
|
449
|
+
}
|
|
450
|
+
async sendFile(e, t, n, o, a) {
|
|
451
|
+
const r = this.client.chatManager.createFileMessage({
|
|
452
|
+
conversationId: e,
|
|
453
|
+
conversationType: t,
|
|
454
|
+
ext: o,
|
|
455
|
+
needReadReceipt: a,
|
|
456
|
+
...typeof n == "string" ? { originalUrl: n } : { data: n }
|
|
457
|
+
});
|
|
458
|
+
return this._send(r);
|
|
459
|
+
}
|
|
460
|
+
async sendVoice(e, t, n, o, a, r) {
|
|
461
|
+
const i = this.client.chatManager.createVoiceMessage({
|
|
462
|
+
conversationId: e,
|
|
463
|
+
conversationType: t,
|
|
464
|
+
duration: o,
|
|
465
|
+
ext: a,
|
|
466
|
+
needReadReceipt: r,
|
|
467
|
+
...typeof n == "string" ? { originalUrl: n } : { data: n }
|
|
468
|
+
});
|
|
469
|
+
return this._send(i);
|
|
470
|
+
}
|
|
471
|
+
async sendVideo(e, t, n, o, a, r) {
|
|
472
|
+
const i = typeof n == "string" ? void 0 : await Tt(n), u = this.client.chatManager.createVideoMessage({
|
|
473
|
+
conversationId: e,
|
|
474
|
+
conversationType: t,
|
|
475
|
+
duration: o,
|
|
476
|
+
ext: a,
|
|
477
|
+
needReadReceipt: r,
|
|
478
|
+
...i ? { width: i.width, height: i.height } : {},
|
|
479
|
+
...typeof n == "string" ? { originalUrl: n } : { data: n }
|
|
480
|
+
});
|
|
481
|
+
return this._send(u);
|
|
482
|
+
}
|
|
483
|
+
async sendLocation(e, t, n, o, a, r) {
|
|
484
|
+
const i = this.client.chatManager.createLocationMessage({
|
|
485
|
+
conversationId: e,
|
|
486
|
+
conversationType: t,
|
|
487
|
+
latitude: n,
|
|
488
|
+
longitude: o,
|
|
489
|
+
address: a,
|
|
490
|
+
ext: r
|
|
491
|
+
});
|
|
492
|
+
return this._send(i);
|
|
493
|
+
}
|
|
494
|
+
async sendCustom(e, t, n, o, a) {
|
|
495
|
+
const r = this.client.chatManager.createCustomMessage({
|
|
496
|
+
conversationId: e,
|
|
497
|
+
conversationType: t,
|
|
498
|
+
event: n,
|
|
499
|
+
params: o,
|
|
500
|
+
ext: a
|
|
501
|
+
});
|
|
502
|
+
return this._send(r);
|
|
503
|
+
}
|
|
504
|
+
async sendCmd(e, t, n, o) {
|
|
505
|
+
const a = this.client.chatManager.createCmdMessage({
|
|
506
|
+
conversationId: e,
|
|
507
|
+
conversationType: t,
|
|
508
|
+
action: n,
|
|
509
|
+
ext: o,
|
|
510
|
+
// CMD 消息(如 typing)只投递给在线用户,不存离线队列。
|
|
511
|
+
deliverOnlineOnly: !0
|
|
512
|
+
});
|
|
513
|
+
return this._send(a);
|
|
514
|
+
}
|
|
515
|
+
async sendCombine(e, t, n, o, a, r, i) {
|
|
516
|
+
const u = performance.now(), d = this.client.chatManager.createCombineMessage({
|
|
517
|
+
conversationId: e,
|
|
518
|
+
conversationType: t,
|
|
519
|
+
title: n,
|
|
520
|
+
summary: o,
|
|
521
|
+
compatibleText: a,
|
|
522
|
+
messageList: r,
|
|
523
|
+
ext: i
|
|
524
|
+
});
|
|
525
|
+
return le.info("createCombineMessage done", {
|
|
526
|
+
items: r.length,
|
|
527
|
+
elapsedMs: Math.round(performance.now() - u)
|
|
528
|
+
}), this._send(d);
|
|
529
|
+
}
|
|
530
|
+
/** 通用发送流程 */
|
|
531
|
+
async _send(e) {
|
|
532
|
+
var i;
|
|
533
|
+
const t = e.msgLocalId, n = e.type === S.COMBINE;
|
|
534
|
+
if (e.type === S.CMD)
|
|
535
|
+
return this.client.chatManager.sendMessage(e);
|
|
536
|
+
e.requireGroupAck && D.info("[GroupAck] 发送消息携带 needReadReceipt", {
|
|
537
|
+
conversationId: e.conversationId,
|
|
538
|
+
conversationType: e.conversationType,
|
|
539
|
+
msgLocalId: e.msgLocalId
|
|
540
|
+
}), this.store.addSendingMessage(t, e);
|
|
541
|
+
let o = 0, a = 0;
|
|
542
|
+
const r = performance.now();
|
|
543
|
+
try {
|
|
544
|
+
const u = await this.client.chatManager.sendMessage(e, {
|
|
545
|
+
onFileUploadProgress: (f) => {
|
|
546
|
+
o += 1;
|
|
547
|
+
const c = f.percent ?? 0, l = performance.now();
|
|
548
|
+
c < 100 && l - a < Rt || (a = l, this.store.updateUploadProgress(t, c));
|
|
549
|
+
}
|
|
550
|
+
});
|
|
551
|
+
n && le.info("sendMessage done", {
|
|
552
|
+
elapsedMs: Math.round(performance.now() - r),
|
|
553
|
+
progressEvents: o
|
|
554
|
+
});
|
|
555
|
+
const d = x(u, this.currentUserId);
|
|
556
|
+
this.store.replaceWithSent(t, d);
|
|
557
|
+
const g = (i = this.options.persistence) == null ? void 0 : i.saveMessage;
|
|
558
|
+
return g && z(() => g(Ie(u))), u;
|
|
559
|
+
} catch (u) {
|
|
560
|
+
n && le.warn("sendMessage failed", {
|
|
561
|
+
elapsedMs: Math.round(performance.now() - r),
|
|
562
|
+
progressEvents: o,
|
|
563
|
+
error: u instanceof Error ? u.message : String(u)
|
|
564
|
+
});
|
|
565
|
+
const d = u instanceof Error ? u.message : String(u);
|
|
566
|
+
throw this.store.markFailed(t, d), u;
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
// ===== 历史消息 =====
|
|
570
|
+
async fetchHistory(e, t, n, o = 20) {
|
|
571
|
+
var g, f;
|
|
572
|
+
const a = (g = this.options.messageRepository) == null ? void 0 : g.loadMessages;
|
|
573
|
+
if (a) {
|
|
574
|
+
const c = await a(e, t, n, o), l = c.list.filter((m) => m.type !== S.CMD).map((m) => Dt(m, this.currentUserId));
|
|
575
|
+
return this.store.prependMessages(e, l), t === M.GROUPCHAT && this.fillGroupReadCounts(l, e), {
|
|
576
|
+
list: l,
|
|
577
|
+
cursor: c.cursor,
|
|
578
|
+
hasMore: c.hasMore
|
|
579
|
+
};
|
|
580
|
+
}
|
|
581
|
+
const r = await this.client.chatManager.getHistoryMessages({
|
|
582
|
+
conversationId: e,
|
|
583
|
+
conversationType: t,
|
|
584
|
+
pageSize: o,
|
|
585
|
+
cursor: n,
|
|
586
|
+
searchDirection: "up"
|
|
587
|
+
});
|
|
588
|
+
ge.info("fetchHistory response", {
|
|
589
|
+
conversationId: e,
|
|
590
|
+
conversationType: t,
|
|
591
|
+
cursor: n,
|
|
592
|
+
pageSize: o,
|
|
593
|
+
count: r.items.length,
|
|
594
|
+
cursorReturned: r.cursor,
|
|
595
|
+
hasMore: r.hasMore,
|
|
596
|
+
items: r.items.map((c) => `${c.msgServerId || c.msgLocalId}|${c.type}|${c.from}->${c.to}|${c.timestamp}`)
|
|
597
|
+
});
|
|
598
|
+
const i = r.items.filter((c) => c.type !== S.CMD), u = i.map((c) => x(c, this.currentUserId));
|
|
599
|
+
this.store.prependMessages(e, u);
|
|
600
|
+
const d = (f = this.options.persistence) == null ? void 0 : f.saveMessages;
|
|
601
|
+
return d && i.length > 0 && z(() => d(i.map((c) => Ie(c)))), t === M.GROUPCHAT && this.fillGroupReadCounts(u, e), {
|
|
602
|
+
list: u,
|
|
603
|
+
cursor: r.cursor,
|
|
604
|
+
hasMore: r.hasMore
|
|
605
|
+
};
|
|
606
|
+
}
|
|
607
|
+
/**
|
|
608
|
+
* 补全群聊历史消息的已读数:对已读数缺失的己方消息,调用
|
|
609
|
+
* getGroupMessageReadReceipts 批量获取 count 并写入 store
|
|
610
|
+
* (服务端单次最多 20 条,超过自动分批);失败仅告警,不影响整体。
|
|
611
|
+
*
|
|
612
|
+
* 注意:不做 needReadReceipt 筛选——该字段是发送时的创建参数,历史消息
|
|
613
|
+
* 返回时通常不携带;已读数只对发送者有意义,且 SDK 已带 groupReadCount
|
|
614
|
+
* 的消息会被过滤,不会重复请求。
|
|
615
|
+
*/
|
|
616
|
+
async fillGroupReadCounts(e, t) {
|
|
617
|
+
const n = e.filter((r) => r.isSelf && !(r.groupReadCount ?? 0)), o = n.map((r) => r.msgServerId).filter((r) => !!r);
|
|
618
|
+
if (ge.info("fillGroupReadCounts scan", {
|
|
619
|
+
groupId: t,
|
|
620
|
+
total: e.length,
|
|
621
|
+
selfMissingCount: n.length,
|
|
622
|
+
targets: o.length
|
|
623
|
+
}), o.length === 0)
|
|
624
|
+
return;
|
|
625
|
+
const a = 20;
|
|
626
|
+
for (let r = 0; r < o.length; r += a) {
|
|
627
|
+
const i = o.slice(r, r + a);
|
|
628
|
+
try {
|
|
629
|
+
const u = await this.client.chatManager.getGroupMessageReadReceipts({
|
|
630
|
+
groupId: t,
|
|
631
|
+
messageIds: i
|
|
632
|
+
});
|
|
633
|
+
ge.info("fillGroupReadCounts result", { groupId: t, batch: i, receipts: u });
|
|
634
|
+
for (const d of u)
|
|
635
|
+
d.count > 0 && this.store.updateMessageById(d.messageId, { groupReadCount: d.count });
|
|
636
|
+
} catch (u) {
|
|
637
|
+
D.warn("[MessageDomain.fillGroupReadCounts] failed:", i, E(u));
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
// ===== 消息操作 =====
|
|
642
|
+
async recall(e, t, n) {
|
|
643
|
+
var a;
|
|
644
|
+
await this.client.chatManager.recallMessage({
|
|
645
|
+
conversationId: e,
|
|
646
|
+
conversationType: t,
|
|
647
|
+
messageId: n
|
|
648
|
+
});
|
|
649
|
+
const o = (a = this.options.persistence) == null ? void 0 : a.markMessageRecalled;
|
|
650
|
+
o && z(() => o(n, this.currentUserId));
|
|
651
|
+
}
|
|
652
|
+
/**
|
|
653
|
+
* 删除消息:移除当前用户的服务端漫游历史(SDK5 `removeHistoryMessages`)。
|
|
654
|
+
* 成功后本端立即落删除墓碑;多端移除事件(onMultiDeviceMessageRemoved)路径
|
|
655
|
+
* 在 chat-events 另有处理。
|
|
656
|
+
*/
|
|
657
|
+
async removeMessages(e, t, n) {
|
|
658
|
+
var a;
|
|
659
|
+
if (n.length === 0)
|
|
660
|
+
return;
|
|
661
|
+
await this.client.chatManager.removeHistoryMessages({
|
|
662
|
+
conversationId: e,
|
|
663
|
+
conversationType: t,
|
|
664
|
+
messageIds: n
|
|
665
|
+
});
|
|
666
|
+
const o = (a = this.options.persistence) == null ? void 0 : a.deleteMessages;
|
|
667
|
+
o && z(() => o([...n]));
|
|
668
|
+
}
|
|
669
|
+
/** 批量发送消息已读回执(统一 API,支持单聊/群聊) */
|
|
670
|
+
async markMessagesRead(e, t, n) {
|
|
671
|
+
if (n.length === 0)
|
|
672
|
+
return;
|
|
673
|
+
const o = 50;
|
|
674
|
+
for (let a = 0; a < n.length; a += o) {
|
|
675
|
+
const r = n.slice(a, a + o);
|
|
676
|
+
await this.client.chatManager.sendMessageReadReceipts({
|
|
677
|
+
conversationId: e,
|
|
678
|
+
conversationType: t,
|
|
679
|
+
messageIds: r
|
|
680
|
+
});
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
/**
|
|
684
|
+
* 补发当前会话中尚未发送过已读回执的接收消息(批量)。
|
|
685
|
+
*
|
|
686
|
+
* 场景:接收方登录时收到群内/单聊离线消息,onMessage 阶段当前会话可能
|
|
687
|
+
* 尚未打开而无法即时发送回执(群聊发送方气泡的已读数量因此不更新);
|
|
688
|
+
* 点击会话进入后统一批量补发,使发送方能及时看到已读状态/人数。
|
|
689
|
+
* 已发送过的消息经 sentReadReceiptIds 去重,不会重复请求;
|
|
690
|
+
* 失败仅 warn 不阻塞进入会话(先标记后发送,失败回滚以便下次重试)。
|
|
691
|
+
*/
|
|
692
|
+
async sendPendingReadReceipts(e, t) {
|
|
693
|
+
const o = this.store.getMessages(e).filter((a) => !a.isSelf && !B.has(a.msgServerId)).map((a) => a.msgServerId).filter((a) => !!a);
|
|
694
|
+
if (o.length !== 0) {
|
|
695
|
+
D.info("[MessageDomain.sendPendingReadReceipts] 补发已读回执", { conversationId: e, conversationType: t, pendingCount: o.length, messageIds: o.slice(0, 5) });
|
|
696
|
+
for (const a of o)
|
|
697
|
+
B.add(a);
|
|
698
|
+
try {
|
|
699
|
+
await this.markMessagesRead(e, t, o);
|
|
700
|
+
} catch (a) {
|
|
701
|
+
for (const r of o)
|
|
702
|
+
B.delete(r);
|
|
703
|
+
D.warn("[MessageDomain.sendPendingReadReceipts] failed:", e, E(a));
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
/** 置顶消息 */
|
|
708
|
+
async pinMessage(e, t, n) {
|
|
709
|
+
await this.client.chatManager.pinMessage({ conversationId: e, conversationType: t, messageId: n });
|
|
710
|
+
}
|
|
711
|
+
/** 取消置顶 */
|
|
712
|
+
async unpinMessage(e, t, n) {
|
|
713
|
+
await this.client.chatManager.unpinMessage({ conversationId: e, conversationType: t, messageId: n });
|
|
714
|
+
}
|
|
715
|
+
/** 获取会话内置顶消息列表(最多 20 条) */
|
|
716
|
+
async getPinnedMessages(e, t) {
|
|
717
|
+
const o = (await this.client.chatManager.getPinnedMessageList({
|
|
718
|
+
conversationId: e,
|
|
719
|
+
conversationType: t
|
|
720
|
+
})).items.map((a) => x(a.message, this.currentUserId));
|
|
721
|
+
return this.store.setPinnedMessages(e, o), o;
|
|
722
|
+
}
|
|
723
|
+
/** 翻译文本消息 */
|
|
724
|
+
async translateMessage(e, t) {
|
|
725
|
+
try {
|
|
726
|
+
return await this.client.chatManager.translateMessage({
|
|
727
|
+
message: e,
|
|
728
|
+
targetLanguages: t
|
|
729
|
+
});
|
|
730
|
+
} catch (n) {
|
|
731
|
+
throw D.error("[MessageDomain.translateMessage] raw SDK error:", E(n)), n;
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
/** 语音消息转文字 */
|
|
735
|
+
async transcribeVoiceMessage(e, t) {
|
|
736
|
+
if (!Pe(e.body))
|
|
737
|
+
throw D.warn("[MessageDomain.transcribeVoiceMessage] not a voice message:", e), new Error("not a voice message");
|
|
738
|
+
const n = {
|
|
739
|
+
...e.body,
|
|
740
|
+
type: S.VOICE
|
|
741
|
+
};
|
|
742
|
+
return D.info("voiceMessageToText raw input:", { message: e, body: n, voiceParams: t }), await this.client.chatManager.voiceMessageToText(n, t);
|
|
743
|
+
}
|
|
744
|
+
/** 下载并解析合并消息 */
|
|
745
|
+
async downloadAndParseCombineMessage(e) {
|
|
746
|
+
return this.client.chatManager.downloadAndParseCombineMessage({ message: e });
|
|
747
|
+
}
|
|
748
|
+
/** 下载并解析合并消息(兼容旧名) */
|
|
749
|
+
async downloadCombineMessage(e) {
|
|
750
|
+
return this.downloadAndParseCombineMessage(e);
|
|
751
|
+
}
|
|
752
|
+
/** 获取群消息已读用户列表 */
|
|
753
|
+
async getGroupMessageReadUsers(e, t, n, o = 20) {
|
|
754
|
+
return this.client.chatManager.getGroupMessageReadUsers({
|
|
755
|
+
groupId: e,
|
|
756
|
+
messageId: t,
|
|
757
|
+
cursor: n,
|
|
758
|
+
pageSize: o
|
|
759
|
+
});
|
|
760
|
+
}
|
|
761
|
+
get currentUserId() {
|
|
762
|
+
return this.client.currentUserId || "";
|
|
763
|
+
}
|
|
764
|
+
/** 发送单条消息已读回执 */
|
|
765
|
+
async markRead(e, t, n) {
|
|
766
|
+
D.info("[MessageDomain.markRead] 发送单条已读回执", { conversationId: e, conversationType: t, messageId: n });
|
|
767
|
+
try {
|
|
768
|
+
await this.client.chatManager.sendMessageReadReceipts({
|
|
769
|
+
conversationId: e,
|
|
770
|
+
conversationType: t,
|
|
771
|
+
messageIds: [n]
|
|
772
|
+
}), D.info("[MessageDomain.markRead] 已读回执发送成功", { conversationId: e, conversationType: t, messageId: n });
|
|
773
|
+
} catch (o) {
|
|
774
|
+
throw D.warn("[MessageDomain.markRead] 已读回执发送失败", { conversationId: e, conversationType: t, messageId: n, error: E(o) }), o;
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
/** 获取群消息已读详情(自动翻页聚合全部已读成员) */
|
|
778
|
+
async fetchGroupReadDetail(e, t, n = 100) {
|
|
779
|
+
let o;
|
|
780
|
+
const a = [];
|
|
781
|
+
let r = 0;
|
|
782
|
+
do {
|
|
783
|
+
const i = await this.client.chatManager.getGroupMessageReadUsers({
|
|
784
|
+
groupId: e,
|
|
785
|
+
messageId: t,
|
|
786
|
+
cursor: o,
|
|
787
|
+
pageSize: n
|
|
788
|
+
});
|
|
789
|
+
a.push(...i.users.map((u) => ({ userId: u.userId, timestamp: u.timestamp }))), r = i.count, o = i.cursor || void 0;
|
|
790
|
+
} while (o);
|
|
791
|
+
return {
|
|
792
|
+
groupId: e,
|
|
793
|
+
messageId: t,
|
|
794
|
+
users: a,
|
|
795
|
+
count: r
|
|
796
|
+
};
|
|
797
|
+
}
|
|
798
|
+
/** 修改文本消息 */
|
|
799
|
+
async modifyText(e, t, n, o) {
|
|
800
|
+
await this.client.chatManager.modifyMessage({
|
|
801
|
+
conversationId: e,
|
|
802
|
+
conversationType: t,
|
|
803
|
+
messageId: n,
|
|
804
|
+
message: {
|
|
805
|
+
type: S.TEXT,
|
|
806
|
+
body: { content: o },
|
|
807
|
+
ext: {}
|
|
808
|
+
}
|
|
809
|
+
});
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
function Nt(s, e) {
|
|
813
|
+
var d, g, f, c, l, m;
|
|
814
|
+
const t = yt(s.lastMessage), n = A(((d = s.lastMessage) == null ? void 0 : d.from) || ""), o = A(((f = (g = s.lastMessage) == null ? void 0 : g.sender) == null ? void 0 : f.userId) || ""), a = o || n, r = a ? (c = e == null ? void 0 : e.resolveSenderName) == null ? void 0 : c.call(e, a) : void 0, i = ((m = (l = s.lastMessage) == null ? void 0 : l.sender) == null ? void 0 : m.nickname) || r || o || n || "", u = Be(s.conversationType, i, t);
|
|
815
|
+
return {
|
|
816
|
+
id: s.conversationId,
|
|
817
|
+
name: s.conversationName || s.conversationId,
|
|
818
|
+
avatar: s.conversationAvatar,
|
|
819
|
+
type: s.conversationType === M.GROUPCHAT ? M.GROUPCHAT : M.SINGLECHAT,
|
|
820
|
+
unreadCount: s.unreadCount || 0,
|
|
821
|
+
lastMessageText: u,
|
|
822
|
+
// 保留群聊最后一条消息发送者 userId,供会话列表项在资料异步就绪后重新解析昵称
|
|
823
|
+
lastMessageFrom: a || void 0,
|
|
824
|
+
lastMessageTime: s.lastMessageAt,
|
|
825
|
+
isPinned: s.isPinned ?? !1,
|
|
826
|
+
pinnedTime: s.pinnedTimestamp,
|
|
827
|
+
isMuted: s.remindType === "NONE",
|
|
828
|
+
marks: [...s.marks || []],
|
|
829
|
+
remindType: s.remindType
|
|
830
|
+
};
|
|
831
|
+
}
|
|
832
|
+
function ae(s, e) {
|
|
833
|
+
return s.map((t) => Nt(t, e));
|
|
834
|
+
}
|
|
835
|
+
const be = R("Conversation");
|
|
836
|
+
function kt(s) {
|
|
837
|
+
return [...s].sort((e, t) => e.isPinned !== t.isPinned ? e.isPinned ? -1 : 1 : e.isPinned ? (t.pinnedTime ?? 0) - (e.pinnedTime ?? 0) : (t.lastMessageTime ?? 0) - (e.lastMessageTime ?? 0));
|
|
838
|
+
}
|
|
839
|
+
function xt(s, e) {
|
|
840
|
+
var o;
|
|
841
|
+
const t = {}, n = [];
|
|
842
|
+
for (const a of s) {
|
|
843
|
+
const r = String(((o = a.lastMessage) == null ? void 0 : o.type) ?? "(null)");
|
|
844
|
+
t[r] = (t[r] ?? 0) + 1, (r === S.COMBINE || r === "unknown") && n.push({
|
|
845
|
+
conversationId: a.conversationId,
|
|
846
|
+
lastMessage: a.lastMessage
|
|
847
|
+
});
|
|
848
|
+
}
|
|
849
|
+
n.length > 0 && be.info(`raw snippets (${e})`, { typeCount: t, suspects: n });
|
|
850
|
+
}
|
|
851
|
+
const Ot = 1e3;
|
|
852
|
+
class Pt {
|
|
853
|
+
constructor(e, t, n = {}) {
|
|
854
|
+
this.client = e, this.store = t, this.hooks = n, this.channelAckSentAt = /* @__PURE__ */ new Map();
|
|
855
|
+
}
|
|
856
|
+
/** 进入某个会话:通知 SDK 当前正在浏览该会话 */
|
|
857
|
+
enter(e, t) {
|
|
858
|
+
var n, o;
|
|
859
|
+
this.client.chatManager.setCurrentConversation({ conversationId: e, conversationType: t }), this.store.setCurrentConversationId(e), (o = (n = this.hooks).sendPendingReadReceipts) == null || o.call(n, e, t);
|
|
860
|
+
}
|
|
861
|
+
/** 离开当前会话 */
|
|
862
|
+
leave() {
|
|
863
|
+
this.client.chatManager.resetCurrentConversation(), this.store.setCurrentConversationId(null);
|
|
864
|
+
}
|
|
865
|
+
/** 从本地缓存读取会话列表 */
|
|
866
|
+
syncLocal() {
|
|
867
|
+
const e = this.client.chatManager.getConversationList();
|
|
868
|
+
be.info("getConversationList raw (syncLocal)", e), xt(e, "syncLocal");
|
|
869
|
+
const t = ae(e, { resolveSenderName: this.hooks.resolveSenderName });
|
|
870
|
+
return this.store.setList(t), t;
|
|
871
|
+
}
|
|
872
|
+
/**
|
|
873
|
+
* 主动刷新服务端会话列表,由 onConversationListUpdate 事件回填 store。
|
|
874
|
+
* 数据入口接管(Phase 3.1):注入 fetchConversations 时改走注入实现
|
|
875
|
+
* (游标翻页至 hasMore=false 合并全量后直接 setList,不触 SDK 也无事件回填)。
|
|
876
|
+
*/
|
|
877
|
+
async refresh(e = !1) {
|
|
878
|
+
var n;
|
|
879
|
+
const t = (n = this.hooks.conversationRepository) == null ? void 0 : n.fetchConversations;
|
|
880
|
+
if (t) {
|
|
881
|
+
const o = [];
|
|
882
|
+
let a;
|
|
883
|
+
do {
|
|
884
|
+
const d = await t(a, 50);
|
|
885
|
+
o.push(...d.list), a = d.hasMore ? d.cursor : void 0;
|
|
886
|
+
} while (a);
|
|
887
|
+
const r = this.store.conversationList ?? [], i = new Map(r.map((d) => [d.id, d])), u = /* @__PURE__ */ new Map();
|
|
888
|
+
for (const d of o) {
|
|
889
|
+
const g = i.get(d.id);
|
|
890
|
+
u.set(d.id, g ? {
|
|
891
|
+
...d,
|
|
892
|
+
name: (!d.name || d.name === d.id) && g.name && g.name !== g.id ? g.name : d.name,
|
|
893
|
+
avatar: d.avatar || g.avatar
|
|
894
|
+
} : d);
|
|
895
|
+
}
|
|
896
|
+
this.store.setList(kt(Array.from(u.values())));
|
|
897
|
+
return;
|
|
898
|
+
}
|
|
899
|
+
await this.client.chatManager.refreshSessionList({ includeEmpty: e });
|
|
900
|
+
}
|
|
901
|
+
/** 删除会话(默认同时删除漫游消息;SDK 0.14.227 成功后总会清理本地会话缓存) */
|
|
902
|
+
async remove(e, t, n = !0) {
|
|
903
|
+
await this.client.chatManager.deleteConversation({
|
|
904
|
+
conversationId: e,
|
|
905
|
+
conversationType: t,
|
|
906
|
+
deleteRoamingMessages: n
|
|
907
|
+
});
|
|
908
|
+
}
|
|
909
|
+
/** 删除会话但保留漫游消息(SDK 已无仅本地删除 API,用 deleteRoamingMessages=false 代替) */
|
|
910
|
+
async removeLocal(e, t) {
|
|
911
|
+
await this.client.chatManager.deleteConversation({
|
|
912
|
+
conversationId: e,
|
|
913
|
+
conversationType: t,
|
|
914
|
+
deleteRoamingMessages: !1
|
|
915
|
+
}), this.store.delete(e);
|
|
916
|
+
}
|
|
917
|
+
/** 置顶/取消置顶会话 */
|
|
918
|
+
async pin(e, t, n) {
|
|
919
|
+
await this.client.chatManager.setConversationPinned({
|
|
920
|
+
conversationId: e,
|
|
921
|
+
conversationType: t,
|
|
922
|
+
pinned: n
|
|
923
|
+
});
|
|
924
|
+
}
|
|
925
|
+
/**
|
|
926
|
+
* 设置/取消会话免打扰。
|
|
927
|
+
* - 免打扰:PushManager.setConversationSilentMode,规则为 remindType=NONE(不提醒);
|
|
928
|
+
* - 取消:clearConversationRemindType 恢复默认提醒。
|
|
929
|
+
* 成功后立即更新本地 store(多端同步事件不保证回推到本端),
|
|
930
|
+
* 若服务端随后下发 CONVERSATION_MUTE_INFO_CHANGED 事件,更新是幂等的。
|
|
931
|
+
*/
|
|
932
|
+
async setMuted(e, t, n) {
|
|
933
|
+
n ? await this.client.pushManager.setConversationSilentMode({
|
|
934
|
+
conversationId: e,
|
|
935
|
+
conversationType: t,
|
|
936
|
+
rule: { mode: "REMIND_TYPE", remindType: "NONE" }
|
|
937
|
+
}) : await this.client.pushManager.clearConversationRemindType({
|
|
938
|
+
conversationId: e,
|
|
939
|
+
conversationType: t
|
|
940
|
+
}), this.store.update(e, {
|
|
941
|
+
isMuted: n,
|
|
942
|
+
remindType: n ? "NONE" : "DEFAULT"
|
|
943
|
+
});
|
|
944
|
+
}
|
|
945
|
+
/** 清空会话未读数(协议仅同步自己多设备,不再发送给对方) */
|
|
946
|
+
async markRead(e, t) {
|
|
947
|
+
await this.client.chatManager.clearConversationUnreadMessageCount({
|
|
948
|
+
conversationId: e,
|
|
949
|
+
conversationType: t
|
|
950
|
+
});
|
|
951
|
+
}
|
|
952
|
+
/**
|
|
953
|
+
* 清空聊天记录(只清消息,不删除会话)。
|
|
954
|
+
* - deleteRoamingMessages=true:同时删除服务端漫游历史消息
|
|
955
|
+
* (SDK removeHistoryMessages 按 beforeTimestamp 清空当前时间之前的全部历史);
|
|
956
|
+
* - deleteRoamingMessages=false:仅由调用方清理本地消息缓存。
|
|
957
|
+
* 注意:不要使用 deleteConversation 实现"清空聊天记录",否则整个会话会从列表消失。
|
|
958
|
+
*/
|
|
959
|
+
async clearChatHistory(e, t, n = !1) {
|
|
960
|
+
n && await this.client.chatManager.removeHistoryMessages({
|
|
961
|
+
conversationId: e,
|
|
962
|
+
conversationType: t,
|
|
963
|
+
beforeTimestamp: Date.now()
|
|
964
|
+
});
|
|
965
|
+
}
|
|
966
|
+
/** 添加会话标记 */
|
|
967
|
+
async addMark(e, t) {
|
|
968
|
+
await this.client.chatManager.addConversationMark({
|
|
969
|
+
conversations: e,
|
|
970
|
+
mark: t
|
|
971
|
+
});
|
|
972
|
+
}
|
|
973
|
+
/** 移除会话标记 */
|
|
974
|
+
async removeMark(e, t) {
|
|
975
|
+
await this.client.chatManager.removeConversationMark({
|
|
976
|
+
conversations: e,
|
|
977
|
+
mark: t
|
|
978
|
+
});
|
|
979
|
+
}
|
|
980
|
+
/** 发送 channel ack */
|
|
981
|
+
async sendChannelAck(e, t) {
|
|
982
|
+
var r, i;
|
|
983
|
+
const n = (i = (r = this.store.conversationList) == null ? void 0 : r.find((u) => u.id === e)) == null ? void 0 : i.unreadCount;
|
|
984
|
+
if (n !== void 0 && n <= 0)
|
|
985
|
+
return;
|
|
986
|
+
const o = Date.now(), a = this.channelAckSentAt.get(e) || 0;
|
|
987
|
+
o - a < Ot || (this.channelAckSentAt.set(e, o), await this.markRead(e, t));
|
|
988
|
+
}
|
|
989
|
+
/** 加载更多会话:SDK5 当前无分页游标,直接返回本地列表 */
|
|
990
|
+
async loadMore(e) {
|
|
991
|
+
const t = this.client.chatManager.getConversationList();
|
|
992
|
+
be.info("getConversationList raw (loadMore)", t);
|
|
993
|
+
const n = ae(t, { resolveSenderName: this.hooks.resolveSenderName });
|
|
994
|
+
this.store.setList(n);
|
|
995
|
+
}
|
|
996
|
+
}
|
|
997
|
+
function Ft(s) {
|
|
998
|
+
if ("userId" in s && s.userId !== void 0) {
|
|
999
|
+
const t = s;
|
|
1000
|
+
return {
|
|
1001
|
+
userId: t.userId,
|
|
1002
|
+
name: t.remark || t.userId,
|
|
1003
|
+
remark: t.remark
|
|
1004
|
+
};
|
|
1005
|
+
}
|
|
1006
|
+
const e = s;
|
|
1007
|
+
return {
|
|
1008
|
+
userId: e.userId,
|
|
1009
|
+
name: e.nickname || e.userId,
|
|
1010
|
+
avatar: e.avatarUrl,
|
|
1011
|
+
remark: e.nickname,
|
|
1012
|
+
signature: e.sign,
|
|
1013
|
+
gender: e.gender != null ? String(e.gender) : void 0,
|
|
1014
|
+
birth: e.birth,
|
|
1015
|
+
phone: e.phone,
|
|
1016
|
+
mail: e.mail,
|
|
1017
|
+
ext: Bt(e.ext)
|
|
1018
|
+
};
|
|
1019
|
+
}
|
|
1020
|
+
function Bt(s) {
|
|
1021
|
+
if (s)
|
|
1022
|
+
try {
|
|
1023
|
+
const e = JSON.parse(s);
|
|
1024
|
+
return e && typeof e == "object" ? e : void 0;
|
|
1025
|
+
} catch {
|
|
1026
|
+
return;
|
|
1027
|
+
}
|
|
1028
|
+
}
|
|
1029
|
+
function we(s) {
|
|
1030
|
+
return s.map((e) => Ft(e));
|
|
1031
|
+
}
|
|
1032
|
+
class Ht {
|
|
1033
|
+
constructor(e, t, n = {}) {
|
|
1034
|
+
this.client = e, this.store = t, this.options = n;
|
|
1035
|
+
}
|
|
1036
|
+
/** 获取当前内存中的联系人列表 */
|
|
1037
|
+
syncLocal() {
|
|
1038
|
+
const e = this.client.contactManager.getContacts(), t = we(e);
|
|
1039
|
+
return this.store.setList(t), t;
|
|
1040
|
+
}
|
|
1041
|
+
/**
|
|
1042
|
+
* 分页拉取联系人列表(数据入口读路径)。
|
|
1043
|
+
* 注入 fetchContacts 时委托注入实现,store 写入由消费方(UI 层)按分页语义负责;
|
|
1044
|
+
* 未注入时回落 SDK 本地全量(syncLocal 内部写 store,无游标分页)。
|
|
1045
|
+
*/
|
|
1046
|
+
async fetchContacts(e, t) {
|
|
1047
|
+
var o;
|
|
1048
|
+
const n = (o = this.options.contactRepository) == null ? void 0 : o.fetchContacts;
|
|
1049
|
+
return n ? n(e, t) : { list: this.syncLocal(), cursor: void 0, hasMore: !1 };
|
|
1050
|
+
}
|
|
1051
|
+
/**
|
|
1052
|
+
* 只读:获取当前本地联系人数量(不写 store、不锁定 loaded)。
|
|
1053
|
+
* 供「轻量计数」场景使用,避免在 roster 同步完成前抢跑锁定 loaded
|
|
1054
|
+
* 导致 onSyncDataFinished 的回填被跳过(列表永久为空)。
|
|
1055
|
+
*/
|
|
1056
|
+
getLocalCount() {
|
|
1057
|
+
return this.client.contactManager.getContacts().length;
|
|
1058
|
+
}
|
|
1059
|
+
/** 添加好友(注入 addContact 时委托业务接管——业务可先登记自有系统再决定是否调 SDK) */
|
|
1060
|
+
async addContact(e, t) {
|
|
1061
|
+
var o;
|
|
1062
|
+
const n = (o = this.options.contactRepository) == null ? void 0 : o.addContact;
|
|
1063
|
+
if (n)
|
|
1064
|
+
return n(e, t);
|
|
1065
|
+
await this.client.contactManager.addContact({
|
|
1066
|
+
userId: e,
|
|
1067
|
+
message: t || ""
|
|
1068
|
+
});
|
|
1069
|
+
}
|
|
1070
|
+
/** 删除好友 */
|
|
1071
|
+
async deleteContact(e) {
|
|
1072
|
+
await this.client.contactManager.deleteContact({ userId: e });
|
|
1073
|
+
}
|
|
1074
|
+
/** 设置好友备注 */
|
|
1075
|
+
async setRemark(e, t) {
|
|
1076
|
+
await this.client.contactManager.setContactRemark({ userId: e, remark: t }), this.store.updateRemark(e, t);
|
|
1077
|
+
}
|
|
1078
|
+
/** 接受好友申请 */
|
|
1079
|
+
async acceptInvite(e) {
|
|
1080
|
+
await this.client.contactManager.acceptContactInvite({ userId: e }), this.store.removeInvite(e);
|
|
1081
|
+
}
|
|
1082
|
+
/** 拒绝好友申请 */
|
|
1083
|
+
async declineInvite(e) {
|
|
1084
|
+
await this.client.contactManager.declineContactInvite({ userId: e }), this.store.removeInvite(e);
|
|
1085
|
+
}
|
|
1086
|
+
/** 获取黑名单(注入 fetchBlocklist 时委托注入实现,结果仍写 store) */
|
|
1087
|
+
async syncBlocklist() {
|
|
1088
|
+
var o;
|
|
1089
|
+
const e = (o = this.options.contactRepository) == null ? void 0 : o.fetchBlocklist;
|
|
1090
|
+
if (e) {
|
|
1091
|
+
const a = await e();
|
|
1092
|
+
return this.store.setBlocklist(a), a;
|
|
1093
|
+
}
|
|
1094
|
+
const t = await this.client.contactManager.getBlocklist(), n = we(t);
|
|
1095
|
+
return this.store.setBlocklist(n), n;
|
|
1096
|
+
}
|
|
1097
|
+
/** 批量加入黑名单 */
|
|
1098
|
+
async addToBlocklist(e) {
|
|
1099
|
+
await this.client.contactManager.addUsersToBlocklist({ userIds: e });
|
|
1100
|
+
}
|
|
1101
|
+
/** 批量移出黑名单 */
|
|
1102
|
+
async removeFromBlocklist(e) {
|
|
1103
|
+
await this.client.contactManager.removeUserFromBlocklist({ userIds: e });
|
|
1104
|
+
}
|
|
1105
|
+
}
|
|
1106
|
+
function Ke(s) {
|
|
1107
|
+
const e = {
|
|
1108
|
+
groupId: s.groupId,
|
|
1109
|
+
groupName: s.name,
|
|
1110
|
+
description: s.description,
|
|
1111
|
+
memberCount: s.memberCount,
|
|
1112
|
+
public: s.public,
|
|
1113
|
+
allowInvites: s.allowInvites,
|
|
1114
|
+
approval: s.joinApprovalRequired,
|
|
1115
|
+
disabled: s.disabled,
|
|
1116
|
+
maxUsers: s.maxMembers
|
|
1117
|
+
};
|
|
1118
|
+
return s.role && (e.role = s.role), "avatarUrl" in s && (e.avatar = s.avatarUrl), "muteAllMembers" in s && (e.mute = s.muteAllMembers), "ownerId" in s && (e.owner = s.ownerId), "owner" in s && s.owner && (e.owner = s.owner.userId), "createdAt" in s && (e.created = s.createdAt), "messageBlocked" in s && (e.shieldgroup = s.messageBlocked), e;
|
|
1119
|
+
}
|
|
1120
|
+
function ce(s) {
|
|
1121
|
+
return s.map((e) => Ke(e));
|
|
1122
|
+
}
|
|
1123
|
+
function Kt(s) {
|
|
1124
|
+
const e = s.user, t = {
|
|
1125
|
+
userId: e.userId,
|
|
1126
|
+
nickname: e.nickname,
|
|
1127
|
+
avatarUrl: e.avatarUrl,
|
|
1128
|
+
role: "role" in s ? s.role : void 0
|
|
1129
|
+
};
|
|
1130
|
+
return "joinedAt" in s && (t.joinedAt = s.joinedAt), "muteExpire" in s && s.muteExpire !== void 0 && (t.muteExpire = s.muteExpire), "muteDuration" in s && s.muteDuration !== void 0 && (t.muteDuration = s.muteDuration), t;
|
|
1131
|
+
}
|
|
1132
|
+
function J(s) {
|
|
1133
|
+
return s.map((e) => Kt(e));
|
|
1134
|
+
}
|
|
1135
|
+
const Y = R("UIKit:GroupDomain"), me = /* @__PURE__ */ new Map(), fe = /* @__PURE__ */ new Map(), pe = /* @__PURE__ */ new Map();
|
|
1136
|
+
class jt {
|
|
1137
|
+
constructor(e, t, n = {}) {
|
|
1138
|
+
this.client = e, this.store = t, this.options = n;
|
|
1139
|
+
}
|
|
1140
|
+
/** 获取已加入群组本地列表 */
|
|
1141
|
+
syncLocal() {
|
|
1142
|
+
const e = this.client.groupManager.getJoinedGroupList(), t = ce(e);
|
|
1143
|
+
return this.store.setList(t), t;
|
|
1144
|
+
}
|
|
1145
|
+
/**
|
|
1146
|
+
* 分页拉取已加入群组列表(数据入口读路径)。
|
|
1147
|
+
* 注入 fetchGroups 时委托注入实现,store 写入由消费方(UI 层)按分页语义负责;
|
|
1148
|
+
* 未注入时回落 SDK 本地全量(syncLocal 内部写 store,SDK 无游标分页)。
|
|
1149
|
+
*/
|
|
1150
|
+
async fetchGroups(e, t) {
|
|
1151
|
+
var o;
|
|
1152
|
+
const n = (o = this.options.groupRepository) == null ? void 0 : o.fetchGroups;
|
|
1153
|
+
return n ? n(e, t) : { list: this.syncLocal(), cursor: void 0, hasMore: !1 };
|
|
1154
|
+
}
|
|
1155
|
+
/**
|
|
1156
|
+
* 只读:获取当前本地已加入群组数量(不写 store、不锁定 loaded)。
|
|
1157
|
+
* 供「轻量计数」场景使用,避免在群组同步完成前抢跑锁定 loaded
|
|
1158
|
+
* 导致 onSyncDataFinished 的回填被跳过(群组列表永久为空)。
|
|
1159
|
+
*/
|
|
1160
|
+
getLocalCount() {
|
|
1161
|
+
return this.client.groupManager.getJoinedGroupList().length;
|
|
1162
|
+
}
|
|
1163
|
+
/** 获取单个群详情 */
|
|
1164
|
+
async fetchGroupInfo(e) {
|
|
1165
|
+
const t = me.get(e);
|
|
1166
|
+
if (t)
|
|
1167
|
+
return t;
|
|
1168
|
+
const n = (async () => {
|
|
1169
|
+
const o = await this.client.groupManager.getGroupInfo({ groupId: e }), a = Ke(o);
|
|
1170
|
+
return this.store.updateGroup(e, a), a;
|
|
1171
|
+
})();
|
|
1172
|
+
me.set(e, n);
|
|
1173
|
+
try {
|
|
1174
|
+
return await n;
|
|
1175
|
+
} finally {
|
|
1176
|
+
me.delete(e);
|
|
1177
|
+
}
|
|
1178
|
+
}
|
|
1179
|
+
/** 批量获取群详情 */
|
|
1180
|
+
async fetchGroupInfoList(e) {
|
|
1181
|
+
const t = await this.client.groupManager.getGroupInfoList({ groupIds: e }), n = ce(t);
|
|
1182
|
+
return n.forEach((o) => this.store.updateGroup(o.groupId, o)), n;
|
|
1183
|
+
}
|
|
1184
|
+
/** 创建群组(注入 createGroup 时整体委托业务接管:不调 SDK、不写本地缓存,权威数据由业务源负责) */
|
|
1185
|
+
async createGroup(e) {
|
|
1186
|
+
var o, a, r;
|
|
1187
|
+
const t = (o = this.options.groupRepository) == null ? void 0 : o.createGroup;
|
|
1188
|
+
if (t)
|
|
1189
|
+
return t(e);
|
|
1190
|
+
const n = await this.client.groupManager.createGroup({
|
|
1191
|
+
name: e.name,
|
|
1192
|
+
description: e.description ?? "",
|
|
1193
|
+
memberIds: e.memberIds,
|
|
1194
|
+
public: e.public ?? !1,
|
|
1195
|
+
joinApprovalRequired: e.joinApprovalRequired ?? !1,
|
|
1196
|
+
allowInvites: e.allowInvites ?? !1,
|
|
1197
|
+
inviteNeedConfirm: e.inviteNeedConfirm ?? !1,
|
|
1198
|
+
maxMembers: e.maxMembers
|
|
1199
|
+
});
|
|
1200
|
+
this.store.addGroup({
|
|
1201
|
+
groupId: n.groupId,
|
|
1202
|
+
groupName: e.name,
|
|
1203
|
+
description: e.description,
|
|
1204
|
+
role: _.OWNER,
|
|
1205
|
+
memberCount: (((a = e.memberIds) == null ? void 0 : a.length) ?? 0) + 1,
|
|
1206
|
+
maxUsers: e.maxMembers,
|
|
1207
|
+
public: e.public ?? !1,
|
|
1208
|
+
allowInvites: e.allowInvites ?? !1,
|
|
1209
|
+
approval: e.joinApprovalRequired ?? !1
|
|
1210
|
+
});
|
|
1211
|
+
try {
|
|
1212
|
+
await this.fetchGroupInfo(n.groupId);
|
|
1213
|
+
const i = (((r = e.memberIds) == null ? void 0 : r.length) ?? 0) + 1, u = this.store.getGroupById(n.groupId);
|
|
1214
|
+
u && (u.memberCount ?? 0) !== i && this.store.updateGroup(n.groupId, { memberCount: i });
|
|
1215
|
+
} catch {
|
|
1216
|
+
}
|
|
1217
|
+
return n;
|
|
1218
|
+
}
|
|
1219
|
+
/** 加入群组 */
|
|
1220
|
+
async joinGroup(e, t) {
|
|
1221
|
+
await this.client.groupManager.joinGroup({ groupId: e, message: t });
|
|
1222
|
+
}
|
|
1223
|
+
/** 离开群组 */
|
|
1224
|
+
async leaveGroup(e) {
|
|
1225
|
+
await this.client.groupManager.leaveGroup({ groupId: e });
|
|
1226
|
+
}
|
|
1227
|
+
/** 解散群组 */
|
|
1228
|
+
async destroyGroup(e) {
|
|
1229
|
+
await this.client.groupManager.destroyGroup({ groupId: e });
|
|
1230
|
+
}
|
|
1231
|
+
/** 拉取群成员列表 */
|
|
1232
|
+
async fetchGroupMembers(e, t, n = 20) {
|
|
1233
|
+
const o = await this.client.groupManager.getGroupMemberList({ groupId: e, cursor: t, pageSize: n }), a = J(o.items);
|
|
1234
|
+
if (t)
|
|
1235
|
+
this.store.appendGroupMembers(e, a);
|
|
1236
|
+
else {
|
|
1237
|
+
this.store.setGroupMembers(e, a);
|
|
1238
|
+
try {
|
|
1239
|
+
await this.syncGroupAdmins(e);
|
|
1240
|
+
} catch {
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1243
|
+
return { list: a, cursor: o.cursor, hasMore: o.hasMore ?? !1 };
|
|
1244
|
+
}
|
|
1245
|
+
/** 拉取并合并群管理员到成员缓存 */
|
|
1246
|
+
async syncGroupAdmins(e) {
|
|
1247
|
+
var o, a;
|
|
1248
|
+
const t = fe.get(e);
|
|
1249
|
+
if (t)
|
|
1250
|
+
return t;
|
|
1251
|
+
if ((a = (o = this.store).isGroupAdminSynced) != null && a.call(o, e))
|
|
1252
|
+
return;
|
|
1253
|
+
const n = (async () => {
|
|
1254
|
+
var u, d;
|
|
1255
|
+
const r = await this.client.groupManager.getGroup(e).getAdmins(), i = J(
|
|
1256
|
+
(r || []).map((g) => ({ user: g, role: _.ADMIN }))
|
|
1257
|
+
);
|
|
1258
|
+
this.store.appendGroupMembers(e, i);
|
|
1259
|
+
for (const g of i)
|
|
1260
|
+
this.store.updateGroupMemberRole(e, g.userId, _.ADMIN);
|
|
1261
|
+
(d = (u = this.store).markGroupAdminSynced) == null || d.call(u, e);
|
|
1262
|
+
})();
|
|
1263
|
+
fe.set(e, n);
|
|
1264
|
+
try {
|
|
1265
|
+
return await n;
|
|
1266
|
+
} finally {
|
|
1267
|
+
fe.delete(e);
|
|
1268
|
+
}
|
|
1269
|
+
}
|
|
1270
|
+
/** 拉取群公告 */
|
|
1271
|
+
async fetchGroupAnnouncement(e) {
|
|
1272
|
+
const t = pe.get(e);
|
|
1273
|
+
if (t)
|
|
1274
|
+
return t;
|
|
1275
|
+
const n = (async () => {
|
|
1276
|
+
const a = (await this.client.groupManager.getGroupAnnouncement({ groupId: e })).announcement ?? "";
|
|
1277
|
+
return this.store.setGroupAnnouncement(e, a), a;
|
|
1278
|
+
})();
|
|
1279
|
+
pe.set(e, n);
|
|
1280
|
+
try {
|
|
1281
|
+
return await n;
|
|
1282
|
+
} finally {
|
|
1283
|
+
pe.delete(e);
|
|
1284
|
+
}
|
|
1285
|
+
}
|
|
1286
|
+
/** 更新群公告 */
|
|
1287
|
+
async updateGroupAnnouncement(e, t) {
|
|
1288
|
+
await this.client.groupManager.updateGroupAnnouncement({ groupId: e, announcement: t }), this.store.setGroupAnnouncement(e, t);
|
|
1289
|
+
}
|
|
1290
|
+
/** 转让群主 */
|
|
1291
|
+
async changeGroupOwner(e, t) {
|
|
1292
|
+
await this.client.groupManager.changeGroupOwner({ groupId: e, newOwner: t });
|
|
1293
|
+
}
|
|
1294
|
+
/** 移除群成员 */
|
|
1295
|
+
async removeGroupMembers(e, t) {
|
|
1296
|
+
await this.client.groupManager.removeGroupMembers({ groupId: e, userIds: t }), this.store.removeGroupMembers(e, t);
|
|
1297
|
+
}
|
|
1298
|
+
/** 邀请用户入群 */
|
|
1299
|
+
async inviteUsersToGroup(e, t) {
|
|
1300
|
+
await this.client.groupManager.inviteUsersToGroup({ groupId: e, userIds: t });
|
|
1301
|
+
}
|
|
1302
|
+
/** 设置群管理员 */
|
|
1303
|
+
async addGroupAdmin(e, t) {
|
|
1304
|
+
await this.client.groupManager.addGroupAdmin({ groupId: e, userId: t }), this.store.updateGroupMemberRole(e, t, _.ADMIN);
|
|
1305
|
+
}
|
|
1306
|
+
/** 取消群管理员 */
|
|
1307
|
+
async removeGroupAdmin(e, t) {
|
|
1308
|
+
await this.client.groupManager.removeGroupAdmin({ groupId: e, userId: t }), this.store.updateGroupMemberRole(e, t, _.MEMBER);
|
|
1309
|
+
}
|
|
1310
|
+
/** 接受群邀请 */
|
|
1311
|
+
async acceptGroupInvitation(e) {
|
|
1312
|
+
await this.client.groupManager.acceptInvitation({ groupId: e });
|
|
1313
|
+
}
|
|
1314
|
+
/** 更新群基础资料(名称/描述/头像/扩展字段) */
|
|
1315
|
+
async updateGroupInfo(e, t) {
|
|
1316
|
+
await this.client.groupManager.getGroup(e).updateInfo(t);
|
|
1317
|
+
const n = {};
|
|
1318
|
+
t.name !== void 0 && (n.groupName = t.name), t.description !== void 0 && (n.description = t.description), t.avatar !== void 0 && (n.avatar = t.avatar), this.store.updateGroup(e, n);
|
|
1319
|
+
}
|
|
1320
|
+
/** 更新群配置(公开/审批/邀请/最大人数等) */
|
|
1321
|
+
async updateGroupConfigs(e, t) {
|
|
1322
|
+
await this.client.groupManager.getGroup(e).updateConfigs(t);
|
|
1323
|
+
const n = {};
|
|
1324
|
+
t.public !== void 0 && (n.public = t.public), t.joinApprovalRequired !== void 0 && (n.approval = t.joinApprovalRequired), t.allowInvites !== void 0 && (n.allowInvites = t.allowInvites), t.maxMembers !== void 0 && (n.maxUsers = t.maxMembers), this.store.updateGroup(e, n);
|
|
1325
|
+
}
|
|
1326
|
+
/** 开启全员禁言 */
|
|
1327
|
+
async muteAllGroupMembers(e) {
|
|
1328
|
+
await this.client.groupManager.getGroup(e).muteAllMembers(), this.store.updateGroup(e, { mute: !0 });
|
|
1329
|
+
}
|
|
1330
|
+
/** 关闭全员禁言 */
|
|
1331
|
+
async unmuteAllGroupMembers(e) {
|
|
1332
|
+
await this.client.groupManager.getGroup(e).unmuteAllMembers(), this.store.updateGroup(e, { mute: !1 });
|
|
1333
|
+
}
|
|
1334
|
+
/**
|
|
1335
|
+
* 禁言指定成员。
|
|
1336
|
+
* @param muteDuration 禁言时长,单位为毫秒;传 -1 表示永久禁言(SDK 5.0.0+ 语义)。
|
|
1337
|
+
*/
|
|
1338
|
+
async muteGroupMembers(e, t, n) {
|
|
1339
|
+
Y.info("muteGroupMembers request raw", { groupId: e, userIds: t, muteDuration: n });
|
|
1340
|
+
const o = await this.client.groupManager.getGroup(e).muteMembers({ userIds: t, muteDuration: n });
|
|
1341
|
+
Y.info("muteGroupMembers response raw", o), this.store.addGroupMuteMembers(e, t);
|
|
1342
|
+
}
|
|
1343
|
+
/** 解除指定成员禁言 */
|
|
1344
|
+
async unmuteGroupMembers(e, t) {
|
|
1345
|
+
Y.info("unmuteGroupMembers request raw", { groupId: e, userIds: t });
|
|
1346
|
+
const n = await this.client.groupManager.getGroup(e).unmuteMembers({ userIds: t });
|
|
1347
|
+
Y.info("unmuteGroupMembers response raw", n), this.store.removeGroupMuteMembers(e, t);
|
|
1348
|
+
}
|
|
1349
|
+
/** 获取群禁言列表 */
|
|
1350
|
+
async getGroupMuteList(e, t, n) {
|
|
1351
|
+
const o = await this.client.groupManager.getGroup(e).getMuteList({ pageNum: t, pageSize: n }), a = Array.isArray(o) ? o : (o == null ? void 0 : o.data) ?? [];
|
|
1352
|
+
return this.store.setGroupMuteList(e, J(a)), o;
|
|
1353
|
+
}
|
|
1354
|
+
/** 获取群黑名单 */
|
|
1355
|
+
async getGroupBlocklist(e, t, n) {
|
|
1356
|
+
const o = await this.client.groupManager.getGroup(e).getBlocklist({ pageNum: t, pageSize: n }), a = Array.isArray(o) ? o : (o == null ? void 0 : o.data) ?? [];
|
|
1357
|
+
return this.store.setGroupBlocklist(e, J(a)), o;
|
|
1358
|
+
}
|
|
1359
|
+
/** 将成员加入群黑名单 */
|
|
1360
|
+
async blockGroupMembers(e, t) {
|
|
1361
|
+
await this.client.groupManager.getGroup(e).blockMembers({ userIds: t }), this.store.addGroupBlocklistMembers(e, t);
|
|
1362
|
+
}
|
|
1363
|
+
/** 将成员移出群黑名单 */
|
|
1364
|
+
async unblockGroupMembers(e, t) {
|
|
1365
|
+
await this.client.groupManager.getGroup(e).unblockMembers({ userIds: t }), this.store.removeGroupBlocklistMembers(e, t);
|
|
1366
|
+
}
|
|
1367
|
+
/** 获取群白名单 */
|
|
1368
|
+
async getGroupAllowlist(e) {
|
|
1369
|
+
const t = await this.client.groupManager.getGroup(e).getAllowlist(), n = Array.isArray(t) ? t : (t == null ? void 0 : t.data) ?? [];
|
|
1370
|
+
return this.store.setGroupAllowlist(e, J(n)), t;
|
|
1371
|
+
}
|
|
1372
|
+
/** 将成员加入群白名单 */
|
|
1373
|
+
async addUsersToGroupAllowlist(e, t) {
|
|
1374
|
+
await this.client.groupManager.getGroup(e).addUsersToAllowlist({ userIds: t });
|
|
1375
|
+
}
|
|
1376
|
+
/** 将成员移出群白名单 */
|
|
1377
|
+
async removeUsersFromGroupAllowlist(e, t) {
|
|
1378
|
+
await this.client.groupManager.getGroup(e).removeUsersFromAllowlist({ userIds: t });
|
|
1379
|
+
}
|
|
1380
|
+
/** 检查当前用户是否在群白名单中 */
|
|
1381
|
+
async checkIfInGroupAllowList(e) {
|
|
1382
|
+
return this.client.groupManager.getGroup(e).checkIfInAllowList();
|
|
1383
|
+
}
|
|
1384
|
+
/** 检查当前用户是否在群禁言列表中 */
|
|
1385
|
+
async checkIfInGroupMuteList(e) {
|
|
1386
|
+
return this.client.groupManager.getGroup(e).checkIfInMuteList();
|
|
1387
|
+
}
|
|
1388
|
+
/** 获取群共享文件列表 */
|
|
1389
|
+
async getGroupSharedFileList(e, t, n) {
|
|
1390
|
+
return await this.client.groupManager.getGroup(e).getSharedFileList({ pageNum: t, pageSize: n });
|
|
1391
|
+
}
|
|
1392
|
+
/** 上传群共享文件 */
|
|
1393
|
+
async uploadGroupSharedFile(e, t) {
|
|
1394
|
+
return new Promise((n, o) => {
|
|
1395
|
+
this.client.groupManager.getGroup(e).uploadSharedFile({
|
|
1396
|
+
file: t,
|
|
1397
|
+
onFileUploadComplete: (a) => {
|
|
1398
|
+
n(a);
|
|
1399
|
+
},
|
|
1400
|
+
onFileUploadError: (a) => {
|
|
1401
|
+
o(a);
|
|
1402
|
+
}
|
|
1403
|
+
});
|
|
1404
|
+
});
|
|
1405
|
+
}
|
|
1406
|
+
/** 删除群共享文件 */
|
|
1407
|
+
async deleteGroupSharedFile(e, t) {
|
|
1408
|
+
await this.client.groupManager.getGroup(e).deleteSharedFile({ fileId: t });
|
|
1409
|
+
}
|
|
1410
|
+
/** 下载群共享文件(SDK 0.14.203+ 无 Blob 环境会返回 ArrayBuffer,统一转为 Blob) */
|
|
1411
|
+
async downloadGroupSharedFile(e, t) {
|
|
1412
|
+
return new Promise((n, o) => {
|
|
1413
|
+
this.client.groupManager.getGroup(e).downloadSharedFile({
|
|
1414
|
+
fileId: t,
|
|
1415
|
+
onFileDownloadComplete: (a) => {
|
|
1416
|
+
n(a instanceof Blob ? a : new Blob([a]));
|
|
1417
|
+
},
|
|
1418
|
+
onFileDownloadError: (a) => o(a)
|
|
1419
|
+
});
|
|
1420
|
+
});
|
|
1421
|
+
}
|
|
1422
|
+
/** 同意入群申请 */
|
|
1423
|
+
async acceptGroupJoinRequest(e, t) {
|
|
1424
|
+
await this.client.groupManager.acceptGroupJoinRequest({ groupId: e, userId: t });
|
|
1425
|
+
}
|
|
1426
|
+
/** 拒绝入群申请 */
|
|
1427
|
+
async rejectGroupJoinRequest(e, t, n) {
|
|
1428
|
+
await this.client.groupManager.rejectGroupJoinRequest({ groupId: e, userId: t, reason: n });
|
|
1429
|
+
}
|
|
1430
|
+
/** 拒绝群邀请 */
|
|
1431
|
+
async declineGroupInvitation(e) {
|
|
1432
|
+
await this.client.groupManager.rejectInvitation({ groupId: e });
|
|
1433
|
+
}
|
|
1434
|
+
}
|
|
1435
|
+
function je(s, e) {
|
|
1436
|
+
if (!s)
|
|
1437
|
+
return "offline";
|
|
1438
|
+
if (!e)
|
|
1439
|
+
return "online";
|
|
1440
|
+
const t = e.toLowerCase(), n = W.ONLINE.toLowerCase(), o = W.AWAY.toLowerCase(), a = W.BUSY.toLowerCase(), r = W.DO_NOT_DISTURB.toLowerCase(), i = W.OFFLINE.toLowerCase();
|
|
1441
|
+
return t === n ? "online" : t === o ? "away" : t === a ? "busy" : t === r ? "doNotDisturb" : t === i ? "offline" : "custom";
|
|
1442
|
+
}
|
|
1443
|
+
function Re(s) {
|
|
1444
|
+
const e = s.publisher || "";
|
|
1445
|
+
if (!e)
|
|
1446
|
+
return null;
|
|
1447
|
+
const t = s.statusList || {}, n = Object.values(t).some((a) => Number(a) === 1), o = s.ext || "";
|
|
1448
|
+
return {
|
|
1449
|
+
userId: e,
|
|
1450
|
+
status: je(n, o),
|
|
1451
|
+
ext: o,
|
|
1452
|
+
lastTime: s.latestTime || Date.now()
|
|
1453
|
+
};
|
|
1454
|
+
}
|
|
1455
|
+
class Vt {
|
|
1456
|
+
constructor(e, t, n = {}) {
|
|
1457
|
+
this.client = e, this.store = t, this.options = n;
|
|
1458
|
+
}
|
|
1459
|
+
/** 订阅用户在线状态 */
|
|
1460
|
+
async subscribe(e, t = 7 * 24 * 60 * 60) {
|
|
1461
|
+
var r;
|
|
1462
|
+
const n = (r = this.options.presenceRepository) == null ? void 0 : r.subscribe;
|
|
1463
|
+
if (n)
|
|
1464
|
+
return await n(e, t), [];
|
|
1465
|
+
if (!this.client.isConnected)
|
|
1466
|
+
return [];
|
|
1467
|
+
const o = await this.client.presenceManager.subscribePresence({
|
|
1468
|
+
userIds: e,
|
|
1469
|
+
expiry: t
|
|
1470
|
+
});
|
|
1471
|
+
this.store.setSubscribed(e);
|
|
1472
|
+
const a = o.map(Re).filter((i) => i !== null);
|
|
1473
|
+
return this.store.updateBatch(a), a;
|
|
1474
|
+
}
|
|
1475
|
+
/** 取消订阅 */
|
|
1476
|
+
async unsubscribe(e) {
|
|
1477
|
+
var n;
|
|
1478
|
+
const t = (n = this.options.presenceRepository) == null ? void 0 : n.unsubscribe;
|
|
1479
|
+
if (t) {
|
|
1480
|
+
await t(e);
|
|
1481
|
+
return;
|
|
1482
|
+
}
|
|
1483
|
+
this.client.isConnected && await this.client.presenceManager.unsubscribePresence({ userIds: e });
|
|
1484
|
+
}
|
|
1485
|
+
/** 主动查询在线状态 */
|
|
1486
|
+
async fetchStatus(e) {
|
|
1487
|
+
var a;
|
|
1488
|
+
const t = (a = this.options.presenceRepository) == null ? void 0 : a.fetchStatus;
|
|
1489
|
+
if (t) {
|
|
1490
|
+
const r = await t(e);
|
|
1491
|
+
return this.store.updateBatch(r), r;
|
|
1492
|
+
}
|
|
1493
|
+
if (!this.client.isConnected)
|
|
1494
|
+
return [];
|
|
1495
|
+
const o = (await this.client.presenceManager.getPresenceStatus({ userIds: e })).map(Re).filter((r) => r !== null);
|
|
1496
|
+
return this.store.updateBatch(o), o;
|
|
1497
|
+
}
|
|
1498
|
+
/** 发布自定义在线状态 */
|
|
1499
|
+
async publish(e) {
|
|
1500
|
+
this.client.isConnected && await this.client.presenceManager.publishPresence({ customStatus: e });
|
|
1501
|
+
}
|
|
1502
|
+
}
|
|
1503
|
+
const F = R("UIKit:UserInfoDomain"), Te = [
|
|
1504
|
+
"nickname",
|
|
1505
|
+
"avatarUrl",
|
|
1506
|
+
"mail",
|
|
1507
|
+
"phone",
|
|
1508
|
+
"gender",
|
|
1509
|
+
"sign",
|
|
1510
|
+
"birth",
|
|
1511
|
+
"ext"
|
|
1512
|
+
];
|
|
1513
|
+
class qt {
|
|
1514
|
+
constructor(e, t, n = {}, o) {
|
|
1515
|
+
this.client = e, this.store = t, this.userInfoRepository = n, this.onSubscriptionPermissionError = o, this.handlerId = "uikit-user-info", this.subscribeQueue = [], this.subscribeFlushPromise = null, this.fetchQueue = [], this.fetchFlushPromise = null, this.hasLoggedPermissionError = !1;
|
|
1516
|
+
}
|
|
1517
|
+
/**
|
|
1518
|
+
* 启动用户资料变更事件监听。应在 SDK 初始化完成后调用。
|
|
1519
|
+
*/
|
|
1520
|
+
listen() {
|
|
1521
|
+
this.listenUserInfoChanges();
|
|
1522
|
+
}
|
|
1523
|
+
/**
|
|
1524
|
+
* 批量获取用户资料;已缓存(且请求属性已覆盖)或正在加载中的 userId 会被跳过。
|
|
1525
|
+
* 同一事件循环内的多次调用会合批为一次底层请求(微任务 flush,与 subscribe 合批同构):
|
|
1526
|
+
* flush 时合并所有调用的 userIds(去重)与 attributes(并集),只发一次请求,
|
|
1527
|
+
* 每个原始调用各自 resolve 回「自己请求的 userIds 对应的 UserInfo[]」(从 store 缓存读回)。
|
|
1528
|
+
* @param userIds 目标用户 ID 列表
|
|
1529
|
+
* @param attributes 需要查询的属性,默认全量 8 个属性
|
|
1530
|
+
*/
|
|
1531
|
+
async fetchUserInfos(e, t = Te) {
|
|
1532
|
+
if (!this.client.isConnected)
|
|
1533
|
+
return [];
|
|
1534
|
+
const n = Array.from(new Set(e.filter(Boolean)));
|
|
1535
|
+
return n.length === 0 ? [] : new Promise((o) => {
|
|
1536
|
+
this.fetchQueue.push({ userIds: n, attributes: t, resolve: o }), this.scheduleFetchFlush();
|
|
1537
|
+
});
|
|
1538
|
+
}
|
|
1539
|
+
scheduleFetchFlush() {
|
|
1540
|
+
this.fetchFlushPromise || (this.fetchFlushPromise = Promise.resolve().then(() => this.flushFetchQueue()));
|
|
1541
|
+
}
|
|
1542
|
+
async flushFetchQueue() {
|
|
1543
|
+
const e = this.fetchQueue;
|
|
1544
|
+
this.fetchQueue = [];
|
|
1545
|
+
try {
|
|
1546
|
+
const t = e.map((a) => ({
|
|
1547
|
+
...a,
|
|
1548
|
+
missingIds: a.userIds.filter(
|
|
1549
|
+
(r) => !this.store.areAttributesFetched(r, a.attributes) && !this.store.isLoading(r) && !this.store.isFetchFailed(r)
|
|
1550
|
+
)
|
|
1551
|
+
})), n = Array.from(new Set(t.flatMap((a) => a.missingIds))), o = Array.from(new Set(e.flatMap((a) => a.attributes)));
|
|
1552
|
+
if (n.length > 0) {
|
|
1553
|
+
this.store.markLoading(n);
|
|
1554
|
+
try {
|
|
1555
|
+
const a = this.userInfoRepository.fetchUserInfos ? await this.fetchFromRepository(n) : await this.fetchFromSdk(n, o), r = new Set(a.map((u) => u.userId).filter(Boolean)), i = n.filter((u) => !r.has(u));
|
|
1556
|
+
i.length > 0 && this.store.markFetchFailed(i), this.store.setUserInfos(a), this.store.markFetchedAttributes(n, o);
|
|
1557
|
+
} catch (a) {
|
|
1558
|
+
F.warn("[UserInfoDomain] fetchUserInfos failed:", E(a)), this.store.markFetchFailed(n);
|
|
1559
|
+
} finally {
|
|
1560
|
+
this.store.markLoaded(n);
|
|
1561
|
+
}
|
|
1562
|
+
}
|
|
1563
|
+
for (const a of t)
|
|
1564
|
+
a.resolve(
|
|
1565
|
+
a.userIds.map((r) => this.store.getUserInfo(r)).filter((r) => !!r)
|
|
1566
|
+
);
|
|
1567
|
+
} finally {
|
|
1568
|
+
this.fetchFlushPromise = null, this.fetchQueue.length > 0 && this.scheduleFetchFlush();
|
|
1569
|
+
}
|
|
1570
|
+
}
|
|
1571
|
+
async fetchFromSdk(e, t) {
|
|
1572
|
+
const n = await this.client.userInfoManager.getUserInfoByAttribute({
|
|
1573
|
+
userIds: e,
|
|
1574
|
+
attributes: t
|
|
1575
|
+
});
|
|
1576
|
+
return Array.from(n);
|
|
1577
|
+
}
|
|
1578
|
+
async fetchFromRepository(e) {
|
|
1579
|
+
return this.userInfoRepository.fetchUserInfos ? (await this.userInfoRepository.fetchUserInfos(e)).map((n) => ({
|
|
1580
|
+
userId: n.userId,
|
|
1581
|
+
nickname: n.nickname,
|
|
1582
|
+
avatarUrl: n.avatarUrl,
|
|
1583
|
+
mail: n.mail,
|
|
1584
|
+
phone: n.phone,
|
|
1585
|
+
gender: n.gender,
|
|
1586
|
+
sign: n.sign,
|
|
1587
|
+
birth: n.birth,
|
|
1588
|
+
ext: n.ext
|
|
1589
|
+
})) : [];
|
|
1590
|
+
}
|
|
1591
|
+
/**
|
|
1592
|
+
* 批量订阅陌生人资料变更通知。
|
|
1593
|
+
* 同一事件循环内的多次调用会合并为一次 SDK 请求;
|
|
1594
|
+
* 若服务端返回无权限,则自动熔断后续订阅并缓存失败用户,避免重复请求与控制台警告刷屏。
|
|
1595
|
+
*/
|
|
1596
|
+
async subscribeUserInfos(e) {
|
|
1597
|
+
if (!this.client.isConnected || this.store.isSubscriptionDisabled())
|
|
1598
|
+
return;
|
|
1599
|
+
const t = Array.from(new Set(e.filter(Boolean))).filter(
|
|
1600
|
+
(n) => !this.store.isSubscribed(n) && !this.store.isSubscribeFailed(n)
|
|
1601
|
+
);
|
|
1602
|
+
if (t.length !== 0)
|
|
1603
|
+
return this.subscribeQueue.push(...t), this.subscribeFlushPromise ? this.subscribeFlushPromise : (this.subscribeFlushPromise = Promise.resolve().then(() => this.flushSubscribeQueue()), this.subscribeFlushPromise);
|
|
1604
|
+
}
|
|
1605
|
+
async flushSubscribeQueue() {
|
|
1606
|
+
const e = Array.from(new Set(this.subscribeQueue));
|
|
1607
|
+
this.subscribeQueue = [];
|
|
1608
|
+
try {
|
|
1609
|
+
await this.client.userInfoManager.subscribeUsersInfo({ userIds: e }), this.store.markSubscribed(e);
|
|
1610
|
+
} catch (t) {
|
|
1611
|
+
this.handleSubscribeError(t, e);
|
|
1612
|
+
} finally {
|
|
1613
|
+
this.subscribeFlushPromise = null, this.subscribeQueue.length > 0 && (this.subscribeFlushPromise = Promise.resolve().then(() => this.flushSubscribeQueue()));
|
|
1614
|
+
}
|
|
1615
|
+
}
|
|
1616
|
+
handleSubscribeError(e, t) {
|
|
1617
|
+
var n;
|
|
1618
|
+
if (this.isPermissionError(e)) {
|
|
1619
|
+
this.store.markSubscribeFailed(t), this.store.disableSubscription(), this.hasLoggedPermissionError || (this.hasLoggedPermissionError = !0, F.warn(
|
|
1620
|
+
"[UserInfoDomain] 用户资料订阅无权限或服务未开通,已自动关闭订阅。后续陌生人资料变更将不会实时推送,拉取到的资料仍可正常展示。",
|
|
1621
|
+
E(e)
|
|
1622
|
+
), (n = this.onSubscriptionPermissionError) == null || n.call(this));
|
|
1623
|
+
return;
|
|
1624
|
+
}
|
|
1625
|
+
this.store.markSubscribeFailed(t), F.warn("[UserInfoDomain] subscribeUserInfos failed:", E(e));
|
|
1626
|
+
}
|
|
1627
|
+
isPermissionError(e) {
|
|
1628
|
+
var n, o;
|
|
1629
|
+
if (!e || typeof e != "object")
|
|
1630
|
+
return !1;
|
|
1631
|
+
const t = e;
|
|
1632
|
+
return t.code === 210 || ((n = t.details) == null ? void 0 : n.httpStatus) === 403 || ((o = t.details) == null ? void 0 : o.reason) === "service_forbidden";
|
|
1633
|
+
}
|
|
1634
|
+
/**
|
|
1635
|
+
* 获取当前登录用户自己的资料(默认全量属性,保证签名等登录后回显)。
|
|
1636
|
+
*/
|
|
1637
|
+
async fetchOwnInfo(e = Te) {
|
|
1638
|
+
const t = this.client.currentUserId;
|
|
1639
|
+
if (!t)
|
|
1640
|
+
return;
|
|
1641
|
+
const [n] = await this.fetchUserInfos([t], e);
|
|
1642
|
+
return n;
|
|
1643
|
+
}
|
|
1644
|
+
/**
|
|
1645
|
+
* 更新当前登录用户资料。
|
|
1646
|
+
*/
|
|
1647
|
+
async updateOwnInfo(e) {
|
|
1648
|
+
if (this.client.isConnected)
|
|
1649
|
+
try {
|
|
1650
|
+
const t = await this.client.userInfoManager.updateOwnInfo(e);
|
|
1651
|
+
return this.store.setUserInfo(t), t;
|
|
1652
|
+
} catch (t) {
|
|
1653
|
+
F.warn("[UserInfoDomain] updateOwnInfo failed:", E(t));
|
|
1654
|
+
return;
|
|
1655
|
+
}
|
|
1656
|
+
}
|
|
1657
|
+
/**
|
|
1658
|
+
* 更新当前登录用户的单个资料属性。
|
|
1659
|
+
*/
|
|
1660
|
+
async updateOwnInfoByAttribute(e, t) {
|
|
1661
|
+
if (this.client.isConnected)
|
|
1662
|
+
try {
|
|
1663
|
+
const n = await this.client.userInfoManager.updateOwnInfoByAttribute(e, t);
|
|
1664
|
+
return this.store.setUserInfo(n), n;
|
|
1665
|
+
} catch (n) {
|
|
1666
|
+
F.warn("[UserInfoDomain] updateOwnInfoByAttribute failed:", E(n));
|
|
1667
|
+
return;
|
|
1668
|
+
}
|
|
1669
|
+
}
|
|
1670
|
+
/**
|
|
1671
|
+
* 取消订阅指定用户的资料变更通知。
|
|
1672
|
+
*/
|
|
1673
|
+
async unsubscribeUsersInfo(e) {
|
|
1674
|
+
if (!this.client.isConnected)
|
|
1675
|
+
return;
|
|
1676
|
+
const t = Array.from(new Set(e.filter(Boolean)));
|
|
1677
|
+
if (t.length !== 0)
|
|
1678
|
+
try {
|
|
1679
|
+
await this.client.userInfoManager.unsubscribeUsersInfo({ userIds: t }), this.store.markUnsubscribed(t);
|
|
1680
|
+
} catch (n) {
|
|
1681
|
+
F.warn("[UserInfoDomain] unsubscribeUsersInfo failed:", E(n));
|
|
1682
|
+
}
|
|
1683
|
+
}
|
|
1684
|
+
/**
|
|
1685
|
+
* 获取当前用户已订阅资料变更的用户列表。
|
|
1686
|
+
*/
|
|
1687
|
+
async getSubscribedUsers() {
|
|
1688
|
+
if (!this.client.isConnected)
|
|
1689
|
+
return [];
|
|
1690
|
+
try {
|
|
1691
|
+
return await this.client.userInfoManager.getSubscribedUsers();
|
|
1692
|
+
} catch (e) {
|
|
1693
|
+
return F.warn("[UserInfoDomain] getSubscribedUsers failed:", E(e)), [];
|
|
1694
|
+
}
|
|
1695
|
+
}
|
|
1696
|
+
/**
|
|
1697
|
+
* 清理事件监听与内部状态。
|
|
1698
|
+
*/
|
|
1699
|
+
dispose() {
|
|
1700
|
+
this.client.userInfoManager.removeEventHandler(this.handlerId), this.subscribeQueue = [], this.subscribeFlushPromise = null;
|
|
1701
|
+
const e = this.fetchQueue;
|
|
1702
|
+
this.fetchQueue = [], this.fetchFlushPromise = null;
|
|
1703
|
+
for (const t of e)
|
|
1704
|
+
t.resolve(
|
|
1705
|
+
t.userIds.map((n) => this.store.getUserInfo(n)).filter((n) => !!n)
|
|
1706
|
+
);
|
|
1707
|
+
this.hasLoggedPermissionError = !1;
|
|
1708
|
+
}
|
|
1709
|
+
listenUserInfoChanges() {
|
|
1710
|
+
this.client.userInfoManager.addEventHandler(this.handlerId, {
|
|
1711
|
+
onOwnInfoUpdated: (e) => {
|
|
1712
|
+
this.store.setUserInfo(e);
|
|
1713
|
+
},
|
|
1714
|
+
onUserInfoUpdated: (e) => {
|
|
1715
|
+
this.store.setUserInfos(Array.from(e));
|
|
1716
|
+
}
|
|
1717
|
+
});
|
|
1718
|
+
}
|
|
1719
|
+
}
|
|
1720
|
+
const L = R("UIKit:ConnEvents");
|
|
1721
|
+
function Wt(s, e = {}) {
|
|
1722
|
+
return {
|
|
1723
|
+
onConnecting: () => {
|
|
1724
|
+
L.info("onConnecting"), s.client.setConnecting(!0);
|
|
1725
|
+
},
|
|
1726
|
+
onConnected: () => {
|
|
1727
|
+
L.info("onConnected"), s.client.setConnected(!0), s.client.setConnecting(!1), s.client.setHasConnectedOnce(!0);
|
|
1728
|
+
},
|
|
1729
|
+
onDisconnected: (t) => {
|
|
1730
|
+
L.info("onDisconnected", t ? { reason: t.reason, errorCode: t.errorCode } : void 0), s.client.setConnected(!1), s.client.setConnecting(!1), at(t == null ? void 0 : t.errorCode) && s.client.setKicked(t.errorCode);
|
|
1731
|
+
},
|
|
1732
|
+
onReconnectFailed: () => {
|
|
1733
|
+
L.info("onReconnectFailed"), s.client.setConnecting(!1), L.error("Auto-reconnect failed after max retries");
|
|
1734
|
+
},
|
|
1735
|
+
onTokenWillExpire: () => {
|
|
1736
|
+
var t;
|
|
1737
|
+
L.info("onTokenWillExpire"), L.warn("Token will expire"), (t = e.onTokenWillExpire) == null || t.call(e);
|
|
1738
|
+
},
|
|
1739
|
+
onTokenExpired: () => {
|
|
1740
|
+
var t;
|
|
1741
|
+
L.info("onTokenExpired"), L.error("Token expired"), (t = e.onTokenExpired) == null || t.call(e);
|
|
1742
|
+
},
|
|
1743
|
+
onOfflineMessageSyncStart: () => {
|
|
1744
|
+
L.info("onOfflineMessageSyncStart"), s.conversation.conversationsLoaded || s.message.setSyncingMessages(!0);
|
|
1745
|
+
},
|
|
1746
|
+
onOfflineMessageSyncFinish: () => {
|
|
1747
|
+
L.info("onOfflineMessageSyncFinish"), s.message.setSyncingMessages(!1);
|
|
1748
|
+
}
|
|
1749
|
+
};
|
|
1750
|
+
}
|
|
1751
|
+
const Ve = R("UIKit:SyncStatus"), q = gt({
|
|
1752
|
+
conversation: { status: "idle" },
|
|
1753
|
+
contact: { status: "idle" },
|
|
1754
|
+
group: { status: "idle" }
|
|
1755
|
+
});
|
|
1756
|
+
let $ = null;
|
|
1757
|
+
function Jt(s) {
|
|
1758
|
+
return $ = s, () => {
|
|
1759
|
+
$ = null;
|
|
1760
|
+
};
|
|
1761
|
+
}
|
|
1762
|
+
function he(s, e) {
|
|
1763
|
+
const t = q[s];
|
|
1764
|
+
t.status = e.status, e.finishedAt !== void 0 && (t.finishedAt = e.finishedAt), e.error !== void 0 && (t.error = e.error), Ve.info(`sync ${s} -> ${e.status}`, e.error ? { stage: e.error.stage, retryable: e.error.retryable, message: e.error.message } : void 0), $ == null || $({
|
|
1765
|
+
type: s,
|
|
1766
|
+
status: e.status === "idle" ? "syncing" : e.status,
|
|
1767
|
+
error: e.error
|
|
1768
|
+
});
|
|
1769
|
+
}
|
|
1770
|
+
function Qt() {
|
|
1771
|
+
const s = Object.keys(q);
|
|
1772
|
+
for (const e of s)
|
|
1773
|
+
q[e] = { status: "idle" };
|
|
1774
|
+
Ve.info("sync status reset(事件反注册/登出)");
|
|
1775
|
+
}
|
|
1776
|
+
function Dn() {
|
|
1777
|
+
const s = ue(() => ({ ...q })), e = ue(
|
|
1778
|
+
() => Object.values(q).some((n) => n.status === "syncing")
|
|
1779
|
+
), t = ue(
|
|
1780
|
+
() => Object.values(q).every((n) => n.status === "success" || n.status === "failed")
|
|
1781
|
+
);
|
|
1782
|
+
return { status: s, isSyncing: e, allFinished: t };
|
|
1783
|
+
}
|
|
1784
|
+
let Ce = null;
|
|
1785
|
+
function qe(s) {
|
|
1786
|
+
Ce = s;
|
|
1787
|
+
}
|
|
1788
|
+
function O() {
|
|
1789
|
+
if (!Ce)
|
|
1790
|
+
throw new Error(
|
|
1791
|
+
"[UIKit] 事件层依赖未注入:请在调用 registerEventHandlers 前先执行 setEventHandlerDeps()"
|
|
1792
|
+
);
|
|
1793
|
+
return Ce;
|
|
1794
|
+
}
|
|
1795
|
+
function $t(s, e) {
|
|
1796
|
+
const t = s.contact.getContact(e);
|
|
1797
|
+
if (t != null && t.remark)
|
|
1798
|
+
return t.remark;
|
|
1799
|
+
const n = s.userInfo.getUserInfo(e);
|
|
1800
|
+
if (n != null && n.nickname)
|
|
1801
|
+
return n.nickname;
|
|
1802
|
+
}
|
|
1803
|
+
function We(s, e) {
|
|
1804
|
+
var r;
|
|
1805
|
+
const t = e.from || "", n = s.contact.getContact(t);
|
|
1806
|
+
if (n != null && n.remark)
|
|
1807
|
+
return n.remark;
|
|
1808
|
+
const o = s.userInfo.getUserInfo(t);
|
|
1809
|
+
if (o != null && o.nickname)
|
|
1810
|
+
return o.nickname;
|
|
1811
|
+
const a = (r = e.ext) == null ? void 0 : r.ease_chat_uikit_user_info;
|
|
1812
|
+
return a != null && a.nickname ? a.nickname : a != null && a.remark ? a.remark : t;
|
|
1813
|
+
}
|
|
1814
|
+
function zt(s, e) {
|
|
1815
|
+
var l;
|
|
1816
|
+
const { useNotification: t, emitNotificationDelivered: n } = O(), { state: o, notify: a, notifyBrowser: r } = t();
|
|
1817
|
+
if (!o.value.enabled || A(e.from) === A(s.client.currentUser) || e.conversationId === s.conversation.currentConversationId)
|
|
1818
|
+
return;
|
|
1819
|
+
const i = s.conversation.conversationList.find((m) => m.id === e.conversationId);
|
|
1820
|
+
if (i != null && i.isMuted)
|
|
1821
|
+
return;
|
|
1822
|
+
const u = typeof document > "u" || document.visibilityState === "hidden";
|
|
1823
|
+
if (o.value.triggerMode === "background" && !u)
|
|
1824
|
+
return;
|
|
1825
|
+
const d = x(e, s.client.currentUser), g = We(s, d), f = d.conversationType === M.GROUPCHAT, c = {
|
|
1826
|
+
// 群聊标题为群名(正文含 "发送者: 内容" 前缀),单聊标题为发送者名
|
|
1827
|
+
title: f && (i == null ? void 0 : i.name) || g,
|
|
1828
|
+
body: ct(d, void 0, g, void 0, Ge),
|
|
1829
|
+
// 群聊用群头像,单聊用发送者头像
|
|
1830
|
+
avatar: f ? i == null ? void 0 : i.avatar : (l = s.userInfo.getUserInfo(e.from)) == null ? void 0 : l.avatarUrl,
|
|
1831
|
+
timestamp: d.timestamp || Date.now(),
|
|
1832
|
+
conversationId: e.conversationId,
|
|
1833
|
+
conversationType: d.conversationType
|
|
1834
|
+
};
|
|
1835
|
+
u && o.value.browserEnabled ? r(c).then((m) => {
|
|
1836
|
+
m ? n(c, "browser") : o.value.inAppEnabled && (a(c), n(c, "in-app"));
|
|
1837
|
+
}) : o.value.inAppEnabled && (a(c), n(c, "in-app"));
|
|
1838
|
+
}
|
|
1839
|
+
function Ue(s, e, t) {
|
|
1840
|
+
const { t: n, useNotification: o, emitNotificationDelivered: a, resolveNoticeUserName: r } = O(), { state: i, notify: u, notifyBrowser: d } = o();
|
|
1841
|
+
if (!i.value.enabled)
|
|
1842
|
+
return;
|
|
1843
|
+
const g = s.userInfo.getUserInfo(e), f = {
|
|
1844
|
+
title: r(g) || e,
|
|
1845
|
+
body: n(t === "declined" ? "contact.inviteDeclinedByPeer" : "chat.notice.contactDeleted"),
|
|
1846
|
+
avatar: g == null ? void 0 : g.avatarUrl,
|
|
1847
|
+
timestamp: Date.now(),
|
|
1848
|
+
conversationId: e,
|
|
1849
|
+
conversationType: M.SINGLECHAT
|
|
1850
|
+
};
|
|
1851
|
+
(typeof document > "u" || document.visibilityState === "hidden") && i.value.browserEnabled ? d(f).then((l) => {
|
|
1852
|
+
l ? a(f, "browser") : i.value.inAppEnabled && (u(f), a(f, "in-app"));
|
|
1853
|
+
}) : i.value.inAppEnabled && (u(f), a(f, "in-app"));
|
|
1854
|
+
}
|
|
1855
|
+
const w = R("UIKit:ChatEvents"), oe = /* @__PURE__ */ new Set(), ye = /* @__PURE__ */ new Set(), j = /* @__PURE__ */ new Map();
|
|
1856
|
+
let ie = !1;
|
|
1857
|
+
function Yt() {
|
|
1858
|
+
oe.clear(), ye.clear(), j.clear(), ie = !1;
|
|
1859
|
+
}
|
|
1860
|
+
function Xt(s, e, t, n) {
|
|
1861
|
+
if (!n)
|
|
1862
|
+
return;
|
|
1863
|
+
const o = `${e}:${t}`, a = j.get(o) || [];
|
|
1864
|
+
a.push(n), j.set(o, a), !ie && (ie = !0, Promise.resolve().then(async () => {
|
|
1865
|
+
for (ie = !1; j.size > 0; ) {
|
|
1866
|
+
const r = Array.from(j.entries());
|
|
1867
|
+
j.clear();
|
|
1868
|
+
for (const [i, u] of r) {
|
|
1869
|
+
const [d, g] = i.split(":");
|
|
1870
|
+
for (let f = 0; f < u.length; f += 50) {
|
|
1871
|
+
const c = u.slice(f, f + 50);
|
|
1872
|
+
w.info("[queueMessageReadReceipt] 批量发送已读回执", { conversationType: d, conversationId: g, batchSize: c.length, messageIds: c });
|
|
1873
|
+
try {
|
|
1874
|
+
await s.chatManager.sendMessageReadReceipts({
|
|
1875
|
+
conversationId: g,
|
|
1876
|
+
conversationType: d,
|
|
1877
|
+
messageIds: c
|
|
1878
|
+
}), Lt(c), w.info("[queueMessageReadReceipt] 已读回执发送成功", { conversationType: d, conversationId: g, messageIds: c });
|
|
1879
|
+
} catch (l) {
|
|
1880
|
+
w.warn("[queueMessageReadReceipt] sendMessageReadReceipts failed:", { conversationType: d, conversationId: g, messageIds: c, err: l });
|
|
1881
|
+
}
|
|
1882
|
+
}
|
|
1883
|
+
}
|
|
1884
|
+
}
|
|
1885
|
+
}));
|
|
1886
|
+
}
|
|
1887
|
+
async function Zt(s, e) {
|
|
1888
|
+
const t = s.conversation.conversationList.map((n) => ({
|
|
1889
|
+
conversationId: n.id,
|
|
1890
|
+
conversationType: n.type
|
|
1891
|
+
}));
|
|
1892
|
+
if (t.length !== 0)
|
|
1893
|
+
for (let n = 0; n < t.length; n += 20)
|
|
1894
|
+
try {
|
|
1895
|
+
const o = await e.pushManager.getConversationSilentModes({
|
|
1896
|
+
conversationList: t.slice(n, n + 20)
|
|
1897
|
+
});
|
|
1898
|
+
for (const a of o.conversations) {
|
|
1899
|
+
const r = a.rule.remindType === "NONE" || a.rule.expireTimestamp !== void 0 && a.rule.expireTimestamp > Date.now(), i = s.conversation.conversationList.find((u) => u.id === a.conversationId);
|
|
1900
|
+
i && i.isMuted !== r && s.conversation.updateConversation(a.conversationId, {
|
|
1901
|
+
isMuted: r,
|
|
1902
|
+
remindType: a.rule.remindType ?? (r ? "NONE" : "DEFAULT")
|
|
1903
|
+
});
|
|
1904
|
+
}
|
|
1905
|
+
} catch (o) {
|
|
1906
|
+
w.warn("patch conversation mute states failed:", o);
|
|
1907
|
+
}
|
|
1908
|
+
}
|
|
1909
|
+
async function X(s, e) {
|
|
1910
|
+
const t = new Map(s.group.groupList.map((o) => [o.groupId, o.groupName])), n = [];
|
|
1911
|
+
for (const o of s.conversation.conversationList)
|
|
1912
|
+
if ((!o.name || o.name === o.id) && !ye.has(o.id)) {
|
|
1913
|
+
if (o.type === M.GROUPCHAT) {
|
|
1914
|
+
const r = t.get(o.id);
|
|
1915
|
+
r && r !== o.id ? s.conversation.updateConversation(o.id, { name: r }) : oe.has(o.id) || n.push(o.id);
|
|
1916
|
+
} else if (o.type === M.SINGLECHAT) {
|
|
1917
|
+
const r = s.contact.getContact(o.id), i = s.userInfo.getUserInfo(o.id), u = (r == null ? void 0 : r.remark) || (r == null ? void 0 : r.name) || (i == null ? void 0 : i.nickname);
|
|
1918
|
+
u && s.conversation.updateConversation(o.id, { name: u });
|
|
1919
|
+
}
|
|
1920
|
+
}
|
|
1921
|
+
if (n.length !== 0) {
|
|
1922
|
+
for (const o of n)
|
|
1923
|
+
oe.add(o), ye.add(o);
|
|
1924
|
+
try {
|
|
1925
|
+
const o = await e.groupManager.getGroupInfoList({ groupIds: n }), a = ce(o);
|
|
1926
|
+
for (const r of a)
|
|
1927
|
+
s.group.updateGroup(r.groupId, r), r.groupName && r.groupName !== r.groupId && s.conversation.updateConversation(r.groupId, { name: r.groupName });
|
|
1928
|
+
} catch (o) {
|
|
1929
|
+
w.warn("fetch missing group names failed:", o);
|
|
1930
|
+
} finally {
|
|
1931
|
+
for (const o of n) oe.delete(o);
|
|
1932
|
+
}
|
|
1933
|
+
}
|
|
1934
|
+
}
|
|
1935
|
+
function en(s, e, t, n) {
|
|
1936
|
+
const o = s.message.getMessages(e), a = o.findIndex(
|
|
1937
|
+
(f) => f.msgServerId === n || f.msgLocalId === n
|
|
1938
|
+
);
|
|
1939
|
+
if (a === -1 || a !== o.length - 1)
|
|
1940
|
+
return;
|
|
1941
|
+
const r = o[a], i = s.conversation.conversationList.find((f) => f.id === e);
|
|
1942
|
+
if (!i || i.lastMessageTime && r.timestamp < i.lastMessageTime - 1e3)
|
|
1943
|
+
return;
|
|
1944
|
+
const d = t === M.GROUPCHAT ? We(s, r) : void 0, { t: g } = O();
|
|
1945
|
+
s.conversation.updateConversation(e, {
|
|
1946
|
+
lastMessageText: Be(
|
|
1947
|
+
t,
|
|
1948
|
+
d,
|
|
1949
|
+
g("message.recalledPreview")
|
|
1950
|
+
)
|
|
1951
|
+
});
|
|
1952
|
+
}
|
|
1953
|
+
function N(s) {
|
|
1954
|
+
Promise.resolve().then(s).catch((e) => w.warn("persistence 钩子执行失败(已忽略):", e));
|
|
1955
|
+
}
|
|
1956
|
+
function Le(s, e) {
|
|
1957
|
+
const t = s.conversation.conversationList, n = new Set(e.map((r) => r.id)), o = e.map((r) => {
|
|
1958
|
+
const i = t.find((g) => g.id === r.id);
|
|
1959
|
+
if (!i)
|
|
1960
|
+
return r;
|
|
1961
|
+
const u = (!r.name || r.name === r.id) && i.name && i.name !== i.id, d = !r.avatar && i.avatar;
|
|
1962
|
+
return {
|
|
1963
|
+
...r,
|
|
1964
|
+
name: u ? i.name : r.name,
|
|
1965
|
+
avatar: d ? i.avatar : r.avatar,
|
|
1966
|
+
// SDK 快照不携带的本地字段保留(草稿)
|
|
1967
|
+
draft: r.draft ?? i.draft,
|
|
1968
|
+
draftTime: r.draftTime ?? i.draftTime,
|
|
1969
|
+
// 免打扰状态以本地为准:SDK 会话快照恒为 DEFAULT 不携带该状态(见文件头注释),
|
|
1970
|
+
// 本地由 setMuted 回写 / CONVERSATION_MUTE_INFO_CHANGED / patchConversationMuteStates 权威维护
|
|
1971
|
+
isMuted: i.isMuted,
|
|
1972
|
+
remindType: i.remindType ?? r.remindType
|
|
1973
|
+
};
|
|
1974
|
+
}), a = t.filter((r) => !n.has(r.id)).sort((r, i) => (i.lastMessageTime ?? 0) - (r.lastMessageTime ?? 0));
|
|
1975
|
+
return [...o, ...a];
|
|
1976
|
+
}
|
|
1977
|
+
function tn(s, e, t, n) {
|
|
1978
|
+
var f;
|
|
1979
|
+
const o = (c) => $t(e, c), {
|
|
1980
|
+
saveMessage: a,
|
|
1981
|
+
updateMessageStatus: r,
|
|
1982
|
+
markMessageRecalled: i,
|
|
1983
|
+
updateMessageContent: u,
|
|
1984
|
+
deleteMessages: d
|
|
1985
|
+
} = (n == null ? void 0 : n.message) ?? {}, g = (f = n == null ? void 0 : n.conversation) == null ? void 0 : f.saveConversations;
|
|
1986
|
+
return {
|
|
1987
|
+
onSyncDataStart: (c) => {
|
|
1988
|
+
w.info("onSyncDataStart", { dataType: c.dataType }), he(c.dataType, { status: "syncing" }), c.dataType === "conversation" && e.conversation.setSyncingConversations(!0);
|
|
1989
|
+
},
|
|
1990
|
+
onSyncDataFinished: (c) => {
|
|
1991
|
+
if (w.info("onSyncDataFinished", { dataType: c.dataType, status: c.status }), c.status === "failed") {
|
|
1992
|
+
const l = c.error;
|
|
1993
|
+
he(c.dataType, {
|
|
1994
|
+
status: "failed",
|
|
1995
|
+
finishedAt: Date.now(),
|
|
1996
|
+
error: {
|
|
1997
|
+
stage: l == null ? void 0 : l.stage,
|
|
1998
|
+
retryable: l == null ? void 0 : l.retryable,
|
|
1999
|
+
message: l == null ? void 0 : l.message
|
|
2000
|
+
}
|
|
2001
|
+
}), w.warn("[ChatEvents] 数据同步失败", {
|
|
2002
|
+
dataType: c.dataType,
|
|
2003
|
+
stage: l == null ? void 0 : l.stage,
|
|
2004
|
+
retryable: l == null ? void 0 : l.retryable,
|
|
2005
|
+
message: l == null ? void 0 : l.message
|
|
2006
|
+
}), c.dataType === "conversation" && (e.conversation.setSyncingConversations(!1), l != null && l.retryable && s.chatManager.refreshSessionList().catch((m) => {
|
|
2007
|
+
w.warn("[ChatEvents] conversation 同步失败重试未成功:", E(m));
|
|
2008
|
+
}));
|
|
2009
|
+
return;
|
|
2010
|
+
}
|
|
2011
|
+
switch (he(c.dataType, { status: "success", finishedAt: Date.now() }), c.dataType) {
|
|
2012
|
+
case "conversation":
|
|
2013
|
+
e.conversation.setSyncingConversations(!1);
|
|
2014
|
+
{
|
|
2015
|
+
const l = s.chatManager.getConversationList().filter((h) => h.conversationType !== "chatRoom");
|
|
2016
|
+
w.info("getConversationList raw (onSyncDataFinished)", l);
|
|
2017
|
+
const m = ae(l, { resolveSenderName: o }), p = Le(e, m);
|
|
2018
|
+
e.conversation.setConversationList(p), w.info("conversation 同步回填", { count: p.length }), g && N(() => g(p.map(Ae)));
|
|
2019
|
+
}
|
|
2020
|
+
e.conversation.setConversationsLoaded(!0), X(e, s), Zt(e, s);
|
|
2021
|
+
break;
|
|
2022
|
+
case "contact":
|
|
2023
|
+
if (!e.contact.loaded || e.contact.contactList.length === 0) {
|
|
2024
|
+
const l = s.contactManager.getContacts();
|
|
2025
|
+
e.contact.setContactList(we(l)), w.info("contact 同步回填", { count: l.length });
|
|
2026
|
+
} else
|
|
2027
|
+
w.info("contact 同步回填跳过(列表已由业务方填充)", { count: e.contact.contactList.length });
|
|
2028
|
+
X(e, s);
|
|
2029
|
+
break;
|
|
2030
|
+
case "group":
|
|
2031
|
+
if (!e.group.loaded || e.group.groupList.length === 0) {
|
|
2032
|
+
const l = s.groupManager.getJoinedGroupList();
|
|
2033
|
+
e.group.setGroupList(ce(l)), w.info("group 同步回填", { count: l.length });
|
|
2034
|
+
} else
|
|
2035
|
+
w.info("group 同步回填跳过(列表已由业务方填充)", { count: e.group.groupList.length });
|
|
2036
|
+
X(e, s);
|
|
2037
|
+
break;
|
|
2038
|
+
}
|
|
2039
|
+
},
|
|
2040
|
+
onConversationListUpdate: (c) => {
|
|
2041
|
+
var b;
|
|
2042
|
+
const l = c.items.filter((v) => v.conversationType !== "chatRoom");
|
|
2043
|
+
w.info("onConversationListUpdate", { count: l.length, reset: c.patch.reset, removed: c.patch.removed.length }), w.info("getConversationList raw (onConversationListUpdate)", l);
|
|
2044
|
+
{
|
|
2045
|
+
const v = {}, C = [];
|
|
2046
|
+
for (const U of l) {
|
|
2047
|
+
const P = String(((b = U.lastMessage) == null ? void 0 : b.type) ?? "(null)");
|
|
2048
|
+
v[P] = (v[P] ?? 0) + 1, (P === S.COMBINE || P === "unknown") && C.push({ conversationId: U.conversationId, lastMessage: U.lastMessage });
|
|
2049
|
+
}
|
|
2050
|
+
C.length > 0 && w.info("raw snippets (onConversationListUpdate)", { typeCount: v, suspects: C });
|
|
2051
|
+
}
|
|
2052
|
+
const m = ae(l, { resolveSenderName: o }), p = Le(e, m), h = new Set(c.patch.removed.map((v) => v.conversationId)), I = h.size > 0 ? p.filter((v) => !h.has(v.id)) : p;
|
|
2053
|
+
if (c.patch.reset || c.patch.removed.length > 0)
|
|
2054
|
+
e.conversation.setConversationList(I);
|
|
2055
|
+
else
|
|
2056
|
+
for (const v of I) {
|
|
2057
|
+
const C = e.conversation.conversationList.find((U) => U.id === v.id);
|
|
2058
|
+
C ? C !== v && e.conversation.updateConversation(v.id, v) : e.conversation.addConversation(v);
|
|
2059
|
+
}
|
|
2060
|
+
g && N(() => g(I.map(Ae))), X(e, s);
|
|
2061
|
+
},
|
|
2062
|
+
onMessage: (c) => {
|
|
2063
|
+
var I, b, v;
|
|
2064
|
+
if (c.conversationType === "chatRoom")
|
|
2065
|
+
return;
|
|
2066
|
+
if (c.type === S.CMD) {
|
|
2067
|
+
const C = c.body.action;
|
|
2068
|
+
w.info("[CMD received]", {
|
|
2069
|
+
conversationId: c.conversationId,
|
|
2070
|
+
from: c.from,
|
|
2071
|
+
action: C,
|
|
2072
|
+
ext: c.ext
|
|
2073
|
+
}), C === "TypingBegin" && (t == null ? void 0 : t.enableTyping) !== !1 && c.conversationType === M.SINGLECHAT && A(c.from) !== A(e.client.currentUser) && e.conversation.setTyping(c.conversationId, c.from);
|
|
2074
|
+
return;
|
|
2075
|
+
}
|
|
2076
|
+
w.info("onMessage", { conversationId: c.conversationId, from: c.from, type: c.type });
|
|
2077
|
+
const l = x(c, e.client.currentUser), m = e.message.getMessages(c.conversationId).find((C) => C.msgServerId === c.msgServerId);
|
|
2078
|
+
m != null && m.stream && ut(m.stream.status) ? e.message.replaceMessageById(c.msgServerId, l) : e.message.addMessage(l), l.type === S.VOICE && !l.isSelf && ((b = (I = e.message).markVoiceUnplayed) == null || b.call(I, l.msgServerId || l.msgLocalId)), a && N(() => a(Ie(c)));
|
|
2079
|
+
const p = e.conversation.currentConversationId, h = typeof document > "u" || document.visibilityState === "visible";
|
|
2080
|
+
if (p && c.conversationId === p && A(c.from) !== A(e.client.currentUser) && h && (s.chatManager.clearConversationUnreadMessageCount({
|
|
2081
|
+
conversationId: c.conversationId,
|
|
2082
|
+
conversationType: c.conversationType
|
|
2083
|
+
}).catch((C) => {
|
|
2084
|
+
w.warn("[UIKit] auto clearConversationUnreadMessageCount failed:", E(C));
|
|
2085
|
+
}), (t == null ? void 0 : t.enableReadReceipt) !== !1 && (c.conversationType === M.SINGLECHAT || c.conversationType === M.GROUPCHAT) && Xt(s, c.conversationType, c.conversationId, c.msgServerId)), (t == null ? void 0 : t.enableAtMe) !== !1 && c.conversationType === M.GROUPCHAT && A(c.from) !== A(e.client.currentUser)) {
|
|
2086
|
+
const C = (v = c.ext) == null ? void 0 : v.em_at_list;
|
|
2087
|
+
Array.isArray(C) && C.includes(e.client.currentUser) && (e.conversation.setAtMe(c.conversationId, !0), e.message.addAtMeMessage(c.conversationId, l.msgServerId || l.msgLocalId));
|
|
2088
|
+
}
|
|
2089
|
+
zt(e, c);
|
|
2090
|
+
},
|
|
2091
|
+
/**
|
|
2092
|
+
* 流式消息(边生成边下发,典型 AI 对话)分片合并。
|
|
2093
|
+
* - 按 `msgServerId` 定位同一条 TEXT 消息,`body.content` 以 `stream.fullText`
|
|
2094
|
+
* (服务端排序合并后的累计全文)幂等覆盖,不依赖分片到达顺序 / deltaText 增量;
|
|
2095
|
+
* - 先到(onMessage 全量或首个分片)则只覆盖更新,未到则插入新消息(首个分片建气泡);
|
|
2096
|
+
* - `stream` 状态整体挂载到消息上,供渲染层展示传输中光标 / 终态收敛 / 异常提示,
|
|
2097
|
+
* 也供插件插槽按 `customType` 接管(markdown 等富类型)。
|
|
2098
|
+
*/
|
|
2099
|
+
onStreamMessage: (c) => {
|
|
2100
|
+
if (c.conversationType === "chatRoom")
|
|
2101
|
+
return;
|
|
2102
|
+
const l = c.stream;
|
|
2103
|
+
if (!l)
|
|
2104
|
+
return;
|
|
2105
|
+
w.info("onStreamMessage", {
|
|
2106
|
+
conversationId: c.conversationId,
|
|
2107
|
+
from: c.from,
|
|
2108
|
+
msgServerId: c.msgServerId,
|
|
2109
|
+
seq: l.seq,
|
|
2110
|
+
status: l.status,
|
|
2111
|
+
customType: l.customType
|
|
2112
|
+
});
|
|
2113
|
+
const m = c.msgServerId || c.msgLocalId;
|
|
2114
|
+
if (!m)
|
|
2115
|
+
return;
|
|
2116
|
+
if (!e.message.getMessages(c.conversationId).some(
|
|
2117
|
+
(h) => h.msgServerId === c.msgServerId || c.msgLocalId !== void 0 && h.msgLocalId === c.msgLocalId
|
|
2118
|
+
)) {
|
|
2119
|
+
e.message.addMessage(x(c, e.client.currentUser));
|
|
2120
|
+
return;
|
|
2121
|
+
}
|
|
2122
|
+
e.message.updateMessageById(m, {
|
|
2123
|
+
body: { ...c.body, content: l.fullText },
|
|
2124
|
+
stream: { ...l }
|
|
2125
|
+
});
|
|
2126
|
+
},
|
|
2127
|
+
onMessageRecalled: (c) => {
|
|
2128
|
+
c.conversationType !== "chatRoom" && (w.info("onMessageRecalled", { messageId: c.messageId }), e.message.recallMessage(c.messageId, e.client.currentUser), i && N(() => i(c.messageId, e.client.currentUser)), en(
|
|
2129
|
+
e,
|
|
2130
|
+
c.conversationId,
|
|
2131
|
+
c.conversationType,
|
|
2132
|
+
c.messageId
|
|
2133
|
+
));
|
|
2134
|
+
},
|
|
2135
|
+
onMessageDelivered: (c) => {
|
|
2136
|
+
w.info("onMessageDelivered", { messageId: c.messageId }), e.message.updateMessageStatus(c.messageId, k.DELIVERED), r && N(() => r(c.messageId, k.DELIVERED));
|
|
2137
|
+
},
|
|
2138
|
+
onMessageReadReceipts: (c) => {
|
|
2139
|
+
for (const l of c)
|
|
2140
|
+
if (l.conversationType === M.GROUPCHAT) {
|
|
2141
|
+
w.info("onMessageReadReceipts(group)", {
|
|
2142
|
+
conversationId: l.conversationId,
|
|
2143
|
+
details: l.receiptDetails.map((m) => ({ messageId: m.messageId, count: m.count }))
|
|
2144
|
+
});
|
|
2145
|
+
for (const m of l.receiptDetails)
|
|
2146
|
+
e.message.updateMessageById(m.messageId, { groupReadCount: m.count });
|
|
2147
|
+
} else {
|
|
2148
|
+
w.info("onMessageReadReceipts(single)", {
|
|
2149
|
+
conversationId: l.conversationId,
|
|
2150
|
+
total: l.messageIds.length,
|
|
2151
|
+
messageIds: l.messageIds.slice(0, 5)
|
|
2152
|
+
});
|
|
2153
|
+
for (const m of l.messageIds)
|
|
2154
|
+
e.message.updateMessageStatus(m, k.READ), r && N(() => r(m, k.READ));
|
|
2155
|
+
}
|
|
2156
|
+
},
|
|
2157
|
+
onMessageUpdated: (c) => {
|
|
2158
|
+
c.conversationType !== "chatRoom" && (w.info("onMessageUpdated", { messageId: c.messageId }), e.message.updateMessageById(c.messageId, {
|
|
2159
|
+
body: c.message.body,
|
|
2160
|
+
ext: c.message.ext,
|
|
2161
|
+
modifiedInfo: c.message.modifiedInfo,
|
|
2162
|
+
modified: !0
|
|
2163
|
+
}), u && N(() => u(
|
|
2164
|
+
c.messageId,
|
|
2165
|
+
c.message.body,
|
|
2166
|
+
c.message.ext,
|
|
2167
|
+
c.message.modifiedInfo
|
|
2168
|
+
)));
|
|
2169
|
+
},
|
|
2170
|
+
onPinnedMessageChanged: async (c) => {
|
|
2171
|
+
if (c.conversationType !== "chatRoom" && (w.info("onPinnedMessageChanged", { conversationId: c.conversationId, operation: c.operation }), !!c.messageId && (c.operation === "pin" ? e.message.setMessagePinned(c.messageId, {
|
|
2172
|
+
operatorId: c.operatorId || "",
|
|
2173
|
+
pinTime: c.pinTime || Date.now()
|
|
2174
|
+
}) : c.operation === "unpin" && e.message.setMessageUnpinned(c.messageId), c.conversationId && c.conversationType)))
|
|
2175
|
+
try {
|
|
2176
|
+
const m = (await s.chatManager.getPinnedMessageList({
|
|
2177
|
+
conversationId: c.conversationId,
|
|
2178
|
+
conversationType: c.conversationType
|
|
2179
|
+
})).items.map((p) => x(p.message, e.client.currentUser));
|
|
2180
|
+
e.message.setPinnedMessages(c.conversationId, m);
|
|
2181
|
+
} catch (l) {
|
|
2182
|
+
w.warn("refresh pinned messages failed:", l);
|
|
2183
|
+
}
|
|
2184
|
+
},
|
|
2185
|
+
onMultiDeviceConversation: (c) => {
|
|
2186
|
+
if (w.info("onMultiDeviceConversation", { operation: c.operation }), c.operation === "ALL_CONVERSATIONS_UNREAD_MESSAGE_COUNT_CLEARED") {
|
|
2187
|
+
for (const p of e.conversation.conversationList)
|
|
2188
|
+
e.conversation.updateUnreadCount(p.id, 0);
|
|
2189
|
+
return;
|
|
2190
|
+
}
|
|
2191
|
+
const { operation: l, conversationId: m } = c;
|
|
2192
|
+
switch (l) {
|
|
2193
|
+
case "CONVERSATION_DELETED":
|
|
2194
|
+
e.conversation.deleteConversation(m);
|
|
2195
|
+
break;
|
|
2196
|
+
case "CONVERSATION_PINNED":
|
|
2197
|
+
e.conversation.updateConversation(m, { isPinned: !0 });
|
|
2198
|
+
break;
|
|
2199
|
+
case "CONVERSATION_UNPINNED":
|
|
2200
|
+
e.conversation.updateConversation(m, { isPinned: !1 });
|
|
2201
|
+
break;
|
|
2202
|
+
case "CONVERSATION_UNREAD_MESSAGE_COUNT_CLEARED":
|
|
2203
|
+
e.conversation.updateUnreadCount(m, 0);
|
|
2204
|
+
break;
|
|
2205
|
+
case "CONVERSATION_MARK":
|
|
2206
|
+
c.mark !== void 0 && e.conversation.updateConversation(m, { marks: [c.mark] });
|
|
2207
|
+
break;
|
|
2208
|
+
case "CONVERSATION_MUTE_INFO_CHANGED":
|
|
2209
|
+
c.remindType && e.conversation.updateConversation(m, {
|
|
2210
|
+
isMuted: c.remindType === "NONE",
|
|
2211
|
+
remindType: c.remindType
|
|
2212
|
+
});
|
|
2213
|
+
break;
|
|
2214
|
+
default:
|
|
2215
|
+
w.warn("onMultiDeviceConversation unhandled:", c);
|
|
2216
|
+
}
|
|
2217
|
+
},
|
|
2218
|
+
onMultiDeviceMessageRemoved: (c) => {
|
|
2219
|
+
w.info("onMultiDeviceMessageRemoved", { conversationId: c.conversationId, operation: c.operation, messageIds: c.messageIds });
|
|
2220
|
+
const { operation: l, conversationId: m, messageIds: p, beforeTimestamp: h } = c;
|
|
2221
|
+
if (!(!m || l !== "MESSAGE_REMOVED")) {
|
|
2222
|
+
if (p && p.length > 0)
|
|
2223
|
+
e.message.deleteMessages([...p]), d && N(() => d([...p]));
|
|
2224
|
+
else if (h) {
|
|
2225
|
+
const b = e.message.getMessages(m).filter((v) => v.timestamp && v.timestamp < h).map((v) => v.msgServerId || v.msgLocalId).filter((v) => !!v);
|
|
2226
|
+
b.length > 0 && (e.message.deleteMessages(b), d && N(() => d(b)));
|
|
2227
|
+
}
|
|
2228
|
+
}
|
|
2229
|
+
}
|
|
2230
|
+
};
|
|
2231
|
+
}
|
|
2232
|
+
const K = R("UIKit:ContactEvents");
|
|
2233
|
+
function De(s, e = "pending") {
|
|
2234
|
+
const t = s.userInfo, n = s.from;
|
|
2235
|
+
return {
|
|
2236
|
+
id: n,
|
|
2237
|
+
type: "contact",
|
|
2238
|
+
userId: n,
|
|
2239
|
+
nickname: t == null ? void 0 : t.nickname,
|
|
2240
|
+
avatarUrl: t == null ? void 0 : t.avatarUrl,
|
|
2241
|
+
// 0.16.0 起 payload.status 重命名为 payload.message
|
|
2242
|
+
reason: s.message,
|
|
2243
|
+
status: e,
|
|
2244
|
+
timestamp: Date.now()
|
|
2245
|
+
};
|
|
2246
|
+
}
|
|
2247
|
+
function nn(s) {
|
|
2248
|
+
const { t: e, insertChatNotice: t } = O();
|
|
2249
|
+
return {
|
|
2250
|
+
onContactInvited: (n) => {
|
|
2251
|
+
K.info("onContactInvited", { from: n.from });
|
|
2252
|
+
const o = n.from, a = o ? s.contact.getContact(o) : void 0;
|
|
2253
|
+
s.contact.addInvite(De(n, a ? "accepted" : "pending"));
|
|
2254
|
+
},
|
|
2255
|
+
onContactAgreed: (n) => {
|
|
2256
|
+
K.info("onContactAgreed", { from: n.from });
|
|
2257
|
+
const o = n.from;
|
|
2258
|
+
if (!o)
|
|
2259
|
+
return;
|
|
2260
|
+
s.contact.getInvite(o) && s.contact.updateInviteStatus(o, "accepted"), s.contact.addContact({ userId: o, name: o });
|
|
2261
|
+
},
|
|
2262
|
+
onContactRefuse: (n) => {
|
|
2263
|
+
K.info("onContactRefuse", { from: n.from });
|
|
2264
|
+
const o = n.from;
|
|
2265
|
+
o && (s.contact.getInvite(o) ? s.contact.updateInviteStatus(o, "declined") : s.contact.addInvite({ ...De(n, "declined"), outgoing: !0, unread: !0 }), Ue(s, o, "declined"));
|
|
2266
|
+
},
|
|
2267
|
+
onContactDeleted: (n) => {
|
|
2268
|
+
K.info("onContactDeleted", { from: n.from });
|
|
2269
|
+
const o = n.from;
|
|
2270
|
+
o && (s.contact.removeContact(o), s.contact.removeInvite(o), t(s, o, M.SINGLECHAT, {
|
|
2271
|
+
eventType: G.CONTACT_DELETED,
|
|
2272
|
+
params: {},
|
|
2273
|
+
defaultText: e("chat.notice.contactDeleted")
|
|
2274
|
+
}), Ue(s, o, "deleted"));
|
|
2275
|
+
},
|
|
2276
|
+
onContactAdded: (n) => {
|
|
2277
|
+
K.info("onContactAdded", { from: n.from });
|
|
2278
|
+
const o = n.from;
|
|
2279
|
+
o && (s.contact.addContact({ userId: o, name: o }), s.contact.removeInvite(o), t(s, o, M.SINGLECHAT, {
|
|
2280
|
+
eventType: G.CONTACT_ADDED,
|
|
2281
|
+
params: {},
|
|
2282
|
+
defaultText: e("chat.notice.contactAdded")
|
|
2283
|
+
}));
|
|
2284
|
+
},
|
|
2285
|
+
onContactInfoUpdated: (n) => {
|
|
2286
|
+
var a, r;
|
|
2287
|
+
K.info("onContactInfoUpdated", { userId: (a = n.contact) == null ? void 0 : a.userId });
|
|
2288
|
+
const o = n.contact;
|
|
2289
|
+
if (o != null && o.userId && o.remark !== void 0) {
|
|
2290
|
+
s.contact.updateContactRemark(o.userId, o.remark);
|
|
2291
|
+
const i = o.remark || ((r = n.userInfo) == null ? void 0 : r.nickname) || o.userId;
|
|
2292
|
+
s.conversation.updateConversation(o.userId, { name: i });
|
|
2293
|
+
}
|
|
2294
|
+
}
|
|
2295
|
+
};
|
|
2296
|
+
}
|
|
2297
|
+
const y = R("UIKit:GroupEvents");
|
|
2298
|
+
function _e(s, e = "pending") {
|
|
2299
|
+
const t = s.groupId, n = "inviter" in s ? s.inviter : void 0, o = "groupName" in s ? s.groupName : void 0;
|
|
2300
|
+
return {
|
|
2301
|
+
id: t,
|
|
2302
|
+
type: "group",
|
|
2303
|
+
groupId: t,
|
|
2304
|
+
groupName: o,
|
|
2305
|
+
inviterId: n == null ? void 0 : n.userId,
|
|
2306
|
+
inviterName: n == null ? void 0 : n.nickname,
|
|
2307
|
+
reason: "reason" in s ? s.reason : void 0,
|
|
2308
|
+
status: e,
|
|
2309
|
+
timestamp: Date.now()
|
|
2310
|
+
};
|
|
2311
|
+
}
|
|
2312
|
+
function Z(s, e, t, n) {
|
|
2313
|
+
const { t: o, resolveNoticeUserName: a } = O();
|
|
2314
|
+
if (s.length === 0)
|
|
2315
|
+
return "";
|
|
2316
|
+
const r = s[0];
|
|
2317
|
+
if (s.length === 1) {
|
|
2318
|
+
const d = r.userId === e ? o("chat.notice.you") : a(r);
|
|
2319
|
+
return o(t).replace("{name}", d);
|
|
2320
|
+
}
|
|
2321
|
+
const i = s.find((d) => d.userId !== e), u = a(i || r);
|
|
2322
|
+
return o(n).replace("{name}", u).replace("{count}", String(s.length));
|
|
2323
|
+
}
|
|
2324
|
+
function ee(s, e) {
|
|
2325
|
+
const { t, resolveNoticeUserName: n } = O(), o = s.find((r) => r.userId !== e) ?? s[0];
|
|
2326
|
+
return {
|
|
2327
|
+
name: (o == null ? void 0 : o.userId) === e ? t("chat.notice.you") : n(o),
|
|
2328
|
+
count: s.length,
|
|
2329
|
+
userIds: s.map((r) => r.userId).join(",")
|
|
2330
|
+
};
|
|
2331
|
+
}
|
|
2332
|
+
function sn(s) {
|
|
2333
|
+
const { t: e, insertChatNotice: t, buildAnnouncementNoticeText: n, resolveNoticeUserName: o } = O();
|
|
2334
|
+
function a(r) {
|
|
2335
|
+
return s.group.groupList.some((i) => i.groupId === r);
|
|
2336
|
+
}
|
|
2337
|
+
return {
|
|
2338
|
+
onInvitationReceived: (r) => {
|
|
2339
|
+
y.info("onInvitationReceived raw payload", r);
|
|
2340
|
+
const i = _e(r, a(r.groupId) ? "accepted" : "pending");
|
|
2341
|
+
s.contact.addInvite(i);
|
|
2342
|
+
},
|
|
2343
|
+
onInvitationAccepted: (r) => {
|
|
2344
|
+
y.info("onInvitationAccepted raw payload", r), s.contact.updateInviteStatus(r.groupId, "accepted");
|
|
2345
|
+
},
|
|
2346
|
+
onInvitationDeclined: (r) => {
|
|
2347
|
+
y.info("onInvitationDeclined raw payload", r), s.contact.updateInviteStatus(r.groupId, "declined");
|
|
2348
|
+
},
|
|
2349
|
+
onAutoAcceptInvitationFromGroup: (r) => {
|
|
2350
|
+
y.info("onAutoAcceptInvitationFromGroup raw payload", r), s.contact.addInvite(_e(r, "accepted"));
|
|
2351
|
+
},
|
|
2352
|
+
onMembersJoined: (r) => {
|
|
2353
|
+
y.info("onMembersJoined raw payload", r);
|
|
2354
|
+
const i = r.members || [], u = s.client.currentUser;
|
|
2355
|
+
i.some((f) => f.userId === u) && (s.contact.getInvite(r.groupId) && s.contact.updateInviteStatus(r.groupId, "accepted"), s.group.getGroupById(r.groupId) || s.group.addGroup({ groupId: r.groupId, groupName: r.groupName })), s.group.incrementMemberCount(r.groupId, i.length);
|
|
2356
|
+
const g = Z(
|
|
2357
|
+
i,
|
|
2358
|
+
u || "",
|
|
2359
|
+
"chat.notice.memberJoined",
|
|
2360
|
+
"chat.notice.memberJoinedMultiple"
|
|
2361
|
+
);
|
|
2362
|
+
t(s, r.groupId, M.GROUPCHAT, {
|
|
2363
|
+
eventType: G.MEMBER_JOINED,
|
|
2364
|
+
params: ee(i, u || ""),
|
|
2365
|
+
defaultText: g
|
|
2366
|
+
});
|
|
2367
|
+
},
|
|
2368
|
+
onMembersExited: (r) => {
|
|
2369
|
+
const i = r.members || [];
|
|
2370
|
+
y.info("onMembersExited raw payload", r), s.group.decrementMemberCount(r.groupId, i.length);
|
|
2371
|
+
const u = Z(
|
|
2372
|
+
i,
|
|
2373
|
+
s.client.currentUser || "",
|
|
2374
|
+
"chat.notice.memberExited",
|
|
2375
|
+
"chat.notice.memberExitedMultiple"
|
|
2376
|
+
);
|
|
2377
|
+
t(s, r.groupId, M.GROUPCHAT, {
|
|
2378
|
+
eventType: G.MEMBER_EXITED,
|
|
2379
|
+
params: ee(i, s.client.currentUser || ""),
|
|
2380
|
+
defaultText: u
|
|
2381
|
+
});
|
|
2382
|
+
},
|
|
2383
|
+
onGroupInfoChanged: (r) => {
|
|
2384
|
+
y.info("onGroupInfoChanged raw payload", r);
|
|
2385
|
+
const i = r.groupInfo ?? r, u = i.name ?? i.groupName, d = s.group.getGroupById(r.groupId);
|
|
2386
|
+
s.group.updateGroup(r.groupId, {
|
|
2387
|
+
groupName: u,
|
|
2388
|
+
description: i.description,
|
|
2389
|
+
avatar: i.avatarUrl ?? i.avatar
|
|
2390
|
+
}), u && (d != null && d.groupName) && u !== d.groupName && (t(s, r.groupId, M.GROUPCHAT, {
|
|
2391
|
+
eventType: G.GROUP_NAME_CHANGED,
|
|
2392
|
+
params: { name: u },
|
|
2393
|
+
defaultText: e("chat.notice.groupNameChanged").replace("{name}", u)
|
|
2394
|
+
}), s.conversation.updateConversation(r.groupId, { name: u }));
|
|
2395
|
+
},
|
|
2396
|
+
onOwnerChanged: (r) => {
|
|
2397
|
+
var m, p, h, I, b, v;
|
|
2398
|
+
y.info("onOwnerChanged raw payload", r);
|
|
2399
|
+
const i = (m = s.group.getGroupById(r.groupId)) == null ? void 0 : m.owner, u = (h = (p = s.group).getPendingOwnerTransfer) == null ? void 0 : h.call(p, r.groupId), d = u || ((I = r.newOwner) == null ? void 0 : I.userId) || "", g = { owner: d }, f = s.client.currentUser || "";
|
|
2400
|
+
f && (f === d ? g.role = _.OWNER : f === i && (g.role = _.MEMBER)), s.group.updateGroup(r.groupId, g), d && s.group.updateGroupMemberRole(r.groupId, d, _.OWNER), i && i !== d && s.group.updateGroupMemberRole(r.groupId, i, _.MEMBER), u && ((v = (b = s.group).clearPendingOwnerTransfer) == null || v.call(b, r.groupId));
|
|
2401
|
+
const c = d === f ? e("chat.notice.you") : o(r.newOwner), l = e("chat.notice.ownerChanged").replace("{name}", c);
|
|
2402
|
+
t(s, r.groupId, M.GROUPCHAT, {
|
|
2403
|
+
eventType: G.OWNER_CHANGED,
|
|
2404
|
+
params: { name: c, ownerId: d },
|
|
2405
|
+
defaultText: l
|
|
2406
|
+
});
|
|
2407
|
+
},
|
|
2408
|
+
onAdminAdded: (r) => {
|
|
2409
|
+
var f;
|
|
2410
|
+
y.info("onAdminAdded raw payload", r);
|
|
2411
|
+
const i = (f = r.administrator) == null ? void 0 : f.userId;
|
|
2412
|
+
i && s.group.updateGroupMemberRole(r.groupId, i, _.ADMIN);
|
|
2413
|
+
const u = s.client.currentUser || "", d = i === u ? e("chat.notice.you") : o(r.administrator), g = e("chat.notice.adminAdded").replace("{name}", d);
|
|
2414
|
+
t(s, r.groupId, M.GROUPCHAT, {
|
|
2415
|
+
eventType: G.ADMIN_ADDED,
|
|
2416
|
+
params: { name: d, userId: i || "" },
|
|
2417
|
+
defaultText: g
|
|
2418
|
+
});
|
|
2419
|
+
},
|
|
2420
|
+
onAdminRemoved: (r) => {
|
|
2421
|
+
var f;
|
|
2422
|
+
y.info("onAdminRemoved raw payload", r);
|
|
2423
|
+
const i = (f = r.administrator) == null ? void 0 : f.userId;
|
|
2424
|
+
i && s.group.updateGroupMemberRole(r.groupId, i, _.MEMBER);
|
|
2425
|
+
const u = s.client.currentUser || "", d = i === u ? e("chat.notice.you") : o(r.administrator), g = e("chat.notice.adminRemoved").replace("{name}", d);
|
|
2426
|
+
t(s, r.groupId, M.GROUPCHAT, {
|
|
2427
|
+
eventType: G.ADMIN_REMOVED,
|
|
2428
|
+
params: { name: d, userId: i || "" },
|
|
2429
|
+
defaultText: g
|
|
2430
|
+
});
|
|
2431
|
+
},
|
|
2432
|
+
onUserRemoved: (r) => {
|
|
2433
|
+
y.info("onUserRemoved raw payload", r);
|
|
2434
|
+
const i = e("chat.notice.you");
|
|
2435
|
+
s.group.removeGroup(r.groupId), s.conversation.deleteConversation(r.groupId), s.message.clearConversationMessages(r.groupId);
|
|
2436
|
+
const u = e("chat.notice.userRemoved").replace("{name}", i);
|
|
2437
|
+
t(s, r.groupId, M.GROUPCHAT, {
|
|
2438
|
+
eventType: G.USER_REMOVED,
|
|
2439
|
+
params: { name: i },
|
|
2440
|
+
defaultText: u
|
|
2441
|
+
});
|
|
2442
|
+
},
|
|
2443
|
+
onGroupDestroyed: (r) => {
|
|
2444
|
+
var i;
|
|
2445
|
+
y.info("onGroupDestroyed raw payload", r), s.group.removeGroup(r.groupId), (((i = s.client.client) == null ? void 0 : i.deleteConversationOnGroupDestroyed) ?? !0) && (s.conversation.deleteConversation(r.groupId), s.message.clearConversationMessages(r.groupId)), t(s, r.groupId, M.GROUPCHAT, {
|
|
2446
|
+
eventType: G.GROUP_DESTROYED,
|
|
2447
|
+
params: {},
|
|
2448
|
+
defaultText: e("chat.notice.groupDestroyed")
|
|
2449
|
+
});
|
|
2450
|
+
},
|
|
2451
|
+
onAnnouncementChanged: (r) => {
|
|
2452
|
+
y.info("onAnnouncementChanged raw payload", r), s.group.updateGroup(r.groupId, { announcement: r.announcement }), s.group.setGroupAnnouncement(r.groupId, r.announcement), t(s, r.groupId, M.GROUPCHAT, {
|
|
2453
|
+
eventType: G.ANNOUNCEMENT_CHANGED,
|
|
2454
|
+
params: { announcement: r.announcement || "" },
|
|
2455
|
+
defaultText: n(r.announcement)
|
|
2456
|
+
});
|
|
2457
|
+
},
|
|
2458
|
+
onMuteListAdded: (r) => {
|
|
2459
|
+
y.info("onMuteListAdded raw payload", r);
|
|
2460
|
+
const i = (r.mutes || []).map((g) => ({
|
|
2461
|
+
userId: g.userId,
|
|
2462
|
+
muteExpire: r.muteExpire
|
|
2463
|
+
}));
|
|
2464
|
+
s.group.addGroupMuteMembers(r.groupId, i);
|
|
2465
|
+
const u = (r.mutes || []).map((g) => g.nickname || g.userId || ""), d = u.map((g) => e("group.mutelist.muteNotice").replace("{name}", g)).join("、");
|
|
2466
|
+
t(s, r.groupId, M.GROUPCHAT, {
|
|
2467
|
+
eventType: G.MUTE_ADDED,
|
|
2468
|
+
params: { names: u.join("、"), count: u.length },
|
|
2469
|
+
defaultText: d
|
|
2470
|
+
});
|
|
2471
|
+
},
|
|
2472
|
+
onMuteListRemoved: (r) => {
|
|
2473
|
+
y.info("onMuteListRemoved raw payload", r);
|
|
2474
|
+
const i = (r.mutes || []).map((g) => g.userId);
|
|
2475
|
+
s.group.removeGroupMuteMembers(r.groupId, i);
|
|
2476
|
+
const u = (r.mutes || []).map((g) => g.nickname || g.userId || ""), d = u.map((g) => e("group.mutelist.unmuteNotice").replace("{name}", g)).join("、");
|
|
2477
|
+
t(s, r.groupId, M.GROUPCHAT, {
|
|
2478
|
+
eventType: G.MUTE_REMOVED,
|
|
2479
|
+
params: { names: u.join("、"), count: u.length },
|
|
2480
|
+
defaultText: d
|
|
2481
|
+
});
|
|
2482
|
+
},
|
|
2483
|
+
onAllMemberMuteStateChanged: (r) => {
|
|
2484
|
+
y.info("onAllMemberMuteStateChanged raw payload", r), s.group.updateGroup(r.groupId, { mute: r.isMuted });
|
|
2485
|
+
const i = e(r.isMuted ? "group.mutelist.muteAllNotice" : "group.mutelist.unmuteAllNotice");
|
|
2486
|
+
t(s, r.groupId, M.GROUPCHAT, {
|
|
2487
|
+
eventType: G.ALL_MEMBER_MUTE_CHANGED,
|
|
2488
|
+
params: { muted: r.isMuted },
|
|
2489
|
+
defaultText: i
|
|
2490
|
+
});
|
|
2491
|
+
},
|
|
2492
|
+
onAllowListAdded: (r) => {
|
|
2493
|
+
y.info("onAllowListAdded raw payload", r);
|
|
2494
|
+
const i = (r.allowlist || []).map((d) => d.userId);
|
|
2495
|
+
s.group.addGroupAllowlistMembers(r.groupId, i);
|
|
2496
|
+
const u = Z(
|
|
2497
|
+
r.allowlist || [],
|
|
2498
|
+
s.client.currentUser || "",
|
|
2499
|
+
"chat.notice.allowlistAdded",
|
|
2500
|
+
"chat.notice.allowlistAddedMultiple"
|
|
2501
|
+
);
|
|
2502
|
+
t(s, r.groupId, M.GROUPCHAT, {
|
|
2503
|
+
eventType: G.ALLOWLIST_ADDED,
|
|
2504
|
+
params: ee(r.allowlist || [], s.client.currentUser || ""),
|
|
2505
|
+
defaultText: u
|
|
2506
|
+
});
|
|
2507
|
+
},
|
|
2508
|
+
onAllowListRemoved: (r) => {
|
|
2509
|
+
y.info("onAllowListRemoved raw payload", r);
|
|
2510
|
+
const i = (r.allowlist || []).map((d) => d.userId);
|
|
2511
|
+
s.group.removeGroupAllowlistMembers(r.groupId, i);
|
|
2512
|
+
const u = Z(
|
|
2513
|
+
r.allowlist || [],
|
|
2514
|
+
s.client.currentUser || "",
|
|
2515
|
+
"chat.notice.allowlistRemoved",
|
|
2516
|
+
"chat.notice.allowlistRemovedMultiple"
|
|
2517
|
+
);
|
|
2518
|
+
t(s, r.groupId, M.GROUPCHAT, {
|
|
2519
|
+
eventType: G.ALLOWLIST_REMOVED,
|
|
2520
|
+
params: ee(r.allowlist || [], s.client.currentUser || ""),
|
|
2521
|
+
defaultText: u
|
|
2522
|
+
});
|
|
2523
|
+
},
|
|
2524
|
+
onGroupDisabledChanged: (r) => {
|
|
2525
|
+
y.info("onGroupDisabledChanged raw payload", r), s.group.updateGroup(r.groupId, { disabled: r.disabled }), t(s, r.groupId, M.GROUPCHAT, {
|
|
2526
|
+
eventType: G.GROUP_DISABLED_CHANGED,
|
|
2527
|
+
params: { disabled: r.disabled },
|
|
2528
|
+
defaultText: e(r.disabled ? "chat.notice.groupDisabled" : "chat.notice.groupEnabled")
|
|
2529
|
+
});
|
|
2530
|
+
},
|
|
2531
|
+
onSharedFileAdded: (r) => {
|
|
2532
|
+
if (y.info("onSharedFileAdded raw payload", r), r.sharedFile) {
|
|
2533
|
+
s.group.addGroupSharedFile(r.groupId, r.sharedFile);
|
|
2534
|
+
const i = r.sharedFile.fileOwner, u = (i == null ? void 0 : i.userId) === s.client.currentUser ? e("chat.notice.you") : o(i), d = e("chat.notice.sharedFileAdded").replace("{name}", u || (i == null ? void 0 : i.userId) || "").replace("{fileName}", r.sharedFile.fileName);
|
|
2535
|
+
t(s, r.groupId, M.GROUPCHAT, {
|
|
2536
|
+
eventType: G.SHARED_FILE_ADDED,
|
|
2537
|
+
params: { name: u || (i == null ? void 0 : i.userId) || "", fileName: r.sharedFile.fileName },
|
|
2538
|
+
defaultText: d
|
|
2539
|
+
});
|
|
2540
|
+
}
|
|
2541
|
+
},
|
|
2542
|
+
onSharedFileDeleted: (r) => {
|
|
2543
|
+
y.info("onSharedFileDeleted raw payload", r), s.group.removeGroupSharedFile(r.groupId, r.fileId);
|
|
2544
|
+
},
|
|
2545
|
+
onRequestToJoinReceived: (r) => {
|
|
2546
|
+
var u;
|
|
2547
|
+
y.info("onRequestToJoinReceived raw payload", r);
|
|
2548
|
+
const i = s.group.getGroupJoinRequests(r.groupId);
|
|
2549
|
+
s.group.setGroupJoinRequests(r.groupId, [
|
|
2550
|
+
...i,
|
|
2551
|
+
{
|
|
2552
|
+
groupId: r.groupId,
|
|
2553
|
+
groupName: r.groupName,
|
|
2554
|
+
// 扁平化申请人 ID,供 accepted/declined 状态匹配使用
|
|
2555
|
+
applicantId: (u = r.applicant) == null ? void 0 : u.userId,
|
|
2556
|
+
applicant: r.applicant,
|
|
2557
|
+
reason: r.reason,
|
|
2558
|
+
status: "pending",
|
|
2559
|
+
timestamp: Date.now()
|
|
2560
|
+
}
|
|
2561
|
+
]);
|
|
2562
|
+
},
|
|
2563
|
+
onRequestToJoinAccepted: (r) => {
|
|
2564
|
+
y.info("onRequestToJoinAccepted raw payload", r);
|
|
2565
|
+
const i = s.client.currentUser, u = s.group.getGroupJoinRequests(r.groupId).filter((d) => {
|
|
2566
|
+
var g;
|
|
2567
|
+
return !(d.status === "pending" && (d.applicantId === i || ((g = d.applicant) == null ? void 0 : g.userId) === i));
|
|
2568
|
+
});
|
|
2569
|
+
s.group.setGroupJoinRequests(r.groupId, u);
|
|
2570
|
+
},
|
|
2571
|
+
onRequestToJoinDeclined: (r) => {
|
|
2572
|
+
var i;
|
|
2573
|
+
y.info("onRequestToJoinDeclined raw payload", r), s.group.updateGroupJoinRequest(
|
|
2574
|
+
r.groupId,
|
|
2575
|
+
((i = r.applicant) == null ? void 0 : i.userId) || "",
|
|
2576
|
+
"declined"
|
|
2577
|
+
);
|
|
2578
|
+
}
|
|
2579
|
+
};
|
|
2580
|
+
}
|
|
2581
|
+
const rn = R("UIKit:PresenceEvents");
|
|
2582
|
+
function on(s) {
|
|
2583
|
+
return {
|
|
2584
|
+
onPresenceStatusChange: (e) => {
|
|
2585
|
+
if (rn.info("onPresenceStatusChange", { count: Array.isArray(e) ? e.length : 0 }), !Array.isArray(e))
|
|
2586
|
+
return;
|
|
2587
|
+
const t = e.map((n) => {
|
|
2588
|
+
const o = n.userId || "", r = (Array.isArray(n.statusDetails) ? n.statusDetails : []).some((u) => Number(u == null ? void 0 : u.status) === 1), i = n.ext || "";
|
|
2589
|
+
return {
|
|
2590
|
+
userId: o,
|
|
2591
|
+
status: je(r, i),
|
|
2592
|
+
ext: i,
|
|
2593
|
+
lastTime: n.lastTime || Date.now()
|
|
2594
|
+
};
|
|
2595
|
+
}).filter((n) => !!n.userId);
|
|
2596
|
+
s.presence.updateBatch(t);
|
|
2597
|
+
}
|
|
2598
|
+
};
|
|
2599
|
+
}
|
|
2600
|
+
function an(s, e, t = {}, n, o) {
|
|
2601
|
+
const a = Wt(e, t), r = tn(s, e, n, o), i = nn(e), u = sn(e), d = on(e);
|
|
2602
|
+
return s.addEventHandler("uikit-conn", a), s.chatManager.addEventHandler("uikit-chat", r), s.contactManager.addEventHandler("uikit-contact", i), s.groupManager.addEventHandler("uikit-group", u), s.presenceManager.addEventHandler("uikit-presence", d), () => {
|
|
2603
|
+
s.removeEventHandler("uikit-conn"), s.chatManager.removeEventHandler("uikit-chat"), s.contactManager.removeEventHandler("uikit-contact"), s.groupManager.removeEventHandler("uikit-group"), s.presenceManager.removeEventHandler("uikit-presence"), Yt(), Qt();
|
|
2604
|
+
};
|
|
2605
|
+
}
|
|
2606
|
+
const T = R("UIKit:Websdk5Adapter"), cn = [
|
|
2607
|
+
ke,
|
|
2608
|
+
$e,
|
|
2609
|
+
ze,
|
|
2610
|
+
Ye,
|
|
2611
|
+
Xe,
|
|
2612
|
+
xe
|
|
2613
|
+
], un = [
|
|
2614
|
+
ke,
|
|
2615
|
+
Qe,
|
|
2616
|
+
xe
|
|
2617
|
+
];
|
|
2618
|
+
function dn() {
|
|
2619
|
+
return {
|
|
2620
|
+
enableContact: !0,
|
|
2621
|
+
enableBlocklist: !0,
|
|
2622
|
+
enablePresence: !0,
|
|
2623
|
+
presenceStrangerMode: "query-on-visible",
|
|
2624
|
+
fetchGroupMemberPresenceOnVisible: !0,
|
|
2625
|
+
contactFetchMode: "all",
|
|
2626
|
+
enableGroup: !0,
|
|
2627
|
+
enableUserInfo: !0,
|
|
2628
|
+
enableUserInfoSubscription: !0,
|
|
2629
|
+
enableInvitePersistence: !0,
|
|
2630
|
+
enableDraft: !0,
|
|
2631
|
+
enableAtMe: !0,
|
|
2632
|
+
enableTyping: !0,
|
|
2633
|
+
enableReadReceipt: !0,
|
|
2634
|
+
filterBlockedContacts: !0
|
|
2635
|
+
};
|
|
2636
|
+
}
|
|
2637
|
+
function ln(s) {
|
|
2638
|
+
if (s != null && s.fetchUserInfos)
|
|
2639
|
+
return { fetchUserInfos: s.fetchUserInfos };
|
|
2640
|
+
}
|
|
2641
|
+
function gn() {
|
|
2642
|
+
try {
|
|
2643
|
+
O();
|
|
2644
|
+
} catch {
|
|
2645
|
+
T.warn("[Websdk5Adapter] 事件层依赖未注入,使用最小兜底实现"), qe({
|
|
2646
|
+
t: (s) => s,
|
|
2647
|
+
insertChatNotice: () => {
|
|
2648
|
+
},
|
|
2649
|
+
buildAnnouncementNoticeText: (s) => s || "",
|
|
2650
|
+
resolveNoticeUserName: (s) => (s == null ? void 0 : s.nickname) || (s == null ? void 0 : s.userId) || "",
|
|
2651
|
+
useNotification: () => ({
|
|
2652
|
+
state: {
|
|
2653
|
+
value: {
|
|
2654
|
+
enabled: !1,
|
|
2655
|
+
browserEnabled: !1,
|
|
2656
|
+
inAppEnabled: !1,
|
|
2657
|
+
triggerMode: "background"
|
|
2658
|
+
}
|
|
2659
|
+
},
|
|
2660
|
+
notify: () => {
|
|
2661
|
+
},
|
|
2662
|
+
notifyBrowser: async () => !1
|
|
2663
|
+
}),
|
|
2664
|
+
emitNotificationDelivered: () => {
|
|
2665
|
+
}
|
|
2666
|
+
});
|
|
2667
|
+
}
|
|
2668
|
+
}
|
|
2669
|
+
function mn(s, e) {
|
|
2670
|
+
let t = !1, n = !1, o = !1;
|
|
2671
|
+
function a() {
|
|
2672
|
+
return n ? "connecting" : t ? "connected" : o ? "reconnectFailed" : "disconnected";
|
|
2673
|
+
}
|
|
2674
|
+
function r() {
|
|
2675
|
+
var i, u;
|
|
2676
|
+
(u = (i = e()) == null ? void 0 : i.onConnectStateChange) == null || u.call(i, a());
|
|
2677
|
+
}
|
|
2678
|
+
return {
|
|
2679
|
+
get currentUser() {
|
|
2680
|
+
return s.currentUserId || "";
|
|
2681
|
+
},
|
|
2682
|
+
get client() {
|
|
2683
|
+
return s.client ? { deleteConversationOnGroupDestroyed: s.client.deleteConversationOnGroupDestroyed } : null;
|
|
2684
|
+
},
|
|
2685
|
+
setConnected(i) {
|
|
2686
|
+
t = i, r();
|
|
2687
|
+
},
|
|
2688
|
+
setConnecting(i) {
|
|
2689
|
+
n = i, r();
|
|
2690
|
+
},
|
|
2691
|
+
setHasConnectedOnce(i) {
|
|
2692
|
+
o = i;
|
|
2693
|
+
},
|
|
2694
|
+
setKicked(i) {
|
|
2695
|
+
r();
|
|
2696
|
+
}
|
|
2697
|
+
};
|
|
2698
|
+
}
|
|
2699
|
+
function fn(s) {
|
|
2700
|
+
const e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map();
|
|
2701
|
+
let n = !1;
|
|
2702
|
+
function o(i) {
|
|
2703
|
+
return e.get(i) ?? [];
|
|
2704
|
+
}
|
|
2705
|
+
function a(i) {
|
|
2706
|
+
for (const [u, d] of e) {
|
|
2707
|
+
const g = d.findIndex((f) => f.msgServerId === i || f.msgLocalId === i);
|
|
2708
|
+
if (g >= 0)
|
|
2709
|
+
return { list: d, index: g, conversationId: u };
|
|
2710
|
+
}
|
|
2711
|
+
return null;
|
|
2712
|
+
}
|
|
2713
|
+
function r(i) {
|
|
2714
|
+
const u = i, d = e.get(u.conversationId) ?? [], g = d.findIndex(
|
|
2715
|
+
(f) => f.msgServerId && f.msgServerId === u.msgServerId
|
|
2716
|
+
);
|
|
2717
|
+
g >= 0 ? d[g] = u : d.push(u), d.sort((f, c) => (f.timestamp ?? 0) - (c.timestamp ?? 0)), e.set(u.conversationId, d);
|
|
2718
|
+
}
|
|
2719
|
+
return {
|
|
2720
|
+
getMessages: o,
|
|
2721
|
+
addMessage(i) {
|
|
2722
|
+
var u, d;
|
|
2723
|
+
r(i), (d = (u = s()) == null ? void 0 : u.onMessage) == null || d.call(u, i);
|
|
2724
|
+
},
|
|
2725
|
+
addSendingMessage(i, u) {
|
|
2726
|
+
t.set(i, u);
|
|
2727
|
+
},
|
|
2728
|
+
replaceWithSent(i, u) {
|
|
2729
|
+
var d, g;
|
|
2730
|
+
t.delete(i), r(u), (g = (d = s()) == null ? void 0 : d.onMessage) == null || g.call(d, u);
|
|
2731
|
+
},
|
|
2732
|
+
updateUploadProgress(i, u) {
|
|
2733
|
+
const d = t.get(i);
|
|
2734
|
+
if (!d)
|
|
2735
|
+
return;
|
|
2736
|
+
const g = a(d.msgLocalId || d.msgServerId || "");
|
|
2737
|
+
if (g) {
|
|
2738
|
+
const f = { ...g.list[g.index], progress: u };
|
|
2739
|
+
g.list[g.index] = f;
|
|
2740
|
+
}
|
|
2741
|
+
},
|
|
2742
|
+
markFailed(i, u) {
|
|
2743
|
+
const d = t.get(i);
|
|
2744
|
+
t.delete(i);
|
|
2745
|
+
const g = (d == null ? void 0 : d.msgLocalId) || (d == null ? void 0 : d.msgServerId);
|
|
2746
|
+
if (!g)
|
|
2747
|
+
return;
|
|
2748
|
+
const f = a(g);
|
|
2749
|
+
if (f) {
|
|
2750
|
+
const c = { ...f.list[f.index], status: "failed", failReason: u };
|
|
2751
|
+
f.list[f.index] = c;
|
|
2752
|
+
}
|
|
2753
|
+
},
|
|
2754
|
+
prependMessages(i, u) {
|
|
2755
|
+
const d = e.get(i) ?? [], g = /* @__PURE__ */ new Map();
|
|
2756
|
+
for (const c of u) {
|
|
2757
|
+
const l = c;
|
|
2758
|
+
l.msgServerId && g.set(l.msgServerId, l);
|
|
2759
|
+
}
|
|
2760
|
+
for (const c of d)
|
|
2761
|
+
c.msgServerId && !g.has(c.msgServerId) && g.set(c.msgServerId, c);
|
|
2762
|
+
const f = Array.from(g.values()).sort(
|
|
2763
|
+
(c, l) => (c.timestamp ?? 0) - (l.timestamp ?? 0)
|
|
2764
|
+
);
|
|
2765
|
+
e.set(i, f);
|
|
2766
|
+
},
|
|
2767
|
+
updateStatusByServerId(i, u) {
|
|
2768
|
+
var g, f;
|
|
2769
|
+
const d = a(i);
|
|
2770
|
+
d && (d.list[d.index] = { ...d.list[d.index], status: u }, (f = (g = s()) == null ? void 0 : g.onMessageStatusChanged) == null || f.call(g, { messageId: i, status: u }));
|
|
2771
|
+
},
|
|
2772
|
+
recallMessage(i, u) {
|
|
2773
|
+
var f, c;
|
|
2774
|
+
const d = a(i);
|
|
2775
|
+
if (!d)
|
|
2776
|
+
return;
|
|
2777
|
+
const g = d.list[d.index];
|
|
2778
|
+
g.recalled = !0, g.recalledBy = u, (c = (f = s()) == null ? void 0 : f.onMessagesRecalled) == null || c.call(f, {
|
|
2779
|
+
messageId: i,
|
|
2780
|
+
conversationId: d.conversationId,
|
|
2781
|
+
conversationType: g.conversationType,
|
|
2782
|
+
operatorId: u
|
|
2783
|
+
});
|
|
2784
|
+
},
|
|
2785
|
+
updateMessage(i, u) {
|
|
2786
|
+
var f, c;
|
|
2787
|
+
const d = a(i);
|
|
2788
|
+
if (!d)
|
|
2789
|
+
return;
|
|
2790
|
+
const g = u;
|
|
2791
|
+
d.list[d.index] = g, g.modified && ((c = (f = s()) == null ? void 0 : f.onMessageUpdated) == null || c.call(f, g));
|
|
2792
|
+
},
|
|
2793
|
+
setPinnedMessages(i, u) {
|
|
2794
|
+
},
|
|
2795
|
+
setTranslation(i, u) {
|
|
2796
|
+
const d = a(i);
|
|
2797
|
+
if (!d)
|
|
2798
|
+
return;
|
|
2799
|
+
const g = d.list[d.index];
|
|
2800
|
+
g.translation = u, g.showTranslation = !0;
|
|
2801
|
+
},
|
|
2802
|
+
setTranslating(i, u) {
|
|
2803
|
+
const d = a(i);
|
|
2804
|
+
d && (d.list[d.index] = { ...d.list[d.index], translating: u });
|
|
2805
|
+
},
|
|
2806
|
+
setVoiceText(i, u) {
|
|
2807
|
+
const d = a(i);
|
|
2808
|
+
if (!d)
|
|
2809
|
+
return;
|
|
2810
|
+
const g = d.list[d.index];
|
|
2811
|
+
g.voiceText = u, g.showVoiceText = !0;
|
|
2812
|
+
},
|
|
2813
|
+
setVoiceTranscribing(i, u) {
|
|
2814
|
+
const d = a(i);
|
|
2815
|
+
d && (d.list[d.index] = { ...d.list[d.index], voiceTranscribing: u });
|
|
2816
|
+
},
|
|
2817
|
+
clearConversationMessages(i) {
|
|
2818
|
+
e.delete(i);
|
|
2819
|
+
},
|
|
2820
|
+
updateMessageById(i, u) {
|
|
2821
|
+
var c, l, m, p;
|
|
2822
|
+
const d = a(i);
|
|
2823
|
+
if (!d)
|
|
2824
|
+
return;
|
|
2825
|
+
const g = d.list[d.index], f = { ...g, ...u };
|
|
2826
|
+
d.list[d.index] = f, (u.modified || u.modifiedInfo) && ((l = (c = s()) == null ? void 0 : c.onMessageUpdated) == null || l.call(c, f)), u.status && u.status !== g.status && ((p = (m = s()) == null ? void 0 : m.onMessageStatusChanged) == null || p.call(m, {
|
|
2827
|
+
messageId: i,
|
|
2828
|
+
status: u.status
|
|
2829
|
+
}));
|
|
2830
|
+
},
|
|
2831
|
+
replaceMessageById(i, u) {
|
|
2832
|
+
var f, c;
|
|
2833
|
+
const d = a(i);
|
|
2834
|
+
if (!d)
|
|
2835
|
+
return;
|
|
2836
|
+
const g = u;
|
|
2837
|
+
d.list[d.index] = g, (c = (f = s()) == null ? void 0 : f.onMessageUpdated) == null || c.call(f, g);
|
|
2838
|
+
},
|
|
2839
|
+
addAtMeMessage(i, u) {
|
|
2840
|
+
var d, g;
|
|
2841
|
+
(g = (d = s()) == null ? void 0 : d.onAtMe) == null || g.call(d, { conversationId: i, messageId: u });
|
|
2842
|
+
},
|
|
2843
|
+
updateMessageStatus(i, u) {
|
|
2844
|
+
var g, f;
|
|
2845
|
+
const d = a(i);
|
|
2846
|
+
d && (d.list[d.index] = { ...d.list[d.index], status: u }, (f = (g = s()) == null ? void 0 : g.onMessageStatusChanged) == null || f.call(g, { messageId: i, status: u }));
|
|
2847
|
+
},
|
|
2848
|
+
setMessagePinned(i, u) {
|
|
2849
|
+
const d = a(i);
|
|
2850
|
+
if (!d)
|
|
2851
|
+
return;
|
|
2852
|
+
const g = d.list[d.index];
|
|
2853
|
+
g.pinned = !0, g.pinTime = u.pinTime, g.pinOperatorId = u.operatorId;
|
|
2854
|
+
},
|
|
2855
|
+
setMessageUnpinned(i) {
|
|
2856
|
+
const u = a(i);
|
|
2857
|
+
if (!u)
|
|
2858
|
+
return;
|
|
2859
|
+
const d = u.list[u.index];
|
|
2860
|
+
d.pinned = !1;
|
|
2861
|
+
},
|
|
2862
|
+
deleteMessages(i) {
|
|
2863
|
+
var g, f;
|
|
2864
|
+
const u = new Set(i), d = /* @__PURE__ */ new Map();
|
|
2865
|
+
for (const [c, l] of e) {
|
|
2866
|
+
const m = [];
|
|
2867
|
+
for (const p of l) {
|
|
2868
|
+
const h = p.msgServerId || p.msgLocalId;
|
|
2869
|
+
if (h && u.has(h)) {
|
|
2870
|
+
const I = d.get(c) ?? [];
|
|
2871
|
+
I.push(h), d.set(c, I);
|
|
2872
|
+
} else
|
|
2873
|
+
m.push(p);
|
|
2874
|
+
}
|
|
2875
|
+
e.set(c, m);
|
|
2876
|
+
}
|
|
2877
|
+
for (const [c, l] of d)
|
|
2878
|
+
(f = (g = s()) == null ? void 0 : g.onMessagesDeleted) == null || f.call(g, { messageIds: l, conversationId: c });
|
|
2879
|
+
},
|
|
2880
|
+
setSyncingMessages(i) {
|
|
2881
|
+
var u, d;
|
|
2882
|
+
n !== i && (n = i, (d = (u = s()) == null ? void 0 : u.onSyncStatus) == null || d.call(u, {
|
|
2883
|
+
type: "message",
|
|
2884
|
+
status: i ? "syncing" : "success"
|
|
2885
|
+
}));
|
|
2886
|
+
}
|
|
2887
|
+
};
|
|
2888
|
+
}
|
|
2889
|
+
function pn(s) {
|
|
2890
|
+
let e = [], t = null, n = !1;
|
|
2891
|
+
function o() {
|
|
2892
|
+
var a, r;
|
|
2893
|
+
(r = (a = s()) == null ? void 0 : a.onConversationChange) == null || r.call(a, e);
|
|
2894
|
+
}
|
|
2895
|
+
return {
|
|
2896
|
+
get conversationList() {
|
|
2897
|
+
return e;
|
|
2898
|
+
},
|
|
2899
|
+
get currentConversationId() {
|
|
2900
|
+
return t;
|
|
2901
|
+
},
|
|
2902
|
+
get conversationsLoaded() {
|
|
2903
|
+
return n;
|
|
2904
|
+
},
|
|
2905
|
+
setList(a) {
|
|
2906
|
+
e = a, o();
|
|
2907
|
+
},
|
|
2908
|
+
setCurrentConversationId(a) {
|
|
2909
|
+
t = a;
|
|
2910
|
+
},
|
|
2911
|
+
setSyncing(a) {
|
|
2912
|
+
},
|
|
2913
|
+
delete(a) {
|
|
2914
|
+
var r, i;
|
|
2915
|
+
e = e.filter((u) => u.id !== a), (i = (r = s()) == null ? void 0 : r.onConversationDeleted) == null || i.call(r, a);
|
|
2916
|
+
},
|
|
2917
|
+
update(a, r) {
|
|
2918
|
+
var u, d;
|
|
2919
|
+
const i = e.findIndex((g) => g.id === a);
|
|
2920
|
+
i < 0 || (e[i] = { ...e[i], ...r }, o(), (d = (u = s()) == null ? void 0 : u.onConversationUpdated) == null || d.call(u, { id: a, conversation: r }));
|
|
2921
|
+
},
|
|
2922
|
+
setConversationList(a) {
|
|
2923
|
+
this.setList(a);
|
|
2924
|
+
},
|
|
2925
|
+
addConversation(a) {
|
|
2926
|
+
const r = e.findIndex((i) => i.id === a.id);
|
|
2927
|
+
r >= 0 ? e[r] = a : e.push(a), o();
|
|
2928
|
+
},
|
|
2929
|
+
deleteConversation(a) {
|
|
2930
|
+
this.delete(a);
|
|
2931
|
+
},
|
|
2932
|
+
updateConversation(a, r) {
|
|
2933
|
+
this.update(a, r);
|
|
2934
|
+
},
|
|
2935
|
+
setConversationsLoaded(a) {
|
|
2936
|
+
n = a;
|
|
2937
|
+
},
|
|
2938
|
+
setSyncingConversations(a) {
|
|
2939
|
+
},
|
|
2940
|
+
setTyping(a, r) {
|
|
2941
|
+
var i, u;
|
|
2942
|
+
(u = (i = s()) == null ? void 0 : i.onTyping) == null || u.call(i, { conversationId: a, userId: r });
|
|
2943
|
+
},
|
|
2944
|
+
setAtMe(a, r) {
|
|
2945
|
+
},
|
|
2946
|
+
updateUnreadCount(a, r) {
|
|
2947
|
+
this.update(a, { unreadCount: r });
|
|
2948
|
+
}
|
|
2949
|
+
};
|
|
2950
|
+
}
|
|
2951
|
+
function hn(s) {
|
|
2952
|
+
let e = [], t = [];
|
|
2953
|
+
function o() {
|
|
2954
|
+
var r, i;
|
|
2955
|
+
(i = (r = s()) == null ? void 0 : r.onContactChange) == null || i.call(r, e);
|
|
2956
|
+
}
|
|
2957
|
+
function a() {
|
|
2958
|
+
var r, i;
|
|
2959
|
+
(i = (r = s()) == null ? void 0 : r.onInviteChange) == null || i.call(r, t);
|
|
2960
|
+
}
|
|
2961
|
+
return {
|
|
2962
|
+
get contactList() {
|
|
2963
|
+
return e;
|
|
2964
|
+
},
|
|
2965
|
+
get loaded() {
|
|
2966
|
+
return !1;
|
|
2967
|
+
},
|
|
2968
|
+
setList(r) {
|
|
2969
|
+
e = r, o();
|
|
2970
|
+
},
|
|
2971
|
+
addContact(r) {
|
|
2972
|
+
var u, d;
|
|
2973
|
+
const i = e.findIndex((g) => g.userId === r.userId);
|
|
2974
|
+
i >= 0 ? e[i] = { ...e[i], ...r } : e.push(r), o(), (d = (u = s()) == null ? void 0 : u.onContactUpdated) == null || d.call(u, r);
|
|
2975
|
+
},
|
|
2976
|
+
removeContact(r) {
|
|
2977
|
+
var u, d;
|
|
2978
|
+
const i = e.find((g) => g.userId === r);
|
|
2979
|
+
e = e.filter((g) => g.userId !== r), i && (o(), (d = (u = s()) == null ? void 0 : u.onContactUpdated) == null || d.call(u, i));
|
|
2980
|
+
},
|
|
2981
|
+
updateRemark(r, i) {
|
|
2982
|
+
var d, g;
|
|
2983
|
+
const u = e.findIndex((f) => f.userId === r);
|
|
2984
|
+
u < 0 || (e[u] = { ...e[u], remark: i, name: i || e[u].name }, o(), (g = (d = s()) == null ? void 0 : d.onContactUpdated) == null || g.call(d, e[u]));
|
|
2985
|
+
},
|
|
2986
|
+
setBlocklist(r) {
|
|
2987
|
+
},
|
|
2988
|
+
addInvite(r) {
|
|
2989
|
+
const i = t.findIndex((u) => u.id === r.id);
|
|
2990
|
+
i >= 0 ? t[i] = { ...t[i], ...r } : t.push(r), a();
|
|
2991
|
+
},
|
|
2992
|
+
removeInvite(r) {
|
|
2993
|
+
t = t.filter((i) => i.id !== r), a();
|
|
2994
|
+
},
|
|
2995
|
+
updateInviteStatus(r, i) {
|
|
2996
|
+
const u = t.findIndex((d) => d.id === r);
|
|
2997
|
+
u < 0 || (t[u] = { ...t[u], status: i }, a());
|
|
2998
|
+
},
|
|
2999
|
+
getContact(r) {
|
|
3000
|
+
return e.find((i) => i.userId === r);
|
|
3001
|
+
},
|
|
3002
|
+
getInvite(r) {
|
|
3003
|
+
return t.find((i) => i.id === r);
|
|
3004
|
+
},
|
|
3005
|
+
setContactList(r) {
|
|
3006
|
+
this.setList(r);
|
|
3007
|
+
},
|
|
3008
|
+
updateContactRemark(r, i) {
|
|
3009
|
+
this.updateRemark(r, i);
|
|
3010
|
+
}
|
|
3011
|
+
};
|
|
3012
|
+
}
|
|
3013
|
+
function vn(s) {
|
|
3014
|
+
let e = [];
|
|
3015
|
+
const t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), u = /* @__PURE__ */ new Map(), d = /* @__PURE__ */ new Set(), g = !1;
|
|
3016
|
+
function f() {
|
|
3017
|
+
var c, l;
|
|
3018
|
+
(l = (c = s()) == null ? void 0 : c.onGroupChange) == null || l.call(c, e);
|
|
3019
|
+
}
|
|
3020
|
+
return {
|
|
3021
|
+
get groupList() {
|
|
3022
|
+
return e;
|
|
3023
|
+
},
|
|
3024
|
+
get loaded() {
|
|
3025
|
+
return g;
|
|
3026
|
+
},
|
|
3027
|
+
setList(c) {
|
|
3028
|
+
e = c, f();
|
|
3029
|
+
},
|
|
3030
|
+
addGroup(c) {
|
|
3031
|
+
var m, p;
|
|
3032
|
+
const l = e.findIndex((h) => h.groupId === c.groupId);
|
|
3033
|
+
l >= 0 ? e[l] = { ...e[l], ...c } : e.push(c), f(), (p = (m = s()) == null ? void 0 : m.onGroupUpdated) == null || p.call(m, c);
|
|
3034
|
+
},
|
|
3035
|
+
removeGroup(c) {
|
|
3036
|
+
var m, p;
|
|
3037
|
+
const l = e.find((h) => h.groupId === c);
|
|
3038
|
+
e = e.filter((h) => h.groupId !== c), l && (f(), (p = (m = s()) == null ? void 0 : m.onGroupUpdated) == null || p.call(m, l));
|
|
3039
|
+
},
|
|
3040
|
+
updateGroup(c, l) {
|
|
3041
|
+
var p, h;
|
|
3042
|
+
const m = e.findIndex((I) => I.groupId === c);
|
|
3043
|
+
m < 0 || (e[m] = { ...e[m], ...l }, f(), (h = (p = s()) == null ? void 0 : p.onGroupUpdated) == null || h.call(p, e[m]));
|
|
3044
|
+
},
|
|
3045
|
+
setGroupMembers(c, l) {
|
|
3046
|
+
var m, p;
|
|
3047
|
+
t.set(c, l), (p = (m = s()) == null ? void 0 : m.onGroupMembersChanged) == null || p.call(m, { groupId: c, members: l });
|
|
3048
|
+
},
|
|
3049
|
+
appendGroupMembers(c, l) {
|
|
3050
|
+
var I, b;
|
|
3051
|
+
const m = t.get(c) ?? [], p = new Map(m.map((v) => [v.userId, v]));
|
|
3052
|
+
for (const v of l)
|
|
3053
|
+
p.set(v.userId, v);
|
|
3054
|
+
const h = Array.from(p.values());
|
|
3055
|
+
t.set(c, h), (b = (I = s()) == null ? void 0 : I.onGroupMembersChanged) == null || b.call(I, { groupId: c, members: h });
|
|
3056
|
+
},
|
|
3057
|
+
removeGroupMembers(c, l) {
|
|
3058
|
+
var h, I;
|
|
3059
|
+
const m = new Set(l), p = (t.get(c) ?? []).filter((b) => !m.has(b.userId));
|
|
3060
|
+
t.set(c, p), (I = (h = s()) == null ? void 0 : h.onGroupMembersChanged) == null || I.call(h, { groupId: c, members: p });
|
|
3061
|
+
},
|
|
3062
|
+
updateGroupMemberRole(c, l, m) {
|
|
3063
|
+
var I, b;
|
|
3064
|
+
const p = t.get(c) ?? [], h = p.findIndex((v) => v.userId === l);
|
|
3065
|
+
h < 0 || (p[h] = { ...p[h], role: m }, t.set(c, p), (b = (I = s()) == null ? void 0 : I.onGroupMembersChanged) == null || b.call(I, { groupId: c, members: p }));
|
|
3066
|
+
},
|
|
3067
|
+
setGroupAnnouncement(c, l) {
|
|
3068
|
+
var m, p;
|
|
3069
|
+
n.set(c, l), (p = (m = s()) == null ? void 0 : m.onGroupAnnouncementChanged) == null || p.call(m, { groupId: c, announcement: l });
|
|
3070
|
+
},
|
|
3071
|
+
isGroupAdminSynced(c) {
|
|
3072
|
+
return d.has(c);
|
|
3073
|
+
},
|
|
3074
|
+
markGroupAdminSynced(c) {
|
|
3075
|
+
d.add(c);
|
|
3076
|
+
},
|
|
3077
|
+
setGroupMuteList(c, l) {
|
|
3078
|
+
o.set(c, l);
|
|
3079
|
+
},
|
|
3080
|
+
addGroupMuteMembers(c, l) {
|
|
3081
|
+
const m = o.get(c) ?? [], p = Array.isArray(l) && l.length > 0 && typeof l[0] == "string" ? l : l.map((h) => h.userId);
|
|
3082
|
+
for (const h of p)
|
|
3083
|
+
m.some((I) => I.userId === h) || m.push({ userId: h });
|
|
3084
|
+
o.set(c, m);
|
|
3085
|
+
},
|
|
3086
|
+
removeGroupMuteMembers(c, l) {
|
|
3087
|
+
const m = new Set(l);
|
|
3088
|
+
o.set(c, (o.get(c) ?? []).filter((p) => !m.has(p.userId)));
|
|
3089
|
+
},
|
|
3090
|
+
setGroupBlocklist(c, l) {
|
|
3091
|
+
a.set(c, l);
|
|
3092
|
+
},
|
|
3093
|
+
addGroupBlocklistMembers(c, l) {
|
|
3094
|
+
const m = a.get(c) ?? [];
|
|
3095
|
+
for (const p of l)
|
|
3096
|
+
m.some((h) => h.userId === p) || m.push({ userId: p });
|
|
3097
|
+
a.set(c, m);
|
|
3098
|
+
},
|
|
3099
|
+
removeGroupBlocklistMembers(c, l) {
|
|
3100
|
+
const m = new Set(l);
|
|
3101
|
+
a.set(c, (a.get(c) ?? []).filter((p) => !m.has(p.userId)));
|
|
3102
|
+
},
|
|
3103
|
+
setGroupAllowlist(c, l) {
|
|
3104
|
+
r.set(c, l);
|
|
3105
|
+
},
|
|
3106
|
+
addGroupAllowlistMembers(c, l) {
|
|
3107
|
+
const m = r.get(c) ?? [];
|
|
3108
|
+
for (const p of l)
|
|
3109
|
+
m.some((h) => h.userId === p) || m.push({ userId: p });
|
|
3110
|
+
r.set(c, m);
|
|
3111
|
+
},
|
|
3112
|
+
removeGroupAllowlistMembers(c, l) {
|
|
3113
|
+
const m = new Set(l);
|
|
3114
|
+
r.set(c, (r.get(c) ?? []).filter((p) => !m.has(p.userId)));
|
|
3115
|
+
},
|
|
3116
|
+
setGroupList(c) {
|
|
3117
|
+
this.setList(c);
|
|
3118
|
+
},
|
|
3119
|
+
getGroupById(c) {
|
|
3120
|
+
return e.find((l) => l.groupId === c);
|
|
3121
|
+
},
|
|
3122
|
+
incrementMemberCount(c, l) {
|
|
3123
|
+
const m = this.getGroupById(c);
|
|
3124
|
+
m && this.updateGroup(c, { memberCount: (m.memberCount ?? 0) + l });
|
|
3125
|
+
},
|
|
3126
|
+
decrementMemberCount(c, l) {
|
|
3127
|
+
const m = this.getGroupById(c);
|
|
3128
|
+
m && this.updateGroup(c, { memberCount: Math.max(0, (m.memberCount ?? 0) - l) });
|
|
3129
|
+
},
|
|
3130
|
+
addGroupSharedFile(c, l) {
|
|
3131
|
+
const m = i.get(c) ?? [];
|
|
3132
|
+
m.push(l), i.set(c, m);
|
|
3133
|
+
},
|
|
3134
|
+
removeGroupSharedFile(c, l) {
|
|
3135
|
+
i.set(c, (i.get(c) ?? []).filter((m) => m.fileId !== l));
|
|
3136
|
+
},
|
|
3137
|
+
getGroupJoinRequests(c) {
|
|
3138
|
+
return u.get(c) ?? [];
|
|
3139
|
+
},
|
|
3140
|
+
setGroupJoinRequests(c, l) {
|
|
3141
|
+
u.set(c, l);
|
|
3142
|
+
},
|
|
3143
|
+
updateGroupJoinRequest(c, l, m) {
|
|
3144
|
+
const h = (u.get(c) ?? []).find(
|
|
3145
|
+
(I) => {
|
|
3146
|
+
var b;
|
|
3147
|
+
return I.applicantId === l || ((b = I.applicant) == null ? void 0 : b.userId) === l;
|
|
3148
|
+
}
|
|
3149
|
+
);
|
|
3150
|
+
h && (h.status = m);
|
|
3151
|
+
}
|
|
3152
|
+
};
|
|
3153
|
+
}
|
|
3154
|
+
function In(s) {
|
|
3155
|
+
let e = [];
|
|
3156
|
+
const t = /* @__PURE__ */ new Set();
|
|
3157
|
+
return {
|
|
3158
|
+
updateBatch(n) {
|
|
3159
|
+
var a, r;
|
|
3160
|
+
const o = new Map(e.map((i) => [i.userId, i]));
|
|
3161
|
+
for (const i of n)
|
|
3162
|
+
o.set(i.userId, i);
|
|
3163
|
+
e = Array.from(o.values()), (r = (a = s()) == null ? void 0 : a.onPresenceChanged) == null || r.call(a, e);
|
|
3164
|
+
},
|
|
3165
|
+
setSubscribed(n) {
|
|
3166
|
+
for (const o of n)
|
|
3167
|
+
t.add(o);
|
|
3168
|
+
}
|
|
3169
|
+
};
|
|
3170
|
+
}
|
|
3171
|
+
function Mn(s) {
|
|
3172
|
+
const e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Set();
|
|
3173
|
+
let a = !1;
|
|
3174
|
+
const r = /* @__PURE__ */ new Map();
|
|
3175
|
+
function i() {
|
|
3176
|
+
var u, d;
|
|
3177
|
+
(d = (u = s()) == null ? void 0 : u.onUserInfoChanged) == null || d.call(u, Array.from(e.values()));
|
|
3178
|
+
}
|
|
3179
|
+
return {
|
|
3180
|
+
getUserInfo(u) {
|
|
3181
|
+
return e.get(u);
|
|
3182
|
+
},
|
|
3183
|
+
setUserInfo(u) {
|
|
3184
|
+
e.set(u.userId, u), i();
|
|
3185
|
+
},
|
|
3186
|
+
setUserInfos(u) {
|
|
3187
|
+
for (const d of u)
|
|
3188
|
+
e.set(d.userId, d);
|
|
3189
|
+
i();
|
|
3190
|
+
},
|
|
3191
|
+
areAttributesFetched(u, d) {
|
|
3192
|
+
const g = r.get(u);
|
|
3193
|
+
return g ? d.every((f) => g.has(f)) : !1;
|
|
3194
|
+
},
|
|
3195
|
+
markFetchedAttributes(u, d) {
|
|
3196
|
+
for (const g of u) {
|
|
3197
|
+
const f = r.get(g) ?? /* @__PURE__ */ new Set();
|
|
3198
|
+
for (const c of d)
|
|
3199
|
+
f.add(c);
|
|
3200
|
+
r.set(g, f);
|
|
3201
|
+
}
|
|
3202
|
+
},
|
|
3203
|
+
markLoading(u) {
|
|
3204
|
+
for (const d of u)
|
|
3205
|
+
t.add(d);
|
|
3206
|
+
},
|
|
3207
|
+
markLoaded(u) {
|
|
3208
|
+
for (const d of u)
|
|
3209
|
+
t.delete(d);
|
|
3210
|
+
},
|
|
3211
|
+
markFetchFailed(u) {
|
|
3212
|
+
for (const d of u)
|
|
3213
|
+
n.add(d);
|
|
3214
|
+
},
|
|
3215
|
+
isFetchFailed(u) {
|
|
3216
|
+
return n.has(u);
|
|
3217
|
+
},
|
|
3218
|
+
markSubscribed(u) {
|
|
3219
|
+
for (const d of u)
|
|
3220
|
+
o.add(d);
|
|
3221
|
+
},
|
|
3222
|
+
markUnsubscribed(u) {
|
|
3223
|
+
for (const d of u)
|
|
3224
|
+
o.delete(d);
|
|
3225
|
+
},
|
|
3226
|
+
markSubscribeFailed(u) {
|
|
3227
|
+
for (const d of u)
|
|
3228
|
+
n.add(d);
|
|
3229
|
+
},
|
|
3230
|
+
isSubscribeFailed(u) {
|
|
3231
|
+
return n.has(u);
|
|
3232
|
+
},
|
|
3233
|
+
disableSubscription() {
|
|
3234
|
+
a = !0;
|
|
3235
|
+
},
|
|
3236
|
+
isSubscriptionDisabled() {
|
|
3237
|
+
return a;
|
|
3238
|
+
},
|
|
3239
|
+
isSubscribed(u) {
|
|
3240
|
+
return o.has(u);
|
|
3241
|
+
},
|
|
3242
|
+
isLoading(u) {
|
|
3243
|
+
return t.has(u);
|
|
3244
|
+
}
|
|
3245
|
+
};
|
|
3246
|
+
}
|
|
3247
|
+
class _n {
|
|
3248
|
+
constructor(e) {
|
|
3249
|
+
this.injectedClient = e, this.capabilities = {
|
|
3250
|
+
combineMessage: !0,
|
|
3251
|
+
pinnedMessage: !0,
|
|
3252
|
+
streamingMessage: !0,
|
|
3253
|
+
groupReadReceipt: !0,
|
|
3254
|
+
// 本 adapter 遵循的契约版本(协商机制见 contract capabilities.ts)
|
|
3255
|
+
contractVersion: dt
|
|
3256
|
+
}, this._client = null, this._handlersSet = /* @__PURE__ */ new Set(), this._eventsRegistered = !1, this._registerImEvents = !0;
|
|
3257
|
+
}
|
|
3258
|
+
/** 原生 SDK 客户端实例(UIKitClient 包装,可选) */
|
|
3259
|
+
get client() {
|
|
3260
|
+
return this._client;
|
|
3261
|
+
}
|
|
3262
|
+
/** 当前登录用户 ID(未登录时为空字符串) */
|
|
3263
|
+
get currentUserId() {
|
|
3264
|
+
var e;
|
|
3265
|
+
return ((e = this._client) == null ? void 0 : e.currentUserId) ?? "";
|
|
3266
|
+
}
|
|
3267
|
+
/** 当前连接是否就绪(Domain 层短路守卫用) */
|
|
3268
|
+
get isConnected() {
|
|
3269
|
+
var e;
|
|
3270
|
+
return ((e = this._client) == null ? void 0 : e.isConnected) ?? !1;
|
|
3271
|
+
}
|
|
3272
|
+
/** 业务域对象集合:供 uikit-im / uikit-core 直接消费既有 Domain API */
|
|
3273
|
+
get domains() {
|
|
3274
|
+
if (!this._domains || !this._userInfoDomain)
|
|
3275
|
+
throw new Error("[Websdk5Adapter] 尚未初始化,请先调用 init()");
|
|
3276
|
+
return { ...this._domains, userInfo: this._userInfoDomain };
|
|
3277
|
+
}
|
|
3278
|
+
async init(e) {
|
|
3279
|
+
const t = e.adapterConfig ?? {}, {
|
|
3280
|
+
features: n,
|
|
3281
|
+
dataSource: o,
|
|
3282
|
+
stores: a,
|
|
3283
|
+
eventDeps: r,
|
|
3284
|
+
onUserInfoSubscriptionPermissionError: i,
|
|
3285
|
+
registerImEvents: u,
|
|
3286
|
+
managerPreset: d,
|
|
3287
|
+
repositories: g,
|
|
3288
|
+
persistence: f,
|
|
3289
|
+
...c
|
|
3290
|
+
} = t, l = e.repositories ?? g, m = e.persistence ?? f;
|
|
3291
|
+
this._persistence = m, this._client = this.injectedClient ?? wt({
|
|
3292
|
+
appKey: e.appKey,
|
|
3293
|
+
debug: e.debug,
|
|
3294
|
+
managers: c.managers ?? (d === "chatroom" ? un : cn),
|
|
3295
|
+
...c
|
|
3296
|
+
}), r && qe(r), this._features = n ?? dn(), this._registerImEvents = u !== !1;
|
|
3297
|
+
const p = a ? Object.keys(a) : [];
|
|
3298
|
+
if (T.info("[Websdk5Adapter] init 开始", {
|
|
3299
|
+
mode: this.injectedClient ? "injected-client" : "builtin",
|
|
3300
|
+
managerPreset: d ?? "im",
|
|
3301
|
+
registerImEvents: this._registerImEvents,
|
|
3302
|
+
injectedStores: p
|
|
3303
|
+
}), p.length < 7) {
|
|
3304
|
+
const v = ["client", "message", "conversation", "contact", "group", "presence", "userInfo"];
|
|
3305
|
+
T.debug(
|
|
3306
|
+
"[Websdk5Adapter] 以下 store 域未注入,回落 adapter 内置 store:",
|
|
3307
|
+
v.filter((C) => !p.includes(C))
|
|
3308
|
+
);
|
|
3309
|
+
}
|
|
3310
|
+
const h = () => this._getFanout(), b = { ...{
|
|
3311
|
+
client: mn(this, h),
|
|
3312
|
+
message: fn(h),
|
|
3313
|
+
conversation: pn(h),
|
|
3314
|
+
contact: hn(h),
|
|
3315
|
+
group: vn(h),
|
|
3316
|
+
presence: In(h),
|
|
3317
|
+
userInfo: Mn(h)
|
|
3318
|
+
}, ...a };
|
|
3319
|
+
this._stores = b, this._domains = {
|
|
3320
|
+
message: new _t(this._client, b.message, {
|
|
3321
|
+
messageRepository: l == null ? void 0 : l.message,
|
|
3322
|
+
persistence: m == null ? void 0 : m.message
|
|
3323
|
+
}),
|
|
3324
|
+
conversation: new Pt(this._client, b.conversation, {
|
|
3325
|
+
sendPendingReadReceipts: (v, C) => {
|
|
3326
|
+
var U, P;
|
|
3327
|
+
((U = this._features) == null ? void 0 : U.enableReadReceipt) !== !1 && ((P = this._domains) == null || P.message.sendPendingReadReceipts(v, C));
|
|
3328
|
+
},
|
|
3329
|
+
resolveSenderName: (v) => {
|
|
3330
|
+
var U;
|
|
3331
|
+
const C = b.contact.getContact(v);
|
|
3332
|
+
return C != null && C.remark || C != null && C.name ? C.remark || C.name : (U = b.userInfo.getUserInfo(v)) == null ? void 0 : U.nickname;
|
|
3333
|
+
},
|
|
3334
|
+
conversationRepository: l == null ? void 0 : l.conversation,
|
|
3335
|
+
persistence: m == null ? void 0 : m.conversation
|
|
3336
|
+
}),
|
|
3337
|
+
contact: new Ht(this._client, b.contact, {
|
|
3338
|
+
contactRepository: l == null ? void 0 : l.contact
|
|
3339
|
+
}),
|
|
3340
|
+
group: new jt(this._client, b.group, {
|
|
3341
|
+
groupRepository: l == null ? void 0 : l.group
|
|
3342
|
+
}),
|
|
3343
|
+
presence: new Vt(this._client, b.presence, {
|
|
3344
|
+
presenceRepository: l == null ? void 0 : l.presence
|
|
3345
|
+
})
|
|
3346
|
+
}, this._userInfoDomain = new qt(
|
|
3347
|
+
this._client,
|
|
3348
|
+
b.userInfo,
|
|
3349
|
+
(l == null ? void 0 : l.userInfo) ?? ln(o) ?? {},
|
|
3350
|
+
i ?? (() => T.warn("[Websdk5Adapter] 用户资料订阅无权限,已自动熔断"))
|
|
3351
|
+
), this._userInfoDomain.listen(), this._setupEventHandlers(), T.info("[Websdk5Adapter] init 完成");
|
|
3352
|
+
}
|
|
3353
|
+
async login(e, t) {
|
|
3354
|
+
var n, o, a, r, i, u, d;
|
|
3355
|
+
if (!this._client)
|
|
3356
|
+
throw new Error("[Websdk5Adapter] 尚未初始化,请先调用 init()");
|
|
3357
|
+
this._eventsRegistered || (T.debug("[Websdk5Adapter] 登出后重新登录,恢复事件处理器与用户资料监听"), (n = this._userInfoDomain) == null || n.listen(), this._setupEventHandlers()), T.info("[Websdk5Adapter] login 开始", { user: e }), (r = (o = this._stores) == null ? void 0 : (a = o.client).setCurrentUser) == null || r.call(a, e);
|
|
3358
|
+
try {
|
|
3359
|
+
await this._client.login(e, t);
|
|
3360
|
+
} catch (g) {
|
|
3361
|
+
throw (d = (i = this._stores) == null ? void 0 : (u = i.client).setCurrentUser) == null || d.call(u, ""), T.error("[Websdk5Adapter] login 失败:", E(g)), g;
|
|
3362
|
+
}
|
|
3363
|
+
T.info("[Websdk5Adapter] login 成功", { user: e });
|
|
3364
|
+
}
|
|
3365
|
+
async logout() {
|
|
3366
|
+
var e, t, n, o;
|
|
3367
|
+
T.info("[Websdk5Adapter] logout"), await ((e = this._client) == null ? void 0 : e.logout()), (t = this._disposeEventHandlers) == null || t.call(this), this._disposeEventHandlers = void 0, (n = this._disposeSyncListener) == null || n.call(this), this._disposeSyncListener = void 0, (o = this._userInfoDomain) == null || o.dispose(), this._eventsRegistered = !1;
|
|
3368
|
+
}
|
|
3369
|
+
/** 订阅中立事件,返回取消订阅函数(支持多方订阅,内部扇出派发) */
|
|
3370
|
+
subscribe(e) {
|
|
3371
|
+
return this._handlersSet.add(e), () => {
|
|
3372
|
+
this._handlersSet.delete(e);
|
|
3373
|
+
};
|
|
3374
|
+
}
|
|
3375
|
+
/** 扇出派发:把同一次内部 store 写入翻译给全部订阅者 */
|
|
3376
|
+
_getFanout() {
|
|
3377
|
+
if (!this._fanout) {
|
|
3378
|
+
const e = this._handlersSet;
|
|
3379
|
+
this._fanout = new Proxy({}, {
|
|
3380
|
+
get: (t, n) => (...o) => {
|
|
3381
|
+
for (const a of e) {
|
|
3382
|
+
const r = a[n];
|
|
3383
|
+
typeof r == "function" && r(...o);
|
|
3384
|
+
}
|
|
3385
|
+
}
|
|
3386
|
+
});
|
|
3387
|
+
}
|
|
3388
|
+
return this._fanout;
|
|
3389
|
+
}
|
|
3390
|
+
_setupEventHandlers() {
|
|
3391
|
+
var e, t;
|
|
3392
|
+
if (!(!this._client || !this._stores)) {
|
|
3393
|
+
if (!this._registerImEvents) {
|
|
3394
|
+
T.debug("[Websdk5Adapter] IM 事件套件已关闭(registerImEvents=false),场景事件由业务经 onAdapterReady 自行注册");
|
|
3395
|
+
return;
|
|
3396
|
+
}
|
|
3397
|
+
gn(), (e = this._disposeSyncListener) == null || e.call(this), this._disposeSyncListener = Jt((n) => {
|
|
3398
|
+
var o, a;
|
|
3399
|
+
(a = (o = this._getFanout()).onSyncStatus) == null || a.call(o, n);
|
|
3400
|
+
}), (t = this._disposeEventHandlers) == null || t.call(this), this._disposeEventHandlers = an(
|
|
3401
|
+
this._client,
|
|
3402
|
+
this._stores,
|
|
3403
|
+
{
|
|
3404
|
+
onTokenWillExpire: () => {
|
|
3405
|
+
var n, o;
|
|
3406
|
+
return (o = (n = this._getFanout()).onTokenWillExpire) == null ? void 0 : o.call(n);
|
|
3407
|
+
},
|
|
3408
|
+
onTokenExpired: () => {
|
|
3409
|
+
var n, o;
|
|
3410
|
+
return (o = (n = this._getFanout()).onTokenExpired) == null ? void 0 : o.call(n);
|
|
3411
|
+
}
|
|
3412
|
+
},
|
|
3413
|
+
this._features,
|
|
3414
|
+
this._persistence
|
|
3415
|
+
), this._eventsRegistered = !0, T.debug("[Websdk5Adapter] SDK 事件处理器已注册");
|
|
3416
|
+
}
|
|
3417
|
+
}
|
|
3418
|
+
get message() {
|
|
3419
|
+
if (!this._domains)
|
|
3420
|
+
throw new Error("[Websdk5Adapter] 尚未初始化,请先调用 init()");
|
|
3421
|
+
const e = this._domains.message, t = this._domains.conversation;
|
|
3422
|
+
return {
|
|
3423
|
+
loadMessages: async (n, o, a, r) => {
|
|
3424
|
+
const i = await e.fetchHistory(n, o, a, r);
|
|
3425
|
+
return {
|
|
3426
|
+
list: i.list,
|
|
3427
|
+
cursor: i.cursor,
|
|
3428
|
+
hasMore: i.hasMore
|
|
3429
|
+
};
|
|
3430
|
+
},
|
|
3431
|
+
sendText: (n, o, a, r, i) => e.sendText(n, o, a, r, i),
|
|
3432
|
+
sendImage: (n, o, a, r, i) => e.sendImage(n, o, a, r, i),
|
|
3433
|
+
sendFile: (n, o, a, r, i) => e.sendFile(n, o, a, r, i),
|
|
3434
|
+
sendVoice: (n, o, a, r, i, u) => e.sendVoice(n, o, a, r, i, u),
|
|
3435
|
+
sendVideo: (n, o, a, r, i, u) => e.sendVideo(n, o, a, r, i, u),
|
|
3436
|
+
// 契约的 needReadReceipt 未透传:domain sendLocation 无此参数(SDK 不支持位置消息回执)
|
|
3437
|
+
sendLocation: (n, o, a, r, i, u) => e.sendLocation(n, o, a, r, i, u),
|
|
3438
|
+
sendCustom: (n, o, a, r, i) => {
|
|
3439
|
+
const u = r ? Object.fromEntries(Object.entries(r).map(([d, g]) => [d, String(g)])) : void 0;
|
|
3440
|
+
return e.sendCustom(n, o, a, u, i);
|
|
3441
|
+
},
|
|
3442
|
+
sendCmd: (n, o, a, r) => e.sendCmd(n, o, a, r),
|
|
3443
|
+
// 契约 sendCombine 无 compatibleText 参数,domain 侧以空串占位
|
|
3444
|
+
sendCombine: (n, o, a, r, i, u) => e.sendCombine(n, o, a, r, "", i, u),
|
|
3445
|
+
recall: (n, o, a) => e.recall(n, o, a),
|
|
3446
|
+
markMessagesRead: (n, o, a) => e.markMessagesRead(n, o, a),
|
|
3447
|
+
markConversationRead: (n, o) => t.markRead(n, o),
|
|
3448
|
+
modifyText: (n, o, a, r) => e.modifyText(n, o, a, r),
|
|
3449
|
+
getGroupReadReceiptUsers: async (n, o, a, r) => {
|
|
3450
|
+
const i = await e.getGroupMessageReadUsers(n, o, a, r);
|
|
3451
|
+
return {
|
|
3452
|
+
list: i.users.map((u) => ({ userId: u.userId, timestamp: u.timestamp })),
|
|
3453
|
+
cursor: i.cursor || void 0,
|
|
3454
|
+
hasMore: i.hasMore
|
|
3455
|
+
};
|
|
3456
|
+
}
|
|
3457
|
+
};
|
|
3458
|
+
}
|
|
3459
|
+
get conversation() {
|
|
3460
|
+
if (!this._domains)
|
|
3461
|
+
throw new Error("[Websdk5Adapter] 尚未初始化,请先调用 init()");
|
|
3462
|
+
const e = this._domains.conversation;
|
|
3463
|
+
return {
|
|
3464
|
+
fetchConversations: async () => ({ list: e.syncLocal(), cursor: void 0, hasMore: !1 })
|
|
3465
|
+
};
|
|
3466
|
+
}
|
|
3467
|
+
get contact() {
|
|
3468
|
+
if (!this._domains)
|
|
3469
|
+
throw new Error("[Websdk5Adapter] 尚未初始化,请先调用 init()");
|
|
3470
|
+
const e = this._domains.contact;
|
|
3471
|
+
return {
|
|
3472
|
+
// 经 domain.fetchContacts 读取:注入 contact.fetchContacts 时由 domain 委托覆盖
|
|
3473
|
+
fetchContacts: async (t, n) => e.fetchContacts(t, n),
|
|
3474
|
+
fetchBlocklist: async () => e.syncBlocklist(),
|
|
3475
|
+
addContact: async (t, n) => {
|
|
3476
|
+
await e.addContact(t, n);
|
|
3477
|
+
},
|
|
3478
|
+
deleteContact: async (t) => {
|
|
3479
|
+
await e.deleteContact(t);
|
|
3480
|
+
},
|
|
3481
|
+
setRemark: async (t, n) => {
|
|
3482
|
+
await e.setRemark(t, n);
|
|
3483
|
+
},
|
|
3484
|
+
addToBlocklist: async (t) => {
|
|
3485
|
+
await e.addToBlocklist(t);
|
|
3486
|
+
},
|
|
3487
|
+
removeFromBlocklist: async (t) => {
|
|
3488
|
+
await e.removeFromBlocklist(t);
|
|
3489
|
+
}
|
|
3490
|
+
};
|
|
3491
|
+
}
|
|
3492
|
+
get group() {
|
|
3493
|
+
if (!this._domains)
|
|
3494
|
+
throw new Error("[Websdk5Adapter] 尚未初始化,请先调用 init()");
|
|
3495
|
+
const e = this._domains.group;
|
|
3496
|
+
return {
|
|
3497
|
+
// 经 domain.fetchGroups 读取:注入 group.fetchGroups 时由 domain 委托覆盖
|
|
3498
|
+
fetchGroups: async (t, n) => e.fetchGroups(t, n),
|
|
3499
|
+
fetchGroupInfo: async (t) => e.fetchGroupInfo(t),
|
|
3500
|
+
createGroup: async (t) => e.createGroup(t),
|
|
3501
|
+
joinGroup: async (t, n) => {
|
|
3502
|
+
await e.joinGroup(t, n);
|
|
3503
|
+
},
|
|
3504
|
+
leaveGroup: async (t) => {
|
|
3505
|
+
await e.leaveGroup(t);
|
|
3506
|
+
},
|
|
3507
|
+
destroyGroup: async (t) => {
|
|
3508
|
+
await e.destroyGroup(t);
|
|
3509
|
+
},
|
|
3510
|
+
fetchGroupMembers: async (t, n, o) => e.fetchGroupMembers(t, n, o),
|
|
3511
|
+
removeGroupMembers: async (t, n) => {
|
|
3512
|
+
await e.removeGroupMembers(t, n);
|
|
3513
|
+
},
|
|
3514
|
+
inviteUsersToGroup: async (t, n) => {
|
|
3515
|
+
await e.inviteUsersToGroup(t, n);
|
|
3516
|
+
},
|
|
3517
|
+
addGroupAdmin: async (t, n) => {
|
|
3518
|
+
await e.addGroupAdmin(t, n);
|
|
3519
|
+
},
|
|
3520
|
+
removeGroupAdmin: async (t, n) => {
|
|
3521
|
+
await e.removeGroupAdmin(t, n);
|
|
3522
|
+
},
|
|
3523
|
+
changeGroupOwner: async (t, n) => {
|
|
3524
|
+
await e.changeGroupOwner(t, n);
|
|
3525
|
+
},
|
|
3526
|
+
updateGroupInfo: async (t, n) => {
|
|
3527
|
+
await e.updateGroupInfo(t, n);
|
|
3528
|
+
},
|
|
3529
|
+
updateGroupConfigs: async (t, n) => {
|
|
3530
|
+
await e.updateGroupConfigs(t, n);
|
|
3531
|
+
},
|
|
3532
|
+
muteAllGroupMembers: async (t) => {
|
|
3533
|
+
await e.muteAllGroupMembers(t);
|
|
3534
|
+
},
|
|
3535
|
+
unmuteAllGroupMembers: async (t) => {
|
|
3536
|
+
await e.unmuteAllGroupMembers(t);
|
|
3537
|
+
},
|
|
3538
|
+
muteGroupMembers: async (t, n, o) => {
|
|
3539
|
+
await e.muteGroupMembers(t, n, o);
|
|
3540
|
+
},
|
|
3541
|
+
unmuteGroupMembers: async (t, n) => {
|
|
3542
|
+
await e.unmuteGroupMembers(t, n);
|
|
3543
|
+
},
|
|
3544
|
+
updateGroupAnnouncement: async (t, n) => {
|
|
3545
|
+
await e.updateGroupAnnouncement(t, n);
|
|
3546
|
+
},
|
|
3547
|
+
acceptGroupInvitation: async (t) => {
|
|
3548
|
+
await e.acceptGroupInvitation(t);
|
|
3549
|
+
},
|
|
3550
|
+
declineGroupInvitation: async (t) => {
|
|
3551
|
+
await e.declineGroupInvitation(t);
|
|
3552
|
+
},
|
|
3553
|
+
acceptGroupJoinRequest: async (t, n) => {
|
|
3554
|
+
await e.acceptGroupJoinRequest(t, n);
|
|
3555
|
+
},
|
|
3556
|
+
rejectGroupJoinRequest: async (t, n, o) => {
|
|
3557
|
+
await e.rejectGroupJoinRequest(t, n, o);
|
|
3558
|
+
}
|
|
3559
|
+
};
|
|
3560
|
+
}
|
|
3561
|
+
get presence() {
|
|
3562
|
+
if (!this._domains)
|
|
3563
|
+
throw new Error("[Websdk5Adapter] 尚未初始化,请先调用 init()");
|
|
3564
|
+
const e = this._domains.presence;
|
|
3565
|
+
return {
|
|
3566
|
+
subscribe: async (t, n) => {
|
|
3567
|
+
await e.subscribe(t, n);
|
|
3568
|
+
},
|
|
3569
|
+
unsubscribe: async (t) => {
|
|
3570
|
+
await e.unsubscribe(t);
|
|
3571
|
+
},
|
|
3572
|
+
fetchStatus: async (t) => e.fetchStatus(t),
|
|
3573
|
+
publish: async (t) => {
|
|
3574
|
+
await e.publish(t);
|
|
3575
|
+
}
|
|
3576
|
+
};
|
|
3577
|
+
}
|
|
3578
|
+
get userInfo() {
|
|
3579
|
+
if (!this._userInfoDomain)
|
|
3580
|
+
throw new Error("[Websdk5Adapter] 尚未初始化,请先调用 init()");
|
|
3581
|
+
const e = this._userInfoDomain;
|
|
3582
|
+
return {
|
|
3583
|
+
fetchUserInfos: async (t, n) => e.fetchUserInfos(t, n),
|
|
3584
|
+
updateOwnInfo: async (t) => {
|
|
3585
|
+
await e.updateOwnInfo(t);
|
|
3586
|
+
},
|
|
3587
|
+
updateOwnInfoByAttribute: async (t, n) => {
|
|
3588
|
+
await e.updateOwnInfoByAttribute(t, n);
|
|
3589
|
+
},
|
|
3590
|
+
subscribeUserInfos: async (t) => {
|
|
3591
|
+
await e.subscribeUserInfos(t);
|
|
3592
|
+
},
|
|
3593
|
+
unsubscribeUsersInfo: async (t) => {
|
|
3594
|
+
await e.unsubscribeUsersInfo(t);
|
|
3595
|
+
},
|
|
3596
|
+
getSubscribedUsers: async () => e.getSubscribedUsers()
|
|
3597
|
+
};
|
|
3598
|
+
}
|
|
3599
|
+
}
|
|
3600
|
+
export {
|
|
3601
|
+
Te as ALL_USER_INFO_ATTRIBUTES,
|
|
3602
|
+
Ht as ContactDomain,
|
|
3603
|
+
Pt as ConversationDomain,
|
|
3604
|
+
jt as GroupDomain,
|
|
3605
|
+
_t as MessageDomain,
|
|
3606
|
+
Vt as PresenceDomain,
|
|
3607
|
+
bt as UIKitClient,
|
|
3608
|
+
qt as UserInfoDomain,
|
|
3609
|
+
un as WEBSDK5_CHATROOM_MANAGERS,
|
|
3610
|
+
cn as WEBSDK5_MANAGERS,
|
|
3611
|
+
_n as Websdk5Adapter,
|
|
3612
|
+
tn as createChatHandlers,
|
|
3613
|
+
wt as createClient,
|
|
3614
|
+
Wt as createConnectionHandlers,
|
|
3615
|
+
nn as createContactHandlers,
|
|
3616
|
+
sn as createGroupHandlers,
|
|
3617
|
+
on as createPresenceHandlers,
|
|
3618
|
+
Ge as defaultAdapterPreviewLabels,
|
|
3619
|
+
Gn as disableSdkLogCapture,
|
|
3620
|
+
Sn as enableSdkLogCapture,
|
|
3621
|
+
Rn as extractLastMessageText,
|
|
3622
|
+
At as extractSdkErrorReason,
|
|
3623
|
+
yt as extractSnippetText,
|
|
3624
|
+
E as formatSdkError,
|
|
3625
|
+
Tn as isMessageInConversation,
|
|
3626
|
+
An as isSdkDebugEnabled,
|
|
3627
|
+
Lt as markReadReceiptSent,
|
|
3628
|
+
xn as normalizeUserId,
|
|
3629
|
+
Ue as notifyContactEvent,
|
|
3630
|
+
zt as notifyOnNewMessage,
|
|
3631
|
+
je as parsePresenceStatus,
|
|
3632
|
+
an as registerEventHandlers,
|
|
3633
|
+
Yt as resetChatEventState,
|
|
3634
|
+
Qt as resetSyncStatus,
|
|
3635
|
+
Un as resolvePeerUserId,
|
|
3636
|
+
Gt as resolveSdkErrorCodeI18nKey,
|
|
3637
|
+
Et as resolveSdkErrorI18nKey,
|
|
3638
|
+
Ln as resolveSdkErrorMessage,
|
|
3639
|
+
We as resolveSenderDisplayName,
|
|
3640
|
+
$t as resolveUserDisplayName,
|
|
3641
|
+
qe as setEventHandlerDeps,
|
|
3642
|
+
ht as setSdkDebugGuard,
|
|
3643
|
+
yn as setSdkLogAppender,
|
|
3644
|
+
he as setSyncStatus,
|
|
3645
|
+
Jt as setSyncStatusListener,
|
|
3646
|
+
Ft as toUiContact,
|
|
3647
|
+
we as toUiContacts,
|
|
3648
|
+
Nt as toUiConversation,
|
|
3649
|
+
ae as toUiConversations,
|
|
3650
|
+
Ke as toUiGroup,
|
|
3651
|
+
Kt as toUiGroupMember,
|
|
3652
|
+
J as toUiGroupMembers,
|
|
3653
|
+
ce as toUiGroups,
|
|
3654
|
+
x as toUiMessage,
|
|
3655
|
+
En as toUiMessages,
|
|
3656
|
+
Dn as useSyncStatus
|
|
3657
|
+
};
|