@imam-inter/openim-sdk-js-wasm 3.8.2-1

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 (75) hide show
  1. package/LICENSE +661 -0
  2. package/README.md +166 -0
  3. package/assets/openIM.wasm +0 -0
  4. package/assets/sql-wasm.wasm +0 -0
  5. package/assets/wasm_exec.js +561 -0
  6. package/lib/api/database/alter.d.ts +2 -0
  7. package/lib/api/database/black.d.ts +7 -0
  8. package/lib/api/database/conversation.d.ts +31 -0
  9. package/lib/api/database/friend.d.ts +12 -0
  10. package/lib/api/database/friendRequest.d.ts +7 -0
  11. package/lib/api/database/groupMember.d.ts +22 -0
  12. package/lib/api/database/groupRequest.d.ts +8 -0
  13. package/lib/api/database/groups.d.ts +14 -0
  14. package/lib/api/database/index.d.ts +20 -0
  15. package/lib/api/database/init.d.ts +3 -0
  16. package/lib/api/database/instance.d.ts +3 -0
  17. package/lib/api/database/localAppSdkVersion.d.ts +2 -0
  18. package/lib/api/database/message.d.ts +31 -0
  19. package/lib/api/database/notification.d.ts +3 -0
  20. package/lib/api/database/sendingMessages.d.ts +3 -0
  21. package/lib/api/database/stranger.d.ts +4 -0
  22. package/lib/api/database/superGroup.d.ts +6 -0
  23. package/lib/api/database/tableMaster.d.ts +1 -0
  24. package/lib/api/database/tempCacheChatLogs.d.ts +2 -0
  25. package/lib/api/database/unreadMessage.d.ts +2 -0
  26. package/lib/api/database/upload.d.ts +4 -0
  27. package/lib/api/database/users.d.ts +3 -0
  28. package/lib/api/database/versionSync.d.ts +3 -0
  29. package/lib/api/index.d.ts +2 -0
  30. package/lib/api/upload.d.ts +5 -0
  31. package/lib/api/worker.d.ts +1 -0
  32. package/lib/constant/index.d.ts +71 -0
  33. package/lib/index.d.ts +6 -0
  34. package/lib/index.es.js +2121 -0
  35. package/lib/index.js +2125 -0
  36. package/lib/index.umd.js +2131 -0
  37. package/lib/sdk/index.d.ts +173 -0
  38. package/lib/sdk/initialize.d.ts +5 -0
  39. package/lib/sqls/index.d.ts +20 -0
  40. package/lib/sqls/localAdminGroupRequests.d.ts +9 -0
  41. package/lib/sqls/localAppSdkVersion.d.ts +8 -0
  42. package/lib/sqls/localBlack.d.ts +12 -0
  43. package/lib/sqls/localChatLogsConversationID.d.ts +36 -0
  44. package/lib/sqls/localConversationUnreadMessages.d.ts +7 -0
  45. package/lib/sqls/localConversations.d.ts +34 -0
  46. package/lib/sqls/localFriend.d.ts +16 -0
  47. package/lib/sqls/localFriendRequest.d.ts +12 -0
  48. package/lib/sqls/localGroupMembers.d.ts +27 -0
  49. package/lib/sqls/localGroupRequests.d.ts +9 -0
  50. package/lib/sqls/localGroups.d.ts +16 -0
  51. package/lib/sqls/localNotification.d.ts +8 -0
  52. package/lib/sqls/localSendingMessages.d.ts +8 -0
  53. package/lib/sqls/localStranger.d.ts +8 -0
  54. package/lib/sqls/localSuperGroups.d.ts +10 -0
  55. package/lib/sqls/localTableMaster.d.ts +5 -0
  56. package/lib/sqls/localUpload.d.ts +10 -0
  57. package/lib/sqls/localUsers.d.ts +8 -0
  58. package/lib/sqls/localVersionSync.d.ts +9 -0
  59. package/lib/sqls/tempCacheLocalChatLogs.d.ts +6 -0
  60. package/lib/types/entity.d.ts +452 -0
  61. package/lib/types/enum.d.ts +134 -0
  62. package/lib/types/eventData.d.ts +51 -0
  63. package/lib/types/params.d.ts +390 -0
  64. package/lib/utils/emitter.d.ts +12 -0
  65. package/lib/utils/escape.d.ts +23 -0
  66. package/lib/utils/index.d.ts +7 -0
  67. package/lib/utils/is.d.ts +6 -0
  68. package/lib/utils/key.d.ts +3 -0
  69. package/lib/utils/logFormat.d.ts +1 -0
  70. package/lib/utils/response.d.ts +1 -0
  71. package/lib/utils/timer.d.ts +1 -0
  72. package/lib/utils/value.d.ts +6 -0
  73. package/lib/worker-legacy.js +1 -0
  74. package/lib/worker.js +1 -0
  75. package/package.json +94 -0
@@ -0,0 +1,2121 @@
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 isSupportModuleWorker = supportsModuleWorkers();
488
+ let workerUrl = isSupportModuleWorker
489
+ ? new URL('worker.js', import.meta.url)
490
+ : new URL('worker-legacy.js', import.meta.url);
491
+ if (isViteEnvironment) {
492
+ workerUrl = workerUrl.href.replace('.vite/deps', '@openim/wasm-client-sdk/lib');
493
+ }
494
+ if (isNuxtEnvironment) {
495
+ workerUrl = workerUrl.href.replace('.cache/vite/client/deps', '@openim/wasm-client-sdk/lib');
496
+ }
497
+ worker = new Worker(workerUrl, {
498
+ type: isSupportModuleWorker ? 'module' : 'classic',
499
+ });
500
+ // This is only required because Safari doesn't support nested
501
+ // workers. This installs a handler that will proxy creating web
502
+ // workers through the main thread
503
+ initBackend(worker);
504
+ rpc = new RPC({
505
+ event: new RPCMessageEvent({
506
+ currentEndpoint: worker,
507
+ targetEndpoint: worker,
508
+ }),
509
+ });
510
+ }
511
+ function resetWorker() {
512
+ if (rpc) {
513
+ rpc.destroy();
514
+ rpc = undefined;
515
+ }
516
+ if (worker) {
517
+ worker.terminate();
518
+ worker = undefined;
519
+ }
520
+ }
521
+ initWorker();
522
+ function catchErrorHandle(error) {
523
+ // defined in rpc-shooter
524
+ if (error.code === -32300) {
525
+ resetWorker();
526
+ return JSON.stringify({
527
+ data: '',
528
+ errCode: DatabaseErrorCode.ErrorDBTimeout,
529
+ errMsg: 'database maybe damaged',
530
+ });
531
+ }
532
+ throw error;
533
+ }
534
+ function _logWrap(...args) {
535
+ if (debug) {
536
+ console.info(...args);
537
+ }
538
+ }
539
+ function registeMethodOnWindow(name, realName, needStringify = true) {
540
+ _logWrap(`=> (database api) registe ${realName !== null && realName !== void 0 ? realName : name}`);
541
+ return async (...args) => {
542
+ if (!rpc || !worker) {
543
+ initWorker();
544
+ }
545
+ if (!rpc) {
546
+ return;
547
+ }
548
+ try {
549
+ _logWrap(`=> (invoked by go wasm) run ${realName !== null && realName !== void 0 ? realName : name} method with args ${JSON.stringify(args)}`);
550
+ const response = await rpc.invoke(name, ...args, { timeout: 5000000 });
551
+ _logWrap(`=> (invoked by go wasm) run ${realName !== null && realName !== void 0 ? realName : name} method with response `, JSON.stringify(response));
552
+ if (!needStringify) {
553
+ return response;
554
+ }
555
+ return JSON.stringify(response);
556
+ }
557
+ catch (error) {
558
+ // defined in rpc-shooter
559
+ catchErrorHandle(error);
560
+ }
561
+ };
562
+ }
563
+ // register method on window for go wasm invoke
564
+ function initDatabaseAPI(isLogStandardOutput = true) {
565
+ if (!rpc) {
566
+ return;
567
+ }
568
+ debug = isLogStandardOutput;
569
+ // upload
570
+ window.wasmOpen = registeMethodOnWindow('wasmOpen');
571
+ window.wasmClose = registeMethodOnWindow('wasmClose');
572
+ window.wasmRead = registeMethodOnWindow('wasmRead', 'wasmRead', false);
573
+ window.getUpload = registeMethodOnWindow('getUpload');
574
+ window.insertUpload = registeMethodOnWindow('insertUpload');
575
+ window.updateUpload = registeMethodOnWindow('updateUpload');
576
+ window.deleteUpload = registeMethodOnWindow('deleteUpload');
577
+ window.fileMapSet = registeMethodOnWindow('fileMapSet');
578
+ window.fileMapClear = registeMethodOnWindow('fileMapClear');
579
+ window.setSqlWasmPath = registeMethodOnWindow('setSqlWasmPath');
580
+ window.initDB = registeMethodOnWindow('initDB');
581
+ window.close = registeMethodOnWindow('close');
582
+ // message
583
+ window.getMessage = registeMethodOnWindow('getMessage');
584
+ window.getMultipleMessage = registeMethodOnWindow('getMultipleMessage');
585
+ window.getSendingMessageList = registeMethodOnWindow('getSendingMessageList');
586
+ window.getNormalMsgSeq = registeMethodOnWindow('getNormalMsgSeq');
587
+ window.updateMessageTimeAndStatus = registeMethodOnWindow('updateMessageTimeAndStatus');
588
+ window.updateMessage = registeMethodOnWindow('updateMessage');
589
+ window.updateMessageBySeq = registeMethodOnWindow('updateMessageBySeq');
590
+ window.updateColumnsMessage = registeMethodOnWindow('updateColumnsMessage');
591
+ window.insertMessage = registeMethodOnWindow('insertMessage');
592
+ window.batchInsertMessageList = registeMethodOnWindow('batchInsertMessageList');
593
+ window.getMessageList = registeMethodOnWindow('getMessageList');
594
+ window.getMessageListNoTime = registeMethodOnWindow('getMessageListNoTime');
595
+ window.messageIfExists = registeMethodOnWindow('messageIfExists');
596
+ window.messageIfExistsBySeq = registeMethodOnWindow('messageIfExistsBySeq');
597
+ window.getAbnormalMsgSeq = registeMethodOnWindow('getAbnormalMsgSeq');
598
+ window.getAbnormalMsgSeqList = registeMethodOnWindow('getAbnormalMsgSeqList');
599
+ window.batchInsertExceptionMsg = registeMethodOnWindow('batchInsertExceptionMsg');
600
+ window.searchMessageByKeyword = registeMethodOnWindow('searchMessageByKeyword');
601
+ window.searchMessageByContentType = registeMethodOnWindow('searchMessageByContentType');
602
+ window.searchMessageByContentTypeAndKeyword = registeMethodOnWindow('searchMessageByContentTypeAndKeyword');
603
+ window.updateMsgSenderNickname = registeMethodOnWindow('updateMsgSenderNickname');
604
+ window.updateMsgSenderFaceURL = registeMethodOnWindow('updateMsgSenderFaceURL');
605
+ window.updateMsgSenderFaceURLAndSenderNickname = registeMethodOnWindow('updateMsgSenderFaceURLAndSenderNickname');
606
+ window.getMsgSeqByClientMsgID = registeMethodOnWindow('getMsgSeqByClientMsgID');
607
+ window.getMsgSeqListByGroupID = registeMethodOnWindow('getMsgSeqListByGroupID');
608
+ window.getMsgSeqListByPeerUserID = registeMethodOnWindow('getMsgSeqListByPeerUserID');
609
+ window.getMsgSeqListBySelfUserID = registeMethodOnWindow('getMsgSeqListBySelfUserID');
610
+ window.deleteAllMessage = registeMethodOnWindow('deleteAllMessage');
611
+ window.getAllUnDeleteMessageSeqList = registeMethodOnWindow('getAllUnDeleteMessageSeqList');
612
+ window.updateSingleMessageHasRead = registeMethodOnWindow('updateSingleMessageHasRead');
613
+ window.updateGroupMessageHasRead = registeMethodOnWindow('updateGroupMessageHasRead');
614
+ window.updateMessageStatusBySourceID = registeMethodOnWindow('updateMessageStatusBySourceID');
615
+ window.getAlreadyExistSeqList = registeMethodOnWindow('getAlreadyExistSeqList');
616
+ window.getMessageBySeq = registeMethodOnWindow('getMessageBySeq');
617
+ window.getMessagesByClientMsgIDs = registeMethodOnWindow('getMessagesByClientMsgIDs');
618
+ window.getMessagesBySeqs = registeMethodOnWindow('getMessagesBySeqs');
619
+ window.getConversationNormalMsgSeq = registeMethodOnWindow('getConversationNormalMsgSeq');
620
+ window.checkConversationNormalMsgSeq = registeMethodOnWindow('getConversationNormalMsgSeq');
621
+ window.getConversationPeerNormalMsgSeq = registeMethodOnWindow('getConversationPeerNormalMsgSeq');
622
+ window.deleteConversationAllMessages = registeMethodOnWindow('deleteConversationAllMessages');
623
+ window.markDeleteConversationAllMessages = registeMethodOnWindow('markDeleteConversationAllMessages');
624
+ window.getUnreadMessage = registeMethodOnWindow('getUnreadMessage');
625
+ window.markConversationMessageAsReadBySeqs = registeMethodOnWindow('markConversationMessageAsReadBySeqs');
626
+ window.markConversationMessageAsReadDB = registeMethodOnWindow('markConversationMessageAsRead');
627
+ window.deleteConversationMsgs = registeMethodOnWindow('deleteConversationMsgs');
628
+ window.markConversationAllMessageAsRead = registeMethodOnWindow('markConversationAllMessageAsRead');
629
+ window.searchAllMessageByContentType = registeMethodOnWindow('searchAllMessageByContentType');
630
+ window.insertSendingMessage = registeMethodOnWindow('insertSendingMessage');
631
+ window.deleteSendingMessage = registeMethodOnWindow('deleteSendingMessage');
632
+ window.getAllSendingMessages = registeMethodOnWindow('getAllSendingMessages');
633
+ // conversation
634
+ window.getAllConversationListDB = registeMethodOnWindow('getAllConversationList');
635
+ window.getAllConversationListToSync = registeMethodOnWindow('getAllConversationListToSync');
636
+ window.getHiddenConversationList = registeMethodOnWindow('getHiddenConversationList');
637
+ window.getConversation = registeMethodOnWindow('getConversation');
638
+ window.getMultipleConversationDB = registeMethodOnWindow('getMultipleConversation');
639
+ window.updateColumnsConversation = registeMethodOnWindow('updateColumnsConversation');
640
+ window.updateConversation = registeMethodOnWindow('updateColumnsConversation', 'updateConversation');
641
+ window.updateConversationForSync = registeMethodOnWindow('updateColumnsConversation', 'updateConversationForSync');
642
+ window.decrConversationUnreadCount = registeMethodOnWindow('decrConversationUnreadCount');
643
+ window.batchInsertConversationList = registeMethodOnWindow('batchInsertConversationList');
644
+ window.insertConversation = registeMethodOnWindow('insertConversation');
645
+ window.getTotalUnreadMsgCountDB = registeMethodOnWindow('getTotalUnreadMsgCount');
646
+ window.getConversationByUserID = registeMethodOnWindow('getConversationByUserID');
647
+ window.getConversationListSplitDB = registeMethodOnWindow('getConversationListSplit');
648
+ window.deleteConversation = registeMethodOnWindow('deleteConversation');
649
+ window.deleteAllConversation = registeMethodOnWindow('deleteAllConversation');
650
+ window.batchUpdateConversationList = registeMethodOnWindow('batchUpdateConversationList');
651
+ window.conversationIfExists = registeMethodOnWindow('conversationIfExists');
652
+ window.resetConversation = registeMethodOnWindow('resetConversation');
653
+ window.resetAllConversation = registeMethodOnWindow('resetAllConversation');
654
+ window.clearConversation = registeMethodOnWindow('clearConversation');
655
+ window.clearAllConversation = registeMethodOnWindow('clearAllConversation');
656
+ window.setConversationDraftDB = registeMethodOnWindow('setConversationDraft');
657
+ window.removeConversationDraft = registeMethodOnWindow('removeConversationDraft');
658
+ window.unPinConversation = registeMethodOnWindow('unPinConversation');
659
+ // window.updateAllConversation = registeMethodOnWindow('updateAllConversation');
660
+ window.incrConversationUnreadCount = registeMethodOnWindow('incrConversationUnreadCount');
661
+ window.setMultipleConversationRecvMsgOpt = registeMethodOnWindow('setMultipleConversationRecvMsgOpt');
662
+ window.getAllSingleConversationIDList = registeMethodOnWindow('getAllSingleConversationIDList');
663
+ window.getAllConversationIDList = registeMethodOnWindow('getAllConversationIDList');
664
+ window.getAllConversations = registeMethodOnWindow('getAllConversations');
665
+ window.searchConversations = registeMethodOnWindow('searchConversations');
666
+ window.getLatestActiveMessage = registeMethodOnWindow('getLatestActiveMessage');
667
+ // users
668
+ window.getLoginUser = registeMethodOnWindow('getLoginUser');
669
+ window.insertLoginUser = registeMethodOnWindow('insertLoginUser');
670
+ window.updateLoginUser = registeMethodOnWindow('updateLoginUser');
671
+ window.getStrangerInfo = registeMethodOnWindow('getStrangerInfo');
672
+ window.setStrangerInfo = registeMethodOnWindow('setStrangerInfo');
673
+ // app sdk versions
674
+ window.getAppSDKVersion = registeMethodOnWindow('getAppSDKVersion');
675
+ window.setAppSDKVersion = registeMethodOnWindow('setAppSDKVersion');
676
+ // versions sync
677
+ window.getVersionSync = registeMethodOnWindow('getVersionSync');
678
+ window.setVersionSync = registeMethodOnWindow('setVersionSync');
679
+ window.deleteVersionSync = registeMethodOnWindow('deleteVersionSync');
680
+ // super groups
681
+ window.getJoinedSuperGroupList = registeMethodOnWindow('getJoinedSuperGroupList');
682
+ window.getJoinedSuperGroupIDList = registeMethodOnWindow('getJoinedSuperGroupIDList');
683
+ window.getSuperGroupInfoByGroupID = registeMethodOnWindow('getSuperGroupInfoByGroupID');
684
+ window.deleteSuperGroup = registeMethodOnWindow('deleteSuperGroup');
685
+ window.insertSuperGroup = registeMethodOnWindow('insertSuperGroup');
686
+ window.updateSuperGroup = registeMethodOnWindow('updateSuperGroup');
687
+ // unread messages
688
+ window.deleteConversationUnreadMessageList = registeMethodOnWindow('deleteConversationUnreadMessageList');
689
+ window.batchInsertConversationUnreadMessageList = registeMethodOnWindow('batchInsertConversationUnreadMessageList');
690
+ // super group messages
691
+ window.superGroupGetMessage = registeMethodOnWindow('superGroupGetMessage');
692
+ window.superGroupGetMultipleMessage = registeMethodOnWindow('superGroupGetMultipleMessage');
693
+ window.superGroupGetNormalMinSeq = registeMethodOnWindow('superGroupGetNormalMinSeq');
694
+ window.getSuperGroupNormalMsgSeq = registeMethodOnWindow('getSuperGroupNormalMsgSeq');
695
+ window.superGroupUpdateMessageTimeAndStatus = registeMethodOnWindow('superGroupUpdateMessageTimeAndStatus');
696
+ window.superGroupUpdateMessage = registeMethodOnWindow('superGroupUpdateMessage');
697
+ window.superGroupInsertMessage = registeMethodOnWindow('superGroupInsertMessage');
698
+ window.superGroupBatchInsertMessageList = registeMethodOnWindow('superGroupBatchInsertMessageList');
699
+ window.superGroupGetMessageListNoTime = registeMethodOnWindow('superGroupGetMessageListNoTime');
700
+ window.superGroupGetMessageList = registeMethodOnWindow('superGroupGetMessageList');
701
+ window.superGroupUpdateColumnsMessage = registeMethodOnWindow('superGroupUpdateColumnsMessage');
702
+ window.superGroupDeleteAllMessage = registeMethodOnWindow('superGroupDeleteAllMessage');
703
+ window.superGroupSearchMessageByKeyword = registeMethodOnWindow('superGroupSearchMessageByKeyword');
704
+ window.superGroupSearchMessageByContentType = registeMethodOnWindow('superGroupSearchMessageByContentType');
705
+ window.superGroupSearchMessageByContentTypeAndKeyword = registeMethodOnWindow('superGroupSearchMessageByContentTypeAndKeyword');
706
+ window.superGroupUpdateMessageStatusBySourceID = registeMethodOnWindow('superGroupUpdateMessageStatusBySourceID');
707
+ window.superGroupGetSendingMessageList = registeMethodOnWindow('superGroupGetSendingMessageList');
708
+ window.superGroupUpdateGroupMessageHasRead = registeMethodOnWindow('superGroupUpdateGroupMessageHasRead');
709
+ window.superGroupGetMsgSeqByClientMsgID = registeMethodOnWindow('superGroupGetMsgSeqByClientMsgID');
710
+ window.superGroupUpdateMsgSenderFaceURLAndSenderNickname =
711
+ registeMethodOnWindow('superGroupUpdateMsgSenderFaceURLAndSenderNickname');
712
+ window.superGroupSearchAllMessageByContentType = registeMethodOnWindow('superGroupSearchAllMessageByContentType');
713
+ // debug
714
+ window.exec = registeMethodOnWindow('exec');
715
+ window.getRowsModified = registeMethodOnWindow('getRowsModified');
716
+ window.exportDB = async () => {
717
+ if (!rpc || !worker) {
718
+ initWorker();
719
+ }
720
+ if (!rpc) {
721
+ return;
722
+ }
723
+ try {
724
+ _logWrap('=> (invoked by go wasm) run exportDB method ');
725
+ const result = await rpc.invoke('exportDB', undefined, { timeout: 5000 });
726
+ _logWrap('=> (invoked by go wasm) run exportDB method with response ', JSON.stringify(result));
727
+ return result;
728
+ }
729
+ catch (error) {
730
+ catchErrorHandle(error);
731
+ }
732
+ };
733
+ // black
734
+ window.getBlackListDB = registeMethodOnWindow('getBlackList');
735
+ window.getBlackListUserID = registeMethodOnWindow('getBlackListUserID');
736
+ window.getBlackInfoByBlockUserID = registeMethodOnWindow('getBlackInfoByBlockUserID');
737
+ window.getBlackInfoList = registeMethodOnWindow('getBlackInfoList');
738
+ window.insertBlack = registeMethodOnWindow('insertBlack');
739
+ window.deleteBlack = registeMethodOnWindow('deleteBlack');
740
+ window.updateBlack = registeMethodOnWindow('updateBlack');
741
+ // friendRequest
742
+ window.insertFriendRequest = registeMethodOnWindow('insertFriendRequest');
743
+ window.deleteFriendRequestBothUserID = registeMethodOnWindow('deleteFriendRequestBothUserID');
744
+ window.updateFriendRequest = registeMethodOnWindow('updateFriendRequest');
745
+ window.getRecvFriendApplication = registeMethodOnWindow('getRecvFriendApplication');
746
+ window.getSendFriendApplication = registeMethodOnWindow('getSendFriendApplication');
747
+ window.getFriendApplicationByBothID = registeMethodOnWindow('getFriendApplicationByBothID');
748
+ window.getBothFriendReq = registeMethodOnWindow('getBothFriendReq');
749
+ // friend
750
+ window.insertFriend = registeMethodOnWindow('insertFriend');
751
+ window.deleteFriendDB = registeMethodOnWindow('deleteFriend');
752
+ window.updateFriend = registeMethodOnWindow('updateFriend');
753
+ window.getAllFriendList = registeMethodOnWindow('getAllFriendList');
754
+ window.searchFriendList = registeMethodOnWindow('searchFriendList');
755
+ window.getFriendInfoByFriendUserID = registeMethodOnWindow('getFriendInfoByFriendUserID');
756
+ window.getFriendInfoList = registeMethodOnWindow('getFriendInfoList');
757
+ window.getPageFriendList = registeMethodOnWindow('getPageFriendList');
758
+ window.updateColumnsFriend = registeMethodOnWindow('updateColumnsFriend');
759
+ window.getFriendListCount = registeMethodOnWindow('getFriendListCount');
760
+ window.batchInsertFriend = registeMethodOnWindow('batchInsertFriend');
761
+ window.deleteAllFriend = registeMethodOnWindow('deleteAllFriend');
762
+ // groups
763
+ window.insertGroup = registeMethodOnWindow('insertGroup');
764
+ window.deleteGroup = registeMethodOnWindow('deleteGroup');
765
+ window.updateGroup = registeMethodOnWindow('updateGroup');
766
+ window.getJoinedGroupListDB = registeMethodOnWindow('getJoinedGroupList');
767
+ window.getGroupInfoByGroupID = registeMethodOnWindow('getGroupInfoByGroupID');
768
+ window.getAllGroupInfoByGroupIDOrGroupName = registeMethodOnWindow('getAllGroupInfoByGroupIDOrGroupName');
769
+ window.subtractMemberCount = registeMethodOnWindow('subtractMemberCount');
770
+ window.addMemberCount = registeMethodOnWindow('addMemberCount');
771
+ window.getJoinedWorkingGroupIDList = registeMethodOnWindow('getJoinedWorkingGroupIDList');
772
+ window.getJoinedWorkingGroupList = registeMethodOnWindow('getJoinedWorkingGroupList');
773
+ window.getGroupMemberAllGroupIDs = registeMethodOnWindow('getGroupMemberAllGroupIDs');
774
+ window.getUserJoinedGroupIDs = registeMethodOnWindow('getUserJoinedGroupIDs');
775
+ window.getGroups = registeMethodOnWindow('getGroups');
776
+ window.getGroupMemberListByUserIDs = registeMethodOnWindow('getGroupMemberListByUserIDs');
777
+ window.batchInsertGroup = registeMethodOnWindow('batchInsertGroup');
778
+ window.deleteAllGroup = registeMethodOnWindow('deleteAllGroup');
779
+ // groupRequest
780
+ window.insertGroupRequest = registeMethodOnWindow('insertGroupRequest');
781
+ window.deleteGroupRequest = registeMethodOnWindow('deleteGroupRequest');
782
+ window.updateGroupRequest = registeMethodOnWindow('updateGroupRequest');
783
+ window.getSendGroupApplication = registeMethodOnWindow('getSendGroupApplication');
784
+ window.insertAdminGroupRequest = registeMethodOnWindow('insertAdminGroupRequest');
785
+ window.deleteAdminGroupRequest = registeMethodOnWindow('deleteAdminGroupRequest');
786
+ window.updateAdminGroupRequest = registeMethodOnWindow('updateAdminGroupRequest');
787
+ window.getAdminGroupApplication = registeMethodOnWindow('getAdminGroupApplication');
788
+ // groupMember
789
+ window.getGroupMemberInfoByGroupIDUserID = registeMethodOnWindow('getGroupMemberInfoByGroupIDUserID');
790
+ window.getAllGroupMemberList = registeMethodOnWindow('getAllGroupMemberList');
791
+ window.getAllGroupMemberUserIDList = registeMethodOnWindow('getAllGroupMemberUserIDList');
792
+ window.getGroupMemberCount = registeMethodOnWindow('getGroupMemberCount');
793
+ window.getGroupSomeMemberInfo = registeMethodOnWindow('getGroupSomeMemberInfo');
794
+ window.getGroupAdminID = registeMethodOnWindow('getGroupAdminID');
795
+ window.getGroupMemberListByGroupID = registeMethodOnWindow('getGroupMemberListByGroupID');
796
+ window.getGroupMemberListSplit = registeMethodOnWindow('getGroupMemberListSplit');
797
+ window.getGroupMemberOwnerAndAdminDB = registeMethodOnWindow('getGroupMemberOwnerAndAdmin');
798
+ window.getGroupMemberOwner = registeMethodOnWindow('getGroupMemberOwner');
799
+ window.getGroupMemberListSplitByJoinTimeFilter = registeMethodOnWindow('getGroupMemberListSplitByJoinTimeFilter');
800
+ window.getGroupOwnerAndAdminByGroupID = registeMethodOnWindow('getGroupOwnerAndAdminByGroupID');
801
+ window.getGroupMemberUIDListByGroupID = registeMethodOnWindow('getGroupMemberUIDListByGroupID');
802
+ window.insertGroupMember = registeMethodOnWindow('insertGroupMember');
803
+ window.batchInsertGroupMember = registeMethodOnWindow('batchInsertGroupMember');
804
+ window.deleteGroupMember = registeMethodOnWindow('deleteGroupMember');
805
+ window.deleteGroupAllMembers = registeMethodOnWindow('deleteGroupAllMembers');
806
+ window.updateGroupMember = registeMethodOnWindow('updateGroupMember');
807
+ window.updateGroupMemberField = registeMethodOnWindow('updateGroupMemberField');
808
+ window.searchGroupMembersDB = registeMethodOnWindow('searchGroupMembers', 'searchGroupMembersDB');
809
+ // temp cache chat logs
810
+ window.batchInsertTempCacheMessageList = registeMethodOnWindow('batchInsertTempCacheMessageList');
811
+ window.InsertTempCacheMessage = registeMethodOnWindow('InsertTempCacheMessage');
812
+ // notification
813
+ window.getNotificationAllSeqs = registeMethodOnWindow('getNotificationAllSeqs');
814
+ window.setNotificationSeq = registeMethodOnWindow('setNotificationSeq');
815
+ window.batchInsertNotificationSeq = registeMethodOnWindow('batchInsertNotificationSeq');
816
+ window.getExistedTables = registeMethodOnWindow('getExistedTables');
817
+ }
818
+ const workerPromise = rpc === null || rpc === void 0 ? void 0 : rpc.connect(5000);
819
+
820
+ class Emitter {
821
+ constructor() {
822
+ this.events = {};
823
+ }
824
+ emit(event, data) {
825
+ if (this.events[event]) {
826
+ this.events[event].forEach(fn => {
827
+ return fn(data);
828
+ });
829
+ }
830
+ return this;
831
+ }
832
+ on(event, fn) {
833
+ if (this.events[event]) {
834
+ this.events[event].push(fn);
835
+ }
836
+ else {
837
+ this.events[event] = [fn];
838
+ }
839
+ return this;
840
+ }
841
+ off(event, fn) {
842
+ if (event && typeof fn === 'function' && this.events[event]) {
843
+ const listeners = this.events[event];
844
+ if (!listeners || listeners.length === 0) {
845
+ return;
846
+ }
847
+ const index = listeners.findIndex(_fn => {
848
+ return _fn === fn;
849
+ });
850
+ if (index !== -1) {
851
+ listeners.splice(index, 1);
852
+ }
853
+ }
854
+ return this;
855
+ }
856
+ }
857
+
858
+ // Unique ID creation requires a high quality random # generator. In the browser we therefore
859
+ // require the crypto API and do not support built-in fallback to lower quality random number
860
+ // generators (like Math.random()).
861
+ let getRandomValues;
862
+ const rnds8 = new Uint8Array(16);
863
+ function rng() {
864
+ // lazy load so that environments that need to polyfill have a chance to do so
865
+ if (!getRandomValues) {
866
+ // getRandomValues needs to be invoked in a context where "this" is a Crypto implementation.
867
+ getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);
868
+
869
+ if (!getRandomValues) {
870
+ throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
871
+ }
872
+ }
873
+
874
+ return getRandomValues(rnds8);
875
+ }
876
+
877
+ /**
878
+ * Convert array of 16 byte values to UUID string format of the form:
879
+ * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
880
+ */
881
+
882
+ const byteToHex = [];
883
+
884
+ for (let i = 0; i < 256; ++i) {
885
+ byteToHex.push((i + 0x100).toString(16).slice(1));
886
+ }
887
+
888
+ function unsafeStringify(arr, offset = 0) {
889
+ // Note: Be careful editing this code! It's been tuned for performance
890
+ // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
891
+ 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();
892
+ }
893
+
894
+ const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
895
+ var native = {
896
+ randomUUID
897
+ };
898
+
899
+ function v4(options, buf, offset) {
900
+ if (native.randomUUID && !buf && !options) {
901
+ return native.randomUUID();
902
+ }
903
+
904
+ options = options || {};
905
+ const rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
906
+
907
+ rnds[6] = rnds[6] & 0x0f | 0x40;
908
+ rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
909
+
910
+ if (buf) {
911
+ offset = offset || 0;
912
+
913
+ for (let i = 0; i < 16; ++i) {
914
+ buf[offset + i] = rnds[i];
915
+ }
916
+
917
+ return buf;
918
+ }
919
+
920
+ return unsafeStringify(rnds);
921
+ }
922
+
923
+ async function wait(duration) {
924
+ return new Promise(resolve => {
925
+ const timer = setTimeout(() => {
926
+ clearTimeout(timer);
927
+ resolve(null);
928
+ }, duration);
929
+ });
930
+ }
931
+
932
+ function logBoxStyleValue(backgroundColor, color) {
933
+ 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;`;
934
+ }
935
+
936
+ let initialized = false;
937
+ let go;
938
+ let goExitPromise;
939
+ const CACHE_KEY = 'openim-wasm-cache';
940
+ async function initializeWasm(url) {
941
+ if (initialized) {
942
+ return null;
943
+ }
944
+ if (typeof window === 'undefined') {
945
+ return Promise.resolve(null);
946
+ }
947
+ go = new Go();
948
+ let wasm;
949
+ try {
950
+ if ('instantiateStreaming' in WebAssembly) {
951
+ wasm = await WebAssembly.instantiateStreaming(fetchWithCache(url), go.importObject);
952
+ }
953
+ else {
954
+ const bytes = await fetchWithCache(url).then(resp => resp.arrayBuffer());
955
+ wasm = await WebAssembly.instantiate(bytes, go.importObject);
956
+ }
957
+ go.run(wasm.instance);
958
+ }
959
+ catch (error) {
960
+ console.error('Failed to initialize WASM:', error);
961
+ return null;
962
+ }
963
+ await wait(100);
964
+ initialized = true;
965
+ return go;
966
+ }
967
+ function getGO() {
968
+ return go;
969
+ }
970
+ function getGoExitPromise() {
971
+ return goExitPromise;
972
+ }
973
+ async function fetchWithCache(url) {
974
+ if (!('caches' in window)) {
975
+ return fetch(url);
976
+ }
977
+ const isResourceUpdated = async () => {
978
+ const serverResponse = await fetch(url, { method: 'HEAD' });
979
+ const etag = serverResponse.headers.get('ETag');
980
+ const lastModified = serverResponse.headers.get('Last-Modified');
981
+ return (serverResponse.ok &&
982
+ (etag !== (cachedResponse === null || cachedResponse === void 0 ? void 0 : cachedResponse.headers.get('ETag')) ||
983
+ lastModified !== (cachedResponse === null || cachedResponse === void 0 ? void 0 : cachedResponse.headers.get('Last-Modified'))));
984
+ };
985
+ const cache = await caches.open(CACHE_KEY);
986
+ const cachedResponse = await cache.match(url);
987
+ if (cachedResponse && !(await isResourceUpdated())) {
988
+ return cachedResponse;
989
+ }
990
+ return fetchAndUpdateCache(url, cache);
991
+ }
992
+ async function fetchAndUpdateCache(url, cache) {
993
+ const response = await fetch(url, { cache: 'no-cache' });
994
+ try {
995
+ await cache.put(url, response.clone());
996
+ }
997
+ catch (error) {
998
+ console.warn('Failed to put cache');
999
+ }
1000
+ return response;
1001
+ }
1002
+
1003
+ var MessageReceiveOptType;
1004
+ (function (MessageReceiveOptType) {
1005
+ MessageReceiveOptType[MessageReceiveOptType["Normal"] = 0] = "Normal";
1006
+ MessageReceiveOptType[MessageReceiveOptType["NotReceive"] = 1] = "NotReceive";
1007
+ MessageReceiveOptType[MessageReceiveOptType["NotNotify"] = 2] = "NotNotify";
1008
+ })(MessageReceiveOptType || (MessageReceiveOptType = {}));
1009
+ var AllowType;
1010
+ (function (AllowType) {
1011
+ AllowType[AllowType["Allowed"] = 0] = "Allowed";
1012
+ AllowType[AllowType["NotAllowed"] = 1] = "NotAllowed";
1013
+ })(AllowType || (AllowType = {}));
1014
+ var GroupType;
1015
+ (function (GroupType) {
1016
+ GroupType[GroupType["Group"] = 2] = "Group";
1017
+ GroupType[GroupType["WorkingGroup"] = 2] = "WorkingGroup";
1018
+ })(GroupType || (GroupType = {}));
1019
+ var GroupJoinSource;
1020
+ (function (GroupJoinSource) {
1021
+ GroupJoinSource[GroupJoinSource["Invitation"] = 2] = "Invitation";
1022
+ GroupJoinSource[GroupJoinSource["Search"] = 3] = "Search";
1023
+ GroupJoinSource[GroupJoinSource["QrCode"] = 4] = "QrCode";
1024
+ })(GroupJoinSource || (GroupJoinSource = {}));
1025
+ var GroupMemberRole;
1026
+ (function (GroupMemberRole) {
1027
+ GroupMemberRole[GroupMemberRole["Normal"] = 20] = "Normal";
1028
+ GroupMemberRole[GroupMemberRole["Admin"] = 60] = "Admin";
1029
+ GroupMemberRole[GroupMemberRole["Owner"] = 100] = "Owner";
1030
+ })(GroupMemberRole || (GroupMemberRole = {}));
1031
+ var GroupVerificationType;
1032
+ (function (GroupVerificationType) {
1033
+ GroupVerificationType[GroupVerificationType["ApplyNeedInviteNot"] = 0] = "ApplyNeedInviteNot";
1034
+ GroupVerificationType[GroupVerificationType["AllNeed"] = 1] = "AllNeed";
1035
+ GroupVerificationType[GroupVerificationType["AllNot"] = 2] = "AllNot";
1036
+ })(GroupVerificationType || (GroupVerificationType = {}));
1037
+ var MessageStatus;
1038
+ (function (MessageStatus) {
1039
+ MessageStatus[MessageStatus["Sending"] = 1] = "Sending";
1040
+ MessageStatus[MessageStatus["Succeed"] = 2] = "Succeed";
1041
+ MessageStatus[MessageStatus["Failed"] = 3] = "Failed";
1042
+ })(MessageStatus || (MessageStatus = {}));
1043
+ var Platform;
1044
+ (function (Platform) {
1045
+ Platform[Platform["iOS"] = 1] = "iOS";
1046
+ Platform[Platform["Android"] = 2] = "Android";
1047
+ Platform[Platform["Windows"] = 3] = "Windows";
1048
+ Platform[Platform["MacOSX"] = 4] = "MacOSX";
1049
+ Platform[Platform["Web"] = 5] = "Web";
1050
+ Platform[Platform["Linux"] = 7] = "Linux";
1051
+ Platform[Platform["AndroidPad"] = 8] = "AndroidPad";
1052
+ Platform[Platform["iPad"] = 9] = "iPad";
1053
+ })(Platform || (Platform = {}));
1054
+ var LogLevel;
1055
+ (function (LogLevel) {
1056
+ LogLevel[LogLevel["Verbose"] = 6] = "Verbose";
1057
+ LogLevel[LogLevel["Debug"] = 5] = "Debug";
1058
+ LogLevel[LogLevel["Info"] = 4] = "Info";
1059
+ LogLevel[LogLevel["Warn"] = 3] = "Warn";
1060
+ LogLevel[LogLevel["Error"] = 2] = "Error";
1061
+ LogLevel[LogLevel["Fatal"] = 1] = "Fatal";
1062
+ LogLevel[LogLevel["Panic"] = 0] = "Panic";
1063
+ })(LogLevel || (LogLevel = {}));
1064
+ var ApplicationHandleResult;
1065
+ (function (ApplicationHandleResult) {
1066
+ ApplicationHandleResult[ApplicationHandleResult["Unprocessed"] = 0] = "Unprocessed";
1067
+ ApplicationHandleResult[ApplicationHandleResult["Agree"] = 1] = "Agree";
1068
+ ApplicationHandleResult[ApplicationHandleResult["Reject"] = -1] = "Reject";
1069
+ })(ApplicationHandleResult || (ApplicationHandleResult = {}));
1070
+ var MessageType;
1071
+ (function (MessageType) {
1072
+ MessageType[MessageType["TextMessage"] = 101] = "TextMessage";
1073
+ MessageType[MessageType["PictureMessage"] = 102] = "PictureMessage";
1074
+ MessageType[MessageType["VoiceMessage"] = 103] = "VoiceMessage";
1075
+ MessageType[MessageType["VideoMessage"] = 104] = "VideoMessage";
1076
+ MessageType[MessageType["FileMessage"] = 105] = "FileMessage";
1077
+ MessageType[MessageType["AtTextMessage"] = 106] = "AtTextMessage";
1078
+ MessageType[MessageType["MergeMessage"] = 107] = "MergeMessage";
1079
+ MessageType[MessageType["CardMessage"] = 108] = "CardMessage";
1080
+ MessageType[MessageType["LocationMessage"] = 109] = "LocationMessage";
1081
+ MessageType[MessageType["CustomMessage"] = 110] = "CustomMessage";
1082
+ MessageType[MessageType["TypingMessage"] = 113] = "TypingMessage";
1083
+ MessageType[MessageType["QuoteMessage"] = 114] = "QuoteMessage";
1084
+ MessageType[MessageType["FaceMessage"] = 115] = "FaceMessage";
1085
+ MessageType[MessageType["FriendAdded"] = 1201] = "FriendAdded";
1086
+ MessageType[MessageType["OANotification"] = 1400] = "OANotification";
1087
+ MessageType[MessageType["GroupCreated"] = 1501] = "GroupCreated";
1088
+ MessageType[MessageType["GroupInfoUpdated"] = 1502] = "GroupInfoUpdated";
1089
+ MessageType[MessageType["MemberQuit"] = 1504] = "MemberQuit";
1090
+ MessageType[MessageType["GroupOwnerTransferred"] = 1507] = "GroupOwnerTransferred";
1091
+ MessageType[MessageType["MemberKicked"] = 1508] = "MemberKicked";
1092
+ MessageType[MessageType["MemberInvited"] = 1509] = "MemberInvited";
1093
+ MessageType[MessageType["MemberEnter"] = 1510] = "MemberEnter";
1094
+ MessageType[MessageType["GroupDismissed"] = 1511] = "GroupDismissed";
1095
+ MessageType[MessageType["GroupMemberMuted"] = 1512] = "GroupMemberMuted";
1096
+ MessageType[MessageType["GroupMemberCancelMuted"] = 1513] = "GroupMemberCancelMuted";
1097
+ MessageType[MessageType["GroupMuted"] = 1514] = "GroupMuted";
1098
+ MessageType[MessageType["GroupCancelMuted"] = 1515] = "GroupCancelMuted";
1099
+ MessageType[MessageType["GroupAnnouncementUpdated"] = 1519] = "GroupAnnouncementUpdated";
1100
+ MessageType[MessageType["GroupNameUpdated"] = 1520] = "GroupNameUpdated";
1101
+ MessageType[MessageType["BurnMessageChange"] = 1701] = "BurnMessageChange";
1102
+ MessageType[MessageType["RevokeMessage"] = 2101] = "RevokeMessage";
1103
+ })(MessageType || (MessageType = {}));
1104
+ var SessionType;
1105
+ (function (SessionType) {
1106
+ SessionType[SessionType["Single"] = 1] = "Single";
1107
+ SessionType[SessionType["Group"] = 3] = "Group";
1108
+ SessionType[SessionType["WorkingGroup"] = 3] = "WorkingGroup";
1109
+ SessionType[SessionType["Notification"] = 4] = "Notification";
1110
+ })(SessionType || (SessionType = {}));
1111
+ var GroupStatus;
1112
+ (function (GroupStatus) {
1113
+ GroupStatus[GroupStatus["Normal"] = 0] = "Normal";
1114
+ GroupStatus[GroupStatus["Banned"] = 1] = "Banned";
1115
+ GroupStatus[GroupStatus["Dismissed"] = 2] = "Dismissed";
1116
+ GroupStatus[GroupStatus["Muted"] = 3] = "Muted";
1117
+ })(GroupStatus || (GroupStatus = {}));
1118
+ var GroupAtType;
1119
+ (function (GroupAtType) {
1120
+ GroupAtType[GroupAtType["AtNormal"] = 0] = "AtNormal";
1121
+ GroupAtType[GroupAtType["AtMe"] = 1] = "AtMe";
1122
+ GroupAtType[GroupAtType["AtAll"] = 2] = "AtAll";
1123
+ GroupAtType[GroupAtType["AtAllAtMe"] = 3] = "AtAllAtMe";
1124
+ GroupAtType[GroupAtType["AtGroupNotice"] = 4] = "AtGroupNotice";
1125
+ })(GroupAtType || (GroupAtType = {}));
1126
+ var GroupMemberFilter;
1127
+ (function (GroupMemberFilter) {
1128
+ GroupMemberFilter[GroupMemberFilter["All"] = 0] = "All";
1129
+ GroupMemberFilter[GroupMemberFilter["Owner"] = 1] = "Owner";
1130
+ GroupMemberFilter[GroupMemberFilter["Admin"] = 2] = "Admin";
1131
+ GroupMemberFilter[GroupMemberFilter["Normal"] = 3] = "Normal";
1132
+ GroupMemberFilter[GroupMemberFilter["AdminAndNormal"] = 4] = "AdminAndNormal";
1133
+ GroupMemberFilter[GroupMemberFilter["AdminAndOwner"] = 5] = "AdminAndOwner";
1134
+ })(GroupMemberFilter || (GroupMemberFilter = {}));
1135
+ var Relationship;
1136
+ (function (Relationship) {
1137
+ Relationship[Relationship["isBlack"] = 0] = "isBlack";
1138
+ Relationship[Relationship["isFriend"] = 1] = "isFriend";
1139
+ })(Relationship || (Relationship = {}));
1140
+ var LoginStatus;
1141
+ (function (LoginStatus) {
1142
+ LoginStatus[LoginStatus["Logout"] = 1] = "Logout";
1143
+ LoginStatus[LoginStatus["Logging"] = 2] = "Logging";
1144
+ LoginStatus[LoginStatus["Logged"] = 3] = "Logged";
1145
+ })(LoginStatus || (LoginStatus = {}));
1146
+ var OnlineState;
1147
+ (function (OnlineState) {
1148
+ OnlineState[OnlineState["Online"] = 1] = "Online";
1149
+ OnlineState[OnlineState["Offline"] = 0] = "Offline";
1150
+ })(OnlineState || (OnlineState = {}));
1151
+ var GroupMessageReaderFilter;
1152
+ (function (GroupMessageReaderFilter) {
1153
+ GroupMessageReaderFilter[GroupMessageReaderFilter["Read"] = 0] = "Read";
1154
+ GroupMessageReaderFilter[GroupMessageReaderFilter["UnRead"] = 1] = "UnRead";
1155
+ })(GroupMessageReaderFilter || (GroupMessageReaderFilter = {}));
1156
+
1157
+ class SDK extends Emitter {
1158
+ constructor(url = '/openIM.wasm', debug = true) {
1159
+ super();
1160
+ this.goExisted = false;
1161
+ this.tryParse = true;
1162
+ this.isLogStandardOutput = true;
1163
+ this.login = async (params, operationID = v4()) => {
1164
+ var _a, _b;
1165
+ this._logWrap(`SDK => (invoked by js) run login with args ${JSON.stringify({
1166
+ params,
1167
+ operationID,
1168
+ })}`);
1169
+ await workerPromise;
1170
+ await this.wasmInitializedPromise;
1171
+ window.commonEventFunc(event => {
1172
+ try {
1173
+ this._logWrap(`%cSDK =>%c received event %c${event}%c `, logBoxStyleValue('#282828', '#ffffff'), '', 'color: #4f2398;', '');
1174
+ const parsed = JSON.parse(event);
1175
+ if (this.tryParse) {
1176
+ try {
1177
+ parsed.data = JSON.parse(parsed.data);
1178
+ }
1179
+ catch (error) {
1180
+ // parse error
1181
+ }
1182
+ }
1183
+ this.emit(parsed.event, parsed);
1184
+ }
1185
+ catch (error) {
1186
+ console.error(error);
1187
+ }
1188
+ });
1189
+ const config = {
1190
+ platformID: params.platformID,
1191
+ apiAddr: params.apiAddr,
1192
+ wsAddr: params.wsAddr,
1193
+ dataDir: './',
1194
+ logLevel: params.logLevel || 5,
1195
+ isLogStandardOutput: (_a = params.isLogStandardOutput) !== null && _a !== void 0 ? _a : this.isLogStandardOutput,
1196
+ logFilePath: './',
1197
+ isExternalExtensions: params.isExternalExtensions || false,
1198
+ };
1199
+ this.tryParse = (_b = params.tryParse) !== null && _b !== void 0 ? _b : true;
1200
+ window.initSDK(operationID, JSON.stringify(config));
1201
+ return await window.login(operationID, params.userID, params.token);
1202
+ };
1203
+ this.logout = (operationID = v4()) => {
1204
+ window.fileMapClear();
1205
+ return this._invoker('logout', window.logout, [operationID]);
1206
+ };
1207
+ this.getAllConversationList = (operationID = v4()) => {
1208
+ return this._invoker('getAllConversationList', window.getAllConversationList, [operationID]);
1209
+ };
1210
+ this.getOneConversation = (params, operationID = v4()) => {
1211
+ return this._invoker('getOneConversation', window.getOneConversation, [operationID, params.sessionType, params.sourceID]);
1212
+ };
1213
+ this.getAdvancedHistoryMessageList = (params, operationID = v4()) => {
1214
+ return this._invoker('getAdvancedHistoryMessageList', window.getAdvancedHistoryMessageList, [operationID, JSON.stringify(params)]);
1215
+ };
1216
+ this.getAdvancedHistoryMessageListReverse = (params, operationID = v4()) => {
1217
+ return this._invoker('getAdvancedHistoryMessageListReverse', window.getAdvancedHistoryMessageListReverse, [operationID, JSON.stringify(params)]);
1218
+ };
1219
+ this.getSpecifiedGroupsInfo = (params, operationID = v4()) => {
1220
+ return this._invoker('getSpecifiedGroupsInfo', window.getSpecifiedGroupsInfo, [operationID, JSON.stringify(params)]);
1221
+ };
1222
+ this.deleteConversationAndDeleteAllMsg = (conversationID, operationID = v4()) => {
1223
+ return this._invoker('deleteConversationAndDeleteAllMsg', window.deleteConversationAndDeleteAllMsg, [operationID, conversationID]);
1224
+ };
1225
+ this.markConversationMessageAsRead = (data, operationID = v4()) => {
1226
+ return this._invoker('markConversationMessageAsRead', window.markConversationMessageAsRead, [operationID, data]);
1227
+ };
1228
+ this.sendGroupMessageReadReceipt = (params, operationID = v4()) => {
1229
+ return this._invoker('sendGroupMessageReadReceipt', window.sendGroupMessageReadReceipt, [
1230
+ operationID,
1231
+ params.conversationID,
1232
+ JSON.stringify(params.clientMsgIDList),
1233
+ ]);
1234
+ };
1235
+ this.getGroupMessageReaderList = (params, operationID = v4()) => {
1236
+ return this._invoker('getGroupMessageReaderList', window.getGroupMessageReaderList, [
1237
+ operationID,
1238
+ params.conversationID,
1239
+ params.clientMsgID,
1240
+ params.filter,
1241
+ params.offset,
1242
+ params.count,
1243
+ ]);
1244
+ };
1245
+ this.getGroupMemberList = (params, operationID = v4()) => {
1246
+ return this._invoker('getGroupMemberList', window.getGroupMemberList, [operationID, params.groupID, params.filter, params.offset, params.count]);
1247
+ };
1248
+ this.createTextMessage = (text, operationID = v4()) => {
1249
+ return this._invoker('createTextMessage', window.createTextMessage, [operationID, text], data => {
1250
+ // compitable with old version sdk
1251
+ return data[0];
1252
+ });
1253
+ };
1254
+ this.createImageMessageByURL = (params, operationID = v4()) => {
1255
+ return this._invoker('createImageMessageByURL', window.createImageMessageByURL, [
1256
+ operationID,
1257
+ params.sourcePath,
1258
+ JSON.stringify(params.sourcePicture),
1259
+ JSON.stringify(params.bigPicture),
1260
+ JSON.stringify(params.snapshotPicture),
1261
+ ], data => {
1262
+ // compitable with old version sdk
1263
+ return data[0];
1264
+ });
1265
+ };
1266
+ this.createImageMessageByFile = (params, operationID = v4()) => {
1267
+ params.sourcePicture.uuid = `${params.sourcePicture.uuid}/${params.file.name}`;
1268
+ window.fileMapSet(params.sourcePicture.uuid, params.file);
1269
+ return this._invoker('createImageMessageByFile', window.createImageMessageByURL, [
1270
+ operationID,
1271
+ params.sourcePath,
1272
+ JSON.stringify(params.sourcePicture),
1273
+ JSON.stringify(params.bigPicture),
1274
+ JSON.stringify(params.snapshotPicture),
1275
+ ], data => {
1276
+ // compitable with old version sdk
1277
+ return data[0];
1278
+ });
1279
+ };
1280
+ this.createCustomMessage = (params, operationID = v4()) => {
1281
+ return this._invoker('createCustomMessage', window.createCustomMessage, [operationID, params.data, params.extension, params.description], data => {
1282
+ // compitable with old version sdk
1283
+ return data[0];
1284
+ });
1285
+ };
1286
+ this.createQuoteMessage = (params, operationID = v4()) => {
1287
+ return this._invoker('createQuoteMessage', window.createQuoteMessage, [operationID, params.text, params.message], data => {
1288
+ // compitable with old version sdk
1289
+ return data[0];
1290
+ });
1291
+ };
1292
+ this.createAdvancedQuoteMessage = (params, operationID = v4()) => {
1293
+ return this._invoker('createAdvancedQuoteMessage', window.createAdvancedQuoteMessage, [
1294
+ operationID,
1295
+ params.text,
1296
+ JSON.stringify(params.message),
1297
+ JSON.stringify(params.messageEntityList),
1298
+ ], data => {
1299
+ // compitable with old version sdk
1300
+ return data[0];
1301
+ });
1302
+ };
1303
+ this.createAdvancedTextMessage = (params, operationID = v4()) => {
1304
+ return this._invoker('createAdvancedTextMessage', window.createAdvancedTextMessage, [operationID, params.text, JSON.stringify(params.messageEntityList)], data => {
1305
+ // compitable with old version sdk
1306
+ return data[0];
1307
+ });
1308
+ };
1309
+ this.sendMessage = (params, operationID = v4()) => {
1310
+ var _a, _b;
1311
+ const offlinePushInfo = (_a = params.offlinePushInfo) !== null && _a !== void 0 ? _a : {
1312
+ title: 'You have a new message.',
1313
+ desc: '',
1314
+ ex: '',
1315
+ iOSPushSound: '+1',
1316
+ iOSBadgeCount: true,
1317
+ };
1318
+ return this._invoker('sendMessage', window.sendMessage, [
1319
+ operationID,
1320
+ JSON.stringify(params.message),
1321
+ params.recvID,
1322
+ params.groupID,
1323
+ JSON.stringify(offlinePushInfo),
1324
+ (_b = params.isOnlineOnly) !== null && _b !== void 0 ? _b : false,
1325
+ ]);
1326
+ };
1327
+ this.sendMessageNotOss = (params, operationID = v4()) => {
1328
+ var _a, _b;
1329
+ const offlinePushInfo = (_a = params.offlinePushInfo) !== null && _a !== void 0 ? _a : {
1330
+ title: 'You have a new message.',
1331
+ desc: '',
1332
+ ex: '',
1333
+ iOSPushSound: '+1',
1334
+ iOSBadgeCount: true,
1335
+ };
1336
+ return this._invoker('sendMessageNotOss', window.sendMessageNotOss, [
1337
+ operationID,
1338
+ JSON.stringify(params.message),
1339
+ params.recvID,
1340
+ params.groupID,
1341
+ JSON.stringify(offlinePushInfo),
1342
+ (_b = params.isOnlineOnly) !== null && _b !== void 0 ? _b : false,
1343
+ ]);
1344
+ };
1345
+ this.setMessageLocalEx = (params, operationID = v4()) => {
1346
+ return this._invoker('setMessageLocalEx', window.setMessageLocalEx, [
1347
+ operationID,
1348
+ params.conversationID,
1349
+ params.clientMsgID,
1350
+ params.localEx,
1351
+ ]);
1352
+ };
1353
+ this.getHistoryMessageListReverse = (params, operationID = v4()) => {
1354
+ return this._invoker('getHistoryMessageListReverse', window.getHistoryMessageListReverse, [operationID, JSON.stringify(params)]);
1355
+ };
1356
+ this.revokeMessage = (data, operationID = v4()) => {
1357
+ return this._invoker('revokeMessage', window.revokeMessage, [
1358
+ operationID,
1359
+ data.conversationID,
1360
+ data.clientMsgID,
1361
+ ]);
1362
+ };
1363
+ this.setConversation = (params, operationID = v4()) => {
1364
+ return this._invoker('setConversation', window.setConversation, [
1365
+ operationID,
1366
+ params.conversationID,
1367
+ JSON.stringify(params),
1368
+ ]);
1369
+ };
1370
+ this.setConversationPrivateChat = (params, operationID = v4()) => {
1371
+ return this._invoker('setConversationPrivateChat', window.setConversation, [
1372
+ operationID,
1373
+ params.conversationID,
1374
+ JSON.stringify({
1375
+ isPrivateChat: params.isPrivate,
1376
+ }),
1377
+ ]);
1378
+ };
1379
+ this.setConversationBurnDuration = (params, operationID = v4()) => {
1380
+ return this._invoker('setConversationBurnDuration', window.setConversation, [
1381
+ operationID,
1382
+ params.conversationID,
1383
+ JSON.stringify({
1384
+ burnDuration: params.burnDuration,
1385
+ }),
1386
+ ]);
1387
+ };
1388
+ this.getLoginStatus = (operationID = v4()) => {
1389
+ return this._invoker('getLoginStatus', window.getLoginStatus, [operationID], data => {
1390
+ // compitable with old version sdk
1391
+ return data[0];
1392
+ });
1393
+ };
1394
+ this.setAppBackgroundStatus = (data, operationID = v4()) => {
1395
+ return this._invoker('setAppBackgroundStatus', window.setAppBackgroundStatus, [operationID, data]);
1396
+ };
1397
+ this.networkStatusChanged = (operationID = v4()) => {
1398
+ return this._invoker('networkStatusChanged ', window.networkStatusChanged, [operationID]);
1399
+ };
1400
+ this.getLoginUserID = (operationID = v4()) => {
1401
+ return this._invoker('getLoginUserID', window.getLoginUserID, [
1402
+ operationID,
1403
+ ]);
1404
+ };
1405
+ this.getSelfUserInfo = (operationID = v4()) => {
1406
+ return this._invoker('getSelfUserInfo', window.getSelfUserInfo, [operationID]);
1407
+ };
1408
+ this.getUsersInfo = (data, operationID = v4()) => {
1409
+ return this._invoker('getUsersInfo', window.getUsersInfo, [operationID, JSON.stringify(data)]);
1410
+ };
1411
+ this.SetSelfInfoEx = (data, operationID = v4()) => {
1412
+ return this._invoker('SetSelfInfoEx', window.setSelfInfo, [
1413
+ operationID,
1414
+ JSON.stringify(data),
1415
+ ]);
1416
+ };
1417
+ this.setSelfInfo = (data, operationID = v4()) => {
1418
+ return this._invoker('setSelfInfo', window.setSelfInfo, [
1419
+ operationID,
1420
+ JSON.stringify(data),
1421
+ ]);
1422
+ };
1423
+ this.createTextAtMessage = (data, operationID = v4()) => {
1424
+ var _a;
1425
+ return this._invoker('createTextAtMessage', window.createTextAtMessage, [
1426
+ operationID,
1427
+ data.text,
1428
+ JSON.stringify(data.atUserIDList),
1429
+ JSON.stringify(data.atUsersInfo),
1430
+ (_a = JSON.stringify(data.message)) !== null && _a !== void 0 ? _a : '',
1431
+ ], data => {
1432
+ // compitable with old version sdk
1433
+ return data[0];
1434
+ });
1435
+ };
1436
+ this.createSoundMessageByURL = (data, operationID = v4()) => {
1437
+ return this._invoker('createSoundMessageByURL', window.createSoundMessageByURL, [operationID, JSON.stringify(data)], data => {
1438
+ // compitable with old version sdk
1439
+ return data[0];
1440
+ });
1441
+ };
1442
+ this.createSoundMessageByFile = (data, operationID = v4()) => {
1443
+ data.uuid = `${data.uuid}/${data.file.name}`;
1444
+ window.fileMapSet(data.uuid, data.file);
1445
+ return this._invoker('createSoundMessageByFile', window.createSoundMessageByURL, [operationID, JSON.stringify(data)], data => {
1446
+ // compitable with old version sdk
1447
+ return data[0];
1448
+ });
1449
+ };
1450
+ this.createVideoMessageByURL = (data, operationID = v4()) => {
1451
+ return this._invoker('createVideoMessageByURL', window.createVideoMessageByURL, [operationID, JSON.stringify(data)], data => {
1452
+ // compitable with old version sdk
1453
+ return data[0];
1454
+ });
1455
+ };
1456
+ this.createVideoMessageByFile = (data, operationID = v4()) => {
1457
+ data.videoUUID = `${data.videoUUID}/${data.videoFile.name}`;
1458
+ data.snapshotUUID = `${data.snapshotUUID}/${data.snapshotFile.name}`;
1459
+ window.fileMapSet(data.videoUUID, data.videoFile);
1460
+ window.fileMapSet(data.snapshotUUID, data.snapshotFile);
1461
+ return this._invoker('createVideoMessageByFile', window.createVideoMessageByURL, [operationID, JSON.stringify(data)], data => {
1462
+ // compitable with old version sdk
1463
+ return data[0];
1464
+ });
1465
+ };
1466
+ this.createFileMessageByURL = (data, operationID = v4()) => {
1467
+ return this._invoker('createFileMessageByURL', window.createFileMessageByURL, [operationID, JSON.stringify(data)], data => {
1468
+ // compitable with old version sdk
1469
+ return data[0];
1470
+ });
1471
+ };
1472
+ this.createFileMessageByFile = (data, operationID = v4()) => {
1473
+ data.uuid = `${data.uuid}/${data.file.name}`;
1474
+ window.fileMapSet(data.uuid, data.file);
1475
+ return this._invoker('createFileMessageByFile', window.createFileMessageByURL, [operationID, JSON.stringify(data)], data => {
1476
+ // compitable with old version sdk
1477
+ return data[0];
1478
+ });
1479
+ };
1480
+ this.createMergerMessage = (data, operationID = v4()) => {
1481
+ return this._invoker('createMergerMessage ', window.createMergerMessage, [
1482
+ operationID,
1483
+ JSON.stringify(data.messageList),
1484
+ data.title,
1485
+ JSON.stringify(data.summaryList),
1486
+ ], data => {
1487
+ // compitable with old version sdk
1488
+ return data[0];
1489
+ });
1490
+ };
1491
+ this.createForwardMessage = (data, operationID = v4()) => {
1492
+ return this._invoker('createForwardMessage ', window.createForwardMessage, [operationID, JSON.stringify(data)], data => {
1493
+ // compitable with old version sdk
1494
+ return data[0];
1495
+ });
1496
+ };
1497
+ this.createFaceMessage = (data, operationID = v4()) => {
1498
+ return this._invoker('createFaceMessage ', window.createFaceMessage, [operationID, data.index, data.data], data => {
1499
+ // compitable with old version sdk
1500
+ return data[0];
1501
+ });
1502
+ };
1503
+ this.createLocationMessage = (data, operationID = v4()) => {
1504
+ return this._invoker('createLocationMessage ', window.createLocationMessage, [operationID, data.description, data.longitude, data.latitude], data => {
1505
+ // compitable with old version sdk
1506
+ return data[0];
1507
+ });
1508
+ };
1509
+ this.createCardMessage = (data, operationID = v4()) => {
1510
+ return this._invoker('createCardMessage ', window.createCardMessage, [operationID, JSON.stringify(data)], data => {
1511
+ // compitable with old version sdk
1512
+ return data[0];
1513
+ });
1514
+ };
1515
+ this.deleteMessageFromLocalStorage = (data, operationID = v4()) => {
1516
+ return this._invoker('deleteMessageFromLocalStorage ', window.deleteMessageFromLocalStorage, [operationID, data.conversationID, data.clientMsgID]);
1517
+ };
1518
+ this.deleteMessage = (data, operationID = v4()) => {
1519
+ return this._invoker('deleteMessage ', window.deleteMessage, [
1520
+ operationID,
1521
+ data.conversationID,
1522
+ data.clientMsgID,
1523
+ ]);
1524
+ };
1525
+ this.deleteAllConversationFromLocal = (operationID = v4()) => {
1526
+ return this._invoker('deleteAllConversationFromLocal ', window.deleteAllConversationFromLocal, [operationID]);
1527
+ };
1528
+ this.deleteAllMsgFromLocal = (operationID = v4()) => {
1529
+ return this._invoker('deleteAllMsgFromLocal ', window.deleteAllMsgFromLocal, [operationID]);
1530
+ };
1531
+ this.deleteAllMsgFromLocalAndSvr = (operationID = v4()) => {
1532
+ return this._invoker('deleteAllMsgFromLocalAndSvr ', window.deleteAllMsgFromLocalAndSvr, [operationID]);
1533
+ };
1534
+ this.insertSingleMessageToLocalStorage = (data, operationID = v4()) => {
1535
+ return this._invoker('insertSingleMessageToLocalStorage ', window.insertSingleMessageToLocalStorage, [operationID, JSON.stringify(data.message), data.recvID, data.sendID]);
1536
+ };
1537
+ this.insertGroupMessageToLocalStorage = (data, operationID = v4()) => {
1538
+ return this._invoker('insertGroupMessageToLocalStorage ', window.insertGroupMessageToLocalStorage, [operationID, JSON.stringify(data.message), data.groupID, data.sendID]);
1539
+ };
1540
+ /**
1541
+ * @deprecated Use changeInputStates instead.
1542
+ */
1543
+ this.typingStatusUpdate = (data, operationID = v4()) => {
1544
+ return this._invoker('typingStatusUpdate ', window.typingStatusUpdate, [
1545
+ operationID,
1546
+ data.recvID,
1547
+ data.msgTip,
1548
+ ]);
1549
+ };
1550
+ this.changeInputStates = (data, operationID = v4()) => {
1551
+ return this._invoker('changeInputStates ', window.changeInputStates, [
1552
+ operationID,
1553
+ data.conversationID,
1554
+ data.focus,
1555
+ ]);
1556
+ };
1557
+ this.getInputstates = (data, operationID = v4()) => {
1558
+ return this._invoker('getInputstates ', window.getInputstates, [
1559
+ operationID,
1560
+ data.conversationID,
1561
+ data.userID,
1562
+ ]);
1563
+ };
1564
+ this.clearConversationAndDeleteAllMsg = (data, operationID = v4()) => {
1565
+ return this._invoker('clearConversationAndDeleteAllMsg ', window.clearConversationAndDeleteAllMsg, [operationID, data]);
1566
+ };
1567
+ this.hideConversation = (data, operationID = v4()) => {
1568
+ return this._invoker('hideConversation ', window.hideConversation, [
1569
+ operationID,
1570
+ data,
1571
+ ]);
1572
+ };
1573
+ this.getConversationListSplit = (data, operationID = v4()) => {
1574
+ return this._invoker('getConversationListSplit ', window.getConversationListSplit, [operationID, data.offset, data.count]);
1575
+ };
1576
+ // searchConversation = (data: SplitConversationParams, operationID = uuidv4()) => {
1577
+ // return this._invoker<ConversationItem[]>(
1578
+ // 'searchConversation ',
1579
+ // window.searchConversation,
1580
+ // [operationID, data.offset, data.count]
1581
+ // );
1582
+ // };
1583
+ this.setConversationEx = (data, operationID = v4()) => {
1584
+ return this._invoker('setConversationEx ', window.setConversation, [
1585
+ operationID,
1586
+ data.conversationID,
1587
+ JSON.stringify({
1588
+ ex: data.ex,
1589
+ }),
1590
+ ]);
1591
+ };
1592
+ this.getConversationIDBySessionType = (data, operationID = v4()) => {
1593
+ return this._invoker('getConversationIDBySessionType ', window.getConversationIDBySessionType, [operationID, data.sourceID, data.sessionType]);
1594
+ };
1595
+ this.getMultipleConversation = (data, operationID = v4()) => {
1596
+ return this._invoker('getMultipleConversation ', window.getMultipleConversation, [operationID, JSON.stringify(data)]);
1597
+ };
1598
+ this.deleteConversation = (data, operationID = v4()) => {
1599
+ return this._invoker('deleteConversation ', window.deleteConversation, [
1600
+ operationID,
1601
+ data,
1602
+ ]);
1603
+ };
1604
+ this.setConversationDraft = (data, operationID = v4()) => {
1605
+ return this._invoker('setConversationDraft ', window.setConversationDraft, [operationID, data.conversationID, data.draftText]);
1606
+ };
1607
+ this.pinConversation = (data, operationID = v4()) => {
1608
+ return this._invoker('pinConversation ', window.setConversation, [
1609
+ operationID,
1610
+ data.conversationID,
1611
+ JSON.stringify({
1612
+ isPinned: data.isPinned,
1613
+ }),
1614
+ ]);
1615
+ };
1616
+ this.getTotalUnreadMsgCount = (operationID = v4()) => {
1617
+ return this._invoker('getTotalUnreadMsgCount ', window.getTotalUnreadMsgCount, [operationID]);
1618
+ };
1619
+ this.getConversationRecvMessageOpt = (data, operationID = v4()) => {
1620
+ return this._invoker('getConversationRecvMessageOpt ', window.getConversationRecvMessageOpt, [operationID, JSON.stringify(data)]);
1621
+ };
1622
+ this.setConversationRecvMessageOpt = (data, operationID = v4()) => {
1623
+ return this._invoker('setConversationRecvMessageOpt ', window.setConversation, [
1624
+ operationID,
1625
+ data.conversationID,
1626
+ JSON.stringify({
1627
+ recvMsgOpt: data.opt,
1628
+ }),
1629
+ ]);
1630
+ };
1631
+ this.searchLocalMessages = (data, operationID = v4()) => {
1632
+ return this._invoker('searchLocalMessages ', window.searchLocalMessages, [operationID, JSON.stringify(data)]);
1633
+ };
1634
+ this.addFriend = (data, operationID = v4()) => {
1635
+ return this._invoker('addFriend ', window.addFriend, [
1636
+ operationID,
1637
+ JSON.stringify(data),
1638
+ ]);
1639
+ };
1640
+ this.searchFriends = (data, operationID = v4()) => {
1641
+ return this._invoker('searchFriends ', window.searchFriends, [operationID, JSON.stringify(data)]);
1642
+ };
1643
+ this.getSpecifiedFriendsInfo = (data, operationID = v4()) => {
1644
+ return this._invoker('getSpecifiedFriendsInfo', window.getSpecifiedFriendsInfo, [operationID, JSON.stringify(data.friendUserIDList), data.filterBlack]);
1645
+ };
1646
+ this.getFriendApplicationListAsRecipient = (operationID = v4()) => {
1647
+ return this._invoker('getFriendApplicationListAsRecipient ', window.getFriendApplicationListAsRecipient, [operationID]);
1648
+ };
1649
+ this.getFriendApplicationListAsApplicant = (operationID = v4()) => {
1650
+ return this._invoker('getFriendApplicationListAsApplicant ', window.getFriendApplicationListAsApplicant, [operationID]);
1651
+ };
1652
+ this.getFriendList = (filterBlack = false, operationID = v4()) => {
1653
+ return this._invoker('getFriendList ', window.getFriendList, [operationID, filterBlack]);
1654
+ };
1655
+ this.getFriendListPage = (data, operationID = v4()) => {
1656
+ var _a;
1657
+ return this._invoker('getFriendListPage ', window.getFriendListPage, [operationID, data.offset, data.count, (_a = data.filterBlack) !== null && _a !== void 0 ? _a : false]);
1658
+ };
1659
+ this.updateFriends = (data, operationID = v4()) => {
1660
+ return this._invoker('updateFriends ', window.updateFriends, [
1661
+ operationID,
1662
+ JSON.stringify(data),
1663
+ ]);
1664
+ };
1665
+ this.setFriendRemark = (data, operationID = v4()) => {
1666
+ return this._invoker('setFriendRemark ', window.updateFriends, [
1667
+ operationID,
1668
+ JSON.stringify({
1669
+ friendUserIDs: [data.toUserID],
1670
+ remark: data.remark,
1671
+ }),
1672
+ ]);
1673
+ };
1674
+ this.pinFriends = (data, operationID = v4()) => {
1675
+ return this._invoker('pinFriends ', window.updateFriends, [
1676
+ operationID,
1677
+ JSON.stringify({
1678
+ friendUserIDs: data.toUserIDs,
1679
+ isPinned: data.isPinned,
1680
+ }),
1681
+ ]);
1682
+ };
1683
+ this.setFriendsEx = (data, operationID = v4()) => {
1684
+ return this._invoker('setFriendsEx ', window.updateFriends, [
1685
+ operationID,
1686
+ JSON.stringify({
1687
+ friendUserIDs: data.toUserIDs,
1688
+ ex: data.ex,
1689
+ }),
1690
+ data.ex,
1691
+ ]);
1692
+ };
1693
+ this.checkFriend = (data, operationID = v4()) => {
1694
+ return this._invoker('checkFriend', window.checkFriend, [
1695
+ operationID,
1696
+ JSON.stringify(data),
1697
+ ]);
1698
+ };
1699
+ this.acceptFriendApplication = (data, operationID = v4()) => {
1700
+ return this._invoker('acceptFriendApplication', window.acceptFriendApplication, [operationID, JSON.stringify(data)]);
1701
+ };
1702
+ this.refuseFriendApplication = (data, operationID = v4()) => {
1703
+ return this._invoker('refuseFriendApplication ', window.refuseFriendApplication, [operationID, JSON.stringify(data)]);
1704
+ };
1705
+ this.deleteFriend = (data, operationID = v4()) => {
1706
+ return this._invoker('deleteFriend ', window.deleteFriend, [
1707
+ operationID,
1708
+ data,
1709
+ ]);
1710
+ };
1711
+ this.addBlack = (data, operationID = v4()) => {
1712
+ var _a;
1713
+ return this._invoker('addBlack ', window.addBlack, [
1714
+ operationID,
1715
+ data.toUserID,
1716
+ (_a = data.ex) !== null && _a !== void 0 ? _a : '',
1717
+ ]);
1718
+ };
1719
+ this.removeBlack = (data, operationID = v4()) => {
1720
+ return this._invoker('removeBlack ', window.removeBlack, [
1721
+ operationID,
1722
+ data,
1723
+ ]);
1724
+ };
1725
+ this.getBlackList = (operationID = v4()) => {
1726
+ return this._invoker('getBlackList ', window.getBlackList, [operationID]);
1727
+ };
1728
+ this.inviteUserToGroup = (data, operationID = v4()) => {
1729
+ return this._invoker('inviteUserToGroup ', window.inviteUserToGroup, [
1730
+ operationID,
1731
+ data.groupID,
1732
+ data.reason,
1733
+ JSON.stringify(data.userIDList),
1734
+ ]);
1735
+ };
1736
+ this.kickGroupMember = (data, operationID = v4()) => {
1737
+ return this._invoker('kickGroupMember ', window.kickGroupMember, [
1738
+ operationID,
1739
+ data.groupID,
1740
+ data.reason,
1741
+ JSON.stringify(data.userIDList),
1742
+ ]);
1743
+ };
1744
+ this.isJoinGroup = (data, operationID = v4()) => {
1745
+ return this._invoker('isJoinGroup ', window.isJoinGroup, [
1746
+ operationID,
1747
+ data,
1748
+ ]);
1749
+ };
1750
+ this.getSpecifiedGroupMembersInfo = (data, operationID = v4()) => {
1751
+ return this._invoker('getSpecifiedGroupMembersInfo ', window.getSpecifiedGroupMembersInfo, [operationID, data.groupID, JSON.stringify(data.userIDList)]);
1752
+ };
1753
+ this.getUsersInGroup = (data, operationID = v4()) => {
1754
+ return this._invoker('getUsersInGroup ', window.getUsersInGroup, [
1755
+ operationID,
1756
+ data.groupID,
1757
+ JSON.stringify(data.userIDList),
1758
+ ]);
1759
+ };
1760
+ this.getGroupMemberListByJoinTimeFilter = (data, operationID = v4()) => {
1761
+ return this._invoker('getGroupMemberListByJoinTimeFilter ', window.getGroupMemberListByJoinTimeFilter, [
1762
+ operationID,
1763
+ data.groupID,
1764
+ data.offset,
1765
+ data.count,
1766
+ data.joinTimeBegin,
1767
+ data.joinTimeEnd,
1768
+ JSON.stringify(data.filterUserIDList),
1769
+ ]);
1770
+ };
1771
+ this.searchGroupMembers = (data, operationID = v4()) => {
1772
+ return this._invoker('searchGroupMembers ', window.searchGroupMembers, [operationID, JSON.stringify(data)]);
1773
+ };
1774
+ this.setGroupApplyMemberFriend = (data, operationID = v4()) => {
1775
+ return this._invoker('setGroupApplyMemberFriend ', window.setGroupInfo, [
1776
+ operationID,
1777
+ JSON.stringify({
1778
+ groupID: data.groupID,
1779
+ applyMemberFriend: data.rule,
1780
+ }),
1781
+ ]);
1782
+ };
1783
+ this.setGroupLookMemberInfo = (data, operationID = v4()) => {
1784
+ return this._invoker('setGroupLookMemberInfo ', window.setGroupInfo, [
1785
+ operationID,
1786
+ JSON.stringify({
1787
+ groupID: data.groupID,
1788
+ lookMemberInfo: data.rule,
1789
+ }),
1790
+ ]);
1791
+ };
1792
+ this.getJoinedGroupList = (operationID = v4()) => {
1793
+ return this._invoker('getJoinedGroupList ', window.getJoinedGroupList, [operationID]);
1794
+ };
1795
+ this.getJoinedGroupListPage = (data, operationID = v4()) => {
1796
+ return this._invoker('getJoinedGroupListPage ', window.getJoinedGroupListPage, [operationID, data.offset, data.count]);
1797
+ };
1798
+ this.createGroup = (data, operationID = v4()) => {
1799
+ return this._invoker('createGroup ', window.createGroup, [
1800
+ operationID,
1801
+ JSON.stringify(data),
1802
+ ]);
1803
+ };
1804
+ this.setGroupInfo = (data, operationID = v4()) => {
1805
+ return this._invoker('setGroupInfo ', window.setGroupInfo, [
1806
+ operationID,
1807
+ JSON.stringify(data),
1808
+ ]);
1809
+ };
1810
+ this.setGroupMemberNickname = (data, operationID = v4()) => {
1811
+ return this._invoker('setGroupMemberNickname ', window.setGroupMemberInfo, [
1812
+ operationID,
1813
+ JSON.stringify({
1814
+ groupID: data.groupID,
1815
+ userID: data.userID,
1816
+ nickname: data.groupMemberNickname,
1817
+ }),
1818
+ ]);
1819
+ };
1820
+ this.setGroupMemberInfo = (data, operationID = v4()) => {
1821
+ return this._invoker('setGroupMemberInfo ', window.setGroupMemberInfo, [
1822
+ operationID,
1823
+ JSON.stringify(data),
1824
+ ]);
1825
+ };
1826
+ this.joinGroup = (data, operationID = v4()) => {
1827
+ var _a;
1828
+ return this._invoker('joinGroup ', window.joinGroup, [
1829
+ operationID,
1830
+ data.groupID,
1831
+ data.reqMsg,
1832
+ data.joinSource,
1833
+ (_a = data.ex) !== null && _a !== void 0 ? _a : '',
1834
+ ]);
1835
+ };
1836
+ this.searchGroups = (data, operationID = v4()) => {
1837
+ return this._invoker('searchGroups ', window.searchGroups, [
1838
+ operationID,
1839
+ JSON.stringify(data),
1840
+ ]);
1841
+ };
1842
+ this.quitGroup = (data, operationID = v4()) => {
1843
+ return this._invoker('quitGroup ', window.quitGroup, [
1844
+ operationID,
1845
+ data,
1846
+ ]);
1847
+ };
1848
+ this.dismissGroup = (data, operationID = v4()) => {
1849
+ return this._invoker('dismissGroup ', window.dismissGroup, [
1850
+ operationID,
1851
+ data,
1852
+ ]);
1853
+ };
1854
+ this.changeGroupMute = (data, operationID = v4()) => {
1855
+ return this._invoker('changeGroupMute ', window.changeGroupMute, [
1856
+ operationID,
1857
+ data.groupID,
1858
+ data.isMute,
1859
+ ]);
1860
+ };
1861
+ this.changeGroupMemberMute = (data, operationID = v4()) => {
1862
+ return this._invoker('changeGroupMemberMute ', window.changeGroupMemberMute, [operationID, data.groupID, data.userID, data.mutedSeconds]);
1863
+ };
1864
+ this.transferGroupOwner = (data, operationID = v4()) => {
1865
+ return this._invoker('transferGroupOwner ', window.transferGroupOwner, [
1866
+ operationID,
1867
+ data.groupID,
1868
+ data.newOwnerUserID,
1869
+ ]);
1870
+ };
1871
+ this.getGroupApplicationListAsApplicant = (operationID = v4()) => {
1872
+ return this._invoker('getGroupApplicationListAsApplicant ', window.getGroupApplicationListAsApplicant, [operationID]);
1873
+ };
1874
+ this.getGroupApplicationListAsRecipient = (operationID = v4()) => {
1875
+ return this._invoker('getGroupApplicationListAsRecipient ', window.getGroupApplicationListAsRecipient, [operationID]);
1876
+ };
1877
+ this.acceptGroupApplication = (data, operationID = v4()) => {
1878
+ return this._invoker('acceptGroupApplication ', window.acceptGroupApplication, [operationID, data.groupID, data.fromUserID, data.handleMsg]);
1879
+ };
1880
+ this.refuseGroupApplication = (data, operationID = v4()) => {
1881
+ return this._invoker('refuseGroupApplication ', window.refuseGroupApplication, [operationID, data.groupID, data.fromUserID, data.handleMsg]);
1882
+ };
1883
+ this.resetConversationGroupAtType = (data, operationID = v4()) => {
1884
+ return this._invoker('resetConversationGroupAtType ', window.setConversation, [
1885
+ operationID,
1886
+ data,
1887
+ JSON.stringify({
1888
+ groupAtType: GroupAtType.AtNormal,
1889
+ }),
1890
+ ]);
1891
+ };
1892
+ this.setGroupMemberRoleLevel = (data, operationID = v4()) => {
1893
+ return this._invoker('setGroupMemberRoleLevel ', window.setGroupMemberInfo, [
1894
+ operationID,
1895
+ JSON.stringify({
1896
+ groupID: data.groupID,
1897
+ userID: data.userID,
1898
+ roleLevel: data.roleLevel,
1899
+ }),
1900
+ ]);
1901
+ };
1902
+ this.setGroupVerification = (data, operationID = v4()) => {
1903
+ return this._invoker('setGroupVerification ', window.setGroupInfo, [
1904
+ operationID,
1905
+ JSON.stringify({
1906
+ groupID: data.groupID,
1907
+ needVerification: data.verification,
1908
+ }),
1909
+ ]);
1910
+ };
1911
+ this.getGroupMemberOwnerAndAdmin = (data, operationID = v4()) => {
1912
+ return this._invoker('getGroupMemberOwnerAndAdmin ', window.getGroupMemberOwnerAndAdmin, [operationID, data]);
1913
+ };
1914
+ this.setGlobalRecvMessageOpt = (opt, operationID = v4()) => {
1915
+ return this._invoker('setGlobalRecvMessageOpt ', window.setSelfInfo, [
1916
+ operationID,
1917
+ JSON.stringify({ globalRecvMsgOpt: opt }),
1918
+ ]);
1919
+ };
1920
+ this.findMessageList = (data, operationID = v4()) => {
1921
+ return this._invoker('findMessageList ', window.findMessageList, [operationID, JSON.stringify(data)]);
1922
+ };
1923
+ this.uploadFile = (data, operationID = v4()) => {
1924
+ var _a;
1925
+ data.uuid = `${data.uuid}/${(_a = data.file) === null || _a === void 0 ? void 0 : _a.name}`;
1926
+ window.fileMapSet(data.uuid, data.file);
1927
+ return this._invoker('uploadFile ', window.uploadFile, [
1928
+ operationID,
1929
+ JSON.stringify({
1930
+ ...data,
1931
+ filepath: '',
1932
+ cause: '',
1933
+ }),
1934
+ ]);
1935
+ };
1936
+ this.subscribeUsersStatus = (data, operationID = v4()) => {
1937
+ return this._invoker('subscribeUsersStatus ', window.subscribeUsersStatus, [operationID, JSON.stringify(data)]);
1938
+ };
1939
+ this.unsubscribeUsersStatus = (data, operationID = v4()) => {
1940
+ return this._invoker('unsubscribeUsersStatus ', window.unsubscribeUsersStatus, [operationID, JSON.stringify(data)]);
1941
+ };
1942
+ this.getUserStatus = (operationID = v4()) => {
1943
+ return this._invoker('getUserStatus ', window.getUserStatus, [operationID]);
1944
+ };
1945
+ this.getSubscribeUsersStatus = (operationID = v4()) => {
1946
+ return this._invoker('getSubscribeUsersStatus ', window.getSubscribeUsersStatus, [operationID]);
1947
+ };
1948
+ this.signalingInvite = (data, operationID = v4()) => {
1949
+ return this._invoker('signalingInvite ', window.signalingInvite, [operationID, JSON.stringify(data)]);
1950
+ };
1951
+ this.signalingInviteInGroup = (data, operationID = v4()) => {
1952
+ return this._invoker('signalingInviteInGroup ', window.signalingInviteInGroup, [operationID, JSON.stringify(data)]);
1953
+ };
1954
+ this.signalingAccept = (data, operationID = v4()) => {
1955
+ return this._invoker('signalingAccept ', window.signalingAccept, [operationID, JSON.stringify(data)]);
1956
+ };
1957
+ this.signalingReject = (data, operationID = v4()) => {
1958
+ return this._invoker('signalingReject ', window.signalingReject, [
1959
+ operationID,
1960
+ JSON.stringify(data),
1961
+ ]);
1962
+ };
1963
+ this.signalingCancel = (data, operationID = v4()) => {
1964
+ return this._invoker('signalingCancel ', window.signalingCancel, [
1965
+ operationID,
1966
+ JSON.stringify(data),
1967
+ ]);
1968
+ };
1969
+ this.signalingHungUp = (data, operationID = v4()) => {
1970
+ return this._invoker('signalingHungUp ', window.signalingHungUp, [
1971
+ operationID,
1972
+ JSON.stringify(data),
1973
+ ]);
1974
+ };
1975
+ this.signalingGetRoomByGroupID = (groupID, operationID = v4()) => {
1976
+ return this._invoker('signalingGetRoomByGroupID ', window.signalingGetRoomByGroupID, [operationID, groupID]);
1977
+ };
1978
+ this.signalingGetTokenByRoomID = (roomID, operationID = v4()) => {
1979
+ return this._invoker('signalingGetTokenByRoomID ', window.signalingGetTokenByRoomID, [operationID, roomID]);
1980
+ };
1981
+ this.getSignalingInvitationInfoStartApp = (operationID = v4()) => {
1982
+ return this._invoker('getSignalingInvitationInfoStartApp ', window.getSignalingInvitationInfoStartApp, [operationID]);
1983
+ };
1984
+ this.signalingSendCustomSignal = (data, operationID = v4()) => {
1985
+ return this._invoker('signalingSendCustomSignal ', window.signalingSendCustomSignal, [operationID, data.customInfo, data.roomID]);
1986
+ };
1987
+ this.setConversationIsMsgDestruct = (data, operationID = v4()) => {
1988
+ return this._invoker('setConversationIsMsgDestruct ', window.setConversation, [
1989
+ operationID,
1990
+ data.conversationID,
1991
+ JSON.stringify({ isMsgDestruct: data.isMsgDestruct }),
1992
+ ]);
1993
+ };
1994
+ this.setConversationMsgDestructTime = (data, operationID = v4()) => {
1995
+ return this._invoker('setConversationMsgDestructTime ', window.setConversation, [
1996
+ operationID,
1997
+ data.conversationID,
1998
+ JSON.stringify({
1999
+ msgDestructTime: data.msgDestructTime,
2000
+ }),
2001
+ ]);
2002
+ };
2003
+ this.fileMapSet = (uuid, file) => window.fileMapSet(uuid, file);
2004
+ initDatabaseAPI(debug);
2005
+ this.isLogStandardOutput = debug;
2006
+ this.wasmInitializedPromise = initializeWasm(url);
2007
+ this.goExitPromise = getGoExitPromise();
2008
+ if (this.goExitPromise) {
2009
+ this.goExitPromise
2010
+ .then(() => {
2011
+ this._logWrap('SDK => wasm exist');
2012
+ })
2013
+ .catch(err => {
2014
+ this._logWrap('SDK => wasm with error ', err);
2015
+ })
2016
+ .finally(() => {
2017
+ this.goExisted = true;
2018
+ });
2019
+ }
2020
+ }
2021
+ _logWrap(...args) {
2022
+ if (this.isLogStandardOutput) {
2023
+ console.info(...args);
2024
+ }
2025
+ }
2026
+ _invoker(functionName, func, args, processor) {
2027
+ return new Promise(async (resolve, reject) => {
2028
+ 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;', '');
2029
+ let response = {
2030
+ operationID: args[0],
2031
+ event: (functionName.slice(0, 1).toUpperCase() +
2032
+ functionName.slice(1).toLowerCase()),
2033
+ };
2034
+ try {
2035
+ if (!getGO() || getGO().exited || this.goExisted) {
2036
+ throw 'wasm exist already, fail to run';
2037
+ }
2038
+ let data = await func(...args);
2039
+ if (processor) {
2040
+ this._logWrap(`%cSDK =>%c [OperationID:${args[0]}] (invoked by js) run ${functionName} with response before processor ${JSON.stringify(data)}`, logBoxStyleValue('#FFDC19'), '');
2041
+ data = processor(data);
2042
+ }
2043
+ if (this.tryParse) {
2044
+ try {
2045
+ data = JSON.parse(data);
2046
+ }
2047
+ catch (error) {
2048
+ // parse error
2049
+ }
2050
+ }
2051
+ response.data = data;
2052
+ resolve(response);
2053
+ }
2054
+ catch (error) {
2055
+ this._logWrap(`%cSDK =>%c [OperationID:${args[0]}] (invoked by js) run ${functionName} with error ${JSON.stringify(error)}`, logBoxStyleValue('#EE4245'), '');
2056
+ response = {
2057
+ ...response,
2058
+ ...error,
2059
+ };
2060
+ reject(response);
2061
+ }
2062
+ });
2063
+ }
2064
+ exportDB(operationID = v4()) {
2065
+ return this._invoker('exportDB', window.exportDB, [operationID]);
2066
+ }
2067
+ }
2068
+ let instance;
2069
+ function getSDK(config) {
2070
+ const { sqlWasmPath, coreWasmPath = '/openIM.wasm', debug = true, } = config || {};
2071
+ if (typeof window === 'undefined') {
2072
+ return {};
2073
+ }
2074
+ if (instance) {
2075
+ return instance;
2076
+ }
2077
+ instance = new SDK(coreWasmPath, debug);
2078
+ if (sqlWasmPath) {
2079
+ window.setSqlWasmPath(sqlWasmPath);
2080
+ }
2081
+ return instance;
2082
+ }
2083
+
2084
+ function decodeBase64(base64, enableUnicode) {
2085
+ var binaryString = atob(base64);
2086
+ if (enableUnicode) {
2087
+ var binaryView = new Uint8Array(binaryString.length);
2088
+ for (var i = 0, n = binaryString.length; i < n; ++i) {
2089
+ binaryView[i] = binaryString.charCodeAt(i);
2090
+ }
2091
+ return String.fromCharCode.apply(null, new Uint16Array(binaryView.buffer));
2092
+ }
2093
+ return binaryString;
2094
+ }
2095
+
2096
+ function createURL(base64, sourcemapArg, enableUnicodeArg) {
2097
+ var sourcemap = sourcemapArg === undefined ? null : sourcemapArg;
2098
+ var enableUnicode = enableUnicodeArg === undefined ? false : enableUnicodeArg;
2099
+ var source = decodeBase64(base64, enableUnicode);
2100
+ var start = source.indexOf('\n', 10) + 1;
2101
+ var body = source.substring(start) + (sourcemap ? '\/\/# sourceMappingURL=' + sourcemap : '');
2102
+ var blob = new Blob([body], { type: 'application/javascript' });
2103
+ return URL.createObjectURL(blob);
2104
+ }
2105
+
2106
+ function createBase64WorkerFactory(base64, sourcemapArg, enableUnicodeArg) {
2107
+ var url;
2108
+ return function WorkerFactory(options) {
2109
+ url = url || createURL(base64, sourcemapArg, enableUnicodeArg);
2110
+ return new Worker(url, options);
2111
+ };
2112
+ }
2113
+
2114
+ var WorkerFactory = createBase64WorkerFactory('Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwohZnVuY3Rpb24oKXsidXNlIHN0cmljdCI7bGV0IHQ9MzczNTkyODU1OTtjbGFzcyBle2NvbnN0cnVjdG9yKHQse2luaXRpYWxPZmZzZXQ6ZT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YWl0IHUoZSkpO2F3YWl0IHMucHJlZmV0Y2hGaXJzdEJsb2NrKDUwMCksYy5zZXQoZSxzKSx0LmludDMyKDApLHQuZmluYWxpemUoKX19KGUsaSxzKSxnKHQsZSk7YnJlYWt9Y2FzZSJ1bmxvY2tGaWxlIjp7bGV0IGk9dC5zdHJpbmcoKSxzPXQuaW50MzIoKTt0LmRvbmUoKSxhd2FpdCBkKGUsaSxzKSxnKHQsZSk7YnJlYWt9ZGVmYXVsdDp0aHJvdyBuZXcgRXJyb3IoIlVua25vd24gbWV0aG9kOiAiK2kpfX1zZWxmLm9ubWVzc2FnZT10PT57c3dpdGNoKHQuZGF0YS50eXBlKXtjYXNlImluaXQiOntsZXRbcyxyXT10LmRhdGEuYnVmZmVycztnKG5ldyBlKHMse25hbWU6ImFyZ3MiLGRlYnVnOiExfSksbmV3IGkocix7bmFtZToicmVzdWx0cyIsZGVidWc6ITF9KSk7YnJlYWt9fX19KCk7Cgo=', null, false);
2115
+
2116
+ var indexeddbMainThreadWorkerB24e7a21 = /*#__PURE__*/Object.freeze({
2117
+ __proto__: null,
2118
+ 'default': WorkerFactory
2119
+ });
2120
+
2121
+ export { AllowType, ApplicationHandleResult, CbEvents, GroupAtType, GroupJoinSource, GroupMemberFilter, GroupMemberRole, GroupMessageReaderFilter, GroupStatus, GroupType, GroupVerificationType, LogLevel, LoginStatus, MessageReceiveOptType, MessageStatus, MessageType, OnlineState, Platform, Relationship, SessionType, getSDK };