@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.
- package/CHANGELOG.md +179 -0
- package/README.md +72 -16
- package/lib/commonjs/api/client.js +113 -0
- package/lib/commonjs/api/client.js.map +1 -1
- package/lib/commonjs/attachments/file-size.js +52 -0
- package/lib/commonjs/attachments/file-size.js.map +1 -0
- package/lib/commonjs/attachments/local-previews.js +40 -0
- package/lib/commonjs/attachments/local-previews.js.map +1 -0
- package/lib/commonjs/attachments/pickers.js +76 -28
- package/lib/commonjs/attachments/pickers.js.map +1 -1
- package/lib/commonjs/i18n.js +24 -3
- package/lib/commonjs/i18n.js.map +1 -1
- package/lib/commonjs/locales.js +13 -3
- package/lib/commonjs/locales.js.map +1 -1
- package/lib/commonjs/state/widget-store.js +486 -63
- package/lib/commonjs/state/widget-store.js.map +1 -1
- package/lib/commonjs/storage.js +3 -1
- package/lib/commonjs/storage.js.map +1 -1
- package/lib/commonjs/types.js.map +1 -1
- package/lib/commonjs/ui/WidgetProvider.js +40 -16
- package/lib/commonjs/ui/WidgetProvider.js.map +1 -1
- package/lib/commonjs/ui/components/AttachmentChips.js +109 -40
- package/lib/commonjs/ui/components/AttachmentChips.js.map +1 -1
- package/lib/commonjs/ui/components/ConversationRow.js +65 -10
- package/lib/commonjs/ui/components/ConversationRow.js.map +1 -1
- package/lib/commonjs/ui/components/ImageViewer.js +231 -25
- package/lib/commonjs/ui/components/ImageViewer.js.map +1 -1
- package/lib/commonjs/ui/components/RatingCard.js +5 -2
- package/lib/commonjs/ui/components/RatingCard.js.map +1 -1
- package/lib/commonjs/ui/components/ZoomableImage.js +58 -10
- package/lib/commonjs/ui/components/ZoomableImage.js.map +1 -1
- package/lib/commonjs/ui/components/icons.js +22 -16
- package/lib/commonjs/ui/components/icons.js.map +1 -1
- package/lib/commonjs/ui/hooks/use-retained-state.js +39 -0
- package/lib/commonjs/ui/hooks/use-retained-state.js.map +1 -0
- package/lib/commonjs/ui/screens/chat/ChatView.js +666 -171
- package/lib/commonjs/ui/screens/chat/ChatView.js.map +1 -1
- package/lib/commonjs/ui/screens/chat/ChatView.styles.js +150 -3
- package/lib/commonjs/ui/screens/chat/ChatView.styles.js.map +1 -1
- package/lib/commonjs/ui/screens/conversations/ConversationsList.js +1 -0
- package/lib/commonjs/ui/screens/conversations/ConversationsList.js.map +1 -1
- package/lib/commonjs/ui/screens/home/HomeView.js +38 -55
- package/lib/commonjs/ui/screens/home/HomeView.js.map +1 -1
- package/lib/commonjs/ui/screens/home/HomeView.styles.js +36 -45
- package/lib/commonjs/ui/screens/home/HomeView.styles.js.map +1 -1
- package/lib/commonjs/ui/styles/theme.js +1 -0
- package/lib/commonjs/ui/styles/theme.js.map +1 -1
- package/lib/commonjs/ui/utils/conversations.js +17 -1
- package/lib/commonjs/ui/utils/conversations.js.map +1 -1
- package/lib/commonjs/ui/utils/html.js +13 -0
- package/lib/commonjs/ui/utils/html.js.map +1 -1
- package/lib/commonjs/ui/utils/image-load-queue.js +114 -0
- package/lib/commonjs/ui/utils/image-load-queue.js.map +1 -0
- package/lib/commonjs/ui/utils/inline-attachments.js +88 -0
- package/lib/commonjs/ui/utils/inline-attachments.js.map +1 -0
- package/lib/module/api/client.js +113 -0
- package/lib/module/api/client.js.map +1 -1
- package/lib/module/attachments/file-size.js +47 -0
- package/lib/module/attachments/file-size.js.map +1 -0
- package/lib/module/attachments/local-previews.js +33 -0
- package/lib/module/attachments/local-previews.js.map +1 -0
- package/lib/module/attachments/pickers.js +74 -27
- package/lib/module/attachments/pickers.js.map +1 -1
- package/lib/module/i18n.js +24 -3
- package/lib/module/i18n.js.map +1 -1
- package/lib/module/locales.js +13 -3
- package/lib/module/locales.js.map +1 -1
- package/lib/module/state/widget-store.js +488 -65
- package/lib/module/state/widget-store.js.map +1 -1
- package/lib/module/storage.js +2 -0
- package/lib/module/storage.js.map +1 -1
- package/lib/module/types.js.map +1 -1
- package/lib/module/ui/WidgetProvider.js +40 -16
- package/lib/module/ui/WidgetProvider.js.map +1 -1
- package/lib/module/ui/components/AttachmentChips.js +111 -42
- package/lib/module/ui/components/AttachmentChips.js.map +1 -1
- package/lib/module/ui/components/ConversationRow.js +65 -10
- package/lib/module/ui/components/ConversationRow.js.map +1 -1
- package/lib/module/ui/components/ImageViewer.js +233 -27
- package/lib/module/ui/components/ImageViewer.js.map +1 -1
- package/lib/module/ui/components/RatingCard.js +5 -2
- package/lib/module/ui/components/RatingCard.js.map +1 -1
- package/lib/module/ui/components/ZoomableImage.js +58 -10
- package/lib/module/ui/components/ZoomableImage.js.map +1 -1
- package/lib/module/ui/components/icons.js +21 -15
- package/lib/module/ui/components/icons.js.map +1 -1
- package/lib/module/ui/hooks/use-retained-state.js +34 -0
- package/lib/module/ui/hooks/use-retained-state.js.map +1 -0
- package/lib/module/ui/screens/chat/ChatView.js +672 -177
- package/lib/module/ui/screens/chat/ChatView.js.map +1 -1
- package/lib/module/ui/screens/chat/ChatView.styles.js +152 -4
- package/lib/module/ui/screens/chat/ChatView.styles.js.map +1 -1
- package/lib/module/ui/screens/conversations/ConversationsList.js +1 -0
- package/lib/module/ui/screens/conversations/ConversationsList.js.map +1 -1
- package/lib/module/ui/screens/home/HomeView.js +40 -57
- package/lib/module/ui/screens/home/HomeView.js.map +1 -1
- package/lib/module/ui/screens/home/HomeView.styles.js +36 -45
- package/lib/module/ui/screens/home/HomeView.styles.js.map +1 -1
- package/lib/module/ui/styles/theme.js +1 -0
- package/lib/module/ui/styles/theme.js.map +1 -1
- package/lib/module/ui/utils/conversations.js +15 -1
- package/lib/module/ui/utils/conversations.js.map +1 -1
- package/lib/module/ui/utils/html.js +12 -0
- package/lib/module/ui/utils/html.js.map +1 -1
- package/lib/module/ui/utils/image-load-queue.js +109 -0
- package/lib/module/ui/utils/image-load-queue.js.map +1 -0
- package/lib/module/ui/utils/inline-attachments.js +85 -0
- package/lib/module/ui/utils/inline-attachments.js.map +1 -0
- package/lib/typescript/commonjs/api/client.d.ts +35 -1
- package/lib/typescript/commonjs/api/client.d.ts.map +1 -1
- package/lib/typescript/commonjs/attachments/file-size.d.ts +15 -0
- package/lib/typescript/commonjs/attachments/file-size.d.ts.map +1 -0
- package/lib/typescript/commonjs/attachments/local-previews.d.ts +14 -0
- package/lib/typescript/commonjs/attachments/local-previews.d.ts.map +1 -0
- package/lib/typescript/commonjs/attachments/pickers.d.ts +35 -10
- package/lib/typescript/commonjs/attachments/pickers.d.ts.map +1 -1
- package/lib/typescript/commonjs/i18n.d.ts +13 -3
- package/lib/typescript/commonjs/i18n.d.ts.map +1 -1
- package/lib/typescript/commonjs/locales.d.ts.map +1 -1
- package/lib/typescript/commonjs/state/widget-store.d.ts +67 -4
- package/lib/typescript/commonjs/state/widget-store.d.ts.map +1 -1
- package/lib/typescript/commonjs/storage.d.ts +2 -0
- package/lib/typescript/commonjs/storage.d.ts.map +1 -1
- package/lib/typescript/commonjs/types.d.ts +58 -0
- package/lib/typescript/commonjs/types.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/WidgetProvider.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/components/AttachmentChips.d.ts +13 -3
- package/lib/typescript/commonjs/ui/components/AttachmentChips.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/components/ConversationRow.d.ts +15 -1
- package/lib/typescript/commonjs/ui/components/ConversationRow.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/components/ImageViewer.d.ts +26 -6
- package/lib/typescript/commonjs/ui/components/ImageViewer.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/components/RatingCard.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/components/ZoomableImage.d.ts +10 -1
- package/lib/typescript/commonjs/ui/components/ZoomableImage.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/components/icons.d.ts +2 -1
- package/lib/typescript/commonjs/ui/components/icons.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/hooks/use-retained-state.d.ts +11 -0
- package/lib/typescript/commonjs/ui/hooks/use-retained-state.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/screens/chat/ChatView.d.ts +4 -4
- package/lib/typescript/commonjs/ui/screens/chat/ChatView.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/screens/chat/ChatView.styles.d.ts +154 -2
- package/lib/typescript/commonjs/ui/screens/chat/ChatView.styles.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/screens/chat/ChatView.types.d.ts +30 -1
- package/lib/typescript/commonjs/ui/screens/chat/ChatView.types.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/screens/conversations/ConversationsList.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/screens/conversations/ConversationsList.types.d.ts +2 -0
- package/lib/typescript/commonjs/ui/screens/conversations/ConversationsList.types.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/screens/home/HomeView.d.ts +7 -5
- package/lib/typescript/commonjs/ui/screens/home/HomeView.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/screens/home/HomeView.styles.d.ts +30 -35
- package/lib/typescript/commonjs/ui/screens/home/HomeView.styles.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/screens/home/HomeView.types.d.ts +5 -6
- package/lib/typescript/commonjs/ui/screens/home/HomeView.types.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/styles/theme.d.ts +2 -0
- package/lib/typescript/commonjs/ui/styles/theme.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/utils/conversations.d.ts +10 -2
- package/lib/typescript/commonjs/ui/utils/conversations.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/utils/html.d.ts +5 -0
- package/lib/typescript/commonjs/ui/utils/html.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/utils/image-load-queue.d.ts +44 -0
- package/lib/typescript/commonjs/ui/utils/image-load-queue.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/utils/inline-attachments.d.ts +29 -0
- package/lib/typescript/commonjs/ui/utils/inline-attachments.d.ts.map +1 -0
- package/lib/typescript/module/api/client.d.ts +35 -1
- package/lib/typescript/module/api/client.d.ts.map +1 -1
- package/lib/typescript/module/attachments/file-size.d.ts +15 -0
- package/lib/typescript/module/attachments/file-size.d.ts.map +1 -0
- package/lib/typescript/module/attachments/local-previews.d.ts +14 -0
- package/lib/typescript/module/attachments/local-previews.d.ts.map +1 -0
- package/lib/typescript/module/attachments/pickers.d.ts +35 -10
- package/lib/typescript/module/attachments/pickers.d.ts.map +1 -1
- package/lib/typescript/module/i18n.d.ts +13 -3
- package/lib/typescript/module/i18n.d.ts.map +1 -1
- package/lib/typescript/module/locales.d.ts.map +1 -1
- package/lib/typescript/module/state/widget-store.d.ts +67 -4
- package/lib/typescript/module/state/widget-store.d.ts.map +1 -1
- package/lib/typescript/module/storage.d.ts +2 -0
- package/lib/typescript/module/storage.d.ts.map +1 -1
- package/lib/typescript/module/types.d.ts +58 -0
- package/lib/typescript/module/types.d.ts.map +1 -1
- package/lib/typescript/module/ui/WidgetProvider.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/AttachmentChips.d.ts +13 -3
- package/lib/typescript/module/ui/components/AttachmentChips.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/ConversationRow.d.ts +15 -1
- package/lib/typescript/module/ui/components/ConversationRow.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/ImageViewer.d.ts +26 -6
- package/lib/typescript/module/ui/components/ImageViewer.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/RatingCard.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/ZoomableImage.d.ts +10 -1
- package/lib/typescript/module/ui/components/ZoomableImage.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/icons.d.ts +2 -1
- package/lib/typescript/module/ui/components/icons.d.ts.map +1 -1
- package/lib/typescript/module/ui/hooks/use-retained-state.d.ts +11 -0
- package/lib/typescript/module/ui/hooks/use-retained-state.d.ts.map +1 -0
- package/lib/typescript/module/ui/screens/chat/ChatView.d.ts +4 -4
- package/lib/typescript/module/ui/screens/chat/ChatView.d.ts.map +1 -1
- package/lib/typescript/module/ui/screens/chat/ChatView.styles.d.ts +154 -2
- package/lib/typescript/module/ui/screens/chat/ChatView.styles.d.ts.map +1 -1
- package/lib/typescript/module/ui/screens/chat/ChatView.types.d.ts +30 -1
- package/lib/typescript/module/ui/screens/chat/ChatView.types.d.ts.map +1 -1
- package/lib/typescript/module/ui/screens/conversations/ConversationsList.d.ts.map +1 -1
- package/lib/typescript/module/ui/screens/conversations/ConversationsList.types.d.ts +2 -0
- package/lib/typescript/module/ui/screens/conversations/ConversationsList.types.d.ts.map +1 -1
- package/lib/typescript/module/ui/screens/home/HomeView.d.ts +7 -5
- package/lib/typescript/module/ui/screens/home/HomeView.d.ts.map +1 -1
- package/lib/typescript/module/ui/screens/home/HomeView.styles.d.ts +30 -35
- package/lib/typescript/module/ui/screens/home/HomeView.styles.d.ts.map +1 -1
- package/lib/typescript/module/ui/screens/home/HomeView.types.d.ts +5 -6
- package/lib/typescript/module/ui/screens/home/HomeView.types.d.ts.map +1 -1
- package/lib/typescript/module/ui/styles/theme.d.ts +2 -0
- package/lib/typescript/module/ui/styles/theme.d.ts.map +1 -1
- package/lib/typescript/module/ui/utils/conversations.d.ts +10 -2
- package/lib/typescript/module/ui/utils/conversations.d.ts.map +1 -1
- package/lib/typescript/module/ui/utils/html.d.ts +5 -0
- package/lib/typescript/module/ui/utils/html.d.ts.map +1 -1
- package/lib/typescript/module/ui/utils/image-load-queue.d.ts +44 -0
- package/lib/typescript/module/ui/utils/image-load-queue.d.ts.map +1 -0
- package/lib/typescript/module/ui/utils/inline-attachments.d.ts +29 -0
- package/lib/typescript/module/ui/utils/inline-attachments.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/api/client.ts +148 -2
- package/src/attachments/file-size.ts +42 -0
- package/src/attachments/local-previews.ts +32 -0
- package/src/attachments/pickers.ts +90 -30
- package/src/i18n.ts +24 -3
- package/src/locales.ts +13 -3
- package/src/state/widget-store.ts +519 -70
- package/src/storage.ts +2 -0
- package/src/types.ts +58 -0
- package/src/ui/WidgetProvider.tsx +50 -12
- package/src/ui/components/AttachmentChips.tsx +100 -29
- package/src/ui/components/ConversationRow.tsx +90 -9
- package/src/ui/components/ImageViewer.tsx +250 -28
- package/src/ui/components/RatingCard.tsx +5 -2
- package/src/ui/components/ZoomableImage.tsx +58 -5
- package/src/ui/components/icons.tsx +10 -12
- package/src/ui/hooks/use-retained-state.ts +35 -0
- package/src/ui/screens/chat/ChatView.styles.ts +151 -3
- package/src/ui/screens/chat/ChatView.tsx +760 -213
- package/src/ui/screens/chat/ChatView.types.ts +30 -1
- package/src/ui/screens/conversations/ConversationsList.tsx +1 -0
- package/src/ui/screens/conversations/ConversationsList.types.ts +2 -0
- package/src/ui/screens/home/HomeView.styles.ts +36 -45
- package/src/ui/screens/home/HomeView.tsx +54 -70
- package/src/ui/screens/home/HomeView.types.ts +5 -6
- package/src/ui/styles/theme.ts +6 -0
- package/src/ui/utils/conversations.ts +16 -2
- package/src/ui/utils/html.ts +26 -0
- package/src/ui/utils/image-load-queue.ts +108 -0
- package/src/ui/utils/inline-attachments.ts +71 -0
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Home space — branded greeting header, the
|
|
3
|
-
*
|
|
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
|
|
9
|
-
*
|
|
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
|
|
@@ -20,5 +22,5 @@ import type { HomeViewProps } from './HomeView.types';
|
|
|
20
22
|
* derive something legible from the background instead.
|
|
21
23
|
*/
|
|
22
24
|
export declare function resolveHeaderTextColor(config: WidgetConfig | null, fallbackColor: string): string;
|
|
23
|
-
export declare function HomeView({ config, color, visitorName, conversationCount,
|
|
25
|
+
export declare function HomeView({ config, color, visitorName, conversationCount, recentConversation, unreadByConversation, teamAgents, isOnline, offlineMessage, startConversationLabel, replyTimeLabel, allowNewConversations, showPreviousConversations, labels, onClose, onStartConversation, onOpenConversation, }: HomeViewProps): import("react").JSX.Element;
|
|
24
26
|
//# sourceMappingURL=HomeView.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HomeView.d.ts","sourceRoot":"","sources":["../../../../../../src/ui/screens/home/HomeView.tsx"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"HomeView.d.ts","sourceRoot":"","sources":["../../../../../../src/ui/screens/home/HomeView.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAcH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AA2BnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEtD;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI,EAAE,aAAa,EAAE,MAAM,GAAG,MAAM,CAQjG;AAED,wBAAgB,QAAQ,CAAC,EACvB,MAAM,EACN,KAAK,EACL,WAAW,EACX,iBAAiB,EACjB,kBAAkB,EAClB,oBAAoB,EACpB,UAAU,EACV,QAAQ,EACR,cAAc,EACd,sBAAsB,EACtB,cAAc,EACd,qBAAqB,EACrB,yBAAyB,EACzB,MAAM,EACN,OAAO,EACP,mBAAmB,EACnB,kBAAkB,GACnB,EAAE,aAAa,+BAkMf"}
|
|
@@ -4,15 +4,16 @@
|
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
6
6
|
* Header geometry in dp, measured off the web widget so the two surfaces line
|
|
7
|
-
* up: a tall header with the greeting pinned low, a
|
|
7
|
+
* up: a tall header with the greeting pinned low, a first card that overhangs
|
|
8
8
|
* the seam by a fixed amount rather than half its height, and a fade that is a
|
|
9
9
|
* straight white ramp over the bottom of the header, starting just under the
|
|
10
10
|
* heading.
|
|
11
11
|
*/
|
|
12
12
|
export declare const HEADER_MIN_HEIGHT = 228;
|
|
13
|
-
/** Between the greeting and whatever comes next: the seam, or the
|
|
13
|
+
/** Between the greeting and whatever comes next: the seam, or the first card. */
|
|
14
14
|
export declare const HEADER_BOTTOM_PADDING = 36;
|
|
15
|
-
|
|
15
|
+
/** How far the first card (recent message, else the start card) rides up over the seam. */
|
|
16
|
+
export declare const LEAD_CARD_LIFT = 28;
|
|
16
17
|
export declare const START_CARD_MIN_HEIGHT = 76;
|
|
17
18
|
export declare const HEADER_FADE_HEIGHT = 90;
|
|
18
19
|
export declare const CLOSE_BUTTON_SIZE = 28;
|
|
@@ -98,8 +99,33 @@ export declare const styles: {
|
|
|
98
99
|
lineHeight: number;
|
|
99
100
|
color: "#92400e";
|
|
100
101
|
};
|
|
101
|
-
|
|
102
|
+
leadCards: {
|
|
102
103
|
marginTop: number;
|
|
104
|
+
gap: 12;
|
|
105
|
+
};
|
|
106
|
+
recentCard: {
|
|
107
|
+
shadowColor: "#0f172a";
|
|
108
|
+
shadowOffset: {
|
|
109
|
+
readonly width: 0;
|
|
110
|
+
readonly height: 4;
|
|
111
|
+
};
|
|
112
|
+
shadowOpacity: 0.08;
|
|
113
|
+
shadowRadius: 14;
|
|
114
|
+
elevation: 3;
|
|
115
|
+
paddingTop: 16;
|
|
116
|
+
paddingBottom: 8;
|
|
117
|
+
borderRadius: 12;
|
|
118
|
+
borderWidth: number;
|
|
119
|
+
borderColor: "#e5e7eb";
|
|
120
|
+
backgroundColor: "#ffffff";
|
|
121
|
+
};
|
|
122
|
+
recentTitle: {
|
|
123
|
+
textAlign: "left" | "right";
|
|
124
|
+
paddingHorizontal: 20;
|
|
125
|
+
marginBottom: 4;
|
|
126
|
+
fontSize: 17;
|
|
127
|
+
fontWeight: "600";
|
|
128
|
+
color: "#1a1a1a";
|
|
103
129
|
};
|
|
104
130
|
startCard: {
|
|
105
131
|
shadowColor: "#0f172a";
|
|
@@ -147,37 +173,6 @@ export declare const styles: {
|
|
|
147
173
|
color: "#9ca3af";
|
|
148
174
|
marginTop: number;
|
|
149
175
|
};
|
|
150
|
-
recentHeader: {
|
|
151
|
-
flexDirection: "row";
|
|
152
|
-
alignItems: "center";
|
|
153
|
-
justifyContent: "space-between";
|
|
154
|
-
minHeight: number;
|
|
155
|
-
marginBottom: 8;
|
|
156
|
-
};
|
|
157
|
-
recentTitle: {
|
|
158
|
-
textAlign: "left" | "right";
|
|
159
|
-
fontSize: 12;
|
|
160
|
-
fontWeight: "700";
|
|
161
|
-
color: "#6b7280";
|
|
162
|
-
letterSpacing: number;
|
|
163
|
-
textTransform: "uppercase";
|
|
164
|
-
};
|
|
165
|
-
viewAllButton: {
|
|
166
|
-
minHeight: number;
|
|
167
|
-
paddingHorizontal: 4;
|
|
168
|
-
justifyContent: "center";
|
|
169
|
-
};
|
|
170
|
-
viewAllLabel: {
|
|
171
|
-
textAlign: "left" | "right";
|
|
172
|
-
fontSize: 13;
|
|
173
|
-
fontWeight: "600";
|
|
174
|
-
};
|
|
175
|
-
recentCard: {
|
|
176
|
-
overflow: "hidden";
|
|
177
|
-
};
|
|
178
|
-
recentDivider: {
|
|
179
|
-
marginStart: number;
|
|
180
|
-
};
|
|
181
176
|
spacer: {
|
|
182
177
|
flex: number;
|
|
183
178
|
minHeight: 16;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HomeView.styles.d.ts","sourceRoot":"","sources":["../../../../../../src/ui/screens/home/HomeView.styles.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"HomeView.styles.d.ts","sourceRoot":"","sources":["../../../../../../src/ui/screens/home/HomeView.styles.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,MAAM,CAAC;AACrC,iFAAiF;AACjF,eAAO,MAAM,qBAAqB,KAAK,CAAC;AACxC,2FAA2F;AAC3F,eAAO,MAAM,cAAc,KAAK,CAAC;AACjC,eAAO,MAAM,qBAAqB,KAAK,CAAC;AACxC,eAAO,MAAM,kBAAkB,KAAK,CAAC;AACrC,eAAO,MAAM,iBAAiB,KAAK,CAAC;AACpC,qFAAqF;AACrF,eAAO,MAAM,WAAW,KAAK,CAAC;AAC9B,eAAO,MAAM,cAAc,MAAM,CAAC;AAClC,eAAO,MAAM,eAAe,KAAK,CAAC;AAElC,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgNjB,CAAC"}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
/** Props and label bundle for the Home space. */
|
|
2
2
|
import type { Conversation, WidgetConfig } from '../../../types';
|
|
3
|
+
import type { LastMessageLabels } from '../../components/ConversationRow';
|
|
3
4
|
import type { RelativeTimeLabels, TeamAgent } from '../../utils/conversations';
|
|
4
5
|
export interface HomeViewLabels {
|
|
5
6
|
close: string;
|
|
6
|
-
/**
|
|
7
|
-
viewPrevious: string;
|
|
8
|
-
viewAll: string;
|
|
7
|
+
/** Heading inside the "Recent message" card. */
|
|
9
8
|
recentTitle: string;
|
|
10
9
|
noConversations: string;
|
|
11
10
|
statusOnline: string;
|
|
@@ -15,14 +14,15 @@ export interface HomeViewLabels {
|
|
|
15
14
|
time: RelativeTimeLabels;
|
|
16
15
|
/** Template with a `{count}` token. */
|
|
17
16
|
unread: string;
|
|
17
|
+
lastMessage: LastMessageLabels;
|
|
18
18
|
}
|
|
19
19
|
export interface HomeViewProps {
|
|
20
20
|
config: WidgetConfig | null;
|
|
21
21
|
color: string;
|
|
22
22
|
visitorName?: string;
|
|
23
23
|
conversationCount: number;
|
|
24
|
-
/**
|
|
25
|
-
|
|
24
|
+
/** The newest conversation, picked by the provider; none before the first one. */
|
|
25
|
+
recentConversation?: Conversation;
|
|
26
26
|
unreadByConversation: Record<string, number>;
|
|
27
27
|
teamAgents: TeamAgent[];
|
|
28
28
|
isOnline: boolean;
|
|
@@ -34,7 +34,6 @@ export interface HomeViewProps {
|
|
|
34
34
|
labels: HomeViewLabels;
|
|
35
35
|
onClose: () => void;
|
|
36
36
|
onStartConversation: () => void;
|
|
37
|
-
onViewConversations: () => void;
|
|
38
37
|
onOpenConversation: (conversationId: string) => void;
|
|
39
38
|
}
|
|
40
39
|
//# sourceMappingURL=HomeView.types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HomeView.types.d.ts","sourceRoot":"","sources":["../../../../../../src/ui/screens/home/HomeView.types.ts"],"names":[],"mappings":"AAAA,iDAAiD;AAEjD,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACjE,OAAO,KAAK,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAE/E,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,
|
|
1
|
+
{"version":3,"file":"HomeView.types.d.ts","sourceRoot":"","sources":["../../../../../../src/ui/screens/home/HomeView.types.ts"],"names":[],"mappings":"AAAA,iDAAiD;AAEjD,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACjE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAC1E,OAAO,KAAK,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAE/E,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,gDAAgD;IAChD,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,gEAAgE;IAChE,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,kBAAkB,CAAC;IACzB,uCAAuC;IACvC,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,iBAAiB,CAAC;CAChC;AAED,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,YAAY,GAAG,IAAI,CAAC;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,kFAAkF;IAClF,kBAAkB,CAAC,EAAE,YAAY,CAAC;IAClC,oBAAoB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7C,UAAU,EAAE,SAAS,EAAE,CAAC;IACxB,QAAQ,EAAE,OAAO,CAAC;IAClB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,sBAAsB,EAAE,MAAM,CAAC;IAC/B,cAAc,EAAE,MAAM,CAAC;IACvB,qBAAqB,EAAE,OAAO,CAAC;IAC/B,yBAAyB,EAAE,OAAO,CAAC;IACnC,MAAM,EAAE,cAAc,CAAC;IACvB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,mBAAmB,EAAE,MAAM,IAAI,CAAC;IAChC,kBAAkB,EAAE,CAAC,cAAc,EAAE,MAAM,KAAK,IAAI,CAAC;CACtD"}
|
|
@@ -62,6 +62,8 @@ export interface WidgetTheme {
|
|
|
62
62
|
allowNewConversations: boolean;
|
|
63
63
|
showPreviousConversations: boolean;
|
|
64
64
|
attachmentsEnabled: boolean;
|
|
65
|
+
/** The server's upload cap; null when it only takes files inline in the message. */
|
|
66
|
+
maxAttachmentBytes: number | null;
|
|
65
67
|
preChatEnabled: boolean;
|
|
66
68
|
}
|
|
67
69
|
export declare const DEFAULT_PRIMARY_COLOR = "#0d9488";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../../../../src/ui/styles/theme.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;CAkBV,CAAC;AAEX,eAAO,MAAM,MAAM;;;;;;CAMT,CAAC;AAEX,eAAO,MAAM,OAAO;;;;;;;CAOV,CAAC;AAEX,iEAAiE;AACjE,eAAO,MAAM,QAAQ;;;;;;;;;CASX,CAAC;AAEX,MAAM,WAAW,WAAW;IAC1B,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;IAC3B,QAAQ,EAAE,OAAO,CAAC;IAClB,4EAA4E;IAC5E,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,sBAAsB,EAAE,MAAM,CAAC;IAC/B,cAAc,EAAE,MAAM,CAAC;IACvB,qBAAqB,EAAE,OAAO,CAAC;IAC/B,yBAAyB,EAAE,OAAO,CAAC;IACnC,kBAAkB,EAAE,OAAO,CAAC;IAC5B,cAAc,EAAE,OAAO,CAAC;CACzB;AAED,eAAO,MAAM,qBAAqB,YAAY,CAAC;AAE/C;;;;GAIG;AAGH,wBAAgB,UAAU,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI,GAAG,WAAW,
|
|
1
|
+
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../../../../src/ui/styles/theme.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;CAkBV,CAAC;AAEX,eAAO,MAAM,MAAM;;;;;;CAMT,CAAC;AAEX,eAAO,MAAM,OAAO;;;;;;;CAOV,CAAC;AAEX,iEAAiE;AACjE,eAAO,MAAM,QAAQ;;;;;;;;;CASX,CAAC;AAEX,MAAM,WAAW,WAAW;IAC1B,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;IAC3B,QAAQ,EAAE,OAAO,CAAC;IAClB,4EAA4E;IAC5E,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,sBAAsB,EAAE,MAAM,CAAC;IAC/B,cAAc,EAAE,MAAM,CAAC;IACvB,qBAAqB,EAAE,OAAO,CAAC;IAC/B,yBAAyB,EAAE,OAAO,CAAC;IACnC,kBAAkB,EAAE,OAAO,CAAC;IAC5B,oFAAoF;IACpF,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,cAAc,EAAE,OAAO,CAAC;CACzB;AAED,eAAO,MAAM,qBAAqB,YAAY,CAAC;AAE/C;;;;GAIG;AAGH,wBAAgB,UAAU,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI,GAAG,WAAW,CAoBnE;AAED,kFAAkF;AAClF,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAI9D;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAYvE;AAED,wFAAwF;AACxF,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAMtE;AAED,kEAAkE;AAClE,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAM/D;AAED,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;CAeV,CAAC"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Conversation selectors and formatting shared by the Home and Messages
|
|
3
|
-
* spaces
|
|
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
|
-
import type { Conversation } from '../../types';
|
|
7
|
+
import type { Conversation, Message } from '../../types';
|
|
7
8
|
export interface TeamAgent {
|
|
8
9
|
name: string | null;
|
|
9
10
|
avatar: string | null;
|
|
@@ -38,4 +39,11 @@ export declare function formatDayLabel(dateStr: string, locale: string, labels:
|
|
|
38
39
|
today: string;
|
|
39
40
|
yesterday: string;
|
|
40
41
|
}): string;
|
|
42
|
+
/** Optimistic visitor bubbles the server hasn't acknowledged (pending/failed). */
|
|
43
|
+
export declare function isLocalMessage(message: Message): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* The visitor's own bubble that never reached the server. A `failed` status
|
|
46
|
+
* the server sets on any other message isn't something this device can re-send.
|
|
47
|
+
*/
|
|
48
|
+
export declare function canRetryMessage(message: Message): boolean;
|
|
41
49
|
//# sourceMappingURL=conversations.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversations.d.ts","sourceRoot":"","sources":["../../../../../src/ui/utils/conversations.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"conversations.d.ts","sourceRoot":"","sources":["../../../../../src/ui/utils/conversations.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEzD,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB;AAOD;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,aAAa,EAAE,YAAY,EAAE,GAAG,YAAY,EAAE,CAE3E;AAED,wBAAgB,uBAAuB,CAAC,aAAa,EAAE,YAAY,EAAE,EAAE,KAAK,SAAI,GAAG,YAAY,EAAE,CAEhG;AAED,iFAAiF;AACjF,wBAAgB,cAAc,CAAC,aAAa,EAAE,YAAY,EAAE,EAAE,KAAK,SAAI,GAAG,SAAS,EAAE,CAepF;AAED,4EAA4E;AAC5E,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,kBAAkB,GAAG,MAAM,CActF;AAKD,wBAAgB,SAAS,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAEvD;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAQvE;AAED,yEAAyE;AACzE,wBAAgB,cAAc,CAC5B,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,MAAM,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GAC3C,MAAM,CAmBR;AAED,kFAAkF;AAClF,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAExD;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAEzD"}
|
|
@@ -6,6 +6,11 @@
|
|
|
6
6
|
export declare function decodeEntities(text: string): string;
|
|
7
7
|
/** Block-level tags become newlines so paragraphs survive the strip. */
|
|
8
8
|
export declare function stripHtml(html: string): string;
|
|
9
|
+
/**
|
|
10
|
+
* Agent reply HTML → the Markdown subset `Markdown` draws: paragraphs, line
|
|
11
|
+
* breaks, lists, bold, italic, inline code and links. Other tags keep their text.
|
|
12
|
+
*/
|
|
13
|
+
export declare function htmlToMarkdown(html: string): string;
|
|
9
14
|
/** Single-line flattening used for campaign cards and list snippets. */
|
|
10
15
|
export declare function htmlToText(html: string): string;
|
|
11
16
|
//# sourceMappingURL=html.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"html.d.ts","sourceRoot":"","sources":["../../../../../src/ui/utils/html.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAoBH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAInD;AAED,wEAAwE;AACxE,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAW9C;AAED,wEAAwE;AACxE,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAU/C"}
|
|
1
|
+
{"version":3,"file":"html.d.ts","sourceRoot":"","sources":["../../../../../src/ui/utils/html.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAoBH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAInD;AAED,wEAAwE;AACxE,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAW9C;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAoBnD;AAED,wEAAwE;AACxE,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAU/C"}
|
|
@@ -0,0 +1,44 @@
|
|
|
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 declare class ImageLoadQueue {
|
|
10
|
+
private readonly concurrency;
|
|
11
|
+
private readonly waiting;
|
|
12
|
+
private readonly loading;
|
|
13
|
+
private readonly done;
|
|
14
|
+
/** The images on screen; null until the list says, so all of them count. */
|
|
15
|
+
private onScreen;
|
|
16
|
+
private readonly listeners;
|
|
17
|
+
private scheduled;
|
|
18
|
+
constructor(concurrency: number);
|
|
19
|
+
/** Queues a mounted image; the returned cleanup gives up its place. */
|
|
20
|
+
add(key: string, priority: number): () => void;
|
|
21
|
+
/** Loaded or failed: it keeps showing, and the next image may start. */
|
|
22
|
+
finish(key: string): void;
|
|
23
|
+
canLoad: (key: string) => boolean;
|
|
24
|
+
subscribe: (listener: () => void) => (() => void);
|
|
25
|
+
/**
|
|
26
|
+
* The images now on screen. One that scrolls off before it has loaded
|
|
27
|
+
* gives up its place and waits, so it can't hold up the ones in view:
|
|
28
|
+
* Android detaches a row scrolled out of view, and a detached image never
|
|
29
|
+
* finishes loading. Only images on screen are started.
|
|
30
|
+
*/
|
|
31
|
+
setOnScreen(keys: Iterable<string>): void;
|
|
32
|
+
/** Scrolled out of the list before it loaded: it queues again if it comes back. */
|
|
33
|
+
private remove;
|
|
34
|
+
/**
|
|
35
|
+
* Hands out places once the render that mounted an image is done, so all
|
|
36
|
+
* the images mounted together are queued first, whatever order they
|
|
37
|
+
* mounted in.
|
|
38
|
+
*/
|
|
39
|
+
private schedule;
|
|
40
|
+
/** Starts what fits; true when anything started (listeners were told). */
|
|
41
|
+
private advance;
|
|
42
|
+
private notify;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=image-load-queue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image-load-queue.d.ts","sourceRoot":"","sources":["../../../../../src/ui/utils/image-load-queue.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,qBAAa,cAAc;IAUb,OAAO,CAAC,QAAQ,CAAC,WAAW;IARxC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA6B;IACrD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA6B;IACrD,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAqB;IAC1C,4EAA4E;IAC5E,OAAO,CAAC,QAAQ,CAAoC;IACpD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAyB;IACnD,OAAO,CAAC,SAAS,CAAS;gBAEG,WAAW,EAAE,MAAM;IAEhD,uEAAuE;IACvE,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,IAAI;IAQ9C,wEAAwE;IACxE,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAMzB,OAAO,GAAI,KAAK,MAAM,KAAG,OAAO,CAAgD;IAEhF,SAAS,GAAI,UAAU,MAAM,IAAI,KAAG,CAAC,MAAM,IAAI,CAAC,CAK9C;IAEF;;;;;OAKG;IACH,WAAW,CAAC,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,GAAG,IAAI;IAYzC,mFAAmF;IACnF,OAAO,CAAC,MAAM;IAKd;;;;OAIG;IACH,OAAO,CAAC,QAAQ;IAShB,0EAA0E;IAC1E,OAAO,CAAC,OAAO;IAoBf,OAAO,CAAC,MAAM;CAGf"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent replies with images between their paragraphs. Workstation marks such
|
|
3
|
+
* images `inline` among the message's attachments and keeps an `<img>` for
|
|
4
|
+
* each in the HTML body, where the teammate put it. Same split as the web
|
|
5
|
+
* Messenger, so both show the text and images in the order they were written.
|
|
6
|
+
*/
|
|
7
|
+
import type { WidgetAttachment } from '../../types';
|
|
8
|
+
/** Markdown for the bubble to draw, or one attachment. */
|
|
9
|
+
export type MessagePart = {
|
|
10
|
+
text: string;
|
|
11
|
+
} | {
|
|
12
|
+
attachment: WidgetAttachment;
|
|
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 declare function splitInlineAttachments(body: string | null | undefined, attachments: WidgetAttachment[] | null | undefined): {
|
|
26
|
+
parts: MessagePart[];
|
|
27
|
+
files: WidgetAttachment[];
|
|
28
|
+
} | null;
|
|
29
|
+
//# sourceMappingURL=inline-attachments.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inline-attachments.d.ts","sourceRoot":"","sources":["../../../../../src/ui/utils/inline-attachments.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAGpD,0DAA0D;AAC1D,MAAM,MAAM,WAAW,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,UAAU,EAAE,gBAAgB,CAAA;CAAE,CAAC;AAE9E;;;;;;;;;;GAUG;AACH,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAC/B,WAAW,EAAE,gBAAgB,EAAE,GAAG,IAAI,GAAG,SAAS,GACjD;IAAE,KAAK,EAAE,WAAW,EAAE,CAAC;IAAC,KAAK,EAAE,gBAAgB,EAAE,CAAA;CAAE,GAAG,IAAI,CA8B5D"}
|
package/package.json
CHANGED
package/src/api/client.ts
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* The token itself lives in `SecureStorage`.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
+
import { measureFileSize } from '../attachments/file-size';
|
|
11
12
|
import { SecureStorage, TOKEN_KEY } from '../storage';
|
|
12
13
|
import type {
|
|
13
14
|
AgentUiAction,
|
|
@@ -84,6 +85,60 @@ interface RequestOptions {
|
|
|
84
85
|
authToken?: string | null;
|
|
85
86
|
}
|
|
86
87
|
|
|
88
|
+
/**
|
|
89
|
+
* Sends a local file as the request body straight from disk and resolves the
|
|
90
|
+
* HTTP status. React Native streams a `{ uri }` body natively; `fetch` would
|
|
91
|
+
* stringify it, so this goes through XMLHttpRequest.
|
|
92
|
+
*/
|
|
93
|
+
function sendFileFromDisk(
|
|
94
|
+
url: string,
|
|
95
|
+
method: string,
|
|
96
|
+
headers: Record<string, string>,
|
|
97
|
+
file: { uri: string; contentType: string },
|
|
98
|
+
signal?: AbortSignal
|
|
99
|
+
): Promise<number> {
|
|
100
|
+
return new Promise((resolve, reject) => {
|
|
101
|
+
const xhr = new XMLHttpRequest();
|
|
102
|
+
const cancel = () => xhr.abort();
|
|
103
|
+
const settle = (finish: () => void) => {
|
|
104
|
+
signal?.removeEventListener('abort', cancel);
|
|
105
|
+
finish();
|
|
106
|
+
};
|
|
107
|
+
xhr.onload = () => settle(() => resolve(xhr.status));
|
|
108
|
+
xhr.onerror = () => settle(() => reject(new RepzoWidgetError('Network request failed', 0, 'network')));
|
|
109
|
+
xhr.ontimeout = xhr.onerror;
|
|
110
|
+
xhr.onabort = () => settle(() => reject(new RepzoWidgetError('Upload cancelled', 0, 'network')));
|
|
111
|
+
xhr.open(method, url);
|
|
112
|
+
Object.entries(headers).forEach(([name, value]) => xhr.setRequestHeader(name, value));
|
|
113
|
+
// Android refuses a `{ uri }` body without one.
|
|
114
|
+
if (!Object.keys(headers).some((name) => name.toLowerCase() === 'content-type')) {
|
|
115
|
+
xhr.setRequestHeader('Content-Type', file.contentType);
|
|
116
|
+
}
|
|
117
|
+
signal?.addEventListener('abort', cancel);
|
|
118
|
+
xhr.send({ uri: file.uri } as unknown as XMLHttpRequestBodyInit);
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* How long Workstation keeps an upload for a message to name, when its answer
|
|
124
|
+
* has no usable `expiresAt` (deployments without it, or a phone clock that
|
|
125
|
+
* reads it as already past).
|
|
126
|
+
*/
|
|
127
|
+
const UPLOAD_LIFETIME_MS = 60 * 60 * 1000;
|
|
128
|
+
|
|
129
|
+
/** A file in storage, waiting for the message that names it. */
|
|
130
|
+
export interface UploadedFile {
|
|
131
|
+
uploadToken: string;
|
|
132
|
+
/** When Workstation stops taking `uploadToken`, on this phone's clock (ms). */
|
|
133
|
+
expiresAt: number;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function uploadExpiry(expiresAt: unknown, now: number): number {
|
|
137
|
+
const at =
|
|
138
|
+
typeof expiresAt === 'string' ? Date.parse(expiresAt) : typeof expiresAt === 'number' ? expiresAt : NaN;
|
|
139
|
+
return at > now ? at : now + UPLOAD_LIFETIME_MS;
|
|
140
|
+
}
|
|
141
|
+
|
|
87
142
|
export class WidgetApiClient {
|
|
88
143
|
private baseUrl = '';
|
|
89
144
|
|
|
@@ -337,15 +392,106 @@ export class WidgetApiClient {
|
|
|
337
392
|
conversationId?: string;
|
|
338
393
|
forceNewConversation?: boolean;
|
|
339
394
|
body: string;
|
|
340
|
-
/**
|
|
341
|
-
|
|
395
|
+
/**
|
|
396
|
+
* Max 5. Either inline (`url`, a base64 data URL, each <= 1.5 MB decoded)
|
|
397
|
+
* or uploaded first (`uploadToken`, from uploadAttachment).
|
|
398
|
+
*/
|
|
399
|
+
attachments?: Array<
|
|
400
|
+
| { name: string; url: string; contentType: string; size: number }
|
|
401
|
+
| { name: string; uploadToken: string; contentType: string; size: number }
|
|
402
|
+
>;
|
|
342
403
|
visitorName?: string;
|
|
343
404
|
visitorEmail?: string;
|
|
344
405
|
agentUiAction?: AgentUiAction;
|
|
406
|
+
/**
|
|
407
|
+
* Same on every retry of a message. Newer Workstation deployments store it
|
|
408
|
+
* once and echo it on the stored row; older ones don't read it.
|
|
409
|
+
*/
|
|
410
|
+
clientMessageId?: string;
|
|
345
411
|
}): Promise<{ messageId: string; conversationId: string; isNewConversation: boolean }> {
|
|
346
412
|
return this.request('/api/widget/messages', { method: 'POST', body: data });
|
|
347
413
|
}
|
|
348
414
|
|
|
415
|
+
/**
|
|
416
|
+
* Puts a local file in storage ahead of the message, which then names it by
|
|
417
|
+
* the returned upload token. The target is presigned storage, or a path on
|
|
418
|
+
* the server where its storage can't presign. The upload URL is signed for
|
|
419
|
+
* exactly the size asked for: a `file://` file whose size `expo-file-system`
|
|
420
|
+
* can read streams from disk, anything else is read as a native blob and
|
|
421
|
+
* measured. `signal` cancels the transfer (the visitor removed the file, or
|
|
422
|
+
* left the conversation). Resolves the token and when it expires.
|
|
423
|
+
*/
|
|
424
|
+
async uploadAttachment(
|
|
425
|
+
file: {
|
|
426
|
+
uri: string;
|
|
427
|
+
name: string;
|
|
428
|
+
contentType: string;
|
|
429
|
+
size: number;
|
|
430
|
+
},
|
|
431
|
+
signal?: AbortSignal
|
|
432
|
+
): Promise<UploadedFile> {
|
|
433
|
+
// A file removed early is never read, nor given a slot in storage.
|
|
434
|
+
const stopIfCancelled = () => {
|
|
435
|
+
if (signal?.aborted) throw new RepzoWidgetError('Upload cancelled', 0, 'network');
|
|
436
|
+
};
|
|
437
|
+
stopIfCancelled();
|
|
438
|
+
// Streaming matters on Android: React Native also copies a blob it reads
|
|
439
|
+
// into a Base64 string for its network inspector, so a file past ~30 MB
|
|
440
|
+
// runs the app out of memory. Only file:// gives an exact Content-Length.
|
|
441
|
+
const streamedSize = urlScheme(file.uri) === 'file:' ? await measureFileSize(file.uri) : null;
|
|
442
|
+
let blob: Blob | null = null;
|
|
443
|
+
if (streamedSize === null) {
|
|
444
|
+
try {
|
|
445
|
+
blob = await (await fetch(file.uri, { signal })).blob();
|
|
446
|
+
} catch (error) {
|
|
447
|
+
throw new RepzoWidgetError(
|
|
448
|
+
error instanceof Error ? error.message : 'Could not read the file',
|
|
449
|
+
0,
|
|
450
|
+
'network'
|
|
451
|
+
);
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
stopIfCancelled();
|
|
455
|
+
const target = await this.request<{
|
|
456
|
+
uploadUrl: string;
|
|
457
|
+
method?: string;
|
|
458
|
+
headers?: Record<string, string>;
|
|
459
|
+
uploadToken: string;
|
|
460
|
+
expiresAt?: string | number;
|
|
461
|
+
}>('/api/widget/uploads', {
|
|
462
|
+
method: 'POST',
|
|
463
|
+
body: {
|
|
464
|
+
fileName: file.name,
|
|
465
|
+
contentType: file.contentType,
|
|
466
|
+
size: streamedSize ?? (blob?.size || file.size),
|
|
467
|
+
},
|
|
468
|
+
});
|
|
469
|
+
// Counted from when the token was issued, not from when the file is up.
|
|
470
|
+
const expiresAt = uploadExpiry(target.expiresAt, Date.now());
|
|
471
|
+
const uploadUrl = this.resolveUrl(target.uploadUrl);
|
|
472
|
+
if (!uploadUrl) throw new RepzoWidgetError('Invalid upload target', 0, 'http');
|
|
473
|
+
stopIfCancelled();
|
|
474
|
+
|
|
475
|
+
const method = target.method ?? 'PUT';
|
|
476
|
+
const headers = target.headers ?? { 'Content-Type': file.contentType };
|
|
477
|
+
let status: number;
|
|
478
|
+
if (blob) {
|
|
479
|
+
try {
|
|
480
|
+
status = (await fetch(uploadUrl, { method, headers, body: blob, signal })).status;
|
|
481
|
+
} catch (error) {
|
|
482
|
+
throw new RepzoWidgetError(
|
|
483
|
+
error instanceof Error ? error.message : 'Upload failed',
|
|
484
|
+
0,
|
|
485
|
+
'network'
|
|
486
|
+
);
|
|
487
|
+
}
|
|
488
|
+
} else {
|
|
489
|
+
status = await sendFileFromDisk(uploadUrl, method, headers, file, signal);
|
|
490
|
+
}
|
|
491
|
+
if (status < 200 || status >= 300) throw new RepzoWidgetError('Upload failed', status, 'http');
|
|
492
|
+
return { uploadToken: target.uploadToken, expiresAt };
|
|
493
|
+
}
|
|
494
|
+
|
|
349
495
|
listConversations(): Promise<{ data: Conversation[] }> {
|
|
350
496
|
return this.request('/api/widget/conversations');
|
|
351
497
|
}
|
|
@@ -0,0 +1,42 @@
|
|
|
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
|
+
|
|
9
|
+
let fileSystem: any = null;
|
|
10
|
+
try {
|
|
11
|
+
fileSystem = require('expo-file-system') ?? null;
|
|
12
|
+
} catch {
|
|
13
|
+
fileSystem = null;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** A positive, finite byte count, or null. */
|
|
17
|
+
export function validSize(size: unknown): number | null {
|
|
18
|
+
return typeof size === 'number' && Number.isFinite(size) && size > 0 ? size : null;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* A local file's exact size in bytes, from its metadata without reading it.
|
|
23
|
+
* Null without `expo-file-system`, or when it can't tell.
|
|
24
|
+
*/
|
|
25
|
+
export async function measureFileSize(uri: string): Promise<number | null> {
|
|
26
|
+
if (typeof fileSystem?.File === 'function') {
|
|
27
|
+
try {
|
|
28
|
+
const size = validSize(new fileSystem.File(uri).size);
|
|
29
|
+
if (size !== null) return size;
|
|
30
|
+
} catch {
|
|
31
|
+
// Fall through to the next reader.
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
if (typeof fileSystem?.getInfoAsync === 'function') {
|
|
35
|
+
try {
|
|
36
|
+
return validSize((await fileSystem.getInfoAsync(uri, { size: true }))?.size);
|
|
37
|
+
} catch {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
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
|
+
|
|
9
|
+
const MAX_PREVIEWS = 50;
|
|
10
|
+
const previews = new Map<string, string>();
|
|
11
|
+
|
|
12
|
+
export function rememberLocalPreview(storedUrl: string, localUrl: string): void {
|
|
13
|
+
if (!storedUrl || !localUrl) return;
|
|
14
|
+
previews.delete(storedUrl);
|
|
15
|
+
previews.set(storedUrl, localUrl);
|
|
16
|
+
// Oldest first: a Map iterates in insertion order.
|
|
17
|
+
if (previews.size > MAX_PREVIEWS) previews.delete(previews.keys().next().value as string);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function localPreviewFor(storedUrl: string): string | null {
|
|
21
|
+
return (storedUrl && previews.get(storedUrl)) || null;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** One that failed to load (the OS cleared the picker's cache): every view moves to the stored copy. */
|
|
25
|
+
export function forgetLocalPreview(storedUrl: string): void {
|
|
26
|
+
previews.delete(storedUrl);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** Signing out forgets them: the next visitor on the phone doesn't inherit the paths. */
|
|
30
|
+
export function clearLocalPreviews(): void {
|
|
31
|
+
previews.clear();
|
|
32
|
+
}
|