systeminformation 6.0.0-beta.2 → 6.0.0-beta.21
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 +67 -18
- package/dist/bsd/mem.js +8 -3
- package/dist/bsd/network-stats.d.ts +1 -1
- package/dist/bsd/network-stats.js +14 -7
- package/dist/bsd/os-info.d.ts +1 -0
- package/dist/common/darwin.d.ts +2 -0
- package/dist/common/darwin.js +17 -1
- package/dist/common/defaults.d.ts +2 -1
- package/dist/common/defaults.js +36 -6
- package/dist/common/exec.js +29 -13
- package/dist/common/files.d.ts +9 -0
- package/dist/common/files.js +67 -3
- package/dist/common/filesys.d.ts +30 -0
- package/dist/common/filesys.js +228 -11
- package/dist/common/host.js +55 -3
- package/dist/common/internet.js +31 -20
- package/dist/common/mappings.d.ts +0 -3
- package/dist/common/mappings.js +35 -14
- package/dist/common/network.d.ts +15 -2
- package/dist/common/network.js +18 -22
- package/dist/common/nvidia.d.ts +1 -1
- package/dist/common/nvidia.js +4 -5
- package/dist/common/parse.d.ts +4 -6
- package/dist/common/parse.js +24 -69
- package/dist/common/security.d.ts +2 -0
- package/dist/common/security.js +18 -3
- package/dist/common/types.d.ts +53 -5
- 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 +54 -8
- package/dist/cpu-current-speed.js +5 -3
- 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 +16 -12
- package/dist/darwin/disks-io.js +3 -3
- package/dist/darwin/displays.d.ts +1 -0
- package/dist/darwin/displays.js +64 -2
- package/dist/darwin/fans.d.ts +2 -0
- package/dist/darwin/fans.js +28 -0
- package/dist/darwin/gpu.js +1 -1
- package/dist/darwin/index.d.ts +3 -0
- package/dist/darwin/index.js +8 -2
- 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 +81 -14
- package/dist/darwin/network-stats.d.ts +1 -1
- package/dist/darwin/network-stats.js +14 -7
- package/dist/darwin/os-info.d.ts +2 -0
- package/dist/darwin/os-info.js +24 -2
- package/dist/darwin/process-focused.d.ts +3 -0
- package/dist/darwin/process-focused.js +26 -0
- package/dist/darwin/serial-ports.d.ts +2 -0
- package/dist/darwin/serial-ports.js +94 -0
- package/dist/darwin/users.js +1 -1
- package/dist/docker.js +4 -5
- package/dist/fans.d.ts +1 -0
- package/dist/fans.js +17 -0
- package/dist/get-data.d.ts +4 -0
- package/dist/get-data.js +6 -2
- package/dist/get.js +6 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +8 -2
- package/dist/inet-public-ip.js +2 -1
- package/dist/linux/audio.js +59 -0
- package/dist/linux/baseboard.js +9 -20
- package/dist/linux/bios.js +6 -15
- package/dist/linux/block-devices.js +3 -1
- package/dist/linux/camera.js +2 -1
- package/dist/linux/chassis.js +4 -10
- package/dist/linux/cpu-temperature.js +34 -19
- package/dist/linux/cpu.js +3 -1
- package/dist/linux/disk-layout.js +9 -12
- package/dist/linux/disks-io.js +9 -9
- package/dist/linux/displays.d.ts +8 -0
- package/dist/linux/displays.js +151 -4
- package/dist/linux/fans.d.ts +2 -0
- package/dist/linux/fans.js +92 -0
- package/dist/linux/fs-size.d.ts +1 -1
- package/dist/linux/fs-size.js +164 -37
- package/dist/linux/fs-stats.js +6 -9
- package/dist/linux/gpu.d.ts +2 -0
- package/dist/linux/gpu.js +97 -22
- package/dist/linux/index.d.ts +3 -0
- package/dist/linux/index.js +8 -2
- package/dist/linux/mem-layout.js +3 -7
- package/dist/linux/mem.d.ts +1 -0
- package/dist/linux/mem.js +21 -1
- package/dist/linux/network-interfaces.d.ts +1 -0
- package/dist/linux/network-interfaces.js +154 -113
- package/dist/linux/network-stats.d.ts +1 -1
- package/dist/linux/network-stats.js +14 -40
- package/dist/linux/npu.js +2 -1
- package/dist/linux/os-info.js +56 -5
- package/dist/linux/printer.js +4 -4
- package/dist/linux/process-focused.d.ts +4 -0
- package/dist/linux/process-focused.js +32 -0
- package/dist/linux/process-load.js +11 -13
- package/dist/linux/processes.js +89 -80
- package/dist/linux/serial-ports.d.ts +2 -0
- package/dist/linux/serial-ports.js +102 -0
- package/dist/linux/services.js +182 -49
- package/dist/linux/system.js +1 -7
- package/dist/linux/users.js +1 -1
- package/dist/linux/uuid.js +4 -10
- package/dist/linux/wifi-networks.js +2 -2
- package/dist/network-interfaces.js +1 -1
- package/dist/observe.d.ts +1 -1
- package/dist/observe.js +5 -1
- package/dist/process-focused.d.ts +1 -0
- package/dist/process-focused.js +17 -0
- package/dist/serial-ports.d.ts +1 -0
- package/dist/serial-ports.js +17 -0
- package/dist/versions.js +34 -80
- package/dist/windows/audio.d.ts +29 -0
- package/dist/windows/audio.js +151 -11
- package/dist/windows/disk-layout.js +3 -0
- package/dist/windows/disks-io.js +3 -3
- package/dist/windows/displays.d.ts +5 -0
- package/dist/windows/displays.js +101 -16
- package/dist/windows/fans.d.ts +2 -0
- package/dist/windows/fans.js +71 -0
- package/dist/windows/fs-size.js +1 -4
- package/dist/windows/gpu.js +3 -2
- package/dist/windows/index.d.ts +3 -0
- package/dist/windows/index.js +8 -2
- package/dist/windows/network-interfaces.js +36 -41
- package/dist/windows/network-stats.js +20 -6
- package/dist/windows/process-focused.d.ts +3 -0
- package/dist/windows/process-focused.js +36 -0
- package/dist/windows/process-load.js +7 -5
- package/dist/windows/processes.d.ts +1 -0
- package/dist/windows/processes.js +54 -26
- package/dist/windows/serial-ports.d.ts +3 -0
- package/dist/windows/serial-ports.js +73 -0
- package/dist/windows/services.js +4 -1
- package/package.json +1 -1
package/dist/linux/services.js
CHANGED
|
@@ -4,8 +4,10 @@ exports.services = void 0;
|
|
|
4
4
|
const common_1 = require("../common");
|
|
5
5
|
const const_1 = require("../common/const");
|
|
6
6
|
const exec_1 = require("../common/exec");
|
|
7
|
+
const files_1 = require("../common/files");
|
|
7
8
|
const parse_1 = require("../common/parse");
|
|
8
9
|
const security_1 = require("../common/security");
|
|
10
|
+
const EXEC_OPTS = { timeout: 5000 };
|
|
9
11
|
const _services_cpu = {
|
|
10
12
|
all: 0,
|
|
11
13
|
all_utime: 0,
|
|
@@ -82,17 +84,181 @@ const darwinGetServices = async () => {
|
|
|
82
84
|
catch { }
|
|
83
85
|
return srvs;
|
|
84
86
|
};
|
|
87
|
+
const calcServicesCpuLinux = async (result) => {
|
|
88
|
+
result.forEach((item) => {
|
|
89
|
+
item.cpu = 0;
|
|
90
|
+
});
|
|
91
|
+
const pids = [];
|
|
92
|
+
for (const i in result) {
|
|
93
|
+
pids.push(...result[i].pids);
|
|
94
|
+
}
|
|
95
|
+
const cpuBaseline = { ..._services_cpu };
|
|
96
|
+
const stats = await (0, files_1.readProcStats)(pids);
|
|
97
|
+
const all = (0, parse_1.parseProcStat)(stats.all);
|
|
98
|
+
const curr_processes = stats.procs;
|
|
99
|
+
const list_new = {};
|
|
100
|
+
curr_processes.forEach((element) => {
|
|
101
|
+
const resultProcess = (0, parse_1.calcProcStatLinux)(element, all, cpuBaseline);
|
|
102
|
+
if (resultProcess.pid) {
|
|
103
|
+
let listPos = -1;
|
|
104
|
+
for (let i = 0; i < result.length; i++) {
|
|
105
|
+
for (let j = 0; j < result[i].pids.length; j++) {
|
|
106
|
+
if (result[i].pids[j] === resultProcess.pid) {
|
|
107
|
+
listPos = i;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
if (listPos >= 0) {
|
|
112
|
+
result[listPos].cpu += resultProcess.cpuu + resultProcess.cpus;
|
|
113
|
+
}
|
|
114
|
+
list_new[resultProcess.pid] = {
|
|
115
|
+
cpuu: resultProcess.cpuu,
|
|
116
|
+
cpus: resultProcess.cpus,
|
|
117
|
+
utime: resultProcess.utime,
|
|
118
|
+
stime: resultProcess.stime
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
_services_cpu.all = all;
|
|
123
|
+
_services_cpu.list = Object.assign({}, list_new);
|
|
124
|
+
_services_cpu.ms = Date.now();
|
|
125
|
+
_services_cpu.result = Object.assign({}, result);
|
|
126
|
+
};
|
|
127
|
+
const systemdTimestamp = (value) => {
|
|
128
|
+
const parts = value.match(/(\d{4}-\d{2}-\d{2}) (\d{2}:\d{2}:\d{2})(?: (\S+))?/);
|
|
129
|
+
if (!parts) {
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
132
|
+
const utc = parts[3] === 'UTC' || parts[3] === 'GMT';
|
|
133
|
+
const date = new Date(`${parts[1]}T${parts[2]}${utc ? 'Z' : ''}`);
|
|
134
|
+
return Number.isNaN(date.getTime()) ? null : date;
|
|
135
|
+
};
|
|
136
|
+
const systemdUnits = async () => {
|
|
137
|
+
const units = [];
|
|
138
|
+
const stdout = await (0, exec_1.execSecure)('systemctl', [
|
|
139
|
+
'show',
|
|
140
|
+
'--no-pager',
|
|
141
|
+
'--property=Id',
|
|
142
|
+
'--property=LoadState',
|
|
143
|
+
'--property=ActiveState',
|
|
144
|
+
'--property=UnitFileState',
|
|
145
|
+
'--property=ActiveEnterTimestamp',
|
|
146
|
+
'--property=ActiveExitTimestamp',
|
|
147
|
+
'--property=MainPID',
|
|
148
|
+
'*.service'
|
|
149
|
+
], EXEC_OPTS);
|
|
150
|
+
stdout.split(/\n\s*\n/).forEach((block) => {
|
|
151
|
+
const lines = block.split('\n');
|
|
152
|
+
const id = (0, common_1.getValue)(lines, 'Id', '=', false, true);
|
|
153
|
+
if (id && (0, common_1.getValue)(lines, 'LoadState', '=', false, true) !== 'not-found') {
|
|
154
|
+
const mainPid = (0, common_1.toInt)((0, common_1.getValue)(lines, 'MainPID', '=', false, true));
|
|
155
|
+
const activeState = (0, common_1.getValue)(lines, 'ActiveState', '=', false, true);
|
|
156
|
+
const running = activeState === 'active' || activeState === 'reloading';
|
|
157
|
+
const enter = systemdTimestamp((0, common_1.getValue)(lines, 'ActiveEnterTimestamp', '=', false, true));
|
|
158
|
+
const exit = systemdTimestamp((0, common_1.getValue)(lines, 'ActiveExitTimestamp', '=', false, true));
|
|
159
|
+
units.push({
|
|
160
|
+
name: id.replace(/\.service$/, ''),
|
|
161
|
+
running,
|
|
162
|
+
startmode: (0, common_1.getValue)(lines, 'UnitFileState', '=', false, true),
|
|
163
|
+
lastChanged: (running ? enter || exit : exit || enter) || null,
|
|
164
|
+
mainPid
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
return units;
|
|
169
|
+
};
|
|
170
|
+
const elapsedToDate = (elapsed) => {
|
|
171
|
+
const parts = elapsed.split('-');
|
|
172
|
+
const days = parts.length > 1 ? (0, common_1.toInt)(parts[0]) : 0;
|
|
173
|
+
const time = (parts.length > 1 ? parts[1] : parts[0]).split(':');
|
|
174
|
+
if (time.length < 2 || time.length > 3) {
|
|
175
|
+
return null;
|
|
176
|
+
}
|
|
177
|
+
const seconds = time.reduce((total, part) => total * 60 + (0, common_1.toInt)(part), 0) + days * 86400;
|
|
178
|
+
return seconds > 0 ? new Date(Date.now() - seconds * 1000) : null;
|
|
179
|
+
};
|
|
180
|
+
const psProcessesLinux = async () => {
|
|
181
|
+
const procs = [];
|
|
182
|
+
const stdout = await (0, exec_1.execSecure)('ps', ['-axo', 'pcpu,pmem,pid,ppid'], EXEC_OPTS);
|
|
183
|
+
stdout
|
|
184
|
+
.replace(/ +/g, ' ')
|
|
185
|
+
.replace(/,+/g, '.')
|
|
186
|
+
.split('\n')
|
|
187
|
+
.forEach((line) => {
|
|
188
|
+
const parts = line.trim().split(' ');
|
|
189
|
+
if (parts.length >= 4) {
|
|
190
|
+
const pid = (0, common_1.toInt)(parts[2]);
|
|
191
|
+
if (pid) {
|
|
192
|
+
procs.push({ pid, ppid: (0, common_1.toInt)(parts[3]), cpu: parseFloat(parts[0]) || 0, mem: parseFloat(parts[1]) || 0 });
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
return procs;
|
|
197
|
+
};
|
|
198
|
+
const servicesFromSystemd = async (srvs, units) => {
|
|
199
|
+
const all = srvs.length === 1 && srvs[0] === '*';
|
|
200
|
+
const matches = (unit) => {
|
|
201
|
+
const name = unit.name.toLowerCase();
|
|
202
|
+
return srvs.indexOf(name) >= 0 || srvs.indexOf(`${name}.service`) >= 0;
|
|
203
|
+
};
|
|
204
|
+
const selected = all ? units : units.filter(matches);
|
|
205
|
+
const procs = await psProcessesLinux();
|
|
206
|
+
const byPid = {};
|
|
207
|
+
const children = {};
|
|
208
|
+
procs.forEach((proc) => {
|
|
209
|
+
byPid[proc.pid] = { cpu: proc.cpu, mem: proc.mem };
|
|
210
|
+
children[proc.ppid] = (children[proc.ppid] || []).concat(proc.pid);
|
|
211
|
+
});
|
|
212
|
+
const result = [];
|
|
213
|
+
selected.forEach((unit) => {
|
|
214
|
+
const pids = [];
|
|
215
|
+
const collect = (pid) => {
|
|
216
|
+
pids.push(pid);
|
|
217
|
+
(children[pid] || []).forEach(collect);
|
|
218
|
+
};
|
|
219
|
+
if (unit.mainPid && byPid[unit.mainPid]) {
|
|
220
|
+
collect(unit.mainPid);
|
|
221
|
+
}
|
|
222
|
+
result.push({
|
|
223
|
+
name: unit.name,
|
|
224
|
+
running: unit.running,
|
|
225
|
+
startmode: unit.startmode,
|
|
226
|
+
lastChanged: unit.lastChanged,
|
|
227
|
+
pids,
|
|
228
|
+
cpu: parseFloat(pids.reduce((sum, pid) => sum + (byPid[pid] ? byPid[pid].cpu : 0), 0).toFixed(2)),
|
|
229
|
+
mem: parseFloat(pids.reduce((sum, pid) => sum + (byPid[pid] ? byPid[pid].mem : 0), 0).toFixed(2))
|
|
230
|
+
});
|
|
231
|
+
});
|
|
232
|
+
if (!all) {
|
|
233
|
+
srvs
|
|
234
|
+
.filter((srv) => !selected.some((unit) => unit.name.toLowerCase() === srv || `${unit.name.toLowerCase()}.service` === srv))
|
|
235
|
+
.forEach((srv) => {
|
|
236
|
+
result.push({ name: srv, running: false, startmode: '', lastChanged: null, pids: [], cpu: 0, mem: 0 });
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
await calcServicesCpuLinux(result);
|
|
240
|
+
return result;
|
|
241
|
+
};
|
|
85
242
|
const services = async (srv) => {
|
|
86
243
|
await (0, common_1.nextTick)();
|
|
87
244
|
const result = [];
|
|
88
245
|
if (!(0, security_1.isPrototypePolluted)()) {
|
|
89
246
|
let srvs = (0, security_1.sanitizeServiceString)(srv);
|
|
247
|
+
if (const_1.LINUX) {
|
|
248
|
+
try {
|
|
249
|
+
const units = await systemdUnits();
|
|
250
|
+
if (units.length) {
|
|
251
|
+
return await servicesFromSystemd(srvs, units);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
catch { }
|
|
255
|
+
}
|
|
90
256
|
if (srvs.length === 1 && srvs[0] === '*') {
|
|
91
257
|
srvs = const_1.DARWIN ? await darwinGetServices() : await nixGetServices();
|
|
92
258
|
}
|
|
93
|
-
let args = const_1.DARWIN ? ['-caxo', 'pcpu,pmem,pid,command'] : ['-axo', 'pcpu,pmem,pid,command'];
|
|
259
|
+
let args = const_1.DARWIN ? ['-caxo', 'pcpu,pmem,pid,etime,command'] : ['-axo', 'pcpu,pmem,pid,etime,command'];
|
|
94
260
|
if (srvs.length > 0) {
|
|
95
|
-
let stdout = await (0, exec_1.execSecure)('ps', args);
|
|
261
|
+
let stdout = await (0, exec_1.execSecure)('ps', args, EXEC_OPTS);
|
|
96
262
|
if (stdout) {
|
|
97
263
|
const lines = stdout.replace(/ +/g, ' ').replace(/,+/g, '.').split('\n');
|
|
98
264
|
srvs.forEach((srv) => {
|
|
@@ -112,16 +278,22 @@ const services = async (srv) => {
|
|
|
112
278
|
});
|
|
113
279
|
}
|
|
114
280
|
const pids = [];
|
|
281
|
+
let lastChanged = null;
|
|
115
282
|
for (const p of ps) {
|
|
116
|
-
const
|
|
117
|
-
if (
|
|
118
|
-
pids.push((0, common_1.toInt)(
|
|
283
|
+
const parts = p.trim().split(' ');
|
|
284
|
+
if (parts[2]) {
|
|
285
|
+
pids.push((0, common_1.toInt)(parts[2]));
|
|
286
|
+
const started = elapsedToDate(parts[3] || '');
|
|
287
|
+
if (started && (!lastChanged || started < lastChanged)) {
|
|
288
|
+
lastChanged = started;
|
|
289
|
+
}
|
|
119
290
|
}
|
|
120
291
|
}
|
|
121
292
|
result.push({
|
|
122
293
|
name: srv,
|
|
123
294
|
running: ps.length > 0,
|
|
124
295
|
startmode: '',
|
|
296
|
+
lastChanged,
|
|
125
297
|
pids: pids,
|
|
126
298
|
cpu: parseFloat(ps
|
|
127
299
|
.reduce(function (pv, cv) {
|
|
@@ -136,54 +308,13 @@ const services = async (srv) => {
|
|
|
136
308
|
});
|
|
137
309
|
});
|
|
138
310
|
if (const_1.LINUX) {
|
|
139
|
-
|
|
140
|
-
for (const i in result) {
|
|
141
|
-
for (const j in result[i].pids) {
|
|
142
|
-
cmd += ';cat /proc/' + result[i].pids[j] + '/stat';
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
const { stdout } = await (0, exec_1.exec)(cmd, const_1.execOptsLinux);
|
|
146
|
-
let curr_processes = stdout.toString().split('\n');
|
|
147
|
-
const all = (0, parse_1.parseProcStat)(curr_processes[0]);
|
|
148
|
-
curr_processes = curr_processes.slice(1);
|
|
149
|
-
const list_new = {};
|
|
150
|
-
curr_processes.forEach((element) => {
|
|
151
|
-
const resultProcess = (0, parse_1.calcProcStatLinux)(element, all, _services_cpu);
|
|
152
|
-
if (resultProcess.pid) {
|
|
153
|
-
let listPos = -1;
|
|
154
|
-
for (let i = 0; i < result.length; i++) {
|
|
155
|
-
for (let j = 0; j < result[i].pids.length; j++) {
|
|
156
|
-
if (result[i].pids[j] === resultProcess.pid) {
|
|
157
|
-
listPos = i;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
if (listPos >= 0) {
|
|
162
|
-
result[listPos].cpu += resultProcess.cpuu + resultProcess.cpus;
|
|
163
|
-
}
|
|
164
|
-
list_new[resultProcess.pid] = {
|
|
165
|
-
cpuu: resultProcess.cpuu,
|
|
166
|
-
cpus: resultProcess.cpus,
|
|
167
|
-
utime: resultProcess.utime,
|
|
168
|
-
stime: resultProcess.stime,
|
|
169
|
-
cutime: resultProcess.cutime,
|
|
170
|
-
cstime: resultProcess.cstime
|
|
171
|
-
};
|
|
172
|
-
}
|
|
173
|
-
});
|
|
174
|
-
_services_cpu.all = all;
|
|
175
|
-
_services_cpu.list = Object.assign({}, list_new);
|
|
176
|
-
_services_cpu.ms = Date.now();
|
|
177
|
-
_services_cpu.result = Object.assign({}, result);
|
|
178
|
-
return result;
|
|
179
|
-
}
|
|
180
|
-
else {
|
|
181
|
-
return result;
|
|
311
|
+
await calcServicesCpuLinux(result);
|
|
182
312
|
}
|
|
313
|
+
return result;
|
|
183
314
|
}
|
|
184
315
|
else {
|
|
185
316
|
args = ['-o', 'comm'];
|
|
186
|
-
stdout = await (0, exec_1.execSecure)('ps', args);
|
|
317
|
+
stdout = await (0, exec_1.execSecure)('ps', args, EXEC_OPTS);
|
|
187
318
|
if (stdout) {
|
|
188
319
|
const lines = stdout.replace(/ +/g, ' ').replace(/,+/g, '.').split('\n');
|
|
189
320
|
srvs.forEach((srv) => {
|
|
@@ -194,6 +325,7 @@ const services = async (srv) => {
|
|
|
194
325
|
name: srv,
|
|
195
326
|
running: ps.length > 0,
|
|
196
327
|
startmode: '',
|
|
328
|
+
lastChanged: null,
|
|
197
329
|
pids: [],
|
|
198
330
|
cpu: 0,
|
|
199
331
|
mem: 0
|
|
@@ -207,6 +339,7 @@ const services = async (srv) => {
|
|
|
207
339
|
name: srv,
|
|
208
340
|
running: false,
|
|
209
341
|
startmode: '',
|
|
342
|
+
lastChanged: null,
|
|
210
343
|
pids: [],
|
|
211
344
|
cpu: 0,
|
|
212
345
|
mem: 0
|
package/dist/linux/system.js
CHANGED
|
@@ -21,14 +21,8 @@ const system = async () => {
|
|
|
21
21
|
result.serial = (0, common_1.getValue)(lines, 'serial number');
|
|
22
22
|
result.uuid = (0, common_1.getValue)(lines, 'uuid').toLowerCase();
|
|
23
23
|
result.sku = (0, common_1.getValue)(lines, 'sku number');
|
|
24
|
-
const cmd = `echo -n "product_name: "; cat /sys/devices/virtual/dmi/id/product_name 2>/dev/null; echo;
|
|
25
|
-
echo -n "product_serial: "; cat /sys/devices/virtual/dmi/id/product_serial 2>/dev/null; echo;
|
|
26
|
-
echo -n "product_uuid: "; cat /sys/devices/virtual/dmi/id/product_uuid 2>/dev/null; echo;
|
|
27
|
-
echo -n "product_version: "; cat /sys/devices/virtual/dmi/id/product_version 2>/dev/null; echo;
|
|
28
|
-
echo -n "sys_vendor: "; cat /sys/devices/virtual/dmi/id/sys_vendor 2>/dev/null; echo;`;
|
|
29
24
|
try {
|
|
30
|
-
|
|
31
|
-
lines = stdout.split('\n');
|
|
25
|
+
lines = await (0, files_1.readSysfsMany)(files_1.DMI_PATH, ['product_name', 'product_serial', 'product_uuid', 'product_version', 'sys_vendor']);
|
|
32
26
|
result.manufacturer = result.manufacturer === '' ? (0, common_1.getValue)(lines, 'sys_vendor') : result.manufacturer;
|
|
33
27
|
result.model = result.model === '' ? (0, common_1.getValue)(lines, 'product_name') : result.model;
|
|
34
28
|
result.version = result.version === '' ? (0, common_1.getValue)(lines, 'product_version') : result.version;
|
package/dist/linux/users.js
CHANGED
|
@@ -89,7 +89,7 @@ const parseUsersLinux = (lines, phase) => {
|
|
|
89
89
|
const users = async () => {
|
|
90
90
|
await (0, common_1.nextTick)();
|
|
91
91
|
let result = [];
|
|
92
|
-
let { stdout } = await (0, exec_1.exec)('export LC_ALL=C; who --ips; echo "---"; w
|
|
92
|
+
let { stdout } = await (0, exec_1.exec)('export LC_ALL=C.UTF-8; who --ips; echo "---"; w | tail -n +2', const_1.execOptsLinux);
|
|
93
93
|
let lines = stdout.toString().split('\n');
|
|
94
94
|
result = parseUsersLinux(lines, 1);
|
|
95
95
|
if (result.length === 0) {
|
package/dist/linux/uuid.js
CHANGED
|
@@ -4,21 +4,15 @@ exports.uuid = void 0;
|
|
|
4
4
|
const promises_1 = require("fs/promises");
|
|
5
5
|
const common_1 = require("../common");
|
|
6
6
|
const defaults_1 = require("../common/defaults");
|
|
7
|
-
const
|
|
7
|
+
const files_1 = require("../common/files");
|
|
8
8
|
const disk_layout_1 = require("./disk-layout");
|
|
9
9
|
const uuid = async () => {
|
|
10
10
|
await (0, common_1.nextTick)();
|
|
11
11
|
const defaults = defaults_1.initUUID;
|
|
12
12
|
try {
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
echo -n "systemuuid: "; cat /sys/devices/virtual/dmi/id/product_uuid 2>/dev/null; echo;`;
|
|
17
|
-
const { stdout } = await (0, exec_1.execSave)(cmd);
|
|
18
|
-
const lines = stdout.toString().split('\n');
|
|
19
|
-
const os = (0, common_1.getValue)(lines, 'os').toLowerCase();
|
|
20
|
-
let hardware = (0, common_1.getValue)(lines, 'hardware').toLowerCase();
|
|
21
|
-
const systemuuid = (0, common_1.getValue)(lines, 'systemuuid').toLowerCase();
|
|
13
|
+
const os = ((await (0, files_1.readSysfs)('/var/lib/dbus/machine-id')) || (await (0, files_1.readSysfs)('/etc/machine-id'))).toLowerCase();
|
|
14
|
+
let hardware = (await (0, files_1.readSysfs)('/sys/class/dmi/id/product_uuid')).toLowerCase();
|
|
15
|
+
const systemuuid = (await (0, files_1.readSysfs)(`${files_1.DMI_PATH}/product_uuid`)).toLowerCase();
|
|
22
16
|
if (!hardware) {
|
|
23
17
|
const lines = (await (0, promises_1.readFile)('/proc/cpuinfo')).toString().split('\n');
|
|
24
18
|
const serial = (0, common_1.getValue)(lines, 'serial');
|
|
@@ -43,7 +43,7 @@ const getWifiNetworkListNmi = async () => {
|
|
|
43
43
|
const getWifiNetworkListIw = async (networkInterface) => {
|
|
44
44
|
const result = [];
|
|
45
45
|
try {
|
|
46
|
-
const { stdout } = await (0, exec_1.exec)(`export LC_ALL=C; iwlist ${networkInterface} scan 2>&1; unset LC_ALL`, const_1.execOptsLinux);
|
|
46
|
+
const { stdout } = await (0, exec_1.exec)(`export LC_ALL=C.UTF-8; iwlist ${networkInterface} scan 2>&1; unset LC_ALL`, const_1.execOptsLinux);
|
|
47
47
|
let iwlistParts = stdout.split(' Cell ');
|
|
48
48
|
if (iwlistParts[0].indexOf('resource busy') >= 0) {
|
|
49
49
|
return -1;
|
|
@@ -137,7 +137,7 @@ const wifiNetworks = async () => {
|
|
|
137
137
|
let result = await getWifiNetworkListNmi();
|
|
138
138
|
if (result.length === 0) {
|
|
139
139
|
try {
|
|
140
|
-
const { stdout } = await (0, exec_1.exec)('export LC_ALL=C; iwconfig 2>/dev/null; unset LC_ALL', const_1.execOptsLinux);
|
|
140
|
+
const { stdout } = await (0, exec_1.exec)('export LC_ALL=C.UTF-8; iwconfig 2>/dev/null; unset LC_ALL', const_1.execOptsLinux);
|
|
141
141
|
const iwconfigParts = stdout.split('\n\n');
|
|
142
142
|
let networkInterface = '';
|
|
143
143
|
iwconfigParts.forEach((element) => {
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.networkInterfaces = void 0;
|
|
4
4
|
const const_1 = require("./common/const");
|
|
5
5
|
const networkInterfaces = async (defaultString = '', rescan = true) => {
|
|
6
|
-
defaultString = ''
|
|
6
|
+
defaultString = typeof defaultString === 'string' ? defaultString : '';
|
|
7
7
|
switch (true) {
|
|
8
8
|
case const_1.LINUX || const_1.ANDROID:
|
|
9
9
|
return (await import('./linux/network-interfaces.js')).networkInterfaces(defaultString, rescan);
|
package/dist/observe.d.ts
CHANGED
package/dist/observe.js
CHANGED
|
@@ -3,6 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.observe = void 0;
|
|
4
4
|
const get_1 = require("./get");
|
|
5
5
|
const observe = (valueObject, interval, callback) => {
|
|
6
|
+
if (typeof callback !== 'function') {
|
|
7
|
+
return undefined;
|
|
8
|
+
}
|
|
9
|
+
const ms = Math.min(Math.max(Number(interval) || 0, 500), 2147483647);
|
|
6
10
|
let _data = null;
|
|
7
11
|
return setInterval(() => {
|
|
8
12
|
(0, get_1.get)(valueObject).then((data) => {
|
|
@@ -11,6 +15,6 @@ const observe = (valueObject, interval, callback) => {
|
|
|
11
15
|
callback(data);
|
|
12
16
|
}
|
|
13
17
|
});
|
|
14
|
-
},
|
|
18
|
+
}, ms);
|
|
15
19
|
};
|
|
16
20
|
exports.observe = observe;
|
|
@@ -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;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const serialPorts: () => Promise<import("./common/types").SerialPortData[] | null>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.serialPorts = void 0;
|
|
4
|
+
const const_1 = require("./common/const");
|
|
5
|
+
const serialPorts = async () => {
|
|
6
|
+
switch (true) {
|
|
7
|
+
case const_1.LINUX || const_1.ANDROID:
|
|
8
|
+
return (await import('./linux/serial-ports.js')).serialPorts();
|
|
9
|
+
case const_1.DARWIN:
|
|
10
|
+
return (await import('./darwin/serial-ports.js')).serialPorts();
|
|
11
|
+
case const_1.WINDOWS:
|
|
12
|
+
return (await import('./windows/serial-ports.js')).serialPorts();
|
|
13
|
+
default:
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
exports.serialPorts = serialPorts;
|
package/dist/versions.js
CHANGED
|
@@ -75,15 +75,14 @@ const versions = async (apps) => {
|
|
|
75
75
|
};
|
|
76
76
|
}
|
|
77
77
|
if (!Array.isArray(apps)) {
|
|
78
|
-
apps = apps.trim().toLowerCase().replace(/,+/g, '|').replace(/ /g, '|');
|
|
79
|
-
apps = apps.split('|');
|
|
78
|
+
apps = typeof apps === 'string' ? apps.trim().toLowerCase().replace(/,+/g, '|').replace(/ /g, '|').split('|') : [];
|
|
80
79
|
}
|
|
81
80
|
const result = {
|
|
82
81
|
versions: {},
|
|
83
82
|
counter: 0
|
|
84
83
|
};
|
|
85
84
|
apps.forEach((el) => {
|
|
86
|
-
if (el) {
|
|
85
|
+
if (el && typeof el === 'string') {
|
|
87
86
|
for (const key in versionObject) {
|
|
88
87
|
if (Object.keys(versionObject).includes(key)) {
|
|
89
88
|
if (key.toLowerCase() === el.toLowerCase() && !Object.keys(result.versions).includes(key)) {
|
|
@@ -414,90 +413,45 @@ const versions = async (apps) => {
|
|
|
414
413
|
});
|
|
415
414
|
}
|
|
416
415
|
if (Object.keys(appsObj.versions).includes('postgresql')) {
|
|
417
|
-
if (const_1.
|
|
418
|
-
|
|
419
|
-
.then((
|
|
420
|
-
const
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
416
|
+
if (const_1.WINDOWS) {
|
|
417
|
+
windows_1.ps.exec('Get-CimInstance Win32_Service | select caption | fl')
|
|
418
|
+
.then((stdout) => {
|
|
419
|
+
const serviceSections = (stdout ? stdout.toString() : '').split(/\n\s*\n/);
|
|
420
|
+
serviceSections.forEach((item) => {
|
|
421
|
+
const lines = item.trim().split('\r\n');
|
|
422
|
+
const srvCaption = (0, common_1.getValue)(lines, 'caption', ':', true).toLowerCase();
|
|
423
|
+
if (srvCaption.indexOf('postgresql') > -1) {
|
|
424
|
+
const parts = srvCaption.split(' server ');
|
|
425
|
+
if (parts.length > 1) {
|
|
426
|
+
appsObj.versions.postgresql = parts[1];
|
|
427
427
|
}
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
functionProcessed();
|
|
432
|
-
});
|
|
433
|
-
}
|
|
434
|
-
else {
|
|
435
|
-
functionProcessed();
|
|
436
|
-
}
|
|
428
|
+
}
|
|
429
|
+
});
|
|
430
|
+
functionProcessed();
|
|
437
431
|
})
|
|
438
432
|
.catch(() => {
|
|
439
|
-
(
|
|
440
|
-
.then((res) => {
|
|
441
|
-
const postgresql = res.stdout.split('\n')[0].split(' ') || [];
|
|
442
|
-
appsObj.versions.postgresql = postgresql.length ? postgresql[postgresql.length - 1] : '';
|
|
443
|
-
appsObj.versions.postgresql = appsObj.versions.postgresql.split('-')[0];
|
|
444
|
-
functionProcessed();
|
|
445
|
-
})
|
|
446
|
-
.catch(() => {
|
|
447
|
-
functionProcessed();
|
|
448
|
-
});
|
|
433
|
+
functionProcessed();
|
|
449
434
|
});
|
|
450
435
|
}
|
|
451
436
|
else {
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
functionProcessed();
|
|
467
|
-
})
|
|
468
|
-
.catch(() => {
|
|
469
|
-
functionProcessed();
|
|
470
|
-
});
|
|
471
|
-
}
|
|
472
|
-
else {
|
|
473
|
-
(0, exec_1.exec)('postgres -V')
|
|
474
|
-
.then((res) => {
|
|
475
|
-
if (res.stdout) {
|
|
476
|
-
const postgresql = res.stdout.split('\n')[0].split(' ') || [];
|
|
477
|
-
appsObj.versions.postgresql = postgresql.length ? postgresql[postgresql.length - 1] : '';
|
|
478
|
-
if (appsObj.versions.postgresql.includes('(') && postgresql.length >= 2 && !postgresql[postgresql.length - 2].includes('(')) {
|
|
479
|
-
appsObj.versions.postgresql = postgresql[postgresql.length - 2];
|
|
480
|
-
}
|
|
437
|
+
const parsePostgres = (stdout) => {
|
|
438
|
+
const postgresql = stdout.split('\n')[0].split(' ') || [];
|
|
439
|
+
let version = postgresql.length ? postgresql[postgresql.length - 1] : '';
|
|
440
|
+
if (version.includes('(') && postgresql.length >= 2 && !postgresql[postgresql.length - 2].includes('(')) {
|
|
441
|
+
version = postgresql[postgresql.length - 2];
|
|
442
|
+
}
|
|
443
|
+
return version.split('-')[0];
|
|
444
|
+
};
|
|
445
|
+
(async () => {
|
|
446
|
+
for (const cmd of ['postgres -V', 'pg_config --version', 'psql -V']) {
|
|
447
|
+
const { stdout } = await (0, exec_1.execSave)(cmd);
|
|
448
|
+
if (stdout) {
|
|
449
|
+
appsObj.versions.postgresql = parsePostgres(stdout);
|
|
450
|
+
break;
|
|
481
451
|
}
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
(0, exec_1.exec)('pg_config --version 2> /dev/null')
|
|
486
|
-
.then((res) => {
|
|
487
|
-
if (res.stdout) {
|
|
488
|
-
const postgresql = res.stdout.toString().split('\n')[0].split(' ') || [];
|
|
489
|
-
appsObj.versions.postgresql = postgresql.length ? postgresql[postgresql.length - 1] : '';
|
|
490
|
-
if (appsObj.versions.postgresql.includes('(') && postgresql.length >= 2 && !postgresql[postgresql.length - 2].includes('(')) {
|
|
491
|
-
appsObj.versions.postgresql = postgresql[postgresql.length - 2];
|
|
492
|
-
}
|
|
493
|
-
}
|
|
494
|
-
})
|
|
495
|
-
.catch(() => { })
|
|
496
|
-
.finally(() => {
|
|
497
|
-
functionProcessed();
|
|
498
|
-
});
|
|
499
|
-
});
|
|
500
|
-
}
|
|
452
|
+
}
|
|
453
|
+
functionProcessed();
|
|
454
|
+
})();
|
|
501
455
|
}
|
|
502
456
|
}
|
|
503
457
|
if (Object.keys(appsObj.versions).includes('perl')) {
|
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 {};
|