@xapp/chat-widget 1.60.2 → 1.60.3
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/index.css +2 -2
- package/dist/index.es.js +41 -19
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +41 -19
- package/dist/index.js.map +1 -1
- package/dist/xapp-chat-widget.css +1 -1
- package/dist/xapp-chat-widget.js +1 -1
- package/dist/xapp-chat-widget.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -2846,19 +2846,25 @@ var StentorRouterChat = /** @class */ (function () {
|
|
|
2846
2846
|
// We are connected
|
|
2847
2847
|
setActStatus("online");
|
|
2848
2848
|
setConnStatus("online");
|
|
2849
|
-
ws.onclose =
|
|
2849
|
+
ws.onclose = function () {
|
|
2850
|
+
log("Closed WS connection (onclosed was called)");
|
|
2851
|
+
startReconnecting();
|
|
2852
|
+
};
|
|
2850
2853
|
clearInterval(interval);
|
|
2851
2854
|
};
|
|
2852
|
-
},
|
|
2855
|
+
}, 5000);
|
|
2853
2856
|
}
|
|
2854
2857
|
log("Creating WS connection");
|
|
2855
2858
|
var ws = wsCreate();
|
|
2856
2859
|
if (!ws) {
|
|
2857
2860
|
return;
|
|
2858
2861
|
}
|
|
2859
|
-
|
|
2862
|
+
ws.onclose = function () {
|
|
2863
|
+
log("Closed WS connection (onclosed was called)");
|
|
2864
|
+
startReconnecting();
|
|
2865
|
+
};
|
|
2860
2866
|
this.ws.onopen = function () {
|
|
2861
|
-
log("Opened WS connection");
|
|
2867
|
+
log("Opened WS connection (onopen was called)");
|
|
2862
2868
|
// We are connected
|
|
2863
2869
|
_this.setAccountStatus("online");
|
|
2864
2870
|
_this.setConnectionStatus("online");
|
|
@@ -2866,13 +2872,27 @@ var StentorRouterChat = /** @class */ (function () {
|
|
|
2866
2872
|
};
|
|
2867
2873
|
StentorRouterChat.prototype.wsCreate = function () {
|
|
2868
2874
|
var _this = this;
|
|
2875
|
+
var _a, _b;
|
|
2869
2876
|
if (this.isDisposed) {
|
|
2870
2877
|
log("Stopping reconnect for disposed router connector");
|
|
2871
2878
|
return undefined;
|
|
2872
2879
|
}
|
|
2880
|
+
else {
|
|
2881
|
+
log("Trying to re-connect...");
|
|
2882
|
+
}
|
|
2873
2883
|
var url = new URL(this.serverUrl);
|
|
2874
2884
|
url.searchParams.set("userId", this._userId);
|
|
2875
2885
|
url.searchParams.set("isAdmin", "".concat(this.isAdmin));
|
|
2886
|
+
// Force close - just in case - when you create new
|
|
2887
|
+
if (this.ws && ((_a = this.ws) === null || _a === void 0 ? void 0 : _a.readyState) !== WebSocket.CLOSED) {
|
|
2888
|
+
var wsState = (_b = this.ws) === null || _b === void 0 ? void 0 : _b.readyState;
|
|
2889
|
+
try {
|
|
2890
|
+
this.ws.close();
|
|
2891
|
+
}
|
|
2892
|
+
catch (err) {
|
|
2893
|
+
err("Failed to close WS (ready state: ".concat(wsState, "): ").concat(err));
|
|
2894
|
+
}
|
|
2895
|
+
}
|
|
2876
2896
|
this.ws = new WebSocket(url.toString());
|
|
2877
2897
|
this.ws.onerror = function (ev) {
|
|
2878
2898
|
var _a;
|
|
@@ -2914,7 +2934,7 @@ var StentorRouterChat = /** @class */ (function () {
|
|
|
2914
2934
|
// Fire up the WebSocket
|
|
2915
2935
|
this.autoReconnect(this.wsCreate.bind(this));
|
|
2916
2936
|
}
|
|
2917
|
-
return [4 /*yield*/, waitFor(this.checkConnection.bind(this),
|
|
2937
|
+
return [4 /*yield*/, waitFor(this.checkConnection.bind(this), 1000, 10000, "connection")
|
|
2918
2938
|
.then(function (t) {
|
|
2919
2939
|
if (t > 0) {
|
|
2920
2940
|
log("Connection is ready in ".concat(t, " ms"));
|
|
@@ -3008,16 +3028,14 @@ var StentorRouterChat = /** @class */ (function () {
|
|
|
3008
3028
|
return __generator$1(this, function (_a) {
|
|
3009
3029
|
switch (_a.label) {
|
|
3010
3030
|
case 0:
|
|
3011
|
-
|
|
3012
|
-
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
_a.label = 2;
|
|
3016
|
-
case 2:
|
|
3031
|
+
// This is rare, but is happened: no visitor info exchange, but the connection is back.
|
|
3032
|
+
// if (this.checkConnection() && !this.checkSession()) {
|
|
3033
|
+
// await this.postVisitorInfo();
|
|
3034
|
+
// }
|
|
3017
3035
|
if (!this.checkSession()) {
|
|
3018
3036
|
this.setConnectionStatus("pending");
|
|
3019
3037
|
}
|
|
3020
|
-
return [4 /*yield*/, waitFor(this.checkSession.bind(this),
|
|
3038
|
+
return [4 /*yield*/, waitFor(this.checkSession.bind(this), 1000, 10000, "session creation")
|
|
3021
3039
|
.then(function (t) {
|
|
3022
3040
|
if (t > 0) {
|
|
3023
3041
|
log("Session creation is ready in ".concat(t, " ms"));
|
|
@@ -3029,7 +3047,7 @@ var StentorRouterChat = /** @class */ (function () {
|
|
|
3029
3047
|
_this.setConnectionStatus("online"); // stop pulsing
|
|
3030
3048
|
_this.sendDisconnectMessage();
|
|
3031
3049
|
})];
|
|
3032
|
-
case
|
|
3050
|
+
case 1:
|
|
3033
3051
|
_a.sent();
|
|
3034
3052
|
this.setConnectionStatus("online");
|
|
3035
3053
|
cb();
|
|
@@ -3068,20 +3086,24 @@ var StentorRouterChat = /** @class */ (function () {
|
|
|
3068
3086
|
StentorRouterChat.prototype.flush = function () { };
|
|
3069
3087
|
StentorRouterChat.prototype.dispose = function () {
|
|
3070
3088
|
this.isDisposed = true;
|
|
3071
|
-
this.ws
|
|
3089
|
+
if (this.ws) {
|
|
3090
|
+
this.ws.close();
|
|
3091
|
+
}
|
|
3072
3092
|
log("Closed web socket (dispose)");
|
|
3073
3093
|
};
|
|
3074
3094
|
StentorRouterChat.prototype.sleep = function () {
|
|
3075
3095
|
this.isDisposed = true;
|
|
3076
|
-
this.ws
|
|
3077
|
-
|
|
3096
|
+
if (this.ws) {
|
|
3097
|
+
this.ws.close();
|
|
3098
|
+
}
|
|
3099
|
+
log("Closed web socket (sleep)");
|
|
3078
3100
|
};
|
|
3079
3101
|
StentorRouterChat.prototype.wakeup = function () {
|
|
3102
|
+
this.isDisposed = false;
|
|
3080
3103
|
// wait for the session setup
|
|
3081
3104
|
if (!this._userId) {
|
|
3082
3105
|
return;
|
|
3083
3106
|
}
|
|
3084
|
-
this.isDisposed = false;
|
|
3085
3107
|
// Fire up the WebSocket
|
|
3086
3108
|
this.autoReconnect(this.wsCreate.bind(this));
|
|
3087
3109
|
log("Waking up");
|
|
@@ -3174,7 +3196,7 @@ function senderToNick(sender) {
|
|
|
3174
3196
|
function waitFor(check, stepMs, timeoutMs, resource) {
|
|
3175
3197
|
var elapsedMs = 0;
|
|
3176
3198
|
var poll = function (resolve, reject) {
|
|
3177
|
-
if (elapsedMs
|
|
3199
|
+
if (elapsedMs >= timeoutMs) {
|
|
3178
3200
|
reject(elapsedMs);
|
|
3179
3201
|
}
|
|
3180
3202
|
else {
|
|
@@ -31064,7 +31086,7 @@ var ChatWidget = function (props) {
|
|
|
31064
31086
|
}
|
|
31065
31087
|
}, [chatServer, innerDispatch, isTabVisible]);
|
|
31066
31088
|
React$1.useEffect(function () {
|
|
31067
|
-
// For reopen widget after move on same
|
|
31089
|
+
// For reopen widget after move on same window
|
|
31068
31090
|
// if (get("opened")) {
|
|
31069
31091
|
// setVisible(true);
|
|
31070
31092
|
// }
|