(feat): redesign WASM module, add TypeScript SDK, migrate to pnpm
Some checks failed
CI / rustfmt (push) Successful in 17s
CI / wasm build (push) Successful in 1m16s
CI / clippy (push) Successful in 1m28s
CI / test (push) Successful in 1m48s
CI / example (push) Successful in 1m31s
CI / duplicate code (push) Failing after 33s
CI / web client (push) Failing after 34s
CI / cargo-machete (push) Successful in 1m18s
CI / cargo-deny (push) Failing after 3m2s

This commit is contained in:
Alois 2026-06-27 23:44:27 +02:00
commit 5caa1c9d5f
49 changed files with 3717 additions and 1501 deletions

View file

@ -53,6 +53,45 @@ impl Default for Policy {
}
}
impl Policy {
pub fn with_send_mode(mut self, send_mode: SendMode) -> Self {
self.send_mode = send_mode;
self
}
pub fn with_max_message_size(mut self, max_message_size: u64) -> Self {
self.max_message_size = max_message_size;
self
}
pub fn with_timeouts(
mut self,
open_stream_timeout: Duration,
write_timeout: Duration,
read_timeout: Duration,
) -> Self {
self.open_stream_timeout = open_stream_timeout;
self.write_timeout = write_timeout;
self.read_timeout = read_timeout;
self
}
pub fn with_keep_alive(mut self, keep_alive_interval: Option<Duration>) -> Self {
self.keep_alive_interval = keep_alive_interval;
self
}
pub fn with_max_idle_timeout(mut self, max_idle_timeout: Option<Duration>) -> Self {
self.max_idle_timeout = max_idle_timeout;
self
}
pub fn with_receiver_queue_capacity(mut self, receiver_queue_capacity: usize) -> Self {
self.receiver_queue_capacity = receiver_queue_capacity;
self
}
}
enum ReceivedFrame {
Message(CommunicationValue),
ClosedByPeer,

View file

@ -1,5 +1,4 @@
use crate::{ConnectionHandle, Policy, Receiver, Sender};
use log;
use mtp_common::CommunicationError;
use rustls::pki_types::{PrivateKeyDer, pem::PemObject};
use std::net::{IpAddr, SocketAddr};
@ -14,13 +13,7 @@ pub struct Host {
impl Host {
pub async fn next(&mut self) -> Option<(Sender, Receiver)> {
log::warn!("[transport Host::next] waiting on recv...");
let result = self.incoming.recv().await;
match &result {
Some(_) => log::warn!("[transport Host::next] received connection"),
None => log::warn!("[transport Host::next] incoming channel closed - sender dropped"),
}
result
self.incoming.recv().await
}
pub fn local_addr(&self) -> std::net::SocketAddr {
@ -66,19 +59,13 @@ pub async fn host(
let policy = Arc::new(policy);
let task = tokio::spawn(async move {
log::warn!("[transport bg task] started");
loop {
log::warn!("[transport bg task] waiting for connection...");
let incoming_session = endpoint.accept().await;
log::warn!("[transport bg task] got incoming session");
let request = match incoming_session.await {
Ok(req) => {
log::warn!("[transport bg task] got request");
req
}
Ok(req) => req,
Err(e) => {
log::warn!("[transport bg task] incoming session error: {e}");
log::debug!("incoming WebTransport session failed: {e}");
continue;
}
};
@ -87,19 +74,15 @@ pub async fn host(
.accept_with_headers([("sec-webtransport-http3-draft02", "1")])
.await
{
Ok(conn) => {
log::warn!("[transport bg task] connection accepted");
conn
}
Ok(conn) => conn,
Err(e) => {
log::warn!("[transport bg task] accept error: {e}");
log::debug!("WebTransport request accept failed: {e}");
continue;
}
};
let incoming_tx = incoming_tx.clone();
let policy = policy.clone();
eprintln!("[transport bg task] spawning handle_connection");
tokio::spawn(handle_connection(connection, incoming_tx, policy));
}
});