systeminformation 6.0.0-beta.0 → 6.0.0-beta.2

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.
@@ -6,6 +6,7 @@ export declare const osInfo: () => Promise<import("../common/types").OsData | {
6
6
  codename: string;
7
7
  codepage: string;
8
8
  uefi: true | null;
9
+ lastUpdate: Date | null;
9
10
  displayServer: string;
10
11
  platform: string;
11
12
  kernel: string;
@@ -15,6 +16,8 @@ export declare const osInfo: () => Promise<import("../common/types").OsData | {
15
16
  build: string;
16
17
  servicepack: string;
17
18
  installDate: Date | null;
19
+ awake: boolean;
20
+ hwAcceleration: string[];
18
21
  hypervizor?: boolean;
19
22
  remoteSession?: boolean;
20
23
  hypervisor?: boolean;
@@ -6,6 +6,14 @@ const defaults_1 = require("../common/defaults");
6
6
  const mappings_1 = require("../common/mappings");
7
7
  const common_1 = require("../common");
8
8
  const codepage_1 = require("../common/codepage");
9
+ const getLastUpdate = async () => {
10
+ const { stdout } = await (0, exec_1.execSave)('stat -f %m /var/db/pkg/local.sqlite /var/db/pkg /var/db/freebsd-update 2>/dev/null');
11
+ const times = (stdout || '')
12
+ .split('\n')
13
+ .map((line) => parseInt(line.trim(), 10))
14
+ .filter((sec) => sec > 0);
15
+ return times.length ? new Date(Math.max(...times) * 1000) : null;
16
+ };
9
17
  const getDisplayServer = () => {
10
18
  const sessionType = (process.env.XDG_SESSION_TYPE || '').toLowerCase();
11
19
  return sessionType || (process.env.WAYLAND_DISPLAY ? 'wayland' : process.env.DISPLAY ? 'x11' : '');
@@ -31,6 +39,7 @@ const osInfo = async () => {
31
39
  codename: '',
32
40
  codepage: (0, codepage_1.getCodepage)(),
33
41
  uefi: uefi || null,
42
+ lastUpdate: await getLastUpdate(),
34
43
  displayServer: getDisplayServer()
35
44
  };
36
45
  return defaults;
@@ -0,0 +1,8 @@
1
+ type LayerCandidate = {
2
+ name: string;
3
+ any?: string[];
4
+ all?: string[][];
5
+ };
6
+ export declare const detectLayers: (candidates: LayerCandidate[]) => Promise<string[]>;
7
+ export declare const hwAcceleration: () => Promise<string[]>;
8
+ export {};
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.hwAcceleration = exports.detectLayers = void 0;
4
+ const const_1 = require("./const");
5
+ const files_1 = require("./files");
6
+ const join = (paths, files, separator) => {
7
+ const result = [];
8
+ paths.forEach((path) => {
9
+ files.forEach((file) => {
10
+ result.push(`${path}${separator}${file}`);
11
+ });
12
+ });
13
+ return result;
14
+ };
15
+ const anyExists = async (files) => (await Promise.all(files.map((file) => (0, files_1.fileExists)(file)))).includes(true);
16
+ const detectLayers = async (candidates) => {
17
+ const detected = await Promise.all(candidates.map(async (candidate) => {
18
+ if (candidate.all) {
19
+ const groups = await Promise.all(candidate.all.map((group) => anyExists(group)));
20
+ return !groups.includes(false) ? candidate.name : '';
21
+ }
22
+ return candidate.any && (await anyExists(candidate.any)) ? candidate.name : '';
23
+ }));
24
+ return detected.filter(Boolean);
25
+ };
26
+ exports.detectLayers = detectLayers;
27
+ const envPaths = (value, separator = ':') => (value || '').split(separator).filter(Boolean);
28
+ const linuxCandidates = () => {
29
+ const paths = [
30
+ ...envPaths(process.env.LD_LIBRARY_PATH),
31
+ '/usr/lib',
32
+ '/usr/lib64',
33
+ '/lib',
34
+ '/usr/lib/x86_64-linux-gnu',
35
+ '/usr/lib/aarch64-linux-gnu',
36
+ '/usr/local/lib',
37
+ '/usr/local/cuda/lib64',
38
+ '/opt/rocm/lib',
39
+ '/opt/intel/oneapi/lib'
40
+ ];
41
+ const lib = (files) => join(paths, files, '/');
42
+ return [
43
+ { name: 'cuda', all: [lib(['libnvidia-ml.so', 'libnvidia-ml.so.1']), lib(['libcudart.so', 'libcudart.so.11', 'libcudart.so.12', 'libcudart.so.13'])] },
44
+ { name: 'rocm', any: lib(['libamdhip64.so', 'librocm_smi64.so']) },
45
+ { name: 'oneapi', any: lib(['libze_loader.so', 'libze_loader.so.1']) },
46
+ { name: 'vulkan', any: lib(['libvulkan.so', 'libvulkan.so.1']) },
47
+ { name: 'opencl', any: lib(['libOpenCL.so', 'libOpenCL.so.1']) }
48
+ ];
49
+ };
50
+ const windowsCandidates = () => {
51
+ const system = [`${const_1.WINDIR}\\System32`, `${const_1.WINDIR}\\SysWOW64`];
52
+ const cudaPath = process.env.CUDA_PATH ? [`${process.env.CUDA_PATH}\\bin`] : [];
53
+ const vendorPaths = envPaths(process.env.PATH, ';').filter((path) => /cuda|nvidia|vulkan|oneapi/i.test(path));
54
+ const paths = [...system, ...cudaPath, ...vendorPaths];
55
+ const lib = (files) => join(paths, files, '\\');
56
+ return [
57
+ { name: 'cuda', all: [lib(['nvml.dll']), lib(['cudart64_11.dll', 'cudart64_12.dll', 'cudart64_13.dll'])] },
58
+ { name: 'oneapi', any: lib(['ze_loader.dll']) },
59
+ { name: 'vulkan', any: lib(['vulkan-1.dll']) },
60
+ { name: 'opencl', any: lib(['OpenCL.dll']) },
61
+ { name: 'dx12', any: join(system, ['d3d12.dll'], '\\') },
62
+ { name: 'directml', any: join(system, ['DirectML.dll'], '\\') }
63
+ ];
64
+ };
65
+ const darwinCandidates = () => {
66
+ const paths = ['/usr/lib', '/usr/local/lib', '/opt/homebrew/lib'];
67
+ const lib = (files) => join(paths, files, '/');
68
+ return [
69
+ { name: 'metal', any: ['/System/Library/Frameworks/Metal.framework'] },
70
+ { name: 'vulkan', any: lib(['libvulkan.dylib', 'libvulkan.1.dylib', 'libMoltenVK.dylib']) },
71
+ { name: 'opencl', any: ['/System/Library/Frameworks/OpenCL.framework', ...lib(['libOpenCL.dylib'])] }
72
+ ];
73
+ };
74
+ const hwAcceleration = async () => {
75
+ switch (true) {
76
+ case const_1.LINUX || const_1.FREEBSD || const_1.NETBSD || const_1.OPENBSD:
77
+ return (0, exports.detectLayers)(linuxCandidates());
78
+ case const_1.DARWIN:
79
+ return (0, exports.detectLayers)(darwinCandidates());
80
+ case const_1.WINDOWS:
81
+ return (0, exports.detectLayers)(windowsCandidates());
82
+ default:
83
+ return [];
84
+ }
85
+ };
86
+ exports.hwAcceleration = hwAcceleration;
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.initNetworkSpeed = exports.initPciData = exports.initNpuData = exports.initNetworkInterface = exports.initProcesses = exports.initDisplay = exports.initDiskIo = exports.initFsStats = exports.initFsBlockDevice = exports.initFsOpenFiles = exports.initSystem = exports.initBios = exports.initBaseboard = exports.initChassis = exports.initUUID = exports.initOsInfo = exports.initMemData = exports.initCheckSite = exports.initCpuTemperature = exports.initCpuCacheResult = exports.initCpuResult = exports.initUsbResult = exports.initAudioResult = exports.initBatteryResult = void 0;
4
4
  const node_os_1 = require("node:os");
5
+ const acceleration_1 = require("./acceleration");
5
6
  const const_1 = require("./const");
6
7
  const host_1 = require("./host");
7
8
  exports.initBatteryResult = {
@@ -121,7 +122,10 @@ const initOsInfo = async () => {
121
122
  servicepack: '',
122
123
  uefi: false,
123
124
  installDate: null,
124
- displayServer: ''
125
+ lastUpdate: null,
126
+ displayServer: '',
127
+ awake: true,
128
+ hwAcceleration: await (0, acceleration_1.hwAcceleration)()
125
129
  };
126
130
  };
127
131
  exports.initOsInfo = initOsInfo;
@@ -178,6 +182,7 @@ exports.initFsBlockDevice = {
178
182
  size: 0,
179
183
  physical: 'HDD',
180
184
  uuid: '',
185
+ guid: '',
181
186
  label: '',
182
187
  model: '',
183
188
  serial: '',
@@ -1 +1,6 @@
1
1
  export declare const checkWebsite: (url: string, timeout?: number) => Promise<unknown>;
2
+ export declare const publicIp: (timeout?: number) => Promise<{
3
+ ip4: string;
4
+ ip6: string;
5
+ ms: number;
6
+ }>;
@@ -3,9 +3,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.checkWebsite = void 0;
6
+ exports.publicIp = exports.checkWebsite = void 0;
7
+ const dns_1 = require("dns");
7
8
  const http_1 = __importDefault(require("http"));
8
9
  const https_1 = __importDefault(require("https"));
10
+ const net_1 = require("net");
9
11
  const checkWebsite = (url, timeout = 5000) => {
10
12
  const client = url.startsWith('https:') || url.indexOf(':443/') > 0 || url.indexOf(':8443/') > 0 ? https_1.default : http_1.default;
11
13
  const t = Date.now();
@@ -45,3 +47,46 @@ const checkWebsite = (url, timeout = 5000) => {
45
47
  });
46
48
  };
47
49
  exports.checkWebsite = checkWebsite;
50
+ const dnsPublicIp = (family, timeout) => new Promise((resolve) => {
51
+ const resolver = new dns_1.Resolver({ timeout, tries: 1 });
52
+ try {
53
+ resolver.setServers([family === 4 ? '208.67.222.222' : '2620:119:35::35']);
54
+ }
55
+ catch {
56
+ return resolve('');
57
+ }
58
+ const done = (err, addresses) => resolve(!err && addresses?.length ? addresses[0] : '');
59
+ if (family === 4) {
60
+ resolver.resolve4('myip.opendns.com', done);
61
+ }
62
+ else {
63
+ resolver.resolve6('myip.opendns.com', done);
64
+ }
65
+ });
66
+ const webPublicIp = (family, timeout) => new Promise((resolve) => {
67
+ const request = https_1.default
68
+ .get(family === 4 ? 'https://api.ipify.org' : 'https://api6.ipify.org', { family }, (res) => {
69
+ let body = '';
70
+ res.on('data', (chunk) => {
71
+ body += chunk;
72
+ if (body.length > 64) {
73
+ request.destroy();
74
+ resolve('');
75
+ }
76
+ });
77
+ res.on('end', () => resolve(res.statusCode === 200 ? body.trim() : ''));
78
+ })
79
+ .on('error', () => resolve(''))
80
+ .setTimeout(timeout, () => {
81
+ request.destroy();
82
+ resolve('');
83
+ });
84
+ });
85
+ const publicIp = async (timeout = 5000) => {
86
+ const t = Date.now();
87
+ const valid = (family, ip) => ((family === 4 ? (0, net_1.isIPv4)(ip) : (0, net_1.isIPv6)(ip)) ? ip : '');
88
+ const lookup = async (family) => valid(family, await dnsPublicIp(family, timeout)) || valid(family, await webPublicIp(family, timeout));
89
+ const [ip4, ip6] = await Promise.all([lookup(4), lookup(6)]);
90
+ return { ip4, ip6, ms: Date.now() - t };
91
+ };
92
+ exports.publicIp = publicIp;
@@ -1,4 +1,4 @@
1
- import { CpuBrandObject } from './types';
1
+ import type { CpuBrandObject } from './types';
2
2
  export declare const audioTypeLabel: (type: string, input?: boolean, output?: boolean) => "" | "Speaker" | "Microphone" | "Phone" | "Headset" | "Controller" | "Line Out" | "Digital Out" | "Digital Signal Processor" | "Sound Driver";
3
3
  export declare const audioDarwinChannelLabel: (str: string) => "" | "HDMI" | "Built-In" | "Audio-Jack" | "Display-Port" | "USB" | "PCIe";
4
4
  export declare const audioWindowsStatus: (statusInfo: number | string) => string;