@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,168 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vanilla Styles - Port of React theme system for vanilla implementations
|
|
3
|
+
*/
|
|
4
|
+
export declare const aeroTheme: {
|
|
5
|
+
colors: {
|
|
6
|
+
primary: {
|
|
7
|
+
50: string;
|
|
8
|
+
100: string;
|
|
9
|
+
200: string;
|
|
10
|
+
300: string;
|
|
11
|
+
400: string;
|
|
12
|
+
500: string;
|
|
13
|
+
600: string;
|
|
14
|
+
700: string;
|
|
15
|
+
800: string;
|
|
16
|
+
900: string;
|
|
17
|
+
};
|
|
18
|
+
convai: {
|
|
19
|
+
light: string;
|
|
20
|
+
medium: string;
|
|
21
|
+
dark: string;
|
|
22
|
+
};
|
|
23
|
+
neutral: {
|
|
24
|
+
50: string;
|
|
25
|
+
100: string;
|
|
26
|
+
200: string;
|
|
27
|
+
300: string;
|
|
28
|
+
400: string;
|
|
29
|
+
500: string;
|
|
30
|
+
600: string;
|
|
31
|
+
700: string;
|
|
32
|
+
800: string;
|
|
33
|
+
900: string;
|
|
34
|
+
};
|
|
35
|
+
glass: {
|
|
36
|
+
light: string;
|
|
37
|
+
medium: string;
|
|
38
|
+
dark: string;
|
|
39
|
+
backdrop: string;
|
|
40
|
+
card: string;
|
|
41
|
+
backdropLight: string;
|
|
42
|
+
borderLight: string;
|
|
43
|
+
};
|
|
44
|
+
accent: {
|
|
45
|
+
purple: string;
|
|
46
|
+
green: string;
|
|
47
|
+
blue: string;
|
|
48
|
+
orange: string;
|
|
49
|
+
red: string;
|
|
50
|
+
};
|
|
51
|
+
error: {
|
|
52
|
+
50: string;
|
|
53
|
+
100: string;
|
|
54
|
+
200: string;
|
|
55
|
+
300: string;
|
|
56
|
+
400: string;
|
|
57
|
+
500: string;
|
|
58
|
+
600: string;
|
|
59
|
+
700: string;
|
|
60
|
+
800: string;
|
|
61
|
+
900: string;
|
|
62
|
+
};
|
|
63
|
+
text: {
|
|
64
|
+
primary: string;
|
|
65
|
+
secondary: string;
|
|
66
|
+
tertiary: string;
|
|
67
|
+
inverse: string;
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
typography: {
|
|
71
|
+
fontFamily: {
|
|
72
|
+
primary: string;
|
|
73
|
+
body: string;
|
|
74
|
+
mono: string;
|
|
75
|
+
};
|
|
76
|
+
fontSize: {
|
|
77
|
+
xs: string;
|
|
78
|
+
sm: string;
|
|
79
|
+
base: string;
|
|
80
|
+
lg: string;
|
|
81
|
+
xl: string;
|
|
82
|
+
"2xl": string;
|
|
83
|
+
"3xl": string;
|
|
84
|
+
"4xl": string;
|
|
85
|
+
};
|
|
86
|
+
fontWeight: {
|
|
87
|
+
normal: number;
|
|
88
|
+
medium: number;
|
|
89
|
+
semibold: number;
|
|
90
|
+
bold: number;
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
spacing: {
|
|
94
|
+
xs: string;
|
|
95
|
+
sm: string;
|
|
96
|
+
md: string;
|
|
97
|
+
lg: string;
|
|
98
|
+
xl: string;
|
|
99
|
+
"2xl": string;
|
|
100
|
+
"3xl": string;
|
|
101
|
+
};
|
|
102
|
+
borderRadius: {
|
|
103
|
+
none: string;
|
|
104
|
+
sm: string;
|
|
105
|
+
md: string;
|
|
106
|
+
lg: string;
|
|
107
|
+
xl: string;
|
|
108
|
+
"2xl": string;
|
|
109
|
+
full: string;
|
|
110
|
+
};
|
|
111
|
+
shadows: {
|
|
112
|
+
sm: string;
|
|
113
|
+
md: string;
|
|
114
|
+
lg: string;
|
|
115
|
+
xl: string;
|
|
116
|
+
glass: string;
|
|
117
|
+
};
|
|
118
|
+
glass: {
|
|
119
|
+
backdrop: string;
|
|
120
|
+
backdropLight: string;
|
|
121
|
+
backdropHeavy: string;
|
|
122
|
+
border: string;
|
|
123
|
+
borderLight: string;
|
|
124
|
+
};
|
|
125
|
+
transitions: {
|
|
126
|
+
fast: string;
|
|
127
|
+
normal: string;
|
|
128
|
+
slow: string;
|
|
129
|
+
spring: string;
|
|
130
|
+
snappy: string;
|
|
131
|
+
};
|
|
132
|
+
zIndex: {
|
|
133
|
+
base: number;
|
|
134
|
+
dropdown: number;
|
|
135
|
+
sticky: number;
|
|
136
|
+
fixed: number;
|
|
137
|
+
modal: number;
|
|
138
|
+
popover: number;
|
|
139
|
+
tooltip: number;
|
|
140
|
+
};
|
|
141
|
+
};
|
|
142
|
+
/**
|
|
143
|
+
* Global CSS styles for the Convai widget
|
|
144
|
+
* This should be injected once into the document head
|
|
145
|
+
*/
|
|
146
|
+
export declare const getGlobalStyles: () => string;
|
|
147
|
+
/**
|
|
148
|
+
* A document (the default) or a shadow root the widget is mounted inside.
|
|
149
|
+
* `@keyframes` and global styles must be injected per-target because
|
|
150
|
+
* shadow trees do not resolve rules defined in the document head.
|
|
151
|
+
*/
|
|
152
|
+
export type StyleTarget = Document | ShadowRoot;
|
|
153
|
+
/**
|
|
154
|
+
* Inject the widget's global styles into a document or a shadow root.
|
|
155
|
+
* Defaults to the document, so existing callers are unaffected.
|
|
156
|
+
*/
|
|
157
|
+
export declare const injectGlobalStyles: (target?: StyleTarget) => void;
|
|
158
|
+
/**
|
|
159
|
+
* Inject the widget's `@keyframes` (e.g. the settings tray's `popIn`)
|
|
160
|
+
* into a document or a shadow root. `@keyframes` defined in the document
|
|
161
|
+
* do not resolve for shadow content, so they must be injected into each
|
|
162
|
+
* shadow root that uses them.
|
|
163
|
+
*/
|
|
164
|
+
export declare const injectKeyframes: (target?: StyleTarget) => void;
|
|
165
|
+
/**
|
|
166
|
+
* Helper to create inline styles object from theme
|
|
167
|
+
*/
|
|
168
|
+
export declare const createStyles: (styles: Record<string, any>) => string;
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import type { IConvaiClient, ChatMessage, PublishedChatConnectOptions } from '@convai/web-sdk/core';
|
|
2
|
+
import type { PublishedChatDescriptor } from '@convai/web-sdk/embed';
|
|
3
|
+
import type { LinkPreviewResolver } from "@convai/web-sdk/core";
|
|
4
|
+
/** Where the widget anchors itself. `inline` renders it in normal document flow. */
|
|
5
|
+
export type WidgetPlacement = 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left' | 'inline';
|
|
6
|
+
/**
|
|
7
|
+
* Options for creating a vanilla ConvaiWidget
|
|
8
|
+
*
|
|
9
|
+
* You can either:
|
|
10
|
+
* 1. Pass an existing convaiClient instance, OR
|
|
11
|
+
* 2. Pass connection config (apiKey, characterId, etc.) directly
|
|
12
|
+
*/
|
|
13
|
+
export interface VanillaWidgetOptions {
|
|
14
|
+
/**
|
|
15
|
+
* Option 1: Pass an existing Convai client instance.
|
|
16
|
+
* Should be initialized with config: new ConvaiClient({ apiKey, characterId, ... })
|
|
17
|
+
* The widget will auto-connect on first click.
|
|
18
|
+
*/
|
|
19
|
+
convaiClient?: IConvaiClient & {
|
|
20
|
+
activity?: string;
|
|
21
|
+
chatMessages: ChatMessage[];
|
|
22
|
+
/**
|
|
23
|
+
* Present on the real `ConvaiClient` (it extends `EventEmitter`) and on
|
|
24
|
+
* the test stubs; absent only if a caller hand-rolls a minimal
|
|
25
|
+
* `IConvaiClient`. Optional so that case still type-checks -- the widget
|
|
26
|
+
* calls it defensively (`client.emit?.(...)`) to surface mic-permission
|
|
27
|
+
* failures on the same `error` channel `ConvaiClient` already uses.
|
|
28
|
+
*/
|
|
29
|
+
emit?: (event: string, ...args: any[]) => void;
|
|
30
|
+
};
|
|
31
|
+
/** Option 2: Pass connection config directly (convenience shortcut). Either apiKey or authToken is required. */
|
|
32
|
+
apiKey?: string;
|
|
33
|
+
/** Auth token for realtime API (alternative to apiKey). See https://realtime-api.convai.com/docs */
|
|
34
|
+
authToken?: string;
|
|
35
|
+
characterId?: string;
|
|
36
|
+
enableVideo?: boolean;
|
|
37
|
+
startWithVideoOn?: boolean;
|
|
38
|
+
/** Enable lipsync/facial animation blendshapes (default: false) */
|
|
39
|
+
enableLipsync?: boolean;
|
|
40
|
+
/** Enable emotion detection and bot-emotion updates (default: false) */
|
|
41
|
+
enableEmotion?: boolean;
|
|
42
|
+
/** Log incoming and outgoing decoded RTVI data messages to the browser console (default: true) */
|
|
43
|
+
logRtviMessages?: boolean;
|
|
44
|
+
/** Blendshape configuration for facial animation format */
|
|
45
|
+
blendshapeConfig?: {
|
|
46
|
+
/** Format of blendshapes: "arkit" or "mha" (Meta Human Animation, default: "mha") */
|
|
47
|
+
format?: "arkit" | "mha";
|
|
48
|
+
/** Custom mapper function to transform incoming blendshapes */
|
|
49
|
+
customMapper?: (input: number[] | Float32Array) => Float32Array;
|
|
50
|
+
/** Indexed NeuroSync ahead-delivery. Defaults to true; set false for the legacy paced path. */
|
|
51
|
+
deliver_chunks_ahead?: boolean;
|
|
52
|
+
/** Ahead-delivery timeline FPS override; ignored when deliver_chunks_ahead is false. */
|
|
53
|
+
output_fps?: number;
|
|
54
|
+
/** Seconds the server buffers blendshapes before releasing them. */
|
|
55
|
+
frames_buffer_duration?: number;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Show video toggle button in settings (default: true).
|
|
59
|
+
* Only works if connection type is "video". If false, hides the video button.
|
|
60
|
+
*/
|
|
61
|
+
showVideo?: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Show screen share toggle button in settings (default: true).
|
|
64
|
+
* Only works if connection type is "video". If false, hides the screen share button.
|
|
65
|
+
*/
|
|
66
|
+
showScreenShare?: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Start in voice mode by default when widget opens (default: true).
|
|
69
|
+
* When true, the widget will open directly in voice mode with microphone enabled.
|
|
70
|
+
*/
|
|
71
|
+
defaultVoiceMode?: boolean;
|
|
72
|
+
/**
|
|
73
|
+
* Open Graph lookup for plain web links the character sends. Supply a
|
|
74
|
+
* function that asks your backend for a page's metadata and each such link
|
|
75
|
+
* gets a site card (favicon, site name, title, description, image) once it
|
|
76
|
+
* resolves. Omit it and links render as before. See
|
|
77
|
+
* docs/convai_link_previews.md, "Site cards".
|
|
78
|
+
*/
|
|
79
|
+
linkPreviewResolver?: LinkPreviewResolver;
|
|
80
|
+
/** Mint a fresh single-use grant when a published-chat session is reopened. */
|
|
81
|
+
requestPublicationGrant?: () => Promise<string>;
|
|
82
|
+
/** Core endpoint override used with requestPublicationGrant. */
|
|
83
|
+
publishedChatConnectOptions?: PublishedChatConnectOptions;
|
|
84
|
+
/** Public descriptor used to label a credential-free published session. */
|
|
85
|
+
publishedChatDescriptor?: Pick<PublishedChatDescriptor, 'display_name' | 'image_url'>;
|
|
86
|
+
/**
|
|
87
|
+
* Where the widget's `<style>` and `@keyframes` nodes are injected.
|
|
88
|
+
*
|
|
89
|
+
* Omit it and the target is derived from `container.getRootNode()` at
|
|
90
|
+
* construction time — correct only when the container is *already* inside
|
|
91
|
+
* its final root. A custom element that builds its subtree first and appends
|
|
92
|
+
* it to its shadow root afterwards (the usual pattern) constructs the widget
|
|
93
|
+
* while the container is still detached, so the derivation sees the
|
|
94
|
+
* document and the shadow root never receives the stylesheet or the `popIn`
|
|
95
|
+
* keyframes — silently, with no error. Pass the shadow root here in that
|
|
96
|
+
* case; when supplied it is used verbatim and no derivation happens.
|
|
97
|
+
*/
|
|
98
|
+
styleTarget?: Document | ShadowRoot;
|
|
99
|
+
/** Corner to anchor to, or `inline` for normal flow. Default `bottom-right`. */
|
|
100
|
+
placement?: WidgetPlacement;
|
|
101
|
+
/** Optional callbacks */
|
|
102
|
+
onConnect?: () => void;
|
|
103
|
+
onDisconnect?: () => void;
|
|
104
|
+
onMessage?: (message: ChatMessage) => void;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Vanilla ConvaiWidget instance with cleanup method
|
|
108
|
+
*/
|
|
109
|
+
export interface VanillaWidget {
|
|
110
|
+
/** Root DOM element of the widget */
|
|
111
|
+
element: HTMLElement;
|
|
112
|
+
/** Cleanup and destroy the widget */
|
|
113
|
+
destroy: () => void;
|
|
114
|
+
/** The Convai client instance */
|
|
115
|
+
client: IConvaiClient & {
|
|
116
|
+
activity?: string;
|
|
117
|
+
chatMessages: ChatMessage[];
|
|
118
|
+
emit?: (event: string, ...args: any[]) => void;
|
|
119
|
+
};
|
|
120
|
+
/** Update widget state (for future extensions) */
|
|
121
|
+
update?: (options: Partial<VanillaWidgetOptions>) => void;
|
|
122
|
+
/**
|
|
123
|
+
* Open the panel. Drives the same internal open path as the launcher
|
|
124
|
+
* click (connect-on-first-open, then the morph to the panel). Idempotent:
|
|
125
|
+
* calling `open()` while already open — or while a first open is still
|
|
126
|
+
* waiting on `connect()` — is a no-op. It will not re-run the morph
|
|
127
|
+
* animation, and it will not start a second connect.
|
|
128
|
+
*/
|
|
129
|
+
open: () => void;
|
|
130
|
+
/**
|
|
131
|
+
* Close the panel. Drives the same internal path as the header's close
|
|
132
|
+
* button. Idempotent: calling `close()` while already closed is a no-op.
|
|
133
|
+
*
|
|
134
|
+
* Called while a first open is still connecting, it *cancels* that open:
|
|
135
|
+
* the connect completes (the client ends up connected) but the panel stays
|
|
136
|
+
* collapsed rather than popping open once the promise resolves.
|
|
137
|
+
*/
|
|
138
|
+
close: () => void;
|
|
139
|
+
/**
|
|
140
|
+
* Toggle the panel open or closed, per the current {@link isOpen} state.
|
|
141
|
+
* Mid-connect this closes — i.e. a second click cancels the open in flight,
|
|
142
|
+
* rather than queueing a second one.
|
|
143
|
+
*/
|
|
144
|
+
toggle: () => void;
|
|
145
|
+
/**
|
|
146
|
+
* Whether the panel is open, or is opening. This is *requested* state, and
|
|
147
|
+
* it updates synchronously: `widget.open(); widget.isOpen` is always `true`,
|
|
148
|
+
* including on a cold client where the panel is only committed once
|
|
149
|
+
* `connect()` resolves seconds later. Cancelling that open (via `close()`,
|
|
150
|
+
* `toggle()`, or a second launcher click) returns it to `false`
|
|
151
|
+
* immediately.
|
|
152
|
+
*
|
|
153
|
+
* The distinction matters only for the first open on a disconnected client;
|
|
154
|
+
* every other transition is synchronous, so rendered and requested state
|
|
155
|
+
* coincide. Consumers reconciling their own open/close events against this
|
|
156
|
+
* flag get the answer that matches the user's last instruction, not the
|
|
157
|
+
* animation frame.
|
|
158
|
+
*/
|
|
159
|
+
readonly isOpen: boolean;
|
|
160
|
+
/**
|
|
161
|
+
* Insert a message into the transcript locally, without sending it to the
|
|
162
|
+
* character. Use this for client-side lines — e.g. a greeting — that must
|
|
163
|
+
* appear in the chat but must never reach the LLM and must never be billed
|
|
164
|
+
* as a turn. This is not `sendUserTextMessage`: nothing is transmitted.
|
|
165
|
+
*/
|
|
166
|
+
appendMessage: (message: {
|
|
167
|
+
sender: "user" | "bot";
|
|
168
|
+
content: string;
|
|
169
|
+
}) => void;
|
|
170
|
+
}
|
package/vanilla.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@convai/web-widget/vanilla` — the chat UI without a framework.
|
|
3
|
+
*
|
|
4
|
+
* This moved here from `@convai/web-sdk/vanilla`, which keeps the client side:
|
|
5
|
+
* `ConvaiClient`, `AudioRenderer` and the WebSocket transport. Take the client
|
|
6
|
+
* from there and the interface from here:
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { ConvaiClient } from '@convai/web-sdk/core'
|
|
10
|
+
* import { createConvaiWidget } from '@convai/web-widget/vanilla'
|
|
11
|
+
*
|
|
12
|
+
* const client = new ConvaiClient({ apiKey, characterId })
|
|
13
|
+
* createConvaiWidget(document.body, { convaiClient: client })
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* No React, no styled-components, no framer-motion: the vanilla widget is
|
|
17
|
+
* hand-written DOM and CSS, so this entry pulls in none of the React UI's
|
|
18
|
+
* dependencies. Importing it has no side effects.
|
|
19
|
+
*/
|
|
20
|
+
export { createConvaiWidget, destroyConvaiWidget } from './ui/vanilla/ConvaiWidget';
|
|
21
|
+
export type { VanillaWidget, VanillaWidgetOptions, WidgetPlacement } from './ui/vanilla/types';
|