@convai/web-sdk 1.9.0-beta.0 → 1.9.0-beta.12
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/README.md +35 -43
- package/dist/core/AudioManager.d.ts +0 -1
- package/dist/core/AudioManager.js +0 -1
- package/dist/core/BlendshapeQueue.d.ts +0 -1
- package/dist/core/BlendshapeQueue.js +20 -6
- package/dist/core/CharacterRoster.d.ts +0 -1
- package/dist/core/CharacterRoster.js +0 -1
- package/dist/core/CharacterVersionManager.d.ts +0 -1
- package/dist/core/CharacterVersionManager.js +0 -1
- package/dist/core/ConnectionStateHandler.d.ts +0 -1
- package/dist/core/ConnectionStateHandler.js +5 -2
- package/dist/core/ConvaiClient.d.ts +66 -3
- package/dist/core/ConvaiClient.js +253 -20
- package/dist/core/ConvaiRoomError.d.ts +0 -1
- package/dist/core/ConvaiRoomError.js +20 -2
- package/dist/core/EventEmitter.d.ts +0 -1
- package/dist/core/EventEmitter.js +0 -1
- package/dist/core/MemoryManager.d.ts +0 -1
- package/dist/core/MemoryManager.js +0 -1
- package/dist/core/MessageHandler.d.ts +5 -3
- package/dist/core/MessageHandler.js +125 -47
- package/dist/core/SSESession.d.ts +13 -9
- package/dist/core/SSESession.js +240 -13
- package/dist/core/ScreenShareManager.d.ts +0 -1
- package/dist/core/ScreenShareManager.js +0 -1
- package/dist/core/VideoManager.d.ts +0 -1
- package/dist/core/VideoManager.js +0 -1
- package/dist/core/characterInfo.d.ts +45 -0
- package/dist/core/characterInfo.js +55 -0
- package/dist/core/characterReference.d.ts +0 -1
- package/dist/core/characterReference.js +0 -1
- package/dist/core/connectRequest.d.ts +0 -1
- package/dist/core/connectRequest.js +0 -1
- package/dist/core/contextUpdateRequest.d.ts +0 -1
- package/dist/core/contextUpdateRequest.js +0 -1
- package/dist/core/index.d.ts +6 -1
- package/dist/core/index.js +20 -1
- package/dist/core/logicalTurn.d.ts +0 -1
- package/dist/core/logicalTurn.js +0 -1
- package/dist/core/modelOutput.d.ts +0 -1
- package/dist/core/modelOutput.js +0 -1
- package/dist/core/publishedChat.d.ts +0 -1
- package/dist/core/publishedChat.js +0 -1
- package/dist/core/rosterRequest.d.ts +0 -1
- package/dist/core/rosterRequest.js +0 -1
- package/dist/core/rtviEnvelope.d.ts +5 -0
- package/dist/core/rtviEnvelope.js +9 -0
- package/dist/core/types.d.ts +241 -17
- package/dist/core/types.js +0 -1
- package/dist/core/videoSourceState.d.ts +0 -1
- package/dist/core/videoSourceState.js +0 -1
- package/dist/core/visionRequest.d.ts +0 -1
- package/dist/core/visionRequest.js +0 -1
- package/dist/embed/index.d.ts +20 -3
- package/dist/embed/index.js +20 -3
- package/dist/embed/publicationApi.d.ts +0 -1
- package/dist/embed/publicationApi.js +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/lipsync-helpers/arkitOrder61.d.ts +0 -1
- package/dist/lipsync-helpers/arkitOrder61.js +5 -3
- package/dist/lipsync-helpers/createBlendshapeQueue.d.ts +0 -1
- package/dist/lipsync-helpers/createBlendshapeQueue.js +7 -1
- package/dist/lipsync-helpers/declarativeMapping.d.ts +2 -1
- package/dist/lipsync-helpers/declarativeMapping.js +72 -146
- package/dist/lipsync-helpers/index.d.ts +0 -1
- package/dist/lipsync-helpers/index.js +0 -1
- package/dist/lipsync-helpers/mappingTypes.d.ts +6 -5
- package/dist/lipsync-helpers/mappingTypes.js +0 -1
- package/dist/lipsync-helpers/metahumanOrder251.d.ts +0 -1
- package/dist/lipsync-helpers/metahumanOrder251.js +8 -9
- package/dist/lipsync-helpers/mhaLimitDrivers.d.ts +0 -1
- package/dist/lipsync-helpers/mhaLimitDrivers.js +0 -1
- package/dist/lipsync-helpers/naturalness/processor.d.ts +0 -1
- package/dist/lipsync-helpers/naturalness/processor.js +6 -4
- package/dist/lipsync-helpers/naturalness/profiles/mha.d.ts +0 -1
- package/dist/lipsync-helpers/naturalness/profiles/mha.js +0 -1
- package/dist/lipsync-helpers/naturalness/types.d.ts +0 -1
- package/dist/lipsync-helpers/naturalness/types.js +0 -1
- package/dist/lipsync-helpers/presetMappers.d.ts +0 -1
- package/dist/lipsync-helpers/presetMappers.js +0 -1
- package/dist/react/components/ConvaiWidget.d.ts +9 -1
- package/dist/react/components/ConvaiWidget.js +23 -28
- package/dist/react/components/index.d.ts +0 -1
- package/dist/react/components/index.js +0 -1
- package/dist/react/components/rtc-widget/components/AudioSettingsPanel.d.ts +0 -1
- package/dist/react/components/rtc-widget/components/AudioSettingsPanel.js +0 -1
- package/dist/react/components/rtc-widget/components/AudioVisualizer.d.ts +0 -1
- package/dist/react/components/rtc-widget/components/AudioVisualizer.js +0 -1
- package/dist/react/components/rtc-widget/components/ConviMessage.d.ts +4 -2
- package/dist/react/components/rtc-widget/components/ConviMessage.js +2 -3
- package/dist/react/components/rtc-widget/components/FloatingVideo.d.ts +0 -1
- package/dist/react/components/rtc-widget/components/FloatingVideo.js +1 -3
- package/dist/react/components/rtc-widget/components/MarkdownRenderer.d.ts +21 -4
- package/dist/react/components/rtc-widget/components/MarkdownRenderer.js +114 -131
- package/dist/react/components/rtc-widget/components/MessageBubble.d.ts +0 -1
- package/dist/react/components/rtc-widget/components/MessageBubble.js +0 -1
- package/dist/react/components/rtc-widget/components/MessageList.d.ts +4 -2
- package/dist/react/components/rtc-widget/components/MessageList.js +2 -3
- package/dist/react/components/rtc-widget/components/SiteCard.d.ts +14 -0
- package/dist/react/components/rtc-widget/components/SiteCard.js +34 -0
- package/dist/react/components/rtc-widget/components/UserMessage.d.ts +0 -1
- package/dist/react/components/rtc-widget/components/UserMessage.js +1 -2
- package/dist/react/components/rtc-widget/components/conviComponents/ConviButton.d.ts +0 -1
- package/dist/react/components/rtc-widget/components/conviComponents/ConviButton.js +0 -1
- package/dist/react/components/rtc-widget/components/conviComponents/ConviFooter.d.ts +0 -1
- package/dist/react/components/rtc-widget/components/conviComponents/ConviFooter.js +1 -3
- package/dist/react/components/rtc-widget/components/conviComponents/ConviHeader.d.ts +0 -1
- package/dist/react/components/rtc-widget/components/conviComponents/ConviHeader.js +1 -3
- package/dist/react/components/rtc-widget/components/conviComponents/SettingsTray.d.ts +0 -1
- package/dist/react/components/rtc-widget/components/conviComponents/SettingsTray.js +1 -4
- package/dist/react/components/rtc-widget/components/conviComponents/VoiceModeOverlay.d.ts +0 -1
- package/dist/react/components/rtc-widget/components/conviComponents/VoiceModeOverlay.js +0 -1
- package/dist/react/components/rtc-widget/components/conviComponents/index.d.ts +0 -1
- package/dist/react/components/rtc-widget/components/conviComponents/index.js +0 -1
- package/dist/react/components/rtc-widget/components/index.d.ts +0 -1
- package/dist/react/components/rtc-widget/components/index.js +0 -1
- package/dist/react/components/rtc-widget/index.d.ts +0 -1
- package/dist/react/components/rtc-widget/index.js +0 -1
- package/dist/react/components/rtc-widget/styles/framerConfig.d.ts +0 -1
- package/dist/react/components/rtc-widget/styles/framerConfig.js +0 -1
- package/dist/react/components/rtc-widget/styles/icons.d.ts +0 -1
- package/dist/react/components/rtc-widget/styles/icons.js +0 -1
- package/dist/react/components/rtc-widget/styles/index.d.ts +0 -1
- package/dist/react/components/rtc-widget/styles/index.js +0 -1
- package/dist/react/components/rtc-widget/styles/styledComponents.d.ts +0 -1
- package/dist/react/components/rtc-widget/styles/styledComponents.js +0 -1
- package/dist/react/components/rtc-widget/styles/theme.d.ts +0 -1
- package/dist/react/components/rtc-widget/styles/theme.js +0 -1
- package/dist/react/components/rtc-widget/types/index.d.ts +0 -1
- package/dist/react/components/rtc-widget/types/index.js +0 -1
- package/dist/react/hooks/index.d.ts +0 -1
- package/dist/react/hooks/index.js +0 -1
- package/dist/react/hooks/useCharacterInfo.d.ts +12 -11
- package/dist/react/hooks/useCharacterInfo.js +49 -50
- package/dist/react/hooks/useConvaiClient.d.ts +0 -1
- package/dist/react/hooks/useConvaiClient.js +8 -5
- package/dist/react/hooks/useLocalCameraTrack.d.ts +0 -1
- package/dist/react/hooks/useLocalCameraTrack.js +0 -1
- package/dist/react/icons.d.ts +37 -0
- package/dist/react/icons.js +53 -0
- package/dist/react/index.d.ts +4 -1
- package/dist/react/index.js +2 -1
- package/dist/utils/inlineMarkdown.d.ts +0 -1
- package/dist/utils/inlineMarkdown.js +0 -1
- package/dist/utils/lightbox.d.ts +15 -0
- package/dist/utils/lightbox.js +94 -0
- package/dist/utils/linkPresentation.d.ts +75 -0
- package/dist/utils/linkPresentation.js +414 -0
- package/dist/utils/linkPreview.d.ts +45 -0
- package/dist/utils/linkPreview.js +71 -0
- package/dist/utils/logger.d.ts +0 -1
- package/dist/utils/logger.js +0 -1
- package/dist/vanilla/AudioRenderer.d.ts +0 -1
- package/dist/vanilla/AudioRenderer.js +0 -1
- package/dist/vanilla/ConvaiWidget.d.ts +0 -1
- package/dist/vanilla/ConvaiWidget.js +302 -226
- package/dist/vanilla/WebSocketSession.d.ts +0 -1
- package/dist/vanilla/WebSocketSession.js +0 -1
- package/dist/vanilla/WidgetEventSubscriptions.d.ts +0 -1
- package/dist/vanilla/WidgetEventSubscriptions.js +0 -1
- package/dist/vanilla/icons.d.ts +0 -1
- package/dist/vanilla/icons.js +0 -1
- package/dist/vanilla/index.d.ts +4 -1
- package/dist/vanilla/index.js +2 -1
- package/dist/vanilla/styles.d.ts +0 -1
- package/dist/vanilla/styles.js +9 -1
- package/dist/vanilla/types.d.ts +9 -1
- package/dist/vanilla/types.js +0 -1
- package/dist/vanilla/websocket.d.ts +0 -1
- package/dist/vanilla/websocket.js +0 -1
- package/dist/version.d.ts +1 -2
- package/dist/version.js +1 -2
- package/package.json +23 -28
- package/dist/core/AudioManager.d.ts.map +0 -1
- package/dist/core/AudioManager.js.map +0 -1
- package/dist/core/BlendshapeQueue.d.ts.map +0 -1
- package/dist/core/BlendshapeQueue.js.map +0 -1
- package/dist/core/CharacterRoster.d.ts.map +0 -1
- package/dist/core/CharacterRoster.js.map +0 -1
- package/dist/core/CharacterVersionManager.d.ts.map +0 -1
- package/dist/core/CharacterVersionManager.js.map +0 -1
- package/dist/core/ConnectionStateHandler.d.ts.map +0 -1
- package/dist/core/ConnectionStateHandler.js.map +0 -1
- package/dist/core/ConvaiClient.d.ts.map +0 -1
- package/dist/core/ConvaiClient.js.map +0 -1
- package/dist/core/ConvaiRoomError.d.ts.map +0 -1
- package/dist/core/ConvaiRoomError.js.map +0 -1
- package/dist/core/EventEmitter.d.ts.map +0 -1
- package/dist/core/EventEmitter.js.map +0 -1
- package/dist/core/MemoryManager.d.ts.map +0 -1
- package/dist/core/MemoryManager.js.map +0 -1
- package/dist/core/MessageHandler.d.ts.map +0 -1
- package/dist/core/MessageHandler.js.map +0 -1
- package/dist/core/SSESession.d.ts.map +0 -1
- package/dist/core/SSESession.js.map +0 -1
- package/dist/core/ScreenShareManager.d.ts.map +0 -1
- package/dist/core/ScreenShareManager.js.map +0 -1
- package/dist/core/VideoManager.d.ts.map +0 -1
- package/dist/core/VideoManager.js.map +0 -1
- package/dist/core/characterReference.d.ts.map +0 -1
- package/dist/core/characterReference.js.map +0 -1
- package/dist/core/connectRequest.d.ts.map +0 -1
- package/dist/core/connectRequest.js.map +0 -1
- package/dist/core/contextUpdateRequest.d.ts.map +0 -1
- package/dist/core/contextUpdateRequest.js.map +0 -1
- package/dist/core/index.d.ts.map +0 -1
- package/dist/core/index.js.map +0 -1
- package/dist/core/logicalTurn.d.ts.map +0 -1
- package/dist/core/logicalTurn.js.map +0 -1
- package/dist/core/modelOutput.d.ts.map +0 -1
- package/dist/core/modelOutput.js.map +0 -1
- package/dist/core/publishedChat.d.ts.map +0 -1
- package/dist/core/publishedChat.js.map +0 -1
- package/dist/core/rosterRequest.d.ts.map +0 -1
- package/dist/core/rosterRequest.js.map +0 -1
- package/dist/core/types.d.ts.map +0 -1
- package/dist/core/types.js.map +0 -1
- package/dist/core/videoSourceState.d.ts.map +0 -1
- package/dist/core/videoSourceState.js.map +0 -1
- package/dist/core/visionRequest.d.ts.map +0 -1
- package/dist/core/visionRequest.js.map +0 -1
- package/dist/embed/ConvaiChatElement.d.ts +0 -103
- package/dist/embed/ConvaiChatElement.d.ts.map +0 -1
- package/dist/embed/ConvaiChatElement.js +0 -679
- package/dist/embed/ConvaiChatElement.js.map +0 -1
- package/dist/embed/browser.d.ts +0 -3
- package/dist/embed/browser.d.ts.map +0 -1
- package/dist/embed/browser.js +0 -5
- package/dist/embed/browser.js.map +0 -1
- package/dist/embed/chat-embed-v1.js +0 -200
- package/dist/embed/chat-embed-v1.js.map +0 -7
- package/dist/embed/index.d.ts.map +0 -1
- package/dist/embed/index.js.map +0 -1
- package/dist/embed/publicationApi.d.ts.map +0 -1
- package/dist/embed/publicationApi.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lipsync-helpers/arkitOrder61.d.ts.map +0 -1
- package/dist/lipsync-helpers/arkitOrder61.js.map +0 -1
- package/dist/lipsync-helpers/createBlendshapeQueue.d.ts.map +0 -1
- package/dist/lipsync-helpers/createBlendshapeQueue.js.map +0 -1
- package/dist/lipsync-helpers/declarativeMapping.d.ts.map +0 -1
- package/dist/lipsync-helpers/declarativeMapping.js.map +0 -1
- package/dist/lipsync-helpers/index.d.ts.map +0 -1
- package/dist/lipsync-helpers/index.js.map +0 -1
- package/dist/lipsync-helpers/mappingTypes.d.ts.map +0 -1
- package/dist/lipsync-helpers/mappingTypes.js.map +0 -1
- package/dist/lipsync-helpers/metahumanOrder251.d.ts.map +0 -1
- package/dist/lipsync-helpers/metahumanOrder251.js.map +0 -1
- package/dist/lipsync-helpers/mhaLimitDrivers.d.ts.map +0 -1
- package/dist/lipsync-helpers/mhaLimitDrivers.js.map +0 -1
- package/dist/lipsync-helpers/naturalness/processor.d.ts.map +0 -1
- package/dist/lipsync-helpers/naturalness/processor.js.map +0 -1
- package/dist/lipsync-helpers/naturalness/profiles/mha.d.ts.map +0 -1
- package/dist/lipsync-helpers/naturalness/profiles/mha.js.map +0 -1
- package/dist/lipsync-helpers/naturalness/types.d.ts.map +0 -1
- package/dist/lipsync-helpers/naturalness/types.js.map +0 -1
- package/dist/lipsync-helpers/presetMappers.d.ts.map +0 -1
- package/dist/lipsync-helpers/presetMappers.js.map +0 -1
- package/dist/react/components/ConvaiWidget.d.ts.map +0 -1
- package/dist/react/components/ConvaiWidget.js.map +0 -1
- package/dist/react/components/index.d.ts.map +0 -1
- package/dist/react/components/index.js.map +0 -1
- package/dist/react/components/rtc-widget/components/AudioSettingsPanel.d.ts.map +0 -1
- package/dist/react/components/rtc-widget/components/AudioSettingsPanel.js.map +0 -1
- package/dist/react/components/rtc-widget/components/AudioVisualizer.d.ts.map +0 -1
- package/dist/react/components/rtc-widget/components/AudioVisualizer.js.map +0 -1
- package/dist/react/components/rtc-widget/components/ConviMessage.d.ts.map +0 -1
- package/dist/react/components/rtc-widget/components/ConviMessage.js.map +0 -1
- package/dist/react/components/rtc-widget/components/FloatingVideo.d.ts.map +0 -1
- package/dist/react/components/rtc-widget/components/FloatingVideo.js.map +0 -1
- package/dist/react/components/rtc-widget/components/MarkdownRenderer.d.ts.map +0 -1
- package/dist/react/components/rtc-widget/components/MarkdownRenderer.js.map +0 -1
- package/dist/react/components/rtc-widget/components/MessageBubble.d.ts.map +0 -1
- package/dist/react/components/rtc-widget/components/MessageBubble.js.map +0 -1
- package/dist/react/components/rtc-widget/components/MessageList.d.ts.map +0 -1
- package/dist/react/components/rtc-widget/components/MessageList.js.map +0 -1
- package/dist/react/components/rtc-widget/components/UserMessage.d.ts.map +0 -1
- package/dist/react/components/rtc-widget/components/UserMessage.js.map +0 -1
- package/dist/react/components/rtc-widget/components/conviComponents/ConviButton.d.ts.map +0 -1
- package/dist/react/components/rtc-widget/components/conviComponents/ConviButton.js.map +0 -1
- package/dist/react/components/rtc-widget/components/conviComponents/ConviFooter.d.ts.map +0 -1
- package/dist/react/components/rtc-widget/components/conviComponents/ConviFooter.js.map +0 -1
- package/dist/react/components/rtc-widget/components/conviComponents/ConviHeader.d.ts.map +0 -1
- package/dist/react/components/rtc-widget/components/conviComponents/ConviHeader.js.map +0 -1
- package/dist/react/components/rtc-widget/components/conviComponents/SettingsTray.d.ts.map +0 -1
- package/dist/react/components/rtc-widget/components/conviComponents/SettingsTray.js.map +0 -1
- package/dist/react/components/rtc-widget/components/conviComponents/VoiceModeOverlay.d.ts.map +0 -1
- package/dist/react/components/rtc-widget/components/conviComponents/VoiceModeOverlay.js.map +0 -1
- package/dist/react/components/rtc-widget/components/conviComponents/index.d.ts.map +0 -1
- package/dist/react/components/rtc-widget/components/conviComponents/index.js.map +0 -1
- package/dist/react/components/rtc-widget/components/index.d.ts.map +0 -1
- package/dist/react/components/rtc-widget/components/index.js.map +0 -1
- package/dist/react/components/rtc-widget/index.d.ts.map +0 -1
- package/dist/react/components/rtc-widget/index.js.map +0 -1
- package/dist/react/components/rtc-widget/styles/framerConfig.d.ts.map +0 -1
- package/dist/react/components/rtc-widget/styles/framerConfig.js.map +0 -1
- package/dist/react/components/rtc-widget/styles/icons.d.ts.map +0 -1
- package/dist/react/components/rtc-widget/styles/icons.js.map +0 -1
- package/dist/react/components/rtc-widget/styles/index.d.ts.map +0 -1
- package/dist/react/components/rtc-widget/styles/index.js.map +0 -1
- package/dist/react/components/rtc-widget/styles/styledComponents.d.ts.map +0 -1
- package/dist/react/components/rtc-widget/styles/styledComponents.js.map +0 -1
- package/dist/react/components/rtc-widget/styles/theme.d.ts.map +0 -1
- package/dist/react/components/rtc-widget/styles/theme.js.map +0 -1
- package/dist/react/components/rtc-widget/types/index.d.ts.map +0 -1
- package/dist/react/components/rtc-widget/types/index.js.map +0 -1
- package/dist/react/hooks/index.d.ts.map +0 -1
- package/dist/react/hooks/index.js.map +0 -1
- package/dist/react/hooks/useCharacterInfo.d.ts.map +0 -1
- package/dist/react/hooks/useCharacterInfo.js.map +0 -1
- package/dist/react/hooks/useConvaiClient.d.ts.map +0 -1
- package/dist/react/hooks/useConvaiClient.js.map +0 -1
- package/dist/react/hooks/useLocalCameraTrack.d.ts.map +0 -1
- package/dist/react/hooks/useLocalCameraTrack.js.map +0 -1
- package/dist/react/index.d.ts.map +0 -1
- package/dist/react/index.js.map +0 -1
- package/dist/utils/inlineMarkdown.d.ts.map +0 -1
- package/dist/utils/inlineMarkdown.js.map +0 -1
- package/dist/utils/logger.d.ts.map +0 -1
- package/dist/utils/logger.js.map +0 -1
- package/dist/vanilla/AudioRenderer.d.ts.map +0 -1
- package/dist/vanilla/AudioRenderer.js.map +0 -1
- package/dist/vanilla/ConvaiWidget.d.ts.map +0 -1
- package/dist/vanilla/ConvaiWidget.js.map +0 -1
- package/dist/vanilla/WebSocketSession.d.ts.map +0 -1
- package/dist/vanilla/WebSocketSession.js.map +0 -1
- package/dist/vanilla/WidgetEventSubscriptions.d.ts.map +0 -1
- package/dist/vanilla/WidgetEventSubscriptions.js.map +0 -1
- package/dist/vanilla/icons.d.ts.map +0 -1
- package/dist/vanilla/icons.js.map +0 -1
- package/dist/vanilla/index.d.ts.map +0 -1
- package/dist/vanilla/index.js.map +0 -1
- package/dist/vanilla/styles.d.ts.map +0 -1
- package/dist/vanilla/styles.js.map +0 -1
- package/dist/vanilla/types.d.ts.map +0 -1
- package/dist/vanilla/types.js.map +0 -1
- package/dist/vanilla/websocket.d.ts.map +0 -1
- package/dist/vanilla/websocket.js.map +0 -1
- package/dist/version.d.ts.map +0 -1
- package/dist/version.js.map +0 -1
|
@@ -7,7 +7,11 @@ import { aeroTheme, injectGlobalStyles, injectKeyframes, } from "./styles.js";
|
|
|
7
7
|
import { Icons } from "./icons.js";
|
|
8
8
|
import { WidgetEventSubscriptions } from "./WidgetEventSubscriptions.js";
|
|
9
9
|
import { ConvaiClient } from "../core/ConvaiClient.js";
|
|
10
|
+
import { fetchCharacterInfo as requestCharacterInfo } from "../core/characterInfo.js";
|
|
10
11
|
import { parseInlineMarkdown, compactUrl } from "../utils/inlineMarkdown.js";
|
|
12
|
+
import { linkKindForUrl, describeUrl, fileNameOf, documentBadge, contactLabel, hoverTitle, isMixedContent, glyph, presentationStyles as S, toCssText, PREVIEW_TIMEOUT_MS, MAX_CARDS_PER_MESSAGE, } from "../utils/linkPresentation.js";
|
|
13
|
+
import { openLightbox } from "../utils/lightbox.js";
|
|
14
|
+
import { resolveLinkPreviewCached, isCardWorthy, siteNameFor, faviconFor, } from "../utils/linkPreview.js";
|
|
11
15
|
import { freshPublicationGrantOptions } from "../core/publishedChat.js";
|
|
12
16
|
/**
|
|
13
17
|
* Positioning declarations for the widget root, keyed by `placement`. The
|
|
@@ -254,42 +258,30 @@ export function createConvaiWidget(container, options) {
|
|
|
254
258
|
// uses when building /connect headers -- a client carrying both must
|
|
255
259
|
// behave identically in both places.
|
|
256
260
|
//
|
|
257
|
-
// The two
|
|
258
|
-
// an auth token
|
|
259
|
-
// answers an API key sent as API-AUTH-TOKEN with `400 Your
|
|
260
|
-
// expired.`
|
|
261
|
-
// showed up only as a header stuck on the fallback name.
|
|
261
|
+
// The two travel in *different* headers, which requestCharacterInfo
|
|
262
|
+
// handles: an auth token goes in API-AUTH-TOKEN, an API key in X-API-Key,
|
|
263
|
+
// and the host answers an API key sent as API-AUTH-TOKEN with `400 Your
|
|
264
|
+
// session has expired.` The failure is swallowed below, so getting it
|
|
265
|
+
// wrong showed up only as a header stuck on the fallback name.
|
|
262
266
|
const credential = client.authToken ?? client.apiKey;
|
|
263
267
|
if (!credential || !client.characterId)
|
|
264
268
|
return;
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
if (client.authToken) {
|
|
269
|
-
headers["API-AUTH-TOKEN"] = client.authToken;
|
|
270
|
-
}
|
|
271
|
-
else {
|
|
272
|
-
headers["X-API-Key"] = credential;
|
|
273
|
-
}
|
|
269
|
+
// Same request as the React hook, because it is literally the same
|
|
270
|
+
// function now -- the two used to be hand-synced copies sharing a
|
|
271
|
+
// hardcoded host, which is what made this unconfigurable on-prem.
|
|
274
272
|
try {
|
|
275
|
-
const
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
273
|
+
const info = await requestCharacterInfo({
|
|
274
|
+
characterId: client.characterId,
|
|
275
|
+
apiKey: credential,
|
|
276
|
+
authToken: client.authToken,
|
|
277
|
+
baseUrl: client.characterInfoUrl,
|
|
279
278
|
});
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
characterName = data.character_name || "Convi";
|
|
284
|
-
characterImage =
|
|
285
|
-
data.model_details?.METAHUMAN?.avatar_image_square ||
|
|
286
|
-
data.model_details?.METAHUMAN?.avatar_image ||
|
|
287
|
-
data.model_details?.modelPlaceholder ||
|
|
288
|
-
"";
|
|
289
|
-
updateHeader();
|
|
290
|
-
}
|
|
279
|
+
characterName = info.name;
|
|
280
|
+
characterImage = info.image ?? "";
|
|
281
|
+
updateHeader();
|
|
291
282
|
}
|
|
292
283
|
catch (error) {
|
|
284
|
+
// Cosmetic: keep the fallback header rather than surface this.
|
|
293
285
|
console.error("Failed to fetch character info:", error);
|
|
294
286
|
}
|
|
295
287
|
};
|
|
@@ -1768,16 +1760,10 @@ export function createConvaiWidget(container, options) {
|
|
|
1768
1760
|
// Microphone toggle removed - only controlled via voice mode now
|
|
1769
1761
|
const handleToggleMute = () => {
|
|
1770
1762
|
isMuted = !isMuted;
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
if (publication.track) {
|
|
1776
|
-
publication.track.setMuted(isMuted);
|
|
1777
|
-
}
|
|
1778
|
-
});
|
|
1779
|
-
});
|
|
1780
|
-
}
|
|
1763
|
+
// The client owns this now: it covers the WebSocket transport, which this
|
|
1764
|
+
// handler never did, and it holds the state so a reconnect or a joining
|
|
1765
|
+
// roster member does not come back audible.
|
|
1766
|
+
client.setCharacterMuted(isMuted);
|
|
1781
1767
|
updateHeader();
|
|
1782
1768
|
};
|
|
1783
1769
|
const handleReset = async () => {
|
|
@@ -2074,217 +2060,308 @@ export function createConvaiWidget(container, options) {
|
|
|
2074
2060
|
});
|
|
2075
2061
|
};
|
|
2076
2062
|
// Microphone button removed - only controlled via voice mode now
|
|
2077
|
-
//
|
|
2078
|
-
//
|
|
2079
|
-
//
|
|
2080
|
-
//
|
|
2081
|
-
//
|
|
2063
|
+
// The bubble renderer. Everything visual comes from utils/linkPresentation
|
|
2064
|
+
// so this and the React MarkdownRenderer cannot drift; this only maps
|
|
2065
|
+
// tokenizer nodes onto DOM. `media` gates cards and chips: bot bubbles get
|
|
2066
|
+
// them, the user's own bubble keeps anchors only, so a pasted URL never
|
|
2067
|
+
// pulls remote media into the transcript.
|
|
2082
2068
|
const renderMarkdown = (text, container, { media = true } = {}) => {
|
|
2083
2069
|
if (!text)
|
|
2084
2070
|
return;
|
|
2085
|
-
// Handle both actual newlines and \n
|
|
2086
|
-
const
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2071
|
+
// Handle both actual newlines and literal "\n" sequences.
|
|
2072
|
+
const lines = text.replace(/\\n/g, "\n").split("\n");
|
|
2073
|
+
// Cards drawn so far in this message, against MAX_CARDS_PER_MESSAGE.
|
|
2074
|
+
const budget = { cards: 0 };
|
|
2075
|
+
const make = (tag, part, ...styles) => {
|
|
2076
|
+
const node = document.createElement(tag);
|
|
2077
|
+
node.setAttribute("part", part);
|
|
2078
|
+
node.style.cssText = toCssText(Object.assign({}, ...styles));
|
|
2079
|
+
return node;
|
|
2080
|
+
};
|
|
2081
|
+
// Inline styles cannot express :focus-visible, so the ring is toggled by hand.
|
|
2082
|
+
const focusRing = (node) => {
|
|
2083
|
+
const base = node.style.cssText;
|
|
2084
|
+
node.addEventListener("focus", () => {
|
|
2085
|
+
if (node.matches(":focus-visible"))
|
|
2086
|
+
node.style.cssText = `${base} ${toCssText(S.linkFocus)}`;
|
|
2087
|
+
});
|
|
2088
|
+
node.addEventListener("blur", () => {
|
|
2089
|
+
node.style.cssText = base;
|
|
2090
|
+
});
|
|
2091
|
+
};
|
|
2092
|
+
const anchor = (href, kind, label) => {
|
|
2093
|
+
const a = make("a", "message-link", S.link);
|
|
2094
|
+
a.href = href;
|
|
2095
|
+
a.target = "_blank";
|
|
2096
|
+
a.rel = "noopener noreferrer";
|
|
2097
|
+
// A bare URL is its own label and may be elided for display; the title
|
|
2098
|
+
// compares against what is shown so the full target is one hover away.
|
|
2099
|
+
const display = label === href ? compactUrl(label) : label;
|
|
2100
|
+
a.textContent = display;
|
|
2101
|
+
const title = hoverTitle(kind, href, display);
|
|
2102
|
+
if (title)
|
|
2103
|
+
a.title = title;
|
|
2104
|
+
if (kind === "ftp") {
|
|
2105
|
+
const badge = make("span", "message-link-badge", S.badge);
|
|
2106
|
+
badge.textContent = "FTP";
|
|
2107
|
+
a.appendChild(badge);
|
|
2108
|
+
}
|
|
2109
|
+
focusRing(a);
|
|
2110
|
+
return a;
|
|
2111
|
+
};
|
|
2112
|
+
const contactChip = (href, kind) => {
|
|
2113
|
+
const a = make("a", "message-contact", S.contact);
|
|
2114
|
+
a.href = href;
|
|
2115
|
+
a.title = hoverTitle(kind, href, href);
|
|
2116
|
+
const g = make("span", "message-contact-glyph", S.contactGlyph);
|
|
2117
|
+
g.innerHTML = glyph(kind);
|
|
2118
|
+
const t = document.createElement("span");
|
|
2119
|
+
t.textContent = contactLabel(href);
|
|
2120
|
+
a.append(g, t);
|
|
2121
|
+
focusRing(a);
|
|
2122
|
+
return a;
|
|
2123
|
+
};
|
|
2124
|
+
const documentCard = (href) => {
|
|
2125
|
+
let host = "";
|
|
2126
|
+
try {
|
|
2127
|
+
host = new URL(href).host;
|
|
2128
|
+
}
|
|
2129
|
+
catch {
|
|
2130
|
+
/* keep empty */
|
|
2131
|
+
}
|
|
2132
|
+
const a = make("a", "message-file-card", S.fileCard);
|
|
2133
|
+
a.href = href;
|
|
2134
|
+
a.target = "_blank";
|
|
2135
|
+
a.rel = "noopener noreferrer";
|
|
2136
|
+
a.title = href;
|
|
2137
|
+
const icon = make("span", "message-file-icon", S.fileIcon);
|
|
2138
|
+
icon.textContent = documentBadge(href);
|
|
2139
|
+
const body = document.createElement("span");
|
|
2140
|
+
body.style.cssText = toCssText(S.fileBody);
|
|
2141
|
+
const name = make("span", "message-file-name", S.fileName);
|
|
2142
|
+
name.textContent = fileNameOf(href);
|
|
2143
|
+
const meta = make("span", "message-file-meta", S.fileMeta);
|
|
2144
|
+
meta.textContent = `${host} · Opens in a new tab`;
|
|
2145
|
+
body.append(name, meta);
|
|
2146
|
+
a.append(icon, body);
|
|
2147
|
+
focusRing(a);
|
|
2148
|
+
return a;
|
|
2149
|
+
};
|
|
2150
|
+
/**
|
|
2151
|
+
* Open Graph card under a plain web link. A comment node holds the place
|
|
2152
|
+
* until the host's resolver settles; it is replaced only when the result
|
|
2153
|
+
* has a title or an image, so nothing flashes for the many links that
|
|
2154
|
+
* resolve to nothing card-worthy. Resolver text becomes text nodes only.
|
|
2155
|
+
*/
|
|
2156
|
+
const siteCard = (href) => {
|
|
2157
|
+
const resolver = options.linkPreviewResolver;
|
|
2158
|
+
const slot = document.createComment("site-card");
|
|
2159
|
+
if (!resolver)
|
|
2160
|
+
return slot;
|
|
2161
|
+
resolveLinkPreviewCached(resolver, href).then((meta) => {
|
|
2162
|
+
if (!isCardWorthy(meta) || !slot.parentNode)
|
|
2163
|
+
return;
|
|
2164
|
+
const a = make("a", "message-site-card", S.siteCard);
|
|
2165
|
+
a.href = href;
|
|
2166
|
+
a.target = "_blank";
|
|
2167
|
+
a.rel = "noopener noreferrer";
|
|
2168
|
+
const header = document.createElement("span");
|
|
2169
|
+
header.style.cssText = toCssText(S.siteHeader);
|
|
2170
|
+
const favicon = faviconFor(meta, href);
|
|
2171
|
+
if (favicon) {
|
|
2172
|
+
const icon = make("img", "message-site-favicon", S.siteFavicon);
|
|
2173
|
+
icon.src = favicon;
|
|
2174
|
+
icon.alt = "";
|
|
2175
|
+
icon.addEventListener("error", () => icon.remove());
|
|
2176
|
+
header.appendChild(icon);
|
|
2097
2177
|
}
|
|
2098
|
-
|
|
2099
|
-
|
|
2178
|
+
const name = make("span", "message-site-name", S.siteName);
|
|
2179
|
+
name.textContent = siteNameFor(meta, href);
|
|
2180
|
+
header.appendChild(name);
|
|
2181
|
+
a.appendChild(header);
|
|
2182
|
+
if (meta.title) {
|
|
2183
|
+
const t = make("span", "message-site-title", S.siteTitle);
|
|
2184
|
+
t.textContent = meta.title;
|
|
2185
|
+
a.appendChild(t);
|
|
2100
2186
|
}
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
opacity: 0;
|
|
2136
|
-
transition: opacity .18s ease;
|
|
2137
|
-
`;
|
|
2138
|
-
const skeleton = document.createElement("span");
|
|
2139
|
-
skeleton.setAttribute("part", "message-media-skeleton");
|
|
2140
|
-
skeleton.setAttribute("aria-hidden", "true");
|
|
2141
|
-
skeleton.dataset.convaiSkeleton = "";
|
|
2142
|
-
skeleton.style.cssText = `
|
|
2143
|
-
position: absolute;
|
|
2144
|
-
inset: 0;
|
|
2145
|
-
border-radius: 8px;
|
|
2146
|
-
background: color-mix(in srgb, currentColor 8%, transparent);
|
|
2147
|
-
background-image: linear-gradient(90deg, transparent, color-mix(in srgb, currentColor 12%, transparent), transparent);
|
|
2148
|
-
background-size: 200% 100%;
|
|
2149
|
-
animation: convai-preview-shimmer 1.4s ease-in-out infinite;
|
|
2150
|
-
`;
|
|
2151
|
-
const caption = document.createElement("span");
|
|
2152
|
-
caption.setAttribute("part", "message-media-caption");
|
|
2153
|
-
caption.textContent = describeUrl(src);
|
|
2154
|
-
caption.style.cssText = `
|
|
2155
|
-
display: block;
|
|
2156
|
-
margin-top: 4px;
|
|
2157
|
-
font-size: 11px;
|
|
2158
|
-
opacity: .7;
|
|
2159
|
-
white-space: nowrap;
|
|
2160
|
-
overflow: hidden;
|
|
2161
|
-
text-overflow: ellipsis;
|
|
2162
|
-
`;
|
|
2163
|
-
const settled = () => {
|
|
2164
|
-
el.style.opacity = "1";
|
|
2165
|
-
skeleton.remove();
|
|
2166
|
-
};
|
|
2167
|
-
el.addEventListener(media === "image" ? "load" : "loadedmetadata", settled);
|
|
2168
|
-
el.addEventListener("error", () => {
|
|
2169
|
-
const dead = document.createElement("span");
|
|
2170
|
-
dead.setAttribute("part", "message-media-unavailable");
|
|
2171
|
-
dead.textContent = `Preview unavailable — ${describeUrl(src)}`;
|
|
2172
|
-
dead.style.cssText = `
|
|
2173
|
-
display: block;
|
|
2174
|
-
margin-top: 6px;
|
|
2175
|
-
font-size: 11px;
|
|
2176
|
-
opacity: .55;
|
|
2177
|
-
font-style: italic;
|
|
2178
|
-
white-space: nowrap;
|
|
2179
|
-
overflow: hidden;
|
|
2180
|
-
text-overflow: ellipsis;
|
|
2181
|
-
`;
|
|
2182
|
-
card.replaceWith(dead);
|
|
2183
|
-
caption.remove();
|
|
2184
|
-
});
|
|
2185
|
-
card.appendChild(el);
|
|
2186
|
-
card.appendChild(skeleton);
|
|
2187
|
-
const frag = document.createDocumentFragment();
|
|
2188
|
-
frag.appendChild(card);
|
|
2189
|
-
frag.appendChild(caption);
|
|
2187
|
+
if (meta.description) {
|
|
2188
|
+
const d = make("span", "message-site-description", S.siteDescription);
|
|
2189
|
+
d.textContent = meta.description;
|
|
2190
|
+
a.appendChild(d);
|
|
2191
|
+
}
|
|
2192
|
+
if (meta.image) {
|
|
2193
|
+
const img = make("img", "message-site-image", S.siteImage);
|
|
2194
|
+
img.src = meta.image;
|
|
2195
|
+
img.alt = "";
|
|
2196
|
+
img.loading = "lazy";
|
|
2197
|
+
img.addEventListener("error", () => img.remove());
|
|
2198
|
+
a.appendChild(img);
|
|
2199
|
+
}
|
|
2200
|
+
focusRing(a);
|
|
2201
|
+
slot.replaceWith(a);
|
|
2202
|
+
});
|
|
2203
|
+
return slot;
|
|
2204
|
+
};
|
|
2205
|
+
const unavailable = (src, insecure) => {
|
|
2206
|
+
const dead = make("span", "message-media-unavailable", S.unavailable);
|
|
2207
|
+
dead.textContent = `Preview unavailable — ${describeUrl(src)}${insecure ? " (insecure URL)" : ""}`;
|
|
2208
|
+
return dead;
|
|
2209
|
+
};
|
|
2210
|
+
/**
|
|
2211
|
+
* Image or video card. The element is created up front so the fetch starts
|
|
2212
|
+
* immediately; a skeleton covers it until it decodes. Error, timeout, or an
|
|
2213
|
+
* insecure URL collapse the card to one muted line — a character can
|
|
2214
|
+
* invent a URL, and an empty player in the transcript reads as a broken
|
|
2215
|
+
* widget.
|
|
2216
|
+
*/
|
|
2217
|
+
const mediaPreview = (src, alt, kind) => {
|
|
2218
|
+
const frag = document.createDocumentFragment();
|
|
2219
|
+
if (isMixedContent(src)) {
|
|
2220
|
+
frag.appendChild(unavailable(src, true));
|
|
2190
2221
|
return frag;
|
|
2222
|
+
}
|
|
2223
|
+
const card = make("span", "message-media-card", S.card, kind === "image" ? S.cardButton : {});
|
|
2224
|
+
const el = kind === "image"
|
|
2225
|
+
? Object.assign(document.createElement("img"), { src, alt, loading: "lazy" })
|
|
2226
|
+
: Object.assign(document.createElement("video"), { src, controls: true, preload: "metadata" });
|
|
2227
|
+
el.setAttribute("part", "message-media");
|
|
2228
|
+
el.style.cssText = toCssText(Object.assign({}, S.media, kind === "video" ? S.videoMedia : {}, { opacity: 0 }));
|
|
2229
|
+
const skeleton = make("span", "message-media-skeleton", S.skeleton);
|
|
2230
|
+
skeleton.setAttribute("aria-hidden", "true");
|
|
2231
|
+
skeleton.dataset.convaiSkeleton = "";
|
|
2232
|
+
const caption = make("span", "message-media-caption", S.caption);
|
|
2233
|
+
caption.textContent = describeUrl(src);
|
|
2234
|
+
const fail = () => {
|
|
2235
|
+
clearTimeout(timer);
|
|
2236
|
+
card.replaceWith(unavailable(src, false));
|
|
2237
|
+
caption.remove();
|
|
2238
|
+
};
|
|
2239
|
+
const settled = () => {
|
|
2240
|
+
clearTimeout(timer);
|
|
2241
|
+
el.style.opacity = "1";
|
|
2242
|
+
skeleton.remove();
|
|
2243
|
+
if (kind === "image") {
|
|
2244
|
+
const zoom = make("span", "message-media-zoom", S.zoom);
|
|
2245
|
+
zoom.innerHTML = glyph("zoom");
|
|
2246
|
+
card.appendChild(zoom);
|
|
2247
|
+
}
|
|
2191
2248
|
};
|
|
2192
|
-
const
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2249
|
+
const timer = setTimeout(fail, PREVIEW_TIMEOUT_MS);
|
|
2250
|
+
el.addEventListener(kind === "image" ? "load" : "loadedmetadata", settled);
|
|
2251
|
+
el.addEventListener("error", fail);
|
|
2252
|
+
if (kind === "image") {
|
|
2253
|
+
card.setAttribute("role", "button");
|
|
2254
|
+
card.tabIndex = 0;
|
|
2255
|
+
card.setAttribute("aria-label", `Open image: ${fileNameOf(src)}`);
|
|
2256
|
+
const open = () => openLightbox({
|
|
2257
|
+
src,
|
|
2258
|
+
alt,
|
|
2259
|
+
caption: describeUrl(src),
|
|
2260
|
+
href: src,
|
|
2261
|
+
root: styleTarget,
|
|
2262
|
+
returnFocusTo: card,
|
|
2263
|
+
});
|
|
2264
|
+
card.addEventListener("click", open);
|
|
2265
|
+
card.addEventListener("keydown", (e) => {
|
|
2266
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
2267
|
+
e.preventDefault();
|
|
2268
|
+
open();
|
|
2269
|
+
}
|
|
2270
|
+
});
|
|
2271
|
+
}
|
|
2272
|
+
card.append(el, skeleton);
|
|
2273
|
+
frag.append(card, caption);
|
|
2274
|
+
return frag;
|
|
2275
|
+
};
|
|
2276
|
+
const processLine = (line) => {
|
|
2277
|
+
const parts = [];
|
|
2278
|
+
for (const node of parseInlineMarkdown(line)) {
|
|
2279
|
+
switch (node.kind) {
|
|
2280
|
+
case "strong": {
|
|
2281
|
+
// matches React UserBubble styling
|
|
2282
|
+
const strong = document.createElement("strong");
|
|
2283
|
+
strong.textContent = node.text;
|
|
2284
|
+
strong.style.cssText = `
|
|
2201
2285
|
font-weight: 600;
|
|
2202
2286
|
color: var(--convai-panel-fg, ${aeroTheme.colors.text.primary});
|
|
2203
2287
|
`;
|
|
2204
|
-
|
|
2205
|
-
|
|
2288
|
+
parts.push(strong);
|
|
2289
|
+
break;
|
|
2290
|
+
}
|
|
2291
|
+
case "em": {
|
|
2292
|
+
const em = document.createElement("em");
|
|
2293
|
+
em.textContent = node.text;
|
|
2294
|
+
em.style.cssText = `font-style: italic;`;
|
|
2295
|
+
parts.push(em);
|
|
2296
|
+
break;
|
|
2297
|
+
}
|
|
2298
|
+
case "blocked": {
|
|
2299
|
+
// Not an anchor, ever. The label reads as the character wrote it;
|
|
2300
|
+
// the target is only revealed on hover.
|
|
2301
|
+
const blocked = make("span", "message-link-blocked", S.blocked);
|
|
2302
|
+
blocked.textContent = node.label;
|
|
2303
|
+
blocked.title = `Link blocked: ${node.href}`;
|
|
2304
|
+
parts.push(blocked);
|
|
2305
|
+
break;
|
|
2306
|
+
}
|
|
2307
|
+
case "image": {
|
|
2308
|
+
if (media && budget.cards < MAX_CARDS_PER_MESSAGE) {
|
|
2309
|
+
budget.cards++;
|
|
2310
|
+
parts.push(mediaPreview(node.src, node.alt, "image"));
|
|
2206
2311
|
}
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
parts.push(em);
|
|
2212
|
-
break;
|
|
2312
|
+
else {
|
|
2313
|
+
// With previews off (or the budget spent), an image still has to
|
|
2314
|
+
// say what it pointed at, so it degrades to a plain anchor.
|
|
2315
|
+
parts.push(anchor(node.src, "image", node.alt || node.src));
|
|
2213
2316
|
}
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
a.setAttribute("part", "message-link");
|
|
2221
|
-
a.style.cssText = `
|
|
2222
|
-
color: #10b981;
|
|
2223
|
-
text-decoration: underline;
|
|
2224
|
-
word-break: break-all;
|
|
2225
|
-
`;
|
|
2226
|
-
parts.push(a);
|
|
2227
|
-
if (media && node.media)
|
|
2228
|
-
parts.push(mediaPreview(node.href, node.label, node.media));
|
|
2317
|
+
break;
|
|
2318
|
+
}
|
|
2319
|
+
case "link": {
|
|
2320
|
+
const kind = linkKindForUrl(node.href);
|
|
2321
|
+
if (kind === "email" || kind === "phone" || kind === "sms") {
|
|
2322
|
+
parts.push(media ? contactChip(node.href, kind) : anchor(node.href, kind, node.label));
|
|
2229
2323
|
break;
|
|
2230
2324
|
}
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
parts.push(blocked);
|
|
2325
|
+
parts.push(anchor(node.href, kind, node.label));
|
|
2326
|
+
// The budget is spent when the card mounts, not when it resolves,
|
|
2327
|
+
// so the cap stays deterministic for a message naming twenty pages.
|
|
2328
|
+
const wantsSiteCard = media &&
|
|
2329
|
+
kind === "web" &&
|
|
2330
|
+
!!options.linkPreviewResolver &&
|
|
2331
|
+
budget.cards < MAX_CARDS_PER_MESSAGE;
|
|
2332
|
+
if (wantsSiteCard) {
|
|
2333
|
+
budget.cards++;
|
|
2334
|
+
parts.push(siteCard(node.href));
|
|
2242
2335
|
break;
|
|
2243
2336
|
}
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
}
|
|
2249
|
-
// With previews off, an image still has to say what it pointed at,
|
|
2250
|
-
// so it degrades to the same anchor a plain link would render.
|
|
2251
|
-
const imgLink = document.createElement("a");
|
|
2252
|
-
imgLink.href = node.src;
|
|
2253
|
-
imgLink.textContent = node.alt || node.src;
|
|
2254
|
-
imgLink.target = "_blank";
|
|
2255
|
-
imgLink.rel = "noopener noreferrer";
|
|
2256
|
-
imgLink.setAttribute("part", "message-link");
|
|
2257
|
-
imgLink.style.cssText = `
|
|
2258
|
-
color: #10b981;
|
|
2259
|
-
text-decoration: underline;
|
|
2260
|
-
word-break: break-all;
|
|
2261
|
-
`;
|
|
2262
|
-
parts.push(imgLink);
|
|
2337
|
+
const wantsCard = media &&
|
|
2338
|
+
(kind === "image" || kind === "video" || kind === "document") &&
|
|
2339
|
+
budget.cards < MAX_CARDS_PER_MESSAGE;
|
|
2340
|
+
if (!wantsCard)
|
|
2263
2341
|
break;
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2342
|
+
budget.cards++;
|
|
2343
|
+
parts.push(kind === "document" ? documentCard(node.href) : mediaPreview(node.href, node.label, kind));
|
|
2344
|
+
break;
|
|
2267
2345
|
}
|
|
2346
|
+
default:
|
|
2347
|
+
parts.push(document.createTextNode(node.text));
|
|
2268
2348
|
}
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2349
|
+
}
|
|
2350
|
+
return parts;
|
|
2351
|
+
};
|
|
2352
|
+
lines.forEach((line, lineIndex) => {
|
|
2353
|
+
// An empty line is paragraph spacing.
|
|
2273
2354
|
if (line.trim() === "" && lineIndex > 0) {
|
|
2274
2355
|
container.appendChild(document.createElement("br"));
|
|
2275
2356
|
return;
|
|
2276
2357
|
}
|
|
2277
|
-
|
|
2278
|
-
if (
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
else {
|
|
2358
|
+
const processed = processLine(line);
|
|
2359
|
+
if (processed.length > 0)
|
|
2360
|
+
processed.forEach((p) => container.appendChild(p));
|
|
2361
|
+
else
|
|
2282
2362
|
container.appendChild(document.createTextNode(line));
|
|
2283
|
-
|
|
2284
|
-
// Add line break between lines
|
|
2285
|
-
if (lineIndex < lines.length - 1) {
|
|
2363
|
+
if (lineIndex < lines.length - 1)
|
|
2286
2364
|
container.appendChild(document.createElement("br"));
|
|
2287
|
-
}
|
|
2288
2365
|
});
|
|
2289
2366
|
};
|
|
2290
2367
|
const updateMessageList = () => {
|
|
@@ -2787,4 +2864,3 @@ export function createConvaiWidget(container, options) {
|
|
|
2787
2864
|
export function destroyConvaiWidget(widget) {
|
|
2788
2865
|
widget.destroy();
|
|
2789
2866
|
}
|
|
2790
|
-
//# sourceMappingURL=ConvaiWidget.js.map
|
package/dist/vanilla/icons.d.ts
CHANGED
package/dist/vanilla/icons.js
CHANGED
package/dist/vanilla/index.d.ts
CHANGED
|
@@ -36,5 +36,8 @@ export { createConvaiWidget, destroyConvaiWidget } from './ConvaiWidget.js';
|
|
|
36
36
|
export * from '../core/types.js';
|
|
37
37
|
export { parseInlineMarkdown, mediaKindForUrl, isSafeHref, compactUrl } from '../utils/inlineMarkdown.js';
|
|
38
38
|
export type { InlineNode, MediaKind } from '../utils/inlineMarkdown.js';
|
|
39
|
+
export { linkKindForUrl, describeUrl } from '../utils/linkPresentation.js';
|
|
40
|
+
export type { LinkKind } from '../utils/linkPresentation.js';
|
|
41
|
+
export { resolveLinkPreviewCached, isCardWorthy, LINK_PREVIEW_TIMEOUT_MS } from '../utils/linkPreview.js';
|
|
42
|
+
export type { LinkPreviewMeta, LinkPreviewResolver } from '../utils/linkPreview.js';
|
|
39
43
|
export type { VanillaWidget, VanillaWidgetOptions, WidgetPlacement, } from './types.js';
|
|
40
|
-
//# sourceMappingURL=index.d.ts.map
|