@convai/web-sdk 1.9.0-beta.1 → 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 -23
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +19 -18
- 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 +7 -0
- package/dist/react/components/rtc-widget/components/MarkdownRenderer.d.ts.map +1 -1
- package/dist/react/components/rtc-widget/components/MarkdownRenderer.js +13 -9
- 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 -11
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +10 -9
- package/dist/react/index.js.map +1 -1
- package/dist/utils/lightbox.js +2 -2
- package/dist/utils/linkPresentation.d.ts +7 -0
- package/dist/utils/linkPresentation.d.ts.map +1 -1
- package/dist/utils/linkPresentation.js +58 -1
- package/dist/utils/linkPresentation.js.map +1 -1
- 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 +76 -9
- 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 -11
- package/dist/vanilla/index.d.ts.map +1 -1
- package/dist/vanilla/index.js +9 -8
- package/dist/vanilla/index.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 +1 -1
|
@@ -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,13 +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 { linkKindForUrl, describeUrl } from '../utils/linkPresentation
|
|
7
|
-
export type { LinkKind } from '../utils/linkPresentation
|
|
8
|
-
export
|
|
9
|
-
export
|
|
10
|
-
export
|
|
11
|
-
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';
|
|
12
14
|
export { RoomAudioRenderer as AudioRenderer, RoomContext as AudioContext } from '@livekit/components-react';
|
|
13
15
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","s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E,YAAY,EAAE,MAAM,SAAS,CAAC;AAG7D,OAAO,EAAE,iBAAiB,IAAI,aAAa,EAAE,WAAW,IAAI,YAAY,EAAE,MAAM,2BAA2B,CAAC"}
|
package/dist/react/index.js
CHANGED
|
@@ -1,23 +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
|
|
12
|
-
export { linkKindForUrl, describeUrl } from '../utils/linkPresentation
|
|
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';
|
|
13
14
|
// Additional hooks (for advanced usage)
|
|
14
|
-
export * from './hooks
|
|
15
|
+
export * from './hooks';
|
|
15
16
|
// Re-export core types for convenience
|
|
16
|
-
export * from '../core/types
|
|
17
|
+
export * from '../core/types';
|
|
17
18
|
// Re-export helper functions explicitly
|
|
18
|
-
export { getDisconnectReasonMessage } from '../core/types
|
|
19
|
+
export { getDisconnectReasonMessage } from '../core/types';
|
|
19
20
|
// Re-export core client for advanced usage
|
|
20
|
-
export { ActionResultAckError, ConvaiClient } from '../core
|
|
21
|
+
export { ActionResultAckError, ConvaiClient } from '../core';
|
|
21
22
|
// Re-export LiveKit components for convenience (backward compatible)
|
|
22
23
|
export { RoomAudioRenderer as AudioRenderer, RoomContext as AudioContext } from '@livekit/components-react';
|
|
23
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;AAEvG,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;
|
|
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"]}
|
package/dist/utils/lightbox.js
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* `part` hooks and the injected keyframes resolve wherever the widget lives.
|
|
5
5
|
* One at a time: opening a second closes the first.
|
|
6
6
|
*/
|
|
7
|
-
import { glyph, presentationStyles, toCssText } from "./linkPresentation
|
|
8
|
-
import { injectKeyframes } from "../vanilla/styles
|
|
7
|
+
import { glyph, presentationStyles, toCssText } from "./linkPresentation";
|
|
8
|
+
import { injectKeyframes } from "../vanilla/styles";
|
|
9
9
|
let current = null;
|
|
10
10
|
const el = (tag, part, style) => {
|
|
11
11
|
const node = document.createElement(tag);
|
|
@@ -65,5 +65,12 @@ export declare const presentationStyles: {
|
|
|
65
65
|
lightboxControls: StyleObject;
|
|
66
66
|
lightboxButton: StyleObject;
|
|
67
67
|
lightboxFallback: StyleObject;
|
|
68
|
+
siteCard: StyleObject;
|
|
69
|
+
siteHeader: StyleObject;
|
|
70
|
+
siteFavicon: StyleObject;
|
|
71
|
+
siteName: StyleObject;
|
|
72
|
+
siteTitle: StyleObject;
|
|
73
|
+
siteDescription: StyleObject;
|
|
74
|
+
siteImage: StyleObject;
|
|
68
75
|
};
|
|
69
76
|
//# sourceMappingURL=linkPresentation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linkPresentation.d.ts","sourceRoot":"","sources":["../../src/utils/linkPresentation.ts"],"names":[],"mappings":"AAYA,MAAM,MAAM,QAAQ,GAChB,KAAK,GACL,OAAO,GACP,OAAO,GACP,UAAU,GACV,OAAO,GACP,OAAO,GACP,KAAK,GACL,KAAK,CAAC;AAMV,kEAAkE;AAClE,eAAO,MAAM,kBAAkB,QAAQ,CAAC;AACxC,gEAAgE;AAChE,eAAO,MAAM,qBAAqB,IAAI,CAAC;AAEvC;;;;GAIG;AAC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;cAOX,WAAW;aAeX,WAAW;kBACwD,WAAW;WAY9E,WAAW;sBAaX,WAAW;cAUX,WAAW;mBAQX,WAAW;qBAQX,WAAW;sBAQX,WAAW;oBAaX,WAAW;sBAOX,WAAW;cAcX,WAAW;gBAC8D,WAAW;iBAOpF,WAAW;cAOX,WAAW;eAUX,WAAW;qBAUX,WAAW;eAQX,WAAW;CACjB,CAAC"}
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* failure budget a preview gets before it collapses. Pure functions and
|
|
9
9
|
* style objects only; no DOM, so it is testable without a renderer.
|
|
10
10
|
*/
|
|
11
|
-
import { compactUrl } from "./inlineMarkdown
|
|
11
|
+
import { compactUrl } from "./inlineMarkdown";
|
|
12
12
|
const IMAGE_EXT = /\.(png|jpe?g|gif|webp|avif)$/i;
|
|
13
13
|
const VIDEO_EXT = /\.(mp4|webm|mov|ogg)$/i;
|
|
14
14
|
const DOCUMENT_EXT = /\.(pdf|docx?|xlsx?|csv|pptx?|txt|md|zip)$/i;
|
|
@@ -122,6 +122,7 @@ const UNITLESS = new Set([
|
|
|
122
122
|
"lineHeight",
|
|
123
123
|
"fontWeight",
|
|
124
124
|
"order",
|
|
125
|
+
"WebkitLineClamp",
|
|
125
126
|
]);
|
|
126
127
|
/** `{ marginTop: 6 }` → `margin-top: 6px;` — the vanilla widget authors cssText. */
|
|
127
128
|
export function toCssText(style) {
|
|
@@ -354,5 +355,61 @@ export const presentationStyles = {
|
|
|
354
355
|
border: "1px dashed rgba(255,255,255,.3)",
|
|
355
356
|
borderRadius: RADIUS,
|
|
356
357
|
},
|
|
358
|
+
// Site card: Open Graph metadata under a plain web link. Same chrome as the
|
|
359
|
+
// file card so the three card kinds read as one family.
|
|
360
|
+
siteCard: {
|
|
361
|
+
display: "block",
|
|
362
|
+
marginTop: 6,
|
|
363
|
+
maxWidth: 320,
|
|
364
|
+
padding: "8px 10px",
|
|
365
|
+
borderRadius: RADIUS,
|
|
366
|
+
background: chrome(6),
|
|
367
|
+
boxShadow: `inset 0 0 0 1px ${chrome(10)}`,
|
|
368
|
+
color: "inherit",
|
|
369
|
+
textDecoration: "none",
|
|
370
|
+
},
|
|
371
|
+
siteHeader: { display: "flex", alignItems: "center", gap: 6, minWidth: 0 },
|
|
372
|
+
siteFavicon: {
|
|
373
|
+
width: 16,
|
|
374
|
+
height: 16,
|
|
375
|
+
flex: "0 0 auto",
|
|
376
|
+
borderRadius: 3,
|
|
377
|
+
objectFit: "contain",
|
|
378
|
+
},
|
|
379
|
+
siteName: {
|
|
380
|
+
fontSize: 12,
|
|
381
|
+
fontWeight: 700,
|
|
382
|
+
whiteSpace: "nowrap",
|
|
383
|
+
overflow: "hidden",
|
|
384
|
+
textOverflow: "ellipsis",
|
|
385
|
+
},
|
|
386
|
+
siteTitle: {
|
|
387
|
+
display: "block",
|
|
388
|
+
marginTop: 2,
|
|
389
|
+
fontSize: 13,
|
|
390
|
+
fontWeight: 600,
|
|
391
|
+
color: ACCENT,
|
|
392
|
+
whiteSpace: "nowrap",
|
|
393
|
+
overflow: "hidden",
|
|
394
|
+
textOverflow: "ellipsis",
|
|
395
|
+
},
|
|
396
|
+
siteDescription: {
|
|
397
|
+
display: "-webkit-box",
|
|
398
|
+
WebkitBoxOrient: "vertical",
|
|
399
|
+
WebkitLineClamp: 2,
|
|
400
|
+
overflow: "hidden",
|
|
401
|
+
marginTop: 2,
|
|
402
|
+
fontSize: 12,
|
|
403
|
+
opacity: 0.75,
|
|
404
|
+
lineHeight: 1.35,
|
|
405
|
+
},
|
|
406
|
+
siteImage: {
|
|
407
|
+
display: "block",
|
|
408
|
+
width: "100%",
|
|
409
|
+
aspectRatio: "16 / 9",
|
|
410
|
+
objectFit: "cover",
|
|
411
|
+
marginTop: 8,
|
|
412
|
+
borderRadius: 6,
|
|
413
|
+
},
|
|
357
414
|
};
|
|
358
415
|
//# sourceMappingURL=linkPresentation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linkPresentation.js","sourceRoot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a,EAAE,QAAQ;QACvB,UAAU,EAAE,QAAQ;QACpB,GAAG,EAAE,EAAE;QACP,QAAQ,EAAE,MAAM;QAChB,SAAS,EAAE,MAAM;QACjB,KAAK,EAAE,MAAM;KACC;IAChB,aAAa,EAAE;QACb,OAAO,EAAE,OAAO;QAChB,QAAQ,EAAE,MAAM;QAChB,SAAS,EAAE,mBAAmB;QAC9B,SAAS,EAAE,SAAS;QACpB,YAAY,EAAE,MAAM;QACpB,UAAU,EAAE,MAAM;KACJ;IAChB,eAAe,EAAE;QACf,QAAQ,EAAE,EAAE;QACZ,OAAO,EAAE,GAAG;QACZ,QAAQ,EAAE,MAAM;QAChB,UAAU,EAAE,QAAQ;QACpB,QAAQ,EAAE,QAAQ;QAClB,YAAY,EAAE,UAAU;KACV;IAChB,gBAAgB,EAAE;QAChB,QAAQ,EAAE,UAAU;QACpB,GAAG,EAAE,CAAC,CAAC;QACP,KAAK,EAAE,CAAC,CAAC;QACT,SAAS,EAAE,mBAAmB;QAC9B,OAAO,EAAE,MAAM;QACf,GAAG,EAAE,CAAC;KACQ;IAChB,cAAc,EAAE;QACd,OAAO,EAAE,aAAa;QACtB,UAAU,EAAE,QAAQ;QACpB,GAAG,EAAE,CAAC;QACN,OAAO,EAAE,UAAU;QACnB,YAAY,EAAE,GAAG;QACjB,MAAM,EAAE,iCAAiC;QACzC,UAAU,EAAE,gBAAgB;QAC5B,KAAK,EAAE,MAAM;QACb,QAAQ,EAAE,EAAE;QACZ,MAAM,EAAE,SAAS;QACjB,cAAc,EAAE,MAAM;KACR;IAChB,gBAAgB,EAAE;QAChB,OAAO,EAAE,WAAW;QACpB,QAAQ,EAAE,EAAE;QACZ,OAAO,EAAE,GAAG;QACZ,MAAM,EAAE,iCAAiC;QACzC,YAAY,EAAE,MAAM;KACN;CACjB,CAAC","sourcesContent":["/**\n * How a link the character sent should look and behave — shared by the React\n * `MarkdownRenderer` and the vanilla widget so the two cannot drift.\n *\n * The tokenizer (`inlineMarkdown.ts`) decides what IS a link and keeps\n * unsafe schemes off anchors. This module decides how a safe link is\n * presented: which kind of card or chip, what the hover title says, and the\n * failure budget a preview gets before it collapses. Pure functions and\n * style objects only; no DOM, so it is testable without a renderer.\n */\nimport { compactUrl } from \"./inlineMarkdown\";\n\nexport type LinkKind =\n | \"web\"\n | \"image\"\n | \"video\"\n | \"document\"\n | \"email\"\n | \"phone\"\n | \"sms\"\n | \"ftp\";\n\nconst IMAGE_EXT = /\\.(png|jpe?g|gif|webp|avif)$/i;\nconst VIDEO_EXT = /\\.(mp4|webm|mov|ogg)$/i;\nconst DOCUMENT_EXT = /\\.(pdf|docx?|xlsx?|csv|pptx?|txt|md|zip)$/i;\n\n/** How long a card may shimmer before it is treated as failed. */\nexport const PREVIEW_TIMEOUT_MS = 12000;\n/** Cards beyond this in one message render as plain anchors. */\nexport const MAX_CARDS_PER_MESSAGE = 6;\n\n/**\n * The presentation class of a safe URL. Distinct from `mediaKindForUrl`,\n * which stays the embed hint (`image | video | null`) that custom renderers\n * already branch on; this adds the kinds that get a chip or a file card.\n */\nexport function linkKindForUrl(url: string): LinkKind {\n const scheme = /^([a-z][a-z0-9+.-]*):/i.exec(url)?.[1]?.toLowerCase();\n if (scheme === \"mailto\") return \"email\";\n if (scheme === \"tel\") return \"phone\";\n if (scheme === \"sms\") return \"sms\";\n if (scheme === \"ftp\" || scheme === \"ftps\") return \"ftp\";\n let pathname: string;\n try {\n pathname = new URL(url).pathname;\n } catch {\n return \"web\";\n }\n if (IMAGE_EXT.test(pathname)) return \"image\";\n if (VIDEO_EXT.test(pathname)) return \"video\";\n if (DOCUMENT_EXT.test(pathname)) return \"document\";\n return \"web\";\n}\n\n/** `cdn.example.com/a/b/c.png` → `cdn.example.com · c.png` */\nexport function describeUrl(url: string): string {\n try {\n const { host, pathname } = new URL(url);\n const file = pathname.split(\"/\").filter(Boolean).pop();\n return file ? `${host} · ${file}` : host;\n } catch {\n return compactUrl(url);\n }\n}\n\n/** The last path segment, for captions and aria labels; the whole URL when unparseable. */\nexport function fileNameOf(url: string): string {\n try {\n return new URL(url).pathname.split(\"/\").filter(Boolean).pop() ?? url;\n } catch {\n return url;\n }\n}\n\n/** Upper-case extension for the file tile; `FILE` when there is none worth showing. */\nexport function documentBadge(url: string): string {\n const ext = /\\.([a-z0-9]{1,5})$/i.exec(fileNameOf(url))?.[1];\n return ext ? ext.toUpperCase() : \"FILE\";\n}\n\n/** `mailto:a@b.com?subject=x` → `a@b.com`; `tel:+1` → `+1` */\nexport function contactLabel(href: string): string {\n return href.replace(/^[a-z][a-z0-9+.-]*:/i, \"\").split(\"?\")[0];\n}\n\n/**\n * The `title` attribute for an anchor of this kind, or nothing when it would\n * only repeat the visible label. For a web link this is how a compacted or\n * labelled URL reveals its real target before anyone clicks.\n */\nexport function hoverTitle(kind: LinkKind, href: string, label: string): string | undefined {\n switch (kind) {\n case \"email\":\n return `Send an email to ${contactLabel(href)}`;\n case \"phone\":\n return `Call ${contactLabel(href)}`;\n case \"sms\":\n return `Send a text to ${contactLabel(href)}`;\n case \"ftp\":\n return \"FTP link — most browsers no longer open these\";\n default:\n return label === href ? undefined : href;\n }\n}\n\n/** An `http:` asset cannot load on an `https:` page; do not even try. */\nexport function isMixedContent(\n src: string,\n pageProtocol: string = typeof location === \"undefined\" ? \"https:\" : location.protocol,\n): boolean {\n return pageProtocol === \"https:\" && /^http:/i.test(src);\n}\n\nexport type GlyphName = \"document\" | \"email\" | \"phone\" | \"sms\" | \"ftp\" | \"zoom\" | \"close\" | \"external\";\n\nconst SVG_OPEN =\n '<svg aria-hidden=\"true\" focusable=\"false\" viewBox=\"0 0 24 24\" width=\"1em\" height=\"1em\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\">';\n\nconst GLYPH_PATHS: Record<GlyphName, string> = {\n document:\n '<path d=\"M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z\"/><path d=\"M14 3v5h5\"/>',\n email: '<rect x=\"3\" y=\"5\" width=\"18\" height=\"14\" rx=\"2\"/><path d=\"m3 7 9 6 9-6\"/>',\n phone:\n '<path d=\"M22 16.9v3a2 2 0 0 1-2.2 2 19.8 19.8 0 0 1-8.6-3.1 19.5 19.5 0 0 1-6-6A19.8 19.8 0 0 1 2.1 4.2 2 2 0 0 1 4.1 2h3a2 2 0 0 1 2 1.7c.1.9.4 1.8.7 2.7a2 2 0 0 1-.5 2.1L8.1 9.7a16 16 0 0 0 6 6l1.3-1.3a2 2 0 0 1 2.1-.4c.9.3 1.8.6 2.7.7a2 2 0 0 1 1.8 2z\"/>',\n sms: '<path d=\"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z\"/>',\n ftp: '<path d=\"M4 17V7l8 5 8-5v10\"/><path d=\"M4 7h16\"/>',\n zoom: '<circle cx=\"11\" cy=\"11\" r=\"7\"/><path d=\"m21 21-4.3-4.3M11 8v6M8 11h6\"/>',\n close: '<path d=\"M18 6 6 18M6 6l12 12\"/>',\n external:\n '<path d=\"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6\"/><path d=\"M15 3h6v6M10 14 21 3\"/>',\n};\n\n/** Inline SVG for a glyph. Strings, not elements, so both renderers can use them. */\nexport function glyph(name: GlyphName): string {\n return `${SVG_OPEN}${GLYPH_PATHS[name]}</svg>`;\n}\n\nexport type StyleObject = Record<string, string | number>;\n\nconst UNITLESS = new Set([\n \"opacity\",\n \"zIndex\",\n \"flex\",\n \"flexGrow\",\n \"flexShrink\",\n \"lineHeight\",\n \"fontWeight\",\n \"order\",\n]);\n\n/** `{ marginTop: 6 }` → `margin-top: 6px;` — the vanilla widget authors cssText. */\nexport function toCssText(style: StyleObject): string {\n return Object.entries(style)\n .map(([k, v]) => {\n const prop = k.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`);\n const val = typeof v === \"number\" && !UNITLESS.has(k) ? `${v}px` : String(v);\n return `${prop}: ${val};`;\n })\n .join(\" \");\n}\n\nconst RADIUS = 8;\nconst ACCENT = \"#10b981\";\nconst chrome = (pct: number) => `color-mix(in srgb, currentColor ${pct}%, transparent)`;\n\n/**\n * Every visual the link layer draws, as one style object per element. React\n * spreads these; vanilla serialises them with `toCssText`. Chrome derives from\n * `currentColor` because the widget sits on a host page whose background it\n * cannot know.\n */\nexport const presentationStyles = {\n link: {\n color: ACCENT,\n textDecoration: \"underline\",\n wordBreak: \"break-all\",\n borderRadius: 2,\n } as StyleObject,\n /** Applied on focus-visible by the renderer; kept here so both agree. */\n linkFocus: { outline: `2px solid ${chrome(60)}`, outlineOffset: 2 } as StyleObject,\n blocked: { opacity: 0.75, textDecoration: \"underline dotted\", cursor: \"help\" } as StyleObject,\n\n card: {\n display: \"block\",\n position: \"relative\",\n marginTop: 6,\n maxWidth: 320,\n aspectRatio: \"16 / 10\",\n borderRadius: RADIUS,\n overflow: \"hidden\",\n background: chrome(6),\n boxShadow: `inset 0 0 0 1px ${chrome(10)}`,\n } as StyleObject,\n cardButton: { cursor: \"zoom-in\" } as StyleObject,\n zoom: {\n position: \"absolute\",\n right: 6,\n bottom: 6,\n width: 24,\n height: 24,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n borderRadius: 6,\n background: \"rgba(0,0,0,.55)\",\n color: \"#fff\",\n fontSize: 14,\n pointerEvents: \"none\",\n } as StyleObject,\n media: {\n display: \"block\",\n width: \"100%\",\n height: \"100%\",\n objectFit: \"cover\",\n borderRadius: RADIUS,\n transition: \"opacity .18s ease\",\n } as StyleObject,\n videoMedia: { objectFit: \"contain\" } as StyleObject,\n skeleton: {\n position: \"absolute\",\n inset: 0,\n borderRadius: RADIUS,\n background: chrome(8),\n backgroundImage: `linear-gradient(90deg, transparent, ${chrome(12)}, transparent)`,\n backgroundSize: \"200% 100%\",\n animation: \"convai-preview-shimmer 1.4s ease-in-out infinite\",\n } as StyleObject,\n caption: {\n display: \"block\",\n marginTop: 4,\n fontSize: 11,\n opacity: 0.7,\n whiteSpace: \"nowrap\",\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n } as StyleObject,\n unavailable: {\n display: \"block\",\n marginTop: 6,\n fontSize: 11,\n opacity: 0.55,\n fontStyle: \"italic\",\n whiteSpace: \"nowrap\",\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n } as StyleObject,\n\n fileCard: {\n display: \"flex\",\n alignItems: \"center\",\n gap: 10,\n marginTop: 6,\n maxWidth: 320,\n padding: \"8px 10px\",\n borderRadius: RADIUS,\n background: chrome(6),\n boxShadow: `inset 0 0 0 1px ${chrome(10)}`,\n color: \"inherit\",\n textDecoration: \"none\",\n } as StyleObject,\n fileIcon: {\n position: \"relative\",\n flex: \"0 0 auto\",\n width: 36,\n height: 44,\n display: \"flex\",\n alignItems: \"flex-end\",\n justifyContent: \"center\",\n paddingBottom: 4,\n boxSizing: \"border-box\",\n borderRadius: 4,\n background: chrome(10),\n color: ACCENT,\n fontSize: 9,\n fontWeight: 700,\n letterSpacing: \".04em\",\n } as StyleObject,\n fileBody: { minWidth: 0, display: \"flex\", flexDirection: \"column\", gap: 2 } as StyleObject,\n fileName: {\n fontSize: 13,\n fontWeight: 600,\n whiteSpace: \"nowrap\",\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n } as StyleObject,\n fileMeta: {\n fontSize: 11,\n opacity: 0.7,\n whiteSpace: \"nowrap\",\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n } as StyleObject,\n\n contact: {\n display: \"inline-flex\",\n alignItems: \"center\",\n gap: 4,\n padding: \"1px 8px 1px 6px\",\n borderRadius: 999,\n background: chrome(8),\n color: ACCENT,\n textDecoration: \"none\",\n fontSize: \"0.95em\",\n lineHeight: 1.6,\n verticalAlign: \"baseline\",\n maxWidth: \"100%\",\n } as StyleObject,\n contactGlyph: { display: \"inline-flex\", fontSize: 13, opacity: 0.9 } as StyleObject,\n badge: {\n display: \"inline-block\",\n marginLeft: 4,\n padding: \"0 4px\",\n borderRadius: 3,\n fontSize: 9,\n fontWeight: 700,\n letterSpacing: \".04em\",\n verticalAlign: \"middle\",\n background: chrome(10),\n opacity: 0.8,\n } as StyleObject,\n\n lightboxBackdrop: {\n position: \"fixed\",\n inset: 0,\n zIndex: 2147483000,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n background: \"rgba(0,0,0,.82)\",\n padding: 24,\n boxSizing: \"border-box\",\n animation: \"convai-lightbox-in .16s ease-out\",\n } as StyleObject,\n lightbox: {\n position: \"relative\",\n display: \"flex\",\n flexDirection: \"column\",\n alignItems: \"center\",\n gap: 10,\n maxWidth: \"90vw\",\n maxHeight: \"90vh\",\n color: \"#fff\",\n } as StyleObject,\n lightboxImage: {\n display: \"block\",\n maxWidth: \"90vw\",\n maxHeight: \"calc(90vh - 72px)\",\n objectFit: \"contain\",\n borderRadius: RADIUS,\n background: \"#000\",\n } as StyleObject,\n lightboxCaption: {\n fontSize: 12,\n opacity: 0.8,\n maxWidth: \"90vw\",\n whiteSpace: \"nowrap\",\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n } as StyleObject,\n lightboxControls: {\n position: \"absolute\",\n top: -4,\n right: -4,\n transform: \"translateY(-100%)\",\n display: \"flex\",\n gap: 6,\n } as StyleObject,\n lightboxButton: {\n display: \"inline-flex\",\n alignItems: \"center\",\n gap: 6,\n padding: \"6px 10px\",\n borderRadius: 999,\n border: \"1px solid rgba(255,255,255,.25)\",\n background: \"rgba(0,0,0,.5)\",\n color: \"#fff\",\n fontSize: 12,\n cursor: \"pointer\",\n textDecoration: \"none\",\n } as StyleObject,\n lightboxFallback: {\n padding: \"32px 40px\",\n fontSize: 13,\n opacity: 0.8,\n border: \"1px dashed rgba(255,255,255,.3)\",\n borderRadius: RADIUS,\n } as StyleObject,\n};\n"]}
|
|
1
|
+
{"version":3,"file":"linkPresentation.js","sourceRoot":"","sources":["../../src/utils/linkPresentation.ts"],"names":[],"mappings":"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\n * `MarkdownRenderer` and the vanilla widget so the two cannot drift.\n *\n * The tokenizer (`inlineMarkdown.ts`) decides what IS a link and keeps\n * unsafe schemes off anchors. This module decides how a safe link is\n * presented: which kind of card or chip, what the hover title says, and the\n * failure budget a preview gets before it collapses. Pure functions and\n * style objects only; no DOM, so it is testable without a renderer.\n */\nimport { compactUrl } from \"./inlineMarkdown\";\n\nexport type LinkKind =\n | \"web\"\n | \"image\"\n | \"video\"\n | \"document\"\n | \"email\"\n | \"phone\"\n | \"sms\"\n | \"ftp\";\n\nconst IMAGE_EXT = /\\.(png|jpe?g|gif|webp|avif)$/i;\nconst VIDEO_EXT = /\\.(mp4|webm|mov|ogg)$/i;\nconst DOCUMENT_EXT = /\\.(pdf|docx?|xlsx?|csv|pptx?|txt|md|zip)$/i;\n\n/** How long a card may shimmer before it is treated as failed. */\nexport const PREVIEW_TIMEOUT_MS = 12000;\n/** Cards beyond this in one message render as plain anchors. */\nexport const MAX_CARDS_PER_MESSAGE = 6;\n\n/**\n * The presentation class of a safe URL. Distinct from `mediaKindForUrl`,\n * which stays the embed hint (`image | video | null`) that custom renderers\n * already branch on; this adds the kinds that get a chip or a file card.\n */\nexport function linkKindForUrl(url: string): LinkKind {\n const scheme = /^([a-z][a-z0-9+.-]*):/i.exec(url)?.[1]?.toLowerCase();\n if (scheme === \"mailto\") return \"email\";\n if (scheme === \"tel\") return \"phone\";\n if (scheme === \"sms\") return \"sms\";\n if (scheme === \"ftp\" || scheme === \"ftps\") return \"ftp\";\n let pathname: string;\n try {\n pathname = new URL(url).pathname;\n } catch {\n return \"web\";\n }\n if (IMAGE_EXT.test(pathname)) return \"image\";\n if (VIDEO_EXT.test(pathname)) return \"video\";\n if (DOCUMENT_EXT.test(pathname)) return \"document\";\n return \"web\";\n}\n\n/** `cdn.example.com/a/b/c.png` → `cdn.example.com · c.png` */\nexport function describeUrl(url: string): string {\n try {\n const { host, pathname } = new URL(url);\n const file = pathname.split(\"/\").filter(Boolean).pop();\n return file ? `${host} · ${file}` : host;\n } catch {\n return compactUrl(url);\n }\n}\n\n/** The last path segment, for captions and aria labels; the whole URL when unparseable. */\nexport function fileNameOf(url: string): string {\n try {\n return new URL(url).pathname.split(\"/\").filter(Boolean).pop() ?? url;\n } catch {\n return url;\n }\n}\n\n/** Upper-case extension for the file tile; `FILE` when there is none worth showing. */\nexport function documentBadge(url: string): string {\n const ext = /\\.([a-z0-9]{1,5})$/i.exec(fileNameOf(url))?.[1];\n return ext ? ext.toUpperCase() : \"FILE\";\n}\n\n/** `mailto:a@b.com?subject=x` → `a@b.com`; `tel:+1` → `+1` */\nexport function contactLabel(href: string): string {\n return href.replace(/^[a-z][a-z0-9+.-]*:/i, \"\").split(\"?\")[0];\n}\n\n/**\n * The `title` attribute for an anchor of this kind, or nothing when it would\n * only repeat the visible label. For a web link this is how a compacted or\n * labelled URL reveals its real target before anyone clicks.\n */\nexport function hoverTitle(kind: LinkKind, href: string, label: string): string | undefined {\n switch (kind) {\n case \"email\":\n return `Send an email to ${contactLabel(href)}`;\n case \"phone\":\n return `Call ${contactLabel(href)}`;\n case \"sms\":\n return `Send a text to ${contactLabel(href)}`;\n case \"ftp\":\n return \"FTP link — most browsers no longer open these\";\n default:\n return label === href ? undefined : href;\n }\n}\n\n/** An `http:` asset cannot load on an `https:` page; do not even try. */\nexport function isMixedContent(\n src: string,\n pageProtocol: string = typeof location === \"undefined\" ? \"https:\" : location.protocol,\n): boolean {\n return pageProtocol === \"https:\" && /^http:/i.test(src);\n}\n\nexport type GlyphName = \"document\" | \"email\" | \"phone\" | \"sms\" | \"ftp\" | \"zoom\" | \"close\" | \"external\";\n\nconst SVG_OPEN =\n '<svg aria-hidden=\"true\" focusable=\"false\" viewBox=\"0 0 24 24\" width=\"1em\" height=\"1em\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\">';\n\nconst GLYPH_PATHS: Record<GlyphName, string> = {\n document:\n '<path d=\"M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z\"/><path d=\"M14 3v5h5\"/>',\n email: '<rect x=\"3\" y=\"5\" width=\"18\" height=\"14\" rx=\"2\"/><path d=\"m3 7 9 6 9-6\"/>',\n phone:\n '<path d=\"M22 16.9v3a2 2 0 0 1-2.2 2 19.8 19.8 0 0 1-8.6-3.1 19.5 19.5 0 0 1-6-6A19.8 19.8 0 0 1 2.1 4.2 2 2 0 0 1 4.1 2h3a2 2 0 0 1 2 1.7c.1.9.4 1.8.7 2.7a2 2 0 0 1-.5 2.1L8.1 9.7a16 16 0 0 0 6 6l1.3-1.3a2 2 0 0 1 2.1-.4c.9.3 1.8.6 2.7.7a2 2 0 0 1 1.8 2z\"/>',\n sms: '<path d=\"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z\"/>',\n ftp: '<path d=\"M4 17V7l8 5 8-5v10\"/><path d=\"M4 7h16\"/>',\n zoom: '<circle cx=\"11\" cy=\"11\" r=\"7\"/><path d=\"m21 21-4.3-4.3M11 8v6M8 11h6\"/>',\n close: '<path d=\"M18 6 6 18M6 6l12 12\"/>',\n external:\n '<path d=\"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6\"/><path d=\"M15 3h6v6M10 14 21 3\"/>',\n};\n\n/** Inline SVG for a glyph. Strings, not elements, so both renderers can use them. */\nexport function glyph(name: GlyphName): string {\n return `${SVG_OPEN}${GLYPH_PATHS[name]}</svg>`;\n}\n\nexport type StyleObject = Record<string, string | number>;\n\nconst UNITLESS = new Set([\n \"opacity\",\n \"zIndex\",\n \"flex\",\n \"flexGrow\",\n \"flexShrink\",\n \"lineHeight\",\n \"fontWeight\",\n \"order\",\n \"WebkitLineClamp\",\n]);\n\n/** `{ marginTop: 6 }` → `margin-top: 6px;` — the vanilla widget authors cssText. */\nexport function toCssText(style: StyleObject): string {\n return Object.entries(style)\n .map(([k, v]) => {\n const prop = k.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`);\n const val = typeof v === \"number\" && !UNITLESS.has(k) ? `${v}px` : String(v);\n return `${prop}: ${val};`;\n })\n .join(\" \");\n}\n\nconst RADIUS = 8;\nconst ACCENT = \"#10b981\";\nconst chrome = (pct: number) => `color-mix(in srgb, currentColor ${pct}%, transparent)`;\n\n/**\n * Every visual the link layer draws, as one style object per element. React\n * spreads these; vanilla serialises them with `toCssText`. Chrome derives from\n * `currentColor` because the widget sits on a host page whose background it\n * cannot know.\n */\nexport const presentationStyles = {\n link: {\n color: ACCENT,\n textDecoration: \"underline\",\n wordBreak: \"break-all\",\n borderRadius: 2,\n } as StyleObject,\n /** Applied on focus-visible by the renderer; kept here so both agree. */\n linkFocus: { outline: `2px solid ${chrome(60)}`, outlineOffset: 2 } as StyleObject,\n blocked: { opacity: 0.75, textDecoration: \"underline dotted\", cursor: \"help\" } as StyleObject,\n\n card: {\n display: \"block\",\n position: \"relative\",\n marginTop: 6,\n maxWidth: 320,\n aspectRatio: \"16 / 10\",\n borderRadius: RADIUS,\n overflow: \"hidden\",\n background: chrome(6),\n boxShadow: `inset 0 0 0 1px ${chrome(10)}`,\n } as StyleObject,\n cardButton: { cursor: \"zoom-in\" } as StyleObject,\n zoom: {\n position: \"absolute\",\n right: 6,\n bottom: 6,\n width: 24,\n height: 24,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n borderRadius: 6,\n background: \"rgba(0,0,0,.55)\",\n color: \"#fff\",\n fontSize: 14,\n pointerEvents: \"none\",\n } as StyleObject,\n media: {\n display: \"block\",\n width: \"100%\",\n height: \"100%\",\n objectFit: \"cover\",\n borderRadius: RADIUS,\n transition: \"opacity .18s ease\",\n } as StyleObject,\n videoMedia: { objectFit: \"contain\" } as StyleObject,\n skeleton: {\n position: \"absolute\",\n inset: 0,\n borderRadius: RADIUS,\n background: chrome(8),\n backgroundImage: `linear-gradient(90deg, transparent, ${chrome(12)}, transparent)`,\n backgroundSize: \"200% 100%\",\n animation: \"convai-preview-shimmer 1.4s ease-in-out infinite\",\n } as StyleObject,\n caption: {\n display: \"block\",\n marginTop: 4,\n fontSize: 11,\n opacity: 0.7,\n whiteSpace: \"nowrap\",\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n } as StyleObject,\n unavailable: {\n display: \"block\",\n marginTop: 6,\n fontSize: 11,\n opacity: 0.55,\n fontStyle: \"italic\",\n whiteSpace: \"nowrap\",\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n } as StyleObject,\n\n fileCard: {\n display: \"flex\",\n alignItems: \"center\",\n gap: 10,\n marginTop: 6,\n maxWidth: 320,\n padding: \"8px 10px\",\n borderRadius: RADIUS,\n background: chrome(6),\n boxShadow: `inset 0 0 0 1px ${chrome(10)}`,\n color: \"inherit\",\n textDecoration: \"none\",\n } as StyleObject,\n fileIcon: {\n position: \"relative\",\n flex: \"0 0 auto\",\n width: 36,\n height: 44,\n display: \"flex\",\n alignItems: \"flex-end\",\n justifyContent: \"center\",\n paddingBottom: 4,\n boxSizing: \"border-box\",\n borderRadius: 4,\n background: chrome(10),\n color: ACCENT,\n fontSize: 9,\n fontWeight: 700,\n letterSpacing: \".04em\",\n } as StyleObject,\n fileBody: { minWidth: 0, display: \"flex\", flexDirection: \"column\", gap: 2 } as StyleObject,\n fileName: {\n fontSize: 13,\n fontWeight: 600,\n whiteSpace: \"nowrap\",\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n } as StyleObject,\n fileMeta: {\n fontSize: 11,\n opacity: 0.7,\n whiteSpace: \"nowrap\",\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n } as StyleObject,\n\n contact: {\n display: \"inline-flex\",\n alignItems: \"center\",\n gap: 4,\n padding: \"1px 8px 1px 6px\",\n borderRadius: 999,\n background: chrome(8),\n color: ACCENT,\n textDecoration: \"none\",\n fontSize: \"0.95em\",\n lineHeight: 1.6,\n verticalAlign: \"baseline\",\n maxWidth: \"100%\",\n } as StyleObject,\n contactGlyph: { display: \"inline-flex\", fontSize: 13, opacity: 0.9 } as StyleObject,\n badge: {\n display: \"inline-block\",\n marginLeft: 4,\n padding: \"0 4px\",\n borderRadius: 3,\n fontSize: 9,\n fontWeight: 700,\n letterSpacing: \".04em\",\n verticalAlign: \"middle\",\n background: chrome(10),\n opacity: 0.8,\n } as StyleObject,\n\n lightboxBackdrop: {\n position: \"fixed\",\n inset: 0,\n zIndex: 2147483000,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n background: \"rgba(0,0,0,.82)\",\n padding: 24,\n boxSizing: \"border-box\",\n animation: \"convai-lightbox-in .16s ease-out\",\n } as StyleObject,\n lightbox: {\n position: \"relative\",\n display: \"flex\",\n flexDirection: \"column\",\n alignItems: \"center\",\n gap: 10,\n maxWidth: \"90vw\",\n maxHeight: \"90vh\",\n color: \"#fff\",\n } as StyleObject,\n lightboxImage: {\n display: \"block\",\n maxWidth: \"90vw\",\n maxHeight: \"calc(90vh - 72px)\",\n objectFit: \"contain\",\n borderRadius: RADIUS,\n background: \"#000\",\n } as StyleObject,\n lightboxCaption: {\n fontSize: 12,\n opacity: 0.8,\n maxWidth: \"90vw\",\n whiteSpace: \"nowrap\",\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n } as StyleObject,\n lightboxControls: {\n position: \"absolute\",\n top: -4,\n right: -4,\n transform: \"translateY(-100%)\",\n display: \"flex\",\n gap: 6,\n } as StyleObject,\n lightboxButton: {\n display: \"inline-flex\",\n alignItems: \"center\",\n gap: 6,\n padding: \"6px 10px\",\n borderRadius: 999,\n border: \"1px solid rgba(255,255,255,.25)\",\n background: \"rgba(0,0,0,.5)\",\n color: \"#fff\",\n fontSize: 12,\n cursor: \"pointer\",\n textDecoration: \"none\",\n } as StyleObject,\n lightboxFallback: {\n padding: \"32px 40px\",\n fontSize: 13,\n opacity: 0.8,\n border: \"1px dashed rgba(255,255,255,.3)\",\n borderRadius: RADIUS,\n } as StyleObject,\n\n // Site card: Open Graph metadata under a plain web link. Same chrome as the\n // file card so the three card kinds read as one family.\n siteCard: {\n display: \"block\",\n marginTop: 6,\n maxWidth: 320,\n padding: \"8px 10px\",\n borderRadius: RADIUS,\n background: chrome(6),\n boxShadow: `inset 0 0 0 1px ${chrome(10)}`,\n color: \"inherit\",\n textDecoration: \"none\",\n } as StyleObject,\n siteHeader: { display: \"flex\", alignItems: \"center\", gap: 6, minWidth: 0 } as StyleObject,\n siteFavicon: {\n width: 16,\n height: 16,\n flex: \"0 0 auto\",\n borderRadius: 3,\n objectFit: \"contain\",\n } as StyleObject,\n siteName: {\n fontSize: 12,\n fontWeight: 700,\n whiteSpace: \"nowrap\",\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n } as StyleObject,\n siteTitle: {\n display: \"block\",\n marginTop: 2,\n fontSize: 13,\n fontWeight: 600,\n color: ACCENT,\n whiteSpace: \"nowrap\",\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n } as StyleObject,\n siteDescription: {\n display: \"-webkit-box\",\n WebkitBoxOrient: \"vertical\",\n WebkitLineClamp: 2,\n overflow: \"hidden\",\n marginTop: 2,\n fontSize: 12,\n opacity: 0.75,\n lineHeight: 1.35,\n } as StyleObject,\n siteImage: {\n display: \"block\",\n width: \"100%\",\n aspectRatio: \"16 / 9\",\n objectFit: \"cover\",\n marginTop: 8,\n borderRadius: 6,\n } as StyleObject,\n};\n"]}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The site-card contract: what a host hands the renderer for a plain web
|
|
3
|
+
* link, and the one cache both renderers share.
|
|
4
|
+
*
|
|
5
|
+
* The SDK cannot read another origin's HTML, so the Open Graph tags a page
|
|
6
|
+
* declares have to come from somewhere server-side. That somewhere is the
|
|
7
|
+
* host's business; the renderer only needs a function that turns a URL into
|
|
8
|
+
* metadata or null. No resolver, no cards.
|
|
9
|
+
*/
|
|
10
|
+
export interface LinkPreviewMeta {
|
|
11
|
+
/** Final URL after redirects. */
|
|
12
|
+
url: string;
|
|
13
|
+
title?: string;
|
|
14
|
+
description?: string;
|
|
15
|
+
/** Absolute http(s) URL, or dropped. */
|
|
16
|
+
image?: string;
|
|
17
|
+
siteName?: string;
|
|
18
|
+
/** Absolute http(s) URL, or dropped. */
|
|
19
|
+
favicon?: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Resolve metadata for a web URL, or null when there is nothing to show.
|
|
23
|
+
* Should resolve null for a bad or unknown URL and reject only on transport
|
|
24
|
+
* failure; either way the renderer draws nothing.
|
|
25
|
+
*/
|
|
26
|
+
export type LinkPreviewResolver = (url: string, signal: AbortSignal) => Promise<LinkPreviewMeta | null>;
|
|
27
|
+
/** A resolve that has not settled by then is treated as nothing to show. */
|
|
28
|
+
export declare const LINK_PREVIEW_TIMEOUT_MS = 8000;
|
|
29
|
+
/** Distinct URLs remembered per page load. */
|
|
30
|
+
export declare const LINK_PREVIEW_CACHE_SIZE = 200;
|
|
31
|
+
/** Description, site name and favicon alone are not worth a card. */
|
|
32
|
+
export declare function isCardWorthy(meta: LinkPreviewMeta | null | undefined): meta is LinkPreviewMeta;
|
|
33
|
+
/** Only http(s) may ever reach an `img`. Relative URLs are the resolver's job. */
|
|
34
|
+
export declare function safeHttpUrl(value: string | undefined): string | undefined;
|
|
35
|
+
export declare function siteNameFor(meta: LinkPreviewMeta, url: string): string;
|
|
36
|
+
/** Declared icon, else the origin's /favicon.ico. Never a third-party icon service. */
|
|
37
|
+
export declare function faviconFor(meta: LinkPreviewMeta, url: string): string | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* One in-flight or settled promise per URL, shared by every card on the page.
|
|
40
|
+
* Rejections settle to null so a dead host is asked once, and each call gets a
|
|
41
|
+
* signal that fires after LINK_PREVIEW_TIMEOUT_MS.
|
|
42
|
+
*/
|
|
43
|
+
export declare function resolveLinkPreviewCached(resolver: LinkPreviewResolver, url: string): Promise<LinkPreviewMeta | null>;
|
|
44
|
+
/** Test seam. */
|
|
45
|
+
export declare function resetLinkPreviewCache(): void;
|
|
46
|
+
//# sourceMappingURL=linkPreview.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"linkPreview.d.ts","sourceRoot":"","sources":["../../src/utils/linkPreview.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,WAAW,eAAe;IAC9B,iCAAiC;IACjC,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,wCAAwC;IACxC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,wCAAwC;IACxC,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,GAAG,CAChC,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,WAAW,KAChB,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAAC;AAErC,4EAA4E;AAC5E,eAAO,MAAM,uBAAuB,OAAO,CAAC;AAC5C,8CAA8C;AAC9C,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAE3C,qEAAqE;AACrE,wBAAgB,YAAY,CAAC,IAAI,EAAE,eAAe,GAAG,IAAI,GAAG,SAAS,GAAG,IAAI,IAAI,eAAe,CAE9F;AAED,kFAAkF;AAClF,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAQzE;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,eAAe,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAOtE;AAED,uFAAuF;AACvF,wBAAgB,UAAU,CAAC,IAAI,EAAE,eAAe,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAQjF;AAID;;;;GAIG;AACH,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,mBAAmB,EAC7B,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAoBjC;AAED,iBAAiB;AACjB,wBAAgB,qBAAqB,IAAI,IAAI,CAE5C"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/** A resolve that has not settled by then is treated as nothing to show. */
|
|
2
|
+
export const LINK_PREVIEW_TIMEOUT_MS = 8000;
|
|
3
|
+
/** Distinct URLs remembered per page load. */
|
|
4
|
+
export const LINK_PREVIEW_CACHE_SIZE = 200;
|
|
5
|
+
/** Description, site name and favicon alone are not worth a card. */
|
|
6
|
+
export function isCardWorthy(meta) {
|
|
7
|
+
return !!meta && (!!meta.title || !!meta.image);
|
|
8
|
+
}
|
|
9
|
+
/** Only http(s) may ever reach an `img`. Relative URLs are the resolver's job. */
|
|
10
|
+
export function safeHttpUrl(value) {
|
|
11
|
+
if (!value)
|
|
12
|
+
return undefined;
|
|
13
|
+
try {
|
|
14
|
+
const u = new URL(value);
|
|
15
|
+
return u.protocol === "http:" || u.protocol === "https:" ? u.href : undefined;
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export function siteNameFor(meta, url) {
|
|
22
|
+
if (meta.siteName)
|
|
23
|
+
return meta.siteName;
|
|
24
|
+
try {
|
|
25
|
+
return new URL(url).hostname.replace(/^www\./, "");
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
return url;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/** Declared icon, else the origin's /favicon.ico. Never a third-party icon service. */
|
|
32
|
+
export function faviconFor(meta, url) {
|
|
33
|
+
const declared = safeHttpUrl(meta.favicon);
|
|
34
|
+
if (declared)
|
|
35
|
+
return declared;
|
|
36
|
+
try {
|
|
37
|
+
return `${new URL(url).origin}/favicon.ico`;
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
const cache = new Map();
|
|
44
|
+
/**
|
|
45
|
+
* One in-flight or settled promise per URL, shared by every card on the page.
|
|
46
|
+
* Rejections settle to null so a dead host is asked once, and each call gets a
|
|
47
|
+
* signal that fires after LINK_PREVIEW_TIMEOUT_MS.
|
|
48
|
+
*/
|
|
49
|
+
export function resolveLinkPreviewCached(resolver, url) {
|
|
50
|
+
const hit = cache.get(url);
|
|
51
|
+
if (hit)
|
|
52
|
+
return hit;
|
|
53
|
+
const controller = new AbortController();
|
|
54
|
+
const timer = setTimeout(() => controller.abort(), LINK_PREVIEW_TIMEOUT_MS);
|
|
55
|
+
const p = Promise.resolve()
|
|
56
|
+
.then(() => resolver(url, controller.signal))
|
|
57
|
+
.then((meta) => meta ? { ...meta, image: safeHttpUrl(meta.image), favicon: safeHttpUrl(meta.favicon) } : null)
|
|
58
|
+
.catch(() => null)
|
|
59
|
+
.finally(() => clearTimeout(timer));
|
|
60
|
+
if (cache.size >= LINK_PREVIEW_CACHE_SIZE) {
|
|
61
|
+
const oldest = cache.keys().next().value;
|
|
62
|
+
if (oldest !== undefined)
|
|
63
|
+
cache.delete(oldest);
|
|
64
|
+
}
|
|
65
|
+
cache.set(url, p);
|
|
66
|
+
return p;
|
|
67
|
+
}
|
|
68
|
+
/** Test seam. */
|
|
69
|
+
export function resetLinkPreviewCache() {
|
|
70
|
+
cache.clear();
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=linkPreview.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"linkPreview.js","sourceRoot":"","sources":["../../src/utils/linkPreview.ts"],"names":[],"mappings":"AA+BA,4EAA4E;AAC5E,MAAM,CAAC,MAAM,uBAAuB,GAAG,IAAI,CAAC;AAC5C,8CAA8C;AAC9C,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,CAAC;AAE3C,qEAAqE;AACrE,MAAM,UAAU,YAAY,CAAC,IAAwC;IACnE,OAAO,CAAC,CAAC,IAAI,IAAI,CAA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ract: what a host hands the renderer for a plain web\n * link, and the one cache both renderers share.\n *\n * The SDK cannot read another origin's HTML, so the Open Graph tags a page\n * declares have to come from somewhere server-side. That somewhere is the\n * host's business; the renderer only needs a function that turns a URL into\n * metadata or null. No resolver, no cards.\n */\nexport interface LinkPreviewMeta {\n /** Final URL after redirects. */\n url: string;\n title?: string;\n description?: string;\n /** Absolute http(s) URL, or dropped. */\n image?: string;\n siteName?: string;\n /** Absolute http(s) URL, or dropped. */\n favicon?: string;\n}\n\n/**\n * Resolve metadata for a web URL, or null when there is nothing to show.\n * Should resolve null for a bad or unknown URL and reject only on transport\n * failure; either way the renderer draws nothing.\n */\nexport type LinkPreviewResolver = (\n url: string,\n signal: AbortSignal,\n) => Promise<LinkPreviewMeta | null>;\n\n/** A resolve that has not settled by then is treated as nothing to show. */\nexport const LINK_PREVIEW_TIMEOUT_MS = 8000;\n/** Distinct URLs remembered per page load. */\nexport const LINK_PREVIEW_CACHE_SIZE = 200;\n\n/** Description, site name and favicon alone are not worth a card. */\nexport function isCardWorthy(meta: LinkPreviewMeta | null | undefined): meta is LinkPreviewMeta {\n return !!meta && (!!meta.title || !!meta.image);\n}\n\n/** Only http(s) may ever reach an `img`. Relative URLs are the resolver's job. */\nexport function safeHttpUrl(value: string | undefined): string | undefined {\n if (!value) return undefined;\n try {\n const u = new URL(value);\n return u.protocol === \"http:\" || u.protocol === \"https:\" ? u.href : undefined;\n } catch {\n return undefined;\n }\n}\n\nexport function siteNameFor(meta: LinkPreviewMeta, url: string): string {\n if (meta.siteName) return meta.siteName;\n try {\n return new URL(url).hostname.replace(/^www\\./, \"\");\n } catch {\n return url;\n }\n}\n\n/** Declared icon, else the origin's /favicon.ico. Never a third-party icon service. */\nexport function faviconFor(meta: LinkPreviewMeta, url: string): string | undefined {\n const declared = safeHttpUrl(meta.favicon);\n if (declared) return declared;\n try {\n return `${new URL(url).origin}/favicon.ico`;\n } catch {\n return undefined;\n }\n}\n\nconst cache = new Map<string, Promise<LinkPreviewMeta | null>>();\n\n/**\n * One in-flight or settled promise per URL, shared by every card on the page.\n * Rejections settle to null so a dead host is asked once, and each call gets a\n * signal that fires after LINK_PREVIEW_TIMEOUT_MS.\n */\nexport function resolveLinkPreviewCached(\n resolver: LinkPreviewResolver,\n url: string,\n): Promise<LinkPreviewMeta | null> {\n const hit = cache.get(url);\n if (hit) return hit;\n\n const controller = new AbortController();\n const timer = setTimeout(() => controller.abort(), LINK_PREVIEW_TIMEOUT_MS);\n const p = Promise.resolve()\n .then(() => resolver(url, controller.signal))\n .then((meta) =>\n meta ? { ...meta, image: safeHttpUrl(meta.image), favicon: safeHttpUrl(meta.favicon) } : null,\n )\n .catch(() => null)\n .finally(() => clearTimeout(timer));\n\n if (cache.size >= LINK_PREVIEW_CACHE_SIZE) {\n const oldest = cache.keys().next().value;\n if (oldest !== undefined) cache.delete(oldest);\n }\n cache.set(url, p);\n return p;\n}\n\n/** Test seam. */\nexport function resetLinkPreviewCache(): void {\n cache.clear();\n}\n"]}
|