@sanseng/livekit-ws-sdk 0.1.2
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 +3 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.d.ts +1789 -0
- package/dist/index.esm.js +1 -0
- package/dist/index.umd.js +1 -0
- package/package.json +63 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,1789 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Disposable Resource Interface
|
|
3
|
+
* Classes implementing this interface must provide resource cleanup logic
|
|
4
|
+
*
|
|
5
|
+
* @author sansen
|
|
6
|
+
* @interface IDisposable
|
|
7
|
+
*/
|
|
8
|
+
interface IDisposable {
|
|
9
|
+
/**
|
|
10
|
+
* Releases all resources held by the object
|
|
11
|
+
*
|
|
12
|
+
* @author sansen
|
|
13
|
+
*/
|
|
14
|
+
dispose(): void;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Abstract base class for disposable resources
|
|
18
|
+
* Provides standardized disposal pattern with safety checks
|
|
19
|
+
*
|
|
20
|
+
* @author sansen
|
|
21
|
+
* @abstract
|
|
22
|
+
* @class Disposable
|
|
23
|
+
* @implements {IDisposable}
|
|
24
|
+
*/
|
|
25
|
+
declare abstract class Disposable implements IDisposable {
|
|
26
|
+
private _disposed;
|
|
27
|
+
/**
|
|
28
|
+
* Checks if the object has been disposed
|
|
29
|
+
*
|
|
30
|
+
* @type {boolean}
|
|
31
|
+
* @protected
|
|
32
|
+
* @author sansen
|
|
33
|
+
*/
|
|
34
|
+
protected get isDisposed(): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Releases all resources held by the object
|
|
37
|
+
* Subclasses should override onDispose method to implement specific cleanup logic
|
|
38
|
+
*
|
|
39
|
+
* @author sansen
|
|
40
|
+
*/
|
|
41
|
+
dispose(): void;
|
|
42
|
+
/**
|
|
43
|
+
* Abstract method for subclasses to implement specific resource cleanup logic
|
|
44
|
+
*
|
|
45
|
+
* @abstract
|
|
46
|
+
* @protected
|
|
47
|
+
* @author sansen
|
|
48
|
+
*/
|
|
49
|
+
protected abstract onDispose(): void;
|
|
50
|
+
/**
|
|
51
|
+
* Ensures the object has not been disposed, throws error if already disposed
|
|
52
|
+
*
|
|
53
|
+
* @protected
|
|
54
|
+
* @throws {SDKError} If object has been disposed
|
|
55
|
+
* @author sansen
|
|
56
|
+
*/
|
|
57
|
+
protected ensureNotDisposed(): void;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Video-related events
|
|
62
|
+
*
|
|
63
|
+
* @author sansen
|
|
64
|
+
* @interface VideoEvents
|
|
65
|
+
*/
|
|
66
|
+
interface VideoEvents {
|
|
67
|
+
videoTrackAdded: { trackId: string; participantId: string };
|
|
68
|
+
videoTrackRemoved: { trackId: string; participantId: string };
|
|
69
|
+
videoRenderModeChanged: { mode: string };
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Audio-related events
|
|
74
|
+
*
|
|
75
|
+
* @author sansen
|
|
76
|
+
* @interface AudioEvents
|
|
77
|
+
*/
|
|
78
|
+
interface AudioEvents {
|
|
79
|
+
audioInputStarted: void;
|
|
80
|
+
audioInputStopped: void;
|
|
81
|
+
audioFrame: { data: Float32Array; sampleRate: number };
|
|
82
|
+
/**
|
|
83
|
+
* Raw audio payload event
|
|
84
|
+
* Contains PCM audio data and metadata (without protocol header)
|
|
85
|
+
*
|
|
86
|
+
* @author sansen
|
|
87
|
+
*/
|
|
88
|
+
audioPayload: {
|
|
89
|
+
/**
|
|
90
|
+
* PCM audio data (Uint8Array, 16-bit little-endian)
|
|
91
|
+
* Does not contain protocol header
|
|
92
|
+
*
|
|
93
|
+
* @type {Uint8Array}
|
|
94
|
+
*/
|
|
95
|
+
payload: Uint8Array;
|
|
96
|
+
/**
|
|
97
|
+
* Sample rate in Hz
|
|
98
|
+
*
|
|
99
|
+
* @type {number}
|
|
100
|
+
*/
|
|
101
|
+
sampleRate: number;
|
|
102
|
+
/**
|
|
103
|
+
* Number of channels (1=mono, 2=stereo)
|
|
104
|
+
*
|
|
105
|
+
* @type {number}
|
|
106
|
+
*/
|
|
107
|
+
channels: number;
|
|
108
|
+
/**
|
|
109
|
+
* Sequence number (0-4095)
|
|
110
|
+
*
|
|
111
|
+
* @type {number}
|
|
112
|
+
*/
|
|
113
|
+
sequenceNumber: number;
|
|
114
|
+
/**
|
|
115
|
+
* Timestamp in milliseconds (from capture start)
|
|
116
|
+
*
|
|
117
|
+
* @type {number}
|
|
118
|
+
*/
|
|
119
|
+
timestamp: number;
|
|
120
|
+
/**
|
|
121
|
+
* Indicates if this is a key frame
|
|
122
|
+
*
|
|
123
|
+
* @type {boolean}
|
|
124
|
+
*/
|
|
125
|
+
keyFrame: boolean;
|
|
126
|
+
/**
|
|
127
|
+
* Frame size in samples
|
|
128
|
+
*
|
|
129
|
+
* @type {number}
|
|
130
|
+
*/
|
|
131
|
+
frameSize: number;
|
|
132
|
+
};
|
|
133
|
+
audioTrackAdded: { trackId: string; participantId: string };
|
|
134
|
+
audioTrackRemoved: { trackId: string };
|
|
135
|
+
audioVolumeChanged: { volume: number };
|
|
136
|
+
audioMuted: void;
|
|
137
|
+
audioUnmuted: void;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Conversation-related events
|
|
142
|
+
*
|
|
143
|
+
* @author sansen
|
|
144
|
+
* @interface ConversationEvents
|
|
145
|
+
*/
|
|
146
|
+
interface ConversationEvents {
|
|
147
|
+
questionSent: { questionId: string; text: string };
|
|
148
|
+
answerWaiting: { questionId: string };
|
|
149
|
+
answerChunk: { questionId: string; chunk: string; isComplete: boolean };
|
|
150
|
+
answerCompleted: { questionId: string; fullAnswer: string };
|
|
151
|
+
serverMessage: { questionId: string; message: string; type: string };
|
|
152
|
+
asrReceived: { questionId: string; text: string };
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Connection-related events
|
|
157
|
+
*
|
|
158
|
+
* @author sansen
|
|
159
|
+
* @interface ConnectionEvents
|
|
160
|
+
*/
|
|
161
|
+
interface ConnectionEvents {
|
|
162
|
+
connected: { source: 'livekit' | 'ws' };
|
|
163
|
+
disconnected: { source: 'livekit' | 'ws'; reason?: string };
|
|
164
|
+
error: { error: Error };
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* SDK public stable event interface
|
|
169
|
+
* Exposed to external consumers of the SDK
|
|
170
|
+
*
|
|
171
|
+
* @author sansen
|
|
172
|
+
* @interface PublicSDKEvents
|
|
173
|
+
*/
|
|
174
|
+
interface PublicSDKEvents {
|
|
175
|
+
// Connection status
|
|
176
|
+
'sdk:connected': { livekit: boolean; ws: boolean; all: boolean };
|
|
177
|
+
'sdk:disconnected': { reason?: string };
|
|
178
|
+
'sdk:error': { message: string; code: string };
|
|
179
|
+
|
|
180
|
+
// Media status (hides internal trackId and participantId)
|
|
181
|
+
'media:video:trackAdded': { isLocal: boolean };
|
|
182
|
+
'media:audio:captureStarted': undefined;
|
|
183
|
+
|
|
184
|
+
// Conversation flow (maintains clear business logic)
|
|
185
|
+
'conversation:question:sent': { questionId: string; text: string };
|
|
186
|
+
'conversation:answer:waiting': { questionId: string };
|
|
187
|
+
'conversation:server:message': { questionId: string; message: string; type: string };
|
|
188
|
+
'conversation:asr:received': { questionId: string; text: string };
|
|
189
|
+
'conversation:answer:chunk': { questionId: string; chunk: string; isComplete: boolean };
|
|
190
|
+
'conversation:answer:completed': { questionId: string; fullAnswer: string };
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Union type of all SDK events
|
|
195
|
+
*
|
|
196
|
+
* @author sansen
|
|
197
|
+
* @typedef {SDKEvents}
|
|
198
|
+
*/
|
|
199
|
+
type SDKEvents = PublicSDKEvents & VideoEvents & AudioEvents & ConversationEvents & ConnectionEvents;
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Event listener function type
|
|
203
|
+
*
|
|
204
|
+
* @template T - Event data type
|
|
205
|
+
* @author sansen
|
|
206
|
+
*/
|
|
207
|
+
type EventListener<T = unknown> = (data: T) => void;
|
|
208
|
+
/**
|
|
209
|
+
* Event Bus
|
|
210
|
+
* Implements observer pattern for decoupled communication between modules
|
|
211
|
+
*
|
|
212
|
+
* @author sansen
|
|
213
|
+
* @class EventBus
|
|
214
|
+
* @extends {Disposable}
|
|
215
|
+
*/
|
|
216
|
+
declare class EventBus extends Disposable {
|
|
217
|
+
private _listeners;
|
|
218
|
+
/**
|
|
219
|
+
* Subscribes to an event
|
|
220
|
+
*
|
|
221
|
+
* @template K - Event key type
|
|
222
|
+
* @param {K} event - Event name
|
|
223
|
+
* @param {EventListener<SDKEvents[K]>} listener - Event listener function
|
|
224
|
+
* @returns {() => void} Unsubscribe function
|
|
225
|
+
* @author sansen
|
|
226
|
+
*/
|
|
227
|
+
on<K extends keyof SDKEvents>(event: K, listener: EventListener<SDKEvents[K]>): () => void;
|
|
228
|
+
/**
|
|
229
|
+
* Subscribes to an event for one-time execution
|
|
230
|
+
*
|
|
231
|
+
* @template K - Event key type
|
|
232
|
+
* @param {K} event - Event name
|
|
233
|
+
* @param {EventListener<SDKEvents[K]>} listener - Event listener function
|
|
234
|
+
* @returns {() => void} Unsubscribe function
|
|
235
|
+
* @author sansen
|
|
236
|
+
*/
|
|
237
|
+
once<K extends keyof SDKEvents>(event: K, listener: EventListener<SDKEvents[K]>): () => void;
|
|
238
|
+
/**
|
|
239
|
+
* Unsubscribes from an event
|
|
240
|
+
*
|
|
241
|
+
* @template K - Event key type
|
|
242
|
+
* @param {K} event - Event name
|
|
243
|
+
* @param {EventListener<SDKEvents[K]>} listener - Event listener function to remove
|
|
244
|
+
* @author sansen
|
|
245
|
+
*/
|
|
246
|
+
off<K extends keyof SDKEvents>(event: K, listener: EventListener<SDKEvents[K]>): void;
|
|
247
|
+
/**
|
|
248
|
+
* Emits an event to all registered listeners
|
|
249
|
+
*
|
|
250
|
+
* @template K - Event key type
|
|
251
|
+
* @param {K} event - Event name
|
|
252
|
+
* @param {SDKEvents[K]} data - Event data
|
|
253
|
+
* @author sansen
|
|
254
|
+
*/
|
|
255
|
+
emit<K extends keyof SDKEvents>(event: K, data: SDKEvents[K]): void;
|
|
256
|
+
/**
|
|
257
|
+
* Removes all event listeners
|
|
258
|
+
*
|
|
259
|
+
* @author sansen
|
|
260
|
+
*/
|
|
261
|
+
removeAllListeners(): void;
|
|
262
|
+
/**
|
|
263
|
+
* Gets the count of listeners for a specific event
|
|
264
|
+
*
|
|
265
|
+
* @template K - Event key type
|
|
266
|
+
* @param {K} event - Event name
|
|
267
|
+
* @returns {number} Number of listeners for the event
|
|
268
|
+
* @author sansen
|
|
269
|
+
*/
|
|
270
|
+
listenerCount<K extends keyof SDKEvents>(event: K): number;
|
|
271
|
+
/**
|
|
272
|
+
* Cleanup method called when the event bus is disposed
|
|
273
|
+
*
|
|
274
|
+
* @protected
|
|
275
|
+
* @author sansen
|
|
276
|
+
*/
|
|
277
|
+
protected onDispose(): void;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* Video State Management
|
|
282
|
+
* Pure data container without business logic
|
|
283
|
+
*
|
|
284
|
+
* @author sansen
|
|
285
|
+
* @class VideoState
|
|
286
|
+
*/
|
|
287
|
+
declare class VideoState {
|
|
288
|
+
/**
|
|
289
|
+
* Current video track identifier
|
|
290
|
+
*
|
|
291
|
+
* @type {string|null}
|
|
292
|
+
* @default null
|
|
293
|
+
* @author sansen
|
|
294
|
+
*/
|
|
295
|
+
currentTrackId: string | null;
|
|
296
|
+
/**
|
|
297
|
+
* Current participant identifier
|
|
298
|
+
*
|
|
299
|
+
* @type {string|null}
|
|
300
|
+
* @default null
|
|
301
|
+
* @author sansen
|
|
302
|
+
*/
|
|
303
|
+
currentParticipantId: string | null;
|
|
304
|
+
/**
|
|
305
|
+
* Current video rendering mode
|
|
306
|
+
*
|
|
307
|
+
* @type {'raw' | 'processed'}
|
|
308
|
+
* @default 'raw'
|
|
309
|
+
* @author sansen
|
|
310
|
+
*/
|
|
311
|
+
renderMode: 'raw' | 'processed';
|
|
312
|
+
/**
|
|
313
|
+
* Indicates if video is currently being rendered
|
|
314
|
+
*
|
|
315
|
+
* @type {boolean}
|
|
316
|
+
* @default false
|
|
317
|
+
* @author sansen
|
|
318
|
+
*/
|
|
319
|
+
isRendering: boolean;
|
|
320
|
+
/**
|
|
321
|
+
* Resets all video state properties to default values
|
|
322
|
+
*
|
|
323
|
+
* @author sansen
|
|
324
|
+
*/
|
|
325
|
+
reset(): void;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* Audio State Management
|
|
330
|
+
* Pure data container without business logic
|
|
331
|
+
*
|
|
332
|
+
* @author sansen
|
|
333
|
+
* @class AudioState
|
|
334
|
+
*/
|
|
335
|
+
declare class AudioState {
|
|
336
|
+
/**
|
|
337
|
+
* Indicates if audio capture (input) is active
|
|
338
|
+
*
|
|
339
|
+
* @type {boolean}
|
|
340
|
+
* @default false
|
|
341
|
+
* @author sansen
|
|
342
|
+
*/
|
|
343
|
+
isCapturing: boolean;
|
|
344
|
+
/**
|
|
345
|
+
* Current audio sample rate in Hz
|
|
346
|
+
*
|
|
347
|
+
* @type {number}
|
|
348
|
+
* @default 48000
|
|
349
|
+
* @author sansen
|
|
350
|
+
*/
|
|
351
|
+
sampleRate: number;
|
|
352
|
+
/**
|
|
353
|
+
* Current number of audio channels (1=mono, 2=stereo)
|
|
354
|
+
*
|
|
355
|
+
* @type {number}
|
|
356
|
+
* @default 1
|
|
357
|
+
* @author sansen
|
|
358
|
+
*/
|
|
359
|
+
channels: number;
|
|
360
|
+
/**
|
|
361
|
+
* Indicates if Voice Activity Detection (VAD) is enabled
|
|
362
|
+
*
|
|
363
|
+
* @type {boolean}
|
|
364
|
+
* @default false
|
|
365
|
+
* @author sansen
|
|
366
|
+
*/
|
|
367
|
+
vadEnabled: boolean;
|
|
368
|
+
/**
|
|
369
|
+
* Indicates if 3A processing (Noise Suppression/Echo Cancellation/Automatic Gain Control) is enabled
|
|
370
|
+
*
|
|
371
|
+
* @type {boolean}
|
|
372
|
+
* @default false
|
|
373
|
+
* @author sansen
|
|
374
|
+
*/
|
|
375
|
+
threeAEnabled: boolean;
|
|
376
|
+
/**
|
|
377
|
+
* Indicates if audio playback (output) is active
|
|
378
|
+
*
|
|
379
|
+
* @type {boolean}
|
|
380
|
+
* @default false
|
|
381
|
+
* @author sansen
|
|
382
|
+
*/
|
|
383
|
+
isPlaying: boolean;
|
|
384
|
+
/**
|
|
385
|
+
* Current output audio track identifier
|
|
386
|
+
*
|
|
387
|
+
* @type {string|null}
|
|
388
|
+
* @default null
|
|
389
|
+
* @author sansen
|
|
390
|
+
*/
|
|
391
|
+
currentOutputTrackId: string | null;
|
|
392
|
+
/**
|
|
393
|
+
* Audio volume level (0.0 - 1.0)
|
|
394
|
+
*
|
|
395
|
+
* @type {number}
|
|
396
|
+
* @default 1.0
|
|
397
|
+
* @author sansen
|
|
398
|
+
*/
|
|
399
|
+
volume: number;
|
|
400
|
+
/**
|
|
401
|
+
* Indicates if audio is muted
|
|
402
|
+
*
|
|
403
|
+
* @type {boolean}
|
|
404
|
+
* @default false
|
|
405
|
+
* @author sansen
|
|
406
|
+
*/
|
|
407
|
+
isMuted: boolean;
|
|
408
|
+
/**
|
|
409
|
+
* Resets all audio state properties to default values
|
|
410
|
+
*
|
|
411
|
+
* @author sansen
|
|
412
|
+
*/
|
|
413
|
+
reset(): void;
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
/**
|
|
417
|
+
* Conversation State Enumeration
|
|
418
|
+
*
|
|
419
|
+
* @author sansen
|
|
420
|
+
* @enum {ConversationStateType}
|
|
421
|
+
*/
|
|
422
|
+
declare enum ConversationStateType {
|
|
423
|
+
/**
|
|
424
|
+
* No active conversation
|
|
425
|
+
*
|
|
426
|
+
* @author sansen
|
|
427
|
+
*/
|
|
428
|
+
IDLE = "idle",
|
|
429
|
+
/**
|
|
430
|
+
* Waiting for server response
|
|
431
|
+
*
|
|
432
|
+
* @author sansen
|
|
433
|
+
*/
|
|
434
|
+
WAITING = "waiting",
|
|
435
|
+
/**
|
|
436
|
+
* Receiving streaming answer chunks
|
|
437
|
+
*
|
|
438
|
+
* @author sansen
|
|
439
|
+
*/
|
|
440
|
+
STREAMING = "streaming",
|
|
441
|
+
/**
|
|
442
|
+
* Answer stream completed
|
|
443
|
+
*
|
|
444
|
+
* @author sansen
|
|
445
|
+
*/
|
|
446
|
+
COMPLETED = "completed",
|
|
447
|
+
/**
|
|
448
|
+
* Conversation error occurred
|
|
449
|
+
*
|
|
450
|
+
* @author sansen
|
|
451
|
+
*/
|
|
452
|
+
ERROR = "error"
|
|
453
|
+
}
|
|
454
|
+
/**
|
|
455
|
+
* Conversation State Management
|
|
456
|
+
* Pure data container without business logic
|
|
457
|
+
*
|
|
458
|
+
* @author sansen
|
|
459
|
+
* @class ConversationState
|
|
460
|
+
*/
|
|
461
|
+
declare class ConversationState {
|
|
462
|
+
/**
|
|
463
|
+
* Current conversation state
|
|
464
|
+
*
|
|
465
|
+
* @type {ConversationStateType}
|
|
466
|
+
* @default ConversationStateType.IDLE
|
|
467
|
+
* @author sansen
|
|
468
|
+
*/
|
|
469
|
+
state: ConversationStateType;
|
|
470
|
+
/**
|
|
471
|
+
* Current session identifier
|
|
472
|
+
*
|
|
473
|
+
* @type {string|null}
|
|
474
|
+
* @default null
|
|
475
|
+
* @author sansen
|
|
476
|
+
*/
|
|
477
|
+
currentSessionId: string | null;
|
|
478
|
+
/**
|
|
479
|
+
* Current question identifier
|
|
480
|
+
*
|
|
481
|
+
* @type {string|null}
|
|
482
|
+
* @default null
|
|
483
|
+
* @author sansen
|
|
484
|
+
*/
|
|
485
|
+
currentQuestionId: string | null;
|
|
486
|
+
/**
|
|
487
|
+
* Current accumulated answer text
|
|
488
|
+
*
|
|
489
|
+
* @type {string}
|
|
490
|
+
* @default ''
|
|
491
|
+
* @author sansen
|
|
492
|
+
*/
|
|
493
|
+
currentAnswer: string;
|
|
494
|
+
/**
|
|
495
|
+
* Indicates if waiting for answer from server
|
|
496
|
+
*
|
|
497
|
+
* @type {boolean}
|
|
498
|
+
* @default false
|
|
499
|
+
* @author sansen
|
|
500
|
+
*/
|
|
501
|
+
isWaiting: boolean;
|
|
502
|
+
/**
|
|
503
|
+
* Indicates if receiving streaming answer chunks
|
|
504
|
+
*
|
|
505
|
+
* @type {boolean}
|
|
506
|
+
* @default false
|
|
507
|
+
* @author sansen
|
|
508
|
+
*/
|
|
509
|
+
isStreaming: boolean;
|
|
510
|
+
/**
|
|
511
|
+
* Last error message from conversation
|
|
512
|
+
*
|
|
513
|
+
* @type {string|null}
|
|
514
|
+
* @default null
|
|
515
|
+
* @author sansen
|
|
516
|
+
*/
|
|
517
|
+
lastError: string | null;
|
|
518
|
+
/**
|
|
519
|
+
* Resets all conversation state properties to default values
|
|
520
|
+
*
|
|
521
|
+
* @author sansen
|
|
522
|
+
*/
|
|
523
|
+
reset(): void;
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
/**
|
|
527
|
+
* Session Status Enumeration
|
|
528
|
+
*
|
|
529
|
+
* @author sansen
|
|
530
|
+
* @enum {SessionStatus}
|
|
531
|
+
*/
|
|
532
|
+
declare enum SessionStatus {
|
|
533
|
+
/**
|
|
534
|
+
* Not connected to server
|
|
535
|
+
*
|
|
536
|
+
* @author sansen
|
|
537
|
+
*/
|
|
538
|
+
DISCONNECTED = "disconnected",
|
|
539
|
+
/**
|
|
540
|
+
* Currently establishing connection
|
|
541
|
+
*
|
|
542
|
+
* @author sansen
|
|
543
|
+
*/
|
|
544
|
+
CONNECTING = "connecting",
|
|
545
|
+
/**
|
|
546
|
+
* Successfully connected to server
|
|
547
|
+
*
|
|
548
|
+
* @author sansen
|
|
549
|
+
*/
|
|
550
|
+
CONNECTED = "connected",
|
|
551
|
+
/**
|
|
552
|
+
* Connection lost, attempting to reconnect
|
|
553
|
+
*
|
|
554
|
+
* @author sansen
|
|
555
|
+
*/
|
|
556
|
+
RECONNECTING = "reconnecting",
|
|
557
|
+
/**
|
|
558
|
+
* Connection error occurred
|
|
559
|
+
*
|
|
560
|
+
* @author sansen
|
|
561
|
+
*/
|
|
562
|
+
ERROR = "error"
|
|
563
|
+
}
|
|
564
|
+
/**
|
|
565
|
+
* Session State Management
|
|
566
|
+
* Pure data container without business logic
|
|
567
|
+
*
|
|
568
|
+
* @author sansen
|
|
569
|
+
* @class SessionState
|
|
570
|
+
*/
|
|
571
|
+
declare class SessionState {
|
|
572
|
+
/**
|
|
573
|
+
* Current session status
|
|
574
|
+
*
|
|
575
|
+
* @type {SessionStatus}
|
|
576
|
+
* @default SessionStatus.DISCONNECTED
|
|
577
|
+
* @author sansen
|
|
578
|
+
*/
|
|
579
|
+
status: SessionStatus;
|
|
580
|
+
/**
|
|
581
|
+
* Indicates if currently connected to server
|
|
582
|
+
*
|
|
583
|
+
* @type {boolean}
|
|
584
|
+
* @default false
|
|
585
|
+
* @author sansen
|
|
586
|
+
*/
|
|
587
|
+
isConnected: boolean;
|
|
588
|
+
/**
|
|
589
|
+
* Indicates if currently attempting to reconnect
|
|
590
|
+
*
|
|
591
|
+
* @type {boolean}
|
|
592
|
+
* @default false
|
|
593
|
+
* @author sansen
|
|
594
|
+
*/
|
|
595
|
+
isReconnecting: boolean;
|
|
596
|
+
/**
|
|
597
|
+
* Number of reconnection attempts made
|
|
598
|
+
*
|
|
599
|
+
* @type {number}
|
|
600
|
+
* @default 0
|
|
601
|
+
* @author sansen
|
|
602
|
+
*/
|
|
603
|
+
reconnectAttempts: number;
|
|
604
|
+
/**
|
|
605
|
+
* Last error message from session
|
|
606
|
+
*
|
|
607
|
+
* @type {string|null}
|
|
608
|
+
* @default null
|
|
609
|
+
* @author sansen
|
|
610
|
+
*/
|
|
611
|
+
lastError: string | null;
|
|
612
|
+
/**
|
|
613
|
+
* Timestamp when connection was established (null if disconnected)
|
|
614
|
+
*
|
|
615
|
+
* @type {number|null}
|
|
616
|
+
* @default null
|
|
617
|
+
* @author sansen
|
|
618
|
+
*/
|
|
619
|
+
connectedAt: number | null;
|
|
620
|
+
/**
|
|
621
|
+
* Resets all session state properties to default values
|
|
622
|
+
*
|
|
623
|
+
* @author sansen
|
|
624
|
+
*/
|
|
625
|
+
reset(): void;
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
/**
|
|
629
|
+
* Common Type Definitions
|
|
630
|
+
*
|
|
631
|
+
* @author sansen
|
|
632
|
+
*/
|
|
633
|
+
|
|
634
|
+
/**
|
|
635
|
+
* Generic callback function type
|
|
636
|
+
*
|
|
637
|
+
* @template T - Callback data type
|
|
638
|
+
* @author sansen
|
|
639
|
+
* @typedef {Callback}
|
|
640
|
+
*/
|
|
641
|
+
type Callback<T = void> = (data: T) => void;
|
|
642
|
+
|
|
643
|
+
/**
|
|
644
|
+
* Error callback function type
|
|
645
|
+
*
|
|
646
|
+
* @author sansen
|
|
647
|
+
* @typedef {ErrorCallback}
|
|
648
|
+
*/
|
|
649
|
+
type ErrorCallback = (error: Error) => void;
|
|
650
|
+
|
|
651
|
+
/**
|
|
652
|
+
* Asynchronous operation result wrapper
|
|
653
|
+
*
|
|
654
|
+
* @template T - Result data type
|
|
655
|
+
* @author sansen
|
|
656
|
+
* @interface AsyncResult
|
|
657
|
+
*/
|
|
658
|
+
interface AsyncResult<T> {
|
|
659
|
+
/**
|
|
660
|
+
* Indicates if the operation was successful
|
|
661
|
+
*
|
|
662
|
+
* @type {boolean}
|
|
663
|
+
*/
|
|
664
|
+
success: boolean;
|
|
665
|
+
/**
|
|
666
|
+
* Operation result data (if successful)
|
|
667
|
+
*
|
|
668
|
+
* @type {T|undefined}
|
|
669
|
+
*/
|
|
670
|
+
data?: T;
|
|
671
|
+
/**
|
|
672
|
+
* Error information (if operation failed)
|
|
673
|
+
*
|
|
674
|
+
* @type {Error|undefined}
|
|
675
|
+
*/
|
|
676
|
+
error?: Error;
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
/**
|
|
680
|
+
* Base configuration options interface
|
|
681
|
+
*
|
|
682
|
+
* @author sansen
|
|
683
|
+
* @interface BaseOptions
|
|
684
|
+
*/
|
|
685
|
+
interface BaseOptions {
|
|
686
|
+
/**
|
|
687
|
+
* Indicates if debug logging is enabled
|
|
688
|
+
*
|
|
689
|
+
* @type {boolean}
|
|
690
|
+
*/
|
|
691
|
+
debug?: boolean;
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
/**
|
|
695
|
+
* Video Configuration Options
|
|
696
|
+
*
|
|
697
|
+
* @author sansen
|
|
698
|
+
*/
|
|
699
|
+
|
|
700
|
+
/**
|
|
701
|
+
* Video rendering mode
|
|
702
|
+
*
|
|
703
|
+
* @author sansen
|
|
704
|
+
* @typedef {VideoRenderMode}
|
|
705
|
+
*/
|
|
706
|
+
type VideoRenderMode = 'raw' | 'processed';
|
|
707
|
+
|
|
708
|
+
/**
|
|
709
|
+
* Green Screen Processing Options
|
|
710
|
+
*
|
|
711
|
+
* @author sansen
|
|
712
|
+
* @interface GreenScreenOptions
|
|
713
|
+
*/
|
|
714
|
+
interface GreenScreenOptions {
|
|
715
|
+
/**
|
|
716
|
+
* Indicates if green screen processing is enabled
|
|
717
|
+
*
|
|
718
|
+
* @type {boolean}
|
|
719
|
+
*/
|
|
720
|
+
enabled: boolean;
|
|
721
|
+
|
|
722
|
+
/**
|
|
723
|
+
* Chroma key color (RGB), default [0, 255, 0] (pure green)
|
|
724
|
+
*
|
|
725
|
+
* @type {[number, number, number]}
|
|
726
|
+
* @default [0, 255, 0]
|
|
727
|
+
*/
|
|
728
|
+
chromaKey?: [number, number, number];
|
|
729
|
+
|
|
730
|
+
/**
|
|
731
|
+
* Similarity threshold (0-1), default 0.4
|
|
732
|
+
* Lower values make matching stricter
|
|
733
|
+
*
|
|
734
|
+
* @type {number}
|
|
735
|
+
* @default 0.4
|
|
736
|
+
*/
|
|
737
|
+
similarity?: number;
|
|
738
|
+
|
|
739
|
+
/**
|
|
740
|
+
* Smoothness (0-1), default 0.1
|
|
741
|
+
* Controls smoothness of alpha transition
|
|
742
|
+
*
|
|
743
|
+
* @type {number}
|
|
744
|
+
* @default 0.1
|
|
745
|
+
*/
|
|
746
|
+
smoothness?: number;
|
|
747
|
+
|
|
748
|
+
/**
|
|
749
|
+
* Despill strength (0-1), default 0.5
|
|
750
|
+
* Controls intensity of green spill removal
|
|
751
|
+
*
|
|
752
|
+
* @type {number}
|
|
753
|
+
* @default 0.5
|
|
754
|
+
*/
|
|
755
|
+
despillStrength?: number;
|
|
756
|
+
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
/**
|
|
760
|
+
* Video Configuration Options Interface
|
|
761
|
+
*
|
|
762
|
+
* @author sansen
|
|
763
|
+
* @interface VideoOptions
|
|
764
|
+
* @extends {BaseOptions}
|
|
765
|
+
*/
|
|
766
|
+
interface VideoOptions extends BaseOptions {
|
|
767
|
+
/**
|
|
768
|
+
* Video rendering mode
|
|
769
|
+
*
|
|
770
|
+
* @type {VideoRenderMode}
|
|
771
|
+
* @default 'raw'
|
|
772
|
+
*/
|
|
773
|
+
renderMode?: VideoRenderMode;
|
|
774
|
+
|
|
775
|
+
/**
|
|
776
|
+
* Green screen processing options
|
|
777
|
+
*
|
|
778
|
+
* @type {GreenScreenOptions}
|
|
779
|
+
*/
|
|
780
|
+
greenScreen?: GreenScreenOptions;
|
|
781
|
+
|
|
782
|
+
/**
|
|
783
|
+
* Video element for playing video
|
|
784
|
+
*
|
|
785
|
+
* @type {HTMLVideoElement}
|
|
786
|
+
*/
|
|
787
|
+
element?: HTMLVideoElement;
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
/**
|
|
791
|
+
* Audio Input Configuration Options
|
|
792
|
+
*
|
|
793
|
+
* @author sansen
|
|
794
|
+
* @interface AudioInputOptions
|
|
795
|
+
*/
|
|
796
|
+
interface AudioInputOptions {
|
|
797
|
+
/**
|
|
798
|
+
* Indicates if audio input is enabled
|
|
799
|
+
*
|
|
800
|
+
* @type {boolean}
|
|
801
|
+
*/
|
|
802
|
+
enabled?: boolean;
|
|
803
|
+
|
|
804
|
+
/**
|
|
805
|
+
* Audio sample rate in Hz (default 24000)
|
|
806
|
+
*
|
|
807
|
+
* @type {number}
|
|
808
|
+
*/
|
|
809
|
+
sampleRate?: number;
|
|
810
|
+
|
|
811
|
+
/**
|
|
812
|
+
* Audio bit depth in bits (default 16)
|
|
813
|
+
*
|
|
814
|
+
* @type {number}
|
|
815
|
+
*/
|
|
816
|
+
bitDepth?: number;
|
|
817
|
+
|
|
818
|
+
/**
|
|
819
|
+
* Number of audio channels, default 1 (mono)
|
|
820
|
+
*
|
|
821
|
+
* @type {number}
|
|
822
|
+
*/
|
|
823
|
+
channels?: number;
|
|
824
|
+
|
|
825
|
+
/**
|
|
826
|
+
* Media track constraints for audio input
|
|
827
|
+
*
|
|
828
|
+
* @type {MediaTrackConstraints}
|
|
829
|
+
*/
|
|
830
|
+
constraints?: MediaTrackConstraints;
|
|
831
|
+
}
|
|
832
|
+
|
|
833
|
+
/**
|
|
834
|
+
* Audio Output Configuration Options
|
|
835
|
+
*
|
|
836
|
+
* @author sansen
|
|
837
|
+
* @interface AudioOutputOptions
|
|
838
|
+
*/
|
|
839
|
+
interface AudioOutputOptions {
|
|
840
|
+
/**
|
|
841
|
+
* Indicates if audio output is enabled
|
|
842
|
+
*
|
|
843
|
+
* @type {boolean}
|
|
844
|
+
*/
|
|
845
|
+
enabled?: boolean;
|
|
846
|
+
|
|
847
|
+
/**
|
|
848
|
+
* Default volume level (0.0 - 1.0)
|
|
849
|
+
*
|
|
850
|
+
* @type {number}
|
|
851
|
+
*/
|
|
852
|
+
volume?: number;
|
|
853
|
+
|
|
854
|
+
/**
|
|
855
|
+
* Indicates if audio output is muted by default
|
|
856
|
+
*
|
|
857
|
+
* @type {boolean}
|
|
858
|
+
*/
|
|
859
|
+
muted?: boolean;
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
/**
|
|
863
|
+
* Audio Configuration Options (backward compatible, also supports separated configuration)
|
|
864
|
+
*
|
|
865
|
+
* @author sansen
|
|
866
|
+
* @interface AudioOptions
|
|
867
|
+
* @extends {BaseOptions}
|
|
868
|
+
*/
|
|
869
|
+
interface AudioOptions extends BaseOptions {
|
|
870
|
+
/**
|
|
871
|
+
* Audio input configuration (new configuration format)
|
|
872
|
+
*
|
|
873
|
+
* @type {AudioInputOptions}
|
|
874
|
+
*/
|
|
875
|
+
input?: AudioInputOptions;
|
|
876
|
+
|
|
877
|
+
/**
|
|
878
|
+
* Audio output configuration (new configuration format)
|
|
879
|
+
*
|
|
880
|
+
* @type {AudioOutputOptions}
|
|
881
|
+
*/
|
|
882
|
+
output?: AudioOutputOptions;
|
|
883
|
+
}
|
|
884
|
+
|
|
885
|
+
/**
|
|
886
|
+
* Conversation Configuration Options
|
|
887
|
+
*
|
|
888
|
+
* @author sansen
|
|
889
|
+
*/
|
|
890
|
+
|
|
891
|
+
/**
|
|
892
|
+
* Input mode for conversation
|
|
893
|
+
*
|
|
894
|
+
* @author sansen
|
|
895
|
+
* @typedef {InputMode}
|
|
896
|
+
*/
|
|
897
|
+
type InputMode = 'text' | 'voice' | 'both';
|
|
898
|
+
|
|
899
|
+
/**
|
|
900
|
+
* Conversation Configuration Options Interface
|
|
901
|
+
*
|
|
902
|
+
* @author sansen
|
|
903
|
+
* @interface ConversationOptions
|
|
904
|
+
* @extends {BaseOptions}
|
|
905
|
+
*/
|
|
906
|
+
interface ConversationOptions extends BaseOptions {
|
|
907
|
+
/**
|
|
908
|
+
* Input mode for conversation interaction
|
|
909
|
+
*
|
|
910
|
+
* @type {InputMode}
|
|
911
|
+
* @default 'both'
|
|
912
|
+
*/
|
|
913
|
+
// inputMode?: InputMode;
|
|
914
|
+
|
|
915
|
+
/**
|
|
916
|
+
* Indicates if automatic sending is enabled (for voice input)
|
|
917
|
+
*
|
|
918
|
+
* @type {boolean}
|
|
919
|
+
* @default false
|
|
920
|
+
*/
|
|
921
|
+
// autoSend?: boolean;
|
|
922
|
+
|
|
923
|
+
/**
|
|
924
|
+
* Voice input timeout in milliseconds
|
|
925
|
+
*
|
|
926
|
+
* @type {number}
|
|
927
|
+
*/
|
|
928
|
+
// voiceTimeout?: number;
|
|
929
|
+
}
|
|
930
|
+
|
|
931
|
+
/**
|
|
932
|
+
* Client Configuration Options
|
|
933
|
+
*
|
|
934
|
+
* @author sansen
|
|
935
|
+
* @interface ClientOptions
|
|
936
|
+
* @extends {BaseOptions}
|
|
937
|
+
*/
|
|
938
|
+
interface ClientOptions extends BaseOptions {
|
|
939
|
+
/**
|
|
940
|
+
* WebSocket server URL prefix (for upstream communication)
|
|
941
|
+
*
|
|
942
|
+
* @type {string}
|
|
943
|
+
* @default ''
|
|
944
|
+
* @author sansen
|
|
945
|
+
*/
|
|
946
|
+
wsUrlPrefix?: string;
|
|
947
|
+
|
|
948
|
+
/**
|
|
949
|
+
* Avatar name identifier
|
|
950
|
+
*
|
|
951
|
+
* @type {string}
|
|
952
|
+
* @default ''
|
|
953
|
+
* @author sansen
|
|
954
|
+
*/
|
|
955
|
+
avatarName: string;
|
|
956
|
+
|
|
957
|
+
/**
|
|
958
|
+
* Audio configuration options
|
|
959
|
+
*
|
|
960
|
+
* @type {AudioOptions}
|
|
961
|
+
* @default undefined
|
|
962
|
+
* @author sansen
|
|
963
|
+
*/
|
|
964
|
+
audio?: AudioOptions;
|
|
965
|
+
|
|
966
|
+
/**
|
|
967
|
+
* Video configuration options
|
|
968
|
+
*
|
|
969
|
+
* @type {VideoOptions}
|
|
970
|
+
* @default undefined
|
|
971
|
+
* @author sansen
|
|
972
|
+
*/
|
|
973
|
+
video?: VideoOptions;
|
|
974
|
+
|
|
975
|
+
/**
|
|
976
|
+
* Reconnection configuration
|
|
977
|
+
*
|
|
978
|
+
* @type {Object}
|
|
979
|
+
*/
|
|
980
|
+
reconnect?: {
|
|
981
|
+
/**
|
|
982
|
+
* Maximum reconnection attempts
|
|
983
|
+
*
|
|
984
|
+
* @type {number}
|
|
985
|
+
*/
|
|
986
|
+
maxAttempts?: number;
|
|
987
|
+
/**
|
|
988
|
+
* Reconnection delay in milliseconds
|
|
989
|
+
*
|
|
990
|
+
* @type {number}
|
|
991
|
+
*/
|
|
992
|
+
delay?: number;
|
|
993
|
+
};
|
|
994
|
+
|
|
995
|
+
/**
|
|
996
|
+
* HTTP service configuration
|
|
997
|
+
*
|
|
998
|
+
* @type {Object}
|
|
999
|
+
*/
|
|
1000
|
+
http?: {
|
|
1001
|
+
/**
|
|
1002
|
+
* Base URL for HTTP requests
|
|
1003
|
+
*
|
|
1004
|
+
* @type {string}
|
|
1005
|
+
*/
|
|
1006
|
+
baseURL?: string;
|
|
1007
|
+
/**
|
|
1008
|
+
* Default HTTP request headers
|
|
1009
|
+
*
|
|
1010
|
+
* @type {Record<string, string>}
|
|
1011
|
+
*/
|
|
1012
|
+
headers?: Record<string, string>;
|
|
1013
|
+
};
|
|
1014
|
+
}
|
|
1015
|
+
|
|
1016
|
+
/**
|
|
1017
|
+
* SDK Custom Error Class
|
|
1018
|
+
* All SDK internal errors should be converted to SDKError instances
|
|
1019
|
+
*
|
|
1020
|
+
* @author sansen
|
|
1021
|
+
* @class SDKError
|
|
1022
|
+
* @extends {Error}
|
|
1023
|
+
*/
|
|
1024
|
+
declare class SDKError extends Error {
|
|
1025
|
+
/**
|
|
1026
|
+
* Error code for categorizing and identifying error types
|
|
1027
|
+
*
|
|
1028
|
+
* @type {string}
|
|
1029
|
+
* @author sansen
|
|
1030
|
+
*/
|
|
1031
|
+
readonly code: string;
|
|
1032
|
+
/**
|
|
1033
|
+
* Original error that caused this SDKError (if any)
|
|
1034
|
+
*
|
|
1035
|
+
* @type {unknown}
|
|
1036
|
+
* @author sansen
|
|
1037
|
+
*/
|
|
1038
|
+
readonly cause?: unknown;
|
|
1039
|
+
/**
|
|
1040
|
+
* Creates an SDKError instance
|
|
1041
|
+
*
|
|
1042
|
+
* @param {string} message - Error description message
|
|
1043
|
+
* @param {string} [code='SDK_ERROR'] - Error code for categorization
|
|
1044
|
+
* @param {unknown} [cause] - Original error that caused this SDKError
|
|
1045
|
+
* @author sansen
|
|
1046
|
+
*/
|
|
1047
|
+
constructor(message: string, code?: string, cause?: unknown);
|
|
1048
|
+
/**
|
|
1049
|
+
* Creates an SDKError from any error type
|
|
1050
|
+
*
|
|
1051
|
+
* @param {unknown} error - Original error to convert
|
|
1052
|
+
* @param {string} [code] - Optional error code, defaults to 'SDK_ERROR'
|
|
1053
|
+
* @returns {SDKError} SDKError instance
|
|
1054
|
+
* @author sansen
|
|
1055
|
+
*/
|
|
1056
|
+
static fromError(error: unknown, code?: string): SDKError;
|
|
1057
|
+
}
|
|
1058
|
+
|
|
1059
|
+
/**
|
|
1060
|
+
* SDK Context
|
|
1061
|
+
* Contains all shared states and event bus
|
|
1062
|
+
*
|
|
1063
|
+
* @author sansen
|
|
1064
|
+
* @class SDKContext
|
|
1065
|
+
*/
|
|
1066
|
+
declare class SDKContext {
|
|
1067
|
+
/**
|
|
1068
|
+
* Event bus for SDK-wide communication
|
|
1069
|
+
*
|
|
1070
|
+
* @type {EventBus}
|
|
1071
|
+
* @memberof SDKContext
|
|
1072
|
+
*/
|
|
1073
|
+
readonly eventBus: EventBus;
|
|
1074
|
+
/**
|
|
1075
|
+
* Video state management
|
|
1076
|
+
*
|
|
1077
|
+
* @type {VideoState}
|
|
1078
|
+
* @memberof SDKContext
|
|
1079
|
+
*/
|
|
1080
|
+
readonly videoState: VideoState;
|
|
1081
|
+
/**
|
|
1082
|
+
* Audio state management
|
|
1083
|
+
*
|
|
1084
|
+
* @type {AudioState}
|
|
1085
|
+
* @memberof SDKContext
|
|
1086
|
+
*/
|
|
1087
|
+
readonly audioState: AudioState;
|
|
1088
|
+
/**
|
|
1089
|
+
* Conversation state management
|
|
1090
|
+
*
|
|
1091
|
+
* @type {ConversationState}
|
|
1092
|
+
* @memberof SDKContext
|
|
1093
|
+
*/
|
|
1094
|
+
readonly conversationState: ConversationState;
|
|
1095
|
+
/**
|
|
1096
|
+
* Session state management
|
|
1097
|
+
*
|
|
1098
|
+
* @type {SessionState}
|
|
1099
|
+
* @memberof SDKContext
|
|
1100
|
+
*/
|
|
1101
|
+
readonly sessionState: SessionState;
|
|
1102
|
+
/**
|
|
1103
|
+
* Client configuration options
|
|
1104
|
+
*
|
|
1105
|
+
* @type {ClientOptions}
|
|
1106
|
+
* @memberof SDKContext
|
|
1107
|
+
*/
|
|
1108
|
+
readonly options: ClientOptions;
|
|
1109
|
+
private _livekitUrl;
|
|
1110
|
+
private _token;
|
|
1111
|
+
private _roomId;
|
|
1112
|
+
private _wsUrl;
|
|
1113
|
+
/**
|
|
1114
|
+
* Creates an SDK context instance
|
|
1115
|
+
*
|
|
1116
|
+
* @param {ClientOptions} options - Client configuration options
|
|
1117
|
+
* @author sansen
|
|
1118
|
+
*/
|
|
1119
|
+
constructor(options: ClientOptions);
|
|
1120
|
+
/**
|
|
1121
|
+
* Sets LiveKit configuration parameters
|
|
1122
|
+
*
|
|
1123
|
+
* @param {string} livekitUrl - LiveKit server URL
|
|
1124
|
+
* @param {string} token - Authentication token
|
|
1125
|
+
* @param {string} roomId - Room identifier
|
|
1126
|
+
* @author sansen
|
|
1127
|
+
*/
|
|
1128
|
+
setLivekitConfig(livekitUrl: string, token: string, roomId: string): void;
|
|
1129
|
+
/**
|
|
1130
|
+
* Emits an error event and creates SDKError instance
|
|
1131
|
+
*
|
|
1132
|
+
* @param {unknown} error - Original error
|
|
1133
|
+
* @param {string} code - Error code
|
|
1134
|
+
* @returns {SDKError} Created SDKError instance
|
|
1135
|
+
* @author sansen
|
|
1136
|
+
*/
|
|
1137
|
+
emitError(error: unknown, code: string): SDKError;
|
|
1138
|
+
/**
|
|
1139
|
+
* Sets WebSocket URL
|
|
1140
|
+
*
|
|
1141
|
+
* @param {string} wsUrl - WebSocket server URL
|
|
1142
|
+
* @author sansen
|
|
1143
|
+
*/
|
|
1144
|
+
setWsUrl(wsUrl: string): void;
|
|
1145
|
+
/**
|
|
1146
|
+
* Gets WebSocket URL
|
|
1147
|
+
*
|
|
1148
|
+
* @type {string}
|
|
1149
|
+
* @author sansen
|
|
1150
|
+
*/
|
|
1151
|
+
get wsUrl(): string;
|
|
1152
|
+
/**
|
|
1153
|
+
* Gets LiveKit server URL
|
|
1154
|
+
*
|
|
1155
|
+
* @type {string}
|
|
1156
|
+
* @author sansen
|
|
1157
|
+
*/
|
|
1158
|
+
get livekitUrl(): string;
|
|
1159
|
+
/**
|
|
1160
|
+
* Gets authentication token
|
|
1161
|
+
*
|
|
1162
|
+
* @type {string}
|
|
1163
|
+
* @author sansen
|
|
1164
|
+
*/
|
|
1165
|
+
get token(): string;
|
|
1166
|
+
/**
|
|
1167
|
+
* Gets room identifier
|
|
1168
|
+
*
|
|
1169
|
+
* @type {string|undefined}
|
|
1170
|
+
* @author sansen
|
|
1171
|
+
*/
|
|
1172
|
+
get roomId(): string | undefined;
|
|
1173
|
+
/**
|
|
1174
|
+
* Gets LiveKit configuration
|
|
1175
|
+
*
|
|
1176
|
+
* @returns {Object} LiveKit configuration object
|
|
1177
|
+
* @author sansen
|
|
1178
|
+
*/
|
|
1179
|
+
getLivekitConfig(): {
|
|
1180
|
+
livekitUrl: string;
|
|
1181
|
+
token: string;
|
|
1182
|
+
};
|
|
1183
|
+
/**
|
|
1184
|
+
* Disposes all resources and cleans up states
|
|
1185
|
+
*
|
|
1186
|
+
* @author sansen
|
|
1187
|
+
*/
|
|
1188
|
+
dispose(): void;
|
|
1189
|
+
}
|
|
1190
|
+
|
|
1191
|
+
interface PublicEmitterAPI {
|
|
1192
|
+
on<K extends keyof PublicSDKEvents>(event: K, listener: (data: PublicSDKEvents[K]) => void): () => void;
|
|
1193
|
+
off<K extends keyof PublicSDKEvents>(event: K, listener: (data: PublicSDKEvents[K]) => void): void;
|
|
1194
|
+
once<K extends keyof PublicSDKEvents>(event: K, listener: (data: PublicSDKEvents[K]) => void): () => void;
|
|
1195
|
+
}
|
|
1196
|
+
|
|
1197
|
+
/**
|
|
1198
|
+
* SDK client
|
|
1199
|
+
* Provides a unified API surface.
|
|
1200
|
+
* Orchestrates the lifecycles of all subsystems.
|
|
1201
|
+
* @author sansen
|
|
1202
|
+
*/
|
|
1203
|
+
declare class SDKClient extends Disposable {
|
|
1204
|
+
/**
|
|
1205
|
+
* SDK context
|
|
1206
|
+
* @author sansen
|
|
1207
|
+
*/
|
|
1208
|
+
protected readonly _context: SDKContext;
|
|
1209
|
+
private _publicEventAPI?;
|
|
1210
|
+
private _publicEmitter?;
|
|
1211
|
+
/**
|
|
1212
|
+
* Video controller
|
|
1213
|
+
* @author sansen
|
|
1214
|
+
*/
|
|
1215
|
+
private _videoController;
|
|
1216
|
+
/**
|
|
1217
|
+
* Audio controller
|
|
1218
|
+
* @author sansen
|
|
1219
|
+
*/
|
|
1220
|
+
private _audioController;
|
|
1221
|
+
/**
|
|
1222
|
+
* Conversation controller
|
|
1223
|
+
* @author sansen
|
|
1224
|
+
*/
|
|
1225
|
+
private _conversationController;
|
|
1226
|
+
/**
|
|
1227
|
+
* LiveKit service
|
|
1228
|
+
* @author sansen
|
|
1229
|
+
*/
|
|
1230
|
+
private _liveKitService;
|
|
1231
|
+
/**
|
|
1232
|
+
* Conversation transport service
|
|
1233
|
+
* @author sansen
|
|
1234
|
+
*/
|
|
1235
|
+
private _conversationTransport;
|
|
1236
|
+
/**
|
|
1237
|
+
* Whether the SDK has been Connected
|
|
1238
|
+
* @author sansen
|
|
1239
|
+
*/
|
|
1240
|
+
private _isConnected;
|
|
1241
|
+
/**
|
|
1242
|
+
* HTTP controller
|
|
1243
|
+
* @author sansen
|
|
1244
|
+
*/
|
|
1245
|
+
private _httpController;
|
|
1246
|
+
private _preConnectPromise;
|
|
1247
|
+
/**
|
|
1248
|
+
* Create SDK client
|
|
1249
|
+
* @param options Client configuration options
|
|
1250
|
+
* @author sansen
|
|
1251
|
+
*/
|
|
1252
|
+
constructor(options: ClientOptions);
|
|
1253
|
+
/**
|
|
1254
|
+
* Get public event bus API
|
|
1255
|
+
* @author sansen
|
|
1256
|
+
*/
|
|
1257
|
+
get events(): PublicEmitterAPI;
|
|
1258
|
+
/**
|
|
1259
|
+
* Push actions to the server
|
|
1260
|
+
* @param onceActions One-time actions
|
|
1261
|
+
* @param loopActions Repeating/loop actions
|
|
1262
|
+
* @returns Promise<string> resolves to 'success' on success, or rejects with an error
|
|
1263
|
+
* @author sansen
|
|
1264
|
+
*/
|
|
1265
|
+
pushActions({ onceActions, loopActions }: {
|
|
1266
|
+
onceActions?: string[];
|
|
1267
|
+
loopActions?: string[];
|
|
1268
|
+
}): Promise<string> | undefined;
|
|
1269
|
+
/**
|
|
1270
|
+
* Interrupt the current conversation connection
|
|
1271
|
+
* @returns Promise<string> resolves to 'success' on success, or rejects with an error
|
|
1272
|
+
* @author sansen
|
|
1273
|
+
*/
|
|
1274
|
+
interruptConnection(): Promise<string> | undefined;
|
|
1275
|
+
/**
|
|
1276
|
+
* Send a text question/message
|
|
1277
|
+
* @param text The question text to send
|
|
1278
|
+
* @returns Promise<string> resolves with the message UID
|
|
1279
|
+
* @author sansen
|
|
1280
|
+
*/
|
|
1281
|
+
sendTextQuestion(text: string): Promise<string>;
|
|
1282
|
+
/**
|
|
1283
|
+
* Start audio capture
|
|
1284
|
+
* Begins microphone capture and starts sending audio frames over WebSocket
|
|
1285
|
+
* @returns Promise<void>
|
|
1286
|
+
* @throws SDKError if the SDK is not initialized or capture fails to start
|
|
1287
|
+
* @author sansen
|
|
1288
|
+
*/
|
|
1289
|
+
startAudioCapture(): Promise<void>;
|
|
1290
|
+
/**
|
|
1291
|
+
* Stop audio capture
|
|
1292
|
+
* Stops microphone capture and stops sending audio frames over WebSocket
|
|
1293
|
+
* @throws SDKError if the SDK is not initialized
|
|
1294
|
+
* @author sansen
|
|
1295
|
+
*/
|
|
1296
|
+
stopAudioCapture(): Promise<void>;
|
|
1297
|
+
/**
|
|
1298
|
+
* Sets the audio volume level
|
|
1299
|
+
* @param volume Volume value (0.0 - 1.0)
|
|
1300
|
+
* @author sansen
|
|
1301
|
+
*/
|
|
1302
|
+
setVolume(volume: number): void;
|
|
1303
|
+
/**
|
|
1304
|
+
* Get audio volume
|
|
1305
|
+
* Gets the current audio volume level
|
|
1306
|
+
* @returns Volume value (0.0 - 1.0)
|
|
1307
|
+
* @author sansen
|
|
1308
|
+
*/
|
|
1309
|
+
getVolume(): number;
|
|
1310
|
+
/**
|
|
1311
|
+
* Mute audio
|
|
1312
|
+
* Mutes the audio output
|
|
1313
|
+
* @author sansen
|
|
1314
|
+
*/
|
|
1315
|
+
mute(): void;
|
|
1316
|
+
/**
|
|
1317
|
+
* Check if audio is currently being captured
|
|
1318
|
+
* @returns boolean true if capturing, false otherwise
|
|
1319
|
+
* @throws SDKError if the SDK is not initialized
|
|
1320
|
+
* @author sansen
|
|
1321
|
+
*/
|
|
1322
|
+
get isAudioCapturing(): boolean;
|
|
1323
|
+
/**
|
|
1324
|
+
* Pre-connect to remote services
|
|
1325
|
+
* Performs pre-connection steps: fetches auth token and LiveKit configuration
|
|
1326
|
+
* @returns Promise<boolean> resolves to true on success
|
|
1327
|
+
* @author sansen
|
|
1328
|
+
*/
|
|
1329
|
+
preConnect(): Promise<boolean>;
|
|
1330
|
+
/**
|
|
1331
|
+
* Connect to the server
|
|
1332
|
+
* Initializes controllers and establishes required connections
|
|
1333
|
+
* @returns Promise<void>
|
|
1334
|
+
* @author sansen
|
|
1335
|
+
*/
|
|
1336
|
+
connect(): Promise<void>;
|
|
1337
|
+
/**
|
|
1338
|
+
* Disconnect
|
|
1339
|
+
* Tears down active connections but retains controller instances to allow reconnect
|
|
1340
|
+
* @author sansen
|
|
1341
|
+
*/
|
|
1342
|
+
disconnect(): Promise<void>;
|
|
1343
|
+
/**
|
|
1344
|
+
* Reconnect
|
|
1345
|
+
* Disconnects and then reconnects the SDK
|
|
1346
|
+
* @throws SDKError if the SDK is not initialized
|
|
1347
|
+
* @returns Promise<void>
|
|
1348
|
+
* @author sansen
|
|
1349
|
+
*/
|
|
1350
|
+
reconnect(): Promise<void>;
|
|
1351
|
+
/**
|
|
1352
|
+
* Cleanup all resources (internal)
|
|
1353
|
+
* @author sansen
|
|
1354
|
+
*/
|
|
1355
|
+
private _cleanup;
|
|
1356
|
+
/**
|
|
1357
|
+
* Check whether the SDK is connected
|
|
1358
|
+
* @author sansen
|
|
1359
|
+
*/
|
|
1360
|
+
get isConnected(): boolean;
|
|
1361
|
+
/**
|
|
1362
|
+
* Ensure the SDK has been initialized
|
|
1363
|
+
* @throws SDKError if the SDK is not initialized
|
|
1364
|
+
* @author sansen
|
|
1365
|
+
*/
|
|
1366
|
+
private _ensureInitialized;
|
|
1367
|
+
/**
|
|
1368
|
+
* Release resources
|
|
1369
|
+
* @author sansen
|
|
1370
|
+
*/
|
|
1371
|
+
protected onDispose(): void;
|
|
1372
|
+
}
|
|
1373
|
+
|
|
1374
|
+
/**
|
|
1375
|
+
* Create an SDK client instance
|
|
1376
|
+
* @param options Client configuration options
|
|
1377
|
+
* @returns SDK client instance
|
|
1378
|
+
* @throws SDKError if the configuration is invalid
|
|
1379
|
+
* @author sansen
|
|
1380
|
+
*/
|
|
1381
|
+
declare function createClient(options: ClientOptions): SDKClient;
|
|
1382
|
+
|
|
1383
|
+
/**
|
|
1384
|
+
* Log Level Enumeration
|
|
1385
|
+
*
|
|
1386
|
+
* @author sansen
|
|
1387
|
+
* @enum {LogLevel}
|
|
1388
|
+
*/
|
|
1389
|
+
declare enum LogLevel {
|
|
1390
|
+
/**
|
|
1391
|
+
* Debug level for detailed diagnostic information
|
|
1392
|
+
*
|
|
1393
|
+
* @author sansen
|
|
1394
|
+
*/
|
|
1395
|
+
DEBUG = 0,
|
|
1396
|
+
/**
|
|
1397
|
+
* Information level for general operational events
|
|
1398
|
+
*
|
|
1399
|
+
* @author sansen
|
|
1400
|
+
*/
|
|
1401
|
+
INFO = 1,
|
|
1402
|
+
/**
|
|
1403
|
+
* Warning level for potentially harmful situations
|
|
1404
|
+
*
|
|
1405
|
+
* @author sansen
|
|
1406
|
+
*/
|
|
1407
|
+
WARN = 2,
|
|
1408
|
+
/**
|
|
1409
|
+
* Error level for error events that might still allow the application to continue
|
|
1410
|
+
*
|
|
1411
|
+
* @author sansen
|
|
1412
|
+
*/
|
|
1413
|
+
ERROR = 3,
|
|
1414
|
+
/**
|
|
1415
|
+
* No logging (disabled)
|
|
1416
|
+
*
|
|
1417
|
+
* @author sansen
|
|
1418
|
+
*/
|
|
1419
|
+
NONE = 4
|
|
1420
|
+
}
|
|
1421
|
+
/**
|
|
1422
|
+
* Logger Utility
|
|
1423
|
+
* Provides configurable logging with different severity levels
|
|
1424
|
+
*
|
|
1425
|
+
* @author sansen
|
|
1426
|
+
* @class Logger
|
|
1427
|
+
*/
|
|
1428
|
+
declare class Logger {
|
|
1429
|
+
private static _level;
|
|
1430
|
+
private static _prefix;
|
|
1431
|
+
/**
|
|
1432
|
+
* Sets the current log level
|
|
1433
|
+
*
|
|
1434
|
+
* @param {LogLevel} level - Log level to set
|
|
1435
|
+
* @author sansen
|
|
1436
|
+
*/
|
|
1437
|
+
static setLevel(level: LogLevel): void;
|
|
1438
|
+
/**
|
|
1439
|
+
* Sets the log prefix
|
|
1440
|
+
*
|
|
1441
|
+
* @param {string} prefix - Prefix to prepend to all log messages
|
|
1442
|
+
* @author sansen
|
|
1443
|
+
*/
|
|
1444
|
+
static setPrefix(prefix: string): void;
|
|
1445
|
+
/**
|
|
1446
|
+
* Logs debug-level messages for detailed diagnostic information
|
|
1447
|
+
*
|
|
1448
|
+
* @param {string} message - Log message
|
|
1449
|
+
* @param {...unknown[]} args - Additional arguments to log
|
|
1450
|
+
* @author sansen
|
|
1451
|
+
*/
|
|
1452
|
+
static debug(message: string, ...args: unknown[]): void;
|
|
1453
|
+
/**
|
|
1454
|
+
* Logs info-level messages for general operational events
|
|
1455
|
+
*
|
|
1456
|
+
* @param {string} message - Log message
|
|
1457
|
+
* @param {...unknown[]} args - Additional arguments to log
|
|
1458
|
+
* @author sansen
|
|
1459
|
+
*/
|
|
1460
|
+
static info(message: string, ...args: unknown[]): void;
|
|
1461
|
+
/**
|
|
1462
|
+
* Logs warning-level messages for potentially harmful situations
|
|
1463
|
+
*
|
|
1464
|
+
* @param {string} message - Log message
|
|
1465
|
+
* @param {...unknown[]} args - Additional arguments to log
|
|
1466
|
+
* @author sansen
|
|
1467
|
+
*/
|
|
1468
|
+
static warn(message: string, ...args: unknown[]): void;
|
|
1469
|
+
/**
|
|
1470
|
+
* Logs error-level messages for error events
|
|
1471
|
+
*
|
|
1472
|
+
* @param {string} message - Log message
|
|
1473
|
+
* @param {...unknown[]} args - Additional arguments to log
|
|
1474
|
+
* @author sansen
|
|
1475
|
+
*/
|
|
1476
|
+
static error(message: string, ...args: unknown[]): void;
|
|
1477
|
+
}
|
|
1478
|
+
|
|
1479
|
+
/**
|
|
1480
|
+
* SDK Default Configuration Constants
|
|
1481
|
+
*
|
|
1482
|
+
* @author sansen
|
|
1483
|
+
*/
|
|
1484
|
+
/**
|
|
1485
|
+
* Default reconnection attempt count
|
|
1486
|
+
*
|
|
1487
|
+
* @constant {number}
|
|
1488
|
+
* @default
|
|
1489
|
+
*/
|
|
1490
|
+
declare const DEFAULT_RECONNECT_ATTEMPTS = 3;
|
|
1491
|
+
/**
|
|
1492
|
+
* Default reconnection delay in milliseconds
|
|
1493
|
+
*
|
|
1494
|
+
* @constant {number}
|
|
1495
|
+
* @default
|
|
1496
|
+
*/
|
|
1497
|
+
declare const DEFAULT_RECONNECT_DELAY = 1000;
|
|
1498
|
+
/**
|
|
1499
|
+
* Default WebSocket connection timeout in milliseconds
|
|
1500
|
+
*
|
|
1501
|
+
* @constant {number}
|
|
1502
|
+
* @default
|
|
1503
|
+
*/
|
|
1504
|
+
declare const DEFAULT_WS_TIMEOUT = 10000;
|
|
1505
|
+
/**
|
|
1506
|
+
* Default audio sample rate (input)
|
|
1507
|
+
*
|
|
1508
|
+
* @constant {number}
|
|
1509
|
+
* @default
|
|
1510
|
+
*/
|
|
1511
|
+
declare const DEFAULT_AUDIO_SAMPLE_RATE = 24000;
|
|
1512
|
+
/**
|
|
1513
|
+
* Default audio channel count
|
|
1514
|
+
*
|
|
1515
|
+
* @constant {number}
|
|
1516
|
+
* @default
|
|
1517
|
+
*/
|
|
1518
|
+
declare const DEFAULT_AUDIO_CHANNELS = 1;
|
|
1519
|
+
/**
|
|
1520
|
+
* Default audio buffer size
|
|
1521
|
+
*
|
|
1522
|
+
* @constant {number}
|
|
1523
|
+
* @default
|
|
1524
|
+
*/
|
|
1525
|
+
declare const DEFAULT_AUDIO_BUFFER_SIZE = 4096;
|
|
1526
|
+
|
|
1527
|
+
/**
|
|
1528
|
+
* Video Processor Interface
|
|
1529
|
+
* Defines contract for video processing implementations
|
|
1530
|
+
*
|
|
1531
|
+
* @author sansen
|
|
1532
|
+
* @interface IVideoProcessor
|
|
1533
|
+
*/
|
|
1534
|
+
interface IVideoProcessor {
|
|
1535
|
+
/**
|
|
1536
|
+
* Processes a video frame
|
|
1537
|
+
*
|
|
1538
|
+
* @param {VideoFrame} frame - Input video frame
|
|
1539
|
+
* @returns {VideoFrame | null} Processed video frame or null if no processing occurred
|
|
1540
|
+
* @author sansen
|
|
1541
|
+
*/
|
|
1542
|
+
process(frame: VideoFrame): VideoFrame | null;
|
|
1543
|
+
|
|
1544
|
+
/**
|
|
1545
|
+
* Cleans up resources
|
|
1546
|
+
*
|
|
1547
|
+
* @author sansen
|
|
1548
|
+
*/
|
|
1549
|
+
dispose(): void;
|
|
1550
|
+
}
|
|
1551
|
+
|
|
1552
|
+
/**
|
|
1553
|
+
* Local Video Debug Source
|
|
1554
|
+
* Loads a local video via HTMLVideoElement and provides VideoFrame capture utilities
|
|
1555
|
+
* Operates independently of LiveKit and uses only browser native APIs
|
|
1556
|
+
*
|
|
1557
|
+
* @author sansen
|
|
1558
|
+
* @class LocalVideoDebugSource
|
|
1559
|
+
* @extends {Disposable}
|
|
1560
|
+
*/
|
|
1561
|
+
declare class LocalVideoDebugSource extends Disposable {
|
|
1562
|
+
private _videoElement;
|
|
1563
|
+
private _videoUrl;
|
|
1564
|
+
private _isPlaying;
|
|
1565
|
+
private _frameCallbackId;
|
|
1566
|
+
/**
|
|
1567
|
+
* Creates a local video debug source instance
|
|
1568
|
+
*
|
|
1569
|
+
* @param {string} videoUrl - Video file URL (can be local file path or remote URL)
|
|
1570
|
+
* @param {HTMLVideoElement} [videoElement] - Optional HTMLVideoElement (will be created if not provided)
|
|
1571
|
+
* @author sansen
|
|
1572
|
+
*/
|
|
1573
|
+
constructor(videoUrl: string, videoElement?: HTMLVideoElement);
|
|
1574
|
+
/**
|
|
1575
|
+
* Gets the underlying video element
|
|
1576
|
+
*
|
|
1577
|
+
* @type {HTMLVideoElement|null}
|
|
1578
|
+
* @author sansen
|
|
1579
|
+
*/
|
|
1580
|
+
get videoElement(): HTMLVideoElement | null;
|
|
1581
|
+
/**
|
|
1582
|
+
* Loads the video resource
|
|
1583
|
+
*
|
|
1584
|
+
* @returns {Promise<void>} Promise that resolves when video is loaded
|
|
1585
|
+
* @author sansen
|
|
1586
|
+
*/
|
|
1587
|
+
load(): Promise<void>;
|
|
1588
|
+
/**
|
|
1589
|
+
* Starts video playback
|
|
1590
|
+
*
|
|
1591
|
+
* @returns {Promise<void>} Promise that resolves when playback starts
|
|
1592
|
+
* @author sansen
|
|
1593
|
+
*/
|
|
1594
|
+
play(): Promise<void>;
|
|
1595
|
+
/**
|
|
1596
|
+
* Pauses video playback
|
|
1597
|
+
*
|
|
1598
|
+
* @author sansen
|
|
1599
|
+
*/
|
|
1600
|
+
pause(): void;
|
|
1601
|
+
/**
|
|
1602
|
+
* Stops video playback and resets to start
|
|
1603
|
+
*
|
|
1604
|
+
* @author sansen
|
|
1605
|
+
*/
|
|
1606
|
+
stop(): void;
|
|
1607
|
+
/**
|
|
1608
|
+
* Checks whether the video is currently playing
|
|
1609
|
+
*
|
|
1610
|
+
* @type {boolean}
|
|
1611
|
+
* @author sansen
|
|
1612
|
+
*/
|
|
1613
|
+
get isPlaying(): boolean;
|
|
1614
|
+
/**
|
|
1615
|
+
* Gets video width in pixels
|
|
1616
|
+
*
|
|
1617
|
+
* @type {number}
|
|
1618
|
+
* @author sansen
|
|
1619
|
+
*/
|
|
1620
|
+
get videoWidth(): number;
|
|
1621
|
+
/**
|
|
1622
|
+
* Gets video height in pixels
|
|
1623
|
+
*
|
|
1624
|
+
* @type {number}
|
|
1625
|
+
* @author sansen
|
|
1626
|
+
*/
|
|
1627
|
+
get videoHeight(): number;
|
|
1628
|
+
/**
|
|
1629
|
+
* Creates a VideoFrame from the current video frame
|
|
1630
|
+
* Uses requestVideoFrameCallback when available, otherwise falls back to drawImage + createImageBitmap
|
|
1631
|
+
*
|
|
1632
|
+
* @returns {Promise<VideoFrame|null>} Promise resolving to VideoFrame or null if capture fails
|
|
1633
|
+
* @author sansen
|
|
1634
|
+
*/
|
|
1635
|
+
captureFrame(): Promise<VideoFrame | null>;
|
|
1636
|
+
/**
|
|
1637
|
+
* Registers a video frame callback
|
|
1638
|
+
* Uses requestVideoFrameCallback when supported or falls back to requestAnimationFrame
|
|
1639
|
+
*
|
|
1640
|
+
* @param {(frame: VideoFrame) => void} callback - Frame callback function
|
|
1641
|
+
* @author sansen
|
|
1642
|
+
*/
|
|
1643
|
+
onFrame(callback: (frame: VideoFrame) => void): void;
|
|
1644
|
+
/**
|
|
1645
|
+
* Cancels the video frame callback
|
|
1646
|
+
*
|
|
1647
|
+
* @author sansen
|
|
1648
|
+
*/
|
|
1649
|
+
offFrame(): void;
|
|
1650
|
+
/**
|
|
1651
|
+
* Cleanup method called when the source is disposed
|
|
1652
|
+
*
|
|
1653
|
+
* @protected
|
|
1654
|
+
* @author sansen
|
|
1655
|
+
*/
|
|
1656
|
+
protected onDispose(): void;
|
|
1657
|
+
}
|
|
1658
|
+
|
|
1659
|
+
/**
|
|
1660
|
+
* Standalone Video Debugger
|
|
1661
|
+
* Completely independent from LiveKit, uses local video files for green screen processing debugging
|
|
1662
|
+
*
|
|
1663
|
+
* Features:
|
|
1664
|
+
* - Load local video files
|
|
1665
|
+
* - Extract video frames
|
|
1666
|
+
* - Process through green screen processor
|
|
1667
|
+
* - Output to Canvas (preserving transparent background)
|
|
1668
|
+
*
|
|
1669
|
+
* Usage example:
|
|
1670
|
+
* ```typescript
|
|
1671
|
+
* const debugger = new StandaloneVideoDebugger('/path/to/video.mp4', canvas);
|
|
1672
|
+
* await debugger.start();
|
|
1673
|
+
* // Video will automatically play and process
|
|
1674
|
+
* ```
|
|
1675
|
+
*
|
|
1676
|
+
* @author sansen
|
|
1677
|
+
* @class StandaloneVideoDebugger
|
|
1678
|
+
* @extends {Disposable}
|
|
1679
|
+
*/
|
|
1680
|
+
declare class StandaloneVideoDebugger extends Disposable {
|
|
1681
|
+
private _videoSource;
|
|
1682
|
+
private readonly _pipelineRunner;
|
|
1683
|
+
private _isRunning;
|
|
1684
|
+
private _options;
|
|
1685
|
+
/**
|
|
1686
|
+
* Creates a standalone video debugger instance
|
|
1687
|
+
*
|
|
1688
|
+
* @param {string} videoUrl - Video file URL (can be local file path or remote URL)
|
|
1689
|
+
* @param {HTMLVideoElement} [videoElement] - Optional video element to use for playback
|
|
1690
|
+
* @param {HTMLCanvasElement} [outputCanvas] - Output canvas element (optional, will be created if not provided)
|
|
1691
|
+
* @param {VideoOptions} [options] - Video configuration options (including green screen settings)
|
|
1692
|
+
* @author sansen
|
|
1693
|
+
*/
|
|
1694
|
+
constructor(videoUrl: string, videoElement?: HTMLVideoElement, outputCanvas?: HTMLCanvasElement, options?: VideoOptions);
|
|
1695
|
+
/**
|
|
1696
|
+
* Switches video source seamlessly
|
|
1697
|
+
*
|
|
1698
|
+
* @param {string} videoUrl - New video URL
|
|
1699
|
+
* @param {HTMLVideoElement} [videoElement] - Optional video element to use
|
|
1700
|
+
* @returns {Promise<void>} Promise that resolves when source is switched
|
|
1701
|
+
* @author sansen
|
|
1702
|
+
*/
|
|
1703
|
+
switchSource(videoUrl: string, videoElement?: HTMLVideoElement): Promise<void>;
|
|
1704
|
+
/**
|
|
1705
|
+
* Gets the output canvas element
|
|
1706
|
+
*
|
|
1707
|
+
* @type {HTMLCanvasElement|null}
|
|
1708
|
+
* @author sansen
|
|
1709
|
+
*/
|
|
1710
|
+
get outputCanvas(): HTMLCanvasElement | null;
|
|
1711
|
+
/**
|
|
1712
|
+
* Gets the video source instance
|
|
1713
|
+
*
|
|
1714
|
+
* @type {LocalVideoDebugSource}
|
|
1715
|
+
* @author sansen
|
|
1716
|
+
*/
|
|
1717
|
+
get videoSource(): LocalVideoDebugSource;
|
|
1718
|
+
/**
|
|
1719
|
+
* Gets the current video processor
|
|
1720
|
+
*
|
|
1721
|
+
* @type {import('../video/video.d').IVideoProcessor|null}
|
|
1722
|
+
* @author sansen
|
|
1723
|
+
*/
|
|
1724
|
+
get processor(): IVideoProcessor | null;
|
|
1725
|
+
/**
|
|
1726
|
+
* Sets a new video processor
|
|
1727
|
+
*
|
|
1728
|
+
* @param {import('../video/video.d').IVideoProcessor|null} processor - Video processor to use
|
|
1729
|
+
* @author sansen
|
|
1730
|
+
*/
|
|
1731
|
+
setProcessor(processor: IVideoProcessor | null): void;
|
|
1732
|
+
/**
|
|
1733
|
+
* Updates green screen configuration options
|
|
1734
|
+
*
|
|
1735
|
+
* @param {Partial<GreenScreenOptions>} greenScreenOptions - Green screen configuration options
|
|
1736
|
+
* @author sansen
|
|
1737
|
+
*/
|
|
1738
|
+
updateGreenScreenOptions(greenScreenOptions: Partial<GreenScreenOptions>): void;
|
|
1739
|
+
/**
|
|
1740
|
+
* Initializes and loads the video
|
|
1741
|
+
*
|
|
1742
|
+
* @returns {Promise<void>} Promise that resolves when initialization is complete
|
|
1743
|
+
* @author sansen
|
|
1744
|
+
*/
|
|
1745
|
+
initialize(): Promise<void>;
|
|
1746
|
+
/**
|
|
1747
|
+
* Starts debugging (loads video and begins processing)
|
|
1748
|
+
*
|
|
1749
|
+
* @returns {Promise<void>} Promise that resolves when debugging is started
|
|
1750
|
+
* @author sansen
|
|
1751
|
+
*/
|
|
1752
|
+
start(): Promise<void>;
|
|
1753
|
+
/**
|
|
1754
|
+
* Stops debugging
|
|
1755
|
+
*
|
|
1756
|
+
* @author sansen
|
|
1757
|
+
*/
|
|
1758
|
+
stop(): void;
|
|
1759
|
+
/**
|
|
1760
|
+
* Pauses debugging
|
|
1761
|
+
*
|
|
1762
|
+
* @author sansen
|
|
1763
|
+
*/
|
|
1764
|
+
pause(): void;
|
|
1765
|
+
/**
|
|
1766
|
+
* Resumes debugging
|
|
1767
|
+
*
|
|
1768
|
+
* @returns {Promise<void>} Promise that resolves when debugging is resumed
|
|
1769
|
+
* @author sansen
|
|
1770
|
+
*/
|
|
1771
|
+
resume(): Promise<void>;
|
|
1772
|
+
/**
|
|
1773
|
+
* Checks if debugger is currently running
|
|
1774
|
+
*
|
|
1775
|
+
* @type {boolean}
|
|
1776
|
+
* @author sansen
|
|
1777
|
+
*/
|
|
1778
|
+
get isRunning(): boolean;
|
|
1779
|
+
/**
|
|
1780
|
+
* Cleanup method called when the debugger is disposed
|
|
1781
|
+
*
|
|
1782
|
+
* @protected
|
|
1783
|
+
* @author sansen
|
|
1784
|
+
*/
|
|
1785
|
+
protected onDispose(): void;
|
|
1786
|
+
}
|
|
1787
|
+
|
|
1788
|
+
export { AudioState, ConversationState, ConversationStateType, DEFAULT_AUDIO_BUFFER_SIZE, DEFAULT_AUDIO_CHANNELS, DEFAULT_AUDIO_SAMPLE_RATE, DEFAULT_RECONNECT_ATTEMPTS, DEFAULT_RECONNECT_DELAY, DEFAULT_WS_TIMEOUT, Disposable, EventBus, LogLevel, Logger, SDKClient, SDKContext, SDKError, SessionState, SessionStatus, StandaloneVideoDebugger, VideoState, createClient };
|
|
1789
|
+
export type { AsyncResult, AudioEvents, AudioOptions, BaseOptions, Callback, ClientOptions, ConnectionEvents, ConversationEvents, ConversationOptions, ErrorCallback, GreenScreenOptions, IDisposable, InputMode, SDKEvents, VideoEvents, VideoOptions, VideoRenderMode };
|