systeminformation 6.0.0-beta.1 → 6.0.0-beta.11

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 (94) hide show
  1. package/README.md +41 -7
  2. package/dist/bsd/network-stats.js +2 -2
  3. package/dist/common/darwin.d.ts +2 -0
  4. package/dist/common/darwin.js +17 -1
  5. package/dist/common/defaults.d.ts +2 -1
  6. package/dist/common/defaults.js +21 -5
  7. package/dist/common/exec.js +1 -1
  8. package/dist/common/files.d.ts +9 -0
  9. package/dist/common/files.js +67 -3
  10. package/dist/common/filesys.d.ts +10 -0
  11. package/dist/common/filesys.js +41 -10
  12. package/dist/common/host.js +55 -3
  13. package/dist/common/mappings.js +2 -1
  14. package/dist/common/network.js +4 -4
  15. package/dist/common/nvidia.d.ts +1 -1
  16. package/dist/common/nvidia.js +4 -5
  17. package/dist/common/parse.d.ts +4 -6
  18. package/dist/common/parse.js +24 -69
  19. package/dist/common/security.d.ts +1 -0
  20. package/dist/common/security.js +3 -1
  21. package/dist/common/types.d.ts +33 -5
  22. package/dist/cpu-current-load.js +28 -6
  23. package/dist/cpu-current-speed.js +5 -3
  24. package/dist/darwin/battery.d.ts +1 -1
  25. package/dist/darwin/battery.js +15 -5
  26. package/dist/darwin/camera.js +3 -3
  27. package/dist/darwin/disk-layout.js +16 -12
  28. package/dist/darwin/disks-io.js +3 -3
  29. package/dist/darwin/displays.js +34 -1
  30. package/dist/darwin/fans.d.ts +2 -0
  31. package/dist/darwin/fans.js +28 -0
  32. package/dist/darwin/gpu.js +1 -1
  33. package/dist/darwin/index.d.ts +2 -0
  34. package/dist/darwin/index.js +6 -2
  35. package/dist/darwin/keyboard.js +4 -4
  36. package/dist/darwin/mouse.js +4 -4
  37. package/dist/darwin/network-interfaces.js +5 -10
  38. package/dist/darwin/network-stats.js +5 -5
  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 +4 -0
  44. package/dist/get-data.js +6 -2
  45. package/dist/index.d.ts +2 -0
  46. package/dist/index.js +6 -2
  47. package/dist/linux/audio.js +59 -0
  48. package/dist/linux/baseboard.js +9 -20
  49. package/dist/linux/bios.js +6 -15
  50. package/dist/linux/camera.js +2 -1
  51. package/dist/linux/chassis.js +4 -10
  52. package/dist/linux/cpu-temperature.js +34 -19
  53. package/dist/linux/cpu.js +3 -1
  54. package/dist/linux/disk-layout.js +7 -10
  55. package/dist/linux/disks-io.js +9 -9
  56. package/dist/linux/displays.js +40 -2
  57. package/dist/linux/fans.d.ts +2 -0
  58. package/dist/linux/fans.js +92 -0
  59. package/dist/linux/fs-size.js +160 -34
  60. package/dist/linux/fs-stats.js +6 -9
  61. package/dist/linux/gpu.js +15 -15
  62. package/dist/linux/index.d.ts +2 -0
  63. package/dist/linux/index.js +6 -2
  64. package/dist/linux/mem-layout.js +2 -2
  65. package/dist/linux/network-interfaces.js +36 -39
  66. package/dist/linux/network-stats.js +8 -36
  67. package/dist/linux/npu.js +2 -1
  68. package/dist/linux/os-info.js +19 -4
  69. package/dist/linux/printer.js +4 -4
  70. package/dist/linux/process-load.js +9 -12
  71. package/dist/linux/processes.js +89 -80
  72. package/dist/linux/serial-ports.d.ts +2 -0
  73. package/dist/linux/serial-ports.js +102 -0
  74. package/dist/linux/services.js +179 -47
  75. package/dist/linux/system.js +1 -7
  76. package/dist/linux/uuid.js +4 -10
  77. package/dist/serial-ports.d.ts +1 -0
  78. package/dist/serial-ports.js +17 -0
  79. package/dist/versions.js +32 -77
  80. package/dist/windows/disk-layout.js +3 -0
  81. package/dist/windows/disks-io.js +3 -3
  82. package/dist/windows/displays.js +43 -12
  83. package/dist/windows/fans.d.ts +2 -0
  84. package/dist/windows/fans.js +71 -0
  85. package/dist/windows/index.d.ts +2 -0
  86. package/dist/windows/index.js +6 -2
  87. package/dist/windows/network-interfaces.js +20 -29
  88. package/dist/windows/network-stats.js +4 -2
  89. package/dist/windows/process-load.js +7 -5
  90. package/dist/windows/processes.js +17 -11
  91. package/dist/windows/serial-ports.d.ts +3 -0
  92. package/dist/windows/serial-ports.js +73 -0
  93. package/dist/windows/services.js +3 -0
  94. package/package.json +1 -1
@@ -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,12 @@ 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
+ workAreaResolutionX: null,
42
+ workAreaResolutionY: null,
43
+ workAreaPositionX: null,
44
+ workAreaPositionY: null,
45
+ currentRefreshRate: currentResolutionParts.length > 1 ? parseInt(currentResolutionParts[1], 10) : null,
46
+ scale: null
41
47
  });
42
48
  });
43
49
  }
@@ -84,6 +90,32 @@ const getDisplayPositionDarwin = async (displays) => {
84
90
  catch { }
85
91
  return displays;
86
92
  };
93
+ const jxaVisibleFrames = 'ObjC.import("AppKit"); var s = $.NSScreen.screens, out = []; for (var i = 0; i < s.count; i++) { var sc = s.objectAtIndex(i), f = sc.frame, v = sc.visibleFrame; out.push([sc.deviceDescription.objectForKey($("NSScreenNumber")).intValue, f.origin.x, f.origin.y, f.size.width, f.size.height, v.origin.x, v.origin.y, v.size.width, v.size.height].join("|")); } out.join("\\n")';
94
+ const getWorkAreaDarwin = async (displays) => {
95
+ try {
96
+ const { stdout } = await (0, exec_1.execSave)(`osascript -l JavaScript -e '${jxaVisibleFrames}'`);
97
+ const screens = stdout
98
+ .toString()
99
+ .split('\n')
100
+ .map((line) => line.split('|').map((part) => parseFloat(part)))
101
+ .filter((parts) => parts.length === 9 && !Number.isNaN(parts[0]));
102
+ const main = screens.find((parts) => parts[1] === 0 && parts[2] === 0);
103
+ if (!main) {
104
+ return displays;
105
+ }
106
+ screens.forEach((parts) => {
107
+ const display = displays.find((element) => (0, common_1.toInt)(element.displayId || '') === parts[0]);
108
+ if (display) {
109
+ display.workAreaResolutionX = Math.round(parts[7]);
110
+ display.workAreaResolutionY = Math.round(parts[8]);
111
+ display.workAreaPositionX = Math.round(parts[5]);
112
+ display.workAreaPositionY = Math.round(main[4] - (parts[6] + parts[8]));
113
+ }
114
+ });
115
+ }
116
+ catch { }
117
+ return displays;
118
+ };
87
119
  const displays = async () => {
88
120
  await (0, common_1.nextTick)();
89
121
  let result = [];
@@ -91,6 +123,7 @@ const displays = async () => {
91
123
  const { stdout } = await (0, exec_1.shareInflight)('SPDisplaysDataType', () => (0, exec_1.exec)('system_profiler -xml -detailLevel full SPDisplaysDataType'));
92
124
  result = parseDisplaysDarwin((0, darwin_1.plistParser)(stdout));
93
125
  result = await getDisplayPositionDarwin(result);
126
+ result = await getWorkAreaDarwin(result);
94
127
  }
95
128
  catch { }
96
129
  return result;
@@ -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;
@@ -12,7 +12,7 @@ const parseControllersDarwin = (graphicsArr) => {
12
12
  const bus = (item.sppci_bus || '').indexOf('builtin') > -1 ? 'Built-In' : (item.sppci_bus || '').indexOf('pcie') > -1 ? 'PCIe' : '';
13
13
  const vram = (parseInt(item.spdisplays_vram || '', 10) || 0) * ((item.spdisplays_vram || '').indexOf('GB') > -1 ? 1024 : 1);
14
14
  const vramDyn = (parseInt(item.spdisplays_vram_shared || '', 10) || 0) * ((item.spdisplays_vram_shared || '').indexOf('GB') > -1 ? 1024 : 1);
15
- const metalVersion = (0, mappings_1.graphicsMetalVersion)(item.spdisplays_metal || item.spdisplays_metalfamily || '');
15
+ const metalVersion = (0, mappings_1.graphicsMetalVersion)(item.spdisplays_mtlgpufamilysupport || item.spdisplays_metal || item.spdisplays_metalfamily || '');
16
16
  controllers.push({
17
17
  vendor: (0, mappings_1.graphicsModelToVendor)(item.spdisplays_vendor || '') || item.spdisplays_vendor || '',
18
18
  model: item.sppci_model || '',
@@ -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");
@@ -56,11 +56,11 @@ const filterBluetooth = (data) => {
56
56
  const keyboard = async () => {
57
57
  await (0, common_1.nextTick)();
58
58
  try {
59
- const { stdout } = await (0, exec_1.exec)('system_profiler SPSPIDataType SPUSBDataType SPBluetoothDataType -xml');
59
+ const { stdout } = await (0, exec_1.exec)('system_profiler SPSPIDataType SPUSBDataType SPUSBHostDataType SPBluetoothDataType -xml');
60
60
  const data = (0, darwin_1.plistParser)(stdout, false);
61
- const spiData = data.length >= 2 && data[0]._items ? data[0]._items : [];
62
- const usbData = data.length >= 2 && data[1]._items ? data[1]._items : [];
63
- const bluetoothData = data.length >= 3 && data[2]._items ? data[2]._items : [];
61
+ const spiData = (0, darwin_1.spItems)(data, 'SPSPIDataType');
62
+ const usbData = (0, darwin_1.spItems)(data, darwin_1.USB_DATA_TYPES);
63
+ const bluetoothData = (0, darwin_1.spItems)(data, 'SPBluetoothDataType');
64
64
  let result = parseKeyboard(spiData);
65
65
  result = result.concat(parseUsb(usbData));
66
66
  result = result.concat(filterBluetooth((0, bluetooth_1.parseBluetooth)(bluetoothData)));
@@ -61,11 +61,11 @@ const filterBluetooth = (data) => {
61
61
  const mouse = async () => {
62
62
  await (0, common_1.nextTick)();
63
63
  try {
64
- const { stdout } = await (0, exec_1.exec)('system_profiler SPSPIDataType SPUSBDataType SPBluetoothDataType -xml');
64
+ const { stdout } = await (0, exec_1.exec)('system_profiler SPSPIDataType SPUSBDataType SPUSBHostDataType SPBluetoothDataType -xml');
65
65
  const data = (0, darwin_1.plistParser)(stdout, false);
66
- const spiData = data.length >= 2 && data[0]._items ? data[0]._items : [];
67
- const usbData = data.length >= 2 && data[1]._items ? data[1]._items : [];
68
- const bluetoothData = data.length >= 3 && data[2]._items ? data[2]._items : [];
66
+ const spiData = (0, darwin_1.spItems)(data, 'SPSPIDataType');
67
+ const usbData = (0, darwin_1.spItems)(data, darwin_1.USB_DATA_TYPES);
68
+ const bluetoothData = (0, darwin_1.spItems)(data, 'SPBluetoothDataType');
69
69
  let result = parseKeyboard(spiData);
70
70
  result = result.concat(parseUsb(usbData));
71
71
  result = result.concat(filterBluetooth((0, bluetooth_1.parseBluetooth)(bluetoothData)));
@@ -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() !== '') {
@@ -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;
@@ -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;
@@ -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';
@@ -43,6 +44,7 @@ export { pci } from './pci';
43
44
  export { printer } from './printer';
44
45
  export { processes } from './processes';
45
46
  export { processLoad } from './process-load';
47
+ export { serialPorts } from './serial-ports';
46
48
  export { services } from './services';
47
49
  export { shell } from './shell';
48
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.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.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.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 = exports.printer = 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");
@@ -100,6 +102,8 @@ var processes_1 = require("./processes");
100
102
  Object.defineProperty(exports, "processes", { enumerable: true, get: function () { return processes_1.processes; } });
101
103
  var process_load_1 = require("./process-load");
102
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; } });
103
107
  var services_1 = require("./services");
104
108
  Object.defineProperty(exports, "services", { enumerable: true, get: function () { return services_1.services; } });
105
109
  var shell_1 = require("./shell");
@@ -4,8 +4,11 @@ exports.audio = void 0;
4
4
  const node_os_1 = require("node:os");
5
5
  const common_1 = require("../common");
6
6
  const const_1 = require("../common/const");
7
+ const promises_1 = require("node:fs/promises");
7
8
  const exec_1 = require("../common/exec");
9
+ const files_1 = require("../common/files");
8
10
  const mappings_1 = require("../common/mappings");
11
+ const security_1 = require("../common/security");
9
12
  const getAudioPci = async () => {
10
13
  const result = [];
11
14
  try {
@@ -46,6 +49,59 @@ const parseAudioPci = (lines, audioPCI) => {
46
49
  status: 'online'
47
50
  };
48
51
  };
52
+ const parseAudioAlsa = (stdout) => {
53
+ const result = [];
54
+ const [cards, pcms] = `${stdout}`.split('--pcm--');
55
+ const lines = (cards || '').split('\n');
56
+ lines.forEach((line, i) => {
57
+ const card = line.match(/^\s*(\d+)\s+\[(.+?)\s*\]:\s*(.*)$/);
58
+ if (card && card[3].trim()) {
59
+ const index = card[1];
60
+ const sep = card[3].lastIndexOf(' - ');
61
+ const name = (sep >= 0 ? card[3].substring(sep + 3) : card[3]).trim();
62
+ let driver = (sep >= 0 ? card[3].substring(0, sep) : '').trim();
63
+ if (name && driver.endsWith(name)) {
64
+ driver = driver.substring(0, driver.length - name.length).trim();
65
+ }
66
+ const longName = (lines[i + 1] || '').trim();
67
+ const manufacturer = longName.indexOf(name) > 0 ? longName.substring(0, longName.indexOf(name)).trim() : '';
68
+ const devices = (pcms || '').split('\n').filter((pcm) => pcm.indexOf(`/card${index}/pcm`) >= 0);
69
+ const out = devices.some((pcm) => pcm.trim().endsWith('p'));
70
+ const isIn = devices.some((pcm) => pcm.trim().endsWith('c'));
71
+ const usb = `${driver} ${longName}`.toLowerCase().indexOf('usb') >= 0;
72
+ const hdmi = `${card[2]} ${name}`.toLowerCase().indexOf('hdmi') >= 0;
73
+ result.push({
74
+ id: `hw:${index}`,
75
+ name,
76
+ manufacturer,
77
+ revision: null,
78
+ driver,
79
+ default: null,
80
+ channel: usb ? 'USB' : hdmi ? 'HDMI' : 'Onboard',
81
+ type: (0, mappings_1.audioTypeLabel)(name, isIn, out),
82
+ in: devices.length ? isIn : null,
83
+ out: devices.length ? out : null,
84
+ status: 'online'
85
+ });
86
+ }
87
+ });
88
+ return result;
89
+ };
90
+ const getAudioAlsa = async () => {
91
+ try {
92
+ const cards = await (0, files_1.readSysfs)('/proc/asound/cards');
93
+ const pcms = [];
94
+ for (const card of (await (0, promises_1.readdir)('/proc/asound')).filter((entry) => /^card\d+$/.test(entry)).sort()) {
95
+ for (const pcm of (await (0, promises_1.readdir)(`/proc/asound/${card}`)).filter((entry) => entry.startsWith('pcm') && (0, security_1.isSafePathSegment)(entry)).sort()) {
96
+ pcms.push(`/proc/asound/${card}/${pcm}`);
97
+ }
98
+ }
99
+ return parseAudioAlsa(`${cards}\n--pcm--\n${pcms.join('\n')}\n`);
100
+ }
101
+ catch {
102
+ return [];
103
+ }
104
+ };
49
105
  const audio = async () => {
50
106
  await (0, common_1.nextTick)();
51
107
  const result = [];
@@ -62,6 +118,9 @@ const audio = async () => {
62
118
  });
63
119
  }
64
120
  catch { }
121
+ if (!result.length) {
122
+ return await getAudioAlsa();
123
+ }
65
124
  return result;
66
125
  };
67
126
  exports.audio = audio;
@@ -7,36 +7,25 @@ const common_1 = require("../common");
7
7
  const const_1 = require("../common/const");
8
8
  const defaults_1 = require("../common/defaults");
9
9
  const exec_1 = require("../common/exec");
10
+ const files_1 = require("../common/files");
10
11
  const parse_1 = require("../common/parse");
11
12
  const raspberry_1 = require("../common/raspberry");
12
13
  const baseboard = async () => {
13
14
  await (0, common_1.nextTick)();
14
15
  const defaults = (0, common_1.cloneObj)(defaults_1.initBaseboard);
15
- let cmd = '';
16
- if (process.arch === 'arm') {
17
- cmd = 'cat /proc/cpuinfo | grep Serial';
18
- }
19
- else {
20
- cmd = 'export LC_ALL=C; dmidecode -t 2 2>/dev/null; unset LC_ALL';
21
- }
22
- const workload = [];
23
- workload.push((0, exec_1.exec)(cmd, const_1.execOptsLinux));
24
- workload.push((0, exec_1.exec)('export LC_ALL=C; dmidecode -t memory 2>/dev/null', const_1.execOptsLinux));
25
- const data = await Promise.allSettled(workload).then((results) => results.map((result) => (result.status === 'fulfilled' ? result.value : null)));
26
- let lines = data[0] ? data[0].stdout.split('\n') : [''];
16
+ const boardTask = process.arch === 'arm'
17
+ ? (0, files_1.readFileLines)('/proc/cpuinfo').then((cpuinfo) => cpuinfo.filter((line) => line.indexOf('Serial') >= 0))
18
+ : (0, exec_1.execSave)('export LC_ALL=C; dmidecode -t 2 2>/dev/null; unset LC_ALL', const_1.execOptsLinux).then((res) => res.stdout.split('\n'));
19
+ const memTask = (0, exec_1.execSave)('export LC_ALL=C; dmidecode -t memory 2>/dev/null', const_1.execOptsLinux).then((res) => res.stdout.split('\n'));
20
+ const [boardLines, memLines] = await Promise.all([boardTask, memTask]);
21
+ let lines = boardLines;
27
22
  let manufacturer = (0, common_1.getValue)(lines, 'Manufacturer');
28
23
  let model = (0, common_1.getValue)(lines, 'Product Name');
29
24
  let version = (0, common_1.getValue)(lines, 'Version');
30
25
  let serial = (0, common_1.getValue)(lines, 'Serial Number');
31
26
  let assetTag = (0, common_1.getValue)(lines, 'Asset Tag');
32
- cmd = `echo -n "board_asset_tag: "; cat /sys/devices/virtual/dmi/id/board_asset_tag 2>/dev/null; echo;
33
- echo -n "board_name: "; cat /sys/devices/virtual/dmi/id/board_name 2>/dev/null; echo;
34
- echo -n "board_serial: "; cat /sys/devices/virtual/dmi/id/board_serial 2>/dev/null; echo;
35
- echo -n "board_vendor: "; cat /sys/devices/virtual/dmi/id/board_vendor 2>/dev/null; echo;
36
- echo -n "board_version: "; cat /sys/devices/virtual/dmi/id/board_version 2>/dev/null; echo;`;
37
27
  try {
38
- const { stdout } = await (0, exec_1.exec)(cmd, const_1.execOptsLinux);
39
- lines = stdout.split('\n');
28
+ lines = await (0, files_1.readSysfsMany)(files_1.DMI_PATH, ['board_asset_tag', 'board_name', 'board_serial', 'board_vendor', 'board_version']);
40
29
  manufacturer = !manufacturer ? (0, common_1.getValue)(lines, 'board_vendor') : manufacturer;
41
30
  model = !model ? (0, common_1.getValue)(lines, 'board_name') : model;
42
31
  version = !version ? (0, common_1.getValue)(lines, 'board_version') : version;
@@ -49,7 +38,7 @@ const baseboard = async () => {
49
38
  model = (0, parse_1.cleanDefaults)(model);
50
39
  version = (0, parse_1.cleanDefaults)(version);
51
40
  manufacturer = (0, parse_1.cleanDefaults)(manufacturer);
52
- lines = data[1] ? data[1].stdout.split('\n') : [''];
41
+ lines = memLines;
53
42
  let memMax = (0, common_1.toInt)((0, common_1.getValue)(lines, 'Maximum Capacity')) * 1024 * 1024 * 1024 || null;
54
43
  let memSlots = (0, common_1.toInt)((0, common_1.getValue)(lines, 'Number Of Devices')) || null;
55
44
  let linesRpi = [];