@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.
Files changed (448) hide show
  1. package/README.md +482 -0
  2. package/lib/commonjs/agent-ui-blocks.js +159 -0
  3. package/lib/commonjs/agent-ui-blocks.js.map +1 -0
  4. package/lib/commonjs/api/client.js +267 -0
  5. package/lib/commonjs/api/client.js.map +1 -0
  6. package/lib/commonjs/api/realtime.js +193 -0
  7. package/lib/commonjs/api/realtime.js.map +1 -0
  8. package/lib/commonjs/api/sse-parser.js +58 -0
  9. package/lib/commonjs/api/sse-parser.js.map +1 -0
  10. package/lib/commonjs/controller.js +23 -0
  11. package/lib/commonjs/controller.js.map +1 -0
  12. package/lib/commonjs/device-id.js +75 -0
  13. package/lib/commonjs/device-id.js.map +1 -0
  14. package/lib/commonjs/events.js +49 -0
  15. package/lib/commonjs/events.js.map +1 -0
  16. package/lib/commonjs/i18n.js +106 -0
  17. package/lib/commonjs/i18n.js.map +1 -0
  18. package/lib/commonjs/index.js +98 -0
  19. package/lib/commonjs/index.js.map +1 -0
  20. package/lib/commonjs/locales.js +85 -0
  21. package/lib/commonjs/locales.js.map +1 -0
  22. package/lib/commonjs/package.json +1 -0
  23. package/lib/commonjs/push/push-notifications.js +208 -0
  24. package/lib/commonjs/push/push-notifications.js.map +1 -0
  25. package/lib/commonjs/state/use-widget-state.js +23 -0
  26. package/lib/commonjs/state/use-widget-state.js.map +1 -0
  27. package/lib/commonjs/state/widget-store.js +1682 -0
  28. package/lib/commonjs/state/widget-store.js.map +1 -0
  29. package/lib/commonjs/storage.js +147 -0
  30. package/lib/commonjs/storage.js.map +1 -0
  31. package/lib/commonjs/types.js +44 -0
  32. package/lib/commonjs/types.js.map +1 -0
  33. package/lib/commonjs/ui/WidgetProvider.js +404 -0
  34. package/lib/commonjs/ui/WidgetProvider.js.map +1 -0
  35. package/lib/commonjs/ui/components/AgentUiBlocks.js +864 -0
  36. package/lib/commonjs/ui/components/AgentUiBlocks.js.map +1 -0
  37. package/lib/commonjs/ui/components/Avatar.js +76 -0
  38. package/lib/commonjs/ui/components/Avatar.js.map +1 -0
  39. package/lib/commonjs/ui/components/ConversationRow.js +155 -0
  40. package/lib/commonjs/ui/components/ConversationRow.js.map +1 -0
  41. package/lib/commonjs/ui/components/ErrorBoundary.js +44 -0
  42. package/lib/commonjs/ui/components/ErrorBoundary.js.map +1 -0
  43. package/lib/commonjs/ui/components/Gradient.js +168 -0
  44. package/lib/commonjs/ui/components/Gradient.js.map +1 -0
  45. package/lib/commonjs/ui/components/Launcher.js +125 -0
  46. package/lib/commonjs/ui/components/Launcher.js.map +1 -0
  47. package/lib/commonjs/ui/components/Markdown.js +257 -0
  48. package/lib/commonjs/ui/components/Markdown.js.map +1 -0
  49. package/lib/commonjs/ui/components/OutboundMessageCard.js +157 -0
  50. package/lib/commonjs/ui/components/OutboundMessageCard.js.map +1 -0
  51. package/lib/commonjs/ui/components/WidgetPanel.js +131 -0
  52. package/lib/commonjs/ui/components/WidgetPanel.js.map +1 -0
  53. package/lib/commonjs/ui/components/icons.js +383 -0
  54. package/lib/commonjs/ui/components/icons.js.map +1 -0
  55. package/lib/commonjs/ui/hooks/use-keyboard-overlap.js +113 -0
  56. package/lib/commonjs/ui/hooks/use-keyboard-overlap.js.map +1 -0
  57. package/lib/commonjs/ui/hooks/use-reduce-motion.js +38 -0
  58. package/lib/commonjs/ui/hooks/use-reduce-motion.js.map +1 -0
  59. package/lib/commonjs/ui/hooks/use-widget-insets.js +41 -0
  60. package/lib/commonjs/ui/hooks/use-widget-insets.js.map +1 -0
  61. package/lib/commonjs/ui/screens/chat/ChatView.js +590 -0
  62. package/lib/commonjs/ui/screens/chat/ChatView.js.map +1 -0
  63. package/lib/commonjs/ui/screens/chat/ChatView.styles.js +362 -0
  64. package/lib/commonjs/ui/screens/chat/ChatView.styles.js.map +1 -0
  65. package/lib/commonjs/ui/screens/chat/ChatView.types.js +6 -0
  66. package/lib/commonjs/ui/screens/chat/ChatView.types.js.map +1 -0
  67. package/lib/commonjs/ui/screens/conversations/ConversationsList.js +150 -0
  68. package/lib/commonjs/ui/screens/conversations/ConversationsList.js.map +1 -0
  69. package/lib/commonjs/ui/screens/conversations/ConversationsList.styles.js +118 -0
  70. package/lib/commonjs/ui/screens/conversations/ConversationsList.styles.js.map +1 -0
  71. package/lib/commonjs/ui/screens/conversations/ConversationsList.types.js +6 -0
  72. package/lib/commonjs/ui/screens/conversations/ConversationsList.types.js.map +1 -0
  73. package/lib/commonjs/ui/screens/home/HomeView.js +336 -0
  74. package/lib/commonjs/ui/screens/home/HomeView.js.map +1 -0
  75. package/lib/commonjs/ui/screens/home/HomeView.styles.js +245 -0
  76. package/lib/commonjs/ui/screens/home/HomeView.styles.js.map +1 -0
  77. package/lib/commonjs/ui/screens/home/HomeView.types.js +6 -0
  78. package/lib/commonjs/ui/screens/home/HomeView.types.js.map +1 -0
  79. package/lib/commonjs/ui/screens/home/greeting.js +49 -0
  80. package/lib/commonjs/ui/screens/home/greeting.js.map +1 -0
  81. package/lib/commonjs/ui/screens/pre-chat/PreChatForm.js +229 -0
  82. package/lib/commonjs/ui/screens/pre-chat/PreChatForm.js.map +1 -0
  83. package/lib/commonjs/ui/screens/pre-chat/PreChatForm.styles.js +125 -0
  84. package/lib/commonjs/ui/screens/pre-chat/PreChatForm.styles.js.map +1 -0
  85. package/lib/commonjs/ui/screens/pre-chat/PreChatForm.types.js +6 -0
  86. package/lib/commonjs/ui/screens/pre-chat/PreChatForm.types.js.map +1 -0
  87. package/lib/commonjs/ui/styles/global.js +55 -0
  88. package/lib/commonjs/ui/styles/global.js.map +1 -0
  89. package/lib/commonjs/ui/styles/theme.js +148 -0
  90. package/lib/commonjs/ui/styles/theme.js.map +1 -0
  91. package/lib/commonjs/ui/utils/conversations.js +125 -0
  92. package/lib/commonjs/ui/utils/conversations.js.map +1 -0
  93. package/lib/commonjs/ui/utils/html.js +44 -0
  94. package/lib/commonjs/ui/utils/html.js.map +1 -0
  95. package/lib/commonjs/ui/utils/native-gradient.js +65 -0
  96. package/lib/commonjs/ui/utils/native-gradient.js.map +1 -0
  97. package/lib/commonjs/ui/utils/rtl.js +56 -0
  98. package/lib/commonjs/ui/utils/rtl.js.map +1 -0
  99. package/lib/commonjs/ui/utils/safe-url.js +67 -0
  100. package/lib/commonjs/ui/utils/safe-url.js.map +1 -0
  101. package/lib/module/agent-ui-blocks.js +152 -0
  102. package/lib/module/agent-ui-blocks.js.map +1 -0
  103. package/lib/module/api/client.js +261 -0
  104. package/lib/module/api/client.js.map +1 -0
  105. package/lib/module/api/realtime.js +189 -0
  106. package/lib/module/api/realtime.js.map +1 -0
  107. package/lib/module/api/sse-parser.js +53 -0
  108. package/lib/module/api/sse-parser.js.map +1 -0
  109. package/lib/module/controller.js +19 -0
  110. package/lib/module/controller.js.map +1 -0
  111. package/lib/module/device-id.js +69 -0
  112. package/lib/module/device-id.js.map +1 -0
  113. package/lib/module/events.js +44 -0
  114. package/lib/module/events.js.map +1 -0
  115. package/lib/module/i18n.js +99 -0
  116. package/lib/module/i18n.js.map +1 -0
  117. package/lib/module/index.js +55 -0
  118. package/lib/module/index.js.map +1 -0
  119. package/lib/module/locales.js +80 -0
  120. package/lib/module/locales.js.map +1 -0
  121. package/lib/module/package.json +1 -0
  122. package/lib/module/push/push-notifications.js +204 -0
  123. package/lib/module/push/push-notifications.js.map +1 -0
  124. package/lib/module/state/use-widget-state.js +18 -0
  125. package/lib/module/state/use-widget-state.js.map +1 -0
  126. package/lib/module/state/widget-store.js +1677 -0
  127. package/lib/module/state/widget-store.js.map +1 -0
  128. package/lib/module/storage.js +141 -0
  129. package/lib/module/storage.js.map +1 -0
  130. package/lib/module/types.js +40 -0
  131. package/lib/module/types.js.map +1 -0
  132. package/lib/module/ui/WidgetProvider.js +400 -0
  133. package/lib/module/ui/WidgetProvider.js.map +1 -0
  134. package/lib/module/ui/components/AgentUiBlocks.js +857 -0
  135. package/lib/module/ui/components/AgentUiBlocks.js.map +1 -0
  136. package/lib/module/ui/components/Avatar.js +71 -0
  137. package/lib/module/ui/components/Avatar.js.map +1 -0
  138. package/lib/module/ui/components/ConversationRow.js +150 -0
  139. package/lib/module/ui/components/ConversationRow.js.map +1 -0
  140. package/lib/module/ui/components/ErrorBoundary.js +39 -0
  141. package/lib/module/ui/components/ErrorBoundary.js.map +1 -0
  142. package/lib/module/ui/components/Gradient.js +165 -0
  143. package/lib/module/ui/components/Gradient.js.map +1 -0
  144. package/lib/module/ui/components/Launcher.js +121 -0
  145. package/lib/module/ui/components/Launcher.js.map +1 -0
  146. package/lib/module/ui/components/Markdown.js +253 -0
  147. package/lib/module/ui/components/Markdown.js.map +1 -0
  148. package/lib/module/ui/components/OutboundMessageCard.js +153 -0
  149. package/lib/module/ui/components/OutboundMessageCard.js.map +1 -0
  150. package/lib/module/ui/components/WidgetPanel.js +127 -0
  151. package/lib/module/ui/components/WidgetPanel.js.map +1 -0
  152. package/lib/module/ui/components/icons.js +370 -0
  153. package/lib/module/ui/components/icons.js.map +1 -0
  154. package/lib/module/ui/hooks/use-keyboard-overlap.js +109 -0
  155. package/lib/module/ui/hooks/use-keyboard-overlap.js.map +1 -0
  156. package/lib/module/ui/hooks/use-reduce-motion.js +34 -0
  157. package/lib/module/ui/hooks/use-reduce-motion.js.map +1 -0
  158. package/lib/module/ui/hooks/use-widget-insets.js +37 -0
  159. package/lib/module/ui/hooks/use-widget-insets.js.map +1 -0
  160. package/lib/module/ui/screens/chat/ChatView.js +586 -0
  161. package/lib/module/ui/screens/chat/ChatView.js.map +1 -0
  162. package/lib/module/ui/screens/chat/ChatView.styles.js +358 -0
  163. package/lib/module/ui/screens/chat/ChatView.styles.js.map +1 -0
  164. package/lib/module/ui/screens/chat/ChatView.types.js +4 -0
  165. package/lib/module/ui/screens/chat/ChatView.types.js.map +1 -0
  166. package/lib/module/ui/screens/conversations/ConversationsList.js +146 -0
  167. package/lib/module/ui/screens/conversations/ConversationsList.js.map +1 -0
  168. package/lib/module/ui/screens/conversations/ConversationsList.styles.js +114 -0
  169. package/lib/module/ui/screens/conversations/ConversationsList.styles.js.map +1 -0
  170. package/lib/module/ui/screens/conversations/ConversationsList.types.js +4 -0
  171. package/lib/module/ui/screens/conversations/ConversationsList.types.js.map +1 -0
  172. package/lib/module/ui/screens/home/HomeView.js +332 -0
  173. package/lib/module/ui/screens/home/HomeView.js.map +1 -0
  174. package/lib/module/ui/screens/home/HomeView.styles.js +242 -0
  175. package/lib/module/ui/screens/home/HomeView.styles.js.map +1 -0
  176. package/lib/module/ui/screens/home/HomeView.types.js +4 -0
  177. package/lib/module/ui/screens/home/HomeView.types.js.map +1 -0
  178. package/lib/module/ui/screens/home/greeting.js +44 -0
  179. package/lib/module/ui/screens/home/greeting.js.map +1 -0
  180. package/lib/module/ui/screens/pre-chat/PreChatForm.js +225 -0
  181. package/lib/module/ui/screens/pre-chat/PreChatForm.js.map +1 -0
  182. package/lib/module/ui/screens/pre-chat/PreChatForm.styles.js +121 -0
  183. package/lib/module/ui/screens/pre-chat/PreChatForm.styles.js.map +1 -0
  184. package/lib/module/ui/screens/pre-chat/PreChatForm.types.js +4 -0
  185. package/lib/module/ui/screens/pre-chat/PreChatForm.types.js.map +1 -0
  186. package/lib/module/ui/styles/global.js +51 -0
  187. package/lib/module/ui/styles/global.js.map +1 -0
  188. package/lib/module/ui/styles/theme.js +137 -0
  189. package/lib/module/ui/styles/theme.js.map +1 -0
  190. package/lib/module/ui/utils/conversations.js +115 -0
  191. package/lib/module/ui/utils/conversations.js.map +1 -0
  192. package/lib/module/ui/utils/html.js +39 -0
  193. package/lib/module/ui/utils/html.js.map +1 -0
  194. package/lib/module/ui/utils/native-gradient.js +60 -0
  195. package/lib/module/ui/utils/native-gradient.js.map +1 -0
  196. package/lib/module/ui/utils/rtl.js +49 -0
  197. package/lib/module/ui/utils/rtl.js.map +1 -0
  198. package/lib/module/ui/utils/safe-url.js +59 -0
  199. package/lib/module/ui/utils/safe-url.js.map +1 -0
  200. package/lib/typescript/commonjs/agent-ui-blocks.d.ts +20 -0
  201. package/lib/typescript/commonjs/agent-ui-blocks.d.ts.map +1 -0
  202. package/lib/typescript/commonjs/api/client.d.ts +115 -0
  203. package/lib/typescript/commonjs/api/client.d.ts.map +1 -0
  204. package/lib/typescript/commonjs/api/realtime.d.ts +39 -0
  205. package/lib/typescript/commonjs/api/realtime.d.ts.map +1 -0
  206. package/lib/typescript/commonjs/api/sse-parser.d.ts +13 -0
  207. package/lib/typescript/commonjs/api/sse-parser.d.ts.map +1 -0
  208. package/lib/typescript/commonjs/controller.d.ts +15 -0
  209. package/lib/typescript/commonjs/controller.d.ts.map +1 -0
  210. package/lib/typescript/commonjs/device-id.d.ts +15 -0
  211. package/lib/typescript/commonjs/device-id.d.ts.map +1 -0
  212. package/lib/typescript/commonjs/events.d.ts +41 -0
  213. package/lib/typescript/commonjs/events.d.ts.map +1 -0
  214. package/lib/typescript/commonjs/i18n.d.ts +78 -0
  215. package/lib/typescript/commonjs/i18n.d.ts.map +1 -0
  216. package/lib/typescript/commonjs/index.d.ts +103 -0
  217. package/lib/typescript/commonjs/index.d.ts.map +1 -0
  218. package/lib/typescript/commonjs/locales.d.ts +18 -0
  219. package/lib/typescript/commonjs/locales.d.ts.map +1 -0
  220. package/lib/typescript/commonjs/package.json +1 -0
  221. package/lib/typescript/commonjs/push/push-notifications.d.ts +71 -0
  222. package/lib/typescript/commonjs/push/push-notifications.d.ts.map +1 -0
  223. package/lib/typescript/commonjs/state/use-widget-state.d.ts +10 -0
  224. package/lib/typescript/commonjs/state/use-widget-state.d.ts.map +1 -0
  225. package/lib/typescript/commonjs/state/widget-store.d.ts +227 -0
  226. package/lib/typescript/commonjs/state/widget-store.d.ts.map +1 -0
  227. package/lib/typescript/commonjs/storage.d.ts +42 -0
  228. package/lib/typescript/commonjs/storage.d.ts.map +1 -0
  229. package/lib/typescript/commonjs/types.d.ts +391 -0
  230. package/lib/typescript/commonjs/types.d.ts.map +1 -0
  231. package/lib/typescript/commonjs/ui/WidgetProvider.d.ts +15 -0
  232. package/lib/typescript/commonjs/ui/WidgetProvider.d.ts.map +1 -0
  233. package/lib/typescript/commonjs/ui/components/AgentUiBlocks.d.ts +27 -0
  234. package/lib/typescript/commonjs/ui/components/AgentUiBlocks.d.ts.map +1 -0
  235. package/lib/typescript/commonjs/ui/components/Avatar.d.ts +19 -0
  236. package/lib/typescript/commonjs/ui/components/Avatar.d.ts.map +1 -0
  237. package/lib/typescript/commonjs/ui/components/ConversationRow.d.ts +26 -0
  238. package/lib/typescript/commonjs/ui/components/ConversationRow.d.ts.map +1 -0
  239. package/lib/typescript/commonjs/ui/components/ErrorBoundary.d.ts +27 -0
  240. package/lib/typescript/commonjs/ui/components/ErrorBoundary.d.ts.map +1 -0
  241. package/lib/typescript/commonjs/ui/components/Gradient.d.ts +33 -0
  242. package/lib/typescript/commonjs/ui/components/Gradient.d.ts.map +1 -0
  243. package/lib/typescript/commonjs/ui/components/Launcher.d.ts +18 -0
  244. package/lib/typescript/commonjs/ui/components/Launcher.d.ts.map +1 -0
  245. package/lib/typescript/commonjs/ui/components/Markdown.d.ts +19 -0
  246. package/lib/typescript/commonjs/ui/components/Markdown.d.ts.map +1 -0
  247. package/lib/typescript/commonjs/ui/components/OutboundMessageCard.d.ts +20 -0
  248. package/lib/typescript/commonjs/ui/components/OutboundMessageCard.d.ts.map +1 -0
  249. package/lib/typescript/commonjs/ui/components/WidgetPanel.d.ts +26 -0
  250. package/lib/typescript/commonjs/ui/components/WidgetPanel.d.ts.map +1 -0
  251. package/lib/typescript/commonjs/ui/components/icons.d.ts +38 -0
  252. package/lib/typescript/commonjs/ui/components/icons.d.ts.map +1 -0
  253. package/lib/typescript/commonjs/ui/hooks/use-keyboard-overlap.d.ts +33 -0
  254. package/lib/typescript/commonjs/ui/hooks/use-keyboard-overlap.d.ts.map +1 -0
  255. package/lib/typescript/commonjs/ui/hooks/use-reduce-motion.d.ts +11 -0
  256. package/lib/typescript/commonjs/ui/hooks/use-reduce-motion.d.ts.map +1 -0
  257. package/lib/typescript/commonjs/ui/hooks/use-widget-insets.d.ts +16 -0
  258. package/lib/typescript/commonjs/ui/hooks/use-widget-insets.d.ts.map +1 -0
  259. package/lib/typescript/commonjs/ui/screens/chat/ChatView.d.ts +11 -0
  260. package/lib/typescript/commonjs/ui/screens/chat/ChatView.d.ts.map +1 -0
  261. package/lib/typescript/commonjs/ui/screens/chat/ChatView.styles.d.ts +349 -0
  262. package/lib/typescript/commonjs/ui/screens/chat/ChatView.styles.d.ts.map +1 -0
  263. package/lib/typescript/commonjs/ui/screens/chat/ChatView.types.d.ts +48 -0
  264. package/lib/typescript/commonjs/ui/screens/chat/ChatView.types.d.ts.map +1 -0
  265. package/lib/typescript/commonjs/ui/screens/conversations/ConversationsList.d.ts +10 -0
  266. package/lib/typescript/commonjs/ui/screens/conversations/ConversationsList.d.ts.map +1 -0
  267. package/lib/typescript/commonjs/ui/screens/conversations/ConversationsList.styles.d.ts +113 -0
  268. package/lib/typescript/commonjs/ui/screens/conversations/ConversationsList.styles.d.ts.map +1 -0
  269. package/lib/typescript/commonjs/ui/screens/conversations/ConversationsList.types.d.ts +31 -0
  270. package/lib/typescript/commonjs/ui/screens/conversations/ConversationsList.types.d.ts.map +1 -0
  271. package/lib/typescript/commonjs/ui/screens/home/HomeView.d.ts +17 -0
  272. package/lib/typescript/commonjs/ui/screens/home/HomeView.d.ts.map +1 -0
  273. package/lib/typescript/commonjs/ui/screens/home/HomeView.styles.d.ts +227 -0
  274. package/lib/typescript/commonjs/ui/screens/home/HomeView.styles.d.ts.map +1 -0
  275. package/lib/typescript/commonjs/ui/screens/home/HomeView.types.d.ts +40 -0
  276. package/lib/typescript/commonjs/ui/screens/home/HomeView.types.d.ts.map +1 -0
  277. package/lib/typescript/commonjs/ui/screens/home/greeting.d.ts +19 -0
  278. package/lib/typescript/commonjs/ui/screens/home/greeting.d.ts.map +1 -0
  279. package/lib/typescript/commonjs/ui/screens/pre-chat/PreChatForm.d.ts +7 -0
  280. package/lib/typescript/commonjs/ui/screens/pre-chat/PreChatForm.d.ts.map +1 -0
  281. package/lib/typescript/commonjs/ui/screens/pre-chat/PreChatForm.styles.d.ts +115 -0
  282. package/lib/typescript/commonjs/ui/screens/pre-chat/PreChatForm.styles.d.ts.map +1 -0
  283. package/lib/typescript/commonjs/ui/screens/pre-chat/PreChatForm.types.d.ts +20 -0
  284. package/lib/typescript/commonjs/ui/screens/pre-chat/PreChatForm.types.d.ts.map +1 -0
  285. package/lib/typescript/commonjs/ui/styles/global.d.ts +46 -0
  286. package/lib/typescript/commonjs/ui/styles/global.d.ts.map +1 -0
  287. package/lib/typescript/commonjs/ui/styles/theme.d.ts +103 -0
  288. package/lib/typescript/commonjs/ui/styles/theme.d.ts.map +1 -0
  289. package/lib/typescript/commonjs/ui/utils/conversations.d.ts +41 -0
  290. package/lib/typescript/commonjs/ui/utils/conversations.d.ts.map +1 -0
  291. package/lib/typescript/commonjs/ui/utils/html.d.ts +10 -0
  292. package/lib/typescript/commonjs/ui/utils/html.d.ts.map +1 -0
  293. package/lib/typescript/commonjs/ui/utils/native-gradient.d.ts +61 -0
  294. package/lib/typescript/commonjs/ui/utils/native-gradient.d.ts.map +1 -0
  295. package/lib/typescript/commonjs/ui/utils/rtl.d.ts +33 -0
  296. package/lib/typescript/commonjs/ui/utils/rtl.d.ts.map +1 -0
  297. package/lib/typescript/commonjs/ui/utils/safe-url.d.ts +21 -0
  298. package/lib/typescript/commonjs/ui/utils/safe-url.d.ts.map +1 -0
  299. package/lib/typescript/module/agent-ui-blocks.d.ts +20 -0
  300. package/lib/typescript/module/agent-ui-blocks.d.ts.map +1 -0
  301. package/lib/typescript/module/api/client.d.ts +115 -0
  302. package/lib/typescript/module/api/client.d.ts.map +1 -0
  303. package/lib/typescript/module/api/realtime.d.ts +39 -0
  304. package/lib/typescript/module/api/realtime.d.ts.map +1 -0
  305. package/lib/typescript/module/api/sse-parser.d.ts +13 -0
  306. package/lib/typescript/module/api/sse-parser.d.ts.map +1 -0
  307. package/lib/typescript/module/controller.d.ts +15 -0
  308. package/lib/typescript/module/controller.d.ts.map +1 -0
  309. package/lib/typescript/module/device-id.d.ts +15 -0
  310. package/lib/typescript/module/device-id.d.ts.map +1 -0
  311. package/lib/typescript/module/events.d.ts +41 -0
  312. package/lib/typescript/module/events.d.ts.map +1 -0
  313. package/lib/typescript/module/i18n.d.ts +78 -0
  314. package/lib/typescript/module/i18n.d.ts.map +1 -0
  315. package/lib/typescript/module/index.d.ts +103 -0
  316. package/lib/typescript/module/index.d.ts.map +1 -0
  317. package/lib/typescript/module/locales.d.ts +18 -0
  318. package/lib/typescript/module/locales.d.ts.map +1 -0
  319. package/lib/typescript/module/package.json +1 -0
  320. package/lib/typescript/module/push/push-notifications.d.ts +71 -0
  321. package/lib/typescript/module/push/push-notifications.d.ts.map +1 -0
  322. package/lib/typescript/module/state/use-widget-state.d.ts +10 -0
  323. package/lib/typescript/module/state/use-widget-state.d.ts.map +1 -0
  324. package/lib/typescript/module/state/widget-store.d.ts +227 -0
  325. package/lib/typescript/module/state/widget-store.d.ts.map +1 -0
  326. package/lib/typescript/module/storage.d.ts +42 -0
  327. package/lib/typescript/module/storage.d.ts.map +1 -0
  328. package/lib/typescript/module/types.d.ts +391 -0
  329. package/lib/typescript/module/types.d.ts.map +1 -0
  330. package/lib/typescript/module/ui/WidgetProvider.d.ts +15 -0
  331. package/lib/typescript/module/ui/WidgetProvider.d.ts.map +1 -0
  332. package/lib/typescript/module/ui/components/AgentUiBlocks.d.ts +27 -0
  333. package/lib/typescript/module/ui/components/AgentUiBlocks.d.ts.map +1 -0
  334. package/lib/typescript/module/ui/components/Avatar.d.ts +19 -0
  335. package/lib/typescript/module/ui/components/Avatar.d.ts.map +1 -0
  336. package/lib/typescript/module/ui/components/ConversationRow.d.ts +26 -0
  337. package/lib/typescript/module/ui/components/ConversationRow.d.ts.map +1 -0
  338. package/lib/typescript/module/ui/components/ErrorBoundary.d.ts +27 -0
  339. package/lib/typescript/module/ui/components/ErrorBoundary.d.ts.map +1 -0
  340. package/lib/typescript/module/ui/components/Gradient.d.ts +33 -0
  341. package/lib/typescript/module/ui/components/Gradient.d.ts.map +1 -0
  342. package/lib/typescript/module/ui/components/Launcher.d.ts +18 -0
  343. package/lib/typescript/module/ui/components/Launcher.d.ts.map +1 -0
  344. package/lib/typescript/module/ui/components/Markdown.d.ts +19 -0
  345. package/lib/typescript/module/ui/components/Markdown.d.ts.map +1 -0
  346. package/lib/typescript/module/ui/components/OutboundMessageCard.d.ts +20 -0
  347. package/lib/typescript/module/ui/components/OutboundMessageCard.d.ts.map +1 -0
  348. package/lib/typescript/module/ui/components/WidgetPanel.d.ts +26 -0
  349. package/lib/typescript/module/ui/components/WidgetPanel.d.ts.map +1 -0
  350. package/lib/typescript/module/ui/components/icons.d.ts +38 -0
  351. package/lib/typescript/module/ui/components/icons.d.ts.map +1 -0
  352. package/lib/typescript/module/ui/hooks/use-keyboard-overlap.d.ts +33 -0
  353. package/lib/typescript/module/ui/hooks/use-keyboard-overlap.d.ts.map +1 -0
  354. package/lib/typescript/module/ui/hooks/use-reduce-motion.d.ts +11 -0
  355. package/lib/typescript/module/ui/hooks/use-reduce-motion.d.ts.map +1 -0
  356. package/lib/typescript/module/ui/hooks/use-widget-insets.d.ts +16 -0
  357. package/lib/typescript/module/ui/hooks/use-widget-insets.d.ts.map +1 -0
  358. package/lib/typescript/module/ui/screens/chat/ChatView.d.ts +11 -0
  359. package/lib/typescript/module/ui/screens/chat/ChatView.d.ts.map +1 -0
  360. package/lib/typescript/module/ui/screens/chat/ChatView.styles.d.ts +349 -0
  361. package/lib/typescript/module/ui/screens/chat/ChatView.styles.d.ts.map +1 -0
  362. package/lib/typescript/module/ui/screens/chat/ChatView.types.d.ts +48 -0
  363. package/lib/typescript/module/ui/screens/chat/ChatView.types.d.ts.map +1 -0
  364. package/lib/typescript/module/ui/screens/conversations/ConversationsList.d.ts +10 -0
  365. package/lib/typescript/module/ui/screens/conversations/ConversationsList.d.ts.map +1 -0
  366. package/lib/typescript/module/ui/screens/conversations/ConversationsList.styles.d.ts +113 -0
  367. package/lib/typescript/module/ui/screens/conversations/ConversationsList.styles.d.ts.map +1 -0
  368. package/lib/typescript/module/ui/screens/conversations/ConversationsList.types.d.ts +31 -0
  369. package/lib/typescript/module/ui/screens/conversations/ConversationsList.types.d.ts.map +1 -0
  370. package/lib/typescript/module/ui/screens/home/HomeView.d.ts +17 -0
  371. package/lib/typescript/module/ui/screens/home/HomeView.d.ts.map +1 -0
  372. package/lib/typescript/module/ui/screens/home/HomeView.styles.d.ts +227 -0
  373. package/lib/typescript/module/ui/screens/home/HomeView.styles.d.ts.map +1 -0
  374. package/lib/typescript/module/ui/screens/home/HomeView.types.d.ts +40 -0
  375. package/lib/typescript/module/ui/screens/home/HomeView.types.d.ts.map +1 -0
  376. package/lib/typescript/module/ui/screens/home/greeting.d.ts +19 -0
  377. package/lib/typescript/module/ui/screens/home/greeting.d.ts.map +1 -0
  378. package/lib/typescript/module/ui/screens/pre-chat/PreChatForm.d.ts +7 -0
  379. package/lib/typescript/module/ui/screens/pre-chat/PreChatForm.d.ts.map +1 -0
  380. package/lib/typescript/module/ui/screens/pre-chat/PreChatForm.styles.d.ts +115 -0
  381. package/lib/typescript/module/ui/screens/pre-chat/PreChatForm.styles.d.ts.map +1 -0
  382. package/lib/typescript/module/ui/screens/pre-chat/PreChatForm.types.d.ts +20 -0
  383. package/lib/typescript/module/ui/screens/pre-chat/PreChatForm.types.d.ts.map +1 -0
  384. package/lib/typescript/module/ui/styles/global.d.ts +46 -0
  385. package/lib/typescript/module/ui/styles/global.d.ts.map +1 -0
  386. package/lib/typescript/module/ui/styles/theme.d.ts +103 -0
  387. package/lib/typescript/module/ui/styles/theme.d.ts.map +1 -0
  388. package/lib/typescript/module/ui/utils/conversations.d.ts +41 -0
  389. package/lib/typescript/module/ui/utils/conversations.d.ts.map +1 -0
  390. package/lib/typescript/module/ui/utils/html.d.ts +10 -0
  391. package/lib/typescript/module/ui/utils/html.d.ts.map +1 -0
  392. package/lib/typescript/module/ui/utils/native-gradient.d.ts +61 -0
  393. package/lib/typescript/module/ui/utils/native-gradient.d.ts.map +1 -0
  394. package/lib/typescript/module/ui/utils/rtl.d.ts +33 -0
  395. package/lib/typescript/module/ui/utils/rtl.d.ts.map +1 -0
  396. package/lib/typescript/module/ui/utils/safe-url.d.ts +21 -0
  397. package/lib/typescript/module/ui/utils/safe-url.d.ts.map +1 -0
  398. package/metro.js +40 -0
  399. package/package.json +116 -0
  400. package/src/agent-ui-blocks.ts +302 -0
  401. package/src/api/client.ts +332 -0
  402. package/src/api/realtime.ts +225 -0
  403. package/src/api/sse-parser.ts +51 -0
  404. package/src/controller.ts +20 -0
  405. package/src/device-id.ts +71 -0
  406. package/src/events.ts +74 -0
  407. package/src/i18n.ts +114 -0
  408. package/src/index.tsx +199 -0
  409. package/src/locales.ts +80 -0
  410. package/src/push/push-notifications.ts +254 -0
  411. package/src/state/use-widget-state.ts +20 -0
  412. package/src/state/widget-store.ts +1815 -0
  413. package/src/storage.ts +153 -0
  414. package/src/types.ts +445 -0
  415. package/src/ui/WidgetProvider.tsx +434 -0
  416. package/src/ui/components/AgentUiBlocks.tsx +912 -0
  417. package/src/ui/components/Avatar.tsx +86 -0
  418. package/src/ui/components/ConversationRow.tsx +163 -0
  419. package/src/ui/components/ErrorBoundary.tsx +49 -0
  420. package/src/ui/components/Gradient.tsx +165 -0
  421. package/src/ui/components/Launcher.tsx +128 -0
  422. package/src/ui/components/Markdown.tsx +291 -0
  423. package/src/ui/components/OutboundMessageCard.tsx +154 -0
  424. package/src/ui/components/WidgetPanel.tsx +133 -0
  425. package/src/ui/components/icons.tsx +315 -0
  426. package/src/ui/hooks/use-keyboard-overlap.ts +134 -0
  427. package/src/ui/hooks/use-reduce-motion.ts +39 -0
  428. package/src/ui/hooks/use-widget-insets.ts +44 -0
  429. package/src/ui/screens/chat/ChatView.styles.ts +357 -0
  430. package/src/ui/screens/chat/ChatView.tsx +690 -0
  431. package/src/ui/screens/chat/ChatView.types.ts +46 -0
  432. package/src/ui/screens/conversations/ConversationsList.styles.ts +111 -0
  433. package/src/ui/screens/conversations/ConversationsList.tsx +144 -0
  434. package/src/ui/screens/conversations/ConversationsList.types.ts +33 -0
  435. package/src/ui/screens/home/HomeView.styles.ts +246 -0
  436. package/src/ui/screens/home/HomeView.tsx +336 -0
  437. package/src/ui/screens/home/HomeView.types.ts +42 -0
  438. package/src/ui/screens/home/greeting.ts +50 -0
  439. package/src/ui/screens/pre-chat/PreChatForm.styles.ts +120 -0
  440. package/src/ui/screens/pre-chat/PreChatForm.tsx +221 -0
  441. package/src/ui/screens/pre-chat/PreChatForm.types.ts +22 -0
  442. package/src/ui/styles/global.ts +50 -0
  443. package/src/ui/styles/theme.ts +155 -0
  444. package/src/ui/utils/conversations.ts +122 -0
  445. package/src/ui/utils/html.ts +58 -0
  446. package/src/ui/utils/native-gradient.ts +60 -0
  447. package/src/ui/utils/rtl.ts +43 -0
  448. package/src/ui/utils/safe-url.ts +63 -0
@@ -0,0 +1,189 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * SSE transport over `GET /api/widget/sse`, authenticated with an
5
+ * `Authorization: Bearer` header (never the query string, which ends up in
6
+ * proxy and server access logs).
7
+ *
8
+ * Uses React Native's streaming XMLHttpRequest and handles both network
9
+ * failures and successful stream EOF with exponential reconnect backoff.
10
+ * Auth failures never retry here: 401 hands over to the store's re-init,
11
+ * while 403 is terminal.
12
+ */
13
+
14
+ import { RepzoWidgetError } from "./client.js";
15
+ import { SseParser } from "./sse-parser.js";
16
+
17
+ /** Server event names, mapped to the shorter names the store switches on. */
18
+ const SERVER_EVENTS = {
19
+ connected: 'connected',
20
+ 'widget.message.new': 'message.new',
21
+ 'widget.typing.start': 'typing.start',
22
+ 'widget.typing.stop': 'typing.stop',
23
+ 'widget.conversation.updated': 'conversation.updated',
24
+ 'widget.conversation.event': 'conversation.event'
25
+ };
26
+ const BASE_RECONNECT_MS = 1_000;
27
+ const MAX_RECONNECT_MS = 60_000;
28
+ /** XHR readyState DONE — the error body is only complete from here. */
29
+ const XHR_DONE = 4;
30
+ /** If DONE never follows a 403 seen mid-body, act on what arrived. */
31
+ const AUTH_ERROR_BODY_WAIT_MS = 3_000;
32
+ export class WidgetRealtime {
33
+ source = null;
34
+ connected = false;
35
+ reconnectTimer = null;
36
+ attempt = 0;
37
+ closedByUs = false;
38
+ url = null;
39
+ token = null;
40
+ handler = null;
41
+ authHooks = null;
42
+ authErrorTimer = null;
43
+ connect(baseUrl, token, handler, authHooks) {
44
+ this.close();
45
+ this.url = `${baseUrl.replace(/\/$/, '')}/api/widget/sse`;
46
+ this.token = token;
47
+ this.handler = handler;
48
+ this.authHooks = authHooks ?? null;
49
+ this.closedByUs = false;
50
+ this.open();
51
+ }
52
+ open() {
53
+ if (!this.url || !this.token || !this.handler) return;
54
+ const source = new XMLHttpRequest();
55
+ this.source = source;
56
+ let offset = 0;
57
+ const isCurrent = () => this.source === source && !this.closedByUs;
58
+ const parser = new SseParser((name, raw) => {
59
+ if (!isCurrent() || !Object.prototype.hasOwnProperty.call(SERVER_EVENTS, name)) return;
60
+ let payload = null;
61
+ if (raw) {
62
+ try {
63
+ payload = JSON.parse(raw);
64
+ } catch {
65
+ payload = raw;
66
+ }
67
+ }
68
+ this.handler?.(SERVER_EVENTS[name], payload);
69
+ });
70
+ const reconnect = () => {
71
+ if (!isCurrent()) return;
72
+ this.handler?.('error', null);
73
+ // A handler may synchronously close or replace this connection.
74
+ if (isCurrent()) this.scheduleReconnect();
75
+ };
76
+ const read = () => {
77
+ if (!isCurrent() || source.readyState < 3) return;
78
+ const complete = source.readyState === XHR_DONE;
79
+ const status = source.status;
80
+ if (status === 401 || status === 403) {
81
+ if (!complete && status === 403) {
82
+ // Wait for the structured error body, but never wait indefinitely.
83
+ this.authErrorTimer ??= setTimeout(() => {
84
+ if (isCurrent()) this.handleAuthError(status, source.responseText);
85
+ }, AUTH_ERROR_BODY_WAIT_MS);
86
+ return;
87
+ }
88
+ this.handleAuthError(status, source.responseText);
89
+ return;
90
+ }
91
+ if (status >= 200 && status < 300) {
92
+ if (!this.connected) {
93
+ this.connected = true;
94
+ this.attempt = 0;
95
+ }
96
+ const text = source.responseText || '';
97
+ const chunk = text.slice(offset);
98
+ offset = text.length;
99
+ parser.push(chunk);
100
+ // A 200 EOF is a disconnected stream too. Tear it down and notify the
101
+ // store so the next `connected` event also triggers history catch-up.
102
+ if (complete) reconnect();
103
+ } else if (complete) {
104
+ reconnect();
105
+ }
106
+ };
107
+ source.onreadystatechange = read;
108
+ source.onprogress = read;
109
+ source.onerror = reconnect;
110
+ source.ontimeout = reconnect;
111
+ source.onabort = reconnect;
112
+ try {
113
+ source.open('GET', this.url, true);
114
+ source.timeout = 0;
115
+ source.setRequestHeader('Accept', 'text/event-stream');
116
+ source.setRequestHeader('Cache-Control', 'no-cache');
117
+ source.setRequestHeader('Authorization', `Bearer ${this.token}`);
118
+ source.send();
119
+ } catch {
120
+ reconnect();
121
+ }
122
+ }
123
+ handleAuthError(status, rawBody) {
124
+ const token = this.token;
125
+ const hooks = this.authHooks;
126
+ // Backoff cannot fix an auth failure — stop and let the store decide.
127
+ this.close();
128
+ if (!hooks || !token) return;
129
+ if (status === 401) {
130
+ hooks.onUnauthorized(token);
131
+ return;
132
+ }
133
+ let body = null;
134
+ try {
135
+ body = rawBody ? JSON.parse(rawBody) : null;
136
+ } catch {
137
+ body = null;
138
+ }
139
+ hooks.onForbidden(RepzoWidgetError.fromResponse(403, body));
140
+ }
141
+ scheduleReconnect() {
142
+ if (this.closedByUs || this.reconnectTimer) return;
143
+ this.teardownSource();
144
+ const delay = Math.min(BASE_RECONNECT_MS * 2 ** this.attempt, MAX_RECONNECT_MS);
145
+ // Jitter keeps a fleet of devices from reconnecting in lockstep.
146
+ const jittered = delay * (0.7 + Math.random() * 0.6);
147
+ this.attempt += 1;
148
+ this.reconnectTimer = setTimeout(() => {
149
+ this.reconnectTimer = null;
150
+ if (this.closedByUs) return;
151
+ this.open();
152
+ }, jittered);
153
+ }
154
+ teardownSource() {
155
+ const source = this.source;
156
+ this.source = null;
157
+ this.connected = false;
158
+ if (this.authErrorTimer) {
159
+ clearTimeout(this.authErrorTimer);
160
+ this.authErrorTimer = null;
161
+ }
162
+ if (!source) return;
163
+ source.onreadystatechange = null;
164
+ source.onprogress = null;
165
+ source.onerror = null;
166
+ source.ontimeout = null;
167
+ source.onabort = null;
168
+ source.abort();
169
+ }
170
+ get isConnected() {
171
+ // Includes a handshake in progress so the store does not replace the
172
+ // connection that a successful re-init just started. EOF clears source.
173
+ return this.source !== null;
174
+ }
175
+ close() {
176
+ this.closedByUs = true;
177
+ this.attempt = 0;
178
+ if (this.reconnectTimer) {
179
+ clearTimeout(this.reconnectTimer);
180
+ this.reconnectTimer = null;
181
+ }
182
+ if (this.authErrorTimer) {
183
+ clearTimeout(this.authErrorTimer);
184
+ this.authErrorTimer = null;
185
+ }
186
+ this.teardownSource();
187
+ }
188
+ }
189
+ //# sourceMappingURL=realtime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["RepzoWidgetError","SseParser","SERVER_EVENTS","connected","BASE_RECONNECT_MS","MAX_RECONNECT_MS","XHR_DONE","AUTH_ERROR_BODY_WAIT_MS","WidgetRealtime","source","reconnectTimer","attempt","closedByUs","url","token","handler","authHooks","authErrorTimer","connect","baseUrl","close","replace","open","XMLHttpRequest","offset","isCurrent","parser","name","raw","Object","prototype","hasOwnProperty","call","payload","JSON","parse","reconnect","scheduleReconnect","read","readyState","complete","status","setTimeout","handleAuthError","responseText","text","chunk","slice","length","push","onreadystatechange","onprogress","onerror","ontimeout","onabort","timeout","setRequestHeader","send","rawBody","hooks","onUnauthorized","body","onForbidden","fromResponse","teardownSource","delay","Math","min","jittered","random","clearTimeout","abort","isConnected"],"sourceRoot":"../../../src","sources":["api/realtime.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,gBAAgB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AAI,CAACA,cAAc,GAAG,IAAI;IAC5B;IACA,IAAI,CAAC+C,cAAc,CAAC,CAAC;EACvB;AACF","ignoreList":[]}
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+
3
+ /** Incremental SSE framing. A blank line dispatches an event; EOF alone does not. */
4
+ export class SseParser {
5
+ line = '';
6
+ event = '';
7
+ data = [];
8
+ afterCR = false;
9
+ atStart = true;
10
+ constructor(dispatch) {
11
+ this.dispatch = dispatch;
12
+ }
13
+ push(chunk) {
14
+ for (const char of chunk) {
15
+ if (this.atStart) {
16
+ this.atStart = false;
17
+ if (char === '\uFEFF') continue;
18
+ }
19
+ if (this.afterCR) {
20
+ this.afterCR = false;
21
+ if (char === '\n') continue;
22
+ }
23
+ if (char === '\r' || char === '\n') {
24
+ const line = this.line;
25
+ this.line = '';
26
+ this.afterCR = char === '\r';
27
+ this.readLine(line);
28
+ } else {
29
+ this.line += char;
30
+ }
31
+ }
32
+ }
33
+ readLine(line) {
34
+ if (!line) {
35
+ const event = this.event || 'message';
36
+ const data = this.data;
37
+ this.event = '';
38
+ this.data = [];
39
+ if (data.length) this.dispatch(event, data.join('\n'));
40
+ return;
41
+ }
42
+ if (line.startsWith(':')) return; // heartbeat/comment
43
+ const colon = line.indexOf(':');
44
+ const field = colon < 0 ? line : line.slice(0, colon);
45
+ let value = colon < 0 ? '' : line.slice(colon + 1);
46
+ if (value.startsWith(' ')) value = value.slice(1);
47
+ if (field === 'event') this.event = value;
48
+ if (field === 'data') this.data.push(value);
49
+ // Reconnect timing belongs to the transport. The store catches up from
50
+ // history on reconnect, so no server retry/id fields are needed here.
51
+ }
52
+ }
53
+ //# sourceMappingURL=sse-parser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["SseParser","line","event","data","afterCR","atStart","constructor","dispatch","push","chunk","char","readLine","length","join","startsWith","colon","indexOf","field","slice","value"],"sourceRoot":"../../../src","sources":["api/sse-parser.ts"],"mappings":";;AAAA;AACA,OAAO,MAAMA,SAAS,CA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E,OAAO,CAAC;IAClC,MAAMC,KAAK,GAAGd,IAAI,CAACe,OAAO,CAAC,GAAG,CAAC;IAC/B,MAAMC,KAAK,GAAGF,KAAK,GAAG,CAAC,GAAGd,IAAI,GAAGA,IAAI,CAACiB,KAAK,CAAC,CAAC,EAAEH,KAAK,CAAC;IACrD,IAAII,KAAK,GAAGJ,KAAK,GAAG,CAAC,GAAG,EAAE,GAAGd,IAAI,CAACiB,KAAK,CAACH,KAAK,GAAG,CAAC,CAAC;IAClD,IAAII,KAAK,CAACL,UAAU,CAAC,GAAG,CAAC,EAAEK,KAAK,GAAGA,KAAK,CAACD,KAAK,CAAC,CAAC,CAAC;IACjD,IAAID,KAAK,KAAK,OAAO,EAAE,IAAI,CAACf,KAAK,GAAGiB,KAAK;IACzC,IAAIF,KAAK,KAAK,MAAM,EAAE,IAAI,CAACd,IAAI,CAACK,IAAI,CAACW,KAAK,CAAC;IAC3C;IACA;EACF;AACF","ignoreList":[]}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Process-wide singleton that owns the store (and therefore the session, the
5
+ * SSE stream and the unread count). Imperative API calls land here whether or
6
+ * not `<RepzoWidgetProvider>` is mounted; the provider is a pure subscriber, so
7
+ * commands issued before boot finishes simply land in state and render once the
8
+ * provider mounts.
9
+ */
10
+
11
+ import { WidgetStore } from "./state/widget-store.js";
12
+ class RepzoWidgetController {
13
+ store = new WidgetStore();
14
+ get events() {
15
+ return this.store.events;
16
+ }
17
+ }
18
+ export const controller = new RepzoWidgetController();
19
+ //# sourceMappingURL=controller.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["WidgetStore","RepzoWidgetController","store","events","controller"],"sourceRoot":"../../src","sources":["controller.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,WAAW,QAAQ,yBAAsB;AAElD,MAAMC,qBAAqB,CAAC;EACjBC,KAAK,GAAG,IAAIF,WAAW,CAAC,CAAC;EAElC,IAAIG,MAAMA,CAAA,EAAG;IACX,OAAO,IAAI,CAACD,KAAK,CAACC,MAAM;EAC1B;AACF;AAEA,OAAO,MAAMC,UAAU,GAAG,IAAIH,qBAAqB,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Per-install id sent as `trackingVisitorId`. This is the mobile equivalent of
5
+ * the web widget's `repzo_vid` cookie: it lets the CRM stitch an anonymous
6
+ * visitor back together if the session token is ever lost. Stable until
7
+ * `logout()`, which rotates it.
8
+ */
9
+
10
+ import { DEVICE_ID_KEY, Storage } from "./storage.js";
11
+ let cached = null;
12
+
13
+ /**
14
+ * 16 random bytes from `crypto.getRandomValues` when the runtime has it (RN
15
+ * with a polyfill, newer Hermes); otherwise Math.random, which is fine for a
16
+ * correlation id but guessable.
17
+ */
18
+ function randomBytes() {
19
+ const bytes = new Uint8Array(16);
20
+ const cryptoApi = globalThis.crypto;
21
+ if (typeof cryptoApi?.getRandomValues === 'function') {
22
+ try {
23
+ cryptoApi.getRandomValues(bytes);
24
+ return bytes;
25
+ } catch {
26
+ // Present but unusable (some polyfills throw) — fall through.
27
+ }
28
+ }
29
+ for (let index = 0; index < bytes.length; index += 1) {
30
+ bytes[index] = Math.random() * 256 | 0;
31
+ }
32
+ return bytes;
33
+ }
34
+
35
+ /** RFC-4122 v4. */
36
+ function uuidv4() {
37
+ const bytes = randomBytes();
38
+ bytes[6] = bytes[6] & 0x0f | 0x40; // version 4
39
+ bytes[8] = bytes[8] & 0x3f | 0x80; // RFC-4122 variant
40
+ const hex = Array.from(bytes, byte => byte.toString(16).padStart(2, '0')).join('');
41
+ return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
42
+ }
43
+ export async function getDeviceId() {
44
+ if (cached) return cached;
45
+ const stored = await Storage.getItem(DEVICE_ID_KEY);
46
+ if (stored) {
47
+ cached = stored;
48
+ return stored;
49
+ }
50
+ const created = uuidv4();
51
+ cached = created;
52
+ await Storage.setItem(DEVICE_ID_KEY, created);
53
+ return created;
54
+ }
55
+
56
+ /** Only used by tests and `rotateDeviceId()`. */
57
+ export function resetDeviceIdCache() {
58
+ cached = null;
59
+ }
60
+
61
+ /**
62
+ * Called by `logout()`: the id stitches anonymous sessions together, so on a
63
+ * shared device the next visitor must not inherit the previous user's.
64
+ */
65
+ export async function rotateDeviceId() {
66
+ cached = null;
67
+ await Storage.removeItem(DEVICE_ID_KEY);
68
+ }
69
+ //# sourceMappingURL=device-id.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["DEVICE_ID_KEY","Storage","cached","randomBytes","bytes","Uint8Array","cryptoApi","globalThis","crypto","getRandomValues","index","length","Math","random","uuidv4","hex","Array","from","byte","toString","padStart","join","slice","getDeviceId","stored","getItem","created","setItem","resetDeviceIdCache","rotateDeviceId","removeItem"],"sourceRoot":"../../src","sources":["device-id.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,aAAa,EAAEC,OAAO,QAAQ,cAAW;AAElD,IAAIC,MAAqB,GAAG,IAAI;;AAEhC;AACA;AACA;AACA;AACA;AACA,SAASC,WAAWA,CAAA,EAAe;EACjC,MAAMC,KAAK,GAAG,IAAIC,UAAU,CAAC,EAAE,CAAC;EAChC,MAAMC,SAAS,GAAIC,UAAU,CAC1BC,MAAM;EACT,IAAI,OAAOF,SAAS,EAAEG,eAAe,KAAK,UAAU,EAAE;IACpD,IAAI;MACFH,SAAS,CAACG,eAAe,CAACL,KAAK,CAAC;MAChC,OAAOA,KAAK;IACd,CAAC,CAAC,MAAM;MACN;IAAA;EAEJ;EACA,KAAK,IAAIM,KAAK,GAAG,CAAC,EAAEA,KAAK,GAAGN,KAAK,CAACO,MAAM,EAAED,KAAK,IAAI,CAAC,EAAE;IACpDN,KAAK,CAACM,KAAK,CAAC,GAAIE,IAAI,CAACC,MAAM,CAAC,CAAC,GAAG,GAAG,GAAI,CAAC;E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,EAAS;EACzC1B,MAAM,GAAG,IAAI;AACf;;AAEA;AACA;AACA;AACA;AACA,OAAO,eAAe2B,cAAcA,CAAA,EAAkB;EACpD3B,MAAM,GAAG,IAAI;EACb,MAAMD,OAAO,CAAC6B,UAAU,CAAC9B,aAAa,CAAC;AACzC","ignoreList":[]}
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Tiny typed event emitter. Pure JS — no NativeEventEmitter, so listeners work
5
+ * identically on iOS, Android and in tests.
6
+ */
7
+
8
+ export const RepzoWidgetEvents = {
9
+ UnreadCountDidChange: 'repzoWidget.unreadCountDidChange',
10
+ MessageDidArrive: 'repzoWidget.messageDidArrive',
11
+ /** The visitor opened a thread — hosts use it to dismiss that conversation's push notification. */
12
+ ConversationDidRead: 'repzoWidget.conversationDidRead',
13
+ WindowDidShow: 'repzoWidget.windowDidShow',
14
+ WindowDidHide: 'repzoWidget.windowDidHide'
15
+ };
16
+ export class EventEmitter {
17
+ listeners = new Map();
18
+ addListener(event, listener) {
19
+ const current = this.listeners.get(event) ?? new Set();
20
+ current.add(listener);
21
+ this.listeners.set(event, current);
22
+ return {
23
+ remove: () => {
24
+ this.listeners.get(event)?.delete(listener);
25
+ }
26
+ };
27
+ }
28
+ emit(event, payload) {
29
+ const current = this.listeners.get(event);
30
+ if (!current) return;
31
+ // Copy first: a listener may remove itself while we iterate.
32
+ for (const listener of Array.from(current)) {
33
+ try {
34
+ listener(payload);
35
+ } catch (error) {
36
+ console.warn('[repzo-widget] event listener threw', error);
37
+ }
38
+ }
39
+ }
40
+ removeAllListeners() {
41
+ this.listeners.clear();
42
+ }
43
+ }
44
+ //# sourceMappingURL=events.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["RepzoWidgetEvents","UnreadCountDidChange","MessageDidArrive","ConversationDidRead","WindowDidShow","WindowDidHide","EventEmitter","listeners","Map","addListener","event","listener","current","get","Set","add","set","remove","delete","emit","payload","Array","from","error","console","warn","removeAllListeners","clear"],"s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[]}
@@ -0,0 +1,99 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Translations come from the widget config (`translations[locale][key]`), with
5
+ * the widget's default locale as the fallback chain — same lookup as the web
6
+ * widget's `t()` in `client/src/widget/App.tsx`.
7
+ */
8
+
9
+ import { BUNDLED_TRANSLATIONS, baseLanguage } from "./locales.js";
10
+ /**
11
+ * Resolution order, most specific first: what the workspace configured for the
12
+ * active locale, what the SDK ships for it, then the same pair for the
13
+ * workspace's default locale, and finally the English built-in. Dashboard
14
+ * copy always outranks a bundled translation.
15
+ */
16
+ export function createTranslator(config, locale) {
17
+ const defaultLocale = config?.defaultLocale || 'en';
18
+ const active = baseLanguage(locale);
19
+ const fallbackLocale = baseLanguage(defaultLocale);
20
+ return (key, fallback) => config?.translations?.[locale]?.[key] || config?.translations?.[active]?.[key] || BUNDLED_TRANSLATIONS[active]?.[key] || config?.translations?.[defaultLocale]?.[key] || BUNDLED_TRANSLATIONS[fallbackLocale]?.[key] || fallback;
21
+ }
22
+ export const DEFAULT_LABELS = {
23
+ back: 'Back',
24
+ loading: 'Loading...',
25
+ loadEarlier: 'Load earlier messages',
26
+ emptyConversation: 'Send a message to start the conversation',
27
+ messagePlaceholder: 'Type a message...',
28
+ attachFile: 'Attach file',
29
+ failedToSend: 'Failed to send',
30
+ thinking: 'Typing',
31
+ messages: 'Messages',
32
+ noMessages: 'No messages yet',
33
+ historyHidden: 'Conversation history is hidden',
34
+ startBelow: 'Start a conversation below',
35
+ preChatTitle: 'Before we chat',
36
+ preChatSubtitle: 'Let us know a bit about you so we can help you better.',
37
+ preChatSkip: 'Skip',
38
+ preChatSubmit: 'Start chat',
39
+ viewPreviousConversations: 'View previous conversations',
40
+ homeRecentTitle: 'Recent',
41
+ homeViewAllCount: 'View all ({count})',
42
+ homeNoConversations: 'Your conversations will show up here',
43
+ homeStatusOnline: "We're online",
44
+ homeStatusAway: "We're away",
45
+ unreadBadge: '{count} unread',
46
+ team: 'Team',
47
+ home: 'Home',
48
+ close: 'Close',
49
+ retry: 'Retry',
50
+ connectionError: 'We could not load the chat. Please try again.',
51
+ connecting: 'Connecting you to the team',
52
+ // Terminal errors — no Retry, nothing the visitor can fix from here.
53
+ chatUnavailable: 'Chat is not available right now.',
54
+ identityVerificationError: "We couldn't verify your account. Please sign in again.",
55
+ // Shown if the widget's own UI hits a render error.
56
+ widgetCrashed: 'Something went wrong.',
57
+ // Relative timestamps on the conversation lists.
58
+ timeJustNow: 'Just now',
59
+ timeMinutes: '{count}m',
60
+ timeHours: '{count}h',
61
+ timeDays: '{count}d',
62
+ timeMonths: '{count}mo',
63
+ timeYears: '{count}y',
64
+ // Day separators inside a thread.
65
+ today: 'Today',
66
+ yesterday: 'Yesterday',
67
+ conversationUpdated: 'Conversation updated',
68
+ // Forms.
69
+ procedureSend: 'Send details',
70
+ procedureSent: 'Sent',
71
+ fieldRequired: '{field} is required',
72
+ invalidEmail: 'Enter a valid email address',
73
+ working: 'Working...',
74
+ // Proactive card.
75
+ outboundTitle: 'New update',
76
+ outboundCta: 'Learn more',
77
+ dismiss: 'Dismiss',
78
+ // Rich blocks an agent can send.
79
+ blockService: 'Service',
80
+ blockProduct: 'Product',
81
+ blockChooseTime: 'Choose a time',
82
+ blockProfessional: 'Professional',
83
+ blockPriceOffer: 'Price offer'
84
+ };
85
+ /**
86
+ * Fill `{token}` placeholders in a translated string. Interpolation belongs in
87
+ * the string layer so translators keep control of word order.
88
+ */
89
+ export function formatLabel(template, values) {
90
+ return template.replace(/\{(\w+)\}/g, (match, key) => key in values ? String(values[key]) : match);
91
+ }
92
+ export function buildLabels(translate) {
93
+ const labels = {};
94
+ Object.keys(DEFAULT_LABELS).forEach(key => {
95
+ labels[key] = translate(key, DEFAULT_LABELS[key]);
96
+ });
97
+ return labels;
98
+ }
99
+ //# sourceMappingURL=i18n.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["BUNDLED_TRANSLATIONS","baseLanguage","createTranslator","config","locale","defaultLocale","active","fallbackLocale","key","fallback","translations","DEFAULT_LABELS","back","loading","loadEarlier","emptyConversation","messagePlaceholder","attachFile","failedToSend","thinking","messages","noMessages","historyHidden","startBelow","preChatTitle","preChatSubtitle","preChatSkip","preChatSubmit","viewPreviousConversations","homeRecentTitle","homeViewAllCount","homeNoConversations","homeStatusOnline","homeStatusAway","unreadBadge","team","home","close","retry","connectionError","connecting","chatUnavailable","identityVerificationError","widgetCrashed","timeJustNow","timeMinutes","timeHours","timeDays","timeMonths","timeYears","today","yesterday","conversationUpdated","procedureSend","procedureSent","fieldRequired","invalidEmail","working","outboundTitle","outboundCta","dismiss","blockService","blockProduct","blockChooseTime","blockProfessional","blockPriceOffer","formatLabel","template","values","replace","match","String","buildLabels","translate","labels","Object","keys","forEach"],"sourceRoot":"../../src","sources":["i18n.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;;AAEA,SAASA,oBAAoB,EAAEC,YAAY,QAAQ,cAAW;AAK9D;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,gBAAgBA,CAACC,MAA2B,EAAEC,MAAc,EAAc;EACxF,MAAMC,aAAa,GAAGF,MAAM,EAAEE,aAAa,IAAI,IAAI;EACnD,MAAMC,MAAM,GAAGL,YAAY,CAACG,MAAM,CAAC;EACnC,MAAMG,cAAc,GAAGN,YAAY,CAACI,aAAa,CAAC;EAElD,OAAO,CAACG,GAAG,EAAEC,QAAQ,KACnBN,MAAM,EAAEO,YAAY,GAAGN,MAAM,CAAC,GAAGI,GAAG,CAAC,IACrCL,MAAM,EAAEO,YAAY,GAAGJ,MAAM,CAAC,GAAGE,GAAG,CAAC,IACrCR,oBAAoB,CAACM,MAAM,CAAC,GAAGE,GAAG,CAAgC,IAClEL,MAAM,EAAEO,YAAY,GAAGL,aAAa,CAAC,GAAGG,GAAG,CAAC,IAC5CR,oBAAoB,CAACO,cAAc,CAAC,GAAGC,GAAG,CAAgC,IAC1EC,QAAQ;AACZ;AAEA,OAAO,MAAME,cAAc,GAAG;EAC5BC,IAAI,EAA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C,OAAO,EAAE,YAAY;EACrB;EACAC,aAAa,EAAE,YAAY;EAC3BC,WAAW,EAAE,YAAY;EACzBC,OAAO,EAAE,SAAS;EAClB;EACAC,YAAY,EAAE,SAAS;EACvBC,YAAY,EAAE,SAAS;EACvBC,eAAe,EAAE,eAAe;EAChCC,iBAAiB,EAAE,cAAc;EACjCC,eAAe,EAAE;AACnB,CAAU;AAIV;AACA;AACA;AACA;AACA,OAAO,SAASC,WAAWA,CAACC,QAAgB,EAAEC,MAAuC,EAAU;EAC7F,OAAOD,QAAQ,CAACE,OAAO,CAAC,YAAY,EAAE,CAACC,KAAK,EAAE9D,GAAW,KACvDA,GAAG,IAAI4D,MAAM,GAAGG,MAAM,CAACH,MAAM,CAAC5D,GAAG,CAAC,CAAC,GAAG8D,KACxC,CAAC;AACH;AAEA,OAAO,SAASE,WAAWA,CAACC,SAAqB,EAA4B;EAC3E,MAAMC,MAAM,GAAG,CAAC,CAA6B;EAC5CC,MAAM,CAACC,IAAI,CAACjE,cAAc,CAAC,CAAgBkE,OAAO,CAAErE,GAAG,IAAK;IAC3DkE,MAAM,CAAClE,GAAG,CAAC,GAAGiE,SAAS,CAACjE,GAAG,EAAEG,cAAc,CAACH,GAAG,CAAC,CAAC;EACnD,CAAC,CAAC;EACF,OAAOkE,MAAM;AACf","ignoreList":[]}
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * @repzo/widget-react-native — the Repzo chat widget for React Native.
5
+ *
6
+ * Pure JavaScript: no native modules, no config plugin, no pod install. The
7
+ * public surface mirrors `@intercom/intercom-react-native` so swapping the two
8
+ * is a rename at each call site.
9
+ */
10
+
11
+ import { controller } from "./controller.js";
12
+ import { RepzoWidgetEvents } from "./events.js";
13
+ import { setSecureStorageAdapter, setStorageAdapter } from "./storage.js";
14
+ export { RepzoWidgetProvider } from "./ui/WidgetProvider.js";
15
+ export { Launcher as RepzoWidgetLauncher } from "./ui/components/Launcher.js";
16
+ export { RepzoWidgetEvents } from "./events.js";
17
+ export { RepzoWidgetError } from "./api/client.js";
18
+ export { DEFAULT_BASE_URL } from "./types.js";
19
+ export { useWidgetState } from "./state/use-widget-state.js";
20
+ /** Spaces the widget can open into — the analogue of Intercom's `Space`. */
21
+ export let Space = /*#__PURE__*/function (Space) {
22
+ Space["home"] = "home";
23
+ Space["messages"] = "messages";
24
+ return Space;
25
+ }({});
26
+ const RepzoWidget = {
27
+ boot: options => controller.store.boot(options),
28
+ loginUnidentifiedUser: () => controller.store.loginUnidentifiedUser(),
29
+ loginUserWithUserAttributes: user => controller.store.loginUserWithUserAttributes(user),
30
+ updateUser: attributes => controller.store.updateUser(attributes),
31
+ logout: () => controller.store.logout(),
32
+ present: async () => {
33
+ controller.store.present();
34
+ },
35
+ presentSpace: async space => {
36
+ controller.store.present(space);
37
+ },
38
+ presentConversation: conversationId => controller.store.openConversation(conversationId),
39
+ hide: async () => {
40
+ controller.store.hide();
41
+ },
42
+ getUnreadConversationCount: async () => Object.values(controller.store.getState().unreadByConversation).filter(count => count > 0).length,
43
+ getUnreadMessageCount: async () => controller.store.getState().unreadCount,
44
+ logEvent: async (eventName, metadata) => {
45
+ controller.store.track(eventName, metadata ?? {});
46
+ },
47
+ setLocale: locale => controller.store.setLocale(locale),
48
+ addEventListener: (event, listener) => controller.events.addListener(event, listener),
49
+ setStorageAdapter: adapter => setStorageAdapter(adapter),
50
+ setSecureStorageAdapter: adapter => setSecureStorageAdapter(adapter),
51
+ setPushToken: options => controller.store.push.setManualToken(options)
52
+ };
53
+ export default RepzoWidget;
54
+ export { RepzoWidgetEvents as Events };
55
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["controller","RepzoWidgetEvents","setSecureStorageAdapter","setStorageAdapter","RepzoWidgetProvider","Launcher","RepzoWidgetLauncher","RepzoWidgetError","DEFAULT_BASE_URL","useWidgetState","Space","RepzoWidget","boot","options","store","loginUnidentifiedUser","loginUserWithUserAttributes","user","updateUser","attributes","logout","present","presentSpace","space","presentConversation","conversationId","openConversation","hide","getUnreadConversationCount","Object","values","getState","unreadByConversation","filter","count","length","getUnreadMessageCount","unreadCount","logEvent","eventName","metadata","track","setLocale","locale","addEventListener","event","listener","events","addListener","adapter","setPushToken","push","setManualToken","Events"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,UAAU,QAAQ,iBAAc;AACzC,SAASC,iBAAiB,QAAuD,aAAU;AAC3F,SAASC,uBAAuB,EAAEC,iBAAiB,QAAQ,cAAW;AAStE,SAASC,mBAAmB,QAAQ,wBAAqB;AACzD,SAASC,QAAQ,IAAIC,mBAAmB,QAAQ,6BAA0B;AAC1E,SAASL,iBAAiB,QAAQ,aAAU;AAC5C,SAASM,gBAAgB,QAAQ,iBAAc;AAC/C,SAASC,gBAAgB,QAAQ,YAAS;AAC1C,SAASC,cAAc,QAAQ,6BAA0B;AA6BzD;AACA,WAAYC,KAAK,0BAALA,KAAK;EAALA,KAAK;EAALA,KAAK;EAAA,OAALA,KAAK;AAAA;AAiGjB,MAAMC,WAA4B,GAAG;EACnCC,IAAI,EAAGC,OAAO,IAAKb,UAAU,CAACc,KAAK,CAACF,IAAI,CAACC,OAAO,CAAC;EAEjDE,qBAAqB,EAAEA,CAAA,KAAMf,UAAU,CAACc,KAAK,CAACC,qBAAqB,CAAC,CAAC;EAErEC,2BAA2B,EAAGC,IAAI,IAAKjB,UAAU,CAACc,KAAK,CAACE,2BAA2B,CAACC,IAAI,CAAC;EAEzFC,UAAU,EAAGC,UAAU,IAAKnB,UAAU,CAACc,KAAK,CAACI,UAAU,CAACC,UAAU,CAAC;EAEnEC,MAAM,EAAEA,CAAA,KAAMpB,UAAU,CAACc,KAAK,CAACM,MAAM,CAAC,CAAC;EAEvCC,OAAO,EAAE,MAAAA,CAAA,KAAY;IACnBrB,UAAU,CAACc,KAAK,CAACO,OAAO,CAAC,CAAC;EAC5B,CAAC;EAEDC,YAAY,EA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