diff --git a/.changeset/pre.json b/.changeset/pre.json index 28cc2ac..af91f8f 100644 --- a/.changeset/pre.json +++ b/.changeset/pre.json @@ -5,6 +5,7 @@ "@fltsci/taurpc": "1.8.1" }, "changesets": [ + "allow-channel-reuse", "bigint-rewrite-f64-not-opaque", "bump-specta-rc-25", "calm-wombats-stand", diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a3e51c..23bda0c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,17 @@ # taurpc +## 2.0.0-canary.8 + +### Patch Changes + +- [#31](https://github.com/fltsci/TauRPC/pull/31) [`e65f48e`](https://github.com/fltsci/TauRPC/commit/e65f48eff5cd8357f8c8232b63cee3827a0e0669) Thanks [@johncarmack1984](https://github.com/johncarmack1984)! - Allow `Channel`s to be reused across multiple TauRPC command invocations. + + Previously, when a command argument contained a `Channel` and the runtime ran a transform pass (e.g. semantic-types decoding), the generated TS proxy mutated the original channel's `onmessage` handler in place. Passing the same channel to a second command (or any code path that re-invoked the proxy) would re-wrap the already-wrapped handler, double-decoding payloads. + + The proxy now wraps via `new Channel((response) => v.onmessage(transform(response)))` instead of mutating, so the original channel is untouched and safe to reuse. + + Generated bindings now import `Channel` from `@tauri-apps/api/core` whenever the affected transform path is reachable. + ## 2.0.0-canary.7 ### Patch Changes diff --git a/package.json b/package.json index 7309645..eb6f53b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@fltsci/taurpc", - "version": "2.0.0-canary.7", + "version": "2.0.0-canary.8", "description": "Type-safe IPC layer for Tauri commands and events; forked from MatsDK/TauRPC", "main": "dist/index.cjs", "repository": {