akeyless-client-commons 1.1.17-test.2 → 1.1.17-test.4
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/components/index.css.map +1 -1
- package/dist/components/index.js +18 -72
- package/dist/components/index.mjs +18 -72
- package/dist/helpers/index.d.mts +2 -10
- package/dist/helpers/index.d.ts +2 -10
- package/dist/helpers/index.js +18 -72
- package/dist/helpers/index.mjs +18 -72
- package/dist/hooks/index.js +21 -75
- package/dist/hooks/index.mjs +21 -75
- package/package.json +1 -1
|
@@ -978,8 +978,7 @@ var SocketService = /*#__PURE__*/ function() {
|
|
|
978
978
|
this.socket = null;
|
|
979
979
|
this.connectCallbacks = [];
|
|
980
980
|
this.disconnectCallbacks = [];
|
|
981
|
-
this.
|
|
982
|
-
this.maxTransportCloseAttempts = 3;
|
|
981
|
+
this.authToken = null;
|
|
983
982
|
}
|
|
984
983
|
_create_class(_SocketService, [
|
|
985
984
|
{
|
|
@@ -992,47 +991,21 @@ var SocketService = /*#__PURE__*/ function() {
|
|
|
992
991
|
this.socket = io(socketUrl, {
|
|
993
992
|
path: "/api/data-socket/connect",
|
|
994
993
|
transports: [
|
|
995
|
-
"websocket"
|
|
996
|
-
"polling"
|
|
994
|
+
"websocket"
|
|
997
995
|
],
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
reconnection: true,
|
|
1002
|
-
reconnectionDelay: 1e3,
|
|
1003
|
-
reconnectionDelayMax: 5e3,
|
|
1004
|
-
reconnectionAttempts: 5,
|
|
1005
|
-
forceNew: false,
|
|
1006
|
-
// Don't force new connection every time
|
|
1007
|
-
upgrade: true,
|
|
1008
|
-
// Allow transport upgrades
|
|
1009
|
-
rememberUpgrade: true
|
|
996
|
+
auth: this.authToken ? {
|
|
997
|
+
token: this.authToken
|
|
998
|
+
} : void 0
|
|
1010
999
|
});
|
|
1011
1000
|
this.socket.on("connect", function() {
|
|
1012
|
-
var _this_socket
|
|
1001
|
+
var _this_socket;
|
|
1013
1002
|
console.log("Socket connected:", (_this_socket = _this.socket) === null || _this_socket === void 0 ? void 0 : _this_socket.id);
|
|
1014
|
-
console.log("Transport:", (_this_socket1 = _this.socket) === null || _this_socket1 === void 0 ? void 0 : _this_socket1.io.engine.transport.name);
|
|
1015
1003
|
_this.connectCallbacks.forEach(function(cb) {
|
|
1016
1004
|
return cb();
|
|
1017
1005
|
});
|
|
1018
1006
|
});
|
|
1019
1007
|
this.socket.on("disconnect", function(reason) {
|
|
1020
1008
|
console.log("Socket disconnected:", reason);
|
|
1021
|
-
if (reason === "transport close" || reason === "transport error") {
|
|
1022
|
-
console.log("Transport issue detected, will attempt reconnection");
|
|
1023
|
-
_this.transportCloseCount++;
|
|
1024
|
-
if (_this.transportCloseCount >= _this.maxTransportCloseAttempts) {
|
|
1025
|
-
console.warn("Transport closed ".concat(_this.transportCloseCount, " times, switching to polling only"));
|
|
1026
|
-
if (_this.socket && _this.socket.io) {
|
|
1027
|
-
_this.socket.io.opts.transports = [
|
|
1028
|
-
"polling"
|
|
1029
|
-
];
|
|
1030
|
-
}
|
|
1031
|
-
_this.transportCloseCount = 0;
|
|
1032
|
-
}
|
|
1033
|
-
} else {
|
|
1034
|
-
_this.transportCloseCount = 0;
|
|
1035
|
-
}
|
|
1036
1009
|
_this.disconnectCallbacks.forEach(function(cb) {
|
|
1037
1010
|
return cb();
|
|
1038
1011
|
});
|
|
@@ -1040,22 +1013,6 @@ var SocketService = /*#__PURE__*/ function() {
|
|
|
1040
1013
|
this.socket.on("connect_error", function(error) {
|
|
1041
1014
|
console.error("Socket connection error:", error);
|
|
1042
1015
|
});
|
|
1043
|
-
this.socket.on("reconnect", function(attemptNumber) {
|
|
1044
|
-
console.log("Socket reconnected after", attemptNumber, "attempts");
|
|
1045
|
-
});
|
|
1046
|
-
this.socket.on("reconnect_error", function(error) {
|
|
1047
|
-
console.error("Socket reconnection error:", error);
|
|
1048
|
-
});
|
|
1049
|
-
this.socket.on("reconnect_failed", function() {
|
|
1050
|
-
console.error("Socket reconnection failed");
|
|
1051
|
-
});
|
|
1052
|
-
this.socket.io.engine.on("upgrade", function() {
|
|
1053
|
-
var _this_socket;
|
|
1054
|
-
console.log("Transport upgraded to:", (_this_socket = _this.socket) === null || _this_socket === void 0 ? void 0 : _this_socket.io.engine.transport.name);
|
|
1055
|
-
});
|
|
1056
|
-
this.socket.io.engine.on("upgradeError", function(error) {
|
|
1057
|
-
console.error("Transport upgrade error:", error);
|
|
1058
|
-
});
|
|
1059
1016
|
}
|
|
1060
1017
|
}
|
|
1061
1018
|
},
|
|
@@ -1079,6 +1036,9 @@ var SocketService = /*#__PURE__*/ function() {
|
|
|
1079
1036
|
/// subscribe to collections
|
|
1080
1037
|
key: "subscribeToCollections",
|
|
1081
1038
|
value: function subscribeToCollections(config) {
|
|
1039
|
+
if (config.length === 0) {
|
|
1040
|
+
return function() {};
|
|
1041
|
+
}
|
|
1082
1042
|
var s = this.getSocketInstance();
|
|
1083
1043
|
var collectionsNames = config.map(function(c) {
|
|
1084
1044
|
return c.collectionName;
|
|
@@ -1273,33 +1233,19 @@ var SocketService = /*#__PURE__*/ function() {
|
|
|
1273
1233
|
}
|
|
1274
1234
|
},
|
|
1275
1235
|
{
|
|
1276
|
-
key: "
|
|
1277
|
-
value: function
|
|
1278
|
-
|
|
1279
|
-
return ((_this_socket = this.socket) === null || _this_socket === void 0 ? void 0 : _this_socket.io.engine.transport.name) || "unknown";
|
|
1280
|
-
}
|
|
1281
|
-
},
|
|
1282
|
-
{
|
|
1283
|
-
key: "forceReconnect",
|
|
1284
|
-
value: function forceReconnect() {
|
|
1236
|
+
key: "setAuthToken",
|
|
1237
|
+
value: function setAuthToken(token) {
|
|
1238
|
+
this.authToken = token;
|
|
1285
1239
|
if (this.socket) {
|
|
1286
|
-
|
|
1287
|
-
|
|
1240
|
+
this.socket.auth = {
|
|
1241
|
+
token: token
|
|
1242
|
+
};
|
|
1243
|
+
if (this.socket.connected) {
|
|
1244
|
+
this.socket.disconnect();
|
|
1245
|
+
}
|
|
1288
1246
|
this.socket.connect();
|
|
1289
1247
|
}
|
|
1290
1248
|
}
|
|
1291
|
-
},
|
|
1292
|
-
{
|
|
1293
|
-
key: "getConnectionState",
|
|
1294
|
-
value: function getConnectionState() {
|
|
1295
|
-
var _this_socket, _this_socket1, _this_socket2, _this_socket3;
|
|
1296
|
-
return {
|
|
1297
|
-
connected: ((_this_socket = this.socket) === null || _this_socket === void 0 ? void 0 : _this_socket.connected) || false,
|
|
1298
|
-
transport: ((_this_socket1 = this.socket) === null || _this_socket1 === void 0 ? void 0 : _this_socket1.io.engine.transport.name) || "unknown",
|
|
1299
|
-
id: (_this_socket2 = this.socket) === null || _this_socket2 === void 0 ? void 0 : _this_socket2.id,
|
|
1300
|
-
reconnecting: ((_this_socket3 = this.socket) === null || _this_socket3 === void 0 ? void 0 : _this_socket3.io.engine.readyState) === "opening"
|
|
1301
|
-
};
|
|
1302
|
-
}
|
|
1303
1249
|
}
|
|
1304
1250
|
], [
|
|
1305
1251
|
{
|
package/dist/helpers/index.d.mts
CHANGED
|
@@ -274,8 +274,7 @@ declare class SocketService {
|
|
|
274
274
|
private socket;
|
|
275
275
|
private connectCallbacks;
|
|
276
276
|
private disconnectCallbacks;
|
|
277
|
-
private
|
|
278
|
-
private maxTransportCloseAttempts;
|
|
277
|
+
private authToken;
|
|
279
278
|
private initSocket;
|
|
280
279
|
private constructor();
|
|
281
280
|
static getInstance(): SocketService;
|
|
@@ -294,14 +293,7 @@ declare class SocketService {
|
|
|
294
293
|
onDisconnect(callback: () => void): void;
|
|
295
294
|
offDisconnect(callback: () => void): void;
|
|
296
295
|
isConnected(): boolean;
|
|
297
|
-
|
|
298
|
-
forceReconnect(): void;
|
|
299
|
-
getConnectionState(): {
|
|
300
|
-
connected: boolean;
|
|
301
|
-
transport: string;
|
|
302
|
-
id: string | undefined;
|
|
303
|
-
reconnecting: boolean;
|
|
304
|
-
};
|
|
296
|
+
setAuthToken(token: string): void;
|
|
305
297
|
}
|
|
306
298
|
declare const socketServiceInstance: SocketService;
|
|
307
299
|
|
package/dist/helpers/index.d.ts
CHANGED
|
@@ -274,8 +274,7 @@ declare class SocketService {
|
|
|
274
274
|
private socket;
|
|
275
275
|
private connectCallbacks;
|
|
276
276
|
private disconnectCallbacks;
|
|
277
|
-
private
|
|
278
|
-
private maxTransportCloseAttempts;
|
|
277
|
+
private authToken;
|
|
279
278
|
private initSocket;
|
|
280
279
|
private constructor();
|
|
281
280
|
static getInstance(): SocketService;
|
|
@@ -294,14 +293,7 @@ declare class SocketService {
|
|
|
294
293
|
onDisconnect(callback: () => void): void;
|
|
295
294
|
offDisconnect(callback: () => void): void;
|
|
296
295
|
isConnected(): boolean;
|
|
297
|
-
|
|
298
|
-
forceReconnect(): void;
|
|
299
|
-
getConnectionState(): {
|
|
300
|
-
connected: boolean;
|
|
301
|
-
transport: string;
|
|
302
|
-
id: string | undefined;
|
|
303
|
-
reconnecting: boolean;
|
|
304
|
-
};
|
|
296
|
+
setAuthToken(token: string): void;
|
|
305
297
|
}
|
|
306
298
|
declare const socketServiceInstance: SocketService;
|
|
307
299
|
|
package/dist/helpers/index.js
CHANGED
|
@@ -2306,8 +2306,7 @@ var SocketService = /*#__PURE__*/ function() {
|
|
|
2306
2306
|
this.socket = null;
|
|
2307
2307
|
this.connectCallbacks = [];
|
|
2308
2308
|
this.disconnectCallbacks = [];
|
|
2309
|
-
this.
|
|
2310
|
-
this.maxTransportCloseAttempts = 3;
|
|
2309
|
+
this.authToken = null;
|
|
2311
2310
|
}
|
|
2312
2311
|
_create_class(_SocketService, [
|
|
2313
2312
|
{
|
|
@@ -2320,47 +2319,21 @@ var SocketService = /*#__PURE__*/ function() {
|
|
|
2320
2319
|
this.socket = (0, import_socket.io)(socketUrl, {
|
|
2321
2320
|
path: "/api/data-socket/connect",
|
|
2322
2321
|
transports: [
|
|
2323
|
-
"websocket"
|
|
2324
|
-
"polling"
|
|
2322
|
+
"websocket"
|
|
2325
2323
|
],
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
reconnection: true,
|
|
2330
|
-
reconnectionDelay: 1e3,
|
|
2331
|
-
reconnectionDelayMax: 5e3,
|
|
2332
|
-
reconnectionAttempts: 5,
|
|
2333
|
-
forceNew: false,
|
|
2334
|
-
// Don't force new connection every time
|
|
2335
|
-
upgrade: true,
|
|
2336
|
-
// Allow transport upgrades
|
|
2337
|
-
rememberUpgrade: true
|
|
2324
|
+
auth: this.authToken ? {
|
|
2325
|
+
token: this.authToken
|
|
2326
|
+
} : void 0
|
|
2338
2327
|
});
|
|
2339
2328
|
this.socket.on("connect", function() {
|
|
2340
|
-
var _this_socket
|
|
2329
|
+
var _this_socket;
|
|
2341
2330
|
console.log("Socket connected:", (_this_socket = _this.socket) === null || _this_socket === void 0 ? void 0 : _this_socket.id);
|
|
2342
|
-
console.log("Transport:", (_this_socket1 = _this.socket) === null || _this_socket1 === void 0 ? void 0 : _this_socket1.io.engine.transport.name);
|
|
2343
2331
|
_this.connectCallbacks.forEach(function(cb) {
|
|
2344
2332
|
return cb();
|
|
2345
2333
|
});
|
|
2346
2334
|
});
|
|
2347
2335
|
this.socket.on("disconnect", function(reason) {
|
|
2348
2336
|
console.log("Socket disconnected:", reason);
|
|
2349
|
-
if (reason === "transport close" || reason === "transport error") {
|
|
2350
|
-
console.log("Transport issue detected, will attempt reconnection");
|
|
2351
|
-
_this.transportCloseCount++;
|
|
2352
|
-
if (_this.transportCloseCount >= _this.maxTransportCloseAttempts) {
|
|
2353
|
-
console.warn("Transport closed ".concat(_this.transportCloseCount, " times, switching to polling only"));
|
|
2354
|
-
if (_this.socket && _this.socket.io) {
|
|
2355
|
-
_this.socket.io.opts.transports = [
|
|
2356
|
-
"polling"
|
|
2357
|
-
];
|
|
2358
|
-
}
|
|
2359
|
-
_this.transportCloseCount = 0;
|
|
2360
|
-
}
|
|
2361
|
-
} else {
|
|
2362
|
-
_this.transportCloseCount = 0;
|
|
2363
|
-
}
|
|
2364
2337
|
_this.disconnectCallbacks.forEach(function(cb) {
|
|
2365
2338
|
return cb();
|
|
2366
2339
|
});
|
|
@@ -2368,22 +2341,6 @@ var SocketService = /*#__PURE__*/ function() {
|
|
|
2368
2341
|
this.socket.on("connect_error", function(error) {
|
|
2369
2342
|
console.error("Socket connection error:", error);
|
|
2370
2343
|
});
|
|
2371
|
-
this.socket.on("reconnect", function(attemptNumber) {
|
|
2372
|
-
console.log("Socket reconnected after", attemptNumber, "attempts");
|
|
2373
|
-
});
|
|
2374
|
-
this.socket.on("reconnect_error", function(error) {
|
|
2375
|
-
console.error("Socket reconnection error:", error);
|
|
2376
|
-
});
|
|
2377
|
-
this.socket.on("reconnect_failed", function() {
|
|
2378
|
-
console.error("Socket reconnection failed");
|
|
2379
|
-
});
|
|
2380
|
-
this.socket.io.engine.on("upgrade", function() {
|
|
2381
|
-
var _this_socket;
|
|
2382
|
-
console.log("Transport upgraded to:", (_this_socket = _this.socket) === null || _this_socket === void 0 ? void 0 : _this_socket.io.engine.transport.name);
|
|
2383
|
-
});
|
|
2384
|
-
this.socket.io.engine.on("upgradeError", function(error) {
|
|
2385
|
-
console.error("Transport upgrade error:", error);
|
|
2386
|
-
});
|
|
2387
2344
|
}
|
|
2388
2345
|
}
|
|
2389
2346
|
},
|
|
@@ -2407,6 +2364,9 @@ var SocketService = /*#__PURE__*/ function() {
|
|
|
2407
2364
|
/// subscribe to collections
|
|
2408
2365
|
key: "subscribeToCollections",
|
|
2409
2366
|
value: function subscribeToCollections(config) {
|
|
2367
|
+
if (config.length === 0) {
|
|
2368
|
+
return function() {};
|
|
2369
|
+
}
|
|
2410
2370
|
var s = this.getSocketInstance();
|
|
2411
2371
|
var collectionsNames = config.map(function(c) {
|
|
2412
2372
|
return c.collectionName;
|
|
@@ -2601,33 +2561,19 @@ var SocketService = /*#__PURE__*/ function() {
|
|
|
2601
2561
|
}
|
|
2602
2562
|
},
|
|
2603
2563
|
{
|
|
2604
|
-
key: "
|
|
2605
|
-
value: function
|
|
2606
|
-
|
|
2607
|
-
return ((_this_socket = this.socket) === null || _this_socket === void 0 ? void 0 : _this_socket.io.engine.transport.name) || "unknown";
|
|
2608
|
-
}
|
|
2609
|
-
},
|
|
2610
|
-
{
|
|
2611
|
-
key: "forceReconnect",
|
|
2612
|
-
value: function forceReconnect() {
|
|
2564
|
+
key: "setAuthToken",
|
|
2565
|
+
value: function setAuthToken(token) {
|
|
2566
|
+
this.authToken = token;
|
|
2613
2567
|
if (this.socket) {
|
|
2614
|
-
|
|
2615
|
-
|
|
2568
|
+
this.socket.auth = {
|
|
2569
|
+
token: token
|
|
2570
|
+
};
|
|
2571
|
+
if (this.socket.connected) {
|
|
2572
|
+
this.socket.disconnect();
|
|
2573
|
+
}
|
|
2616
2574
|
this.socket.connect();
|
|
2617
2575
|
}
|
|
2618
2576
|
}
|
|
2619
|
-
},
|
|
2620
|
-
{
|
|
2621
|
-
key: "getConnectionState",
|
|
2622
|
-
value: function getConnectionState() {
|
|
2623
|
-
var _this_socket, _this_socket1, _this_socket2, _this_socket3;
|
|
2624
|
-
return {
|
|
2625
|
-
connected: ((_this_socket = this.socket) === null || _this_socket === void 0 ? void 0 : _this_socket.connected) || false,
|
|
2626
|
-
transport: ((_this_socket1 = this.socket) === null || _this_socket1 === void 0 ? void 0 : _this_socket1.io.engine.transport.name) || "unknown",
|
|
2627
|
-
id: (_this_socket2 = this.socket) === null || _this_socket2 === void 0 ? void 0 : _this_socket2.id,
|
|
2628
|
-
reconnecting: ((_this_socket3 = this.socket) === null || _this_socket3 === void 0 ? void 0 : _this_socket3.io.engine.readyState) === "opening"
|
|
2629
|
-
};
|
|
2630
|
-
}
|
|
2631
2577
|
}
|
|
2632
2578
|
], [
|
|
2633
2579
|
{
|
package/dist/helpers/index.mjs
CHANGED
|
@@ -1942,8 +1942,7 @@ var SocketService = /*#__PURE__*/ function() {
|
|
|
1942
1942
|
this.socket = null;
|
|
1943
1943
|
this.connectCallbacks = [];
|
|
1944
1944
|
this.disconnectCallbacks = [];
|
|
1945
|
-
this.
|
|
1946
|
-
this.maxTransportCloseAttempts = 3;
|
|
1945
|
+
this.authToken = null;
|
|
1947
1946
|
}
|
|
1948
1947
|
_create_class(_SocketService, [
|
|
1949
1948
|
{
|
|
@@ -1956,47 +1955,21 @@ var SocketService = /*#__PURE__*/ function() {
|
|
|
1956
1955
|
this.socket = io(socketUrl, {
|
|
1957
1956
|
path: "/api/data-socket/connect",
|
|
1958
1957
|
transports: [
|
|
1959
|
-
"websocket"
|
|
1960
|
-
"polling"
|
|
1958
|
+
"websocket"
|
|
1961
1959
|
],
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
reconnection: true,
|
|
1966
|
-
reconnectionDelay: 1e3,
|
|
1967
|
-
reconnectionDelayMax: 5e3,
|
|
1968
|
-
reconnectionAttempts: 5,
|
|
1969
|
-
forceNew: false,
|
|
1970
|
-
// Don't force new connection every time
|
|
1971
|
-
upgrade: true,
|
|
1972
|
-
// Allow transport upgrades
|
|
1973
|
-
rememberUpgrade: true
|
|
1960
|
+
auth: this.authToken ? {
|
|
1961
|
+
token: this.authToken
|
|
1962
|
+
} : void 0
|
|
1974
1963
|
});
|
|
1975
1964
|
this.socket.on("connect", function() {
|
|
1976
|
-
var _this_socket
|
|
1965
|
+
var _this_socket;
|
|
1977
1966
|
console.log("Socket connected:", (_this_socket = _this.socket) === null || _this_socket === void 0 ? void 0 : _this_socket.id);
|
|
1978
|
-
console.log("Transport:", (_this_socket1 = _this.socket) === null || _this_socket1 === void 0 ? void 0 : _this_socket1.io.engine.transport.name);
|
|
1979
1967
|
_this.connectCallbacks.forEach(function(cb) {
|
|
1980
1968
|
return cb();
|
|
1981
1969
|
});
|
|
1982
1970
|
});
|
|
1983
1971
|
this.socket.on("disconnect", function(reason) {
|
|
1984
1972
|
console.log("Socket disconnected:", reason);
|
|
1985
|
-
if (reason === "transport close" || reason === "transport error") {
|
|
1986
|
-
console.log("Transport issue detected, will attempt reconnection");
|
|
1987
|
-
_this.transportCloseCount++;
|
|
1988
|
-
if (_this.transportCloseCount >= _this.maxTransportCloseAttempts) {
|
|
1989
|
-
console.warn("Transport closed ".concat(_this.transportCloseCount, " times, switching to polling only"));
|
|
1990
|
-
if (_this.socket && _this.socket.io) {
|
|
1991
|
-
_this.socket.io.opts.transports = [
|
|
1992
|
-
"polling"
|
|
1993
|
-
];
|
|
1994
|
-
}
|
|
1995
|
-
_this.transportCloseCount = 0;
|
|
1996
|
-
}
|
|
1997
|
-
} else {
|
|
1998
|
-
_this.transportCloseCount = 0;
|
|
1999
|
-
}
|
|
2000
1973
|
_this.disconnectCallbacks.forEach(function(cb) {
|
|
2001
1974
|
return cb();
|
|
2002
1975
|
});
|
|
@@ -2004,22 +1977,6 @@ var SocketService = /*#__PURE__*/ function() {
|
|
|
2004
1977
|
this.socket.on("connect_error", function(error) {
|
|
2005
1978
|
console.error("Socket connection error:", error);
|
|
2006
1979
|
});
|
|
2007
|
-
this.socket.on("reconnect", function(attemptNumber) {
|
|
2008
|
-
console.log("Socket reconnected after", attemptNumber, "attempts");
|
|
2009
|
-
});
|
|
2010
|
-
this.socket.on("reconnect_error", function(error) {
|
|
2011
|
-
console.error("Socket reconnection error:", error);
|
|
2012
|
-
});
|
|
2013
|
-
this.socket.on("reconnect_failed", function() {
|
|
2014
|
-
console.error("Socket reconnection failed");
|
|
2015
|
-
});
|
|
2016
|
-
this.socket.io.engine.on("upgrade", function() {
|
|
2017
|
-
var _this_socket;
|
|
2018
|
-
console.log("Transport upgraded to:", (_this_socket = _this.socket) === null || _this_socket === void 0 ? void 0 : _this_socket.io.engine.transport.name);
|
|
2019
|
-
});
|
|
2020
|
-
this.socket.io.engine.on("upgradeError", function(error) {
|
|
2021
|
-
console.error("Transport upgrade error:", error);
|
|
2022
|
-
});
|
|
2023
1980
|
}
|
|
2024
1981
|
}
|
|
2025
1982
|
},
|
|
@@ -2043,6 +2000,9 @@ var SocketService = /*#__PURE__*/ function() {
|
|
|
2043
2000
|
/// subscribe to collections
|
|
2044
2001
|
key: "subscribeToCollections",
|
|
2045
2002
|
value: function subscribeToCollections(config) {
|
|
2003
|
+
if (config.length === 0) {
|
|
2004
|
+
return function() {};
|
|
2005
|
+
}
|
|
2046
2006
|
var s = this.getSocketInstance();
|
|
2047
2007
|
var collectionsNames = config.map(function(c) {
|
|
2048
2008
|
return c.collectionName;
|
|
@@ -2237,33 +2197,19 @@ var SocketService = /*#__PURE__*/ function() {
|
|
|
2237
2197
|
}
|
|
2238
2198
|
},
|
|
2239
2199
|
{
|
|
2240
|
-
key: "
|
|
2241
|
-
value: function
|
|
2242
|
-
|
|
2243
|
-
return ((_this_socket = this.socket) === null || _this_socket === void 0 ? void 0 : _this_socket.io.engine.transport.name) || "unknown";
|
|
2244
|
-
}
|
|
2245
|
-
},
|
|
2246
|
-
{
|
|
2247
|
-
key: "forceReconnect",
|
|
2248
|
-
value: function forceReconnect() {
|
|
2200
|
+
key: "setAuthToken",
|
|
2201
|
+
value: function setAuthToken(token) {
|
|
2202
|
+
this.authToken = token;
|
|
2249
2203
|
if (this.socket) {
|
|
2250
|
-
|
|
2251
|
-
|
|
2204
|
+
this.socket.auth = {
|
|
2205
|
+
token: token
|
|
2206
|
+
};
|
|
2207
|
+
if (this.socket.connected) {
|
|
2208
|
+
this.socket.disconnect();
|
|
2209
|
+
}
|
|
2252
2210
|
this.socket.connect();
|
|
2253
2211
|
}
|
|
2254
2212
|
}
|
|
2255
|
-
},
|
|
2256
|
-
{
|
|
2257
|
-
key: "getConnectionState",
|
|
2258
|
-
value: function getConnectionState() {
|
|
2259
|
-
var _this_socket, _this_socket1, _this_socket2, _this_socket3;
|
|
2260
|
-
return {
|
|
2261
|
-
connected: ((_this_socket = this.socket) === null || _this_socket === void 0 ? void 0 : _this_socket.connected) || false,
|
|
2262
|
-
transport: ((_this_socket1 = this.socket) === null || _this_socket1 === void 0 ? void 0 : _this_socket1.io.engine.transport.name) || "unknown",
|
|
2263
|
-
id: (_this_socket2 = this.socket) === null || _this_socket2 === void 0 ? void 0 : _this_socket2.id,
|
|
2264
|
-
reconnecting: ((_this_socket3 = this.socket) === null || _this_socket3 === void 0 ? void 0 : _this_socket3.io.engine.readyState) === "opening"
|
|
2265
|
-
};
|
|
2266
|
-
}
|
|
2267
2213
|
}
|
|
2268
2214
|
], [
|
|
2269
2215
|
{
|
package/dist/hooks/index.js
CHANGED
|
@@ -651,8 +651,7 @@ var SocketService = /*#__PURE__*/ function() {
|
|
|
651
651
|
this.socket = null;
|
|
652
652
|
this.connectCallbacks = [];
|
|
653
653
|
this.disconnectCallbacks = [];
|
|
654
|
-
this.
|
|
655
|
-
this.maxTransportCloseAttempts = 3;
|
|
654
|
+
this.authToken = null;
|
|
656
655
|
}
|
|
657
656
|
_create_class(_SocketService, [
|
|
658
657
|
{
|
|
@@ -665,47 +664,21 @@ var SocketService = /*#__PURE__*/ function() {
|
|
|
665
664
|
this.socket = (0, import_socket.io)(socketUrl, {
|
|
666
665
|
path: "/api/data-socket/connect",
|
|
667
666
|
transports: [
|
|
668
|
-
"websocket"
|
|
669
|
-
"polling"
|
|
667
|
+
"websocket"
|
|
670
668
|
],
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
reconnection: true,
|
|
675
|
-
reconnectionDelay: 1e3,
|
|
676
|
-
reconnectionDelayMax: 5e3,
|
|
677
|
-
reconnectionAttempts: 5,
|
|
678
|
-
forceNew: false,
|
|
679
|
-
// Don't force new connection every time
|
|
680
|
-
upgrade: true,
|
|
681
|
-
// Allow transport upgrades
|
|
682
|
-
rememberUpgrade: true
|
|
669
|
+
auth: this.authToken ? {
|
|
670
|
+
token: this.authToken
|
|
671
|
+
} : void 0
|
|
683
672
|
});
|
|
684
673
|
this.socket.on("connect", function() {
|
|
685
|
-
var _this_socket
|
|
674
|
+
var _this_socket;
|
|
686
675
|
console.log("Socket connected:", (_this_socket = _this.socket) === null || _this_socket === void 0 ? void 0 : _this_socket.id);
|
|
687
|
-
console.log("Transport:", (_this_socket1 = _this.socket) === null || _this_socket1 === void 0 ? void 0 : _this_socket1.io.engine.transport.name);
|
|
688
676
|
_this.connectCallbacks.forEach(function(cb) {
|
|
689
677
|
return cb();
|
|
690
678
|
});
|
|
691
679
|
});
|
|
692
680
|
this.socket.on("disconnect", function(reason) {
|
|
693
681
|
console.log("Socket disconnected:", reason);
|
|
694
|
-
if (reason === "transport close" || reason === "transport error") {
|
|
695
|
-
console.log("Transport issue detected, will attempt reconnection");
|
|
696
|
-
_this.transportCloseCount++;
|
|
697
|
-
if (_this.transportCloseCount >= _this.maxTransportCloseAttempts) {
|
|
698
|
-
console.warn("Transport closed ".concat(_this.transportCloseCount, " times, switching to polling only"));
|
|
699
|
-
if (_this.socket && _this.socket.io) {
|
|
700
|
-
_this.socket.io.opts.transports = [
|
|
701
|
-
"polling"
|
|
702
|
-
];
|
|
703
|
-
}
|
|
704
|
-
_this.transportCloseCount = 0;
|
|
705
|
-
}
|
|
706
|
-
} else {
|
|
707
|
-
_this.transportCloseCount = 0;
|
|
708
|
-
}
|
|
709
682
|
_this.disconnectCallbacks.forEach(function(cb) {
|
|
710
683
|
return cb();
|
|
711
684
|
});
|
|
@@ -713,22 +686,6 @@ var SocketService = /*#__PURE__*/ function() {
|
|
|
713
686
|
this.socket.on("connect_error", function(error) {
|
|
714
687
|
console.error("Socket connection error:", error);
|
|
715
688
|
});
|
|
716
|
-
this.socket.on("reconnect", function(attemptNumber) {
|
|
717
|
-
console.log("Socket reconnected after", attemptNumber, "attempts");
|
|
718
|
-
});
|
|
719
|
-
this.socket.on("reconnect_error", function(error) {
|
|
720
|
-
console.error("Socket reconnection error:", error);
|
|
721
|
-
});
|
|
722
|
-
this.socket.on("reconnect_failed", function() {
|
|
723
|
-
console.error("Socket reconnection failed");
|
|
724
|
-
});
|
|
725
|
-
this.socket.io.engine.on("upgrade", function() {
|
|
726
|
-
var _this_socket;
|
|
727
|
-
console.log("Transport upgraded to:", (_this_socket = _this.socket) === null || _this_socket === void 0 ? void 0 : _this_socket.io.engine.transport.name);
|
|
728
|
-
});
|
|
729
|
-
this.socket.io.engine.on("upgradeError", function(error) {
|
|
730
|
-
console.error("Transport upgrade error:", error);
|
|
731
|
-
});
|
|
732
689
|
}
|
|
733
690
|
}
|
|
734
691
|
},
|
|
@@ -752,6 +709,9 @@ var SocketService = /*#__PURE__*/ function() {
|
|
|
752
709
|
/// subscribe to collections
|
|
753
710
|
key: "subscribeToCollections",
|
|
754
711
|
value: function subscribeToCollections(config) {
|
|
712
|
+
if (config.length === 0) {
|
|
713
|
+
return function() {};
|
|
714
|
+
}
|
|
755
715
|
var s = this.getSocketInstance();
|
|
756
716
|
var collectionsNames = config.map(function(c) {
|
|
757
717
|
return c.collectionName;
|
|
@@ -946,33 +906,19 @@ var SocketService = /*#__PURE__*/ function() {
|
|
|
946
906
|
}
|
|
947
907
|
},
|
|
948
908
|
{
|
|
949
|
-
key: "
|
|
950
|
-
value: function
|
|
951
|
-
|
|
952
|
-
return ((_this_socket = this.socket) === null || _this_socket === void 0 ? void 0 : _this_socket.io.engine.transport.name) || "unknown";
|
|
953
|
-
}
|
|
954
|
-
},
|
|
955
|
-
{
|
|
956
|
-
key: "forceReconnect",
|
|
957
|
-
value: function forceReconnect() {
|
|
909
|
+
key: "setAuthToken",
|
|
910
|
+
value: function setAuthToken(token) {
|
|
911
|
+
this.authToken = token;
|
|
958
912
|
if (this.socket) {
|
|
959
|
-
|
|
960
|
-
|
|
913
|
+
this.socket.auth = {
|
|
914
|
+
token: token
|
|
915
|
+
};
|
|
916
|
+
if (this.socket.connected) {
|
|
917
|
+
this.socket.disconnect();
|
|
918
|
+
}
|
|
961
919
|
this.socket.connect();
|
|
962
920
|
}
|
|
963
921
|
}
|
|
964
|
-
},
|
|
965
|
-
{
|
|
966
|
-
key: "getConnectionState",
|
|
967
|
-
value: function getConnectionState() {
|
|
968
|
-
var _this_socket, _this_socket1, _this_socket2, _this_socket3;
|
|
969
|
-
return {
|
|
970
|
-
connected: ((_this_socket = this.socket) === null || _this_socket === void 0 ? void 0 : _this_socket.connected) || false,
|
|
971
|
-
transport: ((_this_socket1 = this.socket) === null || _this_socket1 === void 0 ? void 0 : _this_socket1.io.engine.transport.name) || "unknown",
|
|
972
|
-
id: (_this_socket2 = this.socket) === null || _this_socket2 === void 0 ? void 0 : _this_socket2.id,
|
|
973
|
-
reconnecting: ((_this_socket3 = this.socket) === null || _this_socket3 === void 0 ? void 0 : _this_socket3.io.engine.readyState) === "opening"
|
|
974
|
-
};
|
|
975
|
-
}
|
|
976
922
|
}
|
|
977
923
|
], [
|
|
978
924
|
{
|
|
@@ -1052,9 +998,6 @@ var useSocketSubscription = function(configs, label, settings) {
|
|
|
1052
998
|
socketServiceInstance.onDisconnect(uiOnDisconnect);
|
|
1053
999
|
setSocketConnected(socketServiceInstance.isConnected());
|
|
1054
1000
|
return function() {
|
|
1055
|
-
if (!(settings === null || settings === void 0 ? void 0 : settings.disableLogs) && configs.length > 0) {
|
|
1056
|
-
console.log("==> ".concat(label || "Cache snapshots", " stopped. "));
|
|
1057
|
-
}
|
|
1058
1001
|
if (settings === null || settings === void 0 ? void 0 : settings.cleanupForConfigChange) {
|
|
1059
1002
|
cleanupSubscriptions.forEach(function(cleanup) {
|
|
1060
1003
|
return cleanup();
|
|
@@ -1062,6 +1005,9 @@ var useSocketSubscription = function(configs, label, settings) {
|
|
|
1062
1005
|
socketServiceInstance.offConnect(uiOnConnect);
|
|
1063
1006
|
socketServiceInstance.offDisconnect(uiOnDisconnect);
|
|
1064
1007
|
}
|
|
1008
|
+
if (!(settings === null || settings === void 0 ? void 0 : settings.disableLogs) && configs.length > 0) {
|
|
1009
|
+
console.log("==> ".concat(label || "Cache snapshots", " unsubscribed. "));
|
|
1010
|
+
}
|
|
1065
1011
|
};
|
|
1066
1012
|
}, [
|
|
1067
1013
|
socketConnected,
|