valtech-components 4.0.223 → 4.0.225
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm2022/lib/components/organisms/chat-window/chat-window.component.mjs +8 -3
- package/esm2022/lib/services/i18n/default-content.mjs +5 -1
- package/esm2022/lib/version.mjs +2 -2
- package/fesm2022/valtech-components.mjs +11 -2
- package/fesm2022/valtech-components.mjs.map +1 -1
- package/lib/components/organisms/chat-window/chat-window.component.d.ts +1 -0
- package/lib/version.d.ts +1 -1
- package/package.json +1 -1
- package/src/lib/services/firebase/firebase-messaging-sw.js +90 -0
|
@@ -46,6 +46,7 @@ export declare class ChatWindowComponent implements OnChanges, AfterViewChecked
|
|
|
46
46
|
private messagesListRef?;
|
|
47
47
|
private prevMessageCount;
|
|
48
48
|
private shouldScrollToBottom;
|
|
49
|
+
private readonly messagesSig;
|
|
49
50
|
constructor();
|
|
50
51
|
ngOnChanges(changes: SimpleChanges): void;
|
|
51
52
|
ngAfterViewChecked(): void;
|
package/lib/version.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* firebase-messaging-sw.js — Service Worker estatico de valtech-components.
|
|
3
|
+
*
|
|
4
|
+
* NO EDITAR en el consumer. Este archivo se publica con la libreria y se copia a
|
|
5
|
+
* la raiz del sitio via el glob de angular.json:
|
|
6
|
+
*
|
|
7
|
+
* { "glob": "firebase-messaging-sw.js",
|
|
8
|
+
* "input": "node_modules/valtech-components/src/lib/services/firebase",
|
|
9
|
+
* "output": "/" }
|
|
10
|
+
*
|
|
11
|
+
* Lee la config de Firebase desde /firebase-config.js (self.FIREBASE_CONFIG),
|
|
12
|
+
* generado en build-time por `npx valtech-firebase-config`. Maneja:
|
|
13
|
+
* - mensajes en background (FCM) → muestra la notificacion del sistema.
|
|
14
|
+
* - click en la notificacion → enfoca/abre la app y postMessage NOTIFICATION_CLICK
|
|
15
|
+
* al cliente (lo consume MessagingService.onNotificationClick()).
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/* eslint-disable no-undef */
|
|
19
|
+
|
|
20
|
+
// SDK compat de Firebase (debe coincidir con la major del peer dep firebase ^10).
|
|
21
|
+
importScripts(
|
|
22
|
+
'https://www.gstatic.com/firebasejs/10.14.1/firebase-app-compat.js'
|
|
23
|
+
);
|
|
24
|
+
importScripts(
|
|
25
|
+
'https://www.gstatic.com/firebasejs/10.14.1/firebase-messaging-compat.js'
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
// Config inyectada en build-time (self.FIREBASE_CONFIG).
|
|
29
|
+
try {
|
|
30
|
+
importScripts('/firebase-config.js');
|
|
31
|
+
} catch (err) {
|
|
32
|
+
// Sin config no se puede inicializar; los push no funcionaran pero el SW
|
|
33
|
+
// no debe romper el registro de la app.
|
|
34
|
+
console.error('[firebase-messaging-sw] no se pudo cargar /firebase-config.js', err);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (self.FIREBASE_CONFIG) {
|
|
38
|
+
firebase.initializeApp(self.FIREBASE_CONFIG);
|
|
39
|
+
const messaging = firebase.messaging();
|
|
40
|
+
|
|
41
|
+
// Mensaje recibido con la app en background o cerrada.
|
|
42
|
+
messaging.onBackgroundMessage((payload) => {
|
|
43
|
+
const notification = payload.notification || {};
|
|
44
|
+
const data = payload.data || {};
|
|
45
|
+
const title = notification.title || data.title || 'Notificacion';
|
|
46
|
+
const options = {
|
|
47
|
+
body: notification.body || data.body || '',
|
|
48
|
+
icon: notification.icon || data.icon || '/assets/icons/icon-192.png',
|
|
49
|
+
badge: '/assets/icons/icon-96.png',
|
|
50
|
+
data,
|
|
51
|
+
};
|
|
52
|
+
self.registration.showNotification(title, options);
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Click en la notificacion: enfocar un cliente existente (o abrir uno nuevo) y
|
|
57
|
+
// avisarle para que navegue. El cliente resuelve la ruta desde data.route.
|
|
58
|
+
self.addEventListener('notificationclick', (event) => {
|
|
59
|
+
event.notification.close();
|
|
60
|
+
|
|
61
|
+
const data = event.notification.data || {};
|
|
62
|
+
const route = data.route || data.actionRoute || '/';
|
|
63
|
+
|
|
64
|
+
event.waitUntil(
|
|
65
|
+
self.clients
|
|
66
|
+
.matchAll({ type: 'window', includeUncontrolled: true })
|
|
67
|
+
.then((clientList) => {
|
|
68
|
+
const message = {
|
|
69
|
+
type: 'NOTIFICATION_CLICK',
|
|
70
|
+
notification: {
|
|
71
|
+
title: event.notification.title,
|
|
72
|
+
body: event.notification.body,
|
|
73
|
+
data,
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
for (const client of clientList) {
|
|
78
|
+
if ('focus' in client) {
|
|
79
|
+
client.postMessage(message);
|
|
80
|
+
return client.focus();
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (self.clients.openWindow) {
|
|
85
|
+
return self.clients.openWindow(route);
|
|
86
|
+
}
|
|
87
|
+
return undefined;
|
|
88
|
+
})
|
|
89
|
+
);
|
|
90
|
+
});
|