Skip to content

Generate JavaScript bindings in canonical namespace paths - #109

Merged
leileizhang (lei9444) merged 7 commits into
mainfrom
lei9444-review-pr-107
Sep 1, 2026
Merged

leileizhang (lei9444) merged 7 commits into
mainfrom
lei9444-review-pr-107

Conversation

@lei9444

@lei9444 leileizhang (lei9444) commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • emit JavaScript and declaration implementations under canonical namespace paths while preserving concise root-barrel imports
  • qualify colliding root exports and give closed generics deterministic identities that include their complete generic argument identity
  • use a versioned JSON .dynwinrt-js-types inventory for type identity, ABI validation, deterministic projected names, and persistent module-local compatibility aliases
  • support same-version phased/incremental generation: later collisions deterministically update Root names without breaking imports from retained canonical modules
  • fail closed when namespace-distinct structs would share the same JavaScript pack/unpack helper
  • make dedicated output updates transactional, locked, and fail closed for unsafe paths or incomplete inventories
  • fix required-interface overload projection and namespace-sensitive helper/import assumptions exposed by the new layout
  • update snapshots, E2E runners, samples, and JavaScript binding documentation

Consumer impact

Root imports remain supported:

const { Uri, Button } = require('./generated')

Deep imports now use canonical namespace paths, for example ./generated/windows/foundation/Uri.js. Legacy flat paths such as ./generated/Uri.js are no longer generated. Closed generic names containing named or nested types now include a readable full identity and stable hash; primitive-only generic names remain compact.

The output directory is codegen-owned: existing contents may be replaced or removed and handwritten files should not be stored there. Repeated commands may append bindings when they use the same restored metadata version. After changing WinMD files, SDK versions, or reference inputs, delete the output directory and run all generation commands again; cross-version incremental migration is intentionally unsupported.

The WinApp CLI Node WinUI sample was validated with its explicit IVector_UIElement reference migrated to the generated complete identity. That source migration belongs in the WinApp CLI repository.

Validation

  • cargo fmt --all -- --check
  • cargo test -p dynwinrt-codegen
  • core runtime suite: 248 passed, 1 ignored
  • TypeScript WinRT E2E: 38/38
  • Classic COM E2E: 17/17, including live SMTC
  • WinApp CLI integration suite: 230/230
  • full generated package: 4,101 canonical identities, strict declarations pass, all canonical CJS/ESM modules load
  • clean phased WinApp CLI generation: 1,575 inventory records, 1,577 CJS modules load, and repeated generation changes zero codegen-owned files
  • Electron Windows Gallery generation, TypeScript build, and live Uri projection pass
  • Node WinUI and Electron samples were both launched as real windows using the matching local codegen/runtime

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: e15e0402-1dfa-4d68-b2bb-a33009d1d098
@github-actions

github-actions Bot commented Aug 31, 2026 •

Copy link
Copy Markdown

Mixed-language test coverage

Workflow status: ✅ Passed

Layer Lines Functions Branches/regions
Rust, including native .pyd/.node 82.37% 78.64% 82.29% regions
Generated Python projections 70.48% n/a 21.71% branches
JavaScript aggregate 21.24% 20.56% 53.98% branches
JavaScript runtime 19.91% 14.28% 7.14% branches
Generated WinRT projections 25.74% 19.25% 54.66% branches
Generated Classic COM projections 14.65% 24.46% 53.75% branches

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

leileizhang (lei9444) and others added 6 commits August 31, 2026 10:48
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: e15e0402-1dfa-4d68-b2bb-a33009d1d098
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: e15e0402-1dfa-4d68-b2bb-a33009d1d098
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: e15e0402-1dfa-4d68-b2bb-a33009d1d098
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: e15e0402-1dfa-4d68-b2bb-a33009d1d098
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: e15e0402-1dfa-4d68-b2bb-a33009d1d098
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: e15e0402-1dfa-4d68-b2bb-a33009d1d098
@lei9444
leileizhang (lei9444) merged commit aa5339e into main Sep 1, 2026
26 checks passed
@lei9444
leileizhang (lei9444) deleted the lei9444-review-pr-107 branch September 1, 2026 01:26
leileizhang (lei9444) added a commit that referenced this pull request Sep 1, 2026
Resolve the codegen transaction type rename after PR #109 while preserving the Python projection changes.

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

Copilot-Session: 7dd76e84-9e06-45b9-a8d1-c09f8a157550
leileizhang (lei9444) added a commit that referenced this pull request Sep 1, 2026
Keep the semantic-history regression on the schema v1 merged by PR #109.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
leileizhang (lei9444) added a commit that referenced this pull request Sep 1, 2026
Preserve the resolved PR #109 integration while replacing the merge-based
history with one reviewable commit on current main.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
leileizhang (lei9444) added a commit that referenced this pull request Sep 1, 2026
Preserve the resolved PR #109 integration while replacing the merge-based
history with one reviewable commit on current main.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
leileizhang (lei9444) added a commit that referenced this pull request Sep 1, 2026
* Refactor JavaScript projection planning

Unify semantic type identity, pass explicit projection context, and generate roots from a structured module plan.

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

* Test phased JavaScript collision generation

Cover retained projected-name changes, root and package rewrites, clean-output byte identity, fail-closed metadata, and idempotent reruns.

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

* Exercise retained JavaScript rename path

Generate only the new type in phase two and assert exact retained aliases, root ownership, package targets, byte convergence, and idempotence.

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

* Test retained history semantic equivalence

Compare true retained generation with an independent full-current oracle while allowing only documented implementation-history artifacts to differ.

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

* Align inventory schema test with main

Keep the semantic-history regression on the schema v1 merged by PR #109.

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

* Preserve COM-first incremental generation

Ignore only Classic COM compatibility exports while continuing to validate inventory-backed Com.* WinRT modules.

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

---------

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
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