@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.
Files changed (342) hide show
  1. package/README.md +35 -43
  2. package/dist/core/AudioManager.d.ts +0 -1
  3. package/dist/core/AudioManager.js +0 -1
  4. package/dist/core/BlendshapeQueue.d.ts +0 -1
  5. package/dist/core/BlendshapeQueue.js +20 -6
  6. package/dist/core/CharacterRoster.d.ts +0 -1
  7. package/dist/core/CharacterRoster.js +0 -1
  8. package/dist/core/CharacterVersionManager.d.ts +0 -1
  9. package/dist/core/CharacterVersionManager.js +0 -1
  10. package/dist/core/ConnectionStateHandler.d.ts +0 -1
  11. package/dist/core/ConnectionStateHandler.js +5 -2
  12. package/dist/core/ConvaiClient.d.ts +66 -3
  13. package/dist/core/ConvaiClient.js +253 -20
  14. package/dist/core/ConvaiRoomError.d.ts +0 -1
  15. package/dist/core/ConvaiRoomError.js +20 -2
  16. package/dist/core/EventEmitter.d.ts +0 -1
  17. package/dist/core/EventEmitter.js +0 -1
  18. package/dist/core/MemoryManager.d.ts +0 -1
  19. package/dist/core/MemoryManager.js +0 -1
  20. package/dist/core/MessageHandler.d.ts +5 -3
  21. package/dist/core/MessageHandler.js +125 -47
  22. package/dist/core/SSESession.d.ts +13 -9
  23. package/dist/core/SSESession.js +240 -13
  24. package/dist/core/ScreenShareManager.d.ts +0 -1
  25. package/dist/core/ScreenShareManager.js +0 -1
  26. package/dist/core/VideoManager.d.ts +0 -1
  27. package/dist/core/VideoManager.js +0 -1
  28. package/dist/core/characterInfo.d.ts +45 -0
  29. package/dist/core/characterInfo.js +55 -0
  30. package/dist/core/characterReference.d.ts +0 -1
  31. package/dist/core/characterReference.js +0 -1
  32. package/dist/core/connectRequest.d.ts +0 -1
  33. package/dist/core/connectRequest.js +0 -1
  34. package/dist/core/contextUpdateRequest.d.ts +0 -1
  35. package/dist/core/contextUpdateRequest.js +0 -1
  36. package/dist/core/index.d.ts +6 -1
  37. package/dist/core/index.js +20 -1
  38. package/dist/core/logicalTurn.d.ts +0 -1
  39. package/dist/core/logicalTurn.js +0 -1
  40. package/dist/core/modelOutput.d.ts +0 -1
  41. package/dist/core/modelOutput.js +0 -1
  42. package/dist/core/publishedChat.d.ts +0 -1
  43. package/dist/core/publishedChat.js +0 -1
  44. package/dist/core/rosterRequest.d.ts +0 -1
  45. package/dist/core/rosterRequest.js +0 -1
  46. package/dist/core/rtviEnvelope.d.ts +5 -0
  47. package/dist/core/rtviEnvelope.js +9 -0
  48. package/dist/core/types.d.ts +241 -17
  49. package/dist/core/types.js +0 -1
  50. package/dist/core/videoSourceState.d.ts +0 -1
  51. package/dist/core/videoSourceState.js +0 -1
  52. package/dist/core/visionRequest.d.ts +0 -1
  53. package/dist/core/visionRequest.js +0 -1
  54. package/dist/embed/index.d.ts +20 -3
  55. package/dist/embed/index.js +20 -3
  56. package/dist/embed/publicationApi.d.ts +0 -1
  57. package/dist/embed/publicationApi.js +0 -1
  58. package/dist/index.d.ts +0 -1
  59. package/dist/index.js +0 -1
  60. package/dist/lipsync-helpers/arkitOrder61.d.ts +0 -1
  61. package/dist/lipsync-helpers/arkitOrder61.js +5 -3
  62. package/dist/lipsync-helpers/createBlendshapeQueue.d.ts +0 -1
  63. package/dist/lipsync-helpers/createBlendshapeQueue.js +7 -1
  64. package/dist/lipsync-helpers/declarativeMapping.d.ts +2 -1
  65. package/dist/lipsync-helpers/declarativeMapping.js +72 -146
  66. package/dist/lipsync-helpers/index.d.ts +0 -1
  67. package/dist/lipsync-helpers/index.js +0 -1
  68. package/dist/lipsync-helpers/mappingTypes.d.ts +6 -5
  69. package/dist/lipsync-helpers/mappingTypes.js +0 -1
  70. package/dist/lipsync-helpers/metahumanOrder251.d.ts +0 -1
  71. package/dist/lipsync-helpers/metahumanOrder251.js +8 -9
  72. package/dist/lipsync-helpers/mhaLimitDrivers.d.ts +0 -1
  73. package/dist/lipsync-helpers/mhaLimitDrivers.js +0 -1
  74. package/dist/lipsync-helpers/naturalness/processor.d.ts +0 -1
  75. package/dist/lipsync-helpers/naturalness/processor.js +6 -4
  76. package/dist/lipsync-helpers/naturalness/profiles/mha.d.ts +0 -1
  77. package/dist/lipsync-helpers/naturalness/profiles/mha.js +0 -1
  78. package/dist/lipsync-helpers/naturalness/types.d.ts +0 -1
  79. package/dist/lipsync-helpers/naturalness/types.js +0 -1
  80. package/dist/lipsync-helpers/presetMappers.d.ts +0 -1
  81. package/dist/lipsync-helpers/presetMappers.js +0 -1
  82. package/dist/react/components/ConvaiWidget.d.ts +9 -1
  83. package/dist/react/components/ConvaiWidget.js +23 -28
  84. package/dist/react/components/index.d.ts +0 -1
  85. package/dist/react/components/index.js +0 -1
  86. package/dist/react/components/rtc-widget/components/AudioSettingsPanel.d.ts +0 -1
  87. package/dist/react/components/rtc-widget/components/AudioSettingsPanel.js +0 -1
  88. package/dist/react/components/rtc-widget/components/AudioVisualizer.d.ts +0 -1
  89. package/dist/react/components/rtc-widget/components/AudioVisualizer.js +0 -1
  90. package/dist/react/components/rtc-widget/components/ConviMessage.d.ts +4 -2
  91. package/dist/react/components/rtc-widget/components/ConviMessage.js +2 -3
  92. package/dist/react/components/rtc-widget/components/FloatingVideo.d.ts +0 -1
  93. package/dist/react/components/rtc-widget/components/FloatingVideo.js +1 -3
  94. package/dist/react/components/rtc-widget/components/MarkdownRenderer.d.ts +21 -4
  95. package/dist/react/components/rtc-widget/components/MarkdownRenderer.js +114 -131
  96. package/dist/react/components/rtc-widget/components/MessageBubble.d.ts +0 -1
  97. package/dist/react/components/rtc-widget/components/MessageBubble.js +0 -1
  98. package/dist/react/components/rtc-widget/components/MessageList.d.ts +4 -2
  99. package/dist/react/components/rtc-widget/components/MessageList.js +2 -3
  100. package/dist/react/components/rtc-widget/components/SiteCard.d.ts +14 -0
  101. package/dist/react/components/rtc-widget/components/SiteCard.js +34 -0
  102. package/dist/react/components/rtc-widget/components/UserMessage.d.ts +0 -1
  103. package/dist/react/components/rtc-widget/components/UserMessage.js +1 -2
  104. package/dist/react/components/rtc-widget/components/conviComponents/ConviButton.d.ts +0 -1
  105. package/dist/react/components/rtc-widget/components/conviComponents/ConviButton.js +0 -1
  106. package/dist/react/components/rtc-widget/components/conviComponents/ConviFooter.d.ts +0 -1
  107. package/dist/react/components/rtc-widget/components/conviComponents/ConviFooter.js +1 -3
  108. package/dist/react/components/rtc-widget/components/conviComponents/ConviHeader.d.ts +0 -1
  109. package/dist/react/components/rtc-widget/components/conviComponents/ConviHeader.js +1 -3
  110. package/dist/react/components/rtc-widget/components/conviComponents/SettingsTray.d.ts +0 -1
  111. package/dist/react/components/rtc-widget/components/conviComponents/SettingsTray.js +1 -4
  112. package/dist/react/components/rtc-widget/components/conviComponents/VoiceModeOverlay.d.ts +0 -1
  113. package/dist/react/components/rtc-widget/components/conviComponents/VoiceModeOverlay.js +0 -1
  114. package/dist/react/components/rtc-widget/components/conviComponents/index.d.ts +0 -1
  115. package/dist/react/components/rtc-widget/components/conviComponents/index.js +0 -1
  116. package/dist/react/components/rtc-widget/components/index.d.ts +0 -1
  117. package/dist/react/components/rtc-widget/components/index.js +0 -1
  118. package/dist/react/components/rtc-widget/index.d.ts +0 -1
  119. package/dist/react/components/rtc-widget/index.js +0 -1
  120. package/dist/react/components/rtc-widget/styles/framerConfig.d.ts +0 -1
  121. package/dist/react/components/rtc-widget/styles/framerConfig.js +0 -1
  122. package/dist/react/components/rtc-widget/styles/icons.d.ts +0 -1
  123. package/dist/react/components/rtc-widget/styles/icons.js +0 -1
  124. package/dist/react/components/rtc-widget/styles/index.d.ts +0 -1
  125. package/dist/react/components/rtc-widget/styles/index.js +0 -1
  126. package/dist/react/components/rtc-widget/styles/styledComponents.d.ts +0 -1
  127. package/dist/react/components/rtc-widget/styles/styledComponents.js +0 -1
  128. package/dist/react/components/rtc-widget/styles/theme.d.ts +0 -1
  129. package/dist/react/components/rtc-widget/styles/theme.js +0 -1
  130. package/dist/react/components/rtc-widget/types/index.d.ts +0 -1
  131. package/dist/react/components/rtc-widget/types/index.js +0 -1
  132. package/dist/react/hooks/index.d.ts +0 -1
  133. package/dist/react/hooks/index.js +0 -1
  134. package/dist/react/hooks/useCharacterInfo.d.ts +12 -11
  135. package/dist/react/hooks/useCharacterInfo.js +49 -50
  136. package/dist/react/hooks/useConvaiClient.d.ts +0 -1
  137. package/dist/react/hooks/useConvaiClient.js +8 -5
  138. package/dist/react/hooks/useLocalCameraTrack.d.ts +0 -1
  139. package/dist/react/hooks/useLocalCameraTrack.js +0 -1
  140. package/dist/react/icons.d.ts +37 -0
  141. package/dist/react/icons.js +53 -0
  142. package/dist/react/index.d.ts +4 -1
  143. package/dist/react/index.js +2 -1
  144. package/dist/utils/inlineMarkdown.d.ts +0 -1
  145. package/dist/utils/inlineMarkdown.js +0 -1
  146. package/dist/utils/lightbox.d.ts +15 -0
  147. package/dist/utils/lightbox.js +94 -0
  148. package/dist/utils/linkPresentation.d.ts +75 -0
  149. package/dist/utils/linkPresentation.js +414 -0
  150. package/dist/utils/linkPreview.d.ts +45 -0
  151. package/dist/utils/linkPreview.js +71 -0
  152. package/dist/utils/logger.d.ts +0 -1
  153. package/dist/utils/logger.js +0 -1
  154. package/dist/vanilla/AudioRenderer.d.ts +0 -1
  155. package/dist/vanilla/AudioRenderer.js +0 -1
  156. package/dist/vanilla/ConvaiWidget.d.ts +0 -1
  157. package/dist/vanilla/ConvaiWidget.js +302 -226
  158. package/dist/vanilla/WebSocketSession.d.ts +0 -1
  159. package/dist/vanilla/WebSocketSession.js +0 -1
  160. package/dist/vanilla/WidgetEventSubscriptions.d.ts +0 -1
  161. package/dist/vanilla/WidgetEventSubscriptions.js +0 -1
  162. package/dist/vanilla/icons.d.ts +0 -1
  163. package/dist/vanilla/icons.js +0 -1
  164. package/dist/vanilla/index.d.ts +4 -1
  165. package/dist/vanilla/index.js +2 -1
  166. package/dist/vanilla/styles.d.ts +0 -1
  167. package/dist/vanilla/styles.js +9 -1
  168. package/dist/vanilla/types.d.ts +9 -1
  169. package/dist/vanilla/types.js +0 -1
  170. package/dist/vanilla/websocket.d.ts +0 -1
  171. package/dist/vanilla/websocket.js +0 -1
  172. package/dist/version.d.ts +1 -2
  173. package/dist/version.js +1 -2
  174. package/package.json +23 -28
  175. package/dist/core/AudioManager.d.ts.map +0 -1
  176. package/dist/core/AudioManager.js.map +0 -1
  177. package/dist/core/BlendshapeQueue.d.ts.map +0 -1
  178. package/dist/core/BlendshapeQueue.js.map +0 -1
  179. package/dist/core/CharacterRoster.d.ts.map +0 -1
  180. package/dist/core/CharacterRoster.js.map +0 -1
  181. package/dist/core/CharacterVersionManager.d.ts.map +0 -1
  182. package/dist/core/CharacterVersionManager.js.map +0 -1
  183. package/dist/core/ConnectionStateHandler.d.ts.map +0 -1
  184. package/dist/core/ConnectionStateHandler.js.map +0 -1
  185. package/dist/core/ConvaiClient.d.ts.map +0 -1
  186. package/dist/core/ConvaiClient.js.map +0 -1
  187. package/dist/core/ConvaiRoomError.d.ts.map +0 -1
  188. package/dist/core/ConvaiRoomError.js.map +0 -1
  189. package/dist/core/EventEmitter.d.ts.map +0 -1
  190. package/dist/core/EventEmitter.js.map +0 -1
  191. package/dist/core/MemoryManager.d.ts.map +0 -1
  192. package/dist/core/MemoryManager.js.map +0 -1
  193. package/dist/core/MessageHandler.d.ts.map +0 -1
  194. package/dist/core/MessageHandler.js.map +0 -1
  195. package/dist/core/SSESession.d.ts.map +0 -1
  196. package/dist/core/SSESession.js.map +0 -1
  197. package/dist/core/ScreenShareManager.d.ts.map +0 -1
  198. package/dist/core/ScreenShareManager.js.map +0 -1
  199. package/dist/core/VideoManager.d.ts.map +0 -1
  200. package/dist/core/VideoManager.js.map +0 -1
  201. package/dist/core/characterReference.d.ts.map +0 -1
  202. package/dist/core/characterReference.js.map +0 -1
  203. package/dist/core/connectRequest.d.ts.map +0 -1
  204. package/dist/core/connectRequest.js.map +0 -1
  205. package/dist/core/contextUpdateRequest.d.ts.map +0 -1
  206. package/dist/core/contextUpdateRequest.js.map +0 -1
  207. package/dist/core/index.d.ts.map +0 -1
  208. package/dist/core/index.js.map +0 -1
  209. package/dist/core/logicalTurn.d.ts.map +0 -1
  210. package/dist/core/logicalTurn.js.map +0 -1
  211. package/dist/core/modelOutput.d.ts.map +0 -1
  212. package/dist/core/modelOutput.js.map +0 -1
  213. package/dist/core/publishedChat.d.ts.map +0 -1
  214. package/dist/core/publishedChat.js.map +0 -1
  215. package/dist/core/rosterRequest.d.ts.map +0 -1
  216. package/dist/core/rosterRequest.js.map +0 -1
  217. package/dist/core/types.d.ts.map +0 -1
  218. package/dist/core/types.js.map +0 -1
  219. package/dist/core/videoSourceState.d.ts.map +0 -1
  220. package/dist/core/videoSourceState.js.map +0 -1
  221. package/dist/core/visionRequest.d.ts.map +0 -1
  222. package/dist/core/visionRequest.js.map +0 -1
  223. package/dist/embed/ConvaiChatElement.d.ts +0 -103
  224. package/dist/embed/ConvaiChatElement.d.ts.map +0 -1
  225. package/dist/embed/ConvaiChatElement.js +0 -679
  226. package/dist/embed/ConvaiChatElement.js.map +0 -1
  227. package/dist/embed/browser.d.ts +0 -3
  228. package/dist/embed/browser.d.ts.map +0 -1
  229. package/dist/embed/browser.js +0 -5
  230. package/dist/embed/browser.js.map +0 -1
  231. package/dist/embed/chat-embed-v1.js +0 -200
  232. package/dist/embed/chat-embed-v1.js.map +0 -7
  233. package/dist/embed/index.d.ts.map +0 -1
  234. package/dist/embed/index.js.map +0 -1
  235. package/dist/embed/publicationApi.d.ts.map +0 -1
  236. package/dist/embed/publicationApi.js.map +0 -1
  237. package/dist/index.d.ts.map +0 -1
  238. package/dist/index.js.map +0 -1
  239. package/dist/lipsync-helpers/arkitOrder61.d.ts.map +0 -1
  240. package/dist/lipsync-helpers/arkitOrder61.js.map +0 -1
  241. package/dist/lipsync-helpers/createBlendshapeQueue.d.ts.map +0 -1
  242. package/dist/lipsync-helpers/createBlendshapeQueue.js.map +0 -1
  243. package/dist/lipsync-helpers/declarativeMapping.d.ts.map +0 -1
  244. package/dist/lipsync-helpers/declarativeMapping.js.map +0 -1
  245. package/dist/lipsync-helpers/index.d.ts.map +0 -1
  246. package/dist/lipsync-helpers/index.js.map +0 -1
  247. package/dist/lipsync-helpers/mappingTypes.d.ts.map +0 -1
  248. package/dist/lipsync-helpers/mappingTypes.js.map +0 -1
  249. package/dist/lipsync-helpers/metahumanOrder251.d.ts.map +0 -1
  250. package/dist/lipsync-helpers/metahumanOrder251.js.map +0 -1
  251. package/dist/lipsync-helpers/mhaLimitDrivers.d.ts.map +0 -1
  252. package/dist/lipsync-helpers/mhaLimitDrivers.js.map +0 -1
  253. package/dist/lipsync-helpers/naturalness/processor.d.ts.map +0 -1
  254. package/dist/lipsync-helpers/naturalness/processor.js.map +0 -1
  255. package/dist/lipsync-helpers/naturalness/profiles/mha.d.ts.map +0 -1
  256. package/dist/lipsync-helpers/naturalness/profiles/mha.js.map +0 -1
  257. package/dist/lipsync-helpers/naturalness/types.d.ts.map +0 -1
  258. package/dist/lipsync-helpers/naturalness/types.js.map +0 -1
  259. package/dist/lipsync-helpers/presetMappers.d.ts.map +0 -1
  260. package/dist/lipsync-helpers/presetMappers.js.map +0 -1
  261. package/dist/react/components/ConvaiWidget.d.ts.map +0 -1
  262. package/dist/react/components/ConvaiWidget.js.map +0 -1
  263. package/dist/react/components/index.d.ts.map +0 -1
  264. package/dist/react/components/index.js.map +0 -1
  265. package/dist/react/components/rtc-widget/components/AudioSettingsPanel.d.ts.map +0 -1
  266. package/dist/react/components/rtc-widget/components/AudioSettingsPanel.js.map +0 -1
  267. package/dist/react/components/rtc-widget/components/AudioVisualizer.d.ts.map +0 -1
  268. package/dist/react/components/rtc-widget/components/AudioVisualizer.js.map +0 -1
  269. package/dist/react/components/rtc-widget/components/ConviMessage.d.ts.map +0 -1
  270. package/dist/react/components/rtc-widget/components/ConviMessage.js.map +0 -1
  271. package/dist/react/components/rtc-widget/components/FloatingVideo.d.ts.map +0 -1
  272. package/dist/react/components/rtc-widget/components/FloatingVideo.js.map +0 -1
  273. package/dist/react/components/rtc-widget/components/MarkdownRenderer.d.ts.map +0 -1
  274. package/dist/react/components/rtc-widget/components/MarkdownRenderer.js.map +0 -1
  275. package/dist/react/components/rtc-widget/components/MessageBubble.d.ts.map +0 -1
  276. package/dist/react/components/rtc-widget/components/MessageBubble.js.map +0 -1
  277. package/dist/react/components/rtc-widget/components/MessageList.d.ts.map +0 -1
  278. package/dist/react/components/rtc-widget/components/MessageList.js.map +0 -1
  279. package/dist/react/components/rtc-widget/components/UserMessage.d.ts.map +0 -1
  280. package/dist/react/components/rtc-widget/components/UserMessage.js.map +0 -1
  281. package/dist/react/components/rtc-widget/components/conviComponents/ConviButton.d.ts.map +0 -1
  282. package/dist/react/components/rtc-widget/components/conviComponents/ConviButton.js.map +0 -1
  283. package/dist/react/components/rtc-widget/components/conviComponents/ConviFooter.d.ts.map +0 -1
  284. package/dist/react/components/rtc-widget/components/conviComponents/ConviFooter.js.map +0 -1
  285. package/dist/react/components/rtc-widget/components/conviComponents/ConviHeader.d.ts.map +0 -1
  286. package/dist/react/components/rtc-widget/components/conviComponents/ConviHeader.js.map +0 -1
  287. package/dist/react/components/rtc-widget/components/conviComponents/SettingsTray.d.ts.map +0 -1
  288. package/dist/react/components/rtc-widget/components/conviComponents/SettingsTray.js.map +0 -1
  289. package/dist/react/components/rtc-widget/components/conviComponents/VoiceModeOverlay.d.ts.map +0 -1
  290. package/dist/react/components/rtc-widget/components/conviComponents/VoiceModeOverlay.js.map +0 -1
  291. package/dist/react/components/rtc-widget/components/conviComponents/index.d.ts.map +0 -1
  292. package/dist/react/components/rtc-widget/components/conviComponents/index.js.map +0 -1
  293. package/dist/react/components/rtc-widget/components/index.d.ts.map +0 -1
  294. package/dist/react/components/rtc-widget/components/index.js.map +0 -1
  295. package/dist/react/components/rtc-widget/index.d.ts.map +0 -1
  296. package/dist/react/components/rtc-widget/index.js.map +0 -1
  297. package/dist/react/components/rtc-widget/styles/framerConfig.d.ts.map +0 -1
  298. package/dist/react/components/rtc-widget/styles/framerConfig.js.map +0 -1
  299. package/dist/react/components/rtc-widget/styles/icons.d.ts.map +0 -1
  300. package/dist/react/components/rtc-widget/styles/icons.js.map +0 -1
  301. package/dist/react/components/rtc-widget/styles/index.d.ts.map +0 -1
  302. package/dist/react/components/rtc-widget/styles/index.js.map +0 -1
  303. package/dist/react/components/rtc-widget/styles/styledComponents.d.ts.map +0 -1
  304. package/dist/react/components/rtc-widget/styles/styledComponents.js.map +0 -1
  305. package/dist/react/components/rtc-widget/styles/theme.d.ts.map +0 -1
  306. package/dist/react/components/rtc-widget/styles/theme.js.map +0 -1
  307. package/dist/react/components/rtc-widget/types/index.d.ts.map +0 -1
  308. package/dist/react/components/rtc-widget/types/index.js.map +0 -1
  309. package/dist/react/hooks/index.d.ts.map +0 -1
  310. package/dist/react/hooks/index.js.map +0 -1
  311. package/dist/react/hooks/useCharacterInfo.d.ts.map +0 -1
  312. package/dist/react/hooks/useCharacterInfo.js.map +0 -1
  313. package/dist/react/hooks/useConvaiClient.d.ts.map +0 -1
  314. package/dist/react/hooks/useConvaiClient.js.map +0 -1
  315. package/dist/react/hooks/useLocalCameraTrack.d.ts.map +0 -1
  316. package/dist/react/hooks/useLocalCameraTrack.js.map +0 -1
  317. package/dist/react/index.d.ts.map +0 -1
  318. package/dist/react/index.js.map +0 -1
  319. package/dist/utils/inlineMarkdown.d.ts.map +0 -1
  320. package/dist/utils/inlineMarkdown.js.map +0 -1
  321. package/dist/utils/logger.d.ts.map +0 -1
  322. package/dist/utils/logger.js.map +0 -1
  323. package/dist/vanilla/AudioRenderer.d.ts.map +0 -1
  324. package/dist/vanilla/AudioRenderer.js.map +0 -1
  325. package/dist/vanilla/ConvaiWidget.d.ts.map +0 -1
  326. package/dist/vanilla/ConvaiWidget.js.map +0 -1
  327. package/dist/vanilla/WebSocketSession.d.ts.map +0 -1
  328. package/dist/vanilla/WebSocketSession.js.map +0 -1
  329. package/dist/vanilla/WidgetEventSubscriptions.d.ts.map +0 -1
  330. package/dist/vanilla/WidgetEventSubscriptions.js.map +0 -1
  331. package/dist/vanilla/icons.d.ts.map +0 -1
  332. package/dist/vanilla/icons.js.map +0 -1
  333. package/dist/vanilla/index.d.ts.map +0 -1
  334. package/dist/vanilla/index.js.map +0 -1
  335. package/dist/vanilla/styles.d.ts.map +0 -1
  336. package/dist/vanilla/styles.js.map +0 -1
  337. package/dist/vanilla/types.d.ts.map +0 -1
  338. package/dist/vanilla/types.js.map +0 -1
  339. package/dist/vanilla/websocket.d.ts.map +0 -1
  340. package/dist/vanilla/websocket.js.map +0 -1
  341. package/dist/version.d.ts.map +0 -1
  342. package/dist/version.js.map +0 -1
@@ -0,0 +1,75 @@
1
+ export type LinkKind = "web" | "image" | "video" | "document" | "email" | "phone" | "sms" | "ftp";
2
+ /** How long a card may shimmer before it is treated as failed. */
3
+ export declare const PREVIEW_TIMEOUT_MS = 12000;
4
+ /** Cards beyond this in one message render as plain anchors. */
5
+ export declare const MAX_CARDS_PER_MESSAGE = 6;
6
+ /**
7
+ * The presentation class of a safe URL. Distinct from `mediaKindForUrl`,
8
+ * which stays the embed hint (`image | video | null`) that custom renderers
9
+ * already branch on; this adds the kinds that get a chip or a file card.
10
+ */
11
+ export declare function linkKindForUrl(url: string): LinkKind;
12
+ /** `cdn.example.com/a/b/c.png` → `cdn.example.com · c.png` */
13
+ export declare function describeUrl(url: string): string;
14
+ /** The last path segment, for captions and aria labels; the whole URL when unparseable. */
15
+ export declare function fileNameOf(url: string): string;
16
+ /** Upper-case extension for the file tile; `FILE` when there is none worth showing. */
17
+ export declare function documentBadge(url: string): string;
18
+ /** `mailto:a@b.com?subject=x` → `a@b.com`; `tel:+1` → `+1` */
19
+ export declare function contactLabel(href: string): string;
20
+ /**
21
+ * The `title` attribute for an anchor of this kind, or nothing when it would
22
+ * only repeat the visible label. For a web link this is how a compacted or
23
+ * labelled URL reveals its real target before anyone clicks.
24
+ */
25
+ export declare function hoverTitle(kind: LinkKind, href: string, label: string): string | undefined;
26
+ /** An `http:` asset cannot load on an `https:` page; do not even try. */
27
+ export declare function isMixedContent(src: string, pageProtocol?: string): boolean;
28
+ export type GlyphName = "document" | "email" | "phone" | "sms" | "ftp" | "zoom" | "close" | "external";
29
+ /** Inline SVG for a glyph. Strings, not elements, so both renderers can use them. */
30
+ export declare function glyph(name: GlyphName): string;
31
+ export type StyleObject = Record<string, string | number>;
32
+ /** `{ marginTop: 6 }` → `margin-top: 6px;` — the vanilla widget authors cssText. */
33
+ export declare function toCssText(style: StyleObject): string;
34
+ /**
35
+ * Every visual the link layer draws, as one style object per element. React
36
+ * spreads these; vanilla serialises them with `toCssText`. Chrome derives from
37
+ * `currentColor` because the widget sits on a host page whose background it
38
+ * cannot know.
39
+ */
40
+ export declare const presentationStyles: {
41
+ link: StyleObject;
42
+ /** Applied on focus-visible by the renderer; kept here so both agree. */
43
+ linkFocus: StyleObject;
44
+ blocked: StyleObject;
45
+ card: StyleObject;
46
+ cardButton: StyleObject;
47
+ zoom: StyleObject;
48
+ media: StyleObject;
49
+ videoMedia: StyleObject;
50
+ skeleton: StyleObject;
51
+ caption: StyleObject;
52
+ unavailable: StyleObject;
53
+ fileCard: StyleObject;
54
+ fileIcon: StyleObject;
55
+ fileBody: StyleObject;
56
+ fileName: StyleObject;
57
+ fileMeta: StyleObject;
58
+ contact: StyleObject;
59
+ contactGlyph: StyleObject;
60
+ badge: StyleObject;
61
+ lightboxBackdrop: StyleObject;
62
+ lightbox: StyleObject;
63
+ lightboxImage: StyleObject;
64
+ lightboxCaption: StyleObject;
65
+ lightboxControls: StyleObject;
66
+ lightboxButton: StyleObject;
67
+ lightboxFallback: StyleObject;
68
+ siteCard: StyleObject;
69
+ siteHeader: StyleObject;
70
+ siteFavicon: StyleObject;
71
+ siteName: StyleObject;
72
+ siteTitle: StyleObject;
73
+ siteDescription: StyleObject;
74
+ siteImage: StyleObject;
75
+ };
@@ -0,0 +1,414 @@
1
+ /**
2
+ * How a link the character sent should look and behave — shared by the React
3
+ * `MarkdownRenderer` and the vanilla widget so the two cannot drift.
4
+ *
5
+ * The tokenizer (`inlineMarkdown.ts`) decides what IS a link and keeps
6
+ * unsafe schemes off anchors. This module decides how a safe link is
7
+ * presented: which kind of card or chip, what the hover title says, and the
8
+ * failure budget a preview gets before it collapses. Pure functions and
9
+ * style objects only; no DOM, so it is testable without a renderer.
10
+ */
11
+ import { compactUrl } from "./inlineMarkdown.js";
12
+ const IMAGE_EXT = /\.(png|jpe?g|gif|webp|avif)$/i;
13
+ const VIDEO_EXT = /\.(mp4|webm|mov|ogg)$/i;
14
+ const DOCUMENT_EXT = /\.(pdf|docx?|xlsx?|csv|pptx?|txt|md|zip)$/i;
15
+ /** How long a card may shimmer before it is treated as failed. */
16
+ export const PREVIEW_TIMEOUT_MS = 12000;
17
+ /** Cards beyond this in one message render as plain anchors. */
18
+ export const MAX_CARDS_PER_MESSAGE = 6;
19
+ /**
20
+ * The presentation class of a safe URL. Distinct from `mediaKindForUrl`,
21
+ * which stays the embed hint (`image | video | null`) that custom renderers
22
+ * already branch on; this adds the kinds that get a chip or a file card.
23
+ */
24
+ export function linkKindForUrl(url) {
25
+ const scheme = /^([a-z][a-z0-9+.-]*):/i.exec(url)?.[1]?.toLowerCase();
26
+ if (scheme === "mailto")
27
+ return "email";
28
+ if (scheme === "tel")
29
+ return "phone";
30
+ if (scheme === "sms")
31
+ return "sms";
32
+ if (scheme === "ftp" || scheme === "ftps")
33
+ return "ftp";
34
+ let pathname;
35
+ try {
36
+ pathname = new URL(url).pathname;
37
+ }
38
+ catch {
39
+ return "web";
40
+ }
41
+ if (IMAGE_EXT.test(pathname))
42
+ return "image";
43
+ if (VIDEO_EXT.test(pathname))
44
+ return "video";
45
+ if (DOCUMENT_EXT.test(pathname))
46
+ return "document";
47
+ return "web";
48
+ }
49
+ /** `cdn.example.com/a/b/c.png` → `cdn.example.com · c.png` */
50
+ export function describeUrl(url) {
51
+ try {
52
+ const { host, pathname } = new URL(url);
53
+ const file = pathname.split("/").filter(Boolean).pop();
54
+ return file ? `${host} · ${file}` : host;
55
+ }
56
+ catch {
57
+ return compactUrl(url);
58
+ }
59
+ }
60
+ /** The last path segment, for captions and aria labels; the whole URL when unparseable. */
61
+ export function fileNameOf(url) {
62
+ try {
63
+ return new URL(url).pathname.split("/").filter(Boolean).pop() ?? url;
64
+ }
65
+ catch {
66
+ return url;
67
+ }
68
+ }
69
+ /** Upper-case extension for the file tile; `FILE` when there is none worth showing. */
70
+ export function documentBadge(url) {
71
+ const ext = /\.([a-z0-9]{1,5})$/i.exec(fileNameOf(url))?.[1];
72
+ return ext ? ext.toUpperCase() : "FILE";
73
+ }
74
+ /** `mailto:a@b.com?subject=x` → `a@b.com`; `tel:+1` → `+1` */
75
+ export function contactLabel(href) {
76
+ return href.replace(/^[a-z][a-z0-9+.-]*:/i, "").split("?")[0];
77
+ }
78
+ /**
79
+ * The `title` attribute for an anchor of this kind, or nothing when it would
80
+ * only repeat the visible label. For a web link this is how a compacted or
81
+ * labelled URL reveals its real target before anyone clicks.
82
+ */
83
+ export function hoverTitle(kind, href, label) {
84
+ switch (kind) {
85
+ case "email":
86
+ return `Send an email to ${contactLabel(href)}`;
87
+ case "phone":
88
+ return `Call ${contactLabel(href)}`;
89
+ case "sms":
90
+ return `Send a text to ${contactLabel(href)}`;
91
+ case "ftp":
92
+ return "FTP link — most browsers no longer open these";
93
+ default:
94
+ return label === href ? undefined : href;
95
+ }
96
+ }
97
+ /** An `http:` asset cannot load on an `https:` page; do not even try. */
98
+ export function isMixedContent(src, pageProtocol = typeof location === "undefined" ? "https:" : location.protocol) {
99
+ return pageProtocol === "https:" && /^http:/i.test(src);
100
+ }
101
+ const SVG_OPEN = '<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">';
102
+ const GLYPH_PATHS = {
103
+ document: '<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"/>',
104
+ email: '<rect x="3" y="5" width="18" height="14" rx="2"/><path d="m3 7 9 6 9-6"/>',
105
+ phone: '<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"/>',
106
+ 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"/>',
107
+ ftp: '<path d="M4 17V7l8 5 8-5v10"/><path d="M4 7h16"/>',
108
+ zoom: '<circle cx="11" cy="11" r="7"/><path d="m21 21-4.3-4.3M11 8v6M8 11h6"/>',
109
+ close: '<path d="M18 6 6 18M6 6l12 12"/>',
110
+ external: '<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"/>',
111
+ };
112
+ /** Inline SVG for a glyph. Strings, not elements, so both renderers can use them. */
113
+ export function glyph(name) {
114
+ return `${SVG_OPEN}${GLYPH_PATHS[name]}</svg>`;
115
+ }
116
+ const UNITLESS = new Set([
117
+ "opacity",
118
+ "zIndex",
119
+ "flex",
120
+ "flexGrow",
121
+ "flexShrink",
122
+ "lineHeight",
123
+ "fontWeight",
124
+ "order",
125
+ "WebkitLineClamp",
126
+ ]);
127
+ /** `{ marginTop: 6 }` → `margin-top: 6px;` — the vanilla widget authors cssText. */
128
+ export function toCssText(style) {
129
+ return Object.entries(style)
130
+ .map(([k, v]) => {
131
+ const prop = k.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`);
132
+ const val = typeof v === "number" && !UNITLESS.has(k) ? `${v}px` : String(v);
133
+ return `${prop}: ${val};`;
134
+ })
135
+ .join(" ");
136
+ }
137
+ const RADIUS = 8;
138
+ const ACCENT = "#10b981";
139
+ const chrome = (pct) => `color-mix(in srgb, currentColor ${pct}%, transparent)`;
140
+ /**
141
+ * Every visual the link layer draws, as one style object per element. React
142
+ * spreads these; vanilla serialises them with `toCssText`. Chrome derives from
143
+ * `currentColor` because the widget sits on a host page whose background it
144
+ * cannot know.
145
+ */
146
+ export const presentationStyles = {
147
+ link: {
148
+ color: ACCENT,
149
+ textDecoration: "underline",
150
+ wordBreak: "break-all",
151
+ borderRadius: 2,
152
+ },
153
+ /** Applied on focus-visible by the renderer; kept here so both agree. */
154
+ linkFocus: { outline: `2px solid ${chrome(60)}`, outlineOffset: 2 },
155
+ blocked: { opacity: 0.75, textDecoration: "underline dotted", cursor: "help" },
156
+ card: {
157
+ display: "block",
158
+ position: "relative",
159
+ marginTop: 6,
160
+ maxWidth: 320,
161
+ aspectRatio: "16 / 10",
162
+ borderRadius: RADIUS,
163
+ overflow: "hidden",
164
+ background: chrome(6),
165
+ boxShadow: `inset 0 0 0 1px ${chrome(10)}`,
166
+ },
167
+ cardButton: { cursor: "zoom-in" },
168
+ zoom: {
169
+ position: "absolute",
170
+ right: 6,
171
+ bottom: 6,
172
+ width: 24,
173
+ height: 24,
174
+ display: "flex",
175
+ alignItems: "center",
176
+ justifyContent: "center",
177
+ borderRadius: 6,
178
+ background: "rgba(0,0,0,.55)",
179
+ color: "#fff",
180
+ fontSize: 14,
181
+ pointerEvents: "none",
182
+ },
183
+ media: {
184
+ display: "block",
185
+ width: "100%",
186
+ height: "100%",
187
+ objectFit: "cover",
188
+ borderRadius: RADIUS,
189
+ transition: "opacity .18s ease",
190
+ },
191
+ videoMedia: { objectFit: "contain" },
192
+ skeleton: {
193
+ position: "absolute",
194
+ inset: 0,
195
+ borderRadius: RADIUS,
196
+ background: chrome(8),
197
+ backgroundImage: `linear-gradient(90deg, transparent, ${chrome(12)}, transparent)`,
198
+ backgroundSize: "200% 100%",
199
+ animation: "convai-preview-shimmer 1.4s ease-in-out infinite",
200
+ },
201
+ caption: {
202
+ display: "block",
203
+ marginTop: 4,
204
+ fontSize: 11,
205
+ opacity: 0.7,
206
+ whiteSpace: "nowrap",
207
+ overflow: "hidden",
208
+ textOverflow: "ellipsis",
209
+ },
210
+ unavailable: {
211
+ display: "block",
212
+ marginTop: 6,
213
+ fontSize: 11,
214
+ opacity: 0.55,
215
+ fontStyle: "italic",
216
+ whiteSpace: "nowrap",
217
+ overflow: "hidden",
218
+ textOverflow: "ellipsis",
219
+ },
220
+ fileCard: {
221
+ display: "flex",
222
+ alignItems: "center",
223
+ gap: 10,
224
+ marginTop: 6,
225
+ maxWidth: 320,
226
+ padding: "8px 10px",
227
+ borderRadius: RADIUS,
228
+ background: chrome(6),
229
+ boxShadow: `inset 0 0 0 1px ${chrome(10)}`,
230
+ color: "inherit",
231
+ textDecoration: "none",
232
+ },
233
+ fileIcon: {
234
+ position: "relative",
235
+ flex: "0 0 auto",
236
+ width: 36,
237
+ height: 44,
238
+ display: "flex",
239
+ alignItems: "flex-end",
240
+ justifyContent: "center",
241
+ paddingBottom: 4,
242
+ boxSizing: "border-box",
243
+ borderRadius: 4,
244
+ background: chrome(10),
245
+ color: ACCENT,
246
+ fontSize: 9,
247
+ fontWeight: 700,
248
+ letterSpacing: ".04em",
249
+ },
250
+ fileBody: { minWidth: 0, display: "flex", flexDirection: "column", gap: 2 },
251
+ fileName: {
252
+ fontSize: 13,
253
+ fontWeight: 600,
254
+ whiteSpace: "nowrap",
255
+ overflow: "hidden",
256
+ textOverflow: "ellipsis",
257
+ },
258
+ fileMeta: {
259
+ fontSize: 11,
260
+ opacity: 0.7,
261
+ whiteSpace: "nowrap",
262
+ overflow: "hidden",
263
+ textOverflow: "ellipsis",
264
+ },
265
+ contact: {
266
+ display: "inline-flex",
267
+ alignItems: "center",
268
+ gap: 4,
269
+ padding: "1px 8px 1px 6px",
270
+ borderRadius: 999,
271
+ background: chrome(8),
272
+ color: ACCENT,
273
+ textDecoration: "none",
274
+ fontSize: "0.95em",
275
+ lineHeight: 1.6,
276
+ verticalAlign: "baseline",
277
+ maxWidth: "100%",
278
+ },
279
+ contactGlyph: { display: "inline-flex", fontSize: 13, opacity: 0.9 },
280
+ badge: {
281
+ display: "inline-block",
282
+ marginLeft: 4,
283
+ padding: "0 4px",
284
+ borderRadius: 3,
285
+ fontSize: 9,
286
+ fontWeight: 700,
287
+ letterSpacing: ".04em",
288
+ verticalAlign: "middle",
289
+ background: chrome(10),
290
+ opacity: 0.8,
291
+ },
292
+ lightboxBackdrop: {
293
+ position: "fixed",
294
+ inset: 0,
295
+ zIndex: 2147483000,
296
+ display: "flex",
297
+ alignItems: "center",
298
+ justifyContent: "center",
299
+ background: "rgba(0,0,0,.82)",
300
+ padding: 24,
301
+ boxSizing: "border-box",
302
+ animation: "convai-lightbox-in .16s ease-out",
303
+ },
304
+ lightbox: {
305
+ position: "relative",
306
+ display: "flex",
307
+ flexDirection: "column",
308
+ alignItems: "center",
309
+ gap: 10,
310
+ maxWidth: "90vw",
311
+ maxHeight: "90vh",
312
+ color: "#fff",
313
+ },
314
+ lightboxImage: {
315
+ display: "block",
316
+ maxWidth: "90vw",
317
+ maxHeight: "calc(90vh - 72px)",
318
+ objectFit: "contain",
319
+ borderRadius: RADIUS,
320
+ background: "#000",
321
+ },
322
+ lightboxCaption: {
323
+ fontSize: 12,
324
+ opacity: 0.8,
325
+ maxWidth: "90vw",
326
+ whiteSpace: "nowrap",
327
+ overflow: "hidden",
328
+ textOverflow: "ellipsis",
329
+ },
330
+ lightboxControls: {
331
+ position: "absolute",
332
+ top: -4,
333
+ right: -4,
334
+ transform: "translateY(-100%)",
335
+ display: "flex",
336
+ gap: 6,
337
+ },
338
+ lightboxButton: {
339
+ display: "inline-flex",
340
+ alignItems: "center",
341
+ gap: 6,
342
+ padding: "6px 10px",
343
+ borderRadius: 999,
344
+ border: "1px solid rgba(255,255,255,.25)",
345
+ background: "rgba(0,0,0,.5)",
346
+ color: "#fff",
347
+ fontSize: 12,
348
+ cursor: "pointer",
349
+ textDecoration: "none",
350
+ },
351
+ lightboxFallback: {
352
+ padding: "32px 40px",
353
+ fontSize: 13,
354
+ opacity: 0.8,
355
+ border: "1px dashed rgba(255,255,255,.3)",
356
+ borderRadius: RADIUS,
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
+ },
414
+ };
@@ -0,0 +1,45 @@
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;
@@ -0,0 +1,71 @@
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
+ }
@@ -24,4 +24,3 @@ export declare const loggerConfig: {
24
24
  isDevelopment: boolean;
25
25
  isProduction: boolean;
26
26
  };
27
- //# sourceMappingURL=logger.d.ts.map
@@ -103,4 +103,3 @@ export const loggerConfig = {
103
103
  isDevelopment,
104
104
  isProduction: !isDevelopment,
105
105
  };
106
- //# sourceMappingURL=logger.js.map
@@ -55,4 +55,3 @@ export declare class AudioRenderer {
55
55
  */
56
56
  destroy(): void;
57
57
  }
58
- //# sourceMappingURL=AudioRenderer.d.ts.map
@@ -159,4 +159,3 @@ export class AudioRenderer {
159
159
  this.room.off(RoomEvent.ParticipantDisconnected, this.boundHandleParticipantDisconnected);
160
160
  }
161
161
  }
162
- //# sourceMappingURL=AudioRenderer.js.map
@@ -44,4 +44,3 @@ export declare function createConvaiWidget(container: HTMLElement, options: Vani
44
44
  * @param widget - Widget instance to destroy
45
45
  */
46
46
  export declare function destroyConvaiWidget(widget: VanillaWidget): void;
47
- //# sourceMappingURL=ConvaiWidget.d.ts.map