Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,9 @@ jobs:
- name: Test metadata-driven COM borrowed copies
working-directory: bindings/js
run: npm run test:borrowed-copy
- name: Test Win32 failed-cleanup recovery
working-directory: bindings/js
run: node --expose-gc __test__\fixtures\win32-cleanup-errors.cjs

# dynwinrt-codegen (x64 + arm64)
dynwinrt-codegen:
Expand Down
31 changes: 2 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,13 @@
# dynwinrt

**An experimental runtime for calling Windows APIs from JavaScript, TypeScript, or Python — without writing a native extension.**
**Call Windows Runtime (WinRT) APIs from JavaScript, TypeScript, or Python — without writing a native extension.**

[![@microsoft/dynwinrt](https://img.shields.io/npm/v/@microsoft/dynwinrt.svg?label=%40microsoft%2Fdynwinrt)](https://www.npmjs.com/package/@microsoft/dynwinrt)
[![@microsoft/dynwinrt-codegen](https://img.shields.io/npm/v/@microsoft/dynwinrt-codegen.svg?label=%40microsoft%2Fdynwinrt-codegen)](https://www.npmjs.com/package/@microsoft/dynwinrt-codegen)
[![dynwinrt on PyPI](https://img.shields.io/pypi/v/dynwinrt.svg?label=PyPI%20dynwinrt)](https://pypi.org/project/dynwinrt/)
[![dynwinrt-codegen on PyPI](https://img.shields.io/pypi/v/dynwinrt-codegen.svg?label=PyPI%20dynwinrt-codegen)](https://pypi.org/project/dynwinrt-codegen/)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)

> **Status: experimental.** `dynwinrt` is under active development and intended
> for evaluation and prototyping. Public APIs, generated bindings, and
> runtime/codegen contracts may change between releases; backward compatibility
> is not yet guaranteed. Do not treat it as a stable production dependency.
> Use matching runtime and codegen versions, regenerate bindings when upgrading,
> and validate the APIs you rely on in your target environment.
>
> WinRT projections are available for JavaScript/TypeScript and Python.
> Classic COM and flat Win32 projections currently support JavaScript/TypeScript
> only, with the capability boundaries described below.

## Why dynwinrt?

If you've ever tried to call a modern Windows API (WinAppSDK, Windows AI, notifications, file pickers, sensors, …) from an Electron, Node, or Python app, you've probably hit one of these walls:
Expand All @@ -31,8 +20,7 @@ If you've ever tried to call a modern Windows API (WinAppSDK, Windows AI, notifi

> **Scope** — `dynwinrt` primarily targets **data-style WinRT APIs**. WinUI
> `Application + Window` hosting is also supported on a caller-managed STA UI
> thread. Classic COM and contract-driven flat Win32 have separate
> JavaScript/TypeScript surfaces described below.
> thread. Classic COM has a separate preview surface described below.

## Quick start

Expand Down Expand Up @@ -219,21 +207,6 @@ contracts or provide a universal overload parser. See the
- [Classic COM JavaScript usage guide](docs/guides/windows/classic-com-usage.md)
- [Supported ABI, coverage, limitations, and ownership model](docs/architecture/classic-com-support.md)

## Contract-driven flat Win32

Generate JavaScript bindings with TypeScript declarations for Win32 DLL exports
from `Windows.Win32.winmd`. Supported features include native structures,
counted buffers, managed resource cleanup, and IOCP-backed asynchronous file I/O.
Explicit subsystem contexts load their lifecycle DLLs on demand.

An independent `contracts/win32` registry describes ownership, buffer
relationships, and lifecycle rules. Generated bindings use the separate
`@microsoft/dynwinrt/win32` entrypoint, preserving the existing COM and WinRT
semantic models.
See the [supported capabilities and contract boundary](docs/architecture/flat-win32-contracts.md),
[generation command](tools/dynwinrt-codegen/README.md#contract-driven-flat-win32),
and [JavaScript examples](samples/js/win32/README.md).

## Repository layout

```
Expand Down
25 changes: 25 additions & 0 deletions bindings/js/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,31 @@ adding an eager dependency to ordinary WinRT/COM imports. MAPI utility
initialization is available only on the unsafe subpath and requires a configured
provider.

When a failed call cannot close an owned result, both Win32 entrypoints throw
`DynWin32CallError`, an `Error` with the original invocation message.
Its read-only `cleanupFailures` array contains each native `target`, the original
cleanup `error` (`code`, a signed HRESULT, and `message`), and a managed
`DynWin32Resource`. Keep the error or a resource alias until cleanup succeeds.
After correcting the native condition, call `error.retryCleanup()` or close the
individual resources. Retry does not invoke the original function again.
Failed retries retain the owners; successful retries and `close()` are
idempotent, and the original records remain available with `resource.closed`
set to `true`. Aliases share that close state.

If projecting a recoverable error or its records fails, the runtime attempts
to create an `AggregateError` retaining the native error in `cause` and
`errors[0]`, alongside the projection failure in `errors[1]`.
It also exposes `cleanupFailures` and `retryCleanup()`
for recovery without discarding the native owner. Recovery property descriptors
have no prototype, so inherited descriptor fields cannot break decoration.
If constructing or decorating that aggregate also fails, the original native
error is rethrown unchanged. It can remain unprojected or non-extensible and
need not satisfy `instanceof DynWin32CallError`; use
`DynWin32CallError.getCleanupFailures(error)` and
`DynWin32CallError.retryCleanup(error)` to recover without modifying its
prototype. These static methods validate the native carrier, not `instanceof`.
Errors without cleanup failures retain their existing behavior.

See the [Win32 generation guide](../../tools/dynwinrt-codegen/README.md#contract-driven-flat-win32),
[JavaScript samples](../../samples/js/win32/README.md), and
[supported capabilities and ownership rules](../../docs/architecture/flat-win32-contracts.md).
Expand Down
Loading
Loading