@senior-gestao-empresarial/angular-components 6.8.0 → 6.9.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/bundles/senior-gestao-empresarial-angular-components.umd.js +51 -96
- package/bundles/senior-gestao-empresarial-angular-components.umd.js.map +1 -1
- package/bundles/senior-gestao-empresarial-angular-components.umd.min.js +1 -1
- package/bundles/senior-gestao-empresarial-angular-components.umd.min.js.map +1 -1
- package/components/websocket/websocket.service.d.ts +9 -18
- package/esm2015/components/websocket/websocket.service.js +37 -77
- package/esm5/components/websocket/websocket.service.js +54 -99
- package/fesm2015/senior-gestao-empresarial-angular-components.js +36 -76
- package/fesm2015/senior-gestao-empresarial-angular-components.js.map +1 -1
- package/fesm5/senior-gestao-empresarial-angular-components.js +53 -98
- package/fesm5/senior-gestao-empresarial-angular-components.js.map +1 -1
- package/package.json +1 -1
- package/senior-gestao-empresarial-angular-components.metadata.json +1 -1
|
@@ -7183,15 +7183,15 @@
|
|
|
7183
7183
|
|
|
7184
7184
|
var WebsocketService = /** @class */ (function () {
|
|
7185
7185
|
function WebsocketService() {
|
|
7186
|
-
/** @private */
|
|
7187
|
-
this.focused = true;
|
|
7188
7186
|
/** @private */
|
|
7189
7187
|
this.wasConnected = false;
|
|
7190
7188
|
/** @private */
|
|
7191
|
-
this.
|
|
7189
|
+
this.isConnected = false;
|
|
7192
7190
|
/** @private */
|
|
7193
7191
|
this.isConnecting = false;
|
|
7194
7192
|
/** @private */
|
|
7193
|
+
this.isReconnecting = false;
|
|
7194
|
+
/** @private */
|
|
7195
7195
|
this.primitiveManagers = new Map();
|
|
7196
7196
|
/** @private */
|
|
7197
7197
|
this.connect$ = new rxjs.Subject();
|
|
@@ -7201,23 +7201,19 @@
|
|
|
7201
7201
|
this.reconnect$ = new rxjs.Subject();
|
|
7202
7202
|
/** @private */
|
|
7203
7203
|
this.error$ = new rxjs.Subject();
|
|
7204
|
-
|
|
7205
|
-
window.onblur = this.onBlur;
|
|
7204
|
+
this.subscribe$ = new rxjs.Subject();
|
|
7206
7205
|
this.connect();
|
|
7207
7206
|
}
|
|
7208
7207
|
WebsocketService_1 = WebsocketService;
|
|
7209
7208
|
/**
|
|
7210
|
-
* Observable responsável por emitir uma notificação quando a conexão websocket é estabelecida.
|
|
7211
|
-
* @return Um `Observable<void>` que emite uma notificação quando a conexão websocket é estabelecida.
|
|
7209
|
+
* Observable responsável por emitir uma notificação quando a conexão websocket é estabelecida pela primeira vez.
|
|
7210
|
+
* @return Um `Observable<void>` que emite uma notificação quando a conexão websocket é estabelecida pela primeira vez.
|
|
7212
7211
|
*/
|
|
7213
7212
|
WebsocketService.prototype.onConnect = function () {
|
|
7214
|
-
|
|
7215
|
-
|
|
7216
|
-
|
|
7217
|
-
|
|
7218
|
-
}
|
|
7219
|
-
}, 0);
|
|
7220
|
-
return this.connect$.pipe(operators.first());
|
|
7213
|
+
if (this.isConnected || this.wasConnected) {
|
|
7214
|
+
return rxjs.of(undefined).pipe(operators.take(1));
|
|
7215
|
+
}
|
|
7216
|
+
return this.connect$.asObservable().pipe(operators.take(1));
|
|
7221
7217
|
};
|
|
7222
7218
|
/**
|
|
7223
7219
|
* Observable responsável por emitir uma notificação quando a conexão é desconectada.
|
|
@@ -7234,16 +7230,20 @@
|
|
|
7234
7230
|
return this.reconnect$.asObservable();
|
|
7235
7231
|
};
|
|
7236
7232
|
/**
|
|
7237
|
-
* Observable responsável por emitir uma notificação após o subscribe do evento.
|
|
7238
|
-
* @return Um `Observable<void>` que emite uma notificação após o subscribe do evento.
|
|
7233
|
+
* Observable responsável por emitir uma notificação após o subscribe do evento pela primeira vez.
|
|
7234
|
+
* @return Um `Observable<void>` que emite uma notificação após o subscribe do evento pela primeira vez.
|
|
7239
7235
|
*/
|
|
7240
7236
|
WebsocketService.prototype.onSubscribe = function (_a) {
|
|
7237
|
+
var _this = this;
|
|
7241
7238
|
var domain = _a.domain, service = _a.service, primitive = _a.primitive;
|
|
7242
|
-
var
|
|
7243
|
-
|
|
7244
|
-
|
|
7245
|
-
|
|
7246
|
-
|
|
7239
|
+
var key = this.getPrimitiveManagerKey(domain, service, primitive);
|
|
7240
|
+
return this.onConnect().pipe(operators.switchMap(function () {
|
|
7241
|
+
return _this.primitiveManagers.has(key) && _this.primitiveManagers.get(key).isSubscribed
|
|
7242
|
+
? rxjs.of(void 0).pipe(operators.take(1))
|
|
7243
|
+
: _this.subscribe$.pipe(operators.filter(function (primitiveManager) {
|
|
7244
|
+
return _this.getPrimitiveManagerKey(primitiveManager.domain, primitiveManager.service, primitiveManager.primitive) === key;
|
|
7245
|
+
}), operators.take(1), (operators.map(function () { return void 0; })));
|
|
7246
|
+
}));
|
|
7247
7247
|
};
|
|
7248
7248
|
/**
|
|
7249
7249
|
* Observable responsável por emitir uma notificação quando ocorre algum erro.
|
|
@@ -7273,25 +7273,21 @@
|
|
|
7273
7273
|
primitive: primitive,
|
|
7274
7274
|
stompSubscriptions: [],
|
|
7275
7275
|
event$: new rxjs.Subject(),
|
|
7276
|
-
|
|
7276
|
+
isSubscribed: false,
|
|
7277
7277
|
};
|
|
7278
7278
|
this.primitiveManagers.set(key, primitiveManager);
|
|
7279
|
-
if (this.isConnected
|
|
7279
|
+
if (this.isConnected) {
|
|
7280
7280
|
this.createStompSubscriptions(primitiveManager);
|
|
7281
|
-
return primitiveManager.event
|
|
7282
|
-
.asObservable()
|
|
7283
|
-
.pipe(operators.finalize(function () { return _this.disconnectPrimitiveOnFinalize(primitiveManager); }));
|
|
7281
|
+
return primitiveManager.event$.asObservable().pipe(operators.finalize(function () { return _this.disconnectPrimitiveOnFinalize(primitiveManager); }));
|
|
7284
7282
|
}
|
|
7285
7283
|
else {
|
|
7286
|
-
if (!this.isConnecting) {
|
|
7284
|
+
if (!this.isReconnecting && !this.isConnecting) {
|
|
7287
7285
|
this.connect();
|
|
7288
7286
|
}
|
|
7289
7287
|
this.connect$.pipe(operators.first()).subscribe(function () {
|
|
7290
7288
|
_this.createStompSubscriptions(primitiveManager);
|
|
7291
7289
|
});
|
|
7292
|
-
return primitiveManager.event
|
|
7293
|
-
.asObservable()
|
|
7294
|
-
.pipe(operators.finalize(function () { return _this.disconnectPrimitiveOnFinalize(primitiveManager); }));
|
|
7290
|
+
return primitiveManager.event$.asObservable().pipe(operators.finalize(function () { return _this.disconnectPrimitiveOnFinalize(primitiveManager); }));
|
|
7295
7291
|
}
|
|
7296
7292
|
};
|
|
7297
7293
|
/** @private */
|
|
@@ -7301,19 +7297,21 @@
|
|
|
7301
7297
|
var withoutTokenUrl = this.getSubscriptionUrlWithoutToken(primitiveManager.domain, primitiveManager.service, primitiveManager.primitive);
|
|
7302
7298
|
var stompSubscriptionWithoutToken = this.createStompSubscription(withoutTokenUrl, primitiveManager);
|
|
7303
7299
|
primitiveManager.stompSubscriptions = [stompSubscriptionWithToken, stompSubscriptionWithoutToken];
|
|
7304
|
-
primitiveManager.
|
|
7300
|
+
primitiveManager.isSubscribed = true;
|
|
7301
|
+
this.subscribe$.next(primitiveManager);
|
|
7305
7302
|
};
|
|
7306
7303
|
/** @private */
|
|
7307
7304
|
WebsocketService.prototype.connect = function () {
|
|
7308
7305
|
var _this = this;
|
|
7309
7306
|
this.createStompClient();
|
|
7310
7307
|
this.isConnecting = true;
|
|
7311
|
-
this._stompClient.activate();
|
|
7312
7308
|
this._stompClient.connect({}, function () {
|
|
7313
7309
|
_this.isConnecting = false;
|
|
7314
|
-
_this.
|
|
7310
|
+
_this.isReconnecting = false;
|
|
7311
|
+
_this.isConnected = true;
|
|
7315
7312
|
if (_this.wasConnected) {
|
|
7316
7313
|
_this.reconnectPrimitives();
|
|
7314
|
+
_this.connect$.next();
|
|
7317
7315
|
_this.reconnect$.next();
|
|
7318
7316
|
}
|
|
7319
7317
|
else {
|
|
@@ -7321,19 +7319,16 @@
|
|
|
7321
7319
|
_this.connect$.next();
|
|
7322
7320
|
}
|
|
7323
7321
|
}, function (error) {
|
|
7324
|
-
_this.
|
|
7322
|
+
_this.isConnected = false;
|
|
7325
7323
|
_this.error$.next(error);
|
|
7326
|
-
_this.
|
|
7324
|
+
_this.isReconnecting = true;
|
|
7325
|
+
rxjs.timer(WebsocketService_1.RECONNECT_INTERVAL)
|
|
7326
|
+
.pipe(operators.switchMap(function () {
|
|
7327
|
+
return rxjs.iif(function () { return document.hidden; }, rxjs.fromEvent(document, "visibilitychange").pipe(operators.first()), rxjs.EMPTY);
|
|
7328
|
+
}))
|
|
7329
|
+
.subscribe({ complete: function () { return _this.connect(); } });
|
|
7327
7330
|
});
|
|
7328
7331
|
};
|
|
7329
|
-
/** @private */
|
|
7330
|
-
WebsocketService.prototype.onFocus = function () {
|
|
7331
|
-
this.focused = true;
|
|
7332
|
-
};
|
|
7333
|
-
/** @private */
|
|
7334
|
-
WebsocketService.prototype.onBlur = function () {
|
|
7335
|
-
this.focused = false;
|
|
7336
|
-
};
|
|
7337
7332
|
WebsocketService.prototype.disconnect = function () {
|
|
7338
7333
|
var e_1, _a, e_2, _b, e_3, _c;
|
|
7339
7334
|
var observersCount = this.getObserversCount();
|
|
@@ -7368,7 +7363,6 @@
|
|
|
7368
7363
|
for (var _h = __values(this.primitiveManagers.values()), _j = _h.next(); !_j.done; _j = _h.next()) {
|
|
7369
7364
|
var primitiveManager = _j.value;
|
|
7370
7365
|
primitiveManager.event$.complete();
|
|
7371
|
-
primitiveManager.subscribe$.complete();
|
|
7372
7366
|
}
|
|
7373
7367
|
}
|
|
7374
7368
|
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
@@ -7381,20 +7375,12 @@
|
|
|
7381
7375
|
this.primitiveManagers.clear();
|
|
7382
7376
|
this._stompClient.disconnect();
|
|
7383
7377
|
this._stompClient.deactivate();
|
|
7384
|
-
this.
|
|
7378
|
+
this.isConnected = false;
|
|
7385
7379
|
this.isConnecting = false;
|
|
7386
7380
|
this.wasConnected = false;
|
|
7387
7381
|
this.disconnect$.next();
|
|
7388
7382
|
};
|
|
7389
7383
|
/** @private */
|
|
7390
|
-
WebsocketService.prototype.isConnected = function () {
|
|
7391
|
-
return this.connected;
|
|
7392
|
-
};
|
|
7393
|
-
/** @private */
|
|
7394
|
-
WebsocketService.prototype.setConnected = function (connected) {
|
|
7395
|
-
this.connected = connected;
|
|
7396
|
-
};
|
|
7397
|
-
/** @private */
|
|
7398
7384
|
WebsocketService.prototype.getSubscriptionUrlWithToken = function (domain, service, primitive) {
|
|
7399
7385
|
var tenant = WebsocketService_1.TOKEN ? WebsocketService_1.TOKEN.username.split("@")[1] : null;
|
|
7400
7386
|
var token = WebsocketService_1.TOKEN ? WebsocketService_1.TOKEN.access_token : null;
|
|
@@ -7416,58 +7402,28 @@
|
|
|
7416
7402
|
WebsocketService.prototype.createStompClient = function () {
|
|
7417
7403
|
var ws = new SockJS(WebsocketService_1.WEBSOCKET_URL + "subscription", null, { timeout: WebsocketService_1.CONNECTION_TIMEOUT });
|
|
7418
7404
|
this._stompClient = stompjs.Stomp.over(ws);
|
|
7419
|
-
|
|
7420
|
-
this._stompClient.debug = function () { }; // Para remover os logs.
|
|
7421
|
-
};
|
|
7422
|
-
/** @private */
|
|
7423
|
-
WebsocketService.prototype.reconnect = function () {
|
|
7424
|
-
var _this = this;
|
|
7425
|
-
if (this.connected)
|
|
7426
|
-
this._stompClient.disconnect();
|
|
7427
|
-
setTimeout(function () {
|
|
7428
|
-
if (_this.getObserversCount() === 0)
|
|
7429
|
-
return;
|
|
7430
|
-
if (_this.focused) {
|
|
7431
|
-
_this.connect();
|
|
7432
|
-
}
|
|
7433
|
-
else {
|
|
7434
|
-
_this.reconnect();
|
|
7435
|
-
}
|
|
7436
|
-
}, WebsocketService_1.RECONNECT_TIMER);
|
|
7405
|
+
this._stompClient.debug = function () { return null; };
|
|
7437
7406
|
};
|
|
7438
7407
|
/** @private */
|
|
7439
7408
|
WebsocketService.prototype.reconnectPrimitives = function () {
|
|
7440
|
-
var e_4, _a
|
|
7409
|
+
var e_4, _a;
|
|
7441
7410
|
try {
|
|
7442
|
-
for (var
|
|
7443
|
-
var primitiveManager =
|
|
7444
|
-
try {
|
|
7445
|
-
for (var _e = (e_5 = void 0, __values(primitiveManager.stompSubscriptions)), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
7446
|
-
var stompSubscription = _f.value;
|
|
7447
|
-
stompSubscription.unsubscribe();
|
|
7448
|
-
}
|
|
7449
|
-
}
|
|
7450
|
-
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
7451
|
-
finally {
|
|
7452
|
-
try {
|
|
7453
|
-
if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
|
|
7454
|
-
}
|
|
7455
|
-
finally { if (e_5) throw e_5.error; }
|
|
7456
|
-
}
|
|
7411
|
+
for (var _b = __values(this.primitiveManagers.values()), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
7412
|
+
var primitiveManager = _c.value;
|
|
7457
7413
|
this.createStompSubscriptions(primitiveManager);
|
|
7458
7414
|
}
|
|
7459
7415
|
}
|
|
7460
7416
|
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
7461
7417
|
finally {
|
|
7462
7418
|
try {
|
|
7463
|
-
if (
|
|
7419
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
7464
7420
|
}
|
|
7465
7421
|
finally { if (e_4) throw e_4.error; }
|
|
7466
7422
|
}
|
|
7467
7423
|
};
|
|
7468
7424
|
/** @private */
|
|
7469
7425
|
WebsocketService.prototype.getObserversCount = function () {
|
|
7470
|
-
var
|
|
7426
|
+
var e_5, _a;
|
|
7471
7427
|
var observersCount = 0;
|
|
7472
7428
|
try {
|
|
7473
7429
|
for (var _b = __values(this.primitiveManagers.values()), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
@@ -7475,36 +7431,35 @@
|
|
|
7475
7431
|
observersCount += primitiveManager.event$.observers.length;
|
|
7476
7432
|
}
|
|
7477
7433
|
}
|
|
7478
|
-
catch (
|
|
7434
|
+
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
7479
7435
|
finally {
|
|
7480
7436
|
try {
|
|
7481
7437
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
7482
7438
|
}
|
|
7483
|
-
finally { if (
|
|
7439
|
+
finally { if (e_5) throw e_5.error; }
|
|
7484
7440
|
}
|
|
7485
7441
|
return observersCount;
|
|
7486
7442
|
};
|
|
7487
7443
|
/** @private */
|
|
7488
7444
|
WebsocketService.prototype.disconnectPrimitiveOnFinalize = function (primitiveManager) {
|
|
7489
|
-
var
|
|
7445
|
+
var e_6, _a;
|
|
7490
7446
|
// @IMPORTANT: Replace .observers.length === 1 with .observed in rxjs 7.0+
|
|
7491
7447
|
var hasObservers = !(primitiveManager.event$.observers.length === 1);
|
|
7492
7448
|
if (hasObservers)
|
|
7493
7449
|
return;
|
|
7494
7450
|
primitiveManager.event$.complete();
|
|
7495
|
-
primitiveManager.subscribe$.complete();
|
|
7496
7451
|
try {
|
|
7497
7452
|
for (var _b = __values(primitiveManager.stompSubscriptions), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
7498
7453
|
var stompSubscription = _c.value;
|
|
7499
7454
|
stompSubscription.unsubscribe();
|
|
7500
7455
|
}
|
|
7501
7456
|
}
|
|
7502
|
-
catch (
|
|
7457
|
+
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
7503
7458
|
finally {
|
|
7504
7459
|
try {
|
|
7505
7460
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
7506
7461
|
}
|
|
7507
|
-
finally { if (
|
|
7462
|
+
finally { if (e_6) throw e_6.error; }
|
|
7508
7463
|
}
|
|
7509
7464
|
var key = this.getPrimitiveManagerKey(primitiveManager.domain, primitiveManager.service, primitiveManager.primitive);
|
|
7510
7465
|
this.primitiveManagers.delete(key);
|
|
@@ -7516,7 +7471,7 @@
|
|
|
7516
7471
|
};
|
|
7517
7472
|
var WebsocketService_1;
|
|
7518
7473
|
/** @private */
|
|
7519
|
-
WebsocketService.
|
|
7474
|
+
WebsocketService.RECONNECT_INTERVAL = 3000;
|
|
7520
7475
|
/** @private */
|
|
7521
7476
|
WebsocketService.CONNECTION_TIMEOUT = 15000;
|
|
7522
7477
|
/** @private */
|