@inter-digital/wasm-client-sdk 3.8.3-patch.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/LICENSE +661 -0
  2. package/README.md +156 -0
  3. package/assets/openIM.wasm +0 -0
  4. package/assets/sql-wasm.wasm +0 -0
  5. package/assets/version +1 -0
  6. package/assets/wasm_exec.js +575 -0
  7. package/lib/api/database/alter.d.ts +2 -0
  8. package/lib/api/database/black.d.ts +7 -0
  9. package/lib/api/database/conversation.d.ts +32 -0
  10. package/lib/api/database/friend.d.ts +12 -0
  11. package/lib/api/database/friendRequest.d.ts +7 -0
  12. package/lib/api/database/groupMember.d.ts +22 -0
  13. package/lib/api/database/groupRequest.d.ts +8 -0
  14. package/lib/api/database/groups.d.ts +14 -0
  15. package/lib/api/database/index.d.ts +20 -0
  16. package/lib/api/database/init.d.ts +3 -0
  17. package/lib/api/database/instance.d.ts +3 -0
  18. package/lib/api/database/localAppSdkVersion.d.ts +2 -0
  19. package/lib/api/database/message.d.ts +32 -0
  20. package/lib/api/database/notification.d.ts +3 -0
  21. package/lib/api/database/sendingMessages.d.ts +3 -0
  22. package/lib/api/database/stranger.d.ts +4 -0
  23. package/lib/api/database/superGroup.d.ts +6 -0
  24. package/lib/api/database/tableMaster.d.ts +1 -0
  25. package/lib/api/database/tempCacheChatLogs.d.ts +2 -0
  26. package/lib/api/database/unreadMessage.d.ts +2 -0
  27. package/lib/api/database/upload.d.ts +4 -0
  28. package/lib/api/database/users.d.ts +3 -0
  29. package/lib/api/database/versionSync.d.ts +3 -0
  30. package/lib/api/index.d.ts +2 -0
  31. package/lib/api/upload.d.ts +5 -0
  32. package/lib/api/worker.d.ts +1 -0
  33. package/lib/constant/index.d.ts +71 -0
  34. package/lib/index.d.ts +6 -0
  35. package/lib/index.es.js +2215 -0
  36. package/lib/index.js +2219 -0
  37. package/lib/index.umd.js +2225 -0
  38. package/lib/sdk/index.d.ts +232 -0
  39. package/lib/sdk/initialize.d.ts +5 -0
  40. package/lib/sqls/index.d.ts +20 -0
  41. package/lib/sqls/localAdminGroupRequests.d.ts +9 -0
  42. package/lib/sqls/localAppSdkVersion.d.ts +8 -0
  43. package/lib/sqls/localBlack.d.ts +12 -0
  44. package/lib/sqls/localChatLogsConversationID.d.ts +37 -0
  45. package/lib/sqls/localConversationUnreadMessages.d.ts +7 -0
  46. package/lib/sqls/localConversations.d.ts +35 -0
  47. package/lib/sqls/localFriend.d.ts +16 -0
  48. package/lib/sqls/localFriendRequest.d.ts +12 -0
  49. package/lib/sqls/localGroupMembers.d.ts +27 -0
  50. package/lib/sqls/localGroupRequests.d.ts +9 -0
  51. package/lib/sqls/localGroups.d.ts +16 -0
  52. package/lib/sqls/localNotification.d.ts +8 -0
  53. package/lib/sqls/localSendingMessages.d.ts +8 -0
  54. package/lib/sqls/localStranger.d.ts +8 -0
  55. package/lib/sqls/localSuperGroups.d.ts +10 -0
  56. package/lib/sqls/localTableMaster.d.ts +5 -0
  57. package/lib/sqls/localUpload.d.ts +10 -0
  58. package/lib/sqls/localUsers.d.ts +8 -0
  59. package/lib/sqls/localVersionSync.d.ts +9 -0
  60. package/lib/sqls/tempCacheLocalChatLogs.d.ts +6 -0
  61. package/lib/types/entity.d.ts +450 -0
  62. package/lib/types/enum.d.ts +143 -0
  63. package/lib/types/eventData.d.ts +51 -0
  64. package/lib/types/params.d.ts +415 -0
  65. package/lib/utils/emitter.d.ts +12 -0
  66. package/lib/utils/escape.d.ts +23 -0
  67. package/lib/utils/index.d.ts +7 -0
  68. package/lib/utils/is.d.ts +6 -0
  69. package/lib/utils/key.d.ts +3 -0
  70. package/lib/utils/logFormat.d.ts +1 -0
  71. package/lib/utils/response.d.ts +1 -0
  72. package/lib/utils/timer.d.ts +1 -0
  73. package/lib/utils/value.d.ts +6 -0
  74. package/lib/worker-legacy.js +1 -0
  75. package/lib/worker.js +1 -0
  76. package/package.json +94 -0
@@ -0,0 +1,2215 @@
1
+ // The reason for this strange abstraction is because we can't rely on
2
+ // nested worker support (Safari doesn't support it). We need to proxy
3
+ // creating a child worker through the main thread, and this requires
4
+ // a bit of glue code. We don't want to duplicate this code in each
5
+ // backend that needs it, so this module abstracts it out. It has to
6
+ // have a strange shape because we don't want to eagerly bundle the
7
+ // backend code, so users of this code need to pass an `() =>
8
+ // import('./worker.js')` expression to get the worker module to run.
9
+
10
+ function isWorker() {
11
+ return (
12
+ typeof WorkerGlobalScope !== 'undefined' &&
13
+ self instanceof WorkerGlobalScope
14
+ );
15
+ }
16
+
17
+ function makeStartWorkerFromMain(getModule) {
18
+ return (argBuffer, resultBuffer, parentWorker) => {
19
+ if (isWorker()) {
20
+ throw new Error(
21
+ '`startWorkerFromMain` should only be called from the main thread'
22
+ );
23
+ }
24
+
25
+ if (typeof Worker === 'undefined') {
26
+ // We're on the main thread? Weird: it doesn't have workers
27
+ throw new Error(
28
+ 'Web workers not available. sqlite3 requires web workers to work.'
29
+ );
30
+ }
31
+
32
+ getModule().then(({ default: BackendWorker }) => {
33
+ let worker = new BackendWorker();
34
+
35
+ worker.postMessage({ type: 'init', buffers: [argBuffer, resultBuffer] });
36
+
37
+ worker.addEventListener('message', msg => {
38
+ // Forward any messages to the worker that's supposed
39
+ // to be the parent
40
+ parentWorker.postMessage(msg.data);
41
+ });
42
+ });
43
+ };
44
+ }
45
+
46
+ function makeInitBackend(spawnEventName, getModule) {
47
+ const startWorkerFromMain = makeStartWorkerFromMain(getModule);
48
+
49
+ return worker => {
50
+ worker.addEventListener('message', e => {
51
+ switch (e.data.type) {
52
+ case spawnEventName:
53
+ startWorkerFromMain(e.data.argBuffer, e.data.resultBuffer, worker);
54
+ break;
55
+ }
56
+ });
57
+ };
58
+ }
59
+
60
+ // Use the generic main thread module to create our indexeddb worker
61
+ // proxy
62
+ const initBackend = makeInitBackend('__absurd:spawn-idb-worker', () =>
63
+ Promise.resolve().then(function () { return indexeddbMainThreadWorkerB24e7a21; })
64
+ );
65
+
66
+ var __defProp = Object.defineProperty;
67
+ var __defProps = Object.defineProperties;
68
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
69
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
70
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
71
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
72
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
73
+ var __spreadValues = (a, b) => {
74
+ for (var prop in b || (b = {}))
75
+ if (__hasOwnProp.call(b, prop))
76
+ __defNormalProp(a, prop, b[prop]);
77
+ if (__getOwnPropSymbols)
78
+ for (var prop of __getOwnPropSymbols(b)) {
79
+ if (__propIsEnum.call(b, prop))
80
+ __defNormalProp(a, prop, b[prop]);
81
+ }
82
+ return a;
83
+ };
84
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
85
+ var __publicField = (obj, key, value) => {
86
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
87
+ return value;
88
+ };
89
+ const RPCCodes = {
90
+ CONNECT_TIMEOUT: {
91
+ code: -32300,
92
+ message: "Connect timeout"
93
+ },
94
+ APPLICATION_ERROR: {
95
+ code: -32500,
96
+ message: "Application error"
97
+ },
98
+ METHOD_NOT_FOUND: {
99
+ code: -32601,
100
+ message: `Method not found`
101
+ }
102
+ };
103
+ class RPCMessageEvent {
104
+ constructor(options) {
105
+ __publicField(this, "_currentEndpoint");
106
+ __publicField(this, "_targetEndpoint");
107
+ __publicField(this, "_events");
108
+ __publicField(this, "_originOnmessage");
109
+ __publicField(this, "_receiveMessage");
110
+ __publicField(this, "onerror", null);
111
+ __publicField(this, "config");
112
+ __publicField(this, "sendAdapter");
113
+ __publicField(this, "receiveAdapter");
114
+ this._events = {};
115
+ this._currentEndpoint = options.currentEndpoint;
116
+ this._targetEndpoint = options.targetEndpoint;
117
+ this._originOnmessage = null;
118
+ this.config = options.config;
119
+ this.receiveAdapter = options.receiveAdapter;
120
+ this.sendAdapter = options.sendAdapter;
121
+ const receiveMessage = (event) => {
122
+ const receiveData = this.receiveAdapter ? this.receiveAdapter(event) : event.data;
123
+ if (receiveData && typeof receiveData.event === "string") {
124
+ const eventHandlers = this._events[receiveData.event] || [];
125
+ if (eventHandlers.length) {
126
+ eventHandlers.forEach((handler) => {
127
+ handler(...receiveData.args || []);
128
+ });
129
+ return;
130
+ }
131
+ if (this.onerror) {
132
+ this.onerror(__spreadProps(__spreadValues({}, RPCCodes.METHOD_NOT_FOUND), {
133
+ data: receiveData
134
+ }));
135
+ }
136
+ }
137
+ };
138
+ if (this._currentEndpoint.addEventListener) {
139
+ if ("start" in this._currentEndpoint && this._currentEndpoint.start) {
140
+ this._currentEndpoint.start();
141
+ }
142
+ this._currentEndpoint.addEventListener("message", receiveMessage, false);
143
+ this._receiveMessage = receiveMessage;
144
+ return;
145
+ }
146
+ this._originOnmessage = this._currentEndpoint.onmessage;
147
+ this._currentEndpoint.onmessage = (event) => {
148
+ if (this._originOnmessage) {
149
+ this._originOnmessage(event);
150
+ }
151
+ receiveMessage(event);
152
+ };
153
+ this._receiveMessage = this._currentEndpoint.onmessage;
154
+ }
155
+ emit(event, ...args) {
156
+ const data = {
157
+ event,
158
+ args
159
+ };
160
+ const result = this.sendAdapter ? this.sendAdapter(data, this._targetEndpoint) : { data };
161
+ const sendData = result.data || data;
162
+ const postMessageConfig = this.config ? typeof this.config === "function" ? this.config(sendData, this._targetEndpoint) || {} : this.config || {} : {};
163
+ if (Array.isArray(result.transfer) && result.transfer.length) {
164
+ postMessageConfig.transfer = result.transfer;
165
+ }
166
+ this._targetEndpoint.postMessage(sendData, postMessageConfig);
167
+ }
168
+ on(event, fn) {
169
+ if (!this._events[event]) {
170
+ this._events[event] = [];
171
+ }
172
+ this._events[event].push(fn);
173
+ }
174
+ off(event, fn) {
175
+ if (!this._events[event])
176
+ return;
177
+ if (!fn) {
178
+ this._events[event] = [];
179
+ return;
180
+ }
181
+ const handlers = this._events[event] || [];
182
+ this._events[event] = handlers.filter((handler) => handler !== fn);
183
+ }
184
+ destroy() {
185
+ if (this._currentEndpoint.removeEventListener) {
186
+ this._currentEndpoint.removeEventListener("message", this._receiveMessage, false);
187
+ return;
188
+ }
189
+ try {
190
+ this._currentEndpoint.onmessage = this._originOnmessage;
191
+ } catch (error) {
192
+ console.warn(error);
193
+ }
194
+ }
195
+ }
196
+ const _RPC = class {
197
+ constructor(options) {
198
+ __publicField(this, "_event");
199
+ __publicField(this, "_methods", {});
200
+ __publicField(this, "_timeout", 0);
201
+ __publicField(this, "_$connect", null);
202
+ this._event = options.event;
203
+ this._timeout = options.timeout || 0;
204
+ if (options.methods) {
205
+ Object.entries(options.methods).forEach(([method, handler]) => {
206
+ this.registerMethod(method, handler);
207
+ });
208
+ }
209
+ this._event.onerror = (error) => {
210
+ const { code, message, data } = error;
211
+ if (data.event && Array.isArray(data.args) && data.args.length) {
212
+ const synEventData = data.args[0];
213
+ const ackEventName = this._getAckEventName(synEventData.method);
214
+ const ackEventData = {
215
+ jsonrpc: "2.0",
216
+ id: synEventData == null ? void 0 : synEventData.id,
217
+ error: {
218
+ code,
219
+ message,
220
+ data: synEventData
221
+ }
222
+ };
223
+ this._event.emit(ackEventName, ackEventData);
224
+ } else {
225
+ console.error(error);
226
+ }
227
+ };
228
+ this.connect();
229
+ }
230
+ static uuid() {
231
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
232
+ const r = Math.random() * 16 | 0;
233
+ const v = c == "x" ? r : r & 3 | 8;
234
+ return v.toString(16);
235
+ });
236
+ }
237
+ _getSynEventName(method) {
238
+ return `${_RPC.EVENT.SYN_SIGN}${method}`;
239
+ }
240
+ _getAckEventName(method) {
241
+ return `${_RPC.EVENT.ACK_SIGN}${method}`;
242
+ }
243
+ connect(timeout) {
244
+ if (this._$connect) {
245
+ return this._$connect;
246
+ }
247
+ this._$connect = new Promise((resolve, reject) => {
248
+ const connectTimeout = timeout || this._timeout;
249
+ let connectTimer;
250
+ if (connectTimeout) {
251
+ connectTimer = setTimeout(() => {
252
+ const error = __spreadProps(__spreadValues({}, RPCCodes.TIMEOUT), {
253
+ data: { timeout: connectTimeout }
254
+ });
255
+ reject(error);
256
+ }, connectTimeout);
257
+ }
258
+ const connectEventName = _RPC.EVENT.CONNECT;
259
+ const connectAckEventName = this._getAckEventName(connectEventName);
260
+ const connectSynEventName = this._getSynEventName(connectEventName);
261
+ const resolveConnectEvent = () => {
262
+ clearTimeout(connectTimer);
263
+ resolve();
264
+ };
265
+ this._event.on(connectAckEventName, resolveConnectEvent);
266
+ const connectSynEventHandler = () => {
267
+ this._event.emit(connectAckEventName);
268
+ resolveConnectEvent();
269
+ };
270
+ this._event.on(connectSynEventName, connectSynEventHandler);
271
+ this._event.emit(connectSynEventName);
272
+ });
273
+ return this._$connect;
274
+ }
275
+ registerMethod(method, handler) {
276
+ if (this._methods[method]) {
277
+ throw new Error(`${method} already registered`);
278
+ }
279
+ this._methods[method] = handler;
280
+ const synEventName = this._getSynEventName(method);
281
+ const synEventHandler = (synEventData) => {
282
+ const ackEventName = this._getAckEventName(method);
283
+ if (!synEventData.id) {
284
+ handler(...synEventData.params);
285
+ return;
286
+ }
287
+ Promise.resolve(handler(...synEventData.params)).then((result) => {
288
+ const ackEventData = {
289
+ jsonrpc: "2.0",
290
+ result,
291
+ id: synEventData.id
292
+ };
293
+ this._event.emit(ackEventName, ackEventData);
294
+ }).catch((error) => {
295
+ const ackEventData = {
296
+ jsonrpc: "2.0",
297
+ id: synEventData.id,
298
+ error: {
299
+ code: (error == null ? void 0 : error.code) || RPCCodes.APPLICATION_ERROR.code,
300
+ message: (error == null ? void 0 : error.message) || RPCCodes.APPLICATION_ERROR.message,
301
+ data: null
302
+ }
303
+ };
304
+ this._event.emit(ackEventName, ackEventData);
305
+ });
306
+ };
307
+ this._event.on(synEventName, synEventHandler);
308
+ }
309
+ removeMethod(method) {
310
+ if (!this._methods[method]) {
311
+ delete this._methods[method];
312
+ }
313
+ const synEventName = this._getSynEventName(method);
314
+ this._event.off(synEventName);
315
+ }
316
+ invoke(method, ...args) {
317
+ return new Promise((resolve, reject) => {
318
+ const lastArg = args[args.length - 1];
319
+ const hasInvokeOptions = lastArg && typeof lastArg === "object" && (Reflect.has(lastArg, "isNotify") || Reflect.has(lastArg, "timeout"));
320
+ const options = hasInvokeOptions ? lastArg : { isNotify: false, timeout: 0 };
321
+ const params = hasInvokeOptions ? args.slice(0, -1) : args;
322
+ const synEventName = this._getSynEventName(method);
323
+ const synEventId = _RPC.uuid();
324
+ const synEventData = {
325
+ jsonrpc: "2.0",
326
+ method,
327
+ params,
328
+ id: synEventId
329
+ };
330
+ this._event.emit(synEventName, synEventData);
331
+ if (!options.isNotify) {
332
+ const ackEventName = this._getAckEventName(method);
333
+ const timeout = options.timeout || this._timeout;
334
+ let timer;
335
+ if (timeout) {
336
+ timer = setTimeout(() => {
337
+ const error = __spreadProps(__spreadValues({}, RPCCodes.CONNECT_TIMEOUT), {
338
+ data: { timeout }
339
+ });
340
+ reject(error);
341
+ }, timeout);
342
+ }
343
+ const ackEventHandler = (ackEventData) => {
344
+ if (ackEventData.id === synEventId) {
345
+ clearTimeout(timer);
346
+ this._event.off(ackEventName, ackEventHandler);
347
+ if (!ackEventData.error) {
348
+ resolve(ackEventData.result);
349
+ } else {
350
+ reject(ackEventData.error);
351
+ }
352
+ }
353
+ };
354
+ this._event.on(ackEventName, ackEventHandler);
355
+ } else {
356
+ resolve(void 0);
357
+ }
358
+ });
359
+ }
360
+ destroy() {
361
+ Object.entries(this._methods).forEach(([method]) => {
362
+ const synEventName = this._getSynEventName(method);
363
+ this._event.off(synEventName);
364
+ });
365
+ const connectAckEventName = this._getAckEventName(_RPC.EVENT.CONNECT);
366
+ const connectSynEventName = this._getSynEventName(_RPC.EVENT.CONNECT);
367
+ this._event.off(connectSynEventName);
368
+ this._event.off(connectAckEventName);
369
+ if (this._event.destroy) {
370
+ this._event.destroy();
371
+ }
372
+ }
373
+ };
374
+ let RPC = _RPC;
375
+ __publicField(RPC, "CODES", RPCCodes);
376
+ __publicField(RPC, "EVENT", {
377
+ SYN_SIGN: "syn:",
378
+ ACK_SIGN: "ack:",
379
+ CONNECT: "__rpc_connect_event",
380
+ SYNC_METHODS: "__rpc_sync_methods_event"
381
+ });
382
+
383
+ const DatabaseErrorCode = {
384
+ ErrorInit: 10001,
385
+ ErrorNoRecord: 10002,
386
+ ErrorDBTimeout: 10003,
387
+ };
388
+ var CbEvents;
389
+ (function (CbEvents) {
390
+ CbEvents["Login"] = "Login";
391
+ CbEvents["OnConnectFailed"] = "OnConnectFailed";
392
+ CbEvents["OnConnectSuccess"] = "OnConnectSuccess";
393
+ CbEvents["OnConnecting"] = "OnConnecting";
394
+ CbEvents["OnKickedOffline"] = "OnKickedOffline";
395
+ CbEvents["OnSelfInfoUpdated"] = "OnSelfInfoUpdated";
396
+ CbEvents["OnUserTokenExpired"] = "OnUserTokenExpired";
397
+ CbEvents["OnUserTokenInvalid"] = "OnUserTokenInvalid";
398
+ CbEvents["OnProgress"] = "OnProgress";
399
+ CbEvents["OnRecvNewMessage"] = "OnRecvNewMessage";
400
+ CbEvents["OnRecvNewMessages"] = "OnRecvNewMessages";
401
+ CbEvents["OnRecvOnlineOnlyMessage"] = "OnRecvOnlineOnlyMessage";
402
+ CbEvents["OnRecvOfflineNewMessage"] = "onRecvOfflineNewMessage";
403
+ CbEvents["OnRecvOnlineOnlyMessages"] = "OnRecvOnlineOnlyMessages";
404
+ CbEvents["OnRecvOfflineNewMessages"] = "onRecvOfflineNewMessages";
405
+ CbEvents["OnRecvMessageRevoked"] = "OnRecvMessageRevoked";
406
+ CbEvents["OnNewRecvMessageRevoked"] = "OnNewRecvMessageRevoked";
407
+ CbEvents["OnRecvC2CReadReceipt"] = "OnRecvC2CReadReceipt";
408
+ CbEvents["OnRecvGroupReadReceipt"] = "OnRecvGroupReadReceipt";
409
+ CbEvents["OnConversationChanged"] = "OnConversationChanged";
410
+ CbEvents["OnNewConversation"] = "OnNewConversation";
411
+ CbEvents["OnConversationUserInputStatusChanged"] = "OnConversationUserInputStatusChanged";
412
+ CbEvents["OnSyncServerFailed"] = "OnSyncServerFailed";
413
+ CbEvents["OnSyncServerFinish"] = "OnSyncServerFinish";
414
+ CbEvents["OnSyncServerProgress"] = "OnSyncServerProgress";
415
+ CbEvents["OnSyncServerStart"] = "OnSyncServerStart";
416
+ CbEvents["OnTotalUnreadMessageCountChanged"] = "OnTotalUnreadMessageCountChanged";
417
+ CbEvents["OnBlackAdded"] = "OnBlackAdded";
418
+ CbEvents["OnBlackDeleted"] = "OnBlackDeleted";
419
+ CbEvents["OnFriendApplicationAccepted"] = "OnFriendApplicationAccepted";
420
+ CbEvents["OnFriendApplicationAdded"] = "OnFriendApplicationAdded";
421
+ CbEvents["OnFriendApplicationDeleted"] = "OnFriendApplicationDeleted";
422
+ CbEvents["OnFriendApplicationRejected"] = "OnFriendApplicationRejected";
423
+ CbEvents["OnFriendInfoChanged"] = "OnFriendInfoChanged";
424
+ CbEvents["OnFriendAdded"] = "OnFriendAdded";
425
+ CbEvents["OnFriendDeleted"] = "OnFriendDeleted";
426
+ CbEvents["OnJoinedGroupAdded"] = "OnJoinedGroupAdded";
427
+ CbEvents["OnJoinedGroupDeleted"] = "OnJoinedGroupDeleted";
428
+ CbEvents["OnGroupDismissed"] = "OnGroupDismissed";
429
+ CbEvents["OnGroupMemberAdded"] = "OnGroupMemberAdded";
430
+ CbEvents["OnGroupMemberDeleted"] = "OnGroupMemberDeleted";
431
+ CbEvents["OnGroupApplicationAdded"] = "OnGroupApplicationAdded";
432
+ CbEvents["OnGroupApplicationDeleted"] = "OnGroupApplicationDeleted";
433
+ CbEvents["OnGroupInfoChanged"] = "OnGroupInfoChanged";
434
+ CbEvents["OnGroupMemberInfoChanged"] = "OnGroupMemberInfoChanged";
435
+ CbEvents["OnGroupApplicationAccepted"] = "OnGroupApplicationAccepted";
436
+ CbEvents["OnGroupApplicationRejected"] = "OnGroupApplicationRejected";
437
+ CbEvents["UploadComplete"] = "UploadComplete";
438
+ CbEvents["OnRecvCustomBusinessMessage"] = "OnRecvCustomBusinessMessage";
439
+ CbEvents["OnUserStatusChanged"] = "OnUserStatusChanged";
440
+ CbEvents["OnUploadLogsProgress"] = "OnUploadLogsProgress";
441
+ // rtc
442
+ CbEvents["OnReceiveNewInvitation"] = "OnReceiveNewInvitation";
443
+ CbEvents["OnInviteeAccepted"] = "OnInviteeAccepted";
444
+ CbEvents["OnInviteeRejected"] = "OnInviteeRejected";
445
+ CbEvents["OnInvitationCancelled"] = "OnInvitationCancelled";
446
+ CbEvents["OnHangUp"] = "OnHangUp";
447
+ CbEvents["OnInvitationTimeout"] = "OnInvitationTimeout";
448
+ CbEvents["OnInviteeAcceptedByOtherDevice"] = "OnInviteeAcceptedByOtherDevice";
449
+ CbEvents["OnInviteeRejectedByOtherDevice"] = "OnInviteeRejectedByOtherDevice";
450
+ // meeting
451
+ CbEvents["OnStreamChange"] = "OnStreamChange";
452
+ CbEvents["OnRoomParticipantConnected"] = "OnRoomParticipantConnected";
453
+ CbEvents["OnRoomParticipantDisconnected"] = "OnRoomParticipantDisconnected";
454
+ CbEvents["OnReceiveCustomSignal"] = "OnReceiveCustomSignal";
455
+ // unuse
456
+ CbEvents["UnUsedEvent"] = "UnUsedEvent";
457
+ })(CbEvents || (CbEvents = {}));
458
+
459
+ let rpc;
460
+ let worker;
461
+ let debug = false;
462
+ function supportsModuleWorkers() {
463
+ if (typeof Worker !== 'undefined' && 'type' in Worker.prototype) {
464
+ return true;
465
+ }
466
+ try {
467
+ const blob = new Blob([''], { type: 'text/javascript' });
468
+ const url = URL.createObjectURL(blob);
469
+ new Worker(url, { type: 'module' });
470
+ URL.revokeObjectURL(url);
471
+ return true;
472
+ }
473
+ catch (e) {
474
+ return false;
475
+ }
476
+ }
477
+ function initWorker() {
478
+ if (typeof window === 'undefined') {
479
+ return;
480
+ }
481
+ // use for webpack 4
482
+ // const IMWorker = require('worker-loader!./worker.js');
483
+ // worker = new IMWorker.default();
484
+ // use for webpack5+ or vite
485
+ const isViteEnvironment = import.meta.url.includes('.vite/deps');
486
+ const isNuxtEnvironment = import.meta.url.includes('_nuxt/node_modules');
487
+ const isQuasarEnvironment = import.meta.url.includes('.q-cache');
488
+ const isSupportModuleWorker = supportsModuleWorkers();
489
+ let workerUrl = isSupportModuleWorker
490
+ ? new URL('worker.js', import.meta.url)
491
+ : new URL('worker-legacy.js', import.meta.url);
492
+ if (isViteEnvironment) {
493
+ workerUrl = workerUrl.href.replace('.vite/deps', '@openim/wasm-client-sdk/lib');
494
+ }
495
+ if (isNuxtEnvironment) {
496
+ workerUrl = workerUrl.href.replace('.cache/vite/client/deps', '@openim/wasm-client-sdk/lib');
497
+ }
498
+ if (isQuasarEnvironment) {
499
+ workerUrl = workerUrl.href.replace(/\.q-cache\/dev-spa\/[^/]+\/deps/, '@openim/wasm-client-sdk/lib');
500
+ }
501
+ worker = new Worker(workerUrl, {
502
+ type: isSupportModuleWorker ? 'module' : 'classic',
503
+ });
504
+ // This is only required because Safari doesn't support nested
505
+ // workers. This installs a handler that will proxy creating web
506
+ // workers through the main thread
507
+ initBackend(worker);
508
+ rpc = new RPC({
509
+ event: new RPCMessageEvent({
510
+ currentEndpoint: worker,
511
+ targetEndpoint: worker,
512
+ }),
513
+ });
514
+ }
515
+ function resetWorker() {
516
+ if (rpc) {
517
+ rpc.destroy();
518
+ rpc = undefined;
519
+ }
520
+ if (worker) {
521
+ worker.terminate();
522
+ worker = undefined;
523
+ }
524
+ }
525
+ initWorker();
526
+ function catchErrorHandle(error) {
527
+ // defined in rpc-shooter
528
+ if (error.code === -32300) {
529
+ resetWorker();
530
+ return JSON.stringify({
531
+ data: '',
532
+ errCode: DatabaseErrorCode.ErrorDBTimeout,
533
+ errMsg: 'database maybe damaged',
534
+ });
535
+ }
536
+ throw error;
537
+ }
538
+ function _logWrap(...args) {
539
+ if (debug) {
540
+ console.info(...args);
541
+ }
542
+ }
543
+ function registeMethodOnWindow(name, realName, needStringify = true) {
544
+ _logWrap(`=> (database api) registe ${realName !== null && realName !== void 0 ? realName : name}`);
545
+ return async (...args) => {
546
+ if (!rpc || !worker) {
547
+ initWorker();
548
+ }
549
+ if (!rpc) {
550
+ return;
551
+ }
552
+ try {
553
+ _logWrap(`=> (invoked by go wasm) run ${realName !== null && realName !== void 0 ? realName : name} method with args ${JSON.stringify(args)}`);
554
+ const response = await rpc.invoke(name, ...args, { timeout: 5000000 });
555
+ _logWrap(`=> (invoked by go wasm) run ${realName !== null && realName !== void 0 ? realName : name} method with response `, JSON.stringify(response));
556
+ if (!needStringify) {
557
+ return response;
558
+ }
559
+ return JSON.stringify(response);
560
+ }
561
+ catch (error) {
562
+ // defined in rpc-shooter
563
+ catchErrorHandle(error);
564
+ }
565
+ };
566
+ }
567
+ // register method on window for go wasm invoke
568
+ function initDatabaseAPI(isLogStandardOutput = true) {
569
+ if (!rpc) {
570
+ return;
571
+ }
572
+ debug = isLogStandardOutput;
573
+ // upload
574
+ window.wasmOpen = registeMethodOnWindow('wasmOpen');
575
+ window.wasmClose = registeMethodOnWindow('wasmClose');
576
+ window.wasmRead = registeMethodOnWindow('wasmRead', 'wasmRead', false);
577
+ window.getUpload = registeMethodOnWindow('getUpload');
578
+ window.insertUpload = registeMethodOnWindow('insertUpload');
579
+ window.updateUpload = registeMethodOnWindow('updateUpload');
580
+ window.deleteUpload = registeMethodOnWindow('deleteUpload');
581
+ window.fileMapSet = registeMethodOnWindow('fileMapSet');
582
+ window.fileMapClear = registeMethodOnWindow('fileMapClear');
583
+ window.setSqlWasmPath = registeMethodOnWindow('setSqlWasmPath');
584
+ window.initDB = registeMethodOnWindow('initDB');
585
+ window.close = registeMethodOnWindow('close');
586
+ // message
587
+ window.getMessage = registeMethodOnWindow('getMessage');
588
+ window.getMultipleMessage = registeMethodOnWindow('getMultipleMessage');
589
+ window.getSendingMessageList = registeMethodOnWindow('getSendingMessageList');
590
+ window.getNormalMsgSeq = registeMethodOnWindow('getNormalMsgSeq');
591
+ window.updateMessageTimeAndStatus = registeMethodOnWindow('updateMessageTimeAndStatus');
592
+ window.updateMessage = registeMethodOnWindow('updateMessage');
593
+ window.updateMessageBySeq = registeMethodOnWindow('updateMessageBySeq');
594
+ window.updateColumnsMessage = registeMethodOnWindow('updateColumnsMessage');
595
+ window.insertMessage = registeMethodOnWindow('insertMessage');
596
+ window.batchInsertMessageList = registeMethodOnWindow('batchInsertMessageList');
597
+ window.getMessageList = registeMethodOnWindow('getMessageList');
598
+ window.getMessageListNoTime = registeMethodOnWindow('getMessageListNoTime');
599
+ window.messageIfExists = registeMethodOnWindow('messageIfExists');
600
+ window.messageIfExistsBySeq = registeMethodOnWindow('messageIfExistsBySeq');
601
+ window.getAbnormalMsgSeq = registeMethodOnWindow('getAbnormalMsgSeq');
602
+ window.getAbnormalMsgSeqList = registeMethodOnWindow('getAbnormalMsgSeqList');
603
+ window.batchInsertExceptionMsg = registeMethodOnWindow('batchInsertExceptionMsg');
604
+ window.searchMessageByKeyword = registeMethodOnWindow('searchMessageByKeyword');
605
+ window.searchMessageByContentType = registeMethodOnWindow('searchMessageByContentType');
606
+ window.searchMessageByContentTypeAndKeyword = registeMethodOnWindow('searchMessageByContentTypeAndKeyword');
607
+ window.updateMsgSenderNickname = registeMethodOnWindow('updateMsgSenderNickname');
608
+ window.updateMsgSenderFaceURL = registeMethodOnWindow('updateMsgSenderFaceURL');
609
+ window.updateMsgSenderFaceURLAndSenderNickname = registeMethodOnWindow('updateMsgSenderFaceURLAndSenderNickname');
610
+ window.getMsgSeqByClientMsgID = registeMethodOnWindow('getMsgSeqByClientMsgID');
611
+ window.getMsgSeqListByGroupID = registeMethodOnWindow('getMsgSeqListByGroupID');
612
+ window.getMsgSeqListByPeerUserID = registeMethodOnWindow('getMsgSeqListByPeerUserID');
613
+ window.getMsgSeqListBySelfUserID = registeMethodOnWindow('getMsgSeqListBySelfUserID');
614
+ window.deleteAllMessage = registeMethodOnWindow('deleteAllMessage');
615
+ window.getAllUnDeleteMessageSeqList = registeMethodOnWindow('getAllUnDeleteMessageSeqList');
616
+ window.updateSingleMessageHasRead = registeMethodOnWindow('updateSingleMessageHasRead');
617
+ window.updateGroupMessageHasRead = registeMethodOnWindow('updateGroupMessageHasRead');
618
+ window.updateMessageStatusBySourceID = registeMethodOnWindow('updateMessageStatusBySourceID');
619
+ window.getAlreadyExistSeqList = registeMethodOnWindow('getAlreadyExistSeqList');
620
+ window.getLatestValidServerMessage = registeMethodOnWindow('getLatestValidServerMessage');
621
+ window.getMessageBySeq = registeMethodOnWindow('getMessageBySeq');
622
+ window.getMessagesByClientMsgIDs = registeMethodOnWindow('getMessagesByClientMsgIDs');
623
+ window.getMessagesBySeqs = registeMethodOnWindow('getMessagesBySeqs');
624
+ window.getConversationNormalMsgSeq = registeMethodOnWindow('getConversationNormalMsgSeq');
625
+ window.checkConversationNormalMsgSeq = registeMethodOnWindow('getConversationNormalMsgSeq');
626
+ window.getConversationPeerNormalMsgSeq = registeMethodOnWindow('getConversationPeerNormalMsgSeq');
627
+ window.deleteConversationAllMessages = registeMethodOnWindow('deleteConversationAllMessages');
628
+ window.markDeleteConversationAllMessages = registeMethodOnWindow('markDeleteConversationAllMessages');
629
+ window.getUnreadMessage = registeMethodOnWindow('getUnreadMessage');
630
+ window.markConversationMessageAsReadBySeqs = registeMethodOnWindow('markConversationMessageAsReadBySeqs');
631
+ window.markConversationMessageAsReadDB = registeMethodOnWindow('markConversationMessageAsRead');
632
+ window.deleteConversationMsgs = registeMethodOnWindow('deleteConversationMsgs');
633
+ window.markConversationAllMessageAsRead = registeMethodOnWindow('markConversationAllMessageAsRead');
634
+ window.searchAllMessageByContentType = registeMethodOnWindow('searchAllMessageByContentType');
635
+ window.insertSendingMessage = registeMethodOnWindow('insertSendingMessage');
636
+ window.deleteSendingMessage = registeMethodOnWindow('deleteSendingMessage');
637
+ window.getAllSendingMessages = registeMethodOnWindow('getAllSendingMessages');
638
+ // conversation
639
+ window.getAllConversationListDB = registeMethodOnWindow('getAllConversationList');
640
+ window.getAllConversationListToSync = registeMethodOnWindow('getAllConversationListToSync');
641
+ window.getHiddenConversationList = registeMethodOnWindow('getHiddenConversationList');
642
+ window.getConversation = registeMethodOnWindow('getConversation');
643
+ window.getMultipleConversationDB = registeMethodOnWindow('getMultipleConversation');
644
+ window.updateColumnsConversation = registeMethodOnWindow('updateColumnsConversation');
645
+ window.updateConversation = registeMethodOnWindow('updateColumnsConversation', 'updateConversation');
646
+ window.updateConversationForSync = registeMethodOnWindow('updateColumnsConversation', 'updateConversationForSync');
647
+ window.decrConversationUnreadCount = registeMethodOnWindow('decrConversationUnreadCount');
648
+ window.batchInsertConversationList = registeMethodOnWindow('batchInsertConversationList');
649
+ window.insertConversation = registeMethodOnWindow('insertConversation');
650
+ window.getTotalUnreadMsgCountDB = registeMethodOnWindow('getTotalUnreadMsgCount');
651
+ window.getConversationByUserID = registeMethodOnWindow('getConversationByUserID');
652
+ window.getConversationListSplitDB = registeMethodOnWindow('getConversationListSplit');
653
+ window.deleteConversation = registeMethodOnWindow('deleteConversation');
654
+ window.deleteAllConversation = registeMethodOnWindow('deleteAllConversation');
655
+ window.batchUpdateConversationList = registeMethodOnWindow('batchUpdateConversationList');
656
+ window.conversationIfExists = registeMethodOnWindow('conversationIfExists');
657
+ window.resetConversation = registeMethodOnWindow('resetConversation');
658
+ window.resetAllConversation = registeMethodOnWindow('resetAllConversation');
659
+ window.clearConversation = registeMethodOnWindow('clearConversation');
660
+ window.clearAllConversation = registeMethodOnWindow('clearAllConversation');
661
+ window.setConversationDraftDB = registeMethodOnWindow('setConversationDraft');
662
+ window.removeConversationDraft = registeMethodOnWindow('removeConversationDraft');
663
+ window.unPinConversation = registeMethodOnWindow('unPinConversation');
664
+ // window.updateAllConversation = registeMethodOnWindow('updateAllConversation');
665
+ window.incrConversationUnreadCount = registeMethodOnWindow('incrConversationUnreadCount');
666
+ window.setMultipleConversationRecvMsgOpt = registeMethodOnWindow('setMultipleConversationRecvMsgOpt');
667
+ window.getAllSingleConversationIDList = registeMethodOnWindow('getAllSingleConversationIDList');
668
+ window.findAllUnreadConversationConversationID = registeMethodOnWindow('findAllUnreadConversationConversationID');
669
+ window.getAllConversationIDList = registeMethodOnWindow('getAllConversationIDList');
670
+ window.getAllConversations = registeMethodOnWindow('getAllConversations');
671
+ window.searchConversations = registeMethodOnWindow('searchConversations');
672
+ window.getLatestActiveMessage = registeMethodOnWindow('getLatestActiveMessage');
673
+ // users
674
+ window.getLoginUser = registeMethodOnWindow('getLoginUser');
675
+ window.insertLoginUser = registeMethodOnWindow('insertLoginUser');
676
+ window.updateLoginUser = registeMethodOnWindow('updateLoginUser');
677
+ window.getStrangerInfo = registeMethodOnWindow('getStrangerInfo');
678
+ window.setStrangerInfo = registeMethodOnWindow('setStrangerInfo');
679
+ // app sdk versions
680
+ window.getAppSDKVersion = registeMethodOnWindow('getAppSDKVersion');
681
+ window.setAppSDKVersion = registeMethodOnWindow('setAppSDKVersion');
682
+ // versions sync
683
+ window.getVersionSync = registeMethodOnWindow('getVersionSync');
684
+ window.setVersionSync = registeMethodOnWindow('setVersionSync');
685
+ window.deleteVersionSync = registeMethodOnWindow('deleteVersionSync');
686
+ // super groups
687
+ window.getJoinedSuperGroupList = registeMethodOnWindow('getJoinedSuperGroupList');
688
+ window.getJoinedSuperGroupIDList = registeMethodOnWindow('getJoinedSuperGroupIDList');
689
+ window.getSuperGroupInfoByGroupID = registeMethodOnWindow('getSuperGroupInfoByGroupID');
690
+ window.deleteSuperGroup = registeMethodOnWindow('deleteSuperGroup');
691
+ window.insertSuperGroup = registeMethodOnWindow('insertSuperGroup');
692
+ window.updateSuperGroup = registeMethodOnWindow('updateSuperGroup');
693
+ // unread messages
694
+ window.deleteConversationUnreadMessageList = registeMethodOnWindow('deleteConversationUnreadMessageList');
695
+ window.batchInsertConversationUnreadMessageList = registeMethodOnWindow('batchInsertConversationUnreadMessageList');
696
+ // super group messages
697
+ window.superGroupGetMessage = registeMethodOnWindow('superGroupGetMessage');
698
+ window.superGroupGetMultipleMessage = registeMethodOnWindow('superGroupGetMultipleMessage');
699
+ window.superGroupGetNormalMinSeq = registeMethodOnWindow('superGroupGetNormalMinSeq');
700
+ window.getSuperGroupNormalMsgSeq = registeMethodOnWindow('getSuperGroupNormalMsgSeq');
701
+ window.superGroupUpdateMessageTimeAndStatus = registeMethodOnWindow('superGroupUpdateMessageTimeAndStatus');
702
+ window.superGroupUpdateMessage = registeMethodOnWindow('superGroupUpdateMessage');
703
+ window.superGroupInsertMessage = registeMethodOnWindow('superGroupInsertMessage');
704
+ window.superGroupBatchInsertMessageList = registeMethodOnWindow('superGroupBatchInsertMessageList');
705
+ window.superGroupGetMessageListNoTime = registeMethodOnWindow('superGroupGetMessageListNoTime');
706
+ window.superGroupGetMessageList = registeMethodOnWindow('superGroupGetMessageList');
707
+ window.superGroupUpdateColumnsMessage = registeMethodOnWindow('superGroupUpdateColumnsMessage');
708
+ window.superGroupDeleteAllMessage = registeMethodOnWindow('superGroupDeleteAllMessage');
709
+ window.superGroupSearchMessageByKeyword = registeMethodOnWindow('superGroupSearchMessageByKeyword');
710
+ window.superGroupSearchMessageByContentType = registeMethodOnWindow('superGroupSearchMessageByContentType');
711
+ window.superGroupSearchMessageByContentTypeAndKeyword = registeMethodOnWindow('superGroupSearchMessageByContentTypeAndKeyword');
712
+ window.superGroupUpdateMessageStatusBySourceID = registeMethodOnWindow('superGroupUpdateMessageStatusBySourceID');
713
+ window.superGroupGetSendingMessageList = registeMethodOnWindow('superGroupGetSendingMessageList');
714
+ window.superGroupUpdateGroupMessageHasRead = registeMethodOnWindow('superGroupUpdateGroupMessageHasRead');
715
+ window.superGroupGetMsgSeqByClientMsgID = registeMethodOnWindow('superGroupGetMsgSeqByClientMsgID');
716
+ window.superGroupUpdateMsgSenderFaceURLAndSenderNickname =
717
+ registeMethodOnWindow('superGroupUpdateMsgSenderFaceURLAndSenderNickname');
718
+ window.superGroupSearchAllMessageByContentType = registeMethodOnWindow('superGroupSearchAllMessageByContentType');
719
+ // debug
720
+ window.exec = registeMethodOnWindow('exec');
721
+ window.getRowsModified = registeMethodOnWindow('getRowsModified');
722
+ window.exportDB = async () => {
723
+ if (!rpc || !worker) {
724
+ initWorker();
725
+ }
726
+ if (!rpc) {
727
+ return;
728
+ }
729
+ try {
730
+ _logWrap('=> (invoked by go wasm) run exportDB method ');
731
+ const result = await rpc.invoke('exportDB', undefined, { timeout: 5000 });
732
+ _logWrap('=> (invoked by go wasm) run exportDB method with response ', JSON.stringify(result));
733
+ return result;
734
+ }
735
+ catch (error) {
736
+ catchErrorHandle(error);
737
+ }
738
+ };
739
+ // black
740
+ window.getBlackListDB = registeMethodOnWindow('getBlackList');
741
+ window.getBlackListUserID = registeMethodOnWindow('getBlackListUserID');
742
+ window.getBlackInfoByBlockUserID = registeMethodOnWindow('getBlackInfoByBlockUserID');
743
+ window.getBlackInfoList = registeMethodOnWindow('getBlackInfoList');
744
+ window.insertBlack = registeMethodOnWindow('insertBlack');
745
+ window.deleteBlack = registeMethodOnWindow('deleteBlack');
746
+ window.updateBlack = registeMethodOnWindow('updateBlack');
747
+ // friendRequest
748
+ window.insertFriendRequest = registeMethodOnWindow('insertFriendRequest');
749
+ window.deleteFriendRequestBothUserID = registeMethodOnWindow('deleteFriendRequestBothUserID');
750
+ window.updateFriendRequest = registeMethodOnWindow('updateFriendRequest');
751
+ window.getRecvFriendApplication = registeMethodOnWindow('getRecvFriendApplication');
752
+ window.getSendFriendApplication = registeMethodOnWindow('getSendFriendApplication');
753
+ window.getFriendApplicationByBothID = registeMethodOnWindow('getFriendApplicationByBothID');
754
+ window.getBothFriendReq = registeMethodOnWindow('getBothFriendReq');
755
+ // friend
756
+ window.insertFriend = registeMethodOnWindow('insertFriend');
757
+ window.deleteFriendDB = registeMethodOnWindow('deleteFriend');
758
+ window.updateFriend = registeMethodOnWindow('updateFriend');
759
+ window.getAllFriendList = registeMethodOnWindow('getAllFriendList');
760
+ window.searchFriendList = registeMethodOnWindow('searchFriendList');
761
+ window.getFriendInfoByFriendUserID = registeMethodOnWindow('getFriendInfoByFriendUserID');
762
+ window.getFriendInfoList = registeMethodOnWindow('getFriendInfoList');
763
+ window.getPageFriendList = registeMethodOnWindow('getPageFriendList');
764
+ window.updateColumnsFriend = registeMethodOnWindow('updateColumnsFriend');
765
+ window.getFriendListCount = registeMethodOnWindow('getFriendListCount');
766
+ window.batchInsertFriend = registeMethodOnWindow('batchInsertFriend');
767
+ window.deleteAllFriend = registeMethodOnWindow('deleteAllFriend');
768
+ // groups
769
+ window.insertGroup = registeMethodOnWindow('insertGroup');
770
+ window.deleteGroup = registeMethodOnWindow('deleteGroup');
771
+ window.updateGroup = registeMethodOnWindow('updateGroup');
772
+ window.getJoinedGroupListDB = registeMethodOnWindow('getJoinedGroupList');
773
+ window.getGroupInfoByGroupID = registeMethodOnWindow('getGroupInfoByGroupID');
774
+ window.getAllGroupInfoByGroupIDOrGroupName = registeMethodOnWindow('getAllGroupInfoByGroupIDOrGroupName');
775
+ window.subtractMemberCount = registeMethodOnWindow('subtractMemberCount');
776
+ window.addMemberCount = registeMethodOnWindow('addMemberCount');
777
+ window.getJoinedWorkingGroupIDList = registeMethodOnWindow('getJoinedWorkingGroupIDList');
778
+ window.getJoinedWorkingGroupList = registeMethodOnWindow('getJoinedWorkingGroupList');
779
+ window.getGroupMemberAllGroupIDs = registeMethodOnWindow('getGroupMemberAllGroupIDs');
780
+ window.getUserJoinedGroupIDs = registeMethodOnWindow('getUserJoinedGroupIDs');
781
+ window.getGroups = registeMethodOnWindow('getGroups');
782
+ window.getGroupMemberListByUserIDs = registeMethodOnWindow('getGroupMemberListByUserIDs');
783
+ window.batchInsertGroup = registeMethodOnWindow('batchInsertGroup');
784
+ window.deleteAllGroup = registeMethodOnWindow('deleteAllGroup');
785
+ // groupRequest
786
+ window.insertGroupRequest = registeMethodOnWindow('insertGroupRequest');
787
+ window.deleteGroupRequest = registeMethodOnWindow('deleteGroupRequest');
788
+ window.updateGroupRequest = registeMethodOnWindow('updateGroupRequest');
789
+ window.getSendGroupApplication = registeMethodOnWindow('getSendGroupApplication');
790
+ window.insertAdminGroupRequest = registeMethodOnWindow('insertAdminGroupRequest');
791
+ window.deleteAdminGroupRequest = registeMethodOnWindow('deleteAdminGroupRequest');
792
+ window.updateAdminGroupRequest = registeMethodOnWindow('updateAdminGroupRequest');
793
+ window.getAdminGroupApplication = registeMethodOnWindow('getAdminGroupApplication');
794
+ // groupMember
795
+ window.getGroupMemberInfoByGroupIDUserID = registeMethodOnWindow('getGroupMemberInfoByGroupIDUserID');
796
+ window.getAllGroupMemberList = registeMethodOnWindow('getAllGroupMemberList');
797
+ window.getAllGroupMemberUserIDList = registeMethodOnWindow('getAllGroupMemberUserIDList');
798
+ window.getGroupMemberCount = registeMethodOnWindow('getGroupMemberCount');
799
+ window.getGroupSomeMemberInfo = registeMethodOnWindow('getGroupSomeMemberInfo');
800
+ window.getGroupAdminID = registeMethodOnWindow('getGroupAdminID');
801
+ window.getGroupMemberListByGroupID = registeMethodOnWindow('getGroupMemberListByGroupID');
802
+ window.getGroupMemberListSplit = registeMethodOnWindow('getGroupMemberListSplit');
803
+ window.getGroupMemberOwnerAndAdminDB = registeMethodOnWindow('getGroupMemberOwnerAndAdmin');
804
+ window.getGroupMemberOwner = registeMethodOnWindow('getGroupMemberOwner');
805
+ window.getGroupMemberListSplitByJoinTimeFilter = registeMethodOnWindow('getGroupMemberListSplitByJoinTimeFilter');
806
+ window.getGroupOwnerAndAdminByGroupID = registeMethodOnWindow('getGroupOwnerAndAdminByGroupID');
807
+ window.getGroupMemberUIDListByGroupID = registeMethodOnWindow('getGroupMemberUIDListByGroupID');
808
+ window.insertGroupMember = registeMethodOnWindow('insertGroupMember');
809
+ window.batchInsertGroupMember = registeMethodOnWindow('batchInsertGroupMember');
810
+ window.deleteGroupMember = registeMethodOnWindow('deleteGroupMember');
811
+ window.deleteGroupAllMembers = registeMethodOnWindow('deleteGroupAllMembers');
812
+ window.updateGroupMember = registeMethodOnWindow('updateGroupMember');
813
+ window.updateGroupMemberField = registeMethodOnWindow('updateGroupMemberField');
814
+ window.searchGroupMembersDB = registeMethodOnWindow('searchGroupMembers', 'searchGroupMembersDB');
815
+ // temp cache chat logs
816
+ window.batchInsertTempCacheMessageList = registeMethodOnWindow('batchInsertTempCacheMessageList');
817
+ window.InsertTempCacheMessage = registeMethodOnWindow('InsertTempCacheMessage');
818
+ // notification
819
+ window.getNotificationAllSeqs = registeMethodOnWindow('getNotificationAllSeqs');
820
+ window.setNotificationSeq = registeMethodOnWindow('setNotificationSeq');
821
+ window.batchInsertNotificationSeq = registeMethodOnWindow('batchInsertNotificationSeq');
822
+ window.getExistedTables = registeMethodOnWindow('getExistedTables');
823
+ }
824
+ const workerPromise = rpc === null || rpc === void 0 ? void 0 : rpc.connect(5000);
825
+
826
+ class Emitter {
827
+ constructor() {
828
+ this.events = {};
829
+ }
830
+ emit(event, data) {
831
+ if (this.events[event]) {
832
+ this.events[event].forEach(fn => {
833
+ return fn(data);
834
+ });
835
+ }
836
+ return this;
837
+ }
838
+ on(event, fn) {
839
+ if (this.events[event]) {
840
+ this.events[event].push(fn);
841
+ }
842
+ else {
843
+ this.events[event] = [fn];
844
+ }
845
+ return this;
846
+ }
847
+ off(event, fn) {
848
+ if (event && typeof fn === 'function' && this.events[event]) {
849
+ const listeners = this.events[event];
850
+ if (!listeners || listeners.length === 0) {
851
+ return;
852
+ }
853
+ const index = listeners.findIndex(_fn => {
854
+ return _fn === fn;
855
+ });
856
+ if (index !== -1) {
857
+ listeners.splice(index, 1);
858
+ }
859
+ }
860
+ return this;
861
+ }
862
+ }
863
+
864
+ // Unique ID creation requires a high quality random # generator. In the browser we therefore
865
+ // require the crypto API and do not support built-in fallback to lower quality random number
866
+ // generators (like Math.random()).
867
+ let getRandomValues;
868
+ const rnds8 = new Uint8Array(16);
869
+ function rng() {
870
+ // lazy load so that environments that need to polyfill have a chance to do so
871
+ if (!getRandomValues) {
872
+ // getRandomValues needs to be invoked in a context where "this" is a Crypto implementation.
873
+ getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);
874
+
875
+ if (!getRandomValues) {
876
+ throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
877
+ }
878
+ }
879
+
880
+ return getRandomValues(rnds8);
881
+ }
882
+
883
+ /**
884
+ * Convert array of 16 byte values to UUID string format of the form:
885
+ * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
886
+ */
887
+
888
+ const byteToHex = [];
889
+
890
+ for (let i = 0; i < 256; ++i) {
891
+ byteToHex.push((i + 0x100).toString(16).slice(1));
892
+ }
893
+
894
+ function unsafeStringify(arr, offset = 0) {
895
+ // Note: Be careful editing this code! It's been tuned for performance
896
+ // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
897
+ return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();
898
+ }
899
+
900
+ const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
901
+ var native = {
902
+ randomUUID
903
+ };
904
+
905
+ function v4(options, buf, offset) {
906
+ if (native.randomUUID && !buf && !options) {
907
+ return native.randomUUID();
908
+ }
909
+
910
+ options = options || {};
911
+ const rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
912
+
913
+ rnds[6] = rnds[6] & 0x0f | 0x40;
914
+ rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
915
+
916
+ if (buf) {
917
+ offset = offset || 0;
918
+
919
+ for (let i = 0; i < 16; ++i) {
920
+ buf[offset + i] = rnds[i];
921
+ }
922
+
923
+ return buf;
924
+ }
925
+
926
+ return unsafeStringify(rnds);
927
+ }
928
+
929
+ async function wait(duration) {
930
+ return new Promise(resolve => {
931
+ const timer = setTimeout(() => {
932
+ clearTimeout(timer);
933
+ resolve(null);
934
+ }, duration);
935
+ });
936
+ }
937
+
938
+ function logBoxStyleValue(backgroundColor, color) {
939
+ return `font-size:14px; background:${backgroundColor !== null && backgroundColor !== void 0 ? backgroundColor : '#ffffff'}; color:${color !== null && color !== void 0 ? color : '#000000'}; border-radius:4px; padding-inline:4px;`;
940
+ }
941
+
942
+ let initialized = false;
943
+ let go;
944
+ let goExitPromise;
945
+ const CACHE_KEY = 'openim-wasm-cache';
946
+ async function initializeWasm(url) {
947
+ if (initialized) {
948
+ return null;
949
+ }
950
+ if (typeof window === 'undefined') {
951
+ return Promise.resolve(null);
952
+ }
953
+ go = new Go();
954
+ let wasm;
955
+ try {
956
+ if ('instantiateStreaming' in WebAssembly) {
957
+ wasm = await WebAssembly.instantiateStreaming(fetchWithCache(url), go.importObject);
958
+ }
959
+ else {
960
+ const bytes = await fetchWithCache(url).then(resp => resp.arrayBuffer());
961
+ wasm = await WebAssembly.instantiate(bytes, go.importObject);
962
+ }
963
+ go.run(wasm.instance);
964
+ }
965
+ catch (error) {
966
+ console.error('Failed to initialize WASM:', error);
967
+ return null;
968
+ }
969
+ await wait(100);
970
+ initialized = true;
971
+ return go;
972
+ }
973
+ function getGO() {
974
+ return go;
975
+ }
976
+ function getGoExitPromise() {
977
+ return goExitPromise;
978
+ }
979
+ async function fetchWithCache(url) {
980
+ if (!('caches' in window)) {
981
+ return fetch(url);
982
+ }
983
+ const isResourceUpdated = async () => {
984
+ const serverResponse = await fetch(url, { method: 'HEAD' });
985
+ const etag = serverResponse.headers.get('ETag');
986
+ const lastModified = serverResponse.headers.get('Last-Modified');
987
+ return (serverResponse.ok &&
988
+ (etag !== (cachedResponse === null || cachedResponse === void 0 ? void 0 : cachedResponse.headers.get('ETag')) ||
989
+ lastModified !== (cachedResponse === null || cachedResponse === void 0 ? void 0 : cachedResponse.headers.get('Last-Modified'))));
990
+ };
991
+ const cache = await caches.open(CACHE_KEY);
992
+ const cachedResponse = await cache.match(url);
993
+ if (cachedResponse && !(await isResourceUpdated())) {
994
+ return cachedResponse;
995
+ }
996
+ return fetchAndUpdateCache(url, cache);
997
+ }
998
+ async function fetchAndUpdateCache(url, cache) {
999
+ const response = await fetch(url, { cache: 'no-cache' });
1000
+ try {
1001
+ await cache.put(url, response.clone());
1002
+ }
1003
+ catch (error) {
1004
+ console.warn('Failed to put cache');
1005
+ }
1006
+ return response;
1007
+ }
1008
+
1009
+ var MessageReceiveOptType;
1010
+ (function (MessageReceiveOptType) {
1011
+ MessageReceiveOptType[MessageReceiveOptType["Normal"] = 0] = "Normal";
1012
+ MessageReceiveOptType[MessageReceiveOptType["NotReceive"] = 1] = "NotReceive";
1013
+ MessageReceiveOptType[MessageReceiveOptType["NotNotify"] = 2] = "NotNotify";
1014
+ })(MessageReceiveOptType || (MessageReceiveOptType = {}));
1015
+ var AddFriendPermission;
1016
+ (function (AddFriendPermission) {
1017
+ AddFriendPermission[AddFriendPermission["AddFriendAllowed"] = 0] = "AddFriendAllowed";
1018
+ AddFriendPermission[AddFriendPermission["AddFriendAllowedNoReview"] = 1] = "AddFriendAllowedNoReview";
1019
+ AddFriendPermission[AddFriendPermission["AddFriendDenied"] = 2] = "AddFriendDenied";
1020
+ })(AddFriendPermission || (AddFriendPermission = {}));
1021
+ var AllowType;
1022
+ (function (AllowType) {
1023
+ AllowType[AllowType["Allowed"] = 0] = "Allowed";
1024
+ AllowType[AllowType["NotAllowed"] = 1] = "NotAllowed";
1025
+ })(AllowType || (AllowType = {}));
1026
+ var GroupType;
1027
+ (function (GroupType) {
1028
+ GroupType[GroupType["Group"] = 2] = "Group";
1029
+ GroupType[GroupType["WorkingGroup"] = 2] = "WorkingGroup";
1030
+ })(GroupType || (GroupType = {}));
1031
+ var GroupJoinSource;
1032
+ (function (GroupJoinSource) {
1033
+ GroupJoinSource[GroupJoinSource["Invitation"] = 2] = "Invitation";
1034
+ GroupJoinSource[GroupJoinSource["Search"] = 3] = "Search";
1035
+ GroupJoinSource[GroupJoinSource["QrCode"] = 4] = "QrCode";
1036
+ })(GroupJoinSource || (GroupJoinSource = {}));
1037
+ var GroupMemberRole;
1038
+ (function (GroupMemberRole) {
1039
+ GroupMemberRole[GroupMemberRole["Normal"] = 20] = "Normal";
1040
+ GroupMemberRole[GroupMemberRole["Admin"] = 60] = "Admin";
1041
+ GroupMemberRole[GroupMemberRole["Owner"] = 100] = "Owner";
1042
+ })(GroupMemberRole || (GroupMemberRole = {}));
1043
+ var GroupVerificationType;
1044
+ (function (GroupVerificationType) {
1045
+ GroupVerificationType[GroupVerificationType["ApplyNeedInviteNot"] = 0] = "ApplyNeedInviteNot";
1046
+ GroupVerificationType[GroupVerificationType["AllNeed"] = 1] = "AllNeed";
1047
+ GroupVerificationType[GroupVerificationType["AllNot"] = 2] = "AllNot";
1048
+ })(GroupVerificationType || (GroupVerificationType = {}));
1049
+ var MessageStatus;
1050
+ (function (MessageStatus) {
1051
+ MessageStatus[MessageStatus["Sending"] = 1] = "Sending";
1052
+ MessageStatus[MessageStatus["Succeed"] = 2] = "Succeed";
1053
+ MessageStatus[MessageStatus["Failed"] = 3] = "Failed";
1054
+ })(MessageStatus || (MessageStatus = {}));
1055
+ var Platform;
1056
+ (function (Platform) {
1057
+ Platform[Platform["iOS"] = 1] = "iOS";
1058
+ Platform[Platform["Android"] = 2] = "Android";
1059
+ Platform[Platform["Windows"] = 3] = "Windows";
1060
+ Platform[Platform["MacOSX"] = 4] = "MacOSX";
1061
+ Platform[Platform["Web"] = 5] = "Web";
1062
+ Platform[Platform["Linux"] = 7] = "Linux";
1063
+ Platform[Platform["AndroidPad"] = 8] = "AndroidPad";
1064
+ Platform[Platform["iPad"] = 9] = "iPad";
1065
+ })(Platform || (Platform = {}));
1066
+ var LogLevel;
1067
+ (function (LogLevel) {
1068
+ LogLevel[LogLevel["Verbose"] = 6] = "Verbose";
1069
+ LogLevel[LogLevel["Debug"] = 5] = "Debug";
1070
+ LogLevel[LogLevel["Info"] = 4] = "Info";
1071
+ LogLevel[LogLevel["Warn"] = 3] = "Warn";
1072
+ LogLevel[LogLevel["Error"] = 2] = "Error";
1073
+ LogLevel[LogLevel["Fatal"] = 1] = "Fatal";
1074
+ LogLevel[LogLevel["Panic"] = 0] = "Panic";
1075
+ })(LogLevel || (LogLevel = {}));
1076
+ var ApplicationHandleResult;
1077
+ (function (ApplicationHandleResult) {
1078
+ ApplicationHandleResult[ApplicationHandleResult["Unprocessed"] = 0] = "Unprocessed";
1079
+ ApplicationHandleResult[ApplicationHandleResult["Agree"] = 1] = "Agree";
1080
+ ApplicationHandleResult[ApplicationHandleResult["Reject"] = -1] = "Reject";
1081
+ })(ApplicationHandleResult || (ApplicationHandleResult = {}));
1082
+ var MessageType;
1083
+ (function (MessageType) {
1084
+ MessageType[MessageType["TextMessage"] = 101] = "TextMessage";
1085
+ MessageType[MessageType["PictureMessage"] = 102] = "PictureMessage";
1086
+ MessageType[MessageType["VoiceMessage"] = 103] = "VoiceMessage";
1087
+ MessageType[MessageType["VideoMessage"] = 104] = "VideoMessage";
1088
+ MessageType[MessageType["FileMessage"] = 105] = "FileMessage";
1089
+ MessageType[MessageType["AtTextMessage"] = 106] = "AtTextMessage";
1090
+ MessageType[MessageType["MergeMessage"] = 107] = "MergeMessage";
1091
+ MessageType[MessageType["CardMessage"] = 108] = "CardMessage";
1092
+ MessageType[MessageType["LocationMessage"] = 109] = "LocationMessage";
1093
+ MessageType[MessageType["CustomMessage"] = 110] = "CustomMessage";
1094
+ MessageType[MessageType["TypingMessage"] = 113] = "TypingMessage";
1095
+ MessageType[MessageType["QuoteMessage"] = 114] = "QuoteMessage";
1096
+ MessageType[MessageType["FaceMessage"] = 115] = "FaceMessage";
1097
+ MessageType[MessageType["FriendAdded"] = 1201] = "FriendAdded";
1098
+ MessageType[MessageType["OANotification"] = 1400] = "OANotification";
1099
+ MessageType[MessageType["GroupCreated"] = 1501] = "GroupCreated";
1100
+ MessageType[MessageType["GroupInfoUpdated"] = 1502] = "GroupInfoUpdated";
1101
+ MessageType[MessageType["MemberQuit"] = 1504] = "MemberQuit";
1102
+ MessageType[MessageType["GroupOwnerTransferred"] = 1507] = "GroupOwnerTransferred";
1103
+ MessageType[MessageType["MemberKicked"] = 1508] = "MemberKicked";
1104
+ MessageType[MessageType["MemberInvited"] = 1509] = "MemberInvited";
1105
+ MessageType[MessageType["MemberEnter"] = 1510] = "MemberEnter";
1106
+ MessageType[MessageType["GroupDismissed"] = 1511] = "GroupDismissed";
1107
+ MessageType[MessageType["GroupMemberMuted"] = 1512] = "GroupMemberMuted";
1108
+ MessageType[MessageType["GroupMemberCancelMuted"] = 1513] = "GroupMemberCancelMuted";
1109
+ MessageType[MessageType["GroupMuted"] = 1514] = "GroupMuted";
1110
+ MessageType[MessageType["GroupCancelMuted"] = 1515] = "GroupCancelMuted";
1111
+ MessageType[MessageType["GroupAnnouncementUpdated"] = 1519] = "GroupAnnouncementUpdated";
1112
+ MessageType[MessageType["GroupNameUpdated"] = 1520] = "GroupNameUpdated";
1113
+ MessageType[MessageType["BurnMessageChange"] = 1701] = "BurnMessageChange";
1114
+ MessageType[MessageType["RevokeMessage"] = 2101] = "RevokeMessage";
1115
+ })(MessageType || (MessageType = {}));
1116
+ var SessionType;
1117
+ (function (SessionType) {
1118
+ SessionType[SessionType["Single"] = 1] = "Single";
1119
+ SessionType[SessionType["Group"] = 3] = "Group";
1120
+ SessionType[SessionType["WorkingGroup"] = 3] = "WorkingGroup";
1121
+ SessionType[SessionType["Notification"] = 4] = "Notification";
1122
+ })(SessionType || (SessionType = {}));
1123
+ var GroupStatus;
1124
+ (function (GroupStatus) {
1125
+ GroupStatus[GroupStatus["Normal"] = 0] = "Normal";
1126
+ GroupStatus[GroupStatus["Banned"] = 1] = "Banned";
1127
+ GroupStatus[GroupStatus["Dismissed"] = 2] = "Dismissed";
1128
+ GroupStatus[GroupStatus["Muted"] = 3] = "Muted";
1129
+ })(GroupStatus || (GroupStatus = {}));
1130
+ var GroupAtType;
1131
+ (function (GroupAtType) {
1132
+ GroupAtType[GroupAtType["AtNormal"] = 0] = "AtNormal";
1133
+ GroupAtType[GroupAtType["AtMe"] = 1] = "AtMe";
1134
+ GroupAtType[GroupAtType["AtAll"] = 2] = "AtAll";
1135
+ GroupAtType[GroupAtType["AtAllAtMe"] = 3] = "AtAllAtMe";
1136
+ GroupAtType[GroupAtType["AtGroupNotice"] = 4] = "AtGroupNotice";
1137
+ })(GroupAtType || (GroupAtType = {}));
1138
+ var GroupMemberFilter;
1139
+ (function (GroupMemberFilter) {
1140
+ GroupMemberFilter[GroupMemberFilter["All"] = 0] = "All";
1141
+ GroupMemberFilter[GroupMemberFilter["Owner"] = 1] = "Owner";
1142
+ GroupMemberFilter[GroupMemberFilter["Admin"] = 2] = "Admin";
1143
+ GroupMemberFilter[GroupMemberFilter["Normal"] = 3] = "Normal";
1144
+ GroupMemberFilter[GroupMemberFilter["AdminAndNormal"] = 4] = "AdminAndNormal";
1145
+ GroupMemberFilter[GroupMemberFilter["AdminAndOwner"] = 5] = "AdminAndOwner";
1146
+ })(GroupMemberFilter || (GroupMemberFilter = {}));
1147
+ var Relationship;
1148
+ (function (Relationship) {
1149
+ Relationship[Relationship["isBlack"] = 0] = "isBlack";
1150
+ Relationship[Relationship["isFriend"] = 1] = "isFriend";
1151
+ })(Relationship || (Relationship = {}));
1152
+ var LoginStatus;
1153
+ (function (LoginStatus) {
1154
+ LoginStatus[LoginStatus["Logout"] = 1] = "Logout";
1155
+ LoginStatus[LoginStatus["Logging"] = 2] = "Logging";
1156
+ LoginStatus[LoginStatus["Logged"] = 3] = "Logged";
1157
+ })(LoginStatus || (LoginStatus = {}));
1158
+ var OnlineState;
1159
+ (function (OnlineState) {
1160
+ OnlineState[OnlineState["Online"] = 1] = "Online";
1161
+ OnlineState[OnlineState["Offline"] = 0] = "Offline";
1162
+ })(OnlineState || (OnlineState = {}));
1163
+ var GroupMessageReaderFilter;
1164
+ (function (GroupMessageReaderFilter) {
1165
+ GroupMessageReaderFilter[GroupMessageReaderFilter["Read"] = 0] = "Read";
1166
+ GroupMessageReaderFilter[GroupMessageReaderFilter["UnRead"] = 1] = "UnRead";
1167
+ })(GroupMessageReaderFilter || (GroupMessageReaderFilter = {}));
1168
+ var ViewType;
1169
+ (function (ViewType) {
1170
+ ViewType[ViewType["History"] = 0] = "History";
1171
+ ViewType[ViewType["Search"] = 1] = "Search";
1172
+ })(ViewType || (ViewType = {}));
1173
+
1174
+ class SDK extends Emitter {
1175
+ constructor(url = '/openIM.wasm', debug = true) {
1176
+ super();
1177
+ this.goExisted = false;
1178
+ this.tryParse = true;
1179
+ this.isLogStandardOutput = true;
1180
+ this.login = async (params, operationID = v4()) => {
1181
+ var _a, _b;
1182
+ this._logWrap(`SDK => (invoked by js) run login with args ${JSON.stringify({
1183
+ params,
1184
+ operationID,
1185
+ })}`);
1186
+ await workerPromise;
1187
+ await this.wasmInitializedPromise;
1188
+ window.commonEventFunc(event => {
1189
+ try {
1190
+ this._logWrap(`%cSDK =>%c received event %c${event}%c `, logBoxStyleValue('#282828', '#ffffff'), '', 'color: #4f2398;', '');
1191
+ const parsed = JSON.parse(event);
1192
+ if (this.tryParse) {
1193
+ try {
1194
+ parsed.data = JSON.parse(parsed.data);
1195
+ }
1196
+ catch (error) {
1197
+ // parse error
1198
+ }
1199
+ }
1200
+ this.emit(parsed.event, parsed);
1201
+ }
1202
+ catch (error) {
1203
+ console.error(error);
1204
+ }
1205
+ });
1206
+ const config = {
1207
+ platformID: params.platformID,
1208
+ apiAddr: params.apiAddr,
1209
+ wsAddr: params.wsAddr,
1210
+ dataDir: './',
1211
+ logLevel: params.logLevel || 5,
1212
+ isLogStandardOutput: (_a = params.isLogStandardOutput) !== null && _a !== void 0 ? _a : this.isLogStandardOutput,
1213
+ logFilePath: './',
1214
+ isExternalExtensions: params.isExternalExtensions || false,
1215
+ };
1216
+ this.tryParse = (_b = params.tryParse) !== null && _b !== void 0 ? _b : true;
1217
+ window.initSDK(operationID, JSON.stringify(config));
1218
+ return await window.login(operationID, params.userID, params.token);
1219
+ };
1220
+ this.logout = (operationID = v4()) => {
1221
+ window.fileMapClear();
1222
+ return this._invoker('logout', window.logout, [operationID]);
1223
+ };
1224
+ this.getAllConversationList = (operationID = v4()) => {
1225
+ return this._invoker('getAllConversationList', window.getAllConversationList, [operationID]);
1226
+ };
1227
+ this.getOneConversation = (params, operationID = v4()) => {
1228
+ return this._invoker('getOneConversation', window.getOneConversation, [operationID, params.sessionType, params.sourceID]);
1229
+ };
1230
+ this.getAdvancedHistoryMessageList = (params, operationID = v4()) => {
1231
+ return this._invoker('getAdvancedHistoryMessageList', window.getAdvancedHistoryMessageList, [operationID, JSON.stringify(params)]);
1232
+ };
1233
+ this.getAdvancedHistoryMessageListReverse = (params, operationID = v4()) => {
1234
+ return this._invoker('getAdvancedHistoryMessageListReverse', window.getAdvancedHistoryMessageListReverse, [operationID, JSON.stringify(params)]);
1235
+ };
1236
+ this.fetchSurroundingMessages = (params, operationID = v4()) => {
1237
+ return this._invoker('fetchSurroundingMessages', window.fetchSurroundingMessages, [operationID, JSON.stringify(params)]);
1238
+ };
1239
+ this.getSpecifiedGroupsInfo = (params, operationID = v4()) => {
1240
+ return this._invoker('getSpecifiedGroupsInfo', window.getSpecifiedGroupsInfo, [operationID, JSON.stringify(params)]);
1241
+ };
1242
+ this.deleteConversationAndDeleteAllMsg = (conversationID, operationID = v4()) => {
1243
+ return this._invoker('deleteConversationAndDeleteAllMsg', window.deleteConversationAndDeleteAllMsg, [operationID, conversationID]);
1244
+ };
1245
+ this.markConversationMessageAsRead = (data, operationID = v4()) => {
1246
+ return this._invoker('markConversationMessageAsRead', window.markConversationMessageAsRead, [operationID, data]);
1247
+ };
1248
+ this.sendGroupMessageReadReceipt = (params, operationID = v4()) => {
1249
+ return this._invoker('sendGroupMessageReadReceipt', window.sendGroupMessageReadReceipt, [
1250
+ operationID,
1251
+ params.conversationID,
1252
+ JSON.stringify(params.clientMsgIDList),
1253
+ ]);
1254
+ };
1255
+ this.getGroupMessageReaderList = (params, operationID = v4()) => {
1256
+ return this._invoker('getGroupMessageReaderList', window.getGroupMessageReaderList, [
1257
+ operationID,
1258
+ params.conversationID,
1259
+ params.clientMsgID,
1260
+ params.filter,
1261
+ params.offset,
1262
+ params.count,
1263
+ ]);
1264
+ };
1265
+ this.getGroupMemberList = (params, operationID = v4()) => {
1266
+ return this._invoker('getGroupMemberList', window.getGroupMemberList, [operationID, params.groupID, params.filter, params.offset, params.count]);
1267
+ };
1268
+ this.createTextMessage = (text, operationID = v4()) => {
1269
+ return this._invoker('createTextMessage', window.createTextMessage, [operationID, text], data => {
1270
+ // compitable with old version sdk
1271
+ return data[0];
1272
+ });
1273
+ };
1274
+ this.createImageMessageByURL = (params, operationID = v4()) => {
1275
+ return this._invoker('createImageMessageByURL', window.createImageMessageByURL, [
1276
+ operationID,
1277
+ params.sourcePath,
1278
+ JSON.stringify(params.sourcePicture),
1279
+ JSON.stringify(params.bigPicture),
1280
+ JSON.stringify(params.snapshotPicture),
1281
+ ], data => {
1282
+ // compitable with old version sdk
1283
+ return data[0];
1284
+ });
1285
+ };
1286
+ this.createImageMessageByFile = (params, operationID = v4()) => {
1287
+ params.sourcePicture.uuid = `${params.sourcePicture.uuid}/${params.file.name}`;
1288
+ window.fileMapSet(params.sourcePicture.uuid, params.file);
1289
+ return this._invoker('createImageMessageByFile', window.createImageMessageByURL, [
1290
+ operationID,
1291
+ params.sourcePath,
1292
+ JSON.stringify(params.sourcePicture),
1293
+ JSON.stringify(params.bigPicture),
1294
+ JSON.stringify(params.snapshotPicture),
1295
+ ], data => {
1296
+ // compitable with old version sdk
1297
+ return data[0];
1298
+ });
1299
+ };
1300
+ this.createCustomMessage = (params, operationID = v4()) => {
1301
+ return this._invoker('createCustomMessage', window.createCustomMessage, [operationID, params.data, params.extension, params.description], data => {
1302
+ // compitable with old version sdk
1303
+ return data[0];
1304
+ });
1305
+ };
1306
+ this.createQuoteMessage = (params, operationID = v4()) => {
1307
+ return this._invoker('createQuoteMessage', window.createQuoteMessage, [operationID, params.text, params.message], data => {
1308
+ // compitable with old version sdk
1309
+ return data[0];
1310
+ });
1311
+ };
1312
+ this.createAdvancedQuoteMessage = (params, operationID = v4()) => {
1313
+ return this._invoker('createAdvancedQuoteMessage', window.createAdvancedQuoteMessage, [
1314
+ operationID,
1315
+ params.text,
1316
+ JSON.stringify(params.message),
1317
+ JSON.stringify(params.messageEntityList),
1318
+ ], data => {
1319
+ // compitable with old version sdk
1320
+ return data[0];
1321
+ });
1322
+ };
1323
+ this.createAdvancedTextMessage = (params, operationID = v4()) => {
1324
+ return this._invoker('createAdvancedTextMessage', window.createAdvancedTextMessage, [operationID, params.text, JSON.stringify(params.messageEntityList)], data => {
1325
+ // compitable with old version sdk
1326
+ return data[0];
1327
+ });
1328
+ };
1329
+ this.sendMessage = (params, operationID = v4()) => {
1330
+ var _a, _b;
1331
+ const offlinePushInfo = (_a = params.offlinePushInfo) !== null && _a !== void 0 ? _a : {
1332
+ title: 'You have a new message.',
1333
+ desc: '',
1334
+ ex: '',
1335
+ iOSPushSound: '+1',
1336
+ iOSBadgeCount: true,
1337
+ };
1338
+ return this._invoker('sendMessage', window.sendMessage, [
1339
+ operationID,
1340
+ JSON.stringify(params.message),
1341
+ params.recvID,
1342
+ params.groupID,
1343
+ JSON.stringify(offlinePushInfo),
1344
+ (_b = params.isOnlineOnly) !== null && _b !== void 0 ? _b : false,
1345
+ ]);
1346
+ };
1347
+ this.sendMessageNotOss = (params, operationID = v4()) => {
1348
+ var _a, _b;
1349
+ const offlinePushInfo = (_a = params.offlinePushInfo) !== null && _a !== void 0 ? _a : {
1350
+ title: 'You have a new message.',
1351
+ desc: '',
1352
+ ex: '',
1353
+ iOSPushSound: '+1',
1354
+ iOSBadgeCount: true,
1355
+ };
1356
+ return this._invoker('sendMessageNotOss', window.sendMessageNotOss, [
1357
+ operationID,
1358
+ JSON.stringify(params.message),
1359
+ params.recvID,
1360
+ params.groupID,
1361
+ JSON.stringify(offlinePushInfo),
1362
+ (_b = params.isOnlineOnly) !== null && _b !== void 0 ? _b : false,
1363
+ ]);
1364
+ };
1365
+ this.setMessageLocalEx = (params, operationID = v4()) => {
1366
+ return this._invoker('setMessageLocalEx', window.setMessageLocalEx, [
1367
+ operationID,
1368
+ params.conversationID,
1369
+ params.clientMsgID,
1370
+ params.localEx,
1371
+ ]);
1372
+ };
1373
+ this.getHistoryMessageListReverse = (params, operationID = v4()) => {
1374
+ return this._invoker('getHistoryMessageListReverse', window.getHistoryMessageListReverse, [operationID, JSON.stringify(params)]);
1375
+ };
1376
+ this.revokeMessage = (data, operationID = v4()) => {
1377
+ return this._invoker('revokeMessage', window.revokeMessage, [
1378
+ operationID,
1379
+ data.conversationID,
1380
+ data.clientMsgID,
1381
+ ]);
1382
+ };
1383
+ this.setConversation = (params, operationID = v4()) => {
1384
+ return this._invoker('setConversation', window.setConversation, [
1385
+ operationID,
1386
+ params.conversationID,
1387
+ JSON.stringify(params),
1388
+ ]);
1389
+ };
1390
+ /**
1391
+ * @deprecated Use setConversation instead.
1392
+ */
1393
+ this.setConversationPrivateChat = (params, operationID = v4()) => {
1394
+ return this._invoker('setConversationPrivateChat', window.setConversation, [
1395
+ operationID,
1396
+ params.conversationID,
1397
+ JSON.stringify({
1398
+ isPrivateChat: params.isPrivate,
1399
+ }),
1400
+ ]);
1401
+ };
1402
+ /**
1403
+ * @deprecated Use setConversation instead.
1404
+ */
1405
+ this.setConversationBurnDuration = (params, operationID = v4()) => {
1406
+ return this._invoker('setConversationBurnDuration', window.setConversation, [
1407
+ operationID,
1408
+ params.conversationID,
1409
+ JSON.stringify({
1410
+ burnDuration: params.burnDuration,
1411
+ }),
1412
+ ]);
1413
+ };
1414
+ this.getLoginStatus = (operationID = v4()) => {
1415
+ return this._invoker('getLoginStatus', window.getLoginStatus, [operationID], data => {
1416
+ // compitable with old version sdk
1417
+ return data[0];
1418
+ });
1419
+ };
1420
+ this.setAppBackgroundStatus = (data, operationID = v4()) => {
1421
+ return this._invoker('setAppBackgroundStatus', window.setAppBackgroundStatus, [operationID, data]);
1422
+ };
1423
+ this.networkStatusChanged = (operationID = v4()) => {
1424
+ return this._invoker('networkStatusChanged ', window.networkStatusChanged, [operationID]);
1425
+ };
1426
+ this.getLoginUserID = (operationID = v4()) => {
1427
+ return this._invoker('getLoginUserID', window.getLoginUserID, [
1428
+ operationID,
1429
+ ]);
1430
+ };
1431
+ this.getSelfUserInfo = (operationID = v4()) => {
1432
+ return this._invoker('getSelfUserInfo', window.getSelfUserInfo, [operationID]);
1433
+ };
1434
+ this.getUsersInfo = (data, operationID = v4()) => {
1435
+ return this._invoker('getUsersInfo', window.getUsersInfo, [operationID, JSON.stringify(data)]);
1436
+ };
1437
+ /**
1438
+ * @deprecated Use setSelfInfo instead.
1439
+ */
1440
+ this.SetSelfInfoEx = (data, operationID = v4()) => {
1441
+ return this._invoker('SetSelfInfoEx', window.setSelfInfo, [
1442
+ operationID,
1443
+ JSON.stringify(data),
1444
+ ]);
1445
+ };
1446
+ this.setSelfInfo = (data, operationID = v4()) => {
1447
+ return this._invoker('setSelfInfo', window.setSelfInfo, [
1448
+ operationID,
1449
+ JSON.stringify(data),
1450
+ ]);
1451
+ };
1452
+ this.createTextAtMessage = (data, operationID = v4()) => {
1453
+ var _a;
1454
+ return this._invoker('createTextAtMessage', window.createTextAtMessage, [
1455
+ operationID,
1456
+ data.text,
1457
+ JSON.stringify(data.atUserIDList),
1458
+ JSON.stringify(data.atUsersInfo),
1459
+ (_a = JSON.stringify(data.message)) !== null && _a !== void 0 ? _a : '',
1460
+ ], data => {
1461
+ // compitable with old version sdk
1462
+ return data[0];
1463
+ });
1464
+ };
1465
+ this.createSoundMessageByURL = (data, operationID = v4()) => {
1466
+ return this._invoker('createSoundMessageByURL', window.createSoundMessageByURL, [operationID, JSON.stringify(data)], data => {
1467
+ // compitable with old version sdk
1468
+ return data[0];
1469
+ });
1470
+ };
1471
+ this.createSoundMessageByFile = (data, operationID = v4()) => {
1472
+ data.uuid = `${data.uuid}/${data.file.name}`;
1473
+ window.fileMapSet(data.uuid, data.file);
1474
+ return this._invoker('createSoundMessageByFile', window.createSoundMessageByURL, [operationID, JSON.stringify(data)], data => {
1475
+ // compitable with old version sdk
1476
+ return data[0];
1477
+ });
1478
+ };
1479
+ this.createVideoMessageByURL = (data, operationID = v4()) => {
1480
+ return this._invoker('createVideoMessageByURL', window.createVideoMessageByURL, [operationID, JSON.stringify(data)], data => {
1481
+ // compitable with old version sdk
1482
+ return data[0];
1483
+ });
1484
+ };
1485
+ this.createVideoMessageByFile = (data, operationID = v4()) => {
1486
+ data.videoUUID = `${data.videoUUID}/${data.videoFile.name}`;
1487
+ data.snapshotUUID = `${data.snapshotUUID}/${data.snapshotFile.name}`;
1488
+ window.fileMapSet(data.videoUUID, data.videoFile);
1489
+ window.fileMapSet(data.snapshotUUID, data.snapshotFile);
1490
+ return this._invoker('createVideoMessageByFile', window.createVideoMessageByURL, [operationID, JSON.stringify(data)], data => {
1491
+ // compitable with old version sdk
1492
+ return data[0];
1493
+ });
1494
+ };
1495
+ this.createFileMessageByURL = (data, operationID = v4()) => {
1496
+ return this._invoker('createFileMessageByURL', window.createFileMessageByURL, [operationID, JSON.stringify(data)], data => {
1497
+ // compitable with old version sdk
1498
+ return data[0];
1499
+ });
1500
+ };
1501
+ this.createFileMessageByFile = (data, operationID = v4()) => {
1502
+ data.uuid = `${data.uuid}/${data.file.name}`;
1503
+ window.fileMapSet(data.uuid, data.file);
1504
+ return this._invoker('createFileMessageByFile', window.createFileMessageByURL, [operationID, JSON.stringify(data)], data => {
1505
+ // compitable with old version sdk
1506
+ return data[0];
1507
+ });
1508
+ };
1509
+ this.createMergerMessage = (data, operationID = v4()) => {
1510
+ return this._invoker('createMergerMessage ', window.createMergerMessage, [
1511
+ operationID,
1512
+ JSON.stringify(data.messageList),
1513
+ data.title,
1514
+ JSON.stringify(data.summaryList),
1515
+ ], data => {
1516
+ // compitable with old version sdk
1517
+ return data[0];
1518
+ });
1519
+ };
1520
+ this.createForwardMessage = (data, operationID = v4()) => {
1521
+ return this._invoker('createForwardMessage ', window.createForwardMessage, [operationID, JSON.stringify(data)], data => {
1522
+ // compitable with old version sdk
1523
+ return data[0];
1524
+ });
1525
+ };
1526
+ this.createFaceMessage = (data, operationID = v4()) => {
1527
+ return this._invoker('createFaceMessage ', window.createFaceMessage, [operationID, data.index, data.data], data => {
1528
+ // compitable with old version sdk
1529
+ return data[0];
1530
+ });
1531
+ };
1532
+ this.createLocationMessage = (data, operationID = v4()) => {
1533
+ return this._invoker('createLocationMessage ', window.createLocationMessage, [operationID, data.description, data.longitude, data.latitude], data => {
1534
+ // compitable with old version sdk
1535
+ return data[0];
1536
+ });
1537
+ };
1538
+ this.createCardMessage = (data, operationID = v4()) => {
1539
+ return this._invoker('createCardMessage ', window.createCardMessage, [operationID, JSON.stringify(data)], data => {
1540
+ // compitable with old version sdk
1541
+ return data[0];
1542
+ });
1543
+ };
1544
+ this.deleteMessageFromLocalStorage = (data, operationID = v4()) => {
1545
+ return this._invoker('deleteMessageFromLocalStorage ', window.deleteMessageFromLocalStorage, [operationID, data.conversationID, data.clientMsgID]);
1546
+ };
1547
+ this.deleteMessage = (data, operationID = v4()) => {
1548
+ return this._invoker('deleteMessage ', window.deleteMessage, [
1549
+ operationID,
1550
+ data.conversationID,
1551
+ data.clientMsgID,
1552
+ ]);
1553
+ };
1554
+ this.deleteAllConversationFromLocal = (operationID = v4()) => {
1555
+ return this._invoker('deleteAllConversationFromLocal ', window.deleteAllConversationFromLocal, [operationID]);
1556
+ };
1557
+ this.deleteAllMsgFromLocal = (operationID = v4()) => {
1558
+ return this._invoker('deleteAllMsgFromLocal ', window.deleteAllMsgFromLocal, [operationID]);
1559
+ };
1560
+ this.deleteAllMsgFromLocalAndSvr = (operationID = v4()) => {
1561
+ return this._invoker('deleteAllMsgFromLocalAndSvr ', window.deleteAllMsgFromLocalAndSvr, [operationID]);
1562
+ };
1563
+ this.insertSingleMessageToLocalStorage = (data, operationID = v4()) => {
1564
+ return this._invoker('insertSingleMessageToLocalStorage ', window.insertSingleMessageToLocalStorage, [operationID, JSON.stringify(data.message), data.recvID, data.sendID]);
1565
+ };
1566
+ this.insertGroupMessageToLocalStorage = (data, operationID = v4()) => {
1567
+ return this._invoker('insertGroupMessageToLocalStorage ', window.insertGroupMessageToLocalStorage, [operationID, JSON.stringify(data.message), data.groupID, data.sendID]);
1568
+ };
1569
+ /**
1570
+ * @deprecated Use changeInputStates instead.
1571
+ */
1572
+ this.typingStatusUpdate = (data, operationID = v4()) => {
1573
+ return this._invoker('typingStatusUpdate ', window.typingStatusUpdate, [
1574
+ operationID,
1575
+ data.recvID,
1576
+ data.msgTip,
1577
+ ]);
1578
+ };
1579
+ this.changeInputStates = (data, operationID = v4()) => {
1580
+ return this._invoker('changeInputStates ', window.changeInputStates, [
1581
+ operationID,
1582
+ data.conversationID,
1583
+ data.focus,
1584
+ ]);
1585
+ };
1586
+ this.getInputstates = (data, operationID = v4()) => {
1587
+ return this._invoker('getInputstates ', window.getInputstates, [
1588
+ operationID,
1589
+ data.conversationID,
1590
+ data.userID,
1591
+ ]);
1592
+ };
1593
+ this.clearConversationAndDeleteAllMsg = (data, operationID = v4()) => {
1594
+ return this._invoker('clearConversationAndDeleteAllMsg ', window.clearConversationAndDeleteAllMsg, [operationID, data]);
1595
+ };
1596
+ this.hideConversation = (data, operationID = v4()) => {
1597
+ return this._invoker('hideConversation ', window.hideConversation, [
1598
+ operationID,
1599
+ data,
1600
+ ]);
1601
+ };
1602
+ this.getConversationListSplit = (data, operationID = v4()) => {
1603
+ return this._invoker('getConversationListSplit ', window.getConversationListSplit, [operationID, data.offset, data.count]);
1604
+ };
1605
+ // searchConversation = (data: SplitConversationParams, operationID = uuidv4()) => {
1606
+ // return this._invoker<ConversationItem[]>(
1607
+ // 'searchConversation ',
1608
+ // window.searchConversation,
1609
+ // [operationID, data.offset, data.count]
1610
+ // );
1611
+ // };
1612
+ /**
1613
+ * @deprecated Use setConversation instead.
1614
+ */
1615
+ this.setConversationEx = (data, operationID = v4()) => {
1616
+ return this._invoker('setConversationEx ', window.setConversation, [
1617
+ operationID,
1618
+ data.conversationID,
1619
+ JSON.stringify({
1620
+ ex: data.ex,
1621
+ }),
1622
+ ]);
1623
+ };
1624
+ this.getConversationIDBySessionType = (data, operationID = v4()) => {
1625
+ return this._invoker('getConversationIDBySessionType ', window.getConversationIDBySessionType, [operationID, data.sourceID, data.sessionType]);
1626
+ };
1627
+ this.getMultipleConversation = (data, operationID = v4()) => {
1628
+ return this._invoker('getMultipleConversation ', window.getMultipleConversation, [operationID, JSON.stringify(data)]);
1629
+ };
1630
+ this.deleteConversation = (data, operationID = v4()) => {
1631
+ return this._invoker('deleteConversation ', window.deleteConversation, [
1632
+ operationID,
1633
+ data,
1634
+ ]);
1635
+ };
1636
+ /**
1637
+ * @deprecated Use setConversation instead.
1638
+ */
1639
+ this.setConversationDraft = (data, operationID = v4()) => {
1640
+ return this._invoker('setConversationDraft ', window.setConversationDraft, [operationID, data.conversationID, data.draftText]);
1641
+ };
1642
+ /**
1643
+ * @deprecated Use setConversation instead.
1644
+ */
1645
+ this.pinConversation = (data, operationID = v4()) => {
1646
+ return this._invoker('pinConversation ', window.setConversation, [
1647
+ operationID,
1648
+ data.conversationID,
1649
+ JSON.stringify({
1650
+ isPinned: data.isPinned,
1651
+ }),
1652
+ ]);
1653
+ };
1654
+ this.getTotalUnreadMsgCount = (operationID = v4()) => {
1655
+ return this._invoker('getTotalUnreadMsgCount ', window.getTotalUnreadMsgCount, [operationID]);
1656
+ };
1657
+ this.getConversationRecvMessageOpt = (data, operationID = v4()) => {
1658
+ return this._invoker('getConversationRecvMessageOpt ', window.getConversationRecvMessageOpt, [operationID, JSON.stringify(data)]);
1659
+ };
1660
+ /**
1661
+ * @deprecated Use setConversation instead.
1662
+ */
1663
+ this.setConversationRecvMessageOpt = (data, operationID = v4()) => {
1664
+ return this._invoker('setConversationRecvMessageOpt ', window.setConversation, [
1665
+ operationID,
1666
+ data.conversationID,
1667
+ JSON.stringify({
1668
+ recvMsgOpt: data.opt,
1669
+ }),
1670
+ ]);
1671
+ };
1672
+ this.searchLocalMessages = (data, operationID = v4()) => {
1673
+ return this._invoker('searchLocalMessages ', window.searchLocalMessages, [operationID, JSON.stringify(data)]);
1674
+ };
1675
+ this.addFriend = (data, operationID = v4()) => {
1676
+ return this._invoker('addFriend ', window.addFriend, [
1677
+ operationID,
1678
+ JSON.stringify(data),
1679
+ ]);
1680
+ };
1681
+ this.searchFriends = (data, operationID = v4()) => {
1682
+ return this._invoker('searchFriends ', window.searchFriends, [operationID, JSON.stringify(data)]);
1683
+ };
1684
+ this.getSpecifiedFriendsInfo = (data, operationID = v4()) => {
1685
+ return this._invoker('getSpecifiedFriendsInfo', window.getSpecifiedFriendsInfo, [operationID, JSON.stringify(data.friendUserIDList), data.filterBlack]);
1686
+ };
1687
+ this.getFriendApplicationListAsRecipient = (data = {
1688
+ handleResults: [],
1689
+ offset: 0,
1690
+ count: 0,
1691
+ }, operationID = v4()) => {
1692
+ return this._invoker('getFriendApplicationListAsRecipient ', window.getFriendApplicationListAsRecipient, [operationID, JSON.stringify(data)]);
1693
+ };
1694
+ this.getFriendApplicationListAsApplicant = (data = {
1695
+ offset: 0,
1696
+ count: 0,
1697
+ }, operationID = v4()) => {
1698
+ return this._invoker('getFriendApplicationListAsApplicant ', window.getFriendApplicationListAsApplicant, [operationID, JSON.stringify(data)]);
1699
+ };
1700
+ this.getFriendApplicationUnhandledCount = (data, operationID = v4()) => {
1701
+ return this._invoker('getFriendApplicationUnhandledCount ', window.getFriendApplicationUnhandledCount, [operationID, JSON.stringify(data)]);
1702
+ };
1703
+ this.getFriendList = (filterBlack = false, operationID = v4()) => {
1704
+ return this._invoker('getFriendList ', window.getFriendList, [operationID, filterBlack]);
1705
+ };
1706
+ this.getFriendListPage = (data, operationID = v4()) => {
1707
+ var _a;
1708
+ return this._invoker('getFriendListPage ', window.getFriendListPage, [operationID, data.offset, data.count, (_a = data.filterBlack) !== null && _a !== void 0 ? _a : false]);
1709
+ };
1710
+ this.updateFriends = (data, operationID = v4()) => {
1711
+ return this._invoker('updateFriends ', window.updateFriends, [
1712
+ operationID,
1713
+ JSON.stringify(data),
1714
+ ]);
1715
+ };
1716
+ /**
1717
+ * @deprecated Use updateFriends instead.
1718
+ */
1719
+ this.setFriendRemark = (data, operationID = v4()) => {
1720
+ return this._invoker('setFriendRemark ', window.updateFriends, [
1721
+ operationID,
1722
+ JSON.stringify({
1723
+ friendUserIDs: [data.toUserID],
1724
+ remark: data.remark,
1725
+ }),
1726
+ ]);
1727
+ };
1728
+ /**
1729
+ * @deprecated Use updateFriends instead.
1730
+ */
1731
+ this.pinFriends = (data, operationID = v4()) => {
1732
+ return this._invoker('pinFriends ', window.updateFriends, [
1733
+ operationID,
1734
+ JSON.stringify({
1735
+ friendUserIDs: data.toUserIDs,
1736
+ isPinned: data.isPinned,
1737
+ }),
1738
+ ]);
1739
+ };
1740
+ /**
1741
+ * @deprecated Use updateFriends instead.
1742
+ */
1743
+ this.setFriendsEx = (data, operationID = v4()) => {
1744
+ return this._invoker('setFriendsEx ', window.updateFriends, [
1745
+ operationID,
1746
+ JSON.stringify({
1747
+ friendUserIDs: data.toUserIDs,
1748
+ ex: data.ex,
1749
+ }),
1750
+ data.ex,
1751
+ ]);
1752
+ };
1753
+ this.checkFriend = (data, operationID = v4()) => {
1754
+ return this._invoker('checkFriend', window.checkFriend, [
1755
+ operationID,
1756
+ JSON.stringify(data),
1757
+ ]);
1758
+ };
1759
+ this.acceptFriendApplication = (data, operationID = v4()) => {
1760
+ return this._invoker('acceptFriendApplication', window.acceptFriendApplication, [operationID, JSON.stringify(data)]);
1761
+ };
1762
+ this.refuseFriendApplication = (data, operationID = v4()) => {
1763
+ return this._invoker('refuseFriendApplication ', window.refuseFriendApplication, [operationID, JSON.stringify(data)]);
1764
+ };
1765
+ this.deleteFriend = (data, operationID = v4()) => {
1766
+ return this._invoker('deleteFriend ', window.deleteFriend, [
1767
+ operationID,
1768
+ data,
1769
+ ]);
1770
+ };
1771
+ this.addBlack = (data, operationID = v4()) => {
1772
+ var _a;
1773
+ return this._invoker('addBlack ', window.addBlack, [
1774
+ operationID,
1775
+ data.toUserID,
1776
+ (_a = data.ex) !== null && _a !== void 0 ? _a : '',
1777
+ ]);
1778
+ };
1779
+ this.removeBlack = (data, operationID = v4()) => {
1780
+ return this._invoker('removeBlack ', window.removeBlack, [
1781
+ operationID,
1782
+ data,
1783
+ ]);
1784
+ };
1785
+ this.getBlackList = (operationID = v4()) => {
1786
+ return this._invoker('getBlackList ', window.getBlackList, [operationID]);
1787
+ };
1788
+ this.inviteUserToGroup = (data, operationID = v4()) => {
1789
+ return this._invoker('inviteUserToGroup ', window.inviteUserToGroup, [
1790
+ operationID,
1791
+ data.groupID,
1792
+ data.reason,
1793
+ JSON.stringify(data.userIDList),
1794
+ ]);
1795
+ };
1796
+ this.kickGroupMember = (data, operationID = v4()) => {
1797
+ return this._invoker('kickGroupMember ', window.kickGroupMember, [
1798
+ operationID,
1799
+ data.groupID,
1800
+ data.reason,
1801
+ JSON.stringify(data.userIDList),
1802
+ ]);
1803
+ };
1804
+ this.isJoinGroup = (data, operationID = v4()) => {
1805
+ return this._invoker('isJoinGroup ', window.isJoinGroup, [
1806
+ operationID,
1807
+ data,
1808
+ ]);
1809
+ };
1810
+ this.getSpecifiedGroupMembersInfo = (data, operationID = v4()) => {
1811
+ return this._invoker('getSpecifiedGroupMembersInfo ', window.getSpecifiedGroupMembersInfo, [operationID, data.groupID, JSON.stringify(data.userIDList)]);
1812
+ };
1813
+ this.getUsersInGroup = (data, operationID = v4()) => {
1814
+ return this._invoker('getUsersInGroup ', window.getUsersInGroup, [
1815
+ operationID,
1816
+ data.groupID,
1817
+ JSON.stringify(data.userIDList),
1818
+ ]);
1819
+ };
1820
+ this.getGroupMemberListByJoinTimeFilter = (data, operationID = v4()) => {
1821
+ return this._invoker('getGroupMemberListByJoinTimeFilter ', window.getGroupMemberListByJoinTimeFilter, [
1822
+ operationID,
1823
+ data.groupID,
1824
+ data.offset,
1825
+ data.count,
1826
+ data.joinTimeBegin,
1827
+ data.joinTimeEnd,
1828
+ JSON.stringify(data.filterUserIDList),
1829
+ ]);
1830
+ };
1831
+ this.searchGroupMembers = (data, operationID = v4()) => {
1832
+ return this._invoker('searchGroupMembers ', window.searchGroupMembers, [operationID, JSON.stringify(data)]);
1833
+ };
1834
+ /**
1835
+ * @deprecated Use setGroupInfo instead.
1836
+ */
1837
+ this.setGroupApplyMemberFriend = (data, operationID = v4()) => {
1838
+ return this._invoker('setGroupApplyMemberFriend ', window.setGroupInfo, [
1839
+ operationID,
1840
+ JSON.stringify({
1841
+ groupID: data.groupID,
1842
+ applyMemberFriend: data.rule,
1843
+ }),
1844
+ ]);
1845
+ };
1846
+ /**
1847
+ * @deprecated Use setGroupInfo instead.
1848
+ */
1849
+ this.setGroupLookMemberInfo = (data, operationID = v4()) => {
1850
+ return this._invoker('setGroupLookMemberInfo ', window.setGroupInfo, [
1851
+ operationID,
1852
+ JSON.stringify({
1853
+ groupID: data.groupID,
1854
+ lookMemberInfo: data.rule,
1855
+ }),
1856
+ ]);
1857
+ };
1858
+ this.getJoinedGroupList = (operationID = v4()) => {
1859
+ return this._invoker('getJoinedGroupList ', window.getJoinedGroupList, [operationID]);
1860
+ };
1861
+ this.getJoinedGroupListPage = (data, operationID = v4()) => {
1862
+ return this._invoker('getJoinedGroupListPage ', window.getJoinedGroupListPage, [operationID, data.offset, data.count]);
1863
+ };
1864
+ this.createGroup = (data, operationID = v4()) => {
1865
+ return this._invoker('createGroup ', window.createGroup, [
1866
+ operationID,
1867
+ JSON.stringify(data),
1868
+ ]);
1869
+ };
1870
+ this.setGroupInfo = (data, operationID = v4()) => {
1871
+ return this._invoker('setGroupInfo ', window.setGroupInfo, [
1872
+ operationID,
1873
+ JSON.stringify(data),
1874
+ ]);
1875
+ };
1876
+ /**
1877
+ * @deprecated Use setGroupMemberInfo instead.
1878
+ */
1879
+ this.setGroupMemberNickname = (data, operationID = v4()) => {
1880
+ return this._invoker('setGroupMemberNickname ', window.setGroupMemberInfo, [
1881
+ operationID,
1882
+ JSON.stringify({
1883
+ groupID: data.groupID,
1884
+ userID: data.userID,
1885
+ nickname: data.groupMemberNickname,
1886
+ }),
1887
+ ]);
1888
+ };
1889
+ this.setGroupMemberInfo = (data, operationID = v4()) => {
1890
+ return this._invoker('setGroupMemberInfo ', window.setGroupMemberInfo, [
1891
+ operationID,
1892
+ JSON.stringify(data),
1893
+ ]);
1894
+ };
1895
+ this.joinGroup = (data, operationID = v4()) => {
1896
+ var _a;
1897
+ return this._invoker('joinGroup ', window.joinGroup, [
1898
+ operationID,
1899
+ data.groupID,
1900
+ data.reqMsg,
1901
+ data.joinSource,
1902
+ (_a = data.ex) !== null && _a !== void 0 ? _a : '',
1903
+ ]);
1904
+ };
1905
+ this.searchGroups = (data, operationID = v4()) => {
1906
+ return this._invoker('searchGroups ', window.searchGroups, [
1907
+ operationID,
1908
+ JSON.stringify(data),
1909
+ ]);
1910
+ };
1911
+ this.quitGroup = (data, operationID = v4()) => {
1912
+ return this._invoker('quitGroup ', window.quitGroup, [
1913
+ operationID,
1914
+ data,
1915
+ ]);
1916
+ };
1917
+ this.dismissGroup = (data, operationID = v4()) => {
1918
+ return this._invoker('dismissGroup ', window.dismissGroup, [
1919
+ operationID,
1920
+ data,
1921
+ ]);
1922
+ };
1923
+ this.changeGroupMute = (data, operationID = v4()) => {
1924
+ return this._invoker('changeGroupMute ', window.changeGroupMute, [
1925
+ operationID,
1926
+ data.groupID,
1927
+ data.isMute,
1928
+ ]);
1929
+ };
1930
+ this.changeGroupMemberMute = (data, operationID = v4()) => {
1931
+ return this._invoker('changeGroupMemberMute ', window.changeGroupMemberMute, [operationID, data.groupID, data.userID, data.mutedSeconds]);
1932
+ };
1933
+ this.transferGroupOwner = (data, operationID = v4()) => {
1934
+ return this._invoker('transferGroupOwner ', window.transferGroupOwner, [
1935
+ operationID,
1936
+ data.groupID,
1937
+ data.newOwnerUserID,
1938
+ ]);
1939
+ };
1940
+ this.getGroupApplicationListAsApplicant = (data = {
1941
+ groupID: [],
1942
+ handleResults: [],
1943
+ offset: 0,
1944
+ count: 0,
1945
+ }, operationID = v4()) => {
1946
+ return this._invoker('getGroupApplicationListAsApplicant ', window.getGroupApplicationListAsApplicant, [operationID, JSON.stringify(data)]);
1947
+ };
1948
+ this.getGroupApplicationListAsRecipient = (data = {
1949
+ groupID: [],
1950
+ handleResults: [],
1951
+ offset: 0,
1952
+ count: 0,
1953
+ }, operationID = v4()) => {
1954
+ return this._invoker('getGroupApplicationListAsRecipient ', window.getGroupApplicationListAsRecipient, [operationID, JSON.stringify(data)]);
1955
+ };
1956
+ this.getGroupApplicationUnhandledCount = (data, operationID = v4()) => {
1957
+ return this._invoker('getGroupApplicationUnhandledCount ', window.getGroupApplicationUnhandledCount, [operationID, JSON.stringify(data)]);
1958
+ };
1959
+ this.acceptGroupApplication = (data, operationID = v4()) => {
1960
+ return this._invoker('acceptGroupApplication ', window.acceptGroupApplication, [operationID, data.groupID, data.fromUserID, data.handleMsg]);
1961
+ };
1962
+ this.refuseGroupApplication = (data, operationID = v4()) => {
1963
+ return this._invoker('refuseGroupApplication ', window.refuseGroupApplication, [operationID, data.groupID, data.fromUserID, data.handleMsg]);
1964
+ };
1965
+ /**
1966
+ * @deprecated Use setConversation instead.
1967
+ */
1968
+ this.resetConversationGroupAtType = (data, operationID = v4()) => {
1969
+ return this._invoker('resetConversationGroupAtType ', window.setConversation, [
1970
+ operationID,
1971
+ data,
1972
+ JSON.stringify({
1973
+ groupAtType: GroupAtType.AtNormal,
1974
+ }),
1975
+ ]);
1976
+ };
1977
+ /**
1978
+ * @deprecated Use setGroupMemberInfo instead.
1979
+ */
1980
+ this.setGroupMemberRoleLevel = (data, operationID = v4()) => {
1981
+ return this._invoker('setGroupMemberRoleLevel ', window.setGroupMemberInfo, [
1982
+ operationID,
1983
+ JSON.stringify({
1984
+ groupID: data.groupID,
1985
+ userID: data.userID,
1986
+ roleLevel: data.roleLevel,
1987
+ }),
1988
+ ]);
1989
+ };
1990
+ /**
1991
+ * @deprecated Use setGroupInfo instead.
1992
+ */
1993
+ this.setGroupVerification = (data, operationID = v4()) => {
1994
+ return this._invoker('setGroupVerification ', window.setGroupInfo, [
1995
+ operationID,
1996
+ JSON.stringify({
1997
+ groupID: data.groupID,
1998
+ needVerification: data.verification,
1999
+ }),
2000
+ ]);
2001
+ };
2002
+ this.getGroupMemberOwnerAndAdmin = (data, operationID = v4()) => {
2003
+ return this._invoker('getGroupMemberOwnerAndAdmin ', window.getGroupMemberOwnerAndAdmin, [operationID, data]);
2004
+ };
2005
+ /**
2006
+ * @deprecated Use setSelfInfo instead.
2007
+ */
2008
+ this.setGlobalRecvMessageOpt = (opt, operationID = v4()) => {
2009
+ return this._invoker('setGlobalRecvMessageOpt ', window.setSelfInfo, [
2010
+ operationID,
2011
+ JSON.stringify({ globalRecvMsgOpt: opt }),
2012
+ ]);
2013
+ };
2014
+ this.findMessageList = (data, operationID = v4()) => {
2015
+ return this._invoker('findMessageList ', window.findMessageList, [operationID, JSON.stringify(data)]);
2016
+ };
2017
+ this.uploadFile = (data, operationID = v4()) => {
2018
+ var _a;
2019
+ data.uuid = `${data.uuid}/${(_a = data.file) === null || _a === void 0 ? void 0 : _a.name}`;
2020
+ window.fileMapSet(data.uuid, data.file);
2021
+ return this._invoker('uploadFile ', window.uploadFile, [
2022
+ operationID,
2023
+ JSON.stringify({
2024
+ ...data,
2025
+ filepath: '',
2026
+ cause: '',
2027
+ }),
2028
+ ]);
2029
+ };
2030
+ this.subscribeUsersStatus = (data, operationID = v4()) => {
2031
+ return this._invoker('subscribeUsersStatus ', window.subscribeUsersStatus, [operationID, JSON.stringify(data)]);
2032
+ };
2033
+ this.unsubscribeUsersStatus = (data, operationID = v4()) => {
2034
+ return this._invoker('unsubscribeUsersStatus ', window.unsubscribeUsersStatus, [operationID, JSON.stringify(data)]);
2035
+ };
2036
+ this.getUserStatus = (operationID = v4()) => {
2037
+ return this._invoker('getUserStatus ', window.getUserStatus, [operationID]);
2038
+ };
2039
+ this.getSubscribeUsersStatus = (operationID = v4()) => {
2040
+ return this._invoker('getSubscribeUsersStatus ', window.getSubscribeUsersStatus, [operationID]);
2041
+ };
2042
+ this.signalingInvite = (data, operationID = v4()) => {
2043
+ return this._invoker('signalingInvite ', window.signalingInvite, [operationID, JSON.stringify(data)]);
2044
+ };
2045
+ this.signalingInviteInGroup = (data, operationID = v4()) => {
2046
+ return this._invoker('signalingInviteInGroup ', window.signalingInviteInGroup, [operationID, JSON.stringify(data)]);
2047
+ };
2048
+ this.signalingAccept = (data, operationID = v4()) => {
2049
+ return this._invoker('signalingAccept ', window.signalingAccept, [operationID, JSON.stringify(data)]);
2050
+ };
2051
+ this.signalingReject = (data, operationID = v4()) => {
2052
+ return this._invoker('signalingReject ', window.signalingReject, [
2053
+ operationID,
2054
+ JSON.stringify(data),
2055
+ ]);
2056
+ };
2057
+ this.signalingCancel = (data, operationID = v4()) => {
2058
+ return this._invoker('signalingCancel ', window.signalingCancel, [
2059
+ operationID,
2060
+ JSON.stringify(data),
2061
+ ]);
2062
+ };
2063
+ this.signalingHungUp = (data, operationID = v4()) => {
2064
+ return this._invoker('signalingHungUp ', window.signalingHungUp, [
2065
+ operationID,
2066
+ JSON.stringify(data),
2067
+ ]);
2068
+ };
2069
+ this.signalingGetRoomByGroupID = (groupID, operationID = v4()) => {
2070
+ return this._invoker('signalingGetRoomByGroupID ', window.signalingGetRoomByGroupID, [operationID, groupID]);
2071
+ };
2072
+ this.signalingGetTokenByRoomID = (roomID, operationID = v4()) => {
2073
+ return this._invoker('signalingGetTokenByRoomID ', window.signalingGetTokenByRoomID, [operationID, roomID]);
2074
+ };
2075
+ this.getSignalingInvitationInfoStartApp = (operationID = v4()) => {
2076
+ return this._invoker('getSignalingInvitationInfoStartApp ', window.getSignalingInvitationInfoStartApp, [operationID]);
2077
+ };
2078
+ this.signalingSendCustomSignal = (data, operationID = v4()) => {
2079
+ return this._invoker('signalingSendCustomSignal ', window.signalingSendCustomSignal, [operationID, data.customInfo, data.roomID]);
2080
+ };
2081
+ this.setConversationIsMsgDestruct = (data, operationID = v4()) => {
2082
+ return this._invoker('setConversationIsMsgDestruct ', window.setConversation, [
2083
+ operationID,
2084
+ data.conversationID,
2085
+ JSON.stringify({ isMsgDestruct: data.isMsgDestruct }),
2086
+ ]);
2087
+ };
2088
+ this.setConversationMsgDestructTime = (data, operationID = v4()) => {
2089
+ return this._invoker('setConversationMsgDestructTime ', window.setConversation, [
2090
+ operationID,
2091
+ data.conversationID,
2092
+ JSON.stringify({
2093
+ msgDestructTime: data.msgDestructTime,
2094
+ }),
2095
+ ]);
2096
+ };
2097
+ this.fileMapSet = (uuid, file) => window.fileMapSet(uuid, file);
2098
+ initDatabaseAPI(debug);
2099
+ this.isLogStandardOutput = debug;
2100
+ this.wasmInitializedPromise = initializeWasm(url);
2101
+ this.goExitPromise = getGoExitPromise();
2102
+ if (this.goExitPromise) {
2103
+ this.goExitPromise
2104
+ .then(() => {
2105
+ this._logWrap('SDK => wasm exist');
2106
+ })
2107
+ .catch(err => {
2108
+ this._logWrap('SDK => wasm with error ', err);
2109
+ })
2110
+ .finally(() => {
2111
+ this.goExisted = true;
2112
+ });
2113
+ }
2114
+ }
2115
+ _logWrap(...args) {
2116
+ if (this.isLogStandardOutput) {
2117
+ console.info(...args);
2118
+ }
2119
+ }
2120
+ _invoker(functionName, func, args, processor) {
2121
+ return new Promise(async (resolve, reject) => {
2122
+ this._logWrap(`%cSDK =>%c [OperationID:${args[0]}] (invoked by js) run ${functionName} with args ${JSON.stringify(args)}`, 'font-size:14px; background:#7CAEFF; border-radius:4px; padding-inline:4px;', '');
2123
+ let response = {
2124
+ operationID: args[0],
2125
+ event: (functionName.slice(0, 1).toUpperCase() +
2126
+ functionName.slice(1).toLowerCase()),
2127
+ };
2128
+ try {
2129
+ if (!getGO() || getGO().exited || this.goExisted) {
2130
+ throw 'wasm exist already, fail to run';
2131
+ }
2132
+ let data = await func(...args);
2133
+ if (processor) {
2134
+ this._logWrap(`%cSDK =>%c [OperationID:${args[0]}] (invoked by js) run ${functionName} with response before processor ${JSON.stringify(data)}`, logBoxStyleValue('#FFDC19'), '');
2135
+ data = processor(data);
2136
+ }
2137
+ if (this.tryParse) {
2138
+ try {
2139
+ data = JSON.parse(data);
2140
+ }
2141
+ catch (error) {
2142
+ // parse error
2143
+ }
2144
+ }
2145
+ response.data = data;
2146
+ resolve(response);
2147
+ }
2148
+ catch (error) {
2149
+ this._logWrap(`%cSDK =>%c [OperationID:${args[0]}] (invoked by js) run ${functionName} with error ${JSON.stringify(error)}`, logBoxStyleValue('#EE4245'), '');
2150
+ response = {
2151
+ ...response,
2152
+ ...error,
2153
+ };
2154
+ reject(response);
2155
+ }
2156
+ });
2157
+ }
2158
+ exportDB(operationID = v4()) {
2159
+ return this._invoker('exportDB', window.exportDB, [operationID]);
2160
+ }
2161
+ }
2162
+ let instance;
2163
+ function getSDK(config) {
2164
+ const { sqlWasmPath, coreWasmPath = '/openIM.wasm', debug = true, } = config || {};
2165
+ if (typeof window === 'undefined') {
2166
+ return {};
2167
+ }
2168
+ if (instance) {
2169
+ return instance;
2170
+ }
2171
+ instance = new SDK(coreWasmPath, debug);
2172
+ if (sqlWasmPath) {
2173
+ window.setSqlWasmPath(sqlWasmPath);
2174
+ }
2175
+ return instance;
2176
+ }
2177
+
2178
+ function decodeBase64(base64, enableUnicode) {
2179
+ var binaryString = atob(base64);
2180
+ if (enableUnicode) {
2181
+ var binaryView = new Uint8Array(binaryString.length);
2182
+ for (var i = 0, n = binaryString.length; i < n; ++i) {
2183
+ binaryView[i] = binaryString.charCodeAt(i);
2184
+ }
2185
+ return String.fromCharCode.apply(null, new Uint16Array(binaryView.buffer));
2186
+ }
2187
+ return binaryString;
2188
+ }
2189
+
2190
+ function createURL(base64, sourcemapArg, enableUnicodeArg) {
2191
+ var sourcemap = sourcemapArg === undefined ? null : sourcemapArg;
2192
+ var enableUnicode = enableUnicodeArg === undefined ? false : enableUnicodeArg;
2193
+ var source = decodeBase64(base64, enableUnicode);
2194
+ var start = source.indexOf('\n', 10) + 1;
2195
+ var body = source.substring(start) + (sourcemap ? '\/\/# sourceMappingURL=' + sourcemap : '');
2196
+ var blob = new Blob([body], { type: 'application/javascript' });
2197
+ return URL.createObjectURL(blob);
2198
+ }
2199
+
2200
+ function createBase64WorkerFactory(base64, sourcemapArg, enableUnicodeArg) {
2201
+ var url;
2202
+ return function WorkerFactory(options) {
2203
+ url = url || createURL(base64, sourcemapArg, enableUnicodeArg);
2204
+ return new Worker(url, options);
2205
+ };
2206
+ }
2207
+
2208
+ var WorkerFactory = createBase64WorkerFactory('Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwohZnVuY3Rpb24oKXsidXNlIHN0cmljdCI7bGV0IHQ9MzczNTkyODU1OTtjbGFzcyBle2NvbnN0cnVjdG9yKHQse2luaXRpYWxPZmZzZXQ6ZT00LHVzZUF0b21pY3M6aT0hMCxzdHJlYW06cz0hMCxkZWJ1ZzpyLG5hbWU6bn09e30pe3RoaXMuYnVmZmVyPXQsdGhpcy5hdG9taWNWaWV3PW5ldyBJbnQzMkFycmF5KHQpLHRoaXMub2Zmc2V0PWUsdGhpcy51c2VBdG9taWNzPWksdGhpcy5zdHJlYW09cyx0aGlzLmRlYnVnPXIsdGhpcy5uYW1lPW59bG9nKC4uLnQpe3RoaXMuZGVidWcmJmNvbnNvbGUubG9nKGBbcmVhZGVyOiAke3RoaXMubmFt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aG9kOiAiK2kpfX1zZWxmLm9ubWVzc2FnZT10PT57c3dpdGNoKHQuZGF0YS50eXBlKXtjYXNlImluaXQiOntsZXRbcyxyXT10LmRhdGEuYnVmZmVycztnKG5ldyBlKHMse25hbWU6ImFyZ3MiLGRlYnVnOiExfSksbmV3IGkocix7bmFtZToicmVzdWx0cyIsZGVidWc6ITF9KSk7YnJlYWt9fX19KCk7Cgo=', null, false);
2209
+
2210
+ var indexeddbMainThreadWorkerB24e7a21 = /*#__PURE__*/Object.freeze({
2211
+ __proto__: null,
2212
+ 'default': WorkerFactory
2213
+ });
2214
+
2215
+ export { AddFriendPermission, AllowType, ApplicationHandleResult, CbEvents, GroupAtType, GroupJoinSource, GroupMemberFilter, GroupMemberRole, GroupMessageReaderFilter, GroupStatus, GroupType, GroupVerificationType, LogLevel, LoginStatus, MessageReceiveOptType, MessageStatus, MessageType, OnlineState, Platform, Relationship, SessionType, ViewType, getSDK };