@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/storage.ts
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Storage adapters.
|
|
3
|
+
*
|
|
4
|
+
* `Storage` (device id, unread counts, cached theme) resolves: an adapter
|
|
5
|
+
* injected via `RepzoWidget.setStorageAdapter()`, then
|
|
6
|
+
* `@react-native-async-storage/async-storage` if the host app installed it,
|
|
7
|
+
* then an in-memory map. The in-memory fallback keeps the SDK working (the
|
|
8
|
+
* session just doesn't survive a relaunch) instead of crashing.
|
|
9
|
+
*
|
|
10
|
+
* `SecureStorage` (visitor token, user key) uses the adapter injected via
|
|
11
|
+
* `RepzoWidget.setSecureStorageAdapter()` — Keychain/Keystore backed — and
|
|
12
|
+
* falls back to `Storage` when the host provided none. AsyncStorage is
|
|
13
|
+
* plaintext on disk, so the bearer token belongs in the secure one.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import type { RepzoWidgetStorageAdapter } from './types';
|
|
17
|
+
|
|
18
|
+
export const TOKEN_KEY = 'repzo_widget_token';
|
|
19
|
+
/** Identity key (email/userId) the stored token was issued to; absent = anonymous. */
|
|
20
|
+
export const USER_KEY = 'repzo_widget_user_key';
|
|
21
|
+
export const DEVICE_ID_KEY = 'repzo_widget_device_id';
|
|
22
|
+
export const UNREAD_KEY = 'repzo_widget_unread';
|
|
23
|
+
/** Last config received — repaints the real theme instantly on relaunch. */
|
|
24
|
+
/**
|
|
25
|
+
* v2 wraps the config with the channel/baseUrl/platform it came from. v1 held a
|
|
26
|
+
* bare config that a foreground refresh could overwrite with the web design,
|
|
27
|
+
* so it's ignored (and cleared) rather than painted.
|
|
28
|
+
*/
|
|
29
|
+
export const CONFIG_KEY = 'repzo_widget_config_v2';
|
|
30
|
+
export const LEGACY_CONFIG_KEY = 'repzo_widget_config';
|
|
31
|
+
|
|
32
|
+
function createMemoryAdapter(): RepzoWidgetStorageAdapter {
|
|
33
|
+
const map = new Map<string, string>();
|
|
34
|
+
return {
|
|
35
|
+
getItem: (key) => map.get(key) ?? null,
|
|
36
|
+
setItem: (key, value) => {
|
|
37
|
+
map.set(key, value);
|
|
38
|
+
},
|
|
39
|
+
removeItem: (key) => {
|
|
40
|
+
map.delete(key);
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function resolveAsyncStorage(): RepzoWidgetStorageAdapter | null {
|
|
46
|
+
try {
|
|
47
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires, global-require
|
|
48
|
+
const mod = require('@react-native-async-storage/async-storage');
|
|
49
|
+
const asyncStorage = mod?.default ?? mod;
|
|
50
|
+
if (!asyncStorage?.getItem) return null;
|
|
51
|
+
return {
|
|
52
|
+
getItem: (key) => asyncStorage.getItem(key),
|
|
53
|
+
setItem: (key, value) => asyncStorage.setItem(key, value),
|
|
54
|
+
removeItem: (key) => asyncStorage.removeItem(key),
|
|
55
|
+
};
|
|
56
|
+
} catch {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const memoryAdapter = createMemoryAdapter();
|
|
62
|
+
let injectedAdapter: RepzoWidgetStorageAdapter | null = null;
|
|
63
|
+
let detectedAdapter: RepzoWidgetStorageAdapter | null | undefined;
|
|
64
|
+
|
|
65
|
+
function activeAdapter(): RepzoWidgetStorageAdapter {
|
|
66
|
+
if (injectedAdapter) return injectedAdapter;
|
|
67
|
+
if (detectedAdapter === undefined) detectedAdapter = resolveAsyncStorage();
|
|
68
|
+
return detectedAdapter ?? memoryAdapter;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export function setStorageAdapter(adapter: RepzoWidgetStorageAdapter | null): void {
|
|
72
|
+
injectedAdapter = adapter;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export const Storage = {
|
|
76
|
+
async getItem(key: string): Promise<string | null> {
|
|
77
|
+
try {
|
|
78
|
+
return (await activeAdapter().getItem(key)) ?? null;
|
|
79
|
+
} catch (error) {
|
|
80
|
+
console.warn('[repzo-widget] storage read failed', error);
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
|
|
85
|
+
async setItem(key: string, value: string): Promise<void> {
|
|
86
|
+
try {
|
|
87
|
+
await activeAdapter().setItem(key, value);
|
|
88
|
+
} catch (error) {
|
|
89
|
+
console.warn('[repzo-widget] storage write failed', error);
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
|
|
93
|
+
async removeItem(key: string): Promise<void> {
|
|
94
|
+
try {
|
|
95
|
+
await activeAdapter().removeItem(key);
|
|
96
|
+
} catch (error) {
|
|
97
|
+
console.warn('[repzo-widget] storage delete failed', error);
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
let secureAdapter: RepzoWidgetStorageAdapter | null = null;
|
|
103
|
+
|
|
104
|
+
export function setSecureStorageAdapter(adapter: RepzoWidgetStorageAdapter | null): void {
|
|
105
|
+
secureAdapter = adapter;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export const SecureStorage = {
|
|
109
|
+
async getItem(key: string): Promise<string | null> {
|
|
110
|
+
if (!secureAdapter) return Storage.getItem(key);
|
|
111
|
+
try {
|
|
112
|
+
const value = (await secureAdapter.getItem(key)) ?? null;
|
|
113
|
+
if (value !== null) return value;
|
|
114
|
+
} catch (error) {
|
|
115
|
+
console.warn('[repzo-widget] secure storage read failed', error);
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
// One-time migration: a session written before the host added a secure
|
|
119
|
+
// adapter moves out of plaintext storage on first read.
|
|
120
|
+
const legacy = await Storage.getItem(key);
|
|
121
|
+
if (legacy !== null) {
|
|
122
|
+
await SecureStorage.setItem(key, legacy);
|
|
123
|
+
}
|
|
124
|
+
return legacy;
|
|
125
|
+
},
|
|
126
|
+
|
|
127
|
+
async setItem(key: string, value: string): Promise<void> {
|
|
128
|
+
if (!secureAdapter) {
|
|
129
|
+
await Storage.setItem(key, value);
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
try {
|
|
133
|
+
await secureAdapter.setItem(key, value);
|
|
134
|
+
} catch (error) {
|
|
135
|
+
// Deliberately no plaintext fallback: the value stays in memory only,
|
|
136
|
+
// so the session lasts until the app is killed.
|
|
137
|
+
console.warn('[repzo-widget] secure storage write failed', error);
|
|
138
|
+
}
|
|
139
|
+
await Storage.removeItem(key);
|
|
140
|
+
},
|
|
141
|
+
|
|
142
|
+
/** Clears both stores, so a pre-migration plaintext copy can't linger. */
|
|
143
|
+
async removeItem(key: string): Promise<void> {
|
|
144
|
+
if (secureAdapter) {
|
|
145
|
+
try {
|
|
146
|
+
await secureAdapter.removeItem(key);
|
|
147
|
+
} catch (error) {
|
|
148
|
+
console.warn('[repzo-widget] secure storage delete failed', error);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
await Storage.removeItem(key);
|
|
152
|
+
},
|
|
153
|
+
};
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,445 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wire + UI types for the Repzo widget.
|
|
3
|
+
*
|
|
4
|
+
* Shapes mirror the CRM widget API (`/api/widget/*`) and the web widget's
|
|
5
|
+
* `client/src/widget/lib/api.ts` — keep them in sync so agent-authored
|
|
6
|
+
* metadata (agentUiBlocks / agentProcedureForm) renders identically.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export type WidgetSpaceType = 'home' | 'messages';
|
|
10
|
+
|
|
11
|
+
export interface WidgetSpace {
|
|
12
|
+
type: WidgetSpaceType;
|
|
13
|
+
enabled: boolean;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface PreChatField {
|
|
17
|
+
name: string;
|
|
18
|
+
label: string;
|
|
19
|
+
type: 'text' | 'email' | 'phone' | 'select';
|
|
20
|
+
required: boolean;
|
|
21
|
+
options?: string[];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface WidgetConfig {
|
|
25
|
+
primaryColor: string;
|
|
26
|
+
homeLogoUrl: string | null;
|
|
27
|
+
homeBackgroundType: 'solid' | 'gradient' | 'image';
|
|
28
|
+
homeBackgroundColor: string;
|
|
29
|
+
homeBackgroundGradientStart: string;
|
|
30
|
+
homeBackgroundGradientMiddle: string | null;
|
|
31
|
+
homeBackgroundGradientEnd: string;
|
|
32
|
+
homeBackgroundImageUrl: string | null;
|
|
33
|
+
homeHeaderTextColor: 'black' | 'white';
|
|
34
|
+
homeBackgroundFade: boolean;
|
|
35
|
+
position: 'left' | 'right';
|
|
36
|
+
bubbleText: string;
|
|
37
|
+
welcomeHeading: string;
|
|
38
|
+
welcomeSubheading: string;
|
|
39
|
+
preChatEnabled: boolean;
|
|
40
|
+
preChatFields: PreChatField[];
|
|
41
|
+
businessHoursEnabled: boolean;
|
|
42
|
+
offlineMessage: string;
|
|
43
|
+
spaces: WidgetSpace[];
|
|
44
|
+
launchDirectly: boolean;
|
|
45
|
+
showLauncher: boolean;
|
|
46
|
+
launcherVerticalPadding: number;
|
|
47
|
+
launcherHorizontalPadding: number;
|
|
48
|
+
startConversationLabel: string;
|
|
49
|
+
replyTimeLabel: string;
|
|
50
|
+
allowNewConversations: boolean;
|
|
51
|
+
showPreviousConversations: boolean;
|
|
52
|
+
proactiveEnabled: boolean;
|
|
53
|
+
proactiveTitle: string;
|
|
54
|
+
proactiveBody: string;
|
|
55
|
+
proactiveCtaLabel: string;
|
|
56
|
+
proactiveDelaySeconds: number;
|
|
57
|
+
proactivePathContains: string;
|
|
58
|
+
proactiveFrequency: 'session' | 'visitor';
|
|
59
|
+
proactiveOpenMode: 'home' | 'new_message';
|
|
60
|
+
attachmentsEnabled: boolean;
|
|
61
|
+
analyticsEnabled: boolean;
|
|
62
|
+
toursEnabled: boolean;
|
|
63
|
+
defaultLocale: string;
|
|
64
|
+
enabledLocales: string[];
|
|
65
|
+
translations: Record<string, Record<string, string>>;
|
|
66
|
+
identityVerificationEnabled: boolean;
|
|
67
|
+
hmacMandatory: boolean;
|
|
68
|
+
isOnline: boolean;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** Received attachments are normalized: a missing `id`/`size` is filled in. */
|
|
72
|
+
export interface WidgetAttachment {
|
|
73
|
+
id: string;
|
|
74
|
+
name: string;
|
|
75
|
+
url: string;
|
|
76
|
+
contentType: string;
|
|
77
|
+
size: number;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export interface Conversation {
|
|
81
|
+
id: string;
|
|
82
|
+
subject: string | null;
|
|
83
|
+
status: string;
|
|
84
|
+
snippet: string | null;
|
|
85
|
+
messageCount: number;
|
|
86
|
+
lastMessageAt: string | null;
|
|
87
|
+
createdAt: string;
|
|
88
|
+
agentName: string | null;
|
|
89
|
+
agentAvatar: string | null;
|
|
90
|
+
/**
|
|
91
|
+
* Agent replies the visitor hasn't seen, computed server-side from their
|
|
92
|
+
* read cursor. Absent on older Workstation deployments — the SDK then falls
|
|
93
|
+
* back to its locally persisted counts.
|
|
94
|
+
*/
|
|
95
|
+
unreadCount?: number;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export interface Message {
|
|
99
|
+
id: string;
|
|
100
|
+
messageType?: 'message' | 'note' | 'system';
|
|
101
|
+
direction: 'inbound' | 'outbound';
|
|
102
|
+
senderType: string;
|
|
103
|
+
senderName: string | null;
|
|
104
|
+
body: string | null;
|
|
105
|
+
bodyPlain: string | null;
|
|
106
|
+
attachments: WidgetAttachment[] | null;
|
|
107
|
+
metadata?: Record<string, unknown> | null;
|
|
108
|
+
status: string | null;
|
|
109
|
+
createdAt: string;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export interface OutboundMessage {
|
|
113
|
+
id?: string;
|
|
114
|
+
type?: 'chat' | 'post' | 'announcement' | 'banner';
|
|
115
|
+
title?: string;
|
|
116
|
+
body?: string;
|
|
117
|
+
bodyHtml?: string;
|
|
118
|
+
ctaLabel?: string;
|
|
119
|
+
ctaUrl?: string;
|
|
120
|
+
imageUrl?: string;
|
|
121
|
+
prefill?: string;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/** Identity fields accepted by `POST /api/widget/init`. */
|
|
125
|
+
export interface WidgetUser {
|
|
126
|
+
userId?: string;
|
|
127
|
+
email?: string;
|
|
128
|
+
name?: string;
|
|
129
|
+
phone?: string;
|
|
130
|
+
/** HMAC-SHA256 hex of (email ?? userId) — only needed when the widget enforces identity verification. */
|
|
131
|
+
userHash?: string;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export type WidgetCustomAttributes = Record<string, string | number | boolean>;
|
|
135
|
+
|
|
136
|
+
export interface InitResponse {
|
|
137
|
+
token: string;
|
|
138
|
+
identityId: string;
|
|
139
|
+
config: WidgetConfig;
|
|
140
|
+
conversations: Conversation[];
|
|
141
|
+
user?: { name?: string; email?: string };
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/** Production Workstation deployment — where `/api/widget/*` is served. */
|
|
145
|
+
export const DEFAULT_BASE_URL = 'https://workstation.repzo.com';
|
|
146
|
+
|
|
147
|
+
export interface BootOptions {
|
|
148
|
+
/**
|
|
149
|
+
* Override the CRM deployment root. Defaults to production Workstation
|
|
150
|
+
* (`https://workstation.repzo.com`); set it only for a dev/staging CRM.
|
|
151
|
+
* Android emulators need `http://10.0.2.2:3000` to reach a local CRM.
|
|
152
|
+
*/
|
|
153
|
+
baseUrl?: string;
|
|
154
|
+
/** `inbox_channel_accounts.id` of the Website Chat widget. */
|
|
155
|
+
channelAccountId: string;
|
|
156
|
+
user?: WidgetUser;
|
|
157
|
+
/**
|
|
158
|
+
* Called first for every link the visitor taps inside the widget (agent/AI
|
|
159
|
+
* replies, campaign CTAs, attachments). Return `true` when the host handled
|
|
160
|
+
* it (e.g. routed an `myapp://` deep link itself). Otherwise the SDK only
|
|
161
|
+
* opens `https:`, `http:`, `mailto:` and `tel:` URLs and blocks the rest —
|
|
162
|
+
* agent-authored text must never be able to fire host deep links,
|
|
163
|
+
* `intent:` or `javascript:` URLs.
|
|
164
|
+
*/
|
|
165
|
+
onOpenUrl?: (url: string) => boolean | Promise<boolean>;
|
|
166
|
+
/**
|
|
167
|
+
* FCM push registration (requires `@react-native-firebase/messaging` in the
|
|
168
|
+
* host app and the channel's push provider set to FCM in Workstation).
|
|
169
|
+
*/
|
|
170
|
+
push?: {
|
|
171
|
+
enabled?: boolean;
|
|
172
|
+
/** Default true — set false when the host runs its own permission prompt. */
|
|
173
|
+
requestPermission?: boolean;
|
|
174
|
+
/**
|
|
175
|
+
* The app's bundle id / package name — lets a channel serving several apps
|
|
176
|
+
* match this device to the right Firebase key. Optional for single-app
|
|
177
|
+
* channels.
|
|
178
|
+
*/
|
|
179
|
+
bundleId?: string;
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// ─── Agent UI blocks ────────────────────────────────────────────────────────
|
|
184
|
+
// Structural mirrors of `shared/agent-ui-blocks.ts` in the CRM. Validation is
|
|
185
|
+
// intentionally permissive here (no zod dependency) — the server already
|
|
186
|
+
// validated these before broadcasting them.
|
|
187
|
+
|
|
188
|
+
export type AgentUiModule =
|
|
189
|
+
| 'products'
|
|
190
|
+
| 'product_variants'
|
|
191
|
+
| 'carts'
|
|
192
|
+
| 'orders'
|
|
193
|
+
| 'contacts'
|
|
194
|
+
| 'leads'
|
|
195
|
+
| 'appointments'
|
|
196
|
+
| 'price_offers'
|
|
197
|
+
| 'send';
|
|
198
|
+
|
|
199
|
+
export interface AgentUiAction {
|
|
200
|
+
id: string;
|
|
201
|
+
type:
|
|
202
|
+
| 'add_to_cart'
|
|
203
|
+
| 'buy_now'
|
|
204
|
+
| 'submit_contact'
|
|
205
|
+
| 'record_consent'
|
|
206
|
+
| 'select_appointment_provider'
|
|
207
|
+
| 'select_appointment_slot'
|
|
208
|
+
| 'open_record'
|
|
209
|
+
| 'accept_quote'
|
|
210
|
+
| 'next_action';
|
|
211
|
+
label: string;
|
|
212
|
+
module: AgentUiModule;
|
|
213
|
+
payload: Record<string, unknown>;
|
|
214
|
+
navigateTo?: string;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
export interface AgentUiProduct {
|
|
218
|
+
id: string;
|
|
219
|
+
name: string;
|
|
220
|
+
type: 'physical' | 'service' | 'digital';
|
|
221
|
+
shortDescription?: string;
|
|
222
|
+
description?: string;
|
|
223
|
+
imageUrl?: string;
|
|
224
|
+
sku?: string;
|
|
225
|
+
unit?: string;
|
|
226
|
+
price: number;
|
|
227
|
+
currency: string;
|
|
228
|
+
durationMinutes?: number;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
export interface AgentUiCommerceItem {
|
|
232
|
+
productId?: string;
|
|
233
|
+
variantId?: string;
|
|
234
|
+
name: string;
|
|
235
|
+
description?: string;
|
|
236
|
+
imageUrl?: string;
|
|
237
|
+
sku?: string;
|
|
238
|
+
quantity: number;
|
|
239
|
+
unitPrice: number;
|
|
240
|
+
lineTotal: number;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
export type AgentUiBlock =
|
|
244
|
+
| { id: string; module: AgentUiModule; type: 'product_service_card'; product: AgentUiProduct }
|
|
245
|
+
| {
|
|
246
|
+
id: string;
|
|
247
|
+
module: AgentUiModule;
|
|
248
|
+
type: 'product_choices';
|
|
249
|
+
productId: string;
|
|
250
|
+
title: string;
|
|
251
|
+
variants: Array<{
|
|
252
|
+
id: string;
|
|
253
|
+
title: string;
|
|
254
|
+
sku?: string;
|
|
255
|
+
price: number;
|
|
256
|
+
currency: string;
|
|
257
|
+
imageUrl?: string;
|
|
258
|
+
available: boolean;
|
|
259
|
+
}>;
|
|
260
|
+
}
|
|
261
|
+
| {
|
|
262
|
+
id: string;
|
|
263
|
+
module: AgentUiModule;
|
|
264
|
+
type: 'commerce_actions';
|
|
265
|
+
productId: string;
|
|
266
|
+
variantId?: string;
|
|
267
|
+
quantity: number;
|
|
268
|
+
actions: AgentUiAction[];
|
|
269
|
+
}
|
|
270
|
+
| {
|
|
271
|
+
id: string;
|
|
272
|
+
module: AgentUiModule;
|
|
273
|
+
type: 'cart_order_summary';
|
|
274
|
+
title: string;
|
|
275
|
+
reference?: string;
|
|
276
|
+
status?: string;
|
|
277
|
+
currency: string;
|
|
278
|
+
items: AgentUiCommerceItem[];
|
|
279
|
+
subtotal: number;
|
|
280
|
+
discount: number;
|
|
281
|
+
tax: number;
|
|
282
|
+
shipping: number;
|
|
283
|
+
total: number;
|
|
284
|
+
action?: AgentUiAction;
|
|
285
|
+
}
|
|
286
|
+
| {
|
|
287
|
+
id: string;
|
|
288
|
+
module: AgentUiModule;
|
|
289
|
+
type: 'contact_lead_form';
|
|
290
|
+
title: string;
|
|
291
|
+
description?: string;
|
|
292
|
+
fields: Array<{
|
|
293
|
+
name: string;
|
|
294
|
+
label: string;
|
|
295
|
+
type: 'text' | 'email' | 'phone' | 'textarea';
|
|
296
|
+
required: boolean;
|
|
297
|
+
placeholder?: string;
|
|
298
|
+
value?: string;
|
|
299
|
+
}>;
|
|
300
|
+
submitLabel: string;
|
|
301
|
+
}
|
|
302
|
+
| {
|
|
303
|
+
id: string;
|
|
304
|
+
module: AgentUiModule;
|
|
305
|
+
type: 'consent';
|
|
306
|
+
statement: string;
|
|
307
|
+
channels: Array<'email' | 'phone' | 'whatsapp'>;
|
|
308
|
+
required: boolean;
|
|
309
|
+
privacyUrl?: string;
|
|
310
|
+
}
|
|
311
|
+
| {
|
|
312
|
+
id: string;
|
|
313
|
+
module: AgentUiModule;
|
|
314
|
+
type: 'appointment_slot_picker';
|
|
315
|
+
serviceId: string;
|
|
316
|
+
serviceName: string;
|
|
317
|
+
durationMinutes: number;
|
|
318
|
+
timezone?: string;
|
|
319
|
+
locationId?: string;
|
|
320
|
+
selectedProviderId?: string;
|
|
321
|
+
providers: Array<{ id: string; name: string; avatarUrl?: string | null }>;
|
|
322
|
+
days: Array<{
|
|
323
|
+
date: string;
|
|
324
|
+
slots: Array<{
|
|
325
|
+
startTime: string;
|
|
326
|
+
endTime: string;
|
|
327
|
+
staffUserId?: string | null;
|
|
328
|
+
slotToken: string;
|
|
329
|
+
}>;
|
|
330
|
+
}>;
|
|
331
|
+
}
|
|
332
|
+
| {
|
|
333
|
+
id: string;
|
|
334
|
+
module: AgentUiModule;
|
|
335
|
+
type: 'quote_preview';
|
|
336
|
+
quoteId: string;
|
|
337
|
+
name: string;
|
|
338
|
+
serialNumber?: string;
|
|
339
|
+
status: string;
|
|
340
|
+
amount: number;
|
|
341
|
+
currency: string;
|
|
342
|
+
validUntil?: string;
|
|
343
|
+
contactName?: string;
|
|
344
|
+
items: AgentUiCommerceItem[];
|
|
345
|
+
actions: AgentUiAction[];
|
|
346
|
+
}
|
|
347
|
+
| {
|
|
348
|
+
id: string;
|
|
349
|
+
module: AgentUiModule;
|
|
350
|
+
type: 'success_receipt';
|
|
351
|
+
title: string;
|
|
352
|
+
description?: string;
|
|
353
|
+
entityId?: string;
|
|
354
|
+
reference?: string;
|
|
355
|
+
amount?: number;
|
|
356
|
+
currency?: string;
|
|
357
|
+
navigateTo?: string;
|
|
358
|
+
nextActions: AgentUiAction[];
|
|
359
|
+
};
|
|
360
|
+
|
|
361
|
+
export interface AgentProcedureForm {
|
|
362
|
+
procedureId: string;
|
|
363
|
+
procedureName: string;
|
|
364
|
+
fields: Array<{
|
|
365
|
+
name: string;
|
|
366
|
+
label: string;
|
|
367
|
+
type: 'text' | 'email' | 'phone' | 'date' | 'time';
|
|
368
|
+
required: boolean;
|
|
369
|
+
}>;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
// ─── Realtime ───────────────────────────────────────────────────────────────
|
|
373
|
+
|
|
374
|
+
export type WidgetRealtimeEvent =
|
|
375
|
+
| 'connected'
|
|
376
|
+
| 'message.new'
|
|
377
|
+
| 'typing.start'
|
|
378
|
+
| 'typing.stop'
|
|
379
|
+
| 'conversation.updated'
|
|
380
|
+
| 'conversation.event'
|
|
381
|
+
| 'error';
|
|
382
|
+
|
|
383
|
+
// ─── SDK surface ────────────────────────────────────────────────────────────
|
|
384
|
+
|
|
385
|
+
/**
|
|
386
|
+
* Async key/value store. The regular adapter holds the device id, unread
|
|
387
|
+
* counts and cached theme; the optional secure adapter (Keychain/Keystore via
|
|
388
|
+
* `setSecureStorageAdapter`) holds the visitor token and user key.
|
|
389
|
+
*/
|
|
390
|
+
export interface RepzoWidgetStorageAdapter {
|
|
391
|
+
getItem(key: string): Promise<string | null> | string | null;
|
|
392
|
+
setItem(key: string, value: string): Promise<void> | void;
|
|
393
|
+
removeItem(key: string): Promise<void> | void;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
/**
|
|
397
|
+
* `RepzoWidgetError.code`. The last two come from the server's 403 body and
|
|
398
|
+
* are terminal — the SDK stops realtime and does not retry on its own:
|
|
399
|
+
* - `messenger_api_disabled` — the channel's Messenger API is switched off.
|
|
400
|
+
* - `identity_verification_failed` — `userHash` missing/wrong while the
|
|
401
|
+
* channel enforces identity verification.
|
|
402
|
+
*/
|
|
403
|
+
export type RepzoWidgetErrorCode =
|
|
404
|
+
| 'network'
|
|
405
|
+
| 'http'
|
|
406
|
+
| 'messenger_api_disabled'
|
|
407
|
+
| 'identity_verification_failed';
|
|
408
|
+
|
|
409
|
+
export type WidgetView = 'bubble' | 'home' | 'prechat' | 'chat' | 'conversations';
|
|
410
|
+
|
|
411
|
+
export interface WidgetState {
|
|
412
|
+
booted: boolean;
|
|
413
|
+
loading: boolean;
|
|
414
|
+
error: string | null;
|
|
415
|
+
/** Machine-readable companion to `error` — see `RepzoWidgetErrorCode`. */
|
|
416
|
+
errorCode: RepzoWidgetErrorCode | null;
|
|
417
|
+
config: WidgetConfig | null;
|
|
418
|
+
identityId: string | null;
|
|
419
|
+
isOpen: boolean;
|
|
420
|
+
view: WidgetView;
|
|
421
|
+
activeTab: WidgetSpaceType;
|
|
422
|
+
conversations: Conversation[];
|
|
423
|
+
activeConversationId: string | null;
|
|
424
|
+
messages: Message[];
|
|
425
|
+
messagesLoading: boolean;
|
|
426
|
+
hasMoreMessages: boolean;
|
|
427
|
+
messageCursor: string | null;
|
|
428
|
+
agentTyping: boolean;
|
|
429
|
+
/**
|
|
430
|
+
* Unread team replies across all threads — always the sum of
|
|
431
|
+
* `unreadByConversation`, so it only drops when a thread is opened.
|
|
432
|
+
*/
|
|
433
|
+
unreadCount: number;
|
|
434
|
+
/**
|
|
435
|
+
* Unread replies per conversation. Only `messageType: 'message'` replies
|
|
436
|
+
* count (never system rows); a thread stays unread until the visitor
|
|
437
|
+
* actually opens it.
|
|
438
|
+
*/
|
|
439
|
+
unreadByConversation: Record<string, number>;
|
|
440
|
+
locale: string;
|
|
441
|
+
prefillText: string;
|
|
442
|
+
outboundMessage: OutboundMessage | null;
|
|
443
|
+
/** Name/email captured from pre-chat or `loginUserWithUserAttributes`. */
|
|
444
|
+
visitorProfile: { name?: string; email?: string; phone?: string };
|
|
445
|
+
}
|