@repzo/widget-react-native 1.0.0
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/README.md +482 -0
- package/lib/commonjs/agent-ui-blocks.js +159 -0
- package/lib/commonjs/agent-ui-blocks.js.map +1 -0
- package/lib/commonjs/api/client.js +267 -0
- package/lib/commonjs/api/client.js.map +1 -0
- package/lib/commonjs/api/realtime.js +193 -0
- package/lib/commonjs/api/realtime.js.map +1 -0
- package/lib/commonjs/api/sse-parser.js +58 -0
- package/lib/commonjs/api/sse-parser.js.map +1 -0
- package/lib/commonjs/controller.js +23 -0
- package/lib/commonjs/controller.js.map +1 -0
- package/lib/commonjs/device-id.js +75 -0
- package/lib/commonjs/device-id.js.map +1 -0
- package/lib/commonjs/events.js +49 -0
- package/lib/commonjs/events.js.map +1 -0
- package/lib/commonjs/i18n.js +106 -0
- package/lib/commonjs/i18n.js.map +1 -0
- package/lib/commonjs/index.js +98 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/locales.js +85 -0
- package/lib/commonjs/locales.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/push/push-notifications.js +208 -0
- package/lib/commonjs/push/push-notifications.js.map +1 -0
- package/lib/commonjs/state/use-widget-state.js +23 -0
- package/lib/commonjs/state/use-widget-state.js.map +1 -0
- package/lib/commonjs/state/widget-store.js +1682 -0
- package/lib/commonjs/state/widget-store.js.map +1 -0
- package/lib/commonjs/storage.js +147 -0
- package/lib/commonjs/storage.js.map +1 -0
- package/lib/commonjs/types.js +44 -0
- package/lib/commonjs/types.js.map +1 -0
- package/lib/commonjs/ui/WidgetProvider.js +404 -0
- package/lib/commonjs/ui/WidgetProvider.js.map +1 -0
- package/lib/commonjs/ui/components/AgentUiBlocks.js +864 -0
- package/lib/commonjs/ui/components/AgentUiBlocks.js.map +1 -0
- package/lib/commonjs/ui/components/Avatar.js +76 -0
- package/lib/commonjs/ui/components/Avatar.js.map +1 -0
- package/lib/commonjs/ui/components/ConversationRow.js +155 -0
- package/lib/commonjs/ui/components/ConversationRow.js.map +1 -0
- package/lib/commonjs/ui/components/ErrorBoundary.js +44 -0
- package/lib/commonjs/ui/components/ErrorBoundary.js.map +1 -0
- package/lib/commonjs/ui/components/Gradient.js +168 -0
- package/lib/commonjs/ui/components/Gradient.js.map +1 -0
- package/lib/commonjs/ui/components/Launcher.js +125 -0
- package/lib/commonjs/ui/components/Launcher.js.map +1 -0
- package/lib/commonjs/ui/components/Markdown.js +257 -0
- package/lib/commonjs/ui/components/Markdown.js.map +1 -0
- package/lib/commonjs/ui/components/OutboundMessageCard.js +157 -0
- package/lib/commonjs/ui/components/OutboundMessageCard.js.map +1 -0
- package/lib/commonjs/ui/components/WidgetPanel.js +131 -0
- package/lib/commonjs/ui/components/WidgetPanel.js.map +1 -0
- package/lib/commonjs/ui/components/icons.js +383 -0
- package/lib/commonjs/ui/components/icons.js.map +1 -0
- package/lib/commonjs/ui/hooks/use-keyboard-overlap.js +113 -0
- package/lib/commonjs/ui/hooks/use-keyboard-overlap.js.map +1 -0
- package/lib/commonjs/ui/hooks/use-reduce-motion.js +38 -0
- package/lib/commonjs/ui/hooks/use-reduce-motion.js.map +1 -0
- package/lib/commonjs/ui/hooks/use-widget-insets.js +41 -0
- package/lib/commonjs/ui/hooks/use-widget-insets.js.map +1 -0
- package/lib/commonjs/ui/screens/chat/ChatView.js +590 -0
- package/lib/commonjs/ui/screens/chat/ChatView.js.map +1 -0
- package/lib/commonjs/ui/screens/chat/ChatView.styles.js +362 -0
- package/lib/commonjs/ui/screens/chat/ChatView.styles.js.map +1 -0
- package/lib/commonjs/ui/screens/chat/ChatView.types.js +6 -0
- package/lib/commonjs/ui/screens/chat/ChatView.types.js.map +1 -0
- package/lib/commonjs/ui/screens/conversations/ConversationsList.js +150 -0
- package/lib/commonjs/ui/screens/conversations/ConversationsList.js.map +1 -0
- package/lib/commonjs/ui/screens/conversations/ConversationsList.styles.js +118 -0
- package/lib/commonjs/ui/screens/conversations/ConversationsList.styles.js.map +1 -0
- package/lib/commonjs/ui/screens/conversations/ConversationsList.types.js +6 -0
- package/lib/commonjs/ui/screens/conversations/ConversationsList.types.js.map +1 -0
- package/lib/commonjs/ui/screens/home/HomeView.js +336 -0
- package/lib/commonjs/ui/screens/home/HomeView.js.map +1 -0
- package/lib/commonjs/ui/screens/home/HomeView.styles.js +245 -0
- package/lib/commonjs/ui/screens/home/HomeView.styles.js.map +1 -0
- package/lib/commonjs/ui/screens/home/HomeView.types.js +6 -0
- package/lib/commonjs/ui/screens/home/HomeView.types.js.map +1 -0
- package/lib/commonjs/ui/screens/home/greeting.js +49 -0
- package/lib/commonjs/ui/screens/home/greeting.js.map +1 -0
- package/lib/commonjs/ui/screens/pre-chat/PreChatForm.js +229 -0
- package/lib/commonjs/ui/screens/pre-chat/PreChatForm.js.map +1 -0
- package/lib/commonjs/ui/screens/pre-chat/PreChatForm.styles.js +125 -0
- package/lib/commonjs/ui/screens/pre-chat/PreChatForm.styles.js.map +1 -0
- package/lib/commonjs/ui/screens/pre-chat/PreChatForm.types.js +6 -0
- package/lib/commonjs/ui/screens/pre-chat/PreChatForm.types.js.map +1 -0
- package/lib/commonjs/ui/styles/global.js +55 -0
- package/lib/commonjs/ui/styles/global.js.map +1 -0
- package/lib/commonjs/ui/styles/theme.js +148 -0
- package/lib/commonjs/ui/styles/theme.js.map +1 -0
- package/lib/commonjs/ui/utils/conversations.js +125 -0
- package/lib/commonjs/ui/utils/conversations.js.map +1 -0
- package/lib/commonjs/ui/utils/html.js +44 -0
- package/lib/commonjs/ui/utils/html.js.map +1 -0
- package/lib/commonjs/ui/utils/native-gradient.js +65 -0
- package/lib/commonjs/ui/utils/native-gradient.js.map +1 -0
- package/lib/commonjs/ui/utils/rtl.js +56 -0
- package/lib/commonjs/ui/utils/rtl.js.map +1 -0
- package/lib/commonjs/ui/utils/safe-url.js +67 -0
- package/lib/commonjs/ui/utils/safe-url.js.map +1 -0
- package/lib/module/agent-ui-blocks.js +152 -0
- package/lib/module/agent-ui-blocks.js.map +1 -0
- package/lib/module/api/client.js +261 -0
- package/lib/module/api/client.js.map +1 -0
- package/lib/module/api/realtime.js +189 -0
- package/lib/module/api/realtime.js.map +1 -0
- package/lib/module/api/sse-parser.js +53 -0
- package/lib/module/api/sse-parser.js.map +1 -0
- package/lib/module/controller.js +19 -0
- package/lib/module/controller.js.map +1 -0
- package/lib/module/device-id.js +69 -0
- package/lib/module/device-id.js.map +1 -0
- package/lib/module/events.js +44 -0
- package/lib/module/events.js.map +1 -0
- package/lib/module/i18n.js +99 -0
- package/lib/module/i18n.js.map +1 -0
- package/lib/module/index.js +55 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/locales.js +80 -0
- package/lib/module/locales.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/push/push-notifications.js +204 -0
- package/lib/module/push/push-notifications.js.map +1 -0
- package/lib/module/state/use-widget-state.js +18 -0
- package/lib/module/state/use-widget-state.js.map +1 -0
- package/lib/module/state/widget-store.js +1677 -0
- package/lib/module/state/widget-store.js.map +1 -0
- package/lib/module/storage.js +141 -0
- package/lib/module/storage.js.map +1 -0
- package/lib/module/types.js +40 -0
- package/lib/module/types.js.map +1 -0
- package/lib/module/ui/WidgetProvider.js +400 -0
- package/lib/module/ui/WidgetProvider.js.map +1 -0
- package/lib/module/ui/components/AgentUiBlocks.js +857 -0
- package/lib/module/ui/components/AgentUiBlocks.js.map +1 -0
- package/lib/module/ui/components/Avatar.js +71 -0
- package/lib/module/ui/components/Avatar.js.map +1 -0
- package/lib/module/ui/components/ConversationRow.js +150 -0
- package/lib/module/ui/components/ConversationRow.js.map +1 -0
- package/lib/module/ui/components/ErrorBoundary.js +39 -0
- package/lib/module/ui/components/ErrorBoundary.js.map +1 -0
- package/lib/module/ui/components/Gradient.js +165 -0
- package/lib/module/ui/components/Gradient.js.map +1 -0
- package/lib/module/ui/components/Launcher.js +121 -0
- package/lib/module/ui/components/Launcher.js.map +1 -0
- package/lib/module/ui/components/Markdown.js +253 -0
- package/lib/module/ui/components/Markdown.js.map +1 -0
- package/lib/module/ui/components/OutboundMessageCard.js +153 -0
- package/lib/module/ui/components/OutboundMessageCard.js.map +1 -0
- package/lib/module/ui/components/WidgetPanel.js +127 -0
- package/lib/module/ui/components/WidgetPanel.js.map +1 -0
- package/lib/module/ui/components/icons.js +370 -0
- package/lib/module/ui/components/icons.js.map +1 -0
- package/lib/module/ui/hooks/use-keyboard-overlap.js +109 -0
- package/lib/module/ui/hooks/use-keyboard-overlap.js.map +1 -0
- package/lib/module/ui/hooks/use-reduce-motion.js +34 -0
- package/lib/module/ui/hooks/use-reduce-motion.js.map +1 -0
- package/lib/module/ui/hooks/use-widget-insets.js +37 -0
- package/lib/module/ui/hooks/use-widget-insets.js.map +1 -0
- package/lib/module/ui/screens/chat/ChatView.js +586 -0
- package/lib/module/ui/screens/chat/ChatView.js.map +1 -0
- package/lib/module/ui/screens/chat/ChatView.styles.js +358 -0
- package/lib/module/ui/screens/chat/ChatView.styles.js.map +1 -0
- package/lib/module/ui/screens/chat/ChatView.types.js +4 -0
- package/lib/module/ui/screens/chat/ChatView.types.js.map +1 -0
- package/lib/module/ui/screens/conversations/ConversationsList.js +146 -0
- package/lib/module/ui/screens/conversations/ConversationsList.js.map +1 -0
- package/lib/module/ui/screens/conversations/ConversationsList.styles.js +114 -0
- package/lib/module/ui/screens/conversations/ConversationsList.styles.js.map +1 -0
- package/lib/module/ui/screens/conversations/ConversationsList.types.js +4 -0
- package/lib/module/ui/screens/conversations/ConversationsList.types.js.map +1 -0
- package/lib/module/ui/screens/home/HomeView.js +332 -0
- package/lib/module/ui/screens/home/HomeView.js.map +1 -0
- package/lib/module/ui/screens/home/HomeView.styles.js +242 -0
- package/lib/module/ui/screens/home/HomeView.styles.js.map +1 -0
- package/lib/module/ui/screens/home/HomeView.types.js +4 -0
- package/lib/module/ui/screens/home/HomeView.types.js.map +1 -0
- package/lib/module/ui/screens/home/greeting.js +44 -0
- package/lib/module/ui/screens/home/greeting.js.map +1 -0
- package/lib/module/ui/screens/pre-chat/PreChatForm.js +225 -0
- package/lib/module/ui/screens/pre-chat/PreChatForm.js.map +1 -0
- package/lib/module/ui/screens/pre-chat/PreChatForm.styles.js +121 -0
- package/lib/module/ui/screens/pre-chat/PreChatForm.styles.js.map +1 -0
- package/lib/module/ui/screens/pre-chat/PreChatForm.types.js +4 -0
- package/lib/module/ui/screens/pre-chat/PreChatForm.types.js.map +1 -0
- package/lib/module/ui/styles/global.js +51 -0
- package/lib/module/ui/styles/global.js.map +1 -0
- package/lib/module/ui/styles/theme.js +137 -0
- package/lib/module/ui/styles/theme.js.map +1 -0
- package/lib/module/ui/utils/conversations.js +115 -0
- package/lib/module/ui/utils/conversations.js.map +1 -0
- package/lib/module/ui/utils/html.js +39 -0
- package/lib/module/ui/utils/html.js.map +1 -0
- package/lib/module/ui/utils/native-gradient.js +60 -0
- package/lib/module/ui/utils/native-gradient.js.map +1 -0
- package/lib/module/ui/utils/rtl.js +49 -0
- package/lib/module/ui/utils/rtl.js.map +1 -0
- package/lib/module/ui/utils/safe-url.js +59 -0
- package/lib/module/ui/utils/safe-url.js.map +1 -0
- package/lib/typescript/commonjs/agent-ui-blocks.d.ts +20 -0
- package/lib/typescript/commonjs/agent-ui-blocks.d.ts.map +1 -0
- package/lib/typescript/commonjs/api/client.d.ts +115 -0
- package/lib/typescript/commonjs/api/client.d.ts.map +1 -0
- package/lib/typescript/commonjs/api/realtime.d.ts +39 -0
- package/lib/typescript/commonjs/api/realtime.d.ts.map +1 -0
- package/lib/typescript/commonjs/api/sse-parser.d.ts +13 -0
- package/lib/typescript/commonjs/api/sse-parser.d.ts.map +1 -0
- package/lib/typescript/commonjs/controller.d.ts +15 -0
- package/lib/typescript/commonjs/controller.d.ts.map +1 -0
- package/lib/typescript/commonjs/device-id.d.ts +15 -0
- package/lib/typescript/commonjs/device-id.d.ts.map +1 -0
- package/lib/typescript/commonjs/events.d.ts +41 -0
- package/lib/typescript/commonjs/events.d.ts.map +1 -0
- package/lib/typescript/commonjs/i18n.d.ts +78 -0
- package/lib/typescript/commonjs/i18n.d.ts.map +1 -0
- package/lib/typescript/commonjs/index.d.ts +103 -0
- package/lib/typescript/commonjs/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/locales.d.ts +18 -0
- package/lib/typescript/commonjs/locales.d.ts.map +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/push/push-notifications.d.ts +71 -0
- package/lib/typescript/commonjs/push/push-notifications.d.ts.map +1 -0
- package/lib/typescript/commonjs/state/use-widget-state.d.ts +10 -0
- package/lib/typescript/commonjs/state/use-widget-state.d.ts.map +1 -0
- package/lib/typescript/commonjs/state/widget-store.d.ts +227 -0
- package/lib/typescript/commonjs/state/widget-store.d.ts.map +1 -0
- package/lib/typescript/commonjs/storage.d.ts +42 -0
- package/lib/typescript/commonjs/storage.d.ts.map +1 -0
- package/lib/typescript/commonjs/types.d.ts +391 -0
- package/lib/typescript/commonjs/types.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/WidgetProvider.d.ts +15 -0
- package/lib/typescript/commonjs/ui/WidgetProvider.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/components/AgentUiBlocks.d.ts +27 -0
- package/lib/typescript/commonjs/ui/components/AgentUiBlocks.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/components/Avatar.d.ts +19 -0
- package/lib/typescript/commonjs/ui/components/Avatar.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/components/ConversationRow.d.ts +26 -0
- package/lib/typescript/commonjs/ui/components/ConversationRow.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/components/ErrorBoundary.d.ts +27 -0
- package/lib/typescript/commonjs/ui/components/ErrorBoundary.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/components/Gradient.d.ts +33 -0
- package/lib/typescript/commonjs/ui/components/Gradient.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/components/Launcher.d.ts +18 -0
- package/lib/typescript/commonjs/ui/components/Launcher.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/components/Markdown.d.ts +19 -0
- package/lib/typescript/commonjs/ui/components/Markdown.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/components/OutboundMessageCard.d.ts +20 -0
- package/lib/typescript/commonjs/ui/components/OutboundMessageCard.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/components/WidgetPanel.d.ts +26 -0
- package/lib/typescript/commonjs/ui/components/WidgetPanel.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/components/icons.d.ts +38 -0
- package/lib/typescript/commonjs/ui/components/icons.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/hooks/use-keyboard-overlap.d.ts +33 -0
- package/lib/typescript/commonjs/ui/hooks/use-keyboard-overlap.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/hooks/use-reduce-motion.d.ts +11 -0
- package/lib/typescript/commonjs/ui/hooks/use-reduce-motion.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/hooks/use-widget-insets.d.ts +16 -0
- package/lib/typescript/commonjs/ui/hooks/use-widget-insets.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/screens/chat/ChatView.d.ts +11 -0
- package/lib/typescript/commonjs/ui/screens/chat/ChatView.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/screens/chat/ChatView.styles.d.ts +349 -0
- package/lib/typescript/commonjs/ui/screens/chat/ChatView.styles.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/screens/chat/ChatView.types.d.ts +48 -0
- package/lib/typescript/commonjs/ui/screens/chat/ChatView.types.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/screens/conversations/ConversationsList.d.ts +10 -0
- package/lib/typescript/commonjs/ui/screens/conversations/ConversationsList.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/screens/conversations/ConversationsList.styles.d.ts +113 -0
- package/lib/typescript/commonjs/ui/screens/conversations/ConversationsList.styles.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/screens/conversations/ConversationsList.types.d.ts +31 -0
- package/lib/typescript/commonjs/ui/screens/conversations/ConversationsList.types.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/screens/home/HomeView.d.ts +17 -0
- package/lib/typescript/commonjs/ui/screens/home/HomeView.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/screens/home/HomeView.styles.d.ts +227 -0
- package/lib/typescript/commonjs/ui/screens/home/HomeView.styles.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/screens/home/HomeView.types.d.ts +40 -0
- package/lib/typescript/commonjs/ui/screens/home/HomeView.types.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/screens/home/greeting.d.ts +19 -0
- package/lib/typescript/commonjs/ui/screens/home/greeting.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/screens/pre-chat/PreChatForm.d.ts +7 -0
- package/lib/typescript/commonjs/ui/screens/pre-chat/PreChatForm.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/screens/pre-chat/PreChatForm.styles.d.ts +115 -0
- package/lib/typescript/commonjs/ui/screens/pre-chat/PreChatForm.styles.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/screens/pre-chat/PreChatForm.types.d.ts +20 -0
- package/lib/typescript/commonjs/ui/screens/pre-chat/PreChatForm.types.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/styles/global.d.ts +46 -0
- package/lib/typescript/commonjs/ui/styles/global.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/styles/theme.d.ts +103 -0
- package/lib/typescript/commonjs/ui/styles/theme.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/utils/conversations.d.ts +41 -0
- package/lib/typescript/commonjs/ui/utils/conversations.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/utils/html.d.ts +10 -0
- package/lib/typescript/commonjs/ui/utils/html.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/utils/native-gradient.d.ts +61 -0
- package/lib/typescript/commonjs/ui/utils/native-gradient.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/utils/rtl.d.ts +33 -0
- package/lib/typescript/commonjs/ui/utils/rtl.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/utils/safe-url.d.ts +21 -0
- package/lib/typescript/commonjs/ui/utils/safe-url.d.ts.map +1 -0
- package/lib/typescript/module/agent-ui-blocks.d.ts +20 -0
- package/lib/typescript/module/agent-ui-blocks.d.ts.map +1 -0
- package/lib/typescript/module/api/client.d.ts +115 -0
- package/lib/typescript/module/api/client.d.ts.map +1 -0
- package/lib/typescript/module/api/realtime.d.ts +39 -0
- package/lib/typescript/module/api/realtime.d.ts.map +1 -0
- package/lib/typescript/module/api/sse-parser.d.ts +13 -0
- package/lib/typescript/module/api/sse-parser.d.ts.map +1 -0
- package/lib/typescript/module/controller.d.ts +15 -0
- package/lib/typescript/module/controller.d.ts.map +1 -0
- package/lib/typescript/module/device-id.d.ts +15 -0
- package/lib/typescript/module/device-id.d.ts.map +1 -0
- package/lib/typescript/module/events.d.ts +41 -0
- package/lib/typescript/module/events.d.ts.map +1 -0
- package/lib/typescript/module/i18n.d.ts +78 -0
- package/lib/typescript/module/i18n.d.ts.map +1 -0
- package/lib/typescript/module/index.d.ts +103 -0
- package/lib/typescript/module/index.d.ts.map +1 -0
- package/lib/typescript/module/locales.d.ts +18 -0
- package/lib/typescript/module/locales.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/push/push-notifications.d.ts +71 -0
- package/lib/typescript/module/push/push-notifications.d.ts.map +1 -0
- package/lib/typescript/module/state/use-widget-state.d.ts +10 -0
- package/lib/typescript/module/state/use-widget-state.d.ts.map +1 -0
- package/lib/typescript/module/state/widget-store.d.ts +227 -0
- package/lib/typescript/module/state/widget-store.d.ts.map +1 -0
- package/lib/typescript/module/storage.d.ts +42 -0
- package/lib/typescript/module/storage.d.ts.map +1 -0
- package/lib/typescript/module/types.d.ts +391 -0
- package/lib/typescript/module/types.d.ts.map +1 -0
- package/lib/typescript/module/ui/WidgetProvider.d.ts +15 -0
- package/lib/typescript/module/ui/WidgetProvider.d.ts.map +1 -0
- package/lib/typescript/module/ui/components/AgentUiBlocks.d.ts +27 -0
- package/lib/typescript/module/ui/components/AgentUiBlocks.d.ts.map +1 -0
- package/lib/typescript/module/ui/components/Avatar.d.ts +19 -0
- package/lib/typescript/module/ui/components/Avatar.d.ts.map +1 -0
- package/lib/typescript/module/ui/components/ConversationRow.d.ts +26 -0
- package/lib/typescript/module/ui/components/ConversationRow.d.ts.map +1 -0
- package/lib/typescript/module/ui/components/ErrorBoundary.d.ts +27 -0
- package/lib/typescript/module/ui/components/ErrorBoundary.d.ts.map +1 -0
- package/lib/typescript/module/ui/components/Gradient.d.ts +33 -0
- package/lib/typescript/module/ui/components/Gradient.d.ts.map +1 -0
- package/lib/typescript/module/ui/components/Launcher.d.ts +18 -0
- package/lib/typescript/module/ui/components/Launcher.d.ts.map +1 -0
- package/lib/typescript/module/ui/components/Markdown.d.ts +19 -0
- package/lib/typescript/module/ui/components/Markdown.d.ts.map +1 -0
- package/lib/typescript/module/ui/components/OutboundMessageCard.d.ts +20 -0
- package/lib/typescript/module/ui/components/OutboundMessageCard.d.ts.map +1 -0
- package/lib/typescript/module/ui/components/WidgetPanel.d.ts +26 -0
- package/lib/typescript/module/ui/components/WidgetPanel.d.ts.map +1 -0
- package/lib/typescript/module/ui/components/icons.d.ts +38 -0
- package/lib/typescript/module/ui/components/icons.d.ts.map +1 -0
- package/lib/typescript/module/ui/hooks/use-keyboard-overlap.d.ts +33 -0
- package/lib/typescript/module/ui/hooks/use-keyboard-overlap.d.ts.map +1 -0
- package/lib/typescript/module/ui/hooks/use-reduce-motion.d.ts +11 -0
- package/lib/typescript/module/ui/hooks/use-reduce-motion.d.ts.map +1 -0
- package/lib/typescript/module/ui/hooks/use-widget-insets.d.ts +16 -0
- package/lib/typescript/module/ui/hooks/use-widget-insets.d.ts.map +1 -0
- package/lib/typescript/module/ui/screens/chat/ChatView.d.ts +11 -0
- package/lib/typescript/module/ui/screens/chat/ChatView.d.ts.map +1 -0
- package/lib/typescript/module/ui/screens/chat/ChatView.styles.d.ts +349 -0
- package/lib/typescript/module/ui/screens/chat/ChatView.styles.d.ts.map +1 -0
- package/lib/typescript/module/ui/screens/chat/ChatView.types.d.ts +48 -0
- package/lib/typescript/module/ui/screens/chat/ChatView.types.d.ts.map +1 -0
- package/lib/typescript/module/ui/screens/conversations/ConversationsList.d.ts +10 -0
- package/lib/typescript/module/ui/screens/conversations/ConversationsList.d.ts.map +1 -0
- package/lib/typescript/module/ui/screens/conversations/ConversationsList.styles.d.ts +113 -0
- package/lib/typescript/module/ui/screens/conversations/ConversationsList.styles.d.ts.map +1 -0
- package/lib/typescript/module/ui/screens/conversations/ConversationsList.types.d.ts +31 -0
- package/lib/typescript/module/ui/screens/conversations/ConversationsList.types.d.ts.map +1 -0
- package/lib/typescript/module/ui/screens/home/HomeView.d.ts +17 -0
- package/lib/typescript/module/ui/screens/home/HomeView.d.ts.map +1 -0
- package/lib/typescript/module/ui/screens/home/HomeView.styles.d.ts +227 -0
- package/lib/typescript/module/ui/screens/home/HomeView.styles.d.ts.map +1 -0
- package/lib/typescript/module/ui/screens/home/HomeView.types.d.ts +40 -0
- package/lib/typescript/module/ui/screens/home/HomeView.types.d.ts.map +1 -0
- package/lib/typescript/module/ui/screens/home/greeting.d.ts +19 -0
- package/lib/typescript/module/ui/screens/home/greeting.d.ts.map +1 -0
- package/lib/typescript/module/ui/screens/pre-chat/PreChatForm.d.ts +7 -0
- package/lib/typescript/module/ui/screens/pre-chat/PreChatForm.d.ts.map +1 -0
- package/lib/typescript/module/ui/screens/pre-chat/PreChatForm.styles.d.ts +115 -0
- package/lib/typescript/module/ui/screens/pre-chat/PreChatForm.styles.d.ts.map +1 -0
- package/lib/typescript/module/ui/screens/pre-chat/PreChatForm.types.d.ts +20 -0
- package/lib/typescript/module/ui/screens/pre-chat/PreChatForm.types.d.ts.map +1 -0
- package/lib/typescript/module/ui/styles/global.d.ts +46 -0
- package/lib/typescript/module/ui/styles/global.d.ts.map +1 -0
- package/lib/typescript/module/ui/styles/theme.d.ts +103 -0
- package/lib/typescript/module/ui/styles/theme.d.ts.map +1 -0
- package/lib/typescript/module/ui/utils/conversations.d.ts +41 -0
- package/lib/typescript/module/ui/utils/conversations.d.ts.map +1 -0
- package/lib/typescript/module/ui/utils/html.d.ts +10 -0
- package/lib/typescript/module/ui/utils/html.d.ts.map +1 -0
- package/lib/typescript/module/ui/utils/native-gradient.d.ts +61 -0
- package/lib/typescript/module/ui/utils/native-gradient.d.ts.map +1 -0
- package/lib/typescript/module/ui/utils/rtl.d.ts +33 -0
- package/lib/typescript/module/ui/utils/rtl.d.ts.map +1 -0
- package/lib/typescript/module/ui/utils/safe-url.d.ts +21 -0
- package/lib/typescript/module/ui/utils/safe-url.d.ts.map +1 -0
- package/metro.js +40 -0
- package/package.json +116 -0
- package/src/agent-ui-blocks.ts +302 -0
- package/src/api/client.ts +332 -0
- package/src/api/realtime.ts +225 -0
- package/src/api/sse-parser.ts +51 -0
- package/src/controller.ts +20 -0
- package/src/device-id.ts +71 -0
- package/src/events.ts +74 -0
- package/src/i18n.ts +114 -0
- package/src/index.tsx +199 -0
- package/src/locales.ts +80 -0
- package/src/push/push-notifications.ts +254 -0
- package/src/state/use-widget-state.ts +20 -0
- package/src/state/widget-store.ts +1815 -0
- package/src/storage.ts +153 -0
- package/src/types.ts +445 -0
- package/src/ui/WidgetProvider.tsx +434 -0
- package/src/ui/components/AgentUiBlocks.tsx +912 -0
- package/src/ui/components/Avatar.tsx +86 -0
- package/src/ui/components/ConversationRow.tsx +163 -0
- package/src/ui/components/ErrorBoundary.tsx +49 -0
- package/src/ui/components/Gradient.tsx +165 -0
- package/src/ui/components/Launcher.tsx +128 -0
- package/src/ui/components/Markdown.tsx +291 -0
- package/src/ui/components/OutboundMessageCard.tsx +154 -0
- package/src/ui/components/WidgetPanel.tsx +133 -0
- package/src/ui/components/icons.tsx +315 -0
- package/src/ui/hooks/use-keyboard-overlap.ts +134 -0
- package/src/ui/hooks/use-reduce-motion.ts +39 -0
- package/src/ui/hooks/use-widget-insets.ts +44 -0
- package/src/ui/screens/chat/ChatView.styles.ts +357 -0
- package/src/ui/screens/chat/ChatView.tsx +690 -0
- package/src/ui/screens/chat/ChatView.types.ts +46 -0
- package/src/ui/screens/conversations/ConversationsList.styles.ts +111 -0
- package/src/ui/screens/conversations/ConversationsList.tsx +144 -0
- package/src/ui/screens/conversations/ConversationsList.types.ts +33 -0
- package/src/ui/screens/home/HomeView.styles.ts +246 -0
- package/src/ui/screens/home/HomeView.tsx +336 -0
- package/src/ui/screens/home/HomeView.types.ts +42 -0
- package/src/ui/screens/home/greeting.ts +50 -0
- package/src/ui/screens/pre-chat/PreChatForm.styles.ts +120 -0
- package/src/ui/screens/pre-chat/PreChatForm.tsx +221 -0
- package/src/ui/screens/pre-chat/PreChatForm.types.ts +22 -0
- package/src/ui/styles/global.ts +50 -0
- package/src/ui/styles/theme.ts +155 -0
- package/src/ui/utils/conversations.ts +122 -0
- package/src/ui/utils/html.ts +58 -0
- package/src/ui/utils/native-gradient.ts +60 -0
- package/src/ui/utils/rtl.ts +43 -0
- package/src/ui/utils/safe-url.ts +63 -0
package/src/index.tsx
ADDED
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @repzo/widget-react-native — the Repzo chat widget for React Native.
|
|
3
|
+
*
|
|
4
|
+
* Pure JavaScript: no native modules, no config plugin, no pod install. The
|
|
5
|
+
* public surface mirrors `@intercom/intercom-react-native` so swapping the two
|
|
6
|
+
* is a rename at each call site.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { controller } from './controller';
|
|
10
|
+
import { RepzoWidgetEvents, type EventSubscription, type RepzoWidgetEvent } from './events';
|
|
11
|
+
import { setSecureStorageAdapter, setStorageAdapter } from './storage';
|
|
12
|
+
import type {
|
|
13
|
+
BootOptions,
|
|
14
|
+
RepzoWidgetStorageAdapter,
|
|
15
|
+
WidgetCustomAttributes,
|
|
16
|
+
WidgetSpaceType,
|
|
17
|
+
WidgetUser,
|
|
18
|
+
} from './types';
|
|
19
|
+
|
|
20
|
+
export { RepzoWidgetProvider } from './ui/WidgetProvider';
|
|
21
|
+
export { Launcher as RepzoWidgetLauncher } from './ui/components/Launcher';
|
|
22
|
+
export { RepzoWidgetEvents } from './events';
|
|
23
|
+
export { RepzoWidgetError } from './api/client';
|
|
24
|
+
export { DEFAULT_BASE_URL } from './types';
|
|
25
|
+
export { useWidgetState } from './state/use-widget-state';
|
|
26
|
+
|
|
27
|
+
export type {
|
|
28
|
+
AgentUiAction,
|
|
29
|
+
AgentUiBlock,
|
|
30
|
+
BootOptions,
|
|
31
|
+
Conversation,
|
|
32
|
+
Message,
|
|
33
|
+
OutboundMessage,
|
|
34
|
+
PreChatField,
|
|
35
|
+
RepzoWidgetErrorCode,
|
|
36
|
+
RepzoWidgetStorageAdapter,
|
|
37
|
+
WidgetAttachment,
|
|
38
|
+
WidgetConfig,
|
|
39
|
+
WidgetCustomAttributes,
|
|
40
|
+
WidgetSpace,
|
|
41
|
+
WidgetSpaceType,
|
|
42
|
+
WidgetState,
|
|
43
|
+
WidgetUser,
|
|
44
|
+
WidgetView,
|
|
45
|
+
} from './types';
|
|
46
|
+
export type {
|
|
47
|
+
EventSubscription,
|
|
48
|
+
MessageDidArrivePayload,
|
|
49
|
+
RepzoWidgetEvent,
|
|
50
|
+
RepzoWidgetEventPayloads,
|
|
51
|
+
} from './events';
|
|
52
|
+
export type { WidgetTheme } from './ui/styles/theme';
|
|
53
|
+
|
|
54
|
+
/** Spaces the widget can open into — the analogue of Intercom's `Space`. */
|
|
55
|
+
export enum Space {
|
|
56
|
+
home = 'home',
|
|
57
|
+
messages = 'messages',
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export type RepzoWidgetType = {
|
|
61
|
+
/**
|
|
62
|
+
* Start (or resume) a visitor session and connect realtime.
|
|
63
|
+
* Safe to call repeatedly — a boot for the same widget and user is a no-op,
|
|
64
|
+
* which matters because `POST /api/widget/init` is rate limited to 10/min.
|
|
65
|
+
*/
|
|
66
|
+
boot(options: BootOptions): Promise<void>;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Drop any identity and start a fresh anonymous session. A previously
|
|
70
|
+
* identified user is fully signed out first (same as `logout()`).
|
|
71
|
+
*/
|
|
72
|
+
loginUnidentifiedUser(): Promise<void>;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Identify the visitor. Requires `userId` or `email`; conversations started
|
|
76
|
+
* anonymously on this device move to the identified visitor. If a
|
|
77
|
+
* *different* identified user's session is stored, it is signed out first
|
|
78
|
+
* (same as `logout()`) — their conversations never carry over.
|
|
79
|
+
*/
|
|
80
|
+
loginUserWithUserAttributes(user: WidgetUser): Promise<void>;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Attach custom attributes to the visitor's identity so agents see them on
|
|
84
|
+
* the conversation (max 30 keys, 64-char keys, 512-char values).
|
|
85
|
+
*/
|
|
86
|
+
updateUser(attributes: WidgetCustomAttributes): Promise<void>;
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Sign the visitor out — await it in your app's sign-out flow. Revokes the
|
|
90
|
+
* token server-side and removes the push registration (best-effort, 5s cap
|
|
91
|
+
* each), wipes every user-scoped key, rotates the anonymous device id,
|
|
92
|
+
* closes realtime and resets the UI. Nothing re-inits until the next
|
|
93
|
+
* `boot()` / login call.
|
|
94
|
+
*/
|
|
95
|
+
logout(): Promise<void>;
|
|
96
|
+
|
|
97
|
+
/** Open the widget on its default space. */
|
|
98
|
+
present(): Promise<void>;
|
|
99
|
+
|
|
100
|
+
/** Open the widget on a specific space. */
|
|
101
|
+
presentSpace(space: Space | WidgetSpaceType): Promise<void>;
|
|
102
|
+
|
|
103
|
+
/** Open the widget directly on one conversation. */
|
|
104
|
+
presentConversation(conversationId: string): Promise<void>;
|
|
105
|
+
|
|
106
|
+
/** Dismiss the widget. */
|
|
107
|
+
hide(): Promise<void>;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Conversations with at least one unread team reply (Intercom's meaning).
|
|
111
|
+
* A thread stays unread until the visitor opens it — opening the messenger
|
|
112
|
+
* alone doesn't clear it.
|
|
113
|
+
*/
|
|
114
|
+
getUnreadConversationCount(): Promise<number>;
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Unread team replies across all conversations — the same number
|
|
118
|
+
* `UnreadCountDidChange` carries and the launcher badge shows.
|
|
119
|
+
*/
|
|
120
|
+
getUnreadMessageCount(): Promise<number>;
|
|
121
|
+
|
|
122
|
+
/** Record an analytics event against the visitor. */
|
|
123
|
+
logEvent(eventName: string, metadata?: Record<string, unknown>): Promise<void>;
|
|
124
|
+
|
|
125
|
+
/** Switch the active translation locale. */
|
|
126
|
+
setLocale(locale: string): void;
|
|
127
|
+
|
|
128
|
+
/** Subscribe to `RepzoWidgetEvents.*`. Call `.remove()` on unmount. */
|
|
129
|
+
addEventListener<E extends RepzoWidgetEvent>(
|
|
130
|
+
event: E,
|
|
131
|
+
listener: (payload: any) => void
|
|
132
|
+
): EventSubscription;
|
|
133
|
+
|
|
134
|
+
/** Key/value store for the device id, unread counts and cached theme. */
|
|
135
|
+
setStorageAdapter(adapter: RepzoWidgetStorageAdapter | null): void;
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Keychain/Keystore-backed store for the visitor token and user key (e.g.
|
|
139
|
+
* `expo-secure-store`, `react-native-keychain` — see README). Without one
|
|
140
|
+
* they fall back to `setStorageAdapter`'s store. Call before `boot()`.
|
|
141
|
+
*/
|
|
142
|
+
setSecureStorageAdapter(adapter: RepzoWidgetStorageAdapter | null): void;
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Manually register an FCM device token for push notifications — the escape
|
|
146
|
+
* hatch for hosts without `@react-native-firebase/messaging` (with it
|
|
147
|
+
* installed, `boot({ push: { enabled: true } })` handles everything).
|
|
148
|
+
*/
|
|
149
|
+
setPushToken(options: { token: string; platform?: 'ios' | 'android'; bundleId?: string }): Promise<void>;
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
const RepzoWidget: RepzoWidgetType = {
|
|
153
|
+
boot: (options) => controller.store.boot(options),
|
|
154
|
+
|
|
155
|
+
loginUnidentifiedUser: () => controller.store.loginUnidentifiedUser(),
|
|
156
|
+
|
|
157
|
+
loginUserWithUserAttributes: (user) => controller.store.loginUserWithUserAttributes(user),
|
|
158
|
+
|
|
159
|
+
updateUser: (attributes) => controller.store.updateUser(attributes),
|
|
160
|
+
|
|
161
|
+
logout: () => controller.store.logout(),
|
|
162
|
+
|
|
163
|
+
present: async () => {
|
|
164
|
+
controller.store.present();
|
|
165
|
+
},
|
|
166
|
+
|
|
167
|
+
presentSpace: async (space) => {
|
|
168
|
+
controller.store.present(space as WidgetSpaceType);
|
|
169
|
+
},
|
|
170
|
+
|
|
171
|
+
presentConversation: (conversationId) => controller.store.openConversation(conversationId),
|
|
172
|
+
|
|
173
|
+
hide: async () => {
|
|
174
|
+
controller.store.hide();
|
|
175
|
+
},
|
|
176
|
+
|
|
177
|
+
getUnreadConversationCount: async () =>
|
|
178
|
+
Object.values(controller.store.getState().unreadByConversation).filter((count) => count > 0)
|
|
179
|
+
.length,
|
|
180
|
+
|
|
181
|
+
getUnreadMessageCount: async () => controller.store.getState().unreadCount,
|
|
182
|
+
|
|
183
|
+
logEvent: async (eventName, metadata) => {
|
|
184
|
+
controller.store.track(eventName, metadata ?? {});
|
|
185
|
+
},
|
|
186
|
+
|
|
187
|
+
setLocale: (locale) => controller.store.setLocale(locale),
|
|
188
|
+
|
|
189
|
+
addEventListener: (event, listener) => controller.events.addListener(event, listener),
|
|
190
|
+
|
|
191
|
+
setStorageAdapter: (adapter) => setStorageAdapter(adapter),
|
|
192
|
+
|
|
193
|
+
setSecureStorageAdapter: (adapter) => setSecureStorageAdapter(adapter),
|
|
194
|
+
|
|
195
|
+
setPushToken: (options) => controller.store.push.setManualToken(options),
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
export default RepzoWidget;
|
|
199
|
+
export { RepzoWidgetEvents as Events };
|
package/src/locales.ts
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Translations bundled with the SDK.
|
|
3
|
+
*
|
|
4
|
+
* A workspace can still override any key from the dashboard — those win. These
|
|
5
|
+
* exist so a widget running in a supported language is usable out of the box,
|
|
6
|
+
* instead of falling back to English for every string an admin has not filled
|
|
7
|
+
* in by hand.
|
|
8
|
+
*
|
|
9
|
+
* Keys mirror `DEFAULT_LABELS` in `./i18n`; `{token}` placeholders must be kept
|
|
10
|
+
* so word order stays under the translator's control.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import type { DEFAULT_LABELS } from './i18n';
|
|
14
|
+
|
|
15
|
+
type LabelMap = Partial<Record<keyof typeof DEFAULT_LABELS, string>>;
|
|
16
|
+
|
|
17
|
+
const ar: LabelMap = {
|
|
18
|
+
back: 'رجوع',
|
|
19
|
+
loading: 'جارٍ التحميل...',
|
|
20
|
+
loadEarlier: 'تحميل الرسائل السابقة',
|
|
21
|
+
emptyConversation: 'أرسل رسالة لبدء المحادثة',
|
|
22
|
+
messagePlaceholder: 'اكتب رسالة...',
|
|
23
|
+
attachFile: 'إرفاق ملف',
|
|
24
|
+
failedToSend: 'تعذر الإرسال',
|
|
25
|
+
thinking: 'يكتب',
|
|
26
|
+
messages: 'الرسائل',
|
|
27
|
+
noMessages: 'لا توجد رسائل بعد',
|
|
28
|
+
historyHidden: 'سجل المحادثات مخفي',
|
|
29
|
+
startBelow: 'ابدأ محادثة من الأسفل',
|
|
30
|
+
preChatTitle: 'قبل أن نبدأ',
|
|
31
|
+
preChatSubtitle: 'أخبرنا قليلاً عنك حتى نتمكن من مساعدتك بشكل أفضل.',
|
|
32
|
+
preChatSkip: 'تخطٍ',
|
|
33
|
+
preChatSubmit: 'ابدأ المحادثة',
|
|
34
|
+
viewPreviousConversations: 'عرض المحادثات السابقة',
|
|
35
|
+
homeRecentTitle: 'الأحدث',
|
|
36
|
+
homeViewAllCount: 'عرض الكل ({count})',
|
|
37
|
+
homeNoConversations: 'ستظهر محادثاتك هنا',
|
|
38
|
+
homeStatusOnline: 'نحن متصلون',
|
|
39
|
+
homeStatusAway: 'نحن غير متصلين',
|
|
40
|
+
unreadBadge: '{count} غير مقروءة',
|
|
41
|
+
team: 'الفريق',
|
|
42
|
+
home: 'الرئيسية',
|
|
43
|
+
close: 'إغلاق',
|
|
44
|
+
retry: 'إعادة المحاولة',
|
|
45
|
+
connectionError: 'تعذر تحميل المحادثة. يرجى المحاولة مرة أخرى.',
|
|
46
|
+
connecting: 'جارٍ توصيلك بالفريق',
|
|
47
|
+
chatUnavailable: 'المحادثة غير متاحة حاليًا.',
|
|
48
|
+
identityVerificationError: 'تعذر التحقق من حسابك. يرجى تسجيل الدخول مرة أخرى.',
|
|
49
|
+
widgetCrashed: 'حدث خطأ ما.',
|
|
50
|
+
// Kept short: these sit in a tight row beside the agent's name.
|
|
51
|
+
timeJustNow: 'الآن',
|
|
52
|
+
timeMinutes: '{count} د',
|
|
53
|
+
timeHours: '{count} س',
|
|
54
|
+
timeDays: '{count} ي',
|
|
55
|
+
timeMonths: '{count} شهر',
|
|
56
|
+
timeYears: '{count} سنة',
|
|
57
|
+
today: 'اليوم',
|
|
58
|
+
yesterday: 'أمس',
|
|
59
|
+
conversationUpdated: 'تم تحديث المحادثة',
|
|
60
|
+
procedureSend: 'إرسال التفاصيل',
|
|
61
|
+
procedureSent: 'تم الإرسال',
|
|
62
|
+
fieldRequired: '{field} مطلوب',
|
|
63
|
+
invalidEmail: 'أدخل بريدًا إلكترونيًا صالحًا',
|
|
64
|
+
working: 'جارٍ العمل...',
|
|
65
|
+
outboundTitle: 'تحديث جديد',
|
|
66
|
+
outboundCta: 'اعرف المزيد',
|
|
67
|
+
dismiss: 'تجاهل',
|
|
68
|
+
blockService: 'خدمة',
|
|
69
|
+
blockProduct: 'منتج',
|
|
70
|
+
blockChooseTime: 'اختر وقتًا',
|
|
71
|
+
blockProfessional: 'الموظف',
|
|
72
|
+
blockPriceOffer: 'عرض سعر',
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export const BUNDLED_TRANSLATIONS: Record<string, LabelMap> = { ar };
|
|
76
|
+
|
|
77
|
+
/** `ar-JO`, `ar_SA` and `AR` all resolve to the `ar` bundle. */
|
|
78
|
+
export function baseLanguage(locale?: string | null): string {
|
|
79
|
+
return (locale ?? '').split(/[-_]/)[0]?.toLowerCase() ?? '';
|
|
80
|
+
}
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FCM push notifications — optional.
|
|
3
|
+
*
|
|
4
|
+
* Powered by the HOST app's `@react-native-firebase/messaging` native module,
|
|
5
|
+
* loaded via a dynamic require so the SDK itself stays pure JavaScript. Hosts
|
|
6
|
+
* without Firebase installed get a warn-once no-op; hosts that can't install
|
|
7
|
+
* it can still register a token manually through `RepzoWidget.setPushToken()`.
|
|
8
|
+
*
|
|
9
|
+
* Supports both RNFB API generations: the modular API (`getMessaging()` etc.,
|
|
10
|
+
* the only one left in v26+) and the legacy namespaced `messaging()` factory.
|
|
11
|
+
*
|
|
12
|
+
* The Workstation channel must have its push provider set to FCM — with
|
|
13
|
+
* OneSignal selected these registrations are stored but unused.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { Platform } from 'react-native';
|
|
17
|
+
import type { WidgetApiClient } from '../api/client';
|
|
18
|
+
|
|
19
|
+
export interface WidgetPushOptions {
|
|
20
|
+
/** Register this device for FCM pushes after every successful session init. */
|
|
21
|
+
enabled?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Ask for notification permission before registering (default true). Set
|
|
24
|
+
* false when the host app runs its own permission prompt.
|
|
25
|
+
*/
|
|
26
|
+
requestPermission?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* The app's bundle id / package name. Lets a Workstation channel that serves
|
|
29
|
+
* several apps pick the matching Firebase key for this device's tokens.
|
|
30
|
+
* Optional for single-app channels.
|
|
31
|
+
*/
|
|
32
|
+
bundleId?: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
interface ManualToken {
|
|
36
|
+
token: string;
|
|
37
|
+
platform?: string;
|
|
38
|
+
bundleId?: string | null;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** Version-agnostic view over the host's Firebase messaging module. */
|
|
42
|
+
interface MessagingHandle {
|
|
43
|
+
requestPermission(): Promise<unknown>;
|
|
44
|
+
registerDeviceForRemoteMessages(): Promise<unknown>;
|
|
45
|
+
getToken(): Promise<string | null>;
|
|
46
|
+
onTokenRefresh(cb: (token: string) => void): void;
|
|
47
|
+
onNotificationOpenedApp(cb: (remoteMessage: any) => void): void;
|
|
48
|
+
getInitialNotification(): Promise<any>;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function resolveMessaging(): MessagingHandle | null {
|
|
52
|
+
try {
|
|
53
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires, global-require
|
|
54
|
+
const mod = require('@react-native-firebase/messaging');
|
|
55
|
+
|
|
56
|
+
// Modular API — the only one in RNFB v26+ (the namespaced default export
|
|
57
|
+
// was removed). Every call takes the messaging instance as its first arg.
|
|
58
|
+
if (typeof mod?.getMessaging === 'function') {
|
|
59
|
+
const instance = mod.getMessaging();
|
|
60
|
+
return {
|
|
61
|
+
requestPermission: () => mod.requestPermission(instance),
|
|
62
|
+
registerDeviceForRemoteMessages: () =>
|
|
63
|
+
typeof mod.registerDeviceForRemoteMessages === 'function'
|
|
64
|
+
? mod.registerDeviceForRemoteMessages(instance)
|
|
65
|
+
: Promise.resolve(),
|
|
66
|
+
getToken: () => mod.getToken(instance),
|
|
67
|
+
onTokenRefresh: (cb) => mod.onTokenRefresh(instance, cb),
|
|
68
|
+
onNotificationOpenedApp: (cb) => mod.onNotificationOpenedApp(instance, cb),
|
|
69
|
+
getInitialNotification: () => mod.getInitialNotification(instance),
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// Legacy namespaced API (RNFB <= v22): default export is a factory.
|
|
74
|
+
const factory = mod?.default ?? mod;
|
|
75
|
+
if (typeof factory !== 'function') return null;
|
|
76
|
+
const instance = factory();
|
|
77
|
+
if (!instance) return null;
|
|
78
|
+
return {
|
|
79
|
+
requestPermission: () => instance.requestPermission?.() ?? Promise.resolve(),
|
|
80
|
+
registerDeviceForRemoteMessages: () =>
|
|
81
|
+
typeof instance.registerDeviceForRemoteMessages === 'function'
|
|
82
|
+
? instance.registerDeviceForRemoteMessages()
|
|
83
|
+
: Promise.resolve(),
|
|
84
|
+
getToken: () => instance.getToken(),
|
|
85
|
+
onTokenRefresh: (cb) => instance.onTokenRefresh?.(cb),
|
|
86
|
+
onNotificationOpenedApp: (cb) => instance.onNotificationOpenedApp?.(cb),
|
|
87
|
+
getInitialNotification: () => instance.getInitialNotification?.() ?? Promise.resolve(null),
|
|
88
|
+
};
|
|
89
|
+
} catch {
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export class PushManager {
|
|
95
|
+
private options: WidgetPushOptions = {};
|
|
96
|
+
|
|
97
|
+
private listenersWired = false;
|
|
98
|
+
|
|
99
|
+
private lastToken: string | null = null;
|
|
100
|
+
|
|
101
|
+
private manualToken: ManualToken | null = null;
|
|
102
|
+
|
|
103
|
+
private warnedMissingModule = false;
|
|
104
|
+
|
|
105
|
+
/** False while signed out — token refreshes must not register anywhere. */
|
|
106
|
+
private active = false;
|
|
107
|
+
|
|
108
|
+
/** Registrations still on the wire; unregister() waits for them. */
|
|
109
|
+
private inflight = new Set<Promise<void>>();
|
|
110
|
+
|
|
111
|
+
constructor(
|
|
112
|
+
private client: WidgetApiClient,
|
|
113
|
+
private openConversation: (conversationId: string) => void
|
|
114
|
+
) {}
|
|
115
|
+
|
|
116
|
+
/** Remember the boot options; actual work happens in start() post-init. */
|
|
117
|
+
configure(options?: WidgetPushOptions) {
|
|
118
|
+
this.options = options ?? {};
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Called after every successful session init — the widget token is valid
|
|
123
|
+
* from here. Re-running after a login switch re-registers the token under
|
|
124
|
+
* the new identity (the server upsert moves it).
|
|
125
|
+
*/
|
|
126
|
+
async start(): Promise<void> {
|
|
127
|
+
this.active = true;
|
|
128
|
+
if (this.manualToken) {
|
|
129
|
+
await this.register(this.manualToken);
|
|
130
|
+
}
|
|
131
|
+
if (!this.options.enabled) return;
|
|
132
|
+
|
|
133
|
+
const messaging = resolveMessaging();
|
|
134
|
+
if (!messaging) {
|
|
135
|
+
if (!this.warnedMissingModule) {
|
|
136
|
+
this.warnedMissingModule = true;
|
|
137
|
+
console.warn(
|
|
138
|
+
'[repzo-widget] push is enabled but @react-native-firebase/messaging is not installed — ' +
|
|
139
|
+
'install it in the app, or provide a token via RepzoWidget.setPushToken()'
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
try {
|
|
146
|
+
if (this.options.requestPermission !== false) {
|
|
147
|
+
// A denial isn't an error: getToken still succeeds, the OS just
|
|
148
|
+
// won't display anything until the user flips the setting.
|
|
149
|
+
await messaging.requestPermission();
|
|
150
|
+
}
|
|
151
|
+
} catch {
|
|
152
|
+
// Permission prompt unavailable (e.g. older Android) — keep going.
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// Wired once and kept for the app's lifetime — taps must work even while
|
|
156
|
+
// the widget UI is closed, so there is deliberately no teardown.
|
|
157
|
+
if (!this.listenersWired) {
|
|
158
|
+
this.listenersWired = true;
|
|
159
|
+
this.wireTapHandlers(messaging);
|
|
160
|
+
messaging.onTokenRefresh((token: string) => {
|
|
161
|
+
void this.register({ token });
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// iOS needs the APNs registration before an FCM token exists; RNFB
|
|
166
|
+
// auto-registers by default, this covers hosts that turned that off.
|
|
167
|
+
try {
|
|
168
|
+
await messaging.registerDeviceForRemoteMessages();
|
|
169
|
+
} catch {
|
|
170
|
+
// Already registered, or simulator without push support — getToken
|
|
171
|
+
// decides whether that actually matters.
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
try {
|
|
175
|
+
const token = await messaging.getToken();
|
|
176
|
+
if (token) await this.register({ token });
|
|
177
|
+
} catch (error) {
|
|
178
|
+
console.warn('[repzo-widget] push token fetch failed', error);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/** Host-supplied token for apps without the Firebase module. */
|
|
183
|
+
async setManualToken(manual: ManualToken): Promise<void> {
|
|
184
|
+
this.manualToken = manual;
|
|
185
|
+
// Before boot (or after logout) it is only remembered; start() sends it.
|
|
186
|
+
if (this.active) await this.register(manual);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Called by logout with the session's token captured up front: the DELETE
|
|
191
|
+
* is authenticated with it explicitly and never triggers a re-init.
|
|
192
|
+
* Waits for an in-flight registration first so its token is not missed.
|
|
193
|
+
*/
|
|
194
|
+
async unregister(authToken: string | null): Promise<void> {
|
|
195
|
+
this.active = false;
|
|
196
|
+
await Promise.all([...this.inflight]);
|
|
197
|
+
const token = this.lastToken;
|
|
198
|
+
this.lastToken = null;
|
|
199
|
+
if (!token || !authToken) return;
|
|
200
|
+
try {
|
|
201
|
+
await this.client.removePushToken(token, { authToken, skipReauth: true });
|
|
202
|
+
} catch (error) {
|
|
203
|
+
console.warn('[repzo-widget] push token removal failed', error);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
private register(manual: ManualToken): Promise<void> {
|
|
208
|
+
if (!this.active) return Promise.resolve();
|
|
209
|
+
const run = this.client
|
|
210
|
+
.registerPushToken({
|
|
211
|
+
token: manual.token,
|
|
212
|
+
platform: manual.platform ?? (Platform.OS === 'ios' ? 'ios' : 'android'),
|
|
213
|
+
bundleId: manual.bundleId ?? this.options.bundleId ?? undefined,
|
|
214
|
+
})
|
|
215
|
+
.then(
|
|
216
|
+
() => {
|
|
217
|
+
this.lastToken = manual.token;
|
|
218
|
+
},
|
|
219
|
+
(error) => {
|
|
220
|
+
console.warn('[repzo-widget] push token registration failed', error);
|
|
221
|
+
}
|
|
222
|
+
)
|
|
223
|
+
.finally(() => {
|
|
224
|
+
this.inflight.delete(run);
|
|
225
|
+
});
|
|
226
|
+
this.inflight.add(run);
|
|
227
|
+
return run;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
private wireTapHandlers(messaging: MessagingHandle) {
|
|
231
|
+
// Background → tapped: the app was alive, just not in front.
|
|
232
|
+
messaging.onNotificationOpenedApp((remoteMessage: any) => {
|
|
233
|
+
this.handleTap(remoteMessage);
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
// Killed → tapped: the click that launched the app.
|
|
237
|
+
void messaging
|
|
238
|
+
.getInitialNotification()
|
|
239
|
+
.then((remoteMessage: any) => {
|
|
240
|
+
if (remoteMessage) this.handleTap(remoteMessage);
|
|
241
|
+
})
|
|
242
|
+
.catch(() => {});
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/** Only widget pushes are ours — host app notifications pass through. */
|
|
246
|
+
private handleTap(remoteMessage: any) {
|
|
247
|
+
const data = remoteMessage?.data;
|
|
248
|
+
if (data?.document_type !== 'widget_message') return;
|
|
249
|
+
const conversationId = data?.document_id;
|
|
250
|
+
if (typeof conversationId === 'string' && conversationId) {
|
|
251
|
+
this.openConversation(conversationId);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React binding for the store. The store lives in the controller singleton, so
|
|
3
|
+
* the widget keeps its session, SSE stream and unread count even when no
|
|
4
|
+
* component is mounted; this hook only subscribes to it.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { useSyncExternalStore } from 'react';
|
|
8
|
+
|
|
9
|
+
import { controller } from '../controller';
|
|
10
|
+
import type { WidgetState } from '../types';
|
|
11
|
+
import type { WidgetStore } from './widget-store';
|
|
12
|
+
|
|
13
|
+
export function useWidgetState(): WidgetState {
|
|
14
|
+
const store = controller.store;
|
|
15
|
+
return useSyncExternalStore(store.subscribe, store.getState, store.getState);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function useWidgetStore(): WidgetStore {
|
|
19
|
+
return controller.store;
|
|
20
|
+
}
|