@repzo/widget-react-native 1.3.0 → 1.4.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 (251) hide show
  1. package/CHANGELOG.md +179 -0
  2. package/README.md +72 -16
  3. package/lib/commonjs/api/client.js +113 -0
  4. package/lib/commonjs/api/client.js.map +1 -1
  5. package/lib/commonjs/attachments/file-size.js +52 -0
  6. package/lib/commonjs/attachments/file-size.js.map +1 -0
  7. package/lib/commonjs/attachments/local-previews.js +40 -0
  8. package/lib/commonjs/attachments/local-previews.js.map +1 -0
  9. package/lib/commonjs/attachments/pickers.js +76 -28
  10. package/lib/commonjs/attachments/pickers.js.map +1 -1
  11. package/lib/commonjs/i18n.js +24 -3
  12. package/lib/commonjs/i18n.js.map +1 -1
  13. package/lib/commonjs/locales.js +13 -3
  14. package/lib/commonjs/locales.js.map +1 -1
  15. package/lib/commonjs/state/widget-store.js +486 -63
  16. package/lib/commonjs/state/widget-store.js.map +1 -1
  17. package/lib/commonjs/storage.js +3 -1
  18. package/lib/commonjs/storage.js.map +1 -1
  19. package/lib/commonjs/types.js.map +1 -1
  20. package/lib/commonjs/ui/WidgetProvider.js +40 -16
  21. package/lib/commonjs/ui/WidgetProvider.js.map +1 -1
  22. package/lib/commonjs/ui/components/AttachmentChips.js +109 -40
  23. package/lib/commonjs/ui/components/AttachmentChips.js.map +1 -1
  24. package/lib/commonjs/ui/components/ConversationRow.js +65 -10
  25. package/lib/commonjs/ui/components/ConversationRow.js.map +1 -1
  26. package/lib/commonjs/ui/components/ImageViewer.js +231 -25
  27. package/lib/commonjs/ui/components/ImageViewer.js.map +1 -1
  28. package/lib/commonjs/ui/components/RatingCard.js +5 -2
  29. package/lib/commonjs/ui/components/RatingCard.js.map +1 -1
  30. package/lib/commonjs/ui/components/ZoomableImage.js +58 -10
  31. package/lib/commonjs/ui/components/ZoomableImage.js.map +1 -1
  32. package/lib/commonjs/ui/components/icons.js +22 -16
  33. package/lib/commonjs/ui/components/icons.js.map +1 -1
  34. package/lib/commonjs/ui/hooks/use-retained-state.js +39 -0
  35. package/lib/commonjs/ui/hooks/use-retained-state.js.map +1 -0
  36. package/lib/commonjs/ui/screens/chat/ChatView.js +666 -171
  37. package/lib/commonjs/ui/screens/chat/ChatView.js.map +1 -1
  38. package/lib/commonjs/ui/screens/chat/ChatView.styles.js +150 -3
  39. package/lib/commonjs/ui/screens/chat/ChatView.styles.js.map +1 -1
  40. package/lib/commonjs/ui/screens/conversations/ConversationsList.js +1 -0
  41. package/lib/commonjs/ui/screens/conversations/ConversationsList.js.map +1 -1
  42. package/lib/commonjs/ui/screens/home/HomeView.js +38 -55
  43. package/lib/commonjs/ui/screens/home/HomeView.js.map +1 -1
  44. package/lib/commonjs/ui/screens/home/HomeView.styles.js +36 -45
  45. package/lib/commonjs/ui/screens/home/HomeView.styles.js.map +1 -1
  46. package/lib/commonjs/ui/styles/theme.js +1 -0
  47. package/lib/commonjs/ui/styles/theme.js.map +1 -1
  48. package/lib/commonjs/ui/utils/conversations.js +17 -1
  49. package/lib/commonjs/ui/utils/conversations.js.map +1 -1
  50. package/lib/commonjs/ui/utils/html.js +13 -0
  51. package/lib/commonjs/ui/utils/html.js.map +1 -1
  52. package/lib/commonjs/ui/utils/image-load-queue.js +114 -0
  53. package/lib/commonjs/ui/utils/image-load-queue.js.map +1 -0
  54. package/lib/commonjs/ui/utils/inline-attachments.js +88 -0
  55. package/lib/commonjs/ui/utils/inline-attachments.js.map +1 -0
  56. package/lib/module/api/client.js +113 -0
  57. package/lib/module/api/client.js.map +1 -1
  58. package/lib/module/attachments/file-size.js +47 -0
  59. package/lib/module/attachments/file-size.js.map +1 -0
  60. package/lib/module/attachments/local-previews.js +33 -0
  61. package/lib/module/attachments/local-previews.js.map +1 -0
  62. package/lib/module/attachments/pickers.js +74 -27
  63. package/lib/module/attachments/pickers.js.map +1 -1
  64. package/lib/module/i18n.js +24 -3
  65. package/lib/module/i18n.js.map +1 -1
  66. package/lib/module/locales.js +13 -3
  67. package/lib/module/locales.js.map +1 -1
  68. package/lib/module/state/widget-store.js +488 -65
  69. package/lib/module/state/widget-store.js.map +1 -1
  70. package/lib/module/storage.js +2 -0
  71. package/lib/module/storage.js.map +1 -1
  72. package/lib/module/types.js.map +1 -1
  73. package/lib/module/ui/WidgetProvider.js +40 -16
  74. package/lib/module/ui/WidgetProvider.js.map +1 -1
  75. package/lib/module/ui/components/AttachmentChips.js +111 -42
  76. package/lib/module/ui/components/AttachmentChips.js.map +1 -1
  77. package/lib/module/ui/components/ConversationRow.js +65 -10
  78. package/lib/module/ui/components/ConversationRow.js.map +1 -1
  79. package/lib/module/ui/components/ImageViewer.js +233 -27
  80. package/lib/module/ui/components/ImageViewer.js.map +1 -1
  81. package/lib/module/ui/components/RatingCard.js +5 -2
  82. package/lib/module/ui/components/RatingCard.js.map +1 -1
  83. package/lib/module/ui/components/ZoomableImage.js +58 -10
  84. package/lib/module/ui/components/ZoomableImage.js.map +1 -1
  85. package/lib/module/ui/components/icons.js +21 -15
  86. package/lib/module/ui/components/icons.js.map +1 -1
  87. package/lib/module/ui/hooks/use-retained-state.js +34 -0
  88. package/lib/module/ui/hooks/use-retained-state.js.map +1 -0
  89. package/lib/module/ui/screens/chat/ChatView.js +672 -177
  90. package/lib/module/ui/screens/chat/ChatView.js.map +1 -1
  91. package/lib/module/ui/screens/chat/ChatView.styles.js +152 -4
  92. package/lib/module/ui/screens/chat/ChatView.styles.js.map +1 -1
  93. package/lib/module/ui/screens/conversations/ConversationsList.js +1 -0
  94. package/lib/module/ui/screens/conversations/ConversationsList.js.map +1 -1
  95. package/lib/module/ui/screens/home/HomeView.js +40 -57
  96. package/lib/module/ui/screens/home/HomeView.js.map +1 -1
  97. package/lib/module/ui/screens/home/HomeView.styles.js +36 -45
  98. package/lib/module/ui/screens/home/HomeView.styles.js.map +1 -1
  99. package/lib/module/ui/styles/theme.js +1 -0
  100. package/lib/module/ui/styles/theme.js.map +1 -1
  101. package/lib/module/ui/utils/conversations.js +15 -1
  102. package/lib/module/ui/utils/conversations.js.map +1 -1
  103. package/lib/module/ui/utils/html.js +12 -0
  104. package/lib/module/ui/utils/html.js.map +1 -1
  105. package/lib/module/ui/utils/image-load-queue.js +109 -0
  106. package/lib/module/ui/utils/image-load-queue.js.map +1 -0
  107. package/lib/module/ui/utils/inline-attachments.js +85 -0
  108. package/lib/module/ui/utils/inline-attachments.js.map +1 -0
  109. package/lib/typescript/commonjs/api/client.d.ts +35 -1
  110. package/lib/typescript/commonjs/api/client.d.ts.map +1 -1
  111. package/lib/typescript/commonjs/attachments/file-size.d.ts +15 -0
  112. package/lib/typescript/commonjs/attachments/file-size.d.ts.map +1 -0
  113. package/lib/typescript/commonjs/attachments/local-previews.d.ts +14 -0
  114. package/lib/typescript/commonjs/attachments/local-previews.d.ts.map +1 -0
  115. package/lib/typescript/commonjs/attachments/pickers.d.ts +35 -10
  116. package/lib/typescript/commonjs/attachments/pickers.d.ts.map +1 -1
  117. package/lib/typescript/commonjs/i18n.d.ts +13 -3
  118. package/lib/typescript/commonjs/i18n.d.ts.map +1 -1
  119. package/lib/typescript/commonjs/locales.d.ts.map +1 -1
  120. package/lib/typescript/commonjs/state/widget-store.d.ts +67 -4
  121. package/lib/typescript/commonjs/state/widget-store.d.ts.map +1 -1
  122. package/lib/typescript/commonjs/storage.d.ts +2 -0
  123. package/lib/typescript/commonjs/storage.d.ts.map +1 -1
  124. package/lib/typescript/commonjs/types.d.ts +58 -0
  125. package/lib/typescript/commonjs/types.d.ts.map +1 -1
  126. package/lib/typescript/commonjs/ui/WidgetProvider.d.ts.map +1 -1
  127. package/lib/typescript/commonjs/ui/components/AttachmentChips.d.ts +13 -3
  128. package/lib/typescript/commonjs/ui/components/AttachmentChips.d.ts.map +1 -1
  129. package/lib/typescript/commonjs/ui/components/ConversationRow.d.ts +15 -1
  130. package/lib/typescript/commonjs/ui/components/ConversationRow.d.ts.map +1 -1
  131. package/lib/typescript/commonjs/ui/components/ImageViewer.d.ts +26 -6
  132. package/lib/typescript/commonjs/ui/components/ImageViewer.d.ts.map +1 -1
  133. package/lib/typescript/commonjs/ui/components/RatingCard.d.ts.map +1 -1
  134. package/lib/typescript/commonjs/ui/components/ZoomableImage.d.ts +10 -1
  135. package/lib/typescript/commonjs/ui/components/ZoomableImage.d.ts.map +1 -1
  136. package/lib/typescript/commonjs/ui/components/icons.d.ts +2 -1
  137. package/lib/typescript/commonjs/ui/components/icons.d.ts.map +1 -1
  138. package/lib/typescript/commonjs/ui/hooks/use-retained-state.d.ts +11 -0
  139. package/lib/typescript/commonjs/ui/hooks/use-retained-state.d.ts.map +1 -0
  140. package/lib/typescript/commonjs/ui/screens/chat/ChatView.d.ts +4 -4
  141. package/lib/typescript/commonjs/ui/screens/chat/ChatView.d.ts.map +1 -1
  142. package/lib/typescript/commonjs/ui/screens/chat/ChatView.styles.d.ts +154 -2
  143. package/lib/typescript/commonjs/ui/screens/chat/ChatView.styles.d.ts.map +1 -1
  144. package/lib/typescript/commonjs/ui/screens/chat/ChatView.types.d.ts +30 -1
  145. package/lib/typescript/commonjs/ui/screens/chat/ChatView.types.d.ts.map +1 -1
  146. package/lib/typescript/commonjs/ui/screens/conversations/ConversationsList.d.ts.map +1 -1
  147. package/lib/typescript/commonjs/ui/screens/conversations/ConversationsList.types.d.ts +2 -0
  148. package/lib/typescript/commonjs/ui/screens/conversations/ConversationsList.types.d.ts.map +1 -1
  149. package/lib/typescript/commonjs/ui/screens/home/HomeView.d.ts +7 -5
  150. package/lib/typescript/commonjs/ui/screens/home/HomeView.d.ts.map +1 -1
  151. package/lib/typescript/commonjs/ui/screens/home/HomeView.styles.d.ts +30 -35
  152. package/lib/typescript/commonjs/ui/screens/home/HomeView.styles.d.ts.map +1 -1
  153. package/lib/typescript/commonjs/ui/screens/home/HomeView.types.d.ts +5 -6
  154. package/lib/typescript/commonjs/ui/screens/home/HomeView.types.d.ts.map +1 -1
  155. package/lib/typescript/commonjs/ui/styles/theme.d.ts +2 -0
  156. package/lib/typescript/commonjs/ui/styles/theme.d.ts.map +1 -1
  157. package/lib/typescript/commonjs/ui/utils/conversations.d.ts +10 -2
  158. package/lib/typescript/commonjs/ui/utils/conversations.d.ts.map +1 -1
  159. package/lib/typescript/commonjs/ui/utils/html.d.ts +5 -0
  160. package/lib/typescript/commonjs/ui/utils/html.d.ts.map +1 -1
  161. package/lib/typescript/commonjs/ui/utils/image-load-queue.d.ts +44 -0
  162. package/lib/typescript/commonjs/ui/utils/image-load-queue.d.ts.map +1 -0
  163. package/lib/typescript/commonjs/ui/utils/inline-attachments.d.ts +29 -0
  164. package/lib/typescript/commonjs/ui/utils/inline-attachments.d.ts.map +1 -0
  165. package/lib/typescript/module/api/client.d.ts +35 -1
  166. package/lib/typescript/module/api/client.d.ts.map +1 -1
  167. package/lib/typescript/module/attachments/file-size.d.ts +15 -0
  168. package/lib/typescript/module/attachments/file-size.d.ts.map +1 -0
  169. package/lib/typescript/module/attachments/local-previews.d.ts +14 -0
  170. package/lib/typescript/module/attachments/local-previews.d.ts.map +1 -0
  171. package/lib/typescript/module/attachments/pickers.d.ts +35 -10
  172. package/lib/typescript/module/attachments/pickers.d.ts.map +1 -1
  173. package/lib/typescript/module/i18n.d.ts +13 -3
  174. package/lib/typescript/module/i18n.d.ts.map +1 -1
  175. package/lib/typescript/module/locales.d.ts.map +1 -1
  176. package/lib/typescript/module/state/widget-store.d.ts +67 -4
  177. package/lib/typescript/module/state/widget-store.d.ts.map +1 -1
  178. package/lib/typescript/module/storage.d.ts +2 -0
  179. package/lib/typescript/module/storage.d.ts.map +1 -1
  180. package/lib/typescript/module/types.d.ts +58 -0
  181. package/lib/typescript/module/types.d.ts.map +1 -1
  182. package/lib/typescript/module/ui/WidgetProvider.d.ts.map +1 -1
  183. package/lib/typescript/module/ui/components/AttachmentChips.d.ts +13 -3
  184. package/lib/typescript/module/ui/components/AttachmentChips.d.ts.map +1 -1
  185. package/lib/typescript/module/ui/components/ConversationRow.d.ts +15 -1
  186. package/lib/typescript/module/ui/components/ConversationRow.d.ts.map +1 -1
  187. package/lib/typescript/module/ui/components/ImageViewer.d.ts +26 -6
  188. package/lib/typescript/module/ui/components/ImageViewer.d.ts.map +1 -1
  189. package/lib/typescript/module/ui/components/RatingCard.d.ts.map +1 -1
  190. package/lib/typescript/module/ui/components/ZoomableImage.d.ts +10 -1
  191. package/lib/typescript/module/ui/components/ZoomableImage.d.ts.map +1 -1
  192. package/lib/typescript/module/ui/components/icons.d.ts +2 -1
  193. package/lib/typescript/module/ui/components/icons.d.ts.map +1 -1
  194. package/lib/typescript/module/ui/hooks/use-retained-state.d.ts +11 -0
  195. package/lib/typescript/module/ui/hooks/use-retained-state.d.ts.map +1 -0
  196. package/lib/typescript/module/ui/screens/chat/ChatView.d.ts +4 -4
  197. package/lib/typescript/module/ui/screens/chat/ChatView.d.ts.map +1 -1
  198. package/lib/typescript/module/ui/screens/chat/ChatView.styles.d.ts +154 -2
  199. package/lib/typescript/module/ui/screens/chat/ChatView.styles.d.ts.map +1 -1
  200. package/lib/typescript/module/ui/screens/chat/ChatView.types.d.ts +30 -1
  201. package/lib/typescript/module/ui/screens/chat/ChatView.types.d.ts.map +1 -1
  202. package/lib/typescript/module/ui/screens/conversations/ConversationsList.d.ts.map +1 -1
  203. package/lib/typescript/module/ui/screens/conversations/ConversationsList.types.d.ts +2 -0
  204. package/lib/typescript/module/ui/screens/conversations/ConversationsList.types.d.ts.map +1 -1
  205. package/lib/typescript/module/ui/screens/home/HomeView.d.ts +7 -5
  206. package/lib/typescript/module/ui/screens/home/HomeView.d.ts.map +1 -1
  207. package/lib/typescript/module/ui/screens/home/HomeView.styles.d.ts +30 -35
  208. package/lib/typescript/module/ui/screens/home/HomeView.styles.d.ts.map +1 -1
  209. package/lib/typescript/module/ui/screens/home/HomeView.types.d.ts +5 -6
  210. package/lib/typescript/module/ui/screens/home/HomeView.types.d.ts.map +1 -1
  211. package/lib/typescript/module/ui/styles/theme.d.ts +2 -0
  212. package/lib/typescript/module/ui/styles/theme.d.ts.map +1 -1
  213. package/lib/typescript/module/ui/utils/conversations.d.ts +10 -2
  214. package/lib/typescript/module/ui/utils/conversations.d.ts.map +1 -1
  215. package/lib/typescript/module/ui/utils/html.d.ts +5 -0
  216. package/lib/typescript/module/ui/utils/html.d.ts.map +1 -1
  217. package/lib/typescript/module/ui/utils/image-load-queue.d.ts +44 -0
  218. package/lib/typescript/module/ui/utils/image-load-queue.d.ts.map +1 -0
  219. package/lib/typescript/module/ui/utils/inline-attachments.d.ts +29 -0
  220. package/lib/typescript/module/ui/utils/inline-attachments.d.ts.map +1 -0
  221. package/package.json +1 -1
  222. package/src/api/client.ts +148 -2
  223. package/src/attachments/file-size.ts +42 -0
  224. package/src/attachments/local-previews.ts +32 -0
  225. package/src/attachments/pickers.ts +90 -30
  226. package/src/i18n.ts +24 -3
  227. package/src/locales.ts +13 -3
  228. package/src/state/widget-store.ts +519 -70
  229. package/src/storage.ts +2 -0
  230. package/src/types.ts +58 -0
  231. package/src/ui/WidgetProvider.tsx +50 -12
  232. package/src/ui/components/AttachmentChips.tsx +100 -29
  233. package/src/ui/components/ConversationRow.tsx +90 -9
  234. package/src/ui/components/ImageViewer.tsx +250 -28
  235. package/src/ui/components/RatingCard.tsx +5 -2
  236. package/src/ui/components/ZoomableImage.tsx +58 -5
  237. package/src/ui/components/icons.tsx +10 -12
  238. package/src/ui/hooks/use-retained-state.ts +35 -0
  239. package/src/ui/screens/chat/ChatView.styles.ts +151 -3
  240. package/src/ui/screens/chat/ChatView.tsx +760 -213
  241. package/src/ui/screens/chat/ChatView.types.ts +30 -1
  242. package/src/ui/screens/conversations/ConversationsList.tsx +1 -0
  243. package/src/ui/screens/conversations/ConversationsList.types.ts +2 -0
  244. package/src/ui/screens/home/HomeView.styles.ts +36 -45
  245. package/src/ui/screens/home/HomeView.tsx +54 -70
  246. package/src/ui/screens/home/HomeView.types.ts +5 -6
  247. package/src/ui/styles/theme.ts +6 -0
  248. package/src/ui/utils/conversations.ts +16 -2
  249. package/src/ui/utils/html.ts +26 -0
  250. package/src/ui/utils/image-load-queue.ts +108 -0
  251. package/src/ui/utils/inline-attachments.ts +71 -0
@@ -0,0 +1,109 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Lets images load a few at a time, highest priority first. The chat runs its
5
+ * large images through it: Android holds a whole download in a memory pool
6
+ * capped at three quarters of the app's heap (192 MB on a 256 MB phone), so
7
+ * several 30–50 MB photos at once overflow it and every one of them fails.
8
+ *
9
+ * No `react-native` import on purpose: it stays testable in plain Node.
10
+ */
11
+ export class ImageLoadQueue {
12
+ // Key → priority, for both: an image paused off screen waits again at its own.
13
+ waiting = new Map();
14
+ loading = new Map();
15
+ done = new Set();
16
+ /** The images on screen; null until the list says, so all of them count. */
17
+ onScreen = null;
18
+ listeners = new Set();
19
+ scheduled = false;
20
+ constructor(concurrency) {
21
+ this.concurrency = concurrency;
22
+ }
23
+
24
+ /** Queues a mounted image; the returned cleanup gives up its place. */
25
+ add(key, priority) {
26
+ if (!this.done.has(key) && !this.loading.has(key)) {
27
+ this.waiting.set(key, Number.isFinite(priority) ? priority : 0);
28
+ this.schedule();
29
+ }
30
+ return () => this.remove(key);
31
+ }
32
+
33
+ /** Loaded or failed: it keeps showing, and the next image may start. */
34
+ finish(key) {
35
+ this.waiting.delete(key);
36
+ this.done.add(key);
37
+ if (this.loading.delete(key)) this.advance();
38
+ }
39
+ canLoad = key => this.done.has(key) || this.loading.has(key);
40
+ subscribe = listener => {
41
+ this.listeners.add(listener);
42
+ return () => {
43
+ this.listeners.delete(listener);
44
+ };
45
+ };
46
+
47
+ /**
48
+ * The images now on screen. One that scrolls off before it has loaded
49
+ * gives up its place and waits, so it can't hold up the ones in view:
50
+ * Android detaches a row scrolled out of view, and a detached image never
51
+ * finishes loading. Only images on screen are started.
52
+ */
53
+ setOnScreen(keys) {
54
+ this.onScreen = new Set(keys);
55
+ let paused = false;
56
+ this.loading.forEach((priority, key) => {
57
+ if (this.onScreen.has(key)) return;
58
+ this.loading.delete(key);
59
+ this.waiting.set(key, priority);
60
+ paused = true;
61
+ });
62
+ if (!this.advance() && paused) this.notify();
63
+ }
64
+
65
+ /** Scrolled out of the list before it loaded: it queues again if it comes back. */
66
+ remove(key) {
67
+ this.waiting.delete(key);
68
+ if (this.loading.delete(key)) this.advance();
69
+ }
70
+
71
+ /**
72
+ * Hands out places once the render that mounted an image is done, so all
73
+ * the images mounted together are queued first, whatever order they
74
+ * mounted in.
75
+ */
76
+ schedule() {
77
+ if (this.scheduled) return;
78
+ this.scheduled = true;
79
+ Promise.resolve().then(() => {
80
+ this.scheduled = false;
81
+ this.advance();
82
+ });
83
+ }
84
+
85
+ /** Starts what fits; true when anything started (listeners were told). */
86
+ advance() {
87
+ let started = false;
88
+ while (this.loading.size < this.concurrency) {
89
+ let next = null;
90
+ let best = -Infinity;
91
+ this.waiting.forEach((priority, key) => {
92
+ if (priority > best && (!this.onScreen || this.onScreen.has(key))) {
93
+ best = priority;
94
+ next = key;
95
+ }
96
+ });
97
+ if (next === null) break;
98
+ this.waiting.delete(next);
99
+ this.loading.set(next, best);
100
+ started = true;
101
+ }
102
+ if (started) this.notify();
103
+ return started;
104
+ }
105
+ notify() {
106
+ this.listeners.forEach(listener => listener());
107
+ }
108
+ }
109
+ //# sourceMappingURL=image-load-queue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["ImageLoadQueue","waiting","Map","loading","done","Set","onScreen","listeners","scheduled","constructor","concurrency","add","key","priority","has","set","Number","isFinite","schedule","remove","finish","delete","advance","canLoad","subscribe","listener","setOnScreen","keys","paused","forEach","notify","Promise","resolve","then","started","size","next","best","Infinity"],"sourceRoot":"../../../../src","sources":["ui/utils/image-load-queue.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMA,cAAc,CAAC;EAC1B;EACiBC,OAAO,GAAG,IAAIC,GAAG,CAAiB,CAAC;EACnCC,OAAO,GAAG,IAAID,GAAG,CAAiB,CAAC;EACnCE,I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9B,IAAIC,IAAI,GAAG,CAACC,QAAQ;MACpB,IAAI,CAACrC,OAAO,CAAC4B,OAAO,CAAC,CAAChB,QAAQ,EAAED,GAAG,KAAK;QACtC,IAAIC,QAAQ,GAAGwB,IAAI,KAAK,CAAC,IAAI,CAAC/B,QAAQ,IAAI,IAAI,CAACA,QAAQ,CAACQ,GAAG,CAACF,GAAG,CAAC,CAAC,EAAE;UACjEyB,IAAI,GAAGxB,QAAQ;UACfuB,IAAI,GAAGxB,GAAG;QACZ;MACF,CAAC,CAAC;MACF,IAAIwB,IAAI,KAAK,IAAI,EAAE;MACnB,IAAI,CAACnC,OAAO,CAACoB,MAAM,CAACe,IAAI,CAAC;MACzB,IAAI,CAACjC,OAAO,CAACY,GAAG,CAACqB,IAAI,EAAEC,IAAI,CAAC;MAC5BH,OAAO,GAAG,IAAI;IAChB;IACA,IAAIA,OAAO,EAAE,IAAI,CAACJ,MAAM,CAAC,CAAC;IAC1B,OAAOI,OAAO;EAChB;EAEQJ,MAAMA,CAAA,EAAS;IACrB,IAAI,CAACvB,SAAS,CAACsB,OAAO,CAAEJ,QAAQ,IAAKA,QAAQ,CAAC,CAAC,CAAC;EAClD;AACF","ignoreList":[]}
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Agent replies with images between their paragraphs. Workstation marks such
5
+ * images `inline` among the message's attachments and keeps an `<img>` for
6
+ * each in the HTML body, where the teammate put it. Same split as the web
7
+ * Messenger, so both show the text and images in the order they were written.
8
+ */
9
+
10
+ import { htmlToMarkdown } from "./html.js";
11
+
12
+ /** Markdown for the bubble to draw, or one attachment. */
13
+
14
+ /**
15
+ * The body and its inline images in order, plus the other attachments
16
+ * (`files`) that show after them. Null when nothing is inline: the bubble then
17
+ * shows the body, followed by every attachment.
18
+ *
19
+ * An `<img>` finds its attachment by the id in its URL. In a body whose
20
+ * images carry no ids, they take the attachments in order instead; in one
21
+ * that does, an image without an id (a logo, an emoji) isn't one of the files
22
+ * and takes nothing. One whose id names no remaining attachment (the same file
23
+ * twice) takes nothing either. Inline attachments with no `<img>` go at the end.
24
+ */
25
+ export function splitInlineAttachments(body, attachments) {
26
+ const inline = (attachments ?? []).filter(isInline);
27
+ if (!body || inline.length === 0) return null;
28
+ const remaining = [...inline];
29
+ const parts = [];
30
+ const pushText = html => {
31
+ const text = htmlToMarkdown(html);
32
+ if (text) parts.push({
33
+ text
34
+ });
35
+ };
36
+ const image = /<img\b[^>]*?\bsrc=(["'])(.*?)\1[^>]*>/gi;
37
+ const images = [];
38
+ for (let match = image.exec(body); match; match = image.exec(body)) {
39
+ images.push({
40
+ start: match.index,
41
+ end: image.lastIndex,
42
+ id: mediaId(match[2] ?? '')
43
+ });
44
+ }
45
+ const byId = images.some(found => found.id !== null);
46
+ let last = 0;
47
+ for (const {
48
+ start,
49
+ end,
50
+ id
51
+ } of images) {
52
+ // Left in the text, which drops it as it always has.
53
+ if (byId && !id) continue;
54
+ pushText(body.slice(last, start));
55
+ last = end;
56
+ const index = id ? remaining.findIndex(attachment => attachment.id === id) : 0;
57
+ if (index < 0) continue;
58
+ const [attachment] = remaining.splice(index, 1);
59
+ if (attachment) parts.push({
60
+ attachment
61
+ });
62
+ }
63
+ pushText(body.slice(last));
64
+ remaining.forEach(attachment => parts.push({
65
+ attachment
66
+ }));
67
+ return {
68
+ parts,
69
+ files: (attachments ?? []).filter(attachment => !isInline(attachment))
70
+ };
71
+ }
72
+
73
+ /**
74
+ * Workstation's media URLs carry the attachment's id, as
75
+ * `/api/widget/media/<id>?…` (what replies carry) or `/api/media/<id>/download`.
76
+ */
77
+ function mediaId(src) {
78
+ return /\/api\/(?:widget\/)?media\/([^/?#"'&]+)/.exec(src)?.[1] ?? null;
79
+ }
80
+
81
+ /** Only Workstation's agent replies set `inline`, so it isn't on `WidgetAttachment`. */
82
+ function isInline(attachment) {
83
+ return attachment.inline === true;
84
+ }
85
+ //# sourceMappingURL=inline-attachments.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["htmlToMarkdown","splitInlineAttachments","body","attachments","inline","filter","isInline","length","remaining","parts","pushText","html","text","push","image","images","match","exec","start","index","end","lastIndex","id","mediaId","byId","some","found","last","slice","findIndex","attachment","splice","forEach","files","src"],"sourceRoot":"../../../../src","sources":["ui/utils/inline-attachments.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,cAAc,QAAQ,WAAQ;;AAEvC;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,sBAAsBA,CACpCC,IAA+B,EAC/BC,WAAkD,EACU;EAC5D,MAAMC,MAAM,GAAG,CAACD,WAAW,IAAI,EAAE,EAAEE,MAAM,CAACC,QAAQ,CAAC;EACnD,IAAI,CAACJ,IAAI,IAAIE,MAAM,CAACG,MAAM,KAAK,CAAC,EAAE,OAAO,IAAI;EAE7C,MAAMC,SAAS,GAAG,CAAC,GAAGJ,MAAM,CAAC;EAC7B,MAAMK,KAAoB,GAAG,EAAE;EAC/B,MAAMC,QAAQ,GAAIC,IAAY,IAAK;IACjC,MAAMC,IAAI,GAAGZ,cAAc,CAACW,IAAI,CAAC;IACjC,IAAIC,IAAI,EAAEH,KAAK,CAACI,IAAI,CAAC;MAAED;IAAK,CAAC,CAAC;EAChC,CAAC;EACD,MAAME,KAAK,GAAG,yCAAyC;EACvD,MAAMC,MAAgE,GAAG,EAAE;EAC3E,KAAK,IAAIC,KAAK,GAAGF,KAAK,CAACG,IAAI,CAACf,IAAI,CAAC,EAAEc,KAAK,EAAEA,KAAK,GAAGF,KAAK,CAACG,IAAI,CAACf,IAAI,CAAC,EAAE;IAClEa,MAAM,CAACF,IAAI,CAAC;MAAEK,KAAK,EAAEF,KAAK,CAACG,KAAK;MAAEC,GAAG,EAAEN,KAAK,CAACO,SAAS;MAAEC,EAAE,EAAEC,OAAO,CAACP,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE;IAAE,CAAC,CAAC;EACxF;EACA,MAAMQ,I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,UAAU,CAA0B1B,MAAM,KAAK,IAAI;AAC7D","ignoreList":[]}
@@ -16,6 +16,12 @@ export declare class RepzoWidgetError extends Error {
16
16
  /** Builds the error for a non-2xx `{ message, code }` body. */
17
17
  static fromResponse(status: number, body: unknown): RepzoWidgetError;
18
18
  }
19
+ /** A file in storage, waiting for the message that names it. */
20
+ export interface UploadedFile {
21
+ uploadToken: string;
22
+ /** When Workstation stops taking `uploadToken`, on this phone's clock (ms). */
23
+ expiresAt: number;
24
+ }
19
25
  export declare class WidgetApiClient {
20
26
  private baseUrl;
21
27
  private channelAccountId;
@@ -94,21 +100,49 @@ export declare class WidgetApiClient {
94
100
  conversationId?: string;
95
101
  forceNewConversation?: boolean;
96
102
  body: string;
97
- /** `url` is a base64 data URL; max 5, each <= 1.5 MB decoded. */
103
+ /**
104
+ * Max 5. Either inline (`url`, a base64 data URL, each <= 1.5 MB decoded)
105
+ * or uploaded first (`uploadToken`, from uploadAttachment).
106
+ */
98
107
  attachments?: Array<{
99
108
  name: string;
100
109
  url: string;
101
110
  contentType: string;
102
111
  size: number;
112
+ } | {
113
+ name: string;
114
+ uploadToken: string;
115
+ contentType: string;
116
+ size: number;
103
117
  }>;
104
118
  visitorName?: string;
105
119
  visitorEmail?: string;
106
120
  agentUiAction?: AgentUiAction;
121
+ /**
122
+ * Same on every retry of a message. Newer Workstation deployments store it
123
+ * once and echo it on the stored row; older ones don't read it.
124
+ */
125
+ clientMessageId?: string;
107
126
  }): Promise<{
108
127
  messageId: string;
109
128
  conversationId: string;
110
129
  isNewConversation: boolean;
111
130
  }>;
131
+ /**
132
+ * Puts a local file in storage ahead of the message, which then names it by
133
+ * the returned upload token. The target is presigned storage, or a path on
134
+ * the server where its storage can't presign. The upload URL is signed for
135
+ * exactly the size asked for: a `file://` file whose size `expo-file-system`
136
+ * can read streams from disk, anything else is read as a native blob and
137
+ * measured. `signal` cancels the transfer (the visitor removed the file, or
138
+ * left the conversation). Resolves the token and when it expires.
139
+ */
140
+ uploadAttachment(file: {
141
+ uri: string;
142
+ name: string;
143
+ contentType: string;
144
+ size: number;
145
+ }, signal?: AbortSignal): Promise<UploadedFile>;
112
146
  listConversations(): Promise<{
113
147
  data: Conversation[];
114
148
  }>;
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../src/api/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,KAAK,EACV,aAAa,EACb,YAAY,EACZ,wBAAwB,EACxB,YAAY,EACZ,OAAO,EACP,eAAe,EACf,mBAAmB,EACnB,SAAS,EACT,oBAAoB,EACpB,YAAY,EACZ,UAAU,EACV,UAAU,EACX,MAAM,UAAU,CAAC;AASlB,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,CAE5E;AAED,qBAAa,gBAAiB,SAAQ,KAAK;IACzC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAExB,QAAQ,CAAC,IAAI,EAAE,oBAAoB,CAAC;gBAExB,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,GAAE,oBAA6B;IAOhF,+DAA+D;IAC/D,MAAM,CAAC,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,gBAAgB;CAYrE;AAwBD,qBAAa,eAAe;IAC1B,OAAO,CAAC,OAAO,CAAM;IAErB,OAAO,CAAC,gBAAgB,CAAM;IAE9B,OAAO,CAAC,KAAK,CAAuB;IAEpC,OAAO,CAAC,WAAW,CAAS;IAE5B;;;OAGG;IACH,WAAW,EAAE,CAAC,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,KAAK,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC,GAAG,IAAI,CAAQ;IAEpF,kFAAkF;IAClF,eAAe,EAAE,CAAC,CAAC,KAAK,EAAE,gBAAgB,KAAK,IAAI,CAAC,GAAG,IAAI,CAAQ;IAEnE,2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QACtB,KAAK,EAAE,MAAM,CAAC;QACd,QAAQ,EAAE,MAAM,CAAC;QACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,GAAG,OAAO,CAAC,IAAI,CAAC;IAIjB,gGAAgG;IAChG,gBAAgB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAInD,qEAAqE;IACrE,eAAe,CACb,KAAK,EAAE,MAAM,EACb,IAAI,GAAE;QAAE,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,UAAU,CAAC,EAAE,OAAO,CAAA;KAAO,GAC7D,OAAO,CAAC,IAAI,CAAC;CAOjB"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Local file sizes from the host's `expo-file-system` (optional, like the
3
+ * pickers): read from the file's metadata, never from its contents. Shared by
4
+ * the pickers and the upload client, so the client doesn't pull in pickers.
5
+ *
6
+ * No `react-native` import on purpose: it stays testable in plain Node.
7
+ */
8
+ /** A positive, finite byte count, or null. */
9
+ export declare function validSize(size: unknown): number | null;
10
+ /**
11
+ * A local file's exact size in bytes, from its metadata without reading it.
12
+ * Null without `expo-file-system`, or when it can't tell.
13
+ */
14
+ export declare function measureFileSize(uri: string): Promise<number | null>;
15
+ //# sourceMappingURL=file-size.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-size.d.ts","sourceRoot":"","sources":["../../../../src/attachments/file-size.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AASH,8CAA8C;AAC9C,wBAAgB,SAAS,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAEtD;AAED;;;GAGG;AACH,wBAAsB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAiBzE"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * The phone's copy of each file the visitor sent, by the URL of the stored
3
+ * copy that replaced it in the thread. Right after a send the stored copy
4
+ * may not load yet (Workstation can still be storing it), so a photo keeps
5
+ * showing from the phone instead of turning into a file row. Kept in memory
6
+ * only: a later session shows the stored copy.
7
+ */
8
+ export declare function rememberLocalPreview(storedUrl: string, localUrl: string): void;
9
+ export declare function localPreviewFor(storedUrl: string): string | null;
10
+ /** One that failed to load (the OS cleared the picker's cache): every view moves to the stored copy. */
11
+ export declare function forgetLocalPreview(storedUrl: string): void;
12
+ /** Signing out forgets them: the next visitor on the phone doesn't inherit the paths. */
13
+ export declare function clearLocalPreviews(): void;
14
+ //# sourceMappingURL=local-previews.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"local-previews.d.ts","sourceRoot":"","sources":["../../../../src/attachments/local-previews.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAM9E;AAED,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAEhE;AAED,wGAAwG;AACxG,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAE1D;AAED,yFAAyF;AACzF,wBAAgB,kBAAkB,IAAI,IAAI,CAEzC"}
@@ -1,6 +1,10 @@
1
1
  /**
2
- * Visitor attachments: picking photos/files and turning them into the base64
3
- * data URLs `POST /api/widget/messages` accepts.
2
+ * Visitor attachments: picking photos/files for `POST /api/widget/messages`.
3
+ *
4
+ * A server that takes uploads names its cap (`maxAttachmentBytes`): a picked
5
+ * file then stays a local URI, which the composer uploads right away. An
6
+ * older server only takes files inline, as base64 data URLs within the
7
+ * 1.5 MB / 6 MB caps below.
4
8
  *
5
9
  * The SDK ships no native code, so every picker is borrowed from the host —
6
10
  * the same approach as `storage.ts` and `native-gradient.ts`:
@@ -8,7 +12,7 @@
8
12
  * - `expo-document-picker` → any file
9
13
  * - `expo-file-system` → reads a picked file as base64 (optional; without it
10
14
  * the file is read through `fetch` + `FileReader`)
11
- * - `expo-image-manipulator` → shrinks photos to fit the 1.5 MB cap (optional;
15
+ * - `expo-image-manipulator` → shrinks photos, to fit the 1.5 MB inline cap (optional;
12
16
  * without it a full-resolution camera photo is usually refused as too large)
13
17
  *
14
18
  * A host without those (or with `react-native-image-picker` etc.) plugs its own
@@ -21,25 +25,36 @@
21
25
  import type { AttachmentSource, RepzoWidgetAttachmentOptions } from '../types';
22
26
  /** The server keeps the first five and silently drops the rest. */
23
27
  export declare const MAX_ATTACHMENTS = 5;
24
- /** Per file, decoded. The server silently drops anything larger. */
28
+ /** Per inline file, decoded. The server silently drops anything larger. */
25
29
  export declare const MAX_ATTACHMENT_BYTES = 1500000;
26
30
  /**
27
- * All files in one message, decoded. Base64 inside JSON inflates bytes by
31
+ * All inline files in one message, decoded. Base64 inside JSON inflates bytes by
28
32
  * ~1.37x and the server caps a request body at 10 MB, so five files at the
29
33
  * per-file maximum would come back as a 413.
30
34
  */
31
35
  export declare const MAX_TOTAL_ATTACHMENT_BYTES = 6000000;
32
- /** A picked file, encoded and ready to send; what the composer shows as a chip. */
36
+ /** A picked file, ready to send; what the composer shows as a chip. */
33
37
  export interface DraftAttachment {
34
38
  id: string;
35
39
  name: string;
36
40
  contentType: string;
37
41
  /** Decoded bytes — what the server measures against its cap. */
38
42
  size: number;
39
- /** `data:<mime>;base64,<…>` — the wire format. */
43
+ /** `data:<mime>;base64,<…>` for an inline file; empty when `fileUri` is uploaded instead. */
40
44
  dataUrl: string;
45
+ /** The local file uploaded ahead of the message. */
46
+ fileUri?: string;
41
47
  /** What `<Image>` renders locally: the picked file's URI, else the data URL. */
42
48
  previewUri: string;
49
+ /**
50
+ * Where `fileUri`'s upload stands. The composer starts it as soon as the
51
+ * file is picked and holds Send until every file is up. Absent for inline files.
52
+ */
53
+ uploadStatus?: 'uploading' | 'uploaded' | 'failed';
54
+ /** What the message names the uploaded file by, once `uploadStatus` is `uploaded`. */
55
+ uploadToken?: string;
56
+ /** When `uploadToken` stops working, on this phone's clock (ms). */
57
+ uploadExpiresAt?: number;
43
58
  }
44
59
  /** Why some (or all) of a pick didn't make it into the composer. */
45
60
  export type AttachmentProblem = 'tooMany' | 'tooLarge' | 'tooLargeTogether' | 'cameraDenied' | 'failed';
@@ -50,6 +65,8 @@ export interface PickResult {
50
65
  }
51
66
  /** Set from `boot({ attachments })`; `null` restores auto-detection. */
52
67
  export declare function setAttachmentOptions(options: RepzoWidgetAttachmentOptions | null): void;
68
+ /** Whether a picked file starts uploading before Send (`attachments.uploadOnPick`). */
69
+ export declare function uploadsOnPick(): boolean;
53
70
  /**
54
71
  * The options the attach menu offers, in menu order. Empty means no button:
55
72
  * attachments were switched off by the host, or nothing can pick a file.
@@ -57,13 +74,19 @@ export declare function setAttachmentOptions(options: RepzoWidgetAttachmentOptio
57
74
  export declare function getAttachmentSources(): AttachmentSource[];
58
75
  /**
59
76
  * Opens the picker for `source` and returns what fits alongside `current`.
77
+ * `uploadLimit` is the server's upload cap; without it files go inline.
60
78
  * Never throws: a cancelled pick is `{ added: [], problem: null }`.
61
79
  */
62
- export declare function pickAttachments(source: AttachmentSource, current: DraftAttachment[]): Promise<PickResult>;
63
- /** Null when a file of `size` bytes still fits beside `current`; otherwise the limit it breaks. */
80
+ export declare function pickAttachments(source: AttachmentSource, current: DraftAttachment[], uploadLimit?: number | null): Promise<PickResult>;
81
+ /**
82
+ * Null when a file of `size` bytes still fits beside `current`; otherwise the
83
+ * limit it breaks. With `uploadLimit` the file is uploaded on its own, so
84
+ * only its own size counts; inline files also share one request body.
85
+ */
64
86
  export declare function checkAttachmentFits(current: ReadonlyArray<{
65
87
  size: number;
66
- }>, size: number): AttachmentProblem | null;
88
+ fileUri?: string;
89
+ }>, size: number, uploadLimit?: number | null): AttachmentProblem | null;
67
90
  export declare function buildDataUrl(contentType: string, base64: string): string;
68
91
  /**
69
92
  * A picker's MIME type as a bare lowercase `type/subtype`, or null when it
@@ -78,4 +101,6 @@ export declare function base64ByteLength(base64: string): number;
78
101
  /** `1.2 MB`, `340 KB` — for chips; the limits themselves use decimal units too. */
79
102
  export declare function formatBytes(bytes: number): string;
80
103
  export declare function isImageAttachment(contentType: string | null | undefined): boolean;
104
+ /** The type a file name's extension implies, or null for one this table doesn't know. */
105
+ export declare function guessContentType(nameOrUri: string | null | undefined): string | null;
81
106
  //# sourceMappingURL=pickers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"pickers.d.ts","sourceRoot":"","sources":["../../../../src/attachments/pickers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAmB,4BAA4B,EAAE,MAAM,UAAU,CAAC;AAEhG,mEAAmE;AACnE,eAAO,MAAM,eAAe,IAAI,CAAC;AACjC,oEAAoE;AACpE,eAAO,MAAM,oBAAoB,UAAY,CAAC;AAC9C;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,UAAY,CAAC;AAKpD,mFAAmF;AACnF,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,gEAAgE;IAChE,IAAI,EAAE,MAAM,CAAC;IACb,kDAAkD;IAClD,OAAO,EAAE,MAAM,CAAC;IAChB,gFAAgF;IAChF,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,oEAAoE;AACpE,MAAM,MAAM,iBAAiB,GACzB,SAAS,GACT,UAAU,GACV,kBAAkB,GAClB,cAAc,GACd,QAAQ,CAAC;AAEb,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,eAAe,EAAE,CAAC;IACzB,uEAAuE;IACvE,OAAO,EAAE,iBAAiB,GAAG,IAAI,CAAC;CACnC;AAgDD,wEAAwE;AACxE,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,4BAA4B,GAAG,IAAI,GAAG,IAAI,CAEvF;AAID;;;GAGG;AACH,wBAAgB,oBAAoB,IAAI,gBAAgB,EAAE,CAWzD;AAOD;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,MAAM,GAAG,IAAW,GAChC,iBAAiB,GAAG,IAAI,CAO1B;AAED,wBAAgB,YAAY,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAExE;AAKD;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAIpF;AAED,uEAAuE;AACvE,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAGxD;AAED,8DAA8D;AAC9D,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAKvD;AAED,mFAAmF;AACnF,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAIjD;AAED,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,CAEjF;AAqCD,yFAAyF;AACzF,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAGpF"}
@@ -20,6 +20,10 @@ export declare const DEFAULT_LABELS: {
20
20
  readonly loadEarlier: "Load earlier messages";
21
21
  readonly emptyConversation: "Send a message to start the conversation";
22
22
  readonly messagePlaceholder: "Type a message...";
23
+ readonly sendMessage: "Send message";
24
+ readonly jumpToLatest: "Jump to latest messages";
25
+ readonly jumpToLatestNew: "New messages: {count}. Jump to latest";
26
+ readonly morePhotos: "{count} more photos";
23
27
  readonly attachFile: "Attach file";
24
28
  readonly attachPhotoLibrary: "Photo library";
25
29
  readonly attachTakePhoto: "Take photo";
@@ -29,15 +33,20 @@ export declare const DEFAULT_LABELS: {
29
33
  readonly attachmentTooMany: "You can attach up to {count} files";
30
34
  readonly attachmentsTooLargeTogether: "Attachments are too large to send together — send some in another message";
31
35
  readonly attachmentFailed: "Couldn't attach that file";
36
+ readonly attachmentUploading: "Uploading {name}";
37
+ readonly attachmentUploadFailed: "Couldn't upload {name}. Tap to try again";
38
+ readonly attachmentsUploadFailed: "Couldn't upload a file. Tap it to try again";
32
39
  readonly openAttachment: "Open {name}";
33
40
  readonly voicePlay: "Play voice message";
34
41
  readonly voicePause: "Pause voice message";
35
42
  readonly voiceSpeed: "Playback speed";
36
43
  readonly imageLoadFailed: "Couldn't load this image";
37
44
  readonly openImageExternally: "Open image";
45
+ readonly imagePosition: "{current} of {total}";
38
46
  readonly cameraPermissionDenied: "Allow camera access in Settings to take a photo";
39
47
  readonly cancel: "Cancel";
40
48
  readonly failedToSend: "Failed to send";
49
+ readonly tapToRetry: "Tap to retry";
41
50
  readonly thinking: "Typing";
42
51
  readonly messages: "Messages";
43
52
  readonly noMessages: "No messages yet";
@@ -47,13 +56,14 @@ export declare const DEFAULT_LABELS: {
47
56
  readonly preChatSubtitle: "Let us know a bit about you so we can help you better.";
48
57
  readonly preChatSkip: "Skip";
49
58
  readonly preChatSubmit: "Start chat";
50
- readonly viewPreviousConversations: "View previous conversations";
51
- readonly homeRecentTitle: "Recent";
52
- readonly homeViewAllCount: "View all ({count})";
59
+ readonly homeRecentMessageTitle: "Recent message";
53
60
  readonly homeNoConversations: "Your conversations will show up here";
54
61
  readonly homeStatusOnline: "We're online";
55
62
  readonly homeStatusAway: "We're away";
56
63
  readonly unreadBadge: "{count} unread";
64
+ readonly lastMessagePhoto: "Photo";
65
+ readonly lastMessageFile: "File";
66
+ readonly lastMessageYou: "You: {message}";
57
67
  readonly team: "Team";
58
68
  readonly home: "Home";
59
69
  readonly close: "Close";
@@ -1 +1 @@
1
- {"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../../../src/i18n.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C,MAAM,MAAM,UAAU,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,MAAM,CAAC;A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,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqKjB,CAAC;AAEX,MAAM,MAAM,QAAQ,GAAG,MAAM,OAAO,cAAc,CAAC;AAEnD;;;GAGG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,GAAG,MAAM,CAI7F;AAED,wBAAgB,WAAW,CAAC,SAAS,EAAE,UAAU,GAAG,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,CAM3E"}
@@ -1 +1 @@
1
- {"version":3,"file":"locales.d.ts","sourceRoot":"","sources":["../../../src/locales.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAE7C,KAAK,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,OAAO,cAAc,EAAE,MAAM,CAAC,CAAC,CAAC;AAoIrE,eAAO,MAAM,oBAAoB,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAU,CAAC;AAErE,gEAAgE;AAChE,wBAAgB,YAAY,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAE3D"}
1
+ {"version":3,"file":"locales.d.ts","sourceRoot":"","sources":["../../../src/locales.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAE7C,KAAK,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,OAAO,cAAc,EAAE,MAAM,CAAC,CAAC,CAAC;AA8IrE,eAAO,MAAM,oBAAoB,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAU,CAAC;AAErE,gEAAgE;AAChE,wBAAgB,YAAY,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAE3D"}
@@ -7,7 +7,7 @@
7
7
  * and the unread count must stay alive while the UI is closed — the modal is
8
8
  * only a subscriber.
9
9
  */
10
- import { WidgetApiClient } from '../api/client';
10
+ import { WidgetApiClient, type UploadedFile } from '../api/client';
11
11
  import { EventEmitter } from '../events';
12
12
  import { PushManager } from '../push/push-notifications';
13
13
  import type { AgentUiAction, BootOptions, ConversationRatingResult, OutgoingAttachment, PostInteractionKind, PostReply, WidgetCustomAttributes, WidgetSpaceType, WidgetState, WidgetUser, WidgetView } from '../types';
@@ -27,6 +27,10 @@ export declare class WidgetStore {
27
27
  private inAppNotificationsEnabled;
28
28
  /** `boot({ posts })` — Send posts over the app. */
29
29
  private postsEnabled;
30
+ /** `boot({ photoAlbums })` — a message's photos share one album in the thread. */
31
+ private photoAlbumsEnabled;
32
+ /** `boot({ youPrefix })` — "You:" before the visitor's own newest message in the lists. */
33
+ private youPrefixEnabled;
30
34
  /** Posts whose view was reported this session (the server also dedupes per day). */
31
35
  private viewedPostIds;
32
36
  /** Bumped per post load, so an older answer never lands over a newer one. */
@@ -67,8 +71,17 @@ export declare class WidgetStore {
67
71
  private lastTypingPingAt;
68
72
  private visitorTypingActive;
69
73
  private seenMessageIds;
74
+ /** Who sent each thread's newest message and what it carried; see `withLastMessage`. */
75
+ private lastMessages;
76
+ private lastMessagesLoaded;
70
77
  /** Statuses (e.g. "read") that arrived for an id before a send response revealed it. */
71
78
  private earlyStatuses;
79
+ /** The agent UI action behind a failed bubble, so Retry runs it again too. */
80
+ private failedActions;
81
+ /** The next re-read for a sent file's stored copy (see `syncServerCopies`). */
82
+ private serverCopyTimer;
83
+ private serverCopyRetries;
84
+ private serverCopySyncing;
72
85
  /**
73
86
  * Identity generation. Bumped whenever boot/login/logout is requested; every
74
87
  * async path that writes session state captures it first and bails once it
@@ -116,6 +129,8 @@ export declare class WidgetStore {
116
129
  getState: () => WidgetState;
117
130
  /** Composer identity: explicit opens reset it; a draft receiving its server ID does not. */
118
131
  getThreadGeneration: () => number;
132
+ showsPhotoAlbums: () => boolean;
133
+ showsYouPrefix: () => boolean;
119
134
  private setState;
120
135
  private serialize;
121
136
  /** Queue a requested identity op; anything older becomes stale right away. */
@@ -240,6 +255,25 @@ export declare class WidgetStore {
240
255
  private rememberConversationAgent;
241
256
  private applyConversationAgent;
242
257
  private hydrateConversation;
258
+ /**
259
+ * Workstation's list doesn't say who sent the newest message, and calls one
260
+ * without words "2 attachments". While a row still describes the message
261
+ * this device saw last, both are filled in from it. `snippet` keeps the
262
+ * list's words: apps read it, and the lists draw "Photo" or "File" from
263
+ * `lastMessageAttachment` instead.
264
+ */
265
+ private withLastMessage;
266
+ /**
267
+ * A send or a streamed message is the newest by arrival, whatever the two
268
+ * clocks say; a history page only replaces something older. A sent message
269
+ * is timed by the phone, which may run ahead of Workstation, so instead a
270
+ * page that has it replaces it: whatever is newest there came after it, and
271
+ * Workstation's own time then stands in for the phone's.
272
+ */
273
+ private rememberLastMessage;
274
+ private loadLastMessages;
275
+ /** A thread's newest page shows who sent its newest message, so its row can say too. */
276
+ private learnLastMessage;
243
277
  /**
244
278
  * Normalizes attachments from history pages and live payloads alike. Live
245
279
  * payloads may omit `id`/`size`, so the list still gets a stable key.
@@ -281,6 +315,14 @@ export declare class WidgetStore {
281
315
  * server read cursor, which must not happen for a thread nobody is reading.
282
316
  */
283
317
  private refreshOpenThread;
318
+ /**
319
+ * Until its stored copy replaces it, a sent bubble points at the visitor's
320
+ * local files: a photo still opens in the viewer, but a PDF has nothing to
321
+ * open. When the stream's echo hasn't brought that copy, re-read the
322
+ * thread, and try again a few times while Workstation is still storing it.
323
+ */
324
+ private syncServerCopies;
325
+ private cancelServerCopySync;
284
326
  /** A history page (newest-first) as the oldest-first list the UI renders. */
285
327
  private hydrateMessages;
286
328
  /**
@@ -293,11 +335,32 @@ export declare class WidgetStore {
293
335
  private hydrateBlockMedia;
294
336
  /**
295
337
  * Rejects when the message wasn't sent, so the composer can keep
296
- * attachments for a retry. A text-only bubble is marked failed; one with
297
- * attachments is removed instead — the composer's chips are the retry, and
298
- * keeping both would leave a duplicate after a successful resend.
338
+ * attachments for a retry. A text-only bubble is marked failed and can be
339
+ * re-sent with `retryMessage`; one with attachments is removed instead — the
340
+ * composer's chips are the retry, and keeping both would leave a duplicate
341
+ * after a successful resend. Likewise an agent UI action replaces the
342
+ * failed bubble of the same action, since its card stays tappable.
299
343
  */
300
344
  sendMessage(body: string, attachments?: OutgoingAttachment[], agentUiAction?: AgentUiAction): Promise<void>;
345
+ /**
346
+ * Puts a picked file in storage while the visitor is still writing, so
347
+ * Send goes out at once. Resolves the token `sendMessage` names it by, and
348
+ * when that token expires.
349
+ */
350
+ uploadAttachment(file: {
351
+ uri: string;
352
+ name: string;
353
+ contentType: string;
354
+ size: number;
355
+ }, signal?: AbortSignal): Promise<UploadedFile>;
356
+ /**
357
+ * Re-sends a text bubble that failed. It moves to the end of the thread,
358
+ * since it now goes out after anything sent meanwhile. Rejects like
359
+ * `sendMessage` when it fails again; the bubble is then failed once more.
360
+ */
361
+ retryMessage(messageId: string): Promise<void>;
362
+ /** Sends the optimistic bubble `tempId`, already on screen as pending. */
363
+ private deliverMessage;
301
364
  identifyVisitor(data: {
302
365
  email?: string;
303
366
  name?: string;