@convai/web-widget 0.1.4 → 0.2.0
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 +55 -11
- package/chunks/lightbox-Dxfdw3VU.js +683 -0
- package/index.d.ts +26 -0
- package/index.js +4 -0
- package/package.json +53 -2
- package/react.d.ts +23 -0
- package/react.js +3551 -0
- package/runtime.js +12588 -18085
- package/types.d.ts +62 -0
- package/ui/react/components/ConvaiWidget.d.ts +86 -0
- package/ui/react/components/index.d.ts +1 -0
- package/ui/react/components/rtc-widget/components/AudioSettingsPanel.d.ts +9 -0
- package/ui/react/components/rtc-widget/components/AudioVisualizer.d.ts +35 -0
- package/ui/react/components/rtc-widget/components/ConviMessage.d.ts +13 -0
- package/ui/react/components/rtc-widget/components/FloatingVideo.d.ts +8 -0
- package/ui/react/components/rtc-widget/components/MarkdownRenderer.d.ts +31 -0
- package/ui/react/components/rtc-widget/components/MessageBubble.d.ts +9 -0
- package/ui/react/components/rtc-widget/components/MessageList.d.ts +14 -0
- package/ui/react/components/rtc-widget/components/SiteCard.d.ts +15 -0
- package/ui/react/components/rtc-widget/components/UserMessage.d.ts +9 -0
- package/ui/react/components/rtc-widget/components/conviComponents/ConviButton.d.ts +6 -0
- package/ui/react/components/rtc-widget/components/conviComponents/ConviFooter.d.ts +24 -0
- package/ui/react/components/rtc-widget/components/conviComponents/ConviHeader.d.ts +16 -0
- package/ui/react/components/rtc-widget/components/conviComponents/SettingsTray.d.ts +12 -0
- package/ui/react/components/rtc-widget/components/conviComponents/VoiceModeOverlay.d.ts +14 -0
- package/ui/react/components/rtc-widget/components/conviComponents/index.d.ts +5 -0
- package/ui/react/components/rtc-widget/components/index.d.ts +8 -0
- package/ui/react/components/rtc-widget/index.d.ts +5 -0
- package/ui/react/components/rtc-widget/styles/framerConfig.d.ts +115 -0
- package/ui/react/components/rtc-widget/styles/icons.d.ts +27 -0
- package/ui/react/components/rtc-widget/styles/index.d.ts +5 -0
- package/ui/react/components/rtc-widget/styles/styledComponents.d.ts +53 -0
- package/ui/react/components/rtc-widget/styles/theme.d.ts +187 -0
- package/ui/react/components/rtc-widget/types/index.d.ts +59 -0
- package/ui/react/hooks/useCharacterInfo.d.ts +18 -0
- package/ui/react/hooks/useLocalCameraTrack.d.ts +21 -0
- package/ui/react/icons.d.ts +37 -0
- package/ui/shared/lightbox.d.ts +15 -0
- package/ui/shared/linkStyles.d.ts +64 -0
- package/ui/shared/logger.d.ts +30 -0
- package/ui/vanilla/ConvaiWidget.d.ts +46 -0
- package/ui/vanilla/WidgetEventSubscriptions.d.ts +14 -0
- package/ui/vanilla/icons.d.ts +34 -0
- package/ui/vanilla/styles.d.ts +168 -0
- package/ui/vanilla/types.d.ts +170 -0
- package/vanilla.d.ts +21 -0
- package/vanilla.js +2512 -0
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
export declare const aeroTheme: {
|
|
2
|
+
colors: {
|
|
3
|
+
primary: {
|
|
4
|
+
50: string;
|
|
5
|
+
100: string;
|
|
6
|
+
200: string;
|
|
7
|
+
300: string;
|
|
8
|
+
400: string;
|
|
9
|
+
500: string;
|
|
10
|
+
600: string;
|
|
11
|
+
700: string;
|
|
12
|
+
800: string;
|
|
13
|
+
900: string;
|
|
14
|
+
};
|
|
15
|
+
convai: {
|
|
16
|
+
light: string;
|
|
17
|
+
medium: string;
|
|
18
|
+
dark: string;
|
|
19
|
+
};
|
|
20
|
+
neutral: {
|
|
21
|
+
50: string;
|
|
22
|
+
100: string;
|
|
23
|
+
200: string;
|
|
24
|
+
300: string;
|
|
25
|
+
400: string;
|
|
26
|
+
500: string;
|
|
27
|
+
600: string;
|
|
28
|
+
700: string;
|
|
29
|
+
800: string;
|
|
30
|
+
900: string;
|
|
31
|
+
};
|
|
32
|
+
glass: {
|
|
33
|
+
light: string;
|
|
34
|
+
medium: string;
|
|
35
|
+
dark: string;
|
|
36
|
+
backdrop: string;
|
|
37
|
+
card: string;
|
|
38
|
+
backdropLight: string;
|
|
39
|
+
borderLight: string;
|
|
40
|
+
};
|
|
41
|
+
accent: {
|
|
42
|
+
purple: string;
|
|
43
|
+
green: string;
|
|
44
|
+
blue: string;
|
|
45
|
+
orange: string;
|
|
46
|
+
red: string;
|
|
47
|
+
};
|
|
48
|
+
error: {
|
|
49
|
+
50: string;
|
|
50
|
+
100: string;
|
|
51
|
+
200: string;
|
|
52
|
+
300: string;
|
|
53
|
+
400: string;
|
|
54
|
+
500: string;
|
|
55
|
+
600: string;
|
|
56
|
+
700: string;
|
|
57
|
+
800: string;
|
|
58
|
+
900: string;
|
|
59
|
+
};
|
|
60
|
+
text: {
|
|
61
|
+
primary: string;
|
|
62
|
+
secondary: string;
|
|
63
|
+
tertiary: string;
|
|
64
|
+
inverse: string;
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
typography: {
|
|
68
|
+
fontFamily: {
|
|
69
|
+
primary: string;
|
|
70
|
+
title: string;
|
|
71
|
+
header: string;
|
|
72
|
+
body: string;
|
|
73
|
+
mono: string;
|
|
74
|
+
};
|
|
75
|
+
fontSize: {
|
|
76
|
+
xs: string;
|
|
77
|
+
sm: string;
|
|
78
|
+
base: string;
|
|
79
|
+
lg: string;
|
|
80
|
+
xl: string;
|
|
81
|
+
"2xl": string;
|
|
82
|
+
"3xl": string;
|
|
83
|
+
"4xl": string;
|
|
84
|
+
};
|
|
85
|
+
sizes: {
|
|
86
|
+
xs: string;
|
|
87
|
+
sm: string;
|
|
88
|
+
body: string;
|
|
89
|
+
lg: string;
|
|
90
|
+
xl: string;
|
|
91
|
+
"2xl": string;
|
|
92
|
+
"3xl": string;
|
|
93
|
+
"4xl": string;
|
|
94
|
+
caption: string;
|
|
95
|
+
};
|
|
96
|
+
fontWeight: {
|
|
97
|
+
normal: number;
|
|
98
|
+
medium: number;
|
|
99
|
+
semibold: number;
|
|
100
|
+
bold: number;
|
|
101
|
+
};
|
|
102
|
+
lineHeight: {
|
|
103
|
+
tight: number;
|
|
104
|
+
normal: number;
|
|
105
|
+
relaxed: number;
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
spacing: {
|
|
109
|
+
xs: string;
|
|
110
|
+
sm: string;
|
|
111
|
+
md: string;
|
|
112
|
+
lg: string;
|
|
113
|
+
xl: string;
|
|
114
|
+
"2xl": string;
|
|
115
|
+
"3xl": string;
|
|
116
|
+
};
|
|
117
|
+
borderRadius: {
|
|
118
|
+
none: string;
|
|
119
|
+
sm: string;
|
|
120
|
+
md: string;
|
|
121
|
+
lg: string;
|
|
122
|
+
xl: string;
|
|
123
|
+
"2xl": string;
|
|
124
|
+
full: string;
|
|
125
|
+
};
|
|
126
|
+
shadows: {
|
|
127
|
+
sm: string;
|
|
128
|
+
md: string;
|
|
129
|
+
lg: string;
|
|
130
|
+
xl: string;
|
|
131
|
+
glass: string;
|
|
132
|
+
};
|
|
133
|
+
glass: {
|
|
134
|
+
backdrop: string;
|
|
135
|
+
backdropLight: string;
|
|
136
|
+
backdropHeavy: string;
|
|
137
|
+
border: string;
|
|
138
|
+
borderLight: string;
|
|
139
|
+
};
|
|
140
|
+
transitions: {
|
|
141
|
+
fast: string;
|
|
142
|
+
normal: string;
|
|
143
|
+
slow: string;
|
|
144
|
+
spring: string;
|
|
145
|
+
snappy: string;
|
|
146
|
+
};
|
|
147
|
+
zIndex: {
|
|
148
|
+
base: number;
|
|
149
|
+
dropdown: number;
|
|
150
|
+
sticky: number;
|
|
151
|
+
fixed: number;
|
|
152
|
+
modal: number;
|
|
153
|
+
popover: number;
|
|
154
|
+
tooltip: number;
|
|
155
|
+
};
|
|
156
|
+
};
|
|
157
|
+
export declare const glassStyles: {
|
|
158
|
+
container: string;
|
|
159
|
+
overlay: string;
|
|
160
|
+
card: string;
|
|
161
|
+
input: string;
|
|
162
|
+
button: string;
|
|
163
|
+
};
|
|
164
|
+
export declare const iconSizes: {
|
|
165
|
+
xs: string;
|
|
166
|
+
sm: string;
|
|
167
|
+
md: string;
|
|
168
|
+
lg: string;
|
|
169
|
+
xl: string;
|
|
170
|
+
"2xl": string;
|
|
171
|
+
};
|
|
172
|
+
export declare const variants: {
|
|
173
|
+
button: {
|
|
174
|
+
primary: string;
|
|
175
|
+
secondary: string;
|
|
176
|
+
ghost: string;
|
|
177
|
+
};
|
|
178
|
+
input: {
|
|
179
|
+
default: string;
|
|
180
|
+
search: string;
|
|
181
|
+
};
|
|
182
|
+
card: {
|
|
183
|
+
default: string;
|
|
184
|
+
elevated: string;
|
|
185
|
+
interactive: string;
|
|
186
|
+
};
|
|
187
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
export interface RTCChatMessage {
|
|
2
|
+
id: string;
|
|
3
|
+
text: string;
|
|
4
|
+
isUser: boolean;
|
|
5
|
+
timestamp: string;
|
|
6
|
+
sender: string;
|
|
7
|
+
showLogo?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface CharacterVerbosityConfig {
|
|
10
|
+
characterId: string;
|
|
11
|
+
label?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface ConviUIProps {
|
|
14
|
+
isOpen: boolean;
|
|
15
|
+
backgroundOpacity?: number;
|
|
16
|
+
alwaysExpanded?: boolean;
|
|
17
|
+
characterName?: string;
|
|
18
|
+
characterImage?: string;
|
|
19
|
+
verbosityLevels?: Array<{
|
|
20
|
+
index: number;
|
|
21
|
+
characterId: string;
|
|
22
|
+
label?: string;
|
|
23
|
+
}>;
|
|
24
|
+
currentVerbosityIndex?: number;
|
|
25
|
+
onVerbosityChange?: (index: number, characterId: string) => void;
|
|
26
|
+
verbosityChanged?: boolean;
|
|
27
|
+
messages: RTCChatMessage[];
|
|
28
|
+
isStreaming?: boolean;
|
|
29
|
+
inputMode?: "conversation" | "speaker" | "voice" | "verbosity";
|
|
30
|
+
inputValue: string;
|
|
31
|
+
liveUserText?: string;
|
|
32
|
+
localIsTyping: boolean;
|
|
33
|
+
convaiIsTyping: boolean;
|
|
34
|
+
chatbotMic: boolean;
|
|
35
|
+
isPressingMic: boolean;
|
|
36
|
+
isTalking: boolean;
|
|
37
|
+
isMuted: boolean;
|
|
38
|
+
isVoiceMode: boolean;
|
|
39
|
+
isSettingsOpen: boolean;
|
|
40
|
+
isSpeakerEditMode: boolean;
|
|
41
|
+
isVerbosityMode: boolean;
|
|
42
|
+
isCreatingSpeaker?: boolean;
|
|
43
|
+
onToggle: () => void;
|
|
44
|
+
onClose: () => void;
|
|
45
|
+
onInputChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
46
|
+
onKeyPress: (e: React.KeyboardEvent) => void;
|
|
47
|
+
onSend: () => void;
|
|
48
|
+
onMicPress: () => void;
|
|
49
|
+
onMicRelease: () => void;
|
|
50
|
+
setIsPressingMic: (value: boolean) => void;
|
|
51
|
+
onToggleMute: () => void;
|
|
52
|
+
onToggleVoiceMode: () => void;
|
|
53
|
+
onSettingsToggle: () => void;
|
|
54
|
+
onReset: () => void;
|
|
55
|
+
onToggleVerbosityMode: () => void;
|
|
56
|
+
onContinue?: () => void;
|
|
57
|
+
settingsButtonRef?: React.RefObject<HTMLButtonElement>;
|
|
58
|
+
convaiClient?: any;
|
|
59
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type CharacterInfo } from "@convai/web-sdk/core";
|
|
2
|
+
/**
|
|
3
|
+
* Fetch a character's display name and avatar for the widget header.
|
|
4
|
+
*
|
|
5
|
+
* The request itself lives in `core/characterInfo` so the vanilla widget runs
|
|
6
|
+
* the same code rather than a hand-synced copy of it.
|
|
7
|
+
*
|
|
8
|
+
* @param characterId - Character to look up
|
|
9
|
+
* @param apiKey - Convai API key, sent as `X-API-Key`
|
|
10
|
+
* @param authToken - Preferred over `apiKey`, sent as `API-AUTH-TOKEN`
|
|
11
|
+
* @param baseUrl - Origin to ask; defaults to `https://api.convai.com`. Pass
|
|
12
|
+
* `client.characterInfoUrl` so a non-SaaS deployment is not asked to send
|
|
13
|
+
* its credential to Convai's public API.
|
|
14
|
+
*/
|
|
15
|
+
export declare const useCharacterInfo: (characterId?: string, apiKey?: string, authToken?: string, baseUrl?: string | null) => CharacterInfo & {
|
|
16
|
+
isLoading: boolean;
|
|
17
|
+
error: Error | null;
|
|
18
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { TrackReferenceOrPlaceholder } from "@livekit/components-react";
|
|
2
|
+
/**
|
|
3
|
+
* Hook to get the local camera track reference from LiveKit.
|
|
4
|
+
*
|
|
5
|
+
* Returns a track reference that can be used with LiveKit components
|
|
6
|
+
* to display the local participant's camera feed.
|
|
7
|
+
*
|
|
8
|
+
* @returns {TrackReferenceOrPlaceholder} Track reference for the local camera
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```tsx
|
|
12
|
+
* function VideoComponent() {
|
|
13
|
+
* const cameraTrackRef = useLocalCameraTrack();
|
|
14
|
+
*
|
|
15
|
+
* return (
|
|
16
|
+
* <VideoTrack trackRef={cameraTrackRef} />
|
|
17
|
+
* );
|
|
18
|
+
* }
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export declare const useLocalCameraTrack: () => TrackReferenceOrPlaceholder;
|
|
@@ -0,0 +1,37 @@
|
|
|
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;
|
|
@@ -0,0 +1,15 @@
|
|
|
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;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How a link in the chat panel LOOKS: glyph SVGs, the style objects both
|
|
3
|
+
* renderers apply, the cssText serialiser the vanilla widget uses, and the
|
|
4
|
+
* card budget.
|
|
5
|
+
*
|
|
6
|
+
* This is the rendering half of what used to be one module in
|
|
7
|
+
* @convai/web-sdk. The other half — what a link IS and how it is labelled
|
|
8
|
+
* (`linkKindForUrl`, `describeUrl`, `fileNameOf`, `hoverTitle`, …) — is pure
|
|
9
|
+
* functions with no presentation in them, and stays public in the SDK so a
|
|
10
|
+
* hand-built UI labels links the same way this one does. Import those from
|
|
11
|
+
* `@convai/web-sdk/core`, not from here.
|
|
12
|
+
*/
|
|
13
|
+
/** How long a card may shimmer before it is treated as failed. */
|
|
14
|
+
export declare const PREVIEW_TIMEOUT_MS = 12000;
|
|
15
|
+
/** Cards beyond this in one message render as plain anchors. */
|
|
16
|
+
export declare const MAX_CARDS_PER_MESSAGE = 6;
|
|
17
|
+
export type GlyphName = "document" | "email" | "phone" | "sms" | "ftp" | "zoom" | "close" | "external";
|
|
18
|
+
/** Inline SVG for a glyph. Strings, not elements, so both renderers can use them. */
|
|
19
|
+
export declare function glyph(name: GlyphName): string;
|
|
20
|
+
export type StyleObject = Record<string, string | number>;
|
|
21
|
+
/** `{ marginTop: 6 }` → `margin-top: 6px;` — the vanilla widget authors cssText. */
|
|
22
|
+
export declare function toCssText(style: StyleObject): string;
|
|
23
|
+
/**
|
|
24
|
+
* Every visual the link layer draws, as one style object per element. React
|
|
25
|
+
* spreads these; vanilla serialises them with `toCssText`. Chrome derives from
|
|
26
|
+
* `currentColor` because the widget sits on a host page whose background it
|
|
27
|
+
* cannot know.
|
|
28
|
+
*/
|
|
29
|
+
export declare const presentationStyles: {
|
|
30
|
+
link: StyleObject;
|
|
31
|
+
/** Applied on focus-visible by the renderer; kept here so both agree. */
|
|
32
|
+
linkFocus: StyleObject;
|
|
33
|
+
blocked: StyleObject;
|
|
34
|
+
card: StyleObject;
|
|
35
|
+
cardButton: StyleObject;
|
|
36
|
+
zoom: StyleObject;
|
|
37
|
+
media: StyleObject;
|
|
38
|
+
videoMedia: StyleObject;
|
|
39
|
+
skeleton: StyleObject;
|
|
40
|
+
caption: StyleObject;
|
|
41
|
+
unavailable: StyleObject;
|
|
42
|
+
fileCard: StyleObject;
|
|
43
|
+
fileIcon: StyleObject;
|
|
44
|
+
fileBody: StyleObject;
|
|
45
|
+
fileName: StyleObject;
|
|
46
|
+
fileMeta: StyleObject;
|
|
47
|
+
contact: StyleObject;
|
|
48
|
+
contactGlyph: StyleObject;
|
|
49
|
+
badge: StyleObject;
|
|
50
|
+
lightboxBackdrop: StyleObject;
|
|
51
|
+
lightbox: StyleObject;
|
|
52
|
+
lightboxImage: StyleObject;
|
|
53
|
+
lightboxCaption: StyleObject;
|
|
54
|
+
lightboxControls: StyleObject;
|
|
55
|
+
lightboxButton: StyleObject;
|
|
56
|
+
lightboxFallback: StyleObject;
|
|
57
|
+
siteCard: StyleObject;
|
|
58
|
+
siteHeader: StyleObject;
|
|
59
|
+
siteFavicon: StyleObject;
|
|
60
|
+
siteName: StyleObject;
|
|
61
|
+
siteTitle: StyleObject;
|
|
62
|
+
siteDescription: StyleObject;
|
|
63
|
+
siteImage: StyleObject;
|
|
64
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copied verbatim from @convai/web-sdk rather than imported: it is internal
|
|
3
|
+
* there, and keeping it identical means the one `window.__CONVAI_DEBUG__` flag
|
|
4
|
+
* still turns on the SDK's logs and this package's together.
|
|
5
|
+
*
|
|
6
|
+
* Logger utility that only logs in development mode (or when debug is enabled at runtime).
|
|
7
|
+
* Completely silent in production builds unless explicitly enabled.
|
|
8
|
+
*
|
|
9
|
+
* To see logs after a production build, enable at runtime in the browser console:
|
|
10
|
+
* window.__CONVAI_DEBUG__ = true
|
|
11
|
+
* Then refresh the page. Logs will appear with the [Convai] prefix.
|
|
12
|
+
*
|
|
13
|
+
* To test logger behavior:
|
|
14
|
+
* - Development: Set NODE_ENV=development or run on localhost
|
|
15
|
+
* - Production: Set NODE_ENV=production or deploy to production
|
|
16
|
+
* - Production + debug: Set window.__CONVAI_DEBUG__ = true before/during use
|
|
17
|
+
*/
|
|
18
|
+
export declare const logger: {
|
|
19
|
+
log: (...args: unknown[]) => void;
|
|
20
|
+
warn: (...args: unknown[]) => void;
|
|
21
|
+
error: (...args: unknown[]) => void;
|
|
22
|
+
info: (...args: unknown[]) => void;
|
|
23
|
+
debug: (...args: unknown[]) => void;
|
|
24
|
+
trace: (...args: unknown[]) => void;
|
|
25
|
+
};
|
|
26
|
+
export declare const loggerConfig: {
|
|
27
|
+
environment: string;
|
|
28
|
+
isDevelopment: boolean;
|
|
29
|
+
isProduction: boolean;
|
|
30
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
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";
|
|
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;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
type WidgetEventListener = (...args: unknown[]) => void;
|
|
2
|
+
type SubscribeToWidgetEvent = (listener: WidgetEventListener) => (() => void) | void;
|
|
3
|
+
/**
|
|
4
|
+
* Owns widget event listeners so a destroyed widget cannot mutate detached DOM
|
|
5
|
+
* or notify its host when a client event arrives late.
|
|
6
|
+
*/
|
|
7
|
+
export declare class WidgetEventSubscriptions {
|
|
8
|
+
private readonly isDestroyed;
|
|
9
|
+
private readonly unsubscribes;
|
|
10
|
+
constructor(isDestroyed: () => boolean);
|
|
11
|
+
register(subscribe: SubscribeToWidgetEvent, listener: WidgetEventListener): void;
|
|
12
|
+
unsubscribeAll(): void;
|
|
13
|
+
}
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vanilla JS Icons
|
|
3
|
+
* Reuses the same icons from the React example
|
|
4
|
+
* Uses inline SVG for consistency and no external dependencies
|
|
5
|
+
*/
|
|
6
|
+
export type IconSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl';
|
|
7
|
+
export type LogoState = 'idle' | 'connecting' | 'connected' | 'disconnected' | 'typing' | 'listening' | 'processing';
|
|
8
|
+
/**
|
|
9
|
+
* Icons object with all icon creation functions
|
|
10
|
+
* Matches the icons from react-icons used in the React example
|
|
11
|
+
*/
|
|
12
|
+
export declare const Icons: {
|
|
13
|
+
ConvaiLogo: (size?: IconSize, state?: LogoState, className?: string) => SVGSVGElement;
|
|
14
|
+
ChevronDown: (size?: IconSize, className?: string) => SVGSVGElement;
|
|
15
|
+
Close: (size?: IconSize, className?: string) => SVGSVGElement;
|
|
16
|
+
Send: (size?: IconSize, className?: string) => SVGSVGElement;
|
|
17
|
+
Mic: (size?: IconSize, className?: string) => SVGSVGElement;
|
|
18
|
+
Waveform: (size?: IconSize, className?: string) => SVGSVGElement;
|
|
19
|
+
PhoneOff: (size?: IconSize, className?: string) => SVGSVGElement;
|
|
20
|
+
Video: (size?: IconSize, className?: string) => SVGSVGElement;
|
|
21
|
+
VideoOff: (size?: IconSize, className?: string) => SVGSVGElement;
|
|
22
|
+
VolumeMute: (size?: IconSize, className?: string) => SVGSVGElement;
|
|
23
|
+
VolumeHigh: (size?: IconSize, className?: string) => SVGSVGElement;
|
|
24
|
+
MoreVertical: (size?: IconSize, className?: string) => SVGSVGElement;
|
|
25
|
+
ScreenShare: (size?: IconSize, className?: string) => SVGSVGElement;
|
|
26
|
+
StopScreenShare: (size?: IconSize, className?: string) => SVGSVGElement;
|
|
27
|
+
Redo: (size?: IconSize, className?: string) => SVGSVGElement;
|
|
28
|
+
DragIndicator: (size?: IconSize, className?: string) => SVGSVGElement;
|
|
29
|
+
User: (size?: IconSize, className?: string) => SVGSVGElement;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Helper to create icon wrapper div
|
|
33
|
+
*/
|
|
34
|
+
export declare function createIconWrapper(icon: SVGSVGElement, size?: IconSize, color?: string, className?: string): HTMLDivElement;
|