@convai/web-sdk 0.0.4-beta.1 → 0.1.1-beta.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 +277 -185
- package/dist/components/ConvaiWidget.d.ts.map +1 -1
- package/dist/components/ConvaiWidget.js +13 -0
- package/dist/components/ConvaiWidget.js.map +1 -1
- package/dist/components/rtc-widget/components/AudioSettingsPanel.js +1 -1
- package/dist/components/rtc-widget/components/AudioSettingsPanel.js.map +1 -1
- package/dist/components/rtc-widget/styles/styledComponents.d.ts.map +1 -1
- package/dist/components/rtc-widget/styles/styledComponents.js +72 -51
- package/dist/components/rtc-widget/styles/styledComponents.js.map +1 -1
- package/dist/core/AudioManager.d.ts +75 -0
- package/dist/core/AudioManager.d.ts.map +1 -0
- package/dist/core/AudioManager.js +219 -0
- package/dist/core/AudioManager.js.map +1 -0
- package/dist/core/ConvaiClient.d.ts +122 -0
- package/dist/core/ConvaiClient.d.ts.map +1 -0
- package/dist/core/ConvaiClient.js +509 -0
- package/dist/core/ConvaiClient.js.map +1 -0
- package/dist/core/EventEmitter.d.ts +38 -0
- package/dist/core/EventEmitter.d.ts.map +1 -0
- package/dist/core/EventEmitter.js +68 -0
- package/dist/core/EventEmitter.js.map +1 -0
- package/dist/core/MessageHandler.d.ts +52 -0
- package/dist/core/MessageHandler.d.ts.map +1 -0
- package/dist/core/MessageHandler.js +281 -0
- package/dist/core/MessageHandler.js.map +1 -0
- package/dist/core/ScreenShareManager.d.ts +57 -0
- package/dist/core/ScreenShareManager.d.ts.map +1 -0
- package/dist/core/ScreenShareManager.js +206 -0
- package/dist/core/ScreenShareManager.js.map +1 -0
- package/dist/core/VideoManager.d.ts +69 -0
- package/dist/core/VideoManager.d.ts.map +1 -0
- package/dist/core/VideoManager.js +207 -0
- package/dist/core/VideoManager.js.map +1 -0
- package/dist/core/index.d.ts +9 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +12 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/types.d.ts +311 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +2 -0
- package/dist/core/types.js.map +1 -0
- package/dist/hooks/useConvaiClient.d.ts.map +1 -1
- package/dist/hooks/useConvaiClient.js +16 -0
- package/dist/hooks/useConvaiClient.js.map +1 -1
- package/dist/hooks/useMessageHandler.d.ts.map +1 -1
- package/dist/hooks/useMessageHandler.js +39 -14
- package/dist/hooks/useMessageHandler.js.map +1 -1
- package/dist/index.d.ts +1 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -10
- package/dist/index.js.map +1 -1
- package/dist/react/components/ConvaiWidget.d.ts +59 -0
- package/dist/react/components/ConvaiWidget.d.ts.map +1 -0
- package/dist/react/components/ConvaiWidget.js +421 -0
- package/dist/react/components/ConvaiWidget.js.map +1 -0
- package/dist/react/components/index.d.ts +3 -0
- package/dist/react/components/index.d.ts.map +1 -0
- package/dist/react/components/index.js +5 -0
- package/dist/react/components/index.js.map +1 -0
- package/dist/react/components/rtc-widget/components/AudioSettingsPanel.d.ts +10 -0
- package/dist/react/components/rtc-widget/components/AudioSettingsPanel.d.ts.map +1 -0
- package/dist/react/components/rtc-widget/components/AudioSettingsPanel.js +316 -0
- package/dist/react/components/rtc-widget/components/AudioSettingsPanel.js.map +1 -0
- package/dist/react/components/rtc-widget/components/ConviMessage.d.ts +10 -0
- package/dist/react/components/rtc-widget/components/ConviMessage.d.ts.map +1 -0
- package/dist/react/components/rtc-widget/components/ConviMessage.js +14 -0
- package/dist/react/components/rtc-widget/components/ConviMessage.js.map +1 -0
- package/dist/react/components/rtc-widget/components/FloatingVideo.d.ts +9 -0
- package/dist/react/components/rtc-widget/components/FloatingVideo.d.ts.map +1 -0
- package/dist/react/components/rtc-widget/components/FloatingVideo.js +122 -0
- package/dist/react/components/rtc-widget/components/FloatingVideo.js.map +1 -0
- package/dist/react/components/rtc-widget/components/MarkdownRenderer.d.ts +7 -0
- package/dist/react/components/rtc-widget/components/MarkdownRenderer.d.ts.map +1 -0
- package/dist/react/components/rtc-widget/components/MarkdownRenderer.js +68 -0
- package/dist/react/components/rtc-widget/components/MarkdownRenderer.js.map +1 -0
- package/dist/react/components/rtc-widget/components/MessageBubble.d.ts +10 -0
- package/dist/react/components/rtc-widget/components/MessageBubble.d.ts.map +1 -0
- package/dist/react/components/rtc-widget/components/MessageBubble.js +23 -0
- package/dist/react/components/rtc-widget/components/MessageBubble.js.map +1 -0
- package/dist/react/components/rtc-widget/components/MessageList.d.ts +11 -0
- package/dist/react/components/rtc-widget/components/MessageList.d.ts.map +1 -0
- package/dist/react/components/rtc-widget/components/MessageList.js +89 -0
- package/dist/react/components/rtc-widget/components/MessageList.js.map +1 -0
- package/dist/react/components/rtc-widget/components/UserMessage.d.ts +9 -0
- package/dist/react/components/rtc-widget/components/UserMessage.d.ts.map +1 -0
- package/dist/react/components/rtc-widget/components/UserMessage.js +15 -0
- package/dist/react/components/rtc-widget/components/UserMessage.js.map +1 -0
- package/dist/react/components/rtc-widget/components/conviComponents/ConviButton.d.ts +6 -0
- package/dist/react/components/rtc-widget/components/conviComponents/ConviButton.d.ts.map +1 -0
- package/dist/react/components/rtc-widget/components/conviComponents/ConviButton.js +15 -0
- package/dist/react/components/rtc-widget/components/conviComponents/ConviButton.js.map +1 -0
- package/dist/react/components/rtc-widget/components/conviComponents/ConviFooter.d.ts +25 -0
- package/dist/react/components/rtc-widget/components/conviComponents/ConviFooter.d.ts.map +1 -0
- package/dist/react/components/rtc-widget/components/conviComponents/ConviFooter.js +172 -0
- package/dist/react/components/rtc-widget/components/conviComponents/ConviFooter.js.map +1 -0
- package/dist/react/components/rtc-widget/components/conviComponents/ConviHeader.d.ts +17 -0
- package/dist/react/components/rtc-widget/components/conviComponents/ConviHeader.d.ts.map +1 -0
- package/dist/react/components/rtc-widget/components/conviComponents/ConviHeader.js +66 -0
- package/dist/react/components/rtc-widget/components/conviComponents/ConviHeader.js.map +1 -0
- package/dist/react/components/rtc-widget/components/conviComponents/SettingsTray.d.ts +12 -0
- package/dist/react/components/rtc-widget/components/conviComponents/SettingsTray.d.ts.map +1 -0
- package/dist/react/components/rtc-widget/components/conviComponents/SettingsTray.js +68 -0
- package/dist/react/components/rtc-widget/components/conviComponents/SettingsTray.js.map +1 -0
- package/dist/react/components/rtc-widget/components/conviComponents/VoiceModeOverlay.d.ts +8 -0
- package/dist/react/components/rtc-widget/components/conviComponents/VoiceModeOverlay.d.ts.map +1 -0
- package/dist/react/components/rtc-widget/components/conviComponents/VoiceModeOverlay.js +199 -0
- package/dist/react/components/rtc-widget/components/conviComponents/VoiceModeOverlay.js.map +1 -0
- package/dist/react/components/rtc-widget/components/conviComponents/index.d.ts +6 -0
- package/dist/react/components/rtc-widget/components/conviComponents/index.d.ts.map +1 -0
- package/dist/react/components/rtc-widget/components/conviComponents/index.js +6 -0
- package/dist/react/components/rtc-widget/components/conviComponents/index.js.map +1 -0
- package/dist/react/components/rtc-widget/components/index.d.ts +8 -0
- package/dist/react/components/rtc-widget/components/index.d.ts.map +1 -0
- package/dist/react/components/rtc-widget/components/index.js +13 -0
- package/dist/react/components/rtc-widget/components/index.js.map +1 -0
- package/dist/react/components/rtc-widget/index.d.ts +6 -0
- package/dist/react/components/rtc-widget/index.d.ts.map +1 -0
- package/dist/react/components/rtc-widget/index.js +9 -0
- package/dist/react/components/rtc-widget/index.js.map +1 -0
- package/dist/react/components/rtc-widget/styles/framerConfig.d.ts +116 -0
- package/dist/react/components/rtc-widget/styles/framerConfig.d.ts.map +1 -0
- package/dist/react/components/rtc-widget/styles/framerConfig.js +73 -0
- package/dist/react/components/rtc-widget/styles/framerConfig.js.map +1 -0
- package/dist/react/components/rtc-widget/styles/icons.d.ts +28 -0
- package/dist/react/components/rtc-widget/styles/icons.d.ts.map +1 -0
- package/dist/react/components/rtc-widget/styles/icons.js +257 -0
- package/dist/react/components/rtc-widget/styles/icons.js.map +1 -0
- package/dist/react/components/rtc-widget/styles/index.d.ts +6 -0
- package/dist/react/components/rtc-widget/styles/index.d.ts.map +1 -0
- package/dist/react/components/rtc-widget/styles/index.js +9 -0
- package/dist/react/components/rtc-widget/styles/index.js.map +1 -0
- package/dist/react/components/rtc-widget/styles/styledComponents.d.ts +90 -0
- package/dist/react/components/rtc-widget/styles/styledComponents.d.ts.map +1 -0
- package/dist/react/components/rtc-widget/styles/styledComponents.js +661 -0
- package/dist/react/components/rtc-widget/styles/styledComponents.js.map +1 -0
- package/dist/react/components/rtc-widget/styles/theme.d.ts +188 -0
- package/dist/react/components/rtc-widget/styles/theme.d.ts.map +1 -0
- package/dist/react/components/rtc-widget/styles/theme.js +290 -0
- package/dist/react/components/rtc-widget/styles/theme.js.map +1 -0
- package/dist/react/components/rtc-widget/types/index.d.ts +60 -0
- package/dist/react/components/rtc-widget/types/index.d.ts.map +1 -0
- package/dist/react/components/rtc-widget/types/index.js +2 -0
- package/dist/react/components/rtc-widget/types/index.js.map +1 -0
- package/dist/react/hooks/index.d.ts +4 -0
- package/dist/react/hooks/index.d.ts.map +1 -0
- package/dist/react/hooks/index.js +6 -0
- package/dist/react/hooks/index.js.map +1 -0
- package/dist/react/hooks/useCharacterInfo.d.ts +17 -0
- package/dist/react/hooks/useCharacterInfo.d.ts.map +1 -0
- package/dist/react/hooks/useCharacterInfo.js +60 -0
- package/dist/react/hooks/useCharacterInfo.js.map +1 -0
- package/dist/react/hooks/useConvaiClient.d.ts +32 -0
- package/dist/react/hooks/useConvaiClient.d.ts.map +1 -0
- package/dist/react/hooks/useConvaiClient.js +140 -0
- package/dist/react/hooks/useConvaiClient.js.map +1 -0
- package/dist/react/hooks/useLocalCameraTrack.d.ts +22 -0
- package/dist/react/hooks/useLocalCameraTrack.d.ts.map +1 -0
- package/dist/react/hooks/useLocalCameraTrack.js +34 -0
- package/dist/react/hooks/useLocalCameraTrack.js.map +1 -0
- package/dist/react/index.d.ts +8 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +15 -0
- package/dist/react/index.js.map +1 -0
- package/dist/types/index.d.ts +20 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/utils/speakerManagement.d.ts +22 -0
- package/dist/utils/speakerManagement.d.ts.map +1 -0
- package/dist/utils/speakerManagement.js +71 -0
- package/dist/utils/speakerManagement.js.map +1 -0
- package/dist/vanilla/index.d.ts +3 -0
- package/dist/vanilla/index.d.ts.map +1 -0
- package/dist/vanilla/index.js +5 -0
- package/dist/vanilla/index.js.map +1 -0
- package/package.json +25 -8
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { Room } from "livekit-client";
|
|
2
|
+
import { VideoControls } from "./types";
|
|
3
|
+
import { EventEmitter } from "./EventEmitter";
|
|
4
|
+
/**
|
|
5
|
+
* Manages video controls for LiveKit room
|
|
6
|
+
* Provides methods to enable/disable camera, manage video devices,
|
|
7
|
+
* and control video state.
|
|
8
|
+
*/
|
|
9
|
+
export declare class VideoManager extends EventEmitter implements VideoControls {
|
|
10
|
+
private room;
|
|
11
|
+
private _isVideoEnabled;
|
|
12
|
+
private _isVideoHidden;
|
|
13
|
+
constructor(room?: Room);
|
|
14
|
+
get isVideoEnabled(): boolean;
|
|
15
|
+
get isVideoHidden(): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Set the LiveKit room instance
|
|
18
|
+
*/
|
|
19
|
+
setRoom(room: Room): void;
|
|
20
|
+
/**
|
|
21
|
+
* Setup event listeners for room
|
|
22
|
+
*/
|
|
23
|
+
private setupListeners;
|
|
24
|
+
/**
|
|
25
|
+
* Clean up event listeners
|
|
26
|
+
*/
|
|
27
|
+
private cleanupListeners;
|
|
28
|
+
/**
|
|
29
|
+
* Update video state from room
|
|
30
|
+
*/
|
|
31
|
+
private updateState;
|
|
32
|
+
/**
|
|
33
|
+
* Enable video
|
|
34
|
+
*/
|
|
35
|
+
enableVideo(): Promise<void>;
|
|
36
|
+
/**
|
|
37
|
+
* Disable video
|
|
38
|
+
*/
|
|
39
|
+
disableVideo(): Promise<void>;
|
|
40
|
+
/**
|
|
41
|
+
* Hide video
|
|
42
|
+
*/
|
|
43
|
+
hideVideo(): Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* Show video
|
|
46
|
+
*/
|
|
47
|
+
showVideo(): Promise<void>;
|
|
48
|
+
/**
|
|
49
|
+
* Toggle video
|
|
50
|
+
*/
|
|
51
|
+
toggleVideo(): Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
* Set video device
|
|
54
|
+
*/
|
|
55
|
+
setVideoDevice(deviceId: string): Promise<void>;
|
|
56
|
+
/**
|
|
57
|
+
* Get available video devices
|
|
58
|
+
*/
|
|
59
|
+
getVideoDevices(): Promise<MediaDeviceInfo[]>;
|
|
60
|
+
/**
|
|
61
|
+
* Set video quality
|
|
62
|
+
*/
|
|
63
|
+
setVideoQuality(quality: 'low' | 'medium' | 'high'): Promise<void>;
|
|
64
|
+
/**
|
|
65
|
+
* Reset state on disconnect
|
|
66
|
+
*/
|
|
67
|
+
reset(): void;
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=VideoManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VideoManager.d.ts","sourceRoot":"","sources":["../../src/core/VideoManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAExC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C;;;;GAIG;AACH,qBAAa,YAAa,SAAQ,YAAa,YAAW,aAAa;IACrE,OAAO,CAAC,IAAI,CAAqB;IACjC,OAAO,CAAC,eAAe,CAAkB;IACzC,OAAO,CAAC,cAAc,CAAkB;gBAE5B,IAAI,CAAC,EAAE,IAAI;IAOvB,IAAI,cAAc,IAAI,OAAO,CAE5B;IAED,IAAI,aAAa,IAAI,OAAO,CAE3B;IAED;;OAEG;IACH,OAAO,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI;IAczB;;OAEG;IACH,OAAO,CAAC,cAAc;IAuCtB;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAKxB;;OAEG;IACH,OAAO,CAAC,WAAW;IAYnB;;OAEG;IACG,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;IAclC;;OAEG;IACG,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IAcnC;;OAEG;IACG,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;IAIhC;;OAEG;IACG,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;IAIhC;;OAEG;IACG,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;IAQlC;;OAEG;IACG,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAarD;;OAEG;IACG,eAAe,IAAI,OAAO,CAAC,eAAe,EAAE,CAAC;IAWnD;;OAEG;IACG,eAAe,CAAC,OAAO,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAcxE;;OAEG;IACH,KAAK,IAAI,IAAI;CAQd"}
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import { logger } from "../utils/logger";
|
|
2
|
+
import { EventEmitter } from "./EventEmitter";
|
|
3
|
+
/**
|
|
4
|
+
* Manages video controls for LiveKit room
|
|
5
|
+
* Provides methods to enable/disable camera, manage video devices,
|
|
6
|
+
* and control video state.
|
|
7
|
+
*/
|
|
8
|
+
export class VideoManager extends EventEmitter {
|
|
9
|
+
constructor(room) {
|
|
10
|
+
super();
|
|
11
|
+
this.room = null;
|
|
12
|
+
this._isVideoEnabled = false;
|
|
13
|
+
this._isVideoHidden = false;
|
|
14
|
+
if (room) {
|
|
15
|
+
this.setRoom(room);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
get isVideoEnabled() {
|
|
19
|
+
return this._isVideoEnabled;
|
|
20
|
+
}
|
|
21
|
+
get isVideoHidden() {
|
|
22
|
+
return this._isVideoHidden;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Set the LiveKit room instance
|
|
26
|
+
*/
|
|
27
|
+
setRoom(room) {
|
|
28
|
+
// Clean up previous room listeners
|
|
29
|
+
if (this.room) {
|
|
30
|
+
this.cleanupListeners();
|
|
31
|
+
}
|
|
32
|
+
this.room = room;
|
|
33
|
+
if (room && room.state !== 'disconnected') {
|
|
34
|
+
this.setupListeners();
|
|
35
|
+
this.updateState();
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Setup event listeners for room
|
|
40
|
+
*/
|
|
41
|
+
setupListeners() {
|
|
42
|
+
if (!this.room)
|
|
43
|
+
return;
|
|
44
|
+
const localParticipant = this.room.localParticipant;
|
|
45
|
+
const handleTrackMuted = (track) => {
|
|
46
|
+
if (track.source === 'camera') {
|
|
47
|
+
this._isVideoHidden = true;
|
|
48
|
+
this.emit('videoStateChange', { isVideoHidden: true });
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
const handleTrackUnmuted = (track) => {
|
|
52
|
+
if (track.source === 'camera') {
|
|
53
|
+
this._isVideoHidden = false;
|
|
54
|
+
this.emit('videoStateChange', { isVideoHidden: false });
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
const handleTrackPublished = (publication) => {
|
|
58
|
+
if (publication.source === 'camera') {
|
|
59
|
+
this._isVideoEnabled = true;
|
|
60
|
+
this.emit('videoStateChange', { isVideoEnabled: true });
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
const handleTrackUnpublished = (publication) => {
|
|
64
|
+
if (publication.source === 'camera') {
|
|
65
|
+
this._isVideoEnabled = false;
|
|
66
|
+
this.emit('videoStateChange', { isVideoEnabled: false });
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
localParticipant.on('trackMuted', handleTrackMuted);
|
|
70
|
+
localParticipant.on('trackUnmuted', handleTrackUnmuted);
|
|
71
|
+
localParticipant.on('trackPublished', handleTrackPublished);
|
|
72
|
+
localParticipant.on('trackUnpublished', handleTrackUnpublished);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Clean up event listeners
|
|
76
|
+
*/
|
|
77
|
+
cleanupListeners() {
|
|
78
|
+
if (!this.room)
|
|
79
|
+
return;
|
|
80
|
+
// LiveKit handles cleanup automatically when participant is removed
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Update video state from room
|
|
84
|
+
*/
|
|
85
|
+
updateState() {
|
|
86
|
+
if (!this.room || this.room.state === 'disconnected') {
|
|
87
|
+
this._isVideoEnabled = false;
|
|
88
|
+
this._isVideoHidden = false;
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
const localParticipant = this.room.localParticipant;
|
|
92
|
+
this._isVideoEnabled = localParticipant.isCameraEnabled;
|
|
93
|
+
this._isVideoHidden = false; // LiveKit doesn't have a direct hidden state for video
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Enable video
|
|
97
|
+
*/
|
|
98
|
+
async enableVideo() {
|
|
99
|
+
if (!this.room) {
|
|
100
|
+
throw new Error('Room not initialized');
|
|
101
|
+
}
|
|
102
|
+
try {
|
|
103
|
+
await this.room.localParticipant.setCameraEnabled(true);
|
|
104
|
+
this._isVideoEnabled = true;
|
|
105
|
+
}
|
|
106
|
+
catch (error) {
|
|
107
|
+
logger.error("Failed to enable video:", error);
|
|
108
|
+
throw error;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Disable video
|
|
113
|
+
*/
|
|
114
|
+
async disableVideo() {
|
|
115
|
+
if (!this.room) {
|
|
116
|
+
throw new Error('Room not initialized');
|
|
117
|
+
}
|
|
118
|
+
try {
|
|
119
|
+
await this.room.localParticipant.setCameraEnabled(false);
|
|
120
|
+
this._isVideoEnabled = false;
|
|
121
|
+
}
|
|
122
|
+
catch (error) {
|
|
123
|
+
logger.error("Failed to disable video:", error);
|
|
124
|
+
throw error;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Hide video
|
|
129
|
+
*/
|
|
130
|
+
async hideVideo() {
|
|
131
|
+
await this.disableVideo();
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Show video
|
|
135
|
+
*/
|
|
136
|
+
async showVideo() {
|
|
137
|
+
await this.enableVideo();
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Toggle video
|
|
141
|
+
*/
|
|
142
|
+
async toggleVideo() {
|
|
143
|
+
if (this._isVideoEnabled) {
|
|
144
|
+
await this.disableVideo();
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
await this.enableVideo();
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Set video device
|
|
152
|
+
*/
|
|
153
|
+
async setVideoDevice(deviceId) {
|
|
154
|
+
if (!this.room) {
|
|
155
|
+
throw new Error('Room not initialized');
|
|
156
|
+
}
|
|
157
|
+
try {
|
|
158
|
+
await this.room.localParticipant.setCameraEnabled(true, { deviceId });
|
|
159
|
+
}
|
|
160
|
+
catch (error) {
|
|
161
|
+
logger.error("Failed to set video device:", error);
|
|
162
|
+
throw error;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Get available video devices
|
|
167
|
+
*/
|
|
168
|
+
async getVideoDevices() {
|
|
169
|
+
try {
|
|
170
|
+
const devices = await navigator.mediaDevices.enumerateDevices();
|
|
171
|
+
const videoDevices = devices.filter(device => device.kind === 'videoinput');
|
|
172
|
+
return videoDevices;
|
|
173
|
+
}
|
|
174
|
+
catch (error) {
|
|
175
|
+
logger.error("Failed to get video devices:", error);
|
|
176
|
+
throw error;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Set video quality
|
|
181
|
+
*/
|
|
182
|
+
async setVideoQuality(quality) {
|
|
183
|
+
if (!this.room) {
|
|
184
|
+
throw new Error('Room not initialized');
|
|
185
|
+
}
|
|
186
|
+
try {
|
|
187
|
+
// TODO: Implement video quality settings when LiveKit provides the API
|
|
188
|
+
logger.warn('Video quality setting not yet implemented');
|
|
189
|
+
}
|
|
190
|
+
catch (error) {
|
|
191
|
+
logger.error("Failed to set video quality:", error);
|
|
192
|
+
throw error;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Reset state on disconnect
|
|
197
|
+
*/
|
|
198
|
+
reset() {
|
|
199
|
+
this._isVideoEnabled = false;
|
|
200
|
+
this._isVideoHidden = false;
|
|
201
|
+
this.emit('videoStateChange', {
|
|
202
|
+
isVideoEnabled: false,
|
|
203
|
+
isVideoHidden: false
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
//# sourceMappingURL=VideoManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VideoManager.js","sourceRoot":"","sources":["../../src/core/VideoManager.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C;;;;GAIG;AACH,MAAM,OAAO,YAAa,SAAQ,YAAY;IAK5C,YAAY,IAAW;QACrB,KAAK,EAAE,CAAC;QALF,SAAI,GAAgB,IAAI,CAAC;QACzB,oBAAe,GAAY,KAAK,CAAC;QACjC,mBAAc,GAAY,KAAK,CAAC;QAItC,IAAI,IAAI,EAAE,CAAC;YACT,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACrB,CAAC;IACH,CAAC;IAED,IAAI,cAAc;QAChB,OAAO,IAAI,CAAC,eAAe,CAAC;IAC9B,CAAC;IAED,IAAI,aAAa;QACf,OAAO,IAAI,CAAC,cAAc,CAAC;IAC7B,CAAC;IAED;;OAEG;IACH,OAAO,CAAC,IAAU;QAChB,mCAAmC;QACnC,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;YACd,IAAI,CAAC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B,aAAa,EAAE,KAAK;SACrB,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { ConvaiClient } from './ConvaiClient';
|
|
2
|
+
export * from './types';
|
|
3
|
+
export type { ConvaiClient as ConvaiClientType } from './ConvaiClient';
|
|
4
|
+
export { AudioManager } from './AudioManager';
|
|
5
|
+
export { VideoManager } from './VideoManager';
|
|
6
|
+
export { ScreenShareManager } from './ScreenShareManager';
|
|
7
|
+
export { MessageHandler } from './MessageHandler';
|
|
8
|
+
export { EventEmitter } from './EventEmitter';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAG9C,cAAc,SAAS,CAAC;AAGxB,YAAY,EAAE,YAAY,IAAI,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAGvE,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGlD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// Main client
|
|
2
|
+
export { ConvaiClient } from './ConvaiClient';
|
|
3
|
+
// Types (including IConvaiClient interface)
|
|
4
|
+
export * from './types';
|
|
5
|
+
// Managers (for advanced usage)
|
|
6
|
+
export { AudioManager } from './AudioManager';
|
|
7
|
+
export { VideoManager } from './VideoManager';
|
|
8
|
+
export { ScreenShareManager } from './ScreenShareManager';
|
|
9
|
+
export { MessageHandler } from './MessageHandler';
|
|
10
|
+
// Event Emitter (for advanced usage)
|
|
11
|
+
export { EventEmitter } from './EventEmitter';
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,cAAc;AACd,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,4CAA4C;AAC5C,cAAc,SAAS,CAAC;AAKxB,gCAAgC;AAChC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,qCAAqC;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
import { Room } from 'livekit-client';
|
|
2
|
+
/**
|
|
3
|
+
* Audio processing settings for the microphone input.
|
|
4
|
+
* These settings help optimize the audio quality and reduce interruptions.
|
|
5
|
+
* @internal - This is a fixed configuration and should not be modified by users
|
|
6
|
+
*/
|
|
7
|
+
export interface AudioSettings {
|
|
8
|
+
/** Enable echo cancellation to prevent audio feedback (default: true) */
|
|
9
|
+
echoCancellation?: boolean;
|
|
10
|
+
/** Enable noise suppression to reduce background noise (default: true) */
|
|
11
|
+
noiseSuppression?: boolean;
|
|
12
|
+
/** Enable automatic gain control for consistent volume (default: true) */
|
|
13
|
+
autoGainControl?: boolean;
|
|
14
|
+
/** Audio sample rate in Hz (default: 48000) */
|
|
15
|
+
sampleRate?: number;
|
|
16
|
+
/** Number of audio channels, 1 for mono, 2 for stereo (default: 1) */
|
|
17
|
+
channelCount?: number;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Configuration object for connecting to a Convai character.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* const config: ConvaiConfig = {
|
|
25
|
+
* apiKey: 'your-api-key',
|
|
26
|
+
* characterId: 'your-character-id',
|
|
27
|
+
* endUserId: 'user-uuid', // Optional: enables long-term memory and analytics
|
|
28
|
+
* enableVideo: false, // If false, connection_type will be "audio"
|
|
29
|
+
* };
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export interface ConvaiConfig {
|
|
33
|
+
/** Your Convai API key from convai.com dashboard (required) */
|
|
34
|
+
apiKey: string;
|
|
35
|
+
/** The Character ID to connect to (required) */
|
|
36
|
+
characterId: string;
|
|
37
|
+
/**
|
|
38
|
+
* End user identifier for speaker management (optional).
|
|
39
|
+
*
|
|
40
|
+
* When provided:
|
|
41
|
+
* - Enables long-term memory: Character remembers context from previous conversations with this user
|
|
42
|
+
* - Enables analytics: Track user engagement and behavior
|
|
43
|
+
*
|
|
44
|
+
* When not provided:
|
|
45
|
+
* - Anonymous mode: No persistent memory or user tracking
|
|
46
|
+
* - Each session is independent with no conversation history
|
|
47
|
+
*
|
|
48
|
+
* Use a unique UUID or device ID for persistent user experiences.
|
|
49
|
+
*/
|
|
50
|
+
endUserId?: string;
|
|
51
|
+
/** Custom Convai API URL (optional, defaults to production endpoint) */
|
|
52
|
+
url?: string;
|
|
53
|
+
/**
|
|
54
|
+
* Enable video capability (default: false).
|
|
55
|
+
* If true, connection_type will be "video" (supports audio, video, and screenshare).
|
|
56
|
+
* If false, connection_type will be "audio" (audio only).
|
|
57
|
+
*/
|
|
58
|
+
enableVideo?: boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Start with video camera on when connecting (default: false).
|
|
61
|
+
* Only works if enableVideo is true. If false, camera stays off until user enables it.
|
|
62
|
+
*/
|
|
63
|
+
startWithVideoOn?: boolean;
|
|
64
|
+
/** Enable text-to-speech audio generation (default: true) */
|
|
65
|
+
ttsEnabled?: boolean;
|
|
66
|
+
/** Configuration for character actions and environmental context */
|
|
67
|
+
actionConfig?: {
|
|
68
|
+
/** List of action names the character can perform */
|
|
69
|
+
actions: string[];
|
|
70
|
+
/** Other characters present in the scene or conversation */
|
|
71
|
+
characters: Array<{
|
|
72
|
+
/** Character name */
|
|
73
|
+
name: string;
|
|
74
|
+
/** Character biography or description */
|
|
75
|
+
bio: string;
|
|
76
|
+
}>;
|
|
77
|
+
/** Objects available in the scene or environment */
|
|
78
|
+
objects: Array<{
|
|
79
|
+
/** Object name */
|
|
80
|
+
name: string;
|
|
81
|
+
/** Object description or properties */
|
|
82
|
+
description: string;
|
|
83
|
+
}>;
|
|
84
|
+
/** Name of the object the character is currently focused on */
|
|
85
|
+
currentAttentionObject?: string;
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Represents a single message in the chat conversation.
|
|
90
|
+
* Different message types are used for various parts of the conversation flow.
|
|
91
|
+
*/
|
|
92
|
+
export interface ChatMessage {
|
|
93
|
+
/** Unique identifier for the message */
|
|
94
|
+
id: string;
|
|
95
|
+
/**
|
|
96
|
+
* Type of message:
|
|
97
|
+
* - `user`: User's sent message
|
|
98
|
+
* - `convai`: Character's response
|
|
99
|
+
* - `user-transcription`: Real-time speech-to-text from user
|
|
100
|
+
* - `bot-llm-text`: Character's LLM-generated text
|
|
101
|
+
* - `emotion`: Character's emotional state
|
|
102
|
+
* - `behavior-tree`: Behavior tree response
|
|
103
|
+
* - `action`: Action execution
|
|
104
|
+
* - `bot-emotion`: Bot emotional response
|
|
105
|
+
* - `user-llm-text`: User text processed by LLM
|
|
106
|
+
*/
|
|
107
|
+
type: 'user' | 'convai' | 'emotion' | 'behavior-tree' | 'action' | 'user-transcription' | 'bot-llm-text' | 'bot-emotion' | 'user-llm-text';
|
|
108
|
+
/** The text content of the message */
|
|
109
|
+
content: string;
|
|
110
|
+
/** ISO timestamp string of when the message was created */
|
|
111
|
+
timestamp: string;
|
|
112
|
+
/** Whether this is the final version of the message (for streaming) */
|
|
113
|
+
isFinal?: boolean;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Represents the current state of the Convai client connection and activity.
|
|
117
|
+
* Use this to provide UI feedback about the conversation state.
|
|
118
|
+
*
|
|
119
|
+
* @example
|
|
120
|
+
* ```typescript
|
|
121
|
+
* const { state } = convaiClient;
|
|
122
|
+
*
|
|
123
|
+
* if (state.isConnected) {
|
|
124
|
+
* console.log('Connected to character');
|
|
125
|
+
* }
|
|
126
|
+
*
|
|
127
|
+
* if (state.isSpeaking) {
|
|
128
|
+
* console.log('Character is speaking');
|
|
129
|
+
* }
|
|
130
|
+
*
|
|
131
|
+
* // Or use the combined state
|
|
132
|
+
* console.log(state.agentState); // 'listening' | 'thinking' | 'speaking'
|
|
133
|
+
* ```
|
|
134
|
+
*/
|
|
135
|
+
export interface ConvaiClientState {
|
|
136
|
+
/** Whether the client is currently connected to Convai */
|
|
137
|
+
isConnected: boolean;
|
|
138
|
+
/** Whether a connection attempt is in progress */
|
|
139
|
+
isConnecting: boolean;
|
|
140
|
+
/** Whether the system is actively listening to user input */
|
|
141
|
+
isListening: boolean;
|
|
142
|
+
/** Whether the character is processing/thinking about a response */
|
|
143
|
+
isThinking: boolean;
|
|
144
|
+
/** Whether the character is currently speaking */
|
|
145
|
+
isSpeaking: boolean;
|
|
146
|
+
/**
|
|
147
|
+
* Combined state indicator for the character's current activity.
|
|
148
|
+
* Use this as a single source of truth for UI state.
|
|
149
|
+
*/
|
|
150
|
+
agentState: 'disconnected' | 'connected' | 'listening' | 'thinking' | 'speaking';
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Audio control interface for managing microphone
|
|
154
|
+
*/
|
|
155
|
+
export interface AudioControls {
|
|
156
|
+
isAudioEnabled: boolean;
|
|
157
|
+
isAudioMuted: boolean;
|
|
158
|
+
audioLevel: number;
|
|
159
|
+
enableAudio: () => Promise<void>;
|
|
160
|
+
disableAudio: () => Promise<void>;
|
|
161
|
+
muteAudio: () => Promise<void>;
|
|
162
|
+
unmuteAudio: () => Promise<void>;
|
|
163
|
+
toggleAudio: () => Promise<void>;
|
|
164
|
+
setAudioDevice: (deviceId: string) => Promise<void>;
|
|
165
|
+
getAudioDevices: () => Promise<MediaDeviceInfo[]>;
|
|
166
|
+
startAudioLevelMonitoring: () => void;
|
|
167
|
+
stopAudioLevelMonitoring: () => void;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Video control interface for managing camera
|
|
171
|
+
*/
|
|
172
|
+
export interface VideoControls {
|
|
173
|
+
isVideoEnabled: boolean;
|
|
174
|
+
isVideoHidden: boolean;
|
|
175
|
+
enableVideo: () => Promise<void>;
|
|
176
|
+
disableVideo: () => Promise<void>;
|
|
177
|
+
hideVideo: () => Promise<void>;
|
|
178
|
+
showVideo: () => Promise<void>;
|
|
179
|
+
toggleVideo: () => Promise<void>;
|
|
180
|
+
setVideoDevice: (deviceId: string) => Promise<void>;
|
|
181
|
+
getVideoDevices: () => Promise<MediaDeviceInfo[]>;
|
|
182
|
+
setVideoQuality: (quality: 'low' | 'medium' | 'high') => Promise<void>;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Screen share control interface
|
|
186
|
+
*/
|
|
187
|
+
export interface ScreenShareControls {
|
|
188
|
+
isScreenShareEnabled: boolean;
|
|
189
|
+
isScreenShareActive: boolean;
|
|
190
|
+
enableScreenShare: () => Promise<void>;
|
|
191
|
+
disableScreenShare: () => Promise<void>;
|
|
192
|
+
toggleScreenShare: () => Promise<void>;
|
|
193
|
+
enableScreenShareWithAudio: () => Promise<void>;
|
|
194
|
+
getScreenShareTracks: () => Promise<any[]>;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Main Convai client interface.
|
|
198
|
+
* Provides complete control over Convai character connections and interactions.
|
|
199
|
+
*
|
|
200
|
+
* @example
|
|
201
|
+
* ```typescript
|
|
202
|
+
* import { ConvaiClient } from '@convai/web-sdk/core';
|
|
203
|
+
*
|
|
204
|
+
* const client = new ConvaiClient();
|
|
205
|
+
*
|
|
206
|
+
* // Connect to character
|
|
207
|
+
* await client.connect({
|
|
208
|
+
* apiKey: 'your-api-key',
|
|
209
|
+
* characterId: 'your-character-id',
|
|
210
|
+
* endUserId: '-1' // Dev mode
|
|
211
|
+
* });
|
|
212
|
+
*
|
|
213
|
+
* // Send a message
|
|
214
|
+
* client.sendUserTextMessage('Hello!');
|
|
215
|
+
*
|
|
216
|
+
* // Listen for state changes
|
|
217
|
+
* client.on('stateChange', (state) => {
|
|
218
|
+
* console.log('State:', state);
|
|
219
|
+
* });
|
|
220
|
+
*
|
|
221
|
+
* // Listen for messages
|
|
222
|
+
* client.on('message', (message) => {
|
|
223
|
+
* console.log('New message:', message);
|
|
224
|
+
* });
|
|
225
|
+
* ```
|
|
226
|
+
*/
|
|
227
|
+
export interface IConvaiClient {
|
|
228
|
+
/** Current connection and activity state of the client */
|
|
229
|
+
readonly state: ConvaiClientState;
|
|
230
|
+
/**
|
|
231
|
+
* Connection type: "audio" (audio only) or "video" (audio + video + screenshare).
|
|
232
|
+
* Set based on enableVideo in connect config.
|
|
233
|
+
*/
|
|
234
|
+
readonly connectionType: 'audio' | 'video' | null;
|
|
235
|
+
/** API key used for the current connection (null if not connected) */
|
|
236
|
+
readonly apiKey: string | null;
|
|
237
|
+
/** Character ID used for the current connection (null if not connected) */
|
|
238
|
+
readonly characterId: string | null;
|
|
239
|
+
/**
|
|
240
|
+
* Speaker ID for the current user (null if not connected).
|
|
241
|
+
* Used for long-term memory and user analytics.
|
|
242
|
+
*/
|
|
243
|
+
readonly speakerId: string | null;
|
|
244
|
+
/** Internal LiveKit Room instance (for advanced usage) */
|
|
245
|
+
readonly room: Room;
|
|
246
|
+
/** Array of all chat messages in the current conversation */
|
|
247
|
+
readonly chatMessages: ChatMessage[];
|
|
248
|
+
/** Current real-time transcription of user speech */
|
|
249
|
+
readonly userTranscription: string;
|
|
250
|
+
/** Unique session ID for the current character conversation */
|
|
251
|
+
readonly characterSessionId: string | null;
|
|
252
|
+
/** Whether the bot is ready to receive messages (true after bot-ready message) */
|
|
253
|
+
readonly isBotReady: boolean;
|
|
254
|
+
/** Audio control methods for managing microphone mute/unmute */
|
|
255
|
+
readonly audioControls: AudioControls;
|
|
256
|
+
/** Video control methods for enabling/disabling camera */
|
|
257
|
+
readonly videoControls: VideoControls;
|
|
258
|
+
/** Screen sharing control methods */
|
|
259
|
+
readonly screenShareControls: ScreenShareControls;
|
|
260
|
+
/**
|
|
261
|
+
* Connect to a Convai character.
|
|
262
|
+
*/
|
|
263
|
+
connect: (config?: ConvaiConfig) => Promise<void>;
|
|
264
|
+
/** Disconnect from the current character session */
|
|
265
|
+
disconnect: () => Promise<void>;
|
|
266
|
+
/** Reconnect - disconnect and connect again using stored config */
|
|
267
|
+
reconnect: () => Promise<void>;
|
|
268
|
+
/** Reset the session ID to start a new conversation (clears history) */
|
|
269
|
+
resetSession: () => void;
|
|
270
|
+
/** Send a text message to the character */
|
|
271
|
+
sendUserTextMessage: (text: string) => void;
|
|
272
|
+
/**
|
|
273
|
+
* Send a trigger message to invoke specific character actions or responses.
|
|
274
|
+
* @param triggerName - Name of the trigger to invoke
|
|
275
|
+
* @param triggerMessage - Optional message to accompany the trigger
|
|
276
|
+
*/
|
|
277
|
+
sendTriggerMessage: (triggerName?: string, triggerMessage?: string) => void;
|
|
278
|
+
/**
|
|
279
|
+
* Update template keys in the character's context (e.g., user name, location).
|
|
280
|
+
* These keys can be referenced in the character's responses.
|
|
281
|
+
*/
|
|
282
|
+
updateTemplateKeys: (templateKeys: {
|
|
283
|
+
[key: string]: string;
|
|
284
|
+
}) => void;
|
|
285
|
+
/**
|
|
286
|
+
* Update dynamic information about the current context.
|
|
287
|
+
* This helps the character understand the current situation.
|
|
288
|
+
*/
|
|
289
|
+
updateDynamicInfo: (dynamicInfo: {
|
|
290
|
+
text: string;
|
|
291
|
+
}) => void;
|
|
292
|
+
/**
|
|
293
|
+
* Toggle text-to-speech on or off.
|
|
294
|
+
* When disabled, character responses won't be spoken aloud.
|
|
295
|
+
*/
|
|
296
|
+
toggleTts: (enabled: boolean) => void;
|
|
297
|
+
/**
|
|
298
|
+
* Subscribe to an event
|
|
299
|
+
* @param event Event name ('stateChange', 'message', 'connect', 'disconnect', 'error')
|
|
300
|
+
* @param callback Callback function
|
|
301
|
+
* @returns Unsubscribe function
|
|
302
|
+
*/
|
|
303
|
+
on: (event: string, callback: (...args: any[]) => void) => () => void;
|
|
304
|
+
/**
|
|
305
|
+
* Unsubscribe from an event
|
|
306
|
+
* @param event Event name
|
|
307
|
+
* @param callback Callback function to remove
|
|
308
|
+
*/
|
|
309
|
+
off: (event: string, callback: (...args: any[]) => void) => void;
|
|
310
|
+
}
|
|
311
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAEtC;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B,yEAAyE;IACzE,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,0EAA0E;IAC1E,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,0EAA0E;IAC1E,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,+CAA+C;IAC/C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,sEAAsE;IACtE,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,YAAY;IAC3B,+DAA+D;IAC/D,MAAM,EAAE,MAAM,CAAC;IACf,gDAAgD;IAChD,WAAW,EAAE,MAAM,CAAC;IACpB;;;;;;;;;;;;OAYG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,wEAAwE;IACxE,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;;OAIG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;OAGG;IACH,gBAAgB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AAK,IAAI,CAAC;CAClE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useConvaiClient.d.ts","sourceRoot":"","sources":["../../src/hooks/useConvaiClient.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,YAAY,EACZ,YAAY,EAEZ,WAAW,EAEZ,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"useConvaiClient.d.ts","sourceRoot":"","sources":["../../src/hooks/useConvaiClient.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,YAAY,EACZ,YAAY,EAEZ,WAAW,EAEZ,MAAM,UAAU,CAAC;AAalB;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,eAAe,GAAI,SAAS,YAAY,KAAG,YAAY,GAAG;IACrE,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,WAAW,EAAE,CAAC;CAyW7B,CAAC"}
|