qiscus-sdk-core 2.14.2 → 2.15.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.
- package/dist/qiscus-sdk-core.js +4140 -3643
- package/dist/qiscus-sdk-core.js.map +1 -1
- package/dist/qiscus-sdk-core.min.js +5 -7
- package/dist/qiscus-sdk-core.min.js.map +1 -1
- package/lib/index.js +552 -485
- package/lib/lib/adapters/expired-token.js +5 -5
- package/lib/lib/adapters/http.js +32 -32
- package/lib/lib/adapters/mqtt.js +53 -24
- package/lib/lib/adapters/sync.js +86 -86
- package/package.json +4 -3
package/lib/lib/adapters/sync.js
CHANGED
|
@@ -46,7 +46,7 @@ function synchronizeFactory(getHttp, getInterval, getSync, getId, logger) {
|
|
|
46
46
|
function _generator() {
|
|
47
47
|
_generator = (0, _wrapAsyncGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee() {
|
|
48
48
|
var accumulatedInterval, interval, shouldSync;
|
|
49
|
-
return _regenerator["default"].wrap(function
|
|
49
|
+
return _regenerator["default"].wrap(function (_context) {
|
|
50
50
|
while (1) switch (_context.prev = _context.next) {
|
|
51
51
|
case 0:
|
|
52
52
|
accumulatedInterval = 0;
|
|
@@ -54,26 +54,26 @@ function synchronizeFactory(getHttp, getInterval, getSync, getId, logger) {
|
|
|
54
54
|
shouldSync = function shouldSync() {
|
|
55
55
|
return getHttp() != null && getSync();
|
|
56
56
|
};
|
|
57
|
-
case
|
|
57
|
+
case 1:
|
|
58
58
|
if (!true) {
|
|
59
|
-
_context.next =
|
|
59
|
+
_context.next = 4;
|
|
60
60
|
break;
|
|
61
61
|
}
|
|
62
62
|
accumulatedInterval += interval;
|
|
63
63
|
if (!(accumulatedInterval >= getInterval() && shouldSync())) {
|
|
64
|
-
_context.next =
|
|
64
|
+
_context.next = 2;
|
|
65
65
|
break;
|
|
66
66
|
}
|
|
67
67
|
accumulatedInterval = 0;
|
|
68
|
-
_context.next =
|
|
68
|
+
_context.next = 2;
|
|
69
69
|
return synchronize(getId());
|
|
70
|
-
case
|
|
71
|
-
_context.next = 11;
|
|
72
|
-
return (0, _awaitAsyncGenerator2["default"])(sleep(interval));
|
|
73
|
-
case 11:
|
|
70
|
+
case 2:
|
|
74
71
|
_context.next = 3;
|
|
72
|
+
return (0, _awaitAsyncGenerator2["default"])(sleep(interval));
|
|
73
|
+
case 3:
|
|
74
|
+
_context.next = 1;
|
|
75
75
|
break;
|
|
76
|
-
case
|
|
76
|
+
case 4:
|
|
77
77
|
case "end":
|
|
78
78
|
return _context.stop();
|
|
79
79
|
}
|
|
@@ -93,20 +93,20 @@ function synchronizeFactory(getHttp, getInterval, getSync, getId, logger) {
|
|
|
93
93
|
},
|
|
94
94
|
run: function run() {
|
|
95
95
|
return (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee2() {
|
|
96
|
-
var _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, result, messageId, messages;
|
|
97
|
-
return _regenerator["default"].wrap(function
|
|
96
|
+
var _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, result, messageId, messages, _t;
|
|
97
|
+
return _regenerator["default"].wrap(function (_context2) {
|
|
98
98
|
while (1) switch (_context2.prev = _context2.next) {
|
|
99
99
|
case 0:
|
|
100
100
|
_iteratorAbruptCompletion = false;
|
|
101
101
|
_didIteratorError = false;
|
|
102
|
-
_context2.prev =
|
|
102
|
+
_context2.prev = 1;
|
|
103
103
|
_iterator = _asyncIterator(generator());
|
|
104
|
-
case
|
|
105
|
-
_context2.next =
|
|
104
|
+
case 2:
|
|
105
|
+
_context2.next = 3;
|
|
106
106
|
return _iterator.next();
|
|
107
|
-
case
|
|
107
|
+
case 3:
|
|
108
108
|
if (!(_iteratorAbruptCompletion = !(_step = _context2.sent).done)) {
|
|
109
|
-
_context2.next =
|
|
109
|
+
_context2.next = 5;
|
|
110
110
|
break;
|
|
111
111
|
}
|
|
112
112
|
result = _step.value;
|
|
@@ -126,43 +126,43 @@ function synchronizeFactory(getHttp, getInterval, getSync, getId, logger) {
|
|
|
126
126
|
logger('error when sync', e.message);
|
|
127
127
|
console.log('error when sync', e);
|
|
128
128
|
}
|
|
129
|
-
case
|
|
129
|
+
case 4:
|
|
130
130
|
_iteratorAbruptCompletion = false;
|
|
131
|
-
_context2.next =
|
|
131
|
+
_context2.next = 2;
|
|
132
132
|
break;
|
|
133
|
-
case
|
|
134
|
-
_context2.next =
|
|
133
|
+
case 5:
|
|
134
|
+
_context2.next = 7;
|
|
135
135
|
break;
|
|
136
|
-
case
|
|
137
|
-
_context2.prev =
|
|
138
|
-
|
|
136
|
+
case 6:
|
|
137
|
+
_context2.prev = 6;
|
|
138
|
+
_t = _context2["catch"](1);
|
|
139
139
|
_didIteratorError = true;
|
|
140
|
-
_iteratorError =
|
|
141
|
-
case
|
|
142
|
-
_context2.prev =
|
|
143
|
-
_context2.prev =
|
|
140
|
+
_iteratorError = _t;
|
|
141
|
+
case 7:
|
|
142
|
+
_context2.prev = 7;
|
|
143
|
+
_context2.prev = 8;
|
|
144
144
|
if (!(_iteratorAbruptCompletion && _iterator["return"] != null)) {
|
|
145
|
-
_context2.next =
|
|
145
|
+
_context2.next = 9;
|
|
146
146
|
break;
|
|
147
147
|
}
|
|
148
|
-
_context2.next =
|
|
148
|
+
_context2.next = 9;
|
|
149
149
|
return _iterator["return"]();
|
|
150
|
-
case
|
|
151
|
-
_context2.prev =
|
|
150
|
+
case 9:
|
|
151
|
+
_context2.prev = 9;
|
|
152
152
|
if (!_didIteratorError) {
|
|
153
|
-
_context2.next =
|
|
153
|
+
_context2.next = 10;
|
|
154
154
|
break;
|
|
155
155
|
}
|
|
156
156
|
throw _iteratorError;
|
|
157
|
-
case
|
|
158
|
-
return _context2.finish(
|
|
159
|
-
case
|
|
160
|
-
return _context2.finish(
|
|
161
|
-
case
|
|
157
|
+
case 10:
|
|
158
|
+
return _context2.finish(9);
|
|
159
|
+
case 11:
|
|
160
|
+
return _context2.finish(7);
|
|
161
|
+
case 12:
|
|
162
162
|
case "end":
|
|
163
163
|
return _context2.stop();
|
|
164
164
|
}
|
|
165
|
-
}, _callee2, null, [[
|
|
165
|
+
}, _callee2, null, [[1, 6, 7, 12], [8,, 9, 11]]);
|
|
166
166
|
}))();
|
|
167
167
|
}
|
|
168
168
|
};
|
|
@@ -214,7 +214,7 @@ function synchronizeEventFactory(getHttp, getInterval, getSync, getId, logger) {
|
|
|
214
214
|
function _generator2() {
|
|
215
215
|
_generator2 = (0, _wrapAsyncGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee3() {
|
|
216
216
|
var accumulatedInterval, interval, shouldSync;
|
|
217
|
-
return _regenerator["default"].wrap(function
|
|
217
|
+
return _regenerator["default"].wrap(function (_context3) {
|
|
218
218
|
while (1) switch (_context3.prev = _context3.next) {
|
|
219
219
|
case 0:
|
|
220
220
|
accumulatedInterval = 0;
|
|
@@ -222,26 +222,26 @@ function synchronizeEventFactory(getHttp, getInterval, getSync, getId, logger) {
|
|
|
222
222
|
shouldSync = function shouldSync() {
|
|
223
223
|
return getHttp() != null && getSync();
|
|
224
224
|
};
|
|
225
|
-
case
|
|
225
|
+
case 1:
|
|
226
226
|
if (!true) {
|
|
227
|
-
_context3.next =
|
|
227
|
+
_context3.next = 4;
|
|
228
228
|
break;
|
|
229
229
|
}
|
|
230
230
|
accumulatedInterval += interval;
|
|
231
231
|
if (!(accumulatedInterval >= getInterval() && shouldSync())) {
|
|
232
|
-
_context3.next =
|
|
232
|
+
_context3.next = 2;
|
|
233
233
|
break;
|
|
234
234
|
}
|
|
235
235
|
accumulatedInterval = 0;
|
|
236
|
-
_context3.next =
|
|
236
|
+
_context3.next = 2;
|
|
237
237
|
return synchronize(getId());
|
|
238
|
-
case
|
|
239
|
-
_context3.next = 11;
|
|
240
|
-
return (0, _awaitAsyncGenerator2["default"])(sleep(interval));
|
|
241
|
-
case 11:
|
|
238
|
+
case 2:
|
|
242
239
|
_context3.next = 3;
|
|
240
|
+
return (0, _awaitAsyncGenerator2["default"])(sleep(interval));
|
|
241
|
+
case 3:
|
|
242
|
+
_context3.next = 1;
|
|
243
243
|
break;
|
|
244
|
-
case
|
|
244
|
+
case 4:
|
|
245
245
|
case "end":
|
|
246
246
|
return _context3.stop();
|
|
247
247
|
}
|
|
@@ -261,20 +261,20 @@ function synchronizeEventFactory(getHttp, getInterval, getSync, getId, logger) {
|
|
|
261
261
|
},
|
|
262
262
|
run: function run() {
|
|
263
263
|
return (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee4() {
|
|
264
|
-
var _iteratorAbruptCompletion2, _didIteratorError2, _iteratorError2, _iterator2, _step2, result, eventId;
|
|
265
|
-
return _regenerator["default"].wrap(function
|
|
264
|
+
var _iteratorAbruptCompletion2, _didIteratorError2, _iteratorError2, _iterator2, _step2, result, eventId, _t2;
|
|
265
|
+
return _regenerator["default"].wrap(function (_context4) {
|
|
266
266
|
while (1) switch (_context4.prev = _context4.next) {
|
|
267
267
|
case 0:
|
|
268
268
|
_iteratorAbruptCompletion2 = false;
|
|
269
269
|
_didIteratorError2 = false;
|
|
270
|
-
_context4.prev =
|
|
270
|
+
_context4.prev = 1;
|
|
271
271
|
_iterator2 = _asyncIterator(generator());
|
|
272
|
-
case
|
|
273
|
-
_context4.next =
|
|
272
|
+
case 2:
|
|
273
|
+
_context4.next = 3;
|
|
274
274
|
return _iterator2.next();
|
|
275
|
-
case
|
|
275
|
+
case 3:
|
|
276
276
|
if (!(_iteratorAbruptCompletion2 = !(_step2 = _context4.sent).done)) {
|
|
277
|
-
_context4.next =
|
|
277
|
+
_context4.next = 5;
|
|
278
278
|
break;
|
|
279
279
|
}
|
|
280
280
|
result = _step2.value;
|
|
@@ -298,43 +298,43 @@ function synchronizeEventFactory(getHttp, getInterval, getSync, getId, logger) {
|
|
|
298
298
|
} catch (e) {
|
|
299
299
|
logger('error when sync event', e.message);
|
|
300
300
|
}
|
|
301
|
-
case
|
|
301
|
+
case 4:
|
|
302
302
|
_iteratorAbruptCompletion2 = false;
|
|
303
|
-
_context4.next =
|
|
303
|
+
_context4.next = 2;
|
|
304
304
|
break;
|
|
305
|
-
case
|
|
306
|
-
_context4.next =
|
|
305
|
+
case 5:
|
|
306
|
+
_context4.next = 7;
|
|
307
307
|
break;
|
|
308
|
-
case
|
|
309
|
-
_context4.prev =
|
|
310
|
-
|
|
308
|
+
case 6:
|
|
309
|
+
_context4.prev = 6;
|
|
310
|
+
_t2 = _context4["catch"](1);
|
|
311
311
|
_didIteratorError2 = true;
|
|
312
|
-
_iteratorError2 =
|
|
313
|
-
case
|
|
314
|
-
_context4.prev =
|
|
315
|
-
_context4.prev =
|
|
312
|
+
_iteratorError2 = _t2;
|
|
313
|
+
case 7:
|
|
314
|
+
_context4.prev = 7;
|
|
315
|
+
_context4.prev = 8;
|
|
316
316
|
if (!(_iteratorAbruptCompletion2 && _iterator2["return"] != null)) {
|
|
317
|
-
_context4.next =
|
|
317
|
+
_context4.next = 9;
|
|
318
318
|
break;
|
|
319
319
|
}
|
|
320
|
-
_context4.next =
|
|
320
|
+
_context4.next = 9;
|
|
321
321
|
return _iterator2["return"]();
|
|
322
|
-
case
|
|
323
|
-
_context4.prev =
|
|
322
|
+
case 9:
|
|
323
|
+
_context4.prev = 9;
|
|
324
324
|
if (!_didIteratorError2) {
|
|
325
|
-
_context4.next =
|
|
325
|
+
_context4.next = 10;
|
|
326
326
|
break;
|
|
327
327
|
}
|
|
328
328
|
throw _iteratorError2;
|
|
329
|
-
case
|
|
330
|
-
return _context4.finish(
|
|
331
|
-
case
|
|
332
|
-
return _context4.finish(
|
|
333
|
-
case
|
|
329
|
+
case 10:
|
|
330
|
+
return _context4.finish(9);
|
|
331
|
+
case 11:
|
|
332
|
+
return _context4.finish(7);
|
|
333
|
+
case 12:
|
|
334
334
|
case "end":
|
|
335
335
|
return _context4.stop();
|
|
336
336
|
}
|
|
337
|
-
}, _callee4, null, [[
|
|
337
|
+
}, _callee4, null, [[1, 6, 7, 12], [8,, 9, 11]]);
|
|
338
338
|
}))();
|
|
339
339
|
}
|
|
340
340
|
};
|
|
@@ -423,13 +423,13 @@ function SyncAdapter(getHttpAdapter, _ref) {
|
|
|
423
423
|
return (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee5() {
|
|
424
424
|
var _result$messages, _result$lastMessageId;
|
|
425
425
|
var id, result, messages, lastMessageId, _iterator3, _step3, message;
|
|
426
|
-
return _regenerator["default"].wrap(function
|
|
426
|
+
return _regenerator["default"].wrap(function (_context5) {
|
|
427
427
|
while (1) switch (_context5.prev = _context5.next) {
|
|
428
428
|
case 0:
|
|
429
429
|
id = lastCommentId();
|
|
430
|
-
_context5.next =
|
|
430
|
+
_context5.next = 1;
|
|
431
431
|
return syncFactory.synchronize(id);
|
|
432
|
-
case
|
|
432
|
+
case 1:
|
|
433
433
|
result = _context5.sent;
|
|
434
434
|
messages = (_result$messages = result === null || result === void 0 ? void 0 : result.messages) !== null && _result$messages !== void 0 ? _result$messages : [];
|
|
435
435
|
lastMessageId = (_result$lastMessageId = result === null || result === void 0 ? void 0 : result.lastMessageId) !== null && _result$lastMessageId !== void 0 ? _result$lastMessageId : -1;
|
|
@@ -447,7 +447,7 @@ function SyncAdapter(getHttpAdapter, _ref) {
|
|
|
447
447
|
if (lastMessageId > 0) {
|
|
448
448
|
emitter.emit('last-message-id.new', lastMessageId);
|
|
449
449
|
}
|
|
450
|
-
case
|
|
450
|
+
case 2:
|
|
451
451
|
case "end":
|
|
452
452
|
return _context5.stop();
|
|
453
453
|
}
|
|
@@ -457,12 +457,12 @@ function SyncAdapter(getHttpAdapter, _ref) {
|
|
|
457
457
|
synchronizeEvent: function synchronizeEvent() {
|
|
458
458
|
return (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee6() {
|
|
459
459
|
var result, eventId;
|
|
460
|
-
return _regenerator["default"].wrap(function
|
|
460
|
+
return _regenerator["default"].wrap(function (_context6) {
|
|
461
461
|
while (1) switch (_context6.prev = _context6.next) {
|
|
462
462
|
case 0:
|
|
463
|
-
_context6.next =
|
|
463
|
+
_context6.next = 1;
|
|
464
464
|
return syncEventFactory.synchronize(lastEventId);
|
|
465
|
-
case
|
|
465
|
+
case 1:
|
|
466
466
|
result = _context6.sent;
|
|
467
467
|
try {
|
|
468
468
|
eventId = result.lastId;
|
|
@@ -484,7 +484,7 @@ function SyncAdapter(getHttpAdapter, _ref) {
|
|
|
484
484
|
} catch (e) {
|
|
485
485
|
logger('error when sync event', e.message);
|
|
486
486
|
}
|
|
487
|
-
case
|
|
487
|
+
case 2:
|
|
488
488
|
case "end":
|
|
489
489
|
return _context6.stop();
|
|
490
490
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "qiscus-sdk-core",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.15.0",
|
|
4
4
|
"description": "Qiscus Web SDK Core",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -28,7 +28,8 @@
|
|
|
28
28
|
"prepublishOnly": "npm-run-all clean build",
|
|
29
29
|
"serve": "http-server -p 1234 -c-1 dist",
|
|
30
30
|
"dev:serve": "run-p serve watch",
|
|
31
|
-
"release:patch": "np patch --any-branch --yolo"
|
|
31
|
+
"release:patch": "np patch --any-branch --yolo",
|
|
32
|
+
"release:minor": "np minor --any-branch --yolo"
|
|
32
33
|
},
|
|
33
34
|
"devDependencies": {
|
|
34
35
|
"@babel/cli": "^7.10.5",
|
|
@@ -95,5 +96,5 @@
|
|
|
95
96
|
"engines": {
|
|
96
97
|
"node": "16.15.1"
|
|
97
98
|
},
|
|
98
|
-
"packageManager": "pnpm@
|
|
99
|
+
"packageManager": "pnpm@10.32.1+sha512.a706938f0e89ac1456b6563eab4edf1d1faf3368d1191fc5c59790e96dc918e4456ab2e67d613de1043d2e8c81f87303e6b40d4ffeca9df15ef1ad567348f2be"
|
|
99
100
|
}
|