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