Merge branch 'master' into events-2

This commit is contained in:
Evan Almloff 2023-09-04 07:44:59 -05:00
commit b1b2537949
8 changed files with 22 additions and 22 deletions

View file

@ -25,7 +25,7 @@ The Web is the best-supported target platform for Dioxus.
To develop your Dioxus app for the web, you'll need a tool to build and serve your assets. We recommend using [dioxus-cli](https://github.com/DioxusLabs/dioxus/tree/master/packages/cli) which includes a build system, Wasm optimization, a dev server, and support hot reloading: To develop your Dioxus app for the web, you'll need a tool to build and serve your assets. We recommend using [dioxus-cli](https://github.com/DioxusLabs/dioxus/tree/master/packages/cli) which includes a build system, Wasm optimization, a dev server, and support hot reloading:
```shell ```shell
cargo install dioxus-cli cargo install dioxus-cli --locked
``` ```
Make sure the `wasm32-unknown-unknown` target for rust is installed: Make sure the `wasm32-unknown-unknown` target for rust is installed:

View file

@ -7,12 +7,13 @@ It is also very much usable as a template for your projects, if you're aiming to
## Try the example ## Try the example
Make sure you have Dioxus CLI installed (if you're unsure, run `cargo install dioxus-cli`). Make sure you have Dioxus CLI installed (if you're unsure, run `cargo install dioxus-cli --locked`).
You can run `dx serve` in this directory to start the web server locally, or run You can run `dx serve` in this directory to start the web server locally, or run
`dx build --release` to build the project so you can deploy it on a separate web-server. `dx build --release` to build the project so you can deploy it on a separate web-server.
## Project Structure ## Project Structure
``` ```
├── Cargo.toml ├── Cargo.toml
├── Dioxus.toml ├── Dioxus.toml
@ -33,12 +34,12 @@ You can run `dx serve` in this directory to start the web server locally, or run
If you're just getting started with PWAs, here are some useful resources: If you're just getting started with PWAs, here are some useful resources:
* [PWABuilder docs](https://docs.pwabuilder.com/#/) - [PWABuilder docs](https://docs.pwabuilder.com/#/)
* [MDN article on PWAs](https://developer.mozilla.org/en-US/docs/Web/Progressive_web_apps) - [MDN article on PWAs](https://developer.mozilla.org/en-US/docs/Web/Progressive_web_apps)
For service worker scripting (in JavaScript): For service worker scripting (in JavaScript):
* [Service worker guide from PWABuilder](https://docs.pwabuilder.com/#/home/sw-intro) - [Service worker guide from PWABuilder](https://docs.pwabuilder.com/#/home/sw-intro)
* [Service worker examples, also from PWABuilder](https://github.com/pwa-builder/pwabuilder-serviceworkers) - [Service worker examples, also from PWABuilder](https://github.com/pwa-builder/pwabuilder-serviceworkers)
If you want to stay as close to 100% Rust as possible, you can try using [wasi-worker](https://github.com/dunnock/wasi-worker) to replace the JS service worker file. The JSON manifest will still be required though. If you want to stay as close to 100% Rust as possible, you can try using [wasi-worker](https://github.com/dunnock/wasi-worker) to replace the JS service worker file. The JSON manifest will still be required though.

View file

@ -36,7 +36,7 @@ chrono = "0.4.19"
anyhow = "1.0.53" anyhow = "1.0.53"
hyper = "0.14.17" hyper = "0.14.17"
hyper-rustls = "0.23.2" hyper-rustls = "0.23.2"
indicatif = "0.17.0-rc.11" indicatif = "0.17.5"
subprocess = "0.2.9" subprocess = "0.2.9"
axum = { version = "0.5.1", features = ["ws", "headers"] } axum = { version = "0.5.1", features = ["ws", "headers"] }
@ -75,7 +75,6 @@ gitignore = "1.0.7"
open = "4.1.0" open = "4.1.0"
cargo-generate = "0.18" cargo-generate = "0.18"
toml_edit = "0.19.11" toml_edit = "0.19.11"
# dioxus-rsx = "0.0.1"
# bundling # bundling
tauri-bundler = { version = "=1.2", features = ["native-tls-vendored"] } tauri-bundler = { version = "=1.2", features = ["native-tls-vendored"] }

View file

@ -11,7 +11,7 @@ It handles all building, bundling, development and publishing to simplify develo
### Install the stable version (recommended) ### Install the stable version (recommended)
``` ```
cargo install dioxus-cli cargo install dioxus-cli --locked
``` ```
### Install the latest development build through git ### Install the latest development build through git
@ -28,6 +28,7 @@ This will download the CLI from the master branch,
and install it in Cargo's global binary directory (`~/.cargo/bin/` by default). and install it in Cargo's global binary directory (`~/.cargo/bin/` by default).
### Install from local folder ### Install from local folder
``` ```
cargo install --path . --debug cargo install --path . --debug
``` ```
@ -52,6 +53,7 @@ You can use the `Dioxus.toml` file for further configuration.
Some fields are mandatory, but the CLI tool will tell you which ones are missing. Some fields are mandatory, but the CLI tool will tell you which ones are missing.
You can create a `Dioxus.toml` with all fields already set using `dx config init project-name`, You can create a `Dioxus.toml` with all fields already set using `dx config init project-name`,
or you can use this bare-bones template (only mandatory fields) to get started: or you can use this bare-bones template (only mandatory fields) to get started:
```toml ```toml
[application] [application]
name = "project-name" name = "project-name"

View file

@ -16,8 +16,8 @@ and install it in Cargo's global binary directory (`~/.cargo/bin/` by default).
The published version of the Dioxus CLI is updated less often, but is more stable than the git version. The published version of the Dioxus CLI is updated less often, but is more stable than the git version.
``` ```
cargo install dioxus-cli cargo install dioxus-cli --locked
``` ```
Run `dx --help` for a list of all the available commands. Run `dx --help` for a list of all the available commands.
Furthermore, you can run `dx <COMMAND> --help` to get help with a specific command. Furthermore, you can run `dx <COMMAND> --help` to get help with a specific command.

View file

@ -22,7 +22,7 @@ pub struct BuildResult {
pub elapsed_time: u128, pub elapsed_time: u128,
} }
pub fn build(config: &CrateConfig, quiet: bool) -> Result<BuildResult> { pub fn build(config: &CrateConfig) -> Result<BuildResult> {
// [1] Build the project with cargo, generating a wasm32-unknown-unknown target (is there a more specific, better target to leverage?) // [1] Build the project with cargo, generating a wasm32-unknown-unknown target (is there a more specific, better target to leverage?)
// [2] Generate the appropriate build folders // [2] Generate the appropriate build folders
// [3] Wasm-bindgen the .wasm fiile, and move it into the {builddir}/modules/xxxx/xxxx_bg.wasm // [3] Wasm-bindgen the .wasm fiile, and move it into the {builddir}/modules/xxxx/xxxx_bg.wasm
@ -53,7 +53,8 @@ pub fn build(config: &CrateConfig, quiet: bool) -> Result<BuildResult> {
.arg("build") .arg("build")
.arg("--target") .arg("--target")
.arg("wasm32-unknown-unknown") .arg("wasm32-unknown-unknown")
.arg("--message-format=json"); .arg("--message-format=json")
.arg("--quiet");
let cmd = if config.release { let cmd = if config.release {
cmd.arg("--release") cmd.arg("--release")
@ -66,8 +67,6 @@ pub fn build(config: &CrateConfig, quiet: bool) -> Result<BuildResult> {
cmd cmd
}; };
let cmd = if quiet { cmd.arg("--quiet") } else { cmd };
let cmd = if config.custom_profile.is_some() { let cmd = if config.custom_profile.is_some() {
let custom_profile = config.custom_profile.as_ref().unwrap(); let custom_profile = config.custom_profile.as_ref().unwrap();
cmd.arg("--profile").arg(custom_profile) cmd.arg("--profile").arg(custom_profile)
@ -386,10 +385,9 @@ fn prettier_build(cmd: subprocess::Exec) -> anyhow::Result<Vec<Diagnostic>> {
} }
} }
StopSpinOnDrop(pb.clone());
let stdout = cmd.detached().stream_stdout()?; let stdout = cmd.detached().stream_stdout()?;
let reader = std::io::BufReader::new(stdout); let reader = std::io::BufReader::new(stdout);
for message in cargo_metadata::Message::parse_stream(reader) { for message in cargo_metadata::Message::parse_stream(reader) {
match message.unwrap() { match message.unwrap() {
Message::CompilerMessage(msg) => { Message::CompilerMessage(msg) => {
@ -409,7 +407,7 @@ fn prettier_build(cmd: subprocess::Exec) -> anyhow::Result<Vec<Diagnostic>> {
} }
} }
Message::CompilerArtifact(artifact) => { Message::CompilerArtifact(artifact) => {
pb.set_message(format!("Compiling {} ", artifact.package_id)); pb.set_message(format!("⚙️ Compiling {} ", artifact.package_id));
pb.tick(); pb.tick();
} }
Message::BuildScriptExecuted(script) => { Message::BuildScriptExecuted(script) => {

View file

@ -42,7 +42,7 @@ impl Build {
match platform { match platform {
Platform::Web => { Platform::Web => {
crate::builder::build(&crate_config, false)?; crate::builder::build(&crate_config)?;
} }
Platform::Desktop => { Platform::Desktop => {
crate::builder::build_desktop(&crate_config, false)?; crate::builder::build_desktop(&crate_config, false)?;

View file

@ -73,7 +73,7 @@ pub async fn serve_default(
config: CrateConfig, config: CrateConfig,
start_browser: bool, start_browser: bool,
) -> Result<()> { ) -> Result<()> {
let first_build_result = crate::builder::build(&config, false)?; let first_build_result = crate::builder::build(&config)?;
log::info!("🚀 Starting development server..."); log::info!("🚀 Starting development server...");
@ -134,7 +134,7 @@ pub async fn serve_hot_reload(
config: CrateConfig, config: CrateConfig,
start_browser: bool, start_browser: bool,
) -> Result<()> { ) -> Result<()> {
let first_build_result = crate::builder::build(&config, false)?; let first_build_result = crate::builder::build(&config)?;
log::info!("🚀 Starting development server..."); log::info!("🚀 Starting development server...");
@ -474,7 +474,7 @@ async fn ws_handler(
} }
fn build(config: &CrateConfig, reload_tx: &Sender<()>) -> Result<BuildResult> { fn build(config: &CrateConfig, reload_tx: &Sender<()>) -> Result<BuildResult> {
let result = builder::build(config, true)?; let result = builder::build(config)?;
// change the websocket reload state to true; // change the websocket reload state to true;
// the page will auto-reload. // the page will auto-reload.
if config if config