From 26f7465943b38b2cda21cafe7d2864d1fa7716bd Mon Sep 17 00:00:00 2001 From: xfy Date: Fri, 10 Jul 2026 11:33:07 +0800 Subject: [PATCH] feat(deps): add tokio-stream for SSE streaming - tokio-stream 0.1 (sync feature) wraps mpsc::Receiver into a Stream for the upcoming axum SSE handler; axum::response::sse ships with axum 0.8 already so no extra dep needed there - web-sys features: add EventSource + MessageEvent so the WASM frontend can consume SSE via the native EventSource API --- Cargo.toml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 3324d5d..dc40b61 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -49,9 +49,12 @@ md-5 = { version = "0.10", optional = true } futures = { version = "0.3", optional = true } bytes = { version = "1", optional = true } bollard = { version = "0.21", optional = true } +# 把 mpsc::Receiver 包成 Stream,供 axum SSE handler 使用。 +# axum::response::sse::{Sse,KeepAlive,Event} 随 axum 0.8 自带,无需额外 dep。 +tokio-stream = { version = "0.1", features = ["sync"], optional = true } [target.'cfg(target_arch = "wasm32")'.dependencies] -web-sys = { version = "0.3", features = ["Document", "Window", "Storage", "Element", "HtmlElement", "DomTokenList", "MediaQueryList", "HtmlImageElement", "MouseEvent", "KeyboardEvent", "Node", "EventTarget", "Navigator", "File", "FileList", "FormData", "Request", "RequestInit", "Response", "Headers", "ClipboardEvent", "DataTransfer", "HtmlInputElement"] } +web-sys = { version = "0.3", features = ["Document", "Window", "Storage", "Element", "HtmlElement", "DomTokenList", "MediaQueryList", "HtmlImageElement", "MouseEvent", "KeyboardEvent", "Node", "EventTarget", "Navigator", "File", "FileList", "FormData", "Request", "RequestInit", "Response", "Headers", "ClipboardEvent", "DataTransfer", "HtmlInputElement", "EventSource", "MessageEvent"] } wasm-bindgen = "0.2" wasm-bindgen-futures = "0.4" js-sys = "0.3" @@ -107,4 +110,5 @@ server = [ "dep:futures", "dep:bytes", "dep:bollard", + "dep:tokio-stream", ]