steelseries-sonar-sdk 0.3.0 → 0.3.1

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 +330 -5
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -579,9 +579,334 @@ async function setAudioDevice(sonarEndpoint, deviceChannel, deviceId) {
579
579
  return result;
580
580
  }
581
581
  // src/functions/endpoint/get-app-endpoint.ts
582
- import { promises as fsAsync } from "node:fs";
583
- import { platform as getPlatform } from "node:os";
584
- import { join as joinPath } from "node:path";
582
+ var {promises: fsAsync} = (() => ({}));
583
+
584
+ // node:os
585
+ var platform = function() {
586
+ return "browser";
587
+ };
588
+
589
+ // node:path
590
+ function assertPath(path) {
591
+ if (typeof path !== "string")
592
+ throw new TypeError("Path must be a string. Received " + JSON.stringify(path));
593
+ }
594
+ function normalizeStringPosix(path, allowAboveRoot) {
595
+ var res = "", lastSegmentLength = 0, lastSlash = -1, dots = 0, code;
596
+ for (var i = 0;i <= path.length; ++i) {
597
+ if (i < path.length)
598
+ code = path.charCodeAt(i);
599
+ else if (code === 47)
600
+ break;
601
+ else
602
+ code = 47;
603
+ if (code === 47) {
604
+ if (lastSlash === i - 1 || dots === 1)
605
+ ;
606
+ else if (lastSlash !== i - 1 && dots === 2) {
607
+ if (res.length < 2 || lastSegmentLength !== 2 || res.charCodeAt(res.length - 1) !== 46 || res.charCodeAt(res.length - 2) !== 46) {
608
+ if (res.length > 2) {
609
+ var lastSlashIndex = res.lastIndexOf("/");
610
+ if (lastSlashIndex !== res.length - 1) {
611
+ if (lastSlashIndex === -1)
612
+ res = "", lastSegmentLength = 0;
613
+ else
614
+ res = res.slice(0, lastSlashIndex), lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
615
+ lastSlash = i, dots = 0;
616
+ continue;
617
+ }
618
+ } else if (res.length === 2 || res.length === 1) {
619
+ res = "", lastSegmentLength = 0, lastSlash = i, dots = 0;
620
+ continue;
621
+ }
622
+ }
623
+ if (allowAboveRoot) {
624
+ if (res.length > 0)
625
+ res += "/..";
626
+ else
627
+ res = "..";
628
+ lastSegmentLength = 2;
629
+ }
630
+ } else {
631
+ if (res.length > 0)
632
+ res += "/" + path.slice(lastSlash + 1, i);
633
+ else
634
+ res = path.slice(lastSlash + 1, i);
635
+ lastSegmentLength = i - lastSlash - 1;
636
+ }
637
+ lastSlash = i, dots = 0;
638
+ } else if (code === 46 && dots !== -1)
639
+ ++dots;
640
+ else
641
+ dots = -1;
642
+ }
643
+ return res;
644
+ }
645
+ function _format(sep, pathObject) {
646
+ var dir = pathObject.dir || pathObject.root, base = pathObject.base || (pathObject.name || "") + (pathObject.ext || "");
647
+ if (!dir)
648
+ return base;
649
+ if (dir === pathObject.root)
650
+ return dir + base;
651
+ return dir + sep + base;
652
+ }
653
+ function resolve() {
654
+ var resolvedPath = "", resolvedAbsolute = false, cwd;
655
+ for (var i = arguments.length - 1;i >= -1 && !resolvedAbsolute; i--) {
656
+ var path;
657
+ if (i >= 0)
658
+ path = arguments[i];
659
+ else {
660
+ if (cwd === undefined)
661
+ cwd = process.cwd();
662
+ path = cwd;
663
+ }
664
+ if (assertPath(path), path.length === 0)
665
+ continue;
666
+ resolvedPath = path + "/" + resolvedPath, resolvedAbsolute = path.charCodeAt(0) === 47;
667
+ }
668
+ if (resolvedPath = normalizeStringPosix(resolvedPath, !resolvedAbsolute), resolvedAbsolute)
669
+ if (resolvedPath.length > 0)
670
+ return "/" + resolvedPath;
671
+ else
672
+ return "/";
673
+ else if (resolvedPath.length > 0)
674
+ return resolvedPath;
675
+ else
676
+ return ".";
677
+ }
678
+ function normalize(path) {
679
+ if (assertPath(path), path.length === 0)
680
+ return ".";
681
+ var isAbsolute = path.charCodeAt(0) === 47, trailingSeparator = path.charCodeAt(path.length - 1) === 47;
682
+ if (path = normalizeStringPosix(path, !isAbsolute), path.length === 0 && !isAbsolute)
683
+ path = ".";
684
+ if (path.length > 0 && trailingSeparator)
685
+ path += "/";
686
+ if (isAbsolute)
687
+ return "/" + path;
688
+ return path;
689
+ }
690
+ function isAbsolute(path) {
691
+ return assertPath(path), path.length > 0 && path.charCodeAt(0) === 47;
692
+ }
693
+ function join() {
694
+ if (arguments.length === 0)
695
+ return ".";
696
+ var joined;
697
+ for (var i = 0;i < arguments.length; ++i) {
698
+ var arg = arguments[i];
699
+ if (assertPath(arg), arg.length > 0)
700
+ if (joined === undefined)
701
+ joined = arg;
702
+ else
703
+ joined += "/" + arg;
704
+ }
705
+ if (joined === undefined)
706
+ return ".";
707
+ return normalize(joined);
708
+ }
709
+ function relative(from, to) {
710
+ if (assertPath(from), assertPath(to), from === to)
711
+ return "";
712
+ if (from = resolve(from), to = resolve(to), from === to)
713
+ return "";
714
+ var fromStart = 1;
715
+ for (;fromStart < from.length; ++fromStart)
716
+ if (from.charCodeAt(fromStart) !== 47)
717
+ break;
718
+ var fromEnd = from.length, fromLen = fromEnd - fromStart, toStart = 1;
719
+ for (;toStart < to.length; ++toStart)
720
+ if (to.charCodeAt(toStart) !== 47)
721
+ break;
722
+ var toEnd = to.length, toLen = toEnd - toStart, length = fromLen < toLen ? fromLen : toLen, lastCommonSep = -1, i = 0;
723
+ for (;i <= length; ++i) {
724
+ if (i === length) {
725
+ if (toLen > length) {
726
+ if (to.charCodeAt(toStart + i) === 47)
727
+ return to.slice(toStart + i + 1);
728
+ else if (i === 0)
729
+ return to.slice(toStart + i);
730
+ } else if (fromLen > length) {
731
+ if (from.charCodeAt(fromStart + i) === 47)
732
+ lastCommonSep = i;
733
+ else if (i === 0)
734
+ lastCommonSep = 0;
735
+ }
736
+ break;
737
+ }
738
+ var fromCode = from.charCodeAt(fromStart + i), toCode = to.charCodeAt(toStart + i);
739
+ if (fromCode !== toCode)
740
+ break;
741
+ else if (fromCode === 47)
742
+ lastCommonSep = i;
743
+ }
744
+ var out = "";
745
+ for (i = fromStart + lastCommonSep + 1;i <= fromEnd; ++i)
746
+ if (i === fromEnd || from.charCodeAt(i) === 47)
747
+ if (out.length === 0)
748
+ out += "..";
749
+ else
750
+ out += "/..";
751
+ if (out.length > 0)
752
+ return out + to.slice(toStart + lastCommonSep);
753
+ else {
754
+ if (toStart += lastCommonSep, to.charCodeAt(toStart) === 47)
755
+ ++toStart;
756
+ return to.slice(toStart);
757
+ }
758
+ }
759
+ function _makeLong(path) {
760
+ return path;
761
+ }
762
+ function dirname(path) {
763
+ if (assertPath(path), path.length === 0)
764
+ return ".";
765
+ var code = path.charCodeAt(0), hasRoot = code === 47, end = -1, matchedSlash = true;
766
+ for (var i = path.length - 1;i >= 1; --i)
767
+ if (code = path.charCodeAt(i), code === 47) {
768
+ if (!matchedSlash) {
769
+ end = i;
770
+ break;
771
+ }
772
+ } else
773
+ matchedSlash = false;
774
+ if (end === -1)
775
+ return hasRoot ? "/" : ".";
776
+ if (hasRoot && end === 1)
777
+ return "//";
778
+ return path.slice(0, end);
779
+ }
780
+ function basename(path, ext) {
781
+ if (ext !== undefined && typeof ext !== "string")
782
+ throw new TypeError('"ext" argument must be a string');
783
+ assertPath(path);
784
+ var start = 0, end = -1, matchedSlash = true, i;
785
+ if (ext !== undefined && ext.length > 0 && ext.length <= path.length) {
786
+ if (ext.length === path.length && ext === path)
787
+ return "";
788
+ var extIdx = ext.length - 1, firstNonSlashEnd = -1;
789
+ for (i = path.length - 1;i >= 0; --i) {
790
+ var code = path.charCodeAt(i);
791
+ if (code === 47) {
792
+ if (!matchedSlash) {
793
+ start = i + 1;
794
+ break;
795
+ }
796
+ } else {
797
+ if (firstNonSlashEnd === -1)
798
+ matchedSlash = false, firstNonSlashEnd = i + 1;
799
+ if (extIdx >= 0)
800
+ if (code === ext.charCodeAt(extIdx)) {
801
+ if (--extIdx === -1)
802
+ end = i;
803
+ } else
804
+ extIdx = -1, end = firstNonSlashEnd;
805
+ }
806
+ }
807
+ if (start === end)
808
+ end = firstNonSlashEnd;
809
+ else if (end === -1)
810
+ end = path.length;
811
+ return path.slice(start, end);
812
+ } else {
813
+ for (i = path.length - 1;i >= 0; --i)
814
+ if (path.charCodeAt(i) === 47) {
815
+ if (!matchedSlash) {
816
+ start = i + 1;
817
+ break;
818
+ }
819
+ } else if (end === -1)
820
+ matchedSlash = false, end = i + 1;
821
+ if (end === -1)
822
+ return "";
823
+ return path.slice(start, end);
824
+ }
825
+ }
826
+ function extname(path) {
827
+ assertPath(path);
828
+ var startDot = -1, startPart = 0, end = -1, matchedSlash = true, preDotState = 0;
829
+ for (var i = path.length - 1;i >= 0; --i) {
830
+ var code = path.charCodeAt(i);
831
+ if (code === 47) {
832
+ if (!matchedSlash) {
833
+ startPart = i + 1;
834
+ break;
835
+ }
836
+ continue;
837
+ }
838
+ if (end === -1)
839
+ matchedSlash = false, end = i + 1;
840
+ if (code === 46) {
841
+ if (startDot === -1)
842
+ startDot = i;
843
+ else if (preDotState !== 1)
844
+ preDotState = 1;
845
+ } else if (startDot !== -1)
846
+ preDotState = -1;
847
+ }
848
+ if (startDot === -1 || end === -1 || preDotState === 0 || preDotState === 1 && startDot === end - 1 && startDot === startPart + 1)
849
+ return "";
850
+ return path.slice(startDot, end);
851
+ }
852
+ function format(pathObject) {
853
+ if (pathObject === null || typeof pathObject !== "object")
854
+ throw new TypeError('The "pathObject" argument must be of type Object. Received type ' + typeof pathObject);
855
+ return _format("/", pathObject);
856
+ }
857
+ function parse(path) {
858
+ assertPath(path);
859
+ var ret = { root: "", dir: "", base: "", ext: "", name: "" };
860
+ if (path.length === 0)
861
+ return ret;
862
+ var code = path.charCodeAt(0), isAbsolute2 = code === 47, start;
863
+ if (isAbsolute2)
864
+ ret.root = "/", start = 1;
865
+ else
866
+ start = 0;
867
+ var startDot = -1, startPart = 0, end = -1, matchedSlash = true, i = path.length - 1, preDotState = 0;
868
+ for (;i >= start; --i) {
869
+ if (code = path.charCodeAt(i), code === 47) {
870
+ if (!matchedSlash) {
871
+ startPart = i + 1;
872
+ break;
873
+ }
874
+ continue;
875
+ }
876
+ if (end === -1)
877
+ matchedSlash = false, end = i + 1;
878
+ if (code === 46) {
879
+ if (startDot === -1)
880
+ startDot = i;
881
+ else if (preDotState !== 1)
882
+ preDotState = 1;
883
+ } else if (startDot !== -1)
884
+ preDotState = -1;
885
+ }
886
+ if (startDot === -1 || end === -1 || preDotState === 0 || preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
887
+ if (end !== -1)
888
+ if (startPart === 0 && isAbsolute2)
889
+ ret.base = ret.name = path.slice(1, end);
890
+ else
891
+ ret.base = ret.name = path.slice(startPart, end);
892
+ } else {
893
+ if (startPart === 0 && isAbsolute2)
894
+ ret.name = path.slice(1, startDot), ret.base = path.slice(1, end);
895
+ else
896
+ ret.name = path.slice(startPart, startDot), ret.base = path.slice(startPart, end);
897
+ ret.ext = path.slice(startDot, end);
898
+ }
899
+ if (startPart > 0)
900
+ ret.dir = path.slice(0, startPart - 1);
901
+ else if (isAbsolute2)
902
+ ret.dir = "/";
903
+ return ret;
904
+ }
905
+ var sep = "/";
906
+ var delimiter = ":";
907
+ var posix = ((p) => (p.posix = p, p))({ resolve, normalize, isAbsolute, join, relative, _makeLong, dirname, basename, extname, format, parse, sep, delimiter, win32: null, posix: null });
908
+
909
+ // src/functions/endpoint/get-app-endpoint.ts
585
910
  var WINDOWS_PATHS = ["SteelSeries", "SteelSeries Engine 3", "coreProps.json"];
586
911
  async function getAppEndpoint() {
587
912
  const appDataPath = getPath();
@@ -595,11 +920,11 @@ async function getAppEndpoint() {
595
920
  });
596
921
  }
597
922
  function getPath() {
598
- const os = getPlatform();
923
+ const os = platform();
599
924
  switch (os) {
600
925
  case "win32": {
601
926
  const programData = process.env.ProgramData ?? "C:\\ProgramData";
602
- return joinPath(programData, ...WINDOWS_PATHS);
927
+ return join(programData, ...WINDOWS_PATHS);
603
928
  }
604
929
  default:
605
930
  throw new SonarInitializationException({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "steelseries-sonar-sdk",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "An SDK for interacting with the SteelSeries Sonar software.",
5
5
  "author": "Harley Torrisi <mail@harleycodes.com>",
6
6
  "license": "MIT",
@@ -34,6 +34,6 @@
34
34
  "package": "bun package:clean && bun package:declarations && bun package:src",
35
35
  "package:clean": "rimraf dist",
36
36
  "package:declarations": "bunx tsc --emitDeclarationOnly --outDir dist -p tsconfig.build.json",
37
- "package:src": "bun build src/index.ts --outdir dist --target=node"
37
+ "package:src": "bun build src/index.ts --outdir dist"
38
38
  }
39
39
  }