systeminformation 6.0.0-beta.0 → 6.0.0-beta.10

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 (103) hide show
  1. package/README.md +37 -7
  2. package/dist/bsd/network-stats.js +2 -2
  3. package/dist/bsd/os-info.d.ts +3 -0
  4. package/dist/bsd/os-info.js +9 -0
  5. package/dist/common/acceleration.d.ts +8 -0
  6. package/dist/common/acceleration.js +86 -0
  7. package/dist/common/defaults.d.ts +2 -1
  8. package/dist/common/defaults.js +23 -6
  9. package/dist/common/exec.js +1 -1
  10. package/dist/common/files.d.ts +9 -0
  11. package/dist/common/files.js +67 -3
  12. package/dist/common/filesys.d.ts +10 -0
  13. package/dist/common/filesys.js +41 -10
  14. package/dist/common/internet.d.ts +5 -0
  15. package/dist/common/internet.js +46 -1
  16. package/dist/common/mappings.d.ts +1 -1
  17. package/dist/common/mappings.js +1134 -1134
  18. package/dist/common/network.js +4 -4
  19. package/dist/common/nvidia.d.ts +1 -1
  20. package/dist/common/nvidia.js +4 -5
  21. package/dist/common/parse.d.ts +4 -6
  22. package/dist/common/parse.js +24 -69
  23. package/dist/common/security.d.ts +1 -0
  24. package/dist/common/security.js +3 -1
  25. package/dist/common/types.d.ts +79 -23
  26. package/dist/cpu-current-load.js +28 -6
  27. package/dist/cpu-current-speed.js +5 -3
  28. package/dist/darwin/disk-layout.js +10 -6
  29. package/dist/darwin/disks-io.js +3 -3
  30. package/dist/darwin/displays.js +3 -1
  31. package/dist/darwin/fans.d.ts +2 -0
  32. package/dist/darwin/fans.js +28 -0
  33. package/dist/darwin/index.d.ts +2 -0
  34. package/dist/darwin/index.js +6 -2
  35. package/dist/darwin/network-interfaces.js +5 -10
  36. package/dist/darwin/network-stats.js +5 -5
  37. package/dist/darwin/os-info.d.ts +1 -0
  38. package/dist/darwin/os-info.js +32 -2
  39. package/dist/darwin/serial-ports.d.ts +2 -0
  40. package/dist/darwin/serial-ports.js +94 -0
  41. package/dist/fans.d.ts +1 -0
  42. package/dist/fans.js +17 -0
  43. package/dist/get-data.d.ts +6 -2
  44. package/dist/get-data.js +6 -2
  45. package/dist/index.d.ts +3 -0
  46. package/dist/index.js +8 -2
  47. package/dist/inet-public-ip.d.ts +2 -0
  48. package/dist/inet-public-ip.js +10 -0
  49. package/dist/linux/audio.js +59 -0
  50. package/dist/linux/baseboard.js +9 -20
  51. package/dist/linux/bios.js +6 -15
  52. package/dist/linux/camera.js +2 -1
  53. package/dist/linux/chassis.js +4 -10
  54. package/dist/linux/cpu-temperature.js +34 -19
  55. package/dist/linux/cpu.js +3 -1
  56. package/dist/linux/disk-layout.js +7 -10
  57. package/dist/linux/disks-io.js +9 -9
  58. package/dist/linux/displays.js +6 -1
  59. package/dist/linux/fans.d.ts +2 -0
  60. package/dist/linux/fans.js +92 -0
  61. package/dist/linux/fs-size.js +160 -34
  62. package/dist/linux/fs-stats.js +6 -9
  63. package/dist/linux/gpu.d.ts +13 -0
  64. package/dist/linux/gpu.js +111 -1
  65. package/dist/linux/index.d.ts +2 -0
  66. package/dist/linux/index.js +6 -2
  67. package/dist/linux/mem-layout.js +2 -2
  68. package/dist/linux/network-interfaces.js +36 -39
  69. package/dist/linux/network-stats.js +8 -36
  70. package/dist/linux/npu.js +2 -1
  71. package/dist/linux/os-info.js +35 -10
  72. package/dist/linux/printer.js +4 -4
  73. package/dist/linux/process-load.js +9 -12
  74. package/dist/linux/processes.js +89 -80
  75. package/dist/linux/serial-ports.d.ts +2 -0
  76. package/dist/linux/serial-ports.js +102 -0
  77. package/dist/linux/services.js +179 -47
  78. package/dist/linux/system.js +1 -7
  79. package/dist/linux/time.d.ts +2 -2
  80. package/dist/linux/time.js +3 -3
  81. package/dist/linux/uuid.js +4 -10
  82. package/dist/serial-ports.d.ts +1 -0
  83. package/dist/serial-ports.js +17 -0
  84. package/dist/time.d.ts +1 -1
  85. package/dist/versions.js +60 -77
  86. package/dist/windows/block-devices.d.ts +1 -0
  87. package/dist/windows/block-devices.js +15 -5
  88. package/dist/windows/disk-layout.js +21 -1
  89. package/dist/windows/disks-io.js +8 -5
  90. package/dist/windows/displays.js +29 -12
  91. package/dist/windows/fans.d.ts +2 -0
  92. package/dist/windows/fans.js +71 -0
  93. package/dist/windows/index.d.ts +2 -0
  94. package/dist/windows/index.js +6 -2
  95. package/dist/windows/network-interfaces.js +20 -29
  96. package/dist/windows/network-stats.js +4 -2
  97. package/dist/windows/os-info.js +5 -0
  98. package/dist/windows/process-load.js +7 -5
  99. package/dist/windows/processes.js +17 -11
  100. package/dist/windows/serial-ports.d.ts +3 -0
  101. package/dist/windows/serial-ports.js +73 -0
  102. package/dist/windows/services.js +3 -0
  103. package/package.json +1 -1
@@ -12,6 +12,13 @@ const diskLayout = async () => {
12
12
  let stdout = '';
13
13
  let cmd = '';
14
14
  let cmdFullSmart = '';
15
+ const addSmartCmds = (bsdName) => {
16
+ if (typeof bsdName !== 'string' || !/^disk\d+(s\d+)*$/.test(bsdName)) {
17
+ return;
18
+ }
19
+ cmd += `printf "\n${bsdName}|"; diskutil info /dev/${bsdName} | grep SMART;`;
20
+ cmdFullSmart += `${cmdFullSmart ? 'printf ",";' : ''}smartctl -a -j ${bsdName};`;
21
+ };
15
22
  try {
16
23
  ({ stdout } = await (0, exec_1.exec)(`system_profiler SPSerialATADataType SPNVMeDataType SPUSBDataType SPStorageDataType -xml`, { maxBuffer: const_1.MAX_BUFFER_SIZE }));
17
24
  const data = (0, darwin_1.plistParser)(stdout, false);
@@ -44,8 +51,7 @@ const diskLayout = async () => {
44
51
  temperature: null,
45
52
  bsdName: disk.bsd_name
46
53
  });
47
- cmd += 'printf "\n' + disk.bsd_name + '|"; diskutil info /dev/' + disk.bsd_name + ' | grep SMART;';
48
- cmdFullSmart += `${cmdFullSmart ? 'printf ",";' : ''}smartctl -a -j ${disk.bsd_name};`;
54
+ addSmartCmds(disk.bsd_name);
49
55
  });
50
56
  }
51
57
  });
@@ -74,8 +80,7 @@ const diskLayout = async () => {
74
80
  temperature: null,
75
81
  bsdName: disk.bsd_name
76
82
  });
77
- cmd += 'printf "\n' + disk.bsd_name + '|"; diskutil info /dev/' + disk.bsd_name + ' | grep SMART;';
78
- cmdFullSmart += `${cmdFullSmart ? 'printf ",";' : ''}smartctl -a -j ${disk.bsd_name};`;
83
+ addSmartCmds(disk.bsd_name);
79
84
  });
80
85
  }
81
86
  });
@@ -106,8 +111,7 @@ const diskLayout = async () => {
106
111
  temperature: null,
107
112
  bsdName: media.bsd_name
108
113
  });
109
- cmd += 'printf "\n' + media.bsd_name + '|"; diskutil info /dev/' + media.bsd_name + ' | grep SMART;';
110
- cmdFullSmart += `${cmdFullSmart ? 'printf ",";' : ''}smartctl -a -j ${disk.bsd_name};`;
114
+ addSmartCmds(media.bsd_name);
111
115
  }
112
116
  else if (disk?._items.length) {
113
117
  disk._items.forEach((subdisk) => {
@@ -44,9 +44,9 @@ const disksIO = async () => {
44
44
  rIO_sec: filesys_1._disk_io.rIO_sec,
45
45
  wIO_sec: filesys_1._disk_io.wIO_sec,
46
46
  tIO_sec: filesys_1._disk_io.tIO_sec,
47
- rWaitTime: filesys_1._disk_io.rWaitTime,
48
- wWaitTime: filesys_1._disk_io.wWaitTime,
49
- tWaitTime: filesys_1._disk_io.tWaitTime,
47
+ rWaitTime: filesys_1._disk_io.rWaitTimeDelta,
48
+ wWaitTime: filesys_1._disk_io.wWaitTimeDelta,
49
+ tWaitTime: filesys_1._disk_io.tWaitTimeDelta,
50
50
  rWaitPercent: filesys_1._disk_io.rWaitPercent,
51
51
  wWaitPercent: filesys_1._disk_io.wWaitPercent,
52
52
  tWaitPercent: filesys_1._disk_io.tWaitPercent
@@ -26,6 +26,7 @@ const parseDisplaysDarwin = (graphicsArr) => {
26
26
  displayId: displayItem['_spdisplays_displayID'] || null,
27
27
  deviceName: null,
28
28
  main: displayItem['spdisplays_main'] ? displayItem['spdisplays_main'] === 'spdisplays_yes' : false,
29
+ mirror: (displayItem['spdisplays_mirror'] || 'spdisplays_off') !== 'spdisplays_off',
29
30
  builtin: (displayItem['spdisplays_display_type'] || '').indexOf('built-in') > -1,
30
31
  connection: connectionType.indexOf('_internal') > -1 ? 'Internal' : connectionType.indexOf('_displayport') > -1 ? 'Display Port' : connectionType.indexOf('_hdmi') > -1 ? 'HDMI' : null,
31
32
  sizeX: null,
@@ -37,7 +38,8 @@ const parseDisplaysDarwin = (graphicsArr) => {
37
38
  currentResY: currentResolution.length > 1 ? parseInt(currentResolution[1], 10) : null,
38
39
  positionX: 0,
39
40
  positionY: 0,
40
- currentRefreshRate: currentResolutionParts.length > 1 ? parseInt(currentResolutionParts[1], 10) : null
41
+ currentRefreshRate: currentResolutionParts.length > 1 ? parseInt(currentResolutionParts[1], 10) : null,
42
+ scale: null
41
43
  });
42
44
  });
43
45
  }
@@ -0,0 +1,2 @@
1
+ import type { FanData } from '../common/types';
2
+ export declare const fans: () => Promise<FanData[]>;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fans = void 0;
4
+ const common_1 = require("../common");
5
+ const fans = async () => {
6
+ await (0, common_1.nextTick)();
7
+ const result = [];
8
+ try {
9
+ const macosTemp = require('macos-temperature-sensor');
10
+ if (typeof macosTemp.fans === 'function') {
11
+ const res = macosTemp.fans();
12
+ if (Array.isArray(res)) {
13
+ res.forEach((fan, index) => {
14
+ result.push({
15
+ id: `fan${index}`,
16
+ label: fan?.label || null,
17
+ rpm: typeof fan?.rpm === 'number' ? Math.round(fan.rpm) : null,
18
+ pwm: typeof fan?.pwm === 'number' ? Math.round(fan.pwm) : null,
19
+ source: 'SMC'
20
+ });
21
+ });
22
+ }
23
+ }
24
+ }
25
+ catch { }
26
+ return result;
27
+ };
28
+ exports.fans = fans;
@@ -11,6 +11,7 @@ export { cpuCache } from './cpu-cache';
11
11
  export { cpuCurrentSpeed } from '../cpu-current-speed';
12
12
  export { cpuFlags } from './cpu-flags';
13
13
  export { cpuTemperature } from './cpu-temperature';
14
+ export { fans } from './fans';
14
15
  export { currentLoad } from '../cpu-current-load';
15
16
  export { diskLayout } from './disk-layout';
16
17
  export { disksIO } from './disks-io';
@@ -45,6 +46,7 @@ export { software } from './software';
45
46
  export { system } from './system';
46
47
  export { thunderbolt } from './thunderbolt';
47
48
  export { time } from '../time';
49
+ export { serialPorts } from './serial-ports';
48
50
  export { usb } from './usb';
49
51
  export { users } from './users';
50
52
  export { uuid } from './uuid';
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.software = exports.shell = exports.services = exports.processLoad = exports.processes = exports.printer = exports.pci = exports.osInfo = exports.npu = exports.npm = exports.networkStats = exports.networkInterfaces = exports.networkInterfaceDefault = exports.networkGatewayDefault = exports.networkConnections = exports.mouse = exports.memLayout = exports.mem = exports.keyboard = exports.inetLatency = exports.inetChecksite = exports.gpu = exports.fullLoad = exports.fsStats = exports.fsSize = exports.fsOpenFiles = exports.dockerAll = exports.dockerVolumes = exports.dockerContainerProcesses = exports.dockerContainerStats = exports.dockerContainers = exports.dockerImages = exports.dockerInfo = exports.displays = exports.disksIO = exports.diskLayout = exports.currentLoad = exports.cpuTemperature = exports.cpuFlags = exports.cpuCurrentSpeed = exports.cpuCache = exports.cpu = exports.chassis = exports.camera = exports.bluetoothDevices = exports.blockDevices = exports.bios = exports.battery = exports.baseboard = exports.audio = void 0;
4
- exports.wifiNetworks = exports.wifiInterfaces = exports.wifiConnections = exports.versions = exports.version = exports.vboxInfo = exports.uuid = exports.users = exports.usb = exports.time = exports.thunderbolt = exports.system = void 0;
3
+ exports.shell = exports.services = exports.processLoad = exports.processes = exports.printer = exports.pci = exports.osInfo = exports.npu = exports.npm = exports.networkStats = exports.networkInterfaces = exports.networkInterfaceDefault = exports.networkGatewayDefault = exports.networkConnections = exports.mouse = exports.memLayout = exports.mem = exports.keyboard = exports.inetLatency = exports.inetChecksite = exports.gpu = exports.fullLoad = exports.fsStats = exports.fsSize = exports.fsOpenFiles = exports.dockerAll = exports.dockerVolumes = exports.dockerContainerProcesses = exports.dockerContainerStats = exports.dockerContainers = exports.dockerImages = exports.dockerInfo = exports.displays = exports.disksIO = exports.diskLayout = exports.currentLoad = exports.fans = exports.cpuTemperature = exports.cpuFlags = exports.cpuCurrentSpeed = exports.cpuCache = exports.cpu = exports.chassis = exports.camera = exports.bluetoothDevices = exports.blockDevices = exports.bios = exports.battery = exports.baseboard = exports.audio = void 0;
4
+ exports.wifiNetworks = exports.wifiInterfaces = exports.wifiConnections = exports.versions = exports.version = exports.vboxInfo = exports.uuid = exports.users = exports.usb = exports.serialPorts = exports.time = exports.thunderbolt = exports.system = exports.software = void 0;
5
5
  var audio_1 = require("./audio");
6
6
  Object.defineProperty(exports, "audio", { enumerable: true, get: function () { return audio_1.audio; } });
7
7
  var baseboard_1 = require("./baseboard");
@@ -28,6 +28,8 @@ var cpu_flags_1 = require("./cpu-flags");
28
28
  Object.defineProperty(exports, "cpuFlags", { enumerable: true, get: function () { return cpu_flags_1.cpuFlags; } });
29
29
  var cpu_temperature_1 = require("./cpu-temperature");
30
30
  Object.defineProperty(exports, "cpuTemperature", { enumerable: true, get: function () { return cpu_temperature_1.cpuTemperature; } });
31
+ var fans_1 = require("./fans");
32
+ Object.defineProperty(exports, "fans", { enumerable: true, get: function () { return fans_1.fans; } });
31
33
  var cpu_current_load_1 = require("../cpu-current-load");
32
34
  Object.defineProperty(exports, "currentLoad", { enumerable: true, get: function () { return cpu_current_load_1.currentLoad; } });
33
35
  var disk_layout_1 = require("./disk-layout");
@@ -102,6 +104,8 @@ var thunderbolt_1 = require("./thunderbolt");
102
104
  Object.defineProperty(exports, "thunderbolt", { enumerable: true, get: function () { return thunderbolt_1.thunderbolt; } });
103
105
  var time_1 = require("../time");
104
106
  Object.defineProperty(exports, "time", { enumerable: true, get: function () { return time_1.time; } });
107
+ var serial_ports_1 = require("./serial-ports");
108
+ Object.defineProperty(exports, "serialPorts", { enumerable: true, get: function () { return serial_ports_1.serialPorts; } });
105
109
  var usb_1 = require("./usb");
106
110
  Object.defineProperty(exports, "usb", { enumerable: true, get: function () { return usb_1.usb; } });
107
111
  var users_1 = require("./users");
@@ -187,16 +187,11 @@ const networkInterfaces = async (defaultString = '', rescan = true) => {
187
187
  ieee8021xState: '',
188
188
  carrierChanges: 0
189
189
  });
190
- _networkInterfaces = result;
191
- if (defaultString.toLowerCase().indexOf('default') >= 0) {
192
- result = result.filter((item) => item.default);
193
- if (result.length > 0) {
194
- return [result[0]];
195
- }
196
- else {
197
- result = [];
198
- }
199
- }
190
+ }
191
+ _networkInterfaces = result;
192
+ if (defaultString.toLowerCase().indexOf('default') >= 0) {
193
+ result = result.filter((item) => item.default);
194
+ return result.length ? [result[0]] : [];
200
195
  }
201
196
  }
202
197
  catch { }
@@ -10,7 +10,7 @@ const darwin_1 = require("../darwin");
10
10
  const _network = {};
11
11
  const networkStatsSingle = async (iface) => {
12
12
  await (0, common_1.nextTick)();
13
- const defaults = defaults_1.initNetworkSpeed;
13
+ const defaults = { ...defaults_1.initNetworkSpeed, iface };
14
14
  if (!_network[iface] || (_network[iface] && !_network[iface].ms) || (_network[iface] && _network[iface].ms && Date.now() - _network[iface].ms >= 500)) {
15
15
  let operstate = 'unknown';
16
16
  let rx_bytes = 0;
@@ -19,11 +19,11 @@ const networkStatsSingle = async (iface) => {
19
19
  let rx_errors = 0;
20
20
  let tx_dropped = 0;
21
21
  let tx_errors = 0;
22
- let stdout = '';
23
- ({ stdout } = await (0, exec_1.execSave)(`ifconfig ${iface} | grep "status"`));
24
- operstate = (stdout.split(':')[1] || '').trim().toLowerCase();
22
+ let stdout = await (0, exec_1.execSecure)('ifconfig', [iface]);
23
+ const statusLine = stdout.split('\n').find((l) => l.includes('status')) || '';
24
+ operstate = (statusLine.split(':')[1] || '').trim().toLowerCase();
25
25
  operstate = operstate === 'active' ? 'up' : operstate === 'inactive' ? 'down' : 'unknown';
26
- ({ stdout } = await (0, exec_1.execSave)(`netstat -bdnI ${iface}`));
26
+ stdout = await (0, exec_1.execSecure)('netstat', ['-bdnI', iface]);
27
27
  if (stdout) {
28
28
  const lines = stdout.toString().split('\n');
29
29
  if (lines.length > 1 && lines[1].trim() !== '') {
@@ -1 +1,2 @@
1
+ export declare const parseLastUpdate: (stdout: string) => Date | null;
1
2
  export declare const osInfo: () => Promise<import("../common/types").OsData>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.osInfo = void 0;
3
+ exports.osInfo = exports.parseLastUpdate = void 0;
4
4
  const common_1 = require("../common");
5
5
  const codepage_1 = require("../common/codepage");
6
6
  const defaults_1 = require("../common/defaults");
@@ -16,10 +16,35 @@ const getInstallDate = async () => {
16
16
  return null;
17
17
  }
18
18
  };
19
+ const parseLastUpdate = (stdout) => {
20
+ let date = null;
21
+ (stdout || '').split('</dict>').forEach((entry) => {
22
+ const name = entry.match(/<key>displayName<\/key>\s*<string>([^<]*)<\/string>/);
23
+ const value = entry.match(/<key>date<\/key>\s*<date>([^<]*)<\/date>/);
24
+ if (!name || !value || !/^macOS\b/i.test(name[1].trim())) {
25
+ return;
26
+ }
27
+ const entryDate = new Date(value[1]);
28
+ if (!Number.isNaN(entryDate.getTime()) && (!date || entryDate.getTime() > date.getTime())) {
29
+ date = entryDate;
30
+ }
31
+ });
32
+ return date;
33
+ };
34
+ exports.parseLastUpdate = parseLastUpdate;
35
+ const getLastUpdate = async () => {
36
+ const { stdout } = await (0, exec_1.execSave)('plutil -convert xml1 -o - /Library/Receipts/InstallHistory.plist 2>/dev/null');
37
+ return (0, exports.parseLastUpdate)(stdout || '');
38
+ };
19
39
  const getDisplayServer = async () => {
20
40
  const { stdout } = await (0, exec_1.execSave)('pgrep WindowServer 2>/dev/null');
21
41
  return (stdout || '').trim() ? 'quartz' : '';
22
42
  };
43
+ const getAwake = async () => {
44
+ const { stdout } = await (0, exec_1.execSave)('pmset -g systemstate 2>/dev/null');
45
+ const line = (stdout || '').split('\n').find((l) => l.toLowerCase().includes('system capabilities'));
46
+ return line ? line.includes('Graphics') : true;
47
+ };
23
48
  const getCodename = (release) => {
24
49
  let codename = 'macOS';
25
50
  switch (true) {
@@ -77,6 +102,9 @@ const getCodename = (release) => {
77
102
  case release.startsWith('26.'):
78
103
  codename = 'Tahoe';
79
104
  break;
105
+ case release.startsWith('27.'):
106
+ codename = 'Golden Gate';
107
+ break;
80
108
  default:
81
109
  codename = 'macOS';
82
110
  }
@@ -101,7 +129,9 @@ const osInfo = async () => {
101
129
  uefi: true,
102
130
  codepage: (0, codepage_1.getCodepage)(),
103
131
  installDate: await getInstallDate(),
104
- displayServer: await getDisplayServer()
132
+ lastUpdate: await getLastUpdate(),
133
+ displayServer: await getDisplayServer(),
134
+ awake: await getAwake()
105
135
  };
106
136
  }
107
137
  catch { }
@@ -0,0 +1,2 @@
1
+ import type { SerialPortData } from '../common/types';
2
+ export declare const serialPorts: () => Promise<SerialPortData[]>;
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.serialPorts = void 0;
4
+ const promises_1 = require("fs/promises");
5
+ const common_1 = require("../common");
6
+ const defaults_1 = require("../common/defaults");
7
+ const exec_1 = require("../common/exec");
8
+ const security_1 = require("../common/security");
9
+ const toHex4 = (value) => {
10
+ const num = Number.parseInt(value, 10);
11
+ return Number.isNaN(num) ? null : num.toString(16).padStart(4, '0');
12
+ };
13
+ const parseUsbPorts = (stdout) => {
14
+ const ports = new Map();
15
+ let usb = {};
16
+ for (const raw of stdout.split('\n')) {
17
+ const line = raw.replace(/\|/g, '').trim();
18
+ if (line.startsWith('+-o')) {
19
+ if (line.includes('class IOUSBHostDevice')) {
20
+ usb = {};
21
+ }
22
+ continue;
23
+ }
24
+ const entry = /^"([^"]+)" = (.+)$/.exec(line);
25
+ if (!entry) {
26
+ continue;
27
+ }
28
+ const key = entry[1];
29
+ const value = (entry[2] || '').replace(/^"|"$/g, '').trim();
30
+ switch (key) {
31
+ case 'idVendor':
32
+ usb.vendorId = toHex4(value);
33
+ break;
34
+ case 'idProduct':
35
+ usb.productId = toHex4(value);
36
+ break;
37
+ case 'USB Vendor Name':
38
+ usb.manufacturer = value || null;
39
+ break;
40
+ case 'USB Product Name':
41
+ usb.name = value || null;
42
+ break;
43
+ case 'USB Serial Number':
44
+ usb.serialNumber = value || null;
45
+ break;
46
+ case 'IOCalloutDevice':
47
+ ports.set(value, { ...usb });
48
+ break;
49
+ default:
50
+ break;
51
+ }
52
+ }
53
+ return ports;
54
+ };
55
+ const calloutDevices = (stdout) => {
56
+ const devices = new Set();
57
+ const regex = /"IOCalloutDevice" = "([^"]+)"/g;
58
+ let match = regex.exec(stdout);
59
+ while (match) {
60
+ if (match[1]) {
61
+ devices.add(match[1]);
62
+ }
63
+ match = regex.exec(stdout);
64
+ }
65
+ return devices;
66
+ };
67
+ const serialPorts = async () => {
68
+ await (0, common_1.nextTick)();
69
+ const result = [];
70
+ let devices = [];
71
+ try {
72
+ devices = (await (0, promises_1.readdir)('/dev')).filter((device) => device.startsWith('cu.') && (0, security_1.isSafePathSegment)(device));
73
+ }
74
+ catch {
75
+ return result;
76
+ }
77
+ const [usbTree, bluetoothTree] = await Promise.all([(0, exec_1.execSave)('ioreg -r -c IOUSBHostDevice -l -w0'), (0, exec_1.execSave)('ioreg -r -c IOBluetoothDevice -l -w0')]);
78
+ const usbPorts = parseUsbPorts(usbTree.stdout);
79
+ const bluetoothPorts = calloutDevices(bluetoothTree.stdout);
80
+ for (const device of devices.sort()) {
81
+ const path = `/dev/${device}`;
82
+ const usb = usbPorts.get(path);
83
+ const name = device.substring(3);
84
+ result.push({
85
+ ...(0, common_1.cloneObj)(defaults_1.initSerialPortResult),
86
+ ...usb,
87
+ device: path,
88
+ name: usb?.name || name,
89
+ type: usb ? 'usb' : bluetoothPorts.has(path) ? 'bluetooth' : 'unknown'
90
+ });
91
+ }
92
+ return result;
93
+ };
94
+ exports.serialPorts = serialPorts;
package/dist/fans.d.ts ADDED
@@ -0,0 +1 @@
1
+ export declare const fans: () => Promise<import("./common/types").FanData[] | null>;
package/dist/fans.js ADDED
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fans = void 0;
4
+ const const_1 = require("./common/const");
5
+ const fans = async () => {
6
+ switch (true) {
7
+ case const_1.LINUX || const_1.ANDROID:
8
+ return (await import('./linux/fans.js')).fans();
9
+ case const_1.DARWIN:
10
+ return (await import('./darwin/fans.js')).fans();
11
+ case const_1.WINDOWS:
12
+ return (await import('./windows/fans.js')).fans();
13
+ default:
14
+ return null;
15
+ }
16
+ };
17
+ exports.fans = fans;
@@ -16,6 +16,7 @@ export declare const getStaticData: () => Promise<{
16
16
  audio: import("./common/types").AudioData[] | null;
17
17
  bluetooth: import("./common/types").BluetoothObject[] | null;
18
18
  usb: import("./common/types").UsbData[] | null;
19
+ serialPorts: import("./common/types").SerialPortData[] | null;
19
20
  printer: import("./common/types").PrinterData[] | null;
20
21
  camera: import("./common/types").Camera[] | null;
21
22
  keyboard: import("./common/types").Keyboard[] | null;
@@ -32,7 +33,7 @@ export declare const getDynamicData: (srv?: string, iface?: string) => Promise<{
32
33
  uptime: number;
33
34
  timezone: string;
34
35
  timezoneName: string;
35
- };
36
+ } | null;
36
37
  node: string;
37
38
  v8: string;
38
39
  cpuCurrentSpeed: import("./common/types").CpuCurrentSpeedObject;
@@ -40,6 +41,7 @@ export declare const getDynamicData: (srv?: string, iface?: string) => Promise<{
40
41
  processes: import("./common/types").ProcessesData | null;
41
42
  currentLoad: import("./common/types").CurrentLoadData;
42
43
  temp: any;
44
+ fans: import("./common/types").FanData[] | null;
43
45
  networkStats: import("./common/types").NetworkStatsData[] | null;
44
46
  networkConnections: import("./common/types").NetworkConnectionsData[] | null;
45
47
  mem: any;
@@ -60,7 +62,7 @@ export declare const getAllData: (srv?: string, iface?: string) => Promise<{
60
62
  uptime: number;
61
63
  timezone: string;
62
64
  timezoneName: string;
63
- };
65
+ } | null;
64
66
  node: string;
65
67
  v8: string;
66
68
  cpuCurrentSpeed: import("./common/types").CpuCurrentSpeedObject;
@@ -68,6 +70,7 @@ export declare const getAllData: (srv?: string, iface?: string) => Promise<{
68
70
  processes: import("./common/types").ProcessesData | null;
69
71
  currentLoad: import("./common/types").CurrentLoadData;
70
72
  temp: any;
73
+ fans: import("./common/types").FanData[] | null;
71
74
  networkStats: import("./common/types").NetworkStatsData[] | null;
72
75
  networkConnections: import("./common/types").NetworkConnectionsData[] | null;
73
76
  mem: any;
@@ -98,6 +101,7 @@ export declare const getAllData: (srv?: string, iface?: string) => Promise<{
98
101
  audio: import("./common/types").AudioData[] | null;
99
102
  bluetooth: import("./common/types").BluetoothObject[] | null;
100
103
  usb: import("./common/types").UsbData[] | null;
104
+ serialPorts: import("./common/types").SerialPortData[] | null;
101
105
  printer: import("./common/types").PrinterData[] | null;
102
106
  camera: import("./common/types").Camera[] | null;
103
107
  keyboard: import("./common/types").Keyboard[] | null;
package/dist/get-data.js CHANGED
@@ -38,7 +38,7 @@ const common_1 = require("./common");
38
38
  const si = __importStar(require("./index"));
39
39
  const getStaticData = async () => {
40
40
  await (0, common_1.nextTick)();
41
- const [version, system, bios, baseboard, chassis, os, uuid, versions, cpu, cpuFlags, gpu, displays, net, memLayout, diskLayout, audio, bluetooth, usb, printer, camera, keyboard, mouse, pci, thunderbolt, npu, wifiInterfaces, software] = await Promise.all([
41
+ const [version, system, bios, baseboard, chassis, os, uuid, versions, cpu, cpuFlags, gpu, displays, net, memLayout, diskLayout, audio, bluetooth, usb, serialPorts, printer, camera, keyboard, mouse, pci, thunderbolt, npu, wifiInterfaces, software] = await Promise.all([
42
42
  si.version(),
43
43
  si.system(),
44
44
  si.bios(),
@@ -57,6 +57,7 @@ const getStaticData = async () => {
57
57
  si.audio(),
58
58
  si.bluetoothDevices(),
59
59
  si.usb(),
60
+ si.serialPorts(),
60
61
  si.printer(),
61
62
  si.camera(),
62
63
  si.keyboard(),
@@ -85,6 +86,7 @@ const getStaticData = async () => {
85
86
  audio,
86
87
  bluetooth,
87
88
  usb,
89
+ serialPorts,
88
90
  printer,
89
91
  camera,
90
92
  keyboard,
@@ -99,13 +101,14 @@ const getStaticData = async () => {
99
101
  exports.getStaticData = getStaticData;
100
102
  const getDynamicData = async (srv = '', iface = '') => {
101
103
  await (0, common_1.nextTick)();
102
- const [time, cpuCurrentSpeed, users, processes, currentLoad, temp, networkStats, networkConnections, mem, battery, services, fsSize, fsStats, disksIO, wifiNetworks, wifiConnections, fsOpenFiles, blockDevices, inetLatency] = await Promise.all([
104
+ const [time, cpuCurrentSpeed, users, processes, currentLoad, temp, fans, networkStats, networkConnections, mem, battery, services, fsSize, fsStats, disksIO, wifiNetworks, wifiConnections, fsOpenFiles, blockDevices, inetLatency] = await Promise.all([
103
105
  si.time(),
104
106
  si.cpuCurrentSpeed(),
105
107
  si.users(),
106
108
  si.processes(),
107
109
  si.currentLoad(),
108
110
  si.cpuTemperature(),
111
+ si.fans(),
109
112
  (async () => si.networkStats(iface || (await si.networkInterfaceDefault()) || '*'))(),
110
113
  si.networkConnections(),
111
114
  si.mem(),
@@ -129,6 +132,7 @@ const getDynamicData = async (srv = '', iface = '') => {
129
132
  processes,
130
133
  currentLoad,
131
134
  temp,
135
+ fans,
132
136
  networkStats,
133
137
  networkConnections,
134
138
  mem,
package/dist/index.d.ts CHANGED
@@ -11,6 +11,7 @@ export { cpuCache } from './cpu-cache';
11
11
  export { cpuCurrentSpeed } from './cpu-current-speed';
12
12
  export { cpuFlags } from './cpu-flags';
13
13
  export { cpuTemperature } from './cpu-temperature';
14
+ export { fans } from './fans';
14
15
  export { currentLoad } from './cpu-current-load';
15
16
  export { diskLayout } from './disk-layout';
16
17
  export { disksIO } from './disks-io';
@@ -25,6 +26,7 @@ export { getStaticData, getDynamicData, getAllData } from './get-data';
25
26
  export { gpu } from './gpu';
26
27
  export { inetChecksite } from './inet-checksite';
27
28
  export { inetLatency } from './inet-latency';
29
+ export { inetPublicIp } from './inet-public-ip';
28
30
  export { keyboard } from './keyboard';
29
31
  export { mem } from './mem';
30
32
  export { memLayout } from './mem-layout';
@@ -42,6 +44,7 @@ export { pci } from './pci';
42
44
  export { printer } from './printer';
43
45
  export { processes } from './processes';
44
46
  export { processLoad } from './process-load';
47
+ export { serialPorts } from './serial-ports';
45
48
  export { services } from './services';
46
49
  export { shell } from './shell';
47
50
  export { software } from './software';
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.printer = exports.pci = exports.osInfo = exports.observe = exports.npu = exports.npm = exports.networkStats = exports.networkInterfaces = exports.networkInterfaceDefault = exports.networkGatewayDefault = exports.networkConnections = exports.mouse = exports.memLayout = exports.mem = exports.keyboard = exports.inetLatency = exports.inetChecksite = exports.gpu = exports.getAllData = exports.getDynamicData = exports.getStaticData = exports.get = exports.fullLoad = exports.fsStats = exports.fsSize = exports.fsOpenFiles = exports.dockerAll = exports.dockerVolumes = exports.dockerContainerProcesses = exports.dockerContainerStats = exports.dockerContainers = exports.dockerImages = exports.dockerInfo = exports.displays = exports.disksIO = exports.diskLayout = exports.currentLoad = exports.cpuTemperature = exports.cpuFlags = exports.cpuCurrentSpeed = exports.cpuCache = exports.cpu = exports.chassis = exports.camera = exports.bluetoothDevices = exports.blockDevices = exports.bios = exports.battery = exports.baseboard = exports.audio = void 0;
4
- exports.wifiNetworks = exports.wifiInterfaces = exports.wifiConnections = exports.versions = exports.version = exports.vboxInfo = exports.uuid = exports.users = exports.usb = exports.time = exports.thunderbolt = exports.system = exports.software = exports.shell = exports.services = exports.processLoad = exports.processes = void 0;
3
+ exports.osInfo = exports.observe = exports.npu = exports.npm = exports.networkStats = exports.networkInterfaces = exports.networkInterfaceDefault = exports.networkGatewayDefault = exports.networkConnections = exports.mouse = exports.memLayout = exports.mem = exports.keyboard = exports.inetPublicIp = exports.inetLatency = exports.inetChecksite = exports.gpu = exports.getAllData = exports.getDynamicData = exports.getStaticData = exports.get = exports.fullLoad = exports.fsStats = exports.fsSize = exports.fsOpenFiles = exports.dockerAll = exports.dockerVolumes = exports.dockerContainerProcesses = exports.dockerContainerStats = exports.dockerContainers = exports.dockerImages = exports.dockerInfo = exports.displays = exports.disksIO = exports.diskLayout = exports.currentLoad = exports.fans = exports.cpuTemperature = exports.cpuFlags = exports.cpuCurrentSpeed = exports.cpuCache = exports.cpu = exports.chassis = exports.camera = exports.bluetoothDevices = exports.blockDevices = exports.bios = exports.battery = exports.baseboard = exports.audio = void 0;
4
+ exports.wifiNetworks = exports.wifiInterfaces = exports.wifiConnections = exports.versions = exports.version = exports.vboxInfo = exports.uuid = exports.users = exports.usb = exports.time = exports.thunderbolt = exports.system = exports.software = exports.shell = exports.services = exports.serialPorts = exports.processLoad = exports.processes = exports.printer = exports.pci = void 0;
5
5
  var audio_1 = require("./audio");
6
6
  Object.defineProperty(exports, "audio", { enumerable: true, get: function () { return audio_1.audio; } });
7
7
  var baseboard_1 = require("./baseboard");
@@ -28,6 +28,8 @@ var cpu_flags_1 = require("./cpu-flags");
28
28
  Object.defineProperty(exports, "cpuFlags", { enumerable: true, get: function () { return cpu_flags_1.cpuFlags; } });
29
29
  var cpu_temperature_1 = require("./cpu-temperature");
30
30
  Object.defineProperty(exports, "cpuTemperature", { enumerable: true, get: function () { return cpu_temperature_1.cpuTemperature; } });
31
+ var fans_1 = require("./fans");
32
+ Object.defineProperty(exports, "fans", { enumerable: true, get: function () { return fans_1.fans; } });
31
33
  var cpu_current_load_1 = require("./cpu-current-load");
32
34
  Object.defineProperty(exports, "currentLoad", { enumerable: true, get: function () { return cpu_current_load_1.currentLoad; } });
33
35
  var disk_layout_1 = require("./disk-layout");
@@ -64,6 +66,8 @@ var inet_checksite_1 = require("./inet-checksite");
64
66
  Object.defineProperty(exports, "inetChecksite", { enumerable: true, get: function () { return inet_checksite_1.inetChecksite; } });
65
67
  var inet_latency_1 = require("./inet-latency");
66
68
  Object.defineProperty(exports, "inetLatency", { enumerable: true, get: function () { return inet_latency_1.inetLatency; } });
69
+ var inet_public_ip_1 = require("./inet-public-ip");
70
+ Object.defineProperty(exports, "inetPublicIp", { enumerable: true, get: function () { return inet_public_ip_1.inetPublicIp; } });
67
71
  var keyboard_1 = require("./keyboard");
68
72
  Object.defineProperty(exports, "keyboard", { enumerable: true, get: function () { return keyboard_1.keyboard; } });
69
73
  var mem_1 = require("./mem");
@@ -98,6 +102,8 @@ var processes_1 = require("./processes");
98
102
  Object.defineProperty(exports, "processes", { enumerable: true, get: function () { return processes_1.processes; } });
99
103
  var process_load_1 = require("./process-load");
100
104
  Object.defineProperty(exports, "processLoad", { enumerable: true, get: function () { return process_load_1.processLoad; } });
105
+ var serial_ports_1 = require("./serial-ports");
106
+ Object.defineProperty(exports, "serialPorts", { enumerable: true, get: function () { return serial_ports_1.serialPorts; } });
101
107
  var services_1 = require("./services");
102
108
  Object.defineProperty(exports, "services", { enumerable: true, get: function () { return services_1.services; } });
103
109
  var shell_1 = require("./shell");
@@ -0,0 +1,2 @@
1
+ import type { InetPublicIpData } from './common/types';
2
+ export declare const inetPublicIp: (timeout?: number) => Promise<InetPublicIpData>;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.inetPublicIp = void 0;
4
+ const common_1 = require("./common");
5
+ const internet_1 = require("./common/internet");
6
+ const inetPublicIp = async (timeout) => {
7
+ await (0, common_1.nextTick)();
8
+ return (0, internet_1.publicIp)(timeout);
9
+ };
10
+ exports.inetPublicIp = inetPublicIp;