@ethora/chat-component 25.12.2 → 26.1.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 (49) hide show
  1. package/README.md +587 -145
  2. package/dist/components/MainComponents/MessageContainer.d.ts +1 -0
  3. package/dist/components/MessageBubble/MessageReply.d.ts +2 -2
  4. package/dist/components/MessageNotification/MessageNotificationToast.d.ts +17 -0
  5. package/dist/components/MessageNotification/index.d.ts +2 -0
  6. package/dist/components/Modals/SettingsModals/SharedStyledComponents.d.ts +22 -0
  7. package/dist/components/Modals/styledModalComponents.d.ts +28 -0
  8. package/dist/components/styled/Button.d.ts +2 -2
  9. package/dist/components/styled/DateLabel.d.ts +2 -2
  10. package/dist/components/styled/StyledComponents.d.ts +10 -10
  11. package/dist/components/styled/StyledInputComponents/StyledInputComponents.d.ts +6 -6
  12. package/dist/context/MessageNotificationContext.d.ts +12 -0
  13. package/dist/firebase-config.d.ts +6 -2
  14. package/dist/firebase-messaging-sw.js +351 -0
  15. package/dist/helpers/getDataFromXml.d.ts +1 -0
  16. package/dist/helpers/initRoomsPresence.d.ts +1 -1
  17. package/dist/helpers/storeConsole.d.ts +6 -0
  18. package/dist/hooks/useInAppNotifications.d.ts +18 -0
  19. package/dist/hooks/usePushNotifications.d.ts +45 -0
  20. package/dist/hooks/useTabVisibility.d.ts +1 -0
  21. package/dist/main.css +1 -1
  22. package/dist/main.d.ts +5 -0
  23. package/dist/main.js +14686 -11893
  24. package/dist/main.js.map +1 -1
  25. package/dist/networking/api-requests/push.api.d.ts +18 -0
  26. package/dist/networking/stanzaHandlers.d.ts +4 -2
  27. package/dist/networking/xmpp/allRoomPresences.xmpp.d.ts +11 -1
  28. package/dist/networking/xmpp/presenceInRoom.xmpp.d.ts +1 -1
  29. package/dist/networking/xmpp/sendTextMessage.xmpp.d.ts +1 -1
  30. package/dist/networking/xmpp/sendTextMessageWithTranslateTag.xmpp.d.ts +1 -1
  31. package/dist/networking/xmpp/subscribeToRoomMessages.xmpp.d.ts +9 -0
  32. package/dist/networking/xmppClient.d.ts +13 -3
  33. package/dist/roomStore/chatSettingsSlice.d.ts +1 -0
  34. package/dist/roomStore/index.d.ts +28 -0
  35. package/dist/roomStore/roomHeapSlice.d.ts +1 -1
  36. package/dist/roomStore/roomsSlice.d.ts +11 -1
  37. package/dist/types/models/config.model.d.ts +35 -1
  38. package/dist/types/models/room.model.d.ts +4 -1
  39. package/dist/types/models/xmpp.model.d.ts +3 -1
  40. package/dist/utils/firebasePushNotifications.d.ts +34 -0
  41. package/dist/utils/formatError.d.ts +1 -0
  42. package/dist/utils/messageNotificationManager.d.ts +16 -0
  43. package/dist/utils/notificationPolicy.d.ts +45 -0
  44. package/dist/utils/notificationUtils.d.ts +22 -0
  45. package/dist/utils/pushSubscriptionService.d.ts +12 -0
  46. package/dist/version.d.ts +1 -1
  47. package/package.json +7 -4
  48. package/public/firebase-messaging-sw.js +351 -0
  49. package/scripts/init-push.js +48 -0
@@ -0,0 +1,45 @@
1
+ /**
2
+ * usePushNotifications.ts
3
+ * React hook that orchestrates the full push notification subscription lifecycle:
4
+ * 1. Check browser support
5
+ * 2. Register the service worker
6
+ * 3. Request notification permission
7
+ * 4. Subscribe via PushManager
8
+ * 5. Register the subscription with the Ethora backend (API)
9
+ * 6. Listen for subscription-change messages from the SW and re-register
10
+ *
11
+ * Logs every major step to the console so developers can trace the flow.
12
+ */
13
+ interface UsePushNotificationsOptions {
14
+ /** Enable or disable the push notification flow. Default: true */
15
+ enabled?: boolean;
16
+ /**
17
+ * URL-safe Base64 encoded VAPID public key.
18
+ * Falls back to the VITE_VAPID_PUBLIC_KEY environment variable.
19
+ */
20
+ vapidPublicKey?: string;
21
+ /**
22
+ * Service worker path and scope for Firebase Messaging.
23
+ * Defaults to `/firebase-messaging-sw.js` with scope `/`.
24
+ */
25
+ serviceWorkerPath?: string;
26
+ serviceWorkerScope?: string;
27
+ /**
28
+ * Custom Firebase configuration object.
29
+ * If provided, it overrides the environment variables.
30
+ */
31
+ firebaseConfig?: any;
32
+ /**
33
+ * Show a UI "soft ask" before triggering the browser permission dialog.
34
+ * When true the hook will NOT immediately request permission;
35
+ * instead the consumer should call `requestPermission()` manually.
36
+ * Default: false (immediate request after login).
37
+ */
38
+ softAsk?: boolean;
39
+ }
40
+ interface UsePushNotificationsResult {
41
+ /** Manually trigger the permission + subscription flow (for soft-ask UIs). */
42
+ requestPermission: () => Promise<void>;
43
+ }
44
+ declare const usePushNotifications: (options?: UsePushNotificationsOptions) => UsePushNotificationsResult;
45
+ export default usePushNotifications;
@@ -0,0 +1 @@
1
+ export declare const useTabVisibility: () => boolean;
package/dist/main.css CHANGED
@@ -1 +1 @@
1
- body{margin:0;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}code{font-family:source-code-pro,Menlo,Monaco,Consolas,Courier New,monospace}html,body,#root{height:100%;margin:0;padding:0}::-webkit-scrollbar{width:4px}::-webkit-scrollbar-thumb{background-color:#5e3fde;border-radius:6px}::-webkit-scrollbar-track{background-color:#f0f0f0}*{scrollbar-width:thin;scrollbar-color:#5e3fde #f0f0f0}.apple-emoji{font-family:"Apple Color Emoji","Segoe UI Emoji","Noto Color Emoji",sans-serif}.emoji-mart{max-width:320px;max-height:360px;overflow-y:auto;border-radius:12px;box-shadow:0 4px 12px #0000001a}
1
+ body{margin:0;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}code{font-family:source-code-pro,Menlo,Monaco,Consolas,Courier New,monospace}html,body,#root{height:100%;margin:0;padding:0}::-webkit-scrollbar{width:4px}::-webkit-scrollbar-thumb{background-color:#5e3fde;border-radius:6px}::-webkit-scrollbar-track{background-color:#f0f0f0}*{scrollbar-width:thin;scrollbar-color:#5e3fde #f0f0f0}.apple-emoji{font-family:"Apple Color Emoji","Segoe UI Emoji","Noto Color Emoji",sans-serif}.emoji-mart{max-width:320px;max-height:360px;overflow-y:auto;border-radius:12px;box-shadow:0 4px 12px #0000001a}.message-highlight{animation:messageHighlight 2s ease-out;transition:background-color .3s ease}@keyframes messageHighlight{0%{background-color:#2196f366;transform:scale(1.02);box-shadow:0 0 0 2px #2196f333}30%{background-color:#2196f34d;box-shadow:0 0 0 2px #2196f326}60%{background-color:#2196f333;box-shadow:0 0 0 1px #2196f31a}to{background-color:transparent;transform:scale(1);box-shadow:none}}@media (max-width: 768px){.message-notification-container{left:50%!important;right:auto!important;transform:translate(-50%)!important;align-items:center!important}.message-notification-container[data-position-horizontal=left],.message-notification-container[data-position-horizontal=right]{left:50%!important;right:auto!important;transform:translate(-50%)!important}}
package/dist/main.d.ts CHANGED
@@ -1,6 +1,11 @@
1
+ /**
2
+ * Main entry point for the Ethora Chat Component.
3
+ */
1
4
  export { XmppProvider } from './context/xmppProvider';
2
5
  export { ReduxWrapper as Chat } from './components/MainComponents/ReduxWrapper';
3
6
  export { useUnread } from './hooks/useUnreadMessagesCounter';
4
7
  export { logoutService } from './hooks/useLogout';
5
8
  export { useQRCodeChat, handleQRChatId } from './hooks/useQRCodeChatHandler';
9
+ export { useInAppNotifications } from './hooks/useInAppNotifications';
10
+ export { default as usePushNotifications } from './hooks/usePushNotifications';
6
11
  export { resendMessage } from './utils/resendMessage';