@senior-gestao-empresarial/angular-components 6.12.0-bea9aaec-b4b5-4e5b-b8eb-155b7aa8d5aa → 6.12.0-cdee7359-3bca-4813-b06f-c65cc860eea4

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.
Files changed (29) hide show
  1. package/bundles/senior-gestao-empresarial-angular-components.umd.js +150 -54
  2. package/bundles/senior-gestao-empresarial-angular-components.umd.js.map +1 -1
  3. package/bundles/senior-gestao-empresarial-angular-components.umd.min.js +2 -2
  4. package/bundles/senior-gestao-empresarial-angular-components.umd.min.js.map +1 -1
  5. package/components/utils/async-lock.d.ts +6 -0
  6. package/components/websocket/index.d.ts +2 -0
  7. package/components/websocket/models/index.d.ts +1 -0
  8. package/components/websocket/protocols/index.d.ts +2 -0
  9. package/components/websocket/websocket.service.d.ts +3 -3
  10. package/esm2015/components/utils/async-lock.js +34 -0
  11. package/esm2015/components/websocket/index.js +2 -1
  12. package/esm2015/components/websocket/models/index.js +2 -0
  13. package/esm2015/components/websocket/models/primitive-manager.js +2 -2
  14. package/esm2015/components/websocket/protocols/index.js +1 -0
  15. package/esm2015/components/websocket/user-information.service.js +2 -2
  16. package/esm2015/components/websocket/websocket.service.js +76 -53
  17. package/esm5/components/utils/async-lock.js +43 -0
  18. package/esm5/components/websocket/index.js +2 -1
  19. package/esm5/components/websocket/models/index.js +2 -0
  20. package/esm5/components/websocket/models/primitive-manager.js +2 -2
  21. package/esm5/components/websocket/protocols/index.js +1 -0
  22. package/esm5/components/websocket/user-information.service.js +2 -2
  23. package/esm5/components/websocket/websocket.service.js +109 -54
  24. package/fesm2015/senior-gestao-empresarial-angular-components.js +109 -54
  25. package/fesm2015/senior-gestao-empresarial-angular-components.js.map +1 -1
  26. package/fesm5/senior-gestao-empresarial-angular-components.js +150 -55
  27. package/fesm5/senior-gestao-empresarial-angular-components.js.map +1 -1
  28. package/package.json +1 -1
  29. package/senior-gestao-empresarial-angular-components.metadata.json +1 -1
@@ -7206,6 +7206,47 @@ var NpsService = /** @class */ (function () {
7206
7206
  return NpsService;
7207
7207
  }());
7208
7208
 
7209
+ var AsyncLock = /** @class */ (function () {
7210
+ function AsyncLock() {
7211
+ this.queue = [];
7212
+ this.acquired = false;
7213
+ }
7214
+ AsyncLock.prototype.acquire = function () {
7215
+ return __awaiter(this, void 0, void 0, function () {
7216
+ var _this = this;
7217
+ return __generator(this, function (_a) {
7218
+ if (!this.acquired) {
7219
+ this.acquired = true;
7220
+ return [2 /*return*/, Promise.resolve()];
7221
+ }
7222
+ else {
7223
+ return [2 /*return*/, new Promise(function (resolve, _) {
7224
+ _this.queue.push(resolve);
7225
+ })];
7226
+ }
7227
+ return [2 /*return*/];
7228
+ });
7229
+ });
7230
+ };
7231
+ AsyncLock.prototype.release = function () {
7232
+ return __awaiter(this, void 0, void 0, function () {
7233
+ var continuation;
7234
+ return __generator(this, function (_a) {
7235
+ if (this.queue.length === 0 && this.acquired) {
7236
+ this.acquired = false;
7237
+ return [2 /*return*/, Promise.resolve()];
7238
+ }
7239
+ continuation = this.queue.shift();
7240
+ return [2 /*return*/, new Promise(function (res) {
7241
+ continuation();
7242
+ res();
7243
+ })];
7244
+ });
7245
+ });
7246
+ };
7247
+ return AsyncLock;
7248
+ }());
7249
+
7209
7250
  var UserInformationService = /** @class */ (function () {
7210
7251
  function UserInformationService() {
7211
7252
  }
@@ -7222,7 +7263,7 @@ var UserInformationService = /** @class */ (function () {
7222
7263
  };
7223
7264
  UserInformationService.prototype.getWebSocketUrl = function () {
7224
7265
  var baseUrl = get(UserInformationService_1.BASE_URL_COOKIE_KEY);
7225
- if (!baseUrl.endsWith('/')) {
7266
+ if (baseUrl && !baseUrl.endsWith('/')) {
7226
7267
  baseUrl += '/';
7227
7268
  }
7228
7269
  return baseUrl + 'websocket';
@@ -7286,7 +7327,7 @@ var PrimitiveManager = /** @class */ (function () {
7286
7327
  };
7287
7328
  PrimitiveManager.prototype.hasObservers = function () {
7288
7329
  // @IMPORTANT: Replace .observers.length === 1 with .observed in rxjs 7.0+
7289
- return this.event$.observers.length > 1;
7330
+ return this.event$.observers.length !== 1;
7290
7331
  };
7291
7332
  PrimitiveManager.prototype.getObserversCount = function () {
7292
7333
  return this.event$.observers.length;
@@ -7305,6 +7346,7 @@ var WebsocketService = /** @class */ (function () {
7305
7346
  this.error$ = new Subject();
7306
7347
  this.subscribed$ = new Subject();
7307
7348
  this.primitiveManagers = new Map();
7349
+ this.connectionLock = new AsyncLock();
7308
7350
  this.debugEnable = false;
7309
7351
  this.lostConnection = false;
7310
7352
  }
@@ -7318,29 +7360,48 @@ var WebsocketService = /** @class */ (function () {
7318
7360
  * Manually starts the connection
7319
7361
  */
7320
7362
  WebsocketService.prototype.connect = function () {
7321
- var _this = this;
7322
- if (this.isConnected() || this.isConnecting()) {
7323
- return;
7324
- }
7325
- this.lostConnection = false;
7326
- var stompConfig = {
7327
- webSocketFactory: function () {
7328
- return new SockJS(_this.getSubscriptionUrl(), null, {
7329
- timeout: CONNECTION_TIMEOUT_MILLISECONDS
7330
- });
7331
- },
7332
- connectionTimeout: CONNECTION_TIMEOUT_MILLISECONDS,
7333
- reconnectDelay: RECONNECT_INTERVAL_MILLISECONDS,
7334
- debug: this.debug.bind(this),
7335
- onConnect: this.handleOnConnected.bind(this),
7336
- onDisconnect: this.handleOnDisconnect.bind(this),
7337
- onWebSocketClose: this.handleOnWebSocketClose.bind(this),
7338
- onStompError: this.handleOnStompError.bind(this),
7339
- onWebSocketError: this.handleOnWebSocketError.bind(this)
7340
- };
7341
- this.debug('Connecting the Webscoket');
7342
- this.stompClient = new Client(stompConfig);
7343
- this.stompClient.activate();
7363
+ return __awaiter(this, void 0, void 0, function () {
7364
+ var stompConfig;
7365
+ var _this = this;
7366
+ return __generator(this, function (_a) {
7367
+ switch (_a.label) {
7368
+ case 0: return [4 /*yield*/, this.connectionLock.acquire()];
7369
+ case 1:
7370
+ _a.sent();
7371
+ _a.label = 2;
7372
+ case 2:
7373
+ _a.trys.push([2, , 3, 5]);
7374
+ if (this.isConnected() || this.isConnecting()) {
7375
+ return [2 /*return*/];
7376
+ }
7377
+ this.lostConnection = false;
7378
+ stompConfig = {
7379
+ webSocketFactory: function () {
7380
+ return new SockJS(_this.getSubscriptionUrl(), null, {
7381
+ timeout: CONNECTION_TIMEOUT_MILLISECONDS
7382
+ });
7383
+ },
7384
+ connectionTimeout: CONNECTION_TIMEOUT_MILLISECONDS,
7385
+ reconnectDelay: RECONNECT_INTERVAL_MILLISECONDS,
7386
+ debug: this.debug.bind(this),
7387
+ onConnect: this.handleOnConnected.bind(this),
7388
+ onDisconnect: this.handleOnDisconnect.bind(this),
7389
+ onWebSocketClose: this.handleOnWebSocketClose.bind(this),
7390
+ onStompError: this.handleOnStompError.bind(this),
7391
+ onWebSocketError: this.handleOnWebSocketError.bind(this)
7392
+ };
7393
+ this.debug('Connecting the Webscoket');
7394
+ this.stompClient = new Client(stompConfig);
7395
+ this.stompClient.activate();
7396
+ return [3 /*break*/, 5];
7397
+ case 3: return [4 /*yield*/, this.connectionLock.release()];
7398
+ case 4:
7399
+ _a.sent();
7400
+ return [7 /*endfinally*/];
7401
+ case 5: return [2 /*return*/];
7402
+ }
7403
+ });
7404
+ });
7344
7405
  };
7345
7406
  /**
7346
7407
  * Manually disconnect the websocket. The reconnect loop will be stopped.
@@ -7352,6 +7413,15 @@ var WebsocketService = /** @class */ (function () {
7352
7413
  return __generator(this, function (_d) {
7353
7414
  switch (_d.label) {
7354
7415
  case 0:
7416
+ if (!this.isConnected()) {
7417
+ return [2 /*return*/];
7418
+ }
7419
+ return [4 /*yield*/, this.connectionLock.acquire()];
7420
+ case 1:
7421
+ _d.sent();
7422
+ _d.label = 2;
7423
+ case 2:
7424
+ _d.trys.push([2, , 5, 7]);
7355
7425
  try {
7356
7426
  for (_a = __values(this.primitiveManagers.values()), _b = _a.next(); !_b.done; _b = _a.next()) {
7357
7427
  primitiveManager = _b.value;
@@ -7366,15 +7436,19 @@ var WebsocketService = /** @class */ (function () {
7366
7436
  finally { if (e_1) throw e_1.error; }
7367
7437
  }
7368
7438
  this.primitiveManagers.clear();
7369
- if (!this.stompClient) return [3 /*break*/, 2];
7439
+ this.connected$.next(false);
7440
+ if (!this.stompClient) return [3 /*break*/, 4];
7441
+ this.stompClient.forceDisconnect();
7370
7442
  return [4 /*yield*/, this.stompClient.deactivate()];
7371
- case 1:
7443
+ case 3:
7372
7444
  _d.sent();
7373
- this.stompClient = null;
7374
- _d.label = 2;
7375
- case 2:
7376
- this.connected$.next(false);
7377
- return [2 /*return*/];
7445
+ _d.label = 4;
7446
+ case 4: return [3 /*break*/, 7];
7447
+ case 5: return [4 /*yield*/, this.connectionLock.release()];
7448
+ case 6:
7449
+ _d.sent();
7450
+ return [7 /*endfinally*/];
7451
+ case 7: return [2 /*return*/];
7378
7452
  }
7379
7453
  });
7380
7454
  });
@@ -7448,11 +7522,12 @@ var WebsocketService = /** @class */ (function () {
7448
7522
  }
7449
7523
  var primitiveManager = new PrimitiveManager(domain, service, primitive);
7450
7524
  this.primitiveManagers.set(key, primitiveManager);
7451
- this.connect();
7452
- this.onConnect()
7453
- .pipe(take(1))
7454
- .subscribe(function () {
7455
- _this.createStompSubscriptions(primitiveManager);
7525
+ this.connect().then(function () {
7526
+ _this.onConnect()
7527
+ .pipe(take(1))
7528
+ .subscribe(function () {
7529
+ _this.createStompSubscriptions(primitiveManager);
7530
+ });
7456
7531
  });
7457
7532
  return primitiveManager
7458
7533
  .getEventObservable()
@@ -7469,7 +7544,6 @@ var WebsocketService = /** @class */ (function () {
7469
7544
  var _this = this;
7470
7545
  var domain = options.domain, service = options.service, primitive = options.primitive;
7471
7546
  var key = this.buildPrimitiveManagerKey(domain, service, primitive);
7472
- this.connect();
7473
7547
  return this.onConnect().pipe(take(1), switchMap(function () {
7474
7548
  if (_this.primitiveManagers.has(key)) {
7475
7549
  return _this.primitiveManagers
@@ -7495,16 +7569,17 @@ var WebsocketService = /** @class */ (function () {
7495
7569
  WebsocketService.prototype.info = function (message) {
7496
7570
  console.info('WS info: ' + message);
7497
7571
  };
7498
- WebsocketService.prototype.handleOnConnected = function (data) {
7499
- this.debug('Webscoket connected', data);
7572
+ WebsocketService.prototype.handleOnConnected = function () {
7573
+ this.info('Webscoket connected');
7500
7574
  this.connected$.next(true);
7501
7575
  if (this.lostConnection) {
7502
7576
  this.info('Webscoket reconnected, recriating subscriptions');
7503
7577
  this.handleReconnection();
7504
7578
  }
7505
7579
  };
7506
- WebsocketService.prototype.handleOnDisconnect = function (data) {
7507
- this.debug('Webscoket disconnected', data);
7580
+ WebsocketService.prototype.handleOnDisconnect = function () {
7581
+ this.info('Webscoket disconnected');
7582
+ this.connected$.next(false);
7508
7583
  this.disconnected$.next();
7509
7584
  };
7510
7585
  WebsocketService.prototype.handleOnWebSocketClose = function (data) {
@@ -7514,7 +7589,6 @@ var WebsocketService = /** @class */ (function () {
7514
7589
  this.lostConnection = true;
7515
7590
  };
7516
7591
  WebsocketService.prototype.handleOnStompError = function (data) {
7517
- debugger;
7518
7592
  this.handleError('StompError', data);
7519
7593
  if (this.isAuthenticationError(data)) {
7520
7594
  this.info('Authentication error, recriating subscriptions');
@@ -7570,19 +7644,40 @@ var WebsocketService = /** @class */ (function () {
7570
7644
  return domain + "/" + service + "/" + primitive;
7571
7645
  };
7572
7646
  WebsocketService.prototype.unsubscribePrimitiveOnFinalize = function (primitiveManager) {
7573
- if (primitiveManager.hasObservers()) {
7574
- return;
7575
- }
7576
- primitiveManager.unsubscribe();
7577
- var key = this.buildPrimitiveManagerKey(primitiveManager.domain, primitiveManager.service, primitiveManager.primitive);
7578
- this.primitiveManagers.delete(key);
7579
- this.disconnectIfNoMoreObservables();
7647
+ return __awaiter(this, void 0, void 0, function () {
7648
+ var key;
7649
+ return __generator(this, function (_a) {
7650
+ switch (_a.label) {
7651
+ case 0:
7652
+ if (primitiveManager.hasObservers()) {
7653
+ return [2 /*return*/];
7654
+ }
7655
+ primitiveManager.unsubscribe();
7656
+ key = this.buildPrimitiveManagerKey(primitiveManager.domain, primitiveManager.service, primitiveManager.primitive);
7657
+ this.primitiveManagers.delete(key);
7658
+ return [4 /*yield*/, this.disconnectIfNoMoreObservables()];
7659
+ case 1:
7660
+ _a.sent();
7661
+ return [2 /*return*/];
7662
+ }
7663
+ });
7664
+ });
7580
7665
  };
7581
7666
  WebsocketService.prototype.disconnectIfNoMoreObservables = function () {
7582
- if (this.getObserversCount() === 0) {
7583
- this.debug('Manually disconnecting because there are no more observers');
7584
- this.disconnect();
7585
- }
7667
+ return __awaiter(this, void 0, void 0, function () {
7668
+ return __generator(this, function (_a) {
7669
+ switch (_a.label) {
7670
+ case 0:
7671
+ if (!(this.getObserversCount() === 0)) return [3 /*break*/, 2];
7672
+ this.debug('Manually disconnecting because there are no more observers');
7673
+ return [4 /*yield*/, this.disconnect()];
7674
+ case 1:
7675
+ _a.sent();
7676
+ _a.label = 2;
7677
+ case 2: return [2 /*return*/];
7678
+ }
7679
+ });
7680
+ });
7586
7681
  };
7587
7682
  WebsocketService.prototype.getObserversCount = function () {
7588
7683
  var observersCount = 0;
@@ -7773,5 +7868,5 @@ var ModulesEnum;
7773
7868
  * Generated bundle index. Do not edit.
7774
7869
  */
7775
7870
 
7776
- export { AgreementLookup, BankLookup, BeneficioFiscalLookup, BreadcrumbComponent, BreadcrumbModule, Breakpoints, ContaInternaFilialLookup, CountryLookup, CplTriNotaSaidaE001EndLookup, CplTriNotaSaidaE001PesLookup, CplTriNotaSaidaE001TnsLookup, CplTriNotaSaidaE007UfsLookup, CplTriNotaSaidaE008RaiLookup, CplTriNotaSaidaE015MedLookup, CplTriNotaSaidaE020SnfLookup, CplTriNotaSaidaE024MsgLookup, CplTriNotaSaidaE028CpgLookup, CplTriNotaSaidaE032EdcLookup, CplTriNotaSaidaE051DisLookup, CplTriNotaSaidaE066FpgLookup, CplTriNotaSaidaE070EmpLookup, CplTriNotaSaidaE070FilLookup, CplTriNotaSaidaE075DerLookup, CplTriNotaSaidaE080SerLookup, CplTriNotaSaidaNaturezaReceitaPisCofinsLookup, CplTriNotaSaidaNcmLookup, CplTriNotaSaidaNfEntradaLookup, CplTriNotaSaidaNfSaidaLookup, CurrencyLookup, DocumentoLookup, E001EndLookup, E001PesLookup, E001TnsLookup, E001TnsSupEstLookup, E002TptLookup, E007UfsLookup, E008CepLookup, E008RaiLookup, E012FamLookup, E015MedLookup, E020SnfLookup, E021MotLookup, E023CrpLookup, E024MsgLookup, E027EqiLookup, E027StrLookup, E028CpgLookup, E030AgeLookup, E030BanLookup, E031MoeLookup, E032EdcLookup, E035OcrLookup, E036InsLookup, E039PorLookup, E043MpcLookup, E043PcmLookup, E044CcuFinRatDepLookup, E044CcuLookup, E045PlaLookup, E046HpdLookup, E047NtgLookup, E048FctLookup, E048SfcLookup, E051DisLookup, E066FpgLookup, E067FinLookup, E069GreLookup, E070EmpLookup, E070EntLookup, E070FilLookup, E073PesLookup, E073VeiLookup, E075DerLookup, E080SerLookup, E081TabLookup, E082TprLookup, E085PesLookup, E089DocLookup, E090HrpComGerLookup, E090PesLookup, E091PlfFinRatLookup, E095PesLookup, E099UsuComGerLookup, E099UsuSupCprLookup, E140InsLookup, E140NfsLookup, E200LotLookup, E200SerLookup, E205DepLookup, E210DxpE075DerLookup, E210DxpLookup, E301TcrLookup, E403FprLookup, E420IcpLookup, E420IpcLookup, E420OcpLookup, E501TcpLookup, E600CcoLookup, E640LotLookup, EntityPersonProductLookup, EnumLogicalOperator, EquipmentLookup, ErpLookups, ErpLookupsModule, ErpPolling, ExportUtils, FiltersStorageService, FormUtilsService, HTTP_STATUS_CODE, LigacaoItemFornecedorLookup, LookupValidationUtils, ModulesEnum, NcmLookup, NotaFiscalEntradaLookup, NpsService, ParametersLookup, ProdutoServicoLookup, QuantidadeDisponivelDemandaLookup, RequisicaoLookup, SegmentoLookup, TypeTaxesLookup, UnidadeMedidaLookup, UtilsModule, VerifyModulePermission, VerifyModulePermissions, WebsocketService, naturezaReceitaPisCofins, ɵ0, ErpLookupsService as ɵa, EnumAnaSin as ɵb, EnumNatCtb as ɵc, StorageService as ɵd, UserInformationService as ɵe, VerifyModulePermissionService as ɵf, VerifyModulePermissionsService as ɵg };
7871
+ export { AgreementLookup, BankLookup, BeneficioFiscalLookup, BreadcrumbComponent, BreadcrumbModule, Breakpoints, ContaInternaFilialLookup, CountryLookup, CplTriNotaSaidaE001EndLookup, CplTriNotaSaidaE001PesLookup, CplTriNotaSaidaE001TnsLookup, CplTriNotaSaidaE007UfsLookup, CplTriNotaSaidaE008RaiLookup, CplTriNotaSaidaE015MedLookup, CplTriNotaSaidaE020SnfLookup, CplTriNotaSaidaE024MsgLookup, CplTriNotaSaidaE028CpgLookup, CplTriNotaSaidaE032EdcLookup, CplTriNotaSaidaE051DisLookup, CplTriNotaSaidaE066FpgLookup, CplTriNotaSaidaE070EmpLookup, CplTriNotaSaidaE070FilLookup, CplTriNotaSaidaE075DerLookup, CplTriNotaSaidaE080SerLookup, CplTriNotaSaidaNaturezaReceitaPisCofinsLookup, CplTriNotaSaidaNcmLookup, CplTriNotaSaidaNfEntradaLookup, CplTriNotaSaidaNfSaidaLookup, CurrencyLookup, DocumentoLookup, E001EndLookup, E001PesLookup, E001TnsLookup, E001TnsSupEstLookup, E002TptLookup, E007UfsLookup, E008CepLookup, E008RaiLookup, E012FamLookup, E015MedLookup, E020SnfLookup, E021MotLookup, E023CrpLookup, E024MsgLookup, E027EqiLookup, E027StrLookup, E028CpgLookup, E030AgeLookup, E030BanLookup, E031MoeLookup, E032EdcLookup, E035OcrLookup, E036InsLookup, E039PorLookup, E043MpcLookup, E043PcmLookup, E044CcuFinRatDepLookup, E044CcuLookup, E045PlaLookup, E046HpdLookup, E047NtgLookup, E048FctLookup, E048SfcLookup, E051DisLookup, E066FpgLookup, E067FinLookup, E069GreLookup, E070EmpLookup, E070EntLookup, E070FilLookup, E073PesLookup, E073VeiLookup, E075DerLookup, E080SerLookup, E081TabLookup, E082TprLookup, E085PesLookup, E089DocLookup, E090HrpComGerLookup, E090PesLookup, E091PlfFinRatLookup, E095PesLookup, E099UsuComGerLookup, E099UsuSupCprLookup, E140InsLookup, E140NfsLookup, E200LotLookup, E200SerLookup, E205DepLookup, E210DxpE075DerLookup, E210DxpLookup, E301TcrLookup, E403FprLookup, E420IcpLookup, E420IpcLookup, E420OcpLookup, E501TcpLookup, E600CcoLookup, E640LotLookup, EntityPersonProductLookup, EnumLogicalOperator, EquipmentLookup, ErpLookups, ErpLookupsModule, ErpPolling, ExportUtils, FiltersStorageService, FormUtilsService, HTTP_STATUS_CODE, LigacaoItemFornecedorLookup, LookupValidationUtils, ModulesEnum, NcmLookup, NotaFiscalEntradaLookup, NpsService, ParametersLookup, PrimitiveManager, ProdutoServicoLookup, QuantidadeDisponivelDemandaLookup, RequisicaoLookup, SegmentoLookup, TypeTaxesLookup, UnidadeMedidaLookup, UtilsModule, VerifyModulePermission, VerifyModulePermissions, WebsocketService, naturezaReceitaPisCofins, ɵ0, ErpLookupsService as ɵa, EnumAnaSin as ɵb, EnumNatCtb as ɵc, StorageService as ɵd, UserInformationService as ɵe, VerifyModulePermissionService as ɵf, VerifyModulePermissionsService as ɵg };
7777
7872
  //# sourceMappingURL=senior-gestao-empresarial-angular-components.js.map