@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
package/README.md ADDED
@@ -0,0 +1,482 @@
1
+ # @repzo/widget-react-native
2
+
3
+ The Repzo chat widget for React Native — an Intercom-style messenger that drops
4
+ into any app. Pure JavaScript/TypeScript: **no native modules of its own, no
5
+ config plugin, no `pod install`**. Works on iOS and Android, Expo and bare
6
+ React Native, old and new architecture.
7
+
8
+ It talks to the same `/api/widget/*` endpoints as the web widget (Workstation →
9
+ Settings → Inbox Channels → Website Chat), so a message sent from the app lands
10
+ in the CRM Inbox as a `web_widget` conversation and agent replies stream back
11
+ live over SSE.
12
+
13
+ **Features**
14
+
15
+ - Home + conversations + threaded chat, translated (en/ar, RTL-aware)
16
+ - Session resume, anonymous → identified migration, HMAC identity verification
17
+ - Shared-device safe: logout revokes the token and wipes all visitor data; tokens can live in Keychain/Keystore
18
+ - Live agent replies, typing indicators, unread badges (server-backed counts)
19
+ - Catches up after a dropped connection or a trip to the background — no missed or duplicated replies
20
+ - Agent UI blocks: product cards, slot pickers, lead forms, quotes, receipts
21
+ - **Push notifications via FCM** (optional — needs `@react-native-firebase/messaging` in the host app)
22
+ - Theme cached on-device, so relaunches paint your colors instantly
23
+ - Events for building your own badge, in-app banner, and tray cleanup
24
+
25
+ ## Requirements
26
+
27
+ | Peer | Status |
28
+ | --- | --- |
29
+ | `react`, `react-native` | required |
30
+ | `@react-native-async-storage/async-storage` | optional — default token persistence (or inject your own storage, see below) |
31
+ | `@react-native-firebase/app` + `@react-native-firebase/messaging` | optional — only for push notifications (v22+ and v26+ modular API both supported) |
32
+ | `react-native-linear-gradient` | optional — gradient home backgrounds |
33
+ | `react-native-safe-area-context` | optional — safe-area insets from the host provider |
34
+
35
+ Realtime uses React Native’s built-in streaming XMLHttpRequest; there are no bundled runtime dependencies.
36
+
37
+ ## Installation
38
+
39
+ Not on npm yet — install from Git. The fixes below are on `main`; replace it
40
+ with a release tag to pin a version after the next release:
41
+
42
+ ```sh
43
+ # Yarn / Expo projects
44
+ yarn add @repzo/widget-react-native@git+https://github.com/Repzo/repzo-widget-react-native.git#main
45
+
46
+ # npm
47
+ npm install @repzo/widget-react-native@git+https://github.com/Repzo/repzo-widget-react-native.git#main
48
+ ```
49
+
50
+ Expo: no config plugin and no `npx expo prebuild` needed — the SDK itself runs
51
+ in **Expo Go**. (Push notifications are the one exception: they need a
52
+ development build, see below.)
53
+
54
+ ## Metro setup
55
+
56
+ Wrap your app's final Metro config with `withRepzoWidget`. **This is required
57
+ when any optional integration is absent.** Metro resolves static `require()`
58
+ calls before JavaScript runs, so runtime `try/catch` alone cannot make an
59
+ uninstalled integration optional.
60
+
61
+ ```js
62
+ // metro.config.js — Expo
63
+ const { getDefaultConfig } = require('expo/metro-config');
64
+ const { withRepzoWidget } = require('@repzo/widget-react-native/metro');
65
+
66
+ module.exports = withRepzoWidget(getDefaultConfig(__dirname));
67
+ ```
68
+
69
+ ```js
70
+ // metro.config.js — bare React Native
71
+ const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config');
72
+ const { withRepzoWidget } = require('@repzo/widget-react-native/metro');
73
+
74
+ module.exports = withRepzoWidget(mergeConfig(getDefaultConfig(__dirname), {
75
+ // Your existing config.
76
+ }));
77
+ ```
78
+
79
+ Keep your existing config/plugins and apply this wrapper last. It preserves
80
+ installed integrations and existing custom resolvers, substituting an empty
81
+ module only for missing optional imports made by this widget. Missing host
82
+ imports and broken installed packages still report their errors. Restart Metro
83
+ with its cache reset after changing the config (`npx expo start --clear` or
84
+ `npx react-native start --reset-cache`).
85
+
86
+ ## Quick start
87
+
88
+ ```tsx
89
+ // App.tsx — mount the provider once, anywhere near the root
90
+ import { RepzoWidgetProvider } from '@repzo/widget-react-native';
91
+
92
+ export default function App() {
93
+ return (
94
+ <RepzoWidgetProvider>
95
+ <YourApp />
96
+ </RepzoWidgetProvider>
97
+ );
98
+ }
99
+ ```
100
+
101
+ ```ts
102
+ import RepzoWidget from '@repzo/widget-react-native';
103
+
104
+ // Once, at startup — talks to production Workstation by default
105
+ await RepzoWidget.boot({ channelAccountId: '<widget id>' });
106
+
107
+ // After your user logs in
108
+ await RepzoWidget.loginUserWithUserAttributes({
109
+ userId: user.id,
110
+ name: user.name,
111
+ userHash: user.repzoUserHash, // server-generated — see Identity verification
112
+ });
113
+
114
+ // Open the messenger from your own button
115
+ await RepzoWidget.present();
116
+
117
+ // In your sign-out flow — await it (see "Signing out" below)
118
+ await RepzoWidget.logout();
119
+ ```
120
+
121
+ `channelAccountId` is the last path segment of
122
+ `/settings/inbox-channels/<id>/widget` in Workstation. For a dev/staging CRM
123
+ pass `baseUrl` too — Android emulators reach a CRM on your machine via
124
+ `http://10.0.2.2:3000`, never `localhost`. `baseUrl` must be `https://`;
125
+ `boot()` throws for plain `http://` unless the host is `localhost`,
126
+ `127.0.0.1`, `10.0.2.2` or `*.local`, or the app is a `__DEV__` build.
127
+
128
+ ## Signing out (host duties)
129
+
130
+ Call `await RepzoWidget.logout()` whenever your user signs out, **before**
131
+ the next person can use the device. It:
132
+
133
+ 1. revokes the visitor token on the server (`POST /api/widget/logout`) and
134
+ removes this device's push registration — best-effort, each capped at 5s,
135
+ never re-initing a session;
136
+ 2. wipes every user-scoped key (token, user key, unread counts) and rotates
137
+ the anonymous device id, so the next visitor gets a brand-new identity;
138
+ 3. closes the SSE stream, drops the app-state listeners and resets the UI.
139
+
140
+ Only the cached channel theme survives. Nothing reconnects until your next
141
+ `boot()` / `loginUser…()` call.
142
+
143
+ You don't need `logout()` between two logins —
144
+ `loginUserWithUserAttributes()` with a *different* user signs the previous
145
+ one out the same way first, and never sends their token. It *is* still
146
+ required on sign-out: without it, the stored session (and its conversations)
147
+ stays on the device until the next login replaces it.
148
+
149
+ Identity calls (`boot`, `loginUserWithUserAttributes`,
150
+ `loginUnidentifiedUser`, `logout`) are queued, and a later call supersedes any
151
+ still in flight — so firing them from auth-state listeners without awaiting
152
+ is safe, and the last call wins.
153
+
154
+ ## Identity verification
155
+
156
+ Anyone who knows a `userId` could otherwise impersonate that user. Your
157
+ **server** signs the id with the channel's HMAC secret (Workstation → widget →
158
+ Security tab) and ships the signature to the app:
159
+
160
+ ```
161
+ userHash = HMAC_SHA256(hmacSecret, email ?? userId) // hex
162
+ ```
163
+
164
+ Pass it as `userHash` in `loginUserWithUserAttributes`. The secret must never
165
+ ship inside the app bundle. Optional until the channel enforces it
166
+ ("mandatory" toggle), then unverified logins are rejected.
167
+
168
+ ## Custom storage
169
+
170
+ The SDK persists the device id, unread counts and the cached theme through
171
+ async-storage when installed — or through anything you give it (MMKV shown).
172
+ Call this **before** the first `boot()`:
173
+
174
+ ```ts
175
+ RepzoWidget.setStorageAdapter({
176
+ getItem: (key) => storage.getString(key) ?? null,
177
+ setItem: (key, value) => storage.set(key, value),
178
+ removeItem: (key) => storage.delete(key),
179
+ });
180
+ ```
181
+
182
+ Without async-storage and without an adapter it falls back to memory — the
183
+ session then only lasts until the app is killed.
184
+
185
+ ### Secure token storage (recommended)
186
+
187
+ AsyncStorage is plaintext on disk. The visitor token (a bearer credential,
188
+ valid 14 days) and the user key can go to the Keychain / Android Keystore
189
+ instead — same adapter shape, set **before** the first `boot()`. Without a
190
+ secure adapter they fall back to the regular store above; with one, a token
191
+ already in the regular store is moved over on first read. If a secure write
192
+ fails the token is kept in memory only (never written as plaintext).
193
+
194
+ `expo-secure-store` (`npx expo install expo-secure-store`):
195
+
196
+ ```ts
197
+ import * as SecureStore from 'expo-secure-store';
198
+
199
+ const secureOptions = { keychainAccessible: SecureStore.AFTER_FIRST_UNLOCK };
200
+
201
+ RepzoWidget.setSecureStorageAdapter({
202
+ getItem: (key) => SecureStore.getItemAsync(key, secureOptions),
203
+ setItem: (key, value) => SecureStore.setItemAsync(key, value, secureOptions),
204
+ removeItem: (key) => SecureStore.deleteItemAsync(key, secureOptions),
205
+ });
206
+ ```
207
+
208
+ `react-native-keychain` (one keychain entry per key, via `service`):
209
+
210
+ ```ts
211
+ import * as Keychain from 'react-native-keychain';
212
+
213
+ RepzoWidget.setSecureStorageAdapter({
214
+ getItem: async (key) => {
215
+ const entry = await Keychain.getGenericPassword({ service: key });
216
+ return entry ? entry.password : null;
217
+ },
218
+ setItem: async (key, value) => {
219
+ await Keychain.setGenericPassword('repzo-widget', value, {
220
+ service: key,
221
+ accessible: Keychain.ACCESSIBLE.AFTER_FIRST_UNLOCK,
222
+ });
223
+ },
224
+ removeItem: async (key) => {
225
+ await Keychain.resetGenericPassword({ service: key });
226
+ },
227
+ });
228
+ ```
229
+
230
+ Note that iOS keeps Keychain items across app reinstalls; a stale token
231
+ there simply expires or gets replaced on the next init.
232
+
233
+ ## Links in messages
234
+
235
+ Agent and AI replies, campaign CTAs and attachments are remote content, so
236
+ the SDK only opens `https:`, `http:`, `mailto:` and `tel:` links. Everything
237
+ else (your own `myapp://` deep links, `intent:`, `sms:`, `file:`,
238
+ `javascript:`…) is blocked. To route links yourself, pass `onOpenUrl` — it
239
+ runs first for **every** link; return `true` when you handled it:
240
+
241
+ ```ts
242
+ await RepzoWidget.boot({
243
+ channelAccountId: '<widget id>',
244
+ onOpenUrl: (url) => {
245
+ if (url.startsWith('myapp://orders/')) {
246
+ navigation.navigate('Order', { id: url.split('/').pop() });
247
+ return true;
248
+ }
249
+ return false; // fall back to the default allow-list
250
+ },
251
+ });
252
+ ```
253
+
254
+ Only accept deep links you would be comfortable with *anyone* sending your
255
+ user in a chat message.
256
+
257
+ ## Errors
258
+
259
+ `boot()` / login calls reject with a `RepzoWidgetError` (`status`, `code`).
260
+ Boot failures and the terminal codes below also land in
261
+ `useWidgetState().error` / `errorCode`, and the messenger shows an error
262
+ screen instead of a chat that only looks usable (even when the cached theme
263
+ is already painted). Network/HTTP failures get a Retry button, and the SDK
264
+ also retries by itself when the app returns to the foreground; terminal codes
265
+ get a plain message and no Retry.
266
+
267
+ | `code` | Meaning |
268
+ | --- | --- |
269
+ | `network` | No connection / request failed before a response. |
270
+ | `http` | Any other non-2xx response. |
271
+ | `messenger_api_disabled` | The channel's Messenger API is switched off in Workstation. Terminal: realtime stops and the SDK doesn't retry on its own. |
272
+ | `identity_verification_failed` | The channel enforces identity verification and `userHash` was missing or wrong. Terminal, as above. |
273
+
274
+ Expired or revoked tokens (401) are handled silently: the SDK re-inits once
275
+ (shared by all concurrent requests) and retries.
276
+
277
+ ## Push notifications (optional)
278
+
279
+ Agent replies are pushed **only when the user has no live connection** (app
280
+ backgrounded or killed — a visitor watching the chat gets the message over SSE
281
+ instead). Several replies collapse into one notification per conversation, and
282
+ tapping it deep-links straight into that conversation from both background and
283
+ killed states. Delivery is FCM-only: Firebase relays iOS pushes through APNs
284
+ itself.
285
+
286
+ ### 1. Firebase in the app
287
+
288
+ The push feature is the one thing that needs a native module — Firebase
289
+ Messaging, owned by the host app (Expo Go can't run it; use a development
290
+ build):
291
+
292
+ ```sh
293
+ # Expo
294
+ npx expo install @react-native-firebase/app @react-native-firebase/messaging expo-build-properties
295
+ ```
296
+
297
+ ```jsonc
298
+ // app.json / app.config.js
299
+ {
300
+ "expo": {
301
+ "plugins": [
302
+ "@react-native-firebase/app",
303
+ "@react-native-firebase/messaging",
304
+ ["expo-build-properties", { "ios": { "useFrameworks": "static" } }]
305
+ ],
306
+ "ios": { "googleServicesFile": "./GoogleService-Info.plist" },
307
+ "android": { "googleServicesFile": "./google-services.json" }
308
+ }
309
+ }
310
+ ```
311
+
312
+ Then `npx expo prebuild` and rebuild. Bare React Native: add the two config
313
+ files from your Firebase project (`GoogleService-Info.plist` into the Xcode
314
+ target, `google-services.json` into `android/app/` with the
315
+ `com.google.gms.google-services` Gradle plugin) and `pod install`.
316
+
317
+ ### 2. Android notification channel
318
+
319
+ Android only pops a heads-up banner for high-importance channels. Create one
320
+ named `repzo_widget_messages` at startup (Workstation targets it by id;
321
+ without it, pushes land silently in the tray):
322
+
323
+ ```ts
324
+ import * as Notifications from 'expo-notifications';
325
+
326
+ Notifications.setNotificationChannelAsync('repzo_widget_messages', {
327
+ name: 'Chat messages',
328
+ importance: Notifications.AndroidImportance.MAX,
329
+ vibrationPattern: [0, 250, 250, 250],
330
+ enableVibrate: true,
331
+ });
332
+ ```
333
+
334
+ ### 3. Enable at boot
335
+
336
+ ```ts
337
+ await RepzoWidget.boot({
338
+ channelAccountId: '<widget id>',
339
+ push: {
340
+ enabled: true,
341
+ requestPermission: true, // false if your app runs its own prompt
342
+ bundleId: 'com.your.app', // must match the app entry in Workstation
343
+ },
344
+ });
345
+ ```
346
+
347
+ The SDK registers the device token after every successful boot/login, moves it
348
+ between identities on login switches, refreshes it when Firebase rotates it,
349
+ removes it on `logout()`, and handles notification taps. Nothing else to wire.
350
+
351
+ ### 4. Workstation side
352
+
353
+ Channel → Install tab → mobile → **Set up push notifications**:
354
+
355
+ 1. Delivery provider → **FCM**.
356
+ 2. **Apps** → "Configure an app" → your app's name, bundle id, and the
357
+ **service-account key JSON** of *your own Firebase project* (Project
358
+ settings → Service accounts → Generate new private key). One entry per app
359
+ embedding this SDK — tokens are matched to keys by bundle id.
360
+ 3. iOS only, one time: upload your **APNs `.p8`** in the Firebase console
361
+ (Project settings → Cloud Messaging). Repzo's servers never see it.
362
+
363
+ The two Google config files in your app and the service-account key in
364
+ Workstation must come from the **same Firebase project**, or sends fail with
365
+ `SENDER_ID_MISMATCH`.
366
+
367
+ ### Keep the tray clean
368
+
369
+ The OS never removes a notification just because the user read the
370
+ conversation in-app. Dismiss it yourself:
371
+
372
+ ```ts
373
+ import * as Notifications from 'expo-notifications';
374
+ import RepzoWidget, { RepzoWidgetEvents } from '@repzo/widget-react-native';
375
+
376
+ RepzoWidget.addEventListener(RepzoWidgetEvents.ConversationDidRead, async ({ conversationId }) => {
377
+ const presented = await Notifications.getPresentedNotificationsAsync();
378
+ for (const n of presented) {
379
+ const data = n.request.content.data ?? {};
380
+ if (data.document_type === 'widget_message' && data.document_id === conversationId) {
381
+ await Notifications.dismissNotificationAsync(n.request.identifier);
382
+ }
383
+ }
384
+ });
385
+ ```
386
+
387
+ ### No Firebase module?
388
+
389
+ Bring your own token pipeline and hand the token over:
390
+
391
+ ```ts
392
+ await RepzoWidget.setPushToken({ token, platform: 'android', bundleId: 'com.your.app' });
393
+ ```
394
+
395
+ ## Events
396
+
397
+ ```ts
398
+ const sub = RepzoWidget.addEventListener(RepzoWidgetEvents.UnreadCountDidChange, ({ count }) =>
399
+ setBadge(count)
400
+ );
401
+ // later
402
+ sub.remove();
403
+ ```
404
+
405
+ | Event | Payload | Use it for |
406
+ | --- | --- | --- |
407
+ | `UnreadCountDidChange` | `{ count }` | Badge on your own chat button. `count` is the number of unread team replies across all conversations; it drops only when the visitor opens a thread (opening the messenger alone doesn't clear it). Counts are server-backed, so replies that arrived while the app was killed are included after a cold start. |
408
+ | `MessageDidArrive` | `{ conversationId, message, conversation }` | Your own in-app banner while the app is foregrounded (no push is sent then). Fires only for team replies that count as unread — never the visitor's echo, never system rows like "agent joined", never the thread already open. |
409
+ | `ConversationDidRead` | `{ conversationId }` | Dismissing that conversation's push notification (example above). |
410
+ | `WindowDidShow` / `WindowDidHide` | — | Pause your own UI (tours, toasts) while the messenger is open. |
411
+
412
+ ## API
413
+
414
+ | Method | Notes |
415
+ | --- | --- |
416
+ | `boot({ channelAccountId, baseUrl?, user?, push?, onOpenUrl? })` | Mints/resumes the session and connects SSE. Idempotent; safe to call repeatedly. |
417
+ | `loginUserWithUserAttributes({ userId?, email?, name?, phone?, userHash? })` | Identifies the visitor; moves anonymous history over. A different stored user is signed out first. |
418
+ | `loginUnidentifiedUser()` | Drops the identity (signing out a stored user), fresh anonymous session. |
419
+ | `updateUser(attributes)` | Custom attributes agents see on the conversation (≤30 keys, 64-char keys, 512-char values). |
420
+ | `logout()` | Revokes the token, removes the push registration, wipes visitor data, rotates the device id, resets the UI. Await it on sign-out. |
421
+ | `present()` / `presentSpace('home' \| 'messages')` / `presentConversation(id)` / `hide()` | UI commands. |
422
+ | `getUnreadConversationCount()` | Number of conversations with at least one unread reply. |
423
+ | `getUnreadMessageCount()` | Total unread replies across conversations (same as `UnreadCountDidChange`). Before 0.1.10 `getUnreadConversationCount()` returned this. |
424
+ | `logEvent(name, metadata?)` | Analytics event against the visitor. |
425
+ | `setLocale(locale)` | Switches the translation set (call after `boot`). |
426
+ | `addEventListener(event, cb)` | Returns `{ remove() }`. |
427
+ | `setStorageAdapter(adapter)` | Device id/theme/unread persistence — call before `boot`. |
428
+ | `setSecureStorageAdapter(adapter)` | Keychain/Keystore store for the token + user key — call before `boot`. |
429
+ | `setPushToken({ token, platform?, bundleId? })` | Manual FCM token for hosts without the Firebase module. |
430
+
431
+ `RepzoWidgetLauncher` is an optional floating bubble with an unread badge for
432
+ apps without their own chat entry point — mount it inside a full-screen
433
+ container, it positions itself absolutely.
434
+
435
+ ## Troubleshooting
436
+
437
+ - **No push arrives** — check in this order: the device registered (a row in
438
+ Workstation's `widget_push_tokens` after boot + login), channel provider is
439
+ FCM with an Apps entry whose bundle id matches, the `.p8` is uploaded (iOS),
440
+ and the app was **killed or backgrounded** during the test — an open chat
441
+ never pushes, by design. The SDK logs every push problem with a
442
+ `[repzo-widget]` prefix.
443
+ - **Push registers nothing and warns "not installed"** — the running binary
444
+ predates the Firebase modules (a JS-only reload isn't enough) or you're in
445
+ Expo Go. Rebuild the dev client.
446
+ - **Notification is silent / doesn't pop** — the `repzo_widget_messages`
447
+ channel wasn't created before the first push arrived. Note Android locks a
448
+ channel's settings after creation; uninstall/reinstall to reset while
449
+ testing.
450
+ - **`SENDER_ID_MISMATCH` in Workstation logs** — the app's Google config files
451
+ and the uploaded service-account key are from different Firebase projects.
452
+ - **Widget can't reach a local CRM from a device** — tunnel it (ngrok) or use
453
+ `10.0.2.2` on Android emulators.
454
+
455
+ ## Source layout
456
+
457
+ ```
458
+ src/
459
+ index.tsx public API: RepzoWidget, provider, launcher, types
460
+ api/ HTTP client and the SSE realtime stream
461
+ push/ FCM token registration + notification tap handling
462
+ state/ widget store and the hook that subscribes to it
463
+ ui/
464
+ WidgetProvider.tsx root: mounts the modal and switches between screens
465
+ screens/ home/ chat/ conversations/ pre-chat/
466
+ components/ rows, avatar, icons, gradients, panel chrome, launcher
467
+ styles/ theme.ts (tokens, color helpers), global.ts
468
+ hooks/ utils/
469
+ ```
470
+
471
+ ## Releasing
472
+
473
+ ```sh
474
+ # bump "version" in package.json and SDK_VERSION in src/state/widget-store.ts
475
+ npx tsc --noEmit
476
+ git commit -am "..." && git tag v0.1.x
477
+ git push origin main --tags # github.com/Repzo
478
+ git push public main --tags # github.com/yousef-repzo (mirror)
479
+ ```
480
+
481
+ Consumers pin the tag, so a release is only "live" for an app after its
482
+ `package.json` pin is bumped and dependencies reinstalled.
@@ -0,0 +1,159 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.formatAgentUiActionMessage = formatAgentUiActionMessage;
7
+ exports.getAgentUiBlocks = getAgentUiBlocks;
8
+ exports.getProcedureForm = getProcedureForm;
9
+ exports.parseAgentUiBlocks = parseAgentUiBlocks;
10
+ /**
11
+ * Structural parsing for agent-authored UI blocks.
12
+ *
13
+ * The CRM validates these with zod (`shared/agent-ui-blocks.ts`) before
14
+ * broadcasting, so this side only needs to reject malformed payloads rather
15
+ * than re-implement the schema — which keeps the SDK dependency-free. Action
16
+ * message formatting is copied verbatim so the transcript reads the same on
17
+ * web and mobile.
18
+ */
19
+
20
+ const KNOWN_BLOCK_TYPES = new Set(['product_service_card', 'product_choices', 'commerce_actions', 'cart_order_summary', 'contact_lead_form', 'consent', 'appointment_slot_picker', 'quote_preview', 'success_receipt']);
21
+ const KNOWN_ACTION_TYPES = new Set(['add_to_cart', 'buy_now', 'submit_contact', 'record_consent', 'select_appointment_provider', 'select_appointment_slot', 'open_record', 'accept_quote', 'next_action']);
22
+ function isRecord(value) {
23
+ return !!value && typeof value === 'object' && !Array.isArray(value);
24
+ }
25
+
26
+ // The renderer dereferences nested fields and hands strings to <Text>, so a
27
+ // block is only accepted when every field it touches has the right shape —
28
+ // one wrong type (`providers` missing, a numeric slot time, a string
29
+ // `amount`) must skip that block, not throw inside the host app's tree.
30
+
31
+ const isString = value => typeof value === 'string';
32
+ const isNumber = value => typeof value === 'number' && Number.isFinite(value);
33
+ const isOptional = (value, check) => value === undefined || value === null || check(value);
34
+ const isArrayOf = (value, check) => Array.isArray(value) && value.every(check);
35
+ function isAction(value) {
36
+ if (!isRecord(value)) return false;
37
+ return isString(value.id) && isString(value.label) && isString(value.type) && KNOWN_ACTION_TYPES.has(value.type) && isRecord(value.payload);
38
+ }
39
+ function isCommerceItem(value) {
40
+ return isRecord(value) && isString(value.name) && isNumber(value.quantity) && isNumber(value.unitPrice) && isNumber(value.lineTotal);
41
+ }
42
+ function isVariant(value) {
43
+ return isRecord(value) && isString(value.id) && isString(value.title) && isNumber(value.price) && isString(value.currency);
44
+ }
45
+ function isFormField(value) {
46
+ return isRecord(value) && isString(value.name) && isString(value.label) && isOptional(value.placeholder, isString) && isOptional(value.value, isString);
47
+ }
48
+ function isProvider(value) {
49
+ return isRecord(value) && isString(value.id) && isString(value.name);
50
+ }
51
+ function isSlot(value) {
52
+ return isRecord(value) && isString(value.startTime) && isString(value.endTime) && isString(value.slotToken) && isOptional(value.staffUserId, isString);
53
+ }
54
+ function isDay(value) {
55
+ return isRecord(value) && isString(value.date) && isArrayOf(value.slots, isSlot);
56
+ }
57
+ function isValidBlock(block) {
58
+ switch (block.type) {
59
+ case 'product_service_card':
60
+ {
61
+ const product = block.product;
62
+ return isRecord(product) && isString(product.name) && isNumber(product.price) && isString(product.currency) && isOptional(product.imageUrl, isString) && isOptional(product.shortDescription, isString) && isOptional(product.description, isString) && isOptional(product.unit, isString) && isOptional(product.durationMinutes, isNumber);
63
+ }
64
+ case 'product_choices':
65
+ return isString(block.productId) && isString(block.title) && Array.isArray(block.variants) && block.variants.length > 0 && block.variants.every(isVariant);
66
+ case 'commerce_actions':
67
+ return isArrayOf(block.actions, isAction);
68
+ case 'cart_order_summary':
69
+ return isString(block.title) && isString(block.currency) && isArrayOf(block.items, isCommerceItem) && isNumber(block.subtotal) && isNumber(block.total) && isOptional(block.discount, isNumber) && isOptional(block.tax, isNumber) && isOptional(block.shipping, isNumber) && isOptional(block.status, isString) && isOptional(block.action, isAction);
70
+ case 'contact_lead_form':
71
+ return isString(block.title) && isString(block.submitLabel) && isOptional(block.description, isString) && Array.isArray(block.fields) && block.fields.length > 0 && block.fields.every(isFormField);
72
+ case 'consent':
73
+ return isString(block.statement) && isArrayOf(block.channels, isString);
74
+ case 'appointment_slot_picker':
75
+ return isString(block.serviceId) && isString(block.serviceName) && isNumber(block.durationMinutes) && isOptional(block.timezone, isString) && isOptional(block.selectedProviderId, isString) && isOptional(block.providers, value => isArrayOf(value, isProvider)) && Array.isArray(block.days) && block.days.length > 0 && block.days.every(isDay);
76
+ case 'quote_preview':
77
+ return isString(block.name) && isString(block.currency) && isString(block.status) && isNumber(block.amount) && isOptional(block.serialNumber, isString) && isOptional(block.contactName, isString) && isOptional(block.validUntil, isString) && isOptional(block.actions, value => isArrayOf(value, isAction));
78
+ case 'success_receipt':
79
+ return isString(block.title) && isOptional(block.description, isString) && isOptional(block.reference, isString) && isOptional(block.amount, isNumber) && isOptional(block.currency, isString) && isOptional(block.nextActions, value => isArrayOf(value, isAction));
80
+ default:
81
+ return false;
82
+ }
83
+ }
84
+
85
+ /**
86
+ * Drops blocks this SDK version does not know how to render, or whose fields
87
+ * don't match what the renderer reads. Optional lists the server may omit
88
+ * come back as empty arrays.
89
+ */
90
+ function parseAgentUiBlocks(value) {
91
+ if (!Array.isArray(value)) return [];
92
+ const blocks = [];
93
+ for (const block of value) {
94
+ if (!isRecord(block)) continue;
95
+ if (!isString(block.id) || !isString(block.type)) continue;
96
+ if (!KNOWN_BLOCK_TYPES.has(block.type) || !isValidBlock(block)) continue;
97
+ const normalized = block.type === 'appointment_slot_picker' ? {
98
+ ...block,
99
+ providers: block.providers ?? []
100
+ } : block.type === 'quote_preview' ? {
101
+ ...block,
102
+ actions: block.actions ?? []
103
+ } : block.type === 'success_receipt' ? {
104
+ ...block,
105
+ nextActions: block.nextActions ?? []
106
+ } : block;
107
+ blocks.push(normalized);
108
+ }
109
+ return blocks;
110
+ }
111
+ function getAgentUiBlocks(metadata) {
112
+ if (!isRecord(metadata)) return [];
113
+ return parseAgentUiBlocks(metadata.agentUiBlocks);
114
+ }
115
+ function getProcedureForm(metadata) {
116
+ if (!isRecord(metadata)) return null;
117
+ const form = metadata.agentProcedureForm;
118
+ if (!isRecord(form) || !Array.isArray(form.fields) || form.fields.length === 0) return null;
119
+ return {
120
+ procedureId: typeof form.procedureId === 'string' ? form.procedureId : '',
121
+ procedureName: typeof form.procedureName === 'string' ? form.procedureName : 'Details',
122
+ fields: form.fields.filter(field => field && typeof field.name === 'string').map(field => ({
123
+ name: field.name,
124
+ label: typeof field.label === 'string' ? field.label : field.name,
125
+ type: ['email', 'phone', 'date', 'time', 'text'].includes(field.type) ? field.type : 'text',
126
+ required: field.required !== false
127
+ }))
128
+ };
129
+ }
130
+ function formatAgentUiActionMessage(action) {
131
+ const payload = action.payload;
132
+ switch (action.type) {
133
+ case 'add_to_cart':
134
+ return `Add ${String(payload.productName || 'this item')} to my cart${payload.variantTitle ? ` (${String(payload.variantTitle)})` : ''}.`;
135
+ case 'buy_now':
136
+ if (payload.cartId) return `Create an order from cart ${String(payload.cartId)}.`;
137
+ if (action.module === 'appointments' || payload.productType === 'service') {
138
+ return `Book ${String(payload.productName || 'this service')}${payload.variantTitle ? ` (${String(payload.variantTitle)})` : ''}.`;
139
+ }
140
+ return `Buy ${String(payload.productName || 'this item')} now${payload.variantTitle ? ` (${String(payload.variantTitle)})` : ''}.`;
141
+ case 'select_appointment_provider':
142
+ return `Show appointment times for ${String(payload.serviceName || 'this service')} with ${String(payload.providerName || 'any available professional')}.`;
143
+ case 'select_appointment_slot':
144
+ return `Book ${String(payload.serviceName || 'this service')} on ${String(payload.date || 'the selected date')} at ${String(payload.startTime || 'the selected time')}${payload.providerName ? ` with ${String(payload.providerName)}` : ''}.`;
145
+ case 'accept_quote':
146
+ return `I accept quote ${String(payload.reference || payload.quoteId || '')}.`.trim();
147
+ case 'record_consent':
148
+ return `I consent to being contacted by ${Array.isArray(payload.channels) ? payload.channels.join(', ') : 'the selected channel'}.`;
149
+ case 'open_record':
150
+ return action.label;
151
+ case 'submit_contact':
152
+ return Object.entries(payload).filter(([, value]) => typeof value === 'string' && value.trim()).map(([key, value]) => `${key}: ${String(value).trim()}`).join('\n') || 'I have submitted my contact details.';
153
+ case 'next_action':
154
+ return action.label;
155
+ default:
156
+ return action.label;
157
+ }
158
+ }
159
+ //# sourceMappingURL=agent-ui-blocks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["KNOWN_BLOCK_TYPES","Set","KNOWN_ACTION_TYPES","isRecord","value","Array","isArray","isString","isNumber","Number","isFinite","isOptional","check","undefined","isArrayOf","every","isAction","id","label","type","has","payload","isCommerceItem","name","quantity","unitPrice","lineTotal","isVariant","title","price","currency","isFormField","placeholder","isProvider","isSlot","startTime","endTime","slotToken","staffUserId","isDay","date","slots","isValidBlock","block","product","imageUrl","shortDescription","description","unit","durationMinutes","productId","variants","length","actions","items","subtotal","total","discount","tax","shipping","status","action","submitLabel","fields","statement","channels","serviceId","serviceName","timezone","selectedProviderId","providers","days","amount","serialNumber","contactName","validUntil","reference","nextActions","parseAgentUiBlocks","blocks","normalized","push","getAgentUiBlocks","metadata","agentUiBlocks","getProcedureForm","form","agentProcedureForm","procedureId","procedureName","filter","field","map","includes","required","formatAgentUiActionMessage","String","productName","variantTitle","cartId","module","productType","providerName","quoteId","trim","join","Object","entries","key"],"sourceRoot":"../../src","sources":["agent-ui-blocks.ts"],"mappings":";;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,MAAMA,iBAAiB,GAAG,IAAIC,GAAG,CAAC,CAChC,sBAAsB,EACtB,iBAAiB,EACjB,kBAAkB,EAClB,oBAAoB,EACpB,mBAAmB,EACnB,SAAS,EACT,yBAAyB,EACzB,eAAe,EACf,iBAAiB,CAClB,CAAC;AAEF,MAAMC,kBAAkB,GAAG,IAAID,GAAG,CAAC,CACjC,aAAa,EACb,SAAS,EACT,gBAAgB,EAChB,gBAAgB,EAChB,6BAA6B,EAC7B,yBAAyB,EACzB,aAAa,EACb,cAAc,EACd,aAAa,CACd,CAAC;AAEF,SAASE,QAAQA,CAACC,KAAc,EAAoC;EAClE,OAAO,CAAC,CAACA,KAAK,IAAI,OAAOA,KAAK,KAAK,QAAQ,IAAI,CAACC,KAAK,CAACC,OAAO,CAACF,KAAK,CAAC;AACtE;;AAEA;AACA;AACA;AACA;;AAEA,MAAMG,QAAQ,GAAIH,KAAc,IAAsB,OAAOA,KAAK,KAAK,QAAQ;AAE/E,MAAMI,QAAQ,GAAIJ,KAAc,IAC9B,OAAOA,KAAK,KAAK,QAAQ,IAAIK,MAAM,CAACC,QAAQ,CAACN,KAAK,CAAC;AAErD,MAAMO,UAAU,GAAGA,CAACP,KAAc,EAAEQ,KAAkC,KACpER,KAAK,KAAKS,SAAS,IAAIT,KAAK,KA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