steelseries-sonar-sdk 0.3.3 → 0.3.5

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.
Files changed (2) hide show
  1. package/dist/index.js +50 -42
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -4915,6 +4915,46 @@ function convertVolumeToUser(value) {
4915
4915
  return result;
4916
4916
  }
4917
4917
 
4918
+ // src/sonar/requests/volume-settings/request-volume-settings-classic.ts
4919
+ async function requestVolumeSettingsClassic(sonarEndpoint) {
4920
+ let response;
4921
+ try {
4922
+ const url = new URL(`${sonarEndpoint}/volumeSettings/classic`);
4923
+ response = await fetch(url);
4924
+ } catch (error) {
4925
+ throw new SonarRequestException({ innerException: error });
4926
+ }
4927
+ if (response.ok) {
4928
+ const data = await response.json();
4929
+ if (data?.masters?.classic == null) {
4930
+ throw new SonarRequestException({ innerException: new Error("Missing required data in response.") });
4931
+ }
4932
+ return data;
4933
+ } else {
4934
+ const data = await response.json();
4935
+ throw new SonarRequestException({ innerException: new Error(data?.error ?? data) });
4936
+ }
4937
+ }
4938
+
4939
+ // src/functions/audio/get-audio-data-classic.ts
4940
+ async function getAudioDataClassic(sonarEndpoint) {
4941
+ const data = await requestVolumeSettingsClassic(sonarEndpoint);
4942
+ const volumeData = {
4943
+ ["master" /* Master */]: createResponseVolumeData(data.masters.classic),
4944
+ ["game" /* Game */]: data.devices.game && createResponseVolumeData(data.devices.game.classic),
4945
+ ["chat" /* Chat */]: data.devices.chatRender && createResponseVolumeData(data.devices.chatRender.classic),
4946
+ ["media" /* Media */]: data.devices.media && createResponseVolumeData(data.devices.media.classic),
4947
+ ["aux" /* Aux */]: data.devices.aux && createResponseVolumeData(data.devices.aux.classic),
4948
+ ["mic" /* Mic */]: data.devices.chatCapture && createResponseVolumeData(data.devices.chatCapture.classic)
4949
+ };
4950
+ return volumeData;
4951
+ }
4952
+ function createResponseVolumeData(volumeData) {
4953
+ return {
4954
+ volume: convertVolumeToUser(volumeData.volume),
4955
+ isMuted: volumeData.muted
4956
+ };
4957
+ }
4918
4958
  // src/functions/custom-fetch.ts
4919
4959
  import https2 from "node:https";
4920
4960
 
@@ -5838,7 +5878,7 @@ class AbortError extends FetchBaseError {
5838
5878
  init_esm_min();
5839
5879
  init_from();
5840
5880
  var supportedSchemas = new Set(["data:", "http:", "https:"]);
5841
- async function fetch(url, options_) {
5881
+ async function fetch2(url, options_) {
5842
5882
  return new Promise((resolve, reject) => {
5843
5883
  const request = new Request(url, options_);
5844
5884
  const { parsedURL, options } = getNodeRequestOptions(request);
@@ -5970,7 +6010,7 @@ async function fetch(url, options_) {
5970
6010
  if (responseReferrerPolicy) {
5971
6011
  requestOptions.referrerPolicy = responseReferrerPolicy;
5972
6012
  }
5973
- resolve(fetch(new Request(locationURL, requestOptions)));
6013
+ resolve(fetch2(new Request(locationURL, requestOptions)));
5974
6014
  finalize();
5975
6015
  return;
5976
6016
  }
@@ -6107,49 +6147,17 @@ var httpsAgent = new https2.Agent({
6107
6147
  rejectUnauthorized: false
6108
6148
  });
6109
6149
  async function customFetch(url, init) {
6110
- return await fetch(url, { ...init, agent: httpsAgent });
6111
- }
6112
-
6113
- // src/sonar/requests/volume-settings/request-volume-settings-classic.ts
6114
- async function requestVolumeSettingsClassic(sonarEndpoint) {
6115
- let response;
6116
- try {
6117
- const url = new URL(`${sonarEndpoint}/volumeSettings/classic`);
6118
- response = await customFetch(url);
6119
- } catch (error) {
6120
- throw new SonarRequestException({ innerException: error });
6121
- }
6122
- if (response.ok) {
6123
- const data = await response.json();
6124
- if (data?.masters?.classic == null) {
6125
- throw new SonarRequestException({ innerException: new Error("Missing required data in response.") });
6126
- }
6127
- return data;
6128
- } else {
6129
- const data = await response.json();
6130
- throw new SonarRequestException({ innerException: new Error(data?.error ?? data) });
6150
+ if (typeof Bun !== "undefined") {
6151
+ return await fetch(url.toString(), {
6152
+ method: init?.method,
6153
+ tls: {
6154
+ rejectUnauthorized: false
6155
+ }
6156
+ });
6131
6157
  }
6158
+ return await fetch2(url, { ...init, agent: httpsAgent });
6132
6159
  }
6133
6160
 
6134
- // src/functions/audio/get-audio-data-classic.ts
6135
- async function getAudioDataClassic(sonarEndpoint) {
6136
- const data = await requestVolumeSettingsClassic(sonarEndpoint);
6137
- const volumeData = {
6138
- ["master" /* Master */]: createResponseVolumeData(data.masters.classic),
6139
- ["game" /* Game */]: data.devices.game && createResponseVolumeData(data.devices.game.classic),
6140
- ["chat" /* Chat */]: data.devices.chatRender && createResponseVolumeData(data.devices.chatRender.classic),
6141
- ["media" /* Media */]: data.devices.media && createResponseVolumeData(data.devices.media.classic),
6142
- ["aux" /* Aux */]: data.devices.aux && createResponseVolumeData(data.devices.aux.classic),
6143
- ["mic" /* Mic */]: data.devices.chatCapture && createResponseVolumeData(data.devices.chatCapture.classic)
6144
- };
6145
- return volumeData;
6146
- }
6147
- function createResponseVolumeData(volumeData) {
6148
- return {
6149
- volume: convertVolumeToUser(volumeData.volume),
6150
- isMuted: volumeData.muted
6151
- };
6152
- }
6153
6161
  // src/sonar/requests/volume-settings/request-volume-settings-streamer.ts
6154
6162
  async function requestVolumeSettingsStreamer(sonarEndpoint) {
6155
6163
  let response;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "steelseries-sonar-sdk",
3
- "version": "0.3.3",
3
+ "version": "0.3.5",
4
4
  "description": "An SDK for interacting with the SteelSeries Sonar software.",
5
5
  "author": "Harley Torrisi <mail@harleycodes.com>",
6
6
  "license": "MIT",