@node-ctypes/winrt)Typed Windows Runtime (WinRT) projections and .winmd (ECMA-335) TypeScript code generator for Node.js, powered by
@node-ctypes/comtypes and
node-ctypes.
Think of it as PyWinRT / windows-rs for Node.js — pure TypeScript, zero C++ compilation.
.winmd reader & codegen: reads C:\Windows\System32\WinMetadata\*.winmd or Windows App SDK .winmd files (--winapp) with exact WinRT UUIDv5 PIIDs and --only tree-shaking.IAsyncAction/IAsyncOperation<T> via free-threaded CompletedHandler, on<Event>(), WinRTVector, bootstrapWindowsAppRuntime() (zero Bootstrap.dll), and COM aggregation (composeWinRTClass).npm install @node-ctypes/winrt
npx node-winrt generate Windows.Media.Ocr Windows.Globalization Windows.Security.Credentials.UI --out src/winrt
import { Language } from "./winrt/Windows.Globalization.ts";
import { OcrEngine } from "./winrt/Windows.Media.Ocr.ts";
import { UserConsentVerifier } from "./winrt/Windows.Security.Credentials.UI.ts";
// Event-driven WinRT async -> Promise
const availability = await UserConsentVerifier.checkAvailabilityAsync();
console.log("Windows Hello availability:", availability);
// Disposable WinRT classes (`IClosable::Close()` + `Release()`)
using lang = Language.createLanguage("en-US");
console.log(lang?.languageTag, lang?.displayName);
using engine = OcrEngine.tryCreateFromUserProfileLanguages();
console.log("OCR max dimension:", OcrEngine.maxImageDimension);
To build from source, see Getting started.
| Operating system | x64 | ARM64 | Notes |
|---|---|---|---|
| Windows 10 / 11 | ✅ | ✅ | Full WinRT runtime, WinUI 3 (bootstrapWindowsAppRuntime) and .winmd codegen |
| macOS / Linux | ✅ | ✅ | .winmd parser, PIID calculator and TypeScript code generator run cross-platform |
Node.js 24 or later. Verified in Electron / mirror mode (NODE_CTYPES_NO_EXTERNAL_BUFFERS=1).
.winmd reader, PIID computation, tree-shaking (--only), --winapp, --js emit and type mappingsPromises, on<Event>() delegates, WinRTVector, IVectorView, IMapView, IReference and byte arraysbootstrapWindowsAppRuntime() (zero Bootstrap.dll), DPI awareness, Win32 message loop, COM aggregation (composeWinRTClass) and registration-free DLLsGenerate projections for all examples (npm run demo:gen:all), then run any example directly; see the index.
class App extends Application + override onLaunched() (counterpart to PyWinRT's hello_app.py)async/await event handlers (node:timers/promises, fetch(), WinRT *Async()) via DesktopWindowXamlSource + startWin32MessageLoop()Application + Window + MicaBackdrop + NavigationView + 30 Fluent v2 controlsUserConsentVerifier biometric / PIN promptStorageFile + BitmapDecoder + OcrEngine on PNG/JPG imagesToastNotificationManager + XmlDocumentBluetoothLEAdvertisementWatcher live WinRT events