From 963a641f39466267a31b62c1ff25127362434b87 Mon Sep 17 00:00:00 2001 From: Ren Amamiya Date: Mon, 31 Aug 2026 17:23:59 +0700 Subject: [PATCH] fix build --- Cargo.lock | 1 - Cargo.toml | 123 ++++++++++++------------- crates/state/src/lib.rs | 2 + crates/workspace/Cargo.toml | 5 +- crates/workspace/src/dialogs/import.rs | 7 +- crates/workspace/src/lib.rs | 51 ++++++---- 6 files changed, 106 insertions(+), 83 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bc84014d..b5b74db5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8929,7 +8929,6 @@ version = "1.0.0" dependencies = [ "anyhow", "auto_update", - "browser-signer-proxy", "chat", "chat_ui", "common", diff --git a/Cargo.toml b/Cargo.toml index cc2ebecc..252e54a3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,62 +1,61 @@ -[workspace] -resolver = "2" -members = ["crates/*", "desktop", "web"] -default-members = ["desktop"] - -[workspace.package] -version = "1.0.0" -edition = "2024" -publish = false - -[workspace.dependencies] -# GPUI -gpui = { git = "https://github.com/zed-industries/zed" } -gpui_platform = { git = "https://github.com/zed-industries/zed", features = ["font-kit", "x11", "wayland"] } -gpui_linux = { git = "https://github.com/zed-industries/zed" } -gpui_windows = { git = "https://github.com/zed-industries/zed" } -gpui_macos = { git = "https://github.com/zed-industries/zed" } -gpui_tokio = { git = "https://github.com/zed-industries/zed" } -reqwest_client = { git = "https://github.com/zed-industries/zed" } - -# Nostr -nostr-lmdb = { git = "https://github.com/rust-nostr/nostr" } -nostr-memory = { git = "https://github.com/rust-nostr/nostr" } -nostr-blossom = { git = "https://github.com/rust-nostr/nostr" } -nostr-gossip-memory = { git = "https://github.com/rust-nostr/nostr" } -nostr-connect = { git = "https://github.com/rust-nostr/nostr" } -nostr-sdk = { git = "https://github.com/rust-nostr/nostr" } -nostr = { git = "https://github.com/rust-nostr/nostr", features = [ "nip59", "nip49", "nip44" ] } - -# Others -anyhow = "1.0.44" -chrono = { version = "0.4.38", features = ["wasmbind"] } -futures = "0.3" -itertools = "0.13.0" -log = "0.4" -oneshot = "0.1.10" -flume = { version = "0.11.1", default-features = false, features = ["async", "select"] } -rust-embed = { version = "8.5", features = ["include-exclude"] } -serde = { version = "1.0", features = ["derive"] } -serde_json = "1.0" -schemars = "1" -smallvec = "1.14.0" -smol = "2" -webbrowser = "1.0.4" -tracing-subscriber = { version = "0.3.18", features = ["fmt"] } -errno = { version = "0.3.14", default-features = false } -instant = "0.1" - -[patch.crates-io] -# Use stacker's psm version which may have better WASM support -psm = { git = "https://github.com/rust-lang/stacker", branch = "master" } - -[profile.release] -strip = true -opt-level = "z" -lto = true -codegen-units = 1 -panic = "abort" - -[profile.profiling] -inherits = "release" -debug = true +[workspace] +resolver = "2" +members = ["crates/*", "desktop", "web"] +default-members = ["desktop"] + +[workspace.package] +version = "1.0.0" +edition = "2024" +publish = false + +[workspace.dependencies] +# GPUI +gpui = { git = "https://github.com/zed-industries/zed" } +gpui_platform = { git = "https://github.com/zed-industries/zed", features = ["font-kit", "x11", "wayland"] } +gpui_linux = { git = "https://github.com/zed-industries/zed" } +gpui_windows = { git = "https://github.com/zed-industries/zed" } +gpui_macos = { git = "https://github.com/zed-industries/zed" } +gpui_tokio = { git = "https://github.com/zed-industries/zed" } +reqwest_client = { git = "https://github.com/zed-industries/zed" } + +# Nostr +nostr-lmdb = { git = "https://github.com/rust-nostr/nostr" } +nostr-memory = { git = "https://github.com/rust-nostr/nostr" } +nostr-blossom = { git = "https://github.com/rust-nostr/nostr" } +nostr-gossip-memory = { git = "https://github.com/rust-nostr/nostr" } +nostr-connect = { git = "https://github.com/rust-nostr/nostr" } +nostr-sdk = { git = "https://github.com/rust-nostr/nostr" } +nostr = { git = "https://github.com/rust-nostr/nostr", features = [ "nip59", "nip49", "nip44" ] } + +# Others +anyhow = "1.0.44" +chrono = { version = "0.4.38", features = ["wasmbind"] } +futures = "0.3" +itertools = "0.13.0" +log = "0.4" +oneshot = "0.1.10" +flume = { version = "0.11.1", default-features = false, features = ["async", "select"] } +rust-embed = { version = "8.5", features = ["include-exclude"] } +serde = { version = "1.0", features = ["derive"] } +serde_json = "1.0" +schemars = "1" +smallvec = "1.14.0" +smol = "2" +webbrowser = "1.0.4" +tracing-subscriber = { version = "0.3.18", features = ["fmt"] } +instant = "0.1" + +[patch.crates-io] +# Use stacker's psm version which may have better WASM support +psm = { git = "https://github.com/rust-lang/stacker", branch = "master" } + +[profile.release] +strip = true +opt-level = "z" +lto = true +codegen-units = 1 +panic = "abort" + +[profile.profiling] +inherits = "release" +debug = true diff --git a/crates/state/src/lib.rs b/crates/state/src/lib.rs index 23fa04ae..c03c5505 100644 --- a/crates/state/src/lib.rs +++ b/crates/state/src/lib.rs @@ -3,8 +3,10 @@ use std::collections::HashMap; use anyhow::{Error, anyhow}; #[cfg(not(target_arch = "wasm32"))] use browser_signer_proxy::prelude::*; +#[cfg(not(target_arch = "wasm32"))] use common::config_dir; use gpui::{App, AppContext, Context, Entity, EventEmitter, Global, Task, Window}; +#[cfg(not(target_arch = "wasm32"))] use gpui_tokio::Tokio; use instant::Duration; use nostr_connect::prelude::*; diff --git a/crates/workspace/Cargo.toml b/crates/workspace/Cargo.toml index 6a75fb25..d6e779fe 100644 --- a/crates/workspace/Cargo.toml +++ b/crates/workspace/Cargo.toml @@ -14,15 +14,16 @@ chat = { path = "../chat" } chat_ui = { path = "../chat_ui" } settings = { path = "../settings" } person = { path = "../person" } -auto_update = { path = "../auto_update" } gpui.workspace = true nostr-sdk.workspace = true instant.workspace = true nostr-connect.workspace = true -browser-signer-proxy = { path = "../browser-signer-proxy" } anyhow.workspace = true serde.workspace = true log.workspace = true smallvec.workspace = true + +[target.'cfg(not(target_arch = "wasm32"))'.dependencies] +auto_update = { path = "../auto_update" } diff --git a/crates/workspace/src/dialogs/import.rs b/crates/workspace/src/dialogs/import.rs index cb41d765..b9f3d379 100644 --- a/crates/workspace/src/dialogs/import.rs +++ b/crates/workspace/src/dialogs/import.rs @@ -172,6 +172,11 @@ impl ImportIdentity { }); } + // The "Connect via Web Extension" button is hidden on wasm (`is_wasm`), + // so this stub is never invoked in the browser. + #[cfg(target_arch = "wasm32")] + fn proxy(&mut self, _cx: &mut Context) {} + fn set_loading(&mut self, status: bool, cx: &mut Context) { self.loading = status; cx.notify(); @@ -266,7 +271,7 @@ impl Render for ImportIdentity { this.login(window, cx); })), ) - .child(divider(cx)) + .when(cfg!(target_arch = "wasm32"), |this| this.child(divider(cx))) .when(!is_wasm, |this| { this.child( Button::new("proxy") diff --git a/crates/workspace/src/lib.rs b/crates/workspace/src/lib.rs index 668426e1..451663c4 100644 --- a/crates/workspace/src/lib.rs +++ b/crates/workspace/src/lib.rs @@ -2,6 +2,7 @@ use std::sync::Arc; use ::settings::AppSettings; use anyhow::Error; +#[cfg(not(target_arch = "wasm32"))] use auto_update::AutoUpdater; use chat::{ChatEvent, ChatRegistry}; use common::{CoopImageCache, download_dir}; @@ -379,6 +380,7 @@ impl Workspace { Command::ImportEncryption => { self.import_encryption(window, cx); } + #[cfg(not(target_arch = "wasm32"))] Command::Update => { let auto_updater = AutoUpdater::global(cx); auto_updater.update(cx, |this, cx| { @@ -387,6 +389,9 @@ impl Workspace { }); }); } + // Auto-update is a desktop-only feature; no-op in the browser. + #[cfg(target_arch = "wasm32")] + Command::Update => {} } } @@ -563,7 +568,8 @@ impl Workspace { let avatar = avatar.clone(); let name = name.clone(); - this.min_w(px(256.)) + let menu = this + .min_w(px(256.)) .item(PopupMenuItem::element(move |_window, cx| { h_flex() .gap_1p5() @@ -593,24 +599,27 @@ impl Workspace { IconName::Sun, Box::new(Command::ToggleTheme), ) - .separator() - .menu_with_icon( - "Check for Updates", - IconName::Device, - Box::new(Command::Update), - ) - .menu_with_icon( - "Settings", - IconName::Settings, - Box::new(Command::ShowSettings), - ) + .separator(); + + // Auto-update is a desktop-only feature; there is no updater in the browser. + #[cfg(not(target_arch = "wasm32"))] + let menu = menu.menu_with_icon( + "Check for Updates", + IconName::Device, + Box::new(Command::Update), + ); + + menu.menu_with_icon( + "Settings", + IconName::Settings, + Box::new(Command::ShowSettings), + ) }), ) }) } fn titlebar_right(&mut self, cx: &mut Context) -> impl IntoElement { - let updater = AutoUpdater::global(cx); let chat = ChatRegistry::global(cx); let nip4e_enabled = AppSettings::get_nip4e(cx); let nostr = NostrRegistry::global(cx); @@ -622,15 +631,23 @@ impl Workspace { let persons = PersonRegistry::global(cx); let profile = persons.read(cx).get(&public_key, cx); let announcement = profile.announcement(); - let updater_idle = updater.read(cx).idle(cx); - h_flex() + let titlebar = h_flex() .when(!cx.theme().platform.is_mac(), |this| this.pr_2()) - .gap_2() - .when(!updater_idle, |this| { + .gap_2(); + + // Auto-update is a desktop-only feature; there is no updater in the browser. + #[cfg(not(target_arch = "wasm32"))] + let titlebar = { + let updater = AutoUpdater::global(cx); + let updater_idle = updater.read(cx).idle(cx); + titlebar.when(!updater_idle, |this| { let status = updater.read(cx).status(cx); this.child(div().text_xs().italic().child(status)) }) + }; + + titlebar .when(nip4e_enabled, |this| { this.child( Button::new("key")