dioxus stuff

This commit is contained in:
2024-05-21 21:13:19 -04:00
parent a04238dbcd
commit 7fb6e95c79
8 changed files with 2641 additions and 28 deletions
+1
View File
@@ -1 +1,2 @@
/target
dist/
Generated
+2568 -1
View File
File diff suppressed because it is too large Load Diff
+3 -4
View File
@@ -3,11 +3,10 @@ name = "mumble-webtransport"
version = "0.1.0"
edition = "2021"
[lib]
crate-type = ["cdylib"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
dioxus = { version = "0.5.1", features = ["web"] }
dioxus-web = "0.5.1"
manganis = "0.2.2"
serde-wasm-bindgen = "0.6.5"
serde_json = "1.0.117"
wasm-bindgen = "0.2.92"
+46
View File
@@ -0,0 +1,46 @@
[application]
# App (Project) Name
name = "Mumble Web 2"
# Dioxus App Default Platform
# desktop, web, mobile, ssr
default_platform = "web"
# `build` & `serve` dist path
out_dir = "dist"
# resource (public) file folder
asset_dir = "public"
[web.app]
# HTML title tag content
title = "mumble-web"
[web.watcher]
# when watcher trigger, regenerate the `index.html`
reload_html = true
# which files or dirs will be watcher monitoring
watch_path = ["src", "public"]
# include `assets` in web platform
[web.resource]
# CSS style file
style = []
# Javascript code file
script = []
[web.resource.dev]
# serve: [dev-server] only
# CSS style file
style = []
# Javascript code file
script = []
-14
View File
@@ -1,14 +0,0 @@
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Today's Date</title>
</head>
<body>
<script type="module" src="index.js" /></script>
</body>
</html>
+11
View File
@@ -0,0 +1,11 @@
#![allow(non_snake_case)]
use dioxus::prelude::*;
pub fn app() -> Element {
rsx!(
div {
"Hello, World!"
}
)
}
+6 -9
View File
@@ -1,18 +1,17 @@
pub mod app;
use wasm_bindgen::prelude::*;
use web_sys::console;
use web_sys::WebTransport;
use web_sys::WebTransportOptions;
use web_sys::js_sys::Promise;
#[wasm_bindgen]
extern "C" {
pub fn alert(s: &str);
}
#[wasm_bindgen]
//pub async fn entrypoint() -> std::result::Result<(), wasm_bindgen::JsValue> {
pub async fn entrypoint() -> JsValue {
pub async fn network_entrypoint() {
console::log_1(&"Rust via WASM!".into());
let server_hash = vec![
@@ -58,7 +57,7 @@ pub async fn entrypoint() -> JsValue {
console::log_1(&transport.clone().into());
if let Err(e) = wasm_bindgen_futures::JsFuture::from(transport.ready()).await {
if let Err(e) = wasm_bindgen_futures::JsFuture::from(transport.ready()).await {
console::log_1(&e.into());
panic!();
}
@@ -67,9 +66,7 @@ pub async fn entrypoint() -> JsValue {
let stream: web_sys::WebTransportBidirectionalStream =
match wasm_bindgen_futures::JsFuture::from(transport.create_bidirectional_stream()).await {
Ok(x) => {
x.into()
}
Ok(x) => x.into(),
Err(e) => {
console::log_1(&e.into());
panic!();
@@ -80,5 +77,5 @@ pub async fn entrypoint() -> JsValue {
//let writer = stream.writable();
console::log_1(&"Created bidirectional stream!".into());
return stream.into();
console::log_1(&stream.into());
}
+6
View File
@@ -0,0 +1,6 @@
use mumble_webtransport::{app, network_entrypoint};
pub fn main() {
wasm_bindgen_futures::spawn_local(network_entrypoint());
dioxus::launch(app::app);
}