systeminformation 6.0.0-beta.2 → 6.0.0-beta.21

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 (139) hide show
  1. package/README.md +67 -18
  2. package/dist/bsd/mem.js +8 -3
  3. package/dist/bsd/network-stats.d.ts +1 -1
  4. package/dist/bsd/network-stats.js +14 -7
  5. package/dist/bsd/os-info.d.ts +1 -0
  6. package/dist/common/darwin.d.ts +2 -0
  7. package/dist/common/darwin.js +17 -1
  8. package/dist/common/defaults.d.ts +2 -1
  9. package/dist/common/defaults.js +36 -6
  10. package/dist/common/exec.js +29 -13
  11. package/dist/common/files.d.ts +9 -0
  12. package/dist/common/files.js +67 -3
  13. package/dist/common/filesys.d.ts +30 -0
  14. package/dist/common/filesys.js +228 -11
  15. package/dist/common/host.js +55 -3
  16. package/dist/common/internet.js +31 -20
  17. package/dist/common/mappings.d.ts +0 -3
  18. package/dist/common/mappings.js +35 -14
  19. package/dist/common/network.d.ts +15 -2
  20. package/dist/common/network.js +18 -22
  21. package/dist/common/nvidia.d.ts +1 -1
  22. package/dist/common/nvidia.js +4 -5
  23. package/dist/common/parse.d.ts +4 -6
  24. package/dist/common/parse.js +24 -69
  25. package/dist/common/security.d.ts +2 -0
  26. package/dist/common/security.js +18 -3
  27. package/dist/common/types.d.ts +53 -5
  28. package/dist/common/windows.d.ts +4 -0
  29. package/dist/common/windows.js +57 -1
  30. package/dist/cpu-current-load.d.ts +1 -0
  31. package/dist/cpu-current-load.js +54 -8
  32. package/dist/cpu-current-speed.js +5 -3
  33. package/dist/darwin/battery.d.ts +1 -1
  34. package/dist/darwin/battery.js +15 -5
  35. package/dist/darwin/camera.js +3 -3
  36. package/dist/darwin/disk-layout.js +16 -12
  37. package/dist/darwin/disks-io.js +3 -3
  38. package/dist/darwin/displays.d.ts +1 -0
  39. package/dist/darwin/displays.js +64 -2
  40. package/dist/darwin/fans.d.ts +2 -0
  41. package/dist/darwin/fans.js +28 -0
  42. package/dist/darwin/gpu.js +1 -1
  43. package/dist/darwin/index.d.ts +3 -0
  44. package/dist/darwin/index.js +8 -2
  45. package/dist/darwin/keyboard.js +4 -4
  46. package/dist/darwin/mouse.js +4 -4
  47. package/dist/darwin/network-interfaces.d.ts +3 -0
  48. package/dist/darwin/network-interfaces.js +81 -14
  49. package/dist/darwin/network-stats.d.ts +1 -1
  50. package/dist/darwin/network-stats.js +14 -7
  51. package/dist/darwin/os-info.d.ts +2 -0
  52. package/dist/darwin/os-info.js +24 -2
  53. package/dist/darwin/process-focused.d.ts +3 -0
  54. package/dist/darwin/process-focused.js +26 -0
  55. package/dist/darwin/serial-ports.d.ts +2 -0
  56. package/dist/darwin/serial-ports.js +94 -0
  57. package/dist/darwin/users.js +1 -1
  58. package/dist/docker.js +4 -5
  59. package/dist/fans.d.ts +1 -0
  60. package/dist/fans.js +17 -0
  61. package/dist/get-data.d.ts +4 -0
  62. package/dist/get-data.js +6 -2
  63. package/dist/get.js +6 -1
  64. package/dist/index.d.ts +3 -0
  65. package/dist/index.js +8 -2
  66. package/dist/inet-public-ip.js +2 -1
  67. package/dist/linux/audio.js +59 -0
  68. package/dist/linux/baseboard.js +9 -20
  69. package/dist/linux/bios.js +6 -15
  70. package/dist/linux/block-devices.js +3 -1
  71. package/dist/linux/camera.js +2 -1
  72. package/dist/linux/chassis.js +4 -10
  73. package/dist/linux/cpu-temperature.js +34 -19
  74. package/dist/linux/cpu.js +3 -1
  75. package/dist/linux/disk-layout.js +9 -12
  76. package/dist/linux/disks-io.js +9 -9
  77. package/dist/linux/displays.d.ts +8 -0
  78. package/dist/linux/displays.js +151 -4
  79. package/dist/linux/fans.d.ts +2 -0
  80. package/dist/linux/fans.js +92 -0
  81. package/dist/linux/fs-size.d.ts +1 -1
  82. package/dist/linux/fs-size.js +164 -37
  83. package/dist/linux/fs-stats.js +6 -9
  84. package/dist/linux/gpu.d.ts +2 -0
  85. package/dist/linux/gpu.js +97 -22
  86. package/dist/linux/index.d.ts +3 -0
  87. package/dist/linux/index.js +8 -2
  88. package/dist/linux/mem-layout.js +3 -7
  89. package/dist/linux/mem.d.ts +1 -0
  90. package/dist/linux/mem.js +21 -1
  91. package/dist/linux/network-interfaces.d.ts +1 -0
  92. package/dist/linux/network-interfaces.js +154 -113
  93. package/dist/linux/network-stats.d.ts +1 -1
  94. package/dist/linux/network-stats.js +14 -40
  95. package/dist/linux/npu.js +2 -1
  96. package/dist/linux/os-info.js +56 -5
  97. package/dist/linux/printer.js +4 -4
  98. package/dist/linux/process-focused.d.ts +4 -0
  99. package/dist/linux/process-focused.js +32 -0
  100. package/dist/linux/process-load.js +11 -13
  101. package/dist/linux/processes.js +89 -80
  102. package/dist/linux/serial-ports.d.ts +2 -0
  103. package/dist/linux/serial-ports.js +102 -0
  104. package/dist/linux/services.js +182 -49
  105. package/dist/linux/system.js +1 -7
  106. package/dist/linux/users.js +1 -1
  107. package/dist/linux/uuid.js +4 -10
  108. package/dist/linux/wifi-networks.js +2 -2
  109. package/dist/network-interfaces.js +1 -1
  110. package/dist/observe.d.ts +1 -1
  111. package/dist/observe.js +5 -1
  112. package/dist/process-focused.d.ts +1 -0
  113. package/dist/process-focused.js +17 -0
  114. package/dist/serial-ports.d.ts +1 -0
  115. package/dist/serial-ports.js +17 -0
  116. package/dist/versions.js +34 -80
  117. package/dist/windows/audio.d.ts +29 -0
  118. package/dist/windows/audio.js +151 -11
  119. package/dist/windows/disk-layout.js +3 -0
  120. package/dist/windows/disks-io.js +3 -3
  121. package/dist/windows/displays.d.ts +5 -0
  122. package/dist/windows/displays.js +101 -16
  123. package/dist/windows/fans.d.ts +2 -0
  124. package/dist/windows/fans.js +71 -0
  125. package/dist/windows/fs-size.js +1 -4
  126. package/dist/windows/gpu.js +3 -2
  127. package/dist/windows/index.d.ts +3 -0
  128. package/dist/windows/index.js +8 -2
  129. package/dist/windows/network-interfaces.js +36 -41
  130. package/dist/windows/network-stats.js +20 -6
  131. package/dist/windows/process-focused.d.ts +3 -0
  132. package/dist/windows/process-focused.js +36 -0
  133. package/dist/windows/process-load.js +7 -5
  134. package/dist/windows/processes.d.ts +1 -0
  135. package/dist/windows/processes.js +54 -26
  136. package/dist/windows/serial-ports.d.ts +3 -0
  137. package/dist/windows/serial-ports.js +73 -0
  138. package/dist/windows/services.js +4 -1
  139. package/package.json +1 -1
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.calcNetworkSpeed = exports.testVirtualNic = exports.getFirstExternalNetworkInterface = exports.wifiChannelFromFrequencies = exports.wifiFrequencyFromChannel = exports.wifiQualityFromDB = exports.wifiDBFromQuality = void 0;
4
- const defaults_1 = require("./defaults");
3
+ exports.filterDefaultInterface = exports.calcNetworkSpeed = exports.testVirtualNic = exports.getFirstExternalNetworkInterface = exports.wifiChannelFromFrequencies = exports.wifiFrequencyFromChannel = exports.wifiQualityFromDB = exports.wifiDBFromQuality = void 0;
5
4
  const index_1 = require("./index");
6
5
  const mappings_1 = require("./mappings");
7
6
  const wifiDBFromQuality = (quality) => {
@@ -104,8 +103,8 @@ const testVirtualNic = (iface, ifaceName, mac) => {
104
103
  }
105
104
  };
106
105
  exports.testVirtualNic = testVirtualNic;
107
- const calcNetworkSpeed = (iface, rx_bytes, tx_bytes, rx_dropped, rx_errors, tx_dropped, tx_errors, operstate, _network) => {
108
- const result = (0, index_1.cloneObj)(defaults_1.initNetworkSpeed);
106
+ const calcNetworkSpeed = (counters, _network) => {
107
+ const { iface, rx_bytes, tx_bytes, rx_packets, tx_packets, rx_dropped, rx_errors, tx_dropped, tx_errors, operstate } = counters;
109
108
  let rx_sec = null;
110
109
  let tx_sec = null;
111
110
  let rx_bytes_intervall = 0;
@@ -117,41 +116,36 @@ const calcNetworkSpeed = (iface, rx_bytes, tx_bytes, rx_dropped, rx_errors, tx_d
117
116
  tx_bytes_intervall = tx_bytes - _network[iface].tx_bytes;
118
117
  rx_sec = rx_bytes_intervall >= 0 ? rx_bytes_intervall / (ms / 1000) : 0;
119
118
  tx_sec = tx_bytes_intervall >= 0 ? tx_bytes_intervall / (ms / 1000) : 0;
120
- _network[iface].rx_bytes = rx_bytes;
121
- _network[iface].tx_bytes = tx_bytes;
122
119
  _network[iface].rx_sec = rx_sec;
123
120
  _network[iface].tx_sec = tx_sec;
124
- _network[iface].rx_dropped = rx_dropped;
125
- _network[iface].rx_errors = rx_errors;
126
- _network[iface].tx_dropped = tx_dropped;
127
- _network[iface].tx_errors = tx_errors;
128
- _network[iface].ms = Date.now();
129
- _network[iface].last_ms = result.ms;
130
- _network[iface].operstate = operstate;
131
121
  }
132
122
  else {
133
123
  if (!_network[iface]) {
134
124
  _network[iface] = {};
135
125
  }
136
- _network[iface].rx_bytes = rx_bytes;
137
- _network[iface].tx_bytes = tx_bytes;
138
126
  _network[iface].rx_sec = null;
139
127
  _network[iface].tx_sec = null;
140
- _network[iface].rx_dropped = result.rx_dropped;
141
- _network[iface].rx_errors = result.rx_errors;
142
- _network[iface].tx_dropped = result.tx_dropped;
143
- _network[iface].tx_errors = result.tx_errors;
144
- _network[iface].ms = Date.now();
145
- _network[iface].last_ms = 0;
146
- _network[iface].operstate = operstate;
147
128
  }
129
+ _network[iface].last_ms = ms;
130
+ _network[iface].rx_bytes = rx_bytes;
131
+ _network[iface].tx_bytes = tx_bytes;
132
+ _network[iface].rx_packets = rx_packets;
133
+ _network[iface].tx_packets = tx_packets;
134
+ _network[iface].rx_dropped = rx_dropped;
135
+ _network[iface].rx_errors = rx_errors;
136
+ _network[iface].tx_dropped = tx_dropped;
137
+ _network[iface].tx_errors = tx_errors;
138
+ _network[iface].ms = Date.now();
139
+ _network[iface].operstate = operstate;
148
140
  return {
149
141
  iface,
150
142
  operstate,
151
143
  rx_bytes,
144
+ rx_packets,
152
145
  rx_dropped,
153
146
  rx_errors,
154
147
  tx_bytes,
148
+ tx_packets,
155
149
  tx_dropped,
156
150
  tx_errors,
157
151
  rx_sec,
@@ -160,3 +154,5 @@ const calcNetworkSpeed = (iface, rx_bytes, tx_bytes, rx_dropped, rx_errors, tx_d
160
154
  };
161
155
  };
162
156
  exports.calcNetworkSpeed = calcNetworkSpeed;
157
+ const filterDefaultInterface = (interfaces, defaultString) => defaultString.toLowerCase().indexOf('default') >= 0 ? interfaces.filter((item) => item.default).slice(0, 1) : interfaces.slice();
158
+ exports.filterDefaultInterface = filterDefaultInterface;
@@ -1,5 +1,5 @@
1
1
  import type { GpuData, GpuNvidiaData } from './types';
2
- export declare const getNvidiaSmi: () => Promise<string | null>;
2
+ export declare const getNvidiaSmi: () => Promise<string>;
3
3
  export declare const nvidiaSmi: () => Promise<string>;
4
4
  export declare const nvidiaDevices: () => Promise<({
5
5
  driverVersion: string | undefined;
@@ -22,7 +22,7 @@ const getNvidiaSmi = async () => {
22
22
  const basePath = String.raw `${const_1.WINDIR}\System32\DriverStore\FileRepository`;
23
23
  let lastMod = 0;
24
24
  for (const dir of await (0, promises_1.readdir)(basePath)) {
25
- if (!dir.toLowerCase().startsWith('nv')) {
25
+ if (!dir.toLowerCase().startsWith('nv') || !(0, security_1.isSafePathSegment)(dir)) {
26
26
  continue;
27
27
  }
28
28
  const smiPath = [basePath, dir, 'nvidia-smi.exe'].join('\\');
@@ -41,6 +41,7 @@ const getNvidiaSmi = async () => {
41
41
  else if (const_1.LINUX) {
42
42
  _nvidiaSmiPath = 'nvidia-smi';
43
43
  }
44
+ _nvidiaSmiPath = _nvidiaSmiPath || '';
44
45
  return _nvidiaSmiPath;
45
46
  };
46
47
  exports.getNvidiaSmi = getNvidiaSmi;
@@ -48,11 +49,9 @@ const nvidiaSmi = async () => {
48
49
  const nvidiaSmiExe = await (0, exports.getNvidiaSmi)();
49
50
  if (nvidiaSmiExe) {
50
51
  const nvidiaSmiOpts = '--query-gpu=driver_version,pci.sub_device_id,name,pci.bus_id,fan.speed,memory.total,memory.used,memory.free,utilization.gpu,utilization.memory,temperature.gpu,temperature.memory,power.draw,power.limit,clocks.gr,clocks.mem --format=csv,noheader,nounits';
51
- const cmd = `${nvidiaSmiExe} ${nvidiaSmiOpts}`;
52
52
  try {
53
- const sanitized = (0, security_1.sanitizeShellString)(cmd) + (const_1.LINUX ? ' 2>/dev/null' : '') + (const_1.WINDOWS ? ' 2> nul' : '');
54
- const { stdout } = await (0, exec_1.exec)(sanitized, const_1.execOptsWin);
55
- return stdout;
53
+ const { stdout } = await (0, exec_1.execFile)(nvidiaSmiExe, nvidiaSmiOpts.split(' '), const_1.execOptsWin);
54
+ return String(stdout);
56
55
  }
57
56
  catch { }
58
57
  }
@@ -1,11 +1,9 @@
1
1
  import type { CpuData, ProcStatData } from './types';
2
- export type headerType = {
3
- from: number;
4
- to: number;
5
- cap: string;
6
- };
7
- export declare const parseHead: (head: string, rights: number) => headerType[];
8
2
  export declare const parseProcStat: (line: string) => number;
3
+ export declare const clampCpuPair: (cpuu: number, cpus: number) => {
4
+ cpuu: number;
5
+ cpus: number;
6
+ };
9
7
  export declare const calcProcStatLinux: (line: string, all: number, _cpu_old: CpuData) => ProcStatData;
10
8
  export declare const parseJsonArray: (data: string) => any[];
11
9
  export declare const cleanDefaults: (str: string) => string;
@@ -1,63 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.splitByNumber = exports.kFactor = exports.cleanDefaults = exports.parseJsonArray = exports.calcProcStatLinux = exports.parseProcStat = exports.parseHead = void 0;
3
+ exports.splitByNumber = exports.kFactor = exports.cleanDefaults = exports.parseJsonArray = exports.calcProcStatLinux = exports.clampCpuPair = exports.parseProcStat = void 0;
4
4
  const index_1 = require("./index");
5
- const parseHead = (head, rights) => {
6
- let space = rights > 0;
7
- let count = 1;
8
- let from = 0;
9
- let to = 0;
10
- const result = [];
11
- for (let i = 0; i < head.length; i++) {
12
- if (count <= rights) {
13
- if (/\s/.test(head[i]) && !space) {
14
- to = i - 1;
15
- result.push({
16
- from: from,
17
- to: to + 1,
18
- cap: head.substring(from, to + 1)
19
- });
20
- from = to + 2;
21
- count++;
22
- }
23
- space = head[i] === ' ';
24
- }
25
- else {
26
- if (!/\s/.test(head[i]) && space) {
27
- to = i - 1;
28
- if (from < to) {
29
- result.push({
30
- from: from,
31
- to: to,
32
- cap: head.substring(from, to)
33
- });
34
- }
35
- from = to + 1;
36
- count++;
37
- }
38
- space = head[i] === ' ';
39
- }
40
- }
41
- to = 5000;
42
- result.push({
43
- from: from,
44
- to: to,
45
- cap: head.substring(from, to)
46
- });
47
- let len = result.length;
48
- for (let i = 0; i < len; i++) {
49
- if (result[i].cap.replace(/\s/g, '').length === 0) {
50
- if (i + 1 < len) {
51
- result[i].to = result[i + 1].to;
52
- result[i].cap = result[i].cap + result[i + 1].cap;
53
- result.splice(i + 1, 1);
54
- len = len - 1;
55
- }
56
- }
57
- }
58
- return result;
59
- };
60
- exports.parseHead = parseHead;
61
5
  const parseProcStat = (line) => {
62
6
  const parts = line.replace(/ +/g, ' ').split(' ');
63
7
  const user = parts.length >= 2 ? (0, index_1.toInt)(parts[1]) : 0;
@@ -73,6 +17,21 @@ const parseProcStat = (line) => {
73
17
  return user + nice + system + idle + iowait + irq + softirq + steal + guest + guest_nice;
74
18
  };
75
19
  exports.parseProcStat = parseProcStat;
20
+ const clampCpuPair = (cpuu, cpus) => {
21
+ if (!Number.isFinite(cpuu) || cpuu < 0) {
22
+ cpuu = 0;
23
+ }
24
+ if (!Number.isFinite(cpus) || cpus < 0) {
25
+ cpus = 0;
26
+ }
27
+ const total = cpuu + cpus;
28
+ if (total > 100) {
29
+ cpuu = (cpuu / total) * 100;
30
+ cpus = (cpus / total) * 100;
31
+ }
32
+ return { cpuu, cpus };
33
+ };
34
+ exports.clampCpuPair = clampCpuPair;
76
35
  const calcProcStatLinux = (line, all, _cpu_old) => {
77
36
  const statparts = line.replace(/ +/g, ' ').split(')');
78
37
  if (statparts.length >= 2) {
@@ -81,27 +40,25 @@ const calcProcStatLinux = (line, all, _cpu_old) => {
81
40
  const pid = (0, index_1.toInt)(statparts[0].split(' ')[0]);
82
41
  const utime = (0, index_1.toInt)(parts[12]);
83
42
  const stime = (0, index_1.toInt)(parts[13]);
84
- const cutime = (0, index_1.toInt)(parts[14]);
85
- const cstime = (0, index_1.toInt)(parts[15]);
86
43
  let cpuu = 0;
87
44
  let cpus = 0;
88
45
  if (_cpu_old.all > 0 && _cpu_old.list[pid]) {
89
- cpuu = ((utime + cutime - _cpu_old.list[pid].utime - _cpu_old.list[pid].cutime) / (all - _cpu_old.all)) * 100;
90
- cpus = ((stime + cstime - _cpu_old.list[pid].stime - _cpu_old.list[pid].cstime) / (all - _cpu_old.all)) * 100;
46
+ const delta = all - _cpu_old.all;
47
+ cpuu = delta > 0 ? ((utime - _cpu_old.list[pid].utime) / delta) * 100 : 0;
48
+ cpus = delta > 0 ? ((stime - _cpu_old.list[pid].stime) / delta) * 100 : 0;
91
49
  }
92
50
  else {
93
- cpuu = ((utime + cutime) / all) * 100;
94
- cpus = ((stime + cstime) / all) * 100;
51
+ cpuu = all > 0 ? (utime / all) * 100 : 0;
52
+ cpus = all > 0 ? (stime / all) * 100 : 0;
95
53
  }
54
+ const clamped = (0, exports.clampCpuPair)(cpuu, cpus);
96
55
  return {
97
56
  pid: pid,
98
57
  name: '',
99
58
  utime: utime,
100
59
  stime: stime,
101
- cutime: cutime,
102
- cstime: cstime,
103
- cpuu: cpuu,
104
- cpus: cpus
60
+ cpuu: clamped.cpuu,
61
+ cpus: clamped.cpus
105
62
  };
106
63
  }
107
64
  }
@@ -110,8 +67,6 @@ const calcProcStatLinux = (line, all, _cpu_old) => {
110
67
  name: '',
111
68
  utime: 0,
112
69
  stime: 0,
113
- cutime: 0,
114
- cstime: 0,
115
70
  cpuu: 0,
116
71
  cpus: 0
117
72
  };
@@ -22,6 +22,8 @@ export declare const stringSplit: {
22
22
  export declare const stringStartWith: (searchString: string, position?: number) => boolean;
23
23
  export declare const mathMin: (...values: number[]) => number;
24
24
  export declare const sanitizeShellString: (str: string, strict?: any) => string;
25
+ export declare const isSafePathSegment: (segment: string) => boolean;
26
+ export declare const sanitizeDriveLetter: (str: string) => string;
25
27
  export declare const sanitizeContainerID: (str: string) => string;
26
28
  export declare const sanitizeImageID: (str: string) => string;
27
29
  export declare const isPrototypePolluted: () => boolean;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.sanitizeString = exports.sanitizeInterfacesString = exports.sanitizeServiceString = exports.sanitizeUrl = exports.isPrototypePolluted = exports.sanitizeImageID = exports.sanitizeContainerID = exports.sanitizeShellString = exports.mathMin = exports.stringStartWith = exports.stringSplit = exports.stringTrim = exports.stringSubstring = exports.stringSubstr = exports.stringToString = exports.stringToLower = exports.stringReplace = void 0;
3
+ exports.sanitizeString = exports.sanitizeInterfacesString = exports.sanitizeServiceString = exports.sanitizeUrl = exports.isPrototypePolluted = exports.sanitizeImageID = exports.sanitizeContainerID = exports.sanitizeDriveLetter = exports.isSafePathSegment = exports.sanitizeShellString = exports.mathMin = exports.stringStartWith = exports.stringSplit = exports.stringTrim = exports.stringSubstring = exports.stringSubstr = exports.stringToString = exports.stringToLower = exports.stringReplace = void 0;
4
4
  exports.stringReplace = new String().replace;
5
5
  exports.stringToLower = new String().toLowerCase;
6
6
  exports.stringToString = new String().toString;
@@ -42,6 +42,8 @@ const sanitizeShellString = (str, strict) => {
42
42
  s[i] === "'" ||
43
43
  s[i] === '`' ||
44
44
  s[i] === '"' ||
45
+ (s[i] >= '‘' && s[i] <= '„') ||
46
+ (s[i] >= '–' && s[i] <= '―') ||
45
47
  s[i].length > 1 ||
46
48
  (strict && s[i] === '(') ||
47
49
  (strict && s[i] === ')') ||
@@ -56,6 +58,17 @@ const sanitizeShellString = (str, strict) => {
56
58
  return result;
57
59
  };
58
60
  exports.sanitizeShellString = sanitizeShellString;
61
+ const isSafePathSegment = (segment) => !!segment && segment.indexOf('/') === -1 && segment.indexOf('\0') === -1 && segment !== '.' && segment !== '..';
62
+ exports.isSafePathSegment = isSafePathSegment;
63
+ const sanitizeDriveLetter = (str) => {
64
+ const value = String(str || '');
65
+ if (value.length > 2000) {
66
+ return '';
67
+ }
68
+ const match = /^\s*([a-zA-Z]):?[\\/]?\s*$/.exec(value);
69
+ return match ? `${match[1]}:` : '';
70
+ };
71
+ exports.sanitizeDriveLetter = sanitizeDriveLetter;
59
72
  const sanitizeContainerID = (str) => {
60
73
  const s = String(str || '')
61
74
  .substring(0, 2000)
@@ -149,7 +162,8 @@ const sanitizeUrl = (url) => {
149
162
  }
150
163
  if (urlSanitized && !(0, exports.isPrototypePolluted)()) {
151
164
  Object.setPrototypeOf(urlSanitized, { startsWith: exports.stringStartWith });
152
- if (urlSanitized.startsWith('file:') ||
165
+ if (urlSanitized.startsWith('-') ||
166
+ urlSanitized.startsWith('file:') ||
153
167
  urlSanitized.startsWith('gopher:') ||
154
168
  urlSanitized.startsWith('telnet:') ||
155
169
  urlSanitized.startsWith('mailto:') ||
@@ -208,7 +222,8 @@ const sanitizeInterfacesString = (interfaces) => {
208
222
  startsWith: exports.stringStartWith
209
223
  });
210
224
  interfacesSanitized = interfacesSanitized.trim().replace(/,+/g, '|');
211
- return interfacesSanitized;
225
+ const kept = interfacesSanitized.split('|').filter((part) => part && !/^\s*-/.test(part));
226
+ return kept.length ? kept.join('|') : '-';
212
227
  };
213
228
  exports.sanitizeInterfacesString = sanitizeInterfacesString;
214
229
  const sanitizeString = (str, strict) => {
@@ -321,6 +321,24 @@ export type CpuTemperatureObject = {
321
321
  socket: number[];
322
322
  chipset: number | null;
323
323
  };
324
+ export type FanData = {
325
+ id: string;
326
+ label: string | null;
327
+ rpm: number | null;
328
+ pwm: number | null;
329
+ source: string;
330
+ };
331
+ export type SerialPortType = 'usb' | 'onboard' | 'pci' | 'bluetooth' | 'virtual' | 'unknown';
332
+ export type SerialPortData = {
333
+ device: string;
334
+ name: string | null;
335
+ manufacturer: string | null;
336
+ serialNumber: string | null;
337
+ vendorId: string | null;
338
+ productId: string | null;
339
+ pnpId: string | null;
340
+ type: SerialPortType;
341
+ };
324
342
  export type CurrentLoadData = {
325
343
  avgLoad: number;
326
344
  currentLoad: number;
@@ -328,6 +346,7 @@ export type CurrentLoadData = {
328
346
  currentLoadSystem: number;
329
347
  currentLoadNice: number;
330
348
  currentLoadIdle: number;
349
+ currentLoadIowait: number;
331
350
  currentLoadIrq: number;
332
351
  currentLoadSteal: number;
333
352
  currentLoadGuest: number;
@@ -336,6 +355,7 @@ export type CurrentLoadData = {
336
355
  rawCurrentLoadSystem: number;
337
356
  rawCurrentLoadNice: number;
338
357
  rawCurrentLoadIdle: number;
358
+ rawCurrentLoadIowait: number;
339
359
  rawCurrentLoadIrq: number;
340
360
  rawCurrentLoadSteal: number;
341
361
  rawCurrentLoadGuest: number;
@@ -347,12 +367,14 @@ export type CurrentLoadCpuData = {
347
367
  loadSystem: number;
348
368
  loadNice: number;
349
369
  loadIdle: number;
370
+ loadIowait: number;
350
371
  loadIrq: number;
351
372
  rawLoad: number;
352
373
  rawLoadUser: number;
353
374
  rawLoadSystem: number;
354
375
  rawLoadNice: number;
355
376
  rawLoadIdle: number;
377
+ rawLoadIowait: number;
356
378
  rawLoadIrq: number;
357
379
  };
358
380
  export type WifiNetworkData = {
@@ -442,6 +464,12 @@ export type MemLayoutData = {
442
464
  voltageMin: number | null;
443
465
  voltageMax: number | null;
444
466
  };
467
+ export type OsSecurityData = {
468
+ module: string;
469
+ enabled: boolean;
470
+ mode: string;
471
+ policy: string;
472
+ };
445
473
  export type OsData = {
446
474
  platform: string;
447
475
  distro: string;
@@ -462,6 +490,7 @@ export type OsData = {
462
490
  displayServer: string;
463
491
  awake: boolean;
464
492
  hwAcceleration: string[];
493
+ security: OsSecurityData;
465
494
  hypervizor?: boolean;
466
495
  remoteSession?: boolean;
467
496
  hypervisor?: boolean;
@@ -629,9 +658,9 @@ export type DisksIoData = {
629
658
  rIO_sec: number | null;
630
659
  wIO_sec: number | null;
631
660
  tIO_sec: number | null;
632
- rWaitTime: number;
633
- wWaitTime: number;
634
- tWaitTime: number;
661
+ rWaitTime: number | null;
662
+ wWaitTime: number | null;
663
+ tWaitTime: number | null;
635
664
  rWaitPercent: number | null;
636
665
  wWaitPercent: number | null;
637
666
  tWaitPercent: number | null;
@@ -811,6 +840,7 @@ export type DisplayData = {
811
840
  deviceName: string | null;
812
841
  displayId: string | null;
813
842
  main: boolean;
843
+ mirror: boolean;
814
844
  builtin: boolean;
815
845
  connection: string | null;
816
846
  sizeX: number | null;
@@ -822,7 +852,15 @@ export type DisplayData = {
822
852
  currentResY: number | null;
823
853
  positionX: number;
824
854
  positionY: number;
855
+ workAreaResolutionX: number | null;
856
+ workAreaResolutionY: number | null;
857
+ workAreaPositionX: number | null;
858
+ workAreaPositionY: number | null;
825
859
  currentRefreshRate: number | null;
860
+ scale: number | null;
861
+ powerState: string;
862
+ gpu: string;
863
+ gpuBusAddress: string;
826
864
  };
827
865
  export type GpuNvidiaData = {
828
866
  driverVersion: string;
@@ -847,8 +885,6 @@ export type ProcStatData = {
847
885
  name: string;
848
886
  utime: number;
849
887
  stime: number;
850
- cutime?: number;
851
- cstime?: number;
852
888
  cpu?: number;
853
889
  cpuu: number;
854
890
  cpus: number;
@@ -866,6 +902,7 @@ export type ServicesData = {
866
902
  name: string;
867
903
  running: boolean;
868
904
  startmode: string;
905
+ lastChanged: Date | null;
869
906
  pids: number[];
870
907
  cpu: number;
871
908
  mem: number;
@@ -884,6 +921,7 @@ export type ProcessesProcessData = {
884
921
  cpu: number;
885
922
  cpuu: number;
886
923
  cpus: number;
924
+ cpuTime: number | null;
887
925
  mem: number;
888
926
  priority: number;
889
927
  memVsz: number;
@@ -905,6 +943,11 @@ export type ProcessesData = {
905
943
  unknown: number;
906
944
  list: ProcessesProcessData[];
907
945
  };
946
+ export type ProcessFocusedData = {
947
+ pid: number;
948
+ name: string;
949
+ path: string;
950
+ };
908
951
  export type ProcessLoadData = {
909
952
  proc: string;
910
953
  pid: number | null;
@@ -915,11 +958,14 @@ export type ProcessLoadData = {
915
958
  export type NetworkInterfacesData = {
916
959
  iface: string;
917
960
  ifaceName: string;
961
+ vendor: string;
962
+ model: string;
918
963
  default: boolean;
919
964
  ip4: string;
920
965
  ip4subnet: string;
921
966
  ip6: string;
922
967
  ip6subnet: string;
968
+ gateway: string;
923
969
  mac: string;
924
970
  internal: boolean;
925
971
  virtual: boolean;
@@ -938,9 +984,11 @@ export type NetworkStatsData = {
938
984
  iface: string;
939
985
  operstate: string;
940
986
  rx_bytes: number;
987
+ rx_packets: number;
941
988
  rx_dropped: number;
942
989
  rx_errors: number;
943
990
  tx_bytes: number;
991
+ tx_packets: number;
944
992
  tx_dropped: number;
945
993
  tx_errors: number;
946
994
  rx_sec: number | null;
@@ -55,4 +55,8 @@ declare class PowerShellPool {
55
55
  }
56
56
  export declare const psArray: (value: any) => any[];
57
57
  export declare const ps: PowerShellPool;
58
+ export declare const parseWindowsLocationInfo: (value: string) => string;
59
+ export declare const parseWindowsPnpLocations: (stdout: any) => Map<string, string>;
60
+ export declare const matchPnpLocation: (deviceId: string, locations: Map<string, string>) => string;
61
+ export declare const windowsPciBusAddresses: () => Promise<Map<string, string>>;
58
62
  export {};
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ps = exports.psArray = void 0;
3
+ exports.windowsPciBusAddresses = exports.matchPnpLocation = exports.parseWindowsPnpLocations = exports.parseWindowsLocationInfo = exports.ps = exports.psArray = void 0;
4
4
  const node_child_process_1 = require("node:child_process");
5
+ const exec_1 = require("./exec");
5
6
  const files_1 = require("../common/files");
6
7
  const const_1 = require("./const");
7
8
  const WINDIR = process.env.WINDIR || String.raw `C:\Windows`;
@@ -290,3 +291,58 @@ exports.ps = new PowerShellPool({ size: 4 });
290
291
  if (const_1.WINDOWS) {
291
292
  process.on('exit', () => exports.ps.stop());
292
293
  }
294
+ const parseWindowsLocationInfo = (value) => {
295
+ const text = String(value ?? '').trim();
296
+ if (!/pci/i.test(text)) {
297
+ return '';
298
+ }
299
+ const numbers = text.match(/\d+/g);
300
+ if (!numbers || numbers.length !== 3) {
301
+ return '';
302
+ }
303
+ const [bus, device, fn] = numbers.map((part) => parseInt(part, 10));
304
+ if ([bus, device, fn].some((part) => Number.isNaN(part))) {
305
+ return '';
306
+ }
307
+ return `${bus.toString(16).padStart(2, '0')}:${device.toString(16).padStart(2, '0')}.${fn.toString(16)}`;
308
+ };
309
+ exports.parseWindowsLocationInfo = parseWindowsLocationInfo;
310
+ const parseWindowsPnpLocations = (stdout) => {
311
+ const result = new Map();
312
+ for (const line of String(stdout ?? '').split('\n')) {
313
+ const separator = line.indexOf('|');
314
+ if (separator < 1) {
315
+ continue;
316
+ }
317
+ const busAddress = (0, exports.parseWindowsLocationInfo)(line.substring(separator + 1));
318
+ if (busAddress) {
319
+ result.set(line.substring(0, separator).trim().toLowerCase(), busAddress);
320
+ }
321
+ }
322
+ return result;
323
+ };
324
+ exports.parseWindowsPnpLocations = parseWindowsPnpLocations;
325
+ const matchPnpLocation = (deviceId, locations) => {
326
+ const id = String(deviceId ?? '').trim().toLowerCase();
327
+ if (!id) {
328
+ return '';
329
+ }
330
+ const exact = locations.get(id);
331
+ if (exact) {
332
+ return exact;
333
+ }
334
+ const candidates = [...locations].filter(([instanceId]) => instanceId.startsWith(`${id}\\`));
335
+ return candidates.length === 1 ? candidates[0][1] : '';
336
+ };
337
+ exports.matchPnpLocation = matchPnpLocation;
338
+ const PS_PNP_DISPLAY_LOCATIONS = 'Get-PnpDevice -Class Display -PresentOnly -ErrorAction SilentlyContinue | ForEach-Object { ' +
339
+ "$l = ($_ | Get-PnpDeviceProperty -KeyName DEVPKEY_Device_LocationInfo -ErrorAction SilentlyContinue).Data; \"$($_.InstanceId)|$l\" }";
340
+ const windowsPciBusAddresses = async () => {
341
+ try {
342
+ return (0, exports.parseWindowsPnpLocations)(await (0, exec_1.shareInflight)('pnpDisplayLocations', () => exports.ps.exec(PS_PNP_DISPLAY_LOCATIONS)));
343
+ }
344
+ catch {
345
+ return new Map();
346
+ }
347
+ };
348
+ exports.windowsPciBusAddresses = windowsPciBusAddresses;
@@ -1,2 +1,3 @@
1
1
  import type { CurrentLoadData } from './common/types';
2
+ export declare const avgLoadEwma: (previous: number[] | null, busyCores: number, seconds: number) => number[];
2
3
  export declare const currentLoad: () => Promise<CurrentLoadData>;