about-system 0.0.35 → 0.0.36

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.
@@ -0,0 +1,889 @@
1
+ import f from "os";
2
+ import l from "fs";
3
+ import j from "https";
4
+ import b from "path";
5
+ import { execSync as B } from "child_process";
6
+ const F = {}, I = b.join(
7
+ f.homedir(),
8
+ ".config",
9
+ "systeminfo-settings.json"
10
+ ), M = b.join(f.tmpdir(), "systeminfo-cache.json"), Be = {
11
+ reset: "\x1B[0m",
12
+ red: "\x1B[38;5;196m",
13
+ orange: "\x1B[38;5;208m",
14
+ yellow: "\x1B[38;5;226m",
15
+ green: "\x1B[38;5;46m",
16
+ blue: "\x1B[38;5;39m",
17
+ cyan: "\x1B[38;5;51m",
18
+ purple: "\x1B[38;5;171m",
19
+ magenta: "\x1B[38;5;213m",
20
+ gray: "\x1B[38;5;250m",
21
+ lightblue: "\x1B[38;5;220m"
22
+ }, N = {
23
+ display_order: [
24
+ ["user", "hostname", "os", "device", "kernel", "cpu", "gpu", "bench"],
25
+ [
26
+ "disk_used",
27
+ "ram_used",
28
+ "top_process",
29
+ "uptime",
30
+ "temperature",
31
+ "battery",
32
+ "load_average"
33
+ ],
34
+ ["ip", "iplocal", "city", "domain", "isp"],
35
+ ["shell", "services_running", "pacman", "containers"]
36
+ ],
37
+ colors: {
38
+ user: "red",
39
+ hostname: "orange",
40
+ disk_used: "purple",
41
+ ram_used: "yellow",
42
+ top_process: "magenta",
43
+ uptime: "cyan",
44
+ ip: "green",
45
+ iplocal: "yellow",
46
+ city: "green",
47
+ domain: "gray",
48
+ isp: "lightblue",
49
+ os: "gray",
50
+ cpu: "orange",
51
+ gpu: "yellow",
52
+ bench: "red",
53
+ device: "yellow",
54
+ kernel: "green",
55
+ shell: "orange",
56
+ pacman: "multicolor",
57
+ ports: "multicolor",
58
+ containers: "green",
59
+ memory_available: "blue",
60
+ swap_used: "purple",
61
+ load_average: "red",
62
+ users_logged_in: "cyan",
63
+ network_interfaces: "yellow",
64
+ mount_points: "gray",
65
+ services_running: "green",
66
+ temperature: "red",
67
+ battery: "green",
68
+ screen_resolution: "blue"
69
+ },
70
+ emojis: {
71
+ user: "👤 ",
72
+ hostname: "🏠 ",
73
+ ip: "🌎 ",
74
+ iplocal: "🌐 ",
75
+ city: "📍 ",
76
+ domain: "🔗 ",
77
+ isp: "👮 ",
78
+ os: "⚡ ",
79
+ cpu: "📈 ",
80
+ gpu: "🎮 ",
81
+ bench: "💪 ",
82
+ device: "💻 ",
83
+ kernel: "🔧 ",
84
+ shell: "🐚 ",
85
+ pacman: "🚀 ",
86
+ disk_used: "📁 ",
87
+ ram_used: "💾 ",
88
+ top_process: "🔝 ",
89
+ uptime: "⏱️ ",
90
+ ports: "🔌 ",
91
+ containers: "📦 ",
92
+ memory_available: "🧠 ",
93
+ swap_used: "🔄 ",
94
+ load_average: "⚖️ ",
95
+ users_logged_in: "👥 ",
96
+ network_interfaces: "🌐 ",
97
+ mount_points: "📂 ",
98
+ services_running: "⚙️ ",
99
+ temperature: "🌡️ ",
100
+ battery_charging: "🔌 ",
101
+ battery: "🔋 ",
102
+ screen_resolution: "🖥️ "
103
+ },
104
+ labels: {
105
+ user: "User",
106
+ hostname: "Host",
107
+ ip: "IP",
108
+ iplocal: "Local IP",
109
+ city: "City",
110
+ domain: "Domain",
111
+ isp: "ISP",
112
+ os: "OS",
113
+ cpu: "CPU",
114
+ gpu: "GPU",
115
+ bench: "Bench",
116
+ device: "Device",
117
+ kernel: "Kernel",
118
+ shell: "Shell",
119
+ pacman: "Packages",
120
+ disk_used: "Disk",
121
+ ram_used: "RAM",
122
+ top_process: "Top",
123
+ uptime: "Uptime",
124
+ ports: "Ports",
125
+ containers: "Containers",
126
+ memory_available: "Memory",
127
+ swap_used: "Swap",
128
+ load_average: "Load",
129
+ users_logged_in: "Users",
130
+ network_interfaces: "Network",
131
+ mount_points: "Mounts",
132
+ services_running: "Services",
133
+ temperature: "Temp",
134
+ battery_charging: "Battery",
135
+ battery: "Battery",
136
+ screen_resolution: "Resolution"
137
+ },
138
+ display: {
139
+ show_emojis: !0,
140
+ single_line: !1,
141
+ line_wrap_length: F?.stdout?.columns || 100
142
+ },
143
+ network: {
144
+ show_offline_message: !0
145
+ },
146
+ advanced: {
147
+ debug: !1
148
+ }
149
+ };
150
+ function Ce() {
151
+ try {
152
+ if (l.existsSync(I)) {
153
+ const e = JSON.parse(l.readFileSync(I, "utf8"));
154
+ return { ...N, ...e };
155
+ }
156
+ } catch {
157
+ }
158
+ return N;
159
+ }
160
+ function Pe(e) {
161
+ try {
162
+ const t = b.dirname(I);
163
+ return l.existsSync(t) || l.mkdirSync(t, { recursive: !0 }), l.writeFileSync(I, JSON.stringify(e, null, 2)), !0;
164
+ } catch {
165
+ return !1;
166
+ }
167
+ }
168
+ const v = f.platform() === "win32", A = f.platform() === "darwin", d = f.platform() === "linux";
169
+ function p(e, t = {}) {
170
+ try {
171
+ const n = v ? `cmd /c ${e}` : e;
172
+ return B(n, {
173
+ encoding: "utf8",
174
+ timeout: 1e4,
175
+ stdio: ["pipe", "pipe", "ignore"],
176
+ ...t
177
+ }).toString().trim();
178
+ } catch {
179
+ return "";
180
+ }
181
+ }
182
+ function S(e) {
183
+ try {
184
+ return v ? B(`where ${e}`, { stdio: "ignore" }) : B(`which ${e}`, { stdio: "ignore" }), !0;
185
+ } catch {
186
+ return !1;
187
+ }
188
+ }
189
+ b.join(f.tmpdir(), "systeminfo-cache.json");
190
+ const O = {
191
+ ip: 300 * 1e3,
192
+ cpu: 1440 * 60 * 1e3,
193
+ gpu: 1440 * 60 * 1e3,
194
+ os: 1440 * 60 * 1e3,
195
+ device: 1440 * 60 * 1e3,
196
+ kernel: 3600 * 1e3,
197
+ pacman: 600 * 1e3,
198
+ ports: 300 * 1e3,
199
+ containers: 300 * 1e3,
200
+ top_process: 5 * 1e3,
201
+ disk_used: 60 * 1e3,
202
+ ram_used: 10 * 1e3,
203
+ services_running: 300 * 1e3,
204
+ temperature: 30 * 1e3,
205
+ battery: 60 * 1e3,
206
+ network_interfaces: 300 * 1e3,
207
+ mount_points: 600 * 1e3
208
+ };
209
+ function D(e, t) {
210
+ if (!e || !e.timestamp) return !1;
211
+ const n = Date.now() - e.timestamp, c = O[t] || 6e4;
212
+ return n < c;
213
+ }
214
+ function h(e, t) {
215
+ if (!e[t]) return null;
216
+ const n = e[t];
217
+ return D(n, t) ? n.value : (delete e[t], null);
218
+ }
219
+ function r(e, t, n) {
220
+ e[t] = {
221
+ value: n,
222
+ timestamp: Date.now()
223
+ };
224
+ }
225
+ function T() {
226
+ return f.userInfo().username;
227
+ }
228
+ function E() {
229
+ return f.hostname();
230
+ }
231
+ function G(e) {
232
+ const t = h(e.cache, "os");
233
+ if (t) return t;
234
+ const n = f.platform(), c = f.release();
235
+ let s = "";
236
+ if (v)
237
+ try {
238
+ const o = p("ver").match(/Microsoft Windows \[Version ([^\]]+)\]/);
239
+ s = o ? `Windows ${o[1]}` : `Windows ${c}`;
240
+ } catch {
241
+ s = `Windows ${c}`;
242
+ }
243
+ else if (A)
244
+ s = `macOS ${c}`;
245
+ else if (d)
246
+ try {
247
+ const a = l.readFileSync("/etc/os-release", "utf8"), o = a.match(/^NAME="([^"]+)"/m), i = a.match(/^VERSION_ID="([^"]+)"/m);
248
+ s = o ? o[1] : "Linux", i && (s += ` ${i[1]}`);
249
+ } catch {
250
+ s = `Linux ${c}`;
251
+ }
252
+ else
253
+ s = `${n} ${c}`;
254
+ return r(e.cache, "os", s), s;
255
+ }
256
+ function W(e) {
257
+ const t = h(e.cache, "kernel");
258
+ if (t) return t;
259
+ const n = f.release();
260
+ return r(e.cache, "kernel", n), n;
261
+ }
262
+ function U(e) {
263
+ const t = h(e.cache, "device");
264
+ if (t !== null) return t;
265
+ if (v) {
266
+ try {
267
+ const c = p("wmic csproduct get name /format:list").match(/Name=(.+)/);
268
+ if (c) {
269
+ const s = c[1].trim();
270
+ if (s && s !== "")
271
+ return r(e.cache, "device", s), s;
272
+ }
273
+ } catch {
274
+ }
275
+ try {
276
+ const n = p(
277
+ 'powershell.exe -Command "Get-WmiObject -Class Win32_ComputerSystem | Select-Object -ExpandProperty Model"'
278
+ );
279
+ if (n.trim()) {
280
+ const c = n.trim();
281
+ return r(e.cache, "device", c), c;
282
+ }
283
+ } catch {
284
+ }
285
+ } else if (d)
286
+ try {
287
+ if (S("getprop")) {
288
+ const c = p("getprop ro.product.model");
289
+ if (c)
290
+ return r(e.cache, "device", c), c;
291
+ }
292
+ const n = "/sys/devices/virtual/dmi/id/product_name";
293
+ if (l.existsSync(n)) {
294
+ const c = l.readFileSync(n, "utf8").trim();
295
+ if (c)
296
+ return r(e.cache, "device", c), c;
297
+ }
298
+ } catch {
299
+ }
300
+ return r(e.cache, "device", ""), "";
301
+ }
302
+ function C(e) {
303
+ const t = h(e.cache, "cpu");
304
+ if (t) return t;
305
+ let n = "";
306
+ if (v) {
307
+ try {
308
+ const s = p("wmic cpu get name /format:list").match(/Name=(.+)/);
309
+ s && (n = s[1].trim());
310
+ } catch {
311
+ }
312
+ if (!n)
313
+ try {
314
+ const c = p(
315
+ 'powershell.exe -Command "Get-WmiObject -Class Win32_Processor | Select-Object -ExpandProperty Name"'
316
+ );
317
+ c.trim() && (n = c.trim());
318
+ } catch {
319
+ }
320
+ } else if (d) {
321
+ try {
322
+ const s = p("lscpu").match(/Model name:\s*([^\n,]+)/);
323
+ s && (n = s[1].trim());
324
+ } catch {
325
+ }
326
+ if (!n)
327
+ try {
328
+ const c = l.readFileSync("/proc/cpuinfo", "utf8"), s = c.match(/model name\s*:\s*([^\n]+)/), a = c.match(/Hardware\s*:\s*([^\n]+)/);
329
+ s ? n = s[1].trim() : a && (n = a[1].trim());
330
+ } catch {
331
+ }
332
+ } else {
333
+ const c = f.cpus();
334
+ c.length > 0 && (n = c[0].model.trim().replace(/[\r\n]+/g, " "));
335
+ }
336
+ return n ? (n = n.trim().replace(/with .*/, ""), r(e.cache, "cpu", n), n) : (r(e.cache, "cpu", ""), "");
337
+ }
338
+ function L(e) {
339
+ const t = h(e.cache, "gpu");
340
+ if (t !== null) return t;
341
+ if (v) {
342
+ try {
343
+ const c = p(
344
+ "wmic path win32_VideoController get name /format:list"
345
+ ).match(/Name=(.+)/);
346
+ if (c) {
347
+ const s = c[1].trim();
348
+ if (s && s !== "" && !s.includes("Microsoft Basic"))
349
+ return r(e.cache, "gpu", s), s;
350
+ }
351
+ } catch {
352
+ }
353
+ try {
354
+ const n = p(
355
+ `powershell.exe -Command "Get-WmiObject -Class Win32_VideoController | Where-Object {$_.Name -notlike '*Microsoft Basic*'} | Select-Object -First 1 -ExpandProperty Name"`
356
+ );
357
+ if (n.trim()) {
358
+ const c = n.trim();
359
+ return r(e.cache, "gpu", c), c;
360
+ }
361
+ } catch {
362
+ }
363
+ } else if (d)
364
+ try {
365
+ const c = p("lspci").match(
366
+ /VGA.*?(RTX|GeForce|AMD|Intel|NVIDIA)[^\n]*/i
367
+ );
368
+ if (c) {
369
+ let s = c[0];
370
+ const a = s.match(/\[([^\]]+)\]/);
371
+ if (a ? s = a[1] : s = s.replace(/^.*VGA[^:]*:\s*/, "").replace(/\s*\(.*\)$/, "").trim(), s)
372
+ return r(e.cache, "gpu", s), s;
373
+ }
374
+ } catch {
375
+ }
376
+ return r(e.cache, "gpu", ""), "";
377
+ }
378
+ function R() {
379
+ if (!d) return "";
380
+ try {
381
+ if (process.env.DISPLAY) {
382
+ const t = p("xrandr").match(/(\d+x\d+)\+\d+\+\d+/);
383
+ if (t)
384
+ return t[1];
385
+ }
386
+ } catch {
387
+ }
388
+ return "";
389
+ }
390
+ function V(e) {
391
+ const t = h(e.cache, "bench");
392
+ if (t) return t;
393
+ const n = C(e);
394
+ if (!n)
395
+ return r(e.cache, "bench", ""), "";
396
+ try {
397
+ const c = new URL("../cpu-gb6-multicore-top1000.min.json", import.meta.url).pathname, s = l.readFileSync(c, "utf8"), i = JSON.parse(s).scores.map((u) => ({ name: u[0], score: u[1], rank: u[2] })), m = require("fuse.js"), g = new m(i, {
398
+ keys: ["name"],
399
+ threshold: 0.4,
400
+ minMatchCharLength: 3
401
+ }).search(n);
402
+ if (g.length > 0) {
403
+ const u = g[0].item, w = Math.round(u.score / 100) / 10, k = u.rank, _ = `💪 ${w}k #${k}`;
404
+ return r(e.cache, "bench", _), _;
405
+ }
406
+ } catch {
407
+ }
408
+ return r(e.cache, "bench", ""), "";
409
+ }
410
+ function J(e) {
411
+ const t = h(e.cache, "cpu_bench_info");
412
+ if (t) return t;
413
+ const n = C(e);
414
+ if (!n)
415
+ return r(e.cache, "cpu_bench_info", ""), "";
416
+ try {
417
+ const c = new URL("../cpu-geekbench-1k.json", import.meta.url).pathname, s = l.readFileSync(c, "utf8"), i = JSON.parse(s).scores.map((u) => ({
418
+ name: u[0],
419
+ score: u[1],
420
+ rank: u[2]
421
+ })), m = require("fuse.js"), g = new m(i, {
422
+ keys: ["name"],
423
+ threshold: 0.4,
424
+ minMatchCharLength: 3
425
+ }).search(n);
426
+ if (g.length > 0) {
427
+ const u = g[0].item, w = Math.round(u.score / 100) / 10, k = u.rank;
428
+ let _ = "Unknown";
429
+ u.name.includes("Apple") || u.name.includes("ARM") ? _ = "ARM" : u.name.includes("Intel") ? _ = "Intel" : u.name.includes("AMD") || u.name.includes("Ryzen") || u.name.includes("EPYC") ? _ = "AMD" : u.name.includes("Qualcomm") && (_ = "ARM");
430
+ const $ = `Geekbench 6: ${w}k (Rank #${k}) - ${_}`;
431
+ return r(e.cache, "cpu_bench_info", $), $;
432
+ }
433
+ } catch {
434
+ }
435
+ return r(e.cache, "cpu_bench_info", ""), "";
436
+ }
437
+ function q(e) {
438
+ const t = h(e.cache, "ram_used");
439
+ if (t) return t;
440
+ if (d)
441
+ try {
442
+ const m = l.readFileSync("/proc/meminfo", "utf8"), y = m.match(/MemTotal:\s+(\d+) kB/), g = m.match(/MemFree:\s+(\d+) kB/);
443
+ if (y && g) {
444
+ const u = Math.round(parseInt(y[1]) / 1024), w = Math.round(parseInt(g[1]) / 1024), k = u - w, _ = Math.round(u / 1024), P = `${Math.round(k / 1024)}/${_}GB`;
445
+ return r(e.cache, "ram_used", P), P;
446
+ }
447
+ } catch {
448
+ }
449
+ const n = f.totalmem(), c = f.freemem(), s = n - c, a = Math.round(n / (1024 * 1024 * 1024)), i = `${Math.round(s / (1024 * 1024 * 1024))}/${a}GB`;
450
+ return r(e.cache, "ram_used", i), i;
451
+ }
452
+ function H() {
453
+ if (!d) return "";
454
+ try {
455
+ const t = l.readFileSync("/proc/meminfo", "utf8").match(/MemAvailable:\s+(\d+) kB/);
456
+ if (t)
457
+ return `${Math.round(parseInt(t[1]) / 1024 / 1024)}GB available`;
458
+ } catch {
459
+ }
460
+ return "";
461
+ }
462
+ function z() {
463
+ if (!d) return "";
464
+ try {
465
+ const e = l.readFileSync("/proc/meminfo", "utf8"), t = e.match(/SwapTotal:\s+(\d+) kB/), n = e.match(/SwapFree:\s+(\d+) kB/);
466
+ if (t && n) {
467
+ const c = parseInt(t[1]), s = parseInt(n[1]), a = c - s;
468
+ if (c > 0) {
469
+ const o = Math.round(a / c * 100), i = Math.round(a / 1024);
470
+ return `${o}% (${i}MB) swap`;
471
+ }
472
+ }
473
+ } catch {
474
+ }
475
+ return "";
476
+ }
477
+ function K(e) {
478
+ const t = h(e.cache, "disk_used");
479
+ if (t !== null) return t;
480
+ if (d)
481
+ try {
482
+ const n = p("df -h");
483
+ let c = "";
484
+ if (n.includes("/storage/emulated")) {
485
+ const s = n.match(/\s+(\d+%)\s+\/storage\/emulated/);
486
+ c = s ? s[1] : "";
487
+ } else {
488
+ const s = n.split(`
489
+ `);
490
+ for (const a of s)
491
+ if (a.trim().endsWith(" /")) {
492
+ const o = a.trim().split(/\s+/), i = o.findIndex((m) => m.includes("%"));
493
+ if (i !== -1) {
494
+ c = o[i];
495
+ break;
496
+ }
497
+ }
498
+ if (!c) {
499
+ const a = n.match(/(\d+%)\s+\/\s*$/m);
500
+ c = a ? a[1] : "";
501
+ }
502
+ }
503
+ return r(e.cache, "disk_used", c), c;
504
+ } catch {
505
+ }
506
+ return r(e.cache, "disk_used", ""), "";
507
+ }
508
+ function X(e) {
509
+ const t = h(e.cache, "mount_points");
510
+ if (t !== null) return t;
511
+ if (!d)
512
+ return r(e.cache, "mount_points", ""), "";
513
+ try {
514
+ const c = p("df -h").split(`
515
+ `).slice(1), s = [];
516
+ c.forEach((o) => {
517
+ const i = o.trim().split(/\s+/);
518
+ if (i.length >= 6) {
519
+ const m = i[5], y = i[4];
520
+ !m.startsWith("/dev") && !m.startsWith("/proc") && !m.startsWith("/sys") && m !== "/" && s.push(`${m}(${y})`);
521
+ }
522
+ });
523
+ const a = s.slice(0, 3).join(" ");
524
+ return r(e.cache, "mount_points", a), a;
525
+ } catch {
526
+ }
527
+ return r(e.cache, "mount_points", ""), "";
528
+ }
529
+ function Y(e) {
530
+ const t = h(e.cache, "top_process");
531
+ if (t !== null) return t;
532
+ if (d)
533
+ try {
534
+ const c = p("ps -eo pcpu,comm --sort=-%cpu --no-headers").split(`
535
+ `);
536
+ if (c.length > 0) {
537
+ const s = c[0].trim().replace(/\s+/, " ").split(" "), a = s[0].replace(/\.\d+/, "%"), o = s[1].split("/").pop(), i = `${a}% ${o}`;
538
+ return r(e.cache, "top_process", i), i;
539
+ }
540
+ } catch {
541
+ }
542
+ return r(e.cache, "top_process", ""), "";
543
+ }
544
+ function Q() {
545
+ const e = f.uptime(), t = Math.floor(e / 86400), n = Math.floor(e % 86400 / 3600), c = Math.floor(e % 3600 / 60);
546
+ return `${t}d ${n}h ${c}m`;
547
+ }
548
+ function Z() {
549
+ if (!d) return "";
550
+ try {
551
+ const t = p("who").split(`
552
+ `).filter((n) => n.trim()).length;
553
+ if (t > 0)
554
+ return `${t} users`;
555
+ } catch {
556
+ }
557
+ return "";
558
+ }
559
+ async function x(e) {
560
+ const t = h(e.cache, "ip");
561
+ if (t) return t;
562
+ if (!e.ipInfo)
563
+ return r(e.cache, "ip", ""), "";
564
+ const n = e.ipInfo.ip || "";
565
+ return r(e.cache, "ip", n), n;
566
+ }
567
+ function ee() {
568
+ if (d) {
569
+ try {
570
+ const c = p("ifconfig 2>/dev/null").match(
571
+ /wlan0[\s\S]*?inet (\d+\.\d+\.\d+\.\d+)/
572
+ );
573
+ if (c)
574
+ return c[1];
575
+ } catch {
576
+ }
577
+ try {
578
+ const n = p("ip addr show 2>/dev/null"), c = [], s = n.matchAll(/inet (\d+\.\d+\.\d+\.\d+)\/\d+/g);
579
+ for (const a of s)
580
+ a[1].startsWith("127.") || c.push(a[1]);
581
+ if (c.length > 0)
582
+ return c.join(" ");
583
+ } catch {
584
+ }
585
+ }
586
+ const e = f.networkInterfaces(), t = [];
587
+ for (const n of Object.keys(e))
588
+ for (const c of e[n] || [])
589
+ c.family === "IPv4" && !c.internal && t.push(c.address);
590
+ return t.join(" ");
591
+ }
592
+ async function te(e) {
593
+ const t = h(e.cache, "city");
594
+ if (t !== null) return t;
595
+ if (!e.ipInfo || !e.ipInfo.city)
596
+ return r(e.cache, "city", ""), "";
597
+ const n = e.ipInfo.city;
598
+ return r(e.cache, "city", n), n;
599
+ }
600
+ async function ne(e) {
601
+ const t = h(e.cache, "domain");
602
+ if (t !== null) return t;
603
+ if (!e.ipInfo || !e.ipInfo.hostname)
604
+ return r(e.cache, "domain", ""), "";
605
+ const n = `http://${e.ipInfo.hostname}`;
606
+ return r(e.cache, "domain", n), n;
607
+ }
608
+ async function ce(e) {
609
+ const t = h(e.cache, "isp");
610
+ if (t !== null) return t;
611
+ if (!e.ipInfo || !e.ipInfo.org)
612
+ return r(e.cache, "isp", ""), "";
613
+ const n = e.ipInfo.org.split(" ").slice(1).join(" ");
614
+ return r(e.cache, "isp", n), n;
615
+ }
616
+ function se(e) {
617
+ const t = h(e.cache, "network_interfaces");
618
+ if (t !== null) return t;
619
+ if (!d)
620
+ return r(e.cache, "network_interfaces", ""), "";
621
+ try {
622
+ const n = f.networkInterfaces(), c = [];
623
+ for (const [a, o] of Object.entries(n))
624
+ a !== "lo" && o?.find(
625
+ (m) => m.family === "IPv4" && !m.internal
626
+ ) && c.push(a);
627
+ const s = c.join(" ");
628
+ return r(e.cache, "network_interfaces", s), s;
629
+ } catch {
630
+ }
631
+ return r(e.cache, "network_interfaces", ""), "";
632
+ }
633
+ function re(e) {
634
+ const t = h(e.cache, "ports");
635
+ if (t !== null) return t;
636
+ if (d)
637
+ try {
638
+ const c = p("lsof -nP -iTCP -sTCP:LISTEN").split(`
639
+ `).slice(1), s = /* @__PURE__ */ new Set();
640
+ c.forEach((o) => {
641
+ const i = o.split(/\s+/);
642
+ if (i.length >= 9) {
643
+ const y = i[8].match(/:(\d+)$/);
644
+ if (y) {
645
+ const g = y[1], u = i[0].substring(0, 4);
646
+ s.add(`${g}${u}`);
647
+ }
648
+ }
649
+ });
650
+ const a = Array.from(s).join(" ");
651
+ return r(e.cache, "ports", a), a;
652
+ } catch {
653
+ }
654
+ return r(e.cache, "ports", ""), "";
655
+ }
656
+ function ae(e) {
657
+ if (!d) return "";
658
+ try {
659
+ return l.readFileSync("/proc/loadavg", "utf8").split(" ").slice(0, 3).join(" ");
660
+ } catch {
661
+ }
662
+ return "";
663
+ }
664
+ function ie(e) {
665
+ const t = h(e.cache, "battery");
666
+ if (t !== null) return t;
667
+ if (!d)
668
+ return r(e.cache, "battery", ""), "";
669
+ try {
670
+ const n = "/sys/class/power_supply/BAT0", c = `${n}/capacity`, s = `${n}/status`;
671
+ if (l.existsSync(c)) {
672
+ const a = l.readFileSync(c, "utf8").trim(), o = l.existsSync(s) ? l.readFileSync(s, "utf8").trim() : "Unknown", y = `${parseInt(a)}%${o === "Charging" ? "+" : ""}`;
673
+ return r(e.cache, "battery", y), y;
674
+ }
675
+ } catch {
676
+ }
677
+ return r(e.cache, "battery", ""), "";
678
+ }
679
+ function oe(e) {
680
+ const t = h(e.cache, "temperature");
681
+ if (t !== null) return t;
682
+ if (!d)
683
+ return r(e.cache, "temperature", ""), "";
684
+ try {
685
+ const n = [
686
+ "/sys/class/thermal/thermal_zone0/temp",
687
+ "/sys/class/hwmon/hwmon0/temp1_input",
688
+ "/sys/class/hwmon/hwmon1/temp1_input"
689
+ ];
690
+ for (const c of n)
691
+ if (l.existsSync(c)) {
692
+ const s = l.readFileSync(c, "utf8").trim(), a = Math.round(parseInt(s) / 1e3);
693
+ if (a > 0 && a < 150) {
694
+ const o = `${a}°C`;
695
+ return r(e.cache, "temperature", o), o;
696
+ }
697
+ }
698
+ } catch {
699
+ }
700
+ return r(e.cache, "temperature", ""), "";
701
+ }
702
+ function ue(e) {
703
+ const t = h(e.cache, "services_running");
704
+ if (t !== null) return t;
705
+ if (!d)
706
+ return r(e.cache, "services_running", ""), "";
707
+ try {
708
+ let n = 0;
709
+ if (S("systemctl") ? n = p(
710
+ "systemctl list-units --type=service --state=running --no-pager"
711
+ ).split(`
712
+ `).filter((s) => s.includes(".service")).length : S("service") && (n = p("service --status-all").split(`
713
+ `).filter((s) => s.includes("+")).length), n > 0) {
714
+ const c = `${n} services`;
715
+ return r(e.cache, "services_running", c), c;
716
+ }
717
+ } catch {
718
+ }
719
+ return r(e.cache, "services_running", ""), "";
720
+ }
721
+ function le(e) {
722
+ const t = h(e.cache, "shell");
723
+ if (t !== null) return t;
724
+ if (d)
725
+ try {
726
+ const n = F.ppid, c = p(`ps -p ${n} -o comm=`).split("/").pop();
727
+ if (c)
728
+ return r(e.cache, "shell", c), c;
729
+ } catch {
730
+ }
731
+ return r(e.cache, "shell", ""), "";
732
+ }
733
+ function pe(e) {
734
+ const t = h(e.cache, "packages");
735
+ if (t !== null) return t;
736
+ const s = [
737
+ "apt",
738
+ "npm",
739
+ "uv",
740
+ "docker",
741
+ "hx",
742
+ "nvim",
743
+ "bun",
744
+ "yay",
745
+ "pacman",
746
+ "yum",
747
+ "dnf",
748
+ "zypper",
749
+ "emerge",
750
+ "apk",
751
+ "snap",
752
+ "flatpak"
753
+ ].filter((a) => S(a)).join(" ");
754
+ return r(e.cache, "packages", s), s;
755
+ }
756
+ function he(e) {
757
+ const t = h(e.cache, "containers");
758
+ if (t !== null) return t;
759
+ if (!S("docker"))
760
+ return r(e.cache, "containers", ""), "";
761
+ try {
762
+ if (p("docker ps -q").split(`
763
+ `).filter((i) => i.trim()).length === 0)
764
+ return r(e.cache, "containers", ""), "";
765
+ const s = p(
766
+ 'docker ps --format "{{.Names}} {{.Ports}}"'
767
+ ).split(`
768
+ `).filter((i) => i.trim()), a = [];
769
+ s.forEach((i) => {
770
+ const [m, y] = i.split(" ");
771
+ if (m && (a.push(m), y)) {
772
+ const g = y.match(/->(\d+(-\d+)?)\//g);
773
+ if (g) {
774
+ const u = [
775
+ ...new Set(
776
+ g.map((w) => w.replace(/->\d+(-\d+)?\//, ""))
777
+ )
778
+ ];
779
+ a.push(...u);
780
+ }
781
+ }
782
+ });
783
+ const o = a.join(" ");
784
+ return r(e.cache, "containers", o), o;
785
+ } catch {
786
+ }
787
+ return r(e.cache, "containers", ""), "";
788
+ }
789
+ const me = f.platform() === "win32", fe = f.platform() === "darwin", de = f.platform() === "linux", ye = "da2d6cc4baa5d1", ge = 5e3;
790
+ function _e() {
791
+ try {
792
+ if (l.existsSync(M))
793
+ return JSON.parse(l.readFileSync(M, "utf8"));
794
+ } catch {
795
+ }
796
+ return {};
797
+ }
798
+ function we(e) {
799
+ try {
800
+ const t = b.dirname(M);
801
+ l.existsSync(t) || l.mkdirSync(t, { recursive: !0 }), l.writeFileSync(M, JSON.stringify(e, null, 2));
802
+ } catch {
803
+ }
804
+ }
805
+ async function ve(e = ye, t = ge) {
806
+ return new Promise((n) => {
807
+ const c = `https://ipinfo.io/json${e ? `?token=${e}` : ""}`, s = j.get(c, (a) => {
808
+ let o = "";
809
+ a.on("data", (i) => o += i), a.on("end", () => {
810
+ try {
811
+ n(JSON.parse(o));
812
+ } catch {
813
+ n({});
814
+ }
815
+ });
816
+ });
817
+ s.on("error", () => n({})), s.setTimeout(t, () => {
818
+ s.destroy(), n({});
819
+ });
820
+ });
821
+ }
822
+ const ke = {
823
+ user: T,
824
+ hostname: E,
825
+ ip: x,
826
+ iplocal: ee,
827
+ city: te,
828
+ domain: ne,
829
+ isp: ce,
830
+ os: G,
831
+ // Mapped from os_info
832
+ cpu: C,
833
+ gpu: L,
834
+ bench: V,
835
+ cpu_bench_info: J,
836
+ disk_used: K,
837
+ ram_used: q,
838
+ top_process: Y,
839
+ uptime: Q,
840
+ device: U,
841
+ kernel: W,
842
+ shell: le,
843
+ pacman: pe,
844
+ // Mapped from packages
845
+ ports: re,
846
+ containers: he,
847
+ memory_available: H,
848
+ swap_used: z,
849
+ load_average: ae,
850
+ users_logged_in: Z,
851
+ network_interfaces: se,
852
+ mount_points: X,
853
+ services_running: ue,
854
+ temperature: oe,
855
+ battery: ie,
856
+ screen_resolution: R
857
+ };
858
+ async function Ne(e = {}) {
859
+ const t = _e(), n = { cache: t }, c = t.ipInfo?.value;
860
+ c ? n.ipInfo = c : (n.ipInfo = await ve(), t.ipInfo = {
861
+ value: n.ipInfo,
862
+ timestamp: Date.now()
863
+ });
864
+ const s = {
865
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
866
+ platform: me ? "windows" : fe ? "macos" : de ? "linux" : "unknown"
867
+ };
868
+ for (const [a, o] of Object.entries(ke))
869
+ try {
870
+ const i = await o(n);
871
+ s[a] = i;
872
+ } catch {
873
+ s[a] = "";
874
+ }
875
+ return we(t), s;
876
+ }
877
+ export {
878
+ M as C,
879
+ N as D,
880
+ I as S,
881
+ Ce as a,
882
+ Pe as b,
883
+ Be as c,
884
+ Ne as g,
885
+ ke as i,
886
+ _e as l,
887
+ we as s
888
+ };
889
+ //# sourceMappingURL=system-info-api-BfolzpSf.js.map