@layercode/js-sdk 2.7.0 → 2.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +46 -4
- package/dist/layercode-js-sdk.esm.js +5360 -5090
- package/dist/layercode-js-sdk.esm.js.map +1 -1
- package/dist/layercode-js-sdk.min.js +4631 -4357
- package/dist/layercode-js-sdk.min.js.map +1 -1
- package/dist/types/index.d.ts +29 -0
- package/package.json +1 -1
package/dist/types/index.d.ts
CHANGED
|
@@ -27,6 +27,13 @@ interface AuthorizeSessionRequestParams {
|
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
29
|
type AuthorizeSessionRequest = (params: AuthorizeSessionRequestParams) => Promise<Response>;
|
|
30
|
+
export type LayercodeAudioInputDevice = (MediaDeviceInfo & {
|
|
31
|
+
default: boolean;
|
|
32
|
+
}) & {
|
|
33
|
+
label: string;
|
|
34
|
+
};
|
|
35
|
+
export declare const listAudioInputDevices: () => Promise<LayercodeAudioInputDevice[]>;
|
|
36
|
+
export declare const watchAudioInputDevices: (callback: (devices: LayercodeAudioInputDevice[]) => void) => (() => void);
|
|
30
37
|
/**
|
|
31
38
|
* Interface for LayercodeClient public methods
|
|
32
39
|
*/
|
|
@@ -37,14 +44,20 @@ interface ILayercodeClient {
|
|
|
37
44
|
triggerUserTurnFinished(): Promise<void>;
|
|
38
45
|
getStream(): MediaStream | null;
|
|
39
46
|
setInputDevice(deviceId: string): Promise<void>;
|
|
47
|
+
setPreferredInputDevice(deviceId: string | null): Promise<void>;
|
|
40
48
|
setAudioInput(state: boolean): Promise<void>;
|
|
41
49
|
setAudioOutput(state: boolean): Promise<void>;
|
|
42
50
|
listDevices(): Promise<Array<MediaDeviceInfo & {
|
|
43
51
|
default: boolean;
|
|
44
52
|
}>>;
|
|
53
|
+
onDeviceSwitched?: (deviceId: string) => void;
|
|
54
|
+
onDevicesChanged?: (devices: Array<MediaDeviceInfo & {
|
|
55
|
+
default: boolean;
|
|
56
|
+
}>) => void;
|
|
45
57
|
mute(): void;
|
|
46
58
|
unmute(): void;
|
|
47
59
|
sendClientResponseText(text: string): Promise<void>;
|
|
60
|
+
sendClientResponseData(data: any): Promise<void>;
|
|
48
61
|
readonly status: string;
|
|
49
62
|
readonly userAudioAmplitude: number;
|
|
50
63
|
readonly agentAudioAmplitude: number;
|
|
@@ -124,6 +137,7 @@ declare class LayercodeClient implements ILayercodeClient {
|
|
|
124
137
|
private audioInput;
|
|
125
138
|
private audioOutput;
|
|
126
139
|
private AMPLITUDE_MONITORING_SAMPLE_RATE;
|
|
140
|
+
private audioOutputReady;
|
|
127
141
|
private pushToTalkActive;
|
|
128
142
|
private pushToTalkEnabled;
|
|
129
143
|
private canInterrupt;
|
|
@@ -142,6 +156,9 @@ declare class LayercodeClient implements ILayercodeClient {
|
|
|
142
156
|
private stopPlayerAmplitude?;
|
|
143
157
|
private stopRecorderAmplitude?;
|
|
144
158
|
private deviceChangeListener;
|
|
159
|
+
private recorderRestartChain;
|
|
160
|
+
private deviceListenerReady;
|
|
161
|
+
private resolveDeviceListenerReady;
|
|
145
162
|
_websocketUrl: string;
|
|
146
163
|
status: string;
|
|
147
164
|
userAudioAmplitude: number;
|
|
@@ -153,12 +170,19 @@ declare class LayercodeClient implements ILayercodeClient {
|
|
|
153
170
|
* @param {Object} options - Configuration options
|
|
154
171
|
*/
|
|
155
172
|
constructor(options: LayercodeClientOptions);
|
|
173
|
+
get onDeviceSwitched(): (deviceId: string) => void;
|
|
174
|
+
set onDeviceSwitched(callback: LayercodeClientOptions['onDeviceSwitched']);
|
|
175
|
+
get onDevicesChanged(): (devices: Array<MediaDeviceInfo & {
|
|
176
|
+
default: boolean;
|
|
177
|
+
}>) => void;
|
|
178
|
+
set onDevicesChanged(callback: LayercodeClientOptions['onDevicesChanged']);
|
|
156
179
|
private _initializeVAD;
|
|
157
180
|
/**
|
|
158
181
|
* Updates the connection status and triggers the callback
|
|
159
182
|
* @param {string} status - New status value
|
|
160
183
|
*/
|
|
161
184
|
private _setStatus;
|
|
185
|
+
private _waitForAudioOutputReady;
|
|
162
186
|
private _setAgentSpeaking;
|
|
163
187
|
private _setUserSpeaking;
|
|
164
188
|
/**
|
|
@@ -199,6 +223,8 @@ declare class LayercodeClient implements ILayercodeClient {
|
|
|
199
223
|
/** Emitters for audio flags */
|
|
200
224
|
private _emitAudioInput;
|
|
201
225
|
private _emitAudioOutput;
|
|
226
|
+
private _shouldCaptureUserAudio;
|
|
227
|
+
private _hasLiveRecorderStream;
|
|
202
228
|
get audioInputEnabled(): boolean;
|
|
203
229
|
get userSpeaking(): boolean;
|
|
204
230
|
get agentSpeaking(): boolean;
|
|
@@ -232,10 +258,13 @@ declare class LayercodeClient implements ILayercodeClient {
|
|
|
232
258
|
* @param {string} deviceId - The deviceId of the new microphone
|
|
233
259
|
*/
|
|
234
260
|
setInputDevice(deviceId: string): Promise<void>;
|
|
261
|
+
setPreferredInputDevice(deviceId: string | null): Promise<void>;
|
|
235
262
|
/**
|
|
236
263
|
* Restarts audio recording after a device switch to ensure audio is captured from the new device
|
|
237
264
|
*/
|
|
238
265
|
private _restartAudioRecording;
|
|
266
|
+
private _queueRecorderRestart;
|
|
267
|
+
private _initializeRecorderWithDefaultDevice;
|
|
239
268
|
/**
|
|
240
269
|
* Disconnect VAD
|
|
241
270
|
*/
|
package/package.json
CHANGED