qiscus-sdk-core 2.13.3 → 2.14.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 +451 -230
- package/dist/qiscus-sdk-core.js.map +1 -1
- package/dist/qiscus-sdk-core.min.js +3 -3
- package/dist/qiscus-sdk-core.min.js.map +1 -1
- package/lib/index.js +233 -106
- package/lib/lib/adapters/custom-event.js +3 -3
- package/lib/lib/adapters/http.js +156 -82
- package/lib/lib/adapters/mqtt.js +26 -23
- package/lib/lib/adapters/sync.js +20 -7
- package/package.json +1 -1
package/dist/qiscus-sdk-core.js
CHANGED
|
@@ -29966,7 +29966,7 @@ function extend() {
|
|
|
29966
29966
|
/*! exports provided: name, version, description, license, main, browser, unpkg, files, scripts, devDependencies, dependencies, babel, prettier, engines, packageManager, default */
|
|
29967
29967
|
/***/ (function(module) {
|
|
29968
29968
|
|
|
29969
|
-
module.exports = JSON.parse("{\"name\":\"qiscus-sdk-core\",\"version\":\"2.
|
|
29969
|
+
module.exports = JSON.parse("{\"name\":\"qiscus-sdk-core\",\"version\":\"2.14.0\",\"description\":\"Qiscus Web SDK Core\",\"license\":\"MIT\",\"main\":\"lib/index.js\",\"browser\":\"dist/qiscus-sdk-core.min.js\",\"unpkg\":\"dist/qiscus-sdk-core.min.js\",\"files\":[\"lib\",\"dist\"],\"scripts\":{\"build\":\"npm-run-all --parallel build:node build:web build:web:dev\",\"build:dev\":\"npm-run-all --parallel build:node build:web:dev\",\"build:dev:watch\":\"npm-run-all --parallel build:web:watch serve\",\"build:node\":\"babel -d lib src\",\"build:node:watch\":\"babel -w -d lib src\",\"build:web\":\"webpack --env.production --env.target=web\",\"build:web:dev\":\"webpack --env.development --env.target=web\",\"build:web:watch\":\"webpack --env.development --env.target=web --watch\",\"dev\":\"webpack --env.development --progress --colors --watch\",\"watch\":\"npm-run-all build:web:watch build:node:watch\",\"test\":\"mocha --require @babel/register --colors 'test/**/*test.js'\",\"test:watch\":\"npm run test -- -w\",\"clean\":\"rimraf dist lib\",\"preversion\":\"npm-run-all clean build\",\"prepublishOnly\":\"npm-run-all clean build\",\"serve\":\"http-server -p 1234 -c-1 dist\",\"dev:serve\":\"run-p serve watch\",\"release:patch\":\"np patch --any-branch --yolo\"},\"devDependencies\":{\"@babel/cli\":\"^7.10.5\",\"@babel/core\":\"^7.11.4\",\"@babel/plugin-proposal-class-properties\":\"^7.10.4\",\"@babel/plugin-transform-runtime\":\"^7.11.0\",\"@babel/polyfill\":\"^7.10.4\",\"@babel/preset-env\":\"^7.11.0\",\"@babel/register\":\"^7.10.5\",\"@commitlint/cli\":\"^8.3.5\",\"@commitlint/config-conventional\":\"^8.3.4\",\"babel-eslint\":\"^8.2.6\",\"babel-loader\":\"^8.0.6\",\"babel-plugin-add-module-exports\":\"^1.0.2\",\"babel-plugin-date-fns\":\"^0.1.0\",\"chai\":\"^4.2.0\",\"chai-spies\":\"^1.0.0\",\"eslint\":\"5.0.0\",\"eslint-config-standard\":\"^12.0.0\",\"eslint-loader\":\"^2.2.1\",\"eslint-plugin-import\":\"^2.22.0\",\"eslint-plugin-node\":\"^8.0.1\",\"eslint-plugin-promise\":\"^4.2.1\",\"eslint-plugin-standard\":\"^4.0.1\",\"http-server\":\"^0.12.3\",\"mocha\":\"^5.2.0\",\"np\":\"^8.0.4\",\"npm-run-all\":\"^4.1.5\",\"rimraf\":\"^2.7.1\",\"serve\":\"^12.0.0\",\"webpack\":\"^4.44.1\",\"webpack-cli\":\"^3.3.12\"},\"dependencies\":{\"@babel/runtime\":\"^7.11.2\",\"date-fns\":\"^1.30.1\",\"is_js\":\"^0.9.0\",\"lodash.debounce\":\"^4.0.8\",\"lodash.throttle\":\"^4.1.1\",\"mitt\":\"^1.2.0\",\"mqtt\":\"~4.2.6\",\"superagent\":\"^3.8.3\"},\"babel\":{\"presets\":[[\"@babel/preset-env\",{\"modules\":\"auto\"}]],\"plugins\":[\"@babel/plugin-transform-runtime\",\"@babel/plugin-proposal-class-properties\",\"babel-plugin-add-module-exports\"]},\"prettier\":{\"semi\":false,\"singleQuote\":true,\"trailingComma\":\"es5\"},\"engines\":{\"node\":\"16.15.1\"},\"packageManager\":\"pnpm@8.15.9\"}");
|
|
29970
29970
|
|
|
29971
29971
|
/***/ }),
|
|
29972
29972
|
|
|
@@ -30067,6 +30067,9 @@ var QiscusSDK = /*#__PURE__*/function () {
|
|
|
30067
30067
|
function QiscusSDK() {
|
|
30068
30068
|
var _this = this;
|
|
30069
30069
|
_babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_2___default()(this, QiscusSDK);
|
|
30070
|
+
_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_4___default()(this, "_pendingComments", []);
|
|
30071
|
+
// count of how much does a comment has been retried
|
|
30072
|
+
_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_4___default()(this, "_pendingCommentsCount", {});
|
|
30070
30073
|
_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_4___default()(this, "_readComment", function (roomId, commentId) {
|
|
30071
30074
|
return _this._updateStatus(roomId, commentId);
|
|
30072
30075
|
});
|
|
@@ -30478,9 +30481,14 @@ var QiscusSDK = /*#__PURE__*/function () {
|
|
|
30478
30481
|
_this2.events.emit('room-cleared', room);
|
|
30479
30482
|
});
|
|
30480
30483
|
});
|
|
30484
|
+
this.syncAdapter.on('synchronize', function () {
|
|
30485
|
+
_this2._pendingComments.forEach(function (m) {
|
|
30486
|
+
return _this2._retrySendComment(m);
|
|
30487
|
+
});
|
|
30488
|
+
});
|
|
30481
30489
|
this.customEventAdapter = Object(_lib_adapters_custom_event__WEBPACK_IMPORTED_MODULE_18__["default"])(this.realtimeAdapter, this.user_id);
|
|
30482
30490
|
this.setEventListeners();
|
|
30483
|
-
case
|
|
30491
|
+
case 56:
|
|
30484
30492
|
case "end":
|
|
30485
30493
|
return _context3.stop();
|
|
30486
30494
|
}
|
|
@@ -30657,6 +30665,9 @@ var QiscusSDK = /*#__PURE__*/function () {
|
|
|
30657
30665
|
version: _this3.version,
|
|
30658
30666
|
getCustomHeader: function getCustomHeader() {
|
|
30659
30667
|
return _this3._customHeader;
|
|
30668
|
+
},
|
|
30669
|
+
expiredTokenAdapterGetter: function expiredTokenAdapterGetter() {
|
|
30670
|
+
return _this3.expiredTokenAdapter;
|
|
30660
30671
|
}
|
|
30661
30672
|
});
|
|
30662
30673
|
_this3.HTTPAdapter.setToken(_this3.userData.token);
|
|
@@ -31621,7 +31632,7 @@ var QiscusSDK = /*#__PURE__*/function () {
|
|
|
31621
31632
|
}, {
|
|
31622
31633
|
key: "sendComment",
|
|
31623
31634
|
value: (function () {
|
|
31624
|
-
var _sendComment = _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_5___default.a.mark(function
|
|
31635
|
+
var _sendComment = _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_5___default.a.mark(function _callee15(topicId, commentMessage, uniqueId) {
|
|
31625
31636
|
var _this13 = this;
|
|
31626
31637
|
var type,
|
|
31627
31638
|
payload,
|
|
@@ -31633,13 +31644,23 @@ var QiscusSDK = /*#__PURE__*/function () {
|
|
|
31633
31644
|
repliedMessage,
|
|
31634
31645
|
extrasToBeSubmitted,
|
|
31635
31646
|
messageData,
|
|
31636
|
-
|
|
31637
|
-
|
|
31638
|
-
|
|
31647
|
+
sendComment,
|
|
31648
|
+
_this$options$comment,
|
|
31649
|
+
_this$options,
|
|
31650
|
+
res,
|
|
31651
|
+
commentIndex,
|
|
31652
|
+
_error$message$toLowe,
|
|
31653
|
+
_error$message,
|
|
31654
|
+
whitelistedErrorStatus,
|
|
31655
|
+
message,
|
|
31656
|
+
isOffline,
|
|
31657
|
+
_args15 = arguments;
|
|
31658
|
+
return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_5___default.a.wrap(function _callee15$(_context15) {
|
|
31659
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
31639
31660
|
case 0:
|
|
31640
|
-
type =
|
|
31641
|
-
payload =
|
|
31642
|
-
extras =
|
|
31661
|
+
type = _args15.length > 3 && _args15[3] !== undefined ? _args15[3] : 'text';
|
|
31662
|
+
payload = _args15.length > 4 ? _args15[4] : undefined;
|
|
31663
|
+
extras = _args15.length > 5 ? _args15[5] : undefined;
|
|
31643
31664
|
self = this; // set extra data, etc
|
|
31644
31665
|
if (self.options.prePostCommentCallback) {
|
|
31645
31666
|
self.options.prePostCommentCallback(commentMessage);
|
|
@@ -31655,6 +31676,7 @@ var QiscusSDK = /*#__PURE__*/function () {
|
|
|
31655
31676
|
}
|
|
31656
31677
|
self.pendingCommentId--;
|
|
31657
31678
|
commentData = {
|
|
31679
|
+
room_id: topicId,
|
|
31658
31680
|
message: commentMessage,
|
|
31659
31681
|
username_as: this.username,
|
|
31660
31682
|
username_real: this.user_id,
|
|
@@ -31683,64 +31705,169 @@ var QiscusSDK = /*#__PURE__*/function () {
|
|
|
31683
31705
|
pendingComment.payload = parsedPayload;
|
|
31684
31706
|
}
|
|
31685
31707
|
extrasToBeSubmitted = extras || self.extras;
|
|
31686
|
-
|
|
31708
|
+
_context15.next = 13;
|
|
31687
31709
|
return this._hookAdapter.trigger(_lib_adapters_hook__WEBPACK_IMPORTED_MODULE_23__["Hooks"].MESSAGE_BEFORE_SENT, _objectSpread(_objectSpread({}, pendingComment), {}, {
|
|
31688
31710
|
extras: extrasToBeSubmitted
|
|
31689
31711
|
}));
|
|
31690
31712
|
case 13:
|
|
31691
|
-
messageData =
|
|
31713
|
+
messageData = _context15.sent;
|
|
31692
31714
|
messageData = self.prepareCommentToBeSubmitted(messageData);
|
|
31693
31715
|
if (self.selected) self.selected.comments.push(messageData);
|
|
31694
|
-
|
|
31695
|
-
|
|
31696
|
-
|
|
31697
|
-
|
|
31716
|
+
sendComment = function sendComment() {
|
|
31717
|
+
return _this13.userAdapter.postComment('' + topicId, messageData.message, messageData.unique_id, messageData.type, messageData.payload, messageData.extras);
|
|
31718
|
+
};
|
|
31719
|
+
_context15.prev = 17;
|
|
31720
|
+
_context15.next = 20;
|
|
31721
|
+
return sendComment();
|
|
31722
|
+
case 20:
|
|
31723
|
+
res = _context15.sent;
|
|
31724
|
+
_context15.next = 23;
|
|
31725
|
+
return this._hookAdapter.trigger(_lib_adapters_hook__WEBPACK_IMPORTED_MODULE_23__["Hooks"].MESSAGE_BEFORE_RECEIVED, res);
|
|
31726
|
+
case 23:
|
|
31727
|
+
res = _context15.sent;
|
|
31728
|
+
Object.assign(messageData, res);
|
|
31729
|
+
if (self.selected) {
|
|
31730
|
+
_context15.next = 27;
|
|
31731
|
+
break;
|
|
31732
|
+
}
|
|
31733
|
+
return _context15.abrupt("return", Promise.resolve(messageData));
|
|
31734
|
+
case 27:
|
|
31735
|
+
// When the posting succeeded, we mark the Comment as sent,
|
|
31736
|
+
// so all the interested party can be notified.
|
|
31737
|
+
messageData.markAsSent();
|
|
31738
|
+
messageData.id = res.id;
|
|
31739
|
+
messageData.before_id = res.comment_before_id;
|
|
31740
|
+
// update the timestamp also then re-sort the comment list
|
|
31741
|
+
messageData.unix_timestamp = res.unix_timestamp;
|
|
31742
|
+
(_this$options$comment = (_this$options = this.options).commentSentCallback) === null || _this$options$comment === void 0 || _this$options$comment.call(_this$options, {
|
|
31743
|
+
comment: messageData
|
|
31744
|
+
});
|
|
31745
|
+
self.events.emit('comment-sent', messageData);
|
|
31746
|
+
self.sortComments();
|
|
31747
|
+
commentIndex = self._pendingComments.findIndex(function (c) {
|
|
31748
|
+
return c.unique_id === messageData.unique_id;
|
|
31749
|
+
});
|
|
31750
|
+
if (commentIndex > -1) {
|
|
31751
|
+
self._pendingComments.splice(commentIndex, 1);
|
|
31752
|
+
}
|
|
31753
|
+
return _context15.abrupt("return", messageData);
|
|
31754
|
+
case 39:
|
|
31755
|
+
_context15.prev = 39;
|
|
31756
|
+
_context15.t0 = _context15["catch"](17);
|
|
31757
|
+
messageData.markAsFailed();
|
|
31758
|
+
// From superagent: `https://forwardemail.github.io/superagent/#retrying-requests`
|
|
31759
|
+
whitelistedErrorStatus = [undefined, 408, 413, 429, 500, 502, 503, 504, 521, 522, 524];
|
|
31760
|
+
message = (_error$message$toLowe = (_error$message = _context15.t0.message) === null || _error$message === void 0 ? void 0 : _error$message.toLowerCase()) !== null && _error$message$toLowe !== void 0 ? _error$message$toLowe : '';
|
|
31761
|
+
isOffline = message.includes('offline');
|
|
31762
|
+
if (whitelistedErrorStatus.includes(_context15.t0.status) || isOffline) {
|
|
31763
|
+
this._pendingComments.push(messageData);
|
|
31764
|
+
this.logger('Failed sending comment', _context15.t0);
|
|
31765
|
+
}
|
|
31766
|
+
return _context15.abrupt("return", Promise.reject(_context15.t0));
|
|
31767
|
+
case 47:
|
|
31768
|
+
case "end":
|
|
31769
|
+
return _context15.stop();
|
|
31770
|
+
}
|
|
31771
|
+
}, _callee15, this, [[17, 39]]);
|
|
31772
|
+
}));
|
|
31773
|
+
function sendComment(_x12, _x13, _x14) {
|
|
31774
|
+
return _sendComment.apply(this, arguments);
|
|
31775
|
+
}
|
|
31776
|
+
return sendComment;
|
|
31777
|
+
}())
|
|
31778
|
+
}, {
|
|
31779
|
+
key: "_retrySendComment",
|
|
31780
|
+
value: function () {
|
|
31781
|
+
var _retrySendComment2 = _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_5___default.a.mark(function _callee17(comment) {
|
|
31782
|
+
var _this$_pendingComment,
|
|
31783
|
+
_this14 = this;
|
|
31784
|
+
var _this$options$comment2, _this$options2, index;
|
|
31785
|
+
return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_5___default.a.wrap(function _callee17$(_context17) {
|
|
31786
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
31787
|
+
case 0:
|
|
31788
|
+
this.logger('Retrying send comment', comment);
|
|
31789
|
+
this._pendingCommentsCount[comment.unique_id] = ((_this$_pendingComment = this._pendingCommentsCount[comment.unique_id]) !== null && _this$_pendingComment !== void 0 ? _this$_pendingComment : 0) + 1;
|
|
31790
|
+
|
|
31791
|
+
// If it is exceeding the maximum retry count (which is 10), we will not retry anymore
|
|
31792
|
+
if (!(this._pendingCommentsCount[comment.unique_id] > 10)) {
|
|
31793
|
+
_context17.next = 10;
|
|
31794
|
+
break;
|
|
31795
|
+
}
|
|
31796
|
+
this.logger("Exceeding maximum retry count for comment ".concat(comment.unique_id, ", not retrying anymore"));
|
|
31797
|
+
(_this$options$comment2 = (_this$options2 = this.options).commentRetryExceedCallback) === null || _this$options$comment2 === void 0 || _this$options$comment2.call(_this$options2, comment);
|
|
31798
|
+
// Remove the comment from pending comments
|
|
31799
|
+
index = this._pendingComments.findIndex(function (c) {
|
|
31800
|
+
return c.unique_id === comment.unique_id;
|
|
31801
|
+
});
|
|
31802
|
+
if (index > -1) {
|
|
31803
|
+
this._pendingComments.splice(index, 1);
|
|
31804
|
+
}
|
|
31805
|
+
// Mark the comment as failed
|
|
31806
|
+
comment.markAsFailed();
|
|
31807
|
+
// Emit the event
|
|
31808
|
+
this.events.emit('comment-retry-exceed', comment);
|
|
31809
|
+
return _context17.abrupt("return", Promise.reject(new Error('Exceeding maximum retry count')));
|
|
31810
|
+
case 10:
|
|
31811
|
+
return _context17.abrupt("return", this.userAdapter.postComment('' + comment.room_id, comment.message, comment.unique_id, comment.type, comment.payload, comment.extras).then(/*#__PURE__*/function () {
|
|
31812
|
+
var _ref12 = _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_5___default.a.mark(function _callee16(res) {
|
|
31813
|
+
var _this14$selected, _this14$selected2, _this14$options$comme, _this14$options;
|
|
31814
|
+
var index, commentIndex;
|
|
31815
|
+
return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_5___default.a.wrap(function _callee16$(_context16) {
|
|
31816
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
31698
31817
|
case 0:
|
|
31699
|
-
|
|
31700
|
-
|
|
31701
|
-
case 2:
|
|
31702
|
-
res = _context15.sent;
|
|
31703
|
-
Object.assign(messageData, res);
|
|
31704
|
-
if (self.selected) {
|
|
31705
|
-
_context15.next = 6;
|
|
31818
|
+
if (!(((_this14$selected = _this14.selected) === null || _this14$selected === void 0 ? void 0 : _this14$selected.id) !== comment.room_id)) {
|
|
31819
|
+
_context16.next = 2;
|
|
31706
31820
|
break;
|
|
31707
31821
|
}
|
|
31708
|
-
return
|
|
31709
|
-
case
|
|
31710
|
-
|
|
31711
|
-
|
|
31712
|
-
|
|
31713
|
-
|
|
31714
|
-
|
|
31715
|
-
|
|
31716
|
-
|
|
31717
|
-
|
|
31718
|
-
|
|
31719
|
-
|
|
31822
|
+
return _context16.abrupt("return", res);
|
|
31823
|
+
case 2:
|
|
31824
|
+
Object.assign(comment, res);
|
|
31825
|
+
comment.markAsSent();
|
|
31826
|
+
comment.id = res.id;
|
|
31827
|
+
comment.before_id = res.comment_before_id;
|
|
31828
|
+
comment.unix_timestamp = res.unix_timestamp;
|
|
31829
|
+
index = (_this14$selected2 = _this14.selected) === null || _this14$selected2 === void 0 ? void 0 : _this14$selected2.comments.findIndex(function (c) {
|
|
31830
|
+
return c.unique_id === comment.unique_id;
|
|
31831
|
+
});
|
|
31832
|
+
if (index > -1) {
|
|
31833
|
+
_this14.selected.comments[index] = comment;
|
|
31834
|
+
}
|
|
31835
|
+
_this14.sortComments();
|
|
31836
|
+
(_this14$options$comme = (_this14$options = _this14.options).commentSentCallback) === null || _this14$options$comme === void 0 || _this14$options$comme.call(_this14$options, {
|
|
31837
|
+
comment: comment
|
|
31838
|
+
});
|
|
31839
|
+
_this14.events.emit('comment-sent', comment);
|
|
31840
|
+
commentIndex = _this14._pendingComments.findIndex(function (c) {
|
|
31841
|
+
return c.unique_id === comment.unique_id;
|
|
31842
|
+
});
|
|
31843
|
+
if (commentIndex > -1) {
|
|
31844
|
+
_this14._pendingComments.splice(commentIndex, 1);
|
|
31845
|
+
}
|
|
31846
|
+
return _context16.abrupt("return", comment);
|
|
31847
|
+
case 15:
|
|
31720
31848
|
case "end":
|
|
31721
|
-
return
|
|
31849
|
+
return _context16.stop();
|
|
31722
31850
|
}
|
|
31723
|
-
},
|
|
31851
|
+
}, _callee16);
|
|
31724
31852
|
}));
|
|
31725
|
-
return function (
|
|
31853
|
+
return function (_x16) {
|
|
31726
31854
|
return _ref12.apply(this, arguments);
|
|
31727
31855
|
};
|
|
31728
31856
|
}())["catch"](function (err) {
|
|
31729
|
-
|
|
31857
|
+
comment.markAsFailed();
|
|
31730
31858
|
return Promise.reject(err);
|
|
31731
31859
|
}));
|
|
31732
|
-
case
|
|
31860
|
+
case 11:
|
|
31733
31861
|
case "end":
|
|
31734
|
-
return
|
|
31862
|
+
return _context17.stop();
|
|
31735
31863
|
}
|
|
31736
|
-
},
|
|
31864
|
+
}, _callee17, this);
|
|
31737
31865
|
}));
|
|
31738
|
-
function
|
|
31739
|
-
return
|
|
31866
|
+
function _retrySendComment(_x15) {
|
|
31867
|
+
return _retrySendComment2.apply(this, arguments);
|
|
31740
31868
|
}
|
|
31741
|
-
return
|
|
31869
|
+
return _retrySendComment;
|
|
31742
31870
|
}() // #endregion
|
|
31743
|
-
)
|
|
31744
31871
|
}, {
|
|
31745
31872
|
key: "getUsers",
|
|
31746
31873
|
value: function getUsers() {
|
|
@@ -31918,12 +32045,12 @@ var QiscusSDK = /*#__PURE__*/function () {
|
|
|
31918
32045
|
}, {
|
|
31919
32046
|
key: "removeParticipantsFromGroup",
|
|
31920
32047
|
value: function removeParticipantsFromGroup(roomId, emails) {
|
|
31921
|
-
var
|
|
32048
|
+
var _this15 = this;
|
|
31922
32049
|
if (is_js__WEBPACK_IMPORTED_MODULE_8___default.a.not.array(emails)) {
|
|
31923
32050
|
return Promise.reject(new Error('`emails` must have type of array'));
|
|
31924
32051
|
}
|
|
31925
32052
|
return this.roomAdapter.removeParticipantsFromGroup(roomId, emails).then(function (res) {
|
|
31926
|
-
|
|
32053
|
+
_this15.events.emit('participants-removed', emails);
|
|
31927
32054
|
return Promise.resolve(res);
|
|
31928
32055
|
});
|
|
31929
32056
|
}
|
|
@@ -32086,12 +32213,12 @@ var QiscusSDK = /*#__PURE__*/function () {
|
|
|
32086
32213
|
}, {
|
|
32087
32214
|
key: "deleteComment",
|
|
32088
32215
|
value: function deleteComment(roomId, commentUniqueIds, isForEveryone, isHard) {
|
|
32089
|
-
var
|
|
32216
|
+
var _this16 = this;
|
|
32090
32217
|
if (!Array.isArray(commentUniqueIds)) {
|
|
32091
32218
|
throw new Error("unique ids' must be type of Array");
|
|
32092
32219
|
}
|
|
32093
32220
|
return this.userAdapter.deleteComment(roomId, commentUniqueIds, isForEveryone, isHard).then(function (res) {
|
|
32094
|
-
|
|
32221
|
+
_this16.events.emit('comment-deleted', {
|
|
32095
32222
|
roomId: roomId,
|
|
32096
32223
|
commentUniqueIds: commentUniqueIds,
|
|
32097
32224
|
isForEveryone: isForEveryone,
|
|
@@ -32105,7 +32232,7 @@ var QiscusSDK = /*#__PURE__*/function () {
|
|
|
32105
32232
|
}, {
|
|
32106
32233
|
key: "clearRoomsCache",
|
|
32107
32234
|
value: function clearRoomsCache() {
|
|
32108
|
-
var
|
|
32235
|
+
var _this17 = this;
|
|
32109
32236
|
// remove all room except currently selected
|
|
32110
32237
|
if (this.selected) {
|
|
32111
32238
|
// clear the map
|
|
@@ -32113,14 +32240,14 @@ var QiscusSDK = /*#__PURE__*/function () {
|
|
|
32113
32240
|
// get current index and array length
|
|
32114
32241
|
var roomLength = this.rooms.length;
|
|
32115
32242
|
var curIndex = this.rooms.findIndex(function (room) {
|
|
32116
|
-
return room.id ===
|
|
32243
|
+
return room.id === _this17.selected.id;
|
|
32117
32244
|
});
|
|
32118
32245
|
if (!(curIndex + 1 === roomLength)) {
|
|
32119
32246
|
this.rooms.splice(curIndex + 1, roomLength - (curIndex + 1));
|
|
32120
32247
|
}
|
|
32121
32248
|
// ambil ulang cur index nya, klo udah di awal ga perlu lagi kode dibawah ini
|
|
32122
32249
|
curIndex = this.rooms.findIndex(function (room) {
|
|
32123
|
-
return room.id ===
|
|
32250
|
+
return room.id === _this17.selected.id;
|
|
32124
32251
|
});
|
|
32125
32252
|
if (curIndex > 0 && this.rooms.length > 1) {
|
|
32126
32253
|
this.rooms.splice(1, this.rooms.length - 1);
|
|
@@ -32130,18 +32257,18 @@ var QiscusSDK = /*#__PURE__*/function () {
|
|
|
32130
32257
|
}, {
|
|
32131
32258
|
key: "exitChatRoom",
|
|
32132
32259
|
value: function exitChatRoom() {
|
|
32133
|
-
var
|
|
32260
|
+
var _this18 = this;
|
|
32134
32261
|
// remove all subscriber
|
|
32135
32262
|
this.realtimeAdapter.unsubscribeTyping();
|
|
32136
32263
|
Object(_lib_util__WEBPACK_IMPORTED_MODULE_21__["tryCatch"])(function () {
|
|
32137
|
-
return
|
|
32138
|
-
return it.email !==
|
|
32264
|
+
return _this18.selected.participants.filter(function (it) {
|
|
32265
|
+
return it.email !== _this18.user_id;
|
|
32139
32266
|
}).map(function (it) {
|
|
32140
32267
|
return it.email;
|
|
32141
32268
|
});
|
|
32142
32269
|
}, null, this.noop, function (userIds) {
|
|
32143
32270
|
return userIds.forEach(function (userId) {
|
|
32144
|
-
return
|
|
32271
|
+
return _this18.realtimeAdapter.unsubscribeRoomPresence(userId);
|
|
32145
32272
|
});
|
|
32146
32273
|
});
|
|
32147
32274
|
this.selected = null;
|
|
@@ -32339,7 +32466,7 @@ var QiscusSDK = /*#__PURE__*/function () {
|
|
|
32339
32466
|
}, {
|
|
32340
32467
|
key: "searchMessage",
|
|
32341
32468
|
value: (function () {
|
|
32342
|
-
var _searchMessage = _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_5___default.a.mark(function
|
|
32469
|
+
var _searchMessage = _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_5___default.a.mark(function _callee18() {
|
|
32343
32470
|
var _ref13,
|
|
32344
32471
|
query,
|
|
32345
32472
|
_ref13$roomIds,
|
|
@@ -32352,20 +32479,20 @@ var QiscusSDK = /*#__PURE__*/function () {
|
|
|
32352
32479
|
url,
|
|
32353
32480
|
isValidRoomType,
|
|
32354
32481
|
room,
|
|
32355
|
-
|
|
32356
|
-
return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_5___default.a.wrap(function
|
|
32357
|
-
while (1) switch (
|
|
32482
|
+
_args18 = arguments;
|
|
32483
|
+
return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_5___default.a.wrap(function _callee18$(_context18) {
|
|
32484
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
32358
32485
|
case 0:
|
|
32359
|
-
_ref13 =
|
|
32486
|
+
_ref13 = _args18.length > 0 && _args18[0] !== undefined ? _args18[0] : {}, query = _ref13.query, _ref13$roomIds = _ref13.roomIds, roomIds = _ref13$roomIds === void 0 ? [] : _ref13$roomIds, userId = _ref13.userId, type = _ref13.type, roomType = _ref13.roomType, page = _ref13.page, limit = _ref13.limit;
|
|
32360
32487
|
url = 'api/v2/sdk/search';
|
|
32361
32488
|
isValidRoomType = ['group', 'single', 'channel'].some(function (it) {
|
|
32362
32489
|
return it === roomType;
|
|
32363
32490
|
});
|
|
32364
32491
|
if (!(roomType != null && !isValidRoomType)) {
|
|
32365
|
-
|
|
32492
|
+
_context18.next = 5;
|
|
32366
32493
|
break;
|
|
32367
32494
|
}
|
|
32368
|
-
return
|
|
32495
|
+
return _context18.abrupt("return", Promise.reject('Invalid room type, valid room type are: `group`, `single`, and `channel`'));
|
|
32369
32496
|
case 5:
|
|
32370
32497
|
room = function (roomType) {
|
|
32371
32498
|
var rType = roomType == null ? undefined : roomType === 'single' ? 'single' : 'group';
|
|
@@ -32375,7 +32502,7 @@ var QiscusSDK = /*#__PURE__*/function () {
|
|
|
32375
32502
|
isPublic: isPublic
|
|
32376
32503
|
};
|
|
32377
32504
|
}(roomType);
|
|
32378
|
-
return
|
|
32505
|
+
return _context18.abrupt("return", this.HTTPAdapter.post_json(url, {
|
|
32379
32506
|
token: this.token,
|
|
32380
32507
|
query: query,
|
|
32381
32508
|
sender: userId,
|
|
@@ -32392,9 +32519,9 @@ var QiscusSDK = /*#__PURE__*/function () {
|
|
|
32392
32519
|
}));
|
|
32393
32520
|
case 7:
|
|
32394
32521
|
case "end":
|
|
32395
|
-
return
|
|
32522
|
+
return _context18.stop();
|
|
32396
32523
|
}
|
|
32397
|
-
},
|
|
32524
|
+
}, _callee18, this);
|
|
32398
32525
|
}));
|
|
32399
32526
|
function searchMessage() {
|
|
32400
32527
|
return _searchMessage.apply(this, arguments);
|
|
@@ -32418,7 +32545,7 @@ var QiscusSDK = /*#__PURE__*/function () {
|
|
|
32418
32545
|
}, {
|
|
32419
32546
|
key: "getFileList",
|
|
32420
32547
|
value: (function () {
|
|
32421
|
-
var _getFileList = _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_5___default.a.mark(function
|
|
32548
|
+
var _getFileList = _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_5___default.a.mark(function _callee19() {
|
|
32422
32549
|
var _ref14,
|
|
32423
32550
|
_ref14$roomIds,
|
|
32424
32551
|
roomIds,
|
|
@@ -32431,17 +32558,17 @@ var QiscusSDK = /*#__PURE__*/function () {
|
|
|
32431
32558
|
excludeExtensions,
|
|
32432
32559
|
url,
|
|
32433
32560
|
opts,
|
|
32434
|
-
|
|
32435
|
-
return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_5___default.a.wrap(function
|
|
32436
|
-
while (1) switch (
|
|
32561
|
+
_args19 = arguments;
|
|
32562
|
+
return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_5___default.a.wrap(function _callee19$(_context19) {
|
|
32563
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
32437
32564
|
case 0:
|
|
32438
|
-
_ref14 =
|
|
32565
|
+
_ref14 = _args19.length > 0 && _args19[0] !== undefined ? _args19[0] : {}, _ref14$roomIds = _ref14.roomIds, roomIds = _ref14$roomIds === void 0 ? [] : _ref14$roomIds, fileType = _ref14.fileType, page = _ref14.page, limit = _ref14.limit, sender = _ref14.sender, userId = _ref14.userId, includeExtensions = _ref14.includeExtensions, excludeExtensions = _ref14.excludeExtensions;
|
|
32439
32566
|
url = 'api/v2/sdk/file_list';
|
|
32440
32567
|
if (this.isLogin) {
|
|
32441
|
-
|
|
32568
|
+
_context19.next = 4;
|
|
32442
32569
|
break;
|
|
32443
32570
|
}
|
|
32444
|
-
return
|
|
32571
|
+
return _context19.abrupt("return", Promise.reject('You need to login to use this method'));
|
|
32445
32572
|
case 4:
|
|
32446
32573
|
// intended to check for undefined, so user can provide user
|
|
32447
32574
|
// with null. If null, backend can determine that we want to
|
|
@@ -32463,14 +32590,14 @@ var QiscusSDK = /*#__PURE__*/function () {
|
|
|
32463
32590
|
exclude_extensions: excludeExtensions
|
|
32464
32591
|
};
|
|
32465
32592
|
if (sender != null) opts['sender'] = sender;
|
|
32466
|
-
return
|
|
32593
|
+
return _context19.abrupt("return", this.HTTPAdapter.post_json(url, opts).then(function (res) {
|
|
32467
32594
|
return res.body;
|
|
32468
32595
|
}));
|
|
32469
32596
|
case 9:
|
|
32470
32597
|
case "end":
|
|
32471
|
-
return
|
|
32598
|
+
return _context19.stop();
|
|
32472
32599
|
}
|
|
32473
|
-
},
|
|
32600
|
+
}, _callee19, this);
|
|
32474
32601
|
}));
|
|
32475
32602
|
function getFileList() {
|
|
32476
32603
|
return _getFileList.apply(this, arguments);
|
|
@@ -32600,18 +32727,18 @@ var QiscusSDK = /*#__PURE__*/function () {
|
|
|
32600
32727
|
}, {
|
|
32601
32728
|
key: "updateMessage",
|
|
32602
32729
|
value: function () {
|
|
32603
|
-
var _updateMessage = _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_5___default.a.mark(function
|
|
32604
|
-
return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_5___default.a.wrap(function
|
|
32605
|
-
while (1) switch (
|
|
32730
|
+
var _updateMessage = _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_5___default.a.mark(function _callee20(message) {
|
|
32731
|
+
return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_5___default.a.wrap(function _callee20$(_context20) {
|
|
32732
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
32606
32733
|
case 0:
|
|
32607
|
-
return
|
|
32734
|
+
return _context20.abrupt("return", this.userAdapter.updateMessage(message));
|
|
32608
32735
|
case 1:
|
|
32609
32736
|
case "end":
|
|
32610
|
-
return
|
|
32737
|
+
return _context20.stop();
|
|
32611
32738
|
}
|
|
32612
|
-
},
|
|
32739
|
+
}, _callee20, this);
|
|
32613
32740
|
}));
|
|
32614
|
-
function updateMessage(
|
|
32741
|
+
function updateMessage(_x17) {
|
|
32615
32742
|
return _updateMessage.apply(this, arguments);
|
|
32616
32743
|
}
|
|
32617
32744
|
return updateMessage;
|
|
@@ -32619,10 +32746,10 @@ var QiscusSDK = /*#__PURE__*/function () {
|
|
|
32619
32746
|
}, {
|
|
32620
32747
|
key: "onMessageUpdated",
|
|
32621
32748
|
value: function onMessageUpdated(handler) {
|
|
32622
|
-
var
|
|
32749
|
+
var _this19 = this;
|
|
32623
32750
|
this.realtimeAdapter.on('message:updated', handler);
|
|
32624
32751
|
return function () {
|
|
32625
|
-
return
|
|
32752
|
+
return _this19.realtimeAdapter.off('message:updated', handler);
|
|
32626
32753
|
};
|
|
32627
32754
|
}
|
|
32628
32755
|
|
|
@@ -32633,16 +32760,16 @@ var QiscusSDK = /*#__PURE__*/function () {
|
|
|
32633
32760
|
}, {
|
|
32634
32761
|
key: "closeRealtimeConnection",
|
|
32635
32762
|
value: (function () {
|
|
32636
|
-
var _closeRealtimeConnection = _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_5___default.a.mark(function
|
|
32637
|
-
return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_5___default.a.wrap(function
|
|
32638
|
-
while (1) switch (
|
|
32763
|
+
var _closeRealtimeConnection = _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_5___default.a.mark(function _callee21() {
|
|
32764
|
+
return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_5___default.a.wrap(function _callee21$(_context21) {
|
|
32765
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
32639
32766
|
case 0:
|
|
32640
|
-
return
|
|
32767
|
+
return _context21.abrupt("return", this.realtimeAdapter.closeConnection());
|
|
32641
32768
|
case 1:
|
|
32642
32769
|
case "end":
|
|
32643
|
-
return
|
|
32770
|
+
return _context21.stop();
|
|
32644
32771
|
}
|
|
32645
|
-
},
|
|
32772
|
+
}, _callee21, this);
|
|
32646
32773
|
}));
|
|
32647
32774
|
function closeRealtimeConnection() {
|
|
32648
32775
|
return _closeRealtimeConnection.apply(this, arguments);
|
|
@@ -32657,16 +32784,16 @@ var QiscusSDK = /*#__PURE__*/function () {
|
|
|
32657
32784
|
}, {
|
|
32658
32785
|
key: "openRealtimeConnection",
|
|
32659
32786
|
value: (function () {
|
|
32660
|
-
var _openRealtimeConnection = _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_5___default.a.mark(function
|
|
32661
|
-
return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_5___default.a.wrap(function
|
|
32662
|
-
while (1) switch (
|
|
32787
|
+
var _openRealtimeConnection = _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_5___default.a.mark(function _callee22() {
|
|
32788
|
+
return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_5___default.a.wrap(function _callee22$(_context22) {
|
|
32789
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
32663
32790
|
case 0:
|
|
32664
|
-
return
|
|
32791
|
+
return _context22.abrupt("return", this.realtimeAdapter.openConnection());
|
|
32665
32792
|
case 1:
|
|
32666
32793
|
case "end":
|
|
32667
|
-
return
|
|
32794
|
+
return _context22.stop();
|
|
32668
32795
|
}
|
|
32669
|
-
},
|
|
32796
|
+
}, _callee22, this);
|
|
32670
32797
|
}));
|
|
32671
32798
|
function openRealtimeConnection() {
|
|
32672
32799
|
return _openRealtimeConnection.apply(this, arguments);
|
|
@@ -32676,16 +32803,16 @@ var QiscusSDK = /*#__PURE__*/function () {
|
|
|
32676
32803
|
}, {
|
|
32677
32804
|
key: "startSync",
|
|
32678
32805
|
value: function () {
|
|
32679
|
-
var _startSync = _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_5___default.a.mark(function
|
|
32680
|
-
return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_5___default.a.wrap(function
|
|
32681
|
-
while (1) switch (
|
|
32806
|
+
var _startSync = _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_5___default.a.mark(function _callee23() {
|
|
32807
|
+
return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_5___default.a.wrap(function _callee23$(_context23) {
|
|
32808
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
32682
32809
|
case 0:
|
|
32683
32810
|
this._forceEnableSync = true;
|
|
32684
32811
|
case 1:
|
|
32685
32812
|
case "end":
|
|
32686
|
-
return
|
|
32813
|
+
return _context23.stop();
|
|
32687
32814
|
}
|
|
32688
|
-
},
|
|
32815
|
+
}, _callee23, this);
|
|
32689
32816
|
}));
|
|
32690
32817
|
function startSync() {
|
|
32691
32818
|
return _startSync.apply(this, arguments);
|
|
@@ -32695,16 +32822,16 @@ var QiscusSDK = /*#__PURE__*/function () {
|
|
|
32695
32822
|
}, {
|
|
32696
32823
|
key: "stopSync",
|
|
32697
32824
|
value: function () {
|
|
32698
|
-
var _stopSync = _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_5___default.a.mark(function
|
|
32699
|
-
return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_5___default.a.wrap(function
|
|
32700
|
-
while (1) switch (
|
|
32825
|
+
var _stopSync = _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_5___default.a.mark(function _callee24() {
|
|
32826
|
+
return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_5___default.a.wrap(function _callee24$(_context24) {
|
|
32827
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
32701
32828
|
case 0:
|
|
32702
32829
|
this._forceEnableSync = false;
|
|
32703
32830
|
case 1:
|
|
32704
32831
|
case "end":
|
|
32705
|
-
return
|
|
32832
|
+
return _context24.stop();
|
|
32706
32833
|
}
|
|
32707
|
-
},
|
|
32834
|
+
}, _callee24, this);
|
|
32708
32835
|
}));
|
|
32709
32836
|
function stopSync() {
|
|
32710
32837
|
return _stopSync.apply(this, arguments);
|
|
@@ -33182,7 +33309,7 @@ function CustomEventAdapter(mqttAdapter, userId) {
|
|
|
33182
33309
|
// ?
|
|
33183
33310
|
data: payload
|
|
33184
33311
|
});
|
|
33185
|
-
mqttAdapter.
|
|
33312
|
+
mqttAdapter.publish(getTopic(roomId), _payload);
|
|
33186
33313
|
},
|
|
33187
33314
|
subscribeEvent: function subscribeEvent(roomId, callback) {
|
|
33188
33315
|
if (is_js__WEBPACK_IMPORTED_MODULE_0___default.a.undefined(roomId)) throw new Error('`roomId` required');
|
|
@@ -33192,7 +33319,7 @@ function CustomEventAdapter(mqttAdapter, userId) {
|
|
|
33192
33319
|
var topic = getTopic(roomId);
|
|
33193
33320
|
// Only allow 1 subcription for now
|
|
33194
33321
|
if (subscribedTopics[topic]) return;
|
|
33195
|
-
mqttAdapter.
|
|
33322
|
+
mqttAdapter.subscribe(topic);
|
|
33196
33323
|
var cb = function cb(payload) {
|
|
33197
33324
|
var parsedPayload = JSON.parse(payload);
|
|
33198
33325
|
callback(parsedPayload);
|
|
@@ -33205,7 +33332,7 @@ function CustomEventAdapter(mqttAdapter, userId) {
|
|
|
33205
33332
|
if (is_js__WEBPACK_IMPORTED_MODULE_0___default.a.not.string(roomId)) throw new TypeError('`roomId` must have type of string');
|
|
33206
33333
|
var topic = getTopic(roomId);
|
|
33207
33334
|
if (!subscribedTopics[topic]) return;
|
|
33208
|
-
mqttAdapter.
|
|
33335
|
+
mqttAdapter.unsubscribe(topic);
|
|
33209
33336
|
events.off(topic, subscribedTopics[topic]);
|
|
33210
33337
|
subscribedTopics[topic] = null;
|
|
33211
33338
|
delete subscribedTopics[topic];
|
|
@@ -33438,12 +33565,18 @@ function hookAdapterFactory() {
|
|
|
33438
33565
|
"use strict";
|
|
33439
33566
|
__webpack_require__.r(__webpack_exports__);
|
|
33440
33567
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return HttpAdapter; });
|
|
33441
|
-
/* harmony import */ var
|
|
33442
|
-
/* harmony import */ var
|
|
33443
|
-
/* harmony import */ var
|
|
33444
|
-
/* harmony import */ var
|
|
33445
|
-
/* harmony import */ var
|
|
33446
|
-
/* harmony import */ var
|
|
33568
|
+
/* harmony import */ var _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @babel/runtime/helpers/asyncToGenerator */ "./node_modules/.pnpm/@babel+runtime@7.26.9/node_modules/@babel/runtime/helpers/asyncToGenerator.js");
|
|
33569
|
+
/* harmony import */ var _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0__);
|
|
33570
|
+
/* harmony import */ var _babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "./node_modules/.pnpm/@babel+runtime@7.26.9/node_modules/@babel/runtime/helpers/classCallCheck.js");
|
|
33571
|
+
/* harmony import */ var _babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_1__);
|
|
33572
|
+
/* harmony import */ var _babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @babel/runtime/helpers/createClass */ "./node_modules/.pnpm/@babel+runtime@7.26.9/node_modules/@babel/runtime/helpers/createClass.js");
|
|
33573
|
+
/* harmony import */ var _babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_2__);
|
|
33574
|
+
/* harmony import */ var _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @babel/runtime/regenerator */ "./node_modules/.pnpm/@babel+runtime@7.26.9/node_modules/@babel/runtime/regenerator/index.js");
|
|
33575
|
+
/* harmony import */ var _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_3__);
|
|
33576
|
+
/* harmony import */ var superagent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! superagent */ "./node_modules/.pnpm/superagent@3.8.3/node_modules/superagent/lib/client.js");
|
|
33577
|
+
/* harmony import */ var superagent__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(superagent__WEBPACK_IMPORTED_MODULE_4__);
|
|
33578
|
+
|
|
33579
|
+
|
|
33447
33580
|
|
|
33448
33581
|
|
|
33449
33582
|
|
|
@@ -33453,16 +33586,19 @@ var HttpAdapter = /*#__PURE__*/function () {
|
|
|
33453
33586
|
AppId = _ref.AppId,
|
|
33454
33587
|
userId = _ref.userId,
|
|
33455
33588
|
version = _ref.version,
|
|
33456
|
-
getCustomHeader = _ref.getCustomHeader
|
|
33457
|
-
|
|
33589
|
+
getCustomHeader = _ref.getCustomHeader,
|
|
33590
|
+
expiredTokenAdapterGetter = _ref.expiredTokenAdapterGetter;
|
|
33591
|
+
_babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_1___default()(this, HttpAdapter);
|
|
33458
33592
|
this.baseURL = baseURL;
|
|
33459
33593
|
this.token = null;
|
|
33460
33594
|
this.userId = userId;
|
|
33461
33595
|
this.AppId = AppId;
|
|
33462
33596
|
this.version = version;
|
|
33463
33597
|
this.getCustomHeader = getCustomHeader;
|
|
33598
|
+
/** @type {() => import('./expired-token.js').ExpiredTokenAdapter} */
|
|
33599
|
+
this._expiredTokenAdapterGetter = expiredTokenAdapterGetter;
|
|
33464
33600
|
}
|
|
33465
|
-
return
|
|
33601
|
+
return _babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_2___default()(HttpAdapter, [{
|
|
33466
33602
|
key: "setToken",
|
|
33467
33603
|
value: function setToken(token) {
|
|
33468
33604
|
this.token = token;
|
|
@@ -33473,135 +33609,167 @@ var HttpAdapter = /*#__PURE__*/function () {
|
|
|
33473
33609
|
var _this = this;
|
|
33474
33610
|
var headers = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
33475
33611
|
var options = arguments.length > 2 ? arguments[2] : undefined;
|
|
33476
|
-
return
|
|
33477
|
-
var req
|
|
33478
|
-
|
|
33479
|
-
|
|
33480
|
-
|
|
33481
|
-
|
|
33482
|
-
|
|
33483
|
-
|
|
33612
|
+
return this._retryHelper(/*#__PURE__*/_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0___default()(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_3___default.a.mark(function _callee() {
|
|
33613
|
+
var req;
|
|
33614
|
+
return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_3___default.a.wrap(function _callee$(_context) {
|
|
33615
|
+
while (1) switch (_context.prev = _context.next) {
|
|
33616
|
+
case 0:
|
|
33617
|
+
req = superagent__WEBPACK_IMPORTED_MODULE_4___default.a.get("".concat(_this.baseURL, "/").concat(path));
|
|
33618
|
+
if (options && options.baseURL) req = superagent__WEBPACK_IMPORTED_MODULE_4___default.a.get("".concat(options.baseURL, "/").concat(path));
|
|
33619
|
+
req = _this.setupHeaders(req, headers);
|
|
33620
|
+
return _context.abrupt("return", req);
|
|
33621
|
+
case 4:
|
|
33622
|
+
case "end":
|
|
33623
|
+
return _context.stop();
|
|
33484
33624
|
}
|
|
33485
|
-
|
|
33486
|
-
|
|
33487
|
-
});
|
|
33625
|
+
}, _callee);
|
|
33626
|
+
})));
|
|
33488
33627
|
}
|
|
33489
33628
|
// eslint-disable-next-line
|
|
33490
33629
|
}, {
|
|
33491
33630
|
key: "get_request",
|
|
33492
33631
|
value: function get_request(path) {
|
|
33493
|
-
var
|
|
33494
|
-
|
|
33495
|
-
|
|
33632
|
+
var _this2 = this;
|
|
33633
|
+
return this._retryHelper(/*#__PURE__*/_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0___default()(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_3___default.a.mark(function _callee2() {
|
|
33634
|
+
var req;
|
|
33635
|
+
return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_3___default.a.wrap(function _callee2$(_context2) {
|
|
33636
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
33637
|
+
case 0:
|
|
33638
|
+
req = superagent__WEBPACK_IMPORTED_MODULE_4___default.a.get("".concat(_this2.baseURL, "/").concat(path));
|
|
33639
|
+
req = _this2.setupHeaders(req, {});
|
|
33640
|
+
return _context2.abrupt("return", req);
|
|
33641
|
+
case 3:
|
|
33642
|
+
case "end":
|
|
33643
|
+
return _context2.stop();
|
|
33644
|
+
}
|
|
33645
|
+
}, _callee2);
|
|
33646
|
+
})));
|
|
33496
33647
|
}
|
|
33497
33648
|
}, {
|
|
33498
33649
|
key: "post",
|
|
33499
33650
|
value: function post(path) {
|
|
33500
|
-
var
|
|
33651
|
+
var _this3 = this;
|
|
33501
33652
|
var body = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
33502
33653
|
var headers = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
33503
|
-
return
|
|
33504
|
-
var req
|
|
33505
|
-
|
|
33506
|
-
|
|
33507
|
-
|
|
33508
|
-
|
|
33509
|
-
|
|
33654
|
+
return this._retryHelper(/*#__PURE__*/_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0___default()(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_3___default.a.mark(function _callee3() {
|
|
33655
|
+
var req;
|
|
33656
|
+
return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_3___default.a.wrap(function _callee3$(_context3) {
|
|
33657
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
33658
|
+
case 0:
|
|
33659
|
+
req = superagent__WEBPACK_IMPORTED_MODULE_4___default.a.post("".concat(_this3.baseURL, "/").concat(path));
|
|
33660
|
+
req = _this3.setupHeaders(req, headers);
|
|
33661
|
+
return _context3.abrupt("return", req.send(body).set('Content-Type', 'application/x-www-form-urlencoded'));
|
|
33662
|
+
case 3:
|
|
33663
|
+
case "end":
|
|
33664
|
+
return _context3.stop();
|
|
33510
33665
|
}
|
|
33511
|
-
|
|
33512
|
-
|
|
33513
|
-
});
|
|
33666
|
+
}, _callee3);
|
|
33667
|
+
})));
|
|
33514
33668
|
}
|
|
33515
33669
|
|
|
33516
33670
|
// eslint-disable-next-line
|
|
33517
33671
|
}, {
|
|
33518
33672
|
key: "post_json",
|
|
33519
33673
|
value: function post_json(path) {
|
|
33520
|
-
var
|
|
33674
|
+
var _this4 = this;
|
|
33521
33675
|
var body = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
33522
33676
|
var headers = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
33523
|
-
return
|
|
33524
|
-
var req
|
|
33525
|
-
|
|
33526
|
-
|
|
33527
|
-
|
|
33528
|
-
|
|
33529
|
-
|
|
33677
|
+
return this._retryHelper(/*#__PURE__*/_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0___default()(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_3___default.a.mark(function _callee4() {
|
|
33678
|
+
var req;
|
|
33679
|
+
return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_3___default.a.wrap(function _callee4$(_context4) {
|
|
33680
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
33681
|
+
case 0:
|
|
33682
|
+
req = superagent__WEBPACK_IMPORTED_MODULE_4___default.a.post("".concat(_this4.baseURL, "/").concat(path));
|
|
33683
|
+
req = _this4.setupHeaders(req, headers);
|
|
33684
|
+
req.send(body);
|
|
33685
|
+
return _context4.abrupt("return", req);
|
|
33686
|
+
case 4:
|
|
33687
|
+
case "end":
|
|
33688
|
+
return _context4.stop();
|
|
33530
33689
|
}
|
|
33531
|
-
|
|
33532
|
-
|
|
33533
|
-
});
|
|
33690
|
+
}, _callee4);
|
|
33691
|
+
})));
|
|
33534
33692
|
}
|
|
33535
33693
|
}, {
|
|
33536
33694
|
key: "put",
|
|
33537
33695
|
value: function put(path) {
|
|
33538
|
-
var
|
|
33696
|
+
var _this5 = this;
|
|
33539
33697
|
var body = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
33540
33698
|
var headers = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
33541
|
-
return
|
|
33542
|
-
var req
|
|
33543
|
-
|
|
33544
|
-
|
|
33545
|
-
|
|
33546
|
-
|
|
33547
|
-
|
|
33699
|
+
return this._retryHelper(/*#__PURE__*/_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0___default()(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_3___default.a.mark(function _callee5() {
|
|
33700
|
+
var req;
|
|
33701
|
+
return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_3___default.a.wrap(function _callee5$(_context5) {
|
|
33702
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
33703
|
+
case 0:
|
|
33704
|
+
req = superagent__WEBPACK_IMPORTED_MODULE_4___default.a.put("".concat(_this5.baseURL, "/").concat(path));
|
|
33705
|
+
req = _this5.setupHeaders(req, headers);
|
|
33706
|
+
return _context5.abrupt("return", req.send(body).set('Content-Type', 'application/x-www-form-urlencoded'));
|
|
33707
|
+
case 3:
|
|
33708
|
+
case "end":
|
|
33709
|
+
return _context5.stop();
|
|
33548
33710
|
}
|
|
33549
|
-
|
|
33550
|
-
|
|
33551
|
-
});
|
|
33711
|
+
}, _callee5);
|
|
33712
|
+
})));
|
|
33552
33713
|
}
|
|
33553
33714
|
}, {
|
|
33554
33715
|
key: "patch",
|
|
33555
33716
|
value: function patch(path) {
|
|
33556
|
-
var
|
|
33717
|
+
var _this6 = this;
|
|
33557
33718
|
var body = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
33558
33719
|
var headers = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
33559
|
-
return
|
|
33560
|
-
var req
|
|
33561
|
-
|
|
33562
|
-
|
|
33563
|
-
|
|
33564
|
-
|
|
33565
|
-
|
|
33720
|
+
return this._retryHelper(/*#__PURE__*/_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0___default()(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_3___default.a.mark(function _callee6() {
|
|
33721
|
+
var req;
|
|
33722
|
+
return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_3___default.a.wrap(function _callee6$(_context6) {
|
|
33723
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
33724
|
+
case 0:
|
|
33725
|
+
req = superagent__WEBPACK_IMPORTED_MODULE_4___default.a.patch("".concat(_this6.baseURL, "/").concat(path));
|
|
33726
|
+
req = _this6.setupHeaders(req, headers);
|
|
33727
|
+
return _context6.abrupt("return", req.send(body).set('Content-Type', 'application/x-www-form-urlencoded'));
|
|
33728
|
+
case 3:
|
|
33729
|
+
case "end":
|
|
33730
|
+
return _context6.stop();
|
|
33566
33731
|
}
|
|
33567
|
-
|
|
33568
|
-
|
|
33569
|
-
});
|
|
33732
|
+
}, _callee6);
|
|
33733
|
+
})));
|
|
33570
33734
|
}
|
|
33571
33735
|
}, {
|
|
33572
33736
|
key: "del",
|
|
33573
33737
|
value: function del(path) {
|
|
33574
|
-
var
|
|
33738
|
+
var _this7 = this;
|
|
33575
33739
|
var body = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
33576
33740
|
var headers = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
33577
|
-
return
|
|
33578
|
-
var req
|
|
33579
|
-
|
|
33580
|
-
|
|
33581
|
-
|
|
33582
|
-
|
|
33583
|
-
|
|
33741
|
+
return this._retryHelper(/*#__PURE__*/_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0___default()(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_3___default.a.mark(function _callee7() {
|
|
33742
|
+
var req;
|
|
33743
|
+
return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_3___default.a.wrap(function _callee7$(_context7) {
|
|
33744
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
33745
|
+
case 0:
|
|
33746
|
+
req = superagent__WEBPACK_IMPORTED_MODULE_4___default.a.del("".concat(_this7.baseURL, "/").concat(path));
|
|
33747
|
+
req = _this7.setupHeaders(req, headers);
|
|
33748
|
+
return _context7.abrupt("return", req.send(body).set('Content-Type', 'application/json'));
|
|
33749
|
+
case 3:
|
|
33750
|
+
case "end":
|
|
33751
|
+
return _context7.stop();
|
|
33584
33752
|
}
|
|
33585
|
-
|
|
33586
|
-
|
|
33587
|
-
});
|
|
33753
|
+
}, _callee7);
|
|
33754
|
+
})));
|
|
33588
33755
|
}
|
|
33589
33756
|
}, {
|
|
33590
33757
|
key: "setupHeaders",
|
|
33591
33758
|
value: function setupHeaders(req) {
|
|
33592
33759
|
var headers = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
33760
|
+
req.set('QISCUS-SDK-PLATFORM', 'javascript');
|
|
33593
33761
|
// let's give this default Authorization Header
|
|
33594
33762
|
if (this.AppId != null) {
|
|
33595
|
-
req.set(
|
|
33763
|
+
req.set('QISCUS-SDK-APP-ID', "".concat(this.AppId));
|
|
33596
33764
|
}
|
|
33597
33765
|
if (this.userId != null) {
|
|
33598
|
-
req.set(
|
|
33766
|
+
req.set('QISCUS-SDK-USER-ID', "".concat(this.userId));
|
|
33599
33767
|
}
|
|
33600
33768
|
if (this.token != null) {
|
|
33601
|
-
req.set(
|
|
33769
|
+
req.set('QISCUS-SDK-TOKEN', "".concat(this.token));
|
|
33602
33770
|
}
|
|
33603
33771
|
if (this.version != null) {
|
|
33604
|
-
req.set(
|
|
33772
|
+
req.set('QISCUS-SDK-VERSION', "".concat(this.version));
|
|
33605
33773
|
}
|
|
33606
33774
|
if (this.getCustomHeader != null) {
|
|
33607
33775
|
var customHeaders = this.getCustomHeader();
|
|
@@ -33619,16 +33787,53 @@ var HttpAdapter = /*#__PURE__*/function () {
|
|
|
33619
33787
|
}
|
|
33620
33788
|
return req;
|
|
33621
33789
|
}
|
|
33790
|
+
|
|
33791
|
+
/**
|
|
33792
|
+
* @param {() => request.Request} fn
|
|
33793
|
+
* @returns {Promise<unknown>}
|
|
33794
|
+
*/
|
|
33622
33795
|
}, {
|
|
33623
|
-
key: "
|
|
33624
|
-
value: function
|
|
33625
|
-
var
|
|
33626
|
-
|
|
33627
|
-
|
|
33628
|
-
|
|
33629
|
-
|
|
33796
|
+
key: "_retryHelper",
|
|
33797
|
+
value: (function () {
|
|
33798
|
+
var _retryHelper2 = _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0___default()(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_3___default.a.mark(function _callee8(fn) {
|
|
33799
|
+
var _err$response, _err$response2, _body$error, status, body;
|
|
33800
|
+
return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_3___default.a.wrap(function _callee8$(_context8) {
|
|
33801
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
33802
|
+
case 0:
|
|
33803
|
+
_context8.prev = 0;
|
|
33804
|
+
_context8.next = 3;
|
|
33805
|
+
return fn();
|
|
33806
|
+
case 3:
|
|
33807
|
+
return _context8.abrupt("return", _context8.sent);
|
|
33808
|
+
case 6:
|
|
33809
|
+
_context8.prev = 6;
|
|
33810
|
+
_context8.t0 = _context8["catch"](0);
|
|
33811
|
+
status = _context8.t0 === null || _context8.t0 === void 0 || (_err$response = _context8.t0.response) === null || _err$response === void 0 ? void 0 : _err$response.status;
|
|
33812
|
+
body = _context8.t0 === null || _context8.t0 === void 0 || (_err$response2 = _context8.t0.response) === null || _err$response2 === void 0 ? void 0 : _err$response2.body;
|
|
33813
|
+
if (!(status === 403 && ((_body$error = body.error) === null || _body$error === void 0 || (_body$error = _body$error.message) === null || _body$error === void 0 ? void 0 : _body$error.toLowerCase()) === 'unauthorized. token is expired')) {
|
|
33814
|
+
_context8.next = 18;
|
|
33815
|
+
break;
|
|
33816
|
+
}
|
|
33817
|
+
_context8.next = 13;
|
|
33818
|
+
return this._expiredTokenAdapterGetter().refreshAuthToken();
|
|
33819
|
+
case 13:
|
|
33820
|
+
_context8.next = 15;
|
|
33821
|
+
return fn();
|
|
33822
|
+
case 15:
|
|
33823
|
+
return _context8.abrupt("return", _context8.sent);
|
|
33824
|
+
case 18:
|
|
33825
|
+
throw _context8.t0;
|
|
33826
|
+
case 19:
|
|
33827
|
+
case "end":
|
|
33828
|
+
return _context8.stop();
|
|
33829
|
+
}
|
|
33830
|
+
}, _callee8, this, [[0, 6]]);
|
|
33831
|
+
}));
|
|
33832
|
+
function _retryHelper(_x) {
|
|
33833
|
+
return _retryHelper2.apply(this, arguments);
|
|
33630
33834
|
}
|
|
33631
|
-
|
|
33835
|
+
return _retryHelper;
|
|
33836
|
+
}())
|
|
33632
33837
|
}]);
|
|
33633
33838
|
}();
|
|
33634
33839
|
|
|
@@ -33895,7 +34100,7 @@ var MqttAdapter = /*#__PURE__*/function () {
|
|
|
33895
34100
|
while (1) switch (_context2.prev = _context2.next) {
|
|
33896
34101
|
case 0:
|
|
33897
34102
|
this.shouldConnect = true;
|
|
33898
|
-
this.__mqtt_conneck();
|
|
34103
|
+
this.mqtt = this.__mqtt_conneck();
|
|
33899
34104
|
case 2:
|
|
33900
34105
|
case "end":
|
|
33901
34106
|
return _context2.stop();
|
|
@@ -33915,12 +34120,18 @@ var MqttAdapter = /*#__PURE__*/function () {
|
|
|
33915
34120
|
key: "closeConnection",
|
|
33916
34121
|
value: (function () {
|
|
33917
34122
|
var _closeConnection = _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_2___default()(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_6___default.a.mark(function _callee3() {
|
|
34123
|
+
var _this2 = this;
|
|
33918
34124
|
return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_6___default.a.wrap(function _callee3$(_context3) {
|
|
33919
34125
|
while (1) switch (_context3.prev = _context3.next) {
|
|
33920
34126
|
case 0:
|
|
33921
34127
|
this.shouldConnect = false;
|
|
33922
|
-
this.mqtt.end(true)
|
|
33923
|
-
|
|
34128
|
+
this.mqtt.end(true, function (err) {
|
|
34129
|
+
if (err) {
|
|
34130
|
+
_this2.logger('error when close connection', err.message);
|
|
34131
|
+
}
|
|
34132
|
+
});
|
|
34133
|
+
this.mqtt = null;
|
|
34134
|
+
case 3:
|
|
33924
34135
|
case "end":
|
|
33925
34136
|
return _context3.stop();
|
|
33926
34137
|
}
|
|
@@ -33971,12 +34182,12 @@ var MqttAdapter = /*#__PURE__*/function () {
|
|
|
33971
34182
|
}
|
|
33972
34183
|
this.logger('subscribe to', args);
|
|
33973
34184
|
this.subscribtionBuffer.push(args);
|
|
33974
|
-
|
|
33975
|
-
|
|
34185
|
+
while (this.mqtt != null && this.subscribtionBuffer.length > 0) {
|
|
34186
|
+
var subs = this.subscribtionBuffer.shift();
|
|
34187
|
+
if (subs != null) {
|
|
33976
34188
|
var _this$mqtt;
|
|
33977
|
-
|
|
33978
|
-
|
|
33979
|
-
} while (this.subscribtionBuffer.length > 0);
|
|
34189
|
+
(_this$mqtt = this.mqtt).subscribe.apply(_this$mqtt, _babel_runtime_helpers_toConsumableArray__WEBPACK_IMPORTED_MODULE_0___default()(subs));
|
|
34190
|
+
}
|
|
33980
34191
|
}
|
|
33981
34192
|
}
|
|
33982
34193
|
}, {
|
|
@@ -33985,16 +34196,13 @@ var MqttAdapter = /*#__PURE__*/function () {
|
|
|
33985
34196
|
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
33986
34197
|
args[_key3] = arguments[_key3];
|
|
33987
34198
|
}
|
|
33988
|
-
this.logger('unsubscribe from', args);
|
|
33989
34199
|
this.unsubscribtionBuffer.push(args);
|
|
33990
|
-
|
|
33991
|
-
|
|
33992
|
-
|
|
33993
|
-
|
|
33994
|
-
|
|
33995
|
-
|
|
33996
|
-
}
|
|
33997
|
-
} while (this.unsubscribtionBuffer.length > 0);
|
|
34200
|
+
while (this.mqtt != null && this.unsubscribtionBuffer.length > 0) {
|
|
34201
|
+
var subs = this.unsubscribtionBuffer.shift();
|
|
34202
|
+
if (subs != null) {
|
|
34203
|
+
var _this$mqtt2;
|
|
34204
|
+
(_this$mqtt2 = this.mqtt).unsubscribe.apply(_this$mqtt2, _babel_runtime_helpers_toConsumableArray__WEBPACK_IMPORTED_MODULE_0___default()(subs));
|
|
34205
|
+
}
|
|
33998
34206
|
}
|
|
33999
34207
|
}
|
|
34000
34208
|
}, {
|
|
@@ -34006,12 +34214,12 @@ var MqttAdapter = /*#__PURE__*/function () {
|
|
|
34006
34214
|
payload: payload,
|
|
34007
34215
|
options: options
|
|
34008
34216
|
});
|
|
34009
|
-
|
|
34217
|
+
while (this.mqtt != null && this.publishBuffer.length > 0) {
|
|
34010
34218
|
var data = this.publishBuffer.shift();
|
|
34011
34219
|
if (data != null) {
|
|
34012
|
-
|
|
34220
|
+
this.mqtt.publish(data.topic, data.payload.toString(), data.options);
|
|
34013
34221
|
}
|
|
34014
|
-
}
|
|
34222
|
+
}
|
|
34015
34223
|
}
|
|
34016
34224
|
}, {
|
|
34017
34225
|
key: "emit",
|
|
@@ -34103,13 +34311,13 @@ var MqttAdapter = /*#__PURE__*/function () {
|
|
|
34103
34311
|
}, {
|
|
34104
34312
|
key: "notificationHandler",
|
|
34105
34313
|
value: function notificationHandler(topic, message) {
|
|
34106
|
-
var
|
|
34314
|
+
var _this3 = this;
|
|
34107
34315
|
this.logger('on:notification', message);
|
|
34108
34316
|
message = JSON.parse(message);
|
|
34109
34317
|
var data = message.payload.data;
|
|
34110
34318
|
if ('deleted_messages' in data) {
|
|
34111
34319
|
data.deleted_messages.forEach(function (message) {
|
|
34112
|
-
|
|
34320
|
+
_this3.emit('comment-deleted', {
|
|
34113
34321
|
roomId: message.room_id,
|
|
34114
34322
|
commentUniqueIds: message.message_unique_ids,
|
|
34115
34323
|
isForEveryone: true,
|
|
@@ -34119,7 +34327,7 @@ var MqttAdapter = /*#__PURE__*/function () {
|
|
|
34119
34327
|
}
|
|
34120
34328
|
if ('deleted_rooms' in data) {
|
|
34121
34329
|
data.deleted_rooms.forEach(function (room) {
|
|
34122
|
-
|
|
34330
|
+
_this3.emit('room-cleared', room);
|
|
34123
34331
|
});
|
|
34124
34332
|
}
|
|
34125
34333
|
}
|
|
@@ -34632,16 +34840,20 @@ function synchronizeFactory(getHttp, getInterval, getSync, getId, logger) {
|
|
|
34632
34840
|
}
|
|
34633
34841
|
result = _step.value;
|
|
34634
34842
|
try {
|
|
34635
|
-
|
|
34636
|
-
|
|
34637
|
-
|
|
34638
|
-
messages
|
|
34639
|
-
|
|
34640
|
-
|
|
34641
|
-
|
|
34843
|
+
emitter.emit('synchronize', Date.now());
|
|
34844
|
+
if ((result === null || result === void 0 ? void 0 : result.lastMessageId) != null && (result === null || result === void 0 ? void 0 : result.messages) != null) {
|
|
34845
|
+
messageId = result.lastMessageId;
|
|
34846
|
+
messages = result.messages;
|
|
34847
|
+
if (messageId > getId()) {
|
|
34848
|
+
messages.forEach(function (m) {
|
|
34849
|
+
return emitter.emit('message.new', m);
|
|
34850
|
+
});
|
|
34851
|
+
emitter.emit('last-message-id.new', messageId);
|
|
34852
|
+
}
|
|
34642
34853
|
}
|
|
34643
34854
|
} catch (e) {
|
|
34644
34855
|
logger('error when sync', e.message);
|
|
34856
|
+
console.log('error when sync', e);
|
|
34645
34857
|
}
|
|
34646
34858
|
case 9:
|
|
34647
34859
|
_iteratorAbruptCompletion = false;
|
|
@@ -34890,6 +35102,9 @@ function SyncAdapter(getHttpAdapter, _ref) {
|
|
|
34890
35102
|
syncFactory.on('message.new', function (m) {
|
|
34891
35103
|
return emitter.emit('message.new', m);
|
|
34892
35104
|
});
|
|
35105
|
+
syncFactory.on('synchronize', function (m) {
|
|
35106
|
+
return emitter.emit('synchronize', m);
|
|
35107
|
+
});
|
|
34893
35108
|
syncFactory.run()["catch"](function (err) {
|
|
34894
35109
|
return logger('got error when sync', err);
|
|
34895
35110
|
});
|
|
@@ -34924,6 +35139,12 @@ function SyncAdapter(getHttpAdapter, _ref) {
|
|
|
34924
35139
|
get off() {
|
|
34925
35140
|
return emitter.off;
|
|
34926
35141
|
},
|
|
35142
|
+
get interval() {
|
|
35143
|
+
return getInterval();
|
|
35144
|
+
},
|
|
35145
|
+
get enabled() {
|
|
35146
|
+
return enableSync();
|
|
35147
|
+
},
|
|
34927
35148
|
synchronize: function synchronize() {
|
|
34928
35149
|
syncFactory.synchronize();
|
|
34929
35150
|
},
|