@convai/web-sdk 1.9.2 → 2.0.0-beta.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 (79) hide show
  1. package/README.md +22 -11
  2. package/dist/core/types.d.ts +2 -2
  3. package/dist/react/hooks/index.d.ts +0 -2
  4. package/dist/react/hooks/index.js +0 -3
  5. package/dist/react/index.d.ts +0 -3
  6. package/dist/react/index.js +3 -10
  7. package/dist/vanilla/index.d.ts +6 -18
  8. package/dist/vanilla/index.js +7 -19
  9. package/dist/version.d.ts +1 -1
  10. package/dist/version.js +1 -1
  11. package/package.json +9 -8
  12. package/dist/react/components/ConvaiWidget.d.ts +0 -86
  13. package/dist/react/components/ConvaiWidget.js +0 -610
  14. package/dist/react/components/index.d.ts +0 -1
  15. package/dist/react/components/index.js +0 -2
  16. package/dist/react/components/rtc-widget/components/AudioSettingsPanel.d.ts +0 -9
  17. package/dist/react/components/rtc-widget/components/AudioSettingsPanel.js +0 -315
  18. package/dist/react/components/rtc-widget/components/AudioVisualizer.d.ts +0 -35
  19. package/dist/react/components/rtc-widget/components/AudioVisualizer.js +0 -285
  20. package/dist/react/components/rtc-widget/components/ConviMessage.d.ts +0 -12
  21. package/dist/react/components/rtc-widget/components/ConviMessage.js +0 -13
  22. package/dist/react/components/rtc-widget/components/FloatingVideo.d.ts +0 -8
  23. package/dist/react/components/rtc-widget/components/FloatingVideo.js +0 -120
  24. package/dist/react/components/rtc-widget/components/MarkdownRenderer.d.ts +0 -31
  25. package/dist/react/components/rtc-widget/components/MarkdownRenderer.js +0 -140
  26. package/dist/react/components/rtc-widget/components/MessageBubble.d.ts +0 -9
  27. package/dist/react/components/rtc-widget/components/MessageBubble.js +0 -22
  28. package/dist/react/components/rtc-widget/components/MessageList.d.ts +0 -13
  29. package/dist/react/components/rtc-widget/components/MessageList.js +0 -88
  30. package/dist/react/components/rtc-widget/components/SiteCard.d.ts +0 -14
  31. package/dist/react/components/rtc-widget/components/SiteCard.js +0 -34
  32. package/dist/react/components/rtc-widget/components/UserMessage.d.ts +0 -8
  33. package/dist/react/components/rtc-widget/components/UserMessage.js +0 -14
  34. package/dist/react/components/rtc-widget/components/conviComponents/ConviButton.d.ts +0 -5
  35. package/dist/react/components/rtc-widget/components/conviComponents/ConviButton.js +0 -14
  36. package/dist/react/components/rtc-widget/components/conviComponents/ConviFooter.d.ts +0 -24
  37. package/dist/react/components/rtc-widget/components/conviComponents/ConviFooter.js +0 -170
  38. package/dist/react/components/rtc-widget/components/conviComponents/ConviHeader.d.ts +0 -16
  39. package/dist/react/components/rtc-widget/components/conviComponents/ConviHeader.js +0 -64
  40. package/dist/react/components/rtc-widget/components/conviComponents/SettingsTray.d.ts +0 -11
  41. package/dist/react/components/rtc-widget/components/conviComponents/SettingsTray.js +0 -65
  42. package/dist/react/components/rtc-widget/components/conviComponents/VoiceModeOverlay.d.ts +0 -13
  43. package/dist/react/components/rtc-widget/components/conviComponents/VoiceModeOverlay.js +0 -298
  44. package/dist/react/components/rtc-widget/components/conviComponents/index.d.ts +0 -5
  45. package/dist/react/components/rtc-widget/components/conviComponents/index.js +0 -5
  46. package/dist/react/components/rtc-widget/components/index.d.ts +0 -8
  47. package/dist/react/components/rtc-widget/components/index.js +0 -14
  48. package/dist/react/components/rtc-widget/index.d.ts +0 -5
  49. package/dist/react/components/rtc-widget/index.js +0 -8
  50. package/dist/react/components/rtc-widget/styles/framerConfig.d.ts +0 -115
  51. package/dist/react/components/rtc-widget/styles/framerConfig.js +0 -72
  52. package/dist/react/components/rtc-widget/styles/icons.d.ts +0 -27
  53. package/dist/react/components/rtc-widget/styles/icons.js +0 -256
  54. package/dist/react/components/rtc-widget/styles/index.d.ts +0 -5
  55. package/dist/react/components/rtc-widget/styles/index.js +0 -8
  56. package/dist/react/components/rtc-widget/styles/styledComponents.d.ts +0 -89
  57. package/dist/react/components/rtc-widget/styles/styledComponents.js +0 -662
  58. package/dist/react/components/rtc-widget/styles/theme.d.ts +0 -187
  59. package/dist/react/components/rtc-widget/styles/theme.js +0 -289
  60. package/dist/react/components/rtc-widget/types/index.d.ts +0 -59
  61. package/dist/react/components/rtc-widget/types/index.js +0 -1
  62. package/dist/react/hooks/useCharacterInfo.d.ts +0 -18
  63. package/dist/react/hooks/useCharacterInfo.js +0 -65
  64. package/dist/react/hooks/useLocalCameraTrack.d.ts +0 -21
  65. package/dist/react/hooks/useLocalCameraTrack.js +0 -33
  66. package/dist/react/icons.d.ts +0 -37
  67. package/dist/react/icons.js +0 -53
  68. package/dist/utils/lightbox.d.ts +0 -15
  69. package/dist/utils/lightbox.js +0 -94
  70. package/dist/vanilla/ConvaiWidget.d.ts +0 -46
  71. package/dist/vanilla/ConvaiWidget.js +0 -2866
  72. package/dist/vanilla/WidgetEventSubscriptions.d.ts +0 -14
  73. package/dist/vanilla/WidgetEventSubscriptions.js +0 -36
  74. package/dist/vanilla/icons.d.ts +0 -34
  75. package/dist/vanilla/icons.js +0 -268
  76. package/dist/vanilla/styles.d.ts +0 -168
  77. package/dist/vanilla/styles.js +0 -407
  78. package/dist/vanilla/types.d.ts +0 -170
  79. package/dist/vanilla/types.js +0 -1
@@ -1,120 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useRef, useState } from "react";
3
- import { motion } from "framer-motion";
4
- import { VideoTrack, RoomContext, useRoomContext } from "@livekit/components-react";
5
- import { IoClose, IoVideocamOff, MdDragIndicator } from "../../../icons.js";
6
- import { aeroTheme } from "../styles/theme.js";
7
- import { iosTransitions } from "../styles/framerConfig.js";
8
- import { useLocalCameraTrack } from "../../../hooks/useLocalCameraTrack.js";
9
- /**
10
- * LocalVideoDisplay component for rendering local camera feed inside FloatingVideo.
11
- */
12
- const LocalVideoDisplay = ({ mirror = false }) => {
13
- const cameraTrackRef = useLocalCameraTrack();
14
- // Check if camera track is available (for local participant, check if track exists)
15
- if (!cameraTrackRef.publication?.track) {
16
- return (_jsxs("div", { style: {
17
- width: "100%",
18
- height: "100%",
19
- display: "flex",
20
- flexDirection: "column",
21
- alignItems: "center",
22
- justifyContent: "center",
23
- color: aeroTheme.colors.neutral[400],
24
- gap: "12px",
25
- background: "#000",
26
- }, children: [_jsx(IoVideocamOff, { size: 48 }), _jsx("span", { style: { fontSize: "14px", textAlign: "center" }, children: "Camera is off" })] }));
27
- }
28
- return (_jsx("div", { style: {
29
- width: "100%",
30
- height: "100%",
31
- position: "relative",
32
- }, children: _jsx("div", { style: {
33
- transform: mirror ? "scaleX(-1)" : "none",
34
- width: "100%",
35
- height: "100%",
36
- }, children: _jsx(VideoTrack, { trackRef: cameraTrackRef, style: {
37
- width: "100%",
38
- height: "100%",
39
- objectFit: "cover",
40
- } }) }) }));
41
- };
42
- export const FloatingVideo = ({ isVisible, onClose, mirror = true, }) => {
43
- const room = useRoomContext(); // Get room from parent RoomContext
44
- const [position, setPosition] = useState({ x: 20, y: 20 });
45
- const [isDragging, setIsDragging] = useState(false);
46
- const containerRef = useRef(null);
47
- const handleDragEnd = (event, info) => {
48
- setIsDragging(false);
49
- // Get window dimensions
50
- const windowWidth = window.innerWidth;
51
- const windowHeight = window.innerHeight;
52
- // Get container dimensions
53
- const containerWidth = containerRef.current?.offsetWidth || 320;
54
- const containerHeight = containerRef.current?.offsetHeight || 240;
55
- // Calculate new position with boundary constraints
56
- let newX = position.x + info.offset.x;
57
- let newY = position.y + info.offset.y;
58
- // Keep within bounds
59
- newX = Math.max(0, Math.min(newX, windowWidth - containerWidth));
60
- newY = Math.max(0, Math.min(newY, windowHeight - containerHeight));
61
- setPosition({ x: newX, y: newY });
62
- };
63
- if (!isVisible)
64
- return null;
65
- // Wrap in RoomContext.Provider to ensure room is available to child components
66
- return (_jsx(RoomContext.Provider, { value: room, children: _jsx(motion.div, { ref: containerRef, drag: true, dragMomentum: false, dragElastic: 0, onDragStart: () => setIsDragging(true), onDragEnd: handleDragEnd, initial: { opacity: 0, scale: 0.8 }, animate: { opacity: 1, scale: 1 }, exit: { opacity: 0, scale: 0.8 }, transition: iosTransitions.modalSlide, style: {
67
- position: "fixed",
68
- left: position.x,
69
- top: position.y,
70
- zIndex: 10000,
71
- width: "320px",
72
- borderRadius: aeroTheme.borderRadius.lg,
73
- overflow: "hidden",
74
- boxShadow: "0 8px 32px rgba(0, 0, 0, 0.3)",
75
- cursor: isDragging ? "grabbing" : "grab",
76
- }, children: _jsxs("div", { style: {
77
- background: "rgba(15, 23, 42, 0.95)",
78
- backdropFilter: "blur(20px)",
79
- border: `1px solid ${aeroTheme.colors.neutral[700]}`,
80
- borderRadius: aeroTheme.borderRadius.lg,
81
- overflow: "hidden",
82
- }, children: [_jsxs("div", { style: {
83
- display: "flex",
84
- alignItems: "center",
85
- justifyContent: "space-between",
86
- padding: "8px 12px",
87
- background: "rgba(0, 0, 0, 0.3)",
88
- borderBottom: `1px solid ${aeroTheme.colors.neutral[700]}`,
89
- }, children: [_jsxs("div", { style: {
90
- display: "flex",
91
- alignItems: "center",
92
- gap: "8px",
93
- color: aeroTheme.colors.neutral[300],
94
- fontSize: "12px",
95
- fontWeight: 500,
96
- }, children: [_jsx(MdDragIndicator, { size: 16 }), _jsx("span", { children: "Your Camera" })] }), _jsx(motion.button, { onPointerDown: (e) => e.stopPropagation(), onClick: (e) => {
97
- e.stopPropagation();
98
- onClose();
99
- }, whileHover: { scale: 1.1 }, whileTap: { scale: 0.9 }, style: {
100
- background: "transparent",
101
- border: "none",
102
- color: aeroTheme.colors.neutral[400],
103
- cursor: "pointer",
104
- display: "flex",
105
- alignItems: "center",
106
- justifyContent: "center",
107
- padding: "4px",
108
- }, "aria-label": "Close video", children: _jsx(IoClose, { size: 20 }) })] }), _jsx("div", { style: {
109
- position: "relative",
110
- width: "100%",
111
- paddingBottom: "75%", // 4:3 aspect ratio
112
- background: "#000",
113
- }, children: _jsx("div", { style: {
114
- position: "absolute",
115
- top: 0,
116
- left: 0,
117
- width: "100%",
118
- height: "100%",
119
- }, children: _jsx(LocalVideoDisplay, { mirror: mirror }) }) })] }) }) }));
120
- };
@@ -1,31 +0,0 @@
1
- import React from "react";
2
- import type { LinkPreviewResolver } from "../../../../utils/linkPreview.js";
3
- /**
4
- * The widget's bubble renderer. Everything visual comes from
5
- * utils/linkPresentation so this file and the vanilla widget cannot drift;
6
- * this file only maps tokenizer nodes onto JSX.
7
- *
8
- * `data-convai-part` mirrors the vanilla widget's `part` names. React renders
9
- * in light DOM where `part` means nothing, but the same names let tests and
10
- * host CSS target both renderers with one vocabulary.
11
- */
12
- interface MarkdownRendererProps {
13
- text: string;
14
- /**
15
- * Render cards and chips under links. Bot messages want them; the user's
16
- * own bubble does not — you already know what you typed, and a preview
17
- * there would let a URL a user pasted embed remote media into the
18
- * transcript. Links stay clickable either way.
19
- */
20
- media?: boolean;
21
- /** Test seam for mixed-content detection. Defaults to the page's protocol. */
22
- pageProtocol?: string;
23
- /**
24
- * Host-supplied Open Graph lookup. With it, a plain web link in a bot
25
- * bubble gets a site card once the lookup settles; without it, nothing
26
- * changes. See docs/convai_link_previews.md, "Site cards".
27
- */
28
- resolveLinkPreview?: LinkPreviewResolver;
29
- }
30
- export declare const MarkdownRenderer: React.FC<MarkdownRendererProps>;
31
- export {};
@@ -1,140 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- import React from "react";
3
- import { parseInlineMarkdown, compactUrl } from "../../../../utils/inlineMarkdown.js";
4
- import { linkKindForUrl, describeUrl, fileNameOf, documentBadge, contactLabel, hoverTitle, isMixedContent, glyph, presentationStyles as S, PREVIEW_TIMEOUT_MS, MAX_CARDS_PER_MESSAGE, } from "../../../../utils/linkPresentation.js";
5
- import { openLightbox } from "../../../../utils/lightbox.js";
6
- import { SiteCard } from "./SiteCard.js";
7
- import { injectKeyframes } from "../../../../vanilla/styles.js";
8
- const css = (...objs) => Object.assign({}, ...objs);
9
- const Glyph = ({ name, style }) => (_jsx("span", { style: css(S.contactGlyph, style ?? {}), dangerouslySetInnerHTML: { __html: glyph(name) } }));
10
- /** Inline styles cannot express :focus-visible, so the ring is toggled by hand. */
11
- const useFocusRing = () => {
12
- const [focused, setFocused] = React.useState(false);
13
- return {
14
- style: focused ? S.linkFocus : {},
15
- onFocus: (e) => setFocused(e.target.matches(":focus-visible")),
16
- onBlur: () => setFocused(false),
17
- };
18
- };
19
- const Anchor = ({ href, kind, label }) => {
20
- const ring = useFocusRing();
21
- // A bare URL is its own label and may be elided for display; the title
22
- // compares against what is actually shown so the full target is one hover away.
23
- const display = label === href ? compactUrl(label) : label;
24
- return (_jsxs("a", { href: href, target: "_blank", rel: "noopener noreferrer", title: hoverTitle(kind, href, display), "data-convai-part": "message-link", style: css(S.link, ring.style), onFocus: ring.onFocus, onBlur: ring.onBlur, children: [display, kind === "ftp" && (_jsx("span", { "data-convai-part": "message-link-badge", style: css(S.badge), children: "FTP" }))] }));
25
- };
26
- const ContactChip = ({ href, kind }) => {
27
- const ring = useFocusRing();
28
- return (_jsxs("a", { href: href, title: hoverTitle(kind, href, href), "data-convai-part": "message-contact", style: css(S.contact, ring.style), onFocus: ring.onFocus, onBlur: ring.onBlur, children: [_jsx(Glyph, { name: kind }), _jsx("span", { children: contactLabel(href) })] }));
29
- };
30
- const DocumentCard = ({ href }) => {
31
- const ring = useFocusRing();
32
- let host = "";
33
- try {
34
- host = new URL(href).host;
35
- }
36
- catch {
37
- /* keep empty */
38
- }
39
- return (_jsxs("a", { href: href, target: "_blank", rel: "noopener noreferrer", title: href, "data-convai-part": "message-file-card", style: css(S.fileCard, ring.style), onFocus: ring.onFocus, onBlur: ring.onBlur, children: [_jsx("span", { "data-convai-part": "message-file-icon", style: css(S.fileIcon), children: documentBadge(href) }), _jsxs("span", { style: css(S.fileBody), children: [_jsx("span", { "data-convai-part": "message-file-name", style: css(S.fileName), children: fileNameOf(href) }), _jsxs("span", { "data-convai-part": "message-file-meta", style: css(S.fileMeta), children: [host, " \u00B7 Opens in a new tab"] })] })] }));
40
- };
41
- /**
42
- * Inline preview for an image or video URL. The element is in the tree from
43
- * the start so the fetch begins immediately; a skeleton covers it until it
44
- * decodes. Error, timeout, or an insecure URL collapse it to one muted line
45
- * so a URL the character invented never leaves an empty player behind.
46
- */
47
- const MediaPreview = ({ src, alt, kind, pageProtocol, }) => {
48
- const insecure = isMixedContent(src, pageProtocol);
49
- const [state, setState] = React.useState(insecure ? "error" : "loading");
50
- const cardRef = React.useRef(null);
51
- React.useEffect(() => {
52
- injectKeyframes(document);
53
- }, []);
54
- React.useEffect(() => {
55
- if (state !== "loading")
56
- return;
57
- const t = setTimeout(() => setState((s) => (s === "loading" ? "error" : s)), PREVIEW_TIMEOUT_MS);
58
- return () => clearTimeout(t);
59
- }, [state]);
60
- if (state === "error") {
61
- return (_jsxs("span", { "data-convai-part": "message-media-unavailable", style: css(S.unavailable), children: ["Preview unavailable \u2014 ", describeUrl(src), insecure ? " (insecure URL)" : ""] }));
62
- }
63
- const ready = state === "ready";
64
- const open = () => openLightbox({
65
- src,
66
- alt,
67
- caption: describeUrl(src),
68
- href: src,
69
- root: document,
70
- returnFocusTo: cardRef.current,
71
- });
72
- const buttonProps = kind === "image"
73
- ? {
74
- role: "button",
75
- tabIndex: 0,
76
- "aria-label": `Open image: ${fileNameOf(src)}`,
77
- onClick: open,
78
- onKeyDown: (e) => {
79
- if (e.key === "Enter" || e.key === " ") {
80
- e.preventDefault();
81
- open();
82
- }
83
- },
84
- }
85
- : {};
86
- return (_jsxs(_Fragment, { children: [_jsxs("span", { ref: cardRef, "data-convai-part": "message-media-card", style: css(S.card, kind === "image" ? S.cardButton : {}), ...buttonProps, children: [kind === "image" ? (_jsx("img", { src: src, alt: alt, loading: "lazy", "data-convai-part": "message-media", onLoad: () => setState("ready"), onError: () => setState("error"), style: css(S.media, { opacity: ready ? 1 : 0 }) })) : (_jsx("video", { src: src, controls: true, preload: "metadata", "data-convai-part": "message-media", onLoadedMetadata: () => setState("ready"), onError: () => setState("error"), style: css(S.media, S.videoMedia, { opacity: ready ? 1 : 0 }) })), !ready && (_jsx("span", { "data-convai-skeleton": "", "data-convai-part": "message-media-skeleton", style: css(S.skeleton), "aria-hidden": "true" })), kind === "image" && (_jsx("span", { "data-convai-part": "message-media-zoom", style: css(S.zoom), children: _jsx(Glyph, { name: "zoom", style: { fontSize: 14 } }) }))] }), _jsx("span", { "data-convai-part": "message-media-caption", style: css(S.caption), children: describeUrl(src) })] }));
87
- };
88
- const renderNode = (node, key, media, budget, pageProtocol, resolveLinkPreview) => {
89
- switch (node.kind) {
90
- case "strong":
91
- return _jsx("strong", { children: node.text }, key);
92
- case "em":
93
- return _jsx("em", { children: node.text }, key);
94
- case "blocked":
95
- // Not an anchor, ever. The label reads as the character wrote it; the
96
- // target is only revealed on hover.
97
- return (_jsx("span", { "data-convai-part": "message-link-blocked", style: css(S.blocked), title: `Link blocked: ${node.href}`, children: node.label }, key));
98
- case "image": {
99
- if (media && budget.cards < MAX_CARDS_PER_MESSAGE) {
100
- budget.cards++;
101
- return (_jsx(MediaPreview, { src: node.src, alt: node.alt, kind: "image", pageProtocol: pageProtocol }, key));
102
- }
103
- // With previews off (or the budget spent), an image still has to say
104
- // what it pointed at, so it degrades to the same anchor a link renders.
105
- return _jsx(Anchor, { href: node.src, kind: "image", label: node.alt || node.src }, key);
106
- }
107
- case "link": {
108
- const kind = linkKindForUrl(node.href);
109
- if (kind === "email" || kind === "phone" || kind === "sms") {
110
- return media ? (_jsx(ContactChip, { href: node.href, kind: kind }, key)) : (_jsx(Anchor, { href: node.href, kind: kind, label: node.label }, key));
111
- }
112
- const wantsCard = media &&
113
- (kind === "image" || kind === "video" || kind === "document") &&
114
- budget.cards < MAX_CARDS_PER_MESSAGE;
115
- // The budget is spent when the card mounts, not when it resolves, so the
116
- // cap stays deterministic for a message naming twenty pages.
117
- const wantsSiteCard = media && kind === "web" && !!resolveLinkPreview && budget.cards < MAX_CARDS_PER_MESSAGE;
118
- if (wantsCard || wantsSiteCard)
119
- budget.cards++;
120
- return (_jsxs(React.Fragment, { children: [_jsx(Anchor, { href: node.href, kind: kind, label: node.label }), wantsCard && kind === "document" && _jsx(DocumentCard, { href: node.href }), wantsCard && kind !== "document" && (_jsx(MediaPreview, { src: node.href, alt: node.label, kind: kind, pageProtocol: pageProtocol })), wantsSiteCard && _jsx(SiteCard, { href: node.href, resolver: resolveLinkPreview })] }, key));
121
- }
122
- default:
123
- return _jsx(React.Fragment, { children: node.text }, key);
124
- }
125
- };
126
- const wrapperStyle = { whiteSpace: "pre-wrap", wordWrap: "break-word" };
127
- export const MarkdownRenderer = ({ text, media = true, pageProtocol, resolveLinkPreview, }) => {
128
- if (!text)
129
- return _jsx("div", { style: wrapperStyle });
130
- // Handle both actual newlines and literal "\n" sequences.
131
- const lines = text.replace(/\\n/g, "\n").split("\n");
132
- const budget = { cards: 0 };
133
- return (_jsx("div", { style: wrapperStyle, children: lines.map((line, lineIndex) => {
134
- // An empty line is paragraph spacing.
135
- if (line.trim() === "" && lineIndex > 0)
136
- return _jsx("br", {}, `br-${lineIndex}`);
137
- const nodes = parseInlineMarkdown(line).map((node, i) => renderNode(node, `${node.kind}-${lineIndex}-${i}`, media, budget, pageProtocol, resolveLinkPreview));
138
- return (_jsxs(React.Fragment, { children: [nodes.length > 0 ? nodes : line, lineIndex < lines.length - 1 && _jsx("br", {})] }, `line-${lineIndex}`));
139
- }) }));
140
- };
@@ -1,9 +0,0 @@
1
- import React from "react";
2
- interface MessageBubbleProps {
3
- children: React.ReactNode;
4
- isUser?: boolean;
5
- timestamp?: string;
6
- className?: string;
7
- }
8
- export declare const MessageBubble: ({ children, isUser, timestamp, className, }: MessageBubbleProps) => import("react/jsx-runtime").JSX.Element;
9
- export {};
@@ -1,22 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { BubbleContainer, Bubble, Timestamp } from "../styles/index.js";
3
- const bubbleVariants = {
4
- initial: {
5
- opacity: 0,
6
- y: 20,
7
- scale: 0.95,
8
- },
9
- animate: {
10
- opacity: 1,
11
- y: 0,
12
- scale: 1,
13
- },
14
- exit: {
15
- opacity: 0,
16
- y: -10,
17
- scale: 0.95,
18
- },
19
- };
20
- export const MessageBubble = ({ children, isUser = false, timestamp, className, }) => {
21
- return (_jsxs(BubbleContainer, { "$isUser": isUser, className: className, initial: "initial", animate: "animate", exit: "exit", variants: bubbleVariants, transition: { duration: 0.2, ease: "easeInOut" }, children: [_jsx(Bubble, { "$isUser": isUser, children: children }), timestamp && _jsx(Timestamp, { "$isUser": isUser, children: timestamp })] }));
22
- };
@@ -1,13 +0,0 @@
1
- import type { LinkPreviewResolver } from "../../../../utils/linkPreview.js";
2
- import { RTCChatMessage } from "../types/index.js";
3
- type Message = RTCChatMessage;
4
- interface MessageListProps {
5
- messages: Message[];
6
- className?: string;
7
- isStreaming?: boolean;
8
- forceToBottomToken?: string | number | boolean;
9
- /** Open Graph lookup for plain web links in bot bubbles. */
10
- linkPreviewResolver?: LinkPreviewResolver;
11
- }
12
- export declare const MessageList: ({ messages, className, isStreaming, forceToBottomToken, linkPreviewResolver, }: MessageListProps) => import("react/jsx-runtime").JSX.Element;
13
- export {};
@@ -1,88 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import React, { useRef, useEffect, useCallback } from "react";
3
- import { UserMessage } from "./UserMessage.js";
4
- import { ConviMessage } from "./ConviMessage.js";
5
- import { aeroTheme } from "../styles/index.js";
6
- import { MessageListContainer, MessageWrapper, EmptyState } from "../styles/index.js";
7
- export const MessageList = ({ messages, className, isStreaming = false, forceToBottomToken, linkPreviewResolver, }) => {
8
- const containerRef = useRef(null);
9
- const [shouldAutoScroll, setShouldAutoScroll] = React.useState(true);
10
- // Handle scroll events
11
- const handleScroll = useCallback((e) => {
12
- const { scrollTop, scrollHeight, clientHeight } = e.currentTarget;
13
- // Check if user is near bottom (within 100px)
14
- const isNearBottom = scrollHeight - scrollTop - clientHeight < 100;
15
- setShouldAutoScroll(isNearBottom);
16
- }, []);
17
- // Auto-scroll to bottom
18
- const scrollToBottom = useCallback(() => {
19
- const el = containerRef.current;
20
- if (!el || !shouldAutoScroll)
21
- return;
22
- try {
23
- el.scrollTo({ top: el.scrollHeight, behavior: isStreaming ? "smooth" : "auto" });
24
- }
25
- catch {
26
- // Fallback for older browsers
27
- el.scrollTop = el.scrollHeight;
28
- }
29
- }, [shouldAutoScroll, isStreaming]);
30
- const scrollToBottomImmediate = useCallback(() => {
31
- const el = containerRef.current;
32
- if (!el)
33
- return;
34
- try {
35
- el.scrollTo({ top: el.scrollHeight, behavior: "auto" });
36
- }
37
- catch {
38
- el.scrollTop = el.scrollHeight;
39
- }
40
- }, []);
41
- // Scroll to bottom on new messages
42
- useEffect(() => {
43
- if (messages.length > 0) {
44
- // Use requestAnimationFrame to ensure DOM is updated
45
- requestAnimationFrame(() => {
46
- scrollToBottom();
47
- });
48
- }
49
- }, [messages.length, scrollToBottom]);
50
- // Observe size changes to keep smooth auto-scroll when message content grows
51
- useEffect(() => {
52
- const el = containerRef.current;
53
- if (!el || typeof ResizeObserver === "undefined")
54
- return;
55
- const observer = new ResizeObserver(() => {
56
- if (!shouldAutoScroll)
57
- return;
58
- // Smooth during streaming, instant otherwise to prevent bounce at finalization
59
- try {
60
- el.scrollTo({ top: el.scrollHeight, behavior: isStreaming ? "smooth" : "auto" });
61
- }
62
- catch {
63
- el.scrollTop = el.scrollHeight;
64
- }
65
- });
66
- observer.observe(el);
67
- return () => observer.disconnect();
68
- }, [shouldAutoScroll, isStreaming]);
69
- // Force bottom when token changes (e.g., when chat opens or after reload)
70
- useEffect(() => {
71
- if (forceToBottomToken !== undefined) {
72
- requestAnimationFrame(() => scrollToBottomImmediate());
73
- }
74
- }, [forceToBottomToken, scrollToBottomImmediate]);
75
- // Initial scroll to bottom
76
- useEffect(() => {
77
- if (containerRef.current && messages.length > 0) {
78
- containerRef.current.scrollTop = containerRef.current.scrollHeight;
79
- }
80
- }, []);
81
- if (messages.length === 0) {
82
- return (_jsxs(EmptyState, { children: [_jsx("p", { children: "Start a conversation" }), _jsx("p", { style: {
83
- fontSize: aeroTheme.typography.sizes.caption,
84
- marginTop: 8,
85
- }, children: "Type a message below to begin chatting" })] }));
86
- }
87
- return (_jsx(MessageListContainer, { ref: containerRef, className: className, onScroll: handleScroll, children: messages.map((message) => (_jsx(MessageWrapper, { children: message.isUser ? (_jsx(UserMessage, { message: message.text, timestamp: message.timestamp, sender: message.sender })) : (_jsx(ConviMessage, { message: message.text, timestamp: message.timestamp, showLogo: message.showLogo, sender: message.sender, resolveLinkPreview: linkPreviewResolver })) }, message.id))) }));
88
- };
@@ -1,14 +0,0 @@
1
- import { type LinkPreviewResolver } from "../../../../utils/linkPreview.js";
2
- /**
3
- * Open Graph card under a plain web link. Renders nothing until the host's
4
- * resolver settles and nothing at all unless the result has a title or an
5
- * image: most links resolve to nothing card-worthy, and a placeholder that
6
- * then vanishes reads worse than a card that appears.
7
- *
8
- * Everything from the resolver lands in text nodes or an `img` src that
9
- * `resolveLinkPreviewCached` already restricted to http(s). Never markup.
10
- */
11
- export declare const SiteCard: ({ href, resolver }: {
12
- href: string;
13
- resolver: LinkPreviewResolver;
14
- }) => import("react/jsx-runtime").JSX.Element | null;
@@ -1,34 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import React from "react";
3
- import { resolveLinkPreviewCached, isCardWorthy, siteNameFor, faviconFor, } from "../../../../utils/linkPreview.js";
4
- import { presentationStyles as S } from "../../../../utils/linkPresentation.js";
5
- const css = (...objs) => Object.assign({}, ...objs);
6
- /**
7
- * Open Graph card under a plain web link. Renders nothing until the host's
8
- * resolver settles and nothing at all unless the result has a title or an
9
- * image: most links resolve to nothing card-worthy, and a placeholder that
10
- * then vanishes reads worse than a card that appears.
11
- *
12
- * Everything from the resolver lands in text nodes or an `img` src that
13
- * `resolveLinkPreviewCached` already restricted to http(s). Never markup.
14
- */
15
- export const SiteCard = ({ href, resolver }) => {
16
- const [meta, setMeta] = React.useState(null);
17
- const [faviconOk, setFaviconOk] = React.useState(true);
18
- const [imageOk, setImageOk] = React.useState(true);
19
- const [focused, setFocused] = React.useState(false);
20
- React.useEffect(() => {
21
- let live = true;
22
- resolveLinkPreviewCached(resolver, href).then((m) => {
23
- if (live && isCardWorthy(m))
24
- setMeta(m);
25
- });
26
- return () => {
27
- live = false;
28
- };
29
- }, [href, resolver]);
30
- if (!meta)
31
- return null;
32
- const favicon = faviconFor(meta, href);
33
- return (_jsxs("a", { href: href, target: "_blank", rel: "noopener noreferrer", "data-convai-part": "message-site-card", style: css(S.siteCard, focused ? S.linkFocus : {}), onFocus: (e) => setFocused(e.target.matches(":focus-visible")), onBlur: () => setFocused(false), children: [_jsxs("span", { style: css(S.siteHeader), children: [favicon && faviconOk && (_jsx("img", { src: favicon, alt: "", "data-convai-part": "message-site-favicon", style: css(S.siteFavicon), onError: () => setFaviconOk(false) })), _jsx("span", { "data-convai-part": "message-site-name", style: css(S.siteName), children: siteNameFor(meta, href) })] }), meta.title && (_jsx("span", { "data-convai-part": "message-site-title", style: css(S.siteTitle), children: meta.title })), meta.description && (_jsx("span", { "data-convai-part": "message-site-description", style: css(S.siteDescription), children: meta.description })), meta.image && imageOk && (_jsx("img", { src: meta.image, alt: "", loading: "lazy", "data-convai-part": "message-site-image", style: css(S.siteImage), onError: () => setImageOk(false) }))] }));
34
- };
@@ -1,8 +0,0 @@
1
- interface UserMessageProps {
2
- message: string;
3
- timestamp?: string;
4
- className?: string;
5
- sender?: string;
6
- }
7
- export declare const UserMessage: ({ message, timestamp, className, sender, }: UserMessageProps) => import("react/jsx-runtime").JSX.Element;
8
- export {};
@@ -1,14 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { aeroTheme } from "../styles/index.js";
3
- import { UserBubble, UserMessageContainer, MessageHeader, UserLabel, LogoWrapper, } from "../styles/index.js";
4
- import { FaUser } from "../../../icons.js";
5
- import { MarkdownRenderer } from "./MarkdownRenderer.js";
6
- export const UserMessage = ({ message, timestamp, className, sender, }) => {
7
- return (_jsxs(UserMessageContainer, { className: className, children: [_jsxs(UserBubble, { children: [sender && (_jsxs(MessageHeader, { children: [_jsx(LogoWrapper, { children: _jsx(FaUser, { size: 16, color: aeroTheme.colors.convai.dark }) }), _jsx(UserLabel, { children: sender === "User" ? "You" : sender })] })), _jsx(MarkdownRenderer, { text: message, media: false })] }), timestamp && (_jsx("span", { style: {
8
- fontSize: aeroTheme.typography.sizes.caption,
9
- color: aeroTheme.colors.text.secondary,
10
- marginTop: 4,
11
- alignSelf: "flex-end",
12
- fontFamily: aeroTheme.typography.fontFamily.body,
13
- }, children: timestamp }))] }));
14
- };
@@ -1,5 +0,0 @@
1
- interface ConviButtonProps {
2
- isOpen: boolean;
3
- }
4
- export declare const ConviButton: ({ isOpen }: ConviButtonProps) => import("react/jsx-runtime").JSX.Element;
5
- export {};
@@ -1,14 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { ConvaiLogo } from "../../styles/icons.js";
3
- import { aeroTheme } from "../../styles/theme.js";
4
- import { iosTransitions } from "../../styles/framerConfig.js";
5
- import { ButtonContent, Logo } from "../../styles/styledComponents.js";
6
- export const ConviButton = ({ isOpen }) => {
7
- return (_jsx(ButtonContent, { animate: {
8
- opacity: isOpen ? 0 : 1,
9
- scale: isOpen ? 0.8 : 1,
10
- }, transition: {
11
- duration: 0.3,
12
- ease: "easeInOut",
13
- }, children: _jsx(Logo, { animate: { rotate: isOpen ? 90 : 0 }, transition: iosTransitions.layoutMorph, children: _jsx(ConvaiLogo, { size: "xl", color: aeroTheme.colors.primary[500], animate: isOpen, state: isOpen ? "connected" : "idle" }) }) }));
14
- };
@@ -1,24 +0,0 @@
1
- import React from "react";
2
- interface ConviFooterProps {
3
- inputMode: "conversation" | "speaker" | "voice" | "verbosity";
4
- inputValue: string;
5
- liveUserText: string;
6
- chatbotMic: boolean;
7
- localIsTyping: boolean;
8
- convaiIsTyping: boolean;
9
- isCreatingSpeaker: boolean;
10
- isPressingMic: boolean;
11
- isSettingsOpen: boolean;
12
- isVoiceMode: boolean;
13
- onInputChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
14
- onKeyPress: (e: React.KeyboardEvent) => void;
15
- onSend: () => void;
16
- onMicPress: () => void;
17
- onMicRelease: () => void;
18
- setIsPressingMic: (value: boolean) => void;
19
- onToggleVoiceMode: () => void;
20
- verbosityChanged?: boolean;
21
- onContinue?: () => void;
22
- }
23
- export declare const ConviFooter: ({ inputMode, inputValue, liveUserText, chatbotMic, localIsTyping, convaiIsTyping, isCreatingSpeaker, isPressingMic, isSettingsOpen, isVoiceMode, onInputChange, onKeyPress, onSend, onMicPress, onMicRelease, setIsPressingMic, onToggleVoiceMode, verbosityChanged, onContinue, }: ConviFooterProps) => import("react/jsx-runtime").JSX.Element;
24
- export {};