systeminformation 6.0.0-beta.23 → 6.0.0-beta.25

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 (71) hide show
  1. package/README.md +47 -5
  2. package/dist/bsd/index.d.ts +2 -0
  3. package/dist/bsd/index.js +5 -1
  4. package/dist/common/const.d.ts +2 -0
  5. package/dist/common/const.js +8 -3
  6. package/dist/common/defaults.js +15 -4
  7. package/dist/common/disk-speed.d.ts +20 -0
  8. package/dist/common/disk-speed.js +142 -0
  9. package/dist/common/exec.d.ts +5 -2
  10. package/dist/common/exec.js +6 -3
  11. package/dist/common/filesys.d.ts +1 -1
  12. package/dist/common/filesys.js +24 -4
  13. package/dist/common/mappings.d.ts +1 -1
  14. package/dist/common/mappings.js +14 -4
  15. package/dist/common/types.d.ts +32 -0
  16. package/dist/common/windows.d.ts +1 -0
  17. package/dist/common/windows.js +21 -7
  18. package/dist/cpu-current-load.js +45 -0
  19. package/dist/cpu-current-speed.js +6 -0
  20. package/dist/darwin/cpu-current-speed.d.ts +2 -0
  21. package/dist/darwin/cpu-current-speed.js +30 -0
  22. package/dist/darwin/cpu-temperature.js +7 -13
  23. package/dist/darwin/disk-speed.d.ts +2 -0
  24. package/dist/darwin/disk-speed.js +18 -0
  25. package/dist/darwin/disks-io.js +3 -1
  26. package/dist/darwin/fans.js +11 -13
  27. package/dist/darwin/gpu.d.ts +1 -1
  28. package/dist/darwin/gpu.js +4 -4
  29. package/dist/darwin/index.d.ts +2 -0
  30. package/dist/darwin/index.js +6 -2
  31. package/dist/darwin/network-interfaces.js +14 -4
  32. package/dist/darwin/network-routes.d.ts +3 -0
  33. package/dist/darwin/network-routes.js +74 -0
  34. package/dist/disk-speed.d.ts +1 -0
  35. package/dist/disk-speed.js +17 -0
  36. package/dist/get.js +5 -5
  37. package/dist/index.d.ts +11 -8
  38. package/dist/index.js +28 -21
  39. package/dist/linux/block-devices.d.ts +1 -1
  40. package/dist/linux/block-devices.js +21 -5
  41. package/dist/linux/cpu-topology.d.ts +2 -0
  42. package/dist/linux/cpu-topology.js +15 -0
  43. package/dist/linux/disk-speed.d.ts +2 -0
  44. package/dist/linux/disk-speed.js +16 -0
  45. package/dist/linux/disks-io.d.ts +1 -1
  46. package/dist/linux/disks-io.js +18 -7
  47. package/dist/linux/index.d.ts +2 -0
  48. package/dist/linux/index.js +6 -2
  49. package/dist/linux/mem.js +20 -1
  50. package/dist/linux/network-interfaces.js +18 -7
  51. package/dist/linux/network-routes.d.ts +4 -0
  52. package/dist/linux/network-routes.js +69 -0
  53. package/dist/linux/os-info.js +32 -4
  54. package/dist/linux/pci.d.ts +1 -1
  55. package/dist/linux/pci.js +4 -3
  56. package/dist/network-routes.d.ts +1 -0
  57. package/dist/network-routes.js +17 -0
  58. package/dist/powershell.d.ts +2 -0
  59. package/dist/powershell.js +15 -0
  60. package/dist/windows/block-devices.js +6 -1
  61. package/dist/windows/cpu-topology.d.ts +3 -0
  62. package/dist/windows/cpu-topology.js +90 -0
  63. package/dist/windows/disk-speed.d.ts +6 -0
  64. package/dist/windows/disk-speed.js +73 -0
  65. package/dist/windows/disks-io.js +3 -1
  66. package/dist/windows/index.d.ts +2 -0
  67. package/dist/windows/index.js +6 -2
  68. package/dist/windows/network-interfaces.js +6 -3
  69. package/dist/windows/network-routes.d.ts +3 -0
  70. package/dist/windows/network-routes.js +41 -0
  71. package/package.json +1 -1
@@ -376,6 +376,12 @@ export type CurrentLoadCpuData = {
376
376
  rawLoadIdle: number;
377
377
  rawLoadIowait: number;
378
378
  rawLoadIrq: number;
379
+ coreId: number | null;
380
+ socketId: number | null;
381
+ };
382
+ export type CpuTopologyData = {
383
+ coreId: number | null;
384
+ socketId: number | null;
379
385
  };
380
386
  export type WifiNetworkData = {
381
387
  ssid: string;
@@ -448,6 +454,8 @@ export type MemData = {
448
454
  swapfree: number;
449
455
  writeback: number;
450
456
  dirty: number;
457
+ swapin_sec: number | null;
458
+ swapout_sec: number | null;
451
459
  };
452
460
  export type MemLayoutData = {
453
461
  size: number;
@@ -641,6 +649,19 @@ export type FsBlockDevicesData = {
641
649
  protocol: string;
642
650
  group: string;
643
651
  device: string;
652
+ partUuid: string;
653
+ partLabel: string;
654
+ partType: string;
655
+ partFlags: string;
656
+ partStart: number | null;
657
+ };
658
+ export type DiskSpeedData = {
659
+ path: string;
660
+ fs: string;
661
+ sizeMB: number;
662
+ writeSpeed: number | null;
663
+ readSpeed: number | null;
664
+ ms: number;
644
665
  };
645
666
  export type FsStatsData = {
646
667
  rx: number;
@@ -664,6 +685,8 @@ export type DisksIoData = {
664
685
  rWaitPercent: number | null;
665
686
  wWaitPercent: number | null;
666
687
  tWaitPercent: number | null;
688
+ busyPercent: number | null;
689
+ idlePercent: number | null;
667
690
  ms: number;
668
691
  };
669
692
  export type SmartData = {
@@ -979,6 +1002,14 @@ export type NetworkInterfacesData = {
979
1002
  ieee8021xAuth: string;
980
1003
  ieee8021xState: string;
981
1004
  carrierChanges: number;
1005
+ bridgeMembers: string[];
1006
+ };
1007
+ export type NetworkRouteData = {
1008
+ destination: string;
1009
+ gateway: string;
1010
+ iface: string;
1011
+ metric: number | null;
1012
+ family: string;
982
1013
  };
983
1014
  export type NetworkStatsData = {
984
1015
  iface: string;
@@ -1053,6 +1084,7 @@ export type PciData = {
1053
1084
  subDeviceId: string;
1054
1085
  revision: string;
1055
1086
  driver: string;
1087
+ iommuGroup: string;
1056
1088
  };
1057
1089
  export type NpuData = {
1058
1090
  vendor: string;
@@ -45,6 +45,7 @@ declare class PowerShellPool {
45
45
  workers: PowerShellWorker[];
46
46
  _rr: number;
47
47
  _started: Promise<void> | null;
48
+ _generation: number;
48
49
  constructor({ size, env }?: {
49
50
  size?: number;
50
51
  env?: NodeJS.ProcessEnv;
@@ -2,17 +2,16 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
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");
6
5
  const files_1 = require("../common/files");
7
6
  const const_1 = require("./const");
8
- const WINDIR = process.env.WINDIR || String.raw `C:\Windows`;
7
+ const exec_1 = require("./exec");
9
8
  const JOB_TIMEOUT_MS = 60000;
10
9
  let _powerShell = '';
11
10
  const pickPowerShellExecutable = async () => {
12
11
  if (!const_1.WINDOWS)
13
12
  return '';
14
13
  if (!_powerShell) {
15
- const defaultPath = String.raw `${WINDIR}\system32\WindowsPowerShell\v1.0\powershell.exe`;
14
+ const defaultPath = String.raw `${const_1.WINDIR}\system32\WindowsPowerShell\v1.0\powershell.exe`;
16
15
  if (await (0, files_1.fileExists)(defaultPath)) {
17
16
  _powerShell = defaultPath;
18
17
  }
@@ -65,6 +64,7 @@ class PowerShellWorker {
65
64
  this.child = (0, node_child_process_1.spawn)(this.exe, args, {
66
65
  stdio: 'pipe',
67
66
  windowsHide: true,
67
+ cwd: const_1.WIN_CWD,
68
68
  env: { ...process.env, ...this.env }
69
69
  });
70
70
  this.child.stdout.setEncoding('utf8');
@@ -243,6 +243,7 @@ class PowerShellPool {
243
243
  workers;
244
244
  _rr;
245
245
  _started;
246
+ _generation;
246
247
  constructor({ size = 2, env = { LANG: 'en_US.UTF-8' } } = {}) {
247
248
  this.size = Math.max(1, Math.trunc(size));
248
249
  this.env = env;
@@ -250,18 +251,24 @@ class PowerShellPool {
250
251
  this._rr = 0;
251
252
  this.exe = '';
252
253
  this._started = null;
254
+ this._generation = 0;
253
255
  }
254
256
  start() {
255
257
  if (!this._started) {
258
+ const generation = ++this._generation;
256
259
  this._started = (async () => {
257
- this.exe = await pickPowerShellExecutable();
260
+ const exe = await pickPowerShellExecutable();
261
+ if (generation !== this._generation)
262
+ return;
263
+ this.exe = exe;
258
264
  for (let i = 0; i < this.size; i++) {
259
265
  const w = new PowerShellWorker({ exe: this.exe, env: this.env });
260
266
  w.start();
261
267
  this.workers.push(w);
262
268
  }
263
269
  })().catch((err) => {
264
- this._started = null;
270
+ if (generation === this._generation)
271
+ this._started = null;
265
272
  throw err;
266
273
  });
267
274
  }
@@ -269,6 +276,10 @@ class PowerShellPool {
269
276
  }
270
277
  async exec(script) {
271
278
  await this.start();
279
+ if (!this.workers.length)
280
+ await this.start();
281
+ if (!this.workers.length)
282
+ throw new Error('PowerShell pool not available');
272
283
  const idx = this._rr++ % this.workers.length;
273
284
  let w = this.workers[idx];
274
285
  if (w.dead) {
@@ -279,6 +290,7 @@ class PowerShellPool {
279
290
  return w.exec(script);
280
291
  }
281
292
  async stop() {
293
+ this._generation++;
282
294
  for (const w of this.workers)
283
295
  w.stop();
284
296
  this.workers = [];
@@ -323,7 +335,9 @@ const parseWindowsPnpLocations = (stdout) => {
323
335
  };
324
336
  exports.parseWindowsPnpLocations = parseWindowsPnpLocations;
325
337
  const matchPnpLocation = (deviceId, locations) => {
326
- const id = String(deviceId ?? '').trim().toLowerCase();
338
+ const id = String(deviceId ?? '')
339
+ .trim()
340
+ .toLowerCase();
327
341
  if (!id) {
328
342
  return '';
329
343
  }
@@ -336,7 +350,7 @@ const matchPnpLocation = (deviceId, locations) => {
336
350
  };
337
351
  exports.matchPnpLocation = matchPnpLocation;
338
352
  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\" }";
353
+ '$l = ($_ | Get-PnpDeviceProperty -KeyName DEVPKEY_Device_LocationInfo -ErrorAction SilentlyContinue).Data; "$($_.InstanceId)|$l" }';
340
354
  const windowsPciBusAddresses = async () => {
341
355
  try {
342
356
  return (0, exports.parseWindowsPnpLocations)(await (0, exec_1.shareInflight)('pnpDisplayLocations', () => exports.ps.exec(PS_PNP_DISPLAY_LOCATIONS)));
@@ -53,6 +53,46 @@ const avgLoadEwma = (previous, busyCores, seconds) => {
53
53
  };
54
54
  exports.avgLoadEwma = avgLoadEwma;
55
55
  const avgLoadFromEwma = (cores) => (cores ? parseFloat((Math.max(..._avgLoadEwma) / cores).toFixed(2)) : 0);
56
+ const TOPOLOGY_TRIES = 3;
57
+ let _topology = [];
58
+ let _topologyRead = null;
59
+ let _topologyTries = 0;
60
+ let _topologyTriesCount = -1;
61
+ const readCpuTopology = async () => {
62
+ switch (true) {
63
+ case const_1.LINUX:
64
+ return (await import('./linux/cpu-topology.js')).cpuTopology();
65
+ case const_1.WINDOWS:
66
+ return (await import('./windows/cpu-topology.js')).cpuTopology();
67
+ case const_1.DARWIN:
68
+ return (0, node_os_1.arch)() === 'arm64' ? (0, node_os_1.cpus)().map((_, i) => ({ coreId: i, socketId: 0 })) : [];
69
+ default:
70
+ return [];
71
+ }
72
+ };
73
+ const cpuTopology = async (count) => {
74
+ if (_topology.length !== count) {
75
+ if (_topologyTriesCount !== count) {
76
+ _topologyTriesCount = count;
77
+ _topologyTries = 0;
78
+ }
79
+ if (_topologyTries < TOPOLOGY_TRIES || _topologyRead) {
80
+ if (!_topologyRead) {
81
+ _topologyTries++;
82
+ _topologyRead = readCpuTopology()
83
+ .catch(() => [])
84
+ .finally(() => {
85
+ _topologyRead = null;
86
+ });
87
+ }
88
+ const topology = await _topologyRead;
89
+ if (topology.length === count) {
90
+ _topology = topology;
91
+ }
92
+ }
93
+ }
94
+ return _topology.length === count ? _topology : [];
95
+ };
56
96
  const currentLoad = async () => {
57
97
  await (0, common_1.nextTick)();
58
98
  const loads = (0, node_os_1.loadavg)().map((x) => x / (0, node_os_1.cpus)().length);
@@ -290,6 +330,11 @@ const currentLoad = async () => {
290
330
  cpus: cores
291
331
  };
292
332
  }
333
+ const topology = await cpuTopology(result.cpus.length);
334
+ result.cpus.forEach((core, i) => {
335
+ core.coreId = topology[i]?.coreId ?? null;
336
+ core.socketId = topology[i]?.socketId ?? null;
337
+ });
293
338
  return result;
294
339
  };
295
340
  exports.currentLoad = currentLoad;
@@ -71,6 +71,12 @@ const getCpuCurrentSpeed = async () => {
71
71
  exports.getCpuCurrentSpeed = getCpuCurrentSpeed;
72
72
  const cpuCurrentSpeed = async () => {
73
73
  await (0, common_1.nextTick)();
74
+ if (const_1.DARWIN && (0, node_os_1.arch)() === 'arm64') {
75
+ const appleSilicon = await (await import('./darwin/cpu-current-speed.js')).appleSiliconSpeed();
76
+ if (appleSilicon) {
77
+ return appleSilicon;
78
+ }
79
+ }
74
80
  let result = await (0, exports.getCpuCurrentSpeed)();
75
81
  if (result.avg === 0 && (0, cpu_1.getCpuSpeed)() !== 0) {
76
82
  const currCpuSpeed = (0, cpu_1.getCpuSpeed)();
@@ -0,0 +1,2 @@
1
+ import type { CpuCurrentSpeedObject } from '../common/types';
2
+ export declare const appleSiliconSpeed: () => Promise<CpuCurrentSpeedObject | null>;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.appleSiliconSpeed = void 0;
4
+ const round2 = (value) => Math.round(value * 100) / 100;
5
+ const appleSiliconSpeed = async () => {
6
+ try {
7
+ const smc = require('macos-smc');
8
+ if (typeof smc.frequencies !== 'function') {
9
+ return null;
10
+ }
11
+ const res = await smc.frequencies();
12
+ const cores = (res?.cpu?.cores || [])
13
+ .map((core) => (typeof core?.mhz === 'number' ? core.mhz : core?.minMhz))
14
+ .filter((mhz) => typeof mhz === 'number' && mhz > 0)
15
+ .map((mhz) => round2(mhz / 1000));
16
+ if (!cores.length) {
17
+ return null;
18
+ }
19
+ return {
20
+ min: Math.min(...cores),
21
+ max: Math.max(...cores),
22
+ avg: round2(cores.reduce((sum, speed) => sum + speed, 0) / cores.length),
23
+ cores
24
+ };
25
+ }
26
+ catch {
27
+ return null;
28
+ }
29
+ };
30
+ exports.appleSiliconSpeed = appleSiliconSpeed;
@@ -23,19 +23,13 @@ const cpuTemperature = async () => {
23
23
  }
24
24
  catch { }
25
25
  try {
26
- const macosTemp = require('macos-temperature-sensor');
27
- const res = macosTemp.temperature();
28
- if (res.cpu) {
29
- result.main = Math.round(res.cpu * 100) / 100;
30
- result.max = result.main;
31
- }
32
- if (res.soc) {
33
- result.chipset = Math.round(res.soc * 100) / 100;
34
- }
35
- if (res && res.cpuDieTemps && res.cpuDieTemps.length) {
36
- for (const temp of res.cpuDieTemps) {
37
- result.cores.push(Math.round(temp * 100) / 100);
38
- }
26
+ const smc = require('macos-smc');
27
+ const cpu = smc.temperatures()?.cpu;
28
+ if (typeof cpu?.max === 'number') {
29
+ const round2 = (value) => Math.round(value * 100) / 100;
30
+ result.main = round2(typeof cpu.avg === 'number' ? cpu.avg : cpu.max);
31
+ result.max = round2(cpu.max);
32
+ result.cores = (cpu.sensors || []).map((sensor) => round2(sensor.value));
39
33
  }
40
34
  }
41
35
  catch { }
@@ -0,0 +1,2 @@
1
+ import type { DiskSpeedData } from '../common/types';
2
+ export declare const diskSpeed: (path?: string, sizeMB?: number) => Promise<DiskSpeedData | null>;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.diskSpeed = void 0;
4
+ const disk_speed_1 = require("../common/disk-speed");
5
+ const noCache = (fd) => {
6
+ try {
7
+ const smc = require('macos-smc');
8
+ return typeof smc.noCache === 'function' && smc.noCache(fd) === true;
9
+ }
10
+ catch {
11
+ return false;
12
+ }
13
+ };
14
+ const diskSpeed = (path, sizeMB) => (0, disk_speed_1.runDiskSpeed)(path, sizeMB, {
15
+ prepareWrite: noCache,
16
+ readUncached: (file, bytes) => (0, disk_speed_1.readFileTimed)(file, bytes, noCache)
17
+ });
18
+ exports.diskSpeed = diskSpeed;
@@ -49,7 +49,9 @@ const disksIO = async () => {
49
49
  tWaitTime: filesys_1._disk_io.tWaitTimeDelta,
50
50
  rWaitPercent: filesys_1._disk_io.rWaitPercent,
51
51
  wWaitPercent: filesys_1._disk_io.wWaitPercent,
52
- tWaitPercent: filesys_1._disk_io.tWaitPercent
52
+ tWaitPercent: filesys_1._disk_io.tWaitPercent,
53
+ busyPercent: filesys_1._disk_io.busyPercent,
54
+ idlePercent: filesys_1._disk_io.idlePercent
53
55
  };
54
56
  }
55
57
  };
@@ -6,20 +6,18 @@ const fans = async () => {
6
6
  await (0, common_1.nextTick)();
7
7
  const result = [];
8
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
- });
9
+ const smc = require('macos-smc');
10
+ const res = smc.fans();
11
+ if (Array.isArray(res)) {
12
+ res.forEach((fan, index) => {
13
+ result.push({
14
+ id: `fan${typeof fan?.id === 'number' ? fan.id : index}`,
15
+ label: null,
16
+ rpm: typeof fan?.rpm === 'number' ? Math.round(fan.rpm) : null,
17
+ pwm: typeof fan?.percent === 'number' ? Math.round(fan.percent) : null,
18
+ source: 'SMC'
21
19
  });
22
- }
20
+ });
23
21
  }
24
22
  }
25
23
  catch { }
@@ -1,2 +1,2 @@
1
- import { GpuData } from '../common/types';
1
+ import type { GpuData } from '../common/types';
2
2
  export declare const gpu: () => Promise<GpuData[]>;
@@ -37,12 +37,12 @@ const gpu = async () => {
37
37
  const { stdout } = await (0, exec_1.shareInflight)('SPDisplaysDataType', () => (0, exec_1.exec)('system_profiler -xml -detailLevel full SPDisplaysDataType'));
38
38
  result = parseControllersDarwin((0, darwin_1.plistParser)(stdout));
39
39
  try {
40
- const macosTemp = require('macos-temperature-sensor');
41
- const temps = macosTemp.temperature();
42
- if (temps && temps.gpu) {
40
+ const smc = require('macos-smc');
41
+ const gpuMax = smc.temperatures()?.gpu?.max;
42
+ if (typeof gpuMax === 'number') {
43
43
  for (const controller of result) {
44
44
  if (controller.bus === 'Built-In') {
45
- controller.temperatureGpu = Math.round(temps.gpu * 100) / 100;
45
+ controller.temperatureGpu = Math.round(gpuMax * 100) / 100;
46
46
  }
47
47
  }
48
48
  }
@@ -14,6 +14,7 @@ export { cpuTemperature } from './cpu-temperature';
14
14
  export { fans } from './fans';
15
15
  export { currentLoad } from '../cpu-current-load';
16
16
  export { diskLayout } from './disk-layout';
17
+ export { diskSpeed } from './disk-speed';
17
18
  export { disksIO } from './disks-io';
18
19
  export { displays } from './displays';
19
20
  export { dockerInfo, dockerImages, dockerContainers, dockerContainerStats, dockerContainerProcesses, dockerVolumes, dockerAll } from '../docker';
@@ -32,6 +33,7 @@ export { networkConnections } from './network-connections';
32
33
  export { networkGatewayDefault } from './network-gateway-default';
33
34
  export { networkInterfaceDefault } from './network-interface-default';
34
35
  export { networkInterfaces } from './network-interfaces';
36
+ export { networkRoutes } from './network-routes';
35
37
  export { networkStats } from './network-stats';
36
38
  export { npm } from './npm';
37
39
  export { npu } from './npu';
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.services = exports.processFocused = 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 = exports.shell = void 0;
3
+ exports.processLoad = exports.processes = exports.printer = exports.pci = exports.osInfo = exports.npu = exports.npm = exports.networkStats = exports.networkRoutes = 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.diskSpeed = 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 = exports.shell = exports.services = exports.processFocused = 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");
@@ -34,6 +34,8 @@ var cpu_current_load_1 = require("../cpu-current-load");
34
34
  Object.defineProperty(exports, "currentLoad", { enumerable: true, get: function () { return cpu_current_load_1.currentLoad; } });
35
35
  var disk_layout_1 = require("./disk-layout");
36
36
  Object.defineProperty(exports, "diskLayout", { enumerable: true, get: function () { return disk_layout_1.diskLayout; } });
37
+ var disk_speed_1 = require("./disk-speed");
38
+ Object.defineProperty(exports, "diskSpeed", { enumerable: true, get: function () { return disk_speed_1.diskSpeed; } });
37
39
  var disks_io_1 = require("./disks-io");
38
40
  Object.defineProperty(exports, "disksIO", { enumerable: true, get: function () { return disks_io_1.disksIO; } });
39
41
  var displays_1 = require("./displays");
@@ -76,6 +78,8 @@ var network_interface_default_1 = require("./network-interface-default");
76
78
  Object.defineProperty(exports, "networkInterfaceDefault", { enumerable: true, get: function () { return network_interface_default_1.networkInterfaceDefault; } });
77
79
  var network_interfaces_1 = require("./network-interfaces");
78
80
  Object.defineProperty(exports, "networkInterfaces", { enumerable: true, get: function () { return network_interfaces_1.networkInterfaces; } });
81
+ var network_routes_1 = require("./network-routes");
82
+ Object.defineProperty(exports, "networkRoutes", { enumerable: true, get: function () { return network_routes_1.networkRoutes; } });
79
83
  var network_stats_1 = require("./network-stats");
80
84
  Object.defineProperty(exports, "networkStats", { enumerable: true, get: function () { return network_stats_1.networkStats; } });
81
85
  var npm_1 = require("./npm");
@@ -41,7 +41,8 @@ const parseLinesDarwinNics = (sections) => {
41
41
  type: '',
42
42
  operstate: '',
43
43
  duplex: '',
44
- internal: false
44
+ internal: false,
45
+ bridgeMembers: []
45
46
  };
46
47
  const first = section[0];
47
48
  nic.iface = first.split(':')[0].trim();
@@ -61,6 +62,9 @@ const parseLinesDarwinNics = (sections) => {
61
62
  if (line.trim().startsWith('inet ') && !nic.ip4) {
62
63
  nic.ip4 = line.split('inet ')[1].toLowerCase().split(' ')[0];
63
64
  }
65
+ if (line.trim().startsWith('member: ')) {
66
+ nic.bridgeMembers.push(line.trim().split(/\s+/)[1]);
67
+ }
64
68
  });
65
69
  let speed = (0, common_1.getValue)(section, 'link rate');
66
70
  nic.speed = speed ? parseFloat(speed) : null;
@@ -109,7 +113,12 @@ const parseBsdGateways = (stdout) => {
109
113
  if (parts[0] !== 'default' || parts.length < 3 || !parts[1].includes('.')) {
110
114
  continue;
111
115
  }
112
- const iface = ifaceColumn > 0 ? parts[ifaceColumn] : parts.slice(2).reverse().find((part) => /^[a-z][a-z0-9]*\d$/.test(part));
116
+ const iface = ifaceColumn > 0
117
+ ? parts[ifaceColumn]
118
+ : parts
119
+ .slice(2)
120
+ .reverse()
121
+ .find((part) => /^[a-z][a-z0-9]*\d$/.test(part));
113
122
  if (iface && !result[iface]) {
114
123
  result[iface] = parts[1];
115
124
  }
@@ -189,7 +198,7 @@ const networkInterfaces = async (defaultString = '', rescan = true) => {
189
198
  return (0, network_1.filterDefaultInterface)(_networkInterfaces, defaultString);
190
199
  }
191
200
  _interfaces = (0, index_1.cloneObj)(interfaces);
192
- let result = [];
201
+ const result = [];
193
202
  try {
194
203
  const [nics, defaultInterface, gateways, vendors] = await Promise.all([getBsdNics(), (0, network_interface_default_1.networkInterfaceDefault)(), getBsdGateways(), getBsdNicVendors()]);
195
204
  for (const nic of nics) {
@@ -260,7 +269,8 @@ const networkInterfaces = async (defaultString = '', rescan = true) => {
260
269
  dnsSuffix: '',
261
270
  ieee8021xAuth: '',
262
271
  ieee8021xState: '',
263
- carrierChanges: 0
272
+ carrierChanges: 0,
273
+ bridgeMembers: nic.bridgeMembers
264
274
  });
265
275
  }
266
276
  _networkInterfaces = result;
@@ -0,0 +1,3 @@
1
+ import type { NetworkRouteData } from '../common/types';
2
+ export declare const parseNetstatRoutes: (stdout: string) => NetworkRouteData[];
3
+ export declare const networkRoutes: () => Promise<NetworkRouteData[]>;
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.networkRoutes = exports.parseNetstatRoutes = void 0;
4
+ const common_1 = require("../common");
5
+ const exec_1 = require("../common/exec");
6
+ const EXEC_OPTS = { timeout: 5000, maxBuffer: 1024 * 1024 * 16 };
7
+ const ipv4Cidr = (dest, host) => {
8
+ if (dest === 'default') {
9
+ return '0.0.0.0/0';
10
+ }
11
+ const [addr = '', prefix] = dest.split('/');
12
+ const octets = addr.split('.');
13
+ const bits = prefix ?? (host ? '32' : String(octets.length * 8));
14
+ while (octets.length < 4) {
15
+ octets.push('0');
16
+ }
17
+ return `${octets.join('.')}/${bits}`;
18
+ };
19
+ const ipv6Cidr = (dest) => {
20
+ if (dest === 'default') {
21
+ return '::/0';
22
+ }
23
+ const value = dest.replace(/%[^/]*/, '');
24
+ return value.includes('/') ? value : `${value}/128`;
25
+ };
26
+ const parseNetstatRoutes = (stdout) => {
27
+ const result = [];
28
+ let family = '';
29
+ let gatewayCol = -1;
30
+ let flagsCol = -1;
31
+ let ifaceCol = -1;
32
+ for (const line of stdout.split('\n')) {
33
+ const parts = line.trim().split(/\s+/);
34
+ if (/^Internet6?:$/.test(parts[0] || '')) {
35
+ family = parts[0] === 'Internet6:' ? 'IPv6' : 'IPv4';
36
+ continue;
37
+ }
38
+ if (parts[0] === 'Destination') {
39
+ gatewayCol = parts.indexOf('Gateway');
40
+ flagsCol = parts.indexOf('Flags');
41
+ ifaceCol = parts.findIndex((part) => /^(netif|interface|iface)$/i.test(part));
42
+ continue;
43
+ }
44
+ if (!family || gatewayCol < 0 || flagsCol < 0 || ifaceCol < 0 || parts.length <= ifaceCol) {
45
+ continue;
46
+ }
47
+ const flags = parts[flagsCol] || '';
48
+ if (!flags.startsWith('U') || flags.includes('L')) {
49
+ continue;
50
+ }
51
+ const dest = parts[0] || '';
52
+ const gateway = (parts[gatewayCol] || '').replace(/%.*$/, '');
53
+ result.push({
54
+ destination: family === 'IPv6' ? ipv6Cidr(dest) : ipv4Cidr(dest, flags.includes('H')),
55
+ gateway: gateway.startsWith('link#') ? '' : gateway,
56
+ iface: parts[ifaceCol] || '',
57
+ metric: null,
58
+ family
59
+ });
60
+ }
61
+ return result;
62
+ };
63
+ exports.parseNetstatRoutes = parseNetstatRoutes;
64
+ const networkRoutes = async () => {
65
+ await (0, common_1.nextTick)();
66
+ try {
67
+ const { stdout } = await (0, exec_1.execFile)('netstat', ['-rn'], EXEC_OPTS);
68
+ return (0, exports.parseNetstatRoutes)(stdout.toString());
69
+ }
70
+ catch {
71
+ return [];
72
+ }
73
+ };
74
+ exports.networkRoutes = networkRoutes;
@@ -0,0 +1 @@
1
+ export declare const diskSpeed: (path?: string, sizeMB?: number) => Promise<import("./common/types").DiskSpeedData | null>;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.diskSpeed = void 0;
4
+ const const_1 = require("./common/const");
5
+ const diskSpeed = async (path, sizeMB) => {
6
+ switch (true) {
7
+ case const_1.LINUX || const_1.FREEBSD || const_1.NETBSD || const_1.OPENBSD:
8
+ return (await import('./linux/disk-speed.js')).diskSpeed(path, sizeMB);
9
+ case const_1.DARWIN:
10
+ return (await import('./darwin/disk-speed.js')).diskSpeed(path, sizeMB);
11
+ case const_1.WINDOWS:
12
+ return (await import('./windows/disk-speed.js')).diskSpeed(path, sizeMB);
13
+ default:
14
+ return null;
15
+ }
16
+ };
17
+ exports.diskSpeed = diskSpeed;
package/dist/get.js CHANGED
@@ -36,14 +36,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.get = void 0;
37
37
  const common_1 = require("./common");
38
38
  const functions = __importStar(require("./index"));
39
- const blocked = ['get', 'observe', 'getStaticData', 'getDynamicData', 'getAllData'];
39
+ const blocked = ['get', 'observe', 'getStaticData', 'getDynamicData', 'getAllData', 'powerShellStart', 'powerShellRelease', 'diskSpeed'];
40
40
  const pickKeys = (element, keyList) => {
41
41
  if (keyList.length === 1 && (keyList[0] === '*' || keyList[0] === 'all')) {
42
42
  return element;
43
43
  }
44
44
  const partial = {};
45
45
  keyList.forEach((k) => {
46
- if (Object.prototype.hasOwnProperty.call(element, k)) {
46
+ if (Object.hasOwn(element, k)) {
47
47
  partial[k] = element[k];
48
48
  }
49
49
  });
@@ -73,7 +73,7 @@ const pickResult = (data, value) => {
73
73
  if (filterParts.length === 2) {
74
74
  const filterKey = filterParts[0].trim();
75
75
  const filterValue = filterParts[1].trim();
76
- if (Object.prototype.hasOwnProperty.call(partialRes, filterKey)) {
76
+ if (Object.hasOwn(partialRes, filterKey)) {
77
77
  const val = partialRes[filterKey];
78
78
  if (typeof val === 'number') {
79
79
  if (val === parseFloat(filterValue)) {
@@ -98,7 +98,7 @@ const pickResult = (data, value) => {
98
98
  const get = async (valueObject) => {
99
99
  await (0, common_1.nextTick)();
100
100
  const lib = functions;
101
- const isGettable = (key) => Object.prototype.hasOwnProperty.call(lib, key) && typeof lib[key] === 'function' && typeof (valueObject || {})[key] === 'string' && blocked.indexOf(key) < 0;
101
+ const isGettable = (key) => Object.hasOwn(lib, key) && typeof lib[key] === 'function' && typeof (valueObject || {})[key] === 'string' && blocked.indexOf(key) < 0;
102
102
  const keys = Object.keys(valueObject || {}).filter(isGettable);
103
103
  const data = await Promise.all(keys.map((func) => {
104
104
  const value = valueObject[func];
@@ -114,7 +114,7 @@ const get = async (valueObject) => {
114
114
  keys.forEach((key, i) => {
115
115
  result[key] = pickResult(data[i], valueObject[key]);
116
116
  });
117
- if (Object.prototype.hasOwnProperty.call(valueObject || {}, 'graphics')) {
117
+ if (Object.hasOwn(valueObject || {}, 'graphics')) {
118
118
  result.graphics = 'graphics() was removed in v6 - use gpu and displays instead';
119
119
  }
120
120
  return result;