@convai/web-sdk 1.9.2 → 2.0.0-beta.1

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 (80) hide show
  1. package/README.md +22 -11
  2. package/dist/core/types.d.ts +2 -2
  3. package/dist/react/hooks/index.d.ts +0 -2
  4. package/dist/react/hooks/index.js +0 -3
  5. package/dist/react/hooks/useConvaiClient.js +0 -16
  6. package/dist/react/index.d.ts +0 -3
  7. package/dist/react/index.js +3 -10
  8. package/dist/vanilla/index.d.ts +6 -18
  9. package/dist/vanilla/index.js +7 -19
  10. package/dist/version.d.ts +1 -1
  11. package/dist/version.js +1 -1
  12. package/package.json +9 -8
  13. package/dist/react/components/ConvaiWidget.d.ts +0 -86
  14. package/dist/react/components/ConvaiWidget.js +0 -610
  15. package/dist/react/components/index.d.ts +0 -1
  16. package/dist/react/components/index.js +0 -2
  17. package/dist/react/components/rtc-widget/components/AudioSettingsPanel.d.ts +0 -9
  18. package/dist/react/components/rtc-widget/components/AudioSettingsPanel.js +0 -315
  19. package/dist/react/components/rtc-widget/components/AudioVisualizer.d.ts +0 -35
  20. package/dist/react/components/rtc-widget/components/AudioVisualizer.js +0 -285
  21. package/dist/react/components/rtc-widget/components/ConviMessage.d.ts +0 -12
  22. package/dist/react/components/rtc-widget/components/ConviMessage.js +0 -13
  23. package/dist/react/components/rtc-widget/components/FloatingVideo.d.ts +0 -8
  24. package/dist/react/components/rtc-widget/components/FloatingVideo.js +0 -120
  25. package/dist/react/components/rtc-widget/components/MarkdownRenderer.d.ts +0 -31
  26. package/dist/react/components/rtc-widget/components/MarkdownRenderer.js +0 -140
  27. package/dist/react/components/rtc-widget/components/MessageBubble.d.ts +0 -9
  28. package/dist/react/components/rtc-widget/components/MessageBubble.js +0 -22
  29. package/dist/react/components/rtc-widget/components/MessageList.d.ts +0 -13
  30. package/dist/react/components/rtc-widget/components/MessageList.js +0 -88
  31. package/dist/react/components/rtc-widget/components/SiteCard.d.ts +0 -14
  32. package/dist/react/components/rtc-widget/components/SiteCard.js +0 -34
  33. package/dist/react/components/rtc-widget/components/UserMessage.d.ts +0 -8
  34. package/dist/react/components/rtc-widget/components/UserMessage.js +0 -14
  35. package/dist/react/components/rtc-widget/components/conviComponents/ConviButton.d.ts +0 -5
  36. package/dist/react/components/rtc-widget/components/conviComponents/ConviButton.js +0 -14
  37. package/dist/react/components/rtc-widget/components/conviComponents/ConviFooter.d.ts +0 -24
  38. package/dist/react/components/rtc-widget/components/conviComponents/ConviFooter.js +0 -170
  39. package/dist/react/components/rtc-widget/components/conviComponents/ConviHeader.d.ts +0 -16
  40. package/dist/react/components/rtc-widget/components/conviComponents/ConviHeader.js +0 -64
  41. package/dist/react/components/rtc-widget/components/conviComponents/SettingsTray.d.ts +0 -11
  42. package/dist/react/components/rtc-widget/components/conviComponents/SettingsTray.js +0 -65
  43. package/dist/react/components/rtc-widget/components/conviComponents/VoiceModeOverlay.d.ts +0 -13
  44. package/dist/react/components/rtc-widget/components/conviComponents/VoiceModeOverlay.js +0 -298
  45. package/dist/react/components/rtc-widget/components/conviComponents/index.d.ts +0 -5
  46. package/dist/react/components/rtc-widget/components/conviComponents/index.js +0 -5
  47. package/dist/react/components/rtc-widget/components/index.d.ts +0 -8
  48. package/dist/react/components/rtc-widget/components/index.js +0 -14
  49. package/dist/react/components/rtc-widget/index.d.ts +0 -5
  50. package/dist/react/components/rtc-widget/index.js +0 -8
  51. package/dist/react/components/rtc-widget/styles/framerConfig.d.ts +0 -115
  52. package/dist/react/components/rtc-widget/styles/framerConfig.js +0 -72
  53. package/dist/react/components/rtc-widget/styles/icons.d.ts +0 -27
  54. package/dist/react/components/rtc-widget/styles/icons.js +0 -256
  55. package/dist/react/components/rtc-widget/styles/index.d.ts +0 -5
  56. package/dist/react/components/rtc-widget/styles/index.js +0 -8
  57. package/dist/react/components/rtc-widget/styles/styledComponents.d.ts +0 -89
  58. package/dist/react/components/rtc-widget/styles/styledComponents.js +0 -662
  59. package/dist/react/components/rtc-widget/styles/theme.d.ts +0 -187
  60. package/dist/react/components/rtc-widget/styles/theme.js +0 -289
  61. package/dist/react/components/rtc-widget/types/index.d.ts +0 -59
  62. package/dist/react/components/rtc-widget/types/index.js +0 -1
  63. package/dist/react/hooks/useCharacterInfo.d.ts +0 -18
  64. package/dist/react/hooks/useCharacterInfo.js +0 -65
  65. package/dist/react/hooks/useLocalCameraTrack.d.ts +0 -21
  66. package/dist/react/hooks/useLocalCameraTrack.js +0 -33
  67. package/dist/react/icons.d.ts +0 -37
  68. package/dist/react/icons.js +0 -53
  69. package/dist/utils/lightbox.d.ts +0 -15
  70. package/dist/utils/lightbox.js +0 -94
  71. package/dist/vanilla/ConvaiWidget.d.ts +0 -46
  72. package/dist/vanilla/ConvaiWidget.js +0 -2866
  73. package/dist/vanilla/WidgetEventSubscriptions.d.ts +0 -14
  74. package/dist/vanilla/WidgetEventSubscriptions.js +0 -36
  75. package/dist/vanilla/icons.d.ts +0 -34
  76. package/dist/vanilla/icons.js +0 -268
  77. package/dist/vanilla/styles.d.ts +0 -168
  78. package/dist/vanilla/styles.js +0 -407
  79. package/dist/vanilla/types.d.ts +0 -170
  80. package/dist/vanilla/types.js +0 -1
@@ -1,37 +0,0 @@
1
- /**
2
- * The icons the React widget draws, as inline SVG.
3
- *
4
- * These were the only 15 icons `react-icons` supplied, and that package is an
5
- * 84 MB install — every icon set it ships — for 9 KB of bundled output. Each
6
- * entry below is the exact element tree react-icons 5.6.0 generates for that
7
- * icon, and `IconBase` reproduces its renderer: the same default
8
- * `stroke`/`fill`/`strokeWidth`, `size` -> `height`/`width`, `color` both as
9
- * an attribute and in `style`, and the `xmlns`. `__tests__/icons.test.tsx`
10
- * pins that equivalence against the server-rendered markup of the original
11
- * components, so a change here that alters a single attribute fails a test.
12
- *
13
- * Only the props the widget passes are supported — `size` and `color`, plus
14
- * ordinary SVG attributes. react-icons' `IconContext` is not: nothing in this
15
- * package ever provided one.
16
- */
17
- import React from "react";
18
- export interface IconProps extends React.SVGAttributes<SVGElement> {
19
- size?: string | number;
20
- color?: string;
21
- title?: string;
22
- }
23
- export declare const FaUser: (props: IconProps) => React.ReactElement;
24
- export declare const FiMoreVertical: (props: IconProps) => React.ReactElement;
25
- export declare const FiMic: (props: IconProps) => React.ReactElement;
26
- export declare const FiSend: (props: IconProps) => React.ReactElement;
27
- export declare const FiPhoneOff: (props: IconProps) => React.ReactElement;
28
- export declare const IoClose: (props: IconProps) => React.ReactElement;
29
- export declare const IoVideocam: (props: IconProps) => React.ReactElement;
30
- export declare const IoVideocamOff: (props: IconProps) => React.ReactElement;
31
- export declare const IoVolumeMute: (props: IconProps) => React.ReactElement;
32
- export declare const IoVolumeHigh: (props: IconProps) => React.ReactElement;
33
- export declare const LiaRedoAltSolid: (props: IconProps) => React.ReactElement;
34
- export declare const MdDragIndicator: (props: IconProps) => React.ReactElement;
35
- export declare const MdScreenShare: (props: IconProps) => React.ReactElement;
36
- export declare const MdStopScreenShare: (props: IconProps) => React.ReactElement;
37
- export declare const PiWaveform: (props: IconProps) => React.ReactElement;
@@ -1,53 +0,0 @@
1
- /**
2
- * The icons the React widget draws, as inline SVG.
3
- *
4
- * These were the only 15 icons `react-icons` supplied, and that package is an
5
- * 84 MB install — every icon set it ships — for 9 KB of bundled output. Each
6
- * entry below is the exact element tree react-icons 5.6.0 generates for that
7
- * icon, and `IconBase` reproduces its renderer: the same default
8
- * `stroke`/`fill`/`strokeWidth`, `size` -> `height`/`width`, `color` both as
9
- * an attribute and in `style`, and the `xmlns`. `__tests__/icons.test.tsx`
10
- * pins that equivalence against the server-rendered markup of the original
11
- * components, so a change here that alters a single attribute fails a test.
12
- *
13
- * Only the props the widget passes are supported — `size` and `color`, plus
14
- * ordinary SVG attributes. react-icons' `IconContext` is not: nothing in this
15
- * package ever provided one.
16
- */
17
- import React from "react";
18
- function renderTree(tree) {
19
- return tree.map((node, i) => React.createElement(node.tag, { key: i, ...node.attr }, renderTree(node.child)));
20
- }
21
- function IconBase({ data, size, title, ...svgProps }) {
22
- const computedSize = size || "1em";
23
- return React.createElement("svg", {
24
- stroke: "currentColor",
25
- fill: "currentColor",
26
- strokeWidth: "0",
27
- ...data.attr,
28
- ...svgProps,
29
- className: svgProps.className,
30
- style: { color: svgProps.color, ...svgProps.style },
31
- height: computedSize,
32
- width: computedSize,
33
- xmlns: "http://www.w3.org/2000/svg",
34
- }, title && React.createElement("title", null, title), renderTree(data.child));
35
- }
36
- function icon(data) {
37
- return (props) => IconBase({ ...props, data });
38
- }
39
- export const FaUser = icon({ "tag": "svg", "attr": { "viewBox": "0 0 448 512" }, "child": [{ "tag": "path", "attr": { "d": "M224 256c70.7 0 128-57.3 128-128S294.7 0 224 0 96 57.3 96 128s57.3 128 128 128zm89.6 32h-16.7c-22.2 10.2-46.9 16-72.9 16s-50.6-5.8-72.9-16h-16.7C60.2 288 0 348.2 0 422.4V464c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48v-41.6c0-74.2-60.2-134.4-134.4-134.4z" }, "child": [] }] });
40
- export const FiMoreVertical = icon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24", "fill": "none", "stroke": "currentColor", "strokeWidth": "2", "strokeLinecap": "round", "strokeLinejoin": "round" }, "child": [{ "tag": "circle", "attr": { "cx": "12", "cy": "12", "r": "1" }, "child": [] }, { "tag": "circle", "attr": { "cx": "12", "cy": "5", "r": "1" }, "child": [] }, { "tag": "circle", "attr": { "cx": "12", "cy": "19", "r": "1" }, "child": [] }] });
41
- export const FiMic = icon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24", "fill": "none", "stroke": "currentColor", "strokeWidth": "2", "strokeLinecap": "round", "strokeLinejoin": "round" }, "child": [{ "tag": "path", "attr": { "d": "M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z" }, "child": [] }, { "tag": "path", "attr": { "d": "M19 10v2a7 7 0 0 1-14 0v-2" }, "child": [] }, { "tag": "line", "attr": { "x1": "12", "y1": "19", "x2": "12", "y2": "23" }, "child": [] }, { "tag": "line", "attr": { "x1": "8", "y1": "23", "x2": "16", "y2": "23" }, "child": [] }] });
42
- export const FiSend = icon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24", "fill": "none", "stroke": "currentColor", "strokeWidth": "2", "strokeLinecap": "round", "strokeLinejoin": "round" }, "child": [{ "tag": "line", "attr": { "x1": "22", "y1": "2", "x2": "11", "y2": "13" }, "child": [] }, { "tag": "polygon", "attr": { "points": "22 2 15 22 11 13 2 9 22 2" }, "child": [] }] });
43
- export const FiPhoneOff = icon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24", "fill": "none", "stroke": "currentColor", "strokeWidth": "2", "strokeLinecap": "round", "strokeLinejoin": "round" }, "child": [{ "tag": "path", "attr": { "d": "M10.68 13.31a16 16 0 0 0 3.41 2.6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7 2 2 0 0 1 1.72 2v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.42 19.42 0 0 1-3.33-2.67m-2.67-3.34a19.79 19.79 0 0 1-3.07-8.63A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91" }, "child": [] }, { "tag": "line", "attr": { "x1": "23", "y1": "1", "x2": "1", "y2": "23" }, "child": [] }] });
44
- export const IoClose = icon({ "tag": "svg", "attr": { "viewBox": "0 0 512 512" }, "child": [{ "tag": "path", "attr": { "d": "m289.94 256 95-95A24 24 0 0 0 351 127l-95 95-95-95a24 24 0 0 0-34 34l95 95-95 95a24 24 0 1 0 34 34l95-95 95 95a24 24 0 0 0 34-34z" }, "child": [] }] });
45
- export const IoVideocam = icon({ "tag": "svg", "attr": { "viewBox": "0 0 512 512" }, "child": [{ "tag": "path", "attr": { "d": "M464 384.39a32 32 0 0 1-13-2.77 15.77 15.77 0 0 1-2.71-1.54l-82.71-58.22A32 32 0 0 1 352 295.7v-79.4a32 32 0 0 1 13.58-26.16l82.71-58.22a15.77 15.77 0 0 1 2.71-1.54 32 32 0 0 1 45 29.24v192.76a32 32 0 0 1-32 32zM268 400H84a68.07 68.07 0 0 1-68-68V180a68.07 68.07 0 0 1 68-68h184.48A67.6 67.6 0 0 1 336 179.52V332a68.07 68.07 0 0 1-68 68z" }, "child": [] }] });
46
- export const IoVideocamOff = icon({ "tag": "svg", "attr": { "viewBox": "0 0 512 512" }, "child": [{ "tag": "path", "attr": { "d": "M336 179.52A67.52 67.52 0 0 0 268.48 112h-79.2a4 4 0 0 0-2.82 6.83l142.71 142.71a4 4 0 0 0 6.83-2.82zM16 180v152a68 68 0 0 0 68 68h184a67.66 67.66 0 0 0 42.84-15.24 4 4 0 0 0 .33-6L54.41 122a4 4 0 0 0-4.87-.62A68 68 0 0 0 16 180zm448 204.39a32 32 0 0 1-13-2.77 15.77 15.77 0 0 1-2.71-1.54l-82.71-58.22A32 32 0 0 1 352 295.7v-79.4a32 32 0 0 1 13.58-26.16l82.71-58.22a15.77 15.77 0 0 1 2.71-1.54 32 32 0 0 1 45 29.24v192.76a32 32 0 0 1-32 32z" }, "child": [] }, { "tag": "path", "attr": { "fill": "none", "strokeLinecap": "round", "strokeMiterlimit": "10", "strokeWidth": "32", "d": "M416 416 80 80" }, "child": [] }] });
47
- export const IoVolumeMute = icon({ "tag": "svg", "attr": { "viewBox": "0 0 512 512" }, "child": [{ "tag": "path", "attr": { "fill": "none", "strokeLinecap": "round", "strokeMiterlimit": "10", "strokeWidth": "32", "d": "M416 432 64 80" }, "child": [] }, { "tag": "path", "attr": { "d": "M243.33 98.86a23.89 23.89 0 0 0-25.55 1.82l-.66.51-28.52 23.35a8 8 0 0 0-.59 11.85l54.33 54.33a8 8 0 0 0 13.66-5.66v-64.49a24.51 24.51 0 0 0-12.67-21.71zm8 236.43L96.69 180.69A16 16 0 0 0 85.38 176H56a24 24 0 0 0-24 24v112a24 24 0 0 0 24 24h69.76l92 75.31a23.9 23.9 0 0 0 25.87 1.69A24.51 24.51 0 0 0 256 391.45v-44.86a16 16 0 0 0-4.67-11.3zM352 256c0-24.56-5.81-47.87-17.75-71.27a16 16 0 1 0-28.5 14.55C315.34 218.06 320 236.62 320 256q0 4-.31 8.13a8 8 0 0 0 2.32 6.25l14.36 14.36a8 8 0 0 0 13.55-4.31A146 146 0 0 0 352 256zm64 0c0-51.18-13.08-83.89-34.18-120.06a16 16 0 0 0-27.64 16.12C373.07 184.44 384 211.83 384 256c0 23.83-3.29 42.88-9.37 60.65a8 8 0 0 0 1.9 8.26L389 337.4a8 8 0 0 0 13.13-2.79C411 311.76 416 287.26 416 256z" }, "child": [] }, { "tag": "path", "attr": { "d": "M480 256c0-74.25-20.19-121.11-50.51-168.61a16 16 0 1 0-27 17.22C429.82 147.38 448 189.5 448 256c0 46.19-8.43 80.27-22.43 110.53a8 8 0 0 0 1.59 9l11.92 11.92a8 8 0 0 0 12.92-2.16C471.6 344.9 480 305 480 256z" }, "child": [] }] });
48
- export const IoVolumeHigh = icon({ "tag": "svg", "attr": { "viewBox": "0 0 512 512" }, "child": [{ "tag": "path", "attr": { "d": "M232 416a23.88 23.88 0 0 1-14.2-4.68 8.27 8.27 0 0 1-.66-.51L125.76 336H56a24 24 0 0 1-24-24V200a24 24 0 0 1 24-24h69.75l91.37-74.81a8.27 8.27 0 0 1 .66-.51A24 24 0 0 1 256 120v272a24 24 0 0 1-24 24zm-106.18-80zm-.27-159.86zM320 336a16 16 0 0 1-14.29-23.19c9.49-18.87 14.3-38 14.3-56.81 0-19.38-4.66-37.94-14.25-56.73a16 16 0 0 1 28.5-14.54C346.19 208.12 352 231.44 352 256c0 23.86-6 47.81-17.7 71.19A16 16 0 0 1 320 336z" }, "child": [] }, { "tag": "path", "attr": { "d": "M368 384a16 16 0 0 1-13.86-24C373.05 327.09 384 299.51 384 256c0-44.17-10.93-71.56-29.82-103.94a16 16 0 0 1 27.64-16.12C402.92 172.11 416 204.81 416 256c0 50.43-13.06 83.29-34.13 120a16 16 0 0 1-13.87 8z" }, "child": [] }, { "tag": "path", "attr": { "d": "M416 432a16 16 0 0 1-13.39-24.74C429.85 365.47 448 323.76 448 256c0-66.5-18.18-108.62-45.49-151.39a16 16 0 1 1 27-17.22C459.81 134.89 480 181.74 480 256c0 64.75-14.66 113.63-50.6 168.74A16 16 0 0 1 416 432z" }, "child": [] }] });
49
- export const LiaRedoAltSolid = icon({ "tag": "svg", "attr": { "viewBox": "0 0 32 32" }, "child": [{ "tag": "path", "attr": { "d": "M 16 3 C 8.832031 3 3 8.832031 3 16 C 3 23.167969 8.832031 29 16 29 C 23.167969 29 29 23.167969 29 16 L 27 16 C 27 22.085938 22.085938 27 16 27 C 9.914063 27 5 22.085938 5 16 C 5 9.914063 9.914063 5 16 5 C 19.875 5 23.261719 6.984375 25.21875 10 L 20 10 L 20 12 L 28 12 L 28 4 L 26 4 L 26 7.71875 C 23.617188 4.84375 20.019531 3 16 3 Z" }, "child": [] }] });
50
- export const MdDragIndicator = icon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24" }, "child": [{ "tag": "path", "attr": { "fill": "none", "d": "M0 0h24v24H0V0z" }, "child": [] }, { "tag": "path", "attr": { "d": "M11 18c0 1.1-.9 2-2 2s-2-.9-2-2 .9-2 2-2 2 .9 2 2zm-2-8c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0-6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm6 4c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z" }, "child": [] }] });
51
- export const MdScreenShare = icon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24" }, "child": [{ "tag": "path", "attr": { "fill": "none", "d": "M0 0h24v24H0V0z" }, "child": [] }, { "tag": "path", "attr": { "d": "M20 18c1.1 0 1.99-.9 1.99-2L22 6a2 2 0 0 0-2-2H4c-1.11 0-2 .89-2 2v10a2 2 0 0 0 2 2H0v2h24v-2h-4zm-7-3.53v-2.19c-2.78 0-4.61.85-6 2.72.56-2.67 2.11-5.33 6-5.87V7l4 3.73-4 3.74z" }, "child": [] }] });
52
- export const MdStopScreenShare = icon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24" }, "child": [{ "tag": "path", "attr": { "fill": "none", "d": "M0 0h24v24H0V0z" }, "child": [] }, { "tag": "path", "attr": { "d": "m21.22 18.02 2 2H24v-2h-2.78zm.77-2 .01-10a2 2 0 0 0-2-2H7.22l5.23 5.23c.18-.04.36-.07.55-.1V7.02l4 3.73-1.58 1.47 5.54 5.54c.61-.33 1.03-.99 1.03-1.74zM2.39 1.73 1.11 3l1.54 1.54c-.4.36-.65.89-.65 1.48v10a2 2 0 0 0 2 2H0v2h18.13l2.71 2.71 1.27-1.27L2.39 1.73zM7 15.02c.31-1.48.92-2.95 2.07-4.06l1.59 1.59c-1.54.38-2.7 1.18-3.66 2.47z" }, "child": [] }] });
53
- export const PiWaveform = icon({ "tag": "svg", "attr": { "viewBox": "0 0 256 256", "fill": "currentColor" }, "child": [{ "tag": "path", "attr": { "d": "M56,96v64a8,8,0,0,1-16,0V96a8,8,0,0,1,16,0ZM88,24a8,8,0,0,0-8,8V224a8,8,0,0,0,16,0V32A8,8,0,0,0,88,24Zm40,32a8,8,0,0,0-8,8V192a8,8,0,0,0,16,0V64A8,8,0,0,0,128,56Zm40,32a8,8,0,0,0-8,8v64a8,8,0,0,0,16,0V96A8,8,0,0,0,168,88Zm40-16a8,8,0,0,0-8,8v96a8,8,0,0,0,16,0V80A8,8,0,0,0,208,72Z" }, "child": [] }] });
@@ -1,15 +0,0 @@
1
- export interface LightboxOptions {
2
- src: string;
3
- alt: string;
4
- /** Shown under the image; normally `describeUrl(src)`. */
5
- caption: string;
6
- /** Target of "Open original". */
7
- href: string;
8
- root: Document | ShadowRoot;
9
- /** Where focus goes back to on close. Defaults to whatever was focused on open. */
10
- returnFocusTo?: HTMLElement | null;
11
- }
12
- export interface LightboxHandle {
13
- close(): void;
14
- }
15
- export declare function openLightbox(opts: LightboxOptions): LightboxHandle;
@@ -1,94 +0,0 @@
1
- /**
2
- * The image lightbox — one plain-DOM implementation used by the React
3
- * renderer and the vanilla widget. Mounted into a Document or a ShadowRoot so
4
- * `part` hooks and the injected keyframes resolve wherever the widget lives.
5
- * One at a time: opening a second closes the first.
6
- */
7
- import { glyph, presentationStyles, toCssText } from "./linkPresentation.js";
8
- import { injectKeyframes } from "../vanilla/styles.js";
9
- let current = null;
10
- const el = (tag, part, style) => {
11
- const node = document.createElement(tag);
12
- node.setAttribute("part", part);
13
- node.style.cssText = toCssText(style);
14
- return node;
15
- };
16
- export function openLightbox(opts) {
17
- current?.close();
18
- injectKeyframes(opts.root);
19
- const mount = opts.root instanceof ShadowRoot ? opts.root : opts.root.body;
20
- const backdrop = el("div", "lightbox-backdrop", presentationStyles.lightboxBackdrop);
21
- backdrop.setAttribute("role", "dialog");
22
- backdrop.setAttribute("aria-modal", "true");
23
- backdrop.setAttribute("aria-label", opts.alt || "Image preview");
24
- const box = el("div", "lightbox", presentationStyles.lightbox);
25
- const img = el("img", "lightbox-image", presentationStyles.lightboxImage);
26
- img.src = opts.src;
27
- img.alt = opts.alt;
28
- const caption = el("span", "lightbox-caption", presentationStyles.lightboxCaption);
29
- caption.textContent = opts.caption;
30
- const controls = el("div", "lightbox-controls", presentationStyles.lightboxControls);
31
- const open = el("a", "lightbox-open", presentationStyles.lightboxButton);
32
- open.href = opts.href;
33
- open.target = "_blank";
34
- open.rel = "noopener noreferrer";
35
- open.innerHTML = `${glyph("external")}<span>Open original</span>`;
36
- const close = el("button", "lightbox-close", presentationStyles.lightboxButton);
37
- close.type = "button";
38
- close.setAttribute("aria-label", "Close image preview");
39
- close.innerHTML = glyph("close");
40
- controls.append(open, close);
41
- // A character can invent a URL; the card already collapsed for that case,
42
- // but the full-size load can still fail on its own. Keep the way out visible.
43
- img.addEventListener("error", () => {
44
- const fallback = el("div", "lightbox-fallback", presentationStyles.lightboxFallback);
45
- fallback.textContent = "Image could not be loaded";
46
- img.replaceWith(fallback);
47
- });
48
- const previousOverflow = document.body.style.overflow;
49
- const restoreFocus = opts.returnFocusTo ?? document.activeElement;
50
- const activeElement = () => opts.root instanceof ShadowRoot ? opts.root.activeElement : document.activeElement;
51
- const onKey = (e) => {
52
- if (e.key === "Escape") {
53
- e.preventDefault();
54
- handle.close();
55
- return;
56
- }
57
- if (e.key === "Tab") {
58
- // Trap between the two controls; there is nothing else to reach.
59
- const active = activeElement();
60
- if (e.shiftKey && active === open) {
61
- e.preventDefault();
62
- close.focus();
63
- }
64
- else if (!e.shiftKey && active === close) {
65
- e.preventDefault();
66
- open.focus();
67
- }
68
- }
69
- };
70
- const handle = {
71
- close() {
72
- if (current !== handle)
73
- return;
74
- current = null;
75
- document.removeEventListener("keydown", onKey, true);
76
- backdrop.remove();
77
- document.body.style.overflow = previousOverflow;
78
- restoreFocus?.focus?.();
79
- },
80
- };
81
- backdrop.addEventListener("click", (e) => {
82
- if (e.target === backdrop)
83
- handle.close();
84
- });
85
- close.addEventListener("click", () => handle.close());
86
- document.addEventListener("keydown", onKey, true);
87
- box.append(controls, img, caption);
88
- backdrop.appendChild(box);
89
- mount.appendChild(backdrop);
90
- document.body.style.overflow = "hidden";
91
- current = handle;
92
- close.focus();
93
- return handle;
94
- }
@@ -1,46 +0,0 @@
1
- /**
2
- * Vanilla ConvaiWidget - Complete UI widget for Convai conversations
3
- * Ports the React ConvaiWidget to vanilla TypeScript with DOM manipulation
4
- */
5
- import type { VanillaWidgetOptions, VanillaWidget } from "./types.js";
6
- /**
7
- * Create a Convai chat widget in the specified container
8
- *
9
- * @param container - HTML element to attach the widget to
10
- * @param options - Widget configuration options
11
- * @returns VanillaWidget instance with destroy method
12
- *
13
- * @example Simple usage with config
14
- * ```typescript
15
- * import { createConvaiWidget } from '@convai/web-sdk/vanilla';
16
- *
17
- * const widget = createConvaiWidget(document.body, {
18
- * apiKey: 'your-api-key',
19
- * characterId: 'your-character-id',
20
- * enableVideo: false
21
- * });
22
- * ```
23
- *
24
- * @example Advanced usage with client instance
25
- * ```typescript
26
- * import { ConvaiClient, createConvaiWidget } from '@convai/web-sdk/vanilla';
27
- *
28
- * const client = new ConvaiClient({
29
- * apiKey: 'your-api-key',
30
- * characterId: 'your-character-id'
31
- * });
32
- *
33
- * const widget = createConvaiWidget(document.body, {
34
- * convaiClient: client,
35
- * showVideo: true,
36
- * showScreenShare: true,
37
- * defaultVoiceMode: true
38
- * });
39
- * ```
40
- */
41
- export declare function createConvaiWidget(container: HTMLElement, options: VanillaWidgetOptions): VanillaWidget;
42
- /**
43
- * Destroy a Convai widget instance
44
- * @param widget - Widget instance to destroy
45
- */
46
- export declare function destroyConvaiWidget(widget: VanillaWidget): void;