macos-temperature-sensor
Advanced tools
+0
-1
@@ -27,3 +27,2 @@ const lib_version = require("../package.json").version; | ||
| if (_darwin) { | ||
| // macOS does not provide a native way to get CPU temperature | ||
| const tdie = []; // CPU | ||
@@ -30,0 +29,0 @@ const tpg = []; // SoC |
+1
-7
@@ -16,3 +16,2 @@ #include "temps.h" | ||
| // IOHIDEventFieldBase(type) is usually (type << 16). We'll mirror that. | ||
| static inline uint32_t IOHIDEventFieldBase_local(uint32_t type) { | ||
@@ -22,3 +21,2 @@ return (type << 16); | ||
| // Function pointer types (opaque, header-less) | ||
| typedef IOHIDEventSystemClientRef (*pIOHIDEventSystemClientCreate)(CFAllocatorRef allocator); | ||
@@ -32,3 +30,2 @@ typedef CFArrayRef (*pIOHIDEventSystemClientCopyServices)(IOHIDEventSystemClientRef client); | ||
| // Resolved symbols | ||
| static pIOHIDEventSystemClientCreate fClientCreate = NULL; | ||
@@ -43,3 +40,2 @@ static pIOHIDEventSystemClientCopyServices fCopyServices = NULL; | ||
| // These symbols live in IOKit.framework. We open it explicitly. | ||
| void* h = dlopen("/System/Library/Frameworks/IOKit.framework/IOKit", RTLD_LAZY); | ||
@@ -77,3 +73,2 @@ if (!h) return 0; | ||
| // IOHIDEventRef is a CFType, so CFRelease is valid | ||
| CFRelease((CFTypeRef)ev); | ||
@@ -88,3 +83,3 @@ return v; | ||
| if (!resolve_hid_symbols()) { | ||
| return 100; // missing runtime symbols (very unlikely on macOS) | ||
| return 100; | ||
| } | ||
@@ -108,3 +103,2 @@ | ||
| // Count services that at least have a Product string | ||
| size_t cap = 0; | ||
@@ -111,0 +105,0 @@ for (CFIndex i = 0; i < n; i++) { |
+4
-6
@@ -14,12 +14,10 @@ #pragma once | ||
| typedef struct { | ||
| double p_core_avg_c; // avg of "pACC MTR Temp Sensor*" sensors | ||
| double e_core_avg_c; // avg of "eACC MTR Temp Sensor*" sensors | ||
| size_t sensor_count; // number of returned sensors in sensors[] | ||
| mt_sensor_t* sensors; // malloc'ed array; free with mt_free_snapshot() | ||
| double p_core_avg_c; | ||
| double e_core_avg_c; | ||
| size_t sensor_count; | ||
| mt_sensor_t* sensors; | ||
| } mt_snapshot_t; | ||
| // Collect a snapshot. Returns 0 on success, non-zero on error. | ||
| int mt_read_snapshot(mt_snapshot_t* out); | ||
| // Frees memory owned by snapshot (sensors array) | ||
| void mt_free_snapshot(mt_snapshot_t* s); | ||
@@ -26,0 +24,0 @@ |
+1
-1
| { | ||
| "name": "macos-temperature-sensor", | ||
| "version": "1.0.3", | ||
| "version": "1.0.4", | ||
| "main": "lib/index.js", | ||
@@ -5,0 +5,0 @@ "gypfile": true, |
+4
-3
@@ -68,3 +68,3 @@ # macos-temperature-sensor | ||
| ```json | ||
| ``` | ||
| { | ||
@@ -102,2 +102,3 @@ cpu: 45.832000732421875, | ||
| | ------- | ---------- | --------------------------------------------------------------------------------------------------- | | ||
| | 1.0.4 | 24.12.2025 | fix docs | | ||
| | 1.0.3 | 22.12.2025 | doc improvements | | ||
@@ -120,3 +121,3 @@ | 1.0.2 | 21.12.2025 | added TS typings, doc improvements | | ||
| | macosTemp.version() | library version (no callback/promise) | | ||
| | macosTemp.cpuTemperature(cb) | CPU temperature (if sensors is installed) in Celsius | | ||
| | macosTemp.temperature() | CPU temperature (if sensors is installed) in Celsius | | ||
| | - cpu | cpu max temperature | | ||
@@ -152,3 +153,3 @@ | - soc | soc avg temperature | | ||
| macOS are registered trademarks of Apple Inc., Node.js is a trademark of OpenJS Foundation. | ||
| Apple and macOS are registered trademarks of Apple Inc., Node.js is a trademark of OpenJS Foundation. | ||
| All other trademarks are the property of their respective owners. | ||
@@ -155,0 +156,0 @@ |
+1
-1
| const macTemp = require("../lib/index.js"); | ||
| console.log("mac-temperature-sensor version:", macTemp.version()); | ||
| console.log("mac-temperature-sensor library version:", macTemp.version()); | ||
@@ -5,0 +5,0 @@ try { |
199
0.51%69263
-0.93%70
-1.41%