Skip to content

Add opt-in Windows App SDK auto-initialization for Python and Node.js - #235

Merged
leileizhang (lei9444) merged 2 commits into
mainfrom
lei9444-bootstrap-auto-initialization
Oct 30, 2026
Merged

leileizhang (lei9444) merged 2 commits into
mainfrom
lei9444-bootstrap-auto-initialization

Conversation

@lei9444

@lei9444 leileizhang (lei9444) commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Add opt-in dynwinrt.auto_init and @microsoft/dynwinrt/auto-init imports. A shared GetCurrentPackageFullName probe checks identity without WinRT activation or COM initialization: packaged processes skip all Bootstrap configuration and DLL work, while identityless processes call the existing no-argument initializer. Probe and initialization errors propagate.

Ordinary runtime/generated-package imports stay passive, explicit initialization retains its existing behavior, and applications still own COM setup. Includes packaging, regression coverage, documentation, and a short preview.24 highlight.

Usage

For identityless processes, install a generated bindings package produced with --winappsdk-version and --winappsdk-bootstrap-path, and deploy the matching Windows App Runtime. Python discovers the installed provider; Node needs the generated package imported first. Processes with identity need no Bootstrap configuration just to skip.

from dynwinrt import RoApartment

with RoApartment(0):  # The application chooses STA.
    import dynwinrt.auto_init
    # Create and run the application here.
import { roInitialize } from '@microsoft/dynwinrt';
roInitialize(0);
await import('@winapp/bindings');
await import('@microsoft/dynwinrt/auto-init');
// Create and run the application here.

Use dynamic ESM import after preparation; static imports execute before the body. CommonJS uses ordered require() calls instead. The opt-in import initializes the configured Runtime without identity, or skips Bootstrap with identity; skipping does not verify SDK deployment. Normal module caching applies, and explicit init_winappsdk(...) / initWinappsdk(...) remain available without an identity-based skip.

Validation

Real temporary package-identity processes skipped Bootstrap with missing/conflicting configuration and invalid DLL paths; Bootstrap stayed unloaded and COM stayed uninitialized. Identityless installed-package consumers discovered/registered actual generated SDK bundles, initialized the installed Runtime, and called RuntimeInfo. Temporary package registration was removed. Local live coverage used Windows x64, CPython 3.12, and Node 24; native ARM64 was not exercised locally.

Add identity-first Python and Node entrypoints without changing explicit initialization or ordinary imports. Use a shared native identity probe that does not activate WinRT or initialize COM.

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

github-actions Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Mixed-language test coverage

Workflow status: ✅ Passed

Layer Lines Functions Branches/regions
Rust, including native .pyd/.node 86.66% 82.1% 86.26% regions
Python aggregate 70.61% n/a 38.03% branches
Python runtime 98.29% n/a 95.06% branches
Generated Python WinRT projections 68.46% n/a 30.26% branches
Generated Python WinRT implementations 71.75% n/a 46.08% branches
JavaScript aggregate 18.38% 24.84% 55.92% branches
JavaScript runtime 41.6% 40.9% 77.68% branches
Generated WinRT projections 17.27% 19.36% 52.51% branches
Generated WinRT implementations 45.99% 59.19% 60.97% branches
Generated Classic COM projections 11.38% 23.88% 53.1% branches

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

Run the strict uninitialized-COM regression in a separate integration-test process, outside the unit suite's retained MTA. Prepare the effectful Python module's identity branch before recursive stubtest, restoring the real identity probe before checking all public signatures.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@lei9444
leileizhang (lei9444) merged commit 1ab0b31 into main Oct 30, 2026
33 checks passed
@lei9444
leileizhang (lei9444) deleted the lei9444-bootstrap-auto-initialization branch October 30, 2026 12:30
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.

3 participants