@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
@@ -1,6 +1,7 @@
1
1
  import type { TeamAvatar } from '../../../types';
2
2
  /** Props and label bundle for the chat thread. */
3
3
 
4
+ import type { UploadedFile } from '../../../api/client';
4
5
  import type { DraftAttachment, PickResult } from '../../../attachments/pickers';
5
6
  import type {
6
7
  AgentUiAction,
@@ -20,7 +21,17 @@ export interface ChatLabels {
20
21
  loadEarlier: string;
21
22
  emptyConversation: string;
22
23
  messagePlaceholder: string;
24
+ /** Screen-reader label of the send button. */
25
+ send: string;
26
+ /** The button back to the newest message. */
27
+ jumpToLatest: string;
28
+ /** The same with `{count}` teammate replies that arrived while scrolled up. */
29
+ jumpToLatestNew: string;
30
+ /** Last tile of a photo album, with `{count}` photos behind its "+N". */
31
+ morePhotos: string;
23
32
  failedToSend: string;
33
+ /** After `failedToSend` on a bubble that can be re-sent. */
34
+ tapToRetry: string;
24
35
  thinking: string;
25
36
  team: string;
26
37
  statusOnline: string;
@@ -55,7 +66,10 @@ export interface ChatLabels {
55
66
  openAttachment: string;
56
67
  }
57
68
 
58
- /** Composer attachment copy. Limits are already filled in; `remove` keeps `{name}`. */
69
+ /**
70
+ * Composer attachment copy. Limits are already filled in; `remove`,
71
+ * `uploading` and `uploadFailed` keep `{name}`.
72
+ */
59
73
  export interface AttachLabels {
60
74
  button: string;
61
75
  photoLibrary: string;
@@ -68,6 +82,11 @@ export interface AttachLabels {
68
82
  tooLargeTogether: string;
69
83
  failed: string;
70
84
  cameraDenied: string;
85
+ uploading: string;
86
+ uploadFailed: string;
87
+ uploadFailedNotice: string;
88
+ /** Under a file chip whose upload failed. */
89
+ retry: string;
71
90
  }
72
91
 
73
92
  export interface ChatViewProps {
@@ -98,12 +117,20 @@ export interface ChatViewProps {
98
117
  attachmentSources?: AttachmentSource[];
99
118
  /** Opens a picker and returns what fits beside `current`. Never rejects. */
100
119
  onPickAttachments?: (source: AttachmentSource, current: DraftAttachment[]) => Promise<PickResult>;
120
+ /**
121
+ * Uploads a picked local file (`fileUri`) and resolves its upload token,
122
+ * with when it expires. Absent: such files go up when the message is sent
123
+ * instead.
124
+ */
125
+ onUploadAttachment?: (draft: DraftAttachment, signal?: AbortSignal) => Promise<UploadedFile>;
101
126
  /** Rejects when the send fails, so the composer can keep its attachments. */
102
127
  onSendMessage: (
103
128
  body: string,
104
129
  attachments?: OutgoingAttachment[],
105
130
  action?: AgentUiAction
106
131
  ) => Promise<void>;
132
+ /** Re-sends a failed bubble; rejects when it fails again. Absent: no retry. */
133
+ onRetryMessage?: (messageId: string) => Promise<void>;
107
134
  onIdentifyVisitor?: (data: { email?: string; name?: string; phone?: string }) => Promise<void>;
108
135
  /** Answers a rating card; rejects with the server error (409 locked, 410 expired). */
109
136
  onRateConversation?: (
@@ -113,6 +140,8 @@ export interface ChatViewProps {
113
140
  ) => Promise<ConversationRatingResult>;
114
141
  /** The widget's default language — rating reasons fall back to it. */
115
142
  defaultLocale?: string;
143
+ /** A message's photos share one album (default true; `boot({ photoAlbums })`). */
144
+ photoAlbums?: boolean;
116
145
  onLoadMore: () => void;
117
146
  onTyping: (isTyping: boolean) => void;
118
147
  onBack: () => void;
@@ -119,6 +119,7 @@ export function ConversationsList({
119
119
  timeLabels={labels.time}
120
120
  unreadCount={unreadByConversation[item.id] ?? 0}
121
121
  unreadLabel={labels.unread}
122
+ lastMessageLabels={labels.lastMessage}
122
123
  onPress={() => onSelect(item.id)}
123
124
  />
124
125
  )}
@@ -1,6 +1,7 @@
1
1
  /** Props and label bundle for the Messages space. */
2
2
 
3
3
  import type { Conversation } from '../../../types';
4
+ import type { LastMessageLabels } from '../../components/ConversationRow';
4
5
  import type { RelativeTimeLabels } from '../../utils/conversations';
5
6
 
6
7
  export interface ConversationsListLabels {
@@ -15,6 +16,7 @@ export interface ConversationsListLabels {
15
16
  time: RelativeTimeLabels;
16
17
  /** Template with a `{count}` token. */
17
18
  unread: string;
19
+ lastMessage: LastMessageLabels;
18
20
  }
19
21
 
20
22
  export interface ConversationsListProps {
@@ -3,23 +3,23 @@
3
3
  * the sheet so the component and the styles can never disagree about them.
4
4
  */
5
5
 
6
- import { I18nManager, StyleSheet } from 'react-native';
6
+ import { StyleSheet } from 'react-native';
7
7
 
8
- import { rowDividerInset } from '../../components/ConversationRow';
9
8
  import { fontSize, palette, radius, shadows, spacing } from '../../styles/theme';
10
9
  import { START_ALIGN } from '../../utils/rtl';
11
10
 
12
11
  /**
13
12
  * Header geometry in dp, measured off the web widget so the two surfaces line
14
- * up: a tall header with the greeting pinned low, a start card that overhangs
13
+ * up: a tall header with the greeting pinned low, a first card that overhangs
15
14
  * the seam by a fixed amount rather than half its height, and a fade that is a
16
15
  * straight white ramp over the bottom of the header, starting just under the
17
16
  * heading.
18
17
  */
19
18
  export const HEADER_MIN_HEIGHT = 228;
20
- /** Between the greeting and whatever comes next: the seam, or the start card. */
19
+ /** Between the greeting and whatever comes next: the seam, or the first card. */
21
20
  export const HEADER_BOTTOM_PADDING = 36;
22
- export const START_CARD_LIFT = 28;
21
+ /** How far the first card (recent message, else the start card) rides up over the seam. */
22
+ export const LEAD_CARD_LIFT = 28;
23
23
  export const START_CARD_MIN_HEIGHT = 76;
24
24
  export const HEADER_FADE_HEIGHT = 90;
25
25
  export const CLOSE_BUTTON_SIZE = 28;
@@ -38,7 +38,7 @@ export const styles = StyleSheet.create({
38
38
  minHeight: HEADER_MIN_HEIGHT,
39
39
  paddingHorizontal: spacing.xl,
40
40
  paddingTop: spacing.xl,
41
- // When the start card is shown the component grows this to clear the card.
41
+ // When a card overhangs the seam the component grows this to clear it.
42
42
  paddingBottom: HEADER_BOTTOM_PADDING,
43
43
  overflow: 'hidden',
44
44
  },
@@ -82,7 +82,7 @@ export const styles = StyleSheet.create({
82
82
  lineHeight: fontSize.body * 1.4,
83
83
  },
84
84
 
85
- // Meets the header on a straight seam. No top padding here: the start card
85
+ // Meets the header on a straight seam. No top padding here: the first card
86
86
  // is pulled up past this edge, and the rest of the content takes its spacing
87
87
  // from `bodyContent`.
88
88
  body: {
@@ -115,12 +115,36 @@ export const styles = StyleSheet.create({
115
115
  color: palette.warningText,
116
116
  },
117
117
 
118
- startCardSlot: {
119
- marginTop: -START_CARD_LIFT,
118
+ leadCards: {
119
+ marginTop: -LEAD_CARD_LIFT,
120
+ gap: spacing.md,
121
+ },
122
+ // White like the row inside it, so a press is the only thing that tints it,
123
+ // with the start card's border and shadow so the two read as a stack. No
124
+ // `overflow: hidden`: it would clip the shadow on iOS, and the row never
125
+ // reaches the rounded corners anyway.
126
+ recentCard: {
127
+ paddingTop: spacing.lg,
128
+ paddingBottom: spacing.sm,
129
+ borderRadius: radius.lg,
130
+ borderWidth: StyleSheet.hairlineWidth,
131
+ borderColor: palette.border,
132
+ backgroundColor: palette.white,
133
+ ...shadows.card,
120
134
  },
121
- // Neutral and opaque, like the web card: it spans two backgrounds, and a
122
- // translucent or brand-tinted fill would let the header bleed through its
123
- // top or stain the seam. Shadowed because without it the half over the
135
+ // Inset like the start card's content, so the title, the avatar and the
136
+ // start card's icon share one left edge.
137
+ recentTitle: {
138
+ textAlign: START_ALIGN,
139
+ paddingHorizontal: spacing.xl,
140
+ marginBottom: spacing.xs,
141
+ fontSize: fontSize.title,
142
+ fontWeight: '600',
143
+ color: palette.ink,
144
+ },
145
+ // Neutral and opaque, like the web card: as the first card it spans two
146
+ // backgrounds, and a translucent or brand-tinted fill would let the header
147
+ // bleed through its top or stain the seam. Shadowed because without it the half over the
124
148
  // header reads as a flat cut-out.
125
149
  startCard: {
126
150
  flexDirection: 'row',
@@ -162,39 +186,6 @@ export const styles = StyleSheet.create({
162
186
  marginTop: 2,
163
187
  },
164
188
 
165
- recentHeader: {
166
- flexDirection: 'row',
167
- alignItems: 'center',
168
- justifyContent: 'space-between',
169
- minHeight: 28,
170
- marginBottom: spacing.sm,
171
- },
172
- recentTitle: {
173
- textAlign: START_ALIGN,
174
- fontSize: fontSize.caption,
175
- fontWeight: '700',
176
- color: palette.textMuted,
177
- letterSpacing: I18nManager.isRTL ? 0 : 0.6,
178
- textTransform: 'uppercase',
179
- },
180
- viewAllButton: {
181
- minHeight: 32,
182
- paddingHorizontal: spacing.xs,
183
- justifyContent: 'center',
184
- },
185
- viewAllLabel: {
186
- textAlign: START_ALIGN,
187
- fontSize: fontSize.meta,
188
- fontWeight: '600',
189
- },
190
- // Border rather than a shadow: `overflow: hidden` keeps the rows' ripple
191
- // inside the rounded corners, and would clip a shadow on iOS anyway.
192
- recentCard: {
193
- overflow: 'hidden',
194
- },
195
- recentDivider: {
196
- marginStart: rowDividerInset(spacing.lg),
197
- },
198
189
  // Absorbs the slack so the status strip stays pinned to the bottom, and
199
190
  // centers the empty hint when there is nothing else to show.
200
191
  spacer: {
@@ -1,19 +1,21 @@
1
1
  /**
2
- * Home space — branded greeting header, the "start a conversation" card, a
3
- * preview of recent threads and a team/availability strip.
2
+ * Home space — branded greeting header, the newest conversation in a "Recent
3
+ * message" card, the "start a conversation" card under it and a
4
+ * team/availability strip.
4
5
  * Port of `client/src/widget/components/HomeView.tsx`.
5
6
  *
6
7
  * The header meets the white body on a straight seam, the same as the web
7
8
  * widget. Whether that seam is a hard edge or the background washing out into
8
- * white is the dashboard's `homeBackgroundFade` toggle, and the start card sits
9
- * astride it either way: top over the brand background, bottom over white.
9
+ * white is the dashboard's `homeBackgroundFade` toggle, and the first card (the
10
+ * recent message, or the start card when there is none) sits astride it either
11
+ * way: top over the brand background, bottom over white.
10
12
  *
11
13
  * Everything on this screen comes from the widget config or the conversations
12
14
  * the visitor already has; nothing here assumes a field the backend does not
13
15
  * send today.
14
16
  */
15
17
 
16
- import { Fragment, useEffect, useRef, useState, type ReactNode } from 'react';
18
+ import { useEffect, useRef, useState, type ReactNode } from 'react';
17
19
  import {
18
20
  Animated,
19
21
  Easing,
@@ -47,9 +49,9 @@ import {
47
49
  HEADER_BOTTOM_PADDING,
48
50
  HEADER_FADE_HEIGHT,
49
51
  HEADER_MIN_HEIGHT,
52
+ LEAD_CARD_LIFT,
50
53
  LOGO_HEIGHT,
51
54
  LOGO_MAX_WIDTH,
52
- START_CARD_LIFT,
53
55
  styles,
54
56
  } from './HomeView.styles';
55
57
  import type { HomeViewProps } from './HomeView.types';
@@ -74,7 +76,7 @@ export function HomeView({
74
76
  color,
75
77
  visitorName,
76
78
  conversationCount,
77
- recentConversations,
79
+ recentConversation,
78
80
  unreadByConversation,
79
81
  teamAgents,
80
82
  isOnline,
@@ -86,7 +88,6 @@ export function HomeView({
86
88
  labels,
87
89
  onClose,
88
90
  onStartConversation,
89
- onViewConversations,
90
91
  onOpenConversation,
91
92
  }: HomeViewProps) {
92
93
  const heading = personalizeGreeting(config?.welcomeHeading, visitorName, 'Hi there');
@@ -111,14 +112,14 @@ export function HomeView({
111
112
  // colour over the bottom of the header, so the start card lands on near-white.
112
113
  const fade = config?.homeBackgroundFade ? <FadeOverlay height={HEADER_FADE_HEIGHT} /> : null;
113
114
 
114
- const showRecent = showPreviousConversations && recentConversations.length > 0;
115
- const showViewAll = conversationCount > recentConversations.length;
115
+ const recent = showPreviousConversations ? recentConversation : undefined;
116
+ const hasLeadCards = !!recent || allowNewConversations;
116
117
  const showEmptyHint =
117
118
  showPreviousConversations && conversationCount === 0 && allowNewConversations;
118
119
  // One agent already has their face in the row above; repeating it reads as a bug.
119
120
  const showAvatarStack = teamAgents.length >= 2;
120
121
 
121
- // The start card is pulled up over the seam by a fixed amount, so the header
122
+ // The first card is pulled up over the seam by a fixed amount, so the header
122
123
  // pads its bottom by that same amount and the greeting never slides under it.
123
124
  // The header reaches up under the status bar (no white strip above it), so
124
125
  // it grows by that inset and keeps its content where it was.
@@ -128,7 +129,7 @@ export function HomeView({
128
129
  topInset > 0
129
130
  ? { paddingTop: spacing.xl + topInset, minHeight: HEADER_MIN_HEIGHT + topInset }
130
131
  : null,
131
- allowNewConversations ? { paddingBottom: HEADER_BOTTOM_PADDING + START_CARD_LIFT } : null,
132
+ hasLeadCards ? { paddingBottom: HEADER_BOTTOM_PADDING + LEAD_CARD_LIFT } : null,
132
133
  ];
133
134
 
134
135
  const headerContent = (
@@ -186,30 +187,53 @@ export function HomeView({
186
187
  )}
187
188
 
188
189
  <View style={styles.body}>
189
- {allowNewConversations ? (
190
- <View style={styles.startCardSlot}>
191
- <FadeSlideIn delay={40}>
192
- <Pressable
193
- onPress={onStartConversation}
194
- accessibilityRole="button"
195
- android_ripple={{ color: palette.borderSoft }}
196
- style={({ pressed }) => [styles.startCard, pressed && styles.startCardPressed]}>
197
- <View style={[styles.startIcon, { backgroundColor: color }]}>
198
- <ChatIcon size={18} color={startIconColor} />
190
+ {hasLeadCards ? (
191
+ <View style={styles.leadCards}>
192
+ {recent ? (
193
+ <FadeSlideIn delay={40}>
194
+ <View style={styles.recentCard}>
195
+ <Text style={styles.recentTitle} accessibilityRole="header">
196
+ {labels.recentTitle}
197
+ </Text>
198
+ <ConversationRow
199
+ variant="card"
200
+ conversation={recent}
201
+ color={color}
202
+ fallbackName={labels.team}
203
+ timeLabels={labels.time}
204
+ unreadCount={unreadByConversation[recent.id] ?? 0}
205
+ unreadLabel={labels.unread}
206
+ lastMessageLabels={labels.lastMessage}
207
+ horizontalPadding={spacing.xl}
208
+ onPress={() => onOpenConversation(recent.id)}
209
+ />
199
210
  </View>
200
- <View style={styles.startCopy}>
201
- <Text style={styles.startTitle}>{startConversationLabel}</Text>
202
- <Text style={styles.startSubtitle}>{replyTimeLabel}</Text>
203
- </View>
204
- <ArrowRightIcon size={18} color={color} style={flipForRTL()} />
205
- </Pressable>
206
- </FadeSlideIn>
211
+ </FadeSlideIn>
212
+ ) : null}
213
+ {allowNewConversations ? (
214
+ <FadeSlideIn delay={80}>
215
+ <Pressable
216
+ onPress={onStartConversation}
217
+ accessibilityRole="button"
218
+ android_ripple={{ color: palette.borderSoft }}
219
+ style={({ pressed }) => [styles.startCard, pressed && styles.startCardPressed]}>
220
+ <View style={[styles.startIcon, { backgroundColor: color }]}>
221
+ <ChatIcon size={18} color={startIconColor} />
222
+ </View>
223
+ <View style={styles.startCopy}>
224
+ <Text style={styles.startTitle}>{startConversationLabel}</Text>
225
+ <Text style={styles.startSubtitle}>{replyTimeLabel}</Text>
226
+ </View>
227
+ <ArrowRightIcon size={18} color={color} style={flipForRTL()} />
228
+ </Pressable>
229
+ </FadeSlideIn>
230
+ ) : null}
207
231
  </View>
208
232
  ) : null}
209
233
 
210
234
  <View style={styles.bodyContent}>
211
235
  {offlineMessage ? (
212
- <FadeSlideIn delay={70}>
236
+ <FadeSlideIn delay={110}>
213
237
  <View style={styles.offlineNotice}>
214
238
  <AlertIcon size={18} />
215
239
  <Text style={styles.offlineText}>{offlineMessage}</Text>
@@ -217,46 +241,6 @@ export function HomeView({
217
241
  </FadeSlideIn>
218
242
  ) : null}
219
243
 
220
- {showRecent ? (
221
- <FadeSlideIn delay={140}>
222
- <View style={styles.recentHeader}>
223
- <Text style={styles.recentTitle}>{labels.recentTitle}</Text>
224
- {showViewAll ? (
225
- <Pressable
226
- onPress={onViewConversations}
227
- accessibilityRole="button"
228
- accessibilityLabel={labels.viewPrevious}
229
- hitSlop={10}
230
- style={({ pressed }) => [
231
- styles.viewAllButton,
232
- pressed && globalStyles.pressed,
233
- ]}>
234
- <Text style={[styles.viewAllLabel, { color }]}>{labels.viewAll}</Text>
235
- </Pressable>
236
- ) : null}
237
- </View>
238
- <View style={[globalStyles.card, styles.recentCard]}>
239
- {recentConversations.map((conversation, index) => (
240
- <Fragment key={conversation.id}>
241
- {index > 0 ? (
242
- <View style={[globalStyles.divider, styles.recentDivider]} />
243
- ) : null}
244
- <ConversationRow
245
- conversation={conversation}
246
- color={color}
247
- fallbackName={labels.team}
248
- timeLabels={labels.time}
249
- unreadCount={unreadByConversation[conversation.id] ?? 0}
250
- unreadLabel={labels.unread}
251
- horizontalPadding={spacing.lg}
252
- onPress={() => onOpenConversation(conversation.id)}
253
- />
254
- </Fragment>
255
- ))}
256
- </View>
257
- </FadeSlideIn>
258
- ) : null}
259
-
260
244
  <View style={styles.spacer}>
261
245
  {showEmptyHint ? (
262
246
  <FadeSlideIn delay={140}>
@@ -1,13 +1,12 @@
1
1
  /** Props and label bundle for the Home space. */
2
2
 
3
3
  import type { Conversation, WidgetConfig } from '../../../types';
4
+ import type { LastMessageLabels } from '../../components/ConversationRow';
4
5
  import type { RelativeTimeLabels, TeamAgent } from '../../utils/conversations';
5
6
 
6
7
  export interface HomeViewLabels {
7
8
  close: string;
8
- /** Accessibility label for the "view all" control. */
9
- viewPrevious: string;
10
- viewAll: string;
9
+ /** Heading inside the "Recent message" card. */
11
10
  recentTitle: string;
12
11
  noConversations: string;
13
12
  statusOnline: string;
@@ -17,6 +16,7 @@ export interface HomeViewLabels {
17
16
  time: RelativeTimeLabels;
18
17
  /** Template with a `{count}` token. */
19
18
  unread: string;
19
+ lastMessage: LastMessageLabels;
20
20
  }
21
21
 
22
22
  export interface HomeViewProps {
@@ -24,8 +24,8 @@ export interface HomeViewProps {
24
24
  color: string;
25
25
  visitorName?: string;
26
26
  conversationCount: number;
27
- /** Already sorted newest-first and capped by the provider. */
28
- recentConversations: Conversation[];
27
+ /** The newest conversation, picked by the provider; none before the first one. */
28
+ recentConversation?: Conversation;
29
29
  unreadByConversation: Record<string, number>;
30
30
  teamAgents: TeamAgent[];
31
31
  isOnline: boolean;
@@ -37,6 +37,5 @@ export interface HomeViewProps {
37
37
  labels: HomeViewLabels;
38
38
  onClose: () => void;
39
39
  onStartConversation: () => void;
40
- onViewConversations: () => void;
41
40
  onOpenConversation: (conversationId: string) => void;
42
41
  }
@@ -68,6 +68,8 @@ export interface WidgetTheme {
68
68
  allowNewConversations: boolean;
69
69
  showPreviousConversations: boolean;
70
70
  attachmentsEnabled: boolean;
71
+ /** The server's upload cap; null when it only takes files inline in the message. */
72
+ maxAttachmentBytes: number | null;
71
73
  preChatEnabled: boolean;
72
74
  }
73
75
 
@@ -94,6 +96,10 @@ export function buildTheme(config: WidgetConfig | null): WidgetTheme {
94
96
  allowNewConversations: config?.allowNewConversations ?? true,
95
97
  showPreviousConversations: config?.showPreviousConversations ?? true,
96
98
  attachmentsEnabled: config?.attachmentsEnabled ?? true,
99
+ maxAttachmentBytes:
100
+ typeof config?.maxAttachmentBytes === 'number' && config.maxAttachmentBytes > 0
101
+ ? config.maxAttachmentBytes
102
+ : null,
97
103
  preChatEnabled: config?.preChatEnabled ?? false,
98
104
  };
99
105
  }
@@ -1,11 +1,12 @@
1
1
  /**
2
2
  * Conversation selectors and formatting shared by the Home and Messages
3
- * spaces, so the two can never disagree about ordering or wording.
3
+ * spaces (and the store and chat thread, for message helpers), so they can
4
+ * never disagree about ordering or wording.
4
5
  * Pure and free of React so they stay trivial to test.
5
6
  */
6
7
 
7
8
  import { formatLabel } from '../../i18n';
8
- import type { Conversation } from '../../types';
9
+ import type { Conversation, Message } from '../../types';
9
10
 
10
11
  export interface TeamAgent {
11
12
  name: string | null;
@@ -120,3 +121,16 @@ export function formatDayLabel(
120
121
  return date.toDateString();
121
122
  }
122
123
  }
124
+
125
+ /** Optimistic visitor bubbles the server hasn't acknowledged (pending/failed). */
126
+ export function isLocalMessage(message: Message): boolean {
127
+ return message.id.startsWith('temp-');
128
+ }
129
+
130
+ /**
131
+ * The visitor's own bubble that never reached the server. A `failed` status
132
+ * the server sets on any other message isn't something this device can re-send.
133
+ */
134
+ export function canRetryMessage(message: Message): boolean {
135
+ return message.status === 'failed' && message.direction === 'inbound' && isLocalMessage(message);
136
+ }
@@ -42,6 +42,32 @@ export function stripHtml(html: string): string {
42
42
  .trim();
43
43
  }
44
44
 
45
+ /**
46
+ * Agent reply HTML → the Markdown subset `Markdown` draws: paragraphs, line
47
+ * breaks, lists, bold, italic, inline code and links. Other tags keep their text.
48
+ */
49
+ export function htmlToMarkdown(html: string): string {
50
+ if (!html) return '';
51
+ return decodeEntities(
52
+ html
53
+ .replace(/<br\s*\/?>/gi, '\n')
54
+ .replace(/<ol\b[^>]*>([\s\S]*?)<\/ol>/gi, (_list, items: string) => {
55
+ let number = 0;
56
+ return `\n\n${items.replace(/<li\b[^>]*>/gi, () => `\n${++number}. `)}\n\n`;
57
+ })
58
+ .replace(/<li\b[^>]*>/gi, '\n- ')
59
+ .replace(/<\/(p|div|h[1-6]|blockquote|ul|tr)>/gi, '\n\n')
60
+ .replace(/<(strong|b)\b[^>]*>([\s\S]+?)<\/\1>/gi, '**$2**')
61
+ .replace(/<(em|i)\b[^>]*>([\s\S]+?)<\/\1>/gi, '*$2*')
62
+ .replace(/<code\b[^>]*>([\s\S]+?)<\/code>/gi, '`$1`')
63
+ .replace(/<a\b[^>]*?\bhref=(["'])(.*?)\1[^>]*>([\s\S]*?)<\/a>/gi, '[$3]($2)')
64
+ .replace(/<[^>]+>/g, '')
65
+ )
66
+ .replace(/[ \t]+\n/g, '\n')
67
+ .replace(/\n{3,}/g, '\n\n')
68
+ .trim();
69
+ }
70
+
45
71
  /** Single-line flattening used for campaign cards and list snippets. */
46
72
  export function htmlToText(html: string): string {
47
73
  if (!html) return '';
@@ -0,0 +1,108 @@
1
+ /**
2
+ * Lets images load a few at a time, highest priority first. The chat runs its
3
+ * large images through it: Android holds a whole download in a memory pool
4
+ * capped at three quarters of the app's heap (192 MB on a 256 MB phone), so
5
+ * several 30–50 MB photos at once overflow it and every one of them fails.
6
+ *
7
+ * No `react-native` import on purpose: it stays testable in plain Node.
8
+ */
9
+ export class ImageLoadQueue {
10
+ // Key → priority, for both: an image paused off screen waits again at its own.
11
+ private readonly waiting = new Map<string, number>();
12
+ private readonly loading = new Map<string, number>();
13
+ private readonly done = new Set<string>();
14
+ /** The images on screen; null until the list says, so all of them count. */
15
+ private onScreen: ReadonlySet<string> | null = null;
16
+ private readonly listeners = new Set<() => void>();
17
+ private scheduled = false;
18
+
19
+ constructor(private readonly concurrency: number) {}
20
+
21
+ /** Queues a mounted image; the returned cleanup gives up its place. */
22
+ add(key: string, priority: number): () => void {
23
+ if (!this.done.has(key) && !this.loading.has(key)) {
24
+ this.waiting.set(key, Number.isFinite(priority) ? priority : 0);
25
+ this.schedule();
26
+ }
27
+ return () => this.remove(key);
28
+ }
29
+
30
+ /** Loaded or failed: it keeps showing, and the next image may start. */
31
+ finish(key: string): void {
32
+ this.waiting.delete(key);
33
+ this.done.add(key);
34
+ if (this.loading.delete(key)) this.advance();
35
+ }
36
+
37
+ canLoad = (key: string): boolean => this.done.has(key) || this.loading.has(key);
38
+
39
+ subscribe = (listener: () => void): (() => void) => {
40
+ this.listeners.add(listener);
41
+ return () => {
42
+ this.listeners.delete(listener);
43
+ };
44
+ };
45
+
46
+ /**
47
+ * The images now on screen. One that scrolls off before it has loaded
48
+ * gives up its place and waits, so it can't hold up the ones in view:
49
+ * Android detaches a row scrolled out of view, and a detached image never
50
+ * finishes loading. Only images on screen are started.
51
+ */
52
+ setOnScreen(keys: Iterable<string>): void {
53
+ this.onScreen = new Set(keys);
54
+ let paused = false;
55
+ this.loading.forEach((priority, key) => {
56
+ if (this.onScreen!.has(key)) return;
57
+ this.loading.delete(key);
58
+ this.waiting.set(key, priority);
59
+ paused = true;
60
+ });
61
+ if (!this.advance() && paused) this.notify();
62
+ }
63
+
64
+ /** Scrolled out of the list before it loaded: it queues again if it comes back. */
65
+ private remove(key: string): void {
66
+ this.waiting.delete(key);
67
+ if (this.loading.delete(key)) this.advance();
68
+ }
69
+
70
+ /**
71
+ * Hands out places once the render that mounted an image is done, so all
72
+ * the images mounted together are queued first, whatever order they
73
+ * mounted in.
74
+ */
75
+ private schedule(): void {
76
+ if (this.scheduled) return;
77
+ this.scheduled = true;
78
+ Promise.resolve().then(() => {
79
+ this.scheduled = false;
80
+ this.advance();
81
+ });
82
+ }
83
+
84
+ /** Starts what fits; true when anything started (listeners were told). */
85
+ private advance(): boolean {
86
+ let started = false;
87
+ while (this.loading.size < this.concurrency) {
88
+ let next: string | null = null;
89
+ let best = -Infinity;
90
+ this.waiting.forEach((priority, key) => {
91
+ if (priority > best && (!this.onScreen || this.onScreen.has(key))) {
92
+ best = priority;
93
+ next = key;
94
+ }
95
+ });
96
+ if (next === null) break;
97
+ this.waiting.delete(next);
98
+ this.loading.set(next, best);
99
+ started = true;
100
+ }
101
+ if (started) this.notify();
102
+ return started;
103
+ }
104
+
105
+ private notify(): void {
106
+ this.listeners.forEach((listener) => listener());
107
+ }
108
+ }