@esfaenza/extensions 11.2.22 → 11.2.23

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.
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('ngx-toastr'), require('sweetalert2'), require('cerialize')) :
3
- typeof define === 'function' && define.amd ? define('@esfaenza/extensions', ['exports', '@angular/core', 'ngx-toastr', 'sweetalert2', 'cerialize'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.esfaenza = global.esfaenza || {}, global.esfaenza.extensions = {}), global.ng.core, global.ngxToastr, global.swal, global.cerialize));
5
- }(this, (function (exports, core, ngxToastr, swal, cerialize) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('ngx-toastr'), require('sweetalert2'), require('cerialize'), require('rxjs')) :
3
+ typeof define === 'function' && define.amd ? define('@esfaenza/extensions', ['exports', '@angular/core', 'ngx-toastr', 'sweetalert2', 'cerialize', 'rxjs'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.esfaenza = global.esfaenza || {}, global.esfaenza.extensions = {}), global.ng.core, global.ngxToastr, global.swal, global.cerialize, global.rxjs));
5
+ }(this, (function (exports, core, ngxToastr, swal, cerialize, rxjs) { 'use strict';
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
@@ -1788,6 +1788,67 @@
1788
1788
  { type: core.Injectable }
1789
1789
  ];
1790
1790
 
1791
+ /** Classe che rappresenta un generico messaggio scambiato fra applicazione e moduli */
1792
+ var InterComMessage = /** @class */ (function () {
1793
+ /**
1794
+ * Costruttore
1795
+ *
1796
+ * @param type Tipo di messaggio
1797
+ * @param message Contenuto del messaggio
1798
+ */
1799
+ function InterComMessage(type, message) {
1800
+ this.type = type;
1801
+ this.message = message;
1802
+ }
1803
+ return InterComMessage;
1804
+ }());
1805
+
1806
+ // Angular
1807
+ /** Service che si occupa di gestire la comunicazione fra i moduli interni ed esterni dell'applicativo */
1808
+ var InterComService = /** @class */ (function () {
1809
+ function InterComService() {
1810
+ /** Messaggi in uscita, uno per ogni recipient registratosi dall'entrypoint **register** */
1811
+ this.outbounds = {};
1812
+ /** Messaggi in entrata, unico per applicazione principale */
1813
+ this.inbounds = new rxjs.Subject();
1814
+ }
1815
+ /**
1816
+ * Metodo che permette di inviare un messaggio dall'applicazione ad un modulo esterno o viceversa
1817
+ *
1818
+ * @param {any} messageType Tipologia di messaggio. Sarà di tipo **InboundMessageTypes** per tutti i messaggi inbound, dinamico per tutti i mesaggi outbound (il tipo dipenderà dagli enum dei messaggi dei moduli esterni)
1819
+ * @param {any} message Messaggio da inviare che può essere un dto in casi complessi ma dovrà essere gestito a dovere lato implementativo
1820
+ * @param {string} recipient Destinatario del messaggio. Per i messaggi inbound dev'essere lasciato vuoto, per i messaggi outbound sarà valorizzato alla chiave del modulo a cui si vuole inviare il messaggio
1821
+ */
1822
+ InterComService.prototype.send = function (messageType, message, recipient) {
1823
+ var msg = new InterComMessage(messageType, message);
1824
+ // Se non c'è un recipient significa che è un modulo esterno che invia messaggi al modulo main (quindi messaggio in entrata - inbound)
1825
+ // Altrimenti significa che è il modulo main ad inviare messaggi ai moduli esterni (messaggio in uscita - outbound)
1826
+ if (!recipient) {
1827
+ this.inbounds.next(msg);
1828
+ }
1829
+ else {
1830
+ if (!this.outbounds[recipient])
1831
+ console.warn("@esfaenza/extensions - InterComService: Impossibile inviare il messaggio al recipient " + recipient + " assicurarsi che il modulo sia caricato e che effettui la chiamata al metodo 'regisster'");
1832
+ else
1833
+ this.outbounds[recipient].next(msg);
1834
+ }
1835
+ };
1836
+ /**
1837
+ * Permette di registrare un modulo esterno alla lista dei moduli in listening sulla coda di messaggi
1838
+ *
1839
+ * @param {string} key Chiave del modulo da registrare. Tutti i messaggi inbound saranno inviati dall'applicazione principale su questa chiave
1840
+ */
1841
+ InterComService.prototype.register = function (key) {
1842
+ if (this.outbounds[key])
1843
+ throw "@esfaenza/extensions - InterComService: Impossibile registrare più volte lo stesso modulo";
1844
+ this.outbounds[key] = new rxjs.Subject();
1845
+ };
1846
+ return InterComService;
1847
+ }());
1848
+ InterComService.decorators = [
1849
+ { type: core.Injectable }
1850
+ ];
1851
+
1791
1852
  // Angular
1792
1853
  /**
1793
1854
  * Modulo di estensione che registra autonomamente **TUTTI** i servizi di estensione:
@@ -1797,6 +1858,7 @@
1797
1858
  * HashingService,
1798
1859
  * MessageService,
1799
1860
  * UtilityService
1861
+ * InterComService
1800
1862
  *
1801
1863
  * con eventuali provider che utilizzano
1802
1864
  */
@@ -1813,6 +1875,7 @@
1813
1875
  HashingService,
1814
1876
  MessageService,
1815
1877
  UtilityService,
1878
+ InterComService,
1816
1879
  { provide: EXT_LOCALE, useValue: (config === null || config === void 0 ? void 0 : config.locale) || 'it-IT' },
1817
1880
  { provide: EXT_FANCY_ALERTS, useValue: (config === null || config === void 0 ? void 0 : config.fancy_alerts) || true },
1818
1881
  { provide: APPSEARCH_PREFIX, useValue: (config === null || config === void 0 ? void 0 : config.appsearch_prefix) || 'Hot' },
@@ -1853,6 +1916,13 @@
1853
1916
  return GenericItem;
1854
1917
  }());
1855
1918
 
1919
+ /** Enumeratore dei tipi di messaggio che i moduli esterni possono contattare sull'applicazione principale */
1920
+ exports.InboundMessageTypes = void 0;
1921
+ (function (InboundMessageTypes) {
1922
+ /** Evento di navigazione */
1923
+ InboundMessageTypes[InboundMessageTypes["Navigation"] = 0] = "Navigation";
1924
+ })(exports.InboundMessageTypes || (exports.InboundMessageTypes = {}));
1925
+
1856
1926
  /*
1857
1927
  * Public API Surface of extensions
1858
1928
  */
@@ -1878,6 +1948,8 @@
1878
1948
  exports.FullExtensionsModule = FullExtensionsModule;
1879
1949
  exports.GenericItem = GenericItem;
1880
1950
  exports.HashingService = HashingService;
1951
+ exports.InterComMessage = InterComMessage;
1952
+ exports.InterComService = InterComService;
1881
1953
  exports.MessageService = MessageService;
1882
1954
  exports.UtilityService = UtilityService;
1883
1955