@convai/web-sdk 1.9.0-beta.0 → 1.9.0-beta.2
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/dist/core/AudioManager.d.ts +3 -3
- package/dist/core/AudioManager.js +1 -1
- package/dist/core/CharacterRoster.d.ts +1 -1
- package/dist/core/CharacterVersionManager.d.ts +2 -2
- package/dist/core/CharacterVersionManager.js +1 -1
- package/dist/core/ConnectionStateHandler.d.ts +1 -1
- package/dist/core/ConvaiClient.d.ts +6 -6
- package/dist/core/ConvaiClient.d.ts.map +1 -1
- package/dist/core/ConvaiClient.js +34 -28
- package/dist/core/ConvaiClient.js.map +1 -1
- package/dist/core/MemoryManager.d.ts +1 -1
- package/dist/core/MessageHandler.d.ts +7 -4
- package/dist/core/MessageHandler.d.ts.map +1 -1
- package/dist/core/MessageHandler.js +68 -43
- package/dist/core/MessageHandler.js.map +1 -1
- package/dist/core/SSESession.d.ts +7 -8
- package/dist/core/SSESession.d.ts.map +1 -1
- package/dist/core/SSESession.js +225 -11
- package/dist/core/SSESession.js.map +1 -1
- package/dist/core/ScreenShareManager.d.ts +2 -2
- package/dist/core/ScreenShareManager.js +2 -2
- package/dist/core/VideoManager.d.ts +2 -2
- package/dist/core/VideoManager.js +3 -3
- package/dist/core/connectRequest.d.ts +1 -1
- package/dist/core/contextUpdateRequest.d.ts +1 -1
- package/dist/core/index.d.ts +25 -21
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +19 -17
- package/dist/core/index.js.map +1 -1
- package/dist/core/modelOutput.d.ts +2 -2
- package/dist/core/publishedChat.d.ts +1 -1
- package/dist/core/rosterRequest.d.ts +1 -1
- package/dist/core/rosterRequest.js +1 -1
- package/dist/core/rtviEnvelope.d.ts +6 -0
- package/dist/core/rtviEnvelope.d.ts.map +1 -0
- package/dist/core/rtviEnvelope.js +10 -0
- package/dist/core/rtviEnvelope.js.map +1 -0
- package/dist/core/types.d.ts +27 -9
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/types.js.map +1 -1
- package/dist/core/videoSourceState.d.ts +1 -1
- package/dist/core/visionRequest.d.ts +1 -1
- package/dist/embed/ConvaiChatElement.js +2 -2
- package/dist/embed/browser.d.ts +2 -2
- package/dist/embed/browser.js +3 -3
- package/dist/embed/chat-embed-v1.js +14 -14
- package/dist/embed/chat-embed-v1.js.map +4 -4
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/lipsync-helpers/createBlendshapeQueue.d.ts +2 -2
- package/dist/lipsync-helpers/createBlendshapeQueue.js +2 -2
- package/dist/lipsync-helpers/declarativeMapping.d.ts +1 -1
- package/dist/lipsync-helpers/declarativeMapping.js +2 -2
- package/dist/lipsync-helpers/index.d.ts +12 -12
- package/dist/lipsync-helpers/index.js +9 -9
- package/dist/lipsync-helpers/mhaLimitDrivers.js +2 -2
- package/dist/lipsync-helpers/naturalness/processor.d.ts +1 -1
- package/dist/lipsync-helpers/naturalness/processor.js +1 -1
- package/dist/lipsync-helpers/naturalness/profiles/mha.d.ts +1 -1
- package/dist/lipsync-helpers/naturalness/profiles/mha.js +1 -1
- package/dist/lipsync-helpers/presetMappers.d.ts +1 -1
- package/dist/react/components/ConvaiWidget.d.ts +11 -2
- package/dist/react/components/ConvaiWidget.d.ts.map +1 -1
- package/dist/react/components/ConvaiWidget.js +7 -7
- package/dist/react/components/ConvaiWidget.js.map +1 -1
- package/dist/react/components/index.d.ts +1 -1
- package/dist/react/components/index.js +1 -1
- package/dist/react/components/rtc-widget/components/AudioSettingsPanel.d.ts +1 -1
- package/dist/react/components/rtc-widget/components/ConviMessage.d.ts +4 -1
- package/dist/react/components/rtc-widget/components/ConviMessage.d.ts.map +1 -1
- package/dist/react/components/rtc-widget/components/ConviMessage.js +5 -5
- package/dist/react/components/rtc-widget/components/ConviMessage.js.map +1 -1
- package/dist/react/components/rtc-widget/components/FloatingVideo.js +3 -3
- package/dist/react/components/rtc-widget/components/MarkdownRenderer.d.ts +21 -3
- package/dist/react/components/rtc-widget/components/MarkdownRenderer.d.ts.map +1 -1
- package/dist/react/components/rtc-widget/components/MarkdownRenderer.js +114 -130
- package/dist/react/components/rtc-widget/components/MarkdownRenderer.js.map +1 -1
- package/dist/react/components/rtc-widget/components/MessageBubble.js +1 -1
- package/dist/react/components/rtc-widget/components/MessageList.d.ts +5 -2
- package/dist/react/components/rtc-widget/components/MessageList.d.ts.map +1 -1
- package/dist/react/components/rtc-widget/components/MessageList.js +6 -6
- package/dist/react/components/rtc-widget/components/MessageList.js.map +1 -1
- package/dist/react/components/rtc-widget/components/SiteCard.d.ts +15 -0
- package/dist/react/components/rtc-widget/components/SiteCard.d.ts.map +1 -0
- package/dist/react/components/rtc-widget/components/SiteCard.js +35 -0
- package/dist/react/components/rtc-widget/components/SiteCard.js.map +1 -0
- package/dist/react/components/rtc-widget/components/UserMessage.js +3 -3
- package/dist/react/components/rtc-widget/components/conviComponents/ConviButton.js +4 -4
- package/dist/react/components/rtc-widget/components/conviComponents/ConviFooter.js +3 -3
- package/dist/react/components/rtc-widget/components/conviComponents/ConviHeader.js +4 -4
- package/dist/react/components/rtc-widget/components/conviComponents/SettingsTray.js +3 -3
- package/dist/react/components/rtc-widget/components/conviComponents/VoiceModeOverlay.js +3 -3
- package/dist/react/components/rtc-widget/components/conviComponents/index.d.ts +5 -5
- package/dist/react/components/rtc-widget/components/conviComponents/index.js +5 -5
- package/dist/react/components/rtc-widget/components/index.d.ts +8 -8
- package/dist/react/components/rtc-widget/components/index.js +9 -9
- package/dist/react/components/rtc-widget/index.d.ts +5 -5
- package/dist/react/components/rtc-widget/index.js +3 -3
- package/dist/react/components/rtc-widget/styles/icons.d.ts +1 -1
- package/dist/react/components/rtc-widget/styles/icons.js +1 -1
- package/dist/react/components/rtc-widget/styles/index.d.ts +5 -5
- package/dist/react/components/rtc-widget/styles/index.js +4 -4
- package/dist/react/components/rtc-widget/styles/styledComponents.js +1 -1
- package/dist/react/hooks/index.d.ts +3 -3
- package/dist/react/hooks/index.js +3 -3
- package/dist/react/hooks/useCharacterInfo.js +1 -1
- package/dist/react/hooks/useConvaiClient.d.ts +1 -1
- package/dist/react/hooks/useConvaiClient.js +1 -1
- package/dist/react/index.d.ts +13 -9
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +10 -8
- package/dist/react/index.js.map +1 -1
- package/dist/utils/lightbox.d.ts +16 -0
- package/dist/utils/lightbox.d.ts.map +1 -0
- package/dist/utils/lightbox.js +95 -0
- package/dist/utils/lightbox.js.map +1 -0
- package/dist/utils/linkPresentation.d.ts +76 -0
- package/dist/utils/linkPresentation.d.ts.map +1 -0
- package/dist/utils/linkPresentation.js +415 -0
- package/dist/utils/linkPresentation.js.map +1 -0
- package/dist/utils/linkPreview.d.ts +46 -0
- package/dist/utils/linkPreview.d.ts.map +1 -0
- package/dist/utils/linkPreview.js +72 -0
- package/dist/utils/linkPreview.js.map +1 -0
- package/dist/vanilla/AudioRenderer.js +1 -1
- package/dist/vanilla/ConvaiWidget.d.ts +1 -1
- package/dist/vanilla/ConvaiWidget.d.ts.map +1 -1
- package/dist/vanilla/ConvaiWidget.js +287 -193
- package/dist/vanilla/ConvaiWidget.js.map +1 -1
- package/dist/vanilla/WebSocketSession.d.ts +1 -1
- package/dist/vanilla/WebSocketSession.js +1 -1
- package/dist/vanilla/index.d.ts +13 -9
- package/dist/vanilla/index.d.ts.map +1 -1
- package/dist/vanilla/index.js +9 -7
- package/dist/vanilla/index.js.map +1 -1
- package/dist/vanilla/styles.d.ts.map +1 -1
- package/dist/vanilla/styles.js +9 -0
- package/dist/vanilla/styles.js.map +1 -1
- package/dist/vanilla/types.d.ts +11 -2
- package/dist/vanilla/types.d.ts.map +1 -1
- package/dist/vanilla/types.js.map +1 -1
- package/dist/vanilla/websocket.d.ts +1 -1
- package/dist/vanilla/websocket.js +2 -2
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type LinkPreviewResolver } from "../../../../utils/linkPreview";
|
|
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;
|
|
15
|
+
//# sourceMappingURL=SiteCard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SiteCard.d.ts","sourceRoot":"","sources":["../../../../../src/react/components/rtc-widget/components/SiteCard.tsx"],"names":[],"mappings":"AACA,OAAO,EAML,KAAK,mBAAmB,EACzB,MAAM,+BAA+B,CAAC;AAMvC;;;;;;;;GAQG;AACH,eAAO,MAAM,QAAQ,GAAI,oBAAoB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,mBAAmB,CAAA;CAAE,mDAiE3F,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
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";
|
|
4
|
+
import { presentationStyles as S } from "../../../../utils/linkPresentation";
|
|
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
|
+
};
|
|
35
|
+
//# sourceMappingURL=SiteCard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SiteCard.js","sourceRoot":"","sources":["../../../../../src/react/components/rtc-widget/components/SiteCard.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EACL,wBAAwB,EACxB,YAAY,EACZ,WAAW,EACX,UAAU,GAGX,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,kBAAkB,IAAI,CAAC,EAAoB,MAAM,oCAAoC,CAAC;AAE/F,MAAM,GAAG,GAAG,CAAC,GAAG,IAAmB,EAAuB,EAAE,CAC1D,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,GAAG,IAAI,CAAwB,CAAC;AAEpD;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAmD,EAAE,EAAE;IAC9F,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAyB,IAAI,CAAC,CAAC;IACrE,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IACvD,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IACnD,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAEpD,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,IAAI,IAAI,GAAG,IAAI,CAAC;QAChB,wBAAwB,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE;YAClD,IAAI,IAAI,IAAI,YAAY,CAAC,CAAC,CAAC;gBAAE,OAAO,CAAC,CAAC,CAAC,CAAC;QAC1C,CAAC,CAAC,C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WAAW,IAAI,CACnB,mCAAuB,0BAA0B,EAAC,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC,eAAe,CAAC,YAC5E,IAAI,CAAC,WAAW,GACZ,CACR,EACA,IAAI,CAAC,KAAK,IAAI,OAAO,IAAI,CACxB,cACE,GAAG,EAAE,IAAI,CAAC,KAAK,EACf,GAAG,EAAC,EAAE,EACN,OAAO,EAAC,MAAM,sBACG,oBAAoB,EACrC,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC,EACvB,OAAO,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,GAChC,CACH,IACC,CACL,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import React from \"react\";\nimport {\n resolveLinkPreviewCached,\n isCardWorthy,\n siteNameFor,\n faviconFor,\n type LinkPreviewMeta,\n type LinkPreviewResolver,\n} from \"../../../../utils/linkPreview\";\nimport { presentationStyles as S, type StyleObject } from \"../../../../utils/linkPresentation\";\n\nconst css = (...objs: StyleObject[]): React.CSSProperties =>\n Object.assign({}, ...objs) as React.CSSProperties;\n\n/**\n * Open Graph card under a plain web link. Renders nothing until the host's\n * resolver settles and nothing at all unless the result has a title or an\n * image: most links resolve to nothing card-worthy, and a placeholder that\n * then vanishes reads worse than a card that appears.\n *\n * Everything from the resolver lands in text nodes or an `img` src that\n * `resolveLinkPreviewCached` already restricted to http(s). Never markup.\n */\nexport const SiteCard = ({ href, resolver }: { href: string; resolver: LinkPreviewResolver }) => {\n const [meta, setMeta] = React.useState<LinkPreviewMeta | null>(null);\n const [faviconOk, setFaviconOk] = React.useState(true);\n const [imageOk, setImageOk] = React.useState(true);\n const [focused, setFocused] = React.useState(false);\n\n React.useEffect(() => {\n let live = true;\n resolveLinkPreviewCached(resolver, href).then((m) => {\n if (live && isCardWorthy(m)) setMeta(m);\n });\n return () => {\n live = false;\n };\n }, [href, resolver]);\n\n if (!meta) return null;\n const favicon = faviconFor(meta, href);\n\n return (\n <a\n href={href}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n data-convai-part=\"message-site-card\"\n style={css(S.siteCard, focused ? S.linkFocus : {})}\n onFocus={(e) => setFocused(e.target.matches(\":focus-visible\"))}\n onBlur={() => setFocused(false)}\n >\n <span style={css(S.siteHeader)}>\n {favicon && faviconOk && (\n <img\n src={favicon}\n alt=\"\"\n data-convai-part=\"message-site-favicon\"\n style={css(S.siteFavicon)}\n onError={() => setFaviconOk(false)}\n />\n )}\n <span data-convai-part=\"message-site-name\" style={css(S.siteName)}>\n {siteNameFor(meta, href)}\n </span>\n </span>\n {meta.title && (\n <span data-convai-part=\"message-site-title\" style={css(S.siteTitle)}>\n {meta.title}\n </span>\n )}\n {meta.description && (\n <span data-convai-part=\"message-site-description\" style={css(S.siteDescription)}>\n {meta.description}\n </span>\n )}\n {meta.image && imageOk && (\n <img\n src={meta.image}\n alt=\"\"\n loading=\"lazy\"\n data-convai-part=\"message-site-image\"\n style={css(S.siteImage)}\n onError={() => setImageOk(false)}\n />\n )}\n </a>\n );\n};\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { aeroTheme } from "../styles
|
|
3
|
-
import { UserBubble, UserMessageContainer, MessageHeader, UserLabel, LogoWrapper, } from "../styles
|
|
2
|
+
import { aeroTheme } from "../styles";
|
|
3
|
+
import { UserBubble, UserMessageContainer, MessageHeader, UserLabel, LogoWrapper, } from "../styles";
|
|
4
4
|
import { FaUser } from "react-icons/fa";
|
|
5
|
-
import { MarkdownRenderer } from "./MarkdownRenderer
|
|
5
|
+
import { MarkdownRenderer } from "./MarkdownRenderer";
|
|
6
6
|
export const UserMessage = ({ message, timestamp, className, sender, }) => {
|
|
7
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
8
|
fontSize: aeroTheme.typography.sizes.caption,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { ConvaiLogo } from "../../styles/icons
|
|
3
|
-
import { aeroTheme } from "../../styles/theme
|
|
4
|
-
import { iosTransitions } from "../../styles/framerConfig
|
|
5
|
-
import { ButtonContent, Logo } from "../../styles/styledComponents
|
|
2
|
+
import { ConvaiLogo } from "../../styles/icons";
|
|
3
|
+
import { aeroTheme } from "../../styles/theme";
|
|
4
|
+
import { iosTransitions } from "../../styles/framerConfig";
|
|
5
|
+
import { ButtonContent, Logo } from "../../styles/styledComponents";
|
|
6
6
|
export const ConviButton = ({ isOpen }) => {
|
|
7
7
|
return (_jsx(ButtonContent, { animate: {
|
|
8
8
|
opacity: isOpen ? 0 : 1,
|
|
@@ -2,9 +2,9 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { AnimatePresence, motion } from "framer-motion";
|
|
3
3
|
import { FiSend, FiMic } from "react-icons/fi";
|
|
4
4
|
import { PiWaveform } from "react-icons/pi";
|
|
5
|
-
import { aeroTheme } from "../../styles/theme
|
|
6
|
-
import { iosTransitions } from "../../styles/framerConfig
|
|
7
|
-
import { Footer, InputContainer, Input, ActionButton, } from "../../styles/styledComponents
|
|
5
|
+
import { aeroTheme } from "../../styles/theme";
|
|
6
|
+
import { iosTransitions } from "../../styles/framerConfig";
|
|
7
|
+
import { Footer, InputContainer, Input, ActionButton, } from "../../styles/styledComponents";
|
|
8
8
|
export const ConviFooter = ({ inputMode, inputValue, liveUserText, chatbotMic, localIsTyping, convaiIsTyping, isCreatingSpeaker, isPressingMic, isSettingsOpen, isVoiceMode, onInputChange, onKeyPress, onSend, onMicPress, onMicRelease, setIsPressingMic, onToggleVoiceMode, verbosityChanged = false, onContinue, }) => {
|
|
9
9
|
// Show Continue button in verbosity mode
|
|
10
10
|
if (inputMode === "verbosity") {
|
|
@@ -2,10 +2,10 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { motion } from "framer-motion";
|
|
3
3
|
import { FiMoreVertical } from "react-icons/fi";
|
|
4
4
|
import { IoVolumeMute, IoVolumeHigh } from "react-icons/io5";
|
|
5
|
-
import { ChevronDown } from "../../styles/icons
|
|
6
|
-
import { aeroTheme } from "../../styles/theme
|
|
7
|
-
import { iosTransitions } from "../../styles/framerConfig
|
|
8
|
-
import { Header, Title, CloseButton, SettingsButton, } from "../../styles/styledComponents
|
|
5
|
+
import { ChevronDown } from "../../styles/icons";
|
|
6
|
+
import { aeroTheme } from "../../styles/theme";
|
|
7
|
+
import { iosTransitions } from "../../styles/framerConfig";
|
|
8
|
+
import { Header, Title, CloseButton, SettingsButton, } from "../../styles/styledComponents";
|
|
9
9
|
export const ConviHeader = ({ isOpen, isSpeakerEditMode, isVoiceMode, isVerbosityMode, isMuted, characterImage, characterName = "Character", onClose, onSettingsToggle, onToggleMute, settingsButtonRef, }) => {
|
|
10
10
|
return (_jsxs(Header, { initial: { opacity: 0, y: -20 }, animate: {
|
|
11
11
|
opacity: isOpen ? 1 : 0,
|
|
@@ -3,9 +3,9 @@ import { AnimatePresence } from "framer-motion";
|
|
|
3
3
|
import { LiaRedoAltSolid } from "react-icons/lia";
|
|
4
4
|
import { IoVideocam, IoVideocamOff } from "react-icons/io5";
|
|
5
5
|
import { MdScreenShare, MdStopScreenShare } from "react-icons/md";
|
|
6
|
-
import { aeroTheme } from "../../styles/theme
|
|
7
|
-
import { iosTransitions } from "../../styles/framerConfig
|
|
8
|
-
import { SettingsTray as StyledSettingsTray, SettingsOption, } from "../../styles/styledComponents
|
|
6
|
+
import { aeroTheme } from "../../styles/theme";
|
|
7
|
+
import { iosTransitions } from "../../styles/framerConfig";
|
|
8
|
+
import { SettingsTray as StyledSettingsTray, SettingsOption, } from "../../styles/styledComponents";
|
|
9
9
|
export const SettingsTray = ({ isOpen, isVideoVisible, isScreenShareActive, onReset, onDisconnect, onToggleVideo, onToggleScreenShare, }) => {
|
|
10
10
|
if (!isOpen)
|
|
11
11
|
return null;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect, useRef, useState } from "react";
|
|
3
3
|
import { motion, AnimatePresence } from "framer-motion";
|
|
4
|
-
import { aeroTheme } from "../../styles/theme
|
|
5
|
-
import { iosTransitions } from "../../styles/framerConfig
|
|
6
|
-
import { AudioVisualizer } from "../AudioVisualizer
|
|
4
|
+
import { aeroTheme } from "../../styles/theme";
|
|
5
|
+
import { iosTransitions } from "../../styles/framerConfig";
|
|
6
|
+
import { AudioVisualizer } from "../AudioVisualizer";
|
|
7
7
|
export const VoiceModeOverlay = ({ isActive, isTalking, isListening = false, convaiClient, characterImage, characterName = "Character", room, }) => {
|
|
8
8
|
const barsCount = 40; // Number of bars for user microphone waveform
|
|
9
9
|
// PERF: the waveform is driven OUTSIDE React. A setState per animation
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { ConviButton } from "./ConviButton
|
|
2
|
-
export { ConviHeader } from "./ConviHeader
|
|
3
|
-
export { ConviFooter } from "./ConviFooter
|
|
4
|
-
export { SettingsTray } from "./SettingsTray
|
|
5
|
-
export { VoiceModeOverlay } from "./VoiceModeOverlay
|
|
1
|
+
export { ConviButton } from "./ConviButton";
|
|
2
|
+
export { ConviHeader } from "./ConviHeader";
|
|
3
|
+
export { ConviFooter } from "./ConviFooter";
|
|
4
|
+
export { SettingsTray } from "./SettingsTray";
|
|
5
|
+
export { VoiceModeOverlay } from "./VoiceModeOverlay";
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { ConviButton } from "./ConviButton
|
|
2
|
-
export { ConviHeader } from "./ConviHeader
|
|
3
|
-
export { ConviFooter } from "./ConviFooter
|
|
4
|
-
export { SettingsTray } from "./SettingsTray
|
|
5
|
-
export { VoiceModeOverlay } from "./VoiceModeOverlay
|
|
1
|
+
export { ConviButton } from "./ConviButton";
|
|
2
|
+
export { ConviHeader } from "./ConviHeader";
|
|
3
|
+
export { ConviFooter } from "./ConviFooter";
|
|
4
|
+
export { SettingsTray } from "./SettingsTray";
|
|
5
|
+
export { VoiceModeOverlay } from "./VoiceModeOverlay";
|
|
6
6
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export { MessageBubble } from "./MessageBubble
|
|
2
|
-
export { MessageList } from "./MessageList
|
|
3
|
-
export { UserMessage } from "./UserMessage
|
|
4
|
-
export { ConviMessage } from "./ConviMessage
|
|
5
|
-
export { MarkdownRenderer } from "./MarkdownRenderer
|
|
6
|
-
export { FloatingVideo } from "./FloatingVideo
|
|
7
|
-
export { AudioVisualizer } from "./AudioVisualizer
|
|
8
|
-
export { ConviButton, ConviHeader, ConviFooter, SettingsTray, VoiceModeOverlay, } from "./conviComponents
|
|
1
|
+
export { MessageBubble } from "./MessageBubble";
|
|
2
|
+
export { MessageList } from "./MessageList";
|
|
3
|
+
export { UserMessage } from "./UserMessage";
|
|
4
|
+
export { ConviMessage } from "./ConviMessage";
|
|
5
|
+
export { MarkdownRenderer } from "./MarkdownRenderer";
|
|
6
|
+
export { FloatingVideo } from "./FloatingVideo";
|
|
7
|
+
export { AudioVisualizer } from "./AudioVisualizer";
|
|
8
|
+
export { ConviButton, ConviHeader, ConviFooter, SettingsTray, VoiceModeOverlay, } from "./conviComponents";
|
|
9
9
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
// Export message components
|
|
2
|
-
export { MessageBubble } from "./MessageBubble
|
|
3
|
-
export { MessageList } from "./MessageList
|
|
4
|
-
export { UserMessage } from "./UserMessage
|
|
5
|
-
export { ConviMessage } from "./ConviMessage
|
|
6
|
-
export { MarkdownRenderer } from "./MarkdownRenderer
|
|
2
|
+
export { MessageBubble } from "./MessageBubble";
|
|
3
|
+
export { MessageList } from "./MessageList";
|
|
4
|
+
export { UserMessage } from "./UserMessage";
|
|
5
|
+
export { ConviMessage } from "./ConviMessage";
|
|
6
|
+
export { MarkdownRenderer } from "./MarkdownRenderer";
|
|
7
7
|
// Export floating video component
|
|
8
|
-
export { FloatingVideo } from "./FloatingVideo
|
|
8
|
+
export { FloatingVideo } from "./FloatingVideo";
|
|
9
9
|
// Export audio visualizer
|
|
10
|
-
export { AudioVisualizer } from "./AudioVisualizer
|
|
10
|
+
export { AudioVisualizer } from "./AudioVisualizer";
|
|
11
11
|
// Note: AudioSettingsPanel is internal only - audio settings are fixed
|
|
12
|
-
// export { AudioSettingsPanel } from "./AudioSettingsPanel
|
|
12
|
+
// export { AudioSettingsPanel } from "./AudioSettingsPanel";
|
|
13
13
|
// Export convi sub-components
|
|
14
|
-
export { ConviButton, ConviHeader, ConviFooter, SettingsTray, VoiceModeOverlay, } from "./conviComponents
|
|
14
|
+
export { ConviButton, ConviHeader, ConviFooter, SettingsTray, VoiceModeOverlay, } from "./conviComponents";
|
|
15
15
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { MessageBubble, MessageList, UserMessage, ConviMessage, FloatingVideo, ConviButton, ConviHeader, ConviFooter, SettingsTray, VoiceModeOverlay, } from "./components
|
|
2
|
-
export { aeroTheme, glassStyles, iconSizes, variants, iosTransitions, animationVariants, ConvaiLogo, ChevronDown, } from "./styles
|
|
3
|
-
export { ConvaiContainer, MorphingContainer, ButtonContent, Logo, ChatContent, Header, Title, HeaderLogo, CloseButton, SettingsButton, Content, Footer, InputContainer, Input, ActionButton, } from "./styles
|
|
4
|
-
export type { RTCChatMessage, CharacterVerbosityConfig, ConviUIProps, } from "./types
|
|
5
|
-
export type { LogoState } from "./styles
|
|
1
|
+
export { MessageBubble, MessageList, UserMessage, ConviMessage, FloatingVideo, ConviButton, ConviHeader, ConviFooter, SettingsTray, VoiceModeOverlay, } from "./components";
|
|
2
|
+
export { aeroTheme, glassStyles, iconSizes, variants, iosTransitions, animationVariants, ConvaiLogo, ChevronDown, } from "./styles";
|
|
3
|
+
export { ConvaiContainer, MorphingContainer, ButtonContent, Logo, ChatContent, Header, Title, HeaderLogo, CloseButton, SettingsButton, Content, Footer, InputContainer, Input, ActionButton, } from "./styles";
|
|
4
|
+
export type { RTCChatMessage, CharacterVerbosityConfig, ConviUIProps, } from "./types";
|
|
5
|
+
export type { LogoState } from "./styles";
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// Export all components
|
|
2
2
|
export { MessageBubble, MessageList, UserMessage, ConviMessage, FloatingVideo,
|
|
3
3
|
// AudioSettingsPanel, // Internal only - audio settings are fixed
|
|
4
|
-
ConviButton, ConviHeader, ConviFooter, SettingsTray, VoiceModeOverlay, } from "./components
|
|
4
|
+
ConviButton, ConviHeader, ConviFooter, SettingsTray, VoiceModeOverlay, } from "./components";
|
|
5
5
|
// Export styles and theme
|
|
6
|
-
export { aeroTheme, glassStyles, iconSizes, variants, iosTransitions, animationVariants, ConvaiLogo, ChevronDown, } from "./styles
|
|
6
|
+
export { aeroTheme, glassStyles, iconSizes, variants, iosTransitions, animationVariants, ConvaiLogo, ChevronDown, } from "./styles";
|
|
7
7
|
// Export styled components for custom layouts
|
|
8
|
-
export { ConvaiContainer, MorphingContainer, ButtonContent, Logo, ChatContent, Header, Title, HeaderLogo, CloseButton, SettingsButton, Content, Footer, InputContainer, Input, ActionButton, } from "./styles
|
|
8
|
+
export { ConvaiContainer, MorphingContainer, ButtonContent, Logo, ChatContent, Header, Title, HeaderLogo, CloseButton, SettingsButton, Content, Footer, InputContainer, Input, ActionButton, } from "./styles";
|
|
9
9
|
//# sourceMappingURL=index.js.map
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { useEffect, useState } from "react";
|
|
3
3
|
import { motion } from "framer-motion";
|
|
4
4
|
import styled from "styled-components";
|
|
5
|
-
import { aeroTheme, iconSizes } from "./theme
|
|
5
|
+
import { aeroTheme, iconSizes } from "./theme";
|
|
6
6
|
const LogoSVG = styled(motion.svg) `
|
|
7
7
|
width: ${(props) => props.$size || "100%"};
|
|
8
8
|
height: ${(props) => props.$size || "100%"};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { aeroTheme, glassStyles, iconSizes, variants } from "./theme
|
|
2
|
-
export { iosTransitions, animationVariants } from "./framerConfig
|
|
3
|
-
export { ConvaiContainer, MorphingContainer, ButtonContent, Logo, ChatContent, Header, Title, HeaderLogo, CloseButton, SettingsButton, SettingsTray, SettingsOption, Content, Footer, InputContainer, Input, ActionButton, MessageList, Message, MessageBubble, MessageTime, ButtonContainer, ButtonLogo, ConviBubble, ConviMessageContainer, MessageHeader, ConviLabel, LogoWrapper, UserBubble, UserMessageContainer, UserLabel, BubbleContainer, Bubble, Timestamp, MessageListContainer, MessageWrapper, EmptyState, } from "./styledComponents
|
|
4
|
-
export { ConvaiLogo, ChevronDown, AeroIcons, IconButton } from "./icons
|
|
5
|
-
export type { LogoState } from "./icons
|
|
1
|
+
export { aeroTheme, glassStyles, iconSizes, variants } from "./theme";
|
|
2
|
+
export { iosTransitions, animationVariants } from "./framerConfig";
|
|
3
|
+
export { ConvaiContainer, MorphingContainer, ButtonContent, Logo, ChatContent, Header, Title, HeaderLogo, CloseButton, SettingsButton, SettingsTray, SettingsOption, Content, Footer, InputContainer, Input, ActionButton, MessageList, Message, MessageBubble, MessageTime, ButtonContainer, ButtonLogo, ConviBubble, ConviMessageContainer, MessageHeader, ConviLabel, LogoWrapper, UserBubble, UserMessageContainer, UserLabel, BubbleContainer, Bubble, Timestamp, MessageListContainer, MessageWrapper, EmptyState, } from "./styledComponents";
|
|
4
|
+
export { ConvaiLogo, ChevronDown, AeroIcons, IconButton } from "./icons";
|
|
5
|
+
export type { LogoState } from "./icons";
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// Export theme
|
|
2
|
-
export { aeroTheme, glassStyles, iconSizes, variants } from "./theme
|
|
2
|
+
export { aeroTheme, glassStyles, iconSizes, variants } from "./theme";
|
|
3
3
|
// Export framer configs
|
|
4
|
-
export { iosTransitions, animationVariants } from "./framerConfig
|
|
4
|
+
export { iosTransitions, animationVariants } from "./framerConfig";
|
|
5
5
|
// Export styled components
|
|
6
|
-
export { ConvaiContainer, MorphingContainer, ButtonContent, Logo, ChatContent, Header, Title, HeaderLogo, CloseButton, SettingsButton, SettingsTray, SettingsOption, Content, Footer, InputContainer, Input, ActionButton, MessageList, Message, MessageBubble, MessageTime, ButtonContainer, ButtonLogo, ConviBubble, ConviMessageContainer, MessageHeader, ConviLabel, LogoWrapper, UserBubble, UserMessageContainer, UserLabel, BubbleContainer, Bubble, Timestamp, MessageListContainer, MessageWrapper, EmptyState, } from "./styledComponents
|
|
6
|
+
export { ConvaiContainer, MorphingContainer, ButtonContent, Logo, ChatContent, Header, Title, HeaderLogo, CloseButton, SettingsButton, SettingsTray, SettingsOption, Content, Footer, InputContainer, Input, ActionButton, MessageList, Message, MessageBubble, MessageTime, ButtonContainer, ButtonLogo, ConviBubble, ConviMessageContainer, MessageHeader, ConviLabel, LogoWrapper, UserBubble, UserMessageContainer, UserLabel, BubbleContainer, Bubble, Timestamp, MessageListContainer, MessageWrapper, EmptyState, } from "./styledComponents";
|
|
7
7
|
// Export icons
|
|
8
|
-
export { ConvaiLogo, ChevronDown, AeroIcons, IconButton } from "./icons
|
|
8
|
+
export { ConvaiLogo, ChevronDown, AeroIcons, IconButton } from "./icons";
|
|
9
9
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import styled from "styled-components";
|
|
2
2
|
import { motion } from "framer-motion";
|
|
3
|
-
import { aeroTheme } from "./theme
|
|
3
|
+
import { aeroTheme } from "./theme";
|
|
4
4
|
// Styled Components matching the original webChat exactly
|
|
5
5
|
export const ConvaiContainer = styled(motion.div) `
|
|
6
6
|
position: fixed !important;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { useConvaiClient } from './useConvaiClient
|
|
2
|
-
export { useCharacterInfo } from './useCharacterInfo
|
|
3
|
-
export { useLocalCameraTrack } from './useLocalCameraTrack
|
|
1
|
+
export { useConvaiClient } from './useConvaiClient';
|
|
2
|
+
export { useCharacterInfo } from './useCharacterInfo';
|
|
3
|
+
export { useLocalCameraTrack } from './useLocalCameraTrack';
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Main hook
|
|
2
|
-
export { useConvaiClient } from './useConvaiClient
|
|
2
|
+
export { useConvaiClient } from './useConvaiClient';
|
|
3
3
|
// Additional hooks
|
|
4
|
-
export { useCharacterInfo } from './useCharacterInfo
|
|
5
|
-
export { useLocalCameraTrack } from './useLocalCameraTrack
|
|
4
|
+
export { useCharacterInfo } from './useCharacterInfo';
|
|
5
|
+
export { useLocalCameraTrack } from './useLocalCameraTrack';
|
|
6
6
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ConvaiConfig, IConvaiClient, ChatMessage } from "../../core/types
|
|
1
|
+
import type { ConvaiConfig, IConvaiClient, ChatMessage } from "../../core/types";
|
|
2
2
|
/**
|
|
3
3
|
* React hook wrapper for ConvaiClient
|
|
4
4
|
* Main hook for managing Convai client connection and functionality.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useState, useEffect, useCallback } from "react";
|
|
2
|
-
import { ConvaiClient as CoreConvaiClient } from "../../core
|
|
2
|
+
import { ConvaiClient as CoreConvaiClient } from "../../core";
|
|
3
3
|
/**
|
|
4
4
|
* React hook wrapper for ConvaiClient
|
|
5
5
|
* Main hook for managing Convai client connection and functionality.
|
package/dist/react/index.d.ts
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
export { useConvaiClient } from './hooks/useConvaiClient
|
|
2
|
-
export { ConvaiWidget } from './components/ConvaiWidget
|
|
3
|
-
export { MarkdownRenderer } from './components/rtc-widget/components/MarkdownRenderer
|
|
4
|
-
export { parseInlineMarkdown, mediaKindForUrl, isSafeHref, compactUrl } from '../utils/inlineMarkdown
|
|
5
|
-
export type { InlineNode, MediaKind } from '../utils/inlineMarkdown
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
export {
|
|
9
|
-
export {
|
|
1
|
+
export { useConvaiClient } from './hooks/useConvaiClient';
|
|
2
|
+
export { ConvaiWidget } from './components/ConvaiWidget';
|
|
3
|
+
export { MarkdownRenderer } from './components/rtc-widget/components/MarkdownRenderer';
|
|
4
|
+
export { parseInlineMarkdown, mediaKindForUrl, isSafeHref, compactUrl } from '../utils/inlineMarkdown';
|
|
5
|
+
export type { InlineNode, MediaKind } from '../utils/inlineMarkdown';
|
|
6
|
+
export { linkKindForUrl, describeUrl } from '../utils/linkPresentation';
|
|
7
|
+
export type { LinkKind } from '../utils/linkPresentation';
|
|
8
|
+
export { resolveLinkPreviewCached, isCardWorthy, LINK_PREVIEW_TIMEOUT_MS } from '../utils/linkPreview';
|
|
9
|
+
export type { LinkPreviewMeta, LinkPreviewResolver } from '../utils/linkPreview';
|
|
10
|
+
export * from './hooks';
|
|
11
|
+
export * from '../core/types';
|
|
12
|
+
export { getDisconnectReasonMessage } from '../core/types';
|
|
13
|
+
export { ActionResultAckError, ConvaiClient } from '../core';
|
|
10
14
|
export { RoomAudioRenderer as AudioRenderer, RoomContext as AudioContext } from '@livekit/components-react';
|
|
11
15
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AACA,OAAO,EAA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+1,24 @@
|
|
|
1
1
|
// Main hook (backward compatible)
|
|
2
|
-
export { useConvaiClient } from './hooks/useConvaiClient
|
|
2
|
+
export { useConvaiClient } from './hooks/useConvaiClient';
|
|
3
3
|
// Components
|
|
4
|
-
export { ConvaiWidget } from './components/ConvaiWidget
|
|
4
|
+
export { ConvaiWidget } from './components/ConvaiWidget';
|
|
5
5
|
// Bubble renderer, for a custom chat UI that is not ConvaiWidget. Pass
|
|
6
6
|
// `media={false}` on the user's own bubble: previews are a bot-side
|
|
7
7
|
// affordance, and rendering them on a line the user typed lets any pasted URL
|
|
8
8
|
// pull remote media into the transcript.
|
|
9
|
-
export { MarkdownRenderer } from './components/rtc-widget/components/MarkdownRenderer
|
|
9
|
+
export { MarkdownRenderer } from './components/rtc-widget/components/MarkdownRenderer';
|
|
10
10
|
// The tokenizer behind it, for building a renderer from scratch.
|
|
11
|
-
export { parseInlineMarkdown, mediaKindForUrl, isSafeHref, compactUrl } from '../utils/inlineMarkdown
|
|
11
|
+
export { parseInlineMarkdown, mediaKindForUrl, isSafeHref, compactUrl } from '../utils/inlineMarkdown';
|
|
12
|
+
export { linkKindForUrl, describeUrl } from '../utils/linkPresentation';
|
|
13
|
+
export { resolveLinkPreviewCached, isCardWorthy, LINK_PREVIEW_TIMEOUT_MS } from '../utils/linkPreview';
|
|
12
14
|
// Additional hooks (for advanced usage)
|
|
13
|
-
export * from './hooks
|
|
15
|
+
export * from './hooks';
|
|
14
16
|
// Re-export core types for convenience
|
|
15
|
-
export * from '../core/types
|
|
17
|
+
export * from '../core/types';
|
|
16
18
|
// Re-export helper functions explicitly
|
|
17
|
-
export { getDisconnectReasonMessage } from '../core/types
|
|
19
|
+
export { getDisconnectReasonMessage } from '../core/types';
|
|
18
20
|
// Re-export core client for advanced usage
|
|
19
|
-
export { ActionResultAckError, ConvaiClient } from '../core
|
|
21
|
+
export { ActionResultAckError, ConvaiClient } from '../core';
|
|
20
22
|
// Re-export LiveKit components for convenience (backward compatible)
|
|
21
23
|
export { RoomAudioRenderer as AudioRenderer, RoomContext as AudioContext } from '@livekit/components-react';
|
|
22
24
|
//# sourceMappingURL=index.js.map
|
package/dist/react/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA,kCAAkC;AAClC,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE1D,aAAa;AACb,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEzD,uEAAuE;AACvE,oEAAoE;AACpE,8EAA8E;AAC9E,yCAAyC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,qDAAqD,CAAC;AAEvF,iEAAiE;AACjE,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAGvG,wCAAwC;AACxC,cAAc,SAAS,CAAC;AAExB,uCAAuC;AACvC,cAAc,eAAe,CAAC;AAE9B,wCAAwC;AACxC,OAAO,EAAE,0BAA0B,EAAE,MAAM,eAAe,CAAC;AAE3D,2CAA2C;AAC3C,OAAO,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE7D,qEAAqE;AACrE,OAAO,EAAE,iBAAiB,IAAI,aAAa,EAAE,WAAW,IAAI,YAAY,EAAE,MAAM,2BAA2B,CAAC","sourcesContent":["// Main hook (backward compatible)\nexport { useConvaiClient } from './hooks/useConvaiClient';\n\n// Components\nexport { ConvaiWidget } from './components/ConvaiWidget';\n\n// Bubble renderer, for a custom chat UI that is not ConvaiWidget. Pass\n// `media={false}` on the user's own bubble: previews are a bot-side\n// affordance, and rendering them on a line the user typed lets any pasted URL\n// pull remote media into the transcript.\nexport { MarkdownRenderer } from './components/rtc-widget/components/MarkdownRenderer';\n\n// The tokenizer behind it, for building a renderer from scratch.\nexport { parseInlineMarkdown, mediaKindForUrl, isSafeHref, compactUrl } from '../utils/inlineMarkdown';\nexport type { InlineNode, MediaKind } from '../utils/inlineMarkdown';\n\n// Additional hooks (for advanced usage)\nexport * from './hooks';\n\n// Re-export core types for convenience\nexport * from '../core/types';\n\n// Re-export helper functions explicitly\nexport { getDisconnectReasonMessage } from '../core/types';\n\n// Re-export core client for advanced usage\nexport { ActionResultAckError, ConvaiClient } from '../core';\n\n// Re-export LiveKit components for convenience (backward compatible)\nexport { RoomAudioRenderer as AudioRenderer, RoomContext as AudioContext } from '@livekit/components-react';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA,kCAAkC;AAClC,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE1D,aAAa;AACb,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEzD,uEAAuE;AACvE,oEAAoE;AACpE,8EAA8E;AAC9E,yCAAyC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,qDAAqD,CAAC;AAEvF,iEAAiE;AACjE,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAEvG,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExE,OAAO,EAAE,wBAAwB,EAAE,YAAY,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAGvG,wCAAwC;AACxC,cAAc,SAAS,CAAC;AAExB,uCAAuC;AACvC,cAAc,eAAe,CAAC;AAE9B,wCAAwC;AACxC,OAAO,EAAE,0BAA0B,EAAE,MAAM,eAAe,CAAC;AAE3D,2CAA2C;AAC3C,OAAO,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE7D,qEAAqE;AACrE,OAAO,EAAE,iBAAiB,IAAI,aAAa,EAAE,WAAW,IAAI,YAAY,EAAE,MAAM,2BAA2B,CAAC","sourcesContent":["// Main hook (backward compatible)\nexport { useConvaiClient } from './hooks/useConvaiClient';\n\n// Components\nexport { ConvaiWidget } from './components/ConvaiWidget';\n\n// Bubble renderer, for a custom chat UI that is not ConvaiWidget. Pass\n// `media={false}` on the user's own bubble: previews are a bot-side\n// affordance, and rendering them on a line the user typed lets any pasted URL\n// pull remote media into the transcript.\nexport { MarkdownRenderer } from './components/rtc-widget/components/MarkdownRenderer';\n\n// The tokenizer behind it, for building a renderer from scratch.\nexport { parseInlineMarkdown, mediaKindForUrl, isSafeHref, compactUrl } from '../utils/inlineMarkdown';\nexport type { InlineNode, MediaKind } from '../utils/inlineMarkdown';\nexport { linkKindForUrl, describeUrl } from '../utils/linkPresentation';\nexport type { LinkKind } from '../utils/linkPresentation';\nexport { resolveLinkPreviewCached, isCardWorthy, LINK_PREVIEW_TIMEOUT_MS } from '../utils/linkPreview';\nexport type { LinkPreviewMeta, LinkPreviewResolver } from '../utils/linkPreview';\n\n// Additional hooks (for advanced usage)\nexport * from './hooks';\n\n// Re-export core types for convenience\nexport * from '../core/types';\n\n// Re-export helper functions explicitly\nexport { getDisconnectReasonMessage } from '../core/types';\n\n// Re-export core client for advanced usage\nexport { ActionResultAckError, ConvaiClient } from '../core';\n\n// Re-export LiveKit components for convenience (backward compatible)\nexport { RoomAudioRenderer as AudioRenderer, RoomContext as AudioContext } from '@livekit/components-react';\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface LightboxOptions {
|
|
2
|
+
src: string;
|
|
3
|
+
alt: string;
|
|
4
|
+
/** Shown under the image; normally `describeUrl(src)`. */
|
|
5
|
+
caption: string;
|
|
6
|
+
/** Target of "Open original". */
|
|
7
|
+
href: string;
|
|
8
|
+
root: Document | ShadowRoot;
|
|
9
|
+
/** Where focus goes back to on close. Defaults to whatever was focused on open. */
|
|
10
|
+
returnFocusTo?: HTMLElement | null;
|
|
11
|
+
}
|
|
12
|
+
export interface LightboxHandle {
|
|
13
|
+
close(): void;
|
|
14
|
+
}
|
|
15
|
+
export declare function openLightbox(opts: LightboxOptions): LightboxHandle;
|
|
16
|
+
//# sourceMappingURL=lightbox.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lightbox.d.ts","sourceRoot":"","sources":["../../src/utils/lightbox.ts"],"names":[],"mappings":"AASA,MAAM,WAAW,eAAe;IAC9B,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,0DAA0D;IAC1D,OAAO,EAAE,MAAM,CAAC;IAChB,iCAAiC;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,QAAQ,GAAG,UAAU,CAAC;IAC5B,mFAAmF;IACnF,aAAa,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;CACpC;AAED,MAAM,WAAW,cAAc;IAC7B,KAAK,IAAI,IAAI,CAAC;CACf;AAWD,wBAAgB,YAAY,CAAC,IAAI,EAAE,eAAe,GAAG,cAAc,CAsFlE"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The image lightbox — one plain-DOM implementation used by the React
|
|
3
|
+
* renderer and the vanilla widget. Mounted into a Document or a ShadowRoot so
|
|
4
|
+
* `part` hooks and the injected keyframes resolve wherever the widget lives.
|
|
5
|
+
* One at a time: opening a second closes the first.
|
|
6
|
+
*/
|
|
7
|
+
import { glyph, presentationStyles, toCssText } from "./linkPresentation";
|
|
8
|
+
import { injectKeyframes } from "../vanilla/styles";
|
|
9
|
+
let current = null;
|
|
10
|
+
const el = (tag, part, style) => {
|
|
11
|
+
const node = document.createElement(tag);
|
|
12
|
+
node.setAttribute("part", part);
|
|
13
|
+
node.style.cssText = toCssText(style);
|
|
14
|
+
return node;
|
|
15
|
+
};
|
|
16
|
+
export function openLightbox(opts) {
|
|
17
|
+
current?.close();
|
|
18
|
+
injectKeyframes(opts.root);
|
|
19
|
+
const mount = opts.root instanceof ShadowRoot ? opts.root : opts.root.body;
|
|
20
|
+
const backdrop = el("div", "lightbox-backdrop", presentationStyles.lightboxBackdrop);
|
|
21
|
+
backdrop.setAttribute("role", "dialog");
|
|
22
|
+
backdrop.setAttribute("aria-modal", "true");
|
|
23
|
+
backdrop.setAttribute("aria-label", opts.alt || "Image preview");
|
|
24
|
+
const box = el("div", "lightbox", presentationStyles.lightbox);
|
|
25
|
+
const img = el("img", "lightbox-image", presentationStyles.lightboxImage);
|
|
26
|
+
img.src = opts.src;
|
|
27
|
+
img.alt = opts.alt;
|
|
28
|
+
const caption = el("span", "lightbox-caption", presentationStyles.lightboxCaption);
|
|
29
|
+
caption.textContent = opts.caption;
|
|
30
|
+
const controls = el("div", "lightbox-controls", presentationStyles.lightboxControls);
|
|
31
|
+
const open = el("a", "lightbox-open", presentationStyles.lightboxButton);
|
|
32
|
+
open.href = opts.href;
|
|
33
|
+
open.target = "_blank";
|
|
34
|
+
open.rel = "noopener noreferrer";
|
|
35
|
+
open.innerHTML = `${glyph("external")}<span>Open original</span>`;
|
|
36
|
+
const close = el("button", "lightbox-close", presentationStyles.lightboxButton);
|
|
37
|
+
close.type = "button";
|
|
38
|
+
close.setAttribute("aria-label", "Close image preview");
|
|
39
|
+
close.innerHTML = glyph("close");
|
|
40
|
+
controls.append(open, close);
|
|
41
|
+
// A character can invent a URL; the card already collapsed for that case,
|
|
42
|
+
// but the full-size load can still fail on its own. Keep the way out visible.
|
|
43
|
+
img.addEventListener("error", () => {
|
|
44
|
+
const fallback = el("div", "lightbox-fallback", presentationStyles.lightboxFallback);
|
|
45
|
+
fallback.textContent = "Image could not be loaded";
|
|
46
|
+
img.replaceWith(fallback);
|
|
47
|
+
});
|
|
48
|
+
const previousOverflow = document.body.style.overflow;
|
|
49
|
+
const restoreFocus = opts.returnFocusTo ?? document.activeElement;
|
|
50
|
+
const activeElement = () => opts.root instanceof ShadowRoot ? opts.root.activeElement : document.activeElement;
|
|
51
|
+
const onKey = (e) => {
|
|
52
|
+
if (e.key === "Escape") {
|
|
53
|
+
e.preventDefault();
|
|
54
|
+
handle.close();
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
if (e.key === "Tab") {
|
|
58
|
+
// Trap between the two controls; there is nothing else to reach.
|
|
59
|
+
const active = activeElement();
|
|
60
|
+
if (e.shiftKey && active === open) {
|
|
61
|
+
e.preventDefault();
|
|
62
|
+
close.focus();
|
|
63
|
+
}
|
|
64
|
+
else if (!e.shiftKey && active === close) {
|
|
65
|
+
e.preventDefault();
|
|
66
|
+
open.focus();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
const handle = {
|
|
71
|
+
close() {
|
|
72
|
+
if (current !== handle)
|
|
73
|
+
return;
|
|
74
|
+
current = null;
|
|
75
|
+
document.removeEventListener("keydown", onKey, true);
|
|
76
|
+
backdrop.remove();
|
|
77
|
+
document.body.style.overflow = previousOverflow;
|
|
78
|
+
restoreFocus?.focus?.();
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
backdrop.addEventListener("click", (e) => {
|
|
82
|
+
if (e.target === backdrop)
|
|
83
|
+
handle.close();
|
|
84
|
+
});
|
|
85
|
+
close.addEventListener("click", () => handle.close());
|
|
86
|
+
document.addEventListener("keydown", onKey, true);
|
|
87
|
+
box.append(controls, img, caption);
|
|
88
|
+
backdrop.appendChild(box);
|
|
89
|
+
mount.appendChild(backdrop);
|
|
90
|
+
document.body.style.overflow = "hidden";
|
|
91
|
+
current = handle;
|
|
92
|
+
close.focus();
|
|
93
|
+
return handle;
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=lightbox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lightbox.js","sourceRoot":"","sources":["../../src/utils/lightbox.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,KAAK,EAAE,kBAAkB,EAAE,SAAS,EAAoB,MAAM,oBAAoB,CAAC;AAC5F,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAkBpD,IAAI,OAAO,GAA0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E,CAAC;QAC1B,CAAC;KACF,CAAC;IAEF,QAAQ,CAAC,gBAAgB,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE;QACvC,IAAI,CAAC,CAAC,MAAM,KAAK,QAAQ;YAAE,MAAM,CAAC,KAAK,EAAE,CAAC;IAC5C,CAAC,CAAC,CAAC;IACH,KAAK,CAAC,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;IACtD,QAAQ,CAAC,gBAAgB,CAAC,SAAS,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;IAElD,GAAG,CAAC,MAAM,CAAC,QAAQ,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;IACnC,QAAQ,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IAC1B,KAAK,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;IAC5B,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAG,QAAQ,CAAC;IACxC,OAAO,GAAG,MAAM,CAAC;IACjB,KAAK,CAAC,KAAK,EAAE,CAAC;IACd,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["/**\n * The image lightbox — one plain-DOM implementation used by the React\n * renderer and the vanilla widget. Mounted into a Document or a ShadowRoot so\n * `part` hooks and the injected keyframes resolve wherever the widget lives.\n * One at a time: opening a second closes the first.\n */\nimport { glyph, presentationStyles, toCssText, type StyleObject } from \"./linkPresentation\";\nimport { injectKeyframes } from \"../vanilla/styles\";\n\nexport interface LightboxOptions {\n src: string;\n alt: string;\n /** Shown under the image; normally `describeUrl(src)`. */\n caption: string;\n /** Target of \"Open original\". */\n href: string;\n root: Document | ShadowRoot;\n /** Where focus goes back to on close. Defaults to whatever was focused on open. */\n returnFocusTo?: HTMLElement | null;\n}\n\nexport interface LightboxHandle {\n close(): void;\n}\n\nlet current: LightboxHandle | null = null;\n\nconst el = <K extends keyof HTMLElementTagNameMap>(tag: K, part: string, style: StyleObject) => {\n const node = document.createElement(tag);\n node.setAttribute(\"part\", part);\n node.style.cssText = toCssText(style);\n return node;\n};\n\nexport function openLightbox(opts: LightboxOptions): LightboxHandle {\n current?.close();\n injectKeyframes(opts.root);\n\n const mount: Node = opts.root instanceof ShadowRoot ? opts.root : opts.root.body;\n const backdrop = el(\"div\", \"lightbox-backdrop\", presentationStyles.lightboxBackdrop);\n backdrop.setAttribute(\"role\", \"dialog\");\n backdrop.setAttribute(\"aria-modal\", \"true\");\n backdrop.setAttribute(\"aria-label\", opts.alt || \"Image preview\");\n\n const box = el(\"div\", \"lightbox\", presentationStyles.lightbox);\n const img = el(\"img\", \"lightbox-image\", presentationStyles.lightboxImage);\n img.src = opts.src;\n img.alt = opts.alt;\n const caption = el(\"span\", \"lightbox-caption\", presentationStyles.lightboxCaption);\n caption.textContent = opts.caption;\n\n const controls = el(\"div\", \"lightbox-controls\", presentationStyles.lightboxControls);\n const open = el(\"a\", \"lightbox-open\", presentationStyles.lightboxButton);\n open.href = opts.href;\n open.target = \"_blank\";\n open.rel = \"noopener noreferrer\";\n open.innerHTML = `${glyph(\"external\")}<span>Open original</span>`;\n const close = el(\"button\", \"lightbox-close\", presentationStyles.lightboxButton);\n close.type = \"button\";\n close.setAttribute(\"aria-label\", \"Close image preview\");\n close.innerHTML = glyph(\"close\");\n controls.append(open, close);\n\n // A character can invent a URL; the card already collapsed for that case,\n // but the full-size load can still fail on its own. Keep the way out visible.\n img.addEventListener(\"error\", () => {\n const fallback = el(\"div\", \"lightbox-fallback\", presentationStyles.lightboxFallback);\n fallback.textContent = \"Image could not be loaded\";\n img.replaceWith(fallback);\n });\n\n const previousOverflow = document.body.style.overflow;\n const restoreFocus = opts.returnFocusTo ?? (document.activeElement as HTMLElement | null);\n\n const activeElement = () =>\n opts.root instanceof ShadowRoot ? opts.root.activeElement : document.activeElement;\n\n const onKey = (e: KeyboardEvent) => {\n if (e.key === \"Escape\") {\n e.preventDefault();\n handle.close();\n return;\n }\n if (e.key === \"Tab\") {\n // Trap between the two controls; there is nothing else to reach.\n const active = activeElement();\n if (e.shiftKey && active === open) {\n e.preventDefault();\n close.focus();\n } else if (!e.shiftKey && active === close) {\n e.preventDefault();\n open.focus();\n }\n }\n };\n\n const handle: LightboxHandle = {\n close() {\n if (current !== handle) return;\n current = null;\n document.removeEventListener(\"keydown\", onKey, true);\n backdrop.remove();\n document.body.style.overflow = previousOverflow;\n restoreFocus?.focus?.();\n },\n };\n\n backdrop.addEventListener(\"click\", (e) => {\n if (e.target === backdrop) handle.close();\n });\n close.addEventListener(\"click\", () => handle.close());\n document.addEventListener(\"keydown\", onKey, true);\n\n box.append(controls, img, caption);\n backdrop.appendChild(box);\n mount.appendChild(backdrop);\n document.body.style.overflow = \"hidden\";\n current = handle;\n close.focus();\n return handle;\n}\n"]}
|