{"_id":"@bun-win32/sensapi","_rev":"3-d3416ce9b0fa38bc5dd26c449e3acaba","name":"@bun-win32/sensapi","dist-tags":{"latest":"2.0.1"},"versions":{"1.0.0":{"name":"@bun-win32/sensapi","version":"1.0.0","keywords":["bun","ffi","win32","windows","sensapi","bindings","typescript","dll"],"author":"Stev Peifer <stev@bell.net>","license":"MIT","_id":"@bun-win32/sensapi@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":"69c0650c22ffee6711b7b4519ce2457aabe27d6b","tarball":"https://registry.npmjs.org/@bun-win32/sensapi/-/sensapi-1.0.0.tgz","fileCount":6,"integrity":"sha512-mirg/uHAz0WLq7/km62dO87lWAmdZ0x27PVripUiOSqqtW8q+2E/WrTYQdVgADeabox72BWRkXDHuGMNBcNfEg==","signatures":[{"sig":"MEQCIGQ8q5GiX3l/ayFRC7OaFIbxlWmracGfum3vZM/0ZklpAiB3giavnhLKr9RE2IypePoJbbBxbTWNgFMZ0k9PV2pN1g==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":9004},"main":"./index.ts","type":"module","module":"index.ts","shasum":"69c0650c22ffee6711b7b4519ce2457aabe27d6b","engines":{"bun":">=1.1.0"},"exports":{".":"./index.ts"},"private":false,"scripts":{"example:network-diag":"bun ./example/network-diag.ts","example:link-sentinel":"bun ./example/link-sentinel.ts"},"_npmUser":{"name":"obscuritysrl","email":"stev@bell.net"},"_integrity":"sha512-mirg/uHAz0WLq7/km62dO87lWAmdZ0x27PVripUiOSqqtW8q+2E/WrTYQdVgADeabox72BWRkXDHuGMNBcNfEg==","repository":{"url":"git://github.com/ObscuritySRL/bun-win32.git","type":"git","directory":"packages/sensapi"},"_npmVersion":"10.8.3","description":"Zero-dependency, zero-overhead Win32 SENSAPI bindings for Bun (FFI) on Windows.","directories":{},"sideEffects":false,"_nodeVersion":"24.3.0","dependencies":{"@bun-win32/core":"1.1.2"},"_hasShrinkwrap":false,"devDependencies":{"@types/bun":"latest","@bun-win32/kernel32":"1.0.21"},"peerDependencies":{"typescript":"^5"},"_npmOperationalInternal":{"tmp":"tmp/sensapi_1.0.0_1778689585599_0.9369866830114404","host":"s3://npm-registry-packages-npm-production"}},"2.0.0":{"name":"@bun-win32/sensapi","version":"2.0.0","keywords":["bun","ffi","win32","windows","sensapi","bindings","typescript","dll"],"author":"Stev Peifer <stev.p@outlook.com>","license":"MIT","_id":"@bun-win32/sensapi@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":"780992d44d045a66ede36f20c36791f559cf0614","tarball":"https://registry.npmjs.org/@bun-win32/sensapi/-/sensapi-2.0.0.tgz","fileCount":6,"integrity":"sha512-pMGGQO+lnWJywe8+NitK4ewVVy3sQ8g4nYP2R5E8SLXqiBGjBFkvUkpS+G9HwAlyeHmqqlAtxyvLhRlZ+eRjNA==","signatures":[{"sig":"MEYCIQCbj9JBD2qq4t4Jre9ZsmafsihsbE4VXLkSU59YluIFgQIhAO0YXwv1D+FfF1nX/KTZdBxVvj8izXDdFDcpDg36yQkF","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":10264},"main":"./index.ts","type":"module","module":"index.ts","shasum":"780992d44d045a66ede36f20c36791f559cf0614","engines":{"bun":">=1.1.0"},"exports":{".":"./index.ts"},"private":false,"scripts":{"example:network-diag":"bun ./example/network-diag.ts","example:link-sentinel":"bun ./example/link-sentinel.ts"},"_npmUser":{"name":"obscuritysrl","email":"stev.p@outlook.com"},"_integrity":"sha512-pMGGQO+lnWJywe8+NitK4ewVVy3sQ8g4nYP2R5E8SLXqiBGjBFkvUkpS+G9HwAlyeHmqqlAtxyvLhRlZ+eRjNA==","repository":{"url":"git://github.com/ObscuritySRL/bun-win32.git","type":"git","directory":"packages/sensapi"},"_npmVersion":"10.8.3","description":"Zero-dependency, zero-overhead Win32 SENSAPI 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/sensapi_2.0.0_1782435503850_0.7620267394136866","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 SENSAPI 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/sensapi","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/sensapi"},"type":"module","version":"2.0.1","main":"./index.ts","keywords":["bun","ffi","win32","windows","sensapi","bindings","typescript","dll"],"sideEffects":false,"engines":{"bun":">=1.1.0"},"scripts":{"example:link-sentinel":"bun ./example/link-sentinel.ts","example:network-diag":"bun ./example/network-diag.ts"},"_id":"@bun-win32/sensapi@2.0.1","_integrity":"sha512-d2W+xwpXqwHVUDo8XkaQSBaAhqRrjjIYguPFlMD2yWyP6079eQJDnGAq1Chn0WHfruL3uYjMyx5v3393IoZg0Q==","_nodeVersion":"26.3.0","_npmVersion":"10.8.3","shasum":"48301e527122d2ffbf7ac4b9cb15b2094a9716cf","dist":{"integrity":"sha512-d2W+xwpXqwHVUDo8XkaQSBaAhqRrjjIYguPFlMD2yWyP6079eQJDnGAq1Chn0WHfruL3uYjMyx5v3393IoZg0Q==","shasum":"48301e527122d2ffbf7ac4b9cb15b2094a9716cf","tarball":"https://registry.npmjs.org/@bun-win32/sensapi/-/sensapi-2.0.1.tgz","fileCount":6,"unpackedSize":10264,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQD/0HweVg+EsAR6HXljLLGxrCu9ZVk9sM7GhYmvn1h4WgIhANs0eHg8JKNewUhAYeBlLpK0DI9zmSKwJHPIoTRf2fVc"}]},"_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/sensapi_2.0.1_1782438164176_0.302900743439503"},"_hasShrinkwrap":false}},"time":{"created":"2026-05-13T16:26:25.533Z","modified":"2026-06-26T01:42:44.443Z","1.0.0":"2026-05-13T16:26:25.796Z","2.0.0":"2026-06-26T00:58:23.974Z","2.0.1":"2026-06-26T01:42:44.335Z"},"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","sensapi","bindings","typescript","dll"],"repository":{"type":"git","url":"git://github.com/ObscuritySRL/bun-win32.git","directory":"packages/sensapi"},"description":"Zero-dependency, zero-overhead Win32 SENSAPI bindings for Bun (FFI) on Windows.","maintainers":[{"name":"obscuritysrl","email":"stev.p@outlook.com"}],"readme":"# @bun-win32/sensapi\n\nZero-dependency, zero-overhead Win32 Sensapi bindings for [Bun](https://bun.sh) on Windows.\n\n## Overview\n\n`@bun-win32/sensapi` exposes the `sensapi.dll` exports using [Bun](https://bun.sh)'s FFI. It provides a single class, `Sensapi`, 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 `sensapi.dll` (System Event Notification Service connectivity checks — `IsNetworkAlive`, `IsDestinationReachable`).\n- In-source docs in `structs/Sensapi.ts` with links to Microsoft Docs.\n- Lazy binding on first call; optional eager preload (`Sensapi.Preload()`).\n- No wrapper overhead; calls map 1:1 to native APIs.\n- Strongly-typed Win32 aliases (see `types/Sensapi.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/sensapi\n```\n\n## Quick Start\n\n```ts\nimport Sensapi, { NetworkAliveFlags } from '@bun-win32/sensapi';\n\nSensapi.Preload(['IsNetworkAlive']);\n\nconst flagsBuffer = Buffer.alloc(4);\nconst alive = Sensapi.IsNetworkAlive(flagsBuffer.ptr);\nconst flags = flagsBuffer.readUInt32LE(0);\n\nif (alive === 0) {\n  console.log('No active network connection');\n} else {\n  const parts: string[] = [];\n\n  if ((flags & NetworkAliveFlags.NETWORK_ALIVE_LAN) !== 0) parts.push('LAN');\n  if ((flags & NetworkAliveFlags.NETWORK_ALIVE_WAN) !== 0) parts.push('WAN');\n  if ((flags & NetworkAliveFlags.NETWORK_ALIVE_AOL) !== 0) parts.push('AOL');\n  if ((flags & NetworkAliveFlags.NETWORK_ALIVE_INTERNET) !== 0) parts.push('Internet');\n\n  console.log(`Network alive: ${parts.join(', ') || '(unknown)'} (flags=0x${flags.toString(16).padStart(8, '0')})`);\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:network-diag\nbun run example:link-sentinel\n```\n\n## Notes\n\n- Either rely on lazy binding or call `Sensapi.Preload()`.\n- Windows only. Bun runtime required.\n- `IsDestinationReachable[AW]` is documented as unsupported on Windows Vista and later — Microsoft's guidance is to use the Network List Manager for new code. The binding is still exposed because the export exists and the call is still well-defined (`GetLastError` returns `ERROR_CALL_NOT_IMPLEMENTED`).\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"}