react-ecosistema-unp 1.6.14 → 1.7.0-pre.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.
Files changed (36) hide show
  1. package/dist/assets/MenuLateral.css +1 -1
  2. package/dist/auth/contexts/AuthContex.js +10 -10
  3. package/dist/cards/tarjeta/nuevo-elemento/NuevoElemento.js +1 -1
  4. package/dist/cards/tarjeta-info/TarjetaInfo.js +5 -4
  5. package/dist/data/tarjeta-datos/TarjetaDatos.js +1 -1
  6. package/dist/{index-BpmHFDVa.js → index-Cpp73e44.js} +7 -7
  7. package/dist/lib/auth/contexts/AuthContex.d.ts +3 -0
  8. package/dist/lib/shared/menu-lateral/MenuLateral.d.ts +1 -0
  9. package/dist/lib/shared/ventana-lienzo/VentanaLienzo.d.ts +1 -0
  10. package/dist/lib/shared/ventana-tabs/VentanaTabs.d.ts +1 -0
  11. package/dist/lib/tables/tabla-registros/modal/Modal.d.ts +6 -2
  12. package/dist/lib/ui.d.ts +1 -0
  13. package/dist/lib/utils/websocket-manager/WebSocketContext.d.ts +13 -0
  14. package/dist/lib/utils/websocket-manager/useWebSocket.d.ts +1 -0
  15. package/dist/lib/utils/websocket-manager/websocket.d.ts +19 -0
  16. package/dist/lib/utils.d.ts +2 -0
  17. package/dist/shared/app-list/AppList.js +1 -1
  18. package/dist/shared/iconos-sistema/logout-button/LogoutButton.js +1 -1
  19. package/dist/shared/menu-lateral/MenuLateral.js +181 -99
  20. package/dist/shared/ventana-lienzo/VentanaLienzo.js +13 -13
  21. package/dist/shared/ventana-tabs/VentanaTabs.js +104 -104
  22. package/dist/tables/tabla-registros/TablaRegistros.js +1 -1
  23. package/dist/tables/tabla-registros/buscador/Buscador.js +4 -4
  24. package/dist/tables/tabla-registros/modal/Modal.js +23 -22
  25. package/dist/tables/tabla-registros/tabla/Tabla.js +1 -1
  26. package/dist/ui/contenido-modal/ContenidoModal.js +1 -1
  27. package/dist/ui/contenido-modal/ContenidoModalv0.1.js +1 -1
  28. package/dist/ui/icono-tooltip/IconoTooltip.js +1 -1
  29. package/dist/ui/items-modal/ItemsModal.js +5 -5
  30. package/dist/ui.js +8 -7
  31. package/dist/utils/unp-historico/UnpHistorico.js +4 -3
  32. package/dist/utils/websocket-manager/WebSocketContext.js +23 -0
  33. package/dist/utils/websocket-manager/useWebSocket.js +16 -0
  34. package/dist/utils/websocket-manager/websocket.js +62 -0
  35. package/dist/utils.js +15 -10
  36. package/package.json +1 -1
@@ -0,0 +1,62 @@
1
+ var i = Object.defineProperty;
2
+ var r = (c, t, e) => t in c ? i(c, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : c[t] = e;
3
+ var s = (c, t, e) => r(c, typeof t != "symbol" ? t + "" : t, e);
4
+ class a {
5
+ constructor() {
6
+ s(this, "socket", null);
7
+ s(this, "messageHandlers", /* @__PURE__ */ new Set());
8
+ s(this, "statusCallbacks", []);
9
+ s(this, "url", null);
10
+ s(this, "reconnectTimer", null);
11
+ s(this, "reconnectionAttempts", 0);
12
+ }
13
+ // Método para actualizar estado y notificar a los suscriptores
14
+ setStatus(t) {
15
+ this.statusCallbacks.forEach((e) => e(t));
16
+ }
17
+ // Permite suscribirse a cambios de estado
18
+ subscribeToStatus(t) {
19
+ return this.statusCallbacks.push(t), () => {
20
+ this.statusCallbacks = this.statusCallbacks.filter((e) => e !== t);
21
+ };
22
+ }
23
+ connect(t) {
24
+ this.socket || (this.url = t, this.setStatus("connecting"), this.socket = new WebSocket(t), this.socket.onopen = () => {
25
+ console.log(`✅ WebSocket conectado a ${t}`), this.setStatus("connected"), this.reconnectionAttempts = 0, this.reconnectTimer && clearTimeout(this.reconnectTimer), this.reconnectTimer = null;
26
+ }, this.socket.onmessage = (e) => {
27
+ try {
28
+ const n = JSON.parse(e.data);
29
+ this.messageHandlers.forEach((o) => o(n));
30
+ } catch (n) {
31
+ console.error("❌ Error parseando mensaje WebSocket", n);
32
+ }
33
+ }, this.socket.onclose = () => {
34
+ if (console.warn("🔌 WebSocket cerrado. Reintentando..."), this.socket = null, !this.reconnectTimer) {
35
+ let e = 3e3;
36
+ this.setStatus("connecting"), this.reconnectionAttempts > 5 && (e = 3e4, this.reconnectionAttempts = 0, this.setStatus("disconnected")), this.reconnectTimer = setTimeout(() => {
37
+ this.reconnectTimer = null, this.url && (this.reconnectionAttempts++, this.connect(this.url));
38
+ }, e);
39
+ }
40
+ }, this.socket.onerror = (e) => {
41
+ var n;
42
+ console.error("⚠️ WebSocket error:", e), this.setStatus("disconnected"), (n = this.socket) == null || n.close();
43
+ });
44
+ }
45
+ disconnect() {
46
+ this.socket && (this.socket.close(), this.socket = null), this.setStatus("disconnected");
47
+ }
48
+ send(t) {
49
+ var e;
50
+ ((e = this.socket) == null ? void 0 : e.readyState) === WebSocket.OPEN && this.socket.send(JSON.stringify(t));
51
+ }
52
+ subscribe(t) {
53
+ return this.messageHandlers.add(t), () => this.unsubscribe(t);
54
+ }
55
+ unsubscribe(t) {
56
+ this.messageHandlers.delete(t);
57
+ }
58
+ }
59
+ const l = new a();
60
+ export {
61
+ l as webSocketService
62
+ };
package/dist/utils.js CHANGED
@@ -1,17 +1,22 @@
1
- import { AuthProvider as t } from "./auth/contexts/AuthContex.js";
1
+ import { AuthProvider as r } from "./auth/contexts/AuthContex.js";
2
2
  import { ProtectedRoute as m } from "./utils/components/ProtectedRoute.js";
3
- import { UserRoute as a } from "./utils/components/UserRoute.js";
3
+ import { UserRoute as s } from "./utils/components/UserRoute.js";
4
4
  import { UnpHistorico as f } from "./utils/unp-historico/UnpHistorico.js";
5
- import { IsInvalidStyles as x, useFormValidation as c } from "./utils/validations/useFormValidation.js";
6
- import { CaptchaEcosistema as d } from "./utils/captcha/CaptchaEcosistema.js";
7
- import { useFetchData as l } from "./utils/fetch-data/useFetchData.js";
5
+ import { IsInvalidStyles as x, useFormValidation as a } from "./utils/validations/useFormValidation.js";
6
+ import { CaptchaEcosistema as n } from "./utils/captcha/CaptchaEcosistema.js";
7
+ import { useFetchData as S } from "./utils/fetch-data/useFetchData.js";
8
+ import { WebSocketProvider as h, useWebSocketConnection as k } from "./utils/websocket-manager/WebSocketContext.js";
9
+ import { useWebSocket as v } from "./utils/websocket-manager/useWebSocket.js";
8
10
  export {
9
- t as AuthProvider,
10
- d as CaptchaEcosistema,
11
+ r as AuthProvider,
12
+ n as CaptchaEcosistema,
11
13
  x as IsInvalidStyles,
12
14
  m as ProtectedRoute,
13
15
  f as UnpHistorico,
14
- a as UserRoute,
15
- l as useFetchData,
16
- c as useFormValidation
16
+ s as UserRoute,
17
+ h as WebSocketProvider,
18
+ S as useFetchData,
19
+ a as useFormValidation,
20
+ v as useWebSocket,
21
+ k as useWebSocketConnection
17
22
  };
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "react-ecosistema-unp",
3
3
  "author": "Ecosistema de Información - Unidad Nacional de Protección",
4
4
  "private": false,
5
- "version": "1.6.14",
5
+ "version": "1.7.0-pre.1",
6
6
  "type": "module",
7
7
  "exports": {
8
8
  ".": {