Compare commits
8
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a6e50cf3aa | ||
|
|
8f272f1fe8 | ||
|
|
6a7bf17e6e | ||
|
|
3290f71fa4 | ||
|
|
f7f1ea7438 | ||
|
|
070c6a7e87 | ||
|
|
963a641f39 | ||
|
|
ff20e51729 |
Generated
+43
-35
@@ -276,9 +276,13 @@ name = "assets"
|
|||||||
version = "1.0.0"
|
version = "1.0.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
|
"futures",
|
||||||
"gpui",
|
"gpui",
|
||||||
"log",
|
"log",
|
||||||
|
"reqwest",
|
||||||
"rust-embed",
|
"rust-embed",
|
||||||
|
"wasm-bindgen-futures",
|
||||||
|
"web-sys",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -1247,7 +1251,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "collections"
|
name = "collections"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/zed-industries/zed#bce0c5785bfd9172c939aca4083fd70bc4930927"
|
source = "git+https://github.com/zed-industries/zed#ce48461eaadd16c65c31f835511ab96bd3b6e746"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"gpui_util",
|
"gpui_util",
|
||||||
"indexmap",
|
"indexmap",
|
||||||
@@ -1441,6 +1445,7 @@ dependencies = [
|
|||||||
"gpui_platform",
|
"gpui_platform",
|
||||||
"gpui_web",
|
"gpui_web",
|
||||||
"instant",
|
"instant",
|
||||||
|
"js-sys",
|
||||||
"log",
|
"log",
|
||||||
"person",
|
"person",
|
||||||
"settings",
|
"settings",
|
||||||
@@ -1450,6 +1455,8 @@ dependencies = [
|
|||||||
"ui",
|
"ui",
|
||||||
"universal-time 0.3.1 (git+https://github.com/shadowylab/universal-time)",
|
"universal-time 0.3.1 (git+https://github.com/shadowylab/universal-time)",
|
||||||
"wasm-bindgen",
|
"wasm-bindgen",
|
||||||
|
"wasm-bindgen-futures",
|
||||||
|
"web-sys",
|
||||||
"workspace",
|
"workspace",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -1761,7 +1768,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "derive_refineable"
|
name = "derive_refineable"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/zed-industries/zed#bce0c5785bfd9172c939aca4083fd70bc4930927"
|
source = "git+https://github.com/zed-industries/zed#ce48461eaadd16c65c31f835511ab96bd3b6e746"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
@@ -2658,7 +2665,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "gpui"
|
name = "gpui"
|
||||||
version = "0.2.2"
|
version = "0.2.2"
|
||||||
source = "git+https://github.com/zed-industries/zed#bce0c5785bfd9172c939aca4083fd70bc4930927"
|
source = "git+https://github.com/zed-industries/zed#ce48461eaadd16c65c31f835511ab96bd3b6e746"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"accesskit",
|
"accesskit",
|
||||||
"anyhow",
|
"anyhow",
|
||||||
@@ -2743,7 +2750,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "gpui_apple"
|
name = "gpui_apple"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/zed-industries/zed#bce0c5785bfd9172c939aca4083fd70bc4930927"
|
source = "git+https://github.com/zed-industries/zed#ce48461eaadd16c65c31f835511ab96bd3b6e746"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"block",
|
"block",
|
||||||
@@ -2766,7 +2773,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "gpui_linux"
|
name = "gpui_linux"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/zed-industries/zed#bce0c5785bfd9172c939aca4083fd70bc4930927"
|
source = "git+https://github.com/zed-industries/zed#ce48461eaadd16c65c31f835511ab96bd3b6e746"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"accesskit",
|
"accesskit",
|
||||||
"accesskit_unix",
|
"accesskit_unix",
|
||||||
@@ -2812,7 +2819,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "gpui_macos"
|
name = "gpui_macos"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/zed-industries/zed#bce0c5785bfd9172c939aca4083fd70bc4930927"
|
source = "git+https://github.com/zed-industries/zed#ce48461eaadd16c65c31f835511ab96bd3b6e746"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"accesskit",
|
"accesskit",
|
||||||
"accesskit_macos",
|
"accesskit_macos",
|
||||||
@@ -2858,7 +2865,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "gpui_macros"
|
name = "gpui_macros"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/zed-industries/zed#bce0c5785bfd9172c939aca4083fd70bc4930927"
|
source = "git+https://github.com/zed-industries/zed#ce48461eaadd16c65c31f835511ab96bd3b6e746"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"heck 0.5.0",
|
"heck 0.5.0",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
@@ -2869,7 +2876,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "gpui_platform"
|
name = "gpui_platform"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/zed-industries/zed#bce0c5785bfd9172c939aca4083fd70bc4930927"
|
source = "git+https://github.com/zed-industries/zed#ce48461eaadd16c65c31f835511ab96bd3b6e746"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"console_error_panic_hook",
|
"console_error_panic_hook",
|
||||||
"gpui",
|
"gpui",
|
||||||
@@ -2882,7 +2889,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "gpui_shared_string"
|
name = "gpui_shared_string"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/zed-industries/zed#bce0c5785bfd9172c939aca4083fd70bc4930927"
|
source = "git+https://github.com/zed-industries/zed#ce48461eaadd16c65c31f835511ab96bd3b6e746"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"schemars",
|
"schemars",
|
||||||
"serde",
|
"serde",
|
||||||
@@ -2892,7 +2899,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "gpui_tokio"
|
name = "gpui_tokio"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/zed-industries/zed#bce0c5785bfd9172c939aca4083fd70bc4930927"
|
source = "git+https://github.com/zed-industries/zed#ce48461eaadd16c65c31f835511ab96bd3b6e746"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"gpui",
|
"gpui",
|
||||||
@@ -2903,7 +2910,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "gpui_util"
|
name = "gpui_util"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/zed-industries/zed#bce0c5785bfd9172c939aca4083fd70bc4930927"
|
source = "git+https://github.com/zed-industries/zed#ce48461eaadd16c65c31f835511ab96bd3b6e746"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"log",
|
"log",
|
||||||
@@ -2913,7 +2920,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "gpui_web"
|
name = "gpui_web"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/zed-industries/zed#bce0c5785bfd9172c939aca4083fd70bc4930927"
|
source = "git+https://github.com/zed-industries/zed#ce48461eaadd16c65c31f835511ab96bd3b6e746"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"console_error_panic_hook",
|
"console_error_panic_hook",
|
||||||
@@ -2937,7 +2944,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "gpui_wgpu"
|
name = "gpui_wgpu"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/zed-industries/zed#bce0c5785bfd9172c939aca4083fd70bc4930927"
|
source = "git+https://github.com/zed-industries/zed#ce48461eaadd16c65c31f835511ab96bd3b6e746"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"bytemuck",
|
"bytemuck",
|
||||||
@@ -2963,7 +2970,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "gpui_windows"
|
name = "gpui_windows"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/zed-industries/zed#bce0c5785bfd9172c939aca4083fd70bc4930927"
|
source = "git+https://github.com/zed-industries/zed#ce48461eaadd16c65c31f835511ab96bd3b6e746"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"accesskit",
|
"accesskit",
|
||||||
"accesskit_windows",
|
"accesskit_windows",
|
||||||
@@ -3141,9 +3148,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hermit-abi"
|
name = "hermit-abi"
|
||||||
version = "0.5.2"
|
version = "0.5.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "fc0fef456e4baa96da950455cd02c081ca953b141298e41db3fc7e36b1da849c"
|
checksum = "e17592d60ebacc7d5e169f4663c5f84f9161cc90328abcfe8456f41e4dfcb284"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hex"
|
name = "hex"
|
||||||
@@ -3238,7 +3245,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "http_client"
|
name = "http_client"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/zed-industries/zed#bce0c5785bfd9172c939aca4083fd70bc4930927"
|
source = "git+https://github.com/zed-industries/zed#ce48461eaadd16c65c31f835511ab96bd3b6e746"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"async-compression",
|
"async-compression",
|
||||||
@@ -3258,7 +3265,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "http_client_tls"
|
name = "http_client_tls"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/zed-industries/zed#bce0c5785bfd9172c939aca4083fd70bc4930927"
|
source = "git+https://github.com/zed-industries/zed#ce48461eaadd16c65c31f835511ab96bd3b6e746"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"log",
|
"log",
|
||||||
"rustls",
|
"rustls",
|
||||||
@@ -3942,9 +3949,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "lyon_algorithms"
|
name = "lyon_algorithms"
|
||||||
version = "1.0.20"
|
version = "1.0.21"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8575c0d003ae459399623c4def180c63b77f343b1a7fee64f249b349e7699a31"
|
checksum = "cdfa8785f95e57914ddb35e3b59994aeba6f5e79e9cfd03da1c269f010f36009"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"lyon_path",
|
"lyon_path",
|
||||||
"num-traits",
|
"num-traits",
|
||||||
@@ -3973,9 +3980,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "lyon_tessellation"
|
name = "lyon_tessellation"
|
||||||
version = "1.0.20"
|
version = "1.0.21"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8e43b7e44161571868f5c931d12583592c223c5583eef86b08aa02b7048a3552"
|
checksum = "dabea159dc6eea9171a541b458134b70ca95e3162d068132b2b3b9bc01aad06e"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"float_next_after",
|
"float_next_after",
|
||||||
"lyon_path",
|
"lyon_path",
|
||||||
@@ -4037,7 +4044,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "media"
|
name = "media"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/zed-industries/zed#bce0c5785bfd9172c939aca4083fd70bc4930927"
|
source = "git+https://github.com/zed-industries/zed#ce48461eaadd16c65c31f835511ab96bd3b6e746"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"bindgen",
|
"bindgen",
|
||||||
@@ -4593,6 +4600,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "d49e936b501e5c5bf01fda3a9452ff86dc3ea98ad5f283e1455153142d97518c"
|
checksum = "d49e936b501e5c5bf01fda3a9452ff86dc3ea98ad5f283e1455153142d97518c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 2.13.1",
|
"bitflags 2.13.1",
|
||||||
|
"block2 0.6.2",
|
||||||
"objc2 0.6.4",
|
"objc2 0.6.4",
|
||||||
"objc2-core-foundation",
|
"objc2-core-foundation",
|
||||||
"objc2-foundation 0.3.2",
|
"objc2-foundation 0.3.2",
|
||||||
@@ -4963,7 +4971,7 @@ checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220"
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "perf"
|
name = "perf"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/zed-industries/zed#bce0c5785bfd9172c939aca4083fd70bc4930927"
|
source = "git+https://github.com/zed-industries/zed#ce48461eaadd16c65c31f835511ab96bd3b6e746"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"collections",
|
"collections",
|
||||||
"serde",
|
"serde",
|
||||||
@@ -4977,6 +4985,7 @@ dependencies = [
|
|||||||
"anyhow",
|
"anyhow",
|
||||||
"common",
|
"common",
|
||||||
"flume 0.11.1",
|
"flume 0.11.1",
|
||||||
|
"futures",
|
||||||
"gpui",
|
"gpui",
|
||||||
"instant",
|
"instant",
|
||||||
"log",
|
"log",
|
||||||
@@ -5734,7 +5743,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "refineable"
|
name = "refineable"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/zed-industries/zed#bce0c5785bfd9172c939aca4083fd70bc4930927"
|
source = "git+https://github.com/zed-industries/zed#ce48461eaadd16c65c31f835511ab96bd3b6e746"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"derive_refineable",
|
"derive_refineable",
|
||||||
]
|
]
|
||||||
@@ -5816,7 +5825,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "reqwest_client"
|
name = "reqwest_client"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/zed-industries/zed#bce0c5785bfd9172c939aca4083fd70bc4930927"
|
source = "git+https://github.com/zed-industries/zed#ce48461eaadd16c65c31f835511ab96bd3b6e746"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"bytes",
|
"bytes",
|
||||||
@@ -6117,7 +6126,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "scheduler"
|
name = "scheduler"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/zed-industries/zed#bce0c5785bfd9172c939aca4083fd70bc4930927"
|
source = "git+https://github.com/zed-industries/zed#ce48461eaadd16c65c31f835511ab96bd3b6e746"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-task",
|
"async-task",
|
||||||
"backtrace",
|
"backtrace",
|
||||||
@@ -6711,7 +6720,7 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292"
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "sum_tree"
|
name = "sum_tree"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/zed-industries/zed#bce0c5785bfd9172c939aca4083fd70bc4930927"
|
source = "git+https://github.com/zed-industries/zed#ce48461eaadd16c65c31f835511ab96bd3b6e746"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"heapless 0.9.3",
|
"heapless 0.9.3",
|
||||||
"log",
|
"log",
|
||||||
@@ -7750,7 +7759,7 @@ checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be"
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "util_macros"
|
name = "util_macros"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/zed-industries/zed#bce0c5785bfd9172c939aca4083fd70bc4930927"
|
source = "git+https://github.com/zed-industries/zed#ce48461eaadd16c65c31f835511ab96bd3b6e746"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"perf",
|
"perf",
|
||||||
"quote",
|
"quote",
|
||||||
@@ -7789,9 +7798,9 @@ checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "value-bag"
|
name = "value-bag"
|
||||||
version = "1.14.0"
|
version = "1.13.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "11d4788a546b899f8656382fe210e0c478fe3d2dcd6263d50cb6cc268240de6c"
|
checksum = "068e763e8279de7ab94b6afebded2cb701678af094feb1c12ccb061b4783c1be"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"value-bag-serde1",
|
"value-bag-serde1",
|
||||||
"value-bag-sval2",
|
"value-bag-sval2",
|
||||||
@@ -8929,7 +8938,6 @@ version = "1.0.0"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"auto_update",
|
"auto_update",
|
||||||
"browser-signer-proxy",
|
|
||||||
"chat",
|
"chat",
|
||||||
"chat_ui",
|
"chat_ui",
|
||||||
"common",
|
"common",
|
||||||
@@ -9426,7 +9434,7 @@ checksum = "34b31d188d9d685a4f9c7b46d6e36631b07058d2cfe190267adce54dc230bf12"
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "zlog"
|
name = "zlog"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/zed-industries/zed#bce0c5785bfd9172c939aca4083fd70bc4930927"
|
source = "git+https://github.com/zed-industries/zed#ce48461eaadd16c65c31f835511ab96bd3b6e746"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"chrono",
|
"chrono",
|
||||||
@@ -9443,7 +9451,7 @@ checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b"
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "ztracing"
|
name = "ztracing"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/zed-industries/zed#bce0c5785bfd9172c939aca4083fd70bc4930927"
|
source = "git+https://github.com/zed-industries/zed#ce48461eaadd16c65c31f835511ab96bd3b6e746"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"tracing",
|
"tracing",
|
||||||
"tracing-subscriber",
|
"tracing-subscriber",
|
||||||
@@ -9454,7 +9462,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "ztracing_macro"
|
name = "ztracing_macro"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/zed-industries/zed#bce0c5785bfd9172c939aca4083fd70bc4930927"
|
source = "git+https://github.com/zed-industries/zed#ce48461eaadd16c65c31f835511ab96bd3b6e746"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "zune-core"
|
name = "zune-core"
|
||||||
|
|||||||
@@ -43,7 +43,6 @@ smallvec = "1.14.0"
|
|||||||
smol = "2"
|
smol = "2"
|
||||||
webbrowser = "1.0.4"
|
webbrowser = "1.0.4"
|
||||||
tracing-subscriber = { version = "0.3.18", features = ["fmt"] }
|
tracing-subscriber = { version = "0.3.18", features = ["fmt"] }
|
||||||
errno = { version = "0.3.14", default-features = false }
|
|
||||||
instant = "0.1"
|
instant = "0.1"
|
||||||
|
|
||||||
[patch.crates-io]
|
[patch.crates-io]
|
||||||
|
|||||||
@@ -8,4 +8,12 @@ publish.workspace = true
|
|||||||
gpui.workspace = true
|
gpui.workspace = true
|
||||||
anyhow.workspace = true
|
anyhow.workspace = true
|
||||||
log.workspace = true
|
log.workspace = true
|
||||||
|
|
||||||
|
[target.'cfg(not(target_family = "wasm"))'.dependencies]
|
||||||
rust-embed.workspace = true
|
rust-embed.workspace = true
|
||||||
|
|
||||||
|
[target.'cfg(target_family = "wasm")'.dependencies]
|
||||||
|
futures.workspace = true
|
||||||
|
reqwest = { version = "0.12", default-features = false }
|
||||||
|
wasm-bindgen-futures = "0.4"
|
||||||
|
web-sys = { version = "0.3", features = ["Window", "Location"] }
|
||||||
|
|||||||
@@ -0,0 +1,58 @@
|
|||||||
|
//! Generates a compile-time manifest of the asset files served on wasm, so
|
||||||
|
//! the web entrypoint can preload them before the first frame.
|
||||||
|
//!
|
||||||
|
//! `WASM_ASSETS` is emitted into `OUT_DIR` and included by
|
||||||
|
//! `src/wasm_assets.rs` on wasm targets. Native builds keep using
|
||||||
|
//! `rust-embed` and ignore it.
|
||||||
|
|
||||||
|
use std::path::Path;
|
||||||
|
use std::{env, fs};
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let manifest_dir = env::var("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR not set by cargo");
|
||||||
|
let assets_dir = Path::new(&manifest_dir).join("../../assets");
|
||||||
|
|
||||||
|
let mut paths = Vec::new();
|
||||||
|
for dir in ["icons", "brand"] {
|
||||||
|
let dir_path = assets_dir.join(dir);
|
||||||
|
let entries = fs::read_dir(&dir_path).unwrap_or_else(|error| {
|
||||||
|
panic!(
|
||||||
|
"expected asset directory {} to exist: {error}",
|
||||||
|
dir_path.display()
|
||||||
|
)
|
||||||
|
});
|
||||||
|
|
||||||
|
for entry in entries {
|
||||||
|
let entry = entry.expect("failed to read asset directory entry");
|
||||||
|
if entry.file_type().is_ok_and(|t| t.is_file()) {
|
||||||
|
let name = entry.file_name().to_string_lossy().into_owned();
|
||||||
|
if !name.starts_with('.') {
|
||||||
|
paths.push(format!("{dir}/{name}"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
paths.sort();
|
||||||
|
|
||||||
|
let manifest = format!(
|
||||||
|
"/// Asset files served by the wasm asset loader. Generated by build.rs.\npub const WASM_ASSETS: &[&str] = &[\n{}\n];\n",
|
||||||
|
paths
|
||||||
|
.iter()
|
||||||
|
.map(|path| format!(" \"{path}\","))
|
||||||
|
.collect::<Vec<_>>()
|
||||||
|
.join("\n")
|
||||||
|
);
|
||||||
|
|
||||||
|
let out_dir = env::var("OUT_DIR").expect("OUT_DIR not set by cargo");
|
||||||
|
fs::write(Path::new(&out_dir).join("wasm_assets.rs"), manifest)
|
||||||
|
.expect("failed to write wasm asset manifest");
|
||||||
|
|
||||||
|
// Rerun when the asset files change (adding/removing files updates the
|
||||||
|
// directory mtime).
|
||||||
|
for dir in ["icons", "brand"] {
|
||||||
|
if let Ok(canonical) = assets_dir.join(dir).canonicalize() {
|
||||||
|
println!("cargo:rerun-if-changed={}", canonical.display());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
println!("cargo:rerun-if-changed=build.rs");
|
||||||
|
}
|
||||||
+16
-48
@@ -1,51 +1,19 @@
|
|||||||
use anyhow::Context;
|
//! Application assets for Coop.
|
||||||
use gpui::{App, AssetSource, Result, SharedString};
|
//!
|
||||||
use rust_embed::RustEmbed;
|
//! ## Platform differences
|
||||||
|
//!
|
||||||
|
//! - **Native (desktop)**: assets are embedded into the binary at compile time
|
||||||
|
//! with `rust-embed`.
|
||||||
|
//! - **WASM (web)**: assets are downloaded on demand from `{endpoint}/assets/{path}`
|
||||||
|
//! and cached in memory. This keeps the WASM bundle size small.
|
||||||
|
|
||||||
#[derive(RustEmbed)]
|
#[cfg(not(target_family = "wasm"))]
|
||||||
#[folder = "../../assets"]
|
mod native_assets;
|
||||||
#[include = "fonts/**/*"]
|
|
||||||
#[include = "brand/**/*"]
|
|
||||||
#[include = "icons/**/*"]
|
|
||||||
#[include = "themes/**/*"]
|
|
||||||
#[exclude = "*.DS_Store"]
|
|
||||||
pub struct Assets;
|
|
||||||
|
|
||||||
impl AssetSource for Assets {
|
#[cfg(target_family = "wasm")]
|
||||||
fn load(&self, path: &str) -> Result<Option<std::borrow::Cow<'static, [u8]>>> {
|
mod wasm_assets;
|
||||||
Self::get(path)
|
|
||||||
.map(|f| Some(f.data))
|
|
||||||
.with_context(|| format!("loading asset at path {path:?}"))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn list(&self, path: &str) -> Result<Vec<SharedString>> {
|
#[cfg(not(target_family = "wasm"))]
|
||||||
Ok(Self::iter()
|
pub use native_assets::Assets;
|
||||||
.filter_map(|p| {
|
#[cfg(target_family = "wasm")]
|
||||||
if p.starts_with(path) {
|
pub use wasm_assets::Assets;
|
||||||
Some(p.into())
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.collect())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Assets {
|
|
||||||
/// Populate the [`TextSystem`] of the given [`AppContext`] with all `.ttf` fonts in the `fonts` directory.
|
|
||||||
pub fn load_fonts(&self, cx: &App) -> anyhow::Result<()> {
|
|
||||||
let font_paths = self.list("fonts")?;
|
|
||||||
let mut embedded_fonts = Vec::new();
|
|
||||||
for font_path in font_paths {
|
|
||||||
if font_path.ends_with(".ttf") {
|
|
||||||
let font_bytes = cx
|
|
||||||
.asset_source()
|
|
||||||
.load(&font_path)?
|
|
||||||
.expect("Assets should never return None");
|
|
||||||
embedded_fonts.push(font_bytes);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
cx.text_system().add_fonts(embedded_fonts)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -0,0 +1,63 @@
|
|||||||
|
use std::borrow::Cow;
|
||||||
|
|
||||||
|
use anyhow::Context;
|
||||||
|
use gpui::{App, AssetSource, Result, SharedString};
|
||||||
|
use rust_embed::RustEmbed;
|
||||||
|
|
||||||
|
/// Native implementation using `rust-embed`: assets are embedded into the
|
||||||
|
/// binary at compile time.
|
||||||
|
#[derive(RustEmbed)]
|
||||||
|
#[folder = "../../assets"]
|
||||||
|
#[include = "fonts/**/*"]
|
||||||
|
#[include = "brand/**/*"]
|
||||||
|
#[include = "icons/**/*"]
|
||||||
|
#[include = "themes/**/*"]
|
||||||
|
#[exclude = "*.DS_Store"]
|
||||||
|
pub struct Assets;
|
||||||
|
|
||||||
|
impl Assets {
|
||||||
|
/// Create a new Assets instance. The endpoint parameter is ignored for
|
||||||
|
/// native builds.
|
||||||
|
pub fn new(_endpoint: impl Into<SharedString>) -> Self {
|
||||||
|
Self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl AssetSource for Assets {
|
||||||
|
fn load(&self, path: &str) -> Result<Option<Cow<'static, [u8]>>> {
|
||||||
|
Self::get(path)
|
||||||
|
.map(|f| Some(f.data))
|
||||||
|
.with_context(|| format!("loading asset at path {path:?}"))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn list(&self, path: &str) -> Result<Vec<SharedString>> {
|
||||||
|
Ok(Self::iter()
|
||||||
|
.filter_map(|p| {
|
||||||
|
if p.starts_with(path) {
|
||||||
|
Some(p.into())
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.collect())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Assets {
|
||||||
|
/// Populate the [`TextSystem`] of the given [`AppContext`] with all `.ttf` fonts in the `fonts` directory.
|
||||||
|
pub fn load_fonts(&self, cx: &App) -> anyhow::Result<()> {
|
||||||
|
let font_paths = self.list("fonts")?;
|
||||||
|
let mut embedded_fonts = Vec::new();
|
||||||
|
for font_path in font_paths {
|
||||||
|
if font_path.ends_with(".ttf") {
|
||||||
|
let font_bytes = cx
|
||||||
|
.asset_source()
|
||||||
|
.load(&font_path)?
|
||||||
|
.expect("Assets should never return None");
|
||||||
|
embedded_fonts.push(font_bytes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cx.text_system().add_fonts(embedded_fonts)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,176 @@
|
|||||||
|
use std::borrow::Cow;
|
||||||
|
use std::collections::HashMap;
|
||||||
|
use std::sync::{Arc, RwLock};
|
||||||
|
|
||||||
|
use gpui::{AssetSource, Result, SharedString};
|
||||||
|
use wasm_bindgen_futures::spawn_local;
|
||||||
|
|
||||||
|
// Compile-time manifest of every asset file served on wasm (see build.rs).
|
||||||
|
include!(concat!(env!("OUT_DIR"), "/wasm_assets.rs"));
|
||||||
|
|
||||||
|
/// Path prefixes that the wasm loader serves. Fonts and themes are not
|
||||||
|
/// downloaded on web: the web platform bundles its own fonts, and the theme
|
||||||
|
/// registry falls back to the built-in default theme.
|
||||||
|
const SERVED_PREFIXES: [&str; 2] = ["icons/", "brand/"];
|
||||||
|
|
||||||
|
/// WASM implementation - download assets on demand.
|
||||||
|
///
|
||||||
|
/// Assets are fetched from `{endpoint}/assets/{path}` and cached in memory
|
||||||
|
/// after the first successful download. This keeps the WASM bundle small
|
||||||
|
/// while still providing the full asset set at runtime.
|
||||||
|
pub struct Assets {
|
||||||
|
endpoint: SharedString,
|
||||||
|
cache: Arc<RwLock<HashMap<String, Vec<u8>>>>,
|
||||||
|
pending: Arc<RwLock<HashMap<String, bool>>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Assets {
|
||||||
|
/// Create a new Assets instance backed by the given endpoint.
|
||||||
|
///
|
||||||
|
/// Assets are resolved as `{endpoint}/assets/{path}`. An empty endpoint
|
||||||
|
/// resolves against the current page origin (e.g. `/assets/icons/foo.svg`).
|
||||||
|
pub fn new(endpoint: impl Into<SharedString>) -> Self {
|
||||||
|
Self {
|
||||||
|
endpoint: endpoint.into(),
|
||||||
|
cache: Arc::new(RwLock::new(HashMap::new())),
|
||||||
|
pending: Arc::new(RwLock::new(HashMap::new())),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Absolute URL of the given asset path.
|
||||||
|
///
|
||||||
|
/// `reqwest` requires absolute URLs, so a relative endpoint is resolved
|
||||||
|
/// against the current page origin.
|
||||||
|
fn asset_url(&self, path: &str) -> String {
|
||||||
|
let endpoint = if self.endpoint.is_empty() {
|
||||||
|
web_sys::window()
|
||||||
|
.and_then(|window| window.location().origin().ok())
|
||||||
|
.unwrap_or_default()
|
||||||
|
} else {
|
||||||
|
self.endpoint.to_string()
|
||||||
|
};
|
||||||
|
format!("{endpoint}/assets/{path}")
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Download every asset in [`WASM_ASSETS`] into the cache, in parallel,
|
||||||
|
/// before the app starts.
|
||||||
|
///
|
||||||
|
/// Preloading is required for two reasons:
|
||||||
|
/// - Assets loaded through GPUI's [`gpui::Asset`] machinery (e.g. `img()`)
|
||||||
|
/// cache failed loads and never retry them.
|
||||||
|
/// - SVG painting only re-attempts an empty load on the next repaint, so
|
||||||
|
/// an icon would stay invisible until the window happens to redraw.
|
||||||
|
pub async fn preload(&self) {
|
||||||
|
let downloads = WASM_ASSETS.iter().map(|path| async move {
|
||||||
|
let result = reqwest::get(self.asset_url(path)).await;
|
||||||
|
match result {
|
||||||
|
Ok(response) if response.status().is_success() => match response.bytes().await {
|
||||||
|
Ok(bytes) => {
|
||||||
|
if let Ok(mut cache) = self.cache.write() {
|
||||||
|
cache.insert(path.to_string(), bytes.to_vec());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
log::warn!("Failed to read asset {}: {}", path, e);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Ok(response) => {
|
||||||
|
log::warn!(
|
||||||
|
"Failed to download asset {}: HTTP {}",
|
||||||
|
path,
|
||||||
|
response.status()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
log::warn!("Failed to fetch asset {}: {}", path, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
futures::future::join_all(downloads).await;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl AssetSource for Assets {
|
||||||
|
fn load(&self, path: &str) -> Result<Option<Cow<'static, [u8]>>> {
|
||||||
|
if path.is_empty() {
|
||||||
|
return Ok(None);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Only serve paths the web build actually ships.
|
||||||
|
if !SERVED_PREFIXES
|
||||||
|
.iter()
|
||||||
|
.any(|prefix| path.starts_with(prefix))
|
||||||
|
{
|
||||||
|
return Ok(None);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Serve from the in-memory cache when available.
|
||||||
|
if let Ok(cache) = self.cache.read() {
|
||||||
|
if let Some(data) = cache.get(path) {
|
||||||
|
return Ok(Some(Cow::Owned(data.clone())));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Kick off a single download per path; concurrent requests for the
|
||||||
|
// same path share it.
|
||||||
|
let is_pending = self
|
||||||
|
.pending
|
||||||
|
.read()
|
||||||
|
.map(|pending| pending.contains_key(path))
|
||||||
|
.unwrap_or(false);
|
||||||
|
|
||||||
|
if !is_pending {
|
||||||
|
if let Ok(mut pending) = self.pending.write() {
|
||||||
|
pending.insert(path.to_string(), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
let url = self.asset_url(path);
|
||||||
|
let path_clone = path.to_string();
|
||||||
|
let cache = self.cache.clone();
|
||||||
|
let pending = self.pending.clone();
|
||||||
|
|
||||||
|
spawn_local(async move {
|
||||||
|
match reqwest::get(&url).await {
|
||||||
|
Ok(response) if response.status().is_success() => {
|
||||||
|
match response.bytes().await {
|
||||||
|
Ok(bytes) => {
|
||||||
|
if let Ok(mut cache) = cache.write() {
|
||||||
|
cache.insert(path_clone.clone(), bytes.to_vec());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
log::warn!("Failed to read asset {}: {}", path_clone, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ok(response) => {
|
||||||
|
log::warn!(
|
||||||
|
"Failed to download asset {}: HTTP {}",
|
||||||
|
path_clone,
|
||||||
|
response.status()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
log::warn!("Failed to fetch asset {}: {}", path_clone, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Allow retrying failed downloads on subsequent requests.
|
||||||
|
if let Ok(mut pending) = pending.write() {
|
||||||
|
pending.remove(&path_clone);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// The asset is not available yet. GPUI's SVG atlas does not cache
|
||||||
|
// empty loads, so the next repaint will call `load` again and find
|
||||||
|
// the asset in the cache once the download completes.
|
||||||
|
Ok(None)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn list(&self, _path: &str) -> Result<Vec<SharedString>> {
|
||||||
|
// The asset manifest is not available at runtime on web; embedded
|
||||||
|
// directories are not listed.
|
||||||
|
Ok(Vec::new())
|
||||||
|
}
|
||||||
|
}
|
||||||
+42
-33
@@ -233,7 +233,7 @@ impl ChatRegistry {
|
|||||||
if event.kind == Kind::InboxRelays {
|
if event.kind == Kind::InboxRelays {
|
||||||
let current_user = signer.get_public_key_async().await?;
|
let current_user = signer.get_public_key_async().await?;
|
||||||
if event.pubkey == current_user {
|
if event.pubkey == current_user {
|
||||||
tx.send_async(Signal::InboxReady).await?;
|
tx.send_async(Signal::InboxReady).await.ok();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -262,24 +262,24 @@ impl ChatRegistry {
|
|||||||
|
|
||||||
if rumor.tags.is_empty() {
|
if rumor.tags.is_empty() {
|
||||||
let signal = Signal::error(&event, "Recipient is missing");
|
let signal = Signal::error(&event, "Recipient is missing");
|
||||||
tx.send_async(signal).await?;
|
tx.send_async(signal).await.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Emit message for both new and backlog events
|
// Emit message for both new and backlog events
|
||||||
let signal = Signal::message(event.id, rumor);
|
let signal = Signal::message(event.id, rumor);
|
||||||
tx.send_async(signal).await?;
|
tx.send_async(signal).await.ok();
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
let reason = format!("Failed to extract rumor: {e}");
|
let reason = format!("Failed to extract rumor: {e}");
|
||||||
let signal = Signal::error(event.as_ref(), reason);
|
let signal = Signal::error(event.as_ref(), reason);
|
||||||
tx.send_async(signal).await?;
|
tx.send_async(signal).await.ok();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
RelayMessage::EndOfStoredEvents(id)
|
RelayMessage::EndOfStoredEvents(id)
|
||||||
if (id.as_ref() == &sub_id1 || id.as_ref() == &sub_id2) =>
|
if (id.as_ref() == &sub_id1 || id.as_ref() == &sub_id2) =>
|
||||||
{
|
{
|
||||||
tx.send_async(Signal::Eose).await?;
|
tx.send_async(Signal::Eose).await.ok();
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
@@ -290,33 +290,41 @@ impl ChatRegistry {
|
|||||||
|
|
||||||
self.signal_consumer = Some(cx.spawn(async move |this, cx| {
|
self.signal_consumer = Some(cx.spawn(async move |this, cx| {
|
||||||
while let Ok(message) = rx.recv_async().await {
|
while let Ok(message) = rx.recv_async().await {
|
||||||
match message {
|
// `update_in` (rather than `update`) routes through a
|
||||||
Signal::Message(message) => {
|
// try-borrow: on wasm a task poll that lands while the app
|
||||||
this.update(cx, |this, cx| {
|
// context is borrowed can't panic and kill this consumer
|
||||||
this.new_message(message, cx);
|
// (which would stall all message delivery).
|
||||||
})?;
|
this.update_in(cx, |this, _window, cx| {
|
||||||
|
// Drain the whole queue in a single update so a burst of
|
||||||
|
// events (e.g. history sync after login) collapses into
|
||||||
|
// one repaint instead of one per message (important on
|
||||||
|
// wasm, where everything runs on the main thread).
|
||||||
|
let mut batch = vec![message];
|
||||||
|
while let Ok(extra) = rx.try_recv() {
|
||||||
|
batch.push(extra);
|
||||||
}
|
}
|
||||||
Signal::InboxReady => {
|
|
||||||
this.update(cx, |this, cx| {
|
|
||||||
this.get_messages(cx);
|
|
||||||
})?;
|
|
||||||
}
|
|
||||||
Signal::Eose => {
|
|
||||||
this.update(cx, |this, _cx| {
|
|
||||||
this.tracking.store(false, Ordering::Release);
|
|
||||||
})?;
|
|
||||||
|
|
||||||
this.update(cx, |this, cx| {
|
for message in batch {
|
||||||
this.get_rooms(cx);
|
match message {
|
||||||
})?;
|
Signal::Message(message) => {
|
||||||
|
this.new_message(message, cx);
|
||||||
|
}
|
||||||
|
Signal::InboxReady => {
|
||||||
|
this.get_messages(cx);
|
||||||
|
}
|
||||||
|
Signal::Eose => {
|
||||||
|
this.tracking.store(false, Ordering::Release);
|
||||||
|
this.get_rooms(cx);
|
||||||
|
}
|
||||||
|
Signal::Error(failed) => {
|
||||||
|
let _ = trash.update(cx, |this, cx| {
|
||||||
|
this.insert(failed);
|
||||||
|
cx.notify();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
Signal::Error(failed) => {
|
})?;
|
||||||
trash.update(cx, |this, cx| {
|
|
||||||
this.insert(failed);
|
|
||||||
cx.notify();
|
|
||||||
})?;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -370,7 +378,7 @@ impl ChatRegistry {
|
|||||||
.is_some();
|
.is_some();
|
||||||
|
|
||||||
if !found {
|
if !found {
|
||||||
this.update(cx, |_this, cx| {
|
this.update_in(cx, |_this, _window, cx| {
|
||||||
cx.emit(ChatEvent::InboxRelayNotFound);
|
cx.emit(ChatEvent::InboxRelayNotFound);
|
||||||
})?;
|
})?;
|
||||||
}
|
}
|
||||||
@@ -421,7 +429,7 @@ impl ChatRegistry {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if let Err(e) = task.await {
|
if let Err(e) = task.await {
|
||||||
this.update(cx, |_this, cx| {
|
this.update_in(cx, |_this, _window, cx| {
|
||||||
cx.emit(ChatEvent::Error(e.to_string()));
|
cx.emit(ChatEvent::Error(e.to_string()));
|
||||||
})?;
|
})?;
|
||||||
}
|
}
|
||||||
@@ -430,6 +438,7 @@ impl ChatRegistry {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get all messages for the provided signer
|
||||||
/// Reload the chat registry, fetching messages and contact list from relays.
|
/// Reload the chat registry, fetching messages and contact list from relays.
|
||||||
pub fn reload(&mut self, cx: &mut Context<Self>) {
|
pub fn reload(&mut self, cx: &mut Context<Self>) {
|
||||||
self.reset(cx);
|
self.reset(cx);
|
||||||
@@ -634,13 +643,13 @@ impl ChatRegistry {
|
|||||||
self.tasks.push(cx.spawn(async move |this, cx| {
|
self.tasks.push(cx.spawn(async move |this, cx| {
|
||||||
match task.await {
|
match task.await {
|
||||||
Ok(rooms) => {
|
Ok(rooms) => {
|
||||||
this.update(cx, |this, cx| {
|
this.update_in(cx, |this, _window, cx| {
|
||||||
this.extend_rooms(rooms, cx);
|
this.extend_rooms(rooms, cx);
|
||||||
this.sort(cx);
|
this.sort(cx);
|
||||||
})?;
|
})?;
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
this.update(cx, |_, cx| {
|
this.update_in(cx, |_, _window, cx| {
|
||||||
cx.emit(ChatEvent::Error(e.to_string()));
|
cx.emit(ChatEvent::Error(e.to_string()));
|
||||||
})?;
|
})?;
|
||||||
}
|
}
|
||||||
|
|||||||
+40
-24
@@ -242,33 +242,44 @@ impl ChatPanel {
|
|||||||
while let Ok(status) = rx.recv_async().await {
|
while let Ok(status) = rx.recv_async().await {
|
||||||
{
|
{
|
||||||
let mut map = reports.write().unwrap();
|
let mut map = reports.write().unwrap();
|
||||||
let status_id = match &*status {
|
|
||||||
SendStatus::Ok { id, .. } => *id,
|
|
||||||
SendStatus::Failed { id, .. } => *id,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Find the matching report and update it (exit early on first match)
|
// Drain the whole queue in a single update so bursts of
|
||||||
'outer: for reports_list in map.values_mut() {
|
// send statuses collapse into one repaint (important on
|
||||||
for report in reports_list.iter_mut() {
|
// wasm, where everything runs on the main thread).
|
||||||
let Some(output) = report.output.as_mut() else {
|
let mut statuses = vec![status];
|
||||||
continue;
|
while let Ok(extra) = rx.try_recv() {
|
||||||
};
|
statuses.push(extra);
|
||||||
if *output.id() != status_id {
|
}
|
||||||
continue;
|
|
||||||
}
|
for status in statuses {
|
||||||
match &*status {
|
let status_id = match &*status {
|
||||||
SendStatus::Ok { relay, .. } => {
|
SendStatus::Ok { id, .. } => *id,
|
||||||
output.success.insert(relay.clone(), EventSendStatus::Sent);
|
SendStatus::Failed { id, .. } => *id,
|
||||||
|
};
|
||||||
|
|
||||||
|
// Find the matching report and update it (exit early on first match)
|
||||||
|
'outer: for reports_list in map.values_mut() {
|
||||||
|
for report in reports_list.iter_mut() {
|
||||||
|
let Some(output) = report.output.as_mut() else {
|
||||||
|
continue;
|
||||||
|
};
|
||||||
|
if *output.id() != status_id {
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
SendStatus::Failed { relay, message, .. } => {
|
match &*status {
|
||||||
output.failed.insert(relay.clone(), message.clone());
|
SendStatus::Ok { relay, .. } => {
|
||||||
|
output.success.insert(relay.clone(), EventSendStatus::Sent);
|
||||||
|
}
|
||||||
|
SendStatus::Failed { relay, message, .. } => {
|
||||||
|
output.failed.insert(relay.clone(), message.clone());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
break 'outer;
|
||||||
}
|
}
|
||||||
break 'outer;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.update(cx, |_, cx| cx.notify()).ok();
|
this.update_in(cx, |_, _window, cx| cx.notify()).ok();
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}));
|
}));
|
||||||
@@ -325,8 +336,10 @@ impl ChatPanel {
|
|||||||
self.tasks.push(cx.spawn(async move |this, cx| {
|
self.tasks.push(cx.spawn(async move |this, cx| {
|
||||||
let events = get_messages.await?;
|
let events = get_messages.await?;
|
||||||
|
|
||||||
// Update message list
|
// Update message list. `update_in` (rather than `update`) routes
|
||||||
this.update(cx, |this, cx| {
|
// through a try-borrow: on wasm a task poll that lands while the
|
||||||
|
// app context is borrowed can't panic and kill this task.
|
||||||
|
this.update_in(cx, |this, _window, cx| {
|
||||||
this.insert_messages(&events, cx);
|
this.insert_messages(&events, cx);
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
@@ -468,7 +481,10 @@ impl ChatPanel {
|
|||||||
let mut sent_ids = sent_ids.lock().await;
|
let mut sent_ids = sent_ids.lock().await;
|
||||||
sent_ids.extend(outputs.iter().filter_map(|output| output.gift_wrap_id));
|
sent_ids.extend(outputs.iter().filter_map(|output| output.gift_wrap_id));
|
||||||
|
|
||||||
this.update(cx, |this, cx| {
|
// `update_in` (rather than `update`) routes through a try-borrow:
|
||||||
|
// on wasm a poll that lands while the app context is borrowed
|
||||||
|
// can't panic and kill this task.
|
||||||
|
this.update_in(cx, |this, _window, cx| {
|
||||||
this.insert_reports(id, outputs, cx);
|
this.insert_reports(id, outputs, cx);
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
@@ -639,7 +655,7 @@ impl ChatPanel {
|
|||||||
});
|
});
|
||||||
|
|
||||||
self.tasks.push(cx.spawn_in(window, async move |this, cx| {
|
self.tasks.push(cx.spawn_in(window, async move |this, cx| {
|
||||||
this.update(cx, |this, cx| {
|
this.update_in(cx, |this, _window, cx| {
|
||||||
this.set_uploading(true, cx);
|
this.set_uploading(true, cx);
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
|
|||||||
+11
-11
@@ -184,7 +184,7 @@ impl DeviceRegistry {
|
|||||||
}
|
}
|
||||||
// New response event from the master device
|
// New response event from the master device
|
||||||
Kind::Custom(4455) => {
|
Kind::Custom(4455) => {
|
||||||
this.update(cx, |this, cx| {
|
this.update_in(cx, |this, _window, cx| {
|
||||||
this.extract_encryption(event, cx);
|
this.extract_encryption(event, cx);
|
||||||
})?;
|
})?;
|
||||||
}
|
}
|
||||||
@@ -272,7 +272,7 @@ impl DeviceRegistry {
|
|||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
this.update(cx, |_this, cx| {
|
this.update_in(cx, |_this, _window, cx| {
|
||||||
cx.emit(DeviceEvent::NotSet);
|
cx.emit(DeviceEvent::NotSet);
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
@@ -287,13 +287,13 @@ impl DeviceRegistry {
|
|||||||
self.tasks.push(cx.spawn(async move |this, cx| {
|
self.tasks.push(cx.spawn(async move |this, cx| {
|
||||||
match task.await {
|
match task.await {
|
||||||
Ok(keys) => {
|
Ok(keys) => {
|
||||||
this.update(cx, |this, cx| {
|
this.update_in(cx, |this, _window, cx| {
|
||||||
this.set_signer(keys, cx);
|
this.set_signer(keys, cx);
|
||||||
this.wait_for_request(cx);
|
this.wait_for_request(cx);
|
||||||
})?;
|
})?;
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
this.update(cx, |_this, cx| {
|
this.update_in(cx, |_this, _window, cx| {
|
||||||
cx.emit(DeviceEvent::error(e.to_string()));
|
cx.emit(DeviceEvent::error(e.to_string()));
|
||||||
})?;
|
})?;
|
||||||
}
|
}
|
||||||
@@ -358,12 +358,12 @@ impl DeviceRegistry {
|
|||||||
|
|
||||||
self.tasks.push(cx.spawn(async move |this, cx| {
|
self.tasks.push(cx.spawn(async move |this, cx| {
|
||||||
if let Ok(keys) = task.await {
|
if let Ok(keys) = task.await {
|
||||||
this.update(cx, |this, cx| {
|
this.update_in(cx, |this, _window, cx| {
|
||||||
this.set_signer(keys, cx);
|
this.set_signer(keys, cx);
|
||||||
this.wait_for_request(cx);
|
this.wait_for_request(cx);
|
||||||
})?;
|
})?;
|
||||||
} else {
|
} else {
|
||||||
this.update(cx, |this, cx| {
|
this.update_in(cx, |this, _window, cx| {
|
||||||
this.request(cx);
|
this.request(cx);
|
||||||
})?;
|
})?;
|
||||||
}
|
}
|
||||||
@@ -439,17 +439,17 @@ impl DeviceRegistry {
|
|||||||
self.tasks.push(cx.spawn(async move |this, cx| {
|
self.tasks.push(cx.spawn(async move |this, cx| {
|
||||||
match task.await {
|
match task.await {
|
||||||
Ok(Some(event)) => {
|
Ok(Some(event)) => {
|
||||||
this.update(cx, |this, cx| {
|
this.update_in(cx, |this, _window, cx| {
|
||||||
this.extract_encryption(event, cx);
|
this.extract_encryption(event, cx);
|
||||||
})?;
|
})?;
|
||||||
}
|
}
|
||||||
Ok(None) => {
|
Ok(None) => {
|
||||||
this.update(cx, |this, cx| {
|
this.update_in(cx, |this, _window, cx| {
|
||||||
this.wait_for_approval(cx);
|
this.wait_for_approval(cx);
|
||||||
})?;
|
})?;
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
this.update(cx, |_this, cx| {
|
this.update_in(cx, |_this, _window, cx| {
|
||||||
cx.emit(DeviceEvent::error(e.to_string()));
|
cx.emit(DeviceEvent::error(e.to_string()));
|
||||||
})?;
|
})?;
|
||||||
}
|
}
|
||||||
@@ -508,12 +508,12 @@ impl DeviceRegistry {
|
|||||||
self.tasks.push(cx.spawn(async move |this, cx| {
|
self.tasks.push(cx.spawn(async move |this, cx| {
|
||||||
match task.await {
|
match task.await {
|
||||||
Ok(keys) => {
|
Ok(keys) => {
|
||||||
this.update(cx, |this, cx| {
|
this.update_in(cx, |this, _window, cx| {
|
||||||
this.set_signer(keys, cx);
|
this.set_signer(keys, cx);
|
||||||
})?;
|
})?;
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
this.update(cx, |_this, cx| {
|
this.update_in(cx, |_this, _window, cx| {
|
||||||
cx.emit(DeviceEvent::error(e.to_string()));
|
cx.emit(DeviceEvent::error(e.to_string()));
|
||||||
})?;
|
})?;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,3 +15,4 @@ anyhow.workspace = true
|
|||||||
smallvec.workspace = true
|
smallvec.workspace = true
|
||||||
flume.workspace = true
|
flume.workspace = true
|
||||||
log.workspace = true
|
log.workspace = true
|
||||||
|
futures.workspace = true
|
||||||
|
|||||||
+65
-35
@@ -3,7 +3,8 @@ use std::sync::RwLock;
|
|||||||
|
|
||||||
use anyhow::{Error, anyhow};
|
use anyhow::{Error, anyhow};
|
||||||
use common::EventExt;
|
use common::EventExt;
|
||||||
use gpui::{App, AppContext, Context, Entity, Global, Task, Window};
|
use futures::FutureExt;
|
||||||
|
use gpui::{App, AppContext, BackgroundExecutor, Context, Entity, Global, Task, Window};
|
||||||
use instant::Duration;
|
use instant::Duration;
|
||||||
use nostr_sdk::prelude::*;
|
use nostr_sdk::prelude::*;
|
||||||
use smallvec::{SmallVec, smallvec};
|
use smallvec::{SmallVec, smallvec};
|
||||||
@@ -72,24 +73,40 @@ impl PersonRegistry {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
let client3 = client.clone();
|
let client3 = client.clone();
|
||||||
|
let executor = cx.background_executor().clone();
|
||||||
tasks.push(cx.background_spawn(async move {
|
tasks.push(cx.background_spawn(async move {
|
||||||
Self::handle_requests(&client3, &metadata_rx).await;
|
Self::handle_requests(&client3, &metadata_rx, &executor).await;
|
||||||
}));
|
}));
|
||||||
|
|
||||||
tasks.push(cx.spawn(async move |this, cx| {
|
tasks.push(cx.spawn(async move |this, cx| {
|
||||||
while let Ok(event) = rx.recv_async().await {
|
while let Ok(event) = rx.recv_async().await {
|
||||||
this.update(cx, |this, cx| {
|
// `update_in` (rather than `update`) routes through a
|
||||||
match event {
|
// try-borrow: on wasm a task poll that lands while the app
|
||||||
Dispatch::Person(person) => {
|
// context is borrowed can't panic and kill this consumer
|
||||||
this.insert(person, cx);
|
// (which would stall the whole metadata pipeline).
|
||||||
}
|
this.update_in(cx, |this, _window, cx| {
|
||||||
Dispatch::Announcement(event) => {
|
// Drain the whole queue in a single update so a burst of
|
||||||
this.set_announcement(&event, cx);
|
// events collapses into one repaint instead of one per
|
||||||
}
|
// event (important on wasm, where everything runs on the
|
||||||
Dispatch::Relays(event) => {
|
// main thread).
|
||||||
this.set_messaging_relays(&event, cx);
|
let mut dispatch = vec![event];
|
||||||
}
|
while let Ok(extra) = rx.try_recv() {
|
||||||
};
|
dispatch.push(extra);
|
||||||
|
}
|
||||||
|
|
||||||
|
for event in dispatch {
|
||||||
|
match event {
|
||||||
|
Dispatch::Person(person) => {
|
||||||
|
this.insert(person, cx);
|
||||||
|
}
|
||||||
|
Dispatch::Announcement(event) => {
|
||||||
|
this.set_announcement(&event, cx);
|
||||||
|
}
|
||||||
|
Dispatch::Relays(event) => {
|
||||||
|
this.set_messaging_relays(&event, cx);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.ok();
|
.ok();
|
||||||
}
|
}
|
||||||
@@ -156,30 +173,43 @@ impl PersonRegistry {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Handle request for metadata
|
/// Handle request for metadata
|
||||||
async fn handle_requests(client: &Client, rx: &flume::Receiver<PublicKey>) {
|
///
|
||||||
|
/// Requests are collected into batches and flushed when the batch is
|
||||||
|
/// full or the timeout expires.
|
||||||
|
///
|
||||||
|
/// Note: `flume::Selector::wait_timeout` is intentionally not used here:
|
||||||
|
/// it relies on `std::time::Instant` and `thread::park_timeout`, which are
|
||||||
|
/// unavailable on `wasm32-unknown-unknown` (the former panics, the latter
|
||||||
|
/// is a no-op that would turn the wait into a busy loop on the main
|
||||||
|
/// thread).
|
||||||
|
async fn handle_requests(
|
||||||
|
client: &Client,
|
||||||
|
rx: &flume::Receiver<PublicKey>,
|
||||||
|
executor: &BackgroundExecutor,
|
||||||
|
) {
|
||||||
let mut batch: HashSet<PublicKey> = HashSet::new();
|
let mut batch: HashSet<PublicKey> = HashSet::new();
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
match flume::Selector::new()
|
// Wait for the next request, or the batch timeout.
|
||||||
.recv(rx, |result| result.ok())
|
futures::select! {
|
||||||
.wait_timeout(Duration::from_secs(TIMEOUT))
|
result = rx.recv_async() => match result {
|
||||||
|
Ok(public_key) => {
|
||||||
|
batch.insert(public_key);
|
||||||
|
// Keep collecting until the batch is full
|
||||||
|
if batch.len() < 20 {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(_) => return,
|
||||||
|
},
|
||||||
|
_ = executor.timer(Duration::from_secs(TIMEOUT)).fuse() => {}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Flush the batch
|
||||||
|
if !batch.is_empty()
|
||||||
|
&& let Err(e) = get_metadata(client, std::mem::take(&mut batch)).await
|
||||||
{
|
{
|
||||||
Ok(Some(public_key)) => {
|
log::warn!("Failed to get metadata batch: {e}");
|
||||||
batch.insert(public_key);
|
|
||||||
// Process the batch if it's full
|
|
||||||
if batch.len() >= 20
|
|
||||||
&& let Err(e) = get_metadata(client, std::mem::take(&mut batch)).await
|
|
||||||
{
|
|
||||||
log::warn!("Failed to get metadata batch: {e}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_ => {
|
|
||||||
if !batch.is_empty()
|
|
||||||
&& let Err(e) = get_metadata(client, std::mem::take(&mut batch)).await
|
|
||||||
{
|
|
||||||
log::warn!("Failed to get metadata batch: {e}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -205,7 +235,7 @@ impl PersonRegistry {
|
|||||||
|
|
||||||
self.tasks.push(cx.spawn(async move |this, cx| {
|
self.tasks.push(cx.spawn(async move |this, cx| {
|
||||||
if let Ok(persons) = task.await {
|
if let Ok(persons) = task.await {
|
||||||
this.update(cx, |this, cx| {
|
this.update_in(cx, |this, _window, cx| {
|
||||||
this.bulk_insert(persons, cx);
|
this.bulk_insert(persons, cx);
|
||||||
})
|
})
|
||||||
.ok();
|
.ok();
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ impl Person {
|
|||||||
|
|
||||||
/// Get profile avatar
|
/// Get profile avatar
|
||||||
pub fn avatar(&self) -> SharedString {
|
pub fn avatar(&self) -> SharedString {
|
||||||
self.metadata()
|
self.metadata
|
||||||
.picture
|
.picture
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.filter(|picture| !picture.is_empty())
|
.filter(|picture| !picture.is_empty())
|
||||||
@@ -115,13 +115,13 @@ impl Person {
|
|||||||
|
|
||||||
/// Get profile name
|
/// Get profile name
|
||||||
pub fn name(&self) -> SharedString {
|
pub fn name(&self) -> SharedString {
|
||||||
if let Some(display_name) = self.metadata().display_name.as_ref()
|
if let Some(display_name) = self.metadata.display_name.as_ref()
|
||||||
&& !display_name.is_empty()
|
&& !display_name.is_empty()
|
||||||
{
|
{
|
||||||
return SharedString::from(display_name.trim());
|
return SharedString::from(display_name.trim());
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(name) = self.metadata().name.as_ref()
|
if let Some(name) = self.metadata.name.as_ref()
|
||||||
&& !name.is_empty()
|
&& !name.is_empty()
|
||||||
{
|
{
|
||||||
return SharedString::from(name.trim());
|
return SharedString::from(name.trim());
|
||||||
|
|||||||
+11
-9
@@ -3,8 +3,10 @@ use std::collections::HashMap;
|
|||||||
use anyhow::{Error, anyhow};
|
use anyhow::{Error, anyhow};
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
use browser_signer_proxy::prelude::*;
|
use browser_signer_proxy::prelude::*;
|
||||||
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
use common::config_dir;
|
use common::config_dir;
|
||||||
use gpui::{App, AppContext, Context, Entity, EventEmitter, Global, Task, Window};
|
use gpui::{App, AppContext, Context, Entity, EventEmitter, Global, Task, Window};
|
||||||
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
use gpui_tokio::Tokio;
|
use gpui_tokio::Tokio;
|
||||||
use instant::Duration;
|
use instant::Duration;
|
||||||
use nostr_connect::prelude::*;
|
use nostr_connect::prelude::*;
|
||||||
@@ -179,7 +181,7 @@ impl NostrRegistry {
|
|||||||
let task = cx.spawn(async move |this, cx| {
|
let task = cx.spawn(async move |this, cx| {
|
||||||
match new_signer.get_public_key_async().await {
|
match new_signer.get_public_key_async().await {
|
||||||
Ok(public_key) => {
|
Ok(public_key) => {
|
||||||
this.update(cx, |this, cx| {
|
this.update_in(cx, |this, _window, cx| {
|
||||||
this.signer.swap_inner(new_signer);
|
this.signer.swap_inner(new_signer);
|
||||||
this.current_user = Some(public_key);
|
this.current_user = Some(public_key);
|
||||||
cx.emit(StateEvent::SignerChanged);
|
cx.emit(StateEvent::SignerChanged);
|
||||||
@@ -187,7 +189,7 @@ impl NostrRegistry {
|
|||||||
})?;
|
})?;
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
this.update(cx, |_this, cx| {
|
this.update_in(cx, |_this, _window, cx| {
|
||||||
cx.emit(StateEvent::error(e.to_string()));
|
cx.emit(StateEvent::error(e.to_string()));
|
||||||
})?;
|
})?;
|
||||||
}
|
}
|
||||||
@@ -224,7 +226,7 @@ impl NostrRegistry {
|
|||||||
|
|
||||||
self.tasks.push(cx.spawn(async move |this, cx| {
|
self.tasks.push(cx.spawn(async move |this, cx| {
|
||||||
if let Err(e) = task.await {
|
if let Err(e) = task.await {
|
||||||
this.update(cx, |_this, cx| {
|
this.update_in(cx, |_this, _window, cx| {
|
||||||
cx.emit(StateEvent::error(e.to_string()));
|
cx.emit(StateEvent::error(e.to_string()));
|
||||||
})?;
|
})?;
|
||||||
}
|
}
|
||||||
@@ -246,7 +248,7 @@ impl NostrRegistry {
|
|||||||
let secret_key = SecretKey::parse(&content)?;
|
let secret_key = SecretKey::parse(&content)?;
|
||||||
let keys = Keys::new(secret_key);
|
let keys = Keys::new(secret_key);
|
||||||
|
|
||||||
this.update(cx, |this, cx| {
|
this.update_in(cx, |this, _window, cx| {
|
||||||
this.set_signer(keys, cx);
|
this.set_signer(keys, cx);
|
||||||
cx.notify();
|
cx.notify();
|
||||||
})?;
|
})?;
|
||||||
@@ -261,19 +263,19 @@ impl NostrRegistry {
|
|||||||
// Handle auth url with the default browser
|
// Handle auth url with the default browser
|
||||||
signer.auth_url_handler(CoopAuthUrlHandler);
|
signer.auth_url_handler(CoopAuthUrlHandler);
|
||||||
|
|
||||||
this.update(cx, |this, cx| {
|
this.update_in(cx, |this, _window, cx| {
|
||||||
this.set_signer(signer, cx);
|
this.set_signer(signer, cx);
|
||||||
cx.notify();
|
cx.notify();
|
||||||
})?;
|
})?;
|
||||||
} else if content == "proxy" {
|
} else if content == "proxy" {
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
this.update(cx, |this, cx| {
|
this.update_in(cx, |this, _window, cx| {
|
||||||
this.connect_proxy(cx);
|
this.connect_proxy(cx);
|
||||||
})?;
|
})?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
this.update(cx, |_, cx| {
|
this.update_in(cx, |_, _window, cx| {
|
||||||
cx.emit(StateEvent::NoSigner);
|
cx.emit(StateEvent::NoSigner);
|
||||||
})?;
|
})?;
|
||||||
}
|
}
|
||||||
@@ -350,7 +352,7 @@ impl NostrRegistry {
|
|||||||
let proxy = proxy.clone();
|
let proxy = proxy.clone();
|
||||||
async move |this, cx| {
|
async move |this, cx| {
|
||||||
while let Ok(url) = rx.recv_async().await {
|
while let Ok(url) = rx.recv_async().await {
|
||||||
this.update(cx, |this, cx| {
|
this.update_in(cx, |this, _window, cx| {
|
||||||
let save = cx.write_credentials(USER_KEYRING, "proxy", b"proxy");
|
let save = cx.write_credentials(USER_KEYRING, "proxy", b"proxy");
|
||||||
cx.background_spawn(async move { save.await.ok() }).detach();
|
cx.background_spawn(async move { save.await.ok() }).detach();
|
||||||
cx.open_url(&url);
|
cx.open_url(&url);
|
||||||
@@ -372,7 +374,7 @@ impl NostrRegistry {
|
|||||||
loop {
|
loop {
|
||||||
executor.timer(Duration::from_secs(5)).await;
|
executor.timer(Duration::from_secs(5)).await;
|
||||||
if !proxy.is_session_active() {
|
if !proxy.is_session_active() {
|
||||||
_ = this.update(cx, |this, cx| {
|
_ = this.update_in(cx, |this, _window, cx| {
|
||||||
// Only notify if this proxy is still the active signer
|
// Only notify if this proxy is still the active signer
|
||||||
if this.current_user.is_some() {
|
if this.current_user.is_some() {
|
||||||
this.signer.swap_inner(Keys::generate());
|
this.signer.swap_inner(Keys::generate());
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use instant::Duration;
|
|
||||||
|
|
||||||
use gpui::prelude::FluentBuilder as _;
|
use gpui::prelude::FluentBuilder as _;
|
||||||
use gpui::{
|
use gpui::{
|
||||||
div, px, relative, rems, svg, Animation, AnimationExt, AnyElement, App, Div, ElementId,
|
Animation, AnimationExt, AnyElement, App, Div, ElementId, InteractiveElement, IntoElement,
|
||||||
InteractiveElement, IntoElement, ParentElement, RenderOnce, SharedString,
|
ParentElement, RenderOnce, SharedString, StatefulInteractiveElement, StyleRefinement, Styled,
|
||||||
StatefulInteractiveElement, StyleRefinement, Styled, Window,
|
Window, div, px, relative, rems, svg,
|
||||||
};
|
};
|
||||||
|
use instant::Duration;
|
||||||
use theme::ActiveTheme;
|
use theme::ActiveTheme;
|
||||||
|
|
||||||
use crate::icon::IconNamed;
|
use crate::icon::IconNamed;
|
||||||
use crate::{v_flex, Disableable, IconName, Selectable, Sizable, Size, StyledExt as _};
|
use crate::{Disableable, IconName, Selectable, Sizable, Size, StyledExt as _, v_flex};
|
||||||
|
|
||||||
/// A Checkbox element.
|
/// A Checkbox element.
|
||||||
#[allow(clippy::type_complexity)]
|
#[allow(clippy::type_complexity)]
|
||||||
@@ -172,10 +172,16 @@ pub(crate) fn checkbox_check_icon(
|
|||||||
if !disabled && checked != *toggle_state.read(cx) {
|
if !disabled && checked != *toggle_state.read(cx) {
|
||||||
let duration = Duration::from_secs_f64(0.25);
|
let duration = Duration::from_secs_f64(0.25);
|
||||||
cx.spawn({
|
cx.spawn({
|
||||||
let toggle_state = toggle_state.clone();
|
let toggle_state = toggle_state.downgrade();
|
||||||
async move |cx| {
|
async move |cx| {
|
||||||
cx.background_executor().timer(duration).await;
|
cx.background_executor().timer(duration).await;
|
||||||
toggle_state.update(cx, |this, _| *this = checked);
|
// `update_in` (rather than `update`) routes through a
|
||||||
|
// try-borrow: on wasm a task poll that lands while
|
||||||
|
// the app context is borrowed can't panic and kill
|
||||||
|
// this task.
|
||||||
|
toggle_state
|
||||||
|
.update_in(cx, |this, _window, _| *this = checked)
|
||||||
|
.ok();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.detach();
|
.detach();
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
use instant::Duration;
|
|
||||||
|
|
||||||
use gpui::{Context, Pixels, Task, px};
|
use gpui::{Context, Pixels, Task, px};
|
||||||
|
use instant::Duration;
|
||||||
|
|
||||||
static INTERVAL: Duration = Duration::from_millis(500);
|
static INTERVAL: Duration = Duration::from_millis(500);
|
||||||
static PAUSE_DELAY: Duration = Duration::from_millis(300);
|
static PAUSE_DELAY: Duration = Duration::from_millis(300);
|
||||||
@@ -63,9 +62,11 @@ impl BlinkCursor {
|
|||||||
let epoch = self.next_epoch();
|
let epoch = self.next_epoch();
|
||||||
self._task = cx.spawn(async move |this, cx| {
|
self._task = cx.spawn(async move |this, cx| {
|
||||||
cx.background_executor().timer(INTERVAL).await;
|
cx.background_executor().timer(INTERVAL).await;
|
||||||
if let Some(this) = this.upgrade() {
|
// `update_in` (rather than `update`) routes through a try-borrow:
|
||||||
this.update(cx, |this, cx| this.blink(epoch, cx));
|
// on wasm a task poll that lands while the app context is
|
||||||
}
|
// borrowed can't panic and kill this recurring task.
|
||||||
|
this.update_in(cx, |this, _window, cx| this.blink(epoch, cx))
|
||||||
|
.ok();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,12 +86,11 @@ impl BlinkCursor {
|
|||||||
self._task = cx.spawn(async move |this, cx| {
|
self._task = cx.spawn(async move |this, cx| {
|
||||||
cx.background_executor().timer(PAUSE_DELAY).await;
|
cx.background_executor().timer(PAUSE_DELAY).await;
|
||||||
|
|
||||||
if let Some(this) = this.upgrade() {
|
this.update_in(cx, |this, _window, cx| {
|
||||||
this.update(cx, |this, cx| {
|
this.paused = false;
|
||||||
this.paused = false;
|
this.blink(epoch, cx);
|
||||||
this.blink(epoch, cx);
|
})
|
||||||
});
|
.ok();
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,15 +14,16 @@ chat = { path = "../chat" }
|
|||||||
chat_ui = { path = "../chat_ui" }
|
chat_ui = { path = "../chat_ui" }
|
||||||
settings = { path = "../settings" }
|
settings = { path = "../settings" }
|
||||||
person = { path = "../person" }
|
person = { path = "../person" }
|
||||||
auto_update = { path = "../auto_update" }
|
|
||||||
|
|
||||||
gpui.workspace = true
|
gpui.workspace = true
|
||||||
nostr-sdk.workspace = true
|
nostr-sdk.workspace = true
|
||||||
instant.workspace = true
|
instant.workspace = true
|
||||||
nostr-connect.workspace = true
|
nostr-connect.workspace = true
|
||||||
browser-signer-proxy = { path = "../browser-signer-proxy" }
|
|
||||||
|
|
||||||
anyhow.workspace = true
|
anyhow.workspace = true
|
||||||
serde.workspace = true
|
serde.workspace = true
|
||||||
log.workspace = true
|
log.workspace = true
|
||||||
smallvec.workspace = true
|
smallvec.workspace = true
|
||||||
|
|
||||||
|
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
||||||
|
auto_update = { path = "../auto_update" }
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ impl ImportIdentity {
|
|||||||
})?;
|
})?;
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
this.update(cx, |this, cx| {
|
this.update_in(cx, |this, _window, cx| {
|
||||||
this.set_error(e.to_string(), cx);
|
this.set_error(e.to_string(), cx);
|
||||||
})?;
|
})?;
|
||||||
}
|
}
|
||||||
@@ -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<Self>) {}
|
||||||
|
|
||||||
fn set_loading(&mut self, status: bool, cx: &mut Context<Self>) {
|
fn set_loading(&mut self, status: bool, cx: &mut Context<Self>) {
|
||||||
self.loading = status;
|
self.loading = status;
|
||||||
cx.notify();
|
cx.notify();
|
||||||
@@ -193,7 +198,7 @@ impl ImportIdentity {
|
|||||||
self.tasks.push(cx.spawn(async move |this, cx| {
|
self.tasks.push(cx.spawn(async move |this, cx| {
|
||||||
cx.background_executor().timer(Duration::from_secs(3)).await;
|
cx.background_executor().timer(Duration::from_secs(3)).await;
|
||||||
|
|
||||||
this.update(cx, |this, cx| {
|
this.update_in(cx, |this, _window, cx| {
|
||||||
this.error.update(cx, |this, cx| {
|
this.error.update(cx, |this, cx| {
|
||||||
*this = None;
|
*this = None;
|
||||||
cx.notify();
|
cx.notify();
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ impl RestoreEncryption {
|
|||||||
self.tasks.push(cx.spawn(async move |this, cx| {
|
self.tasks.push(cx.spawn(async move |this, cx| {
|
||||||
cx.background_executor().timer(Duration::from_secs(3)).await;
|
cx.background_executor().timer(Duration::from_secs(3)).await;
|
||||||
|
|
||||||
this.update(cx, |this, cx| {
|
this.update_in(cx, |this, _window, cx| {
|
||||||
this.error.update(cx, |this, cx| {
|
this.error.update(cx, |this, cx| {
|
||||||
*this = None;
|
*this = None;
|
||||||
cx.notify();
|
cx.notify();
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ impl Screening {
|
|||||||
self.tasks.push(cx.spawn(async move |this, cx| {
|
self.tasks.push(cx.spawn(async move |this, cx| {
|
||||||
let result = task.await.unwrap_or(false);
|
let result = task.await.unwrap_or(false);
|
||||||
|
|
||||||
this.update(cx, |this, cx| {
|
this.update_in(cx, |this, _window, cx| {
|
||||||
this.followed = result;
|
this.followed = result;
|
||||||
cx.notify();
|
cx.notify();
|
||||||
})
|
})
|
||||||
@@ -139,7 +139,7 @@ impl Screening {
|
|||||||
self.tasks.push(cx.spawn(async move |this, cx| {
|
self.tasks.push(cx.spawn(async move |this, cx| {
|
||||||
match task.await {
|
match task.await {
|
||||||
Ok(contacts) => {
|
Ok(contacts) => {
|
||||||
this.update(cx, |this, cx| {
|
this.update_in(cx, |this, _window, cx| {
|
||||||
this.mutual_contacts = contacts;
|
this.mutual_contacts = contacts;
|
||||||
cx.notify();
|
cx.notify();
|
||||||
})
|
})
|
||||||
@@ -185,7 +185,7 @@ impl Screening {
|
|||||||
self.tasks.push(cx.spawn(async move |this, cx| {
|
self.tasks.push(cx.spawn(async move |this, cx| {
|
||||||
let result = task.await;
|
let result = task.await;
|
||||||
|
|
||||||
this.update(cx, |this, cx| {
|
this.update_in(cx, |this, _window, cx| {
|
||||||
this.last_active = result;
|
this.last_active = result;
|
||||||
cx.notify();
|
cx.notify();
|
||||||
})
|
})
|
||||||
@@ -208,7 +208,7 @@ impl Screening {
|
|||||||
self.tasks.push(cx.spawn(async move |this, cx| {
|
self.tasks.push(cx.spawn(async move |this, cx| {
|
||||||
let result = task.await.unwrap_or(false);
|
let result = task.await.unwrap_or(false);
|
||||||
|
|
||||||
this.update(cx, |this, cx| {
|
this.update_in(cx, |this, _window, cx| {
|
||||||
this.verified = result;
|
this.verified = result;
|
||||||
cx.notify();
|
cx.notify();
|
||||||
})
|
})
|
||||||
|
|||||||
+34
-17
@@ -2,6 +2,7 @@ use std::sync::Arc;
|
|||||||
|
|
||||||
use ::settings::AppSettings;
|
use ::settings::AppSettings;
|
||||||
use anyhow::Error;
|
use anyhow::Error;
|
||||||
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
use auto_update::AutoUpdater;
|
use auto_update::AutoUpdater;
|
||||||
use chat::{ChatEvent, ChatRegistry};
|
use chat::{ChatEvent, ChatRegistry};
|
||||||
use common::{CoopImageCache, download_dir};
|
use common::{CoopImageCache, download_dir};
|
||||||
@@ -379,6 +380,7 @@ impl Workspace {
|
|||||||
Command::ImportEncryption => {
|
Command::ImportEncryption => {
|
||||||
self.import_encryption(window, cx);
|
self.import_encryption(window, cx);
|
||||||
}
|
}
|
||||||
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
Command::Update => {
|
Command::Update => {
|
||||||
let auto_updater = AutoUpdater::global(cx);
|
let auto_updater = AutoUpdater::global(cx);
|
||||||
auto_updater.update(cx, |this, 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 avatar = avatar.clone();
|
||||||
let name = name.clone();
|
let name = name.clone();
|
||||||
|
|
||||||
this.min_w(px(256.))
|
let menu = this
|
||||||
|
.min_w(px(256.))
|
||||||
.item(PopupMenuItem::element(move |_window, cx| {
|
.item(PopupMenuItem::element(move |_window, cx| {
|
||||||
h_flex()
|
h_flex()
|
||||||
.gap_1p5()
|
.gap_1p5()
|
||||||
@@ -593,24 +599,27 @@ impl Workspace {
|
|||||||
IconName::Sun,
|
IconName::Sun,
|
||||||
Box::new(Command::ToggleTheme),
|
Box::new(Command::ToggleTheme),
|
||||||
)
|
)
|
||||||
.separator()
|
.separator();
|
||||||
.menu_with_icon(
|
|
||||||
"Check for Updates",
|
// Auto-update is a desktop-only feature; there is no updater in the browser.
|
||||||
IconName::Device,
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
Box::new(Command::Update),
|
let menu = menu.menu_with_icon(
|
||||||
)
|
"Check for Updates",
|
||||||
.menu_with_icon(
|
IconName::Device,
|
||||||
"Settings",
|
Box::new(Command::Update),
|
||||||
IconName::Settings,
|
);
|
||||||
Box::new(Command::ShowSettings),
|
|
||||||
)
|
menu.menu_with_icon(
|
||||||
|
"Settings",
|
||||||
|
IconName::Settings,
|
||||||
|
Box::new(Command::ShowSettings),
|
||||||
|
)
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn titlebar_right(&mut self, cx: &mut Context<Self>) -> impl IntoElement {
|
fn titlebar_right(&mut self, cx: &mut Context<Self>) -> impl IntoElement {
|
||||||
let updater = AutoUpdater::global(cx);
|
|
||||||
let chat = ChatRegistry::global(cx);
|
let chat = ChatRegistry::global(cx);
|
||||||
let nip4e_enabled = AppSettings::get_nip4e(cx);
|
let nip4e_enabled = AppSettings::get_nip4e(cx);
|
||||||
let nostr = NostrRegistry::global(cx);
|
let nostr = NostrRegistry::global(cx);
|
||||||
@@ -622,15 +631,23 @@ impl Workspace {
|
|||||||
let persons = PersonRegistry::global(cx);
|
let persons = PersonRegistry::global(cx);
|
||||||
let profile = persons.read(cx).get(&public_key, cx);
|
let profile = persons.read(cx).get(&public_key, cx);
|
||||||
let announcement = profile.announcement();
|
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())
|
.when(!cx.theme().platform.is_mac(), |this| this.pr_2())
|
||||||
.gap_2()
|
.gap_2();
|
||||||
.when(!updater_idle, |this| {
|
|
||||||
|
// 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);
|
let status = updater.read(cx).status(cx);
|
||||||
this.child(div().text_xs().italic().child(status))
|
this.child(div().text_xs().italic().child(status))
|
||||||
})
|
})
|
||||||
|
};
|
||||||
|
|
||||||
|
titlebar
|
||||||
.when(nip4e_enabled, |this| {
|
.when(nip4e_enabled, |this| {
|
||||||
this.child(
|
this.child(
|
||||||
Button::new("key")
|
Button::new("key")
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ impl BackupPanel {
|
|||||||
cx.background_executor().timer(Duration::from_secs(2)).await;
|
cx.background_executor().timer(Duration::from_secs(2)).await;
|
||||||
|
|
||||||
// Clear the error message after a delay
|
// Clear the error message after a delay
|
||||||
this.update(cx, |this, cx| {
|
this.update_in(cx, |this, _window, cx| {
|
||||||
this.set_copied(false, cx);
|
this.set_copied(false, cx);
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
|
|||||||
@@ -108,8 +108,10 @@ impl ContactListPanel {
|
|||||||
self.tasks.push(cx.spawn_in(window, async move |this, cx| {
|
self.tasks.push(cx.spawn_in(window, async move |this, cx| {
|
||||||
let public_keys = task.await?;
|
let public_keys = task.await?;
|
||||||
|
|
||||||
// Update state
|
// Update state. `update_in` (rather than `update`) routes through
|
||||||
this.update(cx, |this, cx| {
|
// a try-borrow, so on wasm a poll that happens to land while the
|
||||||
|
// app context is borrowed can't panic and kill this task.
|
||||||
|
this.update_in(cx, |this, _window, cx| {
|
||||||
this.contacts.extend(public_keys);
|
this.contacts.extend(public_keys);
|
||||||
cx.notify();
|
cx.notify();
|
||||||
})?;
|
})?;
|
||||||
@@ -148,8 +150,11 @@ impl ContactListPanel {
|
|||||||
self.tasks.push(cx.spawn_in(window, async move |this, cx| {
|
self.tasks.push(cx.spawn_in(window, async move |this, cx| {
|
||||||
cx.background_executor().timer(Duration::from_secs(2)).await;
|
cx.background_executor().timer(Duration::from_secs(2)).await;
|
||||||
|
|
||||||
// Clear the error message after a delay
|
// Clear the error message after a delay. `update_in` (rather than
|
||||||
this.update(cx, |this, cx| {
|
// `update`) routes through a try-borrow, so on wasm a poll that
|
||||||
|
// happens to land while the app context is borrowed can't panic
|
||||||
|
// and kill this task.
|
||||||
|
this.update_in(cx, |this, _window, cx| {
|
||||||
this.error = None;
|
this.error = None;
|
||||||
cx.notify();
|
cx.notify();
|
||||||
})?;
|
})?;
|
||||||
|
|||||||
@@ -103,8 +103,10 @@ impl MessagingRelayPanel {
|
|||||||
self.tasks.push(cx.spawn_in(window, async move |this, cx| {
|
self.tasks.push(cx.spawn_in(window, async move |this, cx| {
|
||||||
let relays = task.await?;
|
let relays = task.await?;
|
||||||
|
|
||||||
// Update state
|
// Update state. `update_in` (rather than `update`) routes through
|
||||||
this.update(cx, |this, cx| {
|
// a try-borrow: on wasm a poll that lands while the app context
|
||||||
|
// is borrowed can't panic and kill this task.
|
||||||
|
this.update_in(cx, |this, _window, cx| {
|
||||||
this.relays.extend(relays);
|
this.relays.extend(relays);
|
||||||
cx.notify();
|
cx.notify();
|
||||||
})?;
|
})?;
|
||||||
@@ -148,8 +150,11 @@ impl MessagingRelayPanel {
|
|||||||
self.tasks.push(cx.spawn_in(window, async move |this, cx| {
|
self.tasks.push(cx.spawn_in(window, async move |this, cx| {
|
||||||
cx.background_executor().timer(Duration::from_secs(2)).await;
|
cx.background_executor().timer(Duration::from_secs(2)).await;
|
||||||
|
|
||||||
// Clear the error message after a delay
|
// Clear the error message after a delay. `update_in` (rather than
|
||||||
this.update(cx, |this, cx| {
|
// `update`) routes through a try-borrow: on wasm a poll that
|
||||||
|
// lands while the app context is borrowed can't panic and kill
|
||||||
|
// this task.
|
||||||
|
this.update_in(cx, |this, _window, cx| {
|
||||||
this.error = None;
|
this.error = None;
|
||||||
cx.notify();
|
cx.notify();
|
||||||
})?;
|
})?;
|
||||||
|
|||||||
@@ -167,7 +167,7 @@ impl ProfilePanel {
|
|||||||
});
|
});
|
||||||
|
|
||||||
self.tasks.push(cx.spawn_in(window, async move |this, cx| {
|
self.tasks.push(cx.spawn_in(window, async move |this, cx| {
|
||||||
this.update(cx, |this, cx| {
|
this.update_in(cx, |this, _window, cx| {
|
||||||
this.set_uploading(true, cx);
|
this.set_uploading(true, cx);
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
|
|||||||
@@ -121,8 +121,10 @@ impl RelayListPanel {
|
|||||||
self.tasks.push(cx.spawn_in(window, async move |this, cx| {
|
self.tasks.push(cx.spawn_in(window, async move |this, cx| {
|
||||||
let relays = task.await?;
|
let relays = task.await?;
|
||||||
|
|
||||||
// Update state
|
// Update state. `update_in` (rather than `update`) routes through
|
||||||
this.update(cx, |this, cx| {
|
// a try-borrow: on wasm a poll that lands while the app context
|
||||||
|
// is borrowed can't panic and kill this task.
|
||||||
|
this.update_in(cx, |this, _window, cx| {
|
||||||
this.relays.extend(relays);
|
this.relays.extend(relays);
|
||||||
cx.notify();
|
cx.notify();
|
||||||
})?;
|
})?;
|
||||||
@@ -167,8 +169,11 @@ impl RelayListPanel {
|
|||||||
self.tasks.push(cx.spawn_in(window, async move |this, cx| {
|
self.tasks.push(cx.spawn_in(window, async move |this, cx| {
|
||||||
cx.background_executor().timer(Duration::from_secs(2)).await;
|
cx.background_executor().timer(Duration::from_secs(2)).await;
|
||||||
|
|
||||||
// Clear the error message after a delay
|
// Clear the error message after a delay. `update_in` (rather than
|
||||||
this.update(cx, |this, cx| {
|
// `update`) routes through a try-borrow: on wasm a poll that
|
||||||
|
// lands while the app context is borrowed can't panic and kill
|
||||||
|
// this task.
|
||||||
|
this.update_in(cx, |this, _window, cx| {
|
||||||
this.error = None;
|
this.error = None;
|
||||||
cx.notify();
|
cx.notify();
|
||||||
})?;
|
})?;
|
||||||
|
|||||||
@@ -178,7 +178,10 @@ impl Sidebar {
|
|||||||
self.tasks.push(cx.spawn_in(window, async move |this, cx| {
|
self.tasks.push(cx.spawn_in(window, async move |this, cx| {
|
||||||
match task.await {
|
match task.await {
|
||||||
Ok(contacts) => {
|
Ok(contacts) => {
|
||||||
this.update(cx, |this, cx| {
|
// `update_in` (rather than `update`) routes through a
|
||||||
|
// try-borrow: on wasm a poll that lands while the app
|
||||||
|
// context is borrowed can't panic and kill this task.
|
||||||
|
this.update_in(cx, |this, _window, cx| {
|
||||||
this.set_contact_list(contacts, cx);
|
this.set_contact_list(contacts, cx);
|
||||||
})?;
|
})?;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,6 +30,9 @@ console_error_panic_hook = "0.1"
|
|||||||
tracing-wasm = "0.2"
|
tracing-wasm = "0.2"
|
||||||
console_log = "1.0"
|
console_log = "1.0"
|
||||||
wasm-bindgen = "0.2"
|
wasm-bindgen = "0.2"
|
||||||
|
wasm-bindgen-futures = "0.4"
|
||||||
|
js-sys = "0.3"
|
||||||
|
web-sys = { version = "0.3", features = ["Window", "Performance", "console", "DomException"] }
|
||||||
universal-time = { git = "https://github.com/shadowylab/universal-time" }
|
universal-time = { git = "https://github.com/shadowylab/universal-time" }
|
||||||
|
|
||||||
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
||||||
|
|||||||
@@ -36,6 +36,11 @@ if [[ "$(uname)" == "Darwin" ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Step 1: Build WASM
|
# Step 1: Build WASM
|
||||||
|
#
|
||||||
|
# Single-threaded build: `+bulk-memory` only. The multithreaded web backend
|
||||||
|
# is disabled in `web/src/lib.rs` (gpui's wasm workers freeze their JS event
|
||||||
|
# loop in `Atomics.wait`, which breaks nostr-sdk's spawn_local-driven client
|
||||||
|
# and the WebSocket transport), so no atomics/shared-memory flags here.
|
||||||
echo -e "${GREEN}Step 1: Building WASM...${NC}"
|
echo -e "${GREEN}Step 1: Building WASM...${NC}"
|
||||||
cd "$PROJECT_ROOT"
|
cd "$PROJECT_ROOT"
|
||||||
export CARGO_TARGET_DIR="$PROJECT_ROOT/target"
|
export CARGO_TARGET_DIR="$PROJECT_ROOT/target"
|
||||||
|
|||||||
+137
-12
@@ -1,4 +1,8 @@
|
|||||||
|
use std::borrow::Cow;
|
||||||
|
use std::cell::RefCell;
|
||||||
|
|
||||||
use gpui::*;
|
use gpui::*;
|
||||||
|
use theme::{Theme, ThemeMode};
|
||||||
use ui::Root;
|
use ui::Root;
|
||||||
use universal_time::{Instant, MonotonicClock, SystemTime, WallClock, define_time_provider};
|
use universal_time::{Instant, MonotonicClock, SystemTime, WallClock, define_time_provider};
|
||||||
use wasm_bindgen::prelude::*;
|
use wasm_bindgen::prelude::*;
|
||||||
@@ -7,22 +11,64 @@ struct CustomTimeProvider;
|
|||||||
|
|
||||||
impl WallClock for CustomTimeProvider {
|
impl WallClock for CustomTimeProvider {
|
||||||
fn system_time(&self) -> SystemTime {
|
fn system_time(&self) -> SystemTime {
|
||||||
SystemTime::from_unix_duration(instant::Duration::from_secs(0))
|
// Browser wall clock: milliseconds since the Unix epoch.
|
||||||
|
let millis = js_sys::Date::now();
|
||||||
|
SystemTime::from_unix_duration(instant::Duration::from_millis(millis as u64))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MonotonicClock for CustomTimeProvider {
|
impl MonotonicClock for CustomTimeProvider {
|
||||||
fn instant(&self) -> Instant {
|
fn instant(&self) -> Instant {
|
||||||
Instant::from_ticks(instant::Duration::from_secs(0))
|
// `performance.now()` is monotonic; fall back to the wall clock if
|
||||||
|
// it's unavailable.
|
||||||
|
let millis = web_sys::window()
|
||||||
|
.and_then(|window| window.performance())
|
||||||
|
.map(|performance| performance.now())
|
||||||
|
.unwrap_or_else(js_sys::Date::now);
|
||||||
|
Instant::from_ticks(instant::Duration::from_millis(millis as u64))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
define_time_provider!(CustomTimeProvider);
|
define_time_provider!(CustomTimeProvider);
|
||||||
|
|
||||||
#[wasm_bindgen]
|
thread_local! {
|
||||||
pub fn run() -> Result<(), JsValue> {
|
static APPLICATION: RefCell<Option<ApplicationHandle>> = const { RefCell::new(None) };
|
||||||
console_error_panic_hook::set_once();
|
}
|
||||||
|
|
||||||
|
/// Applies a theme mode and restores the bundled web fonts.
|
||||||
|
///
|
||||||
|
/// `Theme::change` reapplies the theme config, which can carry its own font
|
||||||
|
/// family; host system fonts are unavailable in wasm, so the bundled Inter
|
||||||
|
/// fonts are put back afterwards.
|
||||||
|
fn apply_theme(mode: ThemeMode, cx: &mut App) {
|
||||||
|
Theme::change(mode, None, cx);
|
||||||
|
Theme::global_mut(cx).font_family = "Inter".into();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Switches the app between light and dark after it is running.
|
||||||
|
///
|
||||||
|
/// The embedding page calls this to keep the app in sync with its own
|
||||||
|
/// appearance.
|
||||||
|
#[cfg(target_family = "wasm")]
|
||||||
|
#[wasm_bindgen]
|
||||||
|
pub fn set_theme(dark: bool) {
|
||||||
|
let mode = if dark {
|
||||||
|
ThemeMode::Dark
|
||||||
|
} else {
|
||||||
|
ThemeMode::Light
|
||||||
|
};
|
||||||
|
APPLICATION.with(|application| {
|
||||||
|
if let Some(handle) = application.borrow().as_ref() {
|
||||||
|
handle.update(|cx| {
|
||||||
|
apply_theme(mode, cx);
|
||||||
|
cx.refresh_windows();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
#[wasm_bindgen]
|
||||||
|
pub async fn run() -> Result<(), JsValue> {
|
||||||
// Initialize logging to browser console
|
// Initialize logging to browser console
|
||||||
console_log::init_with_level(log::Level::Info).expect("Failed to initialize logger");
|
console_log::init_with_level(log::Level::Info).expect("Failed to initialize logger");
|
||||||
|
|
||||||
@@ -32,21 +78,92 @@ pub fn run() -> Result<(), JsValue> {
|
|||||||
#[cfg(target_family = "wasm")]
|
#[cfg(target_family = "wasm")]
|
||||||
gpui_platform::web_init();
|
gpui_platform::web_init();
|
||||||
|
|
||||||
|
// Install the panic hook AFTER `web_init` (which sets the default
|
||||||
|
// `console_error_panic_hook`), so ours wins. It prints the entire
|
||||||
|
// JS/wasm stack as a single string: `console_error_panic_hook`'s default
|
||||||
|
// output is an `Error` object whose stack is collapsed in the console,
|
||||||
|
// and on wasm the frames below the panic machinery name the task that
|
||||||
|
// panicked (debug builds keep symbol names) — essential for diagnosing
|
||||||
|
// `RefCell already borrowed`.
|
||||||
|
#[cfg(target_family = "wasm")]
|
||||||
|
std::panic::set_hook(Box::new(|info| {
|
||||||
|
// Capture the JS stack (which includes the wasm frames with symbol
|
||||||
|
// names in debug builds) without constructing DOM objects.
|
||||||
|
let stack = js_sys::Reflect::get(&js_sys::Error::new(""), &"stack".into())
|
||||||
|
.ok()
|
||||||
|
.and_then(|v| v.as_string())
|
||||||
|
.unwrap_or_default();
|
||||||
|
web_sys::console::error_1(
|
||||||
|
&format!("{info}\n\n==== full stack ====\n{stack}\n=====================").into(),
|
||||||
|
);
|
||||||
|
}));
|
||||||
|
|
||||||
#[cfg(not(target_family = "wasm"))]
|
#[cfg(not(target_family = "wasm"))]
|
||||||
let app = gpui_platform::application();
|
let app = gpui_platform::application();
|
||||||
|
|
||||||
#[cfg(target_family = "wasm")]
|
#[cfg(target_family = "wasm")]
|
||||||
let app = {
|
let app = {
|
||||||
let app = gpui_platform::single_threaded_web();
|
// Assets are not embedded in the WASM bundle; they are served from
|
||||||
|
// the `/assets/...` URL prefix (see `web/www/vite.config.js`) and
|
||||||
|
// downloaded by the `assets` crate.
|
||||||
|
let assets = assets::Assets::new("");
|
||||||
|
|
||||||
// Temporary fix: intentionally leak the `Rc<AppCell>` to keep the application alive
|
// Download every icon and brand asset before the first frame: brand
|
||||||
struct WasmApplication(std::rc::Rc<AppCell>);
|
// images are loaded through GPUI's image cache, which does not retry
|
||||||
let wasm_app = unsafe { std::mem::transmute::<Application, WasmApplication>(app) };
|
// failed loads, and pre-caching the icons lets them render
|
||||||
std::mem::forget(wasm_app.0.clone());
|
// immediately instead of waiting for a repaint.
|
||||||
unsafe { std::mem::transmute::<WasmApplication, Application>(wasm_app) }
|
assets.preload().await;
|
||||||
|
|
||||||
|
// NOTE: the multithreaded web backend (application_with_web_backend)
|
||||||
|
// cannot host this app's backend. gpui's wasm background workers
|
||||||
|
// block on `Atomics.wait` while idle, freezing their JS event loop,
|
||||||
|
// so `spawn_local`-driven tasks (nostr-sdk's client actor, the
|
||||||
|
// WebSocket transport) and fetch promises never make progress on a
|
||||||
|
// worker thread. Everything must run on the main thread.
|
||||||
|
gpui_platform::single_threaded_web().with_assets(assets)
|
||||||
};
|
};
|
||||||
|
|
||||||
app.run(|cx| {
|
let launch = move |cx: &mut App| {
|
||||||
|
// Load the embedded Inter font stack for WASM, where host system
|
||||||
|
// fonts are unavailable. Inter is the app's UI font on Linux; the
|
||||||
|
// wasm build reuses it so the web app matches the desktop look.
|
||||||
|
let inter_regular =
|
||||||
|
Cow::Borrowed(include_bytes!("../../assets/fonts/Inter/Inter-Regular.ttf").as_slice());
|
||||||
|
let inter_italic =
|
||||||
|
Cow::Borrowed(include_bytes!("../../assets/fonts/Inter/Inter-Italic.ttf").as_slice());
|
||||||
|
let inter_medium =
|
||||||
|
Cow::Borrowed(include_bytes!("../../assets/fonts/Inter/Inter-Medium.ttf").as_slice());
|
||||||
|
let inter_medium_italic = Cow::Borrowed(
|
||||||
|
include_bytes!("../../assets/fonts/Inter/Inter-MediumItalic.ttf").as_slice(),
|
||||||
|
);
|
||||||
|
let inter_semibold =
|
||||||
|
Cow::Borrowed(include_bytes!("../../assets/fonts/Inter/Inter-SemiBold.ttf").as_slice());
|
||||||
|
let inter_semibold_italic = Cow::Borrowed(
|
||||||
|
include_bytes!("../../assets/fonts/Inter/Inter-SemiBoldItalic.ttf").as_slice(),
|
||||||
|
);
|
||||||
|
let inter_bold =
|
||||||
|
Cow::Borrowed(include_bytes!("../../assets/fonts/Inter/Inter-Bold.ttf").as_slice());
|
||||||
|
let inter_bold_italic = Cow::Borrowed(
|
||||||
|
include_bytes!("../../assets/fonts/Inter/Inter-BoldItalic.ttf").as_slice(),
|
||||||
|
);
|
||||||
|
|
||||||
|
cx.text_system()
|
||||||
|
.add_fonts(vec![
|
||||||
|
inter_regular,
|
||||||
|
inter_italic,
|
||||||
|
inter_medium,
|
||||||
|
inter_medium_italic,
|
||||||
|
inter_semibold,
|
||||||
|
inter_semibold_italic,
|
||||||
|
inter_bold,
|
||||||
|
inter_bold_italic,
|
||||||
|
])
|
||||||
|
.expect("Failed to load fonts");
|
||||||
|
|
||||||
|
// Apply the system appearance before the first frame, so the app
|
||||||
|
// never flashes the default light theme.
|
||||||
|
apply_theme(cx.window_appearance().into(), cx);
|
||||||
|
|
||||||
// Open the root window
|
// Open the root window
|
||||||
cx.open_window(WindowOptions::default(), |window, cx| {
|
cx.open_window(WindowOptions::default(), |window, cx| {
|
||||||
// Initialize components
|
// Initialize components
|
||||||
@@ -78,7 +195,15 @@ pub fn run() -> Result<(), JsValue> {
|
|||||||
.expect("Failed to open window. Please restart the application.");
|
.expect("Failed to open window. Please restart the application.");
|
||||||
|
|
||||||
cx.activate(true);
|
cx.activate(true);
|
||||||
|
};
|
||||||
|
|
||||||
|
#[cfg(target_family = "wasm")]
|
||||||
|
APPLICATION.with(|application| {
|
||||||
|
*application.borrow_mut() = Some(app.run_embedded(launch));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
#[cfg(not(target_family = "wasm"))]
|
||||||
|
app.run(launch);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,11 @@ export default defineConfig({
|
|||||||
viteStaticCopy({
|
viteStaticCopy({
|
||||||
targets: [
|
targets: [
|
||||||
{
|
{
|
||||||
src: path.resolve(__dirname, "../../../assets/icons"),
|
src: path.resolve(__dirname, "../../assets/icons"),
|
||||||
|
dest: "assets",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
src: path.resolve(__dirname, "../../assets/brand"),
|
||||||
dest: "assets",
|
dest: "assets",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
@@ -19,9 +23,9 @@ export default defineConfig({
|
|||||||
name: "serve-assets",
|
name: "serve-assets",
|
||||||
configureServer(server) {
|
configureServer(server) {
|
||||||
server.middlewares.use(
|
server.middlewares.use(
|
||||||
"/coop/assets",
|
"/assets",
|
||||||
(req, res, next) => {
|
(req, res, next) => {
|
||||||
const assetsPath = path.resolve(__dirname, "../../../assets");
|
const assetsPath = path.resolve(__dirname, "../../assets");
|
||||||
const filePath = path.join(
|
const filePath = path.join(
|
||||||
assetsPath,
|
assetsPath,
|
||||||
req.url.replace("/assets", ""),
|
req.url.replace("/assets", ""),
|
||||||
|
|||||||
Reference in New Issue
Block a user