steelseries-sonar-sdk 0.2.0 → 0.2.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/dist/index.js +874 -0
- package/package.json +7 -3
- package/.gitattributes +0 -8
- package/.github/workflows/tests.yml +0 -18
- package/.vscode/extensions.json +0 -8
- package/.vscode/settings.json +0 -33
- package/_.todo +0 -4
- package/biome.json +0 -62
- package/http/sonar.http +0 -104
- package/src/consts/fetch-options-put.ts +0 -3
- package/src/enums.ts +0 -88
- package/src/exceptions.ts +0 -45
- package/src/functions/audio/get-audio-data-classic.ts +0 -31
- package/src/functions/audio/get-audio-data-stream.ts +0 -37
- package/src/functions/audio/get-audio-mode.ts +0 -11
- package/src/functions/audio/set-audio-mode.ts +0 -12
- package/src/functions/audio/set-channel-mute-classic.ts +0 -35
- package/src/functions/audio/set-channel-mute-streamer.ts +0 -41
- package/src/functions/audio/set-channel-volume-classic.ts +0 -37
- package/src/functions/audio/set-channel-volume-streamer.ts +0 -43
- package/src/functions/chatmix/get-chat-mix-state.ts +0 -20
- package/src/functions/chatmix/set-chat-mix-balance.ts +0 -22
- package/src/functions/converters/convert-channel-to-api.ts +0 -19
- package/src/functions/converters/convert-chat-mix-balance-to-api.ts +0 -6
- package/src/functions/converters/convert-chat-mix-balance-to-user.ts +0 -7
- package/src/functions/converters/convert-profile-channel-to-api.ts +0 -19
- package/src/functions/converters/convert-profile-channel-to-user.ts +0 -19
- package/src/functions/converters/convert-volume-to-api.ts +0 -5
- package/src/functions/converters/convert-volume-to-user.ts +0 -6
- package/src/functions/devices/get-audio-devices.ts +0 -40
- package/src/functions/devices/set-audio-device.ts +0 -19
- package/src/functions/endpoint/get-app-endpoint.ts +0 -73
- package/src/functions/endpoint/get-sonar-endpoint-cached.ts +0 -28
- package/src/functions/endpoint/get-sonar-endpoint.ts +0 -88
- package/src/functions/profile/get-channel-profiles.ts +0 -26
- package/src/functions/profile/get-selected-profiles.ts +0 -17
- package/src/functions/profile/set-selected-profile.ts +0 -17
- package/src/index.ts +0 -41
- package/src/sonar/models/audio-settings/chatmix-data.ts +0 -6
- package/src/sonar/models/audio-settings/enums/audio-mode.ts +0 -4
- package/src/sonar/models/audio-settings/enums/chat-mix-state.ts +0 -6
- package/src/sonar/models/audio-settings/enums/device-data-flow.ts +0 -5
- package/src/sonar/models/audio-settings/enums/device-default-roles.ts +0 -6
- package/src/sonar/models/audio-settings/enums/device-role.ts +0 -9
- package/src/sonar/models/audio-settings/enums/device-state.ts +0 -8
- package/src/sonar/models/audio-settings/enums/sonar-channel.ts +0 -8
- package/src/sonar/models/audio-settings/enums/streaming-path.ts +0 -4
- package/src/sonar/models/audio-settings/volume-info-classic.ts +0 -4
- package/src/sonar/models/audio-settings/volume-info-streamer.ts +0 -10
- package/src/sonar/models/audio-settings/volume-settings-classic.ts +0 -13
- package/src/sonar/models/audio-settings/volume-settings-streamer.ts +0 -13
- package/src/sonar/models/config/config.ts +0 -9
- package/src/sonar/models/config/enums/VirtualAudioDevice.ts +0 -7
- package/src/sonar/models/devices/audio-device.ts +0 -17
- package/src/sonar/models/devices/changed-device.ts +0 -7
- package/src/sonar/requests/audio-devices/change-audio-device.ts +0 -37
- package/src/sonar/requests/audio-devices/request-audio-devices.ts +0 -42
- package/src/sonar/requests/chatmix/change-chat-mix-balance.ts +0 -25
- package/src/sonar/requests/chatmix/request-chat-mix-state.ts +0 -24
- package/src/sonar/requests/mode/change-audio-mode.ts +0 -24
- package/src/sonar/requests/mode/request-audio-mode.ts +0 -24
- package/src/sonar/requests/profiles/change-selected-config.ts +0 -25
- package/src/sonar/requests/profiles/request-configs.ts +0 -24
- package/src/sonar/requests/profiles/request-selected-configs.ts +0 -22
- package/src/sonar/requests/volume-settings/change-volume-level-classic.ts +0 -27
- package/src/sonar/requests/volume-settings/change-volume-level-streamer.ts +0 -29
- package/src/sonar/requests/volume-settings/change-volume-mute-classic.ts +0 -27
- package/src/sonar/requests/volume-settings/change-volume-mute-streamer.ts +0 -29
- package/src/sonar/requests/volume-settings/request-volume-settings-classic.ts +0 -22
- package/src/sonar/requests/volume-settings/request-volume-settings-streamer.ts +0 -22
- package/src/types/audio-device.ts +0 -7
- package/src/types/changed-device.ts +0 -7
- package/src/types/channel-volume-classic.ts +0 -4
- package/src/types/channel-volume-streamer-path.ts +0 -4
- package/src/types/channel-volume-streamer.ts +0 -6
- package/src/types/channel-volumes-classic.ts +0 -8
- package/src/types/channel-volumes-streamer.ts +0 -8
- package/src/types/chat-mix-data.ts +0 -7
- package/src/types/profile-option.ts +0 -9
- package/tests/e2e/audio/get-audio-data-classic.real.test.ts +0 -11
- package/tests/e2e/audio/get-audio-data-stream.real.test.ts +0 -11
- package/tests/e2e/audio/get-audio-mode.real.test.ts +0 -12
- package/tests/e2e/audio/set-audio-mode.real.test.ts +0 -20
- package/tests/e2e/audio/set-channel-mute-classic.real.test.ts +0 -18
- package/tests/e2e/audio/set-channel-mute-streamer.real.test.ts +0 -18
- package/tests/e2e/audio/set-channel-volume-classic.real.test.ts +0 -17
- package/tests/e2e/audio/set-channel-volume-streamer.real.test.ts +0 -22
- package/tests/e2e/chatmix/get-chat-mix-state.real.test.ts +0 -25
- package/tests/e2e/chatmix/set-chat-mix-balance.real.test.ts +0 -25
- package/tests/e2e/devices/get-audio-devices.real.test.ts +0 -29
- package/tests/e2e/devices/set-audio-device.real.test.ts +0 -32
- package/tests/e2e/enpoint/get-app-endpoint.real.test.ts +0 -19
- package/tests/e2e/enpoint/get-sonar-endpoint-cached.real.test.ts +0 -32
- package/tests/e2e/enpoint/get-sonar-endpoint.real.test.ts +0 -21
- package/tests/e2e/profiles/get-channel-profiles.real.test.ts +0 -21
- package/tests/e2e/profiles/get-selected-profiles.real.test.ts +0 -11
- package/tests/e2e/profiles/set-selected-profile.real.test.ts +0 -17
- package/tests/helpers/get-endpoint-e2e.ts +0 -8
- package/tests/unit/audio/get-audio-data-classic.test.ts +0 -57
- package/tests/unit/audio/get-audio-data-stream.test.ts +0 -65
- package/tests/unit/audio/get-audio-mode.test.ts +0 -58
- package/tests/unit/audio/set-audio-mode.test.ts +0 -66
- package/tests/unit/audio/set-channel-mute-classic.test.ts +0 -58
- package/tests/unit/audio/set-channel-mute-streamer.test.ts +0 -64
- package/tests/unit/audio/set-channel-volume-classic.test.ts +0 -58
- package/tests/unit/audio/set-channel-volume-streamer.test.ts +0 -64
- package/tests/unit/chatmix/get-chat-mix-state.test.ts +0 -70
- package/tests/unit/chatmix/set-chat-mix-balance.test.ts +0 -58
- package/tests/unit/devices/get-audio-devices.test.ts +0 -59
- package/tests/unit/devices/set-audio-devices.test.ts +0 -62
- package/tests/unit/endpoint/get-app-endpoint.test.ts +0 -72
- package/tests/unit/endpoint/get-sonar-endpoint-cached.test.ts +0 -93
- package/tests/unit/endpoint/get-sonar-endpoint.test.ts +0 -140
- package/tests/unit/profiles/get-channel-profiles.test.ts +0 -91
- package/tests/unit/profiles/get-selected-profiles.test.ts +0 -64
- package/tests/unit/profiles/set-selected-profile.test.ts +0 -55
- package/tsconfig.build.json +0 -12
- package/tsconfig.json +0 -36
- /package/{src → dist}/consts/fetch-options-put.d.ts +0 -0
- /package/{src → dist}/enums.d.ts +0 -0
- /package/{src → dist}/exceptions.d.ts +0 -0
- /package/{src → dist}/functions/audio/get-audio-data-classic.d.ts +0 -0
- /package/{src → dist}/functions/audio/get-audio-data-stream.d.ts +0 -0
- /package/{src → dist}/functions/audio/get-audio-mode.d.ts +0 -0
- /package/{src → dist}/functions/audio/set-audio-mode.d.ts +0 -0
- /package/{src → dist}/functions/audio/set-channel-mute-classic.d.ts +0 -0
- /package/{src → dist}/functions/audio/set-channel-mute-streamer.d.ts +0 -0
- /package/{src → dist}/functions/audio/set-channel-volume-classic.d.ts +0 -0
- /package/{src → dist}/functions/audio/set-channel-volume-streamer.d.ts +0 -0
- /package/{src → dist}/functions/chatmix/get-chat-mix-state.d.ts +0 -0
- /package/{src → dist}/functions/chatmix/set-chat-mix-balance.d.ts +0 -0
- /package/{src → dist}/functions/converters/convert-channel-to-api.d.ts +0 -0
- /package/{src → dist}/functions/converters/convert-chat-mix-balance-to-api.d.ts +0 -0
- /package/{src → dist}/functions/converters/convert-chat-mix-balance-to-user.d.ts +0 -0
- /package/{src → dist}/functions/converters/convert-profile-channel-to-api.d.ts +0 -0
- /package/{src → dist}/functions/converters/convert-profile-channel-to-user.d.ts +0 -0
- /package/{src → dist}/functions/converters/convert-volume-to-api.d.ts +0 -0
- /package/{src → dist}/functions/converters/convert-volume-to-user.d.ts +0 -0
- /package/{src → dist}/functions/devices/get-audio-devices.d.ts +0 -0
- /package/{src → dist}/functions/devices/set-audio-device.d.ts +0 -0
- /package/{src → dist}/functions/endpoint/get-app-endpoint.d.ts +0 -0
- /package/{src → dist}/functions/endpoint/get-sonar-endpoint-cached.d.ts +0 -0
- /package/{src → dist}/functions/endpoint/get-sonar-endpoint.d.ts +0 -0
- /package/{src → dist}/functions/profile/get-channel-profiles.d.ts +0 -0
- /package/{src → dist}/functions/profile/get-selected-profiles.d.ts +0 -0
- /package/{src → dist}/functions/profile/set-selected-profile.d.ts +0 -0
- /package/{src → dist}/index.d.ts +0 -0
- /package/{src → dist}/sonar/models/audio-settings/chatmix-data.d.ts +0 -0
- /package/{src → dist}/sonar/models/audio-settings/enums/audio-mode.d.ts +0 -0
- /package/{src → dist}/sonar/models/audio-settings/enums/chat-mix-state.d.ts +0 -0
- /package/{src → dist}/sonar/models/audio-settings/enums/device-data-flow.d.ts +0 -0
- /package/{src → dist}/sonar/models/audio-settings/enums/device-default-roles.d.ts +0 -0
- /package/{src → dist}/sonar/models/audio-settings/enums/device-role.d.ts +0 -0
- /package/{src → dist}/sonar/models/audio-settings/enums/device-state.d.ts +0 -0
- /package/{src → dist}/sonar/models/audio-settings/enums/sonar-channel.d.ts +0 -0
- /package/{src → dist}/sonar/models/audio-settings/enums/streaming-path.d.ts +0 -0
- /package/{src → dist}/sonar/models/audio-settings/volume-info-classic.d.ts +0 -0
- /package/{src → dist}/sonar/models/audio-settings/volume-info-streamer.d.ts +0 -0
- /package/{src → dist}/sonar/models/audio-settings/volume-settings-classic.d.ts +0 -0
- /package/{src → dist}/sonar/models/audio-settings/volume-settings-streamer.d.ts +0 -0
- /package/{src → dist}/sonar/models/config/config.d.ts +0 -0
- /package/{src → dist}/sonar/models/config/enums/VirtualAudioDevice.d.ts +0 -0
- /package/{src → dist}/sonar/models/devices/audio-device.d.ts +0 -0
- /package/{src → dist}/sonar/models/devices/changed-device.d.ts +0 -0
- /package/{src → dist}/sonar/requests/audio-devices/change-audio-device.d.ts +0 -0
- /package/{src → dist}/sonar/requests/audio-devices/request-audio-devices.d.ts +0 -0
- /package/{src → dist}/sonar/requests/chatmix/change-chat-mix-balance.d.ts +0 -0
- /package/{src → dist}/sonar/requests/chatmix/request-chat-mix-state.d.ts +0 -0
- /package/{src → dist}/sonar/requests/mode/change-audio-mode.d.ts +0 -0
- /package/{src → dist}/sonar/requests/mode/request-audio-mode.d.ts +0 -0
- /package/{src → dist}/sonar/requests/profiles/change-selected-config.d.ts +0 -0
- /package/{src → dist}/sonar/requests/profiles/request-configs.d.ts +0 -0
- /package/{src → dist}/sonar/requests/profiles/request-selected-configs.d.ts +0 -0
- /package/{src → dist}/sonar/requests/volume-settings/change-volume-level-classic.d.ts +0 -0
- /package/{src → dist}/sonar/requests/volume-settings/change-volume-level-streamer.d.ts +0 -0
- /package/{src → dist}/sonar/requests/volume-settings/change-volume-mute-classic.d.ts +0 -0
- /package/{src → dist}/sonar/requests/volume-settings/change-volume-mute-streamer.d.ts +0 -0
- /package/{src → dist}/sonar/requests/volume-settings/request-volume-settings-classic.d.ts +0 -0
- /package/{src → dist}/sonar/requests/volume-settings/request-volume-settings-streamer.d.ts +0 -0
- /package/{src → dist}/types/audio-device.d.ts +0 -0
- /package/{src → dist}/types/changed-device.d.ts +0 -0
- /package/{src → dist}/types/channel-volume-classic.d.ts +0 -0
- /package/{src → dist}/types/channel-volume-streamer-path.d.ts +0 -0
- /package/{src → dist}/types/channel-volume-streamer.d.ts +0 -0
- /package/{src → dist}/types/channel-volumes-classic.d.ts +0 -0
- /package/{src → dist}/types/channel-volumes-streamer.d.ts +0 -0
- /package/{src → dist}/types/chat-mix-data.d.ts +0 -0
- /package/{src → dist}/types/profile-option.d.ts +0 -0
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { ChatMixState } from '@/enums'
|
|
2
|
-
import { convertChatMixBalanceToUser } from '@/functions/converters/convert-chat-mix-balance-to-user'
|
|
3
|
-
import { requestChatMixState } from '@/sonar/requests/chatmix/request-chat-mix-state'
|
|
4
|
-
import type { ChatMixData } from '@/types/chat-mix-data'
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Gets CHATMIX state and data.
|
|
8
|
-
* @param sonarEndpoint Sonar endpoint URL
|
|
9
|
-
* @returns balance as 0 - 100,
|
|
10
|
-
*/
|
|
11
|
-
export async function getChatMixState(sonarEndpoint: string): Promise<ChatMixData> {
|
|
12
|
-
const data = await requestChatMixState(sonarEndpoint)
|
|
13
|
-
|
|
14
|
-
const chatMixData: ChatMixData = {
|
|
15
|
-
chatBalance: convertChatMixBalanceToUser(data.balance),
|
|
16
|
-
state: data.state,
|
|
17
|
-
isEnabled: data.state === ChatMixState.Enabled
|
|
18
|
-
}
|
|
19
|
-
return chatMixData
|
|
20
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { ChatMixState } from '@/enums'
|
|
2
|
-
import { convertChatMixBalanceToApi } from '@/functions/converters/convert-chat-mix-balance-to-api'
|
|
3
|
-
import { convertChatMixBalanceToUser } from '@/functions/converters/convert-chat-mix-balance-to-user'
|
|
4
|
-
import { changeChatMixBalance } from '@/sonar/requests/chatmix/change-chat-mix-balance'
|
|
5
|
-
import type { ChatMixData } from '@/types/chat-mix-data'
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Set CHATMIX balance between audio(0%) and chat(100%).
|
|
9
|
-
* @param sonarEndpoint Sonar endpoint URL
|
|
10
|
-
* @param chatBalance Balance as 0 - 100,
|
|
11
|
-
*/
|
|
12
|
-
export async function setChatMixBalance(sonarEndpoint: string, chatBalance: number): Promise<ChatMixData> {
|
|
13
|
-
const balance = convertChatMixBalanceToApi(chatBalance)
|
|
14
|
-
const data = await changeChatMixBalance(sonarEndpoint, balance)
|
|
15
|
-
|
|
16
|
-
const chatMixData: ChatMixData = {
|
|
17
|
-
chatBalance: convertChatMixBalanceToUser(data.balance),
|
|
18
|
-
state: data.state,
|
|
19
|
-
isEnabled: data.state === ChatMixState.Enabled
|
|
20
|
-
}
|
|
21
|
-
return chatMixData
|
|
22
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { AudioChannel } from '@/enums'
|
|
2
|
-
import { SonarChannel } from '@/sonar/models/audio-settings/enums/sonar-channel'
|
|
3
|
-
|
|
4
|
-
export function convertChannelToApi(channel: AudioChannel): SonarChannel {
|
|
5
|
-
switch (channel) {
|
|
6
|
-
case AudioChannel.Master:
|
|
7
|
-
return SonarChannel.Master
|
|
8
|
-
case AudioChannel.Game:
|
|
9
|
-
return SonarChannel.ChatRender
|
|
10
|
-
case AudioChannel.Media:
|
|
11
|
-
return SonarChannel.Media
|
|
12
|
-
case AudioChannel.Aux:
|
|
13
|
-
return SonarChannel.Aux
|
|
14
|
-
case AudioChannel.Mic:
|
|
15
|
-
return SonarChannel.ChatCapture
|
|
16
|
-
default:
|
|
17
|
-
throw new Error(`Unsupported AudioChannel: ${channel}`)
|
|
18
|
-
}
|
|
19
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { ProfileChannel } from '@/enums'
|
|
2
|
-
import { VirtualAudioDevice } from '@/sonar/models/config/enums/VirtualAudioDevice'
|
|
3
|
-
|
|
4
|
-
export function convertProfileChannelToApi(channel: ProfileChannel): VirtualAudioDevice {
|
|
5
|
-
switch (channel) {
|
|
6
|
-
case ProfileChannel.Game:
|
|
7
|
-
return VirtualAudioDevice.Game
|
|
8
|
-
case ProfileChannel.Chat:
|
|
9
|
-
return VirtualAudioDevice.ChatRender
|
|
10
|
-
case ProfileChannel.Media:
|
|
11
|
-
return VirtualAudioDevice.Media
|
|
12
|
-
case ProfileChannel.Aux:
|
|
13
|
-
return VirtualAudioDevice.Aux
|
|
14
|
-
case ProfileChannel.Mic:
|
|
15
|
-
return VirtualAudioDevice.ChatCapture
|
|
16
|
-
default:
|
|
17
|
-
throw new Error(`Unsupported ProfileChannel: ${channel}`)
|
|
18
|
-
}
|
|
19
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { ProfileChannel } from '@/enums'
|
|
2
|
-
import { VirtualAudioDevice } from '@/sonar/models/config/enums/VirtualAudioDevice'
|
|
3
|
-
|
|
4
|
-
export function convertProfileChannelToUser(channel: VirtualAudioDevice): ProfileChannel {
|
|
5
|
-
switch (channel) {
|
|
6
|
-
case VirtualAudioDevice.Game:
|
|
7
|
-
return ProfileChannel.Game
|
|
8
|
-
case VirtualAudioDevice.ChatRender:
|
|
9
|
-
return ProfileChannel.Chat
|
|
10
|
-
case VirtualAudioDevice.Media:
|
|
11
|
-
return ProfileChannel.Media
|
|
12
|
-
case VirtualAudioDevice.Aux:
|
|
13
|
-
return ProfileChannel.Aux
|
|
14
|
-
case VirtualAudioDevice.ChatCapture:
|
|
15
|
-
return ProfileChannel.Mic
|
|
16
|
-
default:
|
|
17
|
-
throw new Error(`Unsupported ProfileChannel: ${channel}`)
|
|
18
|
-
}
|
|
19
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { DeviceFlow } from '@/enums'
|
|
2
|
-
import { SonarRequestException } from '@/exceptions'
|
|
3
|
-
import { DeviceDataFlow } from '@/sonar/models/audio-settings/enums/device-data-flow'
|
|
4
|
-
import { requestAudioDevices } from '@/sonar/requests/audio-devices/request-audio-devices'
|
|
5
|
-
import type { AudioDevice } from '@/types/audio-device'
|
|
6
|
-
|
|
7
|
-
export async function getAudioDevices(sonarEndpoint: string, deviceType?: DeviceFlow): Promise<AudioDevice[]> {
|
|
8
|
-
let deviceDataFlow: DeviceDataFlow
|
|
9
|
-
switch (deviceType) {
|
|
10
|
-
case DeviceFlow.Input:
|
|
11
|
-
deviceDataFlow = DeviceDataFlow.Capture
|
|
12
|
-
break
|
|
13
|
-
case DeviceFlow.Output:
|
|
14
|
-
deviceDataFlow = DeviceDataFlow.Render
|
|
15
|
-
break
|
|
16
|
-
case undefined:
|
|
17
|
-
deviceDataFlow = DeviceDataFlow.All
|
|
18
|
-
break
|
|
19
|
-
}
|
|
20
|
-
const data = await requestAudioDevices(sonarEndpoint, { deviceDataFlow, removeSteelSeriesVAD: true })
|
|
21
|
-
|
|
22
|
-
const audioDevices: AudioDevice[] = data.map((device) => ({
|
|
23
|
-
id: device.id,
|
|
24
|
-
name: device.friendlyName,
|
|
25
|
-
type: getDeviceTypeFromDataFlow(device.dataFlow)
|
|
26
|
-
}))
|
|
27
|
-
|
|
28
|
-
return audioDevices
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function getDeviceTypeFromDataFlow(dataFlow: DeviceDataFlow): DeviceFlow {
|
|
32
|
-
switch (dataFlow) {
|
|
33
|
-
case DeviceDataFlow.Capture:
|
|
34
|
-
return DeviceFlow.Input
|
|
35
|
-
case DeviceDataFlow.Render:
|
|
36
|
-
return DeviceFlow.Output
|
|
37
|
-
default:
|
|
38
|
-
throw new SonarRequestException({ message: `Unknown device data flow: ${dataFlow}` })
|
|
39
|
-
}
|
|
40
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { DeviceChannel } from '@/enums'
|
|
2
|
-
import { changeAudioDevice } from '@/sonar/requests/audio-devices/change-audio-device'
|
|
3
|
-
import type { ChangedDevice } from '@/types/changed-device'
|
|
4
|
-
|
|
5
|
-
export async function setAudioDevice(
|
|
6
|
-
sonarEndpoint: string,
|
|
7
|
-
deviceChannel: DeviceChannel,
|
|
8
|
-
deviceId: string
|
|
9
|
-
): Promise<ChangedDevice[]> {
|
|
10
|
-
const data = await changeAudioDevice(sonarEndpoint, deviceChannel, deviceId)
|
|
11
|
-
|
|
12
|
-
const result: ChangedDevice[] = data.map((x) => ({
|
|
13
|
-
deviceId: x.deviceId,
|
|
14
|
-
deviceChannel: x.id,
|
|
15
|
-
isRunning: x.isRunning
|
|
16
|
-
}))
|
|
17
|
-
|
|
18
|
-
return result
|
|
19
|
-
}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { promises as fsAsync } from 'node:fs'
|
|
2
|
-
import { platform as getPlatform } from 'node:os'
|
|
3
|
-
import { join as joinPath } from 'node:path'
|
|
4
|
-
import { InitializeErrorReason, SonarInitializationException } from '@/exceptions'
|
|
5
|
-
|
|
6
|
-
const WINDOWS_PATHS = ['SteelSeries', 'SteelSeries Engine 3', 'coreProps.json']
|
|
7
|
-
|
|
8
|
-
type CoreProps = {
|
|
9
|
-
ggEncryptedAddress: string
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Retrieves the SteelSeries GG application's encrypted address from the coreProps.json file.
|
|
14
|
-
*
|
|
15
|
-
* @returns A promise that resolves to the GG application's secure address string (e.g., "https://..."),
|
|
16
|
-
* as found in the ggEncryptedAddress property of coreProps.json.
|
|
17
|
-
*
|
|
18
|
-
* @throws {SonarInitializationException} If the GG server cannot be determined.
|
|
19
|
-
*
|
|
20
|
-
* @remarks
|
|
21
|
-
* - Only supports Windows OS; throws on other platforms.
|
|
22
|
-
* - Locates coreProps.json in the ProgramData directory under SteelSeries folders.
|
|
23
|
-
* - Reads and parses the file, returning the encrypted address as a secure URL.
|
|
24
|
-
*/
|
|
25
|
-
export async function getAppEndpoint(): Promise<string> {
|
|
26
|
-
const appDataPath = getPath()
|
|
27
|
-
const fileContents = await getContents(appDataPath)
|
|
28
|
-
const data = parseContents(fileContents)
|
|
29
|
-
|
|
30
|
-
if (data.ggEncryptedAddress) {
|
|
31
|
-
return `https://${data.ggEncryptedAddress}`
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
throw new SonarInitializationException({
|
|
35
|
-
reason: InitializeErrorReason.BadConfig
|
|
36
|
-
})
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function getPath(): string {
|
|
40
|
-
const os = getPlatform()
|
|
41
|
-
switch (os) {
|
|
42
|
-
case 'win32': {
|
|
43
|
-
const programData = process.env.ProgramData ?? 'C:\\ProgramData'
|
|
44
|
-
return joinPath(programData, ...WINDOWS_PATHS)
|
|
45
|
-
}
|
|
46
|
-
default:
|
|
47
|
-
throw new SonarInitializationException({
|
|
48
|
-
reason: InitializeErrorReason.OSUnsupported
|
|
49
|
-
})
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
async function getContents(path: string): Promise<string> {
|
|
54
|
-
try {
|
|
55
|
-
return await fsAsync.readFile(path, 'utf8')
|
|
56
|
-
} catch (error) {
|
|
57
|
-
throw new SonarInitializationException({
|
|
58
|
-
reason: InitializeErrorReason.BadConfig,
|
|
59
|
-
innerException: error as Error
|
|
60
|
-
})
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
function parseContents(contents: string): CoreProps {
|
|
65
|
-
try {
|
|
66
|
-
return JSON.parse(contents) as CoreProps
|
|
67
|
-
} catch (error) {
|
|
68
|
-
throw new SonarInitializationException({
|
|
69
|
-
reason: InitializeErrorReason.BadConfig,
|
|
70
|
-
innerException: error as Error
|
|
71
|
-
})
|
|
72
|
-
}
|
|
73
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { getSonarEndpoint } from '@/functions/endpoint/get-sonar-endpoint'
|
|
2
|
-
|
|
3
|
-
const cache = {
|
|
4
|
-
appAddress: null as string | null,
|
|
5
|
-
sonarAddress: null as string | null,
|
|
6
|
-
timestamp: 0
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export async function getSonarEndpointCached(appAddress: string, seconds: number = 60): Promise<string> {
|
|
10
|
-
const now = Date.now()
|
|
11
|
-
|
|
12
|
-
if (cache.appAddress === appAddress && cache.sonarAddress && now - cache.timestamp < seconds * 1000) {
|
|
13
|
-
return cache.sonarAddress
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
try {
|
|
17
|
-
const sonarAddress = await getSonarEndpoint(appAddress)
|
|
18
|
-
cache.appAddress = appAddress
|
|
19
|
-
cache.sonarAddress = sonarAddress
|
|
20
|
-
cache.timestamp = now
|
|
21
|
-
return sonarAddress
|
|
22
|
-
} catch (error) {
|
|
23
|
-
cache.appAddress = null
|
|
24
|
-
cache.sonarAddress = null
|
|
25
|
-
cache.timestamp = 0
|
|
26
|
-
throw error
|
|
27
|
-
}
|
|
28
|
-
}
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { InitializeErrorReason, SonarInitializationException } from '@/exceptions'
|
|
2
|
-
|
|
3
|
-
type SubAppsResponse = {
|
|
4
|
-
subApps: {
|
|
5
|
-
sonar?: {
|
|
6
|
-
isEnabled: boolean
|
|
7
|
-
isReady: boolean
|
|
8
|
-
isRunning: boolean
|
|
9
|
-
metadata: {
|
|
10
|
-
webServerAddress: string
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Retrieves the Sonar web server address from an application server's /subApps endpoint.
|
|
18
|
-
*
|
|
19
|
-
* @param appEndpoint - The base URL of the application server (e.g. "https://localhost:1234").
|
|
20
|
-
* @returns A promise that resolves to the Sonar web server address.
|
|
21
|
-
*
|
|
22
|
-
* @throws {SonarInitializationException} If the sonar server cannot be determined.
|
|
23
|
-
*
|
|
24
|
-
* @remarks
|
|
25
|
-
* - Performs a GET request to `${appAddress}/subApps`.
|
|
26
|
-
* - The response body is expected to conform to the SubAppsResponse shape and contain `subApps.sonar`.
|
|
27
|
-
* - Uses a fetch TLS option that disables certificate verification (rejectUnauthorized: false).
|
|
28
|
-
*/
|
|
29
|
-
export async function getSonarEndpoint(appEndpoint: string): Promise<string> {
|
|
30
|
-
let response: Response
|
|
31
|
-
|
|
32
|
-
try {
|
|
33
|
-
response = await fetch(`${appEndpoint}/subApps`, {
|
|
34
|
-
tls: {
|
|
35
|
-
rejectUnauthorized: false
|
|
36
|
-
}
|
|
37
|
-
})
|
|
38
|
-
} catch (error) {
|
|
39
|
-
throw new SonarInitializationException({
|
|
40
|
-
reason: InitializeErrorReason.NotResponding,
|
|
41
|
-
innerException: error as Error
|
|
42
|
-
})
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
if (!response.ok) {
|
|
46
|
-
throw new SonarInitializationException({
|
|
47
|
-
reason: InitializeErrorReason.NotResponding
|
|
48
|
-
})
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const result: SubAppsResponse = (await response.json()) as SubAppsResponse
|
|
52
|
-
|
|
53
|
-
const sonar = result?.subApps?.sonar
|
|
54
|
-
|
|
55
|
-
if (!sonar) {
|
|
56
|
-
throw new SonarInitializationException({
|
|
57
|
-
reason: InitializeErrorReason.NotAvailable
|
|
58
|
-
})
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
if (!sonar.isEnabled) {
|
|
62
|
-
throw new SonarInitializationException({
|
|
63
|
-
reason: InitializeErrorReason.NotEnabled
|
|
64
|
-
})
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
if (!sonar.isRunning) {
|
|
68
|
-
throw new SonarInitializationException({
|
|
69
|
-
reason: InitializeErrorReason.NotRunning
|
|
70
|
-
})
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
if (!sonar.isReady) {
|
|
74
|
-
throw new SonarInitializationException({
|
|
75
|
-
reason: InitializeErrorReason.NotReady
|
|
76
|
-
})
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
const sonarAddress = sonar.metadata?.webServerAddress
|
|
80
|
-
|
|
81
|
-
if (!sonarAddress) {
|
|
82
|
-
throw new SonarInitializationException({
|
|
83
|
-
reason: InitializeErrorReason.NotAvailable
|
|
84
|
-
})
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
return sonarAddress
|
|
88
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { ProfileChannel } from '@/enums'
|
|
2
|
-
import { convertProfileChannelToApi } from '@/functions/converters/convert-profile-channel-to-api'
|
|
3
|
-
import { convertProfileChannelToUser } from '@/functions/converters/convert-profile-channel-to-user'
|
|
4
|
-
import { requestConfigs } from '@/sonar/requests/profiles/request-configs'
|
|
5
|
-
import type { ProfileOption } from '@/types/profile-option'
|
|
6
|
-
|
|
7
|
-
export async function getChannelProfiles(
|
|
8
|
-
sonarAddress: string,
|
|
9
|
-
channel: ProfileChannel,
|
|
10
|
-
favoritesOnly?: boolean
|
|
11
|
-
): Promise<ProfileOption[]> {
|
|
12
|
-
const vad = convertProfileChannelToApi(channel)
|
|
13
|
-
const data = await requestConfigs(sonarAddress, vad)
|
|
14
|
-
const workingSetData = favoritesOnly ? data.filter((x) => x.isFavorite) : data
|
|
15
|
-
|
|
16
|
-
return workingSetData.map((x) => {
|
|
17
|
-
const profile: ProfileOption = {
|
|
18
|
-
id: x.id,
|
|
19
|
-
name: x.name,
|
|
20
|
-
isFavorite: x.isFavorite,
|
|
21
|
-
channel: convertProfileChannelToUser(x.virtualAudioDevice),
|
|
22
|
-
image: x.image
|
|
23
|
-
}
|
|
24
|
-
return profile
|
|
25
|
-
})
|
|
26
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { convertProfileChannelToUser } from '@/functions/converters/convert-profile-channel-to-user'
|
|
2
|
-
import { requestSelectedConfigs } from '@/sonar/requests/profiles/request-selected-configs'
|
|
3
|
-
import type { ProfileOption } from '@/types/profile-option'
|
|
4
|
-
|
|
5
|
-
export async function getSelectedProfiles(sonarAddress: string): Promise<ProfileOption[]> {
|
|
6
|
-
const data = await requestSelectedConfigs(sonarAddress)
|
|
7
|
-
return data.map((x) => {
|
|
8
|
-
const profile: ProfileOption = {
|
|
9
|
-
id: x.id,
|
|
10
|
-
name: x.name,
|
|
11
|
-
isFavorite: x.isFavorite,
|
|
12
|
-
channel: convertProfileChannelToUser(x.virtualAudioDevice),
|
|
13
|
-
image: x.image
|
|
14
|
-
}
|
|
15
|
-
return profile
|
|
16
|
-
})
|
|
17
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { convertProfileChannelToUser } from '@/functions/converters/convert-profile-channel-to-user'
|
|
2
|
-
import { changeSelectedConfig } from '@/sonar/requests/profiles/change-selected-config'
|
|
3
|
-
import type { ProfileOption } from '@/types/profile-option'
|
|
4
|
-
|
|
5
|
-
export async function setSelectedProfile(sonarAddress: string, profileId: string): Promise<ProfileOption> {
|
|
6
|
-
const data = await changeSelectedConfig(sonarAddress, profileId)
|
|
7
|
-
|
|
8
|
-
const result: ProfileOption = {
|
|
9
|
-
id: data.id,
|
|
10
|
-
name: data.name,
|
|
11
|
-
isFavorite: data.isFavorite,
|
|
12
|
-
channel: convertProfileChannelToUser(data.virtualAudioDevice),
|
|
13
|
-
image: data.image
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
return result
|
|
17
|
-
}
|
package/src/index.ts
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
export * from '@/enums'
|
|
2
|
-
export * from '@/exceptions'
|
|
3
|
-
|
|
4
|
-
// Audio
|
|
5
|
-
export * from '@/functions/audio/get-audio-data-classic'
|
|
6
|
-
export * from '@/functions/audio/get-audio-data-stream'
|
|
7
|
-
export * from '@/functions/audio/get-audio-mode'
|
|
8
|
-
export * from '@/functions/audio/set-audio-mode'
|
|
9
|
-
export * from '@/functions/audio/set-channel-mute-classic'
|
|
10
|
-
export * from '@/functions/audio/set-channel-mute-streamer'
|
|
11
|
-
export * from '@/functions/audio/set-channel-volume-classic'
|
|
12
|
-
export * from '@/functions/audio/set-channel-volume-streamer'
|
|
13
|
-
|
|
14
|
-
// Chatmix
|
|
15
|
-
export * from '@/functions/chatmix/get-chat-mix-state'
|
|
16
|
-
export * from '@/functions/chatmix/set-chat-mix-balance'
|
|
17
|
-
|
|
18
|
-
// Devices
|
|
19
|
-
export * from '@/functions/devices/get-audio-devices'
|
|
20
|
-
export * from '@/functions/devices/set-audio-device'
|
|
21
|
-
|
|
22
|
-
// Endpoint
|
|
23
|
-
export * from '@/functions/endpoint/get-app-endpoint'
|
|
24
|
-
export * from '@/functions/endpoint/get-sonar-endpoint'
|
|
25
|
-
export * from '@/functions/endpoint/get-sonar-endpoint-cached'
|
|
26
|
-
|
|
27
|
-
// Profile
|
|
28
|
-
export * from '@/functions/profile/get-channel-profiles'
|
|
29
|
-
export * from '@/functions/profile/get-selected-profiles'
|
|
30
|
-
export * from '@/functions/profile/set-selected-profile'
|
|
31
|
-
|
|
32
|
-
// Types
|
|
33
|
-
export * from '@/types/audio-device'
|
|
34
|
-
export * from '@/types/changed-device'
|
|
35
|
-
export * from '@/types/channel-volume-classic'
|
|
36
|
-
export * from '@/types/channel-volume-streamer'
|
|
37
|
-
export * from '@/types/channel-volume-streamer-path'
|
|
38
|
-
export * from '@/types/channel-volumes-classic'
|
|
39
|
-
export * from '@/types/channel-volumes-streamer'
|
|
40
|
-
export * from '@/types/chat-mix-data'
|
|
41
|
-
export * from '@/types/profile-option'
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { VolumeInfoClassic } from '@/sonar/models/audio-settings/volume-info-classic'
|
|
2
|
-
|
|
3
|
-
export type VolumeSettingsClassic = {
|
|
4
|
-
masters: {
|
|
5
|
-
classic: VolumeInfoClassic
|
|
6
|
-
}
|
|
7
|
-
devices: Record<
|
|
8
|
-
string,
|
|
9
|
-
{
|
|
10
|
-
classic: VolumeInfoClassic
|
|
11
|
-
}
|
|
12
|
-
>
|
|
13
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { VolumeInfoStreamer } from '@/sonar/models/audio-settings/volume-info-streamer'
|
|
2
|
-
|
|
3
|
-
export type VolumeSettingsStreamer = {
|
|
4
|
-
masters: {
|
|
5
|
-
stream: VolumeInfoStreamer
|
|
6
|
-
}
|
|
7
|
-
devices: Record<
|
|
8
|
-
string,
|
|
9
|
-
{
|
|
10
|
-
stream: VolumeInfoStreamer
|
|
11
|
-
}
|
|
12
|
-
>
|
|
13
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { DeviceDataFlow } from '@/sonar/models/audio-settings/enums/device-data-flow'
|
|
2
|
-
import type { DeviceDefaultRoles } from '@/sonar/models/audio-settings/enums/device-default-roles'
|
|
3
|
-
import type { DeviceRole } from '@/sonar/models/audio-settings/enums/device-role'
|
|
4
|
-
import type { DeviceState } from '@/sonar/models/audio-settings/enums/device-state'
|
|
5
|
-
|
|
6
|
-
export type AudioDevice = {
|
|
7
|
-
id: string
|
|
8
|
-
friendlyName: string
|
|
9
|
-
dataFlow: DeviceDataFlow
|
|
10
|
-
role: DeviceRole
|
|
11
|
-
channels: number
|
|
12
|
-
defaultRole: DeviceDefaultRoles
|
|
13
|
-
fwUpdateRequired: boolean
|
|
14
|
-
state: DeviceState
|
|
15
|
-
/** `true` if {@link DeviceRole} ≠ {@link DeviceRole.None} */
|
|
16
|
-
isVad: boolean
|
|
17
|
-
}
|