@node-ctypes/winrt - v0.1.0
    Preparing search index...

    @node-ctypes/winrt - v0.1.0

    node-winrt (@node-ctypes/winrt)

    npm version npm downloads CI License: MIT

    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.

    • Node.js 24+, ESM, TypeScript declarations.
    • Zero-dependency .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.
    • Event-driven WinRT async, events, collections & WinUI 3: 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).



    Generate projections for all examples (npm run demo:gen:all), then run any example directly; see the index.

    • Hello WinUI 3 — minimal class App extends Application + override onLaunched() (counterpart to PyWinRT's hello_app.py)
    • Async WinUI 3 — Fluent v2 WinUI 3 with full async/await event handlers (node:timers/promises, fetch(), WinRT *Async()) via DesktopWindowXamlSource + startWin32MessageLoop()
    • WinUI 3 Controls Gallery — native Application + Window + MicaBackdrop + NavigationView + 30 Fluent v2 controls
    • Windows Hello — UserConsentVerifier biometric / PIN prompt
    • OCR Image — StorageFile + BitmapDecoder + OcrEngine on PNG/JPG images
    • Toast Notification — ToastNotificationManager + XmlDocument
    • Bluetooth LE Scanner — BluetoothLEAdvertisementWatcher live WinRT events

    MIT. See NOTICE for third-party specification references.