@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
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Conversation selectors and formatting shared by the Home and Messages
|
|
5
|
+
* spaces, so the two can never disagree about ordering or wording.
|
|
6
|
+
* Pure and free of React so they stay trivial to test.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { formatLabel } from "../../i18n.js";
|
|
10
|
+
const conversationTime = conversation => {
|
|
11
|
+
const parsed = Date.parse(conversation.lastMessageAt || conversation.createdAt || '');
|
|
12
|
+
return Number.isNaN(parsed) ? 0 : parsed;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Newest first. The store patches a conversation in place when a message
|
|
17
|
+
* arrives and never reorders the array, so position is not recency — every
|
|
18
|
+
* surface that lists conversations has to sort for itself.
|
|
19
|
+
*/
|
|
20
|
+
export function sortByRecency(conversations) {
|
|
21
|
+
return [...conversations].sort((a, b) => conversationTime(b) - conversationTime(a));
|
|
22
|
+
}
|
|
23
|
+
export function pickRecentConversations(conversations, limit = 2) {
|
|
24
|
+
return sortByRecency(conversations).slice(0, limit);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** Distinct agents the visitor has spoken to, most recent conversation first. */
|
|
28
|
+
export function pickTeamAgents(conversations, limit = 3) {
|
|
29
|
+
const seen = new Set();
|
|
30
|
+
const agents = [];
|
|
31
|
+
for (const conversation of sortByRecency(conversations)) {
|
|
32
|
+
const name = conversation.agentName?.trim();
|
|
33
|
+
if (!name) continue;
|
|
34
|
+
const key = name.toLowerCase();
|
|
35
|
+
if (seen.has(key)) continue;
|
|
36
|
+
seen.add(key);
|
|
37
|
+
agents.push({
|
|
38
|
+
name,
|
|
39
|
+
avatar: conversation.agentAvatar
|
|
40
|
+
});
|
|
41
|
+
if (agents.length >= limit) break;
|
|
42
|
+
}
|
|
43
|
+
return agents;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** Every unit is a translated template, so `2h` can become `منذ ساعتين`. */
|
|
47
|
+
|
|
48
|
+
export function formatRelativeTime(dateStr, labels) {
|
|
49
|
+
const date = new Date(dateStr);
|
|
50
|
+
const diffMs = Date.now() - date.getTime();
|
|
51
|
+
const diffMin = Math.floor(diffMs / 60000);
|
|
52
|
+
if (diffMin < 1) return labels.justNow;
|
|
53
|
+
if (diffMin < 60) return formatLabel(labels.minutes, {
|
|
54
|
+
count: diffMin
|
|
55
|
+
});
|
|
56
|
+
const diffHrs = Math.floor(diffMin / 60);
|
|
57
|
+
if (diffHrs < 24) return formatLabel(labels.hours, {
|
|
58
|
+
count: diffHrs
|
|
59
|
+
});
|
|
60
|
+
const diffDays = Math.floor(diffHrs / 24);
|
|
61
|
+
if (diffDays < 30) return formatLabel(labels.days, {
|
|
62
|
+
count: diffDays
|
|
63
|
+
});
|
|
64
|
+
const diffMonths = Math.floor(diffDays / 30);
|
|
65
|
+
if (diffMonths < 12) return formatLabel(labels.months, {
|
|
66
|
+
count: diffMonths
|
|
67
|
+
});
|
|
68
|
+
return formatLabel(labels.years, {
|
|
69
|
+
count: Math.floor(diffDays / 365)
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
const startOfDay = date => new Date(date.getFullYear(), date.getMonth(), date.getDate()).getTime();
|
|
73
|
+
export function isSameDay(a, b) {
|
|
74
|
+
return startOfDay(new Date(a)) === startOfDay(new Date(b));
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Clock time beside a message. Intl ships with Hermes but is guarded anyway —
|
|
79
|
+
* a missing implementation should not blank out every timestamp in the thread.
|
|
80
|
+
*/
|
|
81
|
+
export function formatClockTime(dateStr, locale) {
|
|
82
|
+
const date = new Date(dateStr);
|
|
83
|
+
if (Number.isNaN(date.getTime())) return '';
|
|
84
|
+
try {
|
|
85
|
+
return new Intl.DateTimeFormat(locale, {
|
|
86
|
+
hour: 'numeric',
|
|
87
|
+
minute: '2-digit'
|
|
88
|
+
}).format(date);
|
|
89
|
+
} catch {
|
|
90
|
+
return `${String(date.getHours()).padStart(2, '0')}:${String(date.getMinutes()).padStart(2, '0')}`;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** "Today", "Yesterday", then a real date once it is older than that. */
|
|
95
|
+
export function formatDayLabel(dateStr, locale, labels) {
|
|
96
|
+
const date = new Date(dateStr);
|
|
97
|
+
if (Number.isNaN(date.getTime())) return '';
|
|
98
|
+
const today = startOfDay(new Date());
|
|
99
|
+
const day = startOfDay(date);
|
|
100
|
+
if (day === today) return labels.today;
|
|
101
|
+
if (today - day === 86400000) return labels.yesterday;
|
|
102
|
+
const sameYear = date.getFullYear() === new Date().getFullYear();
|
|
103
|
+
try {
|
|
104
|
+
return new Intl.DateTimeFormat(locale, {
|
|
105
|
+
day: 'numeric',
|
|
106
|
+
month: 'short',
|
|
107
|
+
...(sameYear ? {} : {
|
|
108
|
+
year: 'numeric'
|
|
109
|
+
})
|
|
110
|
+
}).format(date);
|
|
111
|
+
} catch {
|
|
112
|
+
return date.toDateString();
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
//# sourceMappingURL=conversations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["formatLabel","conversationTime","conversation","parsed","Date","parse","lastMessageAt","createdAt","Number","isNaN","sortByRecency","conversations","sort","a","b","pickRecentConversations","limit","slice","pickTeamAgents","seen","Set","agents","name","agentName","trim","key","toLowerCase","has","add","push","avatar","agentAvatar","length","formatRelativeTime","dateStr","labels","date","diffMs","now","getTime","diffMin","Math","floor","justNow","minutes","count","diffHrs","hours","diffDays","days","diffMonths","months","years","startOfDay","getFullYear","getMonth","getDate","isSameDay","formatClockTime","locale","Intl","DateTimeFormat","hour","minute","format","String","getHours","padStart","getMinutes","formatDayLabel","today","day","yesterday","sameYear","month","year","toDateString"],"sourceRoot":"../../../../src","sources":["ui/utils/conversations.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;;AAEA,SAASA,WAAW,QAAQ,eAAY;AAQxC,MAAMC,gBAAgB,GAAIC,YAA0B,IAAa;EAC/D,MAAMC,MAAM,GAAGC,IAAI,CAACC,KAAK,CAACH,YAAY,CAACI,aAAa,IAAIJ,YAAY,CAACK,SAAS,IAAI,EAAE,CAAC;EACrF,OAAOC,MAAM,CAACC,KAAK,CAACN,MAAM,CAAC,GAAG,CAAC,GAAGA,MAAM;AAC1C,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA,OAAO,SAASO,aAAaA,CAACC,aAA6B,EAAkB;EAC3E,OAAO,CAAC,GAAGA,aAAa,CAAC,CAACC,IAAI,CAAC,CAACC,CAAC,EAAEC,CAAC,KAAKb,gBAAgB,CAACa,CAAC,CA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,GAAGrC,IAAI,CAACkB,WAAW,CAAC,CAAC,KAAK,IAAIlD,IAAI,CAAC,CAAC,CAACkD,WAAW,CAAC,CAAC;EAChE,IAAI;IACF,OAAO,IAAIM,IAAI,CAACC,cAAc,CAACF,MAAM,EAAE;MACrCY,GAAG,EAAE,SAAS;MACdG,KAAK,EAAE,OAAO;MACd,IAAID,QAAQ,GAAG,CAAC,CAAC,GAAG;QAAEE,IAAI,EAAE;MAAU,CAAC;IACzC,CAAC,CAAC,CAACX,MAAM,CAAC5B,IAAI,CAAC;EACjB,CAAC,CAAC,MAAM;IACN,OAAOA,IAAI,CAACwC,YAAY,CAAC,CAAC;EAC5B;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* HTML → text helpers. The CRM stores message bodies as HTML and campaign
|
|
5
|
+
* payloads as rich text; React Native has no DOMParser, so these are the
|
|
6
|
+
* regex equivalents of the web widget's `stripHtml` / `htmlToText`.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const ENTITIES = {
|
|
10
|
+
'&': '&',
|
|
11
|
+
'<': '<',
|
|
12
|
+
'>': '>',
|
|
13
|
+
'"': '"',
|
|
14
|
+
''': "'",
|
|
15
|
+
''': "'",
|
|
16
|
+
' ': ' '
|
|
17
|
+
};
|
|
18
|
+
function decodeEntities(text) {
|
|
19
|
+
return text.replace(/&(amp|lt|gt|quot|#39|apos|nbsp);/g, match => ENTITIES[match] ?? match).replace(/&#(\d+);/g, (_match, code) => String.fromCharCode(Number(code)));
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** Block-level tags become newlines so paragraphs survive the strip. */
|
|
23
|
+
export function stripHtml(html) {
|
|
24
|
+
if (!html) return '';
|
|
25
|
+
return decodeEntities(html.replace(/<br\s*\/?>/gi, '\n').replace(/<\/(p|div|li|h[1-6]|blockquote|tr)>/gi, '\n').replace(/<li[^>]*>/gi, '• ').replace(/<[^>]+>/g, '')).replace(/\n{3,}/g, '\n\n').trim();
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Single-line flattening used for campaign cards and list snippets. */
|
|
29
|
+
export function htmlToText(html) {
|
|
30
|
+
if (!html) return '';
|
|
31
|
+
const spaced = html.replace(/<\/(p|div|li|h[1-6]|blockquote)>/gi, ' $&').replace(/<br\s*\/?>/gi, ' ');
|
|
32
|
+
return renderFallbackTokens(decodeEntities(spaced.replace(/<[^>]+>/g, ' ')).replace(/\s+/g, ' ').trim());
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** Unresolved merge tags would otherwise leak `{{ contact.firstName }}` to visitors. */
|
|
36
|
+
function renderFallbackTokens(text) {
|
|
37
|
+
return text.replace(/\{\{\s*contact\.firstName\s*\}\}/g, 'there').replace(/\{\{\s*contact\.fullName\s*\}\}/g, 'there').replace(/\{\{\s*contact\.[^}]+\s*\}\}/g, '').replace(/\s+/g, ' ').trim();
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=html.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["ENTITIES","decodeEntities","text","replace","match","_match","code","String","fromCharCode","Number","stripHtml","html","trim","htmlToText","spaced","renderFallbackTokens"],"sourceRoot":"../../../../src","sources":["ui/utils/html.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;;AAEA,MAAMA,QAAgC,GAAG;EACvC,OAAO,EAAE,GAAG;EACZ,MAAM,EAAE,GAAG;EACX,MAAM,EAAE,GAAG;EACX,QAAQ,EAAE,GAAG;EACb,OAAO,EAAE,GAAG;EACZ,QAAQ,EAAE,GAAG;EACb,QAAQ,EAAE;AACZ,CAAC;AAED,SAASC,cAAcA,CAACC,IAAY,EAAU;EAC5C,OAAOA,IAAI,CACRC,OAAO,CAAC,mCAAmC,EAAGC,KAAK,IAAKJ,QAAQ,CAACI,KAAK,CAAC,IAAIA,KAAK,CAAC,CACjFD,OAAO,CAAC,WAAW,EAA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**
|
|
4
|
+
* A real gradient when the host app happens to ship one, stacked bands when it
|
|
5
|
+
* does not.
|
|
6
|
+
*
|
|
7
|
+
* Stacked bands can only ever approximate a ramp: each strip is a solid fill,
|
|
8
|
+
* and once the strips are thin enough to hide the colour steps their heights
|
|
9
|
+
* start landing on fractional pixels, which shows up as faint seams. A native
|
|
10
|
+
* gradient has neither problem, so we use one where it exists — the same
|
|
11
|
+
* "borrow it from the host" approach as `safe-area.ts` and `storage.ts`.
|
|
12
|
+
*
|
|
13
|
+
* Resolution happens once at module load so component identity stays stable
|
|
14
|
+
* across renders.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
let nativeGradient = null;
|
|
18
|
+
try {
|
|
19
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
20
|
+
const mod = require('react-native-linear-gradient');
|
|
21
|
+
const component = mod?.default ?? mod?.LinearGradient;
|
|
22
|
+
if (component) nativeGradient = component;
|
|
23
|
+
} catch {
|
|
24
|
+
nativeGradient = null;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** Null when the host installed no gradient library; callers fall back to bands. */
|
|
28
|
+
export function getNativeGradient() {
|
|
29
|
+
return nativeGradient;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** Top-to-bottom. The only direction the band fallback can draw. */
|
|
33
|
+
export const VERTICAL = {
|
|
34
|
+
start: {
|
|
35
|
+
x: 0.5,
|
|
36
|
+
y: 0
|
|
37
|
+
},
|
|
38
|
+
end: {
|
|
39
|
+
x: 0.5,
|
|
40
|
+
y: 1
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Top-left to bottom-right, the same way round in every language. A brand
|
|
46
|
+
* ramp is a visual, not a sentence, so it does not mirror with the reading
|
|
47
|
+
* direction. Needs a native gradient: stacked bands are horizontal strips and
|
|
48
|
+
* can only ever run top to bottom.
|
|
49
|
+
*/
|
|
50
|
+
export const DIAGONAL = {
|
|
51
|
+
start: {
|
|
52
|
+
x: 0,
|
|
53
|
+
y: 0
|
|
54
|
+
},
|
|
55
|
+
end: {
|
|
56
|
+
x: 1,
|
|
57
|
+
y: 1
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
//# sourceMappingURL=native-gradient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["nativeGradient","mod","require","component","default","LinearGradient","getNativeGradient","VERTICAL","start","x","y","end","DIAGONAL"],"sourceRoot":"../../../../src","sources":["ui/utils/native-gradient.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAgBA,IAAIA,cAAyD,GAAG,IAAI;AAEpE,IAAI;EACF;EACA,MAAMC,GAAG,GAAGC,OAAO,CAAC,8BAA8B,CAAC;EACnD,MAAMC,SAAS,GAAGF,GAAG,EAAEG,OAAO,IAAIH,GAAG,EAAEI,cAAc;EACrD,IAAIF,SAAS,EAAEH,cAAc,GAAGG,SAA+C;AACjF,CAAC,CAAC,MAAM;EACNH,cAAc,GAAG,IAAI;AACvB;;AAEA;AACA,OAAO,SAASM,iBAAiBA,CAAA,EAA8C;EAC7E,OAAON,cAAc;AACvB;;AAEA;AACA,OAAO,MAAMO,QAAQ,GAAG;EACtBC,KAAK,EAAE;IAAEC,CAAC,EAAE,GAAG;IAAEC,CAAC,EAAE;EAAE,CAAC;EACvBC,GAAG,EAAE;IAAEF,CAAC,EAAE,GAAG;IAAEC,CAAC,EAAE;EAAE;AACtB,CAAU;;AAEV;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAME,QAAQ,GAAG;EACtBJ,KAAK,EAAE;IAAEC,CAAC,EAAE,CAAC;IAAEC,CAAC,EAAE;EAAE,CAAC;EACrBC,GAAG,EAAE;IAAEF,CAAC,EAAE,CAAC;IAAEC,CAAC,EAAE;EAAE;AACpB,CAAU","ignoreList":[]}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Right-to-left helpers.
|
|
5
|
+
*
|
|
6
|
+
* Yoga mirrors `flexDirection: 'row'`, `flex-start`/`flex-end` and the
|
|
7
|
+
* `start`/`end` style props on its own once the host app has turned RTL on.
|
|
8
|
+
* What it cannot mirror is meaning: an arrow that points "forward" is drawn
|
|
9
|
+
* rightwards in English and leftwards in Arabic, and a bubble's tail corner
|
|
10
|
+
* swaps sides with it. Those decisions live here.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { I18nManager } from 'react-native';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Text alignment follows the LAYOUT's direction, not the script's. Left to
|
|
17
|
+
* itself, a Latin string inside an Arabic screen renders hard against the
|
|
18
|
+
* left edge while everything around it is anchored right, which reads as a
|
|
19
|
+
* broken row rather than as mixed content.
|
|
20
|
+
*
|
|
21
|
+
* Read once at module load: switching direction requires an app restart.
|
|
22
|
+
*/
|
|
23
|
+
export const START_ALIGN = I18nManager.isRTL ? 'right' : 'left';
|
|
24
|
+
export function isRTL() {
|
|
25
|
+
return I18nManager.isRTL;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Deeper into the app: a disclosure chevron, a "continue" arrow. */
|
|
29
|
+
export function forwardDirection() {
|
|
30
|
+
return I18nManager.isRTL ? 'left' : 'right';
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** Back out of the current screen. */
|
|
34
|
+
export function backDirection() {
|
|
35
|
+
return I18nManager.isRTL ? 'right' : 'left';
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Mirrors a glyph that is drawn pointing right. Cheaper and less error-prone
|
|
40
|
+
* than maintaining a second set of geometry for every directional icon.
|
|
41
|
+
*/
|
|
42
|
+
export function flipForRTL() {
|
|
43
|
+
return I18nManager.isRTL ? {
|
|
44
|
+
transform: [{
|
|
45
|
+
scaleX: -1
|
|
46
|
+
}]
|
|
47
|
+
} : undefined;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=rtl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["I18nManager","START_ALIGN","isRTL","forwardDirection","backDirection","flipForRTL","transform","scaleX","undefined"],"sourceRoot":"../../../../src","sources":["ui/utils/rtl.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,WAAW,QAAQ,cAAc;;AAE1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,WAA6B,GAAGD,WAAW,CAACE,KAAK,GAAG,OAAO,GAAG,MAAM;AAEjF,OAAO,SAASA,KAAKA,CAAA,EAAY;EAC/B,OAAOF,WAAW,CAACE,KAAK;AAC1B;;AAEA;AACA,OAAO,SAASC,gBAAgBA,CAAA,EAAqB;EACnD,OAAOH,WAAW,CAACE,KAAK,GAAG,MAAM,GAAG,OAAO;AAC7C;;AAEA;AACA,OAAO,SAASE,aAAaA,CAAA,EAAqB;EAChD,OAAOJ,WAAW,CAACE,KAAK,GAAG,OAAO,GAAG,MAAM;AAC7C;;AAEA;AACA;AACA;AACA;AACA,OAAO,SAASG,UAAUA,CAAA,EAAoD;EAC5E,OAAOL,WAAW,CAACE,KAAK,GAAG;IAAEI,SAAS,EAAE,CAAC;MAAEC,MAAM,EAAE,CAAC;IAAE,CAAC;EAAE,CAAC,GAAGC,SAAS;AACxE","ignoreList":[]}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The one gate every widget link goes through before `Linking.openURL`.
|
|
5
|
+
*
|
|
6
|
+
* Agent and AI replies, campaign CTAs and attachment URLs are remote content.
|
|
7
|
+
* Opened blindly they could fire the host app's own deep links
|
|
8
|
+
* (`myapp://transfer?…`), Android `intent:` URLs, `sms:` or `file:` URIs. Only
|
|
9
|
+
* web, mail and phone links open by default; the host can route anything else
|
|
10
|
+
* itself through `boot({ onOpenUrl })`.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { Linking } from 'react-native';
|
|
14
|
+
const ALLOWED_SCHEMES = new Set(['https:', 'http:', 'mailto:', 'tel:']);
|
|
15
|
+
|
|
16
|
+
// eslint-disable-next-line no-control-regex
|
|
17
|
+
const CONTROL_CHARS = /[\u0000-\u001F\u007F]/;
|
|
18
|
+
let hostHandler = null;
|
|
19
|
+
|
|
20
|
+
/** Set from `boot({ onOpenUrl })`; `null` restores the default policy. */
|
|
21
|
+
export function setOpenUrlHandler(handler) {
|
|
22
|
+
hostHandler = handler;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** Lower-cased scheme including the colon (`'https:'`), or null when relative. */
|
|
26
|
+
export function urlScheme(url) {
|
|
27
|
+
const match = /^([a-z][a-z0-9+.-]*):/i.exec(url);
|
|
28
|
+
return match ? `${match[1].toLowerCase()}:` : null;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** Absolute `http(s)://host…` — the only shape media URLs may take. */
|
|
32
|
+
export function isHttpUrl(url) {
|
|
33
|
+
return !CONTROL_CHARS.test(url) && /^https?:\/\/[^/\s]/i.test(url);
|
|
34
|
+
}
|
|
35
|
+
export function isSafeExternalUrl(url) {
|
|
36
|
+
if (!url || CONTROL_CHARS.test(url)) return false;
|
|
37
|
+
const scheme = urlScheme(url);
|
|
38
|
+
if (!scheme || !ALLOWED_SCHEMES.has(scheme)) return false;
|
|
39
|
+
return scheme === 'http:' || scheme === 'https:' ? isHttpUrl(url) : true;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** Host handler first, then the allow-list. Never throws. */
|
|
43
|
+
export async function openExternalUrl(url) {
|
|
44
|
+
const target = (url ?? '').trim();
|
|
45
|
+
if (!target) return;
|
|
46
|
+
if (hostHandler) {
|
|
47
|
+
try {
|
|
48
|
+
if (await hostHandler(target)) return;
|
|
49
|
+
} catch (error) {
|
|
50
|
+
console.warn('[repzo-widget] onOpenUrl threw — falling back to the default policy', error);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
if (!isSafeExternalUrl(target)) {
|
|
54
|
+
console.warn(`[repzo-widget] blocked a link with a disallowed scheme (${urlScheme(target) ?? 'none'})`);
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
Linking.openURL(target).catch(() => {});
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=safe-url.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Linking","ALLOWED_SCHEMES","Set","CONTROL_CHARS","hostHandler","setOpenUrlHandler","handler","urlScheme","url","match","exec","toLowerCase","isHttpUrl","test","isSafeExternalUrl","scheme","has","openExternalUrl","target","trim","error","console","warn","openURL","catch"],"sourceRoot":"../../../../src","sources":["ui/utils/safe-url.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,OAAO,QAAQ,cAAc;AAItC,MAAMC,eAAe,GAAG,IAAIC,GAAG,CAAC,CAAC,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;;AAEvE;AACA,MAAMC,aAAa,GAAG,uBAAuB;AAE7C,IAAIC,WAAkC,GAAG,IAAI;;AAE7C;AACA,OAAO,SAASC,iBAAiBA,CAACC,OAA8B,EAAQ;EACtEF,WAAW,GAAGE,OAAO;AACvB;;AAEA;AACA,OAAO,SAASC,SAASA,CAACC,GAAW,EAAiB;EACpD,MAAMC,KAAK,GAAG,wBAAwB,CAACC,IAAI,CAACF,GAAG,CAAC;EAChD,OAAOC,KAAK,GAAG,GAAGA,KAAK,CAAC,CAAC,CAAC,CAACE,WAAW,CAAC,CAAC,GAAG,GAAG,IAAI;AACpD;;AAEA;AACA,OAAO,SAASC,SAASA,CAACJ,GAAW,EAAW;EAC9C,OAAO,CAACL,aAAa,CAACU,IAAI,CAACL,GAAG,CAAC,IAAI,qBAAqB,CAACK,IAAI,CAACL,GAAG,CAAC;AACpE;AAEA,OAAO,SAASM,iBAAiBA,CAACN,GAAW,EAAW;EACtD,IAAI,CAACA,GAAG,IAAIL,aAAa,CAACU,IAAI,CAACL,GAAG,CAAC,EAAE,OAAO,KAAK;EACjD,MAAMO,MAAM,GAAGR,SAAS,CAACC,GAAG,CAAC;EAC7B,IAAI,CAACO,MAAM,IAAI,CAACd,eAAe,CAACe,GAAG,CAACD,MAAM,CAAC,EAAE,OAAO,KAAK;EACzD,OAAOA,MAAM,KAAK,OAAO,IAAIA,MAAM,KAAK,QAAQ,GAAGH,SAAS,CAACJ,GAAG,CAAC,GAAG,IAAI;AAC1E;;AAEA;AACA,OAAO,eAAeS,eAAeA,CAACT,GAA8B,EAAiB;EACnF,MAAMU,MAAM,GAAG,CAACV,GAAG,IAAI,EAAE,EAAEW,IAAI,CAAC,CAAC;EACjC,IAAI,CAACD,MAAM,EAAE;EAEb,IAAId,WAAW,EAAE;IACf,IAAI;MACF,IAAI,MAAMA,WAAW,CAACc,MAAM,CAAC,EAAE;IACjC,CAAC,CAAC,OAAOE,KAAK,EAAE;MACdC,OAAO,CAACC,IAAI,CAAC,qEAAqE,EAAEF,KAAK,CAAC;IAC5F;EACF;EAEA,IAAI,CAACN,iBAAiB,CAACI,MAAM,CAAC,EAAE;IAC9BG,OAAO,CAACC,IAAI,CAAC,2DAA2Df,SAAS,CAACW,MAAM,CAAC,IAAI,MAAM,GAAG,CAAC;IACvG;EACF;EACAlB,OAAO,CAACuB,OAAO,CAACL,MAAM,CAAC,CAACM,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;AACzC","ignoreList":[]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Structural parsing for agent-authored UI blocks.
|
|
3
|
+
*
|
|
4
|
+
* The CRM validates these with zod (`shared/agent-ui-blocks.ts`) before
|
|
5
|
+
* broadcasting, so this side only needs to reject malformed payloads rather
|
|
6
|
+
* than re-implement the schema — which keeps the SDK dependency-free. Action
|
|
7
|
+
* message formatting is copied verbatim so the transcript reads the same on
|
|
8
|
+
* web and mobile.
|
|
9
|
+
*/
|
|
10
|
+
import type { AgentUiAction, AgentUiBlock, AgentProcedureForm } from './types';
|
|
11
|
+
/**
|
|
12
|
+
* Drops blocks this SDK version does not know how to render, or whose fields
|
|
13
|
+
* don't match what the renderer reads. Optional lists the server may omit
|
|
14
|
+
* come back as empty arrays.
|
|
15
|
+
*/
|
|
16
|
+
export declare function parseAgentUiBlocks(value: unknown): AgentUiBlock[];
|
|
17
|
+
export declare function getAgentUiBlocks(metadata: Record<string, unknown> | null | undefined): AgentUiBlock[];
|
|
18
|
+
export declare function getProcedureForm(metadata: Record<string, unknown> | null | undefined): AgentProcedureForm | null;
|
|
19
|
+
export declare function formatAgentUiActionMessage(action: AgentUiAction): string;
|
|
20
|
+
//# sourceMappingURL=agent-ui-blocks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-ui-blocks.d.ts","sourceRoot":"","sources":["../../../src/agent-ui-blocks.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAgM/E;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,YAAY,EAAE,CAmBjE;AAED,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,GAAG,SAAS,kBAGpF;AAED,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,GAAG,SAAS,GACnD,kBAAkB,GAAG,IAAI,CAiB3B;AAED,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,CA+CxE"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fetch client for `/api/widget/*`.
|
|
3
|
+
*
|
|
4
|
+
* Ported from the web widget's `client/src/widget/lib/api.ts`, with
|
|
5
|
+
* localStorage swapped for the storage adapter and EventSource moved to
|
|
6
|
+
* `api/realtime.ts`. Visitor tokens live up to 14 days with no refresh, so a
|
|
7
|
+
* 401 triggers one silent re-init + retry (single-flight, owned by the store).
|
|
8
|
+
* The token itself lives in `SecureStorage`.
|
|
9
|
+
*/
|
|
10
|
+
import type { AgentUiAction, Conversation, InitResponse, Message, OutboundMessage, RepzoWidgetErrorCode, WidgetAttachment, WidgetConfig, WidgetUser } from '../types';
|
|
11
|
+
export declare function isTerminalErrorCode(code: string | null | undefined): boolean;
|
|
12
|
+
export declare class RepzoWidgetError extends Error {
|
|
13
|
+
readonly status: number;
|
|
14
|
+
readonly code: RepzoWidgetErrorCode;
|
|
15
|
+
constructor(message: string, status: number, code?: RepzoWidgetErrorCode);
|
|
16
|
+
/** Builds the error for a non-2xx `{ message, code }` body. */
|
|
17
|
+
static fromResponse(status: number, body: unknown): RepzoWidgetError;
|
|
18
|
+
}
|
|
19
|
+
export declare class WidgetApiClient {
|
|
20
|
+
private baseUrl;
|
|
21
|
+
private channelAccountId;
|
|
22
|
+
private token;
|
|
23
|
+
private tokenLoaded;
|
|
24
|
+
/**
|
|
25
|
+
* Set by the store: given the token that just got a 401, returns a valid
|
|
26
|
+
* token (fresh, or one another caller already minted), or null.
|
|
27
|
+
*/
|
|
28
|
+
reauthorize: ((failedToken: string | null) => Promise<string | null>) | null;
|
|
29
|
+
/** Set by the store: a 403 with a terminal `code` came back from any endpoint. */
|
|
30
|
+
onTerminalError: ((error: RepzoWidgetError) => void) | null;
|
|
31
|
+
configure(baseUrl: string, channelAccountId: string): void;
|
|
32
|
+
getBaseUrl(): string;
|
|
33
|
+
getChannelAccountId(): string;
|
|
34
|
+
getToken(): Promise<string | null>;
|
|
35
|
+
setToken(token: string): Promise<void>;
|
|
36
|
+
clearToken(): Promise<void>;
|
|
37
|
+
/**
|
|
38
|
+
* Absolute URL for a server media path (avatars, attachments). Only ever
|
|
39
|
+
* returns `http(s)` — relative paths resolve against `baseUrl`; any other
|
|
40
|
+
* scheme (`file:`, `data:`, `intent:`, host deep links…) yields null.
|
|
41
|
+
*/
|
|
42
|
+
resolveUrl(url: string | null | undefined): string | null;
|
|
43
|
+
private request;
|
|
44
|
+
/** Public config. `platform` makes the server apply the Mobile SDKs overrides. */
|
|
45
|
+
getConfig(platform?: 'ios' | 'android' | 'web'): Promise<WidgetConfig>;
|
|
46
|
+
getOutboundMessage(): Promise<{
|
|
47
|
+
message: OutboundMessage | null;
|
|
48
|
+
}>;
|
|
49
|
+
/**
|
|
50
|
+
* Does NOT store the returned token — the store persists it only once it
|
|
51
|
+
* knows the identity op that asked for it is still current.
|
|
52
|
+
*/
|
|
53
|
+
init(params: {
|
|
54
|
+
user?: WidgetUser;
|
|
55
|
+
trackingVisitorId?: string;
|
|
56
|
+
platform?: string;
|
|
57
|
+
sdkVersion?: string;
|
|
58
|
+
/** False for fresh sessions — never resume another identity's token. */
|
|
59
|
+
resumeToken?: boolean;
|
|
60
|
+
}): Promise<InitResponse>;
|
|
61
|
+
/** Revokes `token` server-side. A 401 means it was already dead — fine. */
|
|
62
|
+
logout(token: string): Promise<void>;
|
|
63
|
+
sendMessage(data: {
|
|
64
|
+
conversationId?: string;
|
|
65
|
+
forceNewConversation?: boolean;
|
|
66
|
+
body: string;
|
|
67
|
+
attachments?: WidgetAttachment[];
|
|
68
|
+
visitorName?: string;
|
|
69
|
+
visitorEmail?: string;
|
|
70
|
+
agentUiAction?: AgentUiAction;
|
|
71
|
+
}): Promise<{
|
|
72
|
+
messageId: string;
|
|
73
|
+
conversationId: string;
|
|
74
|
+
isNewConversation: boolean;
|
|
75
|
+
}>;
|
|
76
|
+
listConversations(): Promise<{
|
|
77
|
+
data: Conversation[];
|
|
78
|
+
}>;
|
|
79
|
+
listMessages(conversationId: string, cursor?: string | null): Promise<{
|
|
80
|
+
data: Message[];
|
|
81
|
+
meta: {
|
|
82
|
+
hasMore: boolean;
|
|
83
|
+
nextCursor: string | null;
|
|
84
|
+
};
|
|
85
|
+
}>;
|
|
86
|
+
/**
|
|
87
|
+
* Advances the visitor's read cursor for a thread they're watching live.
|
|
88
|
+
* Best effort and `skipReauth`: a burst of live replies must never turn an
|
|
89
|
+
* expired token into a burst of re-inits.
|
|
90
|
+
*/
|
|
91
|
+
markConversationRead(conversationId: string): Promise<void>;
|
|
92
|
+
identify(data: {
|
|
93
|
+
email?: string;
|
|
94
|
+
name?: string;
|
|
95
|
+
phone?: string;
|
|
96
|
+
customAttributes?: Record<string, string | number | boolean>;
|
|
97
|
+
}): Promise<void>;
|
|
98
|
+
sendTyping(conversationId: string, isTyping: boolean): Promise<void>;
|
|
99
|
+
trackEvent(data: {
|
|
100
|
+
event: string;
|
|
101
|
+
visitorId?: string | null;
|
|
102
|
+
metadata?: Record<string, unknown>;
|
|
103
|
+
}): Promise<void>;
|
|
104
|
+
registerPushToken(data: {
|
|
105
|
+
token: string;
|
|
106
|
+
platform: string;
|
|
107
|
+
bundleId?: string;
|
|
108
|
+
}): Promise<void>;
|
|
109
|
+
/** Logout passes the session's token explicitly and `skipReauth`. */
|
|
110
|
+
removePushToken(token: string, auth?: {
|
|
111
|
+
authToken?: string | null;
|
|
112
|
+
skipReauth?: boolean;
|
|
113
|
+
}): Promise<void>;
|
|
114
|
+
}
|
|
115
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../src/api/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,KAAK,EACV,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,OAAO,EACP,eAAe,EACf,oBAAoB,EACpB,gBAAgB,EAChB,YAAY,EACZ,UAAU,EACX,MAAM,UAAU,CAAC;AASlB,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG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,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAO3D,QAAQ,CAAC,IAAI,EAAE;QACb,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC;KAC9D,GAAG,OAAO,CAAC,IAAI,CAAC;IAIjB,UAAU,CAAC,cAAc,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAOpE,UAAU,CAAC,IAAI,EAAE;QACf,KAAK,EAAE,MAAM,CAAC;QACd,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KACpC,GAAG,OAAO,CAAC,IAAI,CAAC;IAOjB,iBAAiB,CAAC,IAAI,EAAE;QACtB,KAAK,EAAE,MAAM,CAAC;QACd,QAAQ,EAAE,MAAM,CAAC;QACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,GAAG,OAAO,CAAC,IAAI,CAAC;IAIjB,qEAAqE;IACrE,eAAe,CACb,KAAK,EAAE,MAAM,EACb,IAAI,GAAE;QAAE,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,UAAU,CAAC,EAAE,OAAO,CAAA;KAAO,GAC7D,OAAO,CAAC,IAAI,CAAC;CAOjB"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SSE transport over `GET /api/widget/sse`, authenticated with an
|
|
3
|
+
* `Authorization: Bearer` header (never the query string, which ends up in
|
|
4
|
+
* proxy and server access logs).
|
|
5
|
+
*
|
|
6
|
+
* Uses React Native's streaming XMLHttpRequest and handles both network
|
|
7
|
+
* failures and successful stream EOF with exponential reconnect backoff.
|
|
8
|
+
* Auth failures never retry here: 401 hands over to the store's re-init,
|
|
9
|
+
* while 403 is terminal.
|
|
10
|
+
*/
|
|
11
|
+
import type { WidgetRealtimeEvent } from '../types';
|
|
12
|
+
import { RepzoWidgetError } from './client';
|
|
13
|
+
export type RealtimeHandler = (event: WidgetRealtimeEvent, data: any) => void;
|
|
14
|
+
export interface RealtimeAuthHooks {
|
|
15
|
+
/** 401: the token expired or was revoked. The stream stays closed. */
|
|
16
|
+
onUnauthorized(token: string): void;
|
|
17
|
+
/** 403 (e.g. `messenger_api_disabled`): terminal, the stream stays closed. */
|
|
18
|
+
onForbidden(error: RepzoWidgetError): void;
|
|
19
|
+
}
|
|
20
|
+
export declare class WidgetRealtime {
|
|
21
|
+
private source;
|
|
22
|
+
private connected;
|
|
23
|
+
private reconnectTimer;
|
|
24
|
+
private attempt;
|
|
25
|
+
private closedByUs;
|
|
26
|
+
private url;
|
|
27
|
+
private token;
|
|
28
|
+
private handler;
|
|
29
|
+
private authHooks;
|
|
30
|
+
private authErrorTimer;
|
|
31
|
+
connect(baseUrl: string, token: string, handler: RealtimeHandler, authHooks?: RealtimeAuthHooks): void;
|
|
32
|
+
private open;
|
|
33
|
+
private handleAuthError;
|
|
34
|
+
private scheduleReconnect;
|
|
35
|
+
private teardownSource;
|
|
36
|
+
get isConnected(): boolean;
|
|
37
|
+
close(): void;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=realtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"realtime.d.ts","sourceRoot":"","sources":["../../../../src/api/realtime.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAsB5C,MAAM,MAAM,eAAe,GAAG,CAAC,KAAK,EAAE,mBAAmB,EAAE,IAAI,EAAE,GAAG,KAAK,IAAI,CAAC;AAE9E,MAAM,WAAW,iBAAiB;IAChC,sEAAsE;IACtE,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC,8EAA8E;IAC9E,WAAW,CAAC,KAAK,EAAE,gBAAgB,GAAG,IAAI,CAAC;CAC5C;AAED,qBAAa,cAAc;IACzB,OAAO,CAAC,MAAM,CAA+B;IAE7C,OAAO,CAAC,SAAS,CAAS;IAE1B,OAAO,CAAC,cAAc,CAA8C;IAEpE,OAAO,CAAC,OAAO,CAAK;IAEpB,OAAO,CAAC,UAAU,CAAS;IAE3B,OAAO,CAAC,GAAG,CAAuB;IAElC,OAAO,CAAC,KAAK,CAAuB;IAEpC,OAAO,CAAC,OAAO,CAAgC;IAE/C,OAAO,CAAC,SAAS,CAAkC;IAEnD,OAAO,CAAC,cAAc,CAA8C;IAEpE,OAAO,CACL,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,eAAe,EACxB,SAAS,CAAC,EAAE,iBAAiB,GAC5B,IAAI;IAUP,OAAO,CAAC,IAAI;IAyEZ,OAAO,CAAC,eAAe;IAmBvB,OAAO,CAAC,iBAAiB;IAiBzB,OAAO,CAAC,cAAc;IAiBtB,IAAI,WAAW,IAAI,OAAO,CAIzB;IAED,KAAK,IAAI,IAAI;CAad"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** Incremental SSE framing. A blank line dispatches an event; EOF alone does not. */
|
|
2
|
+
export declare class SseParser {
|
|
3
|
+
private readonly dispatch;
|
|
4
|
+
private line;
|
|
5
|
+
private event;
|
|
6
|
+
private data;
|
|
7
|
+
private afterCR;
|
|
8
|
+
private atStart;
|
|
9
|
+
constructor(dispatch: (event: string, data: string) => void);
|
|
10
|
+
push(chunk: string): void;
|
|
11
|
+
private readLine;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=sse-parser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sse-parser.d.ts","sourceRoot":"","sources":["../../../../src/api/sse-parser.ts"],"names":[],"mappings":"AAAA,qFAAqF;AACrF,qBAAa,SAAS;IAOR,OAAO,CAAC,QAAQ,CAAC,QAAQ;IANrC,OAAO,CAAC,IAAI,CAAM;IAClB,OAAO,CAAC,KAAK,CAAM;IACnB,OAAO,CAAC,IAAI,CAAgB;IAC5B,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,OAAO,CAAQ;gBAEM,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,IAAI;IAE5E,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAqBzB,OAAO,CAAC,QAAQ;CAmBjB"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Process-wide singleton that owns the store (and therefore the session, the
|
|
3
|
+
* SSE stream and the unread count). Imperative API calls land here whether or
|
|
4
|
+
* not `<RepzoWidgetProvider>` is mounted; the provider is a pure subscriber, so
|
|
5
|
+
* commands issued before boot finishes simply land in state and render once the
|
|
6
|
+
* provider mounts.
|
|
7
|
+
*/
|
|
8
|
+
import { WidgetStore } from './state/widget-store';
|
|
9
|
+
declare class RepzoWidgetController {
|
|
10
|
+
readonly store: WidgetStore;
|
|
11
|
+
get events(): import("./events").EventEmitter;
|
|
12
|
+
}
|
|
13
|
+
export declare const controller: RepzoWidgetController;
|
|
14
|
+
export type { RepzoWidgetController };
|
|
15
|
+
//# sourceMappingURL=controller.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../../src/controller.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD,cAAM,qBAAqB;IACzB,QAAQ,CAAC,KAAK,cAAqB;IAEnC,IAAI,MAAM,oCAET;CACF;AAED,eAAO,MAAM,UAAU,uBAA8B,CAAC;AACtD,YAAY,EAAE,qBAAqB,EAAE,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-install id sent as `trackingVisitorId`. This is the mobile equivalent of
|
|
3
|
+
* the web widget's `repzo_vid` cookie: it lets the CRM stitch an anonymous
|
|
4
|
+
* visitor back together if the session token is ever lost. Stable until
|
|
5
|
+
* `logout()`, which rotates it.
|
|
6
|
+
*/
|
|
7
|
+
export declare function getDeviceId(): Promise<string>;
|
|
8
|
+
/** Only used by tests and `rotateDeviceId()`. */
|
|
9
|
+
export declare function resetDeviceIdCache(): void;
|
|
10
|
+
/**
|
|
11
|
+
* Called by `logout()`: the id stitches anonymous sessions together, so on a
|
|
12
|
+
* shared device the next visitor must not inherit the previous user's.
|
|
13
|
+
*/
|
|
14
|
+
export declare function rotateDeviceId(): Promise<void>;
|
|
15
|
+
//# sourceMappingURL=device-id.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"device-id.d.ts","sourceRoot":"","sources":["../../../src/device-id.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAsCH,wBAAsB,WAAW,IAAI,OAAO,CAAC,MAAM,CAAC,CAanD;AAED,iDAAiD;AACjD,wBAAgB,kBAAkB,IAAI,IAAI,CAEzC;AAED;;;GAGG;AACH,wBAAsB,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC,CAGpD"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tiny typed event emitter. Pure JS — no NativeEventEmitter, so listeners work
|
|
3
|
+
* identically on iOS, Android and in tests.
|
|
4
|
+
*/
|
|
5
|
+
import type { Conversation, Message } from './types';
|
|
6
|
+
export declare const RepzoWidgetEvents: {
|
|
7
|
+
readonly UnreadCountDidChange: "repzoWidget.unreadCountDidChange";
|
|
8
|
+
readonly MessageDidArrive: "repzoWidget.messageDidArrive";
|
|
9
|
+
/** The visitor opened a thread — hosts use it to dismiss that conversation's push notification. */
|
|
10
|
+
readonly ConversationDidRead: "repzoWidget.conversationDidRead";
|
|
11
|
+
readonly WindowDidShow: "repzoWidget.windowDidShow";
|
|
12
|
+
readonly WindowDidHide: "repzoWidget.windowDidHide";
|
|
13
|
+
};
|
|
14
|
+
export type RepzoWidgetEvent = (typeof RepzoWidgetEvents)[keyof typeof RepzoWidgetEvents];
|
|
15
|
+
export interface MessageDidArrivePayload {
|
|
16
|
+
conversationId: string;
|
|
17
|
+
message: Message;
|
|
18
|
+
/** Null when the reply lands before this device has listed the thread. */
|
|
19
|
+
conversation: Conversation | null;
|
|
20
|
+
}
|
|
21
|
+
export interface RepzoWidgetEventPayloads {
|
|
22
|
+
[RepzoWidgetEvents.UnreadCountDidChange]: {
|
|
23
|
+
count: number;
|
|
24
|
+
};
|
|
25
|
+
[RepzoWidgetEvents.MessageDidArrive]: MessageDidArrivePayload;
|
|
26
|
+
[RepzoWidgetEvents.ConversationDidRead]: {
|
|
27
|
+
conversationId: string;
|
|
28
|
+
};
|
|
29
|
+
[RepzoWidgetEvents.WindowDidShow]: undefined;
|
|
30
|
+
[RepzoWidgetEvents.WindowDidHide]: undefined;
|
|
31
|
+
}
|
|
32
|
+
export interface EventSubscription {
|
|
33
|
+
remove(): void;
|
|
34
|
+
}
|
|
35
|
+
export declare class EventEmitter {
|
|
36
|
+
private listeners;
|
|
37
|
+
addListener<E extends RepzoWidgetEvent>(event: E, listener: (payload: RepzoWidgetEventPayloads[E]) => void): EventSubscription;
|
|
38
|
+
emit<E extends RepzoWidgetEvent>(event: E, payload: RepzoWidgetEventPayloads[E]): void;
|
|
39
|
+
removeAllListeners(): void;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=events.d.ts.map
|