Skip to content

Commit adc3931

Browse files
committed
upgrade js sdk
1 parent c6864cc commit adc3931

File tree

3 files changed

+56
-127
lines changed

3 files changed

+56
-127
lines changed

package-lock.json

Lines changed: 37 additions & 97 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"access": "public"
4040
},
4141
"dependencies": {
42-
"@layercode/js-sdk": "^2.5.0"
42+
"@layercode/js-sdk": "^2.8.0"
4343
},
4444
"devDependencies": {
4545
"@rollup/plugin-commonjs": "^25.0.8",

src/index.tsx

Lines changed: 18 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
import React, { useState, useEffect, useCallback, useRef } from 'react';
2-
import LayercodeClient, {
3-
type AgentConfig,
4-
type AuthorizeSessionRequest,
5-
type LayercodeAudioInputDevice,
6-
listAudioInputDevices,
7-
watchAudioInputDevices,
8-
} from 'layercode-js-sdk';
2+
import LayercodeClient, { type AgentConfig, type AuthorizeSessionRequest, type LayercodeAudioInputDevice, listAudioInputDevices, watchAudioInputDevices } from '@layercode/js-sdk';
93

104
/**
115
* Configuration options for the useLayercodeAgent hook.
@@ -333,27 +327,24 @@ const useLayercodeAgent = (
333327
[_setAudioOutput, clientRef, audioOutput]
334328
);
335329

336-
const selectInputDevice = useCallback(
337-
async (deviceId: string | null) => {
338-
const normalized = normalizeDeviceId(deviceId);
339-
setPreferredInputDeviceId(normalized);
340-
preferredInputDeviceRef.current = normalized;
341-
setInputDeviceListError(null);
330+
const selectInputDevice = useCallback(async (deviceId: string | null) => {
331+
const normalized = normalizeDeviceId(deviceId);
332+
setPreferredInputDeviceId(normalized);
333+
preferredInputDeviceRef.current = normalized;
334+
setInputDeviceListError(null);
342335

343-
if (!clientRef.current) {
344-
return;
345-
}
336+
if (!clientRef.current) {
337+
return;
338+
}
346339

347-
try {
348-
await clientRef.current.setPreferredInputDevice(normalized);
349-
} catch (error) {
350-
const message = error instanceof Error ? error.message : 'Unable to switch microphone';
351-
setInputDeviceListError(message);
352-
throw error;
353-
}
354-
},
355-
[]
356-
);
340+
try {
341+
await clientRef.current.setPreferredInputDevice(normalized);
342+
} catch (error) {
343+
const message = error instanceof Error ? error.message : 'Unable to switch microphone';
344+
setInputDeviceListError(message);
345+
throw error;
346+
}
347+
}, []);
357348

358349
const triggerUserTurnStarted = useCallback(() => {
359350
clientRef.current?.triggerUserTurnStarted();
@@ -521,9 +512,7 @@ const MicrophoneSelect = ({
521512

522513
{inputDeviceListError ? <div className="layercode-mic-select__error">{inputDeviceListError}</div> : null}
523514

524-
{!isInputDeviceListLoading && !inputDeviceListError && !hasDevices ? (
525-
<div className="layercode-mic-select__helper">{emptyLabel}</div>
526-
) : null}
515+
{!isInputDeviceListLoading && !inputDeviceListError && !hasDevices ? <div className="layercode-mic-select__helper">{emptyLabel}</div> : null}
527516

528517
{helperText ? <div className="layercode-mic-select__helper">{helperText}</div> : null}
529518
</div>

0 commit comments

Comments
 (0)