@droppii-org/wasm-client-sdk 0.1.0

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