From a5b31ec8a62c92fb6069687306c74cf3af85e99f Mon Sep 17 00:00:00 2001 From: Yan Chen Date: Mon, 6 Apr 2026 21:49:37 -0700 Subject: [PATCH 01/10] remove debug component when not needed --- src/ast.rs | 16 +++++++++++++--- src/traits/dialog.rs | 8 +++++++- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/ast.rs b/src/ast.rs index 1ba7298..2a0d7bd 100644 --- a/src/ast.rs +++ b/src/ast.rs @@ -14,6 +14,7 @@ pub struct Opt<'a> { imports: LinkInfo, exports: LinkInfo, main: LinkInfo, + need_debug: bool, } #[derive(Default)] struct LinkInfo { @@ -37,6 +38,7 @@ impl<'a> Opt<'a> { imports: LinkInfo::default(), exports: LinkInfo::default(), main: LinkInfo::default(), + need_debug: false, } } fn generate_main_wit(&mut self, resolve: &Resolve, id: WorldId, files: &mut Files) { @@ -162,7 +164,9 @@ impl<'a> Opt<'a> { self.load_exports(exports_wasm)?; let mut out = Source::default(); out.push_str("package component:composed;\n"); - out.push_str("let debug = new import:debug { ... };\n"); + if self.need_debug { + out.push_str("let debug = new import:debug { ... };\n"); + } if !self.args.use_host_recorder { out.push_str("let recorder = new import:recorder { ... };\n"); } @@ -362,7 +366,10 @@ impl<'a> Opt<'a> { WorldItem::Interface { .. } => { let name = resolve.name_world_key(name); let link_type = match name.as_str() { - "proxy:util/debug" => LinkType::Debug, + "proxy:util/debug" => { + self.need_debug = true; + LinkType::Debug + } "proxy:util/dialog" => LinkType::Host, name if name.starts_with("proxy:recorder/") => LinkType::Recorder, _ => LinkType::Host, @@ -382,7 +389,10 @@ impl<'a> Opt<'a> { WorldItem::Interface { .. } => { let name = resolve.name_world_key(name); let link_type = match name.as_str() { - "proxy:util/debug" => LinkType::Debug, + "proxy:util/debug" => { + self.need_debug = true; + LinkType::Debug + } "proxy:conversion/conversion" => LinkType::Imports, "proxy:util/dialog" => LinkType::Host, name if name.starts_with("proxy:recorder/") => LinkType::Recorder, diff --git a/src/traits/dialog.rs b/src/traits/dialog.rs index fe8244f..44b7127 100644 --- a/src/traits/dialog.rs +++ b/src/traits/dialog.rs @@ -236,8 +236,14 @@ impl Trait for DialogTrait { } impl Dialog for MockedResource { fn read_value(_dep: u32) -> Self { + let handle = HANDLE_ID.with(|id| { + let mut id = id.borrow_mut(); + let current_id = *id; + *id += 1; + current_id + }); Self { - handle: 42, + handle, name: "mocked-resource".to_string(), } } From c264400ec70227b418d7f59bf4ab8738e75e72f1 Mon Sep 17 00:00:00 2001 From: Yan Chen Date: Mon, 6 Apr 2026 22:14:18 -0700 Subject: [PATCH 02/10] fix --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 05c2dcd..66aa78e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -12,7 +12,7 @@ jobs: env: WIT_BINDGEN_VERSION: 0.53.1 WAC_VERSION: 0.9.0 - VICEROY_VERSION: 0.16.4 + VICEROY_VERSION: 0.16.5 steps: - uses: actions/checkout@v5 - uses: actions-rust-lang/setup-rust-toolchain@v1 From e2f3517f9f7fc8dc62eae8fe2b1ba6fdd6167318 Mon Sep 17 00:00:00 2001 From: Yan Chen Date: Tue, 7 Apr 2026 09:48:49 -0700 Subject: [PATCH 03/10] try --- src/ast.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ast.rs b/src/ast.rs index 2a0d7bd..4a6536e 100644 --- a/src/ast.rs +++ b/src/ast.rs @@ -38,7 +38,7 @@ impl<'a> Opt<'a> { imports: LinkInfo::default(), exports: LinkInfo::default(), main: LinkInfo::default(), - need_debug: false, + need_debug: true, } } fn generate_main_wit(&mut self, resolve: &Resolve, id: WorldId, files: &mut Files) { From 2285e5c9af654cb2f733e0fdef77d7918416354c Mon Sep 17 00:00:00 2001 From: Yan Chen Date: Tue, 7 Apr 2026 10:46:09 -0700 Subject: [PATCH 04/10] try --- .github/workflows/main.yml | 1 + src/ast.rs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 66aa78e..b912bc7 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -19,6 +19,7 @@ jobs: with: target: wasm32-unknown-unknown, wasm32-wasip2 components: rustfmt, clippy + version: 1.94.0 - uses: bytecodealliance/actions/wasmtime/setup@v1 - uses: bytecodealliance/actions/wasm-tools/setup@v1 - uses: bytecodealliance/actions/wit-bindgen/setup@v1 diff --git a/src/ast.rs b/src/ast.rs index 4a6536e..2a0d7bd 100644 --- a/src/ast.rs +++ b/src/ast.rs @@ -38,7 +38,7 @@ impl<'a> Opt<'a> { imports: LinkInfo::default(), exports: LinkInfo::default(), main: LinkInfo::default(), - need_debug: true, + need_debug: false, } } fn generate_main_wit(&mut self, resolve: &Resolve, id: WorldId, files: &mut Files) { From d502b5e1647f3fca5a62a5bbed1a16f17a1a857f Mon Sep 17 00:00:00 2001 From: Yan Chen Date: Tue, 7 Apr 2026 11:00:27 -0700 Subject: [PATCH 05/10] try --- .github/workflows/main.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b912bc7..9cf2bdb 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -22,6 +22,8 @@ jobs: version: 1.94.0 - uses: bytecodealliance/actions/wasmtime/setup@v1 - uses: bytecodealliance/actions/wasm-tools/setup@v1 + with: + version: 1.245.0 - uses: bytecodealliance/actions/wit-bindgen/setup@v1 with: version: ${{ env.WIT_BINDGEN_VERSION }} From d056a4b5b5325a77cf09233ea16295c7ad4d6fb6 Mon Sep 17 00:00:00 2001 From: Yan Chen Date: Tue, 7 Apr 2026 12:20:34 -0700 Subject: [PATCH 06/10] try --- .github/workflows/main.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9cf2bdb..6bbf255 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -12,18 +12,20 @@ jobs: env: WIT_BINDGEN_VERSION: 0.53.1 WAC_VERSION: 0.9.0 - VICEROY_VERSION: 0.16.5 + VICEROY_VERSION: 0.16.4 steps: - uses: actions/checkout@v5 - uses: actions-rust-lang/setup-rust-toolchain@v1 with: target: wasm32-unknown-unknown, wasm32-wasip2 components: rustfmt, clippy - version: 1.94.0 + version: 1.93.1 - uses: bytecodealliance/actions/wasmtime/setup@v1 + with: + version: 42.0.1 - uses: bytecodealliance/actions/wasm-tools/setup@v1 with: - version: 1.245.0 + version: 1.245.1 - uses: bytecodealliance/actions/wit-bindgen/setup@v1 with: version: ${{ env.WIT_BINDGEN_VERSION }} From d9b0306a13811ffe2670336163a416f5cd7e8f2e Mon Sep 17 00:00:00 2001 From: Yan Chen Date: Tue, 7 Apr 2026 12:24:30 -0700 Subject: [PATCH 07/10] try --- src/ast.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ast.rs b/src/ast.rs index 2a0d7bd..4a6536e 100644 --- a/src/ast.rs +++ b/src/ast.rs @@ -38,7 +38,7 @@ impl<'a> Opt<'a> { imports: LinkInfo::default(), exports: LinkInfo::default(), main: LinkInfo::default(), - need_debug: false, + need_debug: true, } } fn generate_main_wit(&mut self, resolve: &Resolve, id: WorldId, files: &mut Files) { From 62da6e3703787ded7e99294063224f8fa977d3d6 Mon Sep 17 00:00:00 2001 From: Yan Chen Date: Tue, 7 Apr 2026 12:31:03 -0700 Subject: [PATCH 08/10] try --- src/ast.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ast.rs b/src/ast.rs index 4a6536e..2a0d7bd 100644 --- a/src/ast.rs +++ b/src/ast.rs @@ -38,7 +38,7 @@ impl<'a> Opt<'a> { imports: LinkInfo::default(), exports: LinkInfo::default(), main: LinkInfo::default(), - need_debug: true, + need_debug: false, } } fn generate_main_wit(&mut self, resolve: &Resolve, id: WorldId, files: &mut Files) { From 9cb8d6a0e5f56a41c1230612ccc550a6bb8411ed Mon Sep 17 00:00:00 2001 From: Yan Chen Date: Tue, 7 Apr 2026 17:08:47 -0700 Subject: [PATCH 09/10] try --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index cd8c500..3ea1112 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -12,7 +12,7 @@ jobs: env: WIT_BINDGEN_VERSION: 0.55.0 WAC_VERSION: 0.9.0 - VICEROY_VERSION: 0.16.5 + VICEROY_VERSION: 0.16.4 steps: - uses: actions/checkout@v5 - uses: dtolnay/rust-toolchain@stable From 6def38ea6f15d1f6533a72096617eec1f6d753a4 Mon Sep 17 00:00:00 2001 From: Yan Chen Date: Tue, 7 Apr 2026 17:17:33 -0700 Subject: [PATCH 10/10] fix --- src/ast.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ast.rs b/src/ast.rs index 2a0d7bd..e478c34 100644 --- a/src/ast.rs +++ b/src/ast.rs @@ -68,6 +68,7 @@ impl<'a> Opt<'a> { let name = resolve.name_world_key(name); // Don't virtualize util imports if name.starts_with("proxy:util/") { + self.need_debug = true; self.main.imports.insert(name.clone(), LinkType::Debug); out.push_str(&format!("import {name};\n")); continue;