@realtimexsco/live-chat 1.4.4 → 1.4.5

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/dist/index.d.mts CHANGED
@@ -1648,18 +1648,6 @@ interface ForegroundPushBridgeProps {
1648
1648
  */
1649
1649
  onPush?: (payload: ForegroundPushPayload) => void | boolean;
1650
1650
  }
1651
- /**
1652
- * Slack-style routing for pushes that arrive while the tab is FOCUSED
1653
- * (unfocused tabs / other apps are handled by the service worker, which shows
1654
- * the OS notification):
1655
- *
1656
- * - message belongs to the conversation currently open → suppressed
1657
- * entirely (the user is already reading it)
1658
- * - any other conversation → in-app toast
1659
- *
1660
- * Mounted automatically by ChatMain; does nothing until this device has
1661
- * opted in to push (no firebase import, no listeners).
1662
- */
1663
1651
  declare const ForegroundPushBridge: ({ onPush }: ForegroundPushBridgeProps) => null;
1664
1652
 
1665
1653
  export { type ActiveChannelMessagesSlotProps, type AdminsDrawerSlotProps, type AttachmentsDrawerSlotProps, type AvatarSlotProps, CHAT_API_KEYS, CHAT_GET_API_KEYS, Calendar, CalendarDayButton, Channel, type ChannelDetailsDrawerSlotProps, ChannelHeaderView as ChannelHeader, type ChannelHeaderSlotProps, ChannelListView as ChannelList, ChannelListItem, type ChannelListItemSlotProps, type ChannelListSlotProps, type ChannelMessageBoxSlotProps, Chat, type ChatActionModalSlotProps, ChatAlertsProvider, type ChatApiKey, ChatAvatar, type ChatCallContext, type ChatClassNames, type ChatColorMode, type ChatComponents, type ChatCustomizationConfig, ChatCustomizationProvider, ChatDateJumpMenu, type ChatDateTimePreferences, type ChatFeatures, type ChatGetApiKey, ChatLayout, type ChatLayoutConfig, type ChatLayoutSlotProps, ChatLocaleProvider, ChatMain, type ChatPanelAlertsSlotProps, type ChatQueryParams, type ChatQueryParamsByApi, ChatThemeProvider, ChatViewport, type ChatViewportHeight, DefaultChannelListItem, DefaultChatAvatar, DefaultChatLayout, ForegroundPushBridge, type ForegroundPushBridgeProps, type ForegroundPushPayload, ForwardModalView as ForwardModal, type ForwardModalSlotProps, HeaderCallActions, type HeaderCallActionsSlotProps, type HeaderLeftSideSlotProps, type HeaderRightSideSlotProps, type HeaderSearchOverlaySlotProps, type IAttachment, type IChannel, type IDMDelete, type IDMEditMessage, type IDMForward, type IDMMessage, type IDMPin, type IDMReaction, type IDMRead, type IDMStar, type IDMTyping, type IDMUnstar, type IMessage, type ISocketConfig, type JumpToPreset, LoggedUserDetails, type LoggedUserDetailsSlotProps, type MembersDrawerSlotProps, type MessageAttachmentsSlotProps, ChannelMessageBoxView as MessageInput, MessageItemView as MessageItem, type MessageItemSlotProps, ActiveChannelMessagesView as MessageList, type MessageReactionsSlotProps, type MessageReplySnippetSlotProps, type MessageStatusSlotProps, type MessageToolbarSlotProps, PUSH_CHANGED_EVENT, type PendingJump, type PermissionDrawerSlotProps, type PhoneCallButtonSlotProps, type PinnedMessagesDrawerSlotProps, type PushConfig, PushNotificationToggle, type PushNotificationToggleProps, type PushNotificationsState, type PushPreference, type StarredMessagesDrawerSlotProps, type UIConfig, type UsePushNotifications, type VideoCallButtonSlotProps, apiGetPushConfig, apiGetPushPreference, apiRegisterPushToken, apiRemovePushToken, apiUpdatePushPreference, capitalizeFirst, clampJumpDate, ChatMain as default, defaultChatClassNames, defaultChatComponents, defaultChatFeatures, defaultChatLayoutConfig, disablePushOnThisDevice, downloadFile, enablePushOnThisDevice, getChatBaseUrl, getChatQueryParamApis, getChatQueryParams, getChatQueryParamsByApi, getChatSocketUrl, getFirstAndLastNameOneCharacter, getResponsiveWidth, getSocketConfig, getStoredPushToken, isEmpty, isPushSupported, mergeChatCustomization, mergeChatLayoutConfig, onForegroundPush, packageDefaultComponents, resolveApiUrl, resolveChatApiKey, resolveJumpDateBounds, resolveJumpPreset, resolveJumpStep, resolveSocketUrl, setChatAccessToken, setChatBaseURL, setChatClientId, setChatQueryParamApis, setChatQueryParams, setChatQueryParamsByApi, setChatSocketUrl, showNotification, smoothScrollToMessage, socketService, startOfLocalDay, toDateInputValue, uniqueList, useChatAlerts, useChatContext, useChatController, useChatCustomization, useChatCustomizationOptional, useChatFeatures, useChatFeaturesOptional, useChatLocale, useStore as useChatStore, useChatTheme, usePushNotifications };
package/dist/index.d.ts CHANGED
@@ -1648,18 +1648,6 @@ interface ForegroundPushBridgeProps {
1648
1648
  */
1649
1649
  onPush?: (payload: ForegroundPushPayload) => void | boolean;
1650
1650
  }
1651
- /**
1652
- * Slack-style routing for pushes that arrive while the tab is FOCUSED
1653
- * (unfocused tabs / other apps are handled by the service worker, which shows
1654
- * the OS notification):
1655
- *
1656
- * - message belongs to the conversation currently open → suppressed
1657
- * entirely (the user is already reading it)
1658
- * - any other conversation → in-app toast
1659
- *
1660
- * Mounted automatically by ChatMain; does nothing until this device has
1661
- * opted in to push (no firebase import, no listeners).
1662
- */
1663
1651
  declare const ForegroundPushBridge: ({ onPush }: ForegroundPushBridgeProps) => null;
1664
1652
 
1665
1653
  export { type ActiveChannelMessagesSlotProps, type AdminsDrawerSlotProps, type AttachmentsDrawerSlotProps, type AvatarSlotProps, CHAT_API_KEYS, CHAT_GET_API_KEYS, Calendar, CalendarDayButton, Channel, type ChannelDetailsDrawerSlotProps, ChannelHeaderView as ChannelHeader, type ChannelHeaderSlotProps, ChannelListView as ChannelList, ChannelListItem, type ChannelListItemSlotProps, type ChannelListSlotProps, type ChannelMessageBoxSlotProps, Chat, type ChatActionModalSlotProps, ChatAlertsProvider, type ChatApiKey, ChatAvatar, type ChatCallContext, type ChatClassNames, type ChatColorMode, type ChatComponents, type ChatCustomizationConfig, ChatCustomizationProvider, ChatDateJumpMenu, type ChatDateTimePreferences, type ChatFeatures, type ChatGetApiKey, ChatLayout, type ChatLayoutConfig, type ChatLayoutSlotProps, ChatLocaleProvider, ChatMain, type ChatPanelAlertsSlotProps, type ChatQueryParams, type ChatQueryParamsByApi, ChatThemeProvider, ChatViewport, type ChatViewportHeight, DefaultChannelListItem, DefaultChatAvatar, DefaultChatLayout, ForegroundPushBridge, type ForegroundPushBridgeProps, type ForegroundPushPayload, ForwardModalView as ForwardModal, type ForwardModalSlotProps, HeaderCallActions, type HeaderCallActionsSlotProps, type HeaderLeftSideSlotProps, type HeaderRightSideSlotProps, type HeaderSearchOverlaySlotProps, type IAttachment, type IChannel, type IDMDelete, type IDMEditMessage, type IDMForward, type IDMMessage, type IDMPin, type IDMReaction, type IDMRead, type IDMStar, type IDMTyping, type IDMUnstar, type IMessage, type ISocketConfig, type JumpToPreset, LoggedUserDetails, type LoggedUserDetailsSlotProps, type MembersDrawerSlotProps, type MessageAttachmentsSlotProps, ChannelMessageBoxView as MessageInput, MessageItemView as MessageItem, type MessageItemSlotProps, ActiveChannelMessagesView as MessageList, type MessageReactionsSlotProps, type MessageReplySnippetSlotProps, type MessageStatusSlotProps, type MessageToolbarSlotProps, PUSH_CHANGED_EVENT, type PendingJump, type PermissionDrawerSlotProps, type PhoneCallButtonSlotProps, type PinnedMessagesDrawerSlotProps, type PushConfig, PushNotificationToggle, type PushNotificationToggleProps, type PushNotificationsState, type PushPreference, type StarredMessagesDrawerSlotProps, type UIConfig, type UsePushNotifications, type VideoCallButtonSlotProps, apiGetPushConfig, apiGetPushPreference, apiRegisterPushToken, apiRemovePushToken, apiUpdatePushPreference, capitalizeFirst, clampJumpDate, ChatMain as default, defaultChatClassNames, defaultChatComponents, defaultChatFeatures, defaultChatLayoutConfig, disablePushOnThisDevice, downloadFile, enablePushOnThisDevice, getChatBaseUrl, getChatQueryParamApis, getChatQueryParams, getChatQueryParamsByApi, getChatSocketUrl, getFirstAndLastNameOneCharacter, getResponsiveWidth, getSocketConfig, getStoredPushToken, isEmpty, isPushSupported, mergeChatCustomization, mergeChatLayoutConfig, onForegroundPush, packageDefaultComponents, resolveApiUrl, resolveChatApiKey, resolveJumpDateBounds, resolveJumpPreset, resolveJumpStep, resolveSocketUrl, setChatAccessToken, setChatBaseURL, setChatClientId, setChatQueryParamApis, setChatQueryParams, setChatQueryParamsByApi, setChatSocketUrl, showNotification, smoothScrollToMessage, socketService, startOfLocalDay, toDateInputValue, uniqueList, useChatAlerts, useChatContext, useChatController, useChatCustomization, useChatCustomizationOptional, useChatFeatures, useChatFeaturesOptional, useChatLocale, useStore as useChatStore, useChatTheme, usePushNotifications };
package/dist/index.mjs CHANGED
@@ -17577,7 +17577,9 @@ var disablePushOnThisDevice = async () => {
17577
17577
  };
17578
17578
  var onForegroundPush = async (callback) => {
17579
17579
  const config = await apiGetPushConfig();
17580
- if (!config?.configured || !config.firebaseConfig) return () => void 0;
17580
+ if (!config?.configured || !config.firebaseConfig) {
17581
+ throw new Error("Push config unavailable (not configured or API not ready)");
17582
+ }
17581
17583
  const { fb, messaging } = await getFirebaseMessaging(config.firebaseConfig);
17582
17584
  return fb.onMessage(messaging, (payload) => {
17583
17585
  callback({
@@ -17589,25 +17591,54 @@ var onForegroundPush = async (callback) => {
17589
17591
  };
17590
17592
 
17591
17593
  // src/notifications/ForegroundPushBridge.tsx
17594
+ var RETRY_DELAYS_MS = [1e3, 3e3, 8e3, 2e4];
17592
17595
  var ForegroundPushBridge = ({ onPush }) => {
17593
17596
  useEffect(() => {
17594
17597
  let unsubscribe = null;
17598
+ let retryTimer = null;
17595
17599
  let cancelled = false;
17596
17600
  const handlePayload = (payload) => {
17597
17601
  const incoming = payload.data?.conversationId;
17598
17602
  const activeId = useStore.getState().activeConversationId;
17599
- if (incoming && activeId && incoming === activeId) return;
17603
+ if (incoming && activeId && incoming === activeId) {
17604
+ console.debug(
17605
+ "[realtimex-push] foreground push suppressed (conversation open):",
17606
+ incoming
17607
+ );
17608
+ return;
17609
+ }
17610
+ console.debug("[realtimex-push] foreground push \u2192 toast:", {
17611
+ title: payload.title,
17612
+ conversationId: incoming,
17613
+ activeConversationId: activeId
17614
+ });
17600
17615
  if (onPush && onPush(payload) !== false) return;
17601
17616
  const text = payload.title ? payload.body ? `${payload.title}: ${payload.body}` : payload.title : payload.body;
17602
17617
  if (text) showNotification(text, "info");
17603
17618
  };
17604
- const start = async () => {
17619
+ const start = async (attempt = 0) => {
17605
17620
  if (cancelled || unsubscribe || !getStoredPushToken()) return;
17606
17621
  try {
17607
17622
  const stop = await onForegroundPush(handlePayload);
17608
17623
  if (cancelled) stop();
17609
- else unsubscribe = stop;
17610
- } catch {
17624
+ else {
17625
+ unsubscribe = stop;
17626
+ console.debug(
17627
+ "[realtimex-push] foreground listener active"
17628
+ );
17629
+ }
17630
+ } catch (error) {
17631
+ if (cancelled || attempt >= RETRY_DELAYS_MS.length) {
17632
+ console.debug(
17633
+ "[realtimex-push] foreground listener NOT started:",
17634
+ error instanceof Error ? error.message : error
17635
+ );
17636
+ return;
17637
+ }
17638
+ retryTimer = setTimeout(
17639
+ () => void start(attempt + 1),
17640
+ RETRY_DELAYS_MS[attempt]
17641
+ );
17611
17642
  }
17612
17643
  };
17613
17644
  void start();
@@ -17622,6 +17653,7 @@ var ForegroundPushBridge = ({ onPush }) => {
17622
17653
  window.addEventListener(PUSH_CHANGED_EVENT, onPushChanged);
17623
17654
  return () => {
17624
17655
  cancelled = true;
17656
+ if (retryTimer) clearTimeout(retryTimer);
17625
17657
  unsubscribe?.();
17626
17658
  window.removeEventListener(PUSH_CHANGED_EVENT, onPushChanged);
17627
17659
  };