Apply the auto-fixable lint rules and the formatter, and drop the Vite build artifacts.
This commit is contained in:
@@ -1,8 +1,24 @@
|
||||
/* eslint-disable no-console */
|
||||
import React, { useCallback, useEffect, useRef, useState, MouseEventHandler } from 'react';
|
||||
import { Box, Button, color, config, Header, IconButton, Input, Menu, MenuItem, PopOut, RectCords, Scroll, Switch, Text, toRem } from 'folds';
|
||||
import { Icon, Icons } from '../../../components/icons';
|
||||
import {
|
||||
Box,
|
||||
Button,
|
||||
color,
|
||||
config,
|
||||
Header,
|
||||
IconButton,
|
||||
Input,
|
||||
Menu,
|
||||
MenuItem,
|
||||
PopOut,
|
||||
RectCords,
|
||||
Scroll,
|
||||
Switch,
|
||||
Text,
|
||||
toRem,
|
||||
} from 'folds';
|
||||
import FocusTrap from 'focus-trap-react';
|
||||
import { Icon, Icons } from '../../../components/icons';
|
||||
import { Page, PageContent, PageHeader } from '../../../components/page';
|
||||
import { SequenceCard } from '../../../components/sequence-card';
|
||||
import { SettingTile } from '../../../components/setting-tile';
|
||||
@@ -22,24 +38,28 @@ interface AudioDevice {
|
||||
export type ScreenShareResolution = '720p' | '1080p' | '1440p' | '4k' | 'source';
|
||||
|
||||
/** Screen share resolution configs */
|
||||
export const SCREEN_SHARE_RESOLUTIONS: Record<ScreenShareResolution, { width: number; height: number; label: string }> = {
|
||||
export const SCREEN_SHARE_RESOLUTIONS: Record<
|
||||
ScreenShareResolution,
|
||||
{ width: number; height: number; label: string }
|
||||
> = {
|
||||
'720p': { width: 1280, height: 720, label: '720p (HD)' },
|
||||
'1080p': { width: 1920, height: 1080, label: '1080p (Full HD)' },
|
||||
'1440p': { width: 2560, height: 1440, label: '1440p (2K)' },
|
||||
'4k': { width: 3840, height: 2160, label: '4K (Ultra HD)' },
|
||||
'source': { width: 0, height: 0, label: 'Source Resolution' },
|
||||
source: { width: 0, height: 0, label: 'Source Resolution' },
|
||||
};
|
||||
|
||||
/** Screen share bitrate presets in kbps */
|
||||
export type ScreenShareBitrate = 'low' | 'medium' | 'high' | 'ultra';
|
||||
|
||||
/** Screen share bitrate configs */
|
||||
export const SCREEN_SHARE_BITRATES: Record<ScreenShareBitrate, { bitrate: number; label: string }> = {
|
||||
'low': { bitrate: 1000, label: 'Low (1 Mbps)' },
|
||||
'medium': { bitrate: 2500, label: 'Medium (2.5 Mbps)' },
|
||||
'high': { bitrate: 5000, label: 'High (5 Mbps)' },
|
||||
'ultra': { bitrate: 10000, label: 'Ultra (10 Mbps)' },
|
||||
};
|
||||
export const SCREEN_SHARE_BITRATES: Record<ScreenShareBitrate, { bitrate: number; label: string }> =
|
||||
{
|
||||
low: { bitrate: 1000, label: 'Low (1 Mbps)' },
|
||||
medium: { bitrate: 2500, label: 'Medium (2.5 Mbps)' },
|
||||
high: { bitrate: 5000, label: 'High (5 Mbps)' },
|
||||
ultra: { bitrate: 10000, label: 'Ultra (10 Mbps)' },
|
||||
};
|
||||
|
||||
/** Stored audio device settings */
|
||||
interface AudioSettings {
|
||||
@@ -235,11 +255,7 @@ function DeviceSelectButton({ devices, selectedId, onSelect }: DeviceSelectButto
|
||||
escapeDeactivates: stopPropagation,
|
||||
}}
|
||||
>
|
||||
<DeviceSelector
|
||||
devices={devices}
|
||||
selectedId={selectedId}
|
||||
onSelect={handleSelect}
|
||||
/>
|
||||
<DeviceSelector devices={devices} selectedId={selectedId} onSelect={handleSelect} />
|
||||
</FocusTrap>
|
||||
}
|
||||
/>
|
||||
@@ -471,10 +487,14 @@ export function Audio({ requestClose }: AudioProps) {
|
||||
const [microphones, setMicrophones] = useState<AudioDevice[]>([]);
|
||||
const [speakers, setSpeakers] = useState<AudioDevice[]>([]);
|
||||
const [settings, setSettings] = useState<AudioSettings>(loadAudioSettings);
|
||||
const [permissionStatus, setPermissionStatus] = useState<'granted' | 'denied' | 'prompt'>('prompt');
|
||||
const [permissionStatus, setPermissionStatus] = useState<'granted' | 'denied' | 'prompt'>(
|
||||
'prompt',
|
||||
);
|
||||
const [micTestState, setMicTestState] = useState<'idle' | 'testing' | 'done' | 'error'>('idle');
|
||||
const [micLevel, setMicLevel] = useState(0);
|
||||
const [speakerTestState, setSpeakerTestState] = useState<'idle' | 'testing' | 'done' | 'error'>('idle');
|
||||
const [speakerTestState, setSpeakerTestState] = useState<'idle' | 'testing' | 'done' | 'error'>(
|
||||
'idle',
|
||||
);
|
||||
const [micMonitoring, setMicMonitoring] = useState(false);
|
||||
const micAnimFrameRef = useRef<number | null>(null);
|
||||
const micMonitorContextRef = useRef<AudioContext | null>(null);
|
||||
@@ -490,7 +510,7 @@ export function Audio({ requestClose }: AudioProps) {
|
||||
setPermissionStatus('granted');
|
||||
|
||||
const devices = await navigator.mediaDevices.enumerateDevices();
|
||||
|
||||
|
||||
const mics = devices
|
||||
.filter((d) => d.kind === 'audioinput')
|
||||
.map((d) => ({
|
||||
@@ -498,7 +518,7 @@ export function Audio({ requestClose }: AudioProps) {
|
||||
label: d.label,
|
||||
kind: d.kind,
|
||||
}));
|
||||
|
||||
|
||||
const spks = devices
|
||||
.filter((d) => d.kind === 'audiooutput')
|
||||
.map((d) => ({
|
||||
@@ -682,10 +702,10 @@ export function Audio({ requestClose }: AudioProps) {
|
||||
const dataArray = new Uint8Array(analyser.frequencyBinCount);
|
||||
const microphone = audioContext.createMediaStreamSource(stream);
|
||||
const gainNode = audioContext.createGain();
|
||||
|
||||
|
||||
// Connect microphone to analyser for level monitoring
|
||||
microphone.connect(analyser);
|
||||
|
||||
|
||||
// Connect microphone to speakers for playback
|
||||
microphone.connect(gainNode);
|
||||
gainNode.connect(audioContext.destination);
|
||||
@@ -708,11 +728,17 @@ export function Audio({ requestClose }: AudioProps) {
|
||||
console.error('Microphone monitoring failed:', e);
|
||||
}
|
||||
}
|
||||
}, [micMonitoring, settings.microphoneId, settings.noiseSuppression, settings.echoCancellation, settings.autoGainControl]);
|
||||
}, [
|
||||
micMonitoring,
|
||||
settings.microphoneId,
|
||||
settings.noiseSuppression,
|
||||
settings.echoCancellation,
|
||||
settings.autoGainControl,
|
||||
]);
|
||||
|
||||
// Cleanup monitoring on unmount
|
||||
useEffect(() => {
|
||||
return () => {
|
||||
useEffect(
|
||||
() => () => {
|
||||
if (micAnimFrameRef.current !== null) {
|
||||
cancelAnimationFrame(micAnimFrameRef.current);
|
||||
}
|
||||
@@ -722,8 +748,9 @@ export function Audio({ requestClose }: AudioProps) {
|
||||
if (micMonitorContextRef.current) {
|
||||
micMonitorContextRef.current.close();
|
||||
}
|
||||
};
|
||||
}, []);
|
||||
},
|
||||
[],
|
||||
);
|
||||
|
||||
// Apply processing toggles to the live monitor track without tearing it down.
|
||||
useEffect(() => {
|
||||
@@ -807,14 +834,26 @@ export function Audio({ requestClose }: AudioProps) {
|
||||
<Box gap="200" alignItems="Center">
|
||||
<Button
|
||||
size="300"
|
||||
variant={micTestState === 'error' ? 'Critical' : micTestState === 'done' ? 'Success' : 'Secondary'}
|
||||
variant={
|
||||
micTestState === 'error'
|
||||
? 'Critical'
|
||||
: micTestState === 'done'
|
||||
? 'Success'
|
||||
: 'Secondary'
|
||||
}
|
||||
fill="Soft"
|
||||
radii="300"
|
||||
onClick={handleTestMicrophone}
|
||||
disabled={micTestState === 'testing' || micMonitoring}
|
||||
>
|
||||
<Text size="T300">
|
||||
{micTestState === 'testing' ? 'Testing...' : micTestState === 'done' ? 'Done ✓' : micTestState === 'error' ? 'Failed' : 'Test'}
|
||||
{micTestState === 'testing'
|
||||
? 'Testing...'
|
||||
: micTestState === 'done'
|
||||
? 'Done ✓'
|
||||
: micTestState === 'error'
|
||||
? 'Failed'
|
||||
: 'Test'}
|
||||
</Text>
|
||||
</Button>
|
||||
<Button
|
||||
@@ -825,14 +864,27 @@ export function Audio({ requestClose }: AudioProps) {
|
||||
onClick={handleMicMonitoringToggle}
|
||||
disabled={micTestState === 'testing'}
|
||||
>
|
||||
<Text size="T300">
|
||||
{micMonitoring ? 'Stop' : 'Monitor'}
|
||||
</Text>
|
||||
<Text size="T300">{micMonitoring ? 'Stop' : 'Monitor'}</Text>
|
||||
</Button>
|
||||
</Box>
|
||||
{(micTestState === 'testing' || micMonitoring) && (
|
||||
<Box style={{ width: toRem(160), height: toRem(6), background: color.Surface.Container, borderRadius: toRem(3), overflow: 'hidden' }}>
|
||||
<Box style={{ width: `${micLevel}%`, height: '100%', background: micMonitoring ? color.Success.Main : color.Primary.Main, transition: 'width 0.05s ease' }} />
|
||||
<Box
|
||||
style={{
|
||||
width: toRem(160),
|
||||
height: toRem(6),
|
||||
background: color.Surface.Container,
|
||||
borderRadius: toRem(3),
|
||||
overflow: 'hidden',
|
||||
}}
|
||||
>
|
||||
<Box
|
||||
style={{
|
||||
width: `${micLevel}%`,
|
||||
height: '100%',
|
||||
background: micMonitoring ? color.Success.Main : color.Primary.Main,
|
||||
transition: 'width 0.05s ease',
|
||||
}}
|
||||
/>
|
||||
</Box>
|
||||
)}
|
||||
</Box>
|
||||
@@ -864,14 +916,26 @@ export function Audio({ requestClose }: AudioProps) {
|
||||
/>
|
||||
<Button
|
||||
size="300"
|
||||
variant={speakerTestState === 'error' ? 'Critical' : speakerTestState === 'done' ? 'Success' : 'Secondary'}
|
||||
variant={
|
||||
speakerTestState === 'error'
|
||||
? 'Critical'
|
||||
: speakerTestState === 'done'
|
||||
? 'Success'
|
||||
: 'Secondary'
|
||||
}
|
||||
fill="Soft"
|
||||
radii="300"
|
||||
onClick={handleTestSpeaker}
|
||||
disabled={speakerTestState === 'testing'}
|
||||
>
|
||||
<Text size="T300">
|
||||
{speakerTestState === 'testing' ? 'Playing...' : speakerTestState === 'done' ? 'Done ✓' : speakerTestState === 'error' ? 'Failed' : 'Test'}
|
||||
{speakerTestState === 'testing'
|
||||
? 'Playing...'
|
||||
: speakerTestState === 'done'
|
||||
? 'Done ✓'
|
||||
: speakerTestState === 'error'
|
||||
? 'Failed'
|
||||
: 'Test'}
|
||||
</Text>
|
||||
</Button>
|
||||
</Box>
|
||||
@@ -992,10 +1056,12 @@ export function Audio({ requestClose }: AudioProps) {
|
||||
</Header>
|
||||
<Box direction="Column" gap="200" style={{ padding: `0 ${config.space.S300}` }}>
|
||||
<Text size="T300">
|
||||
• If you don't see your devices, make sure they are connected and permissions are granted.
|
||||
• If you don't see your devices, make sure they are connected and
|
||||
permissions are granted.
|
||||
</Text>
|
||||
<Text size="T300">
|
||||
• The "Test" button will help verify your devices are working correctly.
|
||||
• The "Test" button will help verify your devices are working
|
||||
correctly.
|
||||
</Text>
|
||||
<Text size="T300">
|
||||
• Changes are saved automatically and will apply to your next call.
|
||||
|
||||
Reference in New Issue
Block a user