{"_id":"@bun-win32/powrprof","_rev":"4-63a81746613b74493b58fa0576af89e3","name":"@bun-win32/powrprof","dist-tags":{"latest":"2.0.1"},"versions":{"1.0.0":{"name":"@bun-win32/powrprof","version":"1.0.0","keywords":["bun","ffi","win32","windows","powrprof","bindings","typescript","dll"],"author":"Stev Peifer <stev@bell.net>","license":"MIT","_id":"@bun-win32/powrprof@1.0.0","maintainers":[{"name":"obscuritysrl","email":"stev@bell.net"}],"homepage":"https://github.com/ObscuritySRL/bun-win32#readme","bugs":{"url":"https://github.com/ObscuritySRL/bun-win32/issues"},"dist":{"shasum":"fad2f9061d0163f74d8384f834bbfbb0dd035ac7","tarball":"https://registry.npmjs.org/@bun-win32/powrprof/-/powrprof-1.0.0.tgz","fileCount":6,"integrity":"sha512-FXEN3SxvAfkPRIg8HY3oT35DYF/hez+JpgYSSsfxNb8s5KPjnvWlqGETJs02ccOMrAyU+VCBNwauJyXIpChU/g==","signatures":[{"sig":"MEUCIQCUPZirKxHH9RbQJGlzvMuupvoZhMRTLPflZdQMOHnaMwIgGOYhAvMy4AEEveAtR5UF5C6Vw7wB6krMxf/qVyOvm5s=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":51948},"main":"./index.ts","type":"module","module":"index.ts","shasum":"fad2f9061d0163f74d8384f834bbfbb0dd035ac7","engines":{"bun":">=1.1.0"},"exports":{".":"./index.ts"},"private":false,"scripts":{"example":"bun ./example/powrprof.ts"},"_npmUser":{"name":"obscuritysrl","email":"stev@bell.net"},"_integrity":"sha512-FXEN3SxvAfkPRIg8HY3oT35DYF/hez+JpgYSSsfxNb8s5KPjnvWlqGETJs02ccOMrAyU+VCBNwauJyXIpChU/g==","repository":{"url":"git://github.com/ObscuritySRL/bun-win32.git","type":"git","directory":"packages/powrprof"},"_npmVersion":"10.8.3","description":"Zero-dependency, zero-overhead Win32 POWRPROF bindings for Bun (FFI) on Windows.","directories":{},"sideEffects":false,"_nodeVersion":"24.3.0","dependencies":{"@bun-win32/core":"1.1.1"},"_hasShrinkwrap":false,"devDependencies":{"@types/bun":"latest"},"peerDependencies":{"typescript":"^5"},"_npmOperationalInternal":{"tmp":"tmp/powrprof_1.0.0_1775657293598_0.7528787295515031","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@bun-win32/powrprof","version":"1.0.1","keywords":["bun","ffi","win32","windows","powrprof","bindings","typescript","dll"],"author":"Stev Peifer <stev@bell.net>","license":"MIT","_id":"@bun-win32/powrprof@1.0.1","maintainers":[{"name":"obscuritysrl","email":"stev@bell.net"}],"homepage":"https://github.com/ObscuritySRL/bun-win32#readme","bugs":{"url":"https://github.com/ObscuritySRL/bun-win32/issues"},"dist":{"shasum":"617c9be33934b81b7d6c9e969755759b38a60ec6","tarball":"https://registry.npmjs.org/@bun-win32/powrprof/-/powrprof-1.0.1.tgz","fileCount":6,"integrity":"sha512-dIMfVI7fQ62GJLBiw+now/5E1/PrhW7VHhyMICOAF1zyMf7sg6KrlGfd5b6FNLsEGxgiDEaQx0/BHrYVq7V3Ww==","signatures":[{"sig":"MEQCICq68YFsRw5opjdRfe2YdXV7lzlb9rLNXUCik1TDBf4KAiBWCOV/C719jYk1fx+YPz1ZPhxZPFwKz/hrT1yZy0Zc7w==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":52095},"main":"./index.ts","type":"module","module":"index.ts","shasum":"617c9be33934b81b7d6c9e969755759b38a60ec6","engines":{"bun":">=1.1.0"},"exports":{".":"./index.ts"},"private":false,"scripts":{"example:power-audit":"bun ./example/power-audit.ts","example:battery-advisor":"bun ./example/battery-advisor.ts"},"_npmUser":{"name":"obscuritysrl","email":"stev@bell.net"},"_integrity":"sha512-dIMfVI7fQ62GJLBiw+now/5E1/PrhW7VHhyMICOAF1zyMf7sg6KrlGfd5b6FNLsEGxgiDEaQx0/BHrYVq7V3Ww==","repository":{"url":"git://github.com/ObscuritySRL/bun-win32.git","type":"git","directory":"packages/powrprof"},"_npmVersion":"10.8.3","description":"Zero-dependency, zero-overhead Win32 POWRPROF bindings for Bun (FFI) on Windows.","directories":{},"sideEffects":false,"_nodeVersion":"24.3.0","dependencies":{"@bun-win32/core":"1.1.1"},"_hasShrinkwrap":false,"devDependencies":{"@types/bun":"latest","@bun-win32/kernel32":"1.0.20"},"peerDependencies":{"typescript":"^5"},"_npmOperationalInternal":{"tmp":"tmp/powrprof_1.0.1_1775687620423_0.42750115356332397","host":"s3://npm-registry-packages-npm-production"}},"2.0.0":{"name":"@bun-win32/powrprof","version":"2.0.0","keywords":["bun","ffi","win32","windows","powrprof","bindings","typescript","dll"],"author":"Stev Peifer <stev.p@outlook.com>","license":"MIT","_id":"@bun-win32/powrprof@2.0.0","maintainers":[{"name":"obscuritysrl","email":"stev.p@outlook.com"}],"homepage":"https://github.com/ObscuritySRL/bun-win32#readme","bugs":{"url":"https://github.com/ObscuritySRL/bun-win32/issues"},"dist":{"shasum":"cc8e2a34444c472cbb805b4908b5e03af909c292","tarball":"https://registry.npmjs.org/@bun-win32/powrprof/-/powrprof-2.0.0.tgz","fileCount":6,"integrity":"sha512-OeHECJBq1OdB8BeqlvK6/kVUenL/iLrNAk+kpc3gRjEaEOhyLfgUayVsyaDVtRjqt6njqa4UVluNqbP4dfxJaw==","signatures":[{"sig":"MEQCIBymvEHurgrC88g0R/sHW4dvojkrDkEF5qUNbQV5T4xiAiA1HoAACrQz5R3+P4vh1T9kUdcfW8/CDIAKXY6p0XkWcQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":54591},"main":"./index.ts","type":"module","module":"index.ts","shasum":"cc8e2a34444c472cbb805b4908b5e03af909c292","engines":{"bun":">=1.1.0"},"exports":{".":"./index.ts"},"private":false,"scripts":{"example:power-audit":"bun ./example/power-audit.ts","example:battery-advisor":"bun ./example/battery-advisor.ts"},"_npmUser":{"name":"obscuritysrl","email":"stev.p@outlook.com"},"_integrity":"sha512-OeHECJBq1OdB8BeqlvK6/kVUenL/iLrNAk+kpc3gRjEaEOhyLfgUayVsyaDVtRjqt6njqa4UVluNqbP4dfxJaw==","repository":{"url":"git://github.com/ObscuritySRL/bun-win32.git","type":"git","directory":"packages/powrprof"},"_npmVersion":"10.8.3","description":"Zero-dependency, zero-overhead Win32 POWRPROF bindings for Bun (FFI) on Windows.","directories":{},"sideEffects":false,"_nodeVersion":"26.3.0","dependencies":{"@bun-win32/core":"2.0.0"},"_hasShrinkwrap":false,"devDependencies":{"@types/bun":"latest","@bun-win32/kernel32":"2.0.0"},"peerDependencies":{"typescript":"^5"},"_npmOperationalInternal":{"tmp":"tmp/powrprof_2.0.0_1782435491264_0.31050208022983306","host":"s3://npm-registry-packages-npm-production"}},"2.0.1":{"author":"Stev Peifer <stev.p@outlook.com>","bugs":{"url":"https://github.com/ObscuritySRL/bun-win32/issues"},"dependencies":{"@bun-win32/core":"2.0.1"},"description":"Zero-dependency, zero-overhead Win32 POWRPROF bindings for Bun (FFI) on Windows.","devDependencies":{"@bun-win32/kernel32":"2.0.1","@types/bun":"latest"},"exports":{".":"./index.ts"},"license":"MIT","module":"index.ts","name":"@bun-win32/powrprof","peerDependencies":{"typescript":"^5"},"private":false,"homepage":"https://github.com/ObscuritySRL/bun-win32#readme","repository":{"type":"git","url":"git://github.com/ObscuritySRL/bun-win32.git","directory":"packages/powrprof"},"type":"module","version":"2.0.1","main":"./index.ts","keywords":["bun","ffi","win32","windows","powrprof","bindings","typescript","dll"],"sideEffects":false,"engines":{"bun":">=1.1.0"},"scripts":{"example:battery-advisor":"bun ./example/battery-advisor.ts","example:power-audit":"bun ./example/power-audit.ts"},"_id":"@bun-win32/powrprof@2.0.1","_integrity":"sha512-M5NjfTFOXuJTpN/Ttvb0uZZKdOQwFlGxz8/vdNfzh4J3tOY5lYB7mCNyu0H5RyU3nkDmhArLbOJdAN6gn1PdGA==","_nodeVersion":"26.3.0","_npmVersion":"10.8.3","shasum":"599fc19384e64be80ab4c005f99f6299dd375910","dist":{"integrity":"sha512-M5NjfTFOXuJTpN/Ttvb0uZZKdOQwFlGxz8/vdNfzh4J3tOY5lYB7mCNyu0H5RyU3nkDmhArLbOJdAN6gn1PdGA==","shasum":"599fc19384e64be80ab4c005f99f6299dd375910","tarball":"https://registry.npmjs.org/@bun-win32/powrprof/-/powrprof-2.0.1.tgz","fileCount":6,"unpackedSize":54591,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIEXsiSPqL2/m/8J2XyjgdEeOh6R5sx/QG53DljFqJ4J6AiA5sjpbZHtZ9hdX4XPDt+R0kITGputVXG9f97jT54glrw=="}]},"_npmUser":{"name":"obscuritysrl","email":"stev.p@outlook.com"},"directories":{},"maintainers":[{"name":"obscuritysrl","email":"stev.p@outlook.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/powrprof_2.0.1_1782438151308_0.1383050001720294"},"_hasShrinkwrap":false}},"time":{"created":"2026-04-08T14:08:13.482Z","modified":"2026-06-26T01:42:31.553Z","1.0.0":"2026-04-08T14:08:13.756Z","1.0.1":"2026-04-08T22:33:40.593Z","2.0.0":"2026-06-26T00:58:11.401Z","2.0.1":"2026-06-26T01:42:31.450Z"},"bugs":{"url":"https://github.com/ObscuritySRL/bun-win32/issues"},"author":"Stev Peifer <stev.p@outlook.com>","license":"MIT","homepage":"https://github.com/ObscuritySRL/bun-win32#readme","keywords":["bun","ffi","win32","windows","powrprof","bindings","typescript","dll"],"repository":{"type":"git","url":"git://github.com/ObscuritySRL/bun-win32.git","directory":"packages/powrprof"},"description":"Zero-dependency, zero-overhead Win32 POWRPROF bindings for Bun (FFI) on Windows.","maintainers":[{"name":"obscuritysrl","email":"stev.p@outlook.com"}],"readme":"# @bun-win32/powrprof\n\nZero-dependency, zero-overhead Win32 PowrProf bindings for [Bun](https://bun.sh) on Windows.\n\n## Overview\n\n`@bun-win32/powrprof` exposes the `powrprof.dll` exports using [Bun](https://bun.sh)'s FFI. It provides a single class, `PowrProf`, which lazily binds native symbols on first use. You can optionally preload a subset or all symbols up-front via `Preload()`.\n\nThe bindings are strongly typed for a smooth DX in TypeScript.\n\n## Features\n\n- [Bun](https://bun.sh)-first ergonomics on Windows 10/11.\n- Direct FFI to `powrprof.dll` (power schemes, policies, sleep states, and battery management).\n- In-source docs in `structs/PowrProf.ts` with links to Microsoft Docs.\n- Lazy binding on first call; optional eager preload (`PowrProf.Preload()`).\n- No wrapper overhead; calls map 1:1 to native APIs.\n- Strongly-typed Win32 aliases (see `types/PowrProf.ts`).\n\n## Requirements\n\n- [Bun](https://bun.sh) runtime\n- Windows 10 or later\n\n## Installation\n\n```sh\nbun add @bun-win32/powrprof\n```\n\n## Quick Start\n\n```ts\nimport PowrProf, { POWER_INFORMATION_LEVEL } from '@bun-win32/powrprof';\n\n// Get system battery state\nconst batteryState = Buffer.alloc(64);\nconst status = PowrProf.CallNtPowerInformation(\n  POWER_INFORMATION_LEVEL.SystemBatteryState,\n  null, 0,\n  batteryState.ptr, batteryState.byteLength,\n);\n\nif (status === 0) {\n  const view = new DataView(batteryState.buffer);\n  const acOnLine = view.getUint8(0);\n  const batteryPresent = view.getUint8(1);\n  console.log(`AC: ${acOnLine ? 'plugged in' : 'battery'}`);\n  console.log(`Battery present: ${batteryPresent ? 'yes' : 'no'}`);\n}\n```\n\n> [!NOTE]\n> AI agents: see `AI.md` for the package binding contract and source-navigation guidance. It explains how to use the package without scanning the entire implementation.\n\n## Examples\n\nRun the included examples:\n\n```sh\nbun run example/powrprof.ts\n```\n\n## Notes\n\n- Either rely on lazy binding or call `PowrProf.Preload()`.\n- Windows only. Bun runtime required.\n- **SAL types & naming:** nullability is in the **type** — `Optional<T>` (formally optional, SAL `_*opt_`) and `Nullable<T>` (plain `[in]`/`[out]` the docs say can be NULL), the null sentinel derived from `T` (`null` for pointers `LP*`/`P*`, `0n` for handles/by-value addresses); direction is in the **parameter name** — `_out` (`_Out_`), `_in_out` (`_Inout_`), `_In_` bare. See `AI.md` and the repo `AGENTS.md`.\n","readmeFilename":"README.md"}