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 +11 -5
- package/dist/common/darwin.d.ts +2 -0
- package/dist/common/darwin.js +17 -1
- package/dist/common/defaults.js +7 -0
- package/dist/common/host.js +55 -3
- package/dist/common/mappings.d.ts +0 -3
- package/dist/common/mappings.js +3 -14
- package/dist/common/types.d.ts +7 -0
- package/dist/cpu-current-load.d.ts +1 -0
- package/dist/cpu-current-load.js +26 -2
- package/dist/darwin/battery.d.ts +1 -1
- package/dist/darwin/battery.js +15 -5
- package/dist/darwin/camera.js +3 -3
- package/dist/darwin/disk-layout.js +6 -6
- package/dist/darwin/displays.js +31 -0
- package/dist/darwin/gpu.js +1 -1
- package/dist/darwin/keyboard.js +4 -4
- package/dist/darwin/mouse.js +4 -4
- package/dist/darwin/network-interfaces.d.ts +3 -0
- package/dist/darwin/network-interfaces.js +78 -3
- package/dist/linux/displays.d.ts +1 -0
- package/dist/linux/displays.js +89 -3
- package/dist/linux/network-interfaces.d.ts +1 -0
- package/dist/linux/network-interfaces.js +67 -1
- package/dist/windows/audio.d.ts +29 -0
- package/dist/windows/audio.js +151 -11
- package/dist/windows/displays.js +16 -2
- package/dist/windows/network-interfaces.js +14 -1
- package/dist/windows/processes.d.ts +1 -0
- package/dist/windows/processes.js +37 -15
- package/package.json +1 -1
package/dist/linux/displays.js
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.displays = void 0;
|
|
3
|
+
exports.displays = exports.drmDisplays = void 0;
|
|
4
|
+
const promises_1 = require("node:fs/promises");
|
|
5
|
+
const node_path_1 = require("node:path");
|
|
4
6
|
const common_1 = require("../common");
|
|
5
7
|
const const_1 = require("../common/const");
|
|
6
8
|
const defaults_1 = require("../common/defaults");
|
|
7
9
|
const exec_1 = require("../common/exec");
|
|
10
|
+
const files_1 = require("../common/files");
|
|
8
11
|
const index_1 = require("../common/index");
|
|
9
12
|
const raspberry_1 = require("../common/raspberry");
|
|
13
|
+
const security_1 = require("../common/security");
|
|
10
14
|
const parseLinesLinuxEdid = (edid) => {
|
|
11
15
|
const result = (0, index_1.cloneObj)(defaults_1.initDisplay);
|
|
12
16
|
let start = 108;
|
|
@@ -140,6 +144,80 @@ const parseLinesLinuxDisplays = (lines, depth) => {
|
|
|
140
144
|
});
|
|
141
145
|
return displays;
|
|
142
146
|
};
|
|
147
|
+
const getWorkAreaLinux = async (displays) => {
|
|
148
|
+
try {
|
|
149
|
+
const { stdout } = await (0, exec_1.execSave)('xprop -root _NET_WORKAREA 2>/dev/null');
|
|
150
|
+
const values = (stdout.toString().split('=')[1] || '').split(',').map((value) => (0, common_1.toInt)(value));
|
|
151
|
+
const [areaX, areaY, areaWidth, areaHeight] = values;
|
|
152
|
+
if (values.length < 4 || !areaWidth || !areaHeight) {
|
|
153
|
+
return displays;
|
|
154
|
+
}
|
|
155
|
+
displays.forEach((display) => {
|
|
156
|
+
const width = display.currentResX || display.resolutionX;
|
|
157
|
+
const height = display.currentResY || display.resolutionY;
|
|
158
|
+
if (!width || !height) {
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
const left = Math.max(display.positionX, areaX);
|
|
162
|
+
const top = Math.max(display.positionY, areaY);
|
|
163
|
+
const right = Math.min(display.positionX + width, areaX + areaWidth);
|
|
164
|
+
const bottom = Math.min(display.positionY + height, areaY + areaHeight);
|
|
165
|
+
if (right > left && bottom > top) {
|
|
166
|
+
display.workAreaResolutionX = right - left;
|
|
167
|
+
display.workAreaResolutionY = bottom - top;
|
|
168
|
+
display.workAreaPositionX = left;
|
|
169
|
+
display.workAreaPositionY = top;
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
catch { }
|
|
174
|
+
return displays;
|
|
175
|
+
};
|
|
176
|
+
const drmDisplays = async (path = '/sys/class/drm') => {
|
|
177
|
+
const result = [];
|
|
178
|
+
let connectors = [];
|
|
179
|
+
try {
|
|
180
|
+
connectors = (await (0, promises_1.readdir)(path)).filter((name) => /^card\d+-/.test(name) && (0, security_1.isSafePathSegment)(name)).sort();
|
|
181
|
+
}
|
|
182
|
+
catch {
|
|
183
|
+
return result;
|
|
184
|
+
}
|
|
185
|
+
for (const connector of connectors) {
|
|
186
|
+
const dir = (0, node_path_1.join)(path, connector);
|
|
187
|
+
if ((await (0, files_1.readSysfs)((0, node_path_1.join)(dir, 'status'))) !== 'connected') {
|
|
188
|
+
continue;
|
|
189
|
+
}
|
|
190
|
+
const display = (0, index_1.cloneObj)(defaults_1.initDisplay);
|
|
191
|
+
display.connection = connector.replace(/^card\d+-/, '');
|
|
192
|
+
display.builtin = /^(edp|lvds|dsi)/i.test(display.connection);
|
|
193
|
+
display.positionX = 0;
|
|
194
|
+
display.positionY = 0;
|
|
195
|
+
const mode = (await (0, files_1.readSysfs)((0, node_path_1.join)(dir, 'modes'))).split('\n')[0].split('x');
|
|
196
|
+
if (mode.length === 2) {
|
|
197
|
+
display.currentResX = (0, common_1.toInt)(mode[0]);
|
|
198
|
+
display.currentResY = (0, common_1.toInt)(mode[1]);
|
|
199
|
+
}
|
|
200
|
+
try {
|
|
201
|
+
const edid = (await (0, promises_1.readFile)((0, node_path_1.join)(dir, 'edid'))).toString('hex');
|
|
202
|
+
if (edid) {
|
|
203
|
+
const decoded = parseLinesLinuxEdid(edid);
|
|
204
|
+
display.model = decoded.model;
|
|
205
|
+
display.resolutionX = decoded.resolutionX;
|
|
206
|
+
display.resolutionY = decoded.resolutionY;
|
|
207
|
+
display.sizeX = decoded.sizeX;
|
|
208
|
+
display.sizeY = decoded.sizeY;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
catch { }
|
|
212
|
+
result.push(display);
|
|
213
|
+
}
|
|
214
|
+
const main = result.find((display) => display.builtin) || result[0];
|
|
215
|
+
if (main) {
|
|
216
|
+
main.main = true;
|
|
217
|
+
}
|
|
218
|
+
return result;
|
|
219
|
+
};
|
|
220
|
+
exports.drmDisplays = drmDisplays;
|
|
143
221
|
const displays = async () => {
|
|
144
222
|
await (0, common_1.nextTick)();
|
|
145
223
|
const result = [];
|
|
@@ -171,6 +249,10 @@ const displays = async () => {
|
|
|
171
249
|
currentResY: null,
|
|
172
250
|
positionX: 0,
|
|
173
251
|
positionY: 0,
|
|
252
|
+
workAreaResolutionX: null,
|
|
253
|
+
workAreaResolutionY: null,
|
|
254
|
+
workAreaPositionX: null,
|
|
255
|
+
workAreaPositionY: null,
|
|
174
256
|
currentRefreshRate: null,
|
|
175
257
|
scale: null
|
|
176
258
|
});
|
|
@@ -186,13 +268,17 @@ const displays = async () => {
|
|
|
186
268
|
try {
|
|
187
269
|
({ stdout } = await (0, exec_1.exec)('xrandr --verbose 2>/dev/null', const_1.execOptsLinux));
|
|
188
270
|
const lines = stdout.toString().split('\n');
|
|
189
|
-
|
|
271
|
+
const xrandrDisplays = parseLinesLinuxDisplays(lines, depth);
|
|
272
|
+
if (xrandrDisplays.length) {
|
|
273
|
+
return await getWorkAreaLinux(xrandrDisplays);
|
|
274
|
+
}
|
|
190
275
|
}
|
|
191
276
|
catch { }
|
|
192
277
|
}
|
|
193
278
|
catch { }
|
|
194
279
|
}
|
|
195
280
|
catch { }
|
|
196
|
-
|
|
281
|
+
const drm = await (0, exports.drmDisplays)();
|
|
282
|
+
return drm.length ? drm : result;
|
|
197
283
|
};
|
|
198
284
|
exports.displays = displays;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import type { NetworkInterfacesData } from '../common/types';
|
|
2
2
|
export declare const checkLinuxDCHPInterfaces: (file: string, depth?: number) => Promise<any[]>;
|
|
3
|
+
export declare const pciSlotFromPath: (path: string) => string | null;
|
|
3
4
|
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 = exports.checkLinuxDCHPInterfaces = void 0;
|
|
3
|
+
exports.networkInterfaces = exports.pciSlotFromPath = exports.checkLinuxDCHPInterfaces = void 0;
|
|
4
4
|
const promises_1 = require("node:fs/promises");
|
|
5
5
|
const node_os_1 = require("node:os");
|
|
6
6
|
const node_path_1 = require("node:path");
|
|
@@ -13,6 +13,7 @@ const index_1 = require("../common/index");
|
|
|
13
13
|
const network_1 = require("../common/network");
|
|
14
14
|
const security_1 = require("../common/security");
|
|
15
15
|
const network_interface_default_1 = require("./network-interface-default");
|
|
16
|
+
const pci_1 = require("./pci");
|
|
16
17
|
let _interfaces = {};
|
|
17
18
|
let _networkInterfaces = [];
|
|
18
19
|
const splitSectionsNics = (lines) => {
|
|
@@ -194,6 +195,66 @@ const getLinuxIfaceIEEE8021xState = (authenticationProtocol) => {
|
|
|
194
195
|
return 'Unknown';
|
|
195
196
|
}
|
|
196
197
|
};
|
|
198
|
+
const getLinuxGateways = async () => {
|
|
199
|
+
const result = {};
|
|
200
|
+
try {
|
|
201
|
+
const { stdout } = await (0, exec_1.exec)('ip -4 route show default 2> /dev/null', const_1.execOptsLinux);
|
|
202
|
+
for (const line of stdout.split('\n')) {
|
|
203
|
+
for (const match of line.matchAll(/(?:via\s+(\S+)\s+)?dev\s+(\S+)/g)) {
|
|
204
|
+
if (!result[match[2]]) {
|
|
205
|
+
result[match[2]] = match[1] || '';
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
catch { }
|
|
211
|
+
return result;
|
|
212
|
+
};
|
|
213
|
+
const PCI_SLOT = /^[0-9a-f]{4}:[0-9a-f]{2}:[0-9a-f]{2}\.[0-9a-f]$/i;
|
|
214
|
+
const pciSlotFromPath = (path) => {
|
|
215
|
+
const segments = path.split('/');
|
|
216
|
+
return segments.slice(-2).reverse().find((segment) => PCI_SLOT.test(segment)) || null;
|
|
217
|
+
};
|
|
218
|
+
exports.pciSlotFromPath = pciSlotFromPath;
|
|
219
|
+
const _nicHardware = {};
|
|
220
|
+
const _nicHardwareChecked = new Set();
|
|
221
|
+
const getLinuxNicHardware = async (devices) => {
|
|
222
|
+
let pciDevices = null;
|
|
223
|
+
for (const device of devices) {
|
|
224
|
+
const dev = device.split(':')[0];
|
|
225
|
+
if (!(0, security_1.isSafePathSegment)(dev) || _nicHardwareChecked.has(dev)) {
|
|
226
|
+
continue;
|
|
227
|
+
}
|
|
228
|
+
let target = '';
|
|
229
|
+
try {
|
|
230
|
+
target = await (0, promises_1.realpath)(`/sys/class/net/${dev}/device`);
|
|
231
|
+
}
|
|
232
|
+
catch {
|
|
233
|
+
continue;
|
|
234
|
+
}
|
|
235
|
+
const [vendor, model] = await Promise.all([(0, files_1.readSysfs)((0, node_path_1.join)(target, '..', 'manufacturer')), (0, files_1.readSysfs)((0, node_path_1.join)(target, '..', 'product'))]);
|
|
236
|
+
if (vendor || model) {
|
|
237
|
+
_nicHardware[dev] = { vendor, model };
|
|
238
|
+
_nicHardwareChecked.add(dev);
|
|
239
|
+
continue;
|
|
240
|
+
}
|
|
241
|
+
const slot = (0, exports.pciSlotFromPath)(target);
|
|
242
|
+
if (!slot) {
|
|
243
|
+
_nicHardwareChecked.add(dev);
|
|
244
|
+
continue;
|
|
245
|
+
}
|
|
246
|
+
pciDevices = pciDevices || (await (0, pci_1.pci)());
|
|
247
|
+
if (!pciDevices.length) {
|
|
248
|
+
continue;
|
|
249
|
+
}
|
|
250
|
+
const entry = pciDevices.find((item) => item.slot && slot.endsWith(item.slot));
|
|
251
|
+
if (entry) {
|
|
252
|
+
_nicHardware[dev] = { vendor: entry.vendor, model: entry.model };
|
|
253
|
+
}
|
|
254
|
+
_nicHardwareChecked.add(dev);
|
|
255
|
+
}
|
|
256
|
+
return _nicHardware;
|
|
257
|
+
};
|
|
197
258
|
const networkInterfaces = async (defaultString = '', rescan = true) => {
|
|
198
259
|
await (0, common_1.nextTick)();
|
|
199
260
|
const interfaces = (0, node_os_1.networkInterfaces)();
|
|
@@ -215,6 +276,8 @@ const networkInterfaces = async (defaultString = '', rescan = true) => {
|
|
|
215
276
|
}
|
|
216
277
|
}
|
|
217
278
|
catch { }
|
|
279
|
+
const gateways = await getLinuxGateways();
|
|
280
|
+
const hardware = await getLinuxNicHardware(devices);
|
|
218
281
|
for (const dev of devices) {
|
|
219
282
|
const iface = dev;
|
|
220
283
|
let ip4 = '';
|
|
@@ -313,11 +376,14 @@ const networkInterfaces = async (defaultString = '', rescan = true) => {
|
|
|
313
376
|
...defaults_1.initNetworkInterface,
|
|
314
377
|
iface: ifaceSanitized,
|
|
315
378
|
ifaceName,
|
|
379
|
+
vendor: hardware[ifaceSanitized]?.vendor || '',
|
|
380
|
+
model: hardware[ifaceSanitized]?.model || '',
|
|
316
381
|
default: iface === defaultInterface,
|
|
317
382
|
ip4,
|
|
318
383
|
ip4subnet,
|
|
319
384
|
ip6,
|
|
320
385
|
ip6subnet,
|
|
386
|
+
gateway: gateways[ifaceSanitized] || '',
|
|
321
387
|
mac,
|
|
322
388
|
internal,
|
|
323
389
|
virtual,
|
package/dist/windows/audio.d.ts
CHANGED
|
@@ -1,2 +1,31 @@
|
|
|
1
1
|
import type { AudioData } from '../common/types';
|
|
2
|
+
type WindowsAudioEndpoint = {
|
|
3
|
+
f: string;
|
|
4
|
+
s: unknown;
|
|
5
|
+
r?: unknown;
|
|
6
|
+
l?: unknown;
|
|
7
|
+
n: string;
|
|
8
|
+
};
|
|
9
|
+
export declare const audioFlowNames: (endpoints: WindowsAudioEndpoint[], flow: string) => string[];
|
|
10
|
+
export declare const pickDefaultAudioNames: (endpoints: WindowsAudioEndpoint[]) => {
|
|
11
|
+
render: string | null;
|
|
12
|
+
capture: string | null;
|
|
13
|
+
};
|
|
14
|
+
export declare const matchesAudioDevice: (name: string, names: string[]) => boolean;
|
|
15
|
+
export declare const audioFlowFlags: (name: string, renderNames: string[], captureNames: string[]) => {
|
|
16
|
+
in: boolean;
|
|
17
|
+
out: boolean;
|
|
18
|
+
} | {
|
|
19
|
+
in: null;
|
|
20
|
+
out: null;
|
|
21
|
+
};
|
|
22
|
+
export declare const audioChannelWin: (pnpDeviceId: string, name: string) => "HDMI" | "USB" | "PCIe" | "Bluetooth" | "Onboard" | null;
|
|
23
|
+
export declare const audioDefaultFlag: (name: string, defaults: {
|
|
24
|
+
render: string | null;
|
|
25
|
+
capture: string | null;
|
|
26
|
+
}, flows: {
|
|
27
|
+
in: boolean | null;
|
|
28
|
+
out: boolean | null;
|
|
29
|
+
}) => boolean | null;
|
|
2
30
|
export declare const audio: () => Promise<AudioData[]>;
|
|
31
|
+
export {};
|
package/dist/windows/audio.js
CHANGED
|
@@ -1,23 +1,163 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.audio = void 0;
|
|
3
|
+
exports.audio = exports.audioDefaultFlag = exports.audioChannelWin = exports.audioFlowFlags = exports.matchesAudioDevice = exports.pickDefaultAudioNames = exports.audioFlowNames = void 0;
|
|
4
4
|
const common_1 = require("../common");
|
|
5
5
|
const defaults_1 = require("../common/defaults");
|
|
6
6
|
const mappings_1 = require("../common/mappings");
|
|
7
7
|
const windows_1 = require("../common/windows");
|
|
8
|
+
const MMDEVICES = 'HKLM:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\MMDevices\\Audio';
|
|
9
|
+
const NAME_KEYS = ['{b3f8fa53-0004-438e-9003-51a46e139bfc},6', '{a45c254e-df1c-4efd-8020-67d146a850e0},2', '{b3f8fa53-0004-438e-9003-51a46e139bfc},2'];
|
|
10
|
+
const WIN_AUDIO_ENDPOINTS = `@('Render','Capture') | ForEach-Object { $f=$_; Get-ChildItem "${MMDEVICES}\\$f" -ErrorAction SilentlyContinue | ForEach-Object { ` +
|
|
11
|
+
'$k=Get-ItemProperty $_.PSPath -ErrorAction SilentlyContinue; $p=Get-ItemProperty "$($_.PSPath)\\Properties" -ErrorAction SilentlyContinue; ' +
|
|
12
|
+
`[PSCustomObject]@{f=$f;s=$k.DeviceState;r=$k.'Role:0';l=$k.'Level:0';n=(@(${NAME_KEYS.map((key) => `$p.'${key}'`).join(',')}) -join ' ')} } } | ConvertTo-Json -Depth 4 -compress`;
|
|
13
|
+
const toRank = (value) => {
|
|
14
|
+
if (Array.isArray(value)) {
|
|
15
|
+
return value.length ? value.map((byte) => Number(byte) || 0) : null;
|
|
16
|
+
}
|
|
17
|
+
if (value === null || value === undefined || value === '') {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
const numeric = Number(value);
|
|
21
|
+
if (!Number.isFinite(numeric) || numeric < 0) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
const bytes = [];
|
|
25
|
+
let rest = Math.floor(numeric);
|
|
26
|
+
for (let i = 0; i < 8; i++) {
|
|
27
|
+
bytes.push(rest % 256);
|
|
28
|
+
rest = Math.floor(rest / 256);
|
|
29
|
+
}
|
|
30
|
+
return bytes;
|
|
31
|
+
};
|
|
32
|
+
const compareRank = (a, b) => {
|
|
33
|
+
for (let i = Math.max(a.length, b.length) - 1; i >= 0; i--) {
|
|
34
|
+
const diff = (a[i] || 0) - (b[i] || 0);
|
|
35
|
+
if (diff) {
|
|
36
|
+
return diff;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return 0;
|
|
40
|
+
};
|
|
41
|
+
const pickMax = (entries, compare) => {
|
|
42
|
+
let best = entries[0];
|
|
43
|
+
let ambiguous = false;
|
|
44
|
+
for (const entry of entries.slice(1)) {
|
|
45
|
+
const diff = compare(entry.value, best.value);
|
|
46
|
+
if (diff > 0) {
|
|
47
|
+
best = entry;
|
|
48
|
+
ambiguous = false;
|
|
49
|
+
}
|
|
50
|
+
else if (diff === 0) {
|
|
51
|
+
ambiguous = true;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return ambiguous ? null : best.endpoint;
|
|
55
|
+
};
|
|
56
|
+
const bestEndpoint = (active) => {
|
|
57
|
+
if (active.length === 1) {
|
|
58
|
+
return active[0];
|
|
59
|
+
}
|
|
60
|
+
for (const key of ['r', 'l']) {
|
|
61
|
+
const ranked = [];
|
|
62
|
+
for (const endpoint of active) {
|
|
63
|
+
const value = toRank(endpoint[key]);
|
|
64
|
+
if (value) {
|
|
65
|
+
ranked.push({ endpoint, value });
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
const best = ranked.length ? pickMax(ranked, compareRank) : null;
|
|
69
|
+
if (best) {
|
|
70
|
+
return best;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return null;
|
|
74
|
+
};
|
|
75
|
+
const activeEndpoints = (endpoints, flow) => endpoints.filter((endpoint) => endpoint.f === flow && Number(endpoint.s) === 1 && (endpoint.n || '').trim());
|
|
76
|
+
const audioFlowNames = (endpoints, flow) => activeEndpoints(endpoints, flow).map((endpoint) => endpoint.n.trim().toLowerCase());
|
|
77
|
+
exports.audioFlowNames = audioFlowNames;
|
|
78
|
+
const endpointNames = (endpoint) => (endpoint?.n || '').trim().toLowerCase() || null;
|
|
79
|
+
const pickDefaultAudioNames = (endpoints) => ({
|
|
80
|
+
render: endpointNames(bestEndpoint(activeEndpoints(endpoints, 'Render'))),
|
|
81
|
+
capture: endpointNames(bestEndpoint(activeEndpoints(endpoints, 'Capture')))
|
|
82
|
+
});
|
|
83
|
+
exports.pickDefaultAudioNames = pickDefaultAudioNames;
|
|
84
|
+
const matchesAudioDevice = (name, names) => {
|
|
85
|
+
const needle = (name || '').trim().toLowerCase();
|
|
86
|
+
return needle.length > 2 && names.some((entry) => entry.includes(needle));
|
|
87
|
+
};
|
|
88
|
+
exports.matchesAudioDevice = matchesAudioDevice;
|
|
89
|
+
const audioFlowFlags = (name, renderNames, captureNames) => {
|
|
90
|
+
const out = (0, exports.matchesAudioDevice)(name, renderNames);
|
|
91
|
+
const isIn = (0, exports.matchesAudioDevice)(name, captureNames);
|
|
92
|
+
return out || isIn ? { in: isIn, out } : { in: null, out: null };
|
|
93
|
+
};
|
|
94
|
+
exports.audioFlowFlags = audioFlowFlags;
|
|
95
|
+
const audioChannelWin = (pnpDeviceId, name) => {
|
|
96
|
+
const id = (pnpDeviceId || '').toUpperCase();
|
|
97
|
+
const label = (name || '').toLowerCase();
|
|
98
|
+
if (label.includes('hdmi') || label.includes('displayport')) {
|
|
99
|
+
return 'HDMI';
|
|
100
|
+
}
|
|
101
|
+
if (id.startsWith('USB\\')) {
|
|
102
|
+
return 'USB';
|
|
103
|
+
}
|
|
104
|
+
if (id.startsWith('BTH')) {
|
|
105
|
+
return 'Bluetooth';
|
|
106
|
+
}
|
|
107
|
+
if (id.startsWith('HDAUDIO\\') || id.startsWith('INTELAUDIO\\')) {
|
|
108
|
+
return 'Onboard';
|
|
109
|
+
}
|
|
110
|
+
if (id.startsWith('PCI\\')) {
|
|
111
|
+
return 'PCIe';
|
|
112
|
+
}
|
|
113
|
+
return null;
|
|
114
|
+
};
|
|
115
|
+
exports.audioChannelWin = audioChannelWin;
|
|
116
|
+
const audioDefaultFlag = (name, defaults, flows) => {
|
|
117
|
+
const known = [defaults.render, defaults.capture].filter((entry) => Boolean(entry));
|
|
118
|
+
if ((0, exports.matchesAudioDevice)(name, known)) {
|
|
119
|
+
return true;
|
|
120
|
+
}
|
|
121
|
+
if (!known.length || (flows.out && !defaults.render) || (flows.in && !defaults.capture)) {
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
return false;
|
|
125
|
+
};
|
|
126
|
+
exports.audioDefaultFlag = audioDefaultFlag;
|
|
127
|
+
const getWindowsAudioEndpoints = async () => {
|
|
128
|
+
try {
|
|
129
|
+
return (0, windows_1.psArray)(await windows_1.ps.exec(WIN_AUDIO_ENDPOINTS));
|
|
130
|
+
}
|
|
131
|
+
catch {
|
|
132
|
+
return [];
|
|
133
|
+
}
|
|
134
|
+
};
|
|
8
135
|
const audio = async () => {
|
|
9
136
|
await (0, common_1.nextTick)();
|
|
10
137
|
const defaults = (0, common_1.cloneObj)(defaults_1.initAudioResult);
|
|
11
|
-
const
|
|
12
|
-
|
|
138
|
+
const [deviceList, endpoints] = await Promise.all([
|
|
139
|
+
windows_1.ps.exec('Get-CimInstance Win32_SoundDevice | Select-Object DeviceID,PNPDeviceID,StatusInfo,Name,Manufacturer | ConvertTo-Json -Depth 5'),
|
|
140
|
+
getWindowsAudioEndpoints()
|
|
141
|
+
]);
|
|
142
|
+
const defaultNames = (0, exports.pickDefaultAudioNames)(endpoints);
|
|
143
|
+
const renderNames = (0, exports.audioFlowNames)(endpoints, 'Render');
|
|
144
|
+
const captureNames = (0, exports.audioFlowNames)(endpoints, 'Capture');
|
|
145
|
+
return (0, windows_1.psArray)(deviceList)
|
|
13
146
|
.filter((data) => data?.Name)
|
|
14
|
-
.map((data) =>
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
147
|
+
.map((data) => {
|
|
148
|
+
const flows = (0, exports.audioFlowFlags)(data.Name, renderNames, captureNames);
|
|
149
|
+
return {
|
|
150
|
+
...defaults,
|
|
151
|
+
id: data.DeviceID || '',
|
|
152
|
+
name: data.Name,
|
|
153
|
+
manufacturer: (data.Manufacturer || '').trim(),
|
|
154
|
+
default: (0, exports.audioDefaultFlag)(data.Name, defaultNames, flows),
|
|
155
|
+
channel: (0, exports.audioChannelWin)(data.PNPDeviceID, data.Name),
|
|
156
|
+
type: (0, mappings_1.audioTypeLabel)(data.Name, Boolean(flows.in), Boolean(flows.out)),
|
|
157
|
+
in: flows.in,
|
|
158
|
+
out: flows.out,
|
|
159
|
+
status: (0, mappings_1.audioWindowsStatus)(data.StatusInfo)
|
|
160
|
+
};
|
|
161
|
+
});
|
|
22
162
|
};
|
|
23
163
|
exports.audio = audio;
|
package/dist/windows/displays.js
CHANGED
|
@@ -28,6 +28,7 @@ const parseLinesWindowsDisplaysPowershell = (ssections, monitors, dsections, con
|
|
|
28
28
|
const instanceName = monitor ? monitor.instanceName : '';
|
|
29
29
|
const bitsPerPixel = (0, common_1.toInt)((0, common_1.getValue)(linesScreen, 'BitsPerPixel'));
|
|
30
30
|
const bounds = (0, common_1.getValue)(linesScreen, 'Bounds').replace('{', '').replace('}', '').replace(/=/g, ':').split(',');
|
|
31
|
+
const workArea = (0, common_1.getValue)(linesScreen, 'WorkingArea').replace('{', '').replace('}', '').replace(/=/g, ':').split(',');
|
|
31
32
|
const primary = (0, common_1.getValue)(linesScreen, 'Primary');
|
|
32
33
|
const sizeX = monitor ? monitor.sizeX : '';
|
|
33
34
|
const sizeY = monitor ? monitor.sizeY : '';
|
|
@@ -40,6 +41,11 @@ const parseLinesWindowsDisplaysPowershell = (ssections, monitors, dsections, con
|
|
|
40
41
|
const boundsY = (0, common_1.toInt)((0, common_1.getValue)(bounds, 'Y', ':'));
|
|
41
42
|
const resX = mode ? mode.width : boundsWidth;
|
|
42
43
|
const resY = mode ? mode.height : boundsHeight;
|
|
44
|
+
const posX = mode ? mode.positionX : boundsX;
|
|
45
|
+
const posY = mode ? mode.positionY : boundsY;
|
|
46
|
+
const dpiScale = mode && boundsWidth ? mode.width / boundsWidth : 1;
|
|
47
|
+
const workAreaWidth = (0, common_1.getValue)(workArea, 'Width', ':');
|
|
48
|
+
const workAreaHeight = (0, common_1.getValue)(workArea, 'Height', ':');
|
|
43
49
|
const isection = instanceName ? isections.find((element) => element.instanceId.toLowerCase().startsWith(instanceName)) : undefined;
|
|
44
50
|
const dsection = instanceName ? desktopMonitors.find((element) => element.deviceId && instanceName.startsWith(element.deviceId)) : undefined;
|
|
45
51
|
displays.push({
|
|
@@ -61,8 +67,12 @@ const parseLinesWindowsDisplaysPowershell = (ssections, monitors, dsections, con
|
|
|
61
67
|
pixelDepth: bitsPerPixel,
|
|
62
68
|
currentResX: resX,
|
|
63
69
|
currentResY: resY,
|
|
64
|
-
positionX:
|
|
65
|
-
positionY:
|
|
70
|
+
positionX: posX,
|
|
71
|
+
positionY: posY,
|
|
72
|
+
workAreaResolutionX: workAreaWidth ? Math.round((0, common_1.toInt)(workAreaWidth) * dpiScale) : null,
|
|
73
|
+
workAreaResolutionY: workAreaHeight ? Math.round((0, common_1.toInt)(workAreaHeight) * dpiScale) : null,
|
|
74
|
+
workAreaPositionX: workAreaWidth ? Math.round(posX + ((0, common_1.toInt)((0, common_1.getValue)(workArea, 'X', ':')) - boundsX) * dpiScale) : null,
|
|
75
|
+
workAreaPositionY: workAreaHeight ? Math.round(posY + ((0, common_1.toInt)((0, common_1.getValue)(workArea, 'Y', ':')) - boundsY) * dpiScale) : null,
|
|
66
76
|
currentRefreshRate: (mode && mode.refreshRate) || null,
|
|
67
77
|
scale: mode && boundsWidth ? Math.round((mode.width / boundsWidth) * 100) / 100 : null
|
|
68
78
|
});
|
|
@@ -91,6 +101,10 @@ const parseLinesWindowsDisplaysPowershell = (ssections, monitors, dsections, con
|
|
|
91
101
|
currentResY: first ? first.resolutionY : 0,
|
|
92
102
|
positionX: 0,
|
|
93
103
|
positionY: 0,
|
|
104
|
+
workAreaResolutionX: null,
|
|
105
|
+
workAreaResolutionY: null,
|
|
106
|
+
workAreaPositionX: null,
|
|
107
|
+
workAreaPositionY: null,
|
|
94
108
|
currentRefreshRate: null,
|
|
95
109
|
scale: null
|
|
96
110
|
});
|
|
@@ -34,9 +34,13 @@ const parseLinesWindowsNics = (sections, nconfigsections) => {
|
|
|
34
34
|
}
|
|
35
35
|
if (netEnabled !== '') {
|
|
36
36
|
const speed = (0, common_1.toInt)((0, common_1.getValue)(lines, 'speed', ':').trim()) / 1000000;
|
|
37
|
+
const gateway = ((0, common_1.getValue)(linesNicConfig, 'DefaultIPGateway', ':').replace(/[{}"]/g, '').split(',')[0] || '').trim();
|
|
37
38
|
nics.push({
|
|
38
39
|
mac: (0, common_1.getValue)(lines, 'MACAddress', ':').toLowerCase(),
|
|
39
40
|
dhcp: (0, common_1.getValue)(linesNicConfig, 'dhcpEnabled', ':').toLowerCase() === 'true',
|
|
41
|
+
gateway,
|
|
42
|
+
vendor: (0, common_1.getValue)(lines, 'Manufacturer', ':'),
|
|
43
|
+
model: (0, common_1.getValue)(lines, 'ProductName', ':') || (0, common_1.getValue)(lines, 'Description', ':'),
|
|
40
44
|
name: ifacename,
|
|
41
45
|
iface,
|
|
42
46
|
netEnabled: netEnabled === 'TRUE',
|
|
@@ -54,7 +58,7 @@ const parseLinesWindowsNics = (sections, nconfigsections) => {
|
|
|
54
58
|
};
|
|
55
59
|
const getWindowsNics = async () => {
|
|
56
60
|
let cmd = 'Get-CimInstance Win32_NetworkAdapter | fl *' + "; echo '#-#-#-#';";
|
|
57
|
-
cmd += 'Get-CimInstance Win32_NetworkAdapterConfiguration | fl DHCPEnabled' + '';
|
|
61
|
+
cmd += 'Get-CimInstance Win32_NetworkAdapterConfiguration | fl DHCPEnabled, DefaultIPGateway' + '';
|
|
58
62
|
try {
|
|
59
63
|
const stdout = String((await windows_1.ps.exec(cmd)) || '');
|
|
60
64
|
const data = stdout.split('#-#-#-#');
|
|
@@ -251,6 +255,9 @@ const networkInterfaces = async (defaultString = '', rescan = true) => {
|
|
|
251
255
|
let speed = 0;
|
|
252
256
|
let operstate = 'down';
|
|
253
257
|
let dhcp = false;
|
|
258
|
+
let gateway = '';
|
|
259
|
+
let vendor = '';
|
|
260
|
+
let model = '';
|
|
254
261
|
let dnsSuffix = '';
|
|
255
262
|
let ieee8021xAuth = '';
|
|
256
263
|
let ieee8021xState = '';
|
|
@@ -276,6 +283,9 @@ const networkInterfaces = async (defaultString = '', rescan = true) => {
|
|
|
276
283
|
iface = detail.iface || iface;
|
|
277
284
|
ifaceName = detail.name;
|
|
278
285
|
dhcp = detail.dhcp;
|
|
286
|
+
gateway = detail.gateway;
|
|
287
|
+
vendor = detail.vendor;
|
|
288
|
+
model = detail.model;
|
|
279
289
|
operstate = detail.operstate;
|
|
280
290
|
speed = operstate === 'up' ? detail.speed : 0;
|
|
281
291
|
type = detail.type;
|
|
@@ -303,11 +313,14 @@ const networkInterfaces = async (defaultString = '', rescan = true) => {
|
|
|
303
313
|
...defaults_1.initNetworkInterface,
|
|
304
314
|
iface,
|
|
305
315
|
ifaceName,
|
|
316
|
+
vendor,
|
|
317
|
+
model,
|
|
306
318
|
default: iface === defaultInterface,
|
|
307
319
|
ip4,
|
|
308
320
|
ip4subnet,
|
|
309
321
|
ip6,
|
|
310
322
|
ip6subnet,
|
|
323
|
+
gateway,
|
|
311
324
|
mac,
|
|
312
325
|
internal,
|
|
313
326
|
virtual,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { CpuData, ProcessesData, ProcStatData } from '../common/types';
|
|
2
|
+
export declare const processStateWin: (running: number, waiting: number, suspended: number) => "unknown" | "running" | "blocked" | "sleeping";
|
|
2
3
|
export declare const calcProcStatWin: (procStat: ProcStatData, all: number, _cpu_old: CpuData) => {
|
|
3
4
|
pid: number;
|
|
4
5
|
utime: number;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.processes = exports.calcProcStatWin = void 0;
|
|
3
|
+
exports.processes = exports.calcProcStatWin = exports.processStateWin = void 0;
|
|
4
4
|
const node_os_1 = require("node:os");
|
|
5
5
|
const common_1 = require("../common");
|
|
6
6
|
const defaults_1 = require("../common/defaults");
|
|
7
|
-
const mappings_1 = require("../common/mappings");
|
|
8
7
|
const windows_1 = require("../common/windows");
|
|
9
8
|
const parse_1 = require("../common/parse");
|
|
10
9
|
const _processes_cpu = {
|
|
@@ -15,6 +14,32 @@ const _processes_cpu = {
|
|
|
15
14
|
ms: 0,
|
|
16
15
|
result: {}
|
|
17
16
|
};
|
|
17
|
+
const processStateWin = (running, waiting, suspended) => {
|
|
18
|
+
if (running > 0) {
|
|
19
|
+
return 'running';
|
|
20
|
+
}
|
|
21
|
+
if (waiting > 0) {
|
|
22
|
+
return 'sleeping';
|
|
23
|
+
}
|
|
24
|
+
if (suspended > 0) {
|
|
25
|
+
return 'blocked';
|
|
26
|
+
}
|
|
27
|
+
return 'unknown';
|
|
28
|
+
};
|
|
29
|
+
exports.processStateWin = processStateWin;
|
|
30
|
+
const WIN_THREAD_STATES = 'Get-Process -ErrorAction SilentlyContinue | ForEach-Object { $r=0;$w=0;$u=0; try { foreach ($t in $_.Threads) { $s=[int]$t.ThreadState; ' +
|
|
31
|
+
'if ($s -eq 1 -or $s -eq 2 -or $s -eq 3 -or $s -eq 6) { $r++ } elseif ($s -eq 5) { if ([int]$t.WaitReason -eq 5) { $u++ } else { $w++ } } } } catch {}; ' +
|
|
32
|
+
'[PSCustomObject]@{i=$_.Id;r=$r;w=$w;u=$u} } | ConvertTo-Json -compress';
|
|
33
|
+
const getWindowsProcessStates = async () => {
|
|
34
|
+
const result = {};
|
|
35
|
+
try {
|
|
36
|
+
for (const entry of (0, windows_1.psArray)(await windows_1.ps.exec(WIN_THREAD_STATES))) {
|
|
37
|
+
result[entry.i] = (0, exports.processStateWin)(entry.r || 0, entry.w || 0, entry.u || 0);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
catch { }
|
|
41
|
+
return result;
|
|
42
|
+
};
|
|
18
43
|
const calcProcStatWin = (procStat, all, _cpu_old) => {
|
|
19
44
|
let cpuu = 0;
|
|
20
45
|
let cpus = 0;
|
|
@@ -43,8 +68,12 @@ const processes = async () => {
|
|
|
43
68
|
if ((_processes_cpu.ms && Date.now() - _processes_cpu.ms >= 500) || _processes_cpu.ms === 0) {
|
|
44
69
|
const cpuBaseline = { ..._processes_cpu };
|
|
45
70
|
try {
|
|
46
|
-
const
|
|
47
|
-
|
|
71
|
+
const [processList, states] = await Promise.all([
|
|
72
|
+
windows_1.ps.exec(`Get-CimInstance Win32_Process | select-Object ProcessId,ParentProcessId,Caption,CommandLine,ExecutablePath,UserModeTime,KernelModeTime,WorkingSetSize,Priority,PageFileUsage,
|
|
73
|
+
@{n="CreationDate";e={$_.CreationDate.ToString("yyyy-MM-dd HH:mm:ss")}} | ConvertTo-Json -compress`),
|
|
74
|
+
getWindowsProcessStates()
|
|
75
|
+
]);
|
|
76
|
+
const processArray = (0, windows_1.psArray)(processList);
|
|
48
77
|
if (processArray.length) {
|
|
49
78
|
const procs = [];
|
|
50
79
|
const procStats = [];
|
|
@@ -54,7 +83,6 @@ const processes = async () => {
|
|
|
54
83
|
processArray.forEach((element) => {
|
|
55
84
|
const pid = element.ProcessId;
|
|
56
85
|
const parentPid = element.ParentProcessId;
|
|
57
|
-
const statusValue = element.ExecutionState || null;
|
|
58
86
|
const name = element.Caption;
|
|
59
87
|
const commandLine = element.CommandLine;
|
|
60
88
|
const commandPath = element.ExecutablePath;
|
|
@@ -65,15 +93,6 @@ const processes = async () => {
|
|
|
65
93
|
allcpuu += utime - (cpuOld ? cpuOld.utime : 0);
|
|
66
94
|
allcpus += stime - (cpuOld ? cpuOld.stime : 0);
|
|
67
95
|
result.all++;
|
|
68
|
-
if (!statusValue) {
|
|
69
|
-
result.unknown++;
|
|
70
|
-
}
|
|
71
|
-
if (statusValue === 3) {
|
|
72
|
-
result.running++;
|
|
73
|
-
}
|
|
74
|
-
if (statusValue === 4 || statusValue === 5) {
|
|
75
|
-
result.blocked++;
|
|
76
|
-
}
|
|
77
96
|
procStats.push({
|
|
78
97
|
pid: pid,
|
|
79
98
|
name: '',
|
|
@@ -97,7 +116,7 @@ const processes = async () => {
|
|
|
97
116
|
memRss: Math.floor((element.WorkingSetSize || 0) / 1024),
|
|
98
117
|
nice: 0,
|
|
99
118
|
started: element.CreationDate,
|
|
100
|
-
state:
|
|
119
|
+
state: states[pid] || 'unknown',
|
|
101
120
|
tty: '',
|
|
102
121
|
user: '',
|
|
103
122
|
command: commandLine || name,
|
|
@@ -105,6 +124,9 @@ const processes = async () => {
|
|
|
105
124
|
params: ''
|
|
106
125
|
});
|
|
107
126
|
});
|
|
127
|
+
result.running = procs.filter((proc) => proc.state === 'running').length;
|
|
128
|
+
result.blocked = procs.filter((proc) => proc.state === 'blocked').length;
|
|
129
|
+
result.unknown = procs.filter((proc) => proc.state === 'unknown').length;
|
|
108
130
|
result.sleeping = result.all - result.running - result.blocked - result.unknown;
|
|
109
131
|
result.list = procs;
|
|
110
132
|
procStats.forEach((element) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "systeminformation",
|
|
3
|
-
"version": "6.0.0-beta.
|
|
3
|
+
"version": "6.0.0-beta.12",
|
|
4
4
|
"description": "Advanced, lightweight system and OS information library",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Sebastian Hildebrandt <hildebrandt@plus-innovations.com> (https://plus-innovations.com)",
|