systeminformation 6.0.0-beta.11 → 6.0.0-beta.13
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 +17 -7
- package/dist/bsd/network-stats.js +2 -1
- package/dist/common/defaults.js +7 -1
- package/dist/common/filesys.d.ts +19 -0
- package/dist/common/filesys.js +167 -2
- package/dist/common/mappings.d.ts +0 -3
- package/dist/common/mappings.js +1 -13
- package/dist/common/types.d.ts +11 -0
- package/dist/common/windows.d.ts +4 -0
- package/dist/common/windows.js +57 -1
- package/dist/cpu-current-load.d.ts +1 -0
- package/dist/cpu-current-load.js +26 -2
- package/dist/darwin/displays.d.ts +1 -0
- package/dist/darwin/displays.js +30 -1
- package/dist/darwin/index.d.ts +1 -0
- package/dist/darwin/index.js +4 -2
- package/dist/darwin/network-interfaces.d.ts +3 -0
- package/dist/darwin/network-interfaces.js +78 -3
- package/dist/darwin/network-stats.js +3 -2
- package/dist/darwin/process-focused.d.ts +3 -0
- package/dist/darwin/process-focused.js +26 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -1
- package/dist/linux/block-devices.js +3 -1
- package/dist/linux/displays.d.ts +8 -0
- package/dist/linux/displays.js +112 -3
- package/dist/linux/index.d.ts +1 -0
- package/dist/linux/index.js +4 -2
- package/dist/linux/network-interfaces.d.ts +1 -0
- package/dist/linux/network-interfaces.js +69 -2
- package/dist/linux/process-focused.d.ts +4 -0
- package/dist/linux/process-focused.js +32 -0
- package/dist/linux/process-load.js +2 -1
- package/dist/linux/services.js +5 -4
- package/dist/process-focused.d.ts +1 -0
- package/dist/process-focused.js +17 -0
- package/dist/windows/audio.d.ts +29 -0
- package/dist/windows/audio.js +151 -11
- package/dist/windows/displays.d.ts +5 -0
- package/dist/windows/displays.js +59 -5
- package/dist/windows/gpu.js +3 -2
- package/dist/windows/index.d.ts +1 -0
- package/dist/windows/index.js +3 -1
- package/dist/windows/network-interfaces.js +14 -1
- package/dist/windows/process-focused.d.ts +3 -0
- package/dist/windows/process-focused.js +36 -0
- package/dist/windows/processes.d.ts +1 -0
- package/dist/windows/processes.js +37 -15
- package/package.json +1 -1
package/dist/linux/services.js
CHANGED
|
@@ -7,6 +7,7 @@ const exec_1 = require("../common/exec");
|
|
|
7
7
|
const files_1 = require("../common/files");
|
|
8
8
|
const parse_1 = require("../common/parse");
|
|
9
9
|
const security_1 = require("../common/security");
|
|
10
|
+
const EXEC_OPTS = { timeout: 5000 };
|
|
10
11
|
const _services_cpu = {
|
|
11
12
|
all: 0,
|
|
12
13
|
all_utime: 0,
|
|
@@ -145,7 +146,7 @@ const systemdUnits = async () => {
|
|
|
145
146
|
'--property=ActiveExitTimestamp',
|
|
146
147
|
'--property=MainPID',
|
|
147
148
|
'*.service'
|
|
148
|
-
]);
|
|
149
|
+
], EXEC_OPTS);
|
|
149
150
|
stdout.split(/\n\s*\n/).forEach((block) => {
|
|
150
151
|
const lines = block.split('\n');
|
|
151
152
|
const id = (0, common_1.getValue)(lines, 'Id', '=', false, true);
|
|
@@ -178,7 +179,7 @@ const elapsedToDate = (elapsed) => {
|
|
|
178
179
|
};
|
|
179
180
|
const psProcessesLinux = async () => {
|
|
180
181
|
const procs = [];
|
|
181
|
-
const stdout = await (0, exec_1.execSecure)('ps', ['-axo', 'pcpu,pmem,pid,ppid']);
|
|
182
|
+
const stdout = await (0, exec_1.execSecure)('ps', ['-axo', 'pcpu,pmem,pid,ppid'], EXEC_OPTS);
|
|
182
183
|
stdout
|
|
183
184
|
.replace(/ +/g, ' ')
|
|
184
185
|
.replace(/,+/g, '.')
|
|
@@ -257,7 +258,7 @@ const services = async (srv) => {
|
|
|
257
258
|
}
|
|
258
259
|
let args = const_1.DARWIN ? ['-caxo', 'pcpu,pmem,pid,etime,command'] : ['-axo', 'pcpu,pmem,pid,etime,command'];
|
|
259
260
|
if (srvs.length > 0) {
|
|
260
|
-
let stdout = await (0, exec_1.execSecure)('ps', args);
|
|
261
|
+
let stdout = await (0, exec_1.execSecure)('ps', args, EXEC_OPTS);
|
|
261
262
|
if (stdout) {
|
|
262
263
|
const lines = stdout.replace(/ +/g, ' ').replace(/,+/g, '.').split('\n');
|
|
263
264
|
srvs.forEach((srv) => {
|
|
@@ -313,7 +314,7 @@ const services = async (srv) => {
|
|
|
313
314
|
}
|
|
314
315
|
else {
|
|
315
316
|
args = ['-o', 'comm'];
|
|
316
|
-
stdout = await (0, exec_1.execSecure)('ps', args);
|
|
317
|
+
stdout = await (0, exec_1.execSecure)('ps', args, EXEC_OPTS);
|
|
317
318
|
if (stdout) {
|
|
318
319
|
const lines = stdout.replace(/ +/g, ' ').replace(/,+/g, '.').split('\n');
|
|
319
320
|
srvs.forEach((srv) => {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const processFocused: () => Promise<import("./common/types").ProcessFocusedData | null>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.processFocused = void 0;
|
|
4
|
+
const const_1 = require("./common/const");
|
|
5
|
+
const processFocused = async () => {
|
|
6
|
+
switch (true) {
|
|
7
|
+
case const_1.LINUX:
|
|
8
|
+
return (await import('./linux/process-focused.js')).processFocused();
|
|
9
|
+
case const_1.DARWIN:
|
|
10
|
+
return (await import('./darwin/process-focused.js')).processFocused();
|
|
11
|
+
case const_1.WINDOWS:
|
|
12
|
+
return (await import('./windows/process-focused.js')).processFocused();
|
|
13
|
+
default:
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
exports.processFocused = processFocused;
|
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;
|
|
@@ -1,2 +1,7 @@
|
|
|
1
1
|
import type { DisplayData } from '../common/types';
|
|
2
|
+
export declare const parseEnumDisplayDevices: (stdout: any) => Map<string, {
|
|
3
|
+
gpu: string;
|
|
4
|
+
deviceId: string;
|
|
5
|
+
}>;
|
|
6
|
+
export declare const windowsAvailabilityToPowerState: (value: string) => string;
|
|
2
7
|
export declare const displays: () => Promise<DisplayData[]>;
|
package/dist/windows/displays.js
CHANGED
|
@@ -1,12 +1,58 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.displays = void 0;
|
|
3
|
+
exports.displays = exports.windowsAvailabilityToPowerState = exports.parseEnumDisplayDevices = void 0;
|
|
4
4
|
const common_1 = require("../common");
|
|
5
5
|
const mappings_1 = require("../common/mappings");
|
|
6
6
|
const exec_1 = require("../common/exec");
|
|
7
7
|
const windows_1 = require("../common/windows");
|
|
8
8
|
const psCurrentModes = "Add-Type -AssemblyName System.Windows.Forms; if (-not ('SiDevMode' -as [Type])) { Add-Type -TypeDefinition 'using System;using System.Runtime.InteropServices;[StructLayout(LayoutKind.Sequential,CharSet=CharSet.Ansi)]public struct SIDEVMODE{[MarshalAs(UnmanagedType.ByValTStr,SizeConst=32)]public string dmDeviceName;public short dmSpecVersion;public short dmDriverVersion;public short dmSize;public short dmDriverExtra;public int dmFields;public int dmPositionX;public int dmPositionY;public int dmDisplayOrientation;public int dmDisplayFixedOutput;public short dmColor;public short dmDuplex;public short dmYResolution;public short dmTTOption;public short dmCollate;[MarshalAs(UnmanagedType.ByValTStr,SizeConst=32)]public string dmFormName;public short dmLogPixels;public int dmBitsPerPel;public int dmPelsWidth;public int dmPelsHeight;public int dmDisplayFlags;public int dmDisplayFrequency;public int dmICMMethod;public int dmICMIntent;public int dmMediaType;public int dmDitherType;public int dmReserved1;public int dmReserved2;public int dmPanningWidth;public int dmPanningHeight;}public class SiDevMode{[DllImport(\"user32.dll\",CharSet=CharSet.Ansi)]public static extern bool EnumDisplaySettings(string lpszDeviceName,int iModeNum,ref SIDEVMODE lpDevMode);}' }; [System.Windows.Forms.Screen]::AllScreens | ForEach-Object { $dm = New-Object SIDEVMODE; $dm.dmSize = [System.Runtime.InteropServices.Marshal]::SizeOf($dm); if ([SiDevMode]::EnumDisplaySettings($_.DeviceName, -1, [ref]$dm)) { $_.DeviceName + '|' + $dm.dmDisplayFrequency + '|' + $dm.dmBitsPerPel + '|' + $dm.dmPelsWidth + '|' + $dm.dmPelsHeight + '|' + $dm.dmPositionX + '|' + $dm.dmPositionY } }";
|
|
9
|
-
const
|
|
9
|
+
const psDisplayAdapters = `if (-not ([System.Management.Automation.PSTypeName]'SIDispHolder').Type) { Add-Type -TypeDefinition @"
|
|
10
|
+
using System;
|
|
11
|
+
using System.Runtime.InteropServices;
|
|
12
|
+
public class SIDispHolder {
|
|
13
|
+
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
|
|
14
|
+
public struct DISPLAY_DEVICE {
|
|
15
|
+
public int cb;
|
|
16
|
+
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=32)] public string DeviceName;
|
|
17
|
+
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=128)] public string DeviceString;
|
|
18
|
+
public int StateFlags;
|
|
19
|
+
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=128)] public string DeviceID;
|
|
20
|
+
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=128)] public string DeviceKey;
|
|
21
|
+
}
|
|
22
|
+
[DllImport("user32.dll", CharSet=CharSet.Unicode)]
|
|
23
|
+
public static extern bool EnumDisplayDevices(string lpDevice, uint iDevNum, ref SIDispHolder.DISPLAY_DEVICE lpDisplayDevice, uint dwFlags);
|
|
24
|
+
}
|
|
25
|
+
"@ -ErrorAction SilentlyContinue };
|
|
26
|
+
$d = New-Object SIDispHolder+DISPLAY_DEVICE;
|
|
27
|
+
for ($i = 0; $i -lt 16; $i++) {
|
|
28
|
+
$d.cb = [System.Runtime.InteropServices.Marshal]::SizeOf($d);
|
|
29
|
+
if (-not [SIDispHolder]::EnumDisplayDevices($null, $i, [ref]$d, 0)) { break };
|
|
30
|
+
"$($d.DeviceName)|$($d.DeviceString)|$($d.DeviceID)"
|
|
31
|
+
}`;
|
|
32
|
+
const parseEnumDisplayDevices = (stdout) => {
|
|
33
|
+
const result = new Map();
|
|
34
|
+
for (const line of String(stdout ?? '').split('\n')) {
|
|
35
|
+
const parts = line.trim().split('|');
|
|
36
|
+
if (parts.length < 3 || !parts[0].startsWith('\\\\.\\')) {
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
result.set(parts[0].toLowerCase(), { gpu: parts[1].trim(), deviceId: parts[2].trim() });
|
|
40
|
+
}
|
|
41
|
+
return result;
|
|
42
|
+
};
|
|
43
|
+
exports.parseEnumDisplayDevices = parseEnumDisplayDevices;
|
|
44
|
+
const WIN_AVAILABILITY = new Map([
|
|
45
|
+
['3', 'on'],
|
|
46
|
+
['7', 'off'],
|
|
47
|
+
['8', 'off'],
|
|
48
|
+
['13', 'standby'],
|
|
49
|
+
['14', 'standby'],
|
|
50
|
+
['15', 'standby'],
|
|
51
|
+
['17', 'standby']
|
|
52
|
+
]);
|
|
53
|
+
const windowsAvailabilityToPowerState = (value) => WIN_AVAILABILITY.get(String(value ?? '').trim()) || '';
|
|
54
|
+
exports.windowsAvailabilityToPowerState = windowsAvailabilityToPowerState;
|
|
55
|
+
const parseLinesWindowsDisplaysPowershell = (ssections, monitors, dsections, connections, isections, currentModes, adapters, locations) => {
|
|
10
56
|
const displays = [];
|
|
11
57
|
const desktopMonitors = (dsections || []).map((section) => {
|
|
12
58
|
const linesDisplay = section.split('\n');
|
|
@@ -15,7 +61,8 @@ const parseLinesWindowsDisplaysPowershell = (ssections, monitors, dsections, con
|
|
|
15
61
|
vendor: (0, common_1.getValue)(linesDisplay, 'MonitorManufacturer', ':'),
|
|
16
62
|
model: (0, common_1.getValue)(linesDisplay, 'Name', ':'),
|
|
17
63
|
resolutionX: (0, common_1.toInt)((0, common_1.getValue)(linesDisplay, 'ScreenWidth', ':')),
|
|
18
|
-
resolutionY: (0, common_1.toInt)((0, common_1.getValue)(linesDisplay, 'ScreenHeight', ':'))
|
|
64
|
+
resolutionY: (0, common_1.toInt)((0, common_1.getValue)(linesDisplay, 'ScreenHeight', ':')),
|
|
65
|
+
powerState: (0, exports.windowsAvailabilityToPowerState)((0, common_1.getValue)(linesDisplay, 'Availability', ':'))
|
|
19
66
|
};
|
|
20
67
|
});
|
|
21
68
|
const count = Math.max(ssections.length, monitors.length);
|
|
@@ -74,13 +121,19 @@ const parseLinesWindowsDisplaysPowershell = (ssections, monitors, dsections, con
|
|
|
74
121
|
workAreaPositionX: workAreaWidth ? Math.round(posX + ((0, common_1.toInt)((0, common_1.getValue)(workArea, 'X', ':')) - boundsX) * dpiScale) : null,
|
|
75
122
|
workAreaPositionY: workAreaHeight ? Math.round(posY + ((0, common_1.toInt)((0, common_1.getValue)(workArea, 'Y', ':')) - boundsY) * dpiScale) : null,
|
|
76
123
|
currentRefreshRate: (mode && mode.refreshRate) || null,
|
|
77
|
-
scale: mode && boundsWidth ? Math.round((mode.width / boundsWidth) * 100) / 100 : null
|
|
124
|
+
scale: mode && boundsWidth ? Math.round((mode.width / boundsWidth) * 100) / 100 : null,
|
|
125
|
+
powerState: dsection ? dsection.powerState : '',
|
|
126
|
+
gpu: adapters.get(deviceName.toLowerCase())?.gpu || '',
|
|
127
|
+
gpuBusAddress: (0, windows_1.matchPnpLocation)(adapters.get(deviceName.toLowerCase())?.deviceId || '', locations)
|
|
78
128
|
});
|
|
79
129
|
}
|
|
80
130
|
}
|
|
81
131
|
if (ssections.length === 0) {
|
|
82
132
|
const first = desktopMonitors[0];
|
|
83
133
|
displays.push({
|
|
134
|
+
powerState: first ? first.powerState : '',
|
|
135
|
+
gpu: [...adapters.values()][0]?.gpu || '',
|
|
136
|
+
gpuBusAddress: (0, windows_1.matchPnpLocation)([...adapters.values()][0]?.deviceId || '', locations),
|
|
84
137
|
vendor: first ? first.vendor : '',
|
|
85
138
|
vendorId: null,
|
|
86
139
|
model: first ? first.model : '',
|
|
@@ -123,6 +176,7 @@ const displays = async () => {
|
|
|
123
176
|
workload.push(windows_1.ps.exec('Get-CimInstance -Namespace root\\wmi -ClassName WmiMonitorConnectionParams | fl'));
|
|
124
177
|
workload.push(windows_1.ps.exec('gwmi WmiMonitorID -Namespace root\\wmi | ForEach-Object {(($_.ManufacturerName -notmatch 0 | foreach {[char]$_}) -join "") + "|" + (($_.ProductCodeID -notmatch 0 | foreach {[char]$_}) -join "") + "|" + (($_.UserFriendlyName -notmatch 0 | foreach {[char]$_}) -join "") + "|" + (($_.SerialNumberID -notmatch 0 | foreach {[char]$_}) -join "") + "|" + $_.YearOfManufacture + "|" + $_.InstanceName}'));
|
|
125
178
|
workload.push(windows_1.ps.exec(psCurrentModes));
|
|
179
|
+
workload.push(windows_1.ps.exec(psDisplayAdapters));
|
|
126
180
|
const data = await Promise.allSettled(workload).then((results) => results.map((result) => (result.status === 'fulfilled' ? result.value : '')));
|
|
127
181
|
let _resolutionX = 0;
|
|
128
182
|
let _resolutionY = 0;
|
|
@@ -213,7 +267,7 @@ const displays = async () => {
|
|
|
213
267
|
};
|
|
214
268
|
}
|
|
215
269
|
});
|
|
216
|
-
result = parseLinesWindowsDisplaysPowershell(ssections, monitors, dsections, connections, isections, currentModes);
|
|
270
|
+
result = parseLinesWindowsDisplaysPowershell(ssections, monitors, dsections, connections, isections, currentModes, (0, exports.parseEnumDisplayDevices)(data[7]), await (0, windows_1.windowsPciBusAddresses)());
|
|
217
271
|
if (result.length === 1) {
|
|
218
272
|
if (_resolutionX) {
|
|
219
273
|
result[0].resolutionX = _resolutionX;
|
package/dist/windows/gpu.js
CHANGED
|
@@ -5,7 +5,7 @@ const common_1 = require("../common");
|
|
|
5
5
|
const nvidia_1 = require("../common/nvidia");
|
|
6
6
|
const exec_1 = require("../common/exec");
|
|
7
7
|
const windows_1 = require("../common/windows");
|
|
8
|
-
const parseLinesWindowsControllers = (sections, vections) => {
|
|
8
|
+
const parseLinesWindowsControllers = (sections, vections, locations) => {
|
|
9
9
|
const memorySizes = {};
|
|
10
10
|
for (const i in vections) {
|
|
11
11
|
if (Object.prototype.hasOwnProperty.call(vections, i)) {
|
|
@@ -70,6 +70,7 @@ const parseLinesWindowsControllers = (sections, vections) => {
|
|
|
70
70
|
vendor: (0, common_1.getValue)(lines, 'AdapterCompatibility', ':'),
|
|
71
71
|
model: (0, common_1.getValue)(lines, 'name', ':'),
|
|
72
72
|
bus: (0, common_1.getValue)(lines, 'PNPDeviceID', ':').startsWith('PCI') ? 'PCI' : '',
|
|
73
|
+
busAddress: (0, windows_1.matchPnpLocation)((0, common_1.getValue)(lines, 'PNPDeviceID', ':'), locations),
|
|
73
74
|
vram: (memorySize == null ? (0, common_1.toInt)((0, common_1.getValue)(lines, 'AdapterRAM', ':')) : memorySize) / 1024 / 1024,
|
|
74
75
|
vramDynamic: (0, common_1.getValue)(lines, 'VideoMemoryType', ':') === '2',
|
|
75
76
|
subDeviceId
|
|
@@ -96,7 +97,7 @@ const gpu = async () => {
|
|
|
96
97
|
.toString()
|
|
97
98
|
.replace(/\r/g, '')
|
|
98
99
|
.split(/\n\s*\n/);
|
|
99
|
-
result = parseLinesWindowsControllers(csections, vsections);
|
|
100
|
+
result = parseLinesWindowsControllers(csections, vsections, await (0, windows_1.windowsPciBusAddresses)());
|
|
100
101
|
result = result.map((controller) => {
|
|
101
102
|
if (controller.vendor.toLowerCase() === 'nvidia') {
|
|
102
103
|
return (0, nvidia_1.mergeControllerNvidia)(controller, nvidiaData.find((device) => {
|
package/dist/windows/index.d.ts
CHANGED
|
@@ -43,6 +43,7 @@ export { osInfo } from './os-info';
|
|
|
43
43
|
export { pci } from './pci';
|
|
44
44
|
export { printer } from './printer';
|
|
45
45
|
export { processLoad } from './process-load';
|
|
46
|
+
export { processFocused } from './process-focused';
|
|
46
47
|
export { processes } from './processes';
|
|
47
48
|
export { services } from './services';
|
|
48
49
|
export { shell } from './shell';
|
package/dist/windows/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
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.gpu = exports.fsStats = exports.fsSize = exports.fsOpenFiles = exports.displays = exports.disksIO = exports.diskLayout = exports.fans = exports.cpuTemperature = exports.cpuFlags = exports.cpuCache = exports.cpu = exports.chassis = exports.camera = exports.bluetoothDevices = exports.blockDevices = exports.bios = exports.battery = exports.baseboard = exports.audio = exports.vboxInfo = exports.versions = exports.version = exports.time = exports.inetChecksite = exports.dockerVolumes = exports.dockerInfo = exports.dockerImages = exports.dockerContainerStats = exports.dockerContainers = exports.dockerContainerProcesses = exports.dockerAll = exports.fullLoad = exports.cpuCurrentSpeed = exports.currentLoad = void 0;
|
|
4
|
-
exports.wifiNetworks = exports.wifiInterfaces = exports.wifiConnections = exports.uuid = exports.users = exports.usb = exports.serialPorts = exports.thunderbolt = exports.system = exports.software = exports.shell = exports.services = exports.processes = exports.processLoad = void 0;
|
|
4
|
+
exports.wifiNetworks = exports.wifiInterfaces = exports.wifiConnections = exports.uuid = exports.users = exports.usb = exports.serialPorts = exports.thunderbolt = exports.system = exports.software = exports.shell = exports.services = exports.processes = exports.processFocused = exports.processLoad = void 0;
|
|
5
5
|
var cpu_current_load_1 = require("../cpu-current-load");
|
|
6
6
|
Object.defineProperty(exports, "currentLoad", { enumerable: true, get: function () { return cpu_current_load_1.currentLoad; } });
|
|
7
7
|
var cpu_current_speed_1 = require("../cpu-current-speed");
|
|
@@ -98,6 +98,8 @@ var printer_1 = require("./printer");
|
|
|
98
98
|
Object.defineProperty(exports, "printer", { enumerable: true, get: function () { return printer_1.printer; } });
|
|
99
99
|
var process_load_1 = require("./process-load");
|
|
100
100
|
Object.defineProperty(exports, "processLoad", { enumerable: true, get: function () { return process_load_1.processLoad; } });
|
|
101
|
+
var process_focused_1 = require("./process-focused");
|
|
102
|
+
Object.defineProperty(exports, "processFocused", { enumerable: true, get: function () { return process_focused_1.processFocused; } });
|
|
101
103
|
var processes_1 = require("./processes");
|
|
102
104
|
Object.defineProperty(exports, "processes", { enumerable: true, get: function () { return processes_1.processes; } });
|
|
103
105
|
var services_1 = require("./services");
|
|
@@ -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,
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.processFocused = exports.parseWindowsFocused = void 0;
|
|
4
|
+
const windows_1 = require("../common/windows");
|
|
5
|
+
const WIN_FOREGROUND = `if (-not ([System.Management.Automation.PSTypeName]'SI.Win').Type) { Add-Type -Namespace SI -Name Win -MemberDefinition '` +
|
|
6
|
+
'[DllImport("user32.dll")] public static extern IntPtr GetForegroundWindow(); ' +
|
|
7
|
+
'[DllImport("user32.dll")] public static extern int GetWindowThreadProcessId(IntPtr hWnd, out int pid);' +
|
|
8
|
+
`' }; ` +
|
|
9
|
+
'$p = 0; [void][SI.Win]::GetWindowThreadProcessId([SI.Win]::GetForegroundWindow(), [ref]$p); ' +
|
|
10
|
+
'$proc = Get-Process -Id $p -ErrorAction SilentlyContinue; ' +
|
|
11
|
+
'[PSCustomObject]@{pid=$p;name=$proc.ProcessName;path=$proc.Path} | ConvertTo-Json -compress';
|
|
12
|
+
const parseWindowsFocused = (data) => {
|
|
13
|
+
let parsed = data;
|
|
14
|
+
if (typeof parsed === 'string') {
|
|
15
|
+
try {
|
|
16
|
+
parsed = JSON.parse(parsed);
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
if (!parsed || !parsed.pid) {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
return { pid: parsed.pid, name: parsed.name || '', path: parsed.path || '' };
|
|
26
|
+
};
|
|
27
|
+
exports.parseWindowsFocused = parseWindowsFocused;
|
|
28
|
+
const processFocused = async () => {
|
|
29
|
+
try {
|
|
30
|
+
return (0, exports.parseWindowsFocused)(await windows_1.ps.exec(WIN_FOREGROUND));
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
exports.processFocused = processFocused;
|
|
@@ -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;
|