systeminformation 5.33.3 → 6.0.0-beta.0

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 (494) hide show
  1. package/README.md +873 -957
  2. package/dist/audio.d.ts +1 -0
  3. package/dist/audio.js +18 -0
  4. package/dist/baseboard.d.ts +1 -0
  5. package/dist/baseboard.js +17 -0
  6. package/dist/battery.d.ts +1 -0
  7. package/dist/battery.js +19 -0
  8. package/dist/bios.d.ts +1 -0
  9. package/dist/bios.js +17 -0
  10. package/dist/block-devices.d.ts +1 -0
  11. package/dist/block-devices.js +17 -0
  12. package/dist/bluetooth.d.ts +1 -0
  13. package/dist/bluetooth.js +17 -0
  14. package/dist/bsd/battery.d.ts +2 -0
  15. package/dist/bsd/battery.js +27 -0
  16. package/dist/bsd/cpu-cache.d.ts +1 -0
  17. package/dist/bsd/cpu-cache.js +37 -0
  18. package/dist/bsd/cpu-flags.d.ts +1 -0
  19. package/dist/bsd/cpu-flags.js +28 -0
  20. package/dist/bsd/cpu-temperature.d.ts +1 -0
  21. package/dist/bsd/cpu-temperature.js +29 -0
  22. package/dist/bsd/cpu.d.ts +1 -0
  23. package/dist/bsd/cpu.js +98 -0
  24. package/dist/bsd/index.d.ts +38 -0
  25. package/dist/bsd/index.js +85 -0
  26. package/dist/bsd/mem.d.ts +1 -0
  27. package/dist/bsd/mem.js +37 -0
  28. package/dist/bsd/network-stats.d.ts +2 -0
  29. package/dist/bsd/network-stats.js +92 -0
  30. package/dist/bsd/os-info.d.ts +21 -0
  31. package/dist/bsd/os-info.js +38 -0
  32. package/dist/bsd/uuid.d.ts +2 -0
  33. package/dist/bsd/uuid.js +30 -0
  34. package/dist/camera.d.ts +1 -0
  35. package/dist/camera.js +17 -0
  36. package/dist/chassis.d.ts +1 -0
  37. package/dist/chassis.js +17 -0
  38. package/dist/cli.d.ts +2 -0
  39. package/dist/cli.js +107 -0
  40. package/dist/common/codepage.d.ts +1 -0
  41. package/dist/common/codepage.js +43 -0
  42. package/dist/common/const.d.ts +25 -0
  43. package/dist/common/const.js +26 -0
  44. package/dist/common/cpu.d.ts +2 -0
  45. package/dist/common/cpu.js +12 -0
  46. package/dist/common/darwin.d.ts +6 -0
  47. package/dist/common/darwin.js +266 -0
  48. package/dist/common/datetime.d.ts +9 -0
  49. package/dist/common/datetime.js +161 -0
  50. package/dist/common/defaults.d.ts +25 -0
  51. package/dist/common/defaults.js +299 -0
  52. package/dist/common/exec.d.ts +10 -0
  53. package/dist/common/exec.js +69 -0
  54. package/dist/common/files.d.ts +2 -0
  55. package/dist/common/files.js +39 -0
  56. package/dist/common/filesys.d.ts +11 -0
  57. package/dist/common/filesys.js +282 -0
  58. package/dist/common/host.d.ts +2 -0
  59. package/dist/common/host.js +67 -0
  60. package/dist/common/index.d.ts +12 -0
  61. package/dist/common/index.js +146 -0
  62. package/dist/common/internet.d.ts +1 -0
  63. package/dist/common/internet.js +47 -0
  64. package/dist/common/mappings.d.ts +55 -0
  65. package/dist/common/mappings.js +4133 -0
  66. package/dist/common/network.d.ts +8 -0
  67. package/dist/common/network.js +162 -0
  68. package/dist/common/nvidia.d.ts +22 -0
  69. package/dist/common/nvidia.js +159 -0
  70. package/dist/common/parse.d.ts +13 -0
  71. package/dist/common/parse.js +157 -0
  72. package/dist/common/raspberry.d.ts +5 -0
  73. package/dist/common/raspberry.js +277 -0
  74. package/dist/common/security.d.ts +31 -0
  75. package/dist/common/security.js +241 -0
  76. package/dist/common/types.d.ts +992 -0
  77. package/dist/common/types.js +2 -0
  78. package/dist/common/windows.d.ts +58 -0
  79. package/dist/common/windows.js +292 -0
  80. package/dist/cpu-cache.d.ts +1 -0
  81. package/dist/cpu-cache.js +19 -0
  82. package/dist/cpu-current-load.d.ts +2 -0
  83. package/dist/cpu-current-load.js +249 -0
  84. package/dist/cpu-current-speed.d.ts +3 -0
  85. package/dist/cpu-current-speed.js +84 -0
  86. package/dist/cpu-flags.d.ts +1 -0
  87. package/dist/cpu-flags.js +19 -0
  88. package/dist/cpu-full-load.d.ts +1 -0
  89. package/dist/cpu-full-load.js +30 -0
  90. package/dist/cpu-temperature.d.ts +1 -0
  91. package/dist/cpu-temperature.js +19 -0
  92. package/dist/cpu.d.ts +1 -0
  93. package/dist/cpu.js +19 -0
  94. package/dist/darwin/audio.d.ts +2 -0
  95. package/dist/darwin/audio.js +46 -0
  96. package/dist/darwin/baseboard.d.ts +1 -0
  97. package/dist/darwin/baseboard.js +48 -0
  98. package/dist/darwin/battery.d.ts +2 -0
  99. package/dist/darwin/battery.js +65 -0
  100. package/dist/darwin/bios.d.ts +1 -0
  101. package/dist/darwin/bios.js +45 -0
  102. package/dist/darwin/block-devices.d.ts +2 -0
  103. package/dist/darwin/block-devices.js +101 -0
  104. package/dist/darwin/bluetooth.d.ts +3 -0
  105. package/dist/darwin/bluetooth.js +84 -0
  106. package/dist/darwin/camera.d.ts +2 -0
  107. package/dist/darwin/camera.js +55 -0
  108. package/dist/darwin/chassis.d.ts +2 -0
  109. package/dist/darwin/chassis.js +32 -0
  110. package/dist/darwin/cpu-cache.d.ts +2 -0
  111. package/dist/darwin/cpu-cache.js +29 -0
  112. package/dist/darwin/cpu-flags.d.ts +1 -0
  113. package/dist/darwin/cpu-flags.js +16 -0
  114. package/dist/darwin/cpu-temperature.d.ts +1 -0
  115. package/dist/darwin/cpu-temperature.js +44 -0
  116. package/dist/darwin/cpu.d.ts +1 -0
  117. package/dist/darwin/cpu.js +69 -0
  118. package/dist/darwin/disk-layout.d.ts +2 -0
  119. package/dist/darwin/disk-layout.js +231 -0
  120. package/dist/darwin/disks-io.d.ts +2 -0
  121. package/dist/darwin/disks-io.js +56 -0
  122. package/dist/darwin/displays.d.ts +2 -0
  123. package/dist/darwin/displays.js +98 -0
  124. package/dist/darwin/fs-open-files.d.ts +2 -0
  125. package/dist/darwin/fs-open-files.js +27 -0
  126. package/dist/darwin/fs-stats.d.ts +2 -0
  127. package/dist/darwin/fs-stats.js +47 -0
  128. package/dist/darwin/gpu.d.ts +2 -0
  129. package/dist/darwin/gpu.js +55 -0
  130. package/dist/darwin/index.d.ts +56 -0
  131. package/dist/darwin/index.js +122 -0
  132. package/dist/darwin/keyboard.d.ts +2 -0
  133. package/dist/darwin/keyboard.js +73 -0
  134. package/dist/darwin/mem-layout.d.ts +2 -0
  135. package/dist/darwin/mem-layout.js +60 -0
  136. package/dist/darwin/mem.d.ts +2 -0
  137. package/dist/darwin/mem.js +50 -0
  138. package/dist/darwin/mouse.d.ts +2 -0
  139. package/dist/darwin/mouse.js +78 -0
  140. package/dist/darwin/network-connections.d.ts +2 -0
  141. package/dist/darwin/network-connections.js +98 -0
  142. package/dist/darwin/network-gateway-default.d.ts +1 -0
  143. package/dist/darwin/network-gateway-default.js +26 -0
  144. package/dist/darwin/network-interface-default.d.ts +2 -0
  145. package/dist/darwin/network-interface-default.js +41 -0
  146. package/dist/darwin/network-interfaces.d.ts +2 -0
  147. package/dist/darwin/network-interfaces.js +205 -0
  148. package/dist/darwin/network-stats.d.ts +2 -0
  149. package/dist/darwin/network-stats.js +86 -0
  150. package/dist/darwin/npm.d.ts +1 -0
  151. package/dist/darwin/npm.js +5 -0
  152. package/dist/darwin/npu.d.ts +2 -0
  153. package/dist/darwin/npu.js +41 -0
  154. package/dist/darwin/os-info.d.ts +1 -0
  155. package/dist/darwin/os-info.js +110 -0
  156. package/dist/darwin/pci.d.ts +2 -0
  157. package/dist/darwin/pci.js +37 -0
  158. package/dist/darwin/printer.d.ts +2 -0
  159. package/dist/darwin/printer.js +45 -0
  160. package/dist/darwin/software.d.ts +2 -0
  161. package/dist/darwin/software.js +39 -0
  162. package/dist/darwin/system.d.ts +1 -0
  163. package/dist/darwin/system.js +29 -0
  164. package/dist/darwin/thunderbolt.d.ts +1 -0
  165. package/dist/darwin/thunderbolt.js +53 -0
  166. package/dist/darwin/usb.d.ts +3 -0
  167. package/dist/darwin/usb.js +69 -0
  168. package/dist/darwin/users.d.ts +2 -0
  169. package/dist/darwin/users.js +13 -0
  170. package/dist/darwin/uuid.d.ts +2 -0
  171. package/dist/darwin/uuid.js +39 -0
  172. package/dist/darwin/wifi-connections.d.ts +2 -0
  173. package/dist/darwin/wifi-connections.js +60 -0
  174. package/dist/darwin/wifi-interfaces.d.ts +2 -0
  175. package/dist/darwin/wifi-interfaces.js +27 -0
  176. package/dist/darwin/wifi-networks.d.ts +2 -0
  177. package/dist/darwin/wifi-networks.js +61 -0
  178. package/dist/disk-layout.d.ts +1 -0
  179. package/dist/disk-layout.js +17 -0
  180. package/dist/disks-io.d.ts +1 -0
  181. package/dist/disks-io.js +17 -0
  182. package/dist/displays.d.ts +1 -0
  183. package/dist/displays.js +17 -0
  184. package/dist/docker-socket.d.ts +11 -0
  185. package/dist/docker-socket.js +113 -0
  186. package/dist/docker.d.ts +102 -0
  187. package/dist/docker.js +532 -0
  188. package/dist/fs-open-files.d.ts +1 -0
  189. package/dist/fs-open-files.js +17 -0
  190. package/dist/fs-size.d.ts +1 -0
  191. package/dist/fs-size.js +23 -0
  192. package/dist/fs-stats.d.ts +1 -0
  193. package/dist/fs-stats.js +17 -0
  194. package/dist/get-data.d.ts +110 -0
  195. package/dist/get-data.js +151 -0
  196. package/dist/get.d.ts +5 -0
  197. package/dist/get.js +117 -0
  198. package/dist/gpu.d.ts +1 -0
  199. package/dist/gpu.js +17 -0
  200. package/dist/index.d.ts +59 -0
  201. package/dist/index.js +130 -0
  202. package/dist/inet-checksite.d.ts +1 -0
  203. package/dist/inet-checksite.js +11 -0
  204. package/dist/inet-latency.d.ts +1 -0
  205. package/dist/inet-latency.js +17 -0
  206. package/dist/keyboard.d.ts +1 -0
  207. package/dist/keyboard.js +17 -0
  208. package/dist/linux/audio.d.ts +2 -0
  209. package/dist/linux/audio.js +67 -0
  210. package/dist/linux/baseboard.d.ts +1 -0
  211. package/dist/linux/baseboard.js +81 -0
  212. package/dist/linux/battery.d.ts +2 -0
  213. package/dist/linux/battery.js +88 -0
  214. package/dist/linux/bios.d.ts +2 -0
  215. package/dist/linux/bios.js +55 -0
  216. package/dist/linux/block-devices.d.ts +2 -0
  217. package/dist/linux/block-devices.js +30 -0
  218. package/dist/linux/bluetooth.d.ts +2 -0
  219. package/dist/linux/bluetooth.js +86 -0
  220. package/dist/linux/camera.d.ts +2 -0
  221. package/dist/linux/camera.js +63 -0
  222. package/dist/linux/chassis.d.ts +1 -0
  223. package/dist/linux/chassis.js +41 -0
  224. package/dist/linux/cpu-cache.d.ts +1 -0
  225. package/dist/linux/cpu-cache.js +35 -0
  226. package/dist/linux/cpu-flags.d.ts +1 -0
  227. package/dist/linux/cpu-flags.js +33 -0
  228. package/dist/linux/cpu-temperature.d.ts +1 -0
  229. package/dist/linux/cpu-temperature.js +179 -0
  230. package/dist/linux/cpu.d.ts +1 -0
  231. package/dist/linux/cpu.js +135 -0
  232. package/dist/linux/disk-layout.d.ts +2 -0
  233. package/dist/linux/disk-layout.js +151 -0
  234. package/dist/linux/disks-io.d.ts +2 -0
  235. package/dist/linux/disks-io.js +58 -0
  236. package/dist/linux/displays.d.ts +2 -0
  237. package/dist/linux/displays.js +193 -0
  238. package/dist/linux/fs-open-files.d.ts +2 -0
  239. package/dist/linux/fs-open-files.js +44 -0
  240. package/dist/linux/fs-size.d.ts +2 -0
  241. package/dist/linux/fs-size.js +157 -0
  242. package/dist/linux/fs-stats.d.ts +2 -0
  243. package/dist/linux/fs-stats.js +65 -0
  244. package/dist/linux/gpu.d.ts +2 -0
  245. package/dist/linux/gpu.js +273 -0
  246. package/dist/linux/index.d.ts +56 -0
  247. package/dist/linux/index.js +122 -0
  248. package/dist/linux/inet-latency.d.ts +1 -0
  249. package/dist/linux/inet-latency.js +39 -0
  250. package/dist/linux/keyboard.d.ts +2 -0
  251. package/dist/linux/keyboard.js +61 -0
  252. package/dist/linux/mem-layout.d.ts +2 -0
  253. package/dist/linux/mem-layout.js +112 -0
  254. package/dist/linux/mem.d.ts +2 -0
  255. package/dist/linux/mem.js +61 -0
  256. package/dist/linux/mouse.d.ts +2 -0
  257. package/dist/linux/mouse.js +73 -0
  258. package/dist/linux/network-connections.d.ts +2 -0
  259. package/dist/linux/network-connections.js +114 -0
  260. package/dist/linux/network-gateway-default.d.ts +1 -0
  261. package/dist/linux/network-gateway-default.js +22 -0
  262. package/dist/linux/network-interface-default.d.ts +2 -0
  263. package/dist/linux/network-interface-default.js +46 -0
  264. package/dist/linux/network-interfaces.d.ts +3 -0
  265. package/dist/linux/network-interfaces.js +353 -0
  266. package/dist/linux/network-stats.d.ts +2 -0
  267. package/dist/linux/network-stats.js +99 -0
  268. package/dist/linux/npm.d.ts +1 -0
  269. package/dist/linux/npm.js +5 -0
  270. package/dist/linux/npu.d.ts +2 -0
  271. package/dist/linux/npu.js +77 -0
  272. package/dist/linux/os-info.d.ts +1 -0
  273. package/dist/linux/os-info.js +104 -0
  274. package/dist/linux/pci.d.ts +2 -0
  275. package/dist/linux/pci.js +56 -0
  276. package/dist/linux/printer.d.ts +2 -0
  277. package/dist/linux/printer.js +80 -0
  278. package/dist/linux/process-load.d.ts +2 -0
  279. package/dist/linux/process-load.js +164 -0
  280. package/dist/linux/processes.d.ts +2 -0
  281. package/dist/linux/processes.js +358 -0
  282. package/dist/linux/services.d.ts +2 -0
  283. package/dist/linux/services.js +222 -0
  284. package/dist/linux/software.d.ts +2 -0
  285. package/dist/linux/software.js +110 -0
  286. package/dist/linux/system.d.ts +1 -0
  287. package/dist/linux/system.js +186 -0
  288. package/dist/linux/thunderbolt.d.ts +2 -0
  289. package/dist/linux/thunderbolt.js +51 -0
  290. package/dist/linux/time.d.ts +6 -0
  291. package/dist/linux/time.js +28 -0
  292. package/dist/linux/usb.d.ts +2 -0
  293. package/dist/linux/usb.js +62 -0
  294. package/dist/linux/users.d.ts +2 -0
  295. package/dist/linux/users.js +102 -0
  296. package/dist/linux/uuid.d.ts +2 -0
  297. package/dist/linux/uuid.js +44 -0
  298. package/dist/linux/wifi-connections.d.ts +2 -0
  299. package/dist/linux/wifi-connections.js +196 -0
  300. package/dist/linux/wifi-interfaces.d.ts +2 -0
  301. package/dist/linux/wifi-interfaces.js +96 -0
  302. package/dist/linux/wifi-networks.d.ts +2 -0
  303. package/dist/linux/wifi-networks.js +176 -0
  304. package/dist/mem-layout.d.ts +1 -0
  305. package/dist/mem-layout.js +17 -0
  306. package/dist/mem.d.ts +1 -0
  307. package/dist/mem.js +19 -0
  308. package/dist/mouse.d.ts +1 -0
  309. package/dist/mouse.js +17 -0
  310. package/dist/network-connections.d.ts +1 -0
  311. package/dist/network-connections.js +17 -0
  312. package/dist/network-gateway-default.d.ts +1 -0
  313. package/dist/network-gateway-default.js +17 -0
  314. package/dist/network-interface-default.d.ts +1 -0
  315. package/dist/network-interface-default.js +17 -0
  316. package/dist/network-interfaces.d.ts +1 -0
  317. package/dist/network-interfaces.js +18 -0
  318. package/dist/network-stats.d.ts +1 -0
  319. package/dist/network-stats.js +19 -0
  320. package/dist/npm.d.ts +2 -0
  321. package/dist/npm.js +22 -0
  322. package/dist/npu.d.ts +1 -0
  323. package/dist/npu.js +17 -0
  324. package/dist/observe.d.ts +5 -0
  325. package/dist/observe.js +16 -0
  326. package/dist/os-info.d.ts +1 -0
  327. package/dist/os-info.js +21 -0
  328. package/dist/pci.d.ts +1 -0
  329. package/dist/pci.js +17 -0
  330. package/dist/printer.d.ts +1 -0
  331. package/dist/printer.js +17 -0
  332. package/dist/process-load.d.ts +1 -0
  333. package/dist/process-load.js +15 -0
  334. package/dist/processes.d.ts +1 -0
  335. package/dist/processes.js +15 -0
  336. package/dist/services.d.ts +1 -0
  337. package/dist/services.js +15 -0
  338. package/dist/shell.d.ts +1 -0
  339. package/dist/shell.js +16 -0
  340. package/dist/software.d.ts +1 -0
  341. package/dist/software.js +17 -0
  342. package/dist/sun/index.d.ts +17 -0
  343. package/dist/sun/index.js +43 -0
  344. package/dist/sun/inet-latency.d.ts +1 -0
  345. package/dist/sun/inet-latency.js +30 -0
  346. package/dist/sun/os-info.d.ts +1 -0
  347. package/dist/sun/os-info.js +26 -0
  348. package/dist/sun/users.d.ts +2 -0
  349. package/dist/sun/users.js +13 -0
  350. package/dist/system.d.ts +1 -0
  351. package/dist/system.js +17 -0
  352. package/dist/thunderbolt.d.ts +1 -0
  353. package/dist/thunderbolt.js +17 -0
  354. package/dist/time.d.ts +6 -0
  355. package/dist/time.js +28 -0
  356. package/dist/usb.d.ts +1 -0
  357. package/dist/usb.js +17 -0
  358. package/dist/users.d.ts +1 -0
  359. package/dist/users.js +21 -0
  360. package/dist/uuid.d.ts +1 -0
  361. package/dist/uuid.js +19 -0
  362. package/dist/version.d.ts +1 -0
  363. package/dist/version.js +16 -0
  364. package/dist/versions.d.ts +2 -0
  365. package/dist/versions.js +1122 -0
  366. package/dist/virtualbox.d.ts +2 -0
  367. package/dist/virtualbox.js +89 -0
  368. package/dist/wifi-connections.d.ts +1 -0
  369. package/dist/wifi-connections.js +17 -0
  370. package/dist/wifi-interfaces.d.ts +1 -0
  371. package/dist/wifi-interfaces.js +17 -0
  372. package/dist/wifi-networks.d.ts +1 -0
  373. package/dist/wifi-networks.js +17 -0
  374. package/dist/windows/audio.d.ts +2 -0
  375. package/dist/windows/audio.js +23 -0
  376. package/dist/windows/baseboard.d.ts +1 -0
  377. package/dist/windows/baseboard.js +35 -0
  378. package/dist/windows/battery.d.ts +1 -0
  379. package/dist/windows/battery.js +81 -0
  380. package/dist/windows/bios.d.ts +1 -0
  381. package/dist/windows/bios.js +37 -0
  382. package/dist/windows/block-devices.d.ts +2 -0
  383. package/dist/windows/block-devices.js +48 -0
  384. package/dist/windows/bluetooth.d.ts +2 -0
  385. package/dist/windows/bluetooth.js +31 -0
  386. package/dist/windows/camera.d.ts +2 -0
  387. package/dist/windows/camera.js +47 -0
  388. package/dist/windows/chassis.d.ts +1 -0
  389. package/dist/windows/chassis.js +29 -0
  390. package/dist/windows/cpu-cache.d.ts +2 -0
  391. package/dist/windows/cpu-cache.js +59 -0
  392. package/dist/windows/cpu-flags.d.ts +1 -0
  393. package/dist/windows/cpu-flags.js +61 -0
  394. package/dist/windows/cpu-temperature.d.ts +1 -0
  395. package/dist/windows/cpu-temperature.js +32 -0
  396. package/dist/windows/cpu.d.ts +1 -0
  397. package/dist/windows/cpu.js +96 -0
  398. package/dist/windows/disk-layout.d.ts +2 -0
  399. package/dist/windows/disk-layout.js +112 -0
  400. package/dist/windows/disks-io.d.ts +2 -0
  401. package/dist/windows/disks-io.js +43 -0
  402. package/dist/windows/displays.d.ts +2 -0
  403. package/dist/windows/displays.js +213 -0
  404. package/dist/windows/fs-open-files.d.ts +2 -0
  405. package/dist/windows/fs-open-files.js +22 -0
  406. package/dist/windows/fs-size.d.ts +2 -0
  407. package/dist/windows/fs-size.js +47 -0
  408. package/dist/windows/fs-stats.d.ts +2 -0
  409. package/dist/windows/fs-stats.js +37 -0
  410. package/dist/windows/gpu.d.ts +2 -0
  411. package/dist/windows/gpu.js +128 -0
  412. package/dist/windows/index.d.ts +56 -0
  413. package/dist/windows/index.js +122 -0
  414. package/dist/windows/inet-latency.d.ts +1 -0
  415. package/dist/windows/inet-latency.js +34 -0
  416. package/dist/windows/keyboard.d.ts +2 -0
  417. package/dist/windows/keyboard.js +47 -0
  418. package/dist/windows/mem-layout.d.ts +2 -0
  419. package/dist/windows/mem-layout.js +39 -0
  420. package/dist/windows/mem.d.ts +2 -0
  421. package/dist/windows/mem.js +33 -0
  422. package/dist/windows/mouse.d.ts +2 -0
  423. package/dist/windows/mouse.js +64 -0
  424. package/dist/windows/network-connections.d.ts +2 -0
  425. package/dist/windows/network-connections.js +93 -0
  426. package/dist/windows/network-gateway-default.d.ts +1 -0
  427. package/dist/windows/network-gateway-default.js +36 -0
  428. package/dist/windows/network-interface-default.d.ts +2 -0
  429. package/dist/windows/network-interface-default.js +56 -0
  430. package/dist/windows/network-interfaces.d.ts +2 -0
  431. package/dist/windows/network-interfaces.js +346 -0
  432. package/dist/windows/network-stats.d.ts +2 -0
  433. package/dist/windows/network-stats.js +135 -0
  434. package/dist/windows/npm.d.ts +1 -0
  435. package/dist/windows/npm.js +5 -0
  436. package/dist/windows/npu.d.ts +2 -0
  437. package/dist/windows/npu.js +29 -0
  438. package/dist/windows/os-info.d.ts +1 -0
  439. package/dist/windows/os-info.js +65 -0
  440. package/dist/windows/pci.d.ts +2 -0
  441. package/dist/windows/pci.js +33 -0
  442. package/dist/windows/printer.d.ts +2 -0
  443. package/dist/windows/printer.js +36 -0
  444. package/dist/windows/process-load.d.ts +2 -0
  445. package/dist/windows/process-load.js +121 -0
  446. package/dist/windows/processes.d.ts +9 -0
  447. package/dist/windows/processes.js +139 -0
  448. package/dist/windows/services.d.ts +2 -0
  449. package/dist/windows/services.js +83 -0
  450. package/dist/windows/shell.d.ts +1 -0
  451. package/dist/windows/shell.js +19 -0
  452. package/dist/windows/software.d.ts +2 -0
  453. package/dist/windows/software.js +53 -0
  454. package/dist/windows/system.d.ts +1 -0
  455. package/dist/windows/system.js +98 -0
  456. package/dist/windows/thunderbolt.d.ts +2 -0
  457. package/dist/windows/thunderbolt.js +34 -0
  458. package/dist/windows/usb.d.ts +2 -0
  459. package/dist/windows/usb.js +37 -0
  460. package/dist/windows/users.d.ts +2 -0
  461. package/dist/windows/users.js +151 -0
  462. package/dist/windows/uuid.d.ts +2 -0
  463. package/dist/windows/uuid.js +28 -0
  464. package/dist/windows/wifi-connections.d.ts +2 -0
  465. package/dist/windows/wifi-connections.js +56 -0
  466. package/dist/windows/wifi-interfaces.d.ts +2 -0
  467. package/dist/windows/wifi-interfaces.js +45 -0
  468. package/dist/windows/wifi-networks.d.ts +2 -0
  469. package/dist/windows/wifi-networks.js +50 -0
  470. package/package.json +78 -12
  471. package/lib/audio.js +0 -277
  472. package/lib/battery.js +0 -334
  473. package/lib/bluetooth.js +0 -315
  474. package/lib/bluetoothVendors.js +0 -1138
  475. package/lib/cli.js +0 -100
  476. package/lib/cpu.js +0 -2285
  477. package/lib/docker.js +0 -791
  478. package/lib/dockerSocket.js +0 -117
  479. package/lib/filesystem.js +0 -1832
  480. package/lib/graphics.js +0 -1321
  481. package/lib/index.d.ts +0 -1051
  482. package/lib/index.js +0 -520
  483. package/lib/internet.js +0 -259
  484. package/lib/memory.js +0 -622
  485. package/lib/network.js +0 -2008
  486. package/lib/osinfo.js +0 -1321
  487. package/lib/printer.js +0 -209
  488. package/lib/processes.js +0 -1459
  489. package/lib/system.js +0 -855
  490. package/lib/usb.js +0 -309
  491. package/lib/users.js +0 -412
  492. package/lib/util.js +0 -2824
  493. package/lib/virtualbox.js +0 -116
  494. package/lib/wifi.js +0 -839
package/lib/graphics.js DELETED
@@ -1,1321 +0,0 @@
1
- 'use strict';
2
- // @ts-check
3
- // ==================================================================================
4
- // graphics.js
5
- // ----------------------------------------------------------------------------------
6
- // Description: System Information - library
7
- // for Node.js
8
- // Copyright: (c) 2014 - 2026
9
- // Author: Sebastian Hildebrandt
10
- // ----------------------------------------------------------------------------------
11
- // License: MIT
12
- // ==================================================================================
13
- // 7. Graphics (controller, display)
14
- // ----------------------------------------------------------------------------------
15
-
16
- const fs = require('fs');
17
- const path = require('path');
18
- const exec = require('child_process').exec;
19
- const execSync = require('child_process').execSync;
20
- const util = require('./util');
21
-
22
- const _platform = process.platform;
23
- let _nvidiaSmiPath = '';
24
-
25
- const _linux = _platform === 'linux' || _platform === 'android';
26
- const _darwin = _platform === 'darwin';
27
- const _windows = _platform === 'win32';
28
- const _freebsd = _platform === 'freebsd';
29
- const _openbsd = _platform === 'openbsd';
30
- const _netbsd = _platform === 'netbsd';
31
- const _sunos = _platform === 'sunos';
32
-
33
- let _resolutionX = 0;
34
- let _resolutionY = 0;
35
- let _pixelDepth = 0;
36
- let _refreshRate = 0;
37
-
38
- // EnumDisplaySettings (current mode per \\.\DISPLAYn) - per-display refresh rate (issue #853)
39
- const psCurrentModes =
40
- "Add-Type -AssemblyName System.Windows.Forms; if (-not ('SiDevMode' -as [Type])) { Add-Type -TypeDefinition 'using System;using System.Runtime.InteropServices;[StructLayout(LayoutKind.Sequential,CharSet=CharSet.Ansi)]public struct SIDEVMODE{[MarshalAs(UnmanagedType.ByValTStr,SizeConst=32)]public string dmDeviceName;public short dmSpecVersion;public short dmDriverVersion;public short dmSize;public short dmDriverExtra;public int dmFields;public int dmPositionX;public int dmPositionY;public int dmDisplayOrientation;public int dmDisplayFixedOutput;public short dmColor;public short dmDuplex;public short dmYResolution;public short dmTTOption;public short dmCollate;[MarshalAs(UnmanagedType.ByValTStr,SizeConst=32)]public string dmFormName;public short dmLogPixels;public int dmBitsPerPel;public int dmPelsWidth;public int dmPelsHeight;public int dmDisplayFlags;public int dmDisplayFrequency;public int dmICMMethod;public int dmICMIntent;public int dmMediaType;public int dmDitherType;public int dmReserved1;public int dmReserved2;public int dmPanningWidth;public int dmPanningHeight;}public class SiDevMode{[DllImport(\"user32.dll\",CharSet=CharSet.Ansi)]public static extern bool EnumDisplaySettings(string lpszDeviceName,int iModeNum,ref SIDEVMODE lpDevMode);}' }; [System.Windows.Forms.Screen]::AllScreens | ForEach-Object { $dm = New-Object SIDEVMODE; $dm.dmSize = [System.Runtime.InteropServices.Marshal]::SizeOf($dm); if ([SiDevMode]::EnumDisplaySettings($_.DeviceName, -1, [ref]$dm)) { $_.DeviceName + '|' + $dm.dmDisplayFrequency + '|' + $dm.dmBitsPerPel + '|' + $dm.dmPelsWidth + '|' + $dm.dmPelsHeight } }";
41
-
42
- const videoTypes = {
43
- '-2': 'UNINITIALIZED',
44
- '-1': 'OTHER',
45
- 0: 'HD15',
46
- 1: 'SVIDEO',
47
- 2: 'Composite video',
48
- 3: 'Component video',
49
- 4: 'DVI',
50
- 5: 'HDMI',
51
- 6: 'LVDS',
52
- 8: 'D_JPN',
53
- 9: 'SDI',
54
- 10: 'DP',
55
- 11: 'DP embedded',
56
- 12: 'UDI',
57
- 13: 'UDI embedded',
58
- 14: 'SDTVDONGLE',
59
- 15: 'MIRACAST',
60
- 2147483648: 'INTERNAL',
61
- 4294967295: 'RDP'
62
- };
63
-
64
- function getVendorFromModel(model) {
65
- const manufacturers = [
66
- { pattern: '^LG.+', manufacturer: 'LG' },
67
- { pattern: '^BENQ.+', manufacturer: 'BenQ' },
68
- { pattern: '^ASUS.+', manufacturer: 'Asus' },
69
- { pattern: '^DELL.+', manufacturer: 'Dell' },
70
- { pattern: '^SAMSUNG.+', manufacturer: 'Samsung' },
71
- { pattern: '^VIEWSON.+', manufacturer: 'ViewSonic' },
72
- { pattern: '^SONY.+', manufacturer: 'Sony' },
73
- { pattern: '^ACER.+', manufacturer: 'Acer' },
74
- { pattern: '^AOC.+', manufacturer: 'AOC Monitors' },
75
- { pattern: '^HP.+', manufacturer: 'HP' },
76
- { pattern: '^EIZO.?', manufacturer: 'Eizo' },
77
- { pattern: '^PHILIPS.?', manufacturer: 'Philips' },
78
- { pattern: '^IIYAMA.?', manufacturer: 'Iiyama' },
79
- { pattern: '^SHARP.?', manufacturer: 'Sharp' },
80
- { pattern: '^NEC.?', manufacturer: 'NEC' },
81
- { pattern: '^LENOVO.?', manufacturer: 'Lenovo' },
82
- { pattern: 'COMPAQ.?', manufacturer: 'Compaq' },
83
- { pattern: 'APPLE.?', manufacturer: 'Apple' },
84
- { pattern: 'INTEL.?', manufacturer: 'Intel' },
85
- { pattern: 'AMD.?', manufacturer: 'AMD' },
86
- { pattern: 'NVIDIA.?', manufacturer: 'NVIDIA' }
87
- ];
88
-
89
- let result = '';
90
- if (model) {
91
- model = model.toUpperCase();
92
- manufacturers.forEach((manufacturer) => {
93
- const re = RegExp(manufacturer.pattern);
94
- if (re.test(model)) {
95
- result = manufacturer.manufacturer;
96
- }
97
- });
98
- }
99
- return result;
100
- }
101
-
102
- function getVendorFromId(id) {
103
- const vendors = {
104
- 610: 'Apple',
105
- '1e6d': 'LG',
106
- '10ac': 'DELL',
107
- '4dd9': 'Sony',
108
- '38a3': 'NEC'
109
- };
110
- return vendors[id] || '';
111
- }
112
-
113
- function vendorToId(str) {
114
- let result = '';
115
- str = (str || '').toLowerCase();
116
- if (str.indexOf('apple') >= 0) {
117
- result = '0x05ac';
118
- } else if (str.indexOf('nvidia') >= 0) {
119
- result = '0x10de';
120
- } else if (str.indexOf('intel') >= 0) {
121
- result = '0x8086';
122
- } else if (str.indexOf('ati') >= 0 || str.indexOf('amd') >= 0) {
123
- result = '0x1002';
124
- }
125
-
126
- return result;
127
- }
128
-
129
- function getMetalVersion(id) {
130
- const families = {
131
- spdisplays_mtlgpufamilymac1: 'mac1',
132
- spdisplays_mtlgpufamilymac2: 'mac2',
133
- spdisplays_mtlgpufamilyapple1: 'apple1',
134
- spdisplays_mtlgpufamilyapple2: 'apple2',
135
- spdisplays_mtlgpufamilyapple3: 'apple3',
136
- spdisplays_mtlgpufamilyapple4: 'apple4',
137
- spdisplays_mtlgpufamilyapple5: 'apple5',
138
- spdisplays_mtlgpufamilyapple6: 'apple6',
139
- spdisplays_mtlgpufamilyapple7: 'apple7',
140
- spdisplays_metalfeaturesetfamily11: 'family1_v1',
141
- spdisplays_metalfeaturesetfamily12: 'family1_v2',
142
- spdisplays_metalfeaturesetfamily13: 'family1_v3',
143
- spdisplays_metalfeaturesetfamily14: 'family1_v4',
144
- spdisplays_metalfeaturesetfamily21: 'family2_v1'
145
- };
146
- return families[id] || '';
147
- }
148
-
149
- function graphics(callback) {
150
- function parseLinesDarwin(graphicsArr) {
151
- const res = {
152
- controllers: [],
153
- displays: []
154
- };
155
- try {
156
- graphicsArr.forEach((item) => {
157
- // controllers
158
- const bus = (item.sppci_bus || '').indexOf('builtin') > -1 ? 'Built-In' : (item.sppci_bus || '').indexOf('pcie') > -1 ? 'PCIe' : '';
159
- const vram = (parseInt(item.spdisplays_vram || '', 10) || 0) * ((item.spdisplays_vram || '').indexOf('GB') > -1 ? 1024 : 1);
160
- const vramDyn = (parseInt(item.spdisplays_vram_shared || '', 10) || 0) * ((item.spdisplays_vram_shared || '').indexOf('GB') > -1 ? 1024 : 1);
161
- const metalVersion = getMetalVersion(item.spdisplays_metal || item.spdisplays_metalfamily || '');
162
- res.controllers.push({
163
- vendor: getVendorFromModel(item.spdisplays_vendor || '') || item.spdisplays_vendor || '',
164
- model: item.sppci_model || '',
165
- bus,
166
- vramDynamic: bus === 'Built-In',
167
- vram: vram || vramDyn || null,
168
- deviceId: item['spdisplays_device-id'] || '',
169
- vendorId: item['spdisplays_vendor-id'] || vendorToId((item['spdisplays_vendor'] || '') + (item.sppci_model || '')),
170
- external: item.sppci_device_type === 'spdisplays_egpu',
171
- cores: item['sppci_cores'] || null,
172
- metalVersion
173
- });
174
-
175
- // displays
176
- if (item.spdisplays_ndrvs && item.spdisplays_ndrvs.length) {
177
- item.spdisplays_ndrvs.forEach((displayItem) => {
178
- const connectionType = displayItem['spdisplays_connection_type'] || '';
179
- const currentResolutionParts = (displayItem['_spdisplays_resolution'] || '').split('@');
180
- const currentResolution = currentResolutionParts[0].split('x');
181
- const pixelParts = (displayItem['_spdisplays_pixels'] || '').split('x');
182
- const pixelDepthString = displayItem['spdisplays_depth'] || '';
183
- const serial = displayItem['_spdisplays_display-serial-number'] || displayItem['_spdisplays_display-serial-number2'] || null;
184
- res.displays.push({
185
- vendor: getVendorFromId(displayItem['_spdisplays_display-vendor-id'] || '') || getVendorFromModel(displayItem['_name'] || ''),
186
- vendorId: displayItem['_spdisplays_display-vendor-id'] || '',
187
- model: displayItem['_name'] || '',
188
- productionYear: displayItem['_spdisplays_display-year'] || null,
189
- serial: serial !== '0' ? serial : null,
190
- displayId: displayItem['_spdisplays_displayID'] || null,
191
- main: displayItem['spdisplays_main'] ? displayItem['spdisplays_main'] === 'spdisplays_yes' : false,
192
- builtin: (displayItem['spdisplays_display_type'] || '').indexOf('built-in') > -1,
193
- connection: connectionType.indexOf('_internal') > -1 ? 'Internal' : connectionType.indexOf('_displayport') > -1 ? 'Display Port' : connectionType.indexOf('_hdmi') > -1 ? 'HDMI' : null,
194
- sizeX: null,
195
- sizeY: null,
196
- pixelDepth: pixelDepthString === 'CGSThirtyBitColor' ? 30 : pixelDepthString === 'CGSThirtytwoBitColor' ? 32 : pixelDepthString === 'CGSTwentyfourBitColor' ? 24 : null,
197
- resolutionX: pixelParts.length > 1 ? parseInt(pixelParts[0], 10) : null,
198
- resolutionY: pixelParts.length > 1 ? parseInt(pixelParts[1], 10) : null,
199
- currentResX: currentResolution.length > 1 ? parseInt(currentResolution[0], 10) : null,
200
- currentResY: currentResolution.length > 1 ? parseInt(currentResolution[1], 10) : null,
201
- positionX: 0,
202
- positionY: 0,
203
- currentRefreshRate: currentResolutionParts.length > 1 ? parseInt(currentResolutionParts[1], 10) : null
204
- });
205
- });
206
- }
207
- });
208
- return res;
209
- } catch (e) {
210
- return res;
211
- }
212
- }
213
-
214
- function parseLinesLinuxControllers(lines) {
215
- const controllers = [];
216
- let currentController = {
217
- vendor: '',
218
- subVendor: '',
219
- model: '',
220
- bus: '',
221
- busAddress: '',
222
- vram: null,
223
- vramDynamic: false,
224
- pciID: ''
225
- };
226
- let isGraphicsController = false;
227
- // PCI bus IDs
228
- let pciIDs = [];
229
- try {
230
- pciIDs = execSync('export LC_ALL=C; dmidecode -t 9 2>/dev/null; unset LC_ALL | grep "Bus Address: "', util.execOptsLinux).toString().split('\n');
231
- for (let i = 0; i < pciIDs.length; i++) {
232
- pciIDs[i] = pciIDs[i].replace('Bus Address:', '').replace('0000:', '').trim();
233
- }
234
- pciIDs = pciIDs.filter((el) => el != null && el);
235
- } catch {
236
- util.noop();
237
- }
238
- let i = 1;
239
- lines.forEach((line) => {
240
- let subsystem = '';
241
- if (i < lines.length && lines[i]) {
242
- // get next line;
243
- subsystem = lines[i];
244
- if (subsystem.indexOf(':') > 0) {
245
- subsystem = subsystem.split(':')[1];
246
- }
247
- }
248
- if ('' !== line.trim()) {
249
- if (' ' !== line[0] && '\t' !== line[0]) {
250
- // first line of new entry
251
- const isExternal = pciIDs.indexOf(line.split(' ')[0]) >= 0;
252
- let vgapos = line.toLowerCase().indexOf(' vga ');
253
- const _3dcontrollerpos = line.toLowerCase().indexOf('3d controller');
254
- const _displaycontrollerpos = line.toLowerCase().indexOf('display controller');
255
- if (vgapos !== -1 || _3dcontrollerpos !== -1 || _displaycontrollerpos !== -1) {
256
- // VGA
257
- if (_3dcontrollerpos !== -1 && vgapos === -1) {
258
- vgapos = _3dcontrollerpos;
259
- }
260
- if (_displaycontrollerpos !== -1 && vgapos === -1) {
261
- vgapos = _displaycontrollerpos;
262
- }
263
- if (currentController.vendor || currentController.model || currentController.bus || currentController.vram !== null || currentController.vramDynamic) {
264
- // already a controller found
265
- controllers.push(currentController);
266
- currentController = {
267
- vendor: '',
268
- model: '',
269
- bus: '',
270
- busAddress: '',
271
- vram: null,
272
- vramDynamic: false
273
- };
274
- }
275
-
276
- const pciIDCandidate = line.split(' ')[0];
277
- if (/[\da-fA-F]{2}:[\da-fA-F]{2}\.[\da-fA-F]/.test(pciIDCandidate)) {
278
- currentController.busAddress = pciIDCandidate;
279
- }
280
- isGraphicsController = true;
281
- const endpos = line.search(/\[[0-9a-f]{4}:[0-9a-f]{4}]|$/);
282
- const parts = line.substr(vgapos, endpos - vgapos).split(':');
283
- currentController.busAddress = line.substr(0, vgapos).trim();
284
- if (parts.length > 1) {
285
- parts[1] = parts[1].trim();
286
- if (parts[1].toLowerCase().indexOf('corporation') >= 0) {
287
- currentController.vendor = parts[1].substr(0, parts[1].toLowerCase().indexOf('corporation') + 11).trim();
288
- currentController.model = parts[1]
289
- .substr(parts[1].toLowerCase().indexOf('corporation') + 11, 200)
290
- .split('(')[0]
291
- .trim();
292
- currentController.bus = pciIDs.length > 0 && isExternal ? 'PCIe' : 'Onboard';
293
- currentController.vram = null;
294
- currentController.vramDynamic = false;
295
- } else if (parts[1].toLowerCase().indexOf(' inc.') >= 0) {
296
- if ((parts[1].match(/]/g) || []).length > 1) {
297
- currentController.vendor = parts[1].substr(0, parts[1].toLowerCase().indexOf(']') + 1).trim();
298
- currentController.model = parts[1]
299
- .substr(parts[1].toLowerCase().indexOf(']') + 1, 200)
300
- .trim()
301
- .split('(')[0]
302
- .trim();
303
- } else {
304
- currentController.vendor = parts[1].substr(0, parts[1].toLowerCase().indexOf(' inc.') + 5).trim();
305
- currentController.model = parts[1]
306
- .substr(parts[1].toLowerCase().indexOf(' inc.') + 5, 200)
307
- .trim()
308
- .split('(')[0]
309
- .trim();
310
- }
311
- currentController.bus = pciIDs.length > 0 && isExternal ? 'PCIe' : 'Onboard';
312
- currentController.vram = null;
313
- currentController.vramDynamic = false;
314
- } else if (parts[1].toLowerCase().indexOf(' ltd.') >= 0) {
315
- if ((parts[1].match(/]/g) || []).length > 1) {
316
- currentController.vendor = parts[1].substr(0, parts[1].toLowerCase().indexOf(']') + 1).trim();
317
- currentController.model = parts[1]
318
- .substr(parts[1].toLowerCase().indexOf(']') + 1, 200)
319
- .trim()
320
- .split('(')[0]
321
- .trim();
322
- } else {
323
- currentController.vendor = parts[1].substr(0, parts[1].toLowerCase().indexOf(' ltd.') + 5).trim();
324
- currentController.model = parts[1]
325
- .substr(parts[1].toLowerCase().indexOf(' ltd.') + 5, 200)
326
- .trim()
327
- .split('(')[0]
328
- .trim();
329
- }
330
- }
331
- if (currentController.model && subsystem.indexOf(currentController.model) !== -1) {
332
- const subVendor = subsystem.split(currentController.model)[0].trim();
333
- if (subVendor) {
334
- currentController.subVendor = subVendor;
335
- }
336
- }
337
- }
338
- } else {
339
- isGraphicsController = false;
340
- }
341
- }
342
- if (isGraphicsController) {
343
- // within VGA details
344
- const parts = line.split(':');
345
- if (parts.length > 1 && parts[0].replace(/ +/g, '').toLowerCase().indexOf('devicename') !== -1 && parts[1].toLowerCase().indexOf('onboard') !== -1) {
346
- currentController.bus = 'Onboard';
347
- }
348
- if (parts.length > 1 && parts[0].replace(/ +/g, '').toLowerCase().indexOf('region') !== -1 && parts[1].toLowerCase().indexOf('memory') !== -1) {
349
- const sizeMatch = parts[1].match(/size=(\d+)([KMG])?/i);
350
- if (sizeMatch) {
351
- let vram = parseInt(sizeMatch[1], 10);
352
- const unit = (sizeMatch[2] || '').toUpperCase();
353
- if (unit === 'G') {
354
- vram *= 1024;
355
- } else if (unit === 'K') {
356
- vram = Math.round(vram / 1024);
357
- } else if (unit === '') {
358
- vram = Math.round(vram / 1024 / 1024);
359
- } // bytes
360
- // keep the largest memory region (the actual framebuffer aperture)
361
- if (currentController.vram === null || vram > currentController.vram) {
362
- currentController.vram = vram;
363
- }
364
- }
365
- }
366
- }
367
- }
368
- i++;
369
- });
370
-
371
- if (currentController.vendor || currentController.model || currentController.bus || currentController.busAddress || currentController.vram !== null || currentController.vramDynamic) {
372
- // already a controller found
373
- controllers.push(currentController);
374
- }
375
- return controllers;
376
- }
377
-
378
- function parseLinesLinuxClinfo(controllers, lines) {
379
- const fieldPattern = /\[([^\]]+)\]\s+(\w+)\s+(.*)/;
380
- const devices = lines.reduce((devices, line) => {
381
- const field = fieldPattern.exec(line.trim());
382
- if (field) {
383
- if (!devices[field[1]]) {
384
- devices[field[1]] = {};
385
- }
386
- devices[field[1]][field[2]] = field[3];
387
- }
388
- return devices;
389
- }, {});
390
- for (const deviceId in devices) {
391
- const device = devices[deviceId];
392
- if (device['CL_DEVICE_TYPE'] === 'CL_DEVICE_TYPE_GPU') {
393
- let busAddress;
394
- if (device['CL_DEVICE_TOPOLOGY_AMD']) {
395
- const bdf = device['CL_DEVICE_TOPOLOGY_AMD'].match(/[a-zA-Z0-9]+:\d+\.\d+/);
396
- if (bdf) {
397
- busAddress = bdf[0];
398
- }
399
- } else if (device['CL_DEVICE_PCI_BUS_ID_NV'] && device['CL_DEVICE_PCI_SLOT_ID_NV']) {
400
- const bus = parseInt(device['CL_DEVICE_PCI_BUS_ID_NV']);
401
- const slot = parseInt(device['CL_DEVICE_PCI_SLOT_ID_NV']);
402
- if (!isNaN(bus) && !isNaN(slot)) {
403
- const b = bus & 0xff;
404
- const d = (slot >> 3) & 0xff;
405
- const f = slot & 0x07;
406
- busAddress = `${b.toString().padStart(2, '0')}:${d.toString().padStart(2, '0')}.${f}`;
407
- }
408
- }
409
- if (busAddress) {
410
- let controller = controllers.find((controller) => controller.busAddress === busAddress);
411
- if (!controller) {
412
- controller = {
413
- vendor: '',
414
- model: '',
415
- bus: '',
416
- busAddress,
417
- vram: null,
418
- vramDynamic: false
419
- };
420
- controllers.push(controller);
421
- }
422
- controller.vendor = device['CL_DEVICE_VENDOR'];
423
- if (device['CL_DEVICE_BOARD_NAME_AMD']) {
424
- controller.model = device['CL_DEVICE_BOARD_NAME_AMD'];
425
- } else {
426
- controller.model = device['CL_DEVICE_NAME'];
427
- }
428
- const memory = parseInt(device['CL_DEVICE_GLOBAL_MEM_SIZE']);
429
- if (!isNaN(memory)) {
430
- controller.vram = Math.round(memory / 1024 / 1024);
431
- }
432
- }
433
- }
434
- }
435
- return controllers;
436
- }
437
-
438
- function getNvidiaSmi() {
439
- if (_nvidiaSmiPath) {
440
- return _nvidiaSmiPath;
441
- }
442
-
443
- if (_windows) {
444
- try {
445
- const systemSmiPath = path.join(util.WINDIR, 'System32', 'nvidia-smi.exe');
446
- if (fs.existsSync(systemSmiPath)) {
447
- _nvidiaSmiPath = systemSmiPath;
448
- } else {
449
- const basePath = path.join(util.WINDIR, 'System32', 'DriverStore', 'FileRepository');
450
- // find all directories that have an nvidia-smi.exe file with date
451
- const candidates = fs
452
- .readdirSync(basePath, { withFileTypes: true })
453
- .filter((dir) => dir.isDirectory())
454
- .map((dir) => {
455
- const nvidiaSmiPath = path.join(basePath, dir.name, 'nvidia-smi.exe');
456
- try {
457
- const stats = fs.statSync(nvidiaSmiPath);
458
- return { path: nvidiaSmiPath, ctime: stats.ctimeMs };
459
- } catch {
460
- return null;
461
- }
462
- })
463
- .filter(Boolean);
464
- if (candidates.length > 0) {
465
- // take the most recent
466
- _nvidiaSmiPath = candidates.reduce((prev, curr) => (curr.ctime > prev.ctime ? curr : prev)).path;
467
- }
468
- }
469
- } catch {
470
- util.noop();
471
- }
472
- } else if (_linux) {
473
- _nvidiaSmiPath = 'nvidia-smi';
474
- }
475
- return _nvidiaSmiPath;
476
- }
477
-
478
- function nvidiaSmi(options) {
479
- const nvidiaSmiExe = getNvidiaSmi();
480
- options = Object.assign({}, options || util.execOptsWin);
481
- if (nvidiaSmiExe) {
482
- const nvidiaSmiOpts =
483
- '--query-gpu=driver_version,pci.sub_device_id,name,pci.bus_id,fan.speed,memory.total,memory.used,memory.free,utilization.gpu,utilization.memory,temperature.gpu,temperature.memory,power.draw,power.limit,clocks.gr,clocks.mem --format=csv,noheader,nounits';
484
- const cmd = `"${nvidiaSmiExe}" ${nvidiaSmiOpts}`;
485
- if (_linux) {
486
- options.stdio = ['pipe', 'pipe', 'ignore'];
487
- }
488
- try {
489
- const sanitized = cmd + (_linux ? ' 2>/dev/null' : '') + (_windows ? ' 2> nul' : '');
490
- const res = execSync(sanitized, options).toString();
491
- return res;
492
- } catch {
493
- util.noop();
494
- }
495
- }
496
- return '';
497
- }
498
-
499
- function nvidiaDevices() {
500
- function safeParseNumber(value) {
501
- if ([null, undefined].includes(value)) {
502
- return value;
503
- }
504
- return parseFloat(value);
505
- }
506
-
507
- const stdout = nvidiaSmi();
508
- if (!stdout) {
509
- return [];
510
- }
511
-
512
- const gpus = stdout.split('\n').filter(Boolean);
513
- let results = gpus.map((gpu) => {
514
- const splittedData = gpu.split(', ').map((value) => (value.includes('N/A') ? undefined : value));
515
- if (splittedData.length === 16) {
516
- return {
517
- driverVersion: splittedData[0],
518
- subDeviceId: splittedData[1],
519
- name: splittedData[2],
520
- pciBus: splittedData[3],
521
- fanSpeed: safeParseNumber(splittedData[4]),
522
- memoryTotal: safeParseNumber(splittedData[5]),
523
- memoryUsed: safeParseNumber(splittedData[6]),
524
- memoryFree: safeParseNumber(splittedData[7]),
525
- utilizationGpu: safeParseNumber(splittedData[8]),
526
- utilizationMemory: safeParseNumber(splittedData[9]),
527
- temperatureGpu: safeParseNumber(splittedData[10]),
528
- temperatureMemory: safeParseNumber(splittedData[11]),
529
- powerDraw: safeParseNumber(splittedData[12]),
530
- powerLimit: safeParseNumber(splittedData[13]),
531
- clockCore: safeParseNumber(splittedData[14]),
532
- clockMemory: safeParseNumber(splittedData[15])
533
- };
534
- } else {
535
- return {};
536
- }
537
- });
538
- results = results.filter((item) => {
539
- return 'pciBus' in item;
540
- });
541
- return results;
542
- }
543
-
544
- function mergeControllerNvidia(controller, nvidia) {
545
- if (nvidia.driverVersion) {
546
- controller.driverVersion = nvidia.driverVersion;
547
- }
548
- if (nvidia.subDeviceId) {
549
- controller.subDeviceId = nvidia.subDeviceId;
550
- }
551
- if (nvidia.name) {
552
- controller.name = nvidia.name;
553
- }
554
- if (nvidia.pciBus) {
555
- controller.pciBus = nvidia.pciBus;
556
- }
557
- if (nvidia.fanSpeed) {
558
- controller.fanSpeed = nvidia.fanSpeed;
559
- }
560
- if (nvidia.memoryTotal) {
561
- controller.memoryTotal = nvidia.memoryTotal;
562
- controller.vram = nvidia.memoryTotal;
563
- controller.vramDynamic = false;
564
- }
565
- if (nvidia.memoryUsed) {
566
- controller.memoryUsed = nvidia.memoryUsed;
567
- }
568
- if (nvidia.memoryFree) {
569
- controller.memoryFree = nvidia.memoryFree;
570
- }
571
- if (nvidia.utilizationGpu) {
572
- controller.utilizationGpu = nvidia.utilizationGpu;
573
- }
574
- if (nvidia.utilizationMemory) {
575
- controller.utilizationMemory = nvidia.utilizationMemory;
576
- }
577
- if (nvidia.temperatureGpu) {
578
- controller.temperatureGpu = nvidia.temperatureGpu;
579
- }
580
- if (nvidia.temperatureMemory) {
581
- controller.temperatureMemory = nvidia.temperatureMemory;
582
- }
583
- if (nvidia.powerDraw) {
584
- controller.powerDraw = nvidia.powerDraw;
585
- }
586
- if (nvidia.powerLimit) {
587
- controller.powerLimit = nvidia.powerLimit;
588
- }
589
- if (nvidia.clockCore) {
590
- controller.clockCore = nvidia.clockCore;
591
- }
592
- if (nvidia.clockMemory) {
593
- controller.clockMemory = nvidia.clockMemory;
594
- }
595
- return controller;
596
- }
597
-
598
- function parseLinesLinuxEdid(edid) {
599
- // parsen EDID
600
- // --> model
601
- // --> resolutionx
602
- // --> resolutiony
603
- // --> builtin = false
604
- // --> pixeldepth (?)
605
- // --> sizex
606
- // --> sizey
607
- const result = {
608
- vendor: '',
609
- model: '',
610
- deviceName: '',
611
- main: false,
612
- builtin: false,
613
- connection: '',
614
- sizeX: null,
615
- sizeY: null,
616
- pixelDepth: null,
617
- resolutionX: null,
618
- resolutionY: null,
619
- currentResX: null,
620
- currentResY: null,
621
- positionX: 0,
622
- positionY: 0,
623
- currentRefreshRate: null
624
- };
625
- // find first "Detailed Timing Description"
626
- let start = 108;
627
- if (edid.substr(start, 6) === '000000') {
628
- start += 36;
629
- }
630
- if (edid.substr(start, 6) === '000000') {
631
- start += 36;
632
- }
633
- if (edid.substr(start, 6) === '000000') {
634
- start += 36;
635
- }
636
- if (edid.substr(start, 6) === '000000') {
637
- start += 36;
638
- }
639
- result.resolutionX = parseInt('0x0' + edid.substr(start + 8, 1) + edid.substr(start + 4, 2));
640
- result.resolutionY = parseInt('0x0' + edid.substr(start + 14, 1) + edid.substr(start + 10, 2));
641
- result.sizeX = parseInt('0x0' + edid.substr(start + 28, 1) + edid.substr(start + 24, 2));
642
- result.sizeY = parseInt('0x0' + edid.substr(start + 29, 1) + edid.substr(start + 26, 2));
643
- // monitor name
644
- start = edid.indexOf('000000fc00'); // find first "Monitor Description Data"
645
- if (start >= 0) {
646
- let model_raw = edid.substr(start + 10, 26);
647
- if (model_raw.indexOf('0a') !== -1) {
648
- model_raw = model_raw.substr(0, model_raw.indexOf('0a'));
649
- }
650
- try {
651
- if (model_raw.length > 2) {
652
- result.model = model_raw
653
- .match(/.{1,2}/g)
654
- .map((v) => String.fromCharCode(parseInt(v, 16)))
655
- .join('');
656
- }
657
- } catch {
658
- util.noop();
659
- }
660
- } else {
661
- result.model = '';
662
- }
663
- return result;
664
- }
665
-
666
- function parseLinesLinuxDisplays(lines, depth) {
667
- const displays = [];
668
- let currentDisplay = {
669
- vendor: '',
670
- model: '',
671
- deviceName: '',
672
- main: false,
673
- builtin: false,
674
- connection: '',
675
- sizeX: null,
676
- sizeY: null,
677
- pixelDepth: null,
678
- resolutionX: null,
679
- resolutionY: null,
680
- currentResX: null,
681
- currentResY: null,
682
- positionX: 0,
683
- positionY: 0,
684
- currentRefreshRate: null
685
- };
686
- let is_edid = false;
687
- let is_current = false;
688
- let edid_raw = '';
689
- let start = 0;
690
- const applyEdid = () => {
691
- const edid_decoded = parseLinesLinuxEdid(edid_raw);
692
- currentDisplay.vendor = edid_decoded.vendor;
693
- currentDisplay.model = edid_decoded.model;
694
- currentDisplay.resolutionX = edid_decoded.resolutionX;
695
- currentDisplay.resolutionY = edid_decoded.resolutionY;
696
- currentDisplay.sizeX = edid_decoded.sizeX;
697
- currentDisplay.sizeY = edid_decoded.sizeY;
698
- currentDisplay.pixelDepth = depth;
699
- is_edid = false;
700
- };
701
- for (let i = 1; i < lines.length; i++) {
702
- // start with second line
703
- if ('' !== lines[i].trim()) {
704
- if (' ' !== lines[i][0] && '\t' !== lines[i][0] && lines[i].toLowerCase().indexOf(' connected ') !== -1) {
705
- // first line of new entry
706
- if (is_edid && edid_raw) {
707
- // pending EDID belongs to the previous display
708
- applyEdid();
709
- }
710
- if (
711
- currentDisplay.model ||
712
- currentDisplay.main ||
713
- currentDisplay.builtin ||
714
- currentDisplay.connection ||
715
- currentDisplay.sizeX !== null ||
716
- currentDisplay.pixelDepth !== null ||
717
- currentDisplay.resolutionX !== null
718
- ) {
719
- // push last display to array
720
- displays.push(currentDisplay);
721
- currentDisplay = {
722
- vendor: '',
723
- model: '',
724
- main: false,
725
- builtin: false,
726
- connection: '',
727
- sizeX: null,
728
- sizeY: null,
729
- pixelDepth: null,
730
- resolutionX: null,
731
- resolutionY: null,
732
- currentResX: null,
733
- currentResY: null,
734
- positionX: 0,
735
- positionY: 0,
736
- currentRefreshRate: null
737
- };
738
- }
739
- const parts = lines[i].split(' ');
740
- currentDisplay.connection = parts[0];
741
- currentDisplay.main = lines[i].toLowerCase().indexOf(' primary ') >= 0;
742
- currentDisplay.builtin = parts[0].toLowerCase().indexOf('edp') >= 0;
743
- const geometry = lines[i].match(/\d+x\d+\+(-?\d+)\+(-?\d+)/);
744
- if (geometry) {
745
- currentDisplay.positionX = util.toInt(geometry[1]);
746
- currentDisplay.positionY = util.toInt(geometry[2]);
747
- }
748
- }
749
-
750
- // try to read EDID information
751
- if (is_edid) {
752
- if (lines[i].search(/\S|$/) > start) {
753
- edid_raw += lines[i].toLowerCase().trim();
754
- } else {
755
- // parsen EDID
756
- applyEdid();
757
- }
758
- }
759
- if (lines[i].toLowerCase().indexOf('edid:') >= 0) {
760
- is_edid = true;
761
- edid_raw = '';
762
- start = lines[i].search(/\S|$/);
763
- }
764
- if (lines[i].toLowerCase().indexOf('*current') >= 0) {
765
- const parts1 = lines[i].split('(');
766
- if (parts1 && parts1.length > 1 && parts1[0].indexOf('x') >= 0) {
767
- const resParts = parts1[0].trim().split('x');
768
- currentDisplay.currentResX = util.toInt(resParts[0]);
769
- currentDisplay.currentResY = util.toInt(resParts[1]);
770
- }
771
- is_current = true;
772
- }
773
- if (is_current && lines[i].toLowerCase().indexOf('clock') >= 0 && lines[i].toLowerCase().indexOf('hz') >= 0 && lines[i].toLowerCase().indexOf('v: height') >= 0) {
774
- const parts1 = lines[i].split('clock');
775
- if (parts1 && parts1.length > 1 && parts1[1].toLowerCase().indexOf('hz') >= 0) {
776
- currentDisplay.currentRefreshRate = util.toInt(parts1[1]);
777
- }
778
- is_current = false;
779
- }
780
- }
781
- }
782
-
783
- // pushen displays
784
- if (is_edid && edid_raw) {
785
- // EDID was the last block in the output
786
- applyEdid();
787
- }
788
- if (
789
- currentDisplay.model ||
790
- currentDisplay.main ||
791
- currentDisplay.builtin ||
792
- currentDisplay.connection ||
793
- currentDisplay.sizeX !== null ||
794
- currentDisplay.pixelDepth !== null ||
795
- currentDisplay.resolutionX !== null
796
- ) {
797
- // still information there
798
- displays.push(currentDisplay);
799
- }
800
- return displays;
801
- }
802
-
803
- // function starts here
804
- return new Promise((resolve) => {
805
- process.nextTick(() => {
806
- let result = {
807
- controllers: [],
808
- displays: []
809
- };
810
- if (_darwin) {
811
- const cmd = 'system_profiler -xml -detailLevel full SPDisplaysDataType';
812
- exec(cmd, (error, stdout) => {
813
- if (!error) {
814
- try {
815
- const output = stdout.toString();
816
- result = parseLinesDarwin(util.plistParser(output)[0]._items);
817
- } catch (e) {
818
- util.noop();
819
- }
820
- try {
821
- // GPU temperature (Apple Silicon) - optional dependency
822
- const macosTemp = require('macos-temperature-sensor');
823
- const temps = macosTemp.temperature();
824
- if (temps && temps.gpu) {
825
- result.controllers.forEach((controller) => {
826
- if (controller.bus === 'Built-In') {
827
- controller.temperatureGpu = Math.round(temps.gpu * 100) / 100;
828
- }
829
- });
830
- }
831
- } catch {
832
- util.noop();
833
- }
834
- try {
835
- stdout = execSync(
836
- 'defaults read /Library/Preferences/com.apple.windowserver.plist 2>/dev/null;defaults read /Library/Preferences/com.apple.windowserver.displays.plist 2>/dev/null; echo ""',
837
- { maxBuffer: 1024 * 102400 }
838
- );
839
- const output = (stdout || '').toString();
840
- const obj = util.plistReader(output);
841
- if (obj['DisplayAnyUserSets'] && obj['DisplayAnyUserSets']['Configs'] && obj['DisplayAnyUserSets']['Configs'][0] && obj['DisplayAnyUserSets']['Configs'][0]['DisplayConfig']) {
842
- const current = obj['DisplayAnyUserSets']['Configs'][0]['DisplayConfig'];
843
- let i = 0;
844
- current.forEach((o) => {
845
- if (o['CurrentInfo'] && o['CurrentInfo']['OriginX'] !== undefined && result.displays && result.displays[i]) {
846
- result.displays[i].positionX = o['CurrentInfo']['OriginX'];
847
- }
848
- if (o['CurrentInfo'] && o['CurrentInfo']['OriginY'] !== undefined && result.displays && result.displays[i]) {
849
- result.displays[i].positionY = o['CurrentInfo']['OriginY'];
850
- }
851
- i++;
852
- });
853
- }
854
- if (obj['DisplayAnyUserSets'] && obj['DisplayAnyUserSets'].length > 0 && obj['DisplayAnyUserSets'][0].length > 0 && obj['DisplayAnyUserSets'][0][0]['DisplayID']) {
855
- const current = obj['DisplayAnyUserSets'][0];
856
- let i = 0;
857
- current.forEach((o) => {
858
- if ('OriginX' in o && result.displays && result.displays[i]) {
859
- result.displays[i].positionX = o['OriginX'];
860
- }
861
- if ('OriginY' in o && result.displays && result.displays[i]) {
862
- result.displays[i].positionY = o['OriginY'];
863
- }
864
- if (o['Mode'] && o['Mode']['BitsPerPixel'] !== undefined && result.displays && result.displays[i]) {
865
- result.displays[i].pixelDepth = o['Mode']['BitsPerPixel'];
866
- }
867
- i++;
868
- });
869
- }
870
- } catch {
871
- util.noop();
872
- }
873
- }
874
- if (callback) {
875
- callback(result);
876
- }
877
- resolve(result);
878
- });
879
- }
880
- if (_linux) {
881
- // Raspberry: https://elinux.org/RPI_vcgencmd_usage
882
- if (util.isRaspberry()) {
883
- const cmd = "fbset -s 2> /dev/null | grep 'mode \"' ; vcgencmd get_mem gpu 2> /dev/null; tvservice -s 2> /dev/null; tvservice -n 2> /dev/null;";
884
- exec(cmd, (error, stdout) => {
885
- const lines = stdout.toString().split('\n');
886
- if (lines.length > 3 && lines[0].indexOf('mode "') >= 0 && lines[2].indexOf('0x12000a') > -1) {
887
- const parts = lines[0].replace('mode', '').replace(/"/g, '').trim().split('x');
888
- if (parts.length === 2) {
889
- result.displays.push({
890
- vendor: '',
891
- model: util.getValue(lines, 'device_name', '='),
892
- main: true,
893
- builtin: false,
894
- connection: 'HDMI',
895
- sizeX: null,
896
- sizeY: null,
897
- pixelDepth: null,
898
- resolutionX: parseInt(parts[0], 10),
899
- resolutionY: parseInt(parts[1], 10),
900
- currentResX: null,
901
- currentResY: null,
902
- positionX: 0,
903
- positionY: 0,
904
- currentRefreshRate: null
905
- });
906
- }
907
- }
908
- if (lines.length >= 1 && stdout.toString().indexOf('gpu=') >= 0) {
909
- result.controllers.push({
910
- vendor: 'Broadcom',
911
- model: util.getRpiGpu(),
912
- bus: '',
913
- vram: parseInt(util.getValue(lines, 'gpu', '=').replace('M', ''), 10) || null,
914
- vramDynamic: true
915
- });
916
- }
917
- });
918
- }
919
- // } else {
920
- const cmd = 'lspci -vvv 2>/dev/null';
921
- exec(cmd, (error, stdout) => {
922
- if (!error) {
923
- const lines = stdout.toString().split('\n');
924
- if (result.controllers.length === 0) {
925
- result.controllers = parseLinesLinuxControllers(lines);
926
-
927
- const nvidiaData = nvidiaDevices();
928
- // needs to be rewritten ... using no spread operators
929
- result.controllers = result.controllers.map((controller) => {
930
- // match by busAddress
931
- return mergeControllerNvidia(controller, nvidiaData.find((contr) => contr.pciBus && controller.busAddress && contr.pciBus.toLowerCase().endsWith(controller.busAddress.toLowerCase())) || {});
932
- });
933
- }
934
- }
935
- const cmd = 'clinfo --raw';
936
- exec(cmd, (error, stdout) => {
937
- if (!error) {
938
- const lines = stdout.toString().split('\n');
939
- result.controllers = parseLinesLinuxClinfo(result.controllers, lines);
940
- }
941
- const cmd = "xdpyinfo 2>/dev/null | grep 'depth of root window' | awk '{ print $5 }'";
942
- exec(cmd, (error, stdout) => {
943
- let depth = 0;
944
- if (!error) {
945
- const lines = stdout.toString().split('\n');
946
- depth = parseInt(lines[0]) || 0;
947
- }
948
- const cmd = 'xrandr --verbose 2>/dev/null';
949
- exec(cmd, (error, stdout) => {
950
- if (!error) {
951
- const lines = stdout.toString().split('\n');
952
- result.displays = parseLinesLinuxDisplays(lines, depth);
953
- }
954
- if (callback) {
955
- callback(result);
956
- }
957
- resolve(result);
958
- });
959
- });
960
- });
961
- });
962
- // }
963
- }
964
- if (_freebsd || _openbsd || _netbsd) {
965
- if (callback) {
966
- callback(null);
967
- }
968
- resolve(null);
969
- }
970
- if (_sunos) {
971
- if (callback) {
972
- callback(null);
973
- }
974
- resolve(null);
975
- }
976
- if (_windows) {
977
- // https://blogs.technet.microsoft.com/heyscriptingguy/2013/10/03/use-powershell-to-discover-multi-monitor-information/
978
- // https://devblogs.microsoft.com/scripting/use-powershell-to-discover-multi-monitor-information/
979
- try {
980
- const workload = [];
981
- workload.push(util.powerShell('Get-CimInstance win32_VideoController | fl *'));
982
- workload.push(
983
- util.powerShell(
984
- 'gp "HKLM:\\SYSTEM\\ControlSet001\\Control\\Class\\{4d36e968-e325-11ce-bfc1-08002be10318}\\*" -ErrorAction SilentlyContinue | where MatchingDeviceId $null -NE | select MatchingDeviceId,HardwareInformation.qwMemorySize | fl'
985
- )
986
- );
987
- workload.push(util.powerShell('Get-CimInstance win32_desktopmonitor | fl *'));
988
- workload.push(util.powerShell('Get-CimInstance -Namespace root\\wmi -ClassName WmiMonitorBasicDisplayParams | fl'));
989
- workload.push(util.powerShell('Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.Screen]::AllScreens'));
990
- workload.push(util.powerShell('Get-CimInstance -Namespace root\\wmi -ClassName WmiMonitorConnectionParams | fl'));
991
- workload.push(
992
- util.powerShell(
993
- 'gwmi WmiMonitorID -Namespace root\\wmi | ForEach-Object {(($_.ManufacturerName -notmatch 0 | foreach {[char]$_}) -join "") + "|" + (($_.ProductCodeID -notmatch 0 | foreach {[char]$_}) -join "") + "|" + (($_.UserFriendlyName -notmatch 0 | foreach {[char]$_}) -join "") + "|" + (($_.SerialNumberID -notmatch 0 | foreach {[char]$_}) -join "") + "|" + $_.YearOfManufacture + "|" + $_.InstanceName}'
994
- )
995
- );
996
- workload.push(util.powerShell(psCurrentModes));
997
-
998
- const nvidiaData = nvidiaDevices();
999
-
1000
- Promise.all(workload)
1001
- .then((data) => {
1002
- // controller + vram
1003
- const csections = data[0].replace(/\r/g, '').split(/\n\s*\n/);
1004
- const vsections = data[1].replace(/\r/g, '').split(/\n\s*\n/);
1005
- result.controllers = parseLinesWindowsControllers(csections, vsections);
1006
- result.controllers = result.controllers.map((controller) => {
1007
- // match by subDeviceId
1008
- if (controller.vendor.toLowerCase() === 'nvidia') {
1009
- return mergeControllerNvidia(
1010
- controller,
1011
- nvidiaData.find((device) => {
1012
- let windowsSubDeviceId = (controller.subDeviceId || '').toLowerCase();
1013
- const nvidiaSubDeviceIdParts = (device.subDeviceId || '').split('x');
1014
- let nvidiaSubDeviceId = nvidiaSubDeviceIdParts.length > 1 ? nvidiaSubDeviceIdParts[1].toLowerCase() : nvidiaSubDeviceIdParts[0].toLowerCase();
1015
- const lengthDifference = Math.abs(windowsSubDeviceId.length - nvidiaSubDeviceId.length);
1016
- if (windowsSubDeviceId.length > nvidiaSubDeviceId.length) {
1017
- for (let i = 0; i < lengthDifference; i++) {
1018
- nvidiaSubDeviceId = '0' + nvidiaSubDeviceId;
1019
- }
1020
- } else if (windowsSubDeviceId.length < nvidiaSubDeviceId.length) {
1021
- for (let i = 0; i < lengthDifference; i++) {
1022
- windowsSubDeviceId = '0' + windowsSubDeviceId;
1023
- }
1024
- }
1025
- return windowsSubDeviceId === nvidiaSubDeviceId;
1026
- }) || {}
1027
- );
1028
- } else {
1029
- return controller;
1030
- }
1031
- });
1032
-
1033
- // displays
1034
- const dsections = data[2].replace(/\r/g, '').split(/\n\s*\n/);
1035
- // result.displays = parseLinesWindowsDisplays(dsections);
1036
- if (dsections[0].trim() === '') {
1037
- dsections.shift();
1038
- }
1039
- if (dsections.length && dsections[dsections.length - 1].trim() === '') {
1040
- dsections.pop();
1041
- }
1042
-
1043
- // physical monitors (powershell) - keyed by InstanceName (issue #764)
1044
- // inactive monitors (attached but not part of the desktop, e.g. "PC screen only") are skipped
1045
- const monitors = [];
1046
- data[3].replace(/\r/g, '').split(/\n\s*\n/).forEach((section) => {
1047
- const lines = section.split('\n');
1048
- const monitorInstanceName = util.getValue(lines, 'InstanceName').toLowerCase();
1049
- const monitorActive = util.getValue(lines, 'Active').toLowerCase() !== 'false';
1050
- if (monitorInstanceName && monitorActive) {
1051
- monitors.push({
1052
- instanceName: monitorInstanceName,
1053
- sizeX: util.getValue(lines, 'MaxHorizontalImageSize'),
1054
- sizeY: util.getValue(lines, 'MaxVerticalImageSize')
1055
- });
1056
- }
1057
- });
1058
-
1059
- // forms.screens (powershell)
1060
- const ssections = data[4].replace(/\r/g, '').split('BitsPerPixel ');
1061
- ssections.shift();
1062
-
1063
- // connection params (powershell) - video type per InstanceName (issue #764)
1064
- const connections = Object.create(null);
1065
- data[5].replace(/\r/g, '').split(/\n\s*\n/).forEach((section) => {
1066
- const lines = section.split('\n');
1067
- const connectionInstanceName = util.getValue(lines, 'InstanceName').toLowerCase();
1068
- if (connectionInstanceName) {
1069
- connections[connectionInstanceName] = util.getValue(lines, 'VideoOutputTechnology');
1070
- }
1071
- });
1072
-
1073
- // monitor ID (powershell) - model / vendor
1074
- const res = data[6].replace(/\r/g, '').split(/\n/);
1075
- const isections = [];
1076
- res.forEach((element) => {
1077
- const parts = element.split('|');
1078
- if (parts.length === 6) {
1079
- isections.push({
1080
- vendor: parts[0],
1081
- code: parts[1],
1082
- model: parts[2],
1083
- serial: parts[3],
1084
- productionYear: util.toInt(parts[4]) || null,
1085
- instanceId: parts[5]
1086
- });
1087
- }
1088
- });
1089
-
1090
- // current display mode per device name (issue #853)
1091
- const currentModes = Object.create(null);
1092
- (data[7] || '').replace(/\r/g, '').split(/\n/).forEach((element) => {
1093
- const parts = element.split('|');
1094
- const frequency = parts.length === 5 ? util.toInt(parts[1]) : 0;
1095
- // dmDisplayFrequency 0/1 means hardware default
1096
- if (frequency > 1 && parts[0]) {
1097
- currentModes[parts[0].trim().toLowerCase()] = frequency;
1098
- }
1099
- });
1100
-
1101
- result.displays = parseLinesWindowsDisplaysPowershell(ssections, monitors, dsections, connections, isections, currentModes);
1102
-
1103
- if (result.displays.length === 1) {
1104
- if (_resolutionX) {
1105
- result.displays[0].resolutionX = _resolutionX;
1106
- if (!result.displays[0].currentResX) {
1107
- result.displays[0].currentResX = _resolutionX;
1108
- }
1109
- }
1110
- if (_resolutionY) {
1111
- result.displays[0].resolutionY = _resolutionY;
1112
- if (result.displays[0].currentResY === 0) {
1113
- result.displays[0].currentResY = _resolutionY;
1114
- }
1115
- }
1116
- if (_pixelDepth) {
1117
- result.displays[0].pixelDepth = _pixelDepth;
1118
- }
1119
- }
1120
- result.displays = result.displays.map((element) => {
1121
- if (_refreshRate && !element.currentRefreshRate) {
1122
- element.currentRefreshRate = _refreshRate;
1123
- }
1124
- return element;
1125
- });
1126
-
1127
- if (callback) {
1128
- callback(result);
1129
- }
1130
- resolve(result);
1131
- })
1132
- .catch(() => {
1133
- if (callback) {
1134
- callback(result);
1135
- }
1136
- resolve(result);
1137
- });
1138
- } catch (e) {
1139
- if (callback) {
1140
- callback(result);
1141
- }
1142
- resolve(result);
1143
- }
1144
- }
1145
- });
1146
- });
1147
-
1148
- function parseLinesWindowsControllers(sections, vections) {
1149
- const memorySizes = {};
1150
- for (const i in vections) {
1151
- if ({}.hasOwnProperty.call(vections, i)) {
1152
- if (vections[i].trim() !== '') {
1153
- const lines = vections[i].trim().split('\n');
1154
- const matchingDeviceId = util.getValue(lines, 'MatchingDeviceId').match(/PCI\\(VEN_[0-9A-F]{4})&(DEV_[0-9A-F]{4})(?:&(SUBSYS_[0-9A-F]{8}))?(?:&(REV_[0-9A-F]{2}))?/i);
1155
- if (matchingDeviceId) {
1156
- const quadWordmemorySize = parseInt(util.getValue(lines, 'HardwareInformation.qwMemorySize'));
1157
- if (!isNaN(quadWordmemorySize)) {
1158
- let deviceId = matchingDeviceId[1].toUpperCase() + '&' + matchingDeviceId[2].toUpperCase();
1159
- if (matchingDeviceId[3]) {
1160
- deviceId += '&' + matchingDeviceId[3].toUpperCase();
1161
- }
1162
- if (matchingDeviceId[4]) {
1163
- deviceId += '&' + matchingDeviceId[4].toUpperCase();
1164
- }
1165
- memorySizes[deviceId] = quadWordmemorySize;
1166
- }
1167
- }
1168
- }
1169
- }
1170
- }
1171
-
1172
- const controllers = [];
1173
- for (const i in sections) {
1174
- if ({}.hasOwnProperty.call(sections, i)) {
1175
- if (sections[i].trim() !== '') {
1176
- const lines = sections[i].trim().split('\n');
1177
- const pnpDeviceId = util.getValue(lines, 'PNPDeviceID', ':').match(/PCI\\(VEN_[0-9A-F]{4})&(DEV_[0-9A-F]{4})(?:&(SUBSYS_[0-9A-F]{8}))?(?:&(REV_[0-9A-F]{2}))?/i);
1178
- let subDeviceId = null;
1179
- let memorySize = null;
1180
- if (pnpDeviceId) {
1181
- subDeviceId = pnpDeviceId[3] || '';
1182
- if (subDeviceId) {
1183
- subDeviceId = subDeviceId.split('_')[1];
1184
- }
1185
-
1186
- // Match PCI device identifier (there's an order of increasing generality):
1187
- // https://docs.microsoft.com/en-us/windows-hardware/drivers/install/identifiers-for-pci-devices
1188
-
1189
- // PCI\VEN_v(4)&DEV_d(4)&SUBSYS_s(4)n(4)&REV_r(2)
1190
- if (memorySize == null && pnpDeviceId[3] && pnpDeviceId[4]) {
1191
- const deviceId = pnpDeviceId[1].toUpperCase() + '&' + pnpDeviceId[2].toUpperCase() + '&' + pnpDeviceId[3].toUpperCase() + '&' + pnpDeviceId[4].toUpperCase();
1192
- if ({}.hasOwnProperty.call(memorySizes, deviceId)) {
1193
- memorySize = memorySizes[deviceId];
1194
- }
1195
- }
1196
-
1197
- // PCI\VEN_v(4)&DEV_d(4)&SUBSYS_s(4)n(4)
1198
- if (memorySize == null && pnpDeviceId[3]) {
1199
- const deviceId = pnpDeviceId[1].toUpperCase() + '&' + pnpDeviceId[2].toUpperCase() + '&' + pnpDeviceId[3].toUpperCase();
1200
- if ({}.hasOwnProperty.call(memorySizes, deviceId)) {
1201
- memorySize = memorySizes[deviceId];
1202
- }
1203
- }
1204
-
1205
- // PCI\VEN_v(4)&DEV_d(4)&REV_r(2)
1206
- if (memorySize == null && pnpDeviceId[4]) {
1207
- const deviceId = pnpDeviceId[1].toUpperCase() + '&' + pnpDeviceId[2].toUpperCase() + '&' + pnpDeviceId[4].toUpperCase();
1208
- if ({}.hasOwnProperty.call(memorySizes, deviceId)) {
1209
- memorySize = memorySizes[deviceId];
1210
- }
1211
- }
1212
-
1213
- // PCI\VEN_v(4)&DEV_d(4)
1214
- if (memorySize == null) {
1215
- const deviceId = pnpDeviceId[1].toUpperCase() + '&' + pnpDeviceId[2].toUpperCase();
1216
- if ({}.hasOwnProperty.call(memorySizes, deviceId)) {
1217
- memorySize = memorySizes[deviceId];
1218
- }
1219
- }
1220
- }
1221
-
1222
- controllers.push({
1223
- vendor: util.getValue(lines, 'AdapterCompatibility', ':'),
1224
- model: util.getValue(lines, 'name', ':'),
1225
- bus: util.getValue(lines, 'PNPDeviceID', ':').startsWith('PCI') ? 'PCI' : '',
1226
- vram: (memorySize == null ? util.toInt(util.getValue(lines, 'AdapterRAM', ':')) : memorySize) / 1024 / 1024,
1227
- vramDynamic: util.getValue(lines, 'VideoMemoryType', ':') === '2',
1228
- subDeviceId
1229
- });
1230
- _resolutionX = util.toInt(util.getValue(lines, 'CurrentHorizontalResolution', ':')) || _resolutionX;
1231
- _resolutionY = util.toInt(util.getValue(lines, 'CurrentVerticalResolution', ':')) || _resolutionY;
1232
- _refreshRate = util.toInt(util.getValue(lines, 'CurrentRefreshRate', ':')) || _refreshRate;
1233
- _pixelDepth = util.toInt(util.getValue(lines, 'CurrentBitsPerPixel', ':')) || _pixelDepth;
1234
- }
1235
- }
1236
- }
1237
- return controllers;
1238
- }
1239
-
1240
- function parseLinesWindowsDisplaysPowershell(ssections, monitors, dsections, connections, isections, currentModes) {
1241
- const displays = [];
1242
- let vendor = '';
1243
- let model = '';
1244
- let deviceID = '';
1245
- let resolutionX = 0;
1246
- let resolutionY = 0;
1247
- if (dsections && dsections.length) {
1248
- const linesDisplay = dsections[0].split('\n');
1249
- vendor = util.getValue(linesDisplay, 'MonitorManufacturer', ':');
1250
- model = util.getValue(linesDisplay, 'Name', ':');
1251
- deviceID = util.getValue(linesDisplay, 'PNPDeviceID', ':').replace(/&amp;/g, '&').toLowerCase();
1252
- resolutionX = util.toInt(util.getValue(linesDisplay, 'ScreenWidth', ':'));
1253
- resolutionY = util.toInt(util.getValue(linesDisplay, 'ScreenHeight', ':'));
1254
- }
1255
- // iterate over physical monitors too - mirrored monitors have no own logical screen (issue #940)
1256
- const count = Math.max(ssections.length, monitors.length);
1257
- for (let i = 0; i < count; i++) {
1258
- const hasOwnScreen = i < ssections.length;
1259
- // mirrored monitors show the same image as the first screen
1260
- const ssection = hasOwnScreen ? ssections[i] : ssections[0];
1261
- if (ssection !== undefined && ssection.trim() !== '') {
1262
- const linesScreen = ('BitsPerPixel ' + ssection).split('\n');
1263
- // screen <-> monitor correlation stays index based - Forms.Screen exposes no shared key with root\wmi
1264
- const monitor = monitors[i];
1265
- const instanceName = monitor ? monitor.instanceName : '';
1266
- const bitsPerPixel = util.toInt(util.getValue(linesScreen, 'BitsPerPixel')) || null;
1267
- const bounds = util.getValue(linesScreen, 'Bounds').replace('{', '').replace('}', '').replace(/=/g, ':').split(',');
1268
- const primary = util.getValue(linesScreen, 'Primary');
1269
- const sizeX = monitor ? monitor.sizeX : '';
1270
- const sizeY = monitor ? monitor.sizeY : '';
1271
- const videoOutputTechnology = instanceName && connections[instanceName] !== undefined ? connections[instanceName] : '';
1272
- const deviceName = util.getValue(linesScreen, 'DeviceName');
1273
- // WmiMonitorID data matches per InstanceName - prefer it over the locale-dependent Win32_DesktopMonitor values
1274
- const isection = instanceName ? isections.find((element) => element.instanceId.toLowerCase().startsWith(instanceName)) : undefined;
1275
- displays.push({
1276
- vendor: (isection && isection.vendor) || (instanceName.startsWith(deviceID) ? vendor : ''),
1277
- model: (isection && isection.model) || (instanceName.startsWith(deviceID) ? model : ''),
1278
- serial: (isection && isection.serial) || null,
1279
- productionYear: isection ? isection.productionYear : null,
1280
- displayId: instanceName || null,
1281
- deviceName,
1282
- main: hasOwnScreen ? primary.toLowerCase() === 'true' : false,
1283
- builtin: videoOutputTechnology === '2147483648',
1284
- connection: videoOutputTechnology && videoTypes[videoOutputTechnology] ? videoTypes[videoOutputTechnology] : '',
1285
- resolutionX: util.toInt(util.getValue(bounds, 'Width', ':')),
1286
- resolutionY: util.toInt(util.getValue(bounds, 'Height', ':')),
1287
- sizeX: sizeX ? parseInt(sizeX, 10) : null,
1288
- sizeY: sizeY ? parseInt(sizeY, 10) : null,
1289
- pixelDepth: bitsPerPixel,
1290
- currentResX: util.toInt(util.getValue(bounds, 'Width', ':')),
1291
- currentResY: util.toInt(util.getValue(bounds, 'Height', ':')),
1292
- positionX: util.toInt(util.getValue(bounds, 'X', ':')),
1293
- positionY: util.toInt(util.getValue(bounds, 'Y', ':')),
1294
- currentRefreshRate: currentModes[deviceName.toLowerCase()] || null
1295
- });
1296
- }
1297
- }
1298
- if (ssections.length === 0) {
1299
- displays.push({
1300
- vendor,
1301
- model,
1302
- serial: null,
1303
- productionYear: null,
1304
- displayId: null,
1305
- main: true,
1306
- sizeX: null,
1307
- sizeY: null,
1308
- resolutionX,
1309
- resolutionY,
1310
- pixelDepth: null,
1311
- currentResX: resolutionX,
1312
- currentResY: resolutionY,
1313
- positionX: 0,
1314
- positionY: 0
1315
- });
1316
- }
1317
- return displays;
1318
- }
1319
- }
1320
-
1321
- exports.graphics = graphics;