@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,267 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.WidgetApiClient = exports.RepzoWidgetError = void 0;
7
+ exports.isTerminalErrorCode = isTerminalErrorCode;
8
+ var _storage = require("../storage.js");
9
+ var _safeUrl = require("../ui/utils/safe-url.js");
10
+ /**
11
+ * Fetch client for `/api/widget/*`.
12
+ *
13
+ * Ported from the web widget's `client/src/widget/lib/api.ts`, with
14
+ * localStorage swapped for the storage adapter and EventSource moved to
15
+ * `api/realtime.ts`. Visitor tokens live up to 14 days with no refresh, so a
16
+ * 401 triggers one silent re-init + retry (single-flight, owned by the store).
17
+ * The token itself lives in `SecureStorage`.
18
+ */
19
+
20
+ /** Server `code`s that no retry or re-init can fix. */
21
+ const TERMINAL_CODES = new Set(['messenger_api_disabled', 'identity_verification_failed']);
22
+ function isTerminalErrorCode(code) {
23
+ return !!code && TERMINAL_CODES.has(code);
24
+ }
25
+ class RepzoWidgetError extends Error {
26
+ constructor(message, status, code = 'http') {
27
+ super(message);
28
+ this.name = 'RepzoWidgetError';
29
+ this.status = status;
30
+ this.code = code;
31
+ }
32
+
33
+ /** Builds the error for a non-2xx `{ message, code }` body. */
34
+ static fromResponse(status, body) {
35
+ const payload = body && typeof body === 'object' ? body : {};
36
+ const message = typeof payload.message === 'string' && payload.message ? payload.message : null;
37
+ const code = status === 403 && typeof payload.code === 'string' && isTerminalErrorCode(payload.code) ? payload.code : 'http';
38
+ return new RepzoWidgetError(message || `HTTP ${status}`, status, code);
39
+ }
40
+ }
41
+ exports.RepzoWidgetError = RepzoWidgetError;
42
+ class WidgetApiClient {
43
+ baseUrl = '';
44
+ channelAccountId = '';
45
+ token = null;
46
+ tokenLoaded = false;
47
+
48
+ /**
49
+ * Set by the store: given the token that just got a 401, returns a valid
50
+ * token (fresh, or one another caller already minted), or null.
51
+ */
52
+ reauthorize = null;
53
+
54
+ /** Set by the store: a 403 with a terminal `code` came back from any endpoint. */
55
+ onTerminalError = null;
56
+ configure(baseUrl, channelAccountId) {
57
+ this.baseUrl = baseUrl.replace(/\/$/, '');
58
+ this.channelAccountId = channelAccountId;
59
+ }
60
+ getBaseUrl() {
61
+ return this.baseUrl;
62
+ }
63
+ getChannelAccountId() {
64
+ return this.channelAccountId;
65
+ }
66
+ async getToken() {
67
+ if (this.token) return this.token;
68
+ if (!this.tokenLoaded) {
69
+ this.tokenLoaded = true;
70
+ this.token = await _storage.SecureStorage.getItem(_storage.TOKEN_KEY);
71
+ }
72
+ return this.token;
73
+ }
74
+ async setToken(token) {
75
+ this.token = token;
76
+ this.tokenLoaded = true;
77
+ await _storage.SecureStorage.setItem(_storage.TOKEN_KEY, token);
78
+ }
79
+ async clearToken() {
80
+ this.token = null;
81
+ this.tokenLoaded = true;
82
+ await _storage.SecureStorage.removeItem(_storage.TOKEN_KEY);
83
+ }
84
+
85
+ /**
86
+ * Absolute URL for a server media path (avatars, attachments). Only ever
87
+ * returns `http(s)` — relative paths resolve against `baseUrl`; any other
88
+ * scheme (`file:`, `data:`, `intent:`, host deep links…) yields null.
89
+ */
90
+ resolveUrl(url) {
91
+ const trimmed = url?.trim();
92
+ if (!trimmed) return null;
93
+ if ((0, _safeUrl.isHttpUrl)(trimmed)) return trimmed;
94
+ if ((0, _safeUrl.urlScheme)(trimmed)) return null;
95
+ const resolved = `${this.baseUrl}${trimmed.startsWith('/') ? '' : '/'}${trimmed}`;
96
+ return (0, _safeUrl.isHttpUrl)(resolved) ? resolved : null;
97
+ }
98
+ async request(path, options = {}) {
99
+ let sentToken = null;
100
+ const send = async () => {
101
+ const headers = {
102
+ 'Content-Type': 'application/json'
103
+ };
104
+ const token = options.authToken !== undefined ? options.authToken : await this.getToken();
105
+ sentToken = token;
106
+ if (token) headers.Authorization = `Bearer ${token}`;
107
+ try {
108
+ return await fetch(`${this.baseUrl}${path}`, {
109
+ method: options.method ?? 'GET',
110
+ headers,
111
+ body: options.body === undefined ? undefined : JSON.stringify(options.body)
112
+ });
113
+ } catch (error) {
114
+ throw new RepzoWidgetError(error instanceof Error ? error.message : 'Network request failed', 0, 'network');
115
+ }
116
+ };
117
+ let response = await send();
118
+
119
+ // The token expired or was revoked: mint a new session once.
120
+ if (response.status === 401 && !options.skipReauth && this.reauthorize) {
121
+ const refreshed = await this.reauthorize(sentToken);
122
+ if (refreshed) response = await send();
123
+ }
124
+ if (!response.ok) {
125
+ const body = await response.json().catch(() => null);
126
+ const error = RepzoWidgetError.fromResponse(response.status, body);
127
+ // skipReauth calls (init, logout-time) are handled by their caller,
128
+ // which knows whether the result is still current.
129
+ if (isTerminalErrorCode(error.code) && !options.skipReauth) this.onTerminalError?.(error);
130
+ throw error;
131
+ }
132
+ if (response.status === 204) return undefined;
133
+ return await response.json();
134
+ }
135
+
136
+ // ─── Endpoints ────────────────────────────────────────────────────────────
137
+
138
+ /** Public config. `platform` makes the server apply the Mobile SDKs overrides. */
139
+ getConfig(platform) {
140
+ const query = platform ? `?platform=${encodeURIComponent(platform)}` : '';
141
+ return this.request(`/api/widget/config/${encodeURIComponent(this.channelAccountId)}${query}`);
142
+ }
143
+ getOutboundMessage() {
144
+ return this.request(`/api/widget/outbound/${encodeURIComponent(this.channelAccountId)}`);
145
+ }
146
+
147
+ /**
148
+ * Does NOT store the returned token — the store persists it only once it
149
+ * knows the identity op that asked for it is still current.
150
+ */
151
+ async init(params) {
152
+ const visitorToken = params.resumeToken === false ? null : await this.getToken();
153
+ const user = params.user ? {
154
+ ...(params.user.email ? {
155
+ email: params.user.email
156
+ } : {}),
157
+ ...(params.user.name ? {
158
+ name: params.user.name
159
+ } : {}),
160
+ ...(params.user.phone ? {
161
+ phone: params.user.phone
162
+ } : {}),
163
+ ...(params.user.userId ? {
164
+ user_id: params.user.userId
165
+ } : {}),
166
+ ...(params.user.userHash ? {
167
+ user_hash: params.user.userHash
168
+ } : {})
169
+ } : undefined;
170
+ return this.request('/api/widget/init', {
171
+ method: 'POST',
172
+ skipReauth: true,
173
+ body: {
174
+ channelAccountId: this.channelAccountId,
175
+ visitorToken,
176
+ trackingVisitorId: params.trackingVisitorId,
177
+ platform: params.platform,
178
+ sdkVersion: params.sdkVersion,
179
+ ...(user ? {
180
+ user
181
+ } : {})
182
+ }
183
+ });
184
+ }
185
+
186
+ /** Revokes `token` server-side. A 401 means it was already dead — fine. */
187
+ async logout(token) {
188
+ try {
189
+ await this.request('/api/widget/logout', {
190
+ method: 'POST',
191
+ skipReauth: true,
192
+ authToken: token
193
+ });
194
+ } catch (error) {
195
+ if (error instanceof RepzoWidgetError && error.status === 401) return;
196
+ throw error;
197
+ }
198
+ }
199
+ sendMessage(data) {
200
+ return this.request('/api/widget/messages', {
201
+ method: 'POST',
202
+ body: data
203
+ });
204
+ }
205
+ listConversations() {
206
+ return this.request('/api/widget/conversations');
207
+ }
208
+ listMessages(conversationId, cursor) {
209
+ const query = cursor ? `?cursor=${encodeURIComponent(cursor)}` : '';
210
+ return this.request(`/api/widget/conversations/${encodeURIComponent(conversationId)}/messages${query}`);
211
+ }
212
+
213
+ /**
214
+ * Advances the visitor's read cursor for a thread they're watching live.
215
+ * Best effort and `skipReauth`: a burst of live replies must never turn an
216
+ * expired token into a burst of re-inits.
217
+ */
218
+ markConversationRead(conversationId) {
219
+ return this.request(`/api/widget/conversations/${encodeURIComponent(conversationId)}/read`, {
220
+ method: 'POST',
221
+ skipReauth: true
222
+ });
223
+ }
224
+ identify(data) {
225
+ return this.request('/api/widget/identify', {
226
+ method: 'POST',
227
+ body: data
228
+ });
229
+ }
230
+ sendTyping(conversationId, isTyping) {
231
+ return this.request('/api/widget/typing', {
232
+ method: 'POST',
233
+ body: {
234
+ conversationId,
235
+ isTyping
236
+ }
237
+ });
238
+ }
239
+ trackEvent(data) {
240
+ return this.request('/api/widget/events', {
241
+ method: 'POST',
242
+ body: {
243
+ ...data,
244
+ channelAccountId: this.channelAccountId
245
+ }
246
+ });
247
+ }
248
+ registerPushToken(data) {
249
+ return this.request('/api/widget/push-token', {
250
+ method: 'POST',
251
+ body: data
252
+ });
253
+ }
254
+
255
+ /** Logout passes the session's token explicitly and `skipReauth`. */
256
+ removePushToken(token, auth = {}) {
257
+ return this.request('/api/widget/push-token', {
258
+ method: 'DELETE',
259
+ body: {
260
+ token
261
+ },
262
+ ...auth
263
+ });
264
+ }
265
+ }
266
+ exports.WidgetApiClient = WidgetApiClient;
267
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_storage","require","_safeUrl","TERMINAL_CODES","Set","isTerminalErrorCode","code","has","RepzoWidgetError","Error","constructor","message","status","name","fromResponse","body","payload","exports","WidgetApiClient","baseUrl","channelAccountId","token","tokenLoaded","reauthorize","onTerminalError","configure","replace","getBaseUrl","getChannelAccountId","getToken","SecureStorage","getItem","TOKEN_KEY","setToken","setItem","clearToken","removeItem","resolveUrl","url","trimmed","trim","isHttpUrl","urlScheme","resolved","startsWith","request","path","options","sentToken","send","headers","authToken","undefined","Authorization","fetch","method","JSON","stringify","error","response","skipReauth","refreshed","ok","json","catch","getConfig","platform","query","encodeURIComponent","getOutboundMessage","init","params","visitorToken","resumeToken","user","email","phone","userId","user_id","userHash","user_hash","trackingVisitorId","sdkVersion","logout","sendMessage","data","listConversations","listMessages","conversationId","cursor","markConversationRead","identify","sendTyping","isTyping","trackEvent","registerPushToken","removePushToken","auth"],"sourceRoot":"../../../src","sources":["api/client.ts"],"mappings":";;;;;;;AAUA,IAAAA,QAAA,GAAAC,OAAA;AAYA,IAAAC,QAAA,GAAAD,OAAA;AAtBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAgBA;AACA,MAAME,cAAc,GAAG,IAAIC,GAAG,CAAuB,CACnD,wBAAwB,EACxB,8BAA8B,CAC/B,CAAC;AAEK,SAASC,mBAAmBA,CAACC,IAA+B,EAAW;EAC5E,OAAO,CAAC,CAACA,IAAI,IAAIH,cAAc,CAACI,GAAG,CAACD,IAA4B,CAAC;AACnE;AAEO,MAAME,gBAAgB,SAASC,KAAK,CAAC;EAK1CC,WAAWA,CAACC,OAAe,EAAEC,MAAc,EAAEN,IAA0B,GAAG,MAAM,EAAE;IAChF,KAAK,CAACK,OAAO,CAAC;IACd,IAAI,CAACE,IAAI,GAAG,kBAAkB;IAC9B,IAAI,CAACD,MAAM,GAAGA,MAAM;IACpB,IAAI,CAACN,IAAI,GAAGA,IAAI;EAClB;;EAEA;EACA,OAAOQ,YAAYA,CAACF,MAAc,EAAEG,IAAa,EAAoB;IACnE,MAAMC,OAAO,GAAID,IAAI,IAAI,OAAOA,IAAI,KAAK,QAAQ,GAAGA,IAAI,GAAG,CAAC,CAG3D;IACD,MAAMJ,OAAO,GAAG,OAAOK,OAAO,CAACL,OAAO,KAAK,QAAQ,IAAIK,OAAO,CAACL,OAAO,GAAGK,OAAO,CAACL,OAAO,GAAG,IAAI;IAC/F,MAAML,IAAI,GACRM,MAAM,KAAK,GAAG,IAAI,OAAOI,OAAO,CAACV,IAAI,KAAK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f,GAAG4E;IACL,CAAC,CAAC;EACJ;AACF;AAAChF,OAAA,CAAAC,eAAA,GAAAA,eAAA","ignoreList":[]}
@@ -0,0 +1,193 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.WidgetRealtime = void 0;
7
+ var _client = require("./client.js");
8
+ var _sseParser = require("./sse-parser.js");
9
+ /**
10
+ * SSE transport over `GET /api/widget/sse`, authenticated with an
11
+ * `Authorization: Bearer` header (never the query string, which ends up in
12
+ * proxy and server access logs).
13
+ *
14
+ * Uses React Native's streaming XMLHttpRequest and handles both network
15
+ * failures and successful stream EOF with exponential reconnect backoff.
16
+ * Auth failures never retry here: 401 hands over to the store's re-init,
17
+ * while 403 is terminal.
18
+ */
19
+
20
+ /** Server event names, mapped to the shorter names the store switches on. */
21
+ const SERVER_EVENTS = {
22
+ connected: 'connected',
23
+ 'widget.message.new': 'message.new',
24
+ 'widget.typing.start': 'typing.start',
25
+ 'widget.typing.stop': 'typing.stop',
26
+ 'widget.conversation.updated': 'conversation.updated',
27
+ 'widget.conversation.event': 'conversation.event'
28
+ };
29
+ const BASE_RECONNECT_MS = 1_000;
30
+ const MAX_RECONNECT_MS = 60_000;
31
+ /** XHR readyState DONE — the error body is only complete from here. */
32
+ const XHR_DONE = 4;
33
+ /** If DONE never follows a 403 seen mid-body, act on what arrived. */
34
+ const AUTH_ERROR_BODY_WAIT_MS = 3_000;
35
+ class WidgetRealtime {
36
+ source = null;
37
+ connected = false;
38
+ reconnectTimer = null;
39
+ attempt = 0;
40
+ closedByUs = false;
41
+ url = null;
42
+ token = null;
43
+ handler = null;
44
+ authHooks = null;
45
+ authErrorTimer = null;
46
+ connect(baseUrl, token, handler, authHooks) {
47
+ this.close();
48
+ this.url = `${baseUrl.replace(/\/$/, '')}/api/widget/sse`;
49
+ this.token = token;
50
+ this.handler = handler;
51
+ this.authHooks = authHooks ?? null;
52
+ this.closedByUs = false;
53
+ this.open();
54
+ }
55
+ open() {
56
+ if (!this.url || !this.token || !this.handler) return;
57
+ const source = new XMLHttpRequest();
58
+ this.source = source;
59
+ let offset = 0;
60
+ const isCurrent = () => this.source === source && !this.closedByUs;
61
+ const parser = new _sseParser.SseParser((name, raw) => {
62
+ if (!isCurrent() || !Object.prototype.hasOwnProperty.call(SERVER_EVENTS, name)) return;
63
+ let payload = null;
64
+ if (raw) {
65
+ try {
66
+ payload = JSON.parse(raw);
67
+ } catch {
68
+ payload = raw;
69
+ }
70
+ }
71
+ this.handler?.(SERVER_EVENTS[name], payload);
72
+ });
73
+ const reconnect = () => {
74
+ if (!isCurrent()) return;
75
+ this.handler?.('error', null);
76
+ // A handler may synchronously close or replace this connection.
77
+ if (isCurrent()) this.scheduleReconnect();
78
+ };
79
+ const read = () => {
80
+ if (!isCurrent() || source.readyState < 3) return;
81
+ const complete = source.readyState === XHR_DONE;
82
+ const status = source.status;
83
+ if (status === 401 || status === 403) {
84
+ if (!complete && status === 403) {
85
+ // Wait for the structured error body, but never wait indefinitely.
86
+ this.authErrorTimer ??= setTimeout(() => {
87
+ if (isCurrent()) this.handleAuthError(status, source.responseText);
88
+ }, AUTH_ERROR_BODY_WAIT_MS);
89
+ return;
90
+ }
91
+ this.handleAuthError(status, source.responseText);
92
+ return;
93
+ }
94
+ if (status >= 200 && status < 300) {
95
+ if (!this.connected) {
96
+ this.connected = true;
97
+ this.attempt = 0;
98
+ }
99
+ const text = source.responseText || '';
100
+ const chunk = text.slice(offset);
101
+ offset = text.length;
102
+ parser.push(chunk);
103
+ // A 200 EOF is a disconnected stream too. Tear it down and notify the
104
+ // store so the next `connected` event also triggers history catch-up.
105
+ if (complete) reconnect();
106
+ } else if (complete) {
107
+ reconnect();
108
+ }
109
+ };
110
+ source.onreadystatechange = read;
111
+ source.onprogress = read;
112
+ source.onerror = reconnect;
113
+ source.ontimeout = reconnect;
114
+ source.onabort = reconnect;
115
+ try {
116
+ source.open('GET', this.url, true);
117
+ source.timeout = 0;
118
+ source.setRequestHeader('Accept', 'text/event-stream');
119
+ source.setRequestHeader('Cache-Control', 'no-cache');
120
+ source.setRequestHeader('Authorization', `Bearer ${this.token}`);
121
+ source.send();
122
+ } catch {
123
+ reconnect();
124
+ }
125
+ }
126
+ handleAuthError(status, rawBody) {
127
+ const token = this.token;
128
+ const hooks = this.authHooks;
129
+ // Backoff cannot fix an auth failure — stop and let the store decide.
130
+ this.close();
131
+ if (!hooks || !token) return;
132
+ if (status === 401) {
133
+ hooks.onUnauthorized(token);
134
+ return;
135
+ }
136
+ let body = null;
137
+ try {
138
+ body = rawBody ? JSON.parse(rawBody) : null;
139
+ } catch {
140
+ body = null;
141
+ }
142
+ hooks.onForbidden(_client.RepzoWidgetError.fromResponse(403, body));
143
+ }
144
+ scheduleReconnect() {
145
+ if (this.closedByUs || this.reconnectTimer) return;
146
+ this.teardownSource();
147
+ const delay = Math.min(BASE_RECONNECT_MS * 2 ** this.attempt, MAX_RECONNECT_MS);
148
+ // Jitter keeps a fleet of devices from reconnecting in lockstep.
149
+ const jittered = delay * (0.7 + Math.random() * 0.6);
150
+ this.attempt += 1;
151
+ this.reconnectTimer = setTimeout(() => {
152
+ this.reconnectTimer = null;
153
+ if (this.closedByUs) return;
154
+ this.open();
155
+ }, jittered);
156
+ }
157
+ teardownSource() {
158
+ const source = this.source;
159
+ this.source = null;
160
+ this.connected = false;
161
+ if (this.authErrorTimer) {
162
+ clearTimeout(this.authErrorTimer);
163
+ this.authErrorTimer = null;
164
+ }
165
+ if (!source) return;
166
+ source.onreadystatechange = null;
167
+ source.onprogress = null;
168
+ source.onerror = null;
169
+ source.ontimeout = null;
170
+ source.onabort = null;
171
+ source.abort();
172
+ }
173
+ get isConnected() {
174
+ // Includes a handshake in progress so the store does not replace the
175
+ // connection that a successful re-init just started. EOF clears source.
176
+ return this.source !== null;
177
+ }
178
+ close() {
179
+ this.closedByUs = true;
180
+ this.attempt = 0;
181
+ if (this.reconnectTimer) {
182
+ clearTimeout(this.reconnectTimer);
183
+ this.reconnectTimer = null;
184
+ }
185
+ if (this.authErrorTimer) {
186
+ clearTimeout(this.authErrorTimer);
187
+ this.authErrorTimer = null;
188
+ }
189
+ this.teardownSource();
190
+ }
191
+ }
192
+ exports.WidgetRealtime = WidgetRealtime;
193
+ //# sourceMappingURL=realtime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_client","require","_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","SseParser","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","RepzoWidgetError","fromResponse","teardownSource","delay","Math","min","jittered","random","clearTimeout","abort","isConnected","exports"],"sourceRoot":"../../../src","sources":["api/realtime.ts"],"mappings":";;;;;;AAYA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AAbA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAMA;AACA,MAAME,aAAa,GAAG;EACpBC,SAAS,EAAE,WAAW;EACtB,oBAAoB,EAAE,aAAa;EACnC,qBAAqB,EAAE,cAAc;EACrC,oBAAoB,EAAE,aAAa;EACnC,6BAA6B,EAAE,sBAAsB;EACrD,2BAA2B,EAAE;AAC/B,CAAU;AAIV,MAAMC,iBAAiB,GAAG,KAAK;AAC/B,MAAMC,gBAAgB,GAAG,MAAM;AAC/B;AACA,MAAMC,QAAQ,GAAG,CAAC;AAClB;AACA,MAAMC,uBAAuB,GAAG,KAAK;AAW9B,MAAMC,cAAc,CAAC;EAClBC,MAAM,GAA0B,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,EAAE;MACvBuD,YAAY,CAAC,IAAI,CAACvD,cAAc,CAAC;MACjC,IAAI,CAACA,cAAc,GAAG,IAAI;IAC5B;IACA,IAAI,CAACR,MAAM,EAAE;IACbA,MAAM,CAAC0C,kBAAkB,GAAG,IAAI;IAChC1C,MAAM,CAAC2C,UAAU,GAAG,IAAI;IACxB3C,MAAM,CAAC4C,OAAO,GAAG,IAAI;IACrB5C,MAAM,CAAC6C,SAAS,GAAG,IAAI;IACvB7C,MAAM,CAAC8C,OAAO,GAAG,IAAI;IACrB9C,MAAM,CAACgE,KAAK,CAAC,CAAC;EAChB;EAEA,IAAIC,WAAWA,CAAA,EAAY;IACzB;IACA;IACA,OAAO,IAAI,CAACjE,MAAM,KAAK,IAAI;EAC7B;EAEAW,KAAKA,CAAA,EAAS;IACZ,IAAI,CAACR,UAAU,GAAG,IAAI;IACtB,IAAI,CAACD,OAAO,GAAG,CAAC;IAChB,IAAI,IAAI,CAACD,cAAc,EAAE;MACvB8D,YAAY,CAAC,IAAI,CAAC9D,cAAc,CAAC;MACjC,IAAI,CAACA,cAAc,GAAG,IAAI;IAC5B;IACA,IAAI,IAAI,CAACO,cAAc,EAAE;MACvBuD,YAAY,CAAC,IAAI,CAACvD,cAAc,CAAC;MACjC,IAAI,CAACA,cAAc,GAAG,IAAI;IAC5B;IACA,IAAI,CAACiD,cAAc,CAAC,CAAC;EACvB;AACF;AAACS,OAAA,CAAAnE,cAAA,GAAAA,cAAA","ignoreList":[]}
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.SseParser = void 0;
7
+ /** Incremental SSE framing. A blank line dispatches an event; EOF alone does not. */
8
+ class SseParser {
9
+ line = '';
10
+ event = '';
11
+ data = [];
12
+ afterCR = false;
13
+ atStart = true;
14
+ constructor(dispatch) {
15
+ this.dispatch = dispatch;
16
+ }
17
+ push(chunk) {
18
+ for (const char of chunk) {
19
+ if (this.atStart) {
20
+ this.atStart = false;
21
+ if (char === '\uFEFF') continue;
22
+ }
23
+ if (this.afterCR) {
24
+ this.afterCR = false;
25
+ if (char === '\n') continue;
26
+ }
27
+ if (char === '\r' || char === '\n') {
28
+ const line = this.line;
29
+ this.line = '';
30
+ this.afterCR = char === '\r';
31
+ this.readLine(line);
32
+ } else {
33
+ this.line += char;
34
+ }
35
+ }
36
+ }
37
+ readLine(line) {
38
+ if (!line) {
39
+ const event = this.event || 'message';
40
+ const data = this.data;
41
+ this.event = '';
42
+ this.data = [];
43
+ if (data.length) this.dispatch(event, data.join('\n'));
44
+ return;
45
+ }
46
+ if (line.startsWith(':')) return; // heartbeat/comment
47
+ const colon = line.indexOf(':');
48
+ const field = colon < 0 ? line : line.slice(0, colon);
49
+ let value = colon < 0 ? '' : line.slice(colon + 1);
50
+ if (value.startsWith(' ')) value = value.slice(1);
51
+ if (field === 'event') this.event = value;
52
+ if (field === 'data') this.data.push(value);
53
+ // Reconnect timing belongs to the transport. The store catches up from
54
+ // history on reconnect, so no server retry/id fields are needed here.
55
+ }
56
+ }
57
+ exports.SseParser = SseParser;
58
+ //# 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","exports"],"sourceRoot":"../../../src","sources":["api/sse-parser.ts"],"mappings":";;;;;;AAAA;AACO,MAAMA,SAAS,CAAC;EACbC,IAAI,GAAG,EAAE;EACTC,KAAK,GAAG,EAAE;EACVC,IAAI,GAAa,EAAE;EACnBC,OAAO,GAAG,KAAK;EACfC,OAAO,GAAG,IAAI;EAEtBC,WAAWA,CAAkBC,QAA+C,EAAE;IAAA,KAAjDA,QAA+C,GAA/CA,QAA+C;EAAG;EAE/EC,IAAIA,CAACC,KAAa,EAAQ;IACxB,KAAK,MAAMC,IAAI,IAAID,KAAK,EAAE;MACxB,IAAI,IAAI,CAACJ,OAAO,EAAE;QA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,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;AAACC,OAAA,CAAApB,SAAA,GAAAA,SAAA","ignoreList":[]}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.controller = void 0;
7
+ var _widgetStore = require("./state/widget-store.js");
8
+ /**
9
+ * Process-wide singleton that owns the store (and therefore the session, the
10
+ * SSE stream and the unread count). Imperative API calls land here whether or
11
+ * not `<RepzoWidgetProvider>` is mounted; the provider is a pure subscriber, so
12
+ * commands issued before boot finishes simply land in state and render once the
13
+ * provider mounts.
14
+ */
15
+
16
+ class RepzoWidgetController {
17
+ store = new _widgetStore.WidgetStore();
18
+ get events() {
19
+ return this.store.events;
20
+ }
21
+ }
22
+ const controller = exports.controller = new RepzoWidgetController();
23
+ //# sourceMappingURL=controller.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_widgetStore","require","RepzoWidgetController","store","WidgetStore","events","controller","exports"],"sourceRoot":"../../src","sources":["controller.ts"],"mappings":";;;;;;AAQA,IAAAA,YAAA,GAAAC,OAAA;AARA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,MAAMC,qBAAqB,CAAC;EACjBC,KAAK,GAAG,IAAIC,wBAAW,CAAC,CAAC;EAElC,IAAIC,MAAMA,CAAA,EAAG;IACX,OAAO,IAAI,CAACF,KAAK,CAACE,MAAM;EAC1B;AACF;AAEO,MAAMC,UAAU,GAAAC,OAAA,CAAAD,UAAA,GAAG,IAAIJ,qBAAqB,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getDeviceId = getDeviceId;
7
+ exports.resetDeviceIdCache = resetDeviceIdCache;
8
+ exports.rotateDeviceId = rotateDeviceId;
9
+ var _storage = require("./storage.js");
10
+ /**
11
+ * Per-install id sent as `trackingVisitorId`. This is the mobile equivalent of
12
+ * the web widget's `repzo_vid` cookie: it lets the CRM stitch an anonymous
13
+ * visitor back together if the session token is ever lost. Stable until
14
+ * `logout()`, which rotates it.
15
+ */
16
+
17
+ let cached = null;
18
+
19
+ /**
20
+ * 16 random bytes from `crypto.getRandomValues` when the runtime has it (RN
21
+ * with a polyfill, newer Hermes); otherwise Math.random, which is fine for a
22
+ * correlation id but guessable.
23
+ */
24
+ function randomBytes() {
25
+ const bytes = new Uint8Array(16);
26
+ const cryptoApi = globalThis.crypto;
27
+ if (typeof cryptoApi?.getRandomValues === 'function') {
28
+ try {
29
+ cryptoApi.getRandomValues(bytes);
30
+ return bytes;
31
+ } catch {
32
+ // Present but unusable (some polyfills throw) — fall through.
33
+ }
34
+ }
35
+ for (let index = 0; index < bytes.length; index += 1) {
36
+ bytes[index] = Math.random() * 256 | 0;
37
+ }
38
+ return bytes;
39
+ }
40
+
41
+ /** RFC-4122 v4. */
42
+ function uuidv4() {
43
+ const bytes = randomBytes();
44
+ bytes[6] = bytes[6] & 0x0f | 0x40; // version 4
45
+ bytes[8] = bytes[8] & 0x3f | 0x80; // RFC-4122 variant
46
+ const hex = Array.from(bytes, byte => byte.toString(16).padStart(2, '0')).join('');
47
+ return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
48
+ }
49
+ async function getDeviceId() {
50
+ if (cached) return cached;
51
+ const stored = await _storage.Storage.getItem(_storage.DEVICE_ID_KEY);
52
+ if (stored) {
53
+ cached = stored;
54
+ return stored;
55
+ }
56
+ const created = uuidv4();
57
+ cached = created;
58
+ await _storage.Storage.setItem(_storage.DEVICE_ID_KEY, created);
59
+ return created;
60
+ }
61
+
62
+ /** Only used by tests and `rotateDeviceId()`. */
63
+ function resetDeviceIdCache() {
64
+ cached = null;
65
+ }
66
+
67
+ /**
68
+ * Called by `logout()`: the id stitches anonymous sessions together, so on a
69
+ * shared device the next visitor must not inherit the previous user's.
70
+ */
71
+ async function rotateDeviceId() {
72
+ cached = null;
73
+ await _storage.Storage.removeItem(_storage.DEVICE_ID_KEY);
74
+ }
75
+ //# sourceMappingURL=device-id.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_storage","require","cached","randomBytes","bytes","Uint8Array","cryptoApi","globalThis","crypto","getRandomValues","index","length","Math","random","uuidv4","hex","Array","from","byte","toString","padStart","join","slice","getDeviceId","stored","Storage","getItem","DEVICE_ID_KEY","created","setItem","resetDeviceIdCache","rotateDeviceId","removeItem"],"sourceRoot":"../../src","sources":["device-id.ts"],"mappings":";;;;;;;;AAOA,IAAAA,QAAA,GAAAC,OAAA;AAPA;AACA;AACA;AACA;AACA;AACA;;AAIA,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;EAC1C;EACA,OAAOT,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