@layercode/js-sdk 1.0.25 → 1.0.27

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.
@@ -35,6 +35,8 @@ interface LayercodeClientOptions {
35
35
  onDisconnect?: () => void;
36
36
  /** Callback when an error occurs */
37
37
  onError?: (error: Error) => void;
38
+ /** Callback when a device is switched */
39
+ onDeviceSwitched?: (deviceId: string) => void;
38
40
  /** Callback for data messages */
39
41
  onDataMessage?: (message: any) => void;
40
42
  /** Callback for user audio amplitude changes */
@@ -61,12 +63,12 @@ declare class LayercodeClient implements ILayercodeClient {
61
63
  private pushToTalkEnabled;
62
64
  private canInterrupt;
63
65
  private userIsSpeaking;
64
- private endUserTurn;
65
66
  private recorderStarted;
66
67
  private readySent;
67
68
  private currentTurnId;
68
69
  private audioBuffer;
69
- private audioPauseTime;
70
+ private vadConfig;
71
+ private deviceId;
70
72
  _websocketUrl: string;
71
73
  status: string;
72
74
  userAudioAmplitude: number;
@@ -77,17 +79,14 @@ declare class LayercodeClient implements ILayercodeClient {
77
79
  * @param {Object} options - Configuration options
78
80
  */
79
81
  constructor(options: LayercodeClientOptions);
80
- private _setupAmplitudeBasedVAD;
81
82
  private _initializeVAD;
82
83
  /**
83
84
  * Updates the connection status and triggers the callback
84
85
  * @param {string} status - New status value
85
- * @private
86
86
  */
87
87
  private _setStatus;
88
88
  /**
89
89
  * Handles when agent audio finishes playing
90
- * @private
91
90
  */
92
91
  private _clientResponseAudioReplayFinished;
93
92
  private _clientInterruptAssistantReplay;
@@ -96,13 +95,11 @@ declare class LayercodeClient implements ILayercodeClient {
96
95
  /**
97
96
  * Handles incoming WebSocket messages
98
97
  * @param {MessageEvent} event - The WebSocket message event
99
- * @private
100
98
  */
101
99
  private _handleWebSocketMessage;
102
100
  /**
103
101
  * Handles available client browser microphone audio data and sends it over the WebSocket
104
102
  * @param {ArrayBuffer} data - The audio data buffer
105
- * @private
106
103
  */
107
104
  private _handleDataAvailable;
108
105
  private _wsSend;
@@ -112,7 +109,6 @@ declare class LayercodeClient implements ILayercodeClient {
112
109
  * @param {WavRecorder | WavStreamPlayer} source - The audio source (recorder or player).
113
110
  * @param {(amplitude: number) => void} callback - The callback function to invoke on amplitude change.
114
111
  * @param {(amplitude: number) => void} updateInternalState - Function to update the internal amplitude state.
115
- * @private
116
112
  */
117
113
  private _setupAmplitudeMonitoring;
118
114
  /**
@@ -133,6 +129,18 @@ declare class LayercodeClient implements ILayercodeClient {
133
129
  * @param {string} deviceId - The deviceId of the new microphone
134
130
  */
135
131
  setInputDevice(deviceId: string): Promise<void>;
132
+ /**
133
+ * Restarts audio recording after a device switch to ensure audio is captured from the new device
134
+ */
135
+ private _restartAudioRecording;
136
+ /**
137
+ * Reinitializes VAD with a new stream (used after device switching)
138
+ */
139
+ private _reinitializeVAD;
140
+ /**
141
+ * Sets up the device change event listener
142
+ */
143
+ private _setupDeviceChangeListener;
136
144
  }
137
145
  export default LayercodeClient;
138
146
  export type { ILayercodeClient, LayercodeClientOptions };
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "author": "Layercode",
3
3
  "license": "MIT",
4
4
  "name": "@layercode/js-sdk",
5
- "version": "1.0.25",
5
+ "version": "1.0.27",
6
6
  "description": "Layercode JavaScript SDK for browser usage",
7
7
  "type": "module",
8
8
  "main": "dist/layercode-js-sdk.esm.js",
@@ -24,7 +24,7 @@
24
24
  "dev": "rollup -c -w",
25
25
  "clean": "rimraf dist",
26
26
  "prebuild": "npm run clean",
27
- "copy-to-dashboard": "cp dist/layercode-js-sdk.esm.js* ../layercode/dashboard/public/static/js/"
27
+ "copy-to-core": "cp dist/layercode-js-sdk.esm.js* ../layercode/core/public/static/js/"
28
28
  },
29
29
  "keywords": [
30
30
  "layercode",
@@ -48,4 +48,4 @@
48
48
  "@ricky0123/vad-web": "^0.0.24",
49
49
  "onnxruntime-web": "^1.21.1"
50
50
  }
51
- }
51
+ }