about-system 0.10.10 → 0.10.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/README.md +5 -3
  2. package/dist/about-system-cli.js +69 -54
  3. package/dist/about-system-cli.js.map +1 -1
  4. package/dist/index.d.ts +64 -18
  5. package/dist/index.js +1 -1
  6. package/dist/system-info-api-7iy1ZV2o.js +2475 -0
  7. package/dist/system-info-api-7iy1ZV2o.js.map +1 -0
  8. package/dist/system-info-api.d.ts +432 -62
  9. package/dist/system-info-api.js +1 -1
  10. package/dist/web/assets/index--HOsj3jw.js +14 -0
  11. package/dist/web/assets/index-BU_blZyu.css +1 -0
  12. package/dist/web/index.html +13 -0
  13. package/package.json +1 -1
  14. package/src/about-system-cli.ts +42 -3
  15. package/src/cache/cache-config.ts +3 -3
  16. package/src/info/hardware.test.ts +27 -12
  17. package/src/info/hardware.ts +25 -22
  18. package/src/info/network.ts +14 -47
  19. package/src/system-info-api.test.ts +106 -0
  20. package/src/system-info-api.ts +67 -28
  21. package/src/systeminfo-types.d.ts +16 -10
  22. package/src/utils/network.ts +113 -94
  23. package/src/utils/utils.test.ts +84 -75
  24. package/dist/about-system-cli.d.ts.map +0 -1
  25. package/dist/cache/cache-config.d.ts +0 -62
  26. package/dist/cache/cache-config.d.ts.map +0 -1
  27. package/dist/cache/cache.d.ts +0 -53
  28. package/dist/cache/cache.d.ts.map +0 -1
  29. package/dist/index.d.ts.map +0 -1
  30. package/dist/info/hardware.d.ts +0 -76
  31. package/dist/info/hardware.d.ts.map +0 -1
  32. package/dist/info/memory.d.ts +0 -59
  33. package/dist/info/memory.d.ts.map +0 -1
  34. package/dist/info/network.d.ts +0 -54
  35. package/dist/info/network.d.ts.map +0 -1
  36. package/dist/info/platform.d.ts +0 -36
  37. package/dist/info/platform.d.ts.map +0 -1
  38. package/dist/info/process.d.ts +0 -23
  39. package/dist/info/process.d.ts.map +0 -1
  40. package/dist/info/settings.d.ts +0 -185
  41. package/dist/info/settings.d.ts.map +0 -1
  42. package/dist/info/software.d.ts +0 -33
  43. package/dist/info/software.d.ts.map +0 -1
  44. package/dist/info/system-status.d.ts +0 -36
  45. package/dist/info/system-status.d.ts.map +0 -1
  46. package/dist/system-info-api-ByXoHI0m.js +0 -2464
  47. package/dist/system-info-api-ByXoHI0m.js.map +0 -1
  48. package/dist/system-info-api.d.ts.map +0 -1
  49. package/dist/types/internal-types.d.ts +0 -14
  50. package/dist/types/internal-types.d.ts.map +0 -1
  51. package/dist/utils/command.d.ts +0 -18
  52. package/dist/utils/command.d.ts.map +0 -1
  53. package/dist/utils/network.d.ts +0 -27
  54. package/dist/utils/network.d.ts.map +0 -1
  55. package/dist/utils/platform.d.ts +0 -11
  56. package/dist/utils/platform.d.ts.map +0 -1
  57. package/dist/web-server.d.ts +0 -21
  58. package/dist/web-server.d.ts.map +0 -1
@@ -22,6 +22,11 @@ vi.mock("https", () => ({
22
22
  get: httpsGet,
23
23
  default: { get: httpsGet },
24
24
  }));
25
+ const httpGet = vi.hoisted(() => vi.fn());
26
+ vi.mock("http", () => ({
27
+ get: httpGet,
28
+ default: { get: httpGet },
29
+ }));
25
30
 
26
31
  import { commandExists, execCommand } from "./command";
27
32
  import { IS_LINUX, IS_MAC, IS_WINDOWS } from "./platform";
@@ -31,7 +36,9 @@ import { DEFAULT_IPINFO_TOKEN, DEFAULT_NETWORK_TIMEOUT } from "../cache/cache-co
31
36
  afterEach(() => {
32
37
  execSync.mockReset();
33
38
  httpsGet.mockReset();
39
+ httpGet.mockReset();
34
40
  vi.restoreAllMocks();
41
+ vi.useRealTimers();
35
42
  });
36
43
 
37
44
  describe("platform flags", () => {
@@ -118,24 +125,27 @@ describe("commandExists", () => {
118
125
  });
119
126
  });
120
127
 
121
- /** A fake `https.get` whose response body and failure mode a test controls. */
122
- function stubHttpsGet(behavior: (req: EventEmitter & { setTimeout: (ms: number, fn: () => void) => void; destroy: () => void }, onResponse: (res: EventEmitter) => void) => void) {
123
- httpsGet.mockImplementation(
124
- (_url: string, callback: (res: EventEmitter) => void) => {
125
- const req = Object.assign(new EventEmitter(), {
126
- setTimeout: vi.fn(),
127
- destroy: vi.fn(),
128
- });
129
- queueMicrotask(() => behavior(req, callback));
130
- return req;
131
- },
132
- );
133
- return httpsGet;
128
+ type FakeReq = EventEmitter & { destroy: () => void };
129
+
130
+ /**
131
+ * A fake `get` (https or http) whose response a test controls. `behavior`
132
+ * runs on the next microtask; leave it empty to simulate a hung request.
133
+ */
134
+ function stubGet(
135
+ get: typeof httpsGet,
136
+ behavior: (req: FakeReq, onResponse: (res: EventEmitter) => void) => void = () => {},
137
+ ) {
138
+ get.mockImplementation((_url: string, callback: (res: EventEmitter) => void) => {
139
+ const req: FakeReq = Object.assign(new EventEmitter(), { destroy: vi.fn() });
140
+ queueMicrotask(() => behavior(req, callback));
141
+ return req;
142
+ });
143
+ return get;
134
144
  }
135
145
 
136
146
  /** Emits a complete response body on the next tick. */
137
- const respondWith = (body: string) =>
138
- stubHttpsGet((_req, onResponse) => {
147
+ const respondWith = (get: typeof httpsGet, body: string) =>
148
+ stubGet(get, (_req, onResponse) => {
139
149
  const res = new EventEmitter();
140
150
  onResponse(res);
141
151
  res.emit("data", body);
@@ -144,57 +154,61 @@ const respondWith = (body: string) =>
144
154
 
145
155
  describe("fetchFromIPInfo", () => {
146
156
  it("parses the ipinfo.io lite payload", async () => {
147
- respondWith(JSON.stringify({ ip: "1.2.3.4", city: "San Francisco", org: "AS123 Test ISP" }));
157
+ respondWith(httpsGet, JSON.stringify({ ip: "1.2.3.4", asn: "AS123", as_name: "Test ISP", country: "US" }));
148
158
 
149
159
  await expect(fetchFromIPInfo()).resolves.toEqual({
150
160
  ip: "1.2.3.4",
151
- city: "San Francisco",
152
161
  org: "AS123 Test ISP",
153
162
  });
154
163
  });
155
164
 
156
- it("sends request to ipinfo.io lite endpoint with token", async () => {
157
- const get = respondWith("{}");
165
+ it("asks about this machine, not a fixed address", async () => {
166
+ const get = respondWith(httpsGet, "{}");
158
167
  await fetchFromIPInfo();
159
168
 
160
169
  expect(get.mock.calls[0][0]).toBe(
161
- `https://api.ipinfo.io/lite/8.8.8.8?token=${DEFAULT_IPINFO_TOKEN}`,
170
+ `https://api.ipinfo.io/lite/me?token=${DEFAULT_IPINFO_TOKEN}`,
162
171
  );
163
172
  });
164
173
 
165
174
  it("resolves empty rather than rejecting on a malformed body", async () => {
166
- respondWith("<html>gateway error</html>");
175
+ respondWith(httpsGet, "<html>gateway error</html>");
167
176
  await expect(fetchFromIPInfo()).resolves.toEqual({});
168
177
  });
169
178
 
170
179
  it("resolves empty rather than rejecting when the request errors", async () => {
171
- stubHttpsGet((req) => req.emit("error", new Error("ENOTFOUND")));
180
+ stubGet(httpsGet, (req) => req.emit("error", new Error("ENOTFOUND")));
172
181
  await expect(fetchFromIPInfo()).resolves.toEqual({});
173
182
  });
174
183
 
175
- it("arms a timeout that abandons the request", async () => {
176
- let armed: { ms: number; fire: () => void } | undefined;
177
- httpsGet.mockImplementation(() => {
178
- const req = Object.assign(new EventEmitter(), {
179
- setTimeout: (ms: number, fire: () => void) => {
180
- armed = { ms, fire };
181
- },
182
- destroy: vi.fn(),
183
- });
184
- return req;
185
- });
184
+ it("gives up after a hard 3 second deadline by default", async () => {
185
+ vi.useFakeTimers();
186
+ stubGet(httpsGet);
187
+ let done = false;
188
+ const pending = fetchFromIPInfo().then((r) => ((done = true), r));
186
189
 
187
- const pending = fetchFromIPInfo(DEFAULT_IPINFO_TOKEN, 1234);
188
- expect(armed?.ms).toBe(1234);
190
+ await vi.advanceTimersByTimeAsync(DEFAULT_NETWORK_TIMEOUT - 1);
191
+ expect(done).toBe(false);
192
+ await vi.advanceTimersByTimeAsync(1);
193
+ await expect(pending).resolves.toEqual({});
194
+ expect(DEFAULT_NETWORK_TIMEOUT).toBe(3000);
195
+ expect(httpsGet.mock.results[0].value.destroy).toHaveBeenCalled();
196
+ });
197
+
198
+ it("abandons the request when the signal aborts", async () => {
199
+ stubGet(httpsGet);
200
+ const controller = new AbortController();
201
+ const pending = fetchFromIPInfo(DEFAULT_IPINFO_TOKEN, 60_000, controller.signal);
189
202
 
190
- armed?.fire();
203
+ controller.abort();
191
204
  await expect(pending).resolves.toEqual({});
205
+ expect(httpsGet.mock.results[0].value.destroy).toHaveBeenCalled();
192
206
  });
193
207
  });
194
208
 
195
209
  describe("fetchFromIPAPI", () => {
196
210
  it("parses the ip-api.com payload", async () => {
197
- respondWith(JSON.stringify({
211
+ respondWith(httpGet, JSON.stringify({
198
212
  status: "success",
199
213
  query: "1.2.3.4",
200
214
  city: "San Francisco",
@@ -210,66 +224,51 @@ describe("fetchFromIPAPI", () => {
210
224
  });
211
225
  });
212
226
 
213
- it("sends request to ip-api.com endpoint", async () => {
214
- const get = respondWith('{"status":"success"}');
227
+ it("uses plain http, which is all ip-api.com's free tier serves", async () => {
228
+ const get = respondWith(httpGet, '{"status":"success"}');
215
229
  await fetchFromIPAPI();
216
230
 
217
231
  expect(get.mock.calls[0][0]).toBe(
218
232
  "http://ip-api.com/json/?fields=status,message,query,city,isp,org,as"
219
233
  );
234
+ expect(httpsGet).not.toHaveBeenCalled();
220
235
  });
221
236
 
222
237
  it("returns empty object on failed status", async () => {
223
- respondWith(JSON.stringify({ status: "fail", message: "private range" }));
238
+ respondWith(httpGet, JSON.stringify({ status: "fail", message: "private range" }));
224
239
  await expect(fetchFromIPAPI()).resolves.toEqual({});
225
240
  });
226
241
 
227
242
  it("resolves empty rather than rejecting on a malformed body", async () => {
228
- respondWith("<html>gateway error</html>");
243
+ respondWith(httpGet, "<html>gateway error</html>");
229
244
  await expect(fetchFromIPAPI()).resolves.toEqual({});
230
245
  });
231
246
  });
232
247
 
233
- describe("fetchIPInfo (race)", () => {
234
- it("returns ipinfo result when it responds first with data", async () => {
235
- let ipinfoResolve: (value: any) => void;
236
- let ipapiResolve: (value: any) => void;
237
-
238
- const ipinfoPromise = new Promise((resolve) => { ipinfoResolve = resolve; });
239
- const ipapiPromise = new Promise((resolve) => { ipapiResolve = resolve; });
240
-
241
- vi.spyOn(await import("./network"), "fetchFromIPInfo").mockReturnValue(ipinfoPromise);
242
- vi.spyOn(await import("./network"), "fetchFromIPAPI").mockReturnValue(ipapiPromise);
243
-
244
- const resultPromise = fetchIPInfo();
248
+ describe("fetchIPInfo", () => {
249
+ it("prefers ipinfo per field and fills gaps from ip-api", async () => {
250
+ respondWith(httpsGet, JSON.stringify({ ip: "1.2.3.4", asn: "AS123", as_name: "Primary ISP" }));
251
+ respondWith(httpGet, JSON.stringify({ status: "success", query: "5.6.7.8", city: "New York", org: "AS456 Other" }));
245
252
 
246
- // Resolve ipinfo first with data
247
- ipinfoResolve!({ ip: "1.2.3.4", city: "San Francisco" });
248
- ipapiResolve!({ ip: "5.6.7.8", city: "New York" });
249
-
250
- await expect(resultPromise).resolves.toEqual({
253
+ await expect(fetchIPInfo()).resolves.toEqual({
251
254
  ip: "1.2.3.4",
252
- city: "San Francisco",
255
+ city: "New York",
256
+ org: "AS123 Primary ISP",
253
257
  });
254
258
  });
255
259
 
256
- it("falls back to ip-api when ipinfo fails", async () => {
257
- let ipinfoResolve: (value: any) => void;
258
- let ipapiResolve: (value: any) => void;
259
-
260
- const ipinfoPromise = new Promise((resolve) => { ipinfoResolve = resolve; });
261
- const ipapiPromise = new Promise((resolve) => { ipapiResolve = resolve; });
262
-
263
- vi.spyOn(await import("./network"), "fetchFromIPInfo").mockReturnValue(ipinfoPromise);
264
- vi.spyOn(await import("./network"), "fetchFromIPAPI").mockReturnValue(ipapiPromise);
260
+ it("prefers an IPv4 address over ipinfo's IPv6 one", async () => {
261
+ respondWith(httpsGet, JSON.stringify({ ip: "2600:1010::1", asn: "AS123", as_name: "Primary ISP" }));
262
+ respondWith(httpGet, JSON.stringify({ status: "success", query: "5.6.7.8", city: "New York" }));
265
263
 
266
- const resultPromise = fetchIPInfo();
264
+ await expect(fetchIPInfo()).resolves.toMatchObject({ ip: "5.6.7.8" });
265
+ });
267
266
 
268
- // Resolve ipinfo with empty, ipapi with data
269
- ipinfoResolve!({});
270
- ipapiResolve!({ ip: "5.6.7.8", city: "New York", org: "AS456 Fallback ISP" });
267
+ it("falls back to ip-api when ipinfo fails", async () => {
268
+ stubGet(httpsGet, (req) => req.emit("error", new Error("ECONNRESET")));
269
+ respondWith(httpGet, JSON.stringify({ status: "success", query: "5.6.7.8", city: "New York", org: "AS456 Fallback ISP" }));
271
270
 
272
- await expect(resultPromise).resolves.toEqual({
271
+ await expect(fetchIPInfo()).resolves.toEqual({
273
272
  ip: "5.6.7.8",
274
273
  city: "New York",
275
274
  org: "AS456 Fallback ISP",
@@ -277,9 +276,19 @@ describe("fetchIPInfo (race)", () => {
277
276
  });
278
277
 
279
278
  it("returns empty when both fail", async () => {
280
- vi.spyOn(await import("./network"), "fetchFromIPInfo").mockResolvedValue({});
281
- vi.spyOn(await import("./network"), "fetchFromIPAPI").mockResolvedValue({});
279
+ stubGet(httpsGet, (req) => req.emit("error", new Error("ENOTFOUND")));
280
+ stubGet(httpGet, (req) => req.emit("error", new Error("ENOTFOUND")));
282
281
 
283
282
  await expect(fetchIPInfo()).resolves.toEqual({});
284
283
  });
284
+
285
+ it("never waits past the shared deadline when both hang", async () => {
286
+ vi.useFakeTimers();
287
+ stubGet(httpsGet);
288
+ stubGet(httpGet);
289
+ const pending = fetchIPInfo();
290
+
291
+ await vi.advanceTimersByTimeAsync(DEFAULT_NETWORK_TIMEOUT);
292
+ await expect(pending).resolves.toEqual({});
293
+ });
285
294
  });
@@ -1 +0,0 @@
1
- {"version":3,"file":"about-system-cli.d.ts","sourceRoot":"","sources":["../src/about-system-cli.ts"],"names":[],"mappings":";AAoJA,iBAAe,iBAAiB,CAC9B,kBAAkB,GAAE,MAAM,EAAE,EAAE,GAAG,IAAW,GAC3C,OAAO,CAAC,IAAI,CAAC,CAqDf;AA8ED,iBAAS,oBAAoB,IAAI,IAAI,CAoGpC;AAoJD,OAAO,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,CAAC"}
@@ -1,62 +0,0 @@
1
- /**
2
- * Cache configuration and constants
3
- * @module cache-config
4
- */
5
- /**
6
- * Cache file location in system's temporary directory
7
- * @constant
8
- */
9
- export declare const CACHE_FILE: string;
10
- /**
11
- * Cache duration configuration for different system information types
12
- * Values are in milliseconds
13
- *
14
- * @constant
15
- * @property {number} ip - IP information cache (10 minutes)
16
- * @property {number} cpu - CPU information cache (24 hours)
17
- * @property {number} gpu - GPU information cache (24 hours)
18
- * @property {number} os - OS information cache (24 hours)
19
- * @property {number} device - Device information cache (24 hours)
20
- * @property {number} kernel - Kernel information cache (1 hour)
21
- * @property {number} pacman - Package managers cache (10 minutes)
22
- * @property {number} ports - Open ports cache (5 minutes)
23
- * @property {number} containers - Docker containers cache (5 minutes)
24
- * @property {number} top_process - Top process cache (5 seconds)
25
- * @property {number} disk_used - Disk usage cache (1 minute)
26
- * @property {number} ram_used - RAM usage cache (10 seconds)
27
- * @property {number} services_running - Services cache (5 minutes)
28
- * @property {number} temperature - Temperature cache (30 seconds)
29
- * @property {number} battery - Battery status cache (1 minute)
30
- * @property {number} network_interfaces - Network interfaces cache (5 minutes)
31
- * @property {number} mount_points - Mount points cache (10 minutes)
32
- */
33
- export declare const CACHE_DURATION: {
34
- ip: number;
35
- cpu: number;
36
- gpu: number;
37
- os: number;
38
- device: number;
39
- kernel: number;
40
- pacman: number;
41
- ports: number;
42
- containers: number;
43
- top_process: number;
44
- disk_used: number;
45
- ram_used: number;
46
- services_running: number;
47
- temperature: number;
48
- battery: number;
49
- network_interfaces: number;
50
- mount_points: number;
51
- };
52
- /**
53
- * Default IPInfo.io API token for geolocation
54
- * @constant
55
- */
56
- export declare const DEFAULT_IPINFO_TOKEN = "da2d6cc4baa5d1";
57
- /**
58
- * Default network request timeout in milliseconds
59
- * @constant
60
- */
61
- export declare const DEFAULT_NETWORK_TIMEOUT = 5000;
62
- //# sourceMappingURL=cache-config.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cache-config.d.ts","sourceRoot":"","sources":["../../src/cache/cache-config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH;;;GAGG;AACH,eAAO,MAAM,UAAU,QAAkD,CAAC;AAE1E;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;CAkB1B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,oBAAoB,mBAAmB,CAAC;AAErD;;;GAGG;AACH,eAAO,MAAM,uBAAuB,OAAO,CAAC"}
@@ -1,53 +0,0 @@
1
- /**
2
- * Cache management utilities
3
- * @module cache
4
- */
5
- /**
6
- * Represents a cached value with timestamp
7
- * @interface CacheEntry
8
- */
9
- export interface CacheEntry {
10
- /** The cached value */
11
- value: any;
12
- /** Unix timestamp when the value was cached */
13
- timestamp: number;
14
- }
15
- /**
16
- * Cache storage structure
17
- * @interface Cache
18
- */
19
- export interface Cache {
20
- [key: string]: CacheEntry;
21
- }
22
- /**
23
- * Loads cache from disk
24
- * @returns {Cache} Cached data or empty object if cache doesn't exist or is corrupted
25
- */
26
- export declare function loadCache(): Cache;
27
- /**
28
- * Saves cache to disk
29
- * @param {Cache} cache - Cache object to save
30
- */
31
- export declare function saveCache(cache: Cache): void;
32
- /**
33
- * Checks if a cache entry is still valid based on configured duration
34
- * @param {CacheEntry} cacheEntry - The cache entry to validate
35
- * @param {string} key - The key name to determine cache duration
36
- * @returns {boolean} True if cache is still valid
37
- */
38
- export declare function isCacheValid(cacheEntry: CacheEntry, key: string): boolean;
39
- /**
40
- * Retrieves a value from cache if valid
41
- * @param {Cache} cache - Cache object
42
- * @param {string} key - Key to retrieve
43
- * @returns {any} Cached value or null if not found/expired
44
- */
45
- export declare function getCachedValue(cache: Cache, key: string): any;
46
- /**
47
- * Stores a value in cache with current timestamp
48
- * @param {Cache} cache - Cache object
49
- * @param {string} key - Key to store under
50
- * @param {any} value - Value to cache
51
- */
52
- export declare function setCachedValue(cache: Cache, key: string, value: any): void;
53
- //# sourceMappingURL=cache.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../src/cache/cache.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB,uBAAuB;IACvB,KAAK,EAAE,GAAG,CAAC;IACX,+CAA+C;IAC/C,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;GAGG;AACH,MAAM,WAAW,KAAK;IACpB,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAAC;CAC3B;AAED;;;GAGG;AACH,wBAAgB,SAAS,IAAI,KAAK,CASjC;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAM5C;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,UAAU,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAKzE;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,GAAG,GAAG,CAQ7D;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI,CAK1E"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAC3E,YAAY,EAAE,UAAU,EAAE,iBAAiB,EAAE,QAAQ,EAAE,qBAAqB,EAAE,yBAAyB,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC"}
@@ -1,76 +0,0 @@
1
- import { InfoContext } from '../types/internal-types';
2
- /**
3
- * Formats a Geekbench score in whole thousands with its rank and how far up
4
- * the table that rank sits.
5
- * @param score - Raw Geekbench score
6
- * @param rank - Rank in the benchmark table (1 = fastest)
7
- * @param total - Number of entries in the benchmark table
8
- * @returns Score, rank and top percentile
9
- * @example formatBench(20512, 68, 1500) // "21k #68 top 7%"
10
- */
11
- export declare function formatBench(score: number, rank: number, total: number): string;
12
- /**
13
- * Percentile bucket a rank falls in, rounded up so rank 1 reads "top 1%"
14
- * @param rank - Rank in the benchmark table (1 = fastest)
15
- * @param total - Number of entries in the benchmark table
16
- * @returns Whole percentage between 1 and 100
17
- */
18
- export declare function topPercent(rank: number, total: number): number;
19
- /**
20
- * Gets CPU model name and specifications
21
- * Uses platform-specific commands (wmic/lscpu/cpuinfo)
22
- * Automatically strips "with Radeon Graphics" and similar suffixes
23
- * @param context - Info context with cache
24
- * @returns CPU model string or empty string
25
- * @example "Intel Core i7-12700K", "AMD Ryzen 9 5900HX", "Apple M2 Pro"
26
- */
27
- export declare function cpu(context: InfoContext): string;
28
- /**
29
- * Gets graphics card model name
30
- * Extracts GPU info from lspci (Linux) or WMI (Windows)
31
- * Filters out basic/generic display adapters
32
- * @param context - Info context with cache
33
- * @returns GPU model string or empty string
34
- * @example "NVIDIA GeForce RTX 4070", "AMD Radeon RX 6800 XT"
35
- */
36
- export declare function gpu(context: InfoContext): string;
37
- /**
38
- * Gets screen resolution
39
- * Uses xrandr on Linux (X11/Xorg only) or system_profiler on macOS
40
- * @returns Resolution in WIDTHxHEIGHT format or empty string
41
- * @example "1920x1080", "2560x1440", "3840x2160"
42
- */
43
- export declare function screen_resolution(): string;
44
- /**
45
- * Gets CPU benchmark score and rank from Geekbench 6 data
46
- * Uses fuzzy matching to find similar CPU models
47
- * @param context - Info context with cache
48
- * @returns Benchmark info with score and rank, or empty string
49
- * @example "38k #1 top 1%", "21k #68 top 7%"
50
- */
51
- export declare function bench(context: InfoContext): string;
52
- /**
53
- * Gets detailed CPU benchmark information from Geekbench 6 data
54
- * Includes score, rank, and architecture type (ARM/Intel/AMD)
55
- * @param context - Info context with cache
56
- * @returns Detailed benchmark info with architecture, or empty string
57
- * @example "Geekbench 6: 38k (Rank #1, top 1%) - ARM", "Geekbench 6: 21k (Rank #68, top 7%) - Intel"
58
- */
59
- export declare function cpu_bench_info(context: InfoContext): string;
60
- /**
61
- * Gets GPU benchmark score and rank from Geekbench 6 data
62
- * Uses fuzzy matching to find similar GPU models
63
- * @param context - Info context with cache
64
- * @returns Benchmark info with score and rank, or empty string
65
- * @example "38k #1 top 1%", "21k #68 top 7%"
66
- */
67
- export declare function gpu_bench(context: InfoContext): string;
68
- /**
69
- * Gets detailed GPU benchmark information from Geekbench 6 data
70
- * Includes score, rank, and vendor detection
71
- * @param context - Info context with cache
72
- * @returns Detailed benchmark info with vendor, or empty string
73
- * @example "Geekbench 6: 38k (Rank #1, top 1%) - NVIDIA", "Geekbench 6: 21k (Rank #68, top 7%) - AMD"
74
- */
75
- export declare function gpu_bench_info(context: InfoContext): string;
76
- //# sourceMappingURL=hardware.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"hardware.d.ts","sourceRoot":"","sources":["../../src/info/hardware.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAM3D;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAE9E;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAG9D;AAED;;;;;;;GAOG;AACH,wBAAgB,GAAG,CAAC,OAAO,EAAE,WAAW,GAAG,MAAM,CA+DhD;AAED;;;;;;;GAOG;AACH,wBAAgB,GAAG,CAAC,OAAO,EAAE,WAAW,GAAG,MAAM,CA2FhD;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAwB1C;AAED;;;;;;GAMG;AACH,wBAAgB,KAAK,CAAC,OAAO,EAAE,WAAW,GAAG,MAAM,CA4DlD;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,WAAW,GAAG,MAAM,CAgF3D;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,WAAW,GAAG,MAAM,CA4DtD;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,WAAW,GAAG,MAAM,CAyF3D"}
@@ -1,59 +0,0 @@
1
- import { InfoContext } from '../types/internal-types';
2
- /**
3
- * Gets memory usage in gigabytes
4
- * Reads from /proc/meminfo on Linux, falls back to os.totalmem()
5
- * @param context - Info context with cache
6
- * @returns Memory usage as "used/total GB"
7
- * @example "12/32GB", "6/16GB"
8
- */
9
- export declare function ram_used(context: InfoContext): string;
10
- /**
11
- * Gets available memory in gigabytes
12
- * Reads MemAvailable from /proc/meminfo (Linux) or derives it from
13
- * vm_stat's free+inactive pages (macOS)
14
- * @returns Available memory with "GB available" suffix or empty string
15
- * @example "12GB available", "4GB available"
16
- */
17
- export declare function memory_available(): string;
18
- /**
19
- * Gets swap memory usage
20
- * Calculates swap usage from /proc/meminfo (Linux) or `sysctl vm.swapusage`
21
- * (macOS)
22
- * @returns Swap usage as "percentage (size MB) swap" or empty string
23
- * @example "15% (512MB) swap", "0% (0MB) swap"
24
- */
25
- export declare function swap_used(): string;
26
- /**
27
- * Gets root filesystem disk usage percentage
28
- * Uses df command on Linux/Android/macOS
29
- * @param context - Info context with cache
30
- * @returns Percentage string or empty string
31
- * @example "45%", "78%"
32
- */
33
- export declare function disk_used(context: InfoContext): string;
34
- /**
35
- * Gets disk size (used/total) for each real disk
36
- * Uses `df -k` on Linux/macOS, filtering out pseudo filesystems, system/boot
37
- * partitions (e.g. /boot, /System/Volumes/*), and anything under 10GB, since
38
- * those aren't disks a user would care about. When exactly one real disk is
39
- * found (the common case) the result omits the mount point; when multiple
40
- * real disks are found (e.g. a data drive or external volume), each is
41
- * labeled by its mount point.
42
- * @param context - Info context with cache
43
- * @returns Disk size as "used/total GB" or "mount(used/total GB) ..." or empty string
44
- * @example "256/512GB", "/(100/500GB) /Volumes/Backup(900/2000GB)"
45
- */
46
- export declare function disk_size(context: InfoContext): string;
47
- /**
48
- * Gets mounted filesystem information
49
- * Lists non-system mount points with usage from df (Linux/macOS)
50
- * On Linux, excludes /, /dev, /proc, /sys and internal /System/Volumes mounts.
51
- * On macOS, APFS internal volumes (Data, VM, Preboot, Update, ...) all live
52
- * under /System/Volumes and are not user-relevant, so only /Volumes (external
53
- * disks, network shares, disk images) are reported.
54
- * @param context - Info context with cache
55
- * @returns Space-separated mount points with usage or empty string
56
- * @example "/home(45%) /mnt/data(78%)", "/Volumes/Backup(78%)"
57
- */
58
- export declare function mount_points(context: InfoContext): string;
59
- //# sourceMappingURL=memory.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../src/info/memory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAK3D;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,WAAW,GAAG,MAAM,CAmCrD;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,CA+BzC;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,IAAI,MAAM,CA6ClC;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,WAAW,GAAG,MAAM,CAsCtD;AAQD;;;;;;;;;;;GAWG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,WAAW,GAAG,MAAM,CAmEtD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,WAAW,GAAG,MAAM,CAiDzD"}
@@ -1,54 +0,0 @@
1
- import { InfoContext } from '../types/internal-types';
2
- /**
3
- * Gets public IP address from ipinfo.io
4
- * @param context - Info context with cache and IP info
5
- * @returns Public IPv4 address or empty string
6
- * @example "203.0.113.42"
7
- */
8
- export declare function ip(context: InfoContext): Promise<string>;
9
- /**
10
- * Gets local/private IP address(es)
11
- * Tries ifconfig and ip commands on Linux, falls back to Node.js API
12
- * @returns Space-separated local IP addresses (RFC 1918 ranges)
13
- * @example "192.168.1.100" or "10.0.0.50 192.168.1.100"
14
- */
15
- export declare function iplocal(): string;
16
- /**
17
- * Gets geographic city based on public IP
18
- * @param context - Info context with IP geolocation data
19
- * @returns City name or empty string
20
- * @example "San Francisco", "New York", "London"
21
- */
22
- export declare function city(context: InfoContext): Promise<string>;
23
- /**
24
- * Gets reverse DNS hostname with HTTP prefix
25
- * @param context - Info context with IP info
26
- * @returns Domain with http:// prefix or empty string
27
- * @example "http://example.com", "http://host-203-0-113-42.example.net"
28
- */
29
- export declare function domain(context: InfoContext): Promise<string>;
30
- /**
31
- * Gets Internet Service Provider name
32
- * Strips AS number prefix from organization string
33
- * @param context - Info context with IP info
34
- * @returns ISP name or empty string
35
- * @example "Comcast Cable", "Verizon Business", "Cloudflare Inc"
36
- */
37
- export declare function isp(context: InfoContext): Promise<string>;
38
- /**
39
- * Gets active network interface names
40
- * Lists non-loopback interfaces with IPv4 addresses (Linux/macOS only)
41
- * @param context - Info context with cache
42
- * @returns Space-separated interface names or empty string
43
- * @example "eth0 wlan0", "en0 en1"
44
- */
45
- export declare function network_interfaces(context: InfoContext): string;
46
- /**
47
- * Gets open TCP ports with service names
48
- * Uses lsof to find listening TCP ports (Linux/macOS only)
49
- * @param context - Info context with cache
50
- * @returns Space-separated port+process pairs or empty string
51
- * @example "80http 443http 22ssh", "3000node 5432post"
52
- */
53
- export declare function ports(context: InfoContext): string;
54
- //# sourceMappingURL=network.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"network.d.ts","sourceRoot":"","sources":["../../src/info/network.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAK3D;;;;;GAKG;AACH,wBAAsB,EAAE,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC,CAW9D;AAED;;;;;GAKG;AACH,wBAAgB,OAAO,IAAI,MAAM,CAuChC;AAED;;;;;GAKG;AACH,wBAAsB,IAAI,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC,CAWhE;AAED;;;;;GAKG;AACH,wBAAsB,MAAM,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC,CAWlE;AAED;;;;;;GAMG;AACH,wBAAsB,GAAG,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC,CAW/D;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,WAAW,GAAG,MAAM,CA+B/D;AACD;;;;;;GAMG;AACH,wBAAgB,KAAK,CAAC,OAAO,EAAE,WAAW,GAAG,MAAM,CA+BlD"}
@@ -1,36 +0,0 @@
1
- import { InfoContext } from '../types/internal-types';
2
- /**
3
- * Gets the current username
4
- * @returns Current system username
5
- */
6
- export declare function user(): string;
7
- /**
8
- * Gets the system hostname
9
- * @returns Computer hostname/network name
10
- */
11
- export declare function hostname(): string;
12
- /**
13
- * Gets operating system name and version
14
- * Platform-specific detection for Windows, macOS, and Linux
15
- * @param context - Info context with cache
16
- * @returns OS name and version string
17
- * @example "Windows 11 Pro", "macOS Ventura 13.2.1", "Ubuntu 22.04.3 LTS"
18
- */
19
- export declare function os_info(context: InfoContext): string;
20
- /**
21
- * Gets kernel version string
22
- * Returns the operating system kernel version from os.release()
23
- * @param context - Info context with cache
24
- * @returns Kernel version string
25
- * @example "5.15.0-56-generic", "6.11.11-valve12-1-neptune"
26
- */
27
- export declare function kernel(context: InfoContext): string;
28
- /**
29
- * Gets device or computer model name
30
- * Uses WMI on Windows, DMI on Linux, getprop on Android
31
- * @param context - Info context with cache
32
- * @returns Device model name or empty string
33
- * @example "Dell OptiPlex 7090", "MacBook Pro 16-inch", "Valve Steam Deck"
34
- */
35
- export declare function device(context: InfoContext): string;
36
- //# sourceMappingURL=platform.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../../src/info/platform.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAK3D;;;GAGG;AACH,wBAAgB,IAAI,IAAI,MAAM,CAE7B;AAED;;;GAGG;AACH,wBAAgB,QAAQ,IAAI,MAAM,CAEjC;AAED;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,OAAO,EAAE,WAAW,GAAG,MAAM,CAuCpD;AAED;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,OAAO,EAAE,WAAW,GAAG,MAAM,CAOnD;AAED;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,OAAO,EAAE,WAAW,GAAG,MAAM,CA0DnD"}