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