Skip to content

feat: add standalone WinRT interface implementations for Node.js and Python - #148

Merged
leileizhang (lei9444) merged 10 commits into
mainfrom
lei9444-winrt-interface-implementations
Sep 10, 2026
Merged

leileizhang (lei9444) merged 10 commits into
mainfrom
lei9444-winrt-interface-implementations

Conversation

@lei9444

@lei9444 leileizhang (lei9444) commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds standalone, metadata-driven WinRT interface implementations for Node.js/TypeScript and Python. Native callers can invoke language handlers through real IInspectable-rooted objects, without a WinUI composable base or per-interface native adapter.

  • Shared reverse-ABI plans validate complete interface contracts and manage multi-interface identity, references, callback lifetimes, and output ownership.
  • Generated APIs support methods, properties, events, supported structs/arrays, and named multiple outputs, with .d.ts and .pyi declarations.
  • Includes runnable examples, event-delegate lifetime fixes, and coverage collection for the new generated paths.

Usage

With matching runtime/generated bindings, COM initialized, and an existing task-instance view:

const impl = IBackgroundTask.implement({
    run(instance) {
        if (instance) instance.progress += 1;
    },
});
try {
    impl.value.run(instanceView);
} finally {
    impl.dispose();
}
class Handler:
    def run(self, instance):
        if instance is not None:
            instance.progress += 1

with IBackgroundTask.implement(Handler()) as impl:
    impl.value.run(instance_view)

impl.value is a stable, typed primary interface managed by the handle. Additional interfaces use interfaces: [[IStringable, textHandlers]] in JavaScript or interfaces=[(IStringable, text_handler)] in Python. Existing descriptors and independent fromImplementation / from_implementation views remain available.

Behavior and compatibility

  • release() releases the handle's references without disconnecting other native holders. dispose() also disconnects subsequent callbacks across all interfaces; already-entered callbacks may finish.
  • Callbacks are synchronous, non-agile, and owner-thread-only. Unsupported contracts fail before object publication. Arbitrary generic implementations, nested arrays, async language handlers, and Python subinterpreters are not supported.
  • Ordinary WinRT consumption APIs remain available. Regenerated bindings need a matching runtime. Python Char16[] results now match their declared list[str] type; direct imports of affected long-name Python submodules may need updating.
  • OS background-task registration, CLSID activation, package deployment, and COM server hosting are not included.

Documentation and samples

Add metadata-validated WinRT reverse-call plans, standalone multi-interface IInspectable objects, and synchronous owner-thread handlers for Node.js and Python. Generate typed implementation factories and independently owned views, preserve callback lifetime and output ownership, and cover real native vtable calls, properties, events, arrays, and multi-output results.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@github-actions

github-actions Bot commented Sep 9, 2026 •

Copy link
Copy Markdown

Mixed-language test coverage

Workflow status: ✅ Passed

Layer Lines Functions Branches/regions
Rust, including native .pyd/.node 85.47% 80.78% 85.11% regions
Python aggregate 71.06% n/a 37.9% branches
Python runtime 99.12% n/a 97.37% branches
Generated Python WinRT projections 70.05% n/a 27.07% branches
Generated Python WinRT implementations 72.29% n/a 47.04% branches
JavaScript aggregate 21.98% 25.07% 57.34% branches
JavaScript runtime 38.26% 57.89% 71.01% branches
Generated WinRT projections 22.97% 18.71% 54.94% branches
Generated WinRT implementations 48.66% 59.76% 61.14% branches
Generated Classic COM projections 11.92% 23.97% 54.2% branches

View workflow run and download full HTML/LCOV/XML reports

Preserve ongoing coverage reporting work before merging current main. Include generated implementation sources, normalize Python subprocess paths, and retain per-family reports without changing coverage gates.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Integrate 5ea416b. Preserve COM borrowed/completion and WinRT test features/scripts, and use the merged array ownership constructor for exact HRESULT arrays.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Keep implement as the instance factory with a stable handle-managed value, support explicit interface/handler tuples, and retain advanced descriptors and independent views. Pin Python receivers across reentrant primary disposal, share measured reverse helpers, exercise both generated source trees and scalar/array contracts, and keep existing coverage gates unchanged.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The low-level callback fixture receives an owned native value. Release it when rejecting a subscription, and cover intentional retention across a thrown callback separately. Keep natural-exit assertions, native retention semantics, and coverage gates unchanged.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Release the implementation-side visible owned delegate when the controlled task fixture declines registration. Preserve the original failure and assert subscribers are not invoked; do not alter generated temporaries, GC, exit behavior, or timeouts.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Type heterogeneous generated-package interface pairs without erasing handler relations, declare native delegate calls positional-only, and share focused E2E preparation. Pin detached receivers through reentrant disposal while preserving same-thread GIL release; cover the public WinAppSDK dispatcher projection and existing ownership paths.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Retain raw ECMA reference qualifiers before reverse validation, align synchronous JS void callbacks with TypeScript, and allocate generated helper symbols by owning interface and role. Track Python implementation pairs in a versioned inventory with atomic migration and retained-stub validation. Ship retrievable management source in runtime wheels and require its actual tracing and coverage without changing the gates.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Reconcile root visibility independently of helper renames using structured owner records and explicit old/current source replacement, including empty export sets. Preserve namespace views, pair unions, unrelated aliases, runtime-only generation, and atomic output. Cover single-to-ambiguous binary metadata, stable helper names, regenerated owners, star imports, strict typing, and source-path replacement.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Integrate main 06de0fa with the Aion Electron sample and consolidated low-level tests. Resolve the package script overlap by retaining index, WinRT marshalling, and WinRT implementation declaration checks together; preserve both sides of the feature and test changes.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@lei9444
leileizhang (lei9444) merged commit e7469c8 into main Sep 10, 2026
24 checks passed
@lei9444
leileizhang (lei9444) deleted the lei9444-winrt-interface-implementations branch September 10, 2026 12:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants