@esfaenza/signalr-notifications 13.1.3 → 13.3.1

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.
@@ -5,14 +5,18 @@ import * as i0 from "@angular/core";
5
5
  * Classe base da estendere con la definizione degli Endpoint supportati dall'applicazione
6
6
  */
7
7
  export class BaseMessageService {
8
- /**
9
- * Entrypoint che restituisce tutti gli Endpoint dell'applicazione
10
- */
11
- get AllDefinitions() { return []; }
8
+ constructor() {
9
+ this.definitions = [];
10
+ }
11
+ /** Entrypoint che restituisce tutti gli Endpoint dell'applicazione. Da overridare qualora non venga utilizzato il metodo **add** */
12
+ get AllDefinitions() { return this.definitions; }
13
+ add(endpoint) {
14
+ this.definitions.push(endpoint);
15
+ }
12
16
  }
13
- BaseMessageService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: BaseMessageService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
14
- BaseMessageService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: BaseMessageService });
15
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: BaseMessageService, decorators: [{
17
+ BaseMessageService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.9", ngImport: i0, type: BaseMessageService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
18
+ BaseMessageService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.9", ngImport: i0, type: BaseMessageService });
19
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.9", ngImport: i0, type: BaseMessageService, decorators: [{
16
20
  type: Injectable
17
21
  }] });
18
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiQmFzZU1lc3NhZ2VTZXJ2aWNlLmpzIiwic291cmNlUm9v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ASW5qZWN0YWJsZSgpXHJcbmV4cG9ydCBjbGFzcyBCYXNlTWVzc2FnZVNlcnZpY2Uge1xyXG5cclxuICAgIHByaXZhdGUgZGVmaW5pdGlvbnM6IEVuZHBvaW50RGVmPGFueSwgYW55PltdID0gW107XHJcblxyXG4gICAgLyoqIEVudHJ5cG9pbnQgY2hlIHJlc3RpdHVpc2NlIHR1dHRpIGdsaSBFbmRwb2ludCBkZWxsJ2FwcGxpY2F6aW9uZS4gRGEgb3ZlcnJpZGFyZSBxdWFsb3JhIG5vbiB2ZW5nYSB1dGlsaXp6YXRvIGlsIG1ldG9kbyAqKmFkZCoqICovXHJcbiAgICBwdWJsaWMgZ2V0IEFsbERlZmluaXRpb25zKCk6IEVuZHBvaW50RGVmPGFueSwgYW55PltdIHsgcmV0dXJuIHRoaXMuZGVmaW5pdGlvbnM7IH1cclxuXHJcbiAgICBwdWJsaWMgYWRkKGVuZHBvaW50OiBFbmRwb2ludERlZjxhbnksIGFueT4pIHtcclxuICAgICAgICB0aGlzLmRlZmluaXRpb25zLnB1c2goZW5kcG9pbnQpO1xyXG4gICAgfVxyXG59Il19
@@ -14,5 +14,17 @@ export class EndpointDef {
14
14
  this.inTypeDefault = inTypeDefault;
15
15
  this.outTypeDefault = outTypeDefault;
16
16
  }
17
+ /** Helper per la creazione rapida di un Endpoint di solo INPUT */
18
+ static In(name, inTypeDefault) {
19
+ return new EndpointDef(name, inTypeDefault, undefined);
20
+ }
21
+ /** Helper per la creazione rapida di un Endpoint di solo OUTPUT */
22
+ static Out(name, outTypeDefault) {
23
+ return new EndpointDef(name, undefined, outTypeDefault);
24
+ }
25
+ /** Helper per la creazione rapida di un Endpoint di INPUT e OUTPUT (BIDIREZIONALE) */
26
+ static Bi(name, inTypeDefault, outTypeDefault) {
27
+ return new EndpointDef(name, inTypeDefault, outTypeDefault);
28
+ }
17
29
  }
18
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiRW5kcG9pbnRE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ldyBFbmRwb2ludERlZjxUSW4sIFRPdXQ+KG5hbWUsIGluVHlwZURlZmF1bHQsIG91dFR5cGVEZWZhdWx0KTtcclxuICAgIH1cclxufSJdfQ==
@@ -20,10 +20,10 @@ export class SignalrNotificationsModule {
20
20
  };
21
21
  }
22
22
  }
23
- SignalrNotificationsModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: SignalrNotificationsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
24
- SignalrNotificationsModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: SignalrNotificationsModule });
25
- SignalrNotificationsModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: SignalrNotificationsModule });
26
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: SignalrNotificationsModule, decorators: [{
23
+ SignalrNotificationsModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.9", ngImport: i0, type: SignalrNotificationsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
24
+ SignalrNotificationsModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.9", ngImport: i0, type: SignalrNotificationsModule });
25
+ SignalrNotificationsModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.9", ngImport: i0, type: SignalrNotificationsModule });
26
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.9", ngImport: i0, type: SignalrNotificationsModule, decorators: [{
27
27
  type: NgModule
28
28
  }] });
29
29
  //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2lnbmFsci1ub3RpZmljYXRpb25zLm1vZHVsZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4u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A6IGZhbHNlIH0sXHJcbiAgICAgICAgeyBwcm92aWRlOiBNRVNTQUdFX1BBQ0ssIHVzZVZhbHVlOiBjb25maWc/LmF1dG9SZWNvbm5lY3QgIT0gbnVsbCA/IGNvbmZpZz8uYXV0b1JlY29ubmVjdCA6IGZhbHNlIH0sXHJcbiAgICAgICAgeyBwcm92aWRlOiBBVVRPX1JFQ09OTkVDVCwgdXNlVmFsdWU6IGNvbmZpZz8udXNlTWVzc2FnZVBhY2sgIT0gbnVsbCA/IGNvbmZpZz8udXNlTWVzc2FnZVBhY2sgOiBmYWxzZSB9LFxyXG4gICAgICBdXHJcbiAgICB9O1xyXG4gIH1cclxufSJdfQ==
@@ -217,9 +217,9 @@ export class NotificationsService {
217
217
  return Loc[message][this.locale];
218
218
  }
219
219
  }
220
- NotificationsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: NotificationsService, deps: [{ token: i1.BaseMessageService }, { token: HUB_URL }, { token: MESSAGE_PACK }, { token: SIGNALR_ENABLED }, { token: DEBUG_MODE }, { token: AUTO_RECONNECT }, { token: LOCALE }], target: i0.ɵɵFactoryTarget.Injectable });
221
- NotificationsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: NotificationsService });
222
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: NotificationsService, decorators: [{
220
+ NotificationsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.9", ngImport: i0, type: NotificationsService, deps: [{ token: i1.BaseMessageService }, { token: HUB_URL }, { token: MESSAGE_PACK }, { token: SIGNALR_ENABLED }, { token: DEBUG_MODE }, { token: AUTO_RECONNECT }, { token: LOCALE }], target: i0.ɵɵFactoryTarget.Injectable });
221
+ NotificationsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.9", ngImport: i0, type: NotificationsService });
222
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.9", ngImport: i0, type: NotificationsService, decorators: [{
223
223
  type: Injectable
224
224
  }], ctorParameters: function () { return [{ type: i1.BaseMessageService }, { type: undefined, decorators: [{
225
225
  type: Inject,
@@ -60,14 +60,18 @@ const Loc = {
60
60
  * Classe base da estendere con la definizione degli Endpoint supportati dall'applicazione
61
61
  */
62
62
  class BaseMessageService {
63
- /**
64
- * Entrypoint che restituisce tutti gli Endpoint dell'applicazione
65
- */
66
- get AllDefinitions() { return []; }
63
+ constructor() {
64
+ this.definitions = [];
65
+ }
66
+ /** Entrypoint che restituisce tutti gli Endpoint dell'applicazione. Da overridare qualora non venga utilizzato il metodo **add** */
67
+ get AllDefinitions() { return this.definitions; }
68
+ add(endpoint) {
69
+ this.definitions.push(endpoint);
70
+ }
67
71
  }
68
- BaseMessageService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: BaseMessageService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
69
- BaseMessageService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: BaseMessageService });
70
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: BaseMessageService, decorators: [{
72
+ BaseMessageService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.9", ngImport: i0, type: BaseMessageService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
73
+ BaseMessageService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.9", ngImport: i0, type: BaseMessageService });
74
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.9", ngImport: i0, type: BaseMessageService, decorators: [{
71
75
  type: Injectable
72
76
  }] });
73
77
 
@@ -279,9 +283,9 @@ class NotificationsService {
279
283
  return Loc[message][this.locale];
280
284
  }
281
285
  }
282
- NotificationsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: NotificationsService, deps: [{ token: BaseMessageService }, { token: HUB_URL }, { token: MESSAGE_PACK }, { token: SIGNALR_ENABLED }, { token: DEBUG_MODE }, { token: AUTO_RECONNECT }, { token: LOCALE }], target: i0.ɵɵFactoryTarget.Injectable });
283
- NotificationsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: NotificationsService });
284
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: NotificationsService, decorators: [{
286
+ NotificationsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.9", ngImport: i0, type: NotificationsService, deps: [{ token: BaseMessageService }, { token: HUB_URL }, { token: MESSAGE_PACK }, { token: SIGNALR_ENABLED }, { token: DEBUG_MODE }, { token: AUTO_RECONNECT }, { token: LOCALE }], target: i0.ɵɵFactoryTarget.Injectable });
287
+ NotificationsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.9", ngImport: i0, type: NotificationsService });
288
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.9", ngImport: i0, type: NotificationsService, decorators: [{
285
289
  type: Injectable
286
290
  }], ctorParameters: function () {
287
291
  return [{ type: BaseMessageService }, { type: undefined, decorators: [{
@@ -322,10 +326,10 @@ class SignalrNotificationsModule {
322
326
  };
323
327
  }
324
328
  }
325
- SignalrNotificationsModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: SignalrNotificationsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
326
- SignalrNotificationsModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: SignalrNotificationsModule });
327
- SignalrNotificationsModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: SignalrNotificationsModule });
328
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: SignalrNotificationsModule, decorators: [{
329
+ SignalrNotificationsModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.9", ngImport: i0, type: SignalrNotificationsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
330
+ SignalrNotificationsModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.9", ngImport: i0, type: SignalrNotificationsModule });
331
+ SignalrNotificationsModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.9", ngImport: i0, type: SignalrNotificationsModule });
332
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.9", ngImport: i0, type: SignalrNotificationsModule, decorators: [{
329
333
  type: NgModule
330
334
  }] });
331
335
 
@@ -345,6 +349,18 @@ class EndpointDef {
345
349
  this.inTypeDefault = inTypeDefault;
346
350
  this.outTypeDefault = outTypeDefault;
347
351
  }
352
+ /** Helper per la creazione rapida di un Endpoint di solo INPUT */
353
+ static In(name, inTypeDefault) {
354
+ return new EndpointDef(name, inTypeDefault, undefined);
355
+ }
356
+ /** Helper per la creazione rapida di un Endpoint di solo OUTPUT */
357
+ static Out(name, outTypeDefault) {
358
+ return new EndpointDef(name, undefined, outTypeDefault);
359
+ }
360
+ /** Helper per la creazione rapida di un Endpoint di INPUT e OUTPUT (BIDIREZIONALE) */
361
+ static Bi(name, inTypeDefault, outTypeDefault) {
362
+ return new EndpointDef(name, inTypeDefault, outTypeDefault);
363
+ }
348
364
  }
349
365
 
350
366
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"esfaenza-signalr-notifications.mjs","sources":["../../../projects/signalr-notifications/src/lib/tokens.ts","../../../projects/signalr-notifications/src/lib/signalr-notifications.service.loc.ts","../../../projects/signalr-notifications/src/lib/models/BaseMessageService.ts","../../../projects/signalr-notifications/src/lib/signalr-notifications.service.ts","../../../projects/signalr-notifications/src/lib/signalr-notifications.module.ts","../../../projects/signalr-notifications/src/lib/models/EndpointDef.ts","../../../projects/signalr-notifications/src/lib/config/SignalrNotificationsModuleConfig.ts","../../../projects/signalr-notifications/src/public-api.ts","../../../projects/signalr-notifications/src/esfaenza-signalr-notifications.ts"],"sourcesContent":["import { InjectionToken } from '@angular/core';\r\n\r\n/**\r\n * Hub a cui collegarsi\r\n */\r\nexport const HUB_URL: InjectionToken<string> = new InjectionToken<string>('HUB_URL');\r\n\r\n/**\r\n * Indica se la libreria dev'essere attiva o no\r\n */\r\nexport const SIGNALR_ENABLED: InjectionToken<string> = new InjectionToken<boolean>('SIGNALR_ENABLED');\r\n\r\n/**\r\n * Indica se stampare messaggi di debug in console\r\n */\r\nexport const DEBUG_MODE: InjectionToken<string> = new InjectionToken<boolean>('DEBUG_MODE');\r\n\r\n/**\r\n * Indica il locale utilizzato dalla libreria per i messaggi. Sono supportati \"it-IT\" ed \"en-US\"\r\n */\r\nexport const LOCALE: InjectionToken<string> = new InjectionToken<string>('LOCALE');\r\n\r\n/**\r\n * Indica se utilizzare il protocollo di trasferimento \"MessagePack\"\r\n */\r\nexport const MESSAGE_PACK: InjectionToken<boolean> = new InjectionToken<boolean>('MESSAGE_PACK');\r\n\r\n/**\r\n * Indica se tentare in automatico la riconnessione\r\n */\r\nexport const AUTO_RECONNECT: InjectionToken<boolean> = new InjectionToken<boolean>('AUTO_RECONNECT');","/**\r\n * Oggetto statico di localizzazione per i messaggi scritti dal servizio\r\n */\r\nexport const Loc ={\r\n \"Building SignalR Hub with Automatic Reconnection\": { \"en-US\": \"Building SignalR Hub with Automatic Reconnection\", \"it-IT\": \"Compilo l'Hub di SignalR con riconnessione automatica\", },\r\n \"Cannot reconnect SignalR, frontend HUB offline\": { \"en-US\": \"Cannot reconnect SignalR, frontend HUB offline\", \"it-IT\": \"Impossibile riconnettere SignalR, l'Hub del Frontend e' Offline\", },\r\n \"Send request sent before a connection was in stable State, waiting 1 second and retrying\": { \"en-US\": \"Send request sent before a connection was in stable State, waiting 1 second and retrying\", \"it-IT\": \"Richiesta 'Send' ricevuta prima che la connessione fosse in uno stato stabile, attendo 1 secondo e riprovo\", },\r\n \"Invoke request sent before a connection was in stable State, waiting 1 second and retrying\": { \"en-US\": \"Invoke request sent before a connection was in stable State, waiting 1 second and retrying\", \"it-IT\": \"Richiesta 'Invoke' ricevuta prima che la connessione fosse in uno stato stabile, attendo 1 secondo e riprovo\", },\r\n \"Connection lost or missing, reconnecting...\" : { \"en-US\": \"Connection lost or missing, reconnecting...\", \"it-IT\": \"Connessione persa o mancante, mi riconnetto...\", },\r\n \"SignalR won't be enabled as per configuration\": { \"en-US\": \"SignalR won't be enabled as per configuration\", \"it-IT\": \"SignalR non verrà attivato come da configurazione\", },\r\n \"Building SignalR Hub with MessagePack protocol\": { \"en-US\": \"Building SignalR Hub with MessagePack protocol\", \"it-IT\": \"Compilo l'Hub di SignalR con protocollo MessagePack\", },\r\n \"Request received from the server for endpoint\": { \"en-US\": \"Request received from the server for endpoint\", \"it-IT\": \"Richiesta ricevuta dal server per endpoint\", },\r\n \"Refusing to register endpoint\": { \"en-US\": \"Refusing to register endpoint\", \"it-IT\": \"Rifiuto di registrare l'endpoint\", },\r\n \"because it is not declared as IN - ONLY\": { \"en-US\": \"because it is not declared as IN - ONLY\", \"it-IT\": \"in quanto non è registrato solo come IN\", },\r\n \"Send request ignored because SignalR is not active by configuration\": { \"en-US\": \"Send request ignored because SignalR is not active by configuration\", \"it-IT\": \"Richiesta send ignorata in quanto SignalR non è attivo da configurazione\", },\r\n \"Request sent to server\": { \"en-US\": \"Request sent to server\", \"it-IT\": \"Richiesta inviata al server\", },\r\n \"Invoke request ignored because SignalR is not active by configuration\": { \"en-US\": \"Invoke request ignored because SignalR is not active by configuration\", \"it-IT\": \"Richiesta invoke ignorata in quanto SignalR non è attivo da configurazione\", },\r\n \"Request invoked to server\": { \"en-US\": \"Request invoked to server\", \"it-IT\": \"Richiesta invoke inviata al server\", },\r\n \"Observe request ignored because SignalR is not active by configuration\": { \"en-US\": \"Observe request ignored because SignalR is not active by configuration\", \"it-IT\": \"Osservazione ignorata in quanto SignalR non è attivo da configurazione\", },\r\n \"Returning observable for required endpoint\": { \"en-US\": \"Returning observable for required endpoint\", \"it-IT\": \"Restituisco l'observable per l'endpoint richiesto\", },\r\n \"Disconnection request ignored because SignalR is not active by configuration\": { \"en-US\": \"Disconnection request ignored because SignalR is not active by configuration\", \"it-IT\": \"Richiesta di disconnesione ignorata in quanto SignalR non è attivo da configurazione\", },\r\n \"Disconnection request honored\": { \"en-US\": \"Returning observable for required endpoint\", \"it-IT\": \"Restituito observable per l'endpoint richiesto\", },\r\n \"ERRORS on reconnecting before retrying a send command. Sent message WILL BE LOST\": { \"en-US\": \"ERRORS on reconnecting before retrying a send command. Sent message WILL BE LOST\", \"it-IT\": \"ERRORE nella riconnessione precedente a un nuovo tentativo di 'Send'. Il messaggio in questione SARA' PERSO\"}\r\n}","// Angular\r\nimport { Injectable } from '@angular/core';\r\n\r\n// Modelli\r\nimport { EndpointDef } from './EndpointDef';\r\n\r\n/**\r\n * Classe base da estendere con la definizione degli Endpoint supportati dall'applicazione\r\n */\r\n@Injectable()\r\nexport class BaseMessageService {\r\n\r\n /**\r\n * Entrypoint che restituisce tutti gli Endpoint dell'applicazione\r\n */\r\n public get AllDefinitions(): EndpointDef<any, any>[] { return []; }\r\n}","// Angular\r\nimport { Injectable, Inject } from \"@angular/core\";\r\n\r\n// Direttive, Componenti, Librerie\r\nimport * as signalR from '@microsoft/signalr';\r\nimport { HubConnectionState } from \"@microsoft/signalr\";\r\nimport { Observable, Subject, EMPTY, from, of } from \"rxjs\";\r\nimport { catchError, concatMap, delay, tap } from \"rxjs/operators\";\r\n\r\n// Modelli\r\nimport { BaseMessageService } from './models/BaseMessageService';\r\nimport { EndpointDef } from './models/EndpointDef';\r\nimport { DEBUG_MODE, HUB_URL, LOCALE, MESSAGE_PACK, SIGNALR_ENABLED, AUTO_RECONNECT } from \"./tokens\";\r\n\r\n// Localizzazione\r\nimport { Loc } from './signalr-notifications.service.loc';\r\n\r\n/**\r\n * Servizio che gestisce la comunicazione con un Hub SignalR in base alle configurazioni fornite dall'applicazione\r\n */\r\n@Injectable()\r\nexport class NotificationsService {\r\n\r\n /**\r\n * Cache degli Observable generati in base agli Endpoint disponibili\r\n */\r\n private notifications$: { [index: string]: Subject<any> } = {};\r\n\r\n /**\r\n * Connessione Signalr\r\n */\r\n private connection: signalR.HubConnection;\r\n\r\n /**\r\n * Costruttore\r\n * \r\n * @ignore\r\n */\r\n constructor(private MessageDef: BaseMessageService, @Inject(HUB_URL) private hub_url: string, @Inject(MESSAGE_PACK) private msgpack: boolean, @Inject(SIGNALR_ENABLED) private enabled: boolean, @Inject(DEBUG_MODE) private debug: boolean, @Inject(AUTO_RECONNECT) autoreconnect: boolean, @Inject(LOCALE) private locale : string) {\r\n if (!this.enabled) {\r\n this.log(this.loc(\"SignalR won't be enabled as per configuration\"));\r\n return;\r\n }\r\n\r\n this.MessageDef.AllDefinitions.forEach(def => { this.notifications$[def.endpoint] = new Subject<typeof def.inTypeDefault>(); });\r\n\r\n let pars: signalR.IHttpConnectionOptions = { skipNegotiation: true, transport: signalR.HttpTransportType.WebSockets, logger: debug ? signalR.LogLevel.Debug : signalR.LogLevel.None };\r\n var builder = new signalR.HubConnectionBuilder().withUrl(this.hub_url, pars);\r\n\r\n if (autoreconnect) {\r\n this.log(this.loc(\"Building SignalR Hub with Automatic Reconnection\"));\r\n // 100 tentativi di riconnessione, 1 ogni 5 secondi\r\n builder = builder.withAutomaticReconnect(new Array(100).fill(5 * 1000));\r\n }\r\n\r\n if (this.msgpack) {\r\n this.log(this.loc(\"Building SignalR Hub with MessagePack protocol\"));\r\n var mphpModule = require(\"@microsoft/signalr-protocol-msgpack\");\r\n builder = builder.withHubProtocol(new mphpModule.MessagePackHubProtocol())\r\n }\r\n\r\n this.connection = builder.build();\r\n this.connect();\r\n }\r\n\r\n /**\r\n * Effettua la connessione all'Hub Signalr e registra tutti gli Endpoint per cui il Backend comunica con il Frontend sulla **connection**\r\n */\r\n private connect() {\r\n this.connection.start().catch(err => console.log(err));\r\n this.MessageDef.AllDefinitions.forEach(d => {\r\n //Registro solo le cose di IN, quelle di out sono chiamate che faccio io al BE quindi non servono\r\n if (d.inTypeDefault !== null && d.outTypeDefault === null)\r\n this.connection.on(d.endpoint, (message) => {\r\n this.log(this.loc(\"Request received from the server for endpoint\") + \" '\" + d.endpoint + \"': \" + this.substringLog(JSON.stringify(message)));\r\n this.notifications$[d.endpoint].next(message);\r\n });\r\n else\r\n this.log(this.loc(\"Refusing to register endpoint\") + \" \" + d.endpoint + \" \" + this.loc(\"because it is not declared as IN - ONLY\"));\r\n });\r\n }\r\n\r\n /**\r\n * Effettua verifiche sulla connessione e, in caso non fosse collegata, tenta di riconnetterla\r\n * \r\n * @returns {Promise<'OK' | 'KO' | 'NO-OP'>} 'OK' Se la connessione è già connessa o è stata riconnessa con successo, 'KO' Se non è stato possibile riconnettere \r\n * una connessione disconnessa, 'NO-OP' se la connesisone è in uno stato intermedio che non può essere modificato\r\n */\r\n public ensureConnected(): Promise<'OK' | 'KO' | 'NO-OP'> {\r\n if (this.connection.state == HubConnectionState.Disconnected) {\r\n this.log(this.loc(\"Connection lost or missing, reconnecting...\"));\r\n\r\n return this.connection.start()\r\n .then(_ => {\r\n return Promise.resolve(\"OK\");\r\n }, _ => {\r\n this.log(this.loc(\"Cannot reconnect SignalR, frontend HUB offline\"));\r\n return Promise.resolve(\"KO\");\r\n });\r\n }\r\n else if (this.connection.state == HubConnectionState.Connected)\r\n return Promise.resolve(\"OK\");\r\n else\r\n return Promise.resolve(\"NO-OP\");\r\n }\r\n\r\n /**\r\n * Invia un messaggio all'Hub del Backend\r\n * \r\n * @param {EndpointDef<TOut, any>} item Endpoint da contattare\r\n * @param {TOut} dto Dto da inviare all'Endpoint\r\n */\r\n public send<TOut>(item: EndpointDef<TOut, any>, dto: TOut) {\r\n if (!this.enabled) {\r\n this.log(this.loc(\"Send request ignored because SignalR is not active by configuration\"));\r\n return EMPTY;\r\n }\r\n\r\n if (this.connection.state == HubConnectionState.Connecting || this.connection.state == HubConnectionState.Reconnecting || this.connection.state == HubConnectionState.Disconnecting) {\r\n this.log(this.loc(\"Send request sent before a connection was in stable State, waiting 1 second and retrying\"));\r\n setTimeout(() => { this.send(item, dto); }, 1000);\r\n }\r\n else if (this.connection.state == HubConnectionState.Disconnected) {\r\n this.ensureConnected().then(t => {\r\n if (t == \"KO\") this.log(this.loc(\"ERRORS on reconnecting before retrying a send command. Sent message WILL BE LOST\"));\r\n else this.send(item, dto);\r\n })\r\n }\r\n else {\r\n this.connection.send(item.endpoint, dto).then(_ => {\r\n if (this.debug)\r\n console.info(this.loc(\"Request sent to server\") + \" - \" + item.endpoint + \": \" + this.substringLog(JSON.stringify(dto)));\r\n });\r\n }\r\n }\r\n\r\n /**\r\n * Invia un messaggio all'Hub del Backend, aspettandosi una risposta\r\n * \r\n * @param {EndpointDef<TOut, TIn>} item Endpoint da contattare\r\n * @param {TOut} dto Dto da inviare all'Endpoint\r\n * \r\n * @returns {Observable<TIn>} Observable su cui ci si può registrare per ricevere il risultato della chiamata\r\n */\r\n public invoke<TOut, TIn>(item: EndpointDef<TOut, TIn>, dto: TOut): Observable<TIn> {\r\n if (!this.enabled) {\r\n this.log(this.loc(\"Invoke request ignored because SignalR is not active by configuration\"));\r\n return EMPTY;\r\n }\r\n\r\n if (this.connection.state == HubConnectionState.Connecting || this.connection.state == HubConnectionState.Reconnecting || this.connection.state == HubConnectionState.Disconnecting) {\r\n this.log(this.loc(\"Invoke request sent before a connection was in stable State, waiting 1 second and retrying\"));\r\n return of().pipe(delay(1000), concatMap(() => this.invoke(item, dto)));\r\n }\r\n else if (this.connection.state == HubConnectionState.Disconnected) {\r\n return from(this.ensureConnected()).pipe(concatMap((res) => {\r\n if (res == \"KO\") {\r\n this.log(this.loc(\"ERRORS on reconnecting before retrying a send command. Sent message WILL BE LOST\"));\r\n return EMPTY;\r\n }\r\n else return this.invoke(item, dto);\r\n }))\r\n }\r\n else {\r\n return from(this.connection.invoke<TIn>(item.endpoint, dto)).pipe(\r\n tap(() => {\r\n if (this.debug) console.log(this.loc(\"Request invoked to server\") + \" - \" + item.endpoint + \": \" + this.substringLog(JSON.stringify(dto)));\r\n })\r\n );\r\n }\r\n }\r\n\r\n /**\r\n * Hook per osservare i dati spediti ad un Endpoint dal Backend\r\n * \r\n * @param {EndpointDef<TIn, any>} item Endpoint su cui ascoltare\r\n * \r\n * @returns {Observable<TIn>} Observable su cui ci si può registrare per ricevere l'oggetto generato ad ogni chiamata dal Backend al Frontend\r\n */\r\n public observe<TIn>(item: EndpointDef<TIn, any>): Observable<TIn> {\r\n if (!this.enabled)\r\n {\r\n this.log(this.loc(\"Observe request ignored because SignalR is not active by configuration\"));\r\n return EMPTY;\r\n }\r\n\r\n this.log(this.loc(\"Returning observable for required endpoint\") + \": \" + item.endpoint);\r\n return <Observable<TIn>>this.notifications$[item.endpoint];\r\n }\r\n\r\n /**\r\n * Disconnessione del sistema di SignalR\r\n * \r\n * @returns {Observable<void>} Observable a cui registrarsi che viene chiamato quando la disconnessione è terminata\r\n */\r\n public disconnect(): Observable<void> {\r\n //NO-OP se non attivo\r\n if (!this.enabled)\r\n {\r\n this.log(this.loc(\"Disconnection request ignored because SignalR is not active by configuration\"));\r\n return EMPTY;\r\n }\r\n\r\n return from(this.connection.stop()).pipe(\r\n catchError((err, caught) => { console.log(err); return of(null); }),\r\n tap(() => {\r\n this.log(this.loc(\"Disconnection request honored\"));\r\n })\r\n );\r\n }\r\n\r\n /**\r\n * Taglia un log troppo lungo\r\n * \r\n * @param {string} text Log da tagliare\r\n * @param {number} maxchars Numero massimo di caratteri da tenere\r\n * \r\n * @returns {string} Log tagliato\r\n */\r\n private substringLog(text: string, maxchars: number = 120) : string {\r\n return text.length > maxchars ? text.substr(0, maxchars) + \"[...]\" : text;\r\n }\r\n\r\n /**\r\n * Stampa un log a console\r\n * \r\n * @param {string} message Messaggio da stampare\r\n */\r\n private log(message: string) {\r\n if (this.debug)\r\n console.log(\"@signalr-notifications: \" + message)\r\n }\r\n\r\n /**\r\n * Helper di localizzazione\r\n * \r\n * @param {string} message Messaggio da tradurre\r\n * \r\n * @returns {string} Messaggio tradotto\r\n */\r\n private loc(message: string) : string{\r\n if(!Loc[message])\r\n {\r\n console.warn(\"Untranslated message: \" + message)\r\n return \"\";\r\n }\r\n return Loc[message][this.locale];\r\n }\r\n}","\r\nimport { NgModule, ModuleWithProviders } from '@angular/core';\r\nimport { SignalrNotificationsModuleConfig } from './config/SignalrNotificationsModuleConfig';\r\nimport { BaseMessageService } from './models/BaseMessageService';\r\nimport { NotificationsService } from './signalr-notifications.service';\r\nimport { HUB_URL, SIGNALR_ENABLED, DEBUG_MODE, LOCALE, MESSAGE_PACK, AUTO_RECONNECT } from './tokens';\r\n\r\n@NgModule()\r\nexport class SignalrNotificationsModule {\r\n static forRoot(config?: SignalrNotificationsModuleConfig): ModuleWithProviders<SignalrNotificationsModule> {\r\n return {\r\n ngModule: SignalrNotificationsModule,\r\n providers: [\r\n NotificationsService,\r\n { provide: BaseMessageService, useClass: config?.messageService || BaseMessageService },\r\n { provide: HUB_URL, useValue: config?.hubUrl },\r\n { provide: LOCALE, useValue: config?.locale || 'it-IT' },\r\n { provide: SIGNALR_ENABLED, useValue: config?.enabled != null ? config?.enabled : true },\r\n { provide: DEBUG_MODE, useValue: config?.debugMode != null ? config?.debugMode : false },\r\n { provide: MESSAGE_PACK, useValue: config?.autoReconnect != null ? config?.autoReconnect : false },\r\n { provide: AUTO_RECONNECT, useValue: config?.useMessagePack != null ? config?.useMessagePack : false },\r\n ]\r\n };\r\n }\r\n}","/**\r\n * Definisce un Endpoint che spedisce un'informazione di tipo TIn e restituisce un'informazione di tipo TOut\r\n */\r\nexport class EndpointDef<TIn, TOut> {\r\n\r\n /**\r\n * Costruttore\r\n * \r\n * @param {string} endpoint Nome del metodo da chiamare nell'Hub del Backend contattato\r\n * @param {TIn} inTypeDefault Default per il tipo TIn. Utilizzato per fare Typecheck sulle chiamate da Backend a Frontend\r\n * @param {TOut} outTypeDefault Default per il tipo TOut. Utilizzato per fare Typecheck sulle chiamate da Frontend a Backend\r\n */\r\n constructor(public endpoint: string, public inTypeDefault: TIn, public outTypeDefault: TOut) { }\r\n}","// Angular\r\nimport { Type } from '@angular/core';\r\n\r\n// Modelli\r\nimport { BaseMessageService } from '../models/BaseMessageService';\r\n\r\n/**\r\n * Classe di configurazione per la libreria\r\n */\r\nexport class SignalrNotificationsModuleConfig {\r\n\r\n /**\r\n * Url nei confronti del quale aprire la connessione SignalR\r\n */\r\n hubUrl : string;\r\n\r\n /**\r\n * Servizio che definisce i messaggi di IN e OUT coi loro default\r\n */\r\n messageService? : Type<BaseMessageService>;\r\n\r\n /**\r\n * Indica se abilitare o meno la connessione SignalR nei confronti dell'URL **hubUrl**\r\n */\r\n enabled? : boolean;\r\n\r\n /**\r\n * Indica se utilizzare message pack come protocollo di trasmissione\r\n */\r\n useMessagePack? : boolean;\r\n\r\n /**\r\n * Indica se tentare di riconnettersi automaticamente quando la connessione cade\r\n */\r\n autoReconnect? : boolean;\r\n\r\n /**\r\n * Indica se scrivere o meno i messaggi di debug\r\n */\r\n debugMode? : boolean;\r\n\r\n /**\r\n * Lingua dei feedback a console, sono supportati 'it-IT' ed 'en-US'\r\n */\r\n locale? : string\r\n}","/*\n * Public API Surface of signalr-notifications\n */\n\nexport * from './lib/signalr-notifications.service';\nexport * from './lib/signalr-notifications.module';\nexport * from './lib/models/BaseMessageService';\nexport * from './lib/models/EndpointDef';\nexport * from './lib/config/SignalrNotificationsModuleConfig';","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;AAEA;;;AAGO,MAAM,OAAO,GAA2B,IAAI,cAAc,CA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AW;;;;;;;;IASpB,YAAmB,QAAgB,EAAS,aAAkB,EAAS,cAAoB;QAAxE,aAAQ,GAAR,QAAQ,CAAQ;QAAS,kBAAa,GAAb,aAAa,CAAK;QAAS,mBAAc,GAAd,cAAc,CAAM;KAAK;;;ACNpG;;;MAGa,gCAAgC;;;ACT7C;;;;ACAA;;;;;;"}
1
+ {"version":3,"file":"esfaenza-signalr-notifications.mjs","sources":["../../../projects/signalr-notifications/src/lib/tokens.ts","../../../projects/signalr-notifications/src/lib/signalr-notifications.service.loc.ts","../../../projects/signalr-notifications/src/lib/models/BaseMessageService.ts","../../../projects/signalr-notifications/src/lib/signalr-notifications.service.ts","../../../projects/signalr-notifications/src/lib/signalr-notifications.module.ts","../../../projects/signalr-notifications/src/lib/models/EndpointDef.ts","../../../projects/signalr-notifications/src/lib/config/SignalrNotificationsModuleConfig.ts","../../../projects/signalr-notifications/src/public-api.ts","../../../projects/signalr-notifications/src/esfaenza-signalr-notifications.ts"],"sourcesContent":["import { InjectionToken } from '@angular/core';\r\n\r\n/**\r\n * Hub a cui collegarsi\r\n */\r\nexport const HUB_URL: InjectionToken<string> = new InjectionToken<string>('HUB_URL');\r\n\r\n/**\r\n * Indica se la libreria dev'essere attiva o no\r\n */\r\nexport const SIGNALR_ENABLED: InjectionToken<string> = new InjectionToken<boolean>('SIGNALR_ENABLED');\r\n\r\n/**\r\n * Indica se stampare messaggi di debug in console\r\n */\r\nexport const DEBUG_MODE: InjectionToken<string> = new InjectionToken<boolean>('DEBUG_MODE');\r\n\r\n/**\r\n * Indica il locale utilizzato dalla libreria per i messaggi. Sono supportati \"it-IT\" ed \"en-US\"\r\n */\r\nexport const LOCALE: InjectionToken<string> = new InjectionToken<string>('LOCALE');\r\n\r\n/**\r\n * Indica se utilizzare il protocollo di trasferimento \"MessagePack\"\r\n */\r\nexport const MESSAGE_PACK: InjectionToken<boolean> = new InjectionToken<boolean>('MESSAGE_PACK');\r\n\r\n/**\r\n * Indica se tentare in automatico la riconnessione\r\n */\r\nexport const AUTO_RECONNECT: InjectionToken<boolean> = new InjectionToken<boolean>('AUTO_RECONNECT');","/**\r\n * Oggetto statico di localizzazione per i messaggi scritti dal servizio\r\n */\r\nexport const Loc ={\r\n \"Building SignalR Hub with Automatic Reconnection\": { \"en-US\": \"Building SignalR Hub with Automatic Reconnection\", \"it-IT\": \"Compilo l'Hub di SignalR con riconnessione automatica\", },\r\n \"Cannot reconnect SignalR, frontend HUB offline\": { \"en-US\": \"Cannot reconnect SignalR, frontend HUB offline\", \"it-IT\": \"Impossibile riconnettere SignalR, l'Hub del Frontend e' Offline\", },\r\n \"Send request sent before a connection was in stable State, waiting 1 second and retrying\": { \"en-US\": \"Send request sent before a connection was in stable State, waiting 1 second and retrying\", \"it-IT\": \"Richiesta 'Send' ricevuta prima che la connessione fosse in uno stato stabile, attendo 1 secondo e riprovo\", },\r\n \"Invoke request sent before a connection was in stable State, waiting 1 second and retrying\": { \"en-US\": \"Invoke request sent before a connection was in stable State, waiting 1 second and retrying\", \"it-IT\": \"Richiesta 'Invoke' ricevuta prima che la connessione fosse in uno stato stabile, attendo 1 secondo e riprovo\", },\r\n \"Connection lost or missing, reconnecting...\" : { \"en-US\": \"Connection lost or missing, reconnecting...\", \"it-IT\": \"Connessione persa o mancante, mi riconnetto...\", },\r\n \"SignalR won't be enabled as per configuration\": { \"en-US\": \"SignalR won't be enabled as per configuration\", \"it-IT\": \"SignalR non verrà attivato come da configurazione\", },\r\n \"Building SignalR Hub with MessagePack protocol\": { \"en-US\": \"Building SignalR Hub with MessagePack protocol\", \"it-IT\": \"Compilo l'Hub di SignalR con protocollo MessagePack\", },\r\n \"Request received from the server for endpoint\": { \"en-US\": \"Request received from the server for endpoint\", \"it-IT\": \"Richiesta ricevuta dal server per endpoint\", },\r\n \"Refusing to register endpoint\": { \"en-US\": \"Refusing to register endpoint\", \"it-IT\": \"Rifiuto di registrare l'endpoint\", },\r\n \"because it is not declared as IN - ONLY\": { \"en-US\": \"because it is not declared as IN - ONLY\", \"it-IT\": \"in quanto non è registrato solo come IN\", },\r\n \"Send request ignored because SignalR is not active by configuration\": { \"en-US\": \"Send request ignored because SignalR is not active by configuration\", \"it-IT\": \"Richiesta send ignorata in quanto SignalR non è attivo da configurazione\", },\r\n \"Request sent to server\": { \"en-US\": \"Request sent to server\", \"it-IT\": \"Richiesta inviata al server\", },\r\n \"Invoke request ignored because SignalR is not active by configuration\": { \"en-US\": \"Invoke request ignored because SignalR is not active by configuration\", \"it-IT\": \"Richiesta invoke ignorata in quanto SignalR non è attivo da configurazione\", },\r\n \"Request invoked to server\": { \"en-US\": \"Request invoked to server\", \"it-IT\": \"Richiesta invoke inviata al server\", },\r\n \"Observe request ignored because SignalR is not active by configuration\": { \"en-US\": \"Observe request ignored because SignalR is not active by configuration\", \"it-IT\": \"Osservazione ignorata in quanto SignalR non è attivo da configurazione\", },\r\n \"Returning observable for required endpoint\": { \"en-US\": \"Returning observable for required endpoint\", \"it-IT\": \"Restituisco l'observable per l'endpoint richiesto\", },\r\n \"Disconnection request ignored because SignalR is not active by configuration\": { \"en-US\": \"Disconnection request ignored because SignalR is not active by configuration\", \"it-IT\": \"Richiesta di disconnesione ignorata in quanto SignalR non è attivo da configurazione\", },\r\n \"Disconnection request honored\": { \"en-US\": \"Returning observable for required endpoint\", \"it-IT\": \"Restituito observable per l'endpoint richiesto\", },\r\n \"ERRORS on reconnecting before retrying a send command. Sent message WILL BE LOST\": { \"en-US\": \"ERRORS on reconnecting before retrying a send command. Sent message WILL BE LOST\", \"it-IT\": \"ERRORE nella riconnessione precedente a un nuovo tentativo di 'Send'. Il messaggio in questione SARA' PERSO\"}\r\n}","// Angular\r\nimport { Injectable } from '@angular/core';\r\n\r\n// Modelli\r\nimport { EndpointDef } from './EndpointDef';\r\n\r\n/**\r\n * Classe base da estendere con la definizione degli Endpoint supportati dall'applicazione\r\n */\r\n@Injectable()\r\nexport class BaseMessageService {\r\n\r\n private definitions: EndpointDef<any, any>[] = [];\r\n\r\n /** Entrypoint che restituisce tutti gli Endpoint dell'applicazione. Da overridare qualora non venga utilizzato il metodo **add** */\r\n public get AllDefinitions(): EndpointDef<any, any>[] { return this.definitions; }\r\n\r\n public add(endpoint: EndpointDef<any, any>) {\r\n this.definitions.push(endpoint);\r\n }\r\n}","// Angular\r\nimport { Injectable, Inject } from \"@angular/core\";\r\n\r\n// Direttive, Componenti, Librerie\r\nimport * as signalR from '@microsoft/signalr';\r\nimport { HubConnectionState } from \"@microsoft/signalr\";\r\nimport { Observable, Subject, EMPTY, from, of } from \"rxjs\";\r\nimport { catchError, concatMap, delay, tap } from \"rxjs/operators\";\r\n\r\n// Modelli\r\nimport { BaseMessageService } from './models/BaseMessageService';\r\nimport { EndpointDef } from './models/EndpointDef';\r\nimport { DEBUG_MODE, HUB_URL, LOCALE, MESSAGE_PACK, SIGNALR_ENABLED, AUTO_RECONNECT } from \"./tokens\";\r\n\r\n// Localizzazione\r\nimport { Loc } from './signalr-notifications.service.loc';\r\n\r\n/**\r\n * Servizio che gestisce la comunicazione con un Hub SignalR in base alle configurazioni fornite dall'applicazione\r\n */\r\n@Injectable()\r\nexport class NotificationsService {\r\n\r\n /**\r\n * Cache degli Observable generati in base agli Endpoint disponibili\r\n */\r\n private notifications$: { [index: string]: Subject<any> } = {};\r\n\r\n /**\r\n * Connessione Signalr\r\n */\r\n private connection: signalR.HubConnection;\r\n\r\n /**\r\n * Costruttore\r\n * \r\n * @ignore\r\n */\r\n constructor(private MessageDef: BaseMessageService, @Inject(HUB_URL) private hub_url: string, @Inject(MESSAGE_PACK) private msgpack: boolean, @Inject(SIGNALR_ENABLED) private enabled: boolean, @Inject(DEBUG_MODE) private debug: boolean, @Inject(AUTO_RECONNECT) autoreconnect: boolean, @Inject(LOCALE) private locale : string) {\r\n if (!this.enabled) {\r\n this.log(this.loc(\"SignalR won't be enabled as per configuration\"));\r\n return;\r\n }\r\n\r\n this.MessageDef.AllDefinitions.forEach(def => { this.notifications$[def.endpoint] = new Subject<typeof def.inTypeDefault>(); });\r\n\r\n let pars: signalR.IHttpConnectionOptions = { skipNegotiation: true, transport: signalR.HttpTransportType.WebSockets, logger: debug ? signalR.LogLevel.Debug : signalR.LogLevel.None };\r\n var builder = new signalR.HubConnectionBuilder().withUrl(this.hub_url, pars);\r\n\r\n if (autoreconnect) {\r\n this.log(this.loc(\"Building SignalR Hub with Automatic Reconnection\"));\r\n // 100 tentativi di riconnessione, 1 ogni 5 secondi\r\n builder = builder.withAutomaticReconnect(new Array(100).fill(5 * 1000));\r\n }\r\n\r\n if (this.msgpack) {\r\n this.log(this.loc(\"Building SignalR Hub with MessagePack protocol\"));\r\n var mphpModule = require(\"@microsoft/signalr-protocol-msgpack\");\r\n builder = builder.withHubProtocol(new mphpModule.MessagePackHubProtocol())\r\n }\r\n\r\n this.connection = builder.build();\r\n this.connect();\r\n }\r\n\r\n /**\r\n * Effettua la connessione all'Hub Signalr e registra tutti gli Endpoint per cui il Backend comunica con il Frontend sulla **connection**\r\n */\r\n private connect() {\r\n this.connection.start().catch(err => console.log(err));\r\n this.MessageDef.AllDefinitions.forEach(d => {\r\n //Registro solo le cose di IN, quelle di out sono chiamate che faccio io al BE quindi non servono\r\n if (d.inTypeDefault !== null && d.outTypeDefault === null)\r\n this.connection.on(d.endpoint, (message) => {\r\n this.log(this.loc(\"Request received from the server for endpoint\") + \" '\" + d.endpoint + \"': \" + this.substringLog(JSON.stringify(message)));\r\n this.notifications$[d.endpoint].next(message);\r\n });\r\n else\r\n this.log(this.loc(\"Refusing to register endpoint\") + \" \" + d.endpoint + \" \" + this.loc(\"because it is not declared as IN - ONLY\"));\r\n });\r\n }\r\n\r\n /**\r\n * Effettua verifiche sulla connessione e, in caso non fosse collegata, tenta di riconnetterla\r\n * \r\n * @returns {Promise<'OK' | 'KO' | 'NO-OP'>} 'OK' Se la connessione è già connessa o è stata riconnessa con successo, 'KO' Se non è stato possibile riconnettere \r\n * una connessione disconnessa, 'NO-OP' se la connesisone è in uno stato intermedio che non può essere modificato\r\n */\r\n public ensureConnected(): Promise<'OK' | 'KO' | 'NO-OP'> {\r\n if (this.connection.state == HubConnectionState.Disconnected) {\r\n this.log(this.loc(\"Connection lost or missing, reconnecting...\"));\r\n\r\n return this.connection.start()\r\n .then(_ => {\r\n return Promise.resolve(\"OK\");\r\n }, _ => {\r\n this.log(this.loc(\"Cannot reconnect SignalR, frontend HUB offline\"));\r\n return Promise.resolve(\"KO\");\r\n });\r\n }\r\n else if (this.connection.state == HubConnectionState.Connected)\r\n return Promise.resolve(\"OK\");\r\n else\r\n return Promise.resolve(\"NO-OP\");\r\n }\r\n\r\n /**\r\n * Invia un messaggio all'Hub del Backend\r\n * \r\n * @param {EndpointDef<TOut, any>} item Endpoint da contattare\r\n * @param {TOut} dto Dto da inviare all'Endpoint\r\n */\r\n public send<TOut>(item: EndpointDef<TOut, any>, dto: TOut) {\r\n if (!this.enabled) {\r\n this.log(this.loc(\"Send request ignored because SignalR is not active by configuration\"));\r\n return EMPTY;\r\n }\r\n\r\n if (this.connection.state == HubConnectionState.Connecting || this.connection.state == HubConnectionState.Reconnecting || this.connection.state == HubConnectionState.Disconnecting) {\r\n this.log(this.loc(\"Send request sent before a connection was in stable State, waiting 1 second and retrying\"));\r\n setTimeout(() => { this.send(item, dto); }, 1000);\r\n }\r\n else if (this.connection.state == HubConnectionState.Disconnected) {\r\n this.ensureConnected().then(t => {\r\n if (t == \"KO\") this.log(this.loc(\"ERRORS on reconnecting before retrying a send command. Sent message WILL BE LOST\"));\r\n else this.send(item, dto);\r\n })\r\n }\r\n else {\r\n this.connection.send(item.endpoint, dto).then(_ => {\r\n if (this.debug)\r\n console.info(this.loc(\"Request sent to server\") + \" - \" + item.endpoint + \": \" + this.substringLog(JSON.stringify(dto)));\r\n });\r\n }\r\n }\r\n\r\n /**\r\n * Invia un messaggio all'Hub del Backend, aspettandosi una risposta\r\n * \r\n * @param {EndpointDef<TOut, TIn>} item Endpoint da contattare\r\n * @param {TOut} dto Dto da inviare all'Endpoint\r\n * \r\n * @returns {Observable<TIn>} Observable su cui ci si può registrare per ricevere il risultato della chiamata\r\n */\r\n public invoke<TOut, TIn>(item: EndpointDef<TOut, TIn>, dto: TOut): Observable<TIn> {\r\n if (!this.enabled) {\r\n this.log(this.loc(\"Invoke request ignored because SignalR is not active by configuration\"));\r\n return EMPTY;\r\n }\r\n\r\n if (this.connection.state == HubConnectionState.Connecting || this.connection.state == HubConnectionState.Reconnecting || this.connection.state == HubConnectionState.Disconnecting) {\r\n this.log(this.loc(\"Invoke request sent before a connection was in stable State, waiting 1 second and retrying\"));\r\n return of().pipe(delay(1000), concatMap(() => this.invoke(item, dto)));\r\n }\r\n else if (this.connection.state == HubConnectionState.Disconnected) {\r\n return from(this.ensureConnected()).pipe(concatMap((res) => {\r\n if (res == \"KO\") {\r\n this.log(this.loc(\"ERRORS on reconnecting before retrying a send command. Sent message WILL BE LOST\"));\r\n return EMPTY;\r\n }\r\n else return this.invoke(item, dto);\r\n }))\r\n }\r\n else {\r\n return from(this.connection.invoke<TIn>(item.endpoint, dto)).pipe(\r\n tap(() => {\r\n if (this.debug) console.log(this.loc(\"Request invoked to server\") + \" - \" + item.endpoint + \": \" + this.substringLog(JSON.stringify(dto)));\r\n })\r\n );\r\n }\r\n }\r\n\r\n /**\r\n * Hook per osservare i dati spediti ad un Endpoint dal Backend\r\n * \r\n * @param {EndpointDef<TIn, any>} item Endpoint su cui ascoltare\r\n * \r\n * @returns {Observable<TIn>} Observable su cui ci si può registrare per ricevere l'oggetto generato ad ogni chiamata dal Backend al Frontend\r\n */\r\n public observe<TIn>(item: EndpointDef<TIn, any>): Observable<TIn> {\r\n if (!this.enabled)\r\n {\r\n this.log(this.loc(\"Observe request ignored because SignalR is not active by configuration\"));\r\n return EMPTY;\r\n }\r\n\r\n this.log(this.loc(\"Returning observable for required endpoint\") + \": \" + item.endpoint);\r\n return <Observable<TIn>>this.notifications$[item.endpoint];\r\n }\r\n\r\n /**\r\n * Disconnessione del sistema di SignalR\r\n * \r\n * @returns {Observable<void>} Observable a cui registrarsi che viene chiamato quando la disconnessione è terminata\r\n */\r\n public disconnect(): Observable<void> {\r\n //NO-OP se non attivo\r\n if (!this.enabled)\r\n {\r\n this.log(this.loc(\"Disconnection request ignored because SignalR is not active by configuration\"));\r\n return EMPTY;\r\n }\r\n\r\n return from(this.connection.stop()).pipe(\r\n catchError((err, caught) => { console.log(err); return of(null); }),\r\n tap(() => {\r\n this.log(this.loc(\"Disconnection request honored\"));\r\n })\r\n );\r\n }\r\n\r\n /**\r\n * Taglia un log troppo lungo\r\n * \r\n * @param {string} text Log da tagliare\r\n * @param {number} maxchars Numero massimo di caratteri da tenere\r\n * \r\n * @returns {string} Log tagliato\r\n */\r\n private substringLog(text: string, maxchars: number = 120) : string {\r\n return text.length > maxchars ? text.substr(0, maxchars) + \"[...]\" : text;\r\n }\r\n\r\n /**\r\n * Stampa un log a console\r\n * \r\n * @param {string} message Messaggio da stampare\r\n */\r\n private log(message: string) {\r\n if (this.debug)\r\n console.log(\"@signalr-notifications: \" + message)\r\n }\r\n\r\n /**\r\n * Helper di localizzazione\r\n * \r\n * @param {string} message Messaggio da tradurre\r\n * \r\n * @returns {string} Messaggio tradotto\r\n */\r\n private loc(message: string) : string{\r\n if(!Loc[message])\r\n {\r\n console.warn(\"Untranslated message: \" + message)\r\n return \"\";\r\n }\r\n return Loc[message][this.locale];\r\n }\r\n}","\r\nimport { NgModule, ModuleWithProviders } from '@angular/core';\r\nimport { SignalrNotificationsModuleConfig } from './config/SignalrNotificationsModuleConfig';\r\nimport { BaseMessageService } from './models/BaseMessageService';\r\nimport { NotificationsService } from './signalr-notifications.service';\r\nimport { HUB_URL, SIGNALR_ENABLED, DEBUG_MODE, LOCALE, MESSAGE_PACK, AUTO_RECONNECT } from './tokens';\r\n\r\n@NgModule()\r\nexport class SignalrNotificationsModule {\r\n static forRoot(config?: SignalrNotificationsModuleConfig): ModuleWithProviders<SignalrNotificationsModule> {\r\n return {\r\n ngModule: SignalrNotificationsModule,\r\n providers: [\r\n NotificationsService,\r\n { provide: BaseMessageService, useClass: config?.messageService || BaseMessageService },\r\n { provide: HUB_URL, useValue: config?.hubUrl },\r\n { provide: LOCALE, useValue: config?.locale || 'it-IT' },\r\n { provide: SIGNALR_ENABLED, useValue: config?.enabled != null ? config?.enabled : true },\r\n { provide: DEBUG_MODE, useValue: config?.debugMode != null ? config?.debugMode : false },\r\n { provide: MESSAGE_PACK, useValue: config?.autoReconnect != null ? config?.autoReconnect : false },\r\n { provide: AUTO_RECONNECT, useValue: config?.useMessagePack != null ? config?.useMessagePack : false },\r\n ]\r\n };\r\n }\r\n}","/**\r\n * Definisce un Endpoint che spedisce un'informazione di tipo TIn e restituisce un'informazione di tipo TOut\r\n */\r\nexport class EndpointDef<TIn, TOut> {\r\n\r\n /**\r\n * Costruttore\r\n * \r\n * @param {string} endpoint Nome del metodo da chiamare nell'Hub del Backend contattato\r\n * @param {TIn} inTypeDefault Default per il tipo TIn. Utilizzato per fare Typecheck sulle chiamate da Backend a Frontend\r\n * @param {TOut} outTypeDefault Default per il tipo TOut. Utilizzato per fare Typecheck sulle chiamate da Frontend a Backend\r\n */\r\n constructor(public endpoint: string, public inTypeDefault: TIn, public outTypeDefault: TOut) { }\r\n\r\n\r\n /** Helper per la creazione rapida di un Endpoint di solo INPUT */\r\n public static In<TIn>(name: string, inTypeDefault: TIn): EndpointDef<TIn, void> {\r\n return new EndpointDef<TIn, void>(name, inTypeDefault, undefined);\r\n }\r\n\r\n /** Helper per la creazione rapida di un Endpoint di solo OUTPUT */\r\n public static Out<TOut>(name: string, outTypeDefault: TOut): EndpointDef<void, TOut> {\r\n return new EndpointDef<void, TOut>(name, undefined, outTypeDefault);\r\n }\r\n\r\n /** Helper per la creazione rapida di un Endpoint di INPUT e OUTPUT (BIDIREZIONALE) */\r\n public static Bi<TIn, TOut>(name: string, inTypeDefault: TIn, outTypeDefault: TOut): EndpointDef<TIn, TOut> {\r\n return new EndpointDef<TIn, TOut>(name, inTypeDefault, outTypeDefault);\r\n }\r\n}","// Angular\r\nimport { Type } from '@angular/core';\r\n\r\n// Modelli\r\nimport { BaseMessageService } from '../models/BaseMessageService';\r\n\r\n/**\r\n * Classe di configurazione per la libreria\r\n */\r\nexport class SignalrNotificationsModuleConfig {\r\n\r\n /**\r\n * Url nei confronti del quale aprire la connessione SignalR\r\n */\r\n hubUrl : string;\r\n\r\n /**\r\n * Servizio che definisce i messaggi di IN e OUT coi loro default\r\n */\r\n messageService? : Type<BaseMessageService>;\r\n\r\n /**\r\n * Indica se abilitare o meno la connessione SignalR nei confronti dell'URL **hubUrl**\r\n */\r\n enabled? : boolean;\r\n\r\n /**\r\n * Indica se utilizzare message pack come protocollo di trasmissione\r\n */\r\n useMessagePack? : boolean;\r\n\r\n /**\r\n * Indica se tentare di riconnettersi automaticamente quando la connessione cade\r\n */\r\n autoReconnect? : boolean;\r\n\r\n /**\r\n * Indica se scrivere o meno i messaggi di debug\r\n */\r\n debugMode? : boolean;\r\n\r\n /**\r\n * Lingua dei feedback a console, sono supportati 'it-IT' ed 'en-US'\r\n */\r\n locale? : string\r\n}","/*\n * Public API Surface of signalr-notifications\n */\n\nexport * from './lib/signalr-notifications.service';\nexport * from './lib/signalr-notifications.module';\nexport * from './lib/models/BaseMessageService';\nexport * from './lib/models/EndpointDef';\nexport * from './lib/config/SignalrNotificationsModuleConfig';","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;AAEA;;;AAGO,MAAM,OAAO,GAA2B,IAAI,cAAc,CAAS,SAAS,CAAC,CAAC;AAErF;;;AAGO,MAAM,eAAe,GAA2B,IAAI,cAAc,CAAU,iBAAiB,CAAC,CAAC;AAEtG;;;AAGO,MAAM,UAAU,GAA2B,IAAI,cAAc,CAAU,YAAY,CAAC,CAAC;AAE5F;;;AAGO,MAAM,MAAM,GAA2B,IAAI,cAAc,CAAS,QAAQ,CAAC,CAAC;AAEnF;;;AAGO,MAAM,YAAY,GAA4B,IAAI,cAA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Ac,GAAd,cAAc,CAAM;KAAK;;IAIzF,OAAO,EAAE,CAAM,IAAY,EAAE,aAAkB;QAClD,OAAO,IAAI,WAAW,CAAY,IAAI,EAAE,aAAa,EAAE,SAAS,CAAC,CAAC;KACrE;;IAGM,OAAO,GAAG,CAAO,IAAY,EAAE,cAAoB;QACtD,OAAO,IAAI,WAAW,CAAa,IAAI,EAAE,SAAS,EAAE,cAAc,CAAC,CAAC;KACvE;;IAGM,OAAO,EAAE,CAAY,IAAY,EAAE,aAAkB,EAAE,cAAoB;QAC9E,OAAO,IAAI,WAAW,CAAY,IAAI,EAAE,aAAa,EAAE,cAAc,CAAC,CAAC;KAC1E;;;ACtBL;;;MAGa,gCAAgC;;;ACT7C;;;;ACAA;;;;;;"}
@@ -60,14 +60,18 @@ const Loc = {
60
60
  * Classe base da estendere con la definizione degli Endpoint supportati dall'applicazione
61
61
  */
62
62
  class BaseMessageService {
63
- /**
64
- * Entrypoint che restituisce tutti gli Endpoint dell'applicazione
65
- */
66
- get AllDefinitions() { return []; }
63
+ constructor() {
64
+ this.definitions = [];
65
+ }
66
+ /** Entrypoint che restituisce tutti gli Endpoint dell'applicazione. Da overridare qualora non venga utilizzato il metodo **add** */
67
+ get AllDefinitions() { return this.definitions; }
68
+ add(endpoint) {
69
+ this.definitions.push(endpoint);
70
+ }
67
71
  }
68
- BaseMessageService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: BaseMessageService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
69
- BaseMessageService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: BaseMessageService });
70
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: BaseMessageService, decorators: [{
72
+ BaseMessageService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.9", ngImport: i0, type: BaseMessageService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
73
+ BaseMessageService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.9", ngImport: i0, type: BaseMessageService });
74
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.9", ngImport: i0, type: BaseMessageService, decorators: [{
71
75
  type: Injectable
72
76
  }] });
73
77
 
@@ -279,9 +283,9 @@ class NotificationsService {
279
283
  return Loc[message][this.locale];
280
284
  }
281
285
  }
282
- NotificationsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: NotificationsService, deps: [{ token: BaseMessageService }, { token: HUB_URL }, { token: MESSAGE_PACK }, { token: SIGNALR_ENABLED }, { token: DEBUG_MODE }, { token: AUTO_RECONNECT }, { token: LOCALE }], target: i0.ɵɵFactoryTarget.Injectable });
283
- NotificationsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: NotificationsService });
284
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: NotificationsService, decorators: [{
286
+ NotificationsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.9", ngImport: i0, type: NotificationsService, deps: [{ token: BaseMessageService }, { token: HUB_URL }, { token: MESSAGE_PACK }, { token: SIGNALR_ENABLED }, { token: DEBUG_MODE }, { token: AUTO_RECONNECT }, { token: LOCALE }], target: i0.ɵɵFactoryTarget.Injectable });
287
+ NotificationsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.9", ngImport: i0, type: NotificationsService });
288
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.9", ngImport: i0, type: NotificationsService, decorators: [{
285
289
  type: Injectable
286
290
  }], ctorParameters: function () { return [{ type: BaseMessageService }, { type: undefined, decorators: [{
287
291
  type: Inject,
@@ -320,10 +324,10 @@ class SignalrNotificationsModule {
320
324
  };
321
325
  }
322
326
  }
323
- SignalrNotificationsModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: SignalrNotificationsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
324
- SignalrNotificationsModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: SignalrNotificationsModule });
325
- SignalrNotificationsModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: SignalrNotificationsModule });
326
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: SignalrNotificationsModule, decorators: [{
327
+ SignalrNotificationsModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.9", ngImport: i0, type: SignalrNotificationsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
328
+ SignalrNotificationsModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.9", ngImport: i0, type: SignalrNotificationsModule });
329
+ SignalrNotificationsModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.9", ngImport: i0, type: SignalrNotificationsModule });
330
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.9", ngImport: i0, type: SignalrNotificationsModule, decorators: [{
327
331
  type: NgModule
328
332
  }] });
329
333
 
@@ -343,6 +347,18 @@ class EndpointDef {
343
347
  this.inTypeDefault = inTypeDefault;
344
348
  this.outTypeDefault = outTypeDefault;
345
349
  }
350
+ /** Helper per la creazione rapida di un Endpoint di solo INPUT */
351
+ static In(name, inTypeDefault) {
352
+ return new EndpointDef(name, inTypeDefault, undefined);
353
+ }
354
+ /** Helper per la creazione rapida di un Endpoint di solo OUTPUT */
355
+ static Out(name, outTypeDefault) {
356
+ return new EndpointDef(name, undefined, outTypeDefault);
357
+ }
358
+ /** Helper per la creazione rapida di un Endpoint di INPUT e OUTPUT (BIDIREZIONALE) */
359
+ static Bi(name, inTypeDefault, outTypeDefault) {
360
+ return new EndpointDef(name, inTypeDefault, outTypeDefault);
361
+ }
346
362
  }
347
363
 
348
364
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"esfaenza-signalr-notifications.mjs","sources":["../../../projects/signalr-notifications/src/lib/tokens.ts","../../../projects/signalr-notifications/src/lib/signalr-notifications.service.loc.ts","../../../projects/signalr-notifications/src/lib/models/BaseMessageService.ts","../../../projects/signalr-notifications/src/lib/signalr-notifications.service.ts","../../../projects/signalr-notifications/src/lib/signalr-notifications.module.ts","../../../projects/signalr-notifications/src/lib/models/EndpointDef.ts","../../../projects/signalr-notifications/src/lib/config/SignalrNotificationsModuleConfig.ts","../../../projects/signalr-notifications/src/public-api.ts","../../../projects/signalr-notifications/src/esfaenza-signalr-notifications.ts"],"sourcesContent":["import { InjectionToken } from '@angular/core';\r\n\r\n/**\r\n * Hub a cui collegarsi\r\n */\r\nexport const HUB_URL: InjectionToken<string> = new InjectionToken<string>('HUB_URL');\r\n\r\n/**\r\n * Indica se la libreria dev'essere attiva o no\r\n */\r\nexport const SIGNALR_ENABLED: InjectionToken<string> = new InjectionToken<boolean>('SIGNALR_ENABLED');\r\n\r\n/**\r\n * Indica se stampare messaggi di debug in console\r\n */\r\nexport const DEBUG_MODE: InjectionToken<string> = new InjectionToken<boolean>('DEBUG_MODE');\r\n\r\n/**\r\n * Indica il locale utilizzato dalla libreria per i messaggi. Sono supportati \"it-IT\" ed \"en-US\"\r\n */\r\nexport const LOCALE: InjectionToken<string> = new InjectionToken<string>('LOCALE');\r\n\r\n/**\r\n * Indica se utilizzare il protocollo di trasferimento \"MessagePack\"\r\n */\r\nexport const MESSAGE_PACK: InjectionToken<boolean> = new InjectionToken<boolean>('MESSAGE_PACK');\r\n\r\n/**\r\n * Indica se tentare in automatico la riconnessione\r\n */\r\nexport const AUTO_RECONNECT: InjectionToken<boolean> = new InjectionToken<boolean>('AUTO_RECONNECT');","/**\r\n * Oggetto statico di localizzazione per i messaggi scritti dal servizio\r\n */\r\nexport const Loc ={\r\n \"Building SignalR Hub with Automatic Reconnection\": { \"en-US\": \"Building SignalR Hub with Automatic Reconnection\", \"it-IT\": \"Compilo l'Hub di SignalR con riconnessione automatica\", },\r\n \"Cannot reconnect SignalR, frontend HUB offline\": { \"en-US\": \"Cannot reconnect SignalR, frontend HUB offline\", \"it-IT\": \"Impossibile riconnettere SignalR, l'Hub del Frontend e' Offline\", },\r\n \"Send request sent before a connection was in stable State, waiting 1 second and retrying\": { \"en-US\": \"Send request sent before a connection was in stable State, waiting 1 second and retrying\", \"it-IT\": \"Richiesta 'Send' ricevuta prima che la connessione fosse in uno stato stabile, attendo 1 secondo e riprovo\", },\r\n \"Invoke request sent before a connection was in stable State, waiting 1 second and retrying\": { \"en-US\": \"Invoke request sent before a connection was in stable State, waiting 1 second and retrying\", \"it-IT\": \"Richiesta 'Invoke' ricevuta prima che la connessione fosse in uno stato stabile, attendo 1 secondo e riprovo\", },\r\n \"Connection lost or missing, reconnecting...\" : { \"en-US\": \"Connection lost or missing, reconnecting...\", \"it-IT\": \"Connessione persa o mancante, mi riconnetto...\", },\r\n \"SignalR won't be enabled as per configuration\": { \"en-US\": \"SignalR won't be enabled as per configuration\", \"it-IT\": \"SignalR non verrà attivato come da configurazione\", },\r\n \"Building SignalR Hub with MessagePack protocol\": { \"en-US\": \"Building SignalR Hub with MessagePack protocol\", \"it-IT\": \"Compilo l'Hub di SignalR con protocollo MessagePack\", },\r\n \"Request received from the server for endpoint\": { \"en-US\": \"Request received from the server for endpoint\", \"it-IT\": \"Richiesta ricevuta dal server per endpoint\", },\r\n \"Refusing to register endpoint\": { \"en-US\": \"Refusing to register endpoint\", \"it-IT\": \"Rifiuto di registrare l'endpoint\", },\r\n \"because it is not declared as IN - ONLY\": { \"en-US\": \"because it is not declared as IN - ONLY\", \"it-IT\": \"in quanto non è registrato solo come IN\", },\r\n \"Send request ignored because SignalR is not active by configuration\": { \"en-US\": \"Send request ignored because SignalR is not active by configuration\", \"it-IT\": \"Richiesta send ignorata in quanto SignalR non è attivo da configurazione\", },\r\n \"Request sent to server\": { \"en-US\": \"Request sent to server\", \"it-IT\": \"Richiesta inviata al server\", },\r\n \"Invoke request ignored because SignalR is not active by configuration\": { \"en-US\": \"Invoke request ignored because SignalR is not active by configuration\", \"it-IT\": \"Richiesta invoke ignorata in quanto SignalR non è attivo da configurazione\", },\r\n \"Request invoked to server\": { \"en-US\": \"Request invoked to server\", \"it-IT\": \"Richiesta invoke inviata al server\", },\r\n \"Observe request ignored because SignalR is not active by configuration\": { \"en-US\": \"Observe request ignored because SignalR is not active by configuration\", \"it-IT\": \"Osservazione ignorata in quanto SignalR non è attivo da configurazione\", },\r\n \"Returning observable for required endpoint\": { \"en-US\": \"Returning observable for required endpoint\", \"it-IT\": \"Restituisco l'observable per l'endpoint richiesto\", },\r\n \"Disconnection request ignored because SignalR is not active by configuration\": { \"en-US\": \"Disconnection request ignored because SignalR is not active by configuration\", \"it-IT\": \"Richiesta di disconnesione ignorata in quanto SignalR non è attivo da configurazione\", },\r\n \"Disconnection request honored\": { \"en-US\": \"Returning observable for required endpoint\", \"it-IT\": \"Restituito observable per l'endpoint richiesto\", },\r\n \"ERRORS on reconnecting before retrying a send command. Sent message WILL BE LOST\": { \"en-US\": \"ERRORS on reconnecting before retrying a send command. Sent message WILL BE LOST\", \"it-IT\": \"ERRORE nella riconnessione precedente a un nuovo tentativo di 'Send'. Il messaggio in questione SARA' PERSO\"}\r\n}","// Angular\r\nimport { Injectable } from '@angular/core';\r\n\r\n// Modelli\r\nimport { EndpointDef } from './EndpointDef';\r\n\r\n/**\r\n * Classe base da estendere con la definizione degli Endpoint supportati dall'applicazione\r\n */\r\n@Injectable()\r\nexport class BaseMessageService {\r\n\r\n /**\r\n * Entrypoint che restituisce tutti gli Endpoint dell'applicazione\r\n */\r\n public get AllDefinitions(): EndpointDef<any, any>[] { return []; }\r\n}","// Angular\r\nimport { Injectable, Inject } from \"@angular/core\";\r\n\r\n// Direttive, Componenti, Librerie\r\nimport * as signalR from '@microsoft/signalr';\r\nimport { HubConnectionState } from \"@microsoft/signalr\";\r\nimport { Observable, Subject, EMPTY, from, of } from \"rxjs\";\r\nimport { catchError, concatMap, delay, tap } from \"rxjs/operators\";\r\n\r\n// Modelli\r\nimport { BaseMessageService } from './models/BaseMessageService';\r\nimport { EndpointDef } from './models/EndpointDef';\r\nimport { DEBUG_MODE, HUB_URL, LOCALE, MESSAGE_PACK, SIGNALR_ENABLED, AUTO_RECONNECT } from \"./tokens\";\r\n\r\n// Localizzazione\r\nimport { Loc } from './signalr-notifications.service.loc';\r\n\r\n/**\r\n * Servizio che gestisce la comunicazione con un Hub SignalR in base alle configurazioni fornite dall'applicazione\r\n */\r\n@Injectable()\r\nexport class NotificationsService {\r\n\r\n /**\r\n * Cache degli Observable generati in base agli Endpoint disponibili\r\n */\r\n private notifications$: { [index: string]: Subject<any> } = {};\r\n\r\n /**\r\n * Connessione Signalr\r\n */\r\n private connection: signalR.HubConnection;\r\n\r\n /**\r\n * Costruttore\r\n * \r\n * @ignore\r\n */\r\n constructor(private MessageDef: BaseMessageService, @Inject(HUB_URL) private hub_url: string, @Inject(MESSAGE_PACK) private msgpack: boolean, @Inject(SIGNALR_ENABLED) private enabled: boolean, @Inject(DEBUG_MODE) private debug: boolean, @Inject(AUTO_RECONNECT) autoreconnect: boolean, @Inject(LOCALE) private locale : string) {\r\n if (!this.enabled) {\r\n this.log(this.loc(\"SignalR won't be enabled as per configuration\"));\r\n return;\r\n }\r\n\r\n this.MessageDef.AllDefinitions.forEach(def => { this.notifications$[def.endpoint] = new Subject<typeof def.inTypeDefault>(); });\r\n\r\n let pars: signalR.IHttpConnectionOptions = { skipNegotiation: true, transport: signalR.HttpTransportType.WebSockets, logger: debug ? signalR.LogLevel.Debug : signalR.LogLevel.None };\r\n var builder = new signalR.HubConnectionBuilder().withUrl(this.hub_url, pars);\r\n\r\n if (autoreconnect) {\r\n this.log(this.loc(\"Building SignalR Hub with Automatic Reconnection\"));\r\n // 100 tentativi di riconnessione, 1 ogni 5 secondi\r\n builder = builder.withAutomaticReconnect(new Array(100).fill(5 * 1000));\r\n }\r\n\r\n if (this.msgpack) {\r\n this.log(this.loc(\"Building SignalR Hub with MessagePack protocol\"));\r\n var mphpModule = require(\"@microsoft/signalr-protocol-msgpack\");\r\n builder = builder.withHubProtocol(new mphpModule.MessagePackHubProtocol())\r\n }\r\n\r\n this.connection = builder.build();\r\n this.connect();\r\n }\r\n\r\n /**\r\n * Effettua la connessione all'Hub Signalr e registra tutti gli Endpoint per cui il Backend comunica con il Frontend sulla **connection**\r\n */\r\n private connect() {\r\n this.connection.start().catch(err => console.log(err));\r\n this.MessageDef.AllDefinitions.forEach(d => {\r\n //Registro solo le cose di IN, quelle di out sono chiamate che faccio io al BE quindi non servono\r\n if (d.inTypeDefault !== null && d.outTypeDefault === null)\r\n this.connection.on(d.endpoint, (message) => {\r\n this.log(this.loc(\"Request received from the server for endpoint\") + \" '\" + d.endpoint + \"': \" + this.substringLog(JSON.stringify(message)));\r\n this.notifications$[d.endpoint].next(message);\r\n });\r\n else\r\n this.log(this.loc(\"Refusing to register endpoint\") + \" \" + d.endpoint + \" \" + this.loc(\"because it is not declared as IN - ONLY\"));\r\n });\r\n }\r\n\r\n /**\r\n * Effettua verifiche sulla connessione e, in caso non fosse collegata, tenta di riconnetterla\r\n * \r\n * @returns {Promise<'OK' | 'KO' | 'NO-OP'>} 'OK' Se la connessione è già connessa o è stata riconnessa con successo, 'KO' Se non è stato possibile riconnettere \r\n * una connessione disconnessa, 'NO-OP' se la connesisone è in uno stato intermedio che non può essere modificato\r\n */\r\n public ensureConnected(): Promise<'OK' | 'KO' | 'NO-OP'> {\r\n if (this.connection.state == HubConnectionState.Disconnected) {\r\n this.log(this.loc(\"Connection lost or missing, reconnecting...\"));\r\n\r\n return this.connection.start()\r\n .then(_ => {\r\n return Promise.resolve(\"OK\");\r\n }, _ => {\r\n this.log(this.loc(\"Cannot reconnect SignalR, frontend HUB offline\"));\r\n return Promise.resolve(\"KO\");\r\n });\r\n }\r\n else if (this.connection.state == HubConnectionState.Connected)\r\n return Promise.resolve(\"OK\");\r\n else\r\n return Promise.resolve(\"NO-OP\");\r\n }\r\n\r\n /**\r\n * Invia un messaggio all'Hub del Backend\r\n * \r\n * @param {EndpointDef<TOut, any>} item Endpoint da contattare\r\n * @param {TOut} dto Dto da inviare all'Endpoint\r\n */\r\n public send<TOut>(item: EndpointDef<TOut, any>, dto: TOut) {\r\n if (!this.enabled) {\r\n this.log(this.loc(\"Send request ignored because SignalR is not active by configuration\"));\r\n return EMPTY;\r\n }\r\n\r\n if (this.connection.state == HubConnectionState.Connecting || this.connection.state == HubConnectionState.Reconnecting || this.connection.state == HubConnectionState.Disconnecting) {\r\n this.log(this.loc(\"Send request sent before a connection was in stable State, waiting 1 second and retrying\"));\r\n setTimeout(() => { this.send(item, dto); }, 1000);\r\n }\r\n else if (this.connection.state == HubConnectionState.Disconnected) {\r\n this.ensureConnected().then(t => {\r\n if (t == \"KO\") this.log(this.loc(\"ERRORS on reconnecting before retrying a send command. Sent message WILL BE LOST\"));\r\n else this.send(item, dto);\r\n })\r\n }\r\n else {\r\n this.connection.send(item.endpoint, dto).then(_ => {\r\n if (this.debug)\r\n console.info(this.loc(\"Request sent to server\") + \" - \" + item.endpoint + \": \" + this.substringLog(JSON.stringify(dto)));\r\n });\r\n }\r\n }\r\n\r\n /**\r\n * Invia un messaggio all'Hub del Backend, aspettandosi una risposta\r\n * \r\n * @param {EndpointDef<TOut, TIn>} item Endpoint da contattare\r\n * @param {TOut} dto Dto da inviare all'Endpoint\r\n * \r\n * @returns {Observable<TIn>} Observable su cui ci si può registrare per ricevere il risultato della chiamata\r\n */\r\n public invoke<TOut, TIn>(item: EndpointDef<TOut, TIn>, dto: TOut): Observable<TIn> {\r\n if (!this.enabled) {\r\n this.log(this.loc(\"Invoke request ignored because SignalR is not active by configuration\"));\r\n return EMPTY;\r\n }\r\n\r\n if (this.connection.state == HubConnectionState.Connecting || this.connection.state == HubConnectionState.Reconnecting || this.connection.state == HubConnectionState.Disconnecting) {\r\n this.log(this.loc(\"Invoke request sent before a connection was in stable State, waiting 1 second and retrying\"));\r\n return of().pipe(delay(1000), concatMap(() => this.invoke(item, dto)));\r\n }\r\n else if (this.connection.state == HubConnectionState.Disconnected) {\r\n return from(this.ensureConnected()).pipe(concatMap((res) => {\r\n if (res == \"KO\") {\r\n this.log(this.loc(\"ERRORS on reconnecting before retrying a send command. Sent message WILL BE LOST\"));\r\n return EMPTY;\r\n }\r\n else return this.invoke(item, dto);\r\n }))\r\n }\r\n else {\r\n return from(this.connection.invoke<TIn>(item.endpoint, dto)).pipe(\r\n tap(() => {\r\n if (this.debug) console.log(this.loc(\"Request invoked to server\") + \" - \" + item.endpoint + \": \" + this.substringLog(JSON.stringify(dto)));\r\n })\r\n );\r\n }\r\n }\r\n\r\n /**\r\n * Hook per osservare i dati spediti ad un Endpoint dal Backend\r\n * \r\n * @param {EndpointDef<TIn, any>} item Endpoint su cui ascoltare\r\n * \r\n * @returns {Observable<TIn>} Observable su cui ci si può registrare per ricevere l'oggetto generato ad ogni chiamata dal Backend al Frontend\r\n */\r\n public observe<TIn>(item: EndpointDef<TIn, any>): Observable<TIn> {\r\n if (!this.enabled)\r\n {\r\n this.log(this.loc(\"Observe request ignored because SignalR is not active by configuration\"));\r\n return EMPTY;\r\n }\r\n\r\n this.log(this.loc(\"Returning observable for required endpoint\") + \": \" + item.endpoint);\r\n return <Observable<TIn>>this.notifications$[item.endpoint];\r\n }\r\n\r\n /**\r\n * Disconnessione del sistema di SignalR\r\n * \r\n * @returns {Observable<void>} Observable a cui registrarsi che viene chiamato quando la disconnessione è terminata\r\n */\r\n public disconnect(): Observable<void> {\r\n //NO-OP se non attivo\r\n if (!this.enabled)\r\n {\r\n this.log(this.loc(\"Disconnection request ignored because SignalR is not active by configuration\"));\r\n return EMPTY;\r\n }\r\n\r\n return from(this.connection.stop()).pipe(\r\n catchError((err, caught) => { console.log(err); return of(null); }),\r\n tap(() => {\r\n this.log(this.loc(\"Disconnection request honored\"));\r\n })\r\n );\r\n }\r\n\r\n /**\r\n * Taglia un log troppo lungo\r\n * \r\n * @param {string} text Log da tagliare\r\n * @param {number} maxchars Numero massimo di caratteri da tenere\r\n * \r\n * @returns {string} Log tagliato\r\n */\r\n private substringLog(text: string, maxchars: number = 120) : string {\r\n return text.length > maxchars ? text.substr(0, maxchars) + \"[...]\" : text;\r\n }\r\n\r\n /**\r\n * Stampa un log a console\r\n * \r\n * @param {string} message Messaggio da stampare\r\n */\r\n private log(message: string) {\r\n if (this.debug)\r\n console.log(\"@signalr-notifications: \" + message)\r\n }\r\n\r\n /**\r\n * Helper di localizzazione\r\n * \r\n * @param {string} message Messaggio da tradurre\r\n * \r\n * @returns {string} Messaggio tradotto\r\n */\r\n private loc(message: string) : string{\r\n if(!Loc[message])\r\n {\r\n console.warn(\"Untranslated message: \" + message)\r\n return \"\";\r\n }\r\n return Loc[message][this.locale];\r\n }\r\n}","\r\nimport { NgModule, ModuleWithProviders } from '@angular/core';\r\nimport { SignalrNotificationsModuleConfig } from './config/SignalrNotificationsModuleConfig';\r\nimport { BaseMessageService } from './models/BaseMessageService';\r\nimport { NotificationsService } from './signalr-notifications.service';\r\nimport { HUB_URL, SIGNALR_ENABLED, DEBUG_MODE, LOCALE, MESSAGE_PACK, AUTO_RECONNECT } from './tokens';\r\n\r\n@NgModule()\r\nexport class SignalrNotificationsModule {\r\n static forRoot(config?: SignalrNotificationsModuleConfig): ModuleWithProviders<SignalrNotificationsModule> {\r\n return {\r\n ngModule: SignalrNotificationsModule,\r\n providers: [\r\n NotificationsService,\r\n { provide: BaseMessageService, useClass: config?.messageService || BaseMessageService },\r\n { provide: HUB_URL, useValue: config?.hubUrl },\r\n { provide: LOCALE, useValue: config?.locale || 'it-IT' },\r\n { provide: SIGNALR_ENABLED, useValue: config?.enabled != null ? config?.enabled : true },\r\n { provide: DEBUG_MODE, useValue: config?.debugMode != null ? config?.debugMode : false },\r\n { provide: MESSAGE_PACK, useValue: config?.autoReconnect != null ? config?.autoReconnect : false },\r\n { provide: AUTO_RECONNECT, useValue: config?.useMessagePack != null ? config?.useMessagePack : false },\r\n ]\r\n };\r\n }\r\n}","/**\r\n * Definisce un Endpoint che spedisce un'informazione di tipo TIn e restituisce un'informazione di tipo TOut\r\n */\r\nexport class EndpointDef<TIn, TOut> {\r\n\r\n /**\r\n * Costruttore\r\n * \r\n * @param {string} endpoint Nome del metodo da chiamare nell'Hub del Backend contattato\r\n * @param {TIn} inTypeDefault Default per il tipo TIn. Utilizzato per fare Typecheck sulle chiamate da Backend a Frontend\r\n * @param {TOut} outTypeDefault Default per il tipo TOut. Utilizzato per fare Typecheck sulle chiamate da Frontend a Backend\r\n */\r\n constructor(public endpoint: string, public inTypeDefault: TIn, public outTypeDefault: TOut) { }\r\n}","// Angular\r\nimport { Type } from '@angular/core';\r\n\r\n// Modelli\r\nimport { BaseMessageService } from '../models/BaseMessageService';\r\n\r\n/**\r\n * Classe di configurazione per la libreria\r\n */\r\nexport class SignalrNotificationsModuleConfig {\r\n\r\n /**\r\n * Url nei confronti del quale aprire la connessione SignalR\r\n */\r\n hubUrl : string;\r\n\r\n /**\r\n * Servizio che definisce i messaggi di IN e OUT coi loro default\r\n */\r\n messageService? : Type<BaseMessageService>;\r\n\r\n /**\r\n * Indica se abilitare o meno la connessione SignalR nei confronti dell'URL **hubUrl**\r\n */\r\n enabled? : boolean;\r\n\r\n /**\r\n * Indica se utilizzare message pack come protocollo di trasmissione\r\n */\r\n useMessagePack? : boolean;\r\n\r\n /**\r\n * Indica se tentare di riconnettersi automaticamente quando la connessione cade\r\n */\r\n autoReconnect? : boolean;\r\n\r\n /**\r\n * Indica se scrivere o meno i messaggi di debug\r\n */\r\n debugMode? : boolean;\r\n\r\n /**\r\n * Lingua dei feedback a console, sono supportati 'it-IT' ed 'en-US'\r\n */\r\n locale? : string\r\n}","/*\n * Public API Surface of signalr-notifications\n */\n\nexport * from './lib/signalr-notifications.service';\nexport * from './lib/signalr-notifications.module';\nexport * from './lib/models/BaseMessageService';\nexport * from './lib/models/EndpointDef';\nexport * from './lib/config/SignalrNotificationsModuleConfig';","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;AAEA;;;AAGO,MAAM,OAAO,GAA2B,IAAI,cAAc,CAAS,SAAS,CAAC,CAAC;AAErF;;;AAGO,MAAM,eAAe,GAA2B,IAAI,cAAc,CAAU,iBAAiB,CAAC,CAAC;AAEtG;;;AAGO,MAAM,UAAU,GAA2B,IAAI,cAAc,CAAU,YAAY,CAAC,CAAC;AAE5F;;;AAGO,MAAM,MAAM,GAA2B,IAAI,cAAc,CAAS,QAAQ,CAAC,CAAC;AAEnF;;;AAGO,MAAM,YAAY,GAA4B,IAAI,cAAc,CAAU,cAAc,CAAC,CAAC;AAEjG;;;AAGO,MAAM,cAAc,GAA4B,IAAI,cAAc,CAAU,gBAAgB,CAAC;;AC9BpG;;;AAGO,MAAM,GAAG,GAAE;IACd,kDAAkD,EAAE,EAAE,OAAO,EAAE,kDAAkD,EAAE,OAAO,EAAE,uDAAuD,GAAG;IACtL,gDAAgD,EAAE,EAAE,OAAO,EAAE,gDAAgD,EAAE,OAAO,EAAE,iEAAiE,GAAG;IAC5L,0FAA0F,EAAE,EAAE,OAAO,EAAE,0FAA0F,EAAE,OAAO,EAAE,4GAA4G,GAAG;IAC3T,4FAA4F,EAAE,EAAE,OAAO,EAAE,4FAA4F,EAAE,OAAO,EAAE,8GAA8G,GAAG;IACjU,6CAA6C,EAAG,EAAE,OAAO,EAAE,6CAA6C,EAAE,OAAO,EAAE,gDAAgD,GAAG;IACtK,+CAA+C,EAAE,EAAE,OAAO,EAAE,+CAA+C,EAAE,OAAO,EAAE,mDAAmD,GAAG;IAC5K,gDAAgD,EAAE,EAAE,OAAO,EAAE,gDA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,YAAmB,QAAgB,EAAS,aAAkB,EAAS,cAAoB;QAAxE,aAAQ,GAAR,QAAQ,CAAQ;QAAS,kBAAa,GAAb,aAAa,CAAK;QAAS,mBAAc,GAAd,cAAc,CAAM;KAAK;;;ACNpG;;;MAGa,gCAAgC;;;ACT7C;;;;ACAA;;;;;;"}
1
+ {"version":3,"file":"esfaenza-signalr-notifications.mjs","sources":["../../../projects/signalr-notifications/src/lib/tokens.ts","../../../projects/signalr-notifications/src/lib/signalr-notifications.service.loc.ts","../../../projects/signalr-notifications/src/lib/models/BaseMessageService.ts","../../../projects/signalr-notifications/src/lib/signalr-notifications.service.ts","../../../projects/signalr-notifications/src/lib/signalr-notifications.module.ts","../../../projects/signalr-notifications/src/lib/models/EndpointDef.ts","../../../projects/signalr-notifications/src/lib/config/SignalrNotificationsModuleConfig.ts","../../../projects/signalr-notifications/src/public-api.ts","../../../projects/signalr-notifications/src/esfaenza-signalr-notifications.ts"],"sourcesContent":["import { InjectionToken } from '@angular/core';\r\n\r\n/**\r\n * Hub a cui collegarsi\r\n */\r\nexport const HUB_URL: InjectionToken<string> = new InjectionToken<string>('HUB_URL');\r\n\r\n/**\r\n * Indica se la libreria dev'essere attiva o no\r\n */\r\nexport const SIGNALR_ENABLED: InjectionToken<string> = new InjectionToken<boolean>('SIGNALR_ENABLED');\r\n\r\n/**\r\n * Indica se stampare messaggi di debug in console\r\n */\r\nexport const DEBUG_MODE: InjectionToken<string> = new InjectionToken<boolean>('DEBUG_MODE');\r\n\r\n/**\r\n * Indica il locale utilizzato dalla libreria per i messaggi. Sono supportati \"it-IT\" ed \"en-US\"\r\n */\r\nexport const LOCALE: InjectionToken<string> = new InjectionToken<string>('LOCALE');\r\n\r\n/**\r\n * Indica se utilizzare il protocollo di trasferimento \"MessagePack\"\r\n */\r\nexport const MESSAGE_PACK: InjectionToken<boolean> = new InjectionToken<boolean>('MESSAGE_PACK');\r\n\r\n/**\r\n * Indica se tentare in automatico la riconnessione\r\n */\r\nexport const AUTO_RECONNECT: InjectionToken<boolean> = new InjectionToken<boolean>('AUTO_RECONNECT');","/**\r\n * Oggetto statico di localizzazione per i messaggi scritti dal servizio\r\n */\r\nexport const Loc ={\r\n \"Building SignalR Hub with Automatic Reconnection\": { \"en-US\": \"Building SignalR Hub with Automatic Reconnection\", \"it-IT\": \"Compilo l'Hub di SignalR con riconnessione automatica\", },\r\n \"Cannot reconnect SignalR, frontend HUB offline\": { \"en-US\": \"Cannot reconnect SignalR, frontend HUB offline\", \"it-IT\": \"Impossibile riconnettere SignalR, l'Hub del Frontend e' Offline\", },\r\n \"Send request sent before a connection was in stable State, waiting 1 second and retrying\": { \"en-US\": \"Send request sent before a connection was in stable State, waiting 1 second and retrying\", \"it-IT\": \"Richiesta 'Send' ricevuta prima che la connessione fosse in uno stato stabile, attendo 1 secondo e riprovo\", },\r\n \"Invoke request sent before a connection was in stable State, waiting 1 second and retrying\": { \"en-US\": \"Invoke request sent before a connection was in stable State, waiting 1 second and retrying\", \"it-IT\": \"Richiesta 'Invoke' ricevuta prima che la connessione fosse in uno stato stabile, attendo 1 secondo e riprovo\", },\r\n \"Connection lost or missing, reconnecting...\" : { \"en-US\": \"Connection lost or missing, reconnecting...\", \"it-IT\": \"Connessione persa o mancante, mi riconnetto...\", },\r\n \"SignalR won't be enabled as per configuration\": { \"en-US\": \"SignalR won't be enabled as per configuration\", \"it-IT\": \"SignalR non verrà attivato come da configurazione\", },\r\n \"Building SignalR Hub with MessagePack protocol\": { \"en-US\": \"Building SignalR Hub with MessagePack protocol\", \"it-IT\": \"Compilo l'Hub di SignalR con protocollo MessagePack\", },\r\n \"Request received from the server for endpoint\": { \"en-US\": \"Request received from the server for endpoint\", \"it-IT\": \"Richiesta ricevuta dal server per endpoint\", },\r\n \"Refusing to register endpoint\": { \"en-US\": \"Refusing to register endpoint\", \"it-IT\": \"Rifiuto di registrare l'endpoint\", },\r\n \"because it is not declared as IN - ONLY\": { \"en-US\": \"because it is not declared as IN - ONLY\", \"it-IT\": \"in quanto non è registrato solo come IN\", },\r\n \"Send request ignored because SignalR is not active by configuration\": { \"en-US\": \"Send request ignored because SignalR is not active by configuration\", \"it-IT\": \"Richiesta send ignorata in quanto SignalR non è attivo da configurazione\", },\r\n \"Request sent to server\": { \"en-US\": \"Request sent to server\", \"it-IT\": \"Richiesta inviata al server\", },\r\n \"Invoke request ignored because SignalR is not active by configuration\": { \"en-US\": \"Invoke request ignored because SignalR is not active by configuration\", \"it-IT\": \"Richiesta invoke ignorata in quanto SignalR non è attivo da configurazione\", },\r\n \"Request invoked to server\": { \"en-US\": \"Request invoked to server\", \"it-IT\": \"Richiesta invoke inviata al server\", },\r\n \"Observe request ignored because SignalR is not active by configuration\": { \"en-US\": \"Observe request ignored because SignalR is not active by configuration\", \"it-IT\": \"Osservazione ignorata in quanto SignalR non è attivo da configurazione\", },\r\n \"Returning observable for required endpoint\": { \"en-US\": \"Returning observable for required endpoint\", \"it-IT\": \"Restituisco l'observable per l'endpoint richiesto\", },\r\n \"Disconnection request ignored because SignalR is not active by configuration\": { \"en-US\": \"Disconnection request ignored because SignalR is not active by configuration\", \"it-IT\": \"Richiesta di disconnesione ignorata in quanto SignalR non è attivo da configurazione\", },\r\n \"Disconnection request honored\": { \"en-US\": \"Returning observable for required endpoint\", \"it-IT\": \"Restituito observable per l'endpoint richiesto\", },\r\n \"ERRORS on reconnecting before retrying a send command. Sent message WILL BE LOST\": { \"en-US\": \"ERRORS on reconnecting before retrying a send command. Sent message WILL BE LOST\", \"it-IT\": \"ERRORE nella riconnessione precedente a un nuovo tentativo di 'Send'. Il messaggio in questione SARA' PERSO\"}\r\n}","// Angular\r\nimport { Injectable } from '@angular/core';\r\n\r\n// Modelli\r\nimport { EndpointDef } from './EndpointDef';\r\n\r\n/**\r\n * Classe base da estendere con la definizione degli Endpoint supportati dall'applicazione\r\n */\r\n@Injectable()\r\nexport class BaseMessageService {\r\n\r\n private definitions: EndpointDef<any, any>[] = [];\r\n\r\n /** Entrypoint che restituisce tutti gli Endpoint dell'applicazione. Da overridare qualora non venga utilizzato il metodo **add** */\r\n public get AllDefinitions(): EndpointDef<any, any>[] { return this.definitions; }\r\n\r\n public add(endpoint: EndpointDef<any, any>) {\r\n this.definitions.push(endpoint);\r\n }\r\n}","// Angular\r\nimport { Injectable, Inject } from \"@angular/core\";\r\n\r\n// Direttive, Componenti, Librerie\r\nimport * as signalR from '@microsoft/signalr';\r\nimport { HubConnectionState } from \"@microsoft/signalr\";\r\nimport { Observable, Subject, EMPTY, from, of } from \"rxjs\";\r\nimport { catchError, concatMap, delay, tap } from \"rxjs/operators\";\r\n\r\n// Modelli\r\nimport { BaseMessageService } from './models/BaseMessageService';\r\nimport { EndpointDef } from './models/EndpointDef';\r\nimport { DEBUG_MODE, HUB_URL, LOCALE, MESSAGE_PACK, SIGNALR_ENABLED, AUTO_RECONNECT } from \"./tokens\";\r\n\r\n// Localizzazione\r\nimport { Loc } from './signalr-notifications.service.loc';\r\n\r\n/**\r\n * Servizio che gestisce la comunicazione con un Hub SignalR in base alle configurazioni fornite dall'applicazione\r\n */\r\n@Injectable()\r\nexport class NotificationsService {\r\n\r\n /**\r\n * Cache degli Observable generati in base agli Endpoint disponibili\r\n */\r\n private notifications$: { [index: string]: Subject<any> } = {};\r\n\r\n /**\r\n * Connessione Signalr\r\n */\r\n private connection: signalR.HubConnection;\r\n\r\n /**\r\n * Costruttore\r\n * \r\n * @ignore\r\n */\r\n constructor(private MessageDef: BaseMessageService, @Inject(HUB_URL) private hub_url: string, @Inject(MESSAGE_PACK) private msgpack: boolean, @Inject(SIGNALR_ENABLED) private enabled: boolean, @Inject(DEBUG_MODE) private debug: boolean, @Inject(AUTO_RECONNECT) autoreconnect: boolean, @Inject(LOCALE) private locale : string) {\r\n if (!this.enabled) {\r\n this.log(this.loc(\"SignalR won't be enabled as per configuration\"));\r\n return;\r\n }\r\n\r\n this.MessageDef.AllDefinitions.forEach(def => { this.notifications$[def.endpoint] = new Subject<typeof def.inTypeDefault>(); });\r\n\r\n let pars: signalR.IHttpConnectionOptions = { skipNegotiation: true, transport: signalR.HttpTransportType.WebSockets, logger: debug ? signalR.LogLevel.Debug : signalR.LogLevel.None };\r\n var builder = new signalR.HubConnectionBuilder().withUrl(this.hub_url, pars);\r\n\r\n if (autoreconnect) {\r\n this.log(this.loc(\"Building SignalR Hub with Automatic Reconnection\"));\r\n // 100 tentativi di riconnessione, 1 ogni 5 secondi\r\n builder = builder.withAutomaticReconnect(new Array(100).fill(5 * 1000));\r\n }\r\n\r\n if (this.msgpack) {\r\n this.log(this.loc(\"Building SignalR Hub with MessagePack protocol\"));\r\n var mphpModule = require(\"@microsoft/signalr-protocol-msgpack\");\r\n builder = builder.withHubProtocol(new mphpModule.MessagePackHubProtocol())\r\n }\r\n\r\n this.connection = builder.build();\r\n this.connect();\r\n }\r\n\r\n /**\r\n * Effettua la connessione all'Hub Signalr e registra tutti gli Endpoint per cui il Backend comunica con il Frontend sulla **connection**\r\n */\r\n private connect() {\r\n this.connection.start().catch(err => console.log(err));\r\n this.MessageDef.AllDefinitions.forEach(d => {\r\n //Registro solo le cose di IN, quelle di out sono chiamate che faccio io al BE quindi non servono\r\n if (d.inTypeDefault !== null && d.outTypeDefault === null)\r\n this.connection.on(d.endpoint, (message) => {\r\n this.log(this.loc(\"Request received from the server for endpoint\") + \" '\" + d.endpoint + \"': \" + this.substringLog(JSON.stringify(message)));\r\n this.notifications$[d.endpoint].next(message);\r\n });\r\n else\r\n this.log(this.loc(\"Refusing to register endpoint\") + \" \" + d.endpoint + \" \" + this.loc(\"because it is not declared as IN - ONLY\"));\r\n });\r\n }\r\n\r\n /**\r\n * Effettua verifiche sulla connessione e, in caso non fosse collegata, tenta di riconnetterla\r\n * \r\n * @returns {Promise<'OK' | 'KO' | 'NO-OP'>} 'OK' Se la connessione è già connessa o è stata riconnessa con successo, 'KO' Se non è stato possibile riconnettere \r\n * una connessione disconnessa, 'NO-OP' se la connesisone è in uno stato intermedio che non può essere modificato\r\n */\r\n public ensureConnected(): Promise<'OK' | 'KO' | 'NO-OP'> {\r\n if (this.connection.state == HubConnectionState.Disconnected) {\r\n this.log(this.loc(\"Connection lost or missing, reconnecting...\"));\r\n\r\n return this.connection.start()\r\n .then(_ => {\r\n return Promise.resolve(\"OK\");\r\n }, _ => {\r\n this.log(this.loc(\"Cannot reconnect SignalR, frontend HUB offline\"));\r\n return Promise.resolve(\"KO\");\r\n });\r\n }\r\n else if (this.connection.state == HubConnectionState.Connected)\r\n return Promise.resolve(\"OK\");\r\n else\r\n return Promise.resolve(\"NO-OP\");\r\n }\r\n\r\n /**\r\n * Invia un messaggio all'Hub del Backend\r\n * \r\n * @param {EndpointDef<TOut, any>} item Endpoint da contattare\r\n * @param {TOut} dto Dto da inviare all'Endpoint\r\n */\r\n public send<TOut>(item: EndpointDef<TOut, any>, dto: TOut) {\r\n if (!this.enabled) {\r\n this.log(this.loc(\"Send request ignored because SignalR is not active by configuration\"));\r\n return EMPTY;\r\n }\r\n\r\n if (this.connection.state == HubConnectionState.Connecting || this.connection.state == HubConnectionState.Reconnecting || this.connection.state == HubConnectionState.Disconnecting) {\r\n this.log(this.loc(\"Send request sent before a connection was in stable State, waiting 1 second and retrying\"));\r\n setTimeout(() => { this.send(item, dto); }, 1000);\r\n }\r\n else if (this.connection.state == HubConnectionState.Disconnected) {\r\n this.ensureConnected().then(t => {\r\n if (t == \"KO\") this.log(this.loc(\"ERRORS on reconnecting before retrying a send command. Sent message WILL BE LOST\"));\r\n else this.send(item, dto);\r\n })\r\n }\r\n else {\r\n this.connection.send(item.endpoint, dto).then(_ => {\r\n if (this.debug)\r\n console.info(this.loc(\"Request sent to server\") + \" - \" + item.endpoint + \": \" + this.substringLog(JSON.stringify(dto)));\r\n });\r\n }\r\n }\r\n\r\n /**\r\n * Invia un messaggio all'Hub del Backend, aspettandosi una risposta\r\n * \r\n * @param {EndpointDef<TOut, TIn>} item Endpoint da contattare\r\n * @param {TOut} dto Dto da inviare all'Endpoint\r\n * \r\n * @returns {Observable<TIn>} Observable su cui ci si può registrare per ricevere il risultato della chiamata\r\n */\r\n public invoke<TOut, TIn>(item: EndpointDef<TOut, TIn>, dto: TOut): Observable<TIn> {\r\n if (!this.enabled) {\r\n this.log(this.loc(\"Invoke request ignored because SignalR is not active by configuration\"));\r\n return EMPTY;\r\n }\r\n\r\n if (this.connection.state == HubConnectionState.Connecting || this.connection.state == HubConnectionState.Reconnecting || this.connection.state == HubConnectionState.Disconnecting) {\r\n this.log(this.loc(\"Invoke request sent before a connection was in stable State, waiting 1 second and retrying\"));\r\n return of().pipe(delay(1000), concatMap(() => this.invoke(item, dto)));\r\n }\r\n else if (this.connection.state == HubConnectionState.Disconnected) {\r\n return from(this.ensureConnected()).pipe(concatMap((res) => {\r\n if (res == \"KO\") {\r\n this.log(this.loc(\"ERRORS on reconnecting before retrying a send command. Sent message WILL BE LOST\"));\r\n return EMPTY;\r\n }\r\n else return this.invoke(item, dto);\r\n }))\r\n }\r\n else {\r\n return from(this.connection.invoke<TIn>(item.endpoint, dto)).pipe(\r\n tap(() => {\r\n if (this.debug) console.log(this.loc(\"Request invoked to server\") + \" - \" + item.endpoint + \": \" + this.substringLog(JSON.stringify(dto)));\r\n })\r\n );\r\n }\r\n }\r\n\r\n /**\r\n * Hook per osservare i dati spediti ad un Endpoint dal Backend\r\n * \r\n * @param {EndpointDef<TIn, any>} item Endpoint su cui ascoltare\r\n * \r\n * @returns {Observable<TIn>} Observable su cui ci si può registrare per ricevere l'oggetto generato ad ogni chiamata dal Backend al Frontend\r\n */\r\n public observe<TIn>(item: EndpointDef<TIn, any>): Observable<TIn> {\r\n if (!this.enabled)\r\n {\r\n this.log(this.loc(\"Observe request ignored because SignalR is not active by configuration\"));\r\n return EMPTY;\r\n }\r\n\r\n this.log(this.loc(\"Returning observable for required endpoint\") + \": \" + item.endpoint);\r\n return <Observable<TIn>>this.notifications$[item.endpoint];\r\n }\r\n\r\n /**\r\n * Disconnessione del sistema di SignalR\r\n * \r\n * @returns {Observable<void>} Observable a cui registrarsi che viene chiamato quando la disconnessione è terminata\r\n */\r\n public disconnect(): Observable<void> {\r\n //NO-OP se non attivo\r\n if (!this.enabled)\r\n {\r\n this.log(this.loc(\"Disconnection request ignored because SignalR is not active by configuration\"));\r\n return EMPTY;\r\n }\r\n\r\n return from(this.connection.stop()).pipe(\r\n catchError((err, caught) => { console.log(err); return of(null); }),\r\n tap(() => {\r\n this.log(this.loc(\"Disconnection request honored\"));\r\n })\r\n );\r\n }\r\n\r\n /**\r\n * Taglia un log troppo lungo\r\n * \r\n * @param {string} text Log da tagliare\r\n * @param {number} maxchars Numero massimo di caratteri da tenere\r\n * \r\n * @returns {string} Log tagliato\r\n */\r\n private substringLog(text: string, maxchars: number = 120) : string {\r\n return text.length > maxchars ? text.substr(0, maxchars) + \"[...]\" : text;\r\n }\r\n\r\n /**\r\n * Stampa un log a console\r\n * \r\n * @param {string} message Messaggio da stampare\r\n */\r\n private log(message: string) {\r\n if (this.debug)\r\n console.log(\"@signalr-notifications: \" + message)\r\n }\r\n\r\n /**\r\n * Helper di localizzazione\r\n * \r\n * @param {string} message Messaggio da tradurre\r\n * \r\n * @returns {string} Messaggio tradotto\r\n */\r\n private loc(message: string) : string{\r\n if(!Loc[message])\r\n {\r\n console.warn(\"Untranslated message: \" + message)\r\n return \"\";\r\n }\r\n return Loc[message][this.locale];\r\n }\r\n}","\r\nimport { NgModule, ModuleWithProviders } from '@angular/core';\r\nimport { SignalrNotificationsModuleConfig } from './config/SignalrNotificationsModuleConfig';\r\nimport { BaseMessageService } from './models/BaseMessageService';\r\nimport { NotificationsService } from './signalr-notifications.service';\r\nimport { HUB_URL, SIGNALR_ENABLED, DEBUG_MODE, LOCALE, MESSAGE_PACK, AUTO_RECONNECT } from './tokens';\r\n\r\n@NgModule()\r\nexport class SignalrNotificationsModule {\r\n static forRoot(config?: SignalrNotificationsModuleConfig): ModuleWithProviders<SignalrNotificationsModule> {\r\n return {\r\n ngModule: SignalrNotificationsModule,\r\n providers: [\r\n NotificationsService,\r\n { provide: BaseMessageService, useClass: config?.messageService || BaseMessageService },\r\n { provide: HUB_URL, useValue: config?.hubUrl },\r\n { provide: LOCALE, useValue: config?.locale || 'it-IT' },\r\n { provide: SIGNALR_ENABLED, useValue: config?.enabled != null ? config?.enabled : true },\r\n { provide: DEBUG_MODE, useValue: config?.debugMode != null ? config?.debugMode : false },\r\n { provide: MESSAGE_PACK, useValue: config?.autoReconnect != null ? config?.autoReconnect : false },\r\n { provide: AUTO_RECONNECT, useValue: config?.useMessagePack != null ? config?.useMessagePack : false },\r\n ]\r\n };\r\n }\r\n}","/**\r\n * Definisce un Endpoint che spedisce un'informazione di tipo TIn e restituisce un'informazione di tipo TOut\r\n */\r\nexport class EndpointDef<TIn, TOut> {\r\n\r\n /**\r\n * Costruttore\r\n * \r\n * @param {string} endpoint Nome del metodo da chiamare nell'Hub del Backend contattato\r\n * @param {TIn} inTypeDefault Default per il tipo TIn. Utilizzato per fare Typecheck sulle chiamate da Backend a Frontend\r\n * @param {TOut} outTypeDefault Default per il tipo TOut. Utilizzato per fare Typecheck sulle chiamate da Frontend a Backend\r\n */\r\n constructor(public endpoint: string, public inTypeDefault: TIn, public outTypeDefault: TOut) { }\r\n\r\n\r\n /** Helper per la creazione rapida di un Endpoint di solo INPUT */\r\n public static In<TIn>(name: string, inTypeDefault: TIn): EndpointDef<TIn, void> {\r\n return new EndpointDef<TIn, void>(name, inTypeDefault, undefined);\r\n }\r\n\r\n /** Helper per la creazione rapida di un Endpoint di solo OUTPUT */\r\n public static Out<TOut>(name: string, outTypeDefault: TOut): EndpointDef<void, TOut> {\r\n return new EndpointDef<void, TOut>(name, undefined, outTypeDefault);\r\n }\r\n\r\n /** Helper per la creazione rapida di un Endpoint di INPUT e OUTPUT (BIDIREZIONALE) */\r\n public static Bi<TIn, TOut>(name: string, inTypeDefault: TIn, outTypeDefault: TOut): EndpointDef<TIn, TOut> {\r\n return new EndpointDef<TIn, TOut>(name, inTypeDefault, outTypeDefault);\r\n }\r\n}","// Angular\r\nimport { Type } from '@angular/core';\r\n\r\n// Modelli\r\nimport { BaseMessageService } from '../models/BaseMessageService';\r\n\r\n/**\r\n * Classe di configurazione per la libreria\r\n */\r\nexport class SignalrNotificationsModuleConfig {\r\n\r\n /**\r\n * Url nei confronti del quale aprire la connessione SignalR\r\n */\r\n hubUrl : string;\r\n\r\n /**\r\n * Servizio che definisce i messaggi di IN e OUT coi loro default\r\n */\r\n messageService? : Type<BaseMessageService>;\r\n\r\n /**\r\n * Indica se abilitare o meno la connessione SignalR nei confronti dell'URL **hubUrl**\r\n */\r\n enabled? : boolean;\r\n\r\n /**\r\n * Indica se utilizzare message pack come protocollo di trasmissione\r\n */\r\n useMessagePack? : boolean;\r\n\r\n /**\r\n * Indica se tentare di riconnettersi automaticamente quando la connessione cade\r\n */\r\n autoReconnect? : boolean;\r\n\r\n /**\r\n * Indica se scrivere o meno i messaggi di debug\r\n */\r\n debugMode? : boolean;\r\n\r\n /**\r\n * Lingua dei feedback a console, sono supportati 'it-IT' ed 'en-US'\r\n */\r\n locale? : string\r\n}","/*\n * Public API Surface of signalr-notifications\n */\n\nexport * from './lib/signalr-notifications.service';\nexport * from './lib/signalr-notifications.module';\nexport * from './lib/models/BaseMessageService';\nexport * from './lib/models/EndpointDef';\nexport * from './lib/config/SignalrNotificationsModuleConfig';","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;AAEA;;;AAGO,MAAM,OAAO,GAA2B,IAAI,cAAc,CAAS,SAAS,CAAC,CAAC;AAErF;;;AAGO,MAAM,eAAe,GAA2B,IAAI,cAAc,CAAU,iBAAiB,CAAC,CAAC;AAEtG;;;AAGO,MAAM,UAAU,GAA2B,IAAI,cAAc,CAAU,YAAY,CAAC,CAAC;AAE5F;;;AAGO,MAAM,MAAM,GAA2B,IAAI,cAAc,CAAS,QAAQ,CAAC,CAAC;AAEnF;;;AAGO,MAAM,YAAY,GAA4B,IAAI,cAAc,CAAU,cAAc,CA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AC9E,OAAO,IAAI,WAAW,CAAY,IAAI,EAAE,aAAa,EAAE,cAAc,CAAC,CAAC;KAC1E;;;ACtBL;;;MAGa,gCAAgC;;;ACT7C;;;;ACAA;;;;;;"}
@@ -4,10 +4,10 @@ import * as i0 from "@angular/core";
4
4
  * Classe base da estendere con la definizione degli Endpoint supportati dall'applicazione
5
5
  */
6
6
  export declare class BaseMessageService {
7
- /**
8
- * Entrypoint che restituisce tutti gli Endpoint dell'applicazione
9
- */
7
+ private definitions;
8
+ /** Entrypoint che restituisce tutti gli Endpoint dell'applicazione. Da overridare qualora non venga utilizzato il metodo **add** */
10
9
  get AllDefinitions(): EndpointDef<any, any>[];
10
+ add(endpoint: EndpointDef<any, any>): void;
11
11
  static ɵfac: i0.ɵɵFactoryDeclaration<BaseMessageService, never>;
12
12
  static ɵprov: i0.ɵɵInjectableDeclaration<BaseMessageService>;
13
13
  }
@@ -13,4 +13,10 @@ export declare class EndpointDef<TIn, TOut> {
13
13
  * @param {TOut} outTypeDefault Default per il tipo TOut. Utilizzato per fare Typecheck sulle chiamate da Frontend a Backend
14
14
  */
15
15
  constructor(endpoint: string, inTypeDefault: TIn, outTypeDefault: TOut);
16
+ /** Helper per la creazione rapida di un Endpoint di solo INPUT */
17
+ static In<TIn>(name: string, inTypeDefault: TIn): EndpointDef<TIn, void>;
18
+ /** Helper per la creazione rapida di un Endpoint di solo OUTPUT */
19
+ static Out<TOut>(name: string, outTypeDefault: TOut): EndpointDef<void, TOut>;
20
+ /** Helper per la creazione rapida di un Endpoint di INPUT e OUTPUT (BIDIREZIONALE) */
21
+ static Bi<TIn, TOut>(name: string, inTypeDefault: TIn, outTypeDefault: TOut): EndpointDef<TIn, TOut>;
16
22
  }
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@esfaenza/signalr-notifications",
3
- "version": "13.1.3",
3
+ "version": "13.3.1",
4
4
  "dependencies": {
5
5
  "tslib": "^2.0.0"
6
6
  },
7
7
  "peerDependencies": {
8
- "@angular/common": "~13.1.1",
9
- "@angular/core": "~13.1.1",
10
- "@microsoft/signalr": "6.0.1",
11
- "@microsoft/signalr-protocol-msgpack": "6.0.1"
8
+ "@angular/common": "~13.3.9",
9
+ "@angular/core": "~13.3.9",
10
+ "@microsoft/signalr": "6.0.5",
11
+ "@microsoft/signalr-protocol-msgpack": "6.0.5"
12
12
  },
13
13
  "module": "fesm2015/esfaenza-signalr-notifications.mjs",
14
14
  "es2020": "fesm2020/esfaenza-signalr-notifications.mjs",