systeminformation 6.0.0-beta.10 → 6.0.0-beta.12

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.
package/README.md CHANGED
@@ -400,6 +400,10 @@ On Windows, `si.displays()` reports physical monitors: in duplicate/mirror mode
400
400
  | | [0].currentResY | X | | X | X | | current pixel vertical |
401
401
  | | [0].positionX | X | | X | X | | display position X |
402
402
  | | [0].positionY | X | | X | X | | display position Y |
403
+ | | [0].workAreaResolutionX | X | | X | X | | working area (screen minus task bar / panels / menu bar and Dock) resolution X |
404
+ | | [0].workAreaResolutionY | X | | X | X | | working area resolution Y |
405
+ | | [0].workAreaPositionX | X | | X | X | | working area position X |
406
+ | | [0].workAreaPositionY | X | | X | X | | working area position Y |
403
407
  | | [0].currentRefreshRate | X | | X | X | | current screen refresh rate |
404
408
  | | [0].scale | | | | X | | DPI scaling factor, e.g. 1.5 |
405
409
 
@@ -457,7 +461,7 @@ On Windows, `si.displays()` reports physical monitors: in duplicate/mirror mode
457
461
  | Function | Result object | Linux | BSD | Mac | Win | Sun | Comments |
458
462
  | -------------------------------- | ----------------- | ----- | --- | --- | --- | --- | --------------------------------------------------------------------------------------- |
459
463
  | si.currentLoad() | {...} | X | | X | X | X | CPU-Load |
460
- | | avgLoad | X | | X | | X | average load |
464
+ | | avgLoad | X | | X | X | X | average load<br>(Windows: approximated, see docs) |
461
465
  | | currentLoad | X | | X | X | X | CPU load in % |
462
466
  | | currentLoadUser | X | | X | X | X | CPU load user in % |
463
467
  | | currentLoadSystem | X | | X | X | X | CPU load system in % |
@@ -670,11 +674,10 @@ On Windows, `si.displays()` reports physical monitors: in duplicate/mirror mode
670
674
  | | [0].revision | X | | | | | revision |
671
675
  | | [0].driver | X | | | | | driver |
672
676
  | | [0].default | | | X | X | | is default |
673
- | | [0].channel | X | | X | | | channel e.g. USB, HDMI, ... |
677
+ | | [0].channel | X | | X | X | | channel e.g. USB, HDMI, ... |
674
678
  | | [0].type | X | | X | X | | type e.g. Speaker |
675
- | | [0].in | | | X | X | | is input channel |
676
- | | [0].out | | | X | X | | is output channel |
677
- | | [0].interfaceType | X | | X | X | | interface type (PCIe, USB, HDMI, ...) |
679
+ | | [0].in | X | | X | X | | is input channel |
680
+ | | [0].out | X | | X | X | | is output channel |
678
681
  | | [0].status | X | | X | X | | status (e.g. active) |
679
682
 
680
683
  #### 12. Network related functions
@@ -684,11 +687,14 @@ On Windows, `si.displays()` reports physical monitors: in duplicate/mirror mode
684
687
  | si.networkInterfaces() | [{...}] | X | X | X | X | X | array of network interfaces<br>With the 'default' parameter it returns<br>only the default interface |
685
688
  | | [0].iface | X | X | X | X | X | interface |
686
689
  | | [0].ifaceName | X | X | X | X | X | interface name (differs on Windows) |
690
+ | | [0].vendor | X | | X | X | | network adapter vendor (not available for every adapter) |
691
+ | | [0].model | X | | X | X | | network adapter model (not available for every adapter) |
687
692
  | | [0].default | X | X | X | X | X | true if this is the default interface |
688
693
  | | [0].ip4 | X | X | X | X | X | ip4 address |
689
694
  | | [0].ip4subnet | X | X | X | X | X | ip4 subnet mask |
690
695
  | | [0].ip6 | X | X | X | X | X | ip6 address |
691
696
  | | [0].ip6subnet | X | X | X | X | X | ip6 subnet mask |
697
+ | | [0].gateway | X | X | X | X | | default gateway of this interface |
692
698
  | | [0].mac | X | X | X | X | X | MAC address |
693
699
  | | [0].internal | X | X | X | X | X | true if internal interface |
694
700
  | | [0].virtual | X | X | X | X | X | true if virtual interface |
@@ -1,5 +1,7 @@
1
1
  import type { UserData } from './types';
2
2
  export declare const darwinXcodeExists: () => Promise<boolean>;
3
+ export declare const USB_DATA_TYPES: string[];
4
+ export declare const spItems: (data: any, dataTypes: string | string[]) => any[];
3
5
  export declare const plistParser: (xmlStr: string, items?: boolean) => any;
4
6
  export declare const formatBssid: (s: string) => string;
5
7
  export declare const plistReader: (output: string) => {};
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseUsersDarwin = exports.plistReader = exports.formatBssid = exports.plistParser = exports.darwinXcodeExists = void 0;
3
+ exports.parseUsersDarwin = exports.plistReader = exports.formatBssid = exports.plistParser = exports.spItems = exports.USB_DATA_TYPES = exports.darwinXcodeExists = void 0;
4
4
  const fs_1 = require("fs");
5
5
  const promises_1 = require("fs/promises");
6
6
  const datetime_1 = require("./datetime");
@@ -14,6 +14,22 @@ const darwinXcodeExists = async () => {
14
14
  };
15
15
  exports.darwinXcodeExists = darwinXcodeExists;
16
16
  const isProtoKey = (key) => key === '__proto__' || key === 'constructor' || key === 'prototype';
17
+ exports.USB_DATA_TYPES = ['SPUSBDataType', 'SPUSBHostDataType'];
18
+ const spItems = (data, dataTypes) => {
19
+ const types = Array.isArray(dataTypes) ? dataTypes : [dataTypes];
20
+ const result = [];
21
+ if (!Array.isArray(data)) {
22
+ return result;
23
+ }
24
+ for (const dataType of types) {
25
+ const section = data.find((s) => s && s._dataType === dataType);
26
+ if (section && Array.isArray(section._items)) {
27
+ result.push(...section._items);
28
+ }
29
+ }
30
+ return result;
31
+ };
32
+ exports.spItems = spItems;
17
33
  const plistParser = (xmlStr, items = true) => {
18
34
  const tags = ['array', 'dict', 'key', 'string', 'integer', 'date', 'real', 'data', 'boolean', 'arrayEmpty'];
19
35
  const startStr = '<plist version';
@@ -246,6 +246,10 @@ exports.initDisplay = {
246
246
  currentResY: null,
247
247
  positionX: 0,
248
248
  positionY: 0,
249
+ workAreaResolutionX: null,
250
+ workAreaResolutionY: null,
251
+ workAreaPositionX: null,
252
+ workAreaPositionY: null,
249
253
  currentRefreshRate: null,
250
254
  scale: null
251
255
  };
@@ -260,11 +264,14 @@ exports.initProcesses = {
260
264
  exports.initNetworkInterface = {
261
265
  iface: '',
262
266
  ifaceName: '',
267
+ vendor: '',
268
+ model: '',
263
269
  default: false,
264
270
  ip4: '',
265
271
  ip4subnet: '',
266
272
  ip6: '',
267
273
  ip6subnet: '',
274
+ gateway: '',
268
275
  mac: '',
269
276
  internal: true,
270
277
  virtual: false,
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getUniqueMacAddresses = exports.getFQDN = void 0;
4
+ const node_child_process_1 = require("node:child_process");
4
5
  const node_os_1 = require("node:os");
5
6
  const const_1 = require("./const");
6
7
  const exec_1 = require("./exec");
@@ -33,16 +34,67 @@ const getFQDN = async () => {
33
34
  return (0, node_os_1.hostname)();
34
35
  };
35
36
  exports.getFQDN = getFQDN;
37
+ const MASKED_MACS = ['00:00:00:00:00:00', '02:00:00:00:00:00'];
38
+ const getMacAddressesSync = () => {
39
+ const result = {};
40
+ let iface = '';
41
+ let mac = '';
42
+ try {
43
+ if (const_1.LINUX) {
44
+ const lines = (0, node_child_process_1.execSync)('export LC_ALL=C; ip link show up; unset LC_ALL', { encoding: 'utf8' }).split('\n');
45
+ for (let i = 0; i < lines.length; i++) {
46
+ const line = lines[i];
47
+ if (line && line[0] !== ' ') {
48
+ const next = (lines[i + 1] || '').trim().split(' ');
49
+ if (next[0] === 'link/ether') {
50
+ iface = (line.split(' ')[1] || '').replace(/:$/, '');
51
+ mac = next[1] || '';
52
+ }
53
+ if (iface && mac) {
54
+ result[iface] = mac.trim();
55
+ iface = '';
56
+ mac = '';
57
+ }
58
+ }
59
+ }
60
+ }
61
+ else if (const_1.DARWIN || const_1.FREEBSD || const_1.NETBSD || const_1.OPENBSD) {
62
+ const lines = (0, node_child_process_1.execSync)('/sbin/ifconfig', { encoding: 'utf8' }).split('\n');
63
+ for (const line of lines) {
64
+ if (line && line[0] !== '\t' && line.indexOf(':') > 0) {
65
+ iface = line.split(':')[0];
66
+ }
67
+ else if (line.indexOf('\tether ') === 0) {
68
+ mac = line.split('\tether ')[1] || '';
69
+ if (iface && mac) {
70
+ result[iface] = mac.trim();
71
+ iface = '';
72
+ mac = '';
73
+ }
74
+ }
75
+ }
76
+ }
77
+ }
78
+ catch { }
79
+ return result;
80
+ };
36
81
  const getUniqueMacAddresses = () => {
37
82
  let macs = [];
38
83
  try {
39
84
  const interfaces = (0, node_os_1.networkInterfaces)();
85
+ let fallbackMacs = null;
40
86
  for (const dev in interfaces) {
41
87
  if (Object.keys(interfaces).includes(dev)) {
42
88
  interfaces[dev]?.forEach((details) => {
43
- if (details?.mac && details.mac !== '00:00:00:00:00:00') {
44
- const mac = details.mac.toLowerCase();
45
- if (macs.indexOf(mac) === -1) {
89
+ if (details?.mac) {
90
+ let mac = details.mac.toLowerCase();
91
+ if (MASKED_MACS.includes(mac)) {
92
+ if (fallbackMacs === null) {
93
+ fallbackMacs = getMacAddressesSync();
94
+ }
95
+ mac = (fallbackMacs[dev] || '').toLowerCase();
96
+ }
97
+ if (mac && !MASKED_MACS.includes(mac) && macs.indexOf(mac) === -1) {
46
98
  macs.push(mac);
47
99
  }
48
100
  }
@@ -40,9 +40,6 @@ export declare const graphicsModelToVendor: (model: string) => string;
40
40
  export declare const graphicsIdToVendor: (id: string) => any;
41
41
  export declare const graphicsVendorToId: (str: string) => string;
42
42
  export declare const graphicsMetalVersion: (id: string) => any;
43
- export declare const winProcessStatus: {
44
- [index: string]: any;
45
- };
46
43
  export declare const getAppleModel: (key: string) => {
47
44
  key: string;
48
45
  model: string;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseBluetoothVendor = exports.bluetoothVendors = exports.getAppleChassisType = exports.getAppleModel = exports.winProcessStatus = exports.graphicsMetalVersion = exports.graphicsVendorToId = exports.graphicsIdToVendor = exports.graphicsModelToVendor = exports.graphicsVideoTypes = exports.diskVendorFromModel = exports.chassisTypes = exports.wifiFrequencies = exports.socketTypes = exports.cpuBrandManufacturer = exports.getAMDSpeed = exports.cpuManufacturer = exports.getSocketTypesByName = exports.winPrinterStatus = exports.raspberryClockSpeed = exports.getMemManufacturer = exports.JEDEV_RAM_manufacturers = exports.getWindowsRelease = exports.getLogoFile = exports.wifiVendor = exports.usbWindowsType = exports.usbDarwinType = exports.usbLinuxType = exports.manufacturedApple = exports.bluetoothManufacturer = exports.bluetoothTypeLabel = exports.audioWindowsStatus = exports.audioDarwinChannelLabel = exports.audioTypeLabel = void 0;
3
+ exports.parseBluetoothVendor = exports.bluetoothVendors = exports.getAppleChassisType = exports.getAppleModel = exports.graphicsMetalVersion = exports.graphicsVendorToId = exports.graphicsIdToVendor = exports.graphicsModelToVendor = exports.graphicsVideoTypes = exports.diskVendorFromModel = exports.chassisTypes = exports.wifiFrequencies = exports.socketTypes = exports.cpuBrandManufacturer = exports.getAMDSpeed = exports.cpuManufacturer = exports.getSocketTypesByName = exports.winPrinterStatus = exports.raspberryClockSpeed = exports.getMemManufacturer = exports.JEDEV_RAM_manufacturers = exports.getWindowsRelease = exports.getLogoFile = exports.wifiVendor = exports.usbWindowsType = exports.usbDarwinType = exports.usbLinuxType = exports.manufacturedApple = exports.bluetoothManufacturer = exports.bluetoothTypeLabel = exports.audioWindowsStatus = exports.audioDarwinChannelLabel = exports.audioTypeLabel = void 0;
4
4
  const const_1 = require("./const");
5
5
  const speaker = 'Speaker';
6
6
  const microphone = 'Microphone';
@@ -1670,21 +1670,10 @@ const graphicsMetalVersion = (id) => {
1670
1670
  spdisplays_metalfeaturesetfamily14: 'family1_v4',
1671
1671
  spdisplays_metalfeaturesetfamily21: 'family2_v1'
1672
1672
  };
1673
- return families[id] || '';
1673
+ const version = /^spdisplays_metal(\d+)$/.exec(id);
1674
+ return families[id] || (version ? version[1] : '');
1674
1675
  };
1675
1676
  exports.graphicsMetalVersion = graphicsMetalVersion;
1676
- exports.winProcessStatus = {
1677
- '0': 'unknown',
1678
- '1': 'other',
1679
- '2': 'ready',
1680
- '3': 'running',
1681
- '4': 'blocked',
1682
- '5': 'suspended blocked',
1683
- '6': 'suspended ready',
1684
- '7': 'terminated',
1685
- '8': 'stopped',
1686
- '9': 'growing'
1687
- };
1688
1677
  const getAppleModel = (key) => {
1689
1678
  const appleModelIds = [
1690
1679
  {
@@ -845,6 +845,10 @@ export type DisplayData = {
845
845
  currentResY: number | null;
846
846
  positionX: number;
847
847
  positionY: number;
848
+ workAreaResolutionX: number | null;
849
+ workAreaResolutionY: number | null;
850
+ workAreaPositionX: number | null;
851
+ workAreaPositionY: number | null;
848
852
  currentRefreshRate: number | null;
849
853
  scale: number | null;
850
854
  };
@@ -939,11 +943,14 @@ export type ProcessLoadData = {
939
943
  export type NetworkInterfacesData = {
940
944
  iface: string;
941
945
  ifaceName: string;
946
+ vendor: string;
947
+ model: string;
942
948
  default: boolean;
943
949
  ip4: string;
944
950
  ip4subnet: string;
945
951
  ip6: string;
946
952
  ip6subnet: string;
953
+ gateway: string;
947
954
  mac: string;
948
955
  internal: boolean;
949
956
  virtual: boolean;
@@ -1,2 +1,3 @@
1
1
  import type { CurrentLoadData } from './common/types';
2
+ export declare const avgLoadEwma: (previous: number[] | null, busyCores: number, seconds: number) => number[];
2
3
  export declare const currentLoad: () => Promise<CurrentLoadData>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.currentLoad = void 0;
3
+ exports.currentLoad = exports.avgLoadEwma = 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");
@@ -39,10 +39,24 @@ let _current_cpu = {
39
39
  };
40
40
  const _cpus = [];
41
41
  let _corecount = 0;
42
+ const AVG_LOAD_PERIODS = [60, 300, 900];
43
+ let _avgLoadEwma = [0, 0, 0];
44
+ let _avgLoadEwmaMs = null;
45
+ const avgLoadEwma = (previous, busyCores, seconds) => {
46
+ if (!previous || seconds <= 0) {
47
+ return [busyCores, busyCores, busyCores];
48
+ }
49
+ return AVG_LOAD_PERIODS.map((period, i) => {
50
+ const decay = Math.exp(-seconds / period);
51
+ return (previous[i] || 0) * decay + busyCores * (1 - decay);
52
+ });
53
+ };
54
+ exports.avgLoadEwma = avgLoadEwma;
55
+ const avgLoadFromEwma = (cores) => (cores ? parseFloat((Math.max(..._avgLoadEwma) / cores).toFixed(2)) : 0);
42
56
  const currentLoad = async () => {
43
57
  await (0, common_1.nextTick)();
44
58
  const loads = (0, node_os_1.loadavg)().map((x) => x / (0, node_os_1.cpus)().length);
45
- const avgLoad = parseFloat(Math.max(...loads).toFixed(2));
59
+ let avgLoad = parseFloat(Math.max(...loads).toFixed(2));
46
60
  let result = {
47
61
  avgLoad: 0,
48
62
  currentLoad: 0,
@@ -165,6 +179,13 @@ const currentLoad = async () => {
165
179
  const totalTick = totalUser + totalSystem + totalNice + totalIrq + totalSteal + totalGuest + totalIdle + totalIowait;
166
180
  const totalLoad = totalUser + totalSystem + totalNice + totalIrq + totalSteal + totalGuest;
167
181
  const currentTick = totalTick - _current_cpu.tick || 1;
182
+ if (const_1.WINDOWS) {
183
+ const busyCores = ((totalLoad - _current_cpu.load) / currentTick) * _corecount;
184
+ const seconds = _avgLoadEwmaMs === null ? 0 : (_current_cpu.ms - _avgLoadEwmaMs) / 1000;
185
+ _avgLoadEwma = (0, exports.avgLoadEwma)(_avgLoadEwmaMs === null ? null : _avgLoadEwma, busyCores, seconds);
186
+ _avgLoadEwmaMs = _current_cpu.ms;
187
+ avgLoad = avgLoadFromEwma(_corecount);
188
+ }
168
189
  result = {
169
190
  avgLoad: avgLoad,
170
191
  currentLoad: ((totalLoad - _current_cpu.load) / currentTick) * 100,
@@ -220,6 +241,9 @@ const currentLoad = async () => {
220
241
  };
221
242
  }
222
243
  else {
244
+ if (const_1.WINDOWS) {
245
+ avgLoad = avgLoadFromEwma(_corecount);
246
+ }
223
247
  const cores = [];
224
248
  for (let i = 0; i < _corecount; i++) {
225
249
  cores[i] = {};
@@ -1,2 +1,2 @@
1
- import { BatteryObject } from '../common/types';
1
+ import type { BatteryObject } from '../common/types';
2
2
  export declare const battery: () => Promise<BatteryObject[]>;
@@ -7,7 +7,12 @@ const exec_1 = require("../common/exec");
7
7
  const parseBatteryObject = (data) => {
8
8
  const defaults = (0, common_1.cloneObj)(defaults_1.initBatteryResult);
9
9
  data = data || '';
10
- const lines = data.replace(/ +/g, '').replace(/"+/g, '').replace(/-/g, '').split('\n');
10
+ const lines = data
11
+ .replace(/^[ |]+/gm, '')
12
+ .replace(/ +/g, '')
13
+ .replace(/"+/g, '')
14
+ .replace(/-/g, '')
15
+ .split('\n');
11
16
  let percent = null;
12
17
  const line = (0, common_1.getValue)(lines, 'internal', 'Battery');
13
18
  const parts = line.split(';');
@@ -21,9 +26,14 @@ const parseBatteryObject = (data) => {
21
26
  const acConnected = parts && parts[1] ? parts[1].trim() !== 'discharging' : false;
22
27
  const voltage = parseInt('0' + (0, common_1.getValue)(lines, 'voltage', '='), 10) / 1000.0;
23
28
  const capacityUnit = voltage ? 'mWh' : 'mAh';
24
- const maxCapacity = Math.round(parseInt('0' + (0, common_1.getValue)(lines, 'applerawmaxcapacity', '='), 10) * (voltage || 1));
25
- const currentCapacity = Math.round(parseInt('0' + (0, common_1.getValue)(lines, 'applerawcurrentcapacity', '='), 10) * (voltage || 1));
26
- const designedCapacity = Math.round(parseInt('0' + (0, common_1.getValue)(lines, 'DesignCapacity', '='), 10) * (voltage || 1));
29
+ const batteryData = (0, common_1.getValue)(lines, 'BatteryData', '=').replace(/^\{/, '').replace(/\}$/, '').split(',');
30
+ const maxCapacity = Math.round(parseInt('0' +
31
+ ((0, common_1.getValue)(lines, 'AppleRawMaxCapacity', '=') ||
32
+ (0, common_1.getValue)(lines, 'NominalChargeCapacity', '=') ||
33
+ (0, common_1.getValue)(batteryData, 'FullChargeCapacity', '=') ||
34
+ (0, common_1.getValue)(batteryData, 'NominalChargeCapacity', '=')), 10) * (voltage || 1));
35
+ const currentCapacity = Math.round(parseInt('0' + ((0, common_1.getValue)(lines, 'AppleRawCurrentCapacity', '=') || (0, common_1.getValue)(batteryData, 'RemainingCapacity', '=')), 10) * (voltage || 1));
36
+ const designedCapacity = Math.round(parseInt('0' + ((0, common_1.getValue)(lines, 'DesignCapacity', '=') || (0, common_1.getValue)(batteryData, 'DesignCapacity', '=')), 10) * (voltage || 1));
27
37
  let hasBattery = defaults.hasBattery;
28
38
  let type = defaults.type;
29
39
  let timeRemaining = defaults.timeRemaining;
@@ -59,7 +69,7 @@ const parseBatteryObject = (data) => {
59
69
  };
60
70
  const battery = async () => {
61
71
  await (0, common_1.nextTick)();
62
- const { stdout } = await (0, exec_1.execSave)('ioreg -n AppleSmartBattery -r | egrep "CycleCount|IsCharging|DesignCapacity|MaxCapacity|CurrentCapacity|DeviceName|BatterySerialNumber|Serial|TimeRemaining|Voltage"; pmset -g batt | grep %');
72
+ const { stdout } = await (0, exec_1.execSave)('ioreg -n AppleSmartBattery -r | egrep "CycleCount|IsCharging|DesignCapacity|MaxCapacity|CurrentCapacity|DeviceName|BatterySerialNumber|Serial|TimeRemaining|Voltage|BatteryData|NominalChargeCapacity"; pmset -g batt | grep %');
63
73
  return parseBatteryObject(stdout);
64
74
  };
65
75
  exports.battery = battery;
@@ -40,10 +40,10 @@ const parseUsb = (data) => {
40
40
  const camera = async () => {
41
41
  await (0, common_1.nextTick)();
42
42
  try {
43
- const { stdout } = await (0, exec_1.exec)('system_profiler SPCameraDataType SPUSBDataType -xml');
43
+ const { stdout } = await (0, exec_1.exec)('system_profiler SPCameraDataType SPUSBDataType SPUSBHostDataType -xml');
44
44
  const data = (0, darwin_1.plistParser)(stdout, false);
45
- const cameraData = data.length >= 2 && data[0]._items ? data[0]._items : [];
46
- const usbData = data.length >= 2 && data[1]._items ? data[1]._items : [];
45
+ const cameraData = (0, darwin_1.spItems)(data, 'SPCameraDataType');
46
+ const usbData = (0, darwin_1.spItems)(data, darwin_1.USB_DATA_TYPES);
47
47
  let result = parseCamera(cameraData);
48
48
  result = result.concat(parseUsb(usbData));
49
49
  return result;
@@ -20,13 +20,13 @@ const diskLayout = async () => {
20
20
  cmdFullSmart += `${cmdFullSmart ? 'printf ",";' : ''}smartctl -a -j ${bsdName};`;
21
21
  };
22
22
  try {
23
- ({ stdout } = await (0, exec_1.exec)(`system_profiler SPSerialATADataType SPNVMeDataType SPUSBDataType SPStorageDataType -xml`, { maxBuffer: const_1.MAX_BUFFER_SIZE }));
23
+ ({ stdout } = await (0, exec_1.exec)(`system_profiler SPSerialATADataType SPNVMeDataType SPUSBDataType SPUSBHostDataType SPStorageDataType -xml`, { maxBuffer: const_1.MAX_BUFFER_SIZE }));
24
24
  const data = (0, darwin_1.plistParser)(stdout, false);
25
- const diskSATA = data.length >= 4 && data[0]._items ? data[0]._items : [];
26
- const diskNVME = data.length >= 4 && data[1]._items ? data[1]._items : [];
27
- const diskUSB = data.length >= 4 && data[2]._items ? data[2]._items : [];
28
- const diskLine = data.length >= 4 && data[3]._items ? data[3]._items : [];
29
- if (diskSATA?.length && diskSATA._items) {
25
+ const diskSATA = (0, darwin_1.spItems)(data, 'SPSerialATADataType');
26
+ const diskNVME = (0, darwin_1.spItems)(data, 'SPNVMeDataType');
27
+ const diskUSB = (0, darwin_1.spItems)(data, darwin_1.USB_DATA_TYPES);
28
+ const diskLine = (0, darwin_1.spItems)(data, 'SPStorageDataType');
29
+ if (diskSATA?.length) {
30
30
  diskSATA.forEach((controller) => {
31
31
  if (controller?._items && controller._items.length) {
32
32
  const deviceType = controller._names && controller._names.tolower().indexOf('ssd') >= 0 ? 'SSD' : 'HD';
@@ -38,6 +38,10 @@ const parseDisplaysDarwin = (graphicsArr) => {
38
38
  currentResY: currentResolution.length > 1 ? parseInt(currentResolution[1], 10) : null,
39
39
  positionX: 0,
40
40
  positionY: 0,
41
+ workAreaResolutionX: null,
42
+ workAreaResolutionY: null,
43
+ workAreaPositionX: null,
44
+ workAreaPositionY: null,
41
45
  currentRefreshRate: currentResolutionParts.length > 1 ? parseInt(currentResolutionParts[1], 10) : null,
42
46
  scale: null
43
47
  });
@@ -86,6 +90,32 @@ const getDisplayPositionDarwin = async (displays) => {
86
90
  catch { }
87
91
  return displays;
88
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
+ };
89
119
  const displays = async () => {
90
120
  await (0, common_1.nextTick)();
91
121
  let result = [];
@@ -93,6 +123,7 @@ const displays = async () => {
93
123
  const { stdout } = await (0, exec_1.shareInflight)('SPDisplaysDataType', () => (0, exec_1.exec)('system_profiler -xml -detailLevel full SPDisplaysDataType'));
94
124
  result = parseDisplaysDarwin((0, darwin_1.plistParser)(stdout));
95
125
  result = await getDisplayPositionDarwin(result);
126
+ result = await getWorkAreaDarwin(result);
96
127
  }
97
128
  catch { }
98
129
  return result;
@@ -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 || '',
@@ -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)));
@@ -1,2 +1,5 @@
1
1
  import type { NetworkInterfacesData } from '../common/types';
2
+ export declare const parseBsdGateways: (stdout: string) => {
3
+ [iface: string]: string;
4
+ };
2
5
  export declare const networkInterfaces: (defaultString?: string, rescan?: boolean) => Promise<NetworkInterfacesData[]>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.networkInterfaces = void 0;
3
+ exports.networkInterfaces = exports.parseBsdGateways = 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");
@@ -97,6 +97,79 @@ const getBsdNics = async () => {
97
97
  return [];
98
98
  }
99
99
  };
100
+ const parseBsdGateways = (stdout) => {
101
+ const result = {};
102
+ let ifaceColumn = -1;
103
+ for (const line of stdout.split('\n')) {
104
+ const parts = line.trim().split(/\s+/);
105
+ if (parts[0] === 'Destination') {
106
+ ifaceColumn = parts.findIndex((part) => /^(netif|interface|iface)$/i.test(part));
107
+ continue;
108
+ }
109
+ if (parts[0] !== 'default' || parts.length < 3 || !parts[1].includes('.')) {
110
+ continue;
111
+ }
112
+ const iface = ifaceColumn > 0 ? parts[ifaceColumn] : parts.slice(2).reverse().find((part) => /^[a-z][a-z0-9]*\d$/.test(part));
113
+ if (iface && !result[iface]) {
114
+ result[iface] = parts[1];
115
+ }
116
+ }
117
+ return result;
118
+ };
119
+ exports.parseBsdGateways = parseBsdGateways;
120
+ const getBsdGateways = async () => {
121
+ try {
122
+ const { stdout } = await (0, exec_1.exec)('netstat -rn -f inet', { maxBuffer: const_1.MAX_BUFFER_SIZE });
123
+ return (0, exports.parseBsdGateways)(stdout);
124
+ }
125
+ catch {
126
+ return {};
127
+ }
128
+ };
129
+ let _nicVendors = null;
130
+ const getBsdNicVendors = async () => {
131
+ if (_nicVendors) {
132
+ return _nicVendors;
133
+ }
134
+ const result = {};
135
+ if (!const_1.DARWIN) {
136
+ _nicVendors = result;
137
+ return result;
138
+ }
139
+ let complete = false;
140
+ try {
141
+ const { stdout } = await (0, exec_1.exec)('ioreg -r -c IONetworkController -d 2 -w 0', { maxBuffer: const_1.MAX_BUFFER_SIZE });
142
+ let vendor = '';
143
+ let model = '';
144
+ for (const line of stdout.split('\n')) {
145
+ if (line.startsWith('+-o ')) {
146
+ vendor = '';
147
+ model = '';
148
+ continue;
149
+ }
150
+ const value = line.match(/"IO(Vendor|Model)" = "(.*)"/);
151
+ if (value) {
152
+ if (value[1] === 'Vendor') {
153
+ vendor = value[2];
154
+ }
155
+ else {
156
+ model = value[2];
157
+ }
158
+ continue;
159
+ }
160
+ const child = line.match(/^\s+\+-o (\S+)\s+<class \S*Interface/);
161
+ if (child && (vendor || model)) {
162
+ result[child[1]] = { vendor, model };
163
+ }
164
+ }
165
+ complete = true;
166
+ }
167
+ catch { }
168
+ if (complete) {
169
+ _nicVendors = result;
170
+ }
171
+ return result;
172
+ };
100
173
  const getBsdIfaceDHCPstatus = async (iface) => {
101
174
  let result = false;
102
175
  try {
@@ -118,8 +191,7 @@ const networkInterfaces = async (defaultString = '', rescan = true) => {
118
191
  _interfaces = (0, index_1.cloneObj)(interfaces);
119
192
  let result = [];
120
193
  try {
121
- const nics = await getBsdNics();
122
- const defaultInterface = await (0, network_interface_default_1.networkInterfaceDefault)();
194
+ const [nics, defaultInterface, gateways, vendors] = await Promise.all([getBsdNics(), (0, network_interface_default_1.networkInterfaceDefault)(), getBsdGateways(), getBsdNicVendors()]);
123
195
  for (const nic of nics) {
124
196
  let ip4link = '';
125
197
  let ip4linksubnet = '';
@@ -168,11 +240,14 @@ const networkInterfaces = async (defaultString = '', rescan = true) => {
168
240
  result.push({
169
241
  iface: nic.iface,
170
242
  ifaceName: nic.iface,
243
+ vendor: vendors[nic.iface]?.vendor || '',
244
+ model: vendors[nic.iface]?.model || '',
171
245
  default: nic.iface === defaultInterface,
172
246
  ip4: nic.ip4,
173
247
  ip4subnet: nic.ip4subnet || '',
174
248
  ip6: nic.ip6,
175
249
  ip6subnet: nic.ip6subnet || '',
250
+ gateway: gateways[nic.iface] || '',
176
251
  mac: nic.mac,
177
252
  internal: nic.internal,
178
253
  virtual: nic.internal ? false : (0, network_1.testVirtualNic)(nic.iface, nic.iface, nic.mac),
@@ -1,2 +1,3 @@
1
1
  import { DisplayData } from '../common/types';
2
+ export declare const drmDisplays: (path?: string) => Promise<DisplayData[]>;
2
3
  export declare const displays: () => Promise<DisplayData[]>;