From f203b5f99d7bed69f638073ac86fd911b14f2c19 Mon Sep 17 00:00:00 2001 From: YuKun Liu <41265098+mrxiaozhuox@users.noreply.github.com> Date: Sun, 24 Apr 2022 10:44:06 +0800 Subject: [PATCH 001/170] Move `docs` to cli repo --- .github/workflows/docs.yml | 32 ++++++++ docs/.gitignore | 1 + docs/book.toml | 6 ++ docs/src/SUMMARY.md | 11 +++ docs/src/cmd/README.md | 26 +++++++ docs/src/cmd/build.md | 47 ++++++++++++ docs/src/cmd/clean.md | 18 +++++ docs/src/cmd/serve.md | 49 +++++++++++++ docs/src/cmd/translate.md | 57 ++++++++++++++ docs/src/configure.md | 147 +++++++++++++++++++++++++++++++++++++ docs/src/creating.md | 38 ++++++++++ docs/src/installation.md | 24 ++++++ docs/src/introduction.md | 21 ++++++ 13 files changed, 477 insertions(+) create mode 100644 .github/workflows/docs.yml create mode 100644 docs/.gitignore create mode 100644 docs/book.toml create mode 100644 docs/src/SUMMARY.md create mode 100644 docs/src/cmd/README.md create mode 100644 docs/src/cmd/build.md create mode 100644 docs/src/cmd/clean.md create mode 100644 docs/src/cmd/serve.md create mode 100644 docs/src/cmd/translate.md create mode 100644 docs/src/configure.md create mode 100644 docs/src/creating.md create mode 100644 docs/src/installation.md create mode 100644 docs/src/introduction.md diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml new file mode 100644 index 000000000..2638b8a18 --- /dev/null +++ b/.github/workflows/docs.yml @@ -0,0 +1,32 @@ +name: github pages + +on: + push: + paths: + - docs/** + - .github/workflows/docs.yml + branches: + - master + +jobs: + build-deploy: + runs-on: ubuntu-latest + environment: docs + steps: + - uses: actions/checkout@v2 + + - name: Setup mdBook + uses: peaceiris/actions-mdbook@v1 + with: + mdbook-version: "0.4.10" + + - name: Build + run: cd docs && md build -d ../build + + - name: Deploy 🚀 + uses: JamesIves/github-pages-deploy-action@v4.2.3 + with: + branch: gh-pages # The branch the action should deploy to. + folder: build # The folder the action should deploy. + clean: false + token: ${{ secrets.DEPLOY_KEY }} # let's pretend I don't need it for now diff --git a/docs/.gitignore b/docs/.gitignore new file mode 100644 index 000000000..7585238ef --- /dev/null +++ b/docs/.gitignore @@ -0,0 +1 @@ +book diff --git a/docs/book.toml b/docs/book.toml new file mode 100644 index 000000000..c5c216fe4 --- /dev/null +++ b/docs/book.toml @@ -0,0 +1,6 @@ +[book] +authors = ["YuKun Liu"] +language = "en" +multilingual = false +src = "src" +title = "Dioxus Cli" diff --git a/docs/src/SUMMARY.md b/docs/src/SUMMARY.md new file mode 100644 index 000000000..ed7bcbfaf --- /dev/null +++ b/docs/src/SUMMARY.md @@ -0,0 +1,11 @@ +# Summary + +- [Introduction](./introduction.md) +- [Installation](./installation.md) +- [Create a Project](./creating.md) +- [Configure Project](./configure.md) +- [Commands](./cmd/README.md) + - [Build](./cmd/build.md) + - [Serve](./cmd/serve.md) + - [Clean](./cmd/clean.md) + - [Translate](./cmd/translate.md) \ No newline at end of file diff --git a/docs/src/cmd/README.md b/docs/src/cmd/README.md new file mode 100644 index 000000000..c642b475f --- /dev/null +++ b/docs/src/cmd/README.md @@ -0,0 +1,26 @@ +# Commands + +In this chapter we will introduce all `dioxus-cli` commands. + +> you can also use `dioxus --help` to get cli help info. + +``` +dioxus +Build, bundle, & ship your Dioxus app + +USAGE: + dioxus [OPTIONS] + +OPTIONS: + -h, --help Print help information + -v Enable verbose logging + +SUBCOMMANDS: + build Build the Rust WASM app and all of its assets + clean Clean output artifacts + config Dioxus config file controls + create Init a new project for Dioxus + help Print this message or the help of the given subcommand(s) + serve Build, watch & serve the Rust WASM app and all of its assets + translate Translate some source file into Dioxus code +``` \ No newline at end of file diff --git a/docs/src/cmd/build.md b/docs/src/cmd/build.md new file mode 100644 index 000000000..e81973f2d --- /dev/null +++ b/docs/src/cmd/build.md @@ -0,0 +1,47 @@ +# Build + +The `dioxus build` command can help you `pack & build` a dioxus project. + +``` +dioxus-build +Build the Rust WASM app and all of its assets + +USAGE: + dioxus build [OPTIONS] + +OPTIONS: + --example [default: ""] + --platform [default: "default_platform"] + --release [default: false] +``` + +You can use this command to build project to `out_dir` : + +``` +dioxus build --release +``` + +## Target platform + +Use option `platform` choose build target platform: + +``` +# for desktop project +dioxus build --platform desktop +``` + +`platform` only supports `desktop` & `web`. + +``` +# for web project +dioxus build --platform web +``` + +## Build Example + +You can use `--example {name}` to build a example code. + +``` +# build `example/test` code +dioxus build --exmaple test +``` \ No newline at end of file diff --git a/docs/src/cmd/clean.md b/docs/src/cmd/clean.md new file mode 100644 index 000000000..2f889c1a8 --- /dev/null +++ b/docs/src/cmd/clean.md @@ -0,0 +1,18 @@ +# Clean + +`dioxus clean` will call `target clean` and remove `out_dir` directory. + +``` +dioxus-clean +Clean output artifacts + +USAGE: + dioxus clean +``` + +you can use this command to clean all build cache and the `out_dir` content. + +``` +dioxus clean +``` + diff --git a/docs/src/cmd/serve.md b/docs/src/cmd/serve.md new file mode 100644 index 000000000..e5c10a902 --- /dev/null +++ b/docs/src/cmd/serve.md @@ -0,0 +1,49 @@ +# Serve + +The `dioxus serve` can start a dev server (include hot-reload tool) to run the project. + +``` +dioxus-serve +Build, watch & serve the Rust WASM app and all of its assets + +USAGE: + dioxus serve [OPTIONS] + +OPTIONS: + --example [default: ""] + --platform [default: "default_platform"] + --release [default: false] +``` + +You can use this command to build project and start a `dev server` : + +``` +dioxus serve +``` + +## Target platform + +Use option `platform` choose build target platform: + +``` +# for desktop project +dioxus serve --platform desktop +``` + +`platform` only supports `desktop` & `web`. + +`dev-server` only for `web` project. + +``` +# for web project +dioxus serve --platform web +``` + +## Serve Example + +You can use `--example {name}` to start a example code. + +``` +# build `example/test` code +dioxus serve --exmaple test +``` \ No newline at end of file diff --git a/docs/src/cmd/translate.md b/docs/src/cmd/translate.md new file mode 100644 index 000000000..415a88fba --- /dev/null +++ b/docs/src/cmd/translate.md @@ -0,0 +1,57 @@ +# Translate + +`dioxus translate` can translate some source file into Dioxus code. + +``` +dioxus-translate +Translate some source file into Dioxus code + +USAGE: + dioxus translate [OPTIONS] [OUTPUT] + +ARGS: + Output file, stdout if not present + +OPTIONS: + -c, --component Activate debug mode + -f, --file Input file +``` + +## Translate HTML to stdout + +``` +dioxus transtale --file ./index.html +``` + +## Output in a file + +``` +dioxus translate --component --file ./index.html component.rsx +``` + +set `component` flag will wrap `dioxus rsx` code in a component function. + +## Example + +```html +
+

Hello World

+ Link +
+``` + +Translate HTML to Dioxus component code. + +```rust +fn component(cx: Scope) -> Element { + cx.render(rsx! { + div { + h1 { "Hello World" }, + a { + href: "https://dioxuslabs.com/", + "Link" + } + } + }) +} +``` \ No newline at end of file diff --git a/docs/src/configure.md b/docs/src/configure.md new file mode 100644 index 000000000..f274ce70d --- /dev/null +++ b/docs/src/configure.md @@ -0,0 +1,147 @@ +# Configure Project + +This chapter will introduce `Dioxus.toml` and anatomy the config file. + +## Structure + +We use `toml` to define some info for `dioxus` project. + +### Application + +1. ***name*** - project name & title +2. ***default_platform*** - which platform target for this project. + ``` + # current support: web, desktop + # default: web + default_platform = "web" + ``` + change this to `desktop`, the `dioxus build & serve` will default build desktop app. +3. ***out_dir*** - which directory to put the output file; use `dioxus build & service`, the output will put at this directory, and the `assets` will be also copy to here. + ``` + out_dir = "dist" + ``` +4. ***asset_dir*** - which direcotry to put your `static, assets` file, cli will automatic copy all file to `out_dir`, so you can put some resource file in there, like `CSS, JS, Image` file. + ``` + asset_dir = "public" + ``` + +### Web.App + +Web platform application config: + +1. ***title*** - this value will display on the web page title. like `` tag. + ``` + # HTML title tag content + title = "dioxus app | ⛺" + ``` + +### Web.Watcher + +Web platform `dev-server` watcher config: + +1. ***reload_html*** - a boolean value; when watcher trigger, regenerate `index.html` file. + ``` + # when watcher trigger, regenerate the `index.html` + reload_html = true + ``` +2. ***watch_path*** - which files & directories will be watcher monitoring. + ``` + watch_path = ["src", "public"] + ``` + +### Web.Resource + +Include some `CSS Javascript` resources into html file. + +1. ***style*** - include some style(CSS) file into html. + ``` + style = [ + # include from public_dir. + "./assets/style.css", + # or some asset from online cdn. + "https://cdn.jsdelivr.net/npm/bootstrap/dist/css/bootstrap.css" + ] + ``` +2. ***script*** - include some script(JS) file into html. + ``` + style = [ + # include from public_dir. + "./assets/index.js", + # or some asset from online cdn. + "https://cdn.jsdelivr.net/npm/bootstrap/dist/js/bootstrap.js" + ] + ``` + +### Web.Resource.Dev + +Only include resources at `Dev` mode. + +1. ***style*** - include some style(CSS) file into html. + ``` + style = [ + # include from public_dir. + "./assets/style.css", + # or some asset from online cdn. + "https://cdn.jsdelivr.net/npm/bootstrap/dist/css/bootstrap.css" + ] + ``` +2. ***script*** - include some script(JS) file into html. + ``` + style = [ + # include from public_dir. + "./assets/index.js", + # or some asset from online cdn. + "https://cdn.jsdelivr.net/npm/bootstrap/dist/js/bootstrap.js" + ] + ``` + +## Config example + +```toml +[application] + +# App (Project) Name +name = "{{project-name}}" + +# 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 = "dioxus | ⛺" + +[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 = [] +``` \ No newline at end of file diff --git a/docs/src/creating.md b/docs/src/creating.md new file mode 100644 index 000000000..fa725a4f7 --- /dev/null +++ b/docs/src/creating.md @@ -0,0 +1,38 @@ +# Create a Project + +Once you have the Dioxus CLI tool installed, you can use it to create dioxus project. + +## Initializing a default project + +The `dioxus create` command will create a new directory containing a project template. +``` +dioxus create hello-dioxus +``` + +It will clone a default template from github template: [DioxusLabs/dioxus-template](https://github.com/DioxusLabs/dioxus-template) + +> This default template is use for `web` platform application. + +then you can change the current directory in to the project: + +``` +cd hello-dioxus +``` + +> Make sure `wasm32 target` is installed before running the Web project. + +now we can create a `dev server` to display the project: + +``` +dioxus serve +``` + +by default, the dioxus dev server will running at: [`http://127.0.0.1:8080/`](http://127.0.0.1:8080/) + +## Initalizing from other repository + +you can assign which repository you want to create: + +``` +dioxus init hello-dioxus --template=gh:dioxuslabs/dioxus-template +``` \ No newline at end of file diff --git a/docs/src/installation.md b/docs/src/installation.md new file mode 100644 index 000000000..7151de1ff --- /dev/null +++ b/docs/src/installation.md @@ -0,0 +1,24 @@ +# Installation + +There are multiple ways to install the Dioxus CLI tool. Choose any one of the methods below that best suit your needs. + +## Install from latest master version + +We suggest you use `github master` version to install it now. + +We have not yet released the latest version to `crates.io` + +``` +cargo install --git https://github.com/Dioxuslabs/cli +``` + +This will automatically download `Dioxus-CLI` source from github master branch, +and install it in Cargo's global binary directory (`~/.cargo/bin/` by default). + +## Install from `crates.io` version + +``` +cargo install dioxus-cli +``` + +Make sure to add the Cargo bin directory to your `PATH`. \ No newline at end of file diff --git a/docs/src/introduction.md b/docs/src/introduction.md new file mode 100644 index 000000000..2f857a2a5 --- /dev/null +++ b/docs/src/introduction.md @@ -0,0 +1,21 @@ +# Introduction + +📦✨ **Dioxus-Cli** is a tool to help get dioxus projects off the ground. + +![dioxus-logo](https://dioxuslabs.com/guide/images/dioxuslogo_full.png) + +It includes `dev server`, `hot reload` and some `quick command` to help you use dioxus. + +## Features + +- [x] `html` to `rsx` conversion tool +- [x] hot reload for `web` platform +- [x] create dioxus project from `git` repo +- [x] build & pack dioxus project +- [ ] autoformat dioxus `rsx` code + +## Contributors + +Contributors to this guide: + +- [mrxiaozhuox](https://github.com/mrxiaozhuox) \ No newline at end of file From 79df0d0f742f98c7d54a5463e62a19a3ef0b36c8 Mon Sep 17 00:00:00 2001 From: YuKun Liu <41265098+mrxiaozhuox@users.noreply.github.com> Date: Sun, 24 Apr 2022 10:47:04 +0800 Subject: [PATCH 002/170] Fixed workflows --- .github/workflows/docs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 2638b8a18..c6ae8be13 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -21,7 +21,7 @@ jobs: mdbook-version: "0.4.10" - name: Build - run: cd docs && md build -d ../build + run: cd docs && mdbook build -d ../build - name: Deploy 🚀 uses: JamesIves/github-pages-deploy-action@v4.2.3 From 1f1de4d82219125df7ff4654b76c7ef3d7d3ba1b Mon Sep 17 00:00:00 2001 From: YuKun Liu <41265098+mrxiaozhuox@users.noreply.github.com> Date: Sun, 24 Apr 2022 11:03:46 +0800 Subject: [PATCH 003/170] Fixed docs.yml --- .github/workflows/docs.yml | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index c6ae8be13..5643e6194 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -2,31 +2,29 @@ name: github pages on: push: - paths: - - docs/** - - .github/workflows/docs.yml branches: - - master + - main + pull_request: jobs: - build-deploy: - runs-on: ubuntu-latest - environment: docs + deploy: + runs-on: ubuntu-20.04 + concurrency: + group: ${{ github.workflow }}-${{ github.ref }} steps: - uses: actions/checkout@v2 - name: Setup mdBook uses: peaceiris/actions-mdbook@v1 with: - mdbook-version: "0.4.10" + mdbook-version: '0.4.10' + # mdbook-version: 'latest' - - name: Build - run: cd docs && mdbook build -d ../build + - run: cd docs && mdbook build - - name: Deploy 🚀 - uses: JamesIves/github-pages-deploy-action@v4.2.3 + - name: Deploy + uses: peaceiris/actions-gh-pages@v3 + if: ${{ github.ref == 'refs/heads/main' }} with: - branch: gh-pages # The branch the action should deploy to. - folder: build # The folder the action should deploy. - clean: false - token: ${{ secrets.DEPLOY_KEY }} # let's pretend I don't need it for now + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./docs/book \ No newline at end of file From 5f7daedc5d0a9515fce711804e1eaf94204cf6df Mon Sep 17 00:00:00 2001 From: YuKun Liu <41265098+mrxiaozhuox@users.noreply.github.com> Date: Sun, 24 Apr 2022 11:22:02 +0800 Subject: [PATCH 004/170] Update docs.yml --- .github/workflows/docs.yml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 5643e6194..2ed974a47 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -22,9 +22,12 @@ jobs: - run: cd docs && mdbook build - - name: Deploy - uses: peaceiris/actions-gh-pages@v3 - if: ${{ github.ref == 'refs/heads/main' }} + - name: Deploy 🚀 + uses: JamesIves/github-pages-deploy-action@v4.2.3 with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: ./docs/book \ No newline at end of file + branch: gh-pages # The branch the action should deploy to. + folder: docs/book # The folder the action should deploy. + target-folder: docs/nightly/cli + repository-name: dioxuslabs/docsite + clean: false + token: ${{ secrets.DEPLOY_KEY }} # let's pretend I don't need it for now \ No newline at end of file From 2c9f5f1957941dd7875f0b01742809f9ec0823f1 Mon Sep 17 00:00:00 2001 From: YuKun Liu <41265098+mrxiaozhuox@users.noreply.github.com> Date: Fri, 29 Apr 2022 12:59:15 +0800 Subject: [PATCH 005/170] Fixed `dioxus.toml` --- src/assets/dioxus.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/assets/dioxus.toml b/src/assets/dioxus.toml index ab85abe86..b43d0d6df 100644 --- a/src/assets/dioxus.toml +++ b/src/assets/dioxus.toml @@ -42,4 +42,4 @@ script = [] # use binaryen.wasm-opt for output Wasm file # binaryen just will trigger in `web` platform -binaryen = { wasm_opt = [".PROJECT_OUT"] } \ No newline at end of file +binaryen = { wasm_opt = true } \ No newline at end of file From 5d013ecf824b1e62b8741e7e4565af8bf3262f97 Mon Sep 17 00:00:00 2001 From: YuKun Liu <41265098+mrxiaozhuox@users.noreply.github.com> Date: Sat, 7 May 2022 11:54:00 +0800 Subject: [PATCH 006/170] Try to add `Sass` support --- src/assets/dioxus.toml | 5 ++++- src/tools.rs | 32 +++++++++++++++++++++++++++++++- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/src/assets/dioxus.toml b/src/assets/dioxus.toml index b43d0d6df..0c57542b8 100644 --- a/src/assets/dioxus.toml +++ b/src/assets/dioxus.toml @@ -42,4 +42,7 @@ script = [] # use binaryen.wasm-opt for output Wasm file # binaryen just will trigger in `web` platform -binaryen = { wasm_opt = true } \ No newline at end of file +binaryen = { wasm_opt = true } + +# use sass auto will auto check sass file and build it. +sass = { auto = true } \ No newline at end of file diff --git a/src/tools.rs b/src/tools.rs index 937063be0..db4d82268 100644 --- a/src/tools.rs +++ b/src/tools.rs @@ -13,10 +13,11 @@ use tokio::io::AsyncWriteExt; #[derive(Debug, PartialEq, Eq)] pub enum Tool { Binaryen, + Sass, } pub fn tool_list() -> Vec<&'static str> { - vec!["binaryen"] + vec!["binaryen", "sass"] } pub fn app_path() -> PathBuf { @@ -60,6 +61,7 @@ impl Tool { pub fn name(&self) -> &str { match self { Self::Binaryen => "binaryen", + Self::Sass => "sass", } } @@ -67,6 +69,7 @@ impl Tool { pub fn bin_path(&self) -> &str { match self { Self::Binaryen => "bin", + Self::Sass => ".", } } @@ -84,6 +87,17 @@ impl Tool { panic!("unsupported platformm"); } } + Self::Sass => { + if cfg!(target_os = "windows") { + "windows" + } else if cfg!(target_os = "macos") { + "macos" + } else if cfg!(target_os = "linux") { + "linux" + } else { + panic!("unsupported platformm"); + } + } } } @@ -96,6 +110,12 @@ impl Tool { target = self.target_platform() ) } + Self::Sass => { + format!( + "https://github.com/sass/dart-sass/releases/download/1.51.0/dart-sass-1.51.0-{target}-x64.tar.gz", + target = self.target_platform() + ) + } } } @@ -103,6 +123,13 @@ impl Tool { pub fn extension(&self) -> &str { match self { Self::Binaryen => "tar.gz", + Self::Sass => { + if cfg!(target_os = "windows") { + "zip" + } else { + "tar.ge" + } + }, } } @@ -169,6 +196,9 @@ impl Tool { command.to_string() } } + Tool::Sass => { + command.to_string() + } }; if !bin_path.join(&command_file).is_file() { From c48345b86e556c0535d4ead6134921c68d4c121c Mon Sep 17 00:00:00 2001 From: YuKun Liu <41265098+mrxiaozhuox@users.noreply.github.com> Date: Sat, 7 May 2022 16:25:23 +0800 Subject: [PATCH 007/170] Add `zip` support --- Cargo.toml | 2 ++ src/tools.rs | 46 +++++++++++++++++++++++++++++++++++++++------- 2 files changed, 41 insertions(+), 7 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 21e2dad7e..d2bda881f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -39,11 +39,13 @@ hyper = "0.14.17" axum = { version = "0.5.1", features = ["ws", "headers"] } tower-http = { version = "0.2.2", features = ["fs", "trace"] } headers = "0.3.7" + # tools download dirs = "4.0.0" reqwest = { version = "0.11", features = ["rustls-tls", "stream", "trust-dns"] } flate2 = "1.0.22" tar = "0.4.38" +zip = "0.6.2" tower = "0.4.12" [[bin]] diff --git a/src/tools.rs b/src/tools.rs index db4d82268..b37d10cd2 100644 --- a/src/tools.rs +++ b/src/tools.rs @@ -1,6 +1,6 @@ use std::{ fs::{create_dir_all, File}, - path::PathBuf, + path::{Path, PathBuf}, process::Command, }; @@ -112,8 +112,9 @@ impl Tool { } Self::Sass => { format!( - "https://github.com/sass/dart-sass/releases/download/1.51.0/dart-sass-1.51.0-{target}-x64.tar.gz", - target = self.target_platform() + "https://github.com/sass/dart-sass/releases/download/1.51.0/dart-sass-1.51.0-{target}-x64.{extension}", + target = self.target_platform(), + extension = self.extension() ) } } @@ -129,7 +130,7 @@ impl Tool { } else { "tar.ge" } - }, + } } } @@ -169,6 +170,8 @@ impl Tool { let dir_name = if self == &Tool::Binaryen { "binaryen-version_105" + } else if self == &Tool::Sass { + "sass-version-1_51" } else { "" }; @@ -180,6 +183,8 @@ impl Tool { archive.unpack(&tool_path)?; // println!("{:?} -> {:?}", tool_path.join(dir_name), tool_path.join(self.name())); std::fs::rename(tool_path.join(dir_name), tool_path.join(self.name()))?; + } else if self.extension() == "zip" { + // decompress the `zip` file } Ok(()) @@ -196,9 +201,7 @@ impl Tool { command.to_string() } } - Tool::Sass => { - command.to_string() - } + Tool::Sass => command.to_string(), }; if !bin_path.join(&command_file).is_file() { @@ -215,3 +218,32 @@ impl Tool { Ok(output.stdout) } } + +fn extract_zip(file: &Path, target: &Path) -> anyhow::Result<()> { + let zip_file = std::fs::File::open(&file)?; + let mut zip = zip::ZipArchive::new(zip_file)?; + + if !target.exists() { + let _ = std::fs::create_dir_all(target)?; + } + + for i in 0..zip.len() { + let mut file = zip.by_index(i)?; + if file.is_dir() { + // dir + let target = target.join(Path::new(&file.name().replace('\\', ""))); + let _ = std::fs::create_dir_all(target)?; + } else { + // file + let file_path = target.join(Path::new(file.name())); + let mut target_file = if !file_path.exists() { + std::fs::File::create(file_path)? + } else { + std::fs::File::open(file_path)? + }; + let _num = std::io::copy(&mut file, &mut target_file)?; + } + } + + Ok(()) +} From ea723f64cd362d4139d0766fc5a74b95166e2ca0 Mon Sep 17 00:00:00 2001 From: YuKun Liu <41265098+mrxiaozhuox@users.noreply.github.com> Date: Sat, 7 May 2022 19:11:12 +0800 Subject: [PATCH 008/170] Support `sass` install --- src/cli/tool/mod.rs | 4 ++-- src/tools.rs | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/cli/tool/mod.rs b/src/cli/tool/mod.rs index d5c4581aa..f13c1620e 100644 --- a/src/cli/tool/mod.rs +++ b/src/cli/tool/mod.rs @@ -20,9 +20,9 @@ impl Tool { Tool::List {} => { for item in tools::tool_list() { if tools::Tool::from_str(item).unwrap().is_installed() { - println!("{item} [installed]"); + println!("- {item} [installed]"); } else { - println!("{item}"); + println!("- {item}"); } } } diff --git a/src/tools.rs b/src/tools.rs index b37d10cd2..9f96ce0b9 100644 --- a/src/tools.rs +++ b/src/tools.rs @@ -53,6 +53,7 @@ impl Tool { pub fn from_str(name: &str) -> Option { match name { "binaryen" => Some(Self::Binaryen), + "sass" => Some(Self::Sass), _ => None, } } @@ -128,7 +129,7 @@ impl Tool { if cfg!(target_os = "windows") { "zip" } else { - "tar.ge" + "tar.gz" } } } @@ -159,7 +160,7 @@ impl Tool { let chunk = chunk_res.context("error reading chunk from download")?; let _ = file.write(chunk.as_ref()).await; } - + // log::info!("temp file path: {:?}", temp_out); Ok(temp_out) } @@ -170,10 +171,8 @@ impl Tool { let dir_name = if self == &Tool::Binaryen { "binaryen-version_105" - } else if self == &Tool::Sass { - "sass-version-1_51" } else { - "" + "dart-sass" }; if self.extension() == "tar.gz" { @@ -181,10 +180,11 @@ impl Tool { let tar = GzDecoder::new(tar_gz); let mut archive = Archive::new(tar); archive.unpack(&tool_path)?; - // println!("{:?} -> {:?}", tool_path.join(dir_name), tool_path.join(self.name())); std::fs::rename(tool_path.join(dir_name), tool_path.join(self.name()))?; } else if self.extension() == "zip" { // decompress the `zip` file + extract_zip(&temp_path, &tool_path)?; + std::fs::rename(tool_path.join(dir_name), tool_path.join(self.name()))?; } Ok(()) From f7f1d90520bf9712172175ad6ccbec41803172f2 Mon Sep 17 00:00:00 2001 From: YuKun Liu <41265098+mrxiaozhuox@users.noreply.github.com> Date: Sun, 8 May 2022 00:56:22 +0800 Subject: [PATCH 009/170] Add `sass` support --- src/assets/dioxus.toml | 14 +++++++++++++- src/cli/tool/mod.rs | 7 +++++-- src/tools.rs | 8 +++++++- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/assets/dioxus.toml b/src/assets/dioxus.toml index 0c57542b8..8f160b293 100644 --- a/src/assets/dioxus.toml +++ b/src/assets/dioxus.toml @@ -45,4 +45,16 @@ script = [] binaryen = { wasm_opt = true } # use sass auto will auto check sass file and build it. -sass = { auto = true } \ No newline at end of file +[application.tools.sass] + +version = "1.51.0" + +# if auto = true, we will check style array, and translate all sass file to css. +auto = true + +# or you can specify some sass file -> css file +files = [ + # some sass file path + # this file will translate to `/css/test.css` + "/css/test.sass" +] \ No newline at end of file diff --git a/src/cli/tool/mod.rs b/src/cli/tool/mod.rs index f13c1620e..45c866c40 100644 --- a/src/cli/tool/mod.rs +++ b/src/cli/tool/mod.rs @@ -27,7 +27,11 @@ impl Tool { } } Tool::AppPath {} => { - println!("{}", tools::tools_path().to_str().unwrap()); + if let Some(v) = tools::tools_path().to_str() { + println!("{}", v); + } else { + log::error!("Tools path get failed."); + } } Tool::Add { name } => { let tool_list = tools::tool_list(); @@ -58,7 +62,6 @@ impl Tool { log::info!("Tool {name} install successfully!"); } } - Ok(()) } } diff --git a/src/tools.rs b/src/tools.rs index 9f96ce0b9..ae4e58b79 100644 --- a/src/tools.rs +++ b/src/tools.rs @@ -201,7 +201,13 @@ impl Tool { command.to_string() } } - Tool::Sass => command.to_string(), + Tool::Sass => { + if cfg!(target_os = "windows") { + format!("{}.bat", command) + } else { + command.to_string() + } + }, }; if !bin_path.join(&command_file).is_file() { From 768a0426d8519073259f9e642bc0b44f75110f52 Mon Sep 17 00:00:00 2001 From: YuKun Liu <41265098+mrxiaozhuox@users.noreply.github.com> Date: Tue, 10 May 2022 10:31:02 +0800 Subject: [PATCH 010/170] Add `sass` support --- Cargo.toml | 2 ++ src/assets/dioxus.toml | 4 +--- src/builder.rs | 48 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index d2bda881f..c869267b1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -40,6 +40,8 @@ axum = { version = "0.5.1", features = ["ws", "headers"] } tower-http = { version = "0.2.2", features = ["fs", "trace"] } headers = "0.3.7" +walkdir = "2" + # tools download dirs = "4.0.0" reqwest = { version = "0.11", features = ["rustls-tls", "stream", "trust-dns"] } diff --git a/src/assets/dioxus.toml b/src/assets/dioxus.toml index 8f160b293..3e82e0c93 100644 --- a/src/assets/dioxus.toml +++ b/src/assets/dioxus.toml @@ -47,8 +47,6 @@ binaryen = { wasm_opt = true } # use sass auto will auto check sass file and build it. [application.tools.sass] -version = "1.51.0" - # if auto = true, we will check style array, and translate all sass file to css. auto = true @@ -56,5 +54,5 @@ auto = true files = [ # some sass file path # this file will translate to `/css/test.css` - "/css/test.sass" + "/css/test.scss" ] \ No newline at end of file diff --git a/src/builder.rs b/src/builder.rs index f7f68e2bc..7c3a7e9fb 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -1,6 +1,7 @@ use crate::{ config::{CrateConfig, ExecutableType}, error::{Error, Result}, + tools::Tool, DioxusConfig, }; use std::{ @@ -29,6 +30,10 @@ pub fn build(config: &CrateConfig) -> Result<()> { .. } = config; + + // start to build the assets + build_assets(config)?; + let t_start = std::time::Instant::now(); // [1] Build the .wasm module @@ -339,6 +344,49 @@ pub fn gen_page(config: &DioxusConfig, serve: bool) -> String { html.replace("{app_title}", &title) } +// this function will build some assets file +// like sass tool resources +fn build_assets(config: &CrateConfig) -> Result<()> { + let dioxus_config = &config.dioxus_config; + let dioxus_tools = dioxus_config.application.tools.clone().unwrap_or_default(); + + // check sass tool state + let sass = Tool::Sass; + if sass.is_installed() && dioxus_tools.contains_key("sass") { + let sass_conf = dioxus_tools.get("sass").unwrap(); + if let Some(tab) = sass_conf.as_table() { + if tab.contains_key("auto") && tab.get("auto").unwrap().as_bool().unwrap_or(false) { + // if the sass open auto, we need auto-check the assets dir. + let asset_dir = config.asset_dir.clone(); + if asset_dir.is_dir() { + for entry in walkdir::WalkDir::new(asset_dir) + .into_iter() + .filter_map(|e| e.ok()) + { + let temp = entry.path(); + if temp.is_file() { + let suffix = temp.file_name().unwrap().to_str().unwrap(); + let suffix = suffix.split('.').collect::>(); + let suffix: &str = suffix.last().unwrap(); + if suffix == "scss" { + // if file suffix is `scss` we need transform it. + let temp_stem = temp.file_stem().unwrap().to_str().unwrap(); + let target_path = + temp.parent().unwrap().join(format!("{}.css", temp_stem)); + sass.call( + "sass", + vec![temp.to_str().unwrap(), target_path.to_str().unwrap()], + )?; + } + } + } + } + } + } + } + Ok(()) +} + // use binary_install::{Cache, Download}; // /// Attempts to find `wasm-opt` in `PATH` locally, or failing that downloads a From 8b06fe60596371118e47ef71a72627044c17672a Mon Sep 17 00:00:00 2001 From: YuKun Liu <41265098+mrxiaozhuox@users.noreply.github.com> Date: Tue, 10 May 2022 13:46:53 +0800 Subject: [PATCH 011/170] Fixed sass tool --- src/assets/dioxus.toml | 4 ++-- src/builder.rs | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/assets/dioxus.toml b/src/assets/dioxus.toml index 3e82e0c93..105251aa1 100644 --- a/src/assets/dioxus.toml +++ b/src/assets/dioxus.toml @@ -47,10 +47,10 @@ binaryen = { wasm_opt = true } # use sass auto will auto check sass file and build it. [application.tools.sass] -# if auto = true, we will check style array, and translate all sass file to css. +# auto will check the assets dirs, and auto to transform all scss file to css file. auto = true -# or you can specify some sass file -> css file +# you can specify some scss file -> css file files = [ # some sass file path # this file will translate to `/css/test.css` diff --git a/src/builder.rs b/src/builder.rs index 7c3a7e9fb..0e0cf7e9a 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -30,7 +30,6 @@ pub fn build(config: &CrateConfig) -> Result<()> { .. } = config; - // start to build the assets build_assets(config)?; @@ -359,20 +358,21 @@ fn build_assets(config: &CrateConfig) -> Result<()> { // if the sass open auto, we need auto-check the assets dir. let asset_dir = config.asset_dir.clone(); if asset_dir.is_dir() { - for entry in walkdir::WalkDir::new(asset_dir) + for entry in walkdir::WalkDir::new(&asset_dir) .into_iter() .filter_map(|e| e.ok()) { let temp = entry.path(); if temp.is_file() { - let suffix = temp.file_name().unwrap().to_str().unwrap(); - let suffix = suffix.split('.').collect::>(); - let suffix: &str = suffix.last().unwrap(); + let suffix = temp.extension().unwrap().to_str().unwrap(); if suffix == "scss" { // if file suffix is `scss` we need transform it. - let temp_stem = temp.file_stem().unwrap().to_str().unwrap(); - let target_path = - temp.parent().unwrap().join(format!("{}.css", temp_stem)); + let out_file = + format!("{}.css", temp.file_stem().unwrap().to_str().unwrap()); + let target_path = config + .out_dir + .join(temp.strip_prefix(&asset_dir).unwrap().parent().unwrap()) + .join(out_file); sass.call( "sass", vec![temp.to_str().unwrap(), target_path.to_str().unwrap()], From b5ecd09185062724415e9bf7b6b10d7e2c6860e8 Mon Sep 17 00:00:00 2001 From: YuKun Liu <41265098+mrxiaozhuox@users.noreply.github.com> Date: Tue, 10 May 2022 19:22:19 +0800 Subject: [PATCH 012/170] Add `files` list option --- src/assets/dioxus.toml | 2 +- src/builder.rs | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/assets/dioxus.toml b/src/assets/dioxus.toml index 105251aa1..5f5032e2a 100644 --- a/src/assets/dioxus.toml +++ b/src/assets/dioxus.toml @@ -50,7 +50,7 @@ binaryen = { wasm_opt = true } # auto will check the assets dirs, and auto to transform all scss file to css file. auto = true -# you can specify some scss file -> css file +# or you can specify some scss file -> css file files = [ # some sass file path # this file will translate to `/css/test.css` diff --git a/src/builder.rs b/src/builder.rs index 0e0cf7e9a..fb0c8088d 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -381,6 +381,28 @@ fn build_assets(config: &CrateConfig) -> Result<()> { } } } + } else if tab.contains_key("files") && tab.get("files").unwrap().is_array() { + // check files list. + let list = tab.get("files").unwrap().as_array().unwrap(); + for i in list { + if i.is_str() { + let path = i.as_str().unwrap(); + let path = PathBuf::from(path); + let path = config.asset_dir.join(path); + if path.is_file() { + sass.call( + "sass", + vec![ + path.to_str().unwrap(), + path.parent().unwrap().join(format!( + "{}.css", + path.file_stem().unwrap().to_str().unwrap() + )).to_str().unwrap(), + ], + )?; + } + } + } } } } From 551d2477ffcd84d13cfc4c5d15e1c8033a23a160 Mon Sep 17 00:00:00 2001 From: YuKun Liu <41265098+mrxiaozhuox@users.noreply.github.com> Date: Tue, 10 May 2022 22:32:47 +0800 Subject: [PATCH 013/170] Add `source_map` option --- src/assets/dioxus.toml | 4 +++- src/builder.rs | 30 +++++++++++++++++++++++++----- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/src/assets/dioxus.toml b/src/assets/dioxus.toml index 5f5032e2a..b481193a8 100644 --- a/src/assets/dioxus.toml +++ b/src/assets/dioxus.toml @@ -55,4 +55,6 @@ files = [ # some sass file path # this file will translate to `/css/test.css` "/css/test.scss" -] \ No newline at end of file +] + +source_map = true \ No newline at end of file diff --git a/src/builder.rs b/src/builder.rs index fb0c8088d..825a9eebf 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -354,6 +354,17 @@ fn build_assets(config: &CrateConfig) -> Result<()> { if sass.is_installed() && dioxus_tools.contains_key("sass") { let sass_conf = dioxus_tools.get("sass").unwrap(); if let Some(tab) = sass_conf.as_table() { + let source_map = tab.contains_key("source_map"); + let source_map = if source_map && tab.get("source_map").unwrap().is_bool() { + if tab.get("source_map").unwrap().as_bool().unwrap_or_default() { + "--source-map" + } else { + "--no-source-map" + } + } else { + "--no-source-map" + }; + if tab.contains_key("auto") && tab.get("auto").unwrap().as_bool().unwrap_or(false) { // if the sass open auto, we need auto-check the assets dir. let asset_dir = config.asset_dir.clone(); @@ -375,7 +386,11 @@ fn build_assets(config: &CrateConfig) -> Result<()> { .join(out_file); sass.call( "sass", - vec![temp.to_str().unwrap(), target_path.to_str().unwrap()], + vec![ + temp.to_str().unwrap(), + target_path.to_str().unwrap(), + source_map, + ], )?; } } @@ -394,10 +409,15 @@ fn build_assets(config: &CrateConfig) -> Result<()> { "sass", vec![ path.to_str().unwrap(), - path.parent().unwrap().join(format!( - "{}.css", - path.file_stem().unwrap().to_str().unwrap() - )).to_str().unwrap(), + path.parent() + .unwrap() + .join(format!( + "{}.css", + path.file_stem().unwrap().to_str().unwrap() + )) + .to_str() + .unwrap(), + source_map, ], )?; } From 9ddaa773d9ffa8d6274a2731dfdac00223f6b74d Mon Sep 17 00:00:00 2001 From: YuKun Liu <41265098+mrxiaozhuox@users.noreply.github.com> Date: Tue, 10 May 2022 22:58:48 +0800 Subject: [PATCH 014/170] Remove `auto` option --- src/builder.rs | 111 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 73 insertions(+), 38 deletions(-) diff --git a/src/builder.rs b/src/builder.rs index 825a9eebf..75c83990d 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -362,48 +362,54 @@ fn build_assets(config: &CrateConfig) -> Result<()> { "--no-source-map" } } else { - "--no-source-map" + "--source-map" }; - if tab.contains_key("auto") && tab.get("auto").unwrap().as_bool().unwrap_or(false) { - // if the sass open auto, we need auto-check the assets dir. - let asset_dir = config.asset_dir.clone(); - if asset_dir.is_dir() { - for entry in walkdir::WalkDir::new(&asset_dir) - .into_iter() - .filter_map(|e| e.ok()) - { - let temp = entry.path(); - if temp.is_file() { - let suffix = temp.extension().unwrap().to_str().unwrap(); - if suffix == "scss" { - // if file suffix is `scss` we need transform it. - let out_file = - format!("{}.css", temp.file_stem().unwrap().to_str().unwrap()); - let target_path = config - .out_dir - .join(temp.strip_prefix(&asset_dir).unwrap().parent().unwrap()) - .join(out_file); - sass.call( - "sass", - vec![ - temp.to_str().unwrap(), - target_path.to_str().unwrap(), - source_map, - ], - )?; + if tab.contains_key("files") { + if tab.get("files").unwrap().is_str() { + let file = tab.get("files").unwrap().as_str().unwrap().trim(); + + if file == "*" { + // if the sass open auto, we need auto-check the assets dir. + let asset_dir = config.asset_dir.clone(); + if asset_dir.is_dir() { + for entry in walkdir::WalkDir::new(&asset_dir) + .into_iter() + .filter_map(|e| e.ok()) + { + let temp = entry.path(); + if temp.is_file() { + let suffix = temp.extension().unwrap().to_str().unwrap(); + if suffix == "scss" { + // if file suffix is `scss` we need transform it. + let out_file = format!( + "{}.css", + temp.file_stem().unwrap().to_str().unwrap() + ); + let target_path = config + .out_dir + .join( + temp.strip_prefix(&asset_dir) + .unwrap() + .parent() + .unwrap(), + ) + .join(out_file); + sass.call( + "sass", + vec![ + temp.to_str().unwrap(), + target_path.to_str().unwrap(), + source_map, + ], + )?; + } + } } } - } - } - } else if tab.contains_key("files") && tab.get("files").unwrap().is_array() { - // check files list. - let list = tab.get("files").unwrap().as_array().unwrap(); - for i in list { - if i.is_str() { - let path = i.as_str().unwrap(); - let path = PathBuf::from(path); - let path = config.asset_dir.join(path); + } else { + // just transform one file. + let path = config.asset_dir.join(file); if path.is_file() { sass.call( "sass", @@ -422,10 +428,39 @@ fn build_assets(config: &CrateConfig) -> Result<()> { )?; } } + } else if tab.get("files").unwrap().is_array() { + // check files list. + let list = tab.get("files").unwrap().as_array().unwrap(); + for i in list { + if i.is_str() { + let path = i.as_str().unwrap(); + let path = PathBuf::from(path); + let path = config.asset_dir.join(path); + if path.is_file() { + sass.call( + "sass", + vec![ + path.to_str().unwrap(), + path.parent() + .unwrap() + .join(format!( + "{}.css", + path.file_stem().unwrap().to_str().unwrap() + )) + .to_str() + .unwrap(), + source_map, + ], + )?; + } + } + } } } } } + // SASS END + Ok(()) } From ecb846dd24d34c0827bfa3503048bf97a8389fda Mon Sep 17 00:00:00 2001 From: YuKun Liu <41265098+mrxiaozhuox@users.noreply.github.com> Date: Tue, 10 May 2022 23:00:39 +0800 Subject: [PATCH 015/170] Rename `files` to `input` --- src/assets/dioxus.toml | 12 ++++++------ src/builder.rs | 10 +++++----- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/assets/dioxus.toml b/src/assets/dioxus.toml index b481193a8..a5e849bfb 100644 --- a/src/assets/dioxus.toml +++ b/src/assets/dioxus.toml @@ -48,13 +48,13 @@ binaryen = { wasm_opt = true } [application.tools.sass] # auto will check the assets dirs, and auto to transform all scss file to css file. -auto = true +input = "*" # or you can specify some scss file -> css file -files = [ - # some sass file path - # this file will translate to `/css/test.css` - "/css/test.scss" -] +# input = [ +# # some sass file path +# # this file will translate to `/css/test.css` +# "/css/test.scss" +# ] source_map = true \ No newline at end of file diff --git a/src/builder.rs b/src/builder.rs index 75c83990d..f9f0bd9bd 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -365,9 +365,9 @@ fn build_assets(config: &CrateConfig) -> Result<()> { "--source-map" }; - if tab.contains_key("files") { - if tab.get("files").unwrap().is_str() { - let file = tab.get("files").unwrap().as_str().unwrap().trim(); + if tab.contains_key("input") { + if tab.get("input").unwrap().is_str() { + let file = tab.get("input").unwrap().as_str().unwrap().trim(); if file == "*" { // if the sass open auto, we need auto-check the assets dir. @@ -428,9 +428,9 @@ fn build_assets(config: &CrateConfig) -> Result<()> { )?; } } - } else if tab.get("files").unwrap().is_array() { + } else if tab.get("input").unwrap().is_array() { // check files list. - let list = tab.get("files").unwrap().as_array().unwrap(); + let list = tab.get("input").unwrap().as_array().unwrap(); for i in list { if i.is_str() { let path = i.as_str().unwrap(); From bf49d526d773cc87449ac343659609c52890f0ac Mon Sep 17 00:00:00 2001 From: YuKun Liu <41265098+mrxiaozhuox@users.noreply.github.com> Date: Wed, 11 May 2022 00:27:37 +0800 Subject: [PATCH 016/170] Fixed some problem --- src/builder.rs | 13 ++++++++++++- src/tools.rs | 6 +++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/builder.rs b/src/builder.rs index f9f0bd9bd..77f0838f0 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -409,7 +409,13 @@ fn build_assets(config: &CrateConfig) -> Result<()> { } } else { // just transform one file. - let path = config.asset_dir.join(file); + let path = if &file[0..] == "/" { + &file[1..file.len() - 1] + } else { + file + }; + let path = PathBuf::from(path); + let path = config.asset_dir.join(path); if path.is_file() { sass.call( "sass", @@ -434,6 +440,11 @@ fn build_assets(config: &CrateConfig) -> Result<()> { for i in list { if i.is_str() { let path = i.as_str().unwrap(); + let path = if &path[0..] == "/" { + &path[1..path.len() - 1] + } else { + path + }; let path = PathBuf::from(path); let path = config.asset_dir.join(path); if path.is_file() { diff --git a/src/tools.rs b/src/tools.rs index ae4e58b79..2952a9614 100644 --- a/src/tools.rs +++ b/src/tools.rs @@ -207,7 +207,7 @@ impl Tool { } else { command.to_string() } - }, + } }; if !bin_path.join(&command_file).is_file() { @@ -232,7 +232,7 @@ fn extract_zip(file: &Path, target: &Path) -> anyhow::Result<()> { if !target.exists() { let _ = std::fs::create_dir_all(target)?; } - + for i in 0..zip.len() { let mut file = zip.by_index(i)?; if file.is_dir() { @@ -252,4 +252,4 @@ fn extract_zip(file: &Path, target: &Path) -> anyhow::Result<()> { } Ok(()) -} +} \ No newline at end of file From c6aa4e332df58c223416fafc62e729574ff8c564 Mon Sep 17 00:00:00 2001 From: YuKun Liu <41265098+mrxiaozhuox@users.noreply.github.com> Date: Wed, 11 May 2022 10:01:02 +0800 Subject: [PATCH 017/170] Ignore `scss` file in out_dir --- src/builder.rs | 38 +++++++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/src/builder.rs b/src/builder.rs index 77f0838f0..25d087191 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -31,7 +31,7 @@ pub fn build(config: &CrateConfig) -> Result<()> { } = config; // start to build the assets - build_assets(config)?; + let ignore_files = build_assets(config)?; let t_start = std::time::Instant::now(); @@ -158,6 +158,13 @@ pub fn build(config: &CrateConfig) -> Result<()> { log::warn!("Error copying dir: {}", _e); } } + for ignore in &ignore_files { + let ignore = ignore.strip_prefix(&config.asset_dir).unwrap(); + let ignore = config.out_dir.join(ignore); + if ignore.is_file() { + std::fs::remove_file(ignore)?; + } + } } } } @@ -345,7 +352,11 @@ pub fn gen_page(config: &DioxusConfig, serve: bool) -> String { // this function will build some assets file // like sass tool resources -fn build_assets(config: &CrateConfig) -> Result<()> { +// this function will return a array which file don't need copy to out_dir. +fn build_assets(config: &CrateConfig) -> Result> { + + let mut result = vec![]; + let dioxus_config = &config.dioxus_config; let dioxus_tools = dioxus_config.application.tools.clone().unwrap_or_default(); @@ -395,14 +406,17 @@ fn build_assets(config: &CrateConfig) -> Result<()> { .unwrap(), ) .join(out_file); - sass.call( + let res = sass.call( "sass", vec![ temp.to_str().unwrap(), target_path.to_str().unwrap(), source_map, ], - )?; + ); + if res.is_ok() { + result.push(temp.to_path_buf()); + } } } } @@ -417,7 +431,7 @@ fn build_assets(config: &CrateConfig) -> Result<()> { let path = PathBuf::from(path); let path = config.asset_dir.join(path); if path.is_file() { - sass.call( + let res = sass.call( "sass", vec![ path.to_str().unwrap(), @@ -431,7 +445,10 @@ fn build_assets(config: &CrateConfig) -> Result<()> { .unwrap(), source_map, ], - )?; + ); + if res.is_ok() { + result.push(path); + } } } } else if tab.get("input").unwrap().is_array() { @@ -448,7 +465,7 @@ fn build_assets(config: &CrateConfig) -> Result<()> { let path = PathBuf::from(path); let path = config.asset_dir.join(path); if path.is_file() { - sass.call( + let res = sass.call( "sass", vec![ path.to_str().unwrap(), @@ -462,7 +479,10 @@ fn build_assets(config: &CrateConfig) -> Result<()> { .unwrap(), source_map, ], - )?; + ); + if res.is_ok() { + result.push(path); + } } } } @@ -472,7 +492,7 @@ fn build_assets(config: &CrateConfig) -> Result<()> { } // SASS END - Ok(()) + Ok(result) } // use binary_install::{Cache, Download}; From dccd82091a0b499527cd435fccf1a088262235e1 Mon Sep 17 00:00:00 2001 From: YuKun Liu <41265098+mrxiaozhuox@users.noreply.github.com> Date: Wed, 11 May 2022 11:12:23 +0800 Subject: [PATCH 018/170] Fixed `input` option error --- src/builder.rs | 41 ++++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/src/builder.rs b/src/builder.rs index 25d087191..e1ed0a8f1 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -354,7 +354,6 @@ pub fn gen_page(config: &DioxusConfig, serve: bool) -> String { // like sass tool resources // this function will return a array which file don't need copy to out_dir. fn build_assets(config: &CrateConfig) -> Result> { - let mut result = vec![]; let dioxus_config = &config.dioxus_config; @@ -430,19 +429,23 @@ fn build_assets(config: &CrateConfig) -> Result> { }; let path = PathBuf::from(path); let path = config.asset_dir.join(path); + let out_file = + format!("{}.css", path.file_stem().unwrap().to_str().unwrap()); + let target_path = config + .out_dir + .join( + path.strip_prefix(&config.asset_dir) + .unwrap() + .parent() + .unwrap(), + ) + .join(out_file); if path.is_file() { let res = sass.call( "sass", vec![ path.to_str().unwrap(), - path.parent() - .unwrap() - .join(format!( - "{}.css", - path.file_stem().unwrap().to_str().unwrap() - )) - .to_str() - .unwrap(), + target_path.to_str().unwrap(), source_map, ], ); @@ -464,19 +467,23 @@ fn build_assets(config: &CrateConfig) -> Result> { }; let path = PathBuf::from(path); let path = config.asset_dir.join(path); + let out_file = + format!("{}.css", path.file_stem().unwrap().to_str().unwrap()); + let target_path = config + .out_dir + .join( + path.strip_prefix(&config.asset_dir) + .unwrap() + .parent() + .unwrap(), + ) + .join(out_file); if path.is_file() { let res = sass.call( "sass", vec![ path.to_str().unwrap(), - path.parent() - .unwrap() - .join(format!( - "{}.css", - path.file_stem().unwrap().to_str().unwrap() - )) - .to_str() - .unwrap(), + target_path.to_str().unwrap(), source_map, ], ); From 065da8db6589a1c745392b3973bae127ebecb183 Mon Sep 17 00:00:00 2001 From: YuKun Liu <41265098+mrxiaozhuox@users.noreply.github.com> Date: Wed, 11 May 2022 11:14:49 +0800 Subject: [PATCH 019/170] Add `sass` desktop build support --- src/builder.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/builder.rs b/src/builder.rs index e1ed0a8f1..ae6e83605 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -177,6 +177,8 @@ pub fn build(config: &CrateConfig) -> Result<()> { pub fn build_desktop(config: &CrateConfig, is_serve: bool) -> Result<()> { log::info!("🚅 Running build [Desktop] command..."); + let ignore_files = build_assets(config)?; + let mut cmd = Command::new("cargo"); cmd.current_dir(&config.crate_dir) .arg("build") @@ -261,6 +263,13 @@ pub fn build_desktop(config: &CrateConfig, is_serve: bool) -> Result<()> { log::warn!("Error copying dir: {}", e); } } + for ignore in &ignore_files { + let ignore = ignore.strip_prefix(&config.asset_dir).unwrap(); + let ignore = config.out_dir.join(ignore); + if ignore.is_file() { + std::fs::remove_file(ignore)?; + } + } } } } From 60bb0d9eb9f6a6e10267df85840914afa04d460b Mon Sep 17 00:00:00 2001 From: YuKun Liu <41265098+mrxiaozhuox@users.noreply.github.com> Date: Wed, 11 May 2022 11:15:33 +0800 Subject: [PATCH 020/170] Format code --- src/cli/tool/mod.rs | 2 +- src/tools.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cli/tool/mod.rs b/src/cli/tool/mod.rs index 45c866c40..fde94b29a 100644 --- a/src/cli/tool/mod.rs +++ b/src/cli/tool/mod.rs @@ -27,7 +27,7 @@ impl Tool { } } Tool::AppPath {} => { - if let Some(v) = tools::tools_path().to_str() { + if let Some(v) = tools::tools_path().to_str() { println!("{}", v); } else { log::error!("Tools path get failed."); diff --git a/src/tools.rs b/src/tools.rs index 2952a9614..2ab358d6b 100644 --- a/src/tools.rs +++ b/src/tools.rs @@ -252,4 +252,4 @@ fn extract_zip(file: &Path, target: &Path) -> anyhow::Result<()> { } Ok(()) -} \ No newline at end of file +} From cb650bad8a726c50eacdf8d29669532a5fb75c42 Mon Sep 17 00:00:00 2001 From: YuKun Liu <41265098+mrxiaozhuox@users.noreply.github.com> Date: Wed, 11 May 2022 11:47:49 +0800 Subject: [PATCH 021/170] Fixed some problem --- src/builder.rs | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/src/builder.rs b/src/builder.rs index ae6e83605..8f3823a65 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -431,24 +431,19 @@ fn build_assets(config: &CrateConfig) -> Result> { } } else { // just transform one file. - let path = if &file[0..] == "/" { - &file[1..file.len() - 1] + let relative_path = if &file[0..1] == "/" { + &file[1..file.len()] } else { file }; - let path = PathBuf::from(path); - let path = config.asset_dir.join(path); + let path = config.asset_dir.join(relative_path); let out_file = format!("{}.css", path.file_stem().unwrap().to_str().unwrap()); let target_path = config .out_dir - .join( - path.strip_prefix(&config.asset_dir) - .unwrap() - .parent() - .unwrap(), - ) + .join(PathBuf::from(relative_path).parent().unwrap()) .join(out_file); + println!("{:?} -- {:?}", target_path, path); if path.is_file() { let res = sass.call( "sass", @@ -460,6 +455,8 @@ fn build_assets(config: &CrateConfig) -> Result> { ); if res.is_ok() { result.push(path); + } else { + log::error!("{:?}", res); } } } @@ -469,23 +466,17 @@ fn build_assets(config: &CrateConfig) -> Result> { for i in list { if i.is_str() { let path = i.as_str().unwrap(); - let path = if &path[0..] == "/" { - &path[1..path.len() - 1] + let relative_path = if &path[0..1] == "/" { + &path[1..path.len()] } else { path }; - let path = PathBuf::from(path); - let path = config.asset_dir.join(path); + let path = config.asset_dir.join(relative_path); let out_file = format!("{}.css", path.file_stem().unwrap().to_str().unwrap()); let target_path = config .out_dir - .join( - path.strip_prefix(&config.asset_dir) - .unwrap() - .parent() - .unwrap(), - ) + .join(PathBuf::from(relative_path).parent().unwrap()) .join(out_file); if path.is_file() { let res = sass.call( From 7f829c4553eaf45eda2e9c7964ba28cac63723cb Mon Sep 17 00:00:00 2001 From: YuKun Liu <41265098+mrxiaozhuox@users.noreply.github.com> Date: Wed, 11 May 2022 11:50:01 +0800 Subject: [PATCH 022/170] Format code --- src/builder.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/builder.rs b/src/builder.rs index 8f3823a65..e0d3ac285 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -443,7 +443,6 @@ fn build_assets(config: &CrateConfig) -> Result> { .out_dir .join(PathBuf::from(relative_path).parent().unwrap()) .join(out_file); - println!("{:?} -- {:?}", target_path, path); if path.is_file() { let res = sass.call( "sass", From cc56dd19ddbdaf9578ee6f56df7a354bbd2d3bc6 Mon Sep 17 00:00:00 2001 From: YuKun Liu <41265098+mrxiaozhuox@users.noreply.github.com> Date: Thu, 12 May 2022 00:11:51 +0800 Subject: [PATCH 023/170] Add `sass` file extension --- src/builder.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/builder.rs b/src/builder.rs index e0d3ac285..cdb431933 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -399,8 +399,8 @@ fn build_assets(config: &CrateConfig) -> Result> { let temp = entry.path(); if temp.is_file() { let suffix = temp.extension().unwrap().to_str().unwrap(); - if suffix == "scss" { - // if file suffix is `scss` we need transform it. + if suffix == "scss" || suffix == "sass" { + // if file suffix is `scss` / `sass` we need transform it. let out_file = format!( "{}.css", temp.file_stem().unwrap().to_str().unwrap() From 87e6ed0a3d13dfb023c185a249ceee3a7a22d9e8 Mon Sep 17 00:00:00 2001 From: YuKun Liu <41265098+mrxiaozhuox@users.noreply.github.com> Date: Thu, 12 May 2022 22:49:27 +0800 Subject: [PATCH 024/170] Fixed builder problem --- src/builder.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/builder.rs b/src/builder.rs index cdb431933..4f6824780 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -398,7 +398,9 @@ fn build_assets(config: &CrateConfig) -> Result> { { let temp = entry.path(); if temp.is_file() { - let suffix = temp.extension().unwrap().to_str().unwrap(); + let suffix = temp.extension(); + if suffix.is_none() { continue; } + let suffix = suffix.unwrap().to_str().unwrap(); if suffix == "scss" || suffix == "sass" { // if file suffix is `scss` / `sass` we need transform it. let out_file = format!( From 51639af48230bb8a4bb7b50105c1bcd270ac0774 Mon Sep 17 00:00:00 2001 From: YuKun Liu <41265098+mrxiaozhuox@users.noreply.github.com> Date: Mon, 6 Jun 2022 00:16:15 +0800 Subject: [PATCH 025/170] feat: add `profile` flag --- src/builder.rs | 5 +++++ src/cli/build/mod.rs | 4 ++++ src/cli/cfg.rs | 8 ++++++++ src/cli/serve/mod.rs | 4 ++++ src/config.rs | 9 +++++++++ 5 files changed, 30 insertions(+) diff --git a/src/builder.rs b/src/builder.rs index 4f6824780..31bb96f46 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -49,6 +49,11 @@ pub fn build(config: &CrateConfig) -> Result<()> { cmd.arg("--release"); } + if config.custom_profile.is_some() { + let custom_profile = config.custom_profile.as_ref().unwrap(); + cmd.arg(format!("--profile {}", custom_profile)); + } + match executable { ExecutableType::Binary(name) => cmd.arg("--bin").arg(name), ExecutableType::Lib(name) => cmd.arg("--lib").arg(name), diff --git a/src/cli/build/mod.rs b/src/cli/build/mod.rs index 4c043091f..7f8c7b420 100644 --- a/src/cli/build/mod.rs +++ b/src/cli/build/mod.rs @@ -19,6 +19,10 @@ impl Build { crate_config.as_example(self.build.example.unwrap()); } + if self.build.profile.is_some() { + crate_config.set_profile(self.build.profile.unwrap()); + } + let platform = self.build.platform.unwrap_or_else(|| { crate_config .dioxus_config diff --git a/src/cli/cfg.rs b/src/cli/cfg.rs index f5ee45b87..11a1603c7 100644 --- a/src/cli/cfg.rs +++ b/src/cli/cfg.rs @@ -16,6 +16,10 @@ pub struct ConfigOptsBuild { #[clap(long)] pub example: Option, + /// Build with custom profile + #[clap(long)] + pub profile: Option, + /// Build platform: support Web & Desktop [default: "default_platform"] #[clap(long)] pub platform: Option, @@ -36,6 +40,10 @@ pub struct ConfigOptsServe { #[serde(default)] pub release: bool, + /// Build with custom profile + #[clap(long)] + pub profile: Option, + /// Build platform: support Web & Desktop [default: "default_platform"] #[clap(long)] pub platform: Option, diff --git a/src/cli/serve/mod.rs b/src/cli/serve/mod.rs index 85bd92c74..1b79284b7 100644 --- a/src/cli/serve/mod.rs +++ b/src/cli/serve/mod.rs @@ -24,6 +24,10 @@ impl Serve { crate_config.as_example(self.serve.example.unwrap()); } + if self.serve.profile.is_some() { + crate_config.set_profile(self.serve.profile.unwrap()); + } + let platform = self.serve.platform.unwrap_or_else(|| { crate_config .dioxus_config diff --git a/src/config.rs b/src/config.rs index 783c72ccd..9679fadaa 100644 --- a/src/config.rs +++ b/src/config.rs @@ -114,6 +114,7 @@ pub struct CrateConfig { pub executable: ExecutableType, pub dioxus_config: DioxusConfig, pub release: bool, + pub custom_profile: Option, } #[derive(Debug, Clone)] @@ -163,6 +164,8 @@ impl CrateConfig { let release = false; + let custom_profile = None; + Ok(Self { out_dir, crate_dir, @@ -173,6 +176,7 @@ impl CrateConfig { executable, release, dioxus_config, + custom_profile, }) } @@ -186,6 +190,11 @@ impl CrateConfig { self } + pub fn set_profile(&mut self, profile: String) -> &mut Self { + self.custom_profile = Some(profile); + self + } + // pub fn with_build_options(&mut self, options: &BuildOptions) { // if let Some(name) = &options.example { // self.as_example(name.clone()); From 6aa609144d4b8dde995749ad2de4aaa8d69f16f4 Mon Sep 17 00:00:00 2001 From: YuKun Liu <41265098+mrxiaozhuox@users.noreply.github.com> Date: Mon, 6 Jun 2022 08:46:16 +0800 Subject: [PATCH 026/170] feat: add `profile` flag --- src/builder.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/builder.rs b/src/builder.rs index 31bb96f46..57738b1bc 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -51,7 +51,8 @@ pub fn build(config: &CrateConfig) -> Result<()> { if config.custom_profile.is_some() { let custom_profile = config.custom_profile.as_ref().unwrap(); - cmd.arg(format!("--profile {}", custom_profile)); + cmd.arg("--profile"); + cmd.arg(custom_profile); } match executable { @@ -194,6 +195,12 @@ pub fn build_desktop(config: &CrateConfig, is_serve: bool) -> Result<()> { cmd.arg("--release"); } + if config.custom_profile.is_some() { + let custom_profile = config.custom_profile.as_ref().unwrap(); + cmd.arg("--profile"); + cmd.arg(custom_profile); + } + match &config.executable { crate::ExecutableType::Binary(name) => cmd.arg("--bin").arg(name), crate::ExecutableType::Lib(name) => cmd.arg("--lib").arg(name), From d20e7ab50815014e67871ec2227413a085762690 Mon Sep 17 00:00:00 2001 From: YuKun Liu <41265098+mrxiaozhuox@users.noreply.github.com> Date: Mon, 6 Jun 2022 18:18:22 +0800 Subject: [PATCH 027/170] feat: add `features` flag --- src/builder.rs | 12 ++++++++++++ src/cli/cfg.rs | 8 ++++++++ src/config.rs | 9 ++++++++- 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/builder.rs b/src/builder.rs index 57738b1bc..46d4c15f5 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -55,6 +55,12 @@ pub fn build(config: &CrateConfig) -> Result<()> { cmd.arg(custom_profile); } + if config.features.is_some() { + let features_str = config.features.as_ref().unwrap().join(" "); + cmd.arg("--features"); + cmd.arg(features_str); + } + match executable { ExecutableType::Binary(name) => cmd.arg("--bin").arg(name), ExecutableType::Lib(name) => cmd.arg("--lib").arg(name), @@ -201,6 +207,12 @@ pub fn build_desktop(config: &CrateConfig, is_serve: bool) -> Result<()> { cmd.arg(custom_profile); } + if config.features.is_some() { + let features_str = config.features.as_ref().unwrap().join(" "); + cmd.arg("--features"); + cmd.arg(features_str); + } + match &config.executable { crate::ExecutableType::Binary(name) => cmd.arg("--bin").arg(name), crate::ExecutableType::Lib(name) => cmd.arg("--lib").arg(name), diff --git a/src/cli/cfg.rs b/src/cli/cfg.rs index 11a1603c7..b8305e3a8 100644 --- a/src/cli/cfg.rs +++ b/src/cli/cfg.rs @@ -23,6 +23,10 @@ pub struct ConfigOptsBuild { /// Build platform: support Web & Desktop [default: "default_platform"] #[clap(long)] pub platform: Option, + + /// Space separated list of features to activate + #[clap(long)] + pub features: Option>, } #[derive(Clone, Debug, Default, Deserialize, Parser)] @@ -47,6 +51,10 @@ pub struct ConfigOptsServe { /// Build platform: support Web & Desktop [default: "default_platform"] #[clap(long)] pub platform: Option, + + /// Space separated list of features to activate + #[clap(long)] + pub features: Option>, } /// Ensure the given value for `--public-url` is formatted correctly. diff --git a/src/config.rs b/src/config.rs index 9679fadaa..6804ae6cd 100644 --- a/src/config.rs +++ b/src/config.rs @@ -115,6 +115,7 @@ pub struct CrateConfig { pub dioxus_config: DioxusConfig, pub release: bool, pub custom_profile: Option, + pub features: Option>, } #[derive(Debug, Clone)] @@ -163,8 +164,8 @@ impl CrateConfig { let executable = ExecutableType::Binary(output_filename); let release = false; - let custom_profile = None; + let features = None; Ok(Self { out_dir, @@ -177,6 +178,7 @@ impl CrateConfig { release, dioxus_config, custom_profile, + features }) } @@ -195,6 +197,11 @@ impl CrateConfig { self } + pub fn set_features(&mut self, features: Vec) -> &mut Self { + self.features = Some(features); + self + } + // pub fn with_build_options(&mut self, options: &BuildOptions) { // if let Some(name) = &options.example { // self.as_example(name.clone()); From 421d2ed2980d4e4d542f1b7b28c31e9ca279a563 Mon Sep 17 00:00:00 2001 From: YuKun Liu <41265098+mrxiaozhuox@users.noreply.github.com> Date: Mon, 6 Jun 2022 21:48:14 +0800 Subject: [PATCH 028/170] feat: add `verbose` flag --- src/builder.rs | 6 ++++++ src/cli/build/mod.rs | 1 + src/cli/cfg.rs | 10 ++++++++++ src/cli/serve/mod.rs | 1 + src/config.rs | 10 +++++++++- 5 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/builder.rs b/src/builder.rs index 46d4c15f5..02add84ad 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -48,6 +48,9 @@ pub fn build(config: &CrateConfig) -> Result<()> { if config.release { cmd.arg("--release"); } + if config.verbose { + cmd.arg("--verbose"); + } if config.custom_profile.is_some() { let custom_profile = config.custom_profile.as_ref().unwrap(); @@ -200,6 +203,9 @@ pub fn build_desktop(config: &CrateConfig, is_serve: bool) -> Result<()> { if config.release { cmd.arg("--release"); } + if config.verbose { + cmd.arg("--verbose"); + } if config.custom_profile.is_some() { let custom_profile = config.custom_profile.as_ref().unwrap(); diff --git a/src/cli/build/mod.rs b/src/cli/build/mod.rs index 7f8c7b420..661f17a5a 100644 --- a/src/cli/build/mod.rs +++ b/src/cli/build/mod.rs @@ -14,6 +14,7 @@ impl Build { // change the release state. crate_config.with_release(self.build.release); + crate_config.with_verbose(self.build.verbose); if self.build.example.is_some() { crate_config.as_example(self.build.example.unwrap()); diff --git a/src/cli/cfg.rs b/src/cli/cfg.rs index b8305e3a8..26409c370 100644 --- a/src/cli/cfg.rs +++ b/src/cli/cfg.rs @@ -12,6 +12,11 @@ pub struct ConfigOptsBuild { #[serde(default)] pub release: bool, + // Use verbose output [default: false] + #[clap(long)] + #[serde(default)] + pub verbose: bool, + /// Build a example [default: ""] #[clap(long)] pub example: Option, @@ -44,6 +49,11 @@ pub struct ConfigOptsServe { #[serde(default)] pub release: bool, + // Use verbose output [default: false] + #[clap(long)] + #[serde(default)] + pub verbose: bool, + /// Build with custom profile #[clap(long)] pub profile: Option, diff --git a/src/cli/serve/mod.rs b/src/cli/serve/mod.rs index 1b79284b7..d25aa5bad 100644 --- a/src/cli/serve/mod.rs +++ b/src/cli/serve/mod.rs @@ -19,6 +19,7 @@ impl Serve { // change the relase state. crate_config.with_release(self.serve.release); + crate_config.with_verbose(self.serve.verbose); if self.serve.example.is_some() { crate_config.as_example(self.serve.example.unwrap()); diff --git a/src/config.rs b/src/config.rs index 6804ae6cd..6e855002b 100644 --- a/src/config.rs +++ b/src/config.rs @@ -114,6 +114,7 @@ pub struct CrateConfig { pub executable: ExecutableType, pub dioxus_config: DioxusConfig, pub release: bool, + pub verbose: bool, pub custom_profile: Option, pub features: Option>, } @@ -164,6 +165,7 @@ impl CrateConfig { let executable = ExecutableType::Binary(output_filename); let release = false; + let verbose = false; let custom_profile = None; let features = None; @@ -178,7 +180,8 @@ impl CrateConfig { release, dioxus_config, custom_profile, - features + features, + verbose, }) } @@ -192,6 +195,11 @@ impl CrateConfig { self } + pub fn with_verbose(&mut self, verbose: bool) -> &mut Self { + self.verbose = verbose; + self + } + pub fn set_profile(&mut self, profile: String) -> &mut Self { self.custom_profile = Some(profile); self From 49b3ef83d33932bb8ee0e15f128f737994ef902a Mon Sep 17 00:00:00 2001 From: Evan Almloff Date: Thu, 9 Jun 2022 09:37:26 -0500 Subject: [PATCH 029/170] create websocket to update rsx and report errors back --- Cargo.toml | 5 + src/hot_reload/mod.rs | 614 ++++++++++++++++++++++++++++++++++++++++++ src/lib.rs | 3 + src/server/mod.rs | 174 ++++++++++-- 4 files changed, 770 insertions(+), 26 deletions(-) create mode 100644 src/hot_reload/mod.rs diff --git a/Cargo.toml b/Cargo.toml index 21e2dad7e..4acd41463 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,6 +46,11 @@ flate2 = "1.0.22" tar = "0.4.38" tower = "0.4.12" +# hot reload +syn = "1.0" +dioxus-rsx-interpreter = { path = "../dioxus/packages/rsx_interpreter" } +proc-macro2 = { version = "1.0", features = ["span-locations"] } + [[bin]] path = "src/main.rs" name = "dioxus" diff --git a/src/hot_reload/mod.rs b/src/hot_reload/mod.rs new file mode 100644 index 000000000..d70cda29e --- /dev/null +++ b/src/hot_reload/mod.rs @@ -0,0 +1,614 @@ +use dioxus_rsx::{BodyNode, CallBody}; +use proc_macro2::TokenStream; +use syn::{File, Macro}; + +pub enum DiffResult { + CodeChanged, + RsxChanged(Vec<(Macro, TokenStream)>), +} + +pub fn find_rsx(new: &File, old: &File) -> DiffResult { + let mut rsx_calls = Vec::new(); + if new.items.len() != old.items.len() { + return DiffResult::CodeChanged; + } + for (new, old) in new.items.iter().zip(old.items.iter()) { + if find_rsx_item(new, old, &mut rsx_calls) { + return DiffResult::CodeChanged; + } + } + DiffResult::RsxChanged(rsx_calls) +} + +fn find_rsx_item( + new: &syn::Item, + old: &syn::Item, + rsx_calls: &mut Vec<(Macro, TokenStream)>, +) -> bool { + match (new, old) { + (syn::Item::Const(new_item), syn::Item::Const(old_item)) => { + find_rsx_expr(&new_item.expr, &old_item.expr, rsx_calls) + || new_item.attrs != old_item.attrs + || new_item.vis != old_item.vis + || new_item.const_token != old_item.const_token + || new_item.ident != old_item.ident + || new_item.colon_token != old_item.colon_token + || new_item.ty != old_item.ty + || new_item.eq_token != old_item.eq_token + || new_item.semi_token != old_item.semi_token + } + (syn::Item::Enum(new_item), syn::Item::Enum(old_item)) => { + if new_item.variants.len() != old_item.variants.len() { + return true; + } + for (new_varient, old_varient) in new_item.variants.iter().zip(old_item.variants.iter()) + { + match (&new_varient.discriminant, &old_varient.discriminant) { + (Some((new_eq, new_expr)), Some((old_eq, old_expr))) => { + if find_rsx_expr(new_expr, old_expr, rsx_calls) || new_eq != old_eq { + return true; + } + } + (None, None) => (), + _ => return true, + } + if new_varient.attrs != old_varient.attrs + || new_varient.ident != old_varient.ident + || new_varient.fields != old_varient.fields + { + return true; + } + } + new_item.attrs != old_item.attrs + || new_item.vis != old_item.vis + || new_item.enum_token != old_item.enum_token + || new_item.ident != old_item.ident + || new_item.generics != old_item.generics + || new_item.brace_token != old_item.brace_token + } + (syn::Item::ExternCrate(new_item), syn::Item::ExternCrate(old_item)) => { + old_item != new_item + } + (syn::Item::Fn(new_item), syn::Item::Fn(old_item)) => { + find_rsx_block(&new_item.block, &old_item.block, rsx_calls) + || new_item.attrs != old_item.attrs + || new_item.vis != old_item.vis + || new_item.sig != old_item.sig + } + (syn::Item::ForeignMod(new_item), syn::Item::ForeignMod(old_item)) => old_item != new_item, + (syn::Item::Impl(new_item), syn::Item::Impl(old_item)) => { + if new_item.items.len() != old_item.items.len() { + return true; + } + for (new_item, old_item) in new_item.items.iter().zip(old_item.items.iter()) { + if match (new_item, old_item) { + (syn::ImplItem::Const(new_item), syn::ImplItem::Const(old_item)) => { + find_rsx_expr(&new_item.expr, &old_item.expr, rsx_calls) + } + (syn::ImplItem::Method(new_item), syn::ImplItem::Method(old_item)) => { + find_rsx_block(&new_item.block, &old_item.block, rsx_calls) + } + (syn::ImplItem::Type(new_item), syn::ImplItem::Type(old_item)) => { + old_item != new_item + } + (syn::ImplItem::Macro(new_item), syn::ImplItem::Macro(old_item)) => { + old_item != new_item + } + _ => true, + } { + return true; + } + } + new_item.attrs != old_item.attrs + || new_item.defaultness != old_item.defaultness + || new_item.unsafety != old_item.unsafety + || new_item.impl_token != old_item.impl_token + || new_item.generics != old_item.generics + || new_item.trait_ != old_item.trait_ + || new_item.self_ty != old_item.self_ty + || new_item.brace_token != old_item.brace_token + } + (syn::Item::Macro(new_item), syn::Item::Macro(old_item)) => old_item != new_item, + (syn::Item::Macro2(new_item), syn::Item::Macro2(old_item)) => old_item != new_item, + (syn::Item::Mod(new_item), syn::Item::Mod(old_item)) => { + match (&new_item.content, &old_item.content) { + (Some((_, new_items)), Some((_, old_items))) => { + if new_items.len() != old_items.len() { + return true; + } + for (new_item, old_item) in new_items.iter().zip(old_items.iter()) { + if find_rsx_item(new_item, old_item, rsx_calls) { + return true; + } + } + new_item.attrs != old_item.attrs + || new_item.vis != old_item.vis + || new_item.mod_token != old_item.mod_token + || new_item.ident != old_item.ident + || new_item.semi != old_item.semi + } + (None, None) => { + new_item.attrs != old_item.attrs + || new_item.vis != old_item.vis + || new_item.mod_token != old_item.mod_token + || new_item.ident != old_item.ident + || new_item.semi != old_item.semi + } + _ => true, + } + } + (syn::Item::Static(new_item), syn::Item::Static(old_item)) => { + find_rsx_expr(&new_item.expr, &old_item.expr, rsx_calls) + || new_item.attrs != old_item.attrs + || new_item.vis != old_item.vis + || new_item.static_token != old_item.static_token + || new_item.mutability != old_item.mutability + || new_item.ident != old_item.ident + || new_item.colon_token != old_item.colon_token + || new_item.ty != old_item.ty + || new_item.eq_token != old_item.eq_token + || new_item.semi_token != old_item.semi_token + } + (syn::Item::Struct(new_item), syn::Item::Struct(old_item)) => old_item != new_item, + (syn::Item::Trait(new_item), syn::Item::Trait(old_item)) => { + find_rsx_trait(new_item, old_item, rsx_calls) + } + (syn::Item::TraitAlias(new_item), syn::Item::TraitAlias(old_item)) => old_item != new_item, + (syn::Item::Type(new_item), syn::Item::Type(old_item)) => old_item != new_item, + (syn::Item::Union(new_item), syn::Item::Union(old_item)) => old_item != new_item, + (syn::Item::Use(new_item), syn::Item::Use(old_item)) => old_item != new_item, + (syn::Item::Verbatim(_), syn::Item::Verbatim(_)) => false, + _ => return true, + } +} + +fn find_rsx_trait( + new_item: &syn::ItemTrait, + old_item: &syn::ItemTrait, + rsx_calls: &mut Vec<(Macro, TokenStream)>, +) -> bool { + if new_item.items.len() != old_item.items.len() { + return true; + } + for (new_item, old_item) in new_item.items.iter().zip(old_item.items.iter()) { + if match (new_item, old_item) { + (syn::TraitItem::Const(new_item), syn::TraitItem::Const(old_item)) => { + if let (Some((_, new_expr)), Some((_, old_expr))) = + (&new_item.default, &old_item.default) + { + find_rsx_expr(new_expr, old_expr, rsx_calls) + } else { + true + } + } + (syn::TraitItem::Method(new_item), syn::TraitItem::Method(old_item)) => { + if let (Some(new_block), Some(old_block)) = (&new_item.default, &old_item.default) { + find_rsx_block(new_block, old_block, rsx_calls) + } else { + true + } + } + (syn::TraitItem::Type(new_item), syn::TraitItem::Type(old_item)) => { + old_item != new_item + } + (syn::TraitItem::Macro(new_item), syn::TraitItem::Macro(old_item)) => { + old_item != new_item + } + _ => true, + } { + return true; + } + } + new_item.attrs != old_item.attrs + || new_item.vis != old_item.vis + || new_item.unsafety != old_item.unsafety + || new_item.auto_token != old_item.auto_token + || new_item.ident != old_item.ident + || new_item.generics != old_item.generics + || new_item.colon_token != old_item.colon_token + || new_item.supertraits != old_item.supertraits + || new_item.brace_token != old_item.brace_token +} + +fn find_rsx_block( + new_block: &syn::Block, + old_block: &syn::Block, + rsx_calls: &mut Vec<(Macro, TokenStream)>, +) -> bool { + if new_block.stmts.len() != old_block.stmts.len() { + return true; + } + for (new_stmt, old_stmt) in new_block.stmts.iter().zip(old_block.stmts.iter()) { + if find_rsx_stmt(new_stmt, old_stmt, rsx_calls) { + return true; + } + } + new_block.brace_token != old_block.brace_token +} + +fn find_rsx_stmt( + new_stmt: &syn::Stmt, + old_stmt: &syn::Stmt, + rsx_calls: &mut Vec<(Macro, TokenStream)>, +) -> bool { + match (new_stmt, old_stmt) { + (syn::Stmt::Local(new_local), syn::Stmt::Local(old_local)) => { + (match (&new_local.init, &old_local.init) { + (Some((new_eq, new_expr)), Some((old_eq, old_expr))) => { + find_rsx_expr(new_expr, old_expr, rsx_calls) || new_eq != old_eq + } + (None, None) => false, + _ => true, + } || new_local.attrs != old_local.attrs + || new_local.let_token != old_local.let_token + || new_local.pat != old_local.pat + || new_local.semi_token != old_local.semi_token) + } + (syn::Stmt::Item(new_item), syn::Stmt::Item(old_item)) => { + find_rsx_item(new_item, old_item, rsx_calls) + } + (syn::Stmt::Expr(new_expr), syn::Stmt::Expr(old_expr)) => { + find_rsx_expr(new_expr, old_expr, rsx_calls) + } + (syn::Stmt::Semi(new_expr, new_semi), syn::Stmt::Semi(old_expr, old_semi)) => { + find_rsx_expr(new_expr, old_expr, rsx_calls) || new_semi != old_semi + } + _ => true, + } +} + +fn find_rsx_expr( + new_expr: &syn::Expr, + old_expr: &syn::Expr, + rsx_calls: &mut Vec<(Macro, TokenStream)>, +) -> bool { + match (new_expr, old_expr) { + (syn::Expr::Array(new_expr), syn::Expr::Array(old_expr)) => { + if new_expr.elems.len() != old_expr.elems.len() { + return true; + } + for (new_el, old_el) in new_expr.elems.iter().zip(old_expr.elems.iter()) { + if find_rsx_expr(new_el, old_el, rsx_calls) { + return true; + } + } + new_expr.attrs != old_expr.attrs || new_expr.bracket_token != old_expr.bracket_token + } + (syn::Expr::Assign(new_expr), syn::Expr::Assign(old_expr)) => { + find_rsx_expr(&new_expr.left, &old_expr.left, rsx_calls) + || find_rsx_expr(&new_expr.right, &old_expr.right, rsx_calls) + || new_expr.attrs != old_expr.attrs + || new_expr.eq_token != old_expr.eq_token + } + (syn::Expr::AssignOp(new_expr), syn::Expr::AssignOp(old_expr)) => { + find_rsx_expr(&new_expr.left, &old_expr.left, rsx_calls) + || find_rsx_expr(&new_expr.right, &old_expr.right, rsx_calls) + || new_expr.attrs != old_expr.attrs + || new_expr.op != old_expr.op + } + (syn::Expr::Async(new_expr), syn::Expr::Async(old_expr)) => { + find_rsx_block(&new_expr.block, &old_expr.block, rsx_calls) + || new_expr.attrs != old_expr.attrs + || new_expr.async_token != old_expr.async_token + || new_expr.capture != old_expr.capture + } + (syn::Expr::Await(new_expr), syn::Expr::Await(old_expr)) => { + find_rsx_expr(&new_expr.base, &old_expr.base, rsx_calls) + || new_expr.attrs != old_expr.attrs + || new_expr.dot_token != old_expr.dot_token + || new_expr.await_token != old_expr.await_token + } + (syn::Expr::Binary(new_expr), syn::Expr::Binary(old_expr)) => { + find_rsx_expr(&new_expr.left, &old_expr.left, rsx_calls) + || find_rsx_expr(&new_expr.right, &old_expr.right, rsx_calls) + || new_expr.attrs != old_expr.attrs + || new_expr.op != old_expr.op + } + (syn::Expr::Block(new_expr), syn::Expr::Block(old_expr)) => { + find_rsx_block(&new_expr.block, &old_expr.block, rsx_calls) + || new_expr.attrs != old_expr.attrs + || new_expr.label != old_expr.label + } + (syn::Expr::Box(new_expr), syn::Expr::Box(old_expr)) => { + find_rsx_expr(&new_expr.expr, &old_expr.expr, rsx_calls) + || new_expr.attrs != old_expr.attrs + || new_expr.box_token != old_expr.box_token + } + (syn::Expr::Break(new_expr), syn::Expr::Break(old_expr)) => { + match (&new_expr.expr, &old_expr.expr) { + (Some(new_inner), Some(old_inner)) => { + find_rsx_expr(new_inner, old_inner, rsx_calls) + || new_expr.attrs != old_expr.attrs + || new_expr.break_token != old_expr.break_token + || new_expr.label != old_expr.label + } + (None, None) => { + new_expr.attrs != old_expr.attrs + || new_expr.break_token != old_expr.break_token + || new_expr.label != old_expr.label + } + _ => true, + } + } + (syn::Expr::Call(new_expr), syn::Expr::Call(old_expr)) => { + find_rsx_expr(&new_expr.func, &old_expr.func, rsx_calls); + if new_expr.args.len() != old_expr.args.len() { + return true; + } + for (new_arg, old_arg) in new_expr.args.iter().zip(old_expr.args.iter()) { + if find_rsx_expr(new_arg, old_arg, rsx_calls) { + return true; + } + } + new_expr.attrs != old_expr.attrs || new_expr.paren_token != old_expr.paren_token + } + (syn::Expr::Cast(new_expr), syn::Expr::Cast(old_expr)) => { + find_rsx_expr(&new_expr.expr, &old_expr.expr, rsx_calls) + || new_expr.attrs != old_expr.attrs + || new_expr.as_token != old_expr.as_token + || new_expr.ty != old_expr.ty + } + (syn::Expr::Closure(new_expr), syn::Expr::Closure(old_expr)) => { + find_rsx_expr(&new_expr.body, &old_expr.body, rsx_calls) + || new_expr.attrs != old_expr.attrs + || new_expr.movability != old_expr.movability + || new_expr.asyncness != old_expr.asyncness + || new_expr.capture != old_expr.capture + || new_expr.or1_token != old_expr.or1_token + || new_expr.inputs != old_expr.inputs + || new_expr.or2_token != old_expr.or2_token + || new_expr.output != old_expr.output + } + (syn::Expr::Continue(new_expr), syn::Expr::Continue(old_expr)) => old_expr != new_expr, + (syn::Expr::Field(new_expr), syn::Expr::Field(old_expr)) => { + find_rsx_expr(&new_expr.base, &old_expr.base, rsx_calls) + || new_expr.attrs != old_expr.attrs + || new_expr.dot_token != old_expr.dot_token + || new_expr.member != old_expr.member + } + (syn::Expr::ForLoop(new_expr), syn::Expr::ForLoop(old_expr)) => { + find_rsx_block(&new_expr.body, &old_expr.body, rsx_calls) + || find_rsx_expr(&new_expr.expr, &old_expr.expr, rsx_calls) + || new_expr.attrs != old_expr.attrs + || new_expr.label != old_expr.label + || new_expr.for_token != old_expr.for_token + || new_expr.pat != old_expr.pat + || new_expr.in_token != old_expr.in_token + } + (syn::Expr::Group(new_expr), syn::Expr::Group(old_expr)) => { + find_rsx_expr(&new_expr.expr, &old_expr.expr, rsx_calls) + } + (syn::Expr::If(new_expr), syn::Expr::If(old_expr)) => { + if find_rsx_expr(&new_expr.cond, &old_expr.cond, rsx_calls) + || find_rsx_block(&new_expr.then_branch, &old_expr.then_branch, rsx_calls) + { + return true; + } + match (&new_expr.else_branch, &old_expr.else_branch) { + (Some((new_tok, new_else)), Some((old_tok, old_else))) => { + find_rsx_expr(new_else, old_else, rsx_calls) + || new_expr.attrs != old_expr.attrs + || new_expr.if_token != old_expr.if_token + || new_expr.cond != old_expr.cond + || new_tok != old_tok + } + (None, None) => { + new_expr.attrs != old_expr.attrs + || new_expr.if_token != old_expr.if_token + || new_expr.cond != old_expr.cond + } + _ => true, + } + } + (syn::Expr::Index(new_expr), syn::Expr::Index(old_expr)) => { + find_rsx_expr(&new_expr.expr, &old_expr.expr, rsx_calls) + || find_rsx_expr(&new_expr.index, &old_expr.index, rsx_calls) + || new_expr.attrs != old_expr.attrs + || new_expr.bracket_token != old_expr.bracket_token + } + (syn::Expr::Let(new_expr), syn::Expr::Let(old_expr)) => { + find_rsx_expr(&new_expr.expr, &old_expr.expr, rsx_calls) + || new_expr.attrs != old_expr.attrs + || new_expr.let_token != old_expr.let_token + || new_expr.pat != old_expr.pat + || new_expr.eq_token != old_expr.eq_token + } + (syn::Expr::Lit(new_expr), syn::Expr::Lit(old_expr)) => old_expr != new_expr, + (syn::Expr::Loop(new_expr), syn::Expr::Loop(old_expr)) => { + find_rsx_block(&new_expr.body, &old_expr.body, rsx_calls) + || new_expr.attrs != old_expr.attrs + || new_expr.label != old_expr.label + || new_expr.loop_token != old_expr.loop_token + } + (syn::Expr::Macro(new_expr), syn::Expr::Macro(old_expr)) => { + let new_mac = &new_expr.mac; + let old_mac = &old_expr.mac; + if new_mac.path.get_ident().map(|ident| ident.to_string()) == Some("rsx".to_string()) + && old_mac.path.get_ident().map(|ident| ident.to_string()) + == Some("rsx".to_string()) + { + rsx_calls.push((old_mac.clone(), new_mac.tokens.clone())); + false + } else { + new_expr != old_expr + } + } + (syn::Expr::Match(new_expr), syn::Expr::Match(old_expr)) => { + if find_rsx_expr(&new_expr.expr, &old_expr.expr, rsx_calls) { + return true; + } + for (new_arm, old_arm) in new_expr.arms.iter().zip(old_expr.arms.iter()) { + match (&new_arm.guard, &old_arm.guard) { + (Some((new_tok, new_expr)), Some((old_tok, old_expr))) => { + if find_rsx_expr(new_expr, old_expr, rsx_calls) || new_tok != old_tok { + return true; + } + } + (None, None) => (), + _ => return true, + } + if find_rsx_expr(&new_arm.body, &old_arm.body, rsx_calls) + || new_arm.attrs != old_arm.attrs + || new_arm.pat != old_arm.pat + || new_arm.fat_arrow_token != old_arm.fat_arrow_token + || new_arm.comma != old_arm.comma + { + return true; + } + } + new_expr.attrs != old_expr.attrs + || new_expr.match_token != old_expr.match_token + || new_expr.brace_token != old_expr.brace_token + } + (syn::Expr::MethodCall(new_expr), syn::Expr::MethodCall(old_expr)) => { + if find_rsx_expr(&new_expr.receiver, &old_expr.receiver, rsx_calls) { + return true; + } + for (new_arg, old_arg) in new_expr.args.iter().zip(old_expr.args.iter()) { + if find_rsx_expr(new_arg, old_arg, rsx_calls) { + return true; + } + } + new_expr.attrs != old_expr.attrs + || new_expr.dot_token != old_expr.dot_token + || new_expr.method != old_expr.method + || new_expr.turbofish != old_expr.turbofish + || new_expr.paren_token != old_expr.paren_token + } + (syn::Expr::Paren(new_expr), syn::Expr::Paren(old_expr)) => { + find_rsx_expr(&new_expr.expr, &old_expr.expr, rsx_calls) + || new_expr.attrs != old_expr.attrs + || new_expr.paren_token != old_expr.paren_token + } + (syn::Expr::Path(new_expr), syn::Expr::Path(old_expr)) => old_expr != new_expr, + (syn::Expr::Range(new_expr), syn::Expr::Range(old_expr)) => { + match (&new_expr.from, &old_expr.from) { + (Some(new_expr), Some(old_expr)) => { + if find_rsx_expr(new_expr, old_expr, rsx_calls) { + return true; + } + } + (None, None) => (), + _ => return true, + } + match (&new_expr.to, &old_expr.to) { + (Some(new_inner), Some(old_inner)) => { + find_rsx_expr(new_inner, old_inner, rsx_calls) + || new_expr.attrs != old_expr.attrs + || new_expr.limits != old_expr.limits + } + (None, None) => { + new_expr.attrs != old_expr.attrs || new_expr.limits != old_expr.limits + } + _ => true, + } + } + (syn::Expr::Reference(new_expr), syn::Expr::Reference(old_expr)) => { + find_rsx_expr(&new_expr.expr, &old_expr.expr, rsx_calls) + || new_expr.attrs != old_expr.attrs + || new_expr.and_token != old_expr.and_token + || new_expr.mutability != old_expr.mutability + } + (syn::Expr::Repeat(new_expr), syn::Expr::Repeat(old_expr)) => { + find_rsx_expr(&new_expr.expr, &old_expr.expr, rsx_calls) + || find_rsx_expr(&new_expr.len, &old_expr.len, rsx_calls) + || new_expr.attrs != old_expr.attrs + || new_expr.bracket_token != old_expr.bracket_token + || new_expr.semi_token != old_expr.semi_token + } + (syn::Expr::Return(new_expr), syn::Expr::Return(old_expr)) => { + match (&new_expr.expr, &old_expr.expr) { + (Some(new_inner), Some(old_inner)) => { + find_rsx_expr(new_inner, old_inner, rsx_calls) + || new_expr.attrs != old_expr.attrs + || new_expr.return_token != old_expr.return_token + } + (None, None) => { + new_expr.attrs != old_expr.attrs + || new_expr.return_token != old_expr.return_token + } + _ => true, + } + } + (syn::Expr::Struct(new_expr), syn::Expr::Struct(old_expr)) => { + match (&new_expr.rest, &old_expr.rest) { + (Some(new_expr), Some(old_expr)) => { + if find_rsx_expr(new_expr, old_expr, rsx_calls) { + return true; + } + } + (None, None) => (), + _ => return true, + } + for (new_field, old_field) in new_expr.fields.iter().zip(old_expr.fields.iter()) { + if find_rsx_expr(&new_field.expr, &old_field.expr, rsx_calls) + || new_field.attrs != old_field.attrs + || new_field.member != old_field.member + || new_field.colon_token != old_field.colon_token + { + return true; + } + } + new_expr.attrs != old_expr.attrs + || new_expr.path != old_expr.path + || new_expr.brace_token != old_expr.brace_token + || new_expr.dot2_token != old_expr.dot2_token + } + (syn::Expr::Try(new_expr), syn::Expr::Try(old_expr)) => { + find_rsx_expr(&new_expr.expr, &old_expr.expr, rsx_calls) + || new_expr.attrs != old_expr.attrs + || new_expr.question_token != old_expr.question_token + } + (syn::Expr::TryBlock(new_expr), syn::Expr::TryBlock(old_expr)) => { + find_rsx_block(&new_expr.block, &old_expr.block, rsx_calls) + || new_expr.attrs != old_expr.attrs + || new_expr.try_token != old_expr.try_token + } + (syn::Expr::Tuple(new_expr), syn::Expr::Tuple(old_expr)) => { + for (new_el, old_el) in new_expr.elems.iter().zip(old_expr.elems.iter()) { + if find_rsx_expr(new_el, old_el, rsx_calls) { + return true; + } + } + new_expr.attrs != old_expr.attrs || new_expr.paren_token != old_expr.paren_token + } + (syn::Expr::Type(new_expr), syn::Expr::Type(old_expr)) => { + find_rsx_expr(&new_expr.expr, &old_expr.expr, rsx_calls) + || new_expr.attrs != old_expr.attrs + || new_expr.colon_token != old_expr.colon_token + || new_expr.ty != old_expr.ty + } + (syn::Expr::Unary(new_expr), syn::Expr::Unary(old_expr)) => { + find_rsx_expr(&new_expr.expr, &old_expr.expr, rsx_calls) + || new_expr.attrs != old_expr.attrs + || new_expr.op != old_expr.op + } + (syn::Expr::Unsafe(new_expr), syn::Expr::Unsafe(old_expr)) => { + find_rsx_block(&new_expr.block, &old_expr.block, rsx_calls) + || new_expr.attrs != old_expr.attrs + || new_expr.unsafe_token != old_expr.unsafe_token + } + (syn::Expr::While(new_expr), syn::Expr::While(old_expr)) => { + find_rsx_expr(&new_expr.cond, &old_expr.cond, rsx_calls) + || find_rsx_block(&new_expr.body, &old_expr.body, rsx_calls) + || new_expr.attrs != old_expr.attrs + || new_expr.label != old_expr.label + || new_expr.while_token != old_expr.while_token + } + (syn::Expr::Yield(new_expr), syn::Expr::Yield(old_expr)) => { + match (&new_expr.expr, &old_expr.expr) { + (Some(new_inner), Some(old_inner)) => { + find_rsx_expr(new_inner, old_inner, rsx_calls) + || new_expr.attrs != old_expr.attrs + || new_expr.yield_token != old_expr.yield_token + } + (None, None) => { + new_expr.attrs != old_expr.attrs || new_expr.yield_token != old_expr.yield_token + } + _ => true, + } + } + (syn::Expr::Verbatim(_), syn::Expr::Verbatim(_)) => false, + _ => true, + } +} diff --git a/src/lib.rs b/src/lib.rs index 8cd4b1f2d..722b03a06 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -18,3 +18,6 @@ pub use error::*; pub mod logging; pub use logging::*; + +pub mod hot_reload; +pub use hot_reload::*; diff --git a/src/server/mod.rs b/src/server/mod.rs index 1df13ca6a..230136e54 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -7,18 +7,28 @@ use axum::{ Router, }; use notify::{RecommendedWatcher, Watcher}; +use std::{fs::File, io::Read}; +use syn::__private::ToTokens; use std::{path::PathBuf, sync::Arc}; use tower::ServiceBuilder; use tower_http::services::fs::{ServeDir, ServeFileSystemResponseBody}; -use crate::{builder, serve::Serve, CrateConfig, Result}; +use crate::{builder, find_rsx, serve::Serve, CrateConfig, Result}; use tokio::sync::broadcast; -struct WsRelodState { +use std::collections::HashMap; + +use dioxus_rsx_interpreter::{error::RecompileReason, CodeLocation, SetRsxMessage}; + +struct WsReloadState { update: broadcast::Sender, } +struct HotReloadState { + messages: broadcast::Sender, +} + pub async fn startup(config: CrateConfig) -> Result<()> { log::info!("🚀 Starting development server..."); @@ -26,35 +36,20 @@ pub async fn startup(config: CrateConfig) -> Result<()> { let (reload_tx, _) = broadcast::channel(100); - let ws_reload_state = Arc::new(WsRelodState { + let ws_reload_state = Arc::new(WsReloadState { update: reload_tx.clone(), }); + let hot_reload_tx = broadcast::channel(100).0; + let hot_reload_state = Arc::new(HotReloadState { + messages: hot_reload_tx.clone(), + }); + let mut last_update_time = chrono::Local::now().timestamp(); // file watcher: check file change let watcher_conf = config.clone(); - let mut watcher = RecommendedWatcher::new(move |_: notify::Result| { - if chrono::Local::now().timestamp() > last_update_time { - log::info!("Start to rebuild project..."); - if builder::build(&watcher_conf).is_ok() { - // change the websocket reload state to true; - // the page will auto-reload. - if watcher_conf - .dioxus_config - .web - .watcher - .reload_html - .unwrap_or(false) - { - let _ = Serve::regen_dev_page(&watcher_conf); - } - let _ = reload_tx.send("reload".into()); - last_update_time = chrono::Local::now().timestamp(); - } - } - }) - .unwrap(); + let mut old_files_parsed: HashMap = HashMap::new(); let allow_watch_path = config .dioxus_config .web @@ -63,6 +58,92 @@ pub async fn startup(config: CrateConfig) -> Result<()> { .clone() .unwrap_or_else(|| vec![PathBuf::from("src")]); + let crate_dir = config.crate_dir.clone(); + + let mut watcher = RecommendedWatcher::new(move |evt: notify::Result| { + if let Ok(evt) = evt { + if let notify::EventKind::Modify(_) = evt.kind { + for path in evt.paths { + log::info!("File changed: {}", path.display()); + let mut file = File::open(path.clone()).unwrap(); + let mut src = String::new(); + file.read_to_string(&mut src).expect("Unable to read file"); + if src.is_empty() { + continue; + } + if let Ok(syntax) = syn::parse_file(&src) { + if let Some(old_str) = old_files_parsed.get(path.to_str().unwrap()) { + if let Ok(old) = syn::parse_file(&old_str) { + match find_rsx(&syntax, &old) { + crate::DiffResult::CodeChanged => { + log::info!("reload required"); + if chrono::Local::now().timestamp() > last_update_time { + log::info!("Start to rebuild project..."); + if builder::build(&watcher_conf).is_ok() { + // change the websocket reload state to true; + // the page will auto-reload. + if watcher_conf + .dioxus_config + .web + .watcher + .reload_html + .unwrap_or(false) + { + let _ = Serve::regen_dev_page(&watcher_conf); + } + let _ = reload_tx.send("reload".into()); + old_files_parsed.insert( + path.to_str().unwrap().to_string(), + src, + ); + last_update_time = chrono::Local::now().timestamp(); + } + } + } + crate::DiffResult::RsxChanged(changed) => { + for (old, new) in changed.into_iter() { + if let Some(hr) = old + .to_token_stream() + .into_iter() + .map(|tree| { + let location = tree.span(); + let start = location.start(); + CodeLocation { + file: path + .strip_prefix(&crate_dir) + .unwrap() + .display() + .to_string(), + line: start.line as u32, + column: start.column as u32 + 1, + } + }) + .min_by(|cl1, cl2| { + cl1.line + .cmp(&cl2.line) + .then(cl1.column.cmp(&cl2.column)) + }) + { + let rsx = new.to_string(); + let _ = hot_reload_tx.send(SetRsxMessage { + location: hr, + new_text: rsx, + }); + } + } + } + } + } + } else { + old_files_parsed.insert(path.to_str().unwrap().to_string(), src); + } + } + } + } + } + }) + .unwrap(); + for sub_path in allow_watch_path { watcher .watch( @@ -115,6 +196,7 @@ pub async fn startup(config: CrateConfig) -> Result<()> { let router = Router::new() .route("/_dioxus/ws", get(ws_handler)) + .route("/_dioxus/hot_reload", get(hot_reload_handler)) .fallback( get_service(file_service).handle_error(|error: std::io::Error| async move { ( @@ -125,7 +207,12 @@ pub async fn startup(config: CrateConfig) -> Result<()> { ); axum::Server::bind(&format!("0.0.0.0:{}", port).parse().unwrap()) - .serve(router.layer(Extension(ws_reload_state)).into_make_service()) + .serve( + router + .layer(Extension(ws_reload_state)) + .layer(Extension(hot_reload_state)) + .into_make_service(), + ) .await?; Ok(()) @@ -134,7 +221,7 @@ pub async fn startup(config: CrateConfig) -> Result<()> { async fn ws_handler( ws: WebSocketUpgrade, _: Option>, - Extension(state): Extension>, + Extension(state): Extension>, ) -> impl IntoResponse { ws.on_upgrade(|mut socket| async move { let mut rx = state.update.subscribe(); @@ -157,3 +244,38 @@ async fn ws_handler( reload_watcher.await.unwrap(); }) } + +async fn hot_reload_handler( + ws: WebSocketUpgrade, + _: Option>, + Extension(state): Extension>, +) -> impl IntoResponse { + ws.on_upgrade(|mut socket| async move { + println!("🔥 Hot Reload WebSocket is connected."); + let mut rx = state.messages.subscribe(); + loop { + let read_set_rsx = rx.recv(); + let read_err = socket.recv(); + tokio::select! { + err = read_err => { + if let Some(Ok(Message::Text(err))) = err { + let error: RecompileReason = serde_json::from_str(&err).unwrap(); + log::error!("{:?}", error); + }; + }, + set_rsx = read_set_rsx => { + if let Ok(rsx) = set_rsx{ + if socket + .send(Message::Text(serde_json::to_string(&rsx).unwrap())) + .await + .is_err() + { + break; + }; + // println!("{:?}", rsx); + } + } + }; + } + }) +} From 3ccd65b582b8320b24c8921829b777084a6d2e1e Mon Sep 17 00:00:00 2001 From: Evan Almloff Date: Thu, 9 Jun 2022 10:35:18 -0500 Subject: [PATCH 030/170] remove unused import --- src/hot_reload/mod.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/hot_reload/mod.rs b/src/hot_reload/mod.rs index d70cda29e..3aced9567 100644 --- a/src/hot_reload/mod.rs +++ b/src/hot_reload/mod.rs @@ -1,4 +1,3 @@ -use dioxus_rsx::{BodyNode, CallBody}; use proc_macro2::TokenStream; use syn::{File, Macro}; From 61e9f56816495ad18c367cc72038409e60382ddc Mon Sep 17 00:00:00 2001 From: Evan Almloff Date: Thu, 9 Jun 2022 11:37:48 -0500 Subject: [PATCH 031/170] automaticly reload when rsx requires it --- src/server/mod.rs | 59 +++++++++++++++++++++++++---------------------- 1 file changed, 32 insertions(+), 27 deletions(-) diff --git a/src/server/mod.rs b/src/server/mod.rs index 230136e54..c4ab60385 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -7,7 +7,7 @@ use axum::{ Router, }; use notify::{RecommendedWatcher, Watcher}; -use std::{fs::File, io::Read}; +use std::{fs::File, io::Read, sync::Mutex}; use syn::__private::ToTokens; use std::{path::PathBuf, sync::Arc}; @@ -23,10 +23,13 @@ use dioxus_rsx_interpreter::{error::RecompileReason, CodeLocation, SetRsxMessage struct WsReloadState { update: broadcast::Sender, + last_file_rebuild: Arc>>, + watcher_config: CrateConfig, } struct HotReloadState { messages: broadcast::Sender, + update: broadcast::Sender, } pub async fn startup(config: CrateConfig) -> Result<()> { @@ -36,20 +39,23 @@ pub async fn startup(config: CrateConfig) -> Result<()> { let (reload_tx, _) = broadcast::channel(100); + let last_file_rebuild = Arc::new(Mutex::new(HashMap::new())); + let ws_reload_state = Arc::new(WsReloadState { update: reload_tx.clone(), + last_file_rebuild: last_file_rebuild.clone(), + watcher_config: config.clone(), }); let hot_reload_tx = broadcast::channel(100).0; let hot_reload_state = Arc::new(HotReloadState { messages: hot_reload_tx.clone(), + update: reload_tx.clone(), }); let mut last_update_time = chrono::Local::now().timestamp(); // file watcher: check file change - let watcher_conf = config.clone(); - let mut old_files_parsed: HashMap = HashMap::new(); let allow_watch_path = config .dioxus_config .web @@ -64,7 +70,6 @@ pub async fn startup(config: CrateConfig) -> Result<()> { if let Ok(evt) = evt { if let notify::EventKind::Modify(_) = evt.kind { for path in evt.paths { - log::info!("File changed: {}", path.display()); let mut file = File::open(path.clone()).unwrap(); let mut src = String::new(); file.read_to_string(&mut src).expect("Unable to read file"); @@ -72,35 +77,19 @@ pub async fn startup(config: CrateConfig) -> Result<()> { continue; } if let Ok(syntax) = syn::parse_file(&src) { - if let Some(old_str) = old_files_parsed.get(path.to_str().unwrap()) { + let mut last_file_rebuild = last_file_rebuild.lock().unwrap(); + if let Some(old_str) = last_file_rebuild.get(path.to_str().unwrap()) { if let Ok(old) = syn::parse_file(&old_str) { match find_rsx(&syntax, &old) { crate::DiffResult::CodeChanged => { log::info!("reload required"); if chrono::Local::now().timestamp() > last_update_time { - log::info!("Start to rebuild project..."); - if builder::build(&watcher_conf).is_ok() { - // change the websocket reload state to true; - // the page will auto-reload. - if watcher_conf - .dioxus_config - .web - .watcher - .reload_html - .unwrap_or(false) - { - let _ = Serve::regen_dev_page(&watcher_conf); - } - let _ = reload_tx.send("reload".into()); - old_files_parsed.insert( - path.to_str().unwrap().to_string(), - src, - ); - last_update_time = chrono::Local::now().timestamp(); - } + let _ = reload_tx.send("reload".into()); + last_update_time = chrono::Local::now().timestamp(); } } crate::DiffResult::RsxChanged(changed) => { + log::info!("reloading rsx"); for (old, new) in changed.into_iter() { if let Some(hr) = old .to_token_stream() @@ -135,7 +124,7 @@ pub async fn startup(config: CrateConfig) -> Result<()> { } } } else { - old_files_parsed.insert(path.to_str().unwrap().to_string(), src); + last_file_rebuild.insert(path.to_str().unwrap().to_string(), src); } } } @@ -229,6 +218,22 @@ async fn ws_handler( loop { let v = rx.recv().await.unwrap(); if v == "reload" { + log::info!("Start to rebuild project..."); + if builder::build(&state.watcher_config).is_ok() { + // change the websocket reload state to true; + // the page will auto-reload. + if state + .watcher_config + .dioxus_config + .web + .watcher + .reload_html + .unwrap_or(false) + { + let _ = Serve::regen_dev_page(&state.watcher_config); + } + *state.last_file_rebuild.lock().unwrap() = HashMap::new(); + } // ignore the error if socket .send(Message::Text(String::from("reload"))) @@ -261,6 +266,7 @@ async fn hot_reload_handler( if let Some(Ok(Message::Text(err))) = err { let error: RecompileReason = serde_json::from_str(&err).unwrap(); log::error!("{:?}", error); + state.update.send("reload".to_string()).unwrap(); }; }, set_rsx = read_set_rsx => { @@ -272,7 +278,6 @@ async fn hot_reload_handler( { break; }; - // println!("{:?}", rsx); } } }; From f19958d766c5584c89df6d617170e87f275591bd Mon Sep 17 00:00:00 2001 From: Evan Almloff Date: Thu, 9 Jun 2022 11:58:09 -0500 Subject: [PATCH 032/170] move into feature --- Cargo.toml | 10 +-- src/lib.rs | 2 +- src/server/mod.rs | 159 +++++++++++++++++++++++++++------------------- 3 files changed, 100 insertions(+), 71 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 4acd41463..770fd7b1d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,10 +46,12 @@ flate2 = "1.0.22" tar = "0.4.38" tower = "0.4.12" -# hot reload -syn = "1.0" -dioxus-rsx-interpreter = { path = "../dioxus/packages/rsx_interpreter" } -proc-macro2 = { version = "1.0", features = ["span-locations"] } +syn = { version = "1.0", optional = true } +dioxus-rsx-interpreter = { path = "../dioxus/packages/rsx_interpreter", optional = true } +proc-macro2 = { version = "1.0", features = ["span-locations"], optional = true } + +[features] +hot_reload = ["dioxus-rsx-interpreter", "proc-macro2", "syn"] [[bin]] path = "src/main.rs" diff --git a/src/lib.rs b/src/lib.rs index 722b03a06..683b7251a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -19,5 +19,5 @@ pub use error::*; pub mod logging; pub use logging::*; +#[cfg(feature = "hot_reload")] pub mod hot_reload; -pub use hot_reload::*; diff --git a/src/server/mod.rs b/src/server/mod.rs index c4ab60385..18d50fc57 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -7,26 +7,34 @@ use axum::{ Router, }; use notify::{RecommendedWatcher, Watcher}; -use std::{fs::File, io::Read, sync::Mutex}; -use syn::__private::ToTokens; +use std::{fs::File, io::Read}; use std::{path::PathBuf, sync::Arc}; use tower::ServiceBuilder; use tower_http::services::fs::{ServeDir, ServeFileSystemResponseBody}; -use crate::{builder, find_rsx, serve::Serve, CrateConfig, Result}; +use crate::{builder, serve::Serve, CrateConfig, Result}; use tokio::sync::broadcast; -use std::collections::HashMap; - -use dioxus_rsx_interpreter::{error::RecompileReason, CodeLocation, SetRsxMessage}; +#[cfg(feature = "hot_reload")] +mod hot_reload_improts { + pub use crate::hot_reload::{find_rsx, DiffResult}; + pub use dioxus_rsx_interpreter::{error::RecompileReason, CodeLocation, SetRsxMessage}; + pub use std::collections::HashMap; + pub use std::sync::Mutex; + pub use syn::__private::ToTokens; +} +#[cfg(feature = "hot_reload")] +use hot_reload_improts::*; struct WsReloadState { update: broadcast::Sender, + #[cfg(feature = "hot_reload")] last_file_rebuild: Arc>>, watcher_config: CrateConfig, } +#[cfg(feature = "hot_reload")] struct HotReloadState { messages: broadcast::Sender, update: broadcast::Sender, @@ -39,19 +47,24 @@ pub async fn startup(config: CrateConfig) -> Result<()> { let (reload_tx, _) = broadcast::channel(100); + #[cfg(feature = "hot_reload")] let last_file_rebuild = Arc::new(Mutex::new(HashMap::new())); - - let ws_reload_state = Arc::new(WsReloadState { - update: reload_tx.clone(), - last_file_rebuild: last_file_rebuild.clone(), - watcher_config: config.clone(), - }); - + #[cfg(feature = "hot_reload")] let hot_reload_tx = broadcast::channel(100).0; + #[cfg(feature = "hot_reload")] let hot_reload_state = Arc::new(HotReloadState { messages: hot_reload_tx.clone(), update: reload_tx.clone(), }); + #[cfg(feature = "hot_reload")] + let crate_dir = config.crate_dir.clone(); + + let ws_reload_state = Arc::new(WsReloadState { + update: reload_tx.clone(), + #[cfg(feature = "hot_reload")] + last_file_rebuild: last_file_rebuild.clone(), + watcher_config: config.clone(), + }); let mut last_update_time = chrono::Local::now().timestamp(); @@ -64,8 +77,6 @@ pub async fn startup(config: CrateConfig) -> Result<()> { .clone() .unwrap_or_else(|| vec![PathBuf::from("src")]); - let crate_dir = config.crate_dir.clone(); - let mut watcher = RecommendedWatcher::new(move |evt: notify::Result| { if let Ok(evt) = evt { if let notify::EventKind::Modify(_) = evt.kind { @@ -76,55 +87,66 @@ pub async fn startup(config: CrateConfig) -> Result<()> { if src.is_empty() { continue; } - if let Ok(syntax) = syn::parse_file(&src) { - let mut last_file_rebuild = last_file_rebuild.lock().unwrap(); - if let Some(old_str) = last_file_rebuild.get(path.to_str().unwrap()) { - if let Ok(old) = syn::parse_file(&old_str) { - match find_rsx(&syntax, &old) { - crate::DiffResult::CodeChanged => { - log::info!("reload required"); - if chrono::Local::now().timestamp() > last_update_time { - let _ = reload_tx.send("reload".into()); - last_update_time = chrono::Local::now().timestamp(); + #[cfg(feature = "hot_reload")] + { + if let Ok(syntax) = syn::parse_file(&src) { + let mut last_file_rebuild = last_file_rebuild.lock().unwrap(); + if let Some(old_str) = last_file_rebuild.get(path.to_str().unwrap()) { + if let Ok(old) = syn::parse_file(&old_str) { + match find_rsx(&syntax, &old) { + DiffResult::CodeChanged => { + log::info!("reload required"); + if chrono::Local::now().timestamp() > last_update_time { + let _ = reload_tx.send("reload".into()); + last_update_time = chrono::Local::now().timestamp(); + } } - } - crate::DiffResult::RsxChanged(changed) => { - log::info!("reloading rsx"); - for (old, new) in changed.into_iter() { - if let Some(hr) = old - .to_token_stream() - .into_iter() - .map(|tree| { - let location = tree.span(); - let start = location.start(); - CodeLocation { - file: path - .strip_prefix(&crate_dir) - .unwrap() - .display() - .to_string(), - line: start.line as u32, - column: start.column as u32 + 1, - } - }) - .min_by(|cl1, cl2| { - cl1.line - .cmp(&cl2.line) - .then(cl1.column.cmp(&cl2.column)) - }) - { - let rsx = new.to_string(); - let _ = hot_reload_tx.send(SetRsxMessage { - location: hr, - new_text: rsx, - }); + DiffResult::RsxChanged(changed) => { + log::info!("reloading rsx"); + for (old, new) in changed.into_iter() { + if let Some(hr) = old + .to_token_stream() + .into_iter() + .map(|tree| { + let location = tree.span(); + let start = location.start(); + CodeLocation { + file: path + .strip_prefix(&crate_dir) + .unwrap() + .display() + .to_string(), + line: start.line as u32, + column: start.column as u32 + 1, + } + }) + .min_by(|cl1, cl2| { + cl1.line + .cmp(&cl2.line) + .then(cl1.column.cmp(&cl2.column)) + }) + { + let rsx = new.to_string(); + let _ = hot_reload_tx.send(SetRsxMessage { + location: hr, + new_text: rsx, + }); + } } } } } + } else { + last_file_rebuild.insert(path.to_str().unwrap().to_string(), src); } - } else { - last_file_rebuild.insert(path.to_str().unwrap().to_string(), src); + } + } + #[cfg(not(feature = "hot_reload"))] + { + log::info!("reload required"); + if chrono::Local::now().timestamp() > last_update_time { + let _ = reload_tx.send("reload".into()); + last_update_time = chrono::Local::now().timestamp(); } } } @@ -185,7 +207,6 @@ pub async fn startup(config: CrateConfig) -> Result<()> { let router = Router::new() .route("/_dioxus/ws", get(ws_handler)) - .route("/_dioxus/hot_reload", get(hot_reload_handler)) .fallback( get_service(file_service).handle_error(|error: std::io::Error| async move { ( @@ -194,14 +215,16 @@ pub async fn startup(config: CrateConfig) -> Result<()> { ) }), ); + #[cfg(feature = "hot_reload")] + let router = router.route("/_dioxus/hot_reload", get(hot_reload_handler)); + + let router = router.layer(Extension(ws_reload_state)); + + #[cfg(feature = "hot_reload")] + let router = router.layer(Extension(hot_reload_state)); axum::Server::bind(&format!("0.0.0.0:{}", port).parse().unwrap()) - .serve( - router - .layer(Extension(ws_reload_state)) - .layer(Extension(hot_reload_state)) - .into_make_service(), - ) + .serve(router.into_make_service()) .await?; Ok(()) @@ -232,7 +255,10 @@ async fn ws_handler( { let _ = Serve::regen_dev_page(&state.watcher_config); } - *state.last_file_rebuild.lock().unwrap() = HashMap::new(); + #[cfg(feature = "hot_reload")] + { + *state.last_file_rebuild.lock().unwrap() = HashMap::new(); + } } // ignore the error if socket @@ -250,6 +276,7 @@ async fn ws_handler( }) } +#[cfg(feature = "hot_reload")] async fn hot_reload_handler( ws: WebSocketUpgrade, _: Option>, From f06920a37ec12fafbff53d766c14b89fd8b21c8a Mon Sep 17 00:00:00 2001 From: Evan Almloff Date: Thu, 9 Jun 2022 12:38:59 -0500 Subject: [PATCH 033/170] search directory .rs files to diff automaticly --- src/server/mod.rs | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/src/server/mod.rs b/src/server/mod.rs index 18d50fc57..8670debb1 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -7,7 +7,10 @@ use axum::{ Router, }; use notify::{RecommendedWatcher, Watcher}; -use std::{fs::File, io::Read}; +use std::{ + fs::{self, File}, + io::{self, Read}, +}; use std::{path::PathBuf, sync::Arc}; use tower::ServiceBuilder; @@ -50,6 +53,8 @@ pub async fn startup(config: CrateConfig) -> Result<()> { #[cfg(feature = "hot_reload")] let last_file_rebuild = Arc::new(Mutex::new(HashMap::new())); #[cfg(feature = "hot_reload")] + find_rs_files(&config.crate_dir, &mut *last_file_rebuild.lock().unwrap()).unwrap(); + #[cfg(feature = "hot_reload")] let hot_reload_tx = broadcast::channel(100).0; #[cfg(feature = "hot_reload")] let hot_reload_state = Arc::new(HotReloadState { @@ -215,6 +220,7 @@ pub async fn startup(config: CrateConfig) -> Result<()> { ) }), ); + #[cfg(feature = "hot_reload")] let router = router.route("/_dioxus/hot_reload", get(hot_reload_handler)); @@ -257,7 +263,9 @@ async fn ws_handler( } #[cfg(feature = "hot_reload")] { - *state.last_file_rebuild.lock().unwrap() = HashMap::new(); + let mut write = state.last_file_rebuild.lock().unwrap(); + *write = HashMap::new(); + find_rs_files(&state.watcher_config.crate_dir, &mut *write).unwrap(); } } // ignore the error @@ -311,3 +319,23 @@ async fn hot_reload_handler( } }) } + +#[cfg(feature = "hot_reload")] +fn find_rs_files(root: &PathBuf, files: &mut HashMap) -> io::Result<()> { + for entry in fs::read_dir(root)? { + if let Ok(entry) = entry { + let path = entry.path(); + if path.is_dir() { + find_rs_files(&path, files)?; + } else { + if path.extension().map(|s| s.to_str()).flatten() == Some("rs") { + let mut file = File::open(path.clone()).unwrap(); + let mut src = String::new(); + file.read_to_string(&mut src).expect("Unable to read file"); + files.insert(path.display().to_string(), src); + } + } + } + } + Ok(()) +} From aa9f5a1a425c0e07e234ac8e594d041b53fb79f4 Mon Sep 17 00:00:00 2001 From: Evan Almloff Date: Thu, 9 Jun 2022 12:44:07 -0500 Subject: [PATCH 034/170] clean up imports --- src/server/mod.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/server/mod.rs b/src/server/mod.rs index 8670debb1..9c0c86fd6 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -7,10 +7,7 @@ use axum::{ Router, }; use notify::{RecommendedWatcher, Watcher}; -use std::{ - fs::{self, File}, - io::{self, Read}, -}; +use std::{fs::File, io::Read}; use std::{path::PathBuf, sync::Arc}; use tower::ServiceBuilder; @@ -25,6 +22,7 @@ mod hot_reload_improts { pub use dioxus_rsx_interpreter::{error::RecompileReason, CodeLocation, SetRsxMessage}; pub use std::collections::HashMap; pub use std::sync::Mutex; + pub use std::{fs, io}; pub use syn::__private::ToTokens; } #[cfg(feature = "hot_reload")] From 1d29f66cfc40cbd33065a193cbc013694cfebf0f Mon Sep 17 00:00:00 2001 From: Evan Almloff Date: Thu, 9 Jun 2022 13:00:28 -0500 Subject: [PATCH 035/170] use log::info instead of print --- src/server/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/server/mod.rs b/src/server/mod.rs index 9c0c86fd6..95026d768 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -289,7 +289,7 @@ async fn hot_reload_handler( Extension(state): Extension>, ) -> impl IntoResponse { ws.on_upgrade(|mut socket| async move { - println!("🔥 Hot Reload WebSocket is connected."); + log::info!("🔥 Hot Reload WebSocket connected"); let mut rx = state.messages.subscribe(); loop { let read_set_rsx = rx.recv(); From 0c4028ad5270281e0893dd8e919fdebb3407b44c Mon Sep 17 00:00:00 2001 From: Evan Almloff Date: Fri, 10 Jun 2022 19:18:02 -0500 Subject: [PATCH 036/170] close websocket on disconnect --- src/server/mod.rs | 54 ++++++++++++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 22 deletions(-) diff --git a/src/server/mod.rs b/src/server/mod.rs index 95026d768..3506112f2 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -291,30 +291,40 @@ async fn hot_reload_handler( ws.on_upgrade(|mut socket| async move { log::info!("🔥 Hot Reload WebSocket connected"); let mut rx = state.messages.subscribe(); - loop { - let read_set_rsx = rx.recv(); - let read_err = socket.recv(); - tokio::select! { - err = read_err => { - if let Some(Ok(Message::Text(err))) = err { - let error: RecompileReason = serde_json::from_str(&err).unwrap(); - log::error!("{:?}", error); - state.update.send("reload".to_string()).unwrap(); - }; - }, - set_rsx = read_set_rsx => { - if let Ok(rsx) = set_rsx{ - if socket - .send(Message::Text(serde_json::to_string(&rsx).unwrap())) - .await - .is_err() - { + let hot_reload_handle = tokio::spawn(async move { + loop { + let read_set_rsx = rx.recv(); + let read_err = socket.recv(); + tokio::select! { + err = read_err => { + if let Some(Ok(err)) = err { + if let Message::Text(err) = err { + let error: RecompileReason = serde_json::from_str(&err).unwrap(); + log::error!("{:?}", error); + if state.update.send("reload".to_string()).is_err() { + break; + } + } + } else { break; - }; + } + }, + set_rsx = read_set_rsx => { + if let Ok(rsx) = set_rsx { + if socket + .send(Message::Text(serde_json::to_string(&rsx).unwrap())) + .await + .is_err() + { + break; + }; + } } - } - }; - } + }; + } + }); + + hot_reload_handle.await.unwrap(); }) } From d1c619e5dc9409eb358dfaf141458a5b38edc02b Mon Sep 17 00:00:00 2001 From: xTeKc <81730792+xTeKc@users.noreply.github.com> Date: Sun, 12 Jun 2022 03:31:13 -0400 Subject: [PATCH 037/170] update edition --- rustfmt.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rustfmt.toml b/rustfmt.toml index 9071fb4b5..39b98f125 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -1,8 +1,8 @@ version = "Two" -edition = "2018" +edition = "2021" imports_granularity = "Crate" #use_small_heuristics = "Max" #control_brace_style = "ClosingNextLine" normalize_comments = true -format_code_in_doc_comments = true \ No newline at end of file +format_code_in_doc_comments = true From f287e757611ac2a84a8622bcf9b4a3d3cf60294b Mon Sep 17 00:00:00 2001 From: xTeKc <81730792+xTeKc@users.noreply.github.com> Date: Sun, 12 Jun 2022 03:31:35 -0400 Subject: [PATCH 038/170] update edition --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index c869267b1..24493e787 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ name = "dioxus-cli" version = "0.1.4" authors = ["Jonathan Kelley"] -edition = "2018" +edition = "2021" description = "CLI tool for developing, testing, and publishing Dioxus apps" license = "MIT/Apache-2.0" From bfab711010dd4f508930c3ce6af8f39c65c6c025 Mon Sep 17 00:00:00 2001 From: xTeKc <81730792+xTeKc@users.noreply.github.com> Date: Sun, 12 Jun 2022 03:35:25 -0400 Subject: [PATCH 039/170] force closure to take ownership --- src/server/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/server/mod.rs b/src/server/mod.rs index 1df13ca6a..ada3e10c7 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -79,7 +79,7 @@ pub async fn startup(config: CrateConfig) -> Result<()> { let file_service_config = config.clone(); let file_service = ServiceBuilder::new() .and_then( - |response: Response| async move { + move |response: Response| async move { let response = if file_service_config .dioxus_config .web From b3db5469c36b143d024b6b828cebcef261740510 Mon Sep 17 00:00:00 2001 From: Evan Almloff Date: Mon, 13 Jun 2022 15:33:49 -0500 Subject: [PATCH 040/170] ignore files that have not been changed recently when checking for changes initially --- src/hot_reload/mod.rs | 4 +- src/server/mod.rs | 206 +++++++++++++++++++++++++++++------------- 2 files changed, 145 insertions(+), 65 deletions(-) diff --git a/src/hot_reload/mod.rs b/src/hot_reload/mod.rs index 3aced9567..8297fedb9 100644 --- a/src/hot_reload/mod.rs +++ b/src/hot_reload/mod.rs @@ -426,7 +426,9 @@ fn find_rsx_expr( && old_mac.path.get_ident().map(|ident| ident.to_string()) == Some("rsx".to_string()) { - rsx_calls.push((old_mac.clone(), new_mac.tokens.clone())); + if old_mac != new_mac { + rsx_calls.push((old_mac.clone(), new_mac.tokens.clone())); + } false } else { new_expr != old_expr diff --git a/src/server/mod.rs b/src/server/mod.rs index 3506112f2..a0bdf24b0 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -7,7 +7,6 @@ use axum::{ Router, }; use notify::{RecommendedWatcher, Watcher}; -use std::{fs::File, io::Read}; use std::{path::PathBuf, sync::Arc}; use tower::ServiceBuilder; @@ -20,9 +19,12 @@ use tokio::sync::broadcast; mod hot_reload_improts { pub use crate::hot_reload::{find_rsx, DiffResult}; pub use dioxus_rsx_interpreter::{error::RecompileReason, CodeLocation, SetRsxMessage}; + pub use proc_macro2::TokenStream; pub use std::collections::HashMap; pub use std::sync::Mutex; - pub use std::{fs, io}; + pub use std::time::SystemTime; + pub use std::{fs, io, path::Path}; + pub use std::{fs::File, io::Read}; pub use syn::__private::ToTokens; } #[cfg(feature = "hot_reload")] @@ -31,7 +33,7 @@ use hot_reload_improts::*; struct WsReloadState { update: broadcast::Sender, #[cfg(feature = "hot_reload")] - last_file_rebuild: Arc>>, + last_file_rebuild: Arc>, watcher_config: CrateConfig, } @@ -39,6 +41,47 @@ struct WsReloadState { struct HotReloadState { messages: broadcast::Sender, update: broadcast::Sender, + last_file_rebuild: Arc>, + watcher_config: CrateConfig, +} + +#[cfg(feature = "hot_reload")] +struct FileMap { + map: HashMap, + last_updated_time: std::time::SystemTime, +} + +#[cfg(feature = "hot_reload")] +impl FileMap { + fn new(path: PathBuf) -> Self { + fn find_rs_files(root: PathBuf) -> io::Result> { + let mut files = HashMap::new(); + if root.is_dir() { + let mut handles = Vec::new(); + for entry in fs::read_dir(root)? { + if let Ok(entry) = entry { + let path = entry.path(); + handles.push(std::thread::spawn(move || find_rs_files(path))); + } + } + for handle in handles { + files.extend(handle.join().unwrap()?); + } + } else { + if root.extension().map(|s| s.to_str()).flatten() == Some("rs") { + let mut file = File::open(root.clone()).unwrap(); + let mut src = String::new(); + file.read_to_string(&mut src).expect("Unable to read file"); + files.insert(root, src); + } + } + Ok(files) + } + Self { + last_updated_time: SystemTime::now(), + map: find_rs_files(path).unwrap(), + } + } } pub async fn startup(config: CrateConfig) -> Result<()> { @@ -49,15 +92,15 @@ pub async fn startup(config: CrateConfig) -> Result<()> { let (reload_tx, _) = broadcast::channel(100); #[cfg(feature = "hot_reload")] - let last_file_rebuild = Arc::new(Mutex::new(HashMap::new())); - #[cfg(feature = "hot_reload")] - find_rs_files(&config.crate_dir, &mut *last_file_rebuild.lock().unwrap()).unwrap(); + let last_file_rebuild = Arc::new(Mutex::new(FileMap::new(config.crate_dir.clone()))); #[cfg(feature = "hot_reload")] let hot_reload_tx = broadcast::channel(100).0; #[cfg(feature = "hot_reload")] let hot_reload_state = Arc::new(HotReloadState { messages: hot_reload_tx.clone(), update: reload_tx.clone(), + last_file_rebuild: last_file_rebuild.clone(), + watcher_config: config.clone(), }); #[cfg(feature = "hot_reload")] let crate_dir = config.crate_dir.clone(); @@ -83,18 +126,21 @@ pub async fn startup(config: CrateConfig) -> Result<()> { let mut watcher = RecommendedWatcher::new(move |evt: notify::Result| { if let Ok(evt) = evt { if let notify::EventKind::Modify(_) = evt.kind { - for path in evt.paths { - let mut file = File::open(path.clone()).unwrap(); - let mut src = String::new(); - file.read_to_string(&mut src).expect("Unable to read file"); - if src.is_empty() { - continue; - } - #[cfg(feature = "hot_reload")] - { + #[cfg(feature = "hot_reload")] + { + for path in evt.paths { + let mut file = File::open(path.clone()).unwrap(); + if path.extension().map(|p| p.to_str()).flatten() != Some("rs") { + continue; + } + let mut src = String::new(); + file.read_to_string(&mut src).expect("Unable to read file"); + if src.is_empty() { + continue; + } if let Ok(syntax) = syn::parse_file(&src) { let mut last_file_rebuild = last_file_rebuild.lock().unwrap(); - if let Some(old_str) = last_file_rebuild.get(path.to_str().unwrap()) { + if let Some(old_str) = last_file_rebuild.map.get(&path) { if let Ok(old) = syn::parse_file(&old_str) { match find_rsx(&syntax, &old) { DiffResult::CodeChanged => { @@ -107,28 +153,13 @@ pub async fn startup(config: CrateConfig) -> Result<()> { DiffResult::RsxChanged(changed) => { log::info!("reloading rsx"); for (old, new) in changed.into_iter() { - if let Some(hr) = old - .to_token_stream() - .into_iter() - .map(|tree| { - let location = tree.span(); - let start = location.start(); - CodeLocation { - file: path - .strip_prefix(&crate_dir) - .unwrap() - .display() - .to_string(), - line: start.line as u32, - column: start.column as u32 + 1, - } - }) - .min_by(|cl1, cl2| { - cl1.line - .cmp(&cl2.line) - .then(cl1.column.cmp(&cl2.column)) - }) - { + if let Some(hr) = get_min_location( + &path + .strip_prefix(&crate_dir) + .unwrap() + .to_path_buf(), + old.to_token_stream(), + ) { let rsx = new.to_string(); let _ = hot_reload_tx.send(SetRsxMessage { location: hr, @@ -140,17 +171,17 @@ pub async fn startup(config: CrateConfig) -> Result<()> { } } } else { - last_file_rebuild.insert(path.to_str().unwrap().to_string(), src); + *last_file_rebuild = FileMap::new(crate_dir.clone()); } } } - #[cfg(not(feature = "hot_reload"))] - { - log::info!("reload required"); - if chrono::Local::now().timestamp() > last_update_time { - let _ = reload_tx.send("reload".into()); - last_update_time = chrono::Local::now().timestamp(); - } + } + #[cfg(not(feature = "hot_reload"))] + { + log::info!("reload required"); + if chrono::Local::now().timestamp() > last_update_time { + let _ = reload_tx.send("reload".into()); + last_update_time = chrono::Local::now().timestamp(); } } } @@ -262,8 +293,7 @@ async fn ws_handler( #[cfg(feature = "hot_reload")] { let mut write = state.last_file_rebuild.lock().unwrap(); - *write = HashMap::new(); - find_rs_files(&state.watcher_config.crate_dir, &mut *write).unwrap(); + *write = FileMap::new(state.watcher_config.crate_dir.clone()); } } // ignore the error @@ -290,6 +320,59 @@ async fn hot_reload_handler( ) -> impl IntoResponse { ws.on_upgrade(|mut socket| async move { log::info!("🔥 Hot Reload WebSocket connected"); + { + log::info!("Searching files for changes since last run..."); + // update any files that changed before the websocket connected. + let mut messages = Vec::new(); + + { + let handle = state.last_file_rebuild.lock().unwrap(); + let update_time = handle.last_updated_time.clone(); + for (k, v) in handle.map.iter() { + let mut file = File::open(k).unwrap(); + if let Ok(md) = file.metadata() { + if let Ok(time) = md.modified() { + if time < update_time { + continue; + } + } + } + let mut new = String::new(); + file.read_to_string(&mut new).expect("Unable to read file"); + if let Ok(new) = syn::parse_file(&new) { + if let Ok(old) = syn::parse_file(&v) { + if let DiffResult::RsxChanged(changed) = find_rsx(&new, &old) { + for (old, new) in changed.into_iter() { + if let Some(hr) = get_min_location( + k.strip_prefix(&state.watcher_config.crate_dir).unwrap(), + old.to_token_stream(), + ) { + let rsx = new.to_string(); + let msg = SetRsxMessage { + location: hr, + new_text: rsx, + }; + messages.push(msg); + } + } + } + } + } + } + } + + for msg in &messages { + if socket + .send(Message::Text(serde_json::to_string(msg).unwrap())) + .await + .is_err() + { + return; + } + } + log::info!("Updated page"); + } + let mut rx = state.messages.subscribe(); let hot_reload_handle = tokio::spawn(async move { loop { @@ -329,21 +412,16 @@ async fn hot_reload_handler( } #[cfg(feature = "hot_reload")] -fn find_rs_files(root: &PathBuf, files: &mut HashMap) -> io::Result<()> { - for entry in fs::read_dir(root)? { - if let Ok(entry) = entry { - let path = entry.path(); - if path.is_dir() { - find_rs_files(&path, files)?; - } else { - if path.extension().map(|s| s.to_str()).flatten() == Some("rs") { - let mut file = File::open(path.clone()).unwrap(); - let mut src = String::new(); - file.read_to_string(&mut src).expect("Unable to read file"); - files.insert(path.display().to_string(), src); - } +fn get_min_location(path: &Path, ts: TokenStream) -> Option { + ts.into_iter() + .map(|tree| { + let location = tree.span(); + let start = location.start(); + CodeLocation { + file: path.display().to_string(), + line: start.line as u32, + column: start.column as u32 + 1, } - } - } - Ok(()) + }) + .min_by(|cl1, cl2| cl1.line.cmp(&cl2.line).then(cl1.column.cmp(&cl2.column))) } From 712d258496415f839b389da8163d5634a36e15f1 Mon Sep 17 00:00:00 2001 From: Evan Almloff Date: Tue, 14 Jun 2022 07:31:37 -0500 Subject: [PATCH 041/170] clean up config statements --- src/hot_reload/mod.rs | 4 +- src/server/hot_reload.rs | 174 ++++++++++++++++++ src/server/mod.rs | 383 +++++++++++++++------------------------ 3 files changed, 321 insertions(+), 240 deletions(-) create mode 100644 src/server/hot_reload.rs diff --git a/src/hot_reload/mod.rs b/src/hot_reload/mod.rs index 8297fedb9..3aced9567 100644 --- a/src/hot_reload/mod.rs +++ b/src/hot_reload/mod.rs @@ -426,9 +426,7 @@ fn find_rsx_expr( && old_mac.path.get_ident().map(|ident| ident.to_string()) == Some("rsx".to_string()) { - if old_mac != new_mac { - rsx_calls.push((old_mac.clone(), new_mac.tokens.clone())); - } + rsx_calls.push((old_mac.clone(), new_mac.tokens.clone())); false } else { new_expr != old_expr diff --git a/src/server/hot_reload.rs b/src/server/hot_reload.rs new file mode 100644 index 000000000..661d249e6 --- /dev/null +++ b/src/server/hot_reload.rs @@ -0,0 +1,174 @@ +use axum::{ + extract::{ws::Message, Extension, TypedHeader, WebSocketUpgrade}, + response::IntoResponse, +}; + +use std::{path::PathBuf, sync::Arc}; + +pub use crate::hot_reload::{find_rsx, DiffResult}; +use crate::CrateConfig; +pub use dioxus_rsx_interpreter::{error::RecompileReason, CodeLocation, SetRsxMessage}; +pub use proc_macro2::TokenStream; +pub use std::collections::HashMap; +pub use std::sync::Mutex; +pub use std::time::SystemTime; +pub use std::{fs, io, path::Path}; +pub use std::{fs::File, io::Read}; +pub use syn::__private::ToTokens; +use tokio::sync::broadcast; + +pub struct HotReloadState { + pub messages: broadcast::Sender, + pub update: broadcast::Sender, + pub last_file_rebuild: Arc>, + pub watcher_config: CrateConfig, +} + +pub struct FileMap { + pub map: HashMap, + pub last_updated_time: std::time::SystemTime, +} + +impl FileMap { + pub fn new(path: PathBuf) -> Self { + fn find_rs_files(root: PathBuf) -> io::Result> { + let mut files = HashMap::new(); + if root.is_dir() { + let mut handles = Vec::new(); + for entry in fs::read_dir(root)? { + if let Ok(entry) = entry { + let path = entry.path(); + handles.push(std::thread::spawn(move || find_rs_files(path))); + } + } + for handle in handles { + files.extend(handle.join().unwrap()?); + } + } else { + if root.extension().map(|s| s.to_str()).flatten() == Some("rs") { + let mut file = File::open(root.clone()).unwrap(); + let mut src = String::new(); + file.read_to_string(&mut src).expect("Unable to read file"); + files.insert(root, src); + } + } + Ok(files) + } + Self { + last_updated_time: SystemTime::now(), + map: find_rs_files(path).unwrap(), + } + } +} + +pub async fn hot_reload_handler( + ws: WebSocketUpgrade, + _: Option>, + Extension(state): Extension>, +) -> impl IntoResponse { + ws.on_upgrade(|mut socket| async move { + log::info!("🔥 Hot Reload WebSocket connected"); + { + log::info!("Searching files for changes since last run..."); + // update any files that changed before the websocket connected. + let mut messages = Vec::new(); + + { + let handle = state.last_file_rebuild.lock().unwrap(); + let update_time = handle.last_updated_time.clone(); + for (k, v) in handle.map.iter() { + let mut file = File::open(k).unwrap(); + if let Ok(md) = file.metadata() { + if let Ok(time) = md.modified() { + if time < update_time { + continue; + } + } + } + let mut new = String::new(); + file.read_to_string(&mut new).expect("Unable to read file"); + if let Ok(new) = syn::parse_file(&new) { + if let Ok(old) = syn::parse_file(&v) { + if let DiffResult::RsxChanged(changed) = find_rsx(&new, &old) { + for (old, new) in changed.into_iter() { + if let Some(hr) = get_min_location( + k.strip_prefix(&state.watcher_config.crate_dir).unwrap(), + old.to_token_stream(), + ) { + let rsx = new.to_string(); + let msg = SetRsxMessage { + location: hr, + new_text: rsx, + }; + messages.push(msg); + } + } + } + } + } + } + } + + for msg in &messages { + if socket + .send(Message::Text(serde_json::to_string(msg).unwrap())) + .await + .is_err() + { + return; + } + } + log::info!("Updated page"); + } + + let mut rx = state.messages.subscribe(); + let hot_reload_handle = tokio::spawn(async move { + loop { + let read_set_rsx = rx.recv(); + let read_err = socket.recv(); + tokio::select! { + err = read_err => { + if let Some(Ok(err)) = err { + if let Message::Text(err) = err { + let error: RecompileReason = serde_json::from_str(&err).unwrap(); + log::error!("{:?}", error); + if state.update.send("reload".to_string()).is_err() { + break; + } + } + } else { + break; + } + }, + set_rsx = read_set_rsx => { + if let Ok(rsx) = set_rsx { + if socket + .send(Message::Text(serde_json::to_string(&rsx).unwrap())) + .await + .is_err() + { + break; + }; + } + } + }; + } + }); + + hot_reload_handle.await.unwrap(); + }) +} + +pub fn get_min_location(path: &Path, ts: TokenStream) -> Option { + ts.into_iter() + .map(|tree| { + let location = tree.span(); + let start = location.start(); + CodeLocation { + file: path.display().to_string(), + line: start.line as u32, + column: start.column as u32 + 1, + } + }) + .min_by(|cl1, cl2| cl1.line.cmp(&cl2.line).then(cl1.column.cmp(&cl2.column))) +} diff --git a/src/server/mod.rs b/src/server/mod.rs index a0bdf24b0..262dbf17d 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -16,19 +16,9 @@ use crate::{builder, serve::Serve, CrateConfig, Result}; use tokio::sync::broadcast; #[cfg(feature = "hot_reload")] -mod hot_reload_improts { - pub use crate::hot_reload::{find_rsx, DiffResult}; - pub use dioxus_rsx_interpreter::{error::RecompileReason, CodeLocation, SetRsxMessage}; - pub use proc_macro2::TokenStream; - pub use std::collections::HashMap; - pub use std::sync::Mutex; - pub use std::time::SystemTime; - pub use std::{fs, io, path::Path}; - pub use std::{fs::File, io::Read}; - pub use syn::__private::ToTokens; -} +mod hot_reload; #[cfg(feature = "hot_reload")] -use hot_reload_improts::*; +use hot_reload::*; struct WsReloadState { update: broadcast::Sender, @@ -38,76 +28,24 @@ struct WsReloadState { } #[cfg(feature = "hot_reload")] -struct HotReloadState { - messages: broadcast::Sender, - update: broadcast::Sender, - last_file_rebuild: Arc>, - watcher_config: CrateConfig, -} - -#[cfg(feature = "hot_reload")] -struct FileMap { - map: HashMap, - last_updated_time: std::time::SystemTime, -} - -#[cfg(feature = "hot_reload")] -impl FileMap { - fn new(path: PathBuf) -> Self { - fn find_rs_files(root: PathBuf) -> io::Result> { - let mut files = HashMap::new(); - if root.is_dir() { - let mut handles = Vec::new(); - for entry in fs::read_dir(root)? { - if let Ok(entry) = entry { - let path = entry.path(); - handles.push(std::thread::spawn(move || find_rs_files(path))); - } - } - for handle in handles { - files.extend(handle.join().unwrap()?); - } - } else { - if root.extension().map(|s| s.to_str()).flatten() == Some("rs") { - let mut file = File::open(root.clone()).unwrap(); - let mut src = String::new(); - file.read_to_string(&mut src).expect("Unable to read file"); - files.insert(root, src); - } - } - Ok(files) - } - Self { - last_updated_time: SystemTime::now(), - map: find_rs_files(path).unwrap(), - } - } -} - pub async fn startup(config: CrateConfig) -> Result<()> { log::info!("🚀 Starting development server..."); let dist_path = config.out_dir.clone(); - let (reload_tx, _) = broadcast::channel(100); - - #[cfg(feature = "hot_reload")] let last_file_rebuild = Arc::new(Mutex::new(FileMap::new(config.crate_dir.clone()))); - #[cfg(feature = "hot_reload")] let hot_reload_tx = broadcast::channel(100).0; - #[cfg(feature = "hot_reload")] let hot_reload_state = Arc::new(HotReloadState { messages: hot_reload_tx.clone(), update: reload_tx.clone(), last_file_rebuild: last_file_rebuild.clone(), watcher_config: config.clone(), }); - #[cfg(feature = "hot_reload")] - let crate_dir = config.crate_dir.clone(); + let crate_dir = config.crate_dir.clone(); let ws_reload_state = Arc::new(WsReloadState { update: reload_tx.clone(), - #[cfg(feature = "hot_reload")] + last_file_rebuild: last_file_rebuild.clone(), watcher_config: config.clone(), }); @@ -125,63 +63,49 @@ pub async fn startup(config: CrateConfig) -> Result<()> { let mut watcher = RecommendedWatcher::new(move |evt: notify::Result| { if let Ok(evt) = evt { - if let notify::EventKind::Modify(_) = evt.kind { - #[cfg(feature = "hot_reload")] - { - for path in evt.paths { - let mut file = File::open(path.clone()).unwrap(); - if path.extension().map(|p| p.to_str()).flatten() != Some("rs") { - continue; - } - let mut src = String::new(); - file.read_to_string(&mut src).expect("Unable to read file"); - if src.is_empty() { - continue; - } - if let Ok(syntax) = syn::parse_file(&src) { - let mut last_file_rebuild = last_file_rebuild.lock().unwrap(); - if let Some(old_str) = last_file_rebuild.map.get(&path) { - if let Ok(old) = syn::parse_file(&old_str) { - match find_rsx(&syntax, &old) { - DiffResult::CodeChanged => { - log::info!("reload required"); - if chrono::Local::now().timestamp() > last_update_time { - let _ = reload_tx.send("reload".into()); - last_update_time = chrono::Local::now().timestamp(); - } - } - DiffResult::RsxChanged(changed) => { - log::info!("reloading rsx"); - for (old, new) in changed.into_iter() { - if let Some(hr) = get_min_location( - &path - .strip_prefix(&crate_dir) - .unwrap() - .to_path_buf(), - old.to_token_stream(), - ) { - let rsx = new.to_string(); - let _ = hot_reload_tx.send(SetRsxMessage { - location: hr, - new_text: rsx, - }); - } - } + for path in evt.paths { + let mut file = File::open(path.clone()).unwrap(); + if path.extension().map(|p| p.to_str()).flatten() != Some("rs") { + continue; + } + let mut src = String::new(); + file.read_to_string(&mut src).expect("Unable to read file"); + if src.is_empty() { + continue; + } + // find changes to the rsx in the file + if let Ok(syntax) = syn::parse_file(&src) { + let mut last_file_rebuild = last_file_rebuild.lock().unwrap(); + if let Some(old_str) = last_file_rebuild.map.get(&path) { + if let Ok(old) = syn::parse_file(&old_str) { + match find_rsx(&syntax, &old) { + DiffResult::CodeChanged => { + log::info!("reload required"); + if chrono::Local::now().timestamp() > last_update_time { + let _ = reload_tx.send("reload".into()); + last_update_time = chrono::Local::now().timestamp(); + } + } + DiffResult::RsxChanged(changed) => { + log::info!("reloading rsx"); + for (old, new) in changed.into_iter() { + if let Some(hr) = get_min_location( + &path.strip_prefix(&crate_dir).unwrap().to_path_buf(), + old.to_token_stream(), + ) { + let rsx = new.to_string(); + let _ = hot_reload_tx.send(SetRsxMessage { + location: hr, + new_text: rsx, + }); } } } - } else { - *last_file_rebuild = FileMap::new(crate_dir.clone()); } } - } - } - #[cfg(not(feature = "hot_reload"))] - { - log::info!("reload required"); - if chrono::Local::now().timestamp() > last_update_time { - let _ = reload_tx.send("reload".into()); - last_update_time = chrono::Local::now().timestamp(); + } else { + // if this is a new file, rebuild the project + *last_file_rebuild = FileMap::new(crate_dir.clone()); } } } @@ -250,13 +174,112 @@ pub async fn startup(config: CrateConfig) -> Result<()> { }), ); - #[cfg(feature = "hot_reload")] - let router = router.route("/_dioxus/hot_reload", get(hot_reload_handler)); + let router = router + .route("/_dioxus/hot_reload", get(hot_reload_handler)) + .layer(Extension(ws_reload_state)) + .layer(Extension(hot_reload_state)); - let router = router.layer(Extension(ws_reload_state)); + axum::Server::bind(&format!("0.0.0.0:{}", port).parse().unwrap()) + .serve(router.into_make_service()) + .await?; - #[cfg(feature = "hot_reload")] - let router = router.layer(Extension(hot_reload_state)); + Ok(()) +} + +#[cfg(not(feature = "hot_reload"))] +pub async fn startup(config: CrateConfig) -> Result<()> { + log::info!("🚀 Starting development server..."); + + let dist_path = config.out_dir.clone(); + + let (reload_tx, _) = broadcast::channel(100); + + let ws_reload_state = Arc::new(WsReloadState { + update: reload_tx.clone(), + watcher_config: config.clone(), + }); + + let mut last_update_time = chrono::Local::now().timestamp(); + + // file watcher: check file change + let allow_watch_path = config + .dioxus_config + .web + .watcher + .watch_path + .clone() + .unwrap_or_else(|| vec![PathBuf::from("src")]); + + let mut watcher = RecommendedWatcher::new(move |_: notify::Result| { + log::info!("reload required"); + if chrono::Local::now().timestamp() > last_update_time { + let _ = reload_tx.send("reload".into()); + last_update_time = chrono::Local::now().timestamp(); + } + }) + .unwrap(); + + for sub_path in allow_watch_path { + watcher + .watch( + &config.crate_dir.join(sub_path), + notify::RecursiveMode::Recursive, + ) + .unwrap(); + } + + // start serve dev-server at 0.0.0.0:8080 + let port = "8080"; + log::info!("📡 Dev-Server is started at: http://127.0.0.1:{}/", port); + + let file_service_config = config.clone(); + let file_service = ServiceBuilder::new() + .and_then( + |response: Response| async move { + let response = if file_service_config + .dioxus_config + .web + .watcher + .index_on_404 + .unwrap_or(false) + && response.status() == StatusCode::NOT_FOUND + { + let body = Full::from( + // TODO: Cache/memoize this. + std::fs::read_to_string( + file_service_config + .crate_dir + .join(file_service_config.out_dir) + .join("index.html"), + ) + .ok() + .unwrap(), + ) + .map_err(|err| match err {}) + .boxed(); + Response::builder() + .status(StatusCode::OK) + .body(body) + .unwrap() + } else { + response.map(|body| body.boxed()) + }; + Ok(response) + }, + ) + .service(ServeDir::new((&config.crate_dir).join(&dist_path))); + + let router = Router::new() + .route("/_dioxus/ws", get(ws_handler)) + .fallback( + get_service(file_service).handle_error(|error: std::io::Error| async move { + ( + StatusCode::INTERNAL_SERVER_ERROR, + format!("Unhandled internal error: {}", error), + ) + }), + ) + .layer(Extension(ws_reload_state)); axum::Server::bind(&format!("0.0.0.0:{}", port).parse().unwrap()) .serve(router.into_make_service()) @@ -311,117 +334,3 @@ async fn ws_handler( reload_watcher.await.unwrap(); }) } - -#[cfg(feature = "hot_reload")] -async fn hot_reload_handler( - ws: WebSocketUpgrade, - _: Option>, - Extension(state): Extension>, -) -> impl IntoResponse { - ws.on_upgrade(|mut socket| async move { - log::info!("🔥 Hot Reload WebSocket connected"); - { - log::info!("Searching files for changes since last run..."); - // update any files that changed before the websocket connected. - let mut messages = Vec::new(); - - { - let handle = state.last_file_rebuild.lock().unwrap(); - let update_time = handle.last_updated_time.clone(); - for (k, v) in handle.map.iter() { - let mut file = File::open(k).unwrap(); - if let Ok(md) = file.metadata() { - if let Ok(time) = md.modified() { - if time < update_time { - continue; - } - } - } - let mut new = String::new(); - file.read_to_string(&mut new).expect("Unable to read file"); - if let Ok(new) = syn::parse_file(&new) { - if let Ok(old) = syn::parse_file(&v) { - if let DiffResult::RsxChanged(changed) = find_rsx(&new, &old) { - for (old, new) in changed.into_iter() { - if let Some(hr) = get_min_location( - k.strip_prefix(&state.watcher_config.crate_dir).unwrap(), - old.to_token_stream(), - ) { - let rsx = new.to_string(); - let msg = SetRsxMessage { - location: hr, - new_text: rsx, - }; - messages.push(msg); - } - } - } - } - } - } - } - - for msg in &messages { - if socket - .send(Message::Text(serde_json::to_string(msg).unwrap())) - .await - .is_err() - { - return; - } - } - log::info!("Updated page"); - } - - let mut rx = state.messages.subscribe(); - let hot_reload_handle = tokio::spawn(async move { - loop { - let read_set_rsx = rx.recv(); - let read_err = socket.recv(); - tokio::select! { - err = read_err => { - if let Some(Ok(err)) = err { - if let Message::Text(err) = err { - let error: RecompileReason = serde_json::from_str(&err).unwrap(); - log::error!("{:?}", error); - if state.update.send("reload".to_string()).is_err() { - break; - } - } - } else { - break; - } - }, - set_rsx = read_set_rsx => { - if let Ok(rsx) = set_rsx { - if socket - .send(Message::Text(serde_json::to_string(&rsx).unwrap())) - .await - .is_err() - { - break; - }; - } - } - }; - } - }); - - hot_reload_handle.await.unwrap(); - }) -} - -#[cfg(feature = "hot_reload")] -fn get_min_location(path: &Path, ts: TokenStream) -> Option { - ts.into_iter() - .map(|tree| { - let location = tree.span(); - let start = location.start(); - CodeLocation { - file: path.display().to_string(), - line: start.line as u32, - column: start.column as u32 + 1, - } - }) - .min_by(|cl1, cl2| cl1.line.cmp(&cl2.line).then(cl1.column.cmp(&cl2.column))) -} From fb7ea5915b303fe79682a299bbb6bdc3907e2e82 Mon Sep 17 00:00:00 2001 From: Evan Almloff Date: Tue, 14 Jun 2022 09:47:16 -0500 Subject: [PATCH 042/170] use cli flag instead of feature flag --- Cargo.toml | 8 +++----- src/cli/cfg.rs | 5 +++++ src/cli/serve/mod.rs | 4 +++- src/config.rs | 8 ++++++++ src/lib.rs | 1 - src/server/mod.rs | 26 +++++++++++++++----------- 6 files changed, 34 insertions(+), 18 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 770fd7b1d..7f1223520 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,12 +46,10 @@ flate2 = "1.0.22" tar = "0.4.38" tower = "0.4.12" -syn = { version = "1.0", optional = true } -dioxus-rsx-interpreter = { path = "../dioxus/packages/rsx_interpreter", optional = true } -proc-macro2 = { version = "1.0", features = ["span-locations"], optional = true } +syn = { version = "1.0" } +dioxus-rsx-interpreter = { path = "../dioxus/packages/rsx_interpreter" } +proc-macro2 = { version = "1.0", features = ["span-locations"] } -[features] -hot_reload = ["dioxus-rsx-interpreter", "proc-macro2", "syn"] [[bin]] path = "src/main.rs" diff --git a/src/cli/cfg.rs b/src/cli/cfg.rs index f5ee45b87..3f284cbbf 100644 --- a/src/cli/cfg.rs +++ b/src/cli/cfg.rs @@ -39,6 +39,11 @@ pub struct ConfigOptsServe { /// Build platform: support Web & Desktop [default: "default_platform"] #[clap(long)] pub platform: Option, + + /// Build with hot reloading rsx [default: false] + #[clap(long)] + #[serde(default)] + pub hot_reload: bool, } /// Ensure the given value for `--public-url` is formatted correctly. diff --git a/src/cli/serve/mod.rs b/src/cli/serve/mod.rs index 85bd92c74..391e646d4 100644 --- a/src/cli/serve/mod.rs +++ b/src/cli/serve/mod.rs @@ -18,7 +18,9 @@ impl Serve { let mut crate_config = crate::CrateConfig::new()?; // change the relase state. - crate_config.with_release(self.serve.release); + crate_config + .with_release(self.serve.release) + .with_hot_reload(self.serve.hot_reload); if self.serve.example.is_some() { crate_config.as_example(self.serve.example.unwrap()); diff --git a/src/config.rs b/src/config.rs index 783c72ccd..aa2a03440 100644 --- a/src/config.rs +++ b/src/config.rs @@ -114,6 +114,7 @@ pub struct CrateConfig { pub executable: ExecutableType, pub dioxus_config: DioxusConfig, pub release: bool, + pub hot_reload: bool, } #[derive(Debug, Clone)] @@ -162,6 +163,7 @@ impl CrateConfig { let executable = ExecutableType::Binary(output_filename); let release = false; + let hot_reload = false; Ok(Self { out_dir, @@ -173,6 +175,7 @@ impl CrateConfig { executable, release, dioxus_config, + hot_reload, }) } @@ -186,6 +189,11 @@ impl CrateConfig { self } + pub fn with_hot_reload(&mut self, hot_reload: bool) -> &mut Self { + self.hot_reload = hot_reload; + self + } + // pub fn with_build_options(&mut self, options: &BuildOptions) { // if let Some(name) = &options.example { // self.as_example(name.clone()); diff --git a/src/lib.rs b/src/lib.rs index 683b7251a..6d009c18c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -19,5 +19,4 @@ pub use error::*; pub mod logging; pub use logging::*; -#[cfg(feature = "hot_reload")] pub mod hot_reload; diff --git a/src/server/mod.rs b/src/server/mod.rs index 262dbf17d..8a98fd9d9 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -15,20 +15,24 @@ use tower_http::services::fs::{ServeDir, ServeFileSystemResponseBody}; use crate::{builder, serve::Serve, CrateConfig, Result}; use tokio::sync::broadcast; -#[cfg(feature = "hot_reload")] mod hot_reload; -#[cfg(feature = "hot_reload")] use hot_reload::*; struct WsReloadState { update: broadcast::Sender, - #[cfg(feature = "hot_reload")] - last_file_rebuild: Arc>, + last_file_rebuild: Option>>, watcher_config: CrateConfig, } -#[cfg(feature = "hot_reload")] pub async fn startup(config: CrateConfig) -> Result<()> { + if config.hot_reload { + startup_hot_reload(config).await + } else { + startup_default(config).await + } +} + +pub async fn startup_hot_reload(config: CrateConfig) -> Result<()> { log::info!("🚀 Starting development server..."); let dist_path = config.out_dir.clone(); @@ -46,7 +50,7 @@ pub async fn startup(config: CrateConfig) -> Result<()> { let ws_reload_state = Arc::new(WsReloadState { update: reload_tx.clone(), - last_file_rebuild: last_file_rebuild.clone(), + last_file_rebuild: Some(last_file_rebuild.clone()), watcher_config: config.clone(), }); @@ -186,8 +190,7 @@ pub async fn startup(config: CrateConfig) -> Result<()> { Ok(()) } -#[cfg(not(feature = "hot_reload"))] -pub async fn startup(config: CrateConfig) -> Result<()> { +pub async fn startup_default(config: CrateConfig) -> Result<()> { log::info!("🚀 Starting development server..."); let dist_path = config.out_dir.clone(); @@ -196,6 +199,8 @@ pub async fn startup(config: CrateConfig) -> Result<()> { let ws_reload_state = Arc::new(WsReloadState { update: reload_tx.clone(), + + last_file_rebuild: None, watcher_config: config.clone(), }); @@ -313,9 +318,8 @@ async fn ws_handler( { let _ = Serve::regen_dev_page(&state.watcher_config); } - #[cfg(feature = "hot_reload")] - { - let mut write = state.last_file_rebuild.lock().unwrap(); + if let Some(file_map) = &state.last_file_rebuild { + let mut write = file_map.lock().unwrap(); *write = FileMap::new(state.watcher_config.crate_dir.clone()); } } From b0f987aa106994e95af8e75765ce12321684821b Mon Sep 17 00:00:00 2001 From: Demonthos <66571940+Demonthos@users.noreply.github.com> Date: Wed, 15 Jun 2022 12:55:25 -0500 Subject: [PATCH 043/170] accept all interperter errors --- src/server/hot_reload.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/server/hot_reload.rs b/src/server/hot_reload.rs index 661d249e6..a9f51abe7 100644 --- a/src/server/hot_reload.rs +++ b/src/server/hot_reload.rs @@ -7,7 +7,7 @@ use std::{path::PathBuf, sync::Arc}; pub use crate::hot_reload::{find_rsx, DiffResult}; use crate::CrateConfig; -pub use dioxus_rsx_interpreter::{error::RecompileReason, CodeLocation, SetRsxMessage}; +pub use dioxus_rsx_interpreter::{error::Error, CodeLocation, SetRsxMessage}; pub use proc_macro2::TokenStream; pub use std::collections::HashMap; pub use std::sync::Mutex; @@ -130,7 +130,7 @@ pub async fn hot_reload_handler( err = read_err => { if let Some(Ok(err)) = err { if let Message::Text(err) = err { - let error: RecompileReason = serde_json::from_str(&err).unwrap(); + let error: Error = serde_json::from_str(&err).unwrap(); log::error!("{:?}", error); if state.update.send("reload".to_string()).is_err() { break; From 8ff50df3a5dc14b90b15fd84122a12436326144a Mon Sep 17 00:00:00 2001 From: Evan Almloff Date: Wed, 15 Jun 2022 13:29:35 -0500 Subject: [PATCH 044/170] preserve whitespace in rsx --- src/server/hot_reload.rs | 37 ++++++++++++++++--------------------- src/server/mod.rs | 29 ++++++++++++++++++++++------- 2 files changed, 38 insertions(+), 28 deletions(-) diff --git a/src/server/hot_reload.rs b/src/server/hot_reload.rs index a9f51abe7..f79a7a50e 100644 --- a/src/server/hot_reload.rs +++ b/src/server/hot_reload.rs @@ -15,6 +15,7 @@ pub use std::time::SystemTime; pub use std::{fs, io, path::Path}; pub use std::{fs::File, io::Read}; pub use syn::__private::ToTokens; +use syn::spanned::Spanned; use tokio::sync::broadcast; pub struct HotReloadState { @@ -91,17 +92,16 @@ pub async fn hot_reload_handler( if let Ok(old) = syn::parse_file(&v) { if let DiffResult::RsxChanged(changed) = find_rsx(&new, &old) { for (old, new) in changed.into_iter() { - if let Some(hr) = get_min_location( + let hr = get_location( k.strip_prefix(&state.watcher_config.crate_dir).unwrap(), old.to_token_stream(), - ) { - let rsx = new.to_string(); - let msg = SetRsxMessage { - location: hr, - new_text: rsx, - }; - messages.push(msg); - } + ); + let rsx = new.to_string(); + let msg = SetRsxMessage { + location: hr, + new_text: rsx, + }; + messages.push(msg); } } } @@ -159,16 +159,11 @@ pub async fn hot_reload_handler( }) } -pub fn get_min_location(path: &Path, ts: TokenStream) -> Option { - ts.into_iter() - .map(|tree| { - let location = tree.span(); - let start = location.start(); - CodeLocation { - file: path.display().to_string(), - line: start.line as u32, - column: start.column as u32 + 1, - } - }) - .min_by(|cl1, cl2| cl1.line.cmp(&cl2.line).then(cl1.column.cmp(&cl2.column))) +pub fn get_location(path: &Path, ts: TokenStream) -> CodeLocation { + let span = ts.span().start(); + CodeLocation { + file: path.display().to_string(), + line: span.line as u32, + column: span.column as u32 + 1, + } } diff --git a/src/server/mod.rs b/src/server/mod.rs index 8a98fd9d9..3397beac6 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -7,6 +7,7 @@ use axum::{ Router, }; use notify::{RecommendedWatcher, Watcher}; +use syn::spanned::Spanned; use std::{path::PathBuf, sync::Arc}; use tower::ServiceBuilder; @@ -93,16 +94,30 @@ pub async fn startup_hot_reload(config: CrateConfig) -> Result<()> { DiffResult::RsxChanged(changed) => { log::info!("reloading rsx"); for (old, new) in changed.into_iter() { - if let Some(hr) = get_min_location( + let hr = get_location( &path.strip_prefix(&crate_dir).unwrap().to_path_buf(), old.to_token_stream(), - ) { - let rsx = new.to_string(); - let _ = hot_reload_tx.send(SetRsxMessage { - location: hr, - new_text: rsx, - }); + ); + // get the original source code to preserve whitespace + let span = new.span(); + let start = span.start(); + let end = span.end(); + let mut lines: Vec<_> = src + .lines() + .skip(start.line - 1) + .take(end.line - start.line + 1) + .collect(); + if let Some(first) = lines.first_mut() { + *first = first.split_at(start.column).1; } + if let Some(last) = lines.last_mut() { + *last = last.split_at(end.column).0; + } + let rsx = lines.join("\n"); + let _ = hot_reload_tx.send(SetRsxMessage { + location: hr, + new_text: rsx, + }); } } } From edc31dfc031025a6a7893da39fe3278fa053d2c7 Mon Sep 17 00:00:00 2001 From: Evan Almloff Date: Wed, 15 Jun 2022 13:58:24 -0500 Subject: [PATCH 045/170] better error messages --- src/server/hot_reload.rs | 45 +++++++++++++++++++++++++++++----------- 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/src/server/hot_reload.rs b/src/server/hot_reload.rs index f79a7a50e..2011b8958 100644 --- a/src/server/hot_reload.rs +++ b/src/server/hot_reload.rs @@ -86,22 +86,36 @@ pub async fn hot_reload_handler( } } } - let mut new = String::new(); - file.read_to_string(&mut new).expect("Unable to read file"); - if let Ok(new) = syn::parse_file(&new) { - if let Ok(old) = syn::parse_file(&v) { - if let DiffResult::RsxChanged(changed) = find_rsx(&new, &old) { + let mut new_str = String::new(); + file.read_to_string(&mut new_str).expect("Unable to read file"); + if let Ok(new_file) = syn::parse_file(&new_str) { + if let Ok(old_file) = syn::parse_file(&v) { + if let DiffResult::RsxChanged(changed) = find_rsx(&new_file, &old_file) { for (old, new) in changed.into_iter() { let hr = get_location( k.strip_prefix(&state.watcher_config.crate_dir).unwrap(), old.to_token_stream(), ); - let rsx = new.to_string(); - let msg = SetRsxMessage { + // get the original source code to preserve whitespace + let span = new.span(); + let start = span.start(); + let end = span.end(); + let mut lines: Vec<_> = new_str + .lines() + .skip(start.line - 1) + .take(end.line - start.line + 1) + .collect(); + if let Some(first) = lines.first_mut() { + *first = first.split_at(start.column).1; + } + if let Some(last) = lines.last_mut() { + *last = last.split_at(end.column).0; + } + let rsx = lines.join("\n"); + messages.push(SetRsxMessage { location: hr, new_text: rsx, - }; - messages.push(msg); + }); } } } @@ -131,9 +145,16 @@ pub async fn hot_reload_handler( if let Some(Ok(err)) = err { if let Message::Text(err) = err { let error: Error = serde_json::from_str(&err).unwrap(); - log::error!("{:?}", error); - if state.update.send("reload".to_string()).is_err() { - break; + match error{ + Error::ParseError(parse_error) => { + log::error!("parse error:\n--> at {}:{}:{}\n\t{:?}", parse_error.location.file, parse_error.location.line, parse_error.location.column, parse_error.message); + }, + Error::RecompileRequiredError(reason) => { + log::info!("{:?}", reason); + if state.update.send("reload".to_string()).is_err() { + break; + } + } } } } else { From 8e33b8e02711cc4108f4d05d2cf95d647ad697d7 Mon Sep 17 00:00:00 2001 From: Evan Almloff Date: Thu, 16 Jun 2022 09:11:02 -0500 Subject: [PATCH 046/170] improve speed when reloading the site --- src/server/hot_reload.rs | 91 +++++++++++++++++++++-------- src/server/mod.rs | 120 +++++++++++++++++++++------------------ 2 files changed, 132 insertions(+), 79 deletions(-) diff --git a/src/server/hot_reload.rs b/src/server/hot_reload.rs index 2011b8958..14f9ffbc6 100644 --- a/src/server/hot_reload.rs +++ b/src/server/hot_reload.rs @@ -2,12 +2,13 @@ use axum::{ extract::{ws::Message, Extension, TypedHeader, WebSocketUpgrade}, response::IntoResponse, }; +use dioxus_rsx_interpreter::SetRsxMessage; use std::{path::PathBuf, sync::Arc}; pub use crate::hot_reload::{find_rsx, DiffResult}; use crate::CrateConfig; -pub use dioxus_rsx_interpreter::{error::Error, CodeLocation, SetRsxMessage}; +pub use dioxus_rsx_interpreter::{error::Error, CodeLocation, SetManyRsxMessage}; pub use proc_macro2::TokenStream; pub use std::collections::HashMap; pub use std::sync::Mutex; @@ -19,7 +20,7 @@ use syn::spanned::Spanned; use tokio::sync::broadcast; pub struct HotReloadState { - pub messages: broadcast::Sender, + pub messages: broadcast::Sender, pub update: broadcast::Sender, pub last_file_rebuild: Arc>, pub watcher_config: CrateConfig, @@ -32,32 +33,76 @@ pub struct FileMap { impl FileMap { pub fn new(path: PathBuf) -> Self { + log::info!("Searching files for changes since last compile..."); fn find_rs_files(root: PathBuf) -> io::Result> { let mut files = HashMap::new(); if root.is_dir() { - let mut handles = Vec::new(); for entry in fs::read_dir(root)? { if let Ok(entry) = entry { let path = entry.path(); - handles.push(std::thread::spawn(move || find_rs_files(path))); + files.extend(find_rs_files(path)?); } } - for handle in handles { - files.extend(handle.join().unwrap()?); - } } else { if root.extension().map(|s| s.to_str()).flatten() == Some("rs") { - let mut file = File::open(root.clone()).unwrap(); - let mut src = String::new(); - file.read_to_string(&mut src).expect("Unable to read file"); - files.insert(root, src); + if let Ok(mut file) = File::open(root.clone()) { + let mut src = String::new(); + file.read_to_string(&mut src).expect("Unable to read file"); + files.insert(root, src); + } } } Ok(files) } - Self { - last_updated_time: SystemTime::now(), + + let last_updated_time = SystemTime::now(); + let result = Self { + last_updated_time, map: find_rs_files(path).unwrap(), + }; + log::info!("Files updated"); + result + } + + pub fn update(&mut self, path: PathBuf) { + log::info!("Updating files that changed since last compile..."); + self.last_updated_time = SystemTime::now(); + self.update_inner(path); + log::info!("Files updated"); + } + + fn update_inner(&mut self, path: PathBuf) { + if path.is_dir() { + if let Ok(files) = fs::read_dir(path) { + for entry in files { + if let Ok(entry) = entry { + if let Ok(md) = entry.metadata() { + if let Ok(time) = md.modified() { + if time < self.last_updated_time { + return; + } + } + } + let path = entry.path(); + self.update(path); + } + } + } + } else { + if path.extension().map(|s| s.to_str()).flatten() == Some("rs") { + if let Ok(mut file) = File::open(path.clone()) { + if let Ok(md) = file.metadata() { + if let Ok(time) = md.modified() { + if time < self.last_updated_time { + return; + } + } + } + let mut src = String::new(); + file.read_to_string(&mut src).expect("Unable to read file"); + self.map.insert(path, src); + } + } } } } @@ -70,7 +115,6 @@ pub async fn hot_reload_handler( ws.on_upgrade(|mut socket| async move { log::info!("🔥 Hot Reload WebSocket connected"); { - log::info!("Searching files for changes since last run..."); // update any files that changed before the websocket connected. let mut messages = Vec::new(); @@ -123,16 +167,14 @@ pub async fn hot_reload_handler( } } - for msg in &messages { - if socket - .send(Message::Text(serde_json::to_string(msg).unwrap())) - .await - .is_err() - { - return; - } + let msg = SetManyRsxMessage(messages); + if socket + .send(Message::Text(serde_json::to_string(&msg).unwrap())) + .await + .is_err() + { + return; } - log::info!("Updated page"); } let mut rx = state.messages.subscribe(); @@ -149,8 +191,7 @@ pub async fn hot_reload_handler( Error::ParseError(parse_error) => { log::error!("parse error:\n--> at {}:{}:{}\n\t{:?}", parse_error.location.file, parse_error.location.line, parse_error.location.column, parse_error.message); }, - Error::RecompileRequiredError(reason) => { - log::info!("{:?}", reason); + Error::RecompileRequiredError(_) => { if state.update.send("reload".to_string()).is_err() { break; } diff --git a/src/server/mod.rs b/src/server/mod.rs index 3397beac6..19791fd79 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -6,6 +6,7 @@ use axum::{ routing::{get, get_service}, Router, }; +use dioxus_rsx_interpreter::SetRsxMessage; use notify::{RecommendedWatcher, Watcher}; use syn::spanned::Spanned; @@ -67,67 +68,75 @@ pub async fn startup_hot_reload(config: CrateConfig) -> Result<()> { .unwrap_or_else(|| vec![PathBuf::from("src")]); let mut watcher = RecommendedWatcher::new(move |evt: notify::Result| { - if let Ok(evt) = evt { - for path in evt.paths { - let mut file = File::open(path.clone()).unwrap(); - if path.extension().map(|p| p.to_str()).flatten() != Some("rs") { - continue; - } - let mut src = String::new(); - file.read_to_string(&mut src).expect("Unable to read file"); - if src.is_empty() { - continue; - } - // find changes to the rsx in the file - if let Ok(syntax) = syn::parse_file(&src) { - let mut last_file_rebuild = last_file_rebuild.lock().unwrap(); - if let Some(old_str) = last_file_rebuild.map.get(&path) { - if let Ok(old) = syn::parse_file(&old_str) { - match find_rsx(&syntax, &old) { - DiffResult::CodeChanged => { - log::info!("reload required"); - if chrono::Local::now().timestamp() > last_update_time { - let _ = reload_tx.send("reload".into()); - last_update_time = chrono::Local::now().timestamp(); + if chrono::Local::now().timestamp() > last_update_time { + if let Ok(evt) = evt { + let mut messages = Vec::new(); + for path in evt.paths { + let mut file = File::open(path.clone()).unwrap(); + if path.extension().map(|p| p.to_str()).flatten() != Some("rs") { + continue; + } + let mut src = String::new(); + file.read_to_string(&mut src).expect("Unable to read file"); + if src.is_empty() { + continue; + } + // find changes to the rsx in the file + if let Ok(syntax) = syn::parse_file(&src) { + let mut last_file_rebuild = last_file_rebuild.lock().unwrap(); + if let Some(old_str) = last_file_rebuild.map.get(&path) { + if let Ok(old) = syn::parse_file(&old_str) { + match find_rsx(&syntax, &old) { + DiffResult::CodeChanged => { + log::info!("reload required"); + let _ = reload_tx.send("reload time".into()); + break; } - } - DiffResult::RsxChanged(changed) => { - log::info!("reloading rsx"); - for (old, new) in changed.into_iter() { - let hr = get_location( - &path.strip_prefix(&crate_dir).unwrap().to_path_buf(), - old.to_token_stream(), - ); - // get the original source code to preserve whitespace - let span = new.span(); - let start = span.start(); - let end = span.end(); - let mut lines: Vec<_> = src - .lines() - .skip(start.line - 1) - .take(end.line - start.line + 1) - .collect(); - if let Some(first) = lines.first_mut() { - *first = first.split_at(start.column).1; + DiffResult::RsxChanged(changed) => { + log::info!("reloading rsx"); + for (old, new) in changed.into_iter() { + let hr = get_location( + &path + .strip_prefix(&crate_dir) + .unwrap() + .to_path_buf(), + old.to_token_stream(), + ); + // get the original source code to preserve whitespace + let span = new.span(); + let start = span.start(); + let end = span.end(); + let mut lines: Vec<_> = src + .lines() + .skip(start.line - 1) + .take(end.line - start.line + 1) + .collect(); + if let Some(first) = lines.first_mut() { + *first = first.split_at(start.column).1; + } + if let Some(last) = lines.last_mut() { + *last = last.split_at(end.column).0; + } + let rsx = lines.join("\n"); + messages.push(SetRsxMessage { + location: hr, + new_text: rsx, + }); } - if let Some(last) = lines.last_mut() { - *last = last.split_at(end.column).0; - } - let rsx = lines.join("\n"); - let _ = hot_reload_tx.send(SetRsxMessage { - location: hr, - new_text: rsx, - }); } } } + } else { + // if this is a new file, rebuild the project + *last_file_rebuild = FileMap::new(crate_dir.clone()); } - } else { - // if this is a new file, rebuild the project - *last_file_rebuild = FileMap::new(crate_dir.clone()); } } + if !messages.is_empty() { + let _ = hot_reload_tx.send(SetManyRsxMessage(messages)); + } } + last_update_time = chrono::Local::now().timestamp(); } }) .unwrap(); @@ -313,7 +322,7 @@ async fn ws_handler( _: Option>, Extension(state): Extension>, ) -> impl IntoResponse { - ws.on_upgrade(|mut socket| async move { + ws.max_send_queue(1).on_upgrade(|mut socket| async move { let mut rx = state.update.subscribe(); let reload_watcher = tokio::spawn(async move { loop { @@ -335,7 +344,7 @@ async fn ws_handler( } if let Some(file_map) = &state.last_file_rebuild { let mut write = file_map.lock().unwrap(); - *write = FileMap::new(state.watcher_config.crate_dir.clone()); + write.update(state.watcher_config.crate_dir.clone()); } } // ignore the error @@ -346,6 +355,9 @@ async fn ws_handler( { break; } + + // flush the errors after recompling + rx = rx.resubscribe(); } } }); From 22e40c6bc1f35f0a3c9a6ec9d225f7c4fe029fff Mon Sep 17 00:00:00 2001 From: Evan Almloff Date: Thu, 16 Jun 2022 10:21:28 -0500 Subject: [PATCH 047/170] removed debugging messages --- src/server/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/server/mod.rs b/src/server/mod.rs index 19791fd79..bf9299022 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -89,7 +89,7 @@ pub async fn startup_hot_reload(config: CrateConfig) -> Result<()> { match find_rsx(&syntax, &old) { DiffResult::CodeChanged => { log::info!("reload required"); - let _ = reload_tx.send("reload time".into()); + let _ = reload_tx.send("reload".into()); break; } DiffResult::RsxChanged(changed) => { From a79046f36a39a20cc4e43f8e3d83df46e23b4fa5 Mon Sep 17 00:00:00 2001 From: Evan Almloff Date: Thu, 16 Jun 2022 13:13:06 -0500 Subject: [PATCH 048/170] use build manager instead of rebuilding in the ws handler --- src/server/hot_reload.rs | 53 +++--------------- src/server/mod.rs | 115 ++++++++++++++++++++++----------------- 2 files changed, 72 insertions(+), 96 deletions(-) diff --git a/src/server/hot_reload.rs b/src/server/hot_reload.rs index 14f9ffbc6..6a2a58ba0 100644 --- a/src/server/hot_reload.rs +++ b/src/server/hot_reload.rs @@ -6,6 +6,7 @@ use dioxus_rsx_interpreter::SetRsxMessage; use std::{path::PathBuf, sync::Arc}; +use super::BuildManager; pub use crate::hot_reload::{find_rsx, DiffResult}; use crate::CrateConfig; pub use dioxus_rsx_interpreter::{error::Error, CodeLocation, SetManyRsxMessage}; @@ -21,7 +22,7 @@ use tokio::sync::broadcast; pub struct HotReloadState { pub messages: broadcast::Sender, - pub update: broadcast::Sender, + pub build_manager: Arc, pub last_file_rebuild: Arc>, pub watcher_config: CrateConfig, } @@ -63,48 +64,6 @@ impl FileMap { log::info!("Files updated"); result } - - pub fn update(&mut self, path: PathBuf) { - log::info!("Updating files that changed since last compile..."); - self.last_updated_time = SystemTime::now(); - self.update_inner(path); - log::info!("Files updated"); - } - - fn update_inner(&mut self, path: PathBuf) { - if path.is_dir() { - if let Ok(files) = fs::read_dir(path) { - for entry in files { - if let Ok(entry) = entry { - if let Ok(md) = entry.metadata() { - if let Ok(time) = md.modified() { - if time < self.last_updated_time { - return; - } - } - } - let path = entry.path(); - self.update(path); - } - } - } - } else { - if path.extension().map(|s| s.to_str()).flatten() == Some("rs") { - if let Ok(mut file) = File::open(path.clone()) { - if let Ok(md) = file.metadata() { - if let Ok(time) = md.modified() { - if time < self.last_updated_time { - return; - } - } - } - let mut src = String::new(); - file.read_to_string(&mut src).expect("Unable to read file"); - self.map.insert(path, src); - } - } - } - } } pub async fn hot_reload_handler( @@ -115,10 +74,11 @@ pub async fn hot_reload_handler( ws.on_upgrade(|mut socket| async move { log::info!("🔥 Hot Reload WebSocket connected"); { - // update any files that changed before the websocket connected. + // update any rsx calls that changed before the websocket connected. let mut messages = Vec::new(); { + println!("Finding updates since last reload..."); let handle = state.last_file_rebuild.lock().unwrap(); let update_time = handle.last_updated_time.clone(); for (k, v) in handle.map.iter() { @@ -165,6 +125,7 @@ pub async fn hot_reload_handler( } } } + println!("finished"); } let msg = SetManyRsxMessage(messages); @@ -192,8 +153,8 @@ pub async fn hot_reload_handler( log::error!("parse error:\n--> at {}:{}:{}\n\t{:?}", parse_error.location.file, parse_error.location.line, parse_error.location.column, parse_error.message); }, Error::RecompileRequiredError(_) => { - if state.update.send("reload".to_string()).is_err() { - break; + if let Err(err) = state.build_manager.build(){ + log::error!("{}", err); } } } diff --git a/src/server/mod.rs b/src/server/mod.rs index bf9299022..5742c86ee 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -20,18 +20,43 @@ use tokio::sync::broadcast; mod hot_reload; use hot_reload::*; +pub struct BuildManager { + config: CrateConfig, + reload_tx: broadcast::Sender<()>, +} + +impl BuildManager { + fn build(&self) -> Result<()> { + log::info!("Start to rebuild project..."); + builder::build(&self.config)?; + // change the websocket reload state to true; + // the page will auto-reload. + if self + .config + .dioxus_config + .web + .watcher + .reload_html + .unwrap_or(false) + { + let _ = Serve::regen_dev_page(&self.config); + } + let _ = self.reload_tx.send(()); + Ok(()) + } +} + struct WsReloadState { - update: broadcast::Sender, - last_file_rebuild: Option>>, - watcher_config: CrateConfig, + update: broadcast::Sender<()>, } pub async fn startup(config: CrateConfig) -> Result<()> { if config.hot_reload { - startup_hot_reload(config).await + startup_hot_reload(config).await? } else { - startup_default(config).await + startup_default(config).await? } + Ok(()) } pub async fn startup_hot_reload(config: CrateConfig) -> Result<()> { @@ -40,10 +65,14 @@ pub async fn startup_hot_reload(config: CrateConfig) -> Result<()> { let dist_path = config.out_dir.clone(); let (reload_tx, _) = broadcast::channel(100); let last_file_rebuild = Arc::new(Mutex::new(FileMap::new(config.crate_dir.clone()))); + let build_manager = Arc::new(BuildManager { + config: config.clone(), + reload_tx: reload_tx.clone(), + }); let hot_reload_tx = broadcast::channel(100).0; let hot_reload_state = Arc::new(HotReloadState { messages: hot_reload_tx.clone(), - update: reload_tx.clone(), + build_manager: build_manager.clone(), last_file_rebuild: last_file_rebuild.clone(), watcher_config: config.clone(), }); @@ -51,9 +80,6 @@ pub async fn startup_hot_reload(config: CrateConfig) -> Result<()> { let crate_dir = config.crate_dir.clone(); let ws_reload_state = Arc::new(WsReloadState { update: reload_tx.clone(), - - last_file_rebuild: Some(last_file_rebuild.clone()), - watcher_config: config.clone(), }); let mut last_update_time = chrono::Local::now().timestamp(); @@ -71,6 +97,7 @@ pub async fn startup_hot_reload(config: CrateConfig) -> Result<()> { if chrono::Local::now().timestamp() > last_update_time { if let Ok(evt) = evt { let mut messages = Vec::new(); + let mut needs_rebuild = false; for path in evt.paths { let mut file = File::open(path.clone()).unwrap(); if path.extension().map(|p| p.to_str()).flatten() != Some("rs") { @@ -88,9 +115,8 @@ pub async fn startup_hot_reload(config: CrateConfig) -> Result<()> { if let Ok(old) = syn::parse_file(&old_str) { match find_rsx(&syntax, &old) { DiffResult::CodeChanged => { - log::info!("reload required"); - let _ = reload_tx.send("reload".into()); - break; + needs_rebuild = true; + last_file_rebuild.map.insert(path, src); } DiffResult::RsxChanged(changed) => { log::info!("reloading rsx"); @@ -132,6 +158,12 @@ pub async fn startup_hot_reload(config: CrateConfig) -> Result<()> { } } } + if needs_rebuild { + log::info!("reload required"); + if let Err(err) = build_manager.build() { + log::error!("{}", err); + } + } if !messages.is_empty() { let _ = hot_reload_tx.send(SetManyRsxMessage(messages)); } @@ -221,11 +253,13 @@ pub async fn startup_default(config: CrateConfig) -> Result<()> { let (reload_tx, _) = broadcast::channel(100); + let build_manager = BuildManager { + config: config.clone(), + reload_tx: reload_tx.clone(), + }; + let ws_reload_state = Arc::new(WsReloadState { update: reload_tx.clone(), - - last_file_rebuild: None, - watcher_config: config.clone(), }); let mut last_update_time = chrono::Local::now().timestamp(); @@ -242,8 +276,10 @@ pub async fn startup_default(config: CrateConfig) -> Result<()> { let mut watcher = RecommendedWatcher::new(move |_: notify::Result| { log::info!("reload required"); if chrono::Local::now().timestamp() > last_update_time { - let _ = reload_tx.send("reload".into()); - last_update_time = chrono::Local::now().timestamp(); + match build_manager.build() { + Ok(_) => last_update_time = chrono::Local::now().timestamp(), + Err(e) => log::error!("{}", e), + } } }) .unwrap(); @@ -322,43 +358,22 @@ async fn ws_handler( _: Option>, Extension(state): Extension>, ) -> impl IntoResponse { - ws.max_send_queue(1).on_upgrade(|mut socket| async move { + ws.on_upgrade(|mut socket| async move { let mut rx = state.update.subscribe(); let reload_watcher = tokio::spawn(async move { loop { - let v = rx.recv().await.unwrap(); - if v == "reload" { - log::info!("Start to rebuild project..."); - if builder::build(&state.watcher_config).is_ok() { - // change the websocket reload state to true; - // the page will auto-reload. - if state - .watcher_config - .dioxus_config - .web - .watcher - .reload_html - .unwrap_or(false) - { - let _ = Serve::regen_dev_page(&state.watcher_config); - } - if let Some(file_map) = &state.last_file_rebuild { - let mut write = file_map.lock().unwrap(); - write.update(state.watcher_config.crate_dir.clone()); - } - } - // ignore the error - if socket - .send(Message::Text(String::from("reload"))) - .await - .is_err() - { - break; - } - - // flush the errors after recompling - rx = rx.resubscribe(); + rx.recv().await.unwrap(); + // ignore the error + if socket + .send(Message::Text(String::from("reload"))) + .await + .is_err() + { + break; } + + // flush the errors after recompling + rx = rx.resubscribe(); } }); From 815bdcdf0032a37518ee1611d9b0cd08bd2c79f3 Mon Sep 17 00:00:00 2001 From: Evan Almloff Date: Thu, 16 Jun 2022 13:23:45 -0500 Subject: [PATCH 049/170] clean up logs --- src/server/hot_reload.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/server/hot_reload.rs b/src/server/hot_reload.rs index 6a2a58ba0..a0eb43e08 100644 --- a/src/server/hot_reload.rs +++ b/src/server/hot_reload.rs @@ -78,7 +78,7 @@ pub async fn hot_reload_handler( let mut messages = Vec::new(); { - println!("Finding updates since last reload..."); + log::info!("Finding updates since last compile..."); let handle = state.last_file_rebuild.lock().unwrap(); let update_time = handle.last_updated_time.clone(); for (k, v) in handle.map.iter() { @@ -125,7 +125,7 @@ pub async fn hot_reload_handler( } } } - println!("finished"); + log::info!("finished"); } let msg = SetManyRsxMessage(messages); From 2908e53d1b55d6d5664d1b27046d53966d42bd5e Mon Sep 17 00:00:00 2001 From: Evan Almloff Date: Fri, 17 Jun 2022 14:50:05 -0500 Subject: [PATCH 050/170] add delay before reading the changed file --- src/server/mod.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/server/mod.rs b/src/server/mod.rs index 1eb159ae5..16401aa85 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -95,6 +95,8 @@ pub async fn startup_hot_reload(config: CrateConfig) -> Result<()> { let mut watcher = RecommendedWatcher::new(move |evt: notify::Result| { if chrono::Local::now().timestamp() > last_update_time { + // Give time for the change to take effect before reading the file + std::thread::sleep(std::time::Duration::from_millis(100)); if let Ok(evt) = evt { let mut messages = Vec::new(); let mut needs_rebuild = false; @@ -105,9 +107,6 @@ pub async fn startup_hot_reload(config: CrateConfig) -> Result<()> { } let mut src = String::new(); file.read_to_string(&mut src).expect("Unable to read file"); - if src.is_empty() { - continue; - } // find changes to the rsx in the file if let Ok(syntax) = syn::parse_file(&src) { let mut last_file_rebuild = last_file_rebuild.lock().unwrap(); From 7025bd43aab4e98c8fe1b5907f51c19117efc814 Mon Sep 17 00:00:00 2001 From: Evan Almloff Date: Mon, 20 Jun 2022 15:44:14 -0500 Subject: [PATCH 051/170] use line!, col!, and row! instead of panic location --- src/server/hot_reload.rs | 2 +- src/server/mod.rs | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/server/hot_reload.rs b/src/server/hot_reload.rs index a0eb43e08..7c9a6957e 100644 --- a/src/server/hot_reload.rs +++ b/src/server/hot_reload.rs @@ -97,7 +97,7 @@ pub async fn hot_reload_handler( if let DiffResult::RsxChanged(changed) = find_rsx(&new_file, &old_file) { for (old, new) in changed.into_iter() { let hr = get_location( - k.strip_prefix(&state.watcher_config.crate_dir).unwrap(), + k, old.to_token_stream(), ); // get the original source code to preserve whitespace diff --git a/src/server/mod.rs b/src/server/mod.rs index 16401aa85..8cdd76373 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -121,10 +121,7 @@ pub async fn startup_hot_reload(config: CrateConfig) -> Result<()> { log::info!("reloading rsx"); for (old, new) in changed.into_iter() { let hr = get_location( - &path - .strip_prefix(&crate_dir) - .unwrap() - .to_path_buf(), + &path.to_path_buf(), old.to_token_stream(), ); // get the original source code to preserve whitespace From f8014f307b7ae0ac53a9415e4849d35b4a286fc3 Mon Sep 17 00:00:00 2001 From: Demonthos <66571940+Demonthos@users.noreply.github.com> Date: Tue, 21 Jun 2022 10:19:42 -0500 Subject: [PATCH 052/170] depend on dioxus master until next release --- Cargo.toml | 2 +- src/server/hot_reload.rs | 4 ++-- src/server/mod.rs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index f5afe80db..59a840d77 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -51,7 +51,7 @@ zip = "0.6.2" tower = "0.4.12" syn = { version = "1.0" } -dioxus-rsx-interpreter = { path = "../dioxus/packages/rsx_interpreter" } +dioxus = { git = "https://github.com/dioxuslabs/dioxus/", features = ["hot_reload"] } proc-macro2 = { version = "1.0", features = ["span-locations"] } diff --git a/src/server/hot_reload.rs b/src/server/hot_reload.rs index 7c9a6957e..ea9c64fc7 100644 --- a/src/server/hot_reload.rs +++ b/src/server/hot_reload.rs @@ -2,14 +2,14 @@ use axum::{ extract::{ws::Message, Extension, TypedHeader, WebSocketUpgrade}, response::IntoResponse, }; -use dioxus_rsx_interpreter::SetRsxMessage; +use dioxus::rsx_interpreter::SetRsxMessage; use std::{path::PathBuf, sync::Arc}; use super::BuildManager; pub use crate::hot_reload::{find_rsx, DiffResult}; use crate::CrateConfig; -pub use dioxus_rsx_interpreter::{error::Error, CodeLocation, SetManyRsxMessage}; +pub use dioxus::rsx_interpreter::{error::Error, CodeLocation, SetManyRsxMessage}; pub use proc_macro2::TokenStream; pub use std::collections::HashMap; pub use std::sync::Mutex; diff --git a/src/server/mod.rs b/src/server/mod.rs index 8cdd76373..387355ee9 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -6,7 +6,7 @@ use axum::{ routing::{get, get_service}, Router, }; -use dioxus_rsx_interpreter::SetRsxMessage; +use dioxus::rsx_interpreter::SetRsxMessage; use notify::{RecommendedWatcher, Watcher}; use syn::spanned::Spanned; From abded864c315400c1b7b0b1f80af9bf182a2b9c1 Mon Sep 17 00:00:00 2001 From: Evan Almloff Date: Tue, 28 Jun 2022 09:59:05 -0500 Subject: [PATCH 053/170] update hot_reload to hot-reload --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 59a840d77..42de2ba4c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -51,7 +51,7 @@ zip = "0.6.2" tower = "0.4.12" syn = { version = "1.0" } -dioxus = { git = "https://github.com/dioxuslabs/dioxus/", features = ["hot_reload"] } +dioxus = { git = "https://github.com/dioxuslabs/dioxus/", features = ["hot-reload"] } proc-macro2 = { version = "1.0", features = ["span-locations"] } From c9ac828ec773ad37f5fa5c12cfc610e9506d6ab8 Mon Sep 17 00:00:00 2001 From: Evan Almloff Date: Tue, 28 Jun 2022 10:00:02 -0500 Subject: [PATCH 054/170] fix path seperator --- src/server/hot_reload.rs | 9 ++++++--- src/server/mod.rs | 1 + 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/server/hot_reload.rs b/src/server/hot_reload.rs index ea9c64fc7..d34f079f5 100644 --- a/src/server/hot_reload.rs +++ b/src/server/hot_reload.rs @@ -97,6 +97,7 @@ pub async fn hot_reload_handler( if let DiffResult::RsxChanged(changed) = find_rsx(&new_file, &old_file) { for (old, new) in changed.into_iter() { let hr = get_location( + &state.watcher_config.crate_dir, k, old.to_token_stream(), ); @@ -150,7 +151,7 @@ pub async fn hot_reload_handler( let error: Error = serde_json::from_str(&err).unwrap(); match error{ Error::ParseError(parse_error) => { - log::error!("parse error:\n--> at {}:{}:{}\n\t{:?}", parse_error.location.file, parse_error.location.line, parse_error.location.column, parse_error.message); + log::error!("parse error:\n--> at {}:{}:{}\n\t{:?}", parse_error.location.file_path, parse_error.location.line, parse_error.location.column, parse_error.message); }, Error::RecompileRequiredError(_) => { if let Err(err) = state.build_manager.build(){ @@ -182,10 +183,12 @@ pub async fn hot_reload_handler( }) } -pub fn get_location(path: &Path, ts: TokenStream) -> CodeLocation { +pub fn get_location(crate_path: &Path, path: &Path, ts: TokenStream) -> CodeLocation { let span = ts.span().start(); + let relative = path.strip_prefix(crate_path).unwrap(); CodeLocation { - file: path.display().to_string(), + file_path: relative.display().to_string(), + crate_path: crate_path.display().to_string(), line: span.line as u32, column: span.column as u32 + 1, } diff --git a/src/server/mod.rs b/src/server/mod.rs index 387355ee9..4bb08170e 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -121,6 +121,7 @@ pub async fn startup_hot_reload(config: CrateConfig) -> Result<()> { log::info!("reloading rsx"); for (old, new) in changed.into_iter() { let hr = get_location( + &crate_dir, &path.to_path_buf(), old.to_token_stream(), ); From c54d4677302a6bafcd9185fd3340fb59f94c6047 Mon Sep 17 00:00:00 2001 From: YuKun Liu <41265098+mrxiaozhuox@users.noreply.github.com> Date: Wed, 29 Jun 2022 16:40:23 +0800 Subject: [PATCH 055/170] feat: set `port` configurable --- src/cli/cfg.rs | 5 +++++ src/cli/serve/mod.rs | 2 +- src/server/mod.rs | 14 ++++++-------- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/cli/cfg.rs b/src/cli/cfg.rs index 73f9570d4..9fe453c49 100644 --- a/src/cli/cfg.rs +++ b/src/cli/cfg.rs @@ -40,6 +40,11 @@ pub struct ConfigOptsServe { #[clap(parse(from_os_str))] pub target: Option, + /// Port of dev server + #[clap(long)] + #[clap(default_value_t = 8080)] + pub port: u16, + /// Build a example [default: ""] #[clap(long)] pub example: Option, diff --git a/src/cli/serve/mod.rs b/src/cli/serve/mod.rs index 5511845cb..5528ebade 100644 --- a/src/cli/serve/mod.rs +++ b/src/cli/serve/mod.rs @@ -69,7 +69,7 @@ impl Serve { Serve::regen_dev_page(&crate_config)?; // start the develop server - server::startup(crate_config.clone()).await?; + server::startup(self.serve.port, crate_config.clone()).await?; Ok(()) } diff --git a/src/server/mod.rs b/src/server/mod.rs index 387355ee9..096b07cc0 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -50,16 +50,16 @@ struct WsReloadState { update: broadcast::Sender<()>, } -pub async fn startup(config: CrateConfig) -> Result<()> { +pub async fn startup(port: u16, config: CrateConfig) -> Result<()> { if config.hot_reload { - startup_hot_reload(config).await? + startup_hot_reload(port, config).await? } else { - startup_default(config).await? + startup_default(port, config).await? } Ok(()) } -pub async fn startup_hot_reload(config: CrateConfig) -> Result<()> { +pub async fn startup_hot_reload(port: u16, config: CrateConfig) -> Result<()> { log::info!("🚀 Starting development server..."); let dist_path = config.out_dir.clone(); @@ -179,7 +179,6 @@ pub async fn startup_hot_reload(config: CrateConfig) -> Result<()> { } // start serve dev-server at 0.0.0.0:8080 - let port = "8080"; log::info!("📡 Dev-Server is started at: http://127.0.0.1:{}/", port); let file_service_config = config.clone(); @@ -242,7 +241,7 @@ pub async fn startup_hot_reload(config: CrateConfig) -> Result<()> { Ok(()) } -pub async fn startup_default(config: CrateConfig) -> Result<()> { +pub async fn startup_default(port: u16, config: CrateConfig) -> Result<()> { log::info!("🚀 Starting development server..."); let dist_path = config.out_dir.clone(); @@ -289,8 +288,7 @@ pub async fn startup_default(config: CrateConfig) -> Result<()> { .unwrap(); } - // start serve dev-server at 0.0.0.0:8080 - let port = "8080"; + // start serve dev-server at 0.0.0.0 log::info!("📡 Dev-Server is started at: http://127.0.0.1:{}/", port); let file_service_config = config.clone(); From f4ed207649e8dbcb36092f5db58834edded7c0de Mon Sep 17 00:00:00 2001 From: YuKun Liu <41265098+mrxiaozhuox@users.noreply.github.com> Date: Wed, 6 Jul 2022 00:22:40 +0800 Subject: [PATCH 056/170] feat: commit code --- src/server/hot_reload.rs | 6 +++--- src/server/mod.rs | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/server/hot_reload.rs b/src/server/hot_reload.rs index ea9c64fc7..6f494dfc7 100644 --- a/src/server/hot_reload.rs +++ b/src/server/hot_reload.rs @@ -34,7 +34,7 @@ pub struct FileMap { impl FileMap { pub fn new(path: PathBuf) -> Self { - log::info!("Searching files for changes since last compile..."); + log::info!("🔮 Searching files for changes since last compile..."); fn find_rs_files(root: PathBuf) -> io::Result> { let mut files = HashMap::new(); if root.is_dir() { @@ -61,7 +61,7 @@ impl FileMap { last_updated_time, map: find_rs_files(path).unwrap(), }; - log::info!("Files updated"); + // log::info!("Files updated"); result } } @@ -78,7 +78,7 @@ pub async fn hot_reload_handler( let mut messages = Vec::new(); { - log::info!("Finding updates since last compile..."); + log::info!("🔮 Finding updates since last compile..."); let handle = state.last_file_rebuild.lock().unwrap(); let update_time = handle.last_updated_time.clone(); for (k, v) in handle.map.iter() { diff --git a/src/server/mod.rs b/src/server/mod.rs index 096b07cc0..75134a1ac 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -27,7 +27,7 @@ pub struct BuildManager { impl BuildManager { fn build(&self) -> Result<()> { - log::info!("Start to rebuild project..."); + log::info!("🪁 Rebuild code"); builder::build(&self.config)?; // change the websocket reload state to true; // the page will auto-reload. @@ -118,7 +118,7 @@ pub async fn startup_hot_reload(port: u16, config: CrateConfig) -> Result<()> { last_file_rebuild.map.insert(path, src); } DiffResult::RsxChanged(changed) => { - log::info!("reloading rsx"); + log::info!("🪁 reloading rsx"); for (old, new) in changed.into_iter() { let hr = get_location( &path.to_path_buf(), @@ -269,7 +269,7 @@ pub async fn startup_default(port: u16, config: CrateConfig) -> Result<()> { .unwrap_or_else(|| vec![PathBuf::from("src")]); let mut watcher = RecommendedWatcher::new(move |_: notify::Result| { - log::info!("reload required"); + // log::info!("🚧 reload required"); if chrono::Local::now().timestamp() > last_update_time { match build_manager.build() { Ok(_) => last_update_time = chrono::Local::now().timestamp(), From 719e48c0a5f36cad505d2b0b6dd4a2bc9b212a6e Mon Sep 17 00:00:00 2001 From: YuKun Liu <41265098+mrxiaozhuox@users.noreply.github.com> Date: Wed, 6 Jul 2022 16:16:16 +0800 Subject: [PATCH 057/170] feat: beautify console --- Cargo.toml | 3 ++- src/cli/mod.rs | 6 +----- src/lib.rs | 4 +++- src/server/mod.rs | 45 ++++++++++++++++++++++++++++++++++++++++++--- 4 files changed, 48 insertions(+), 10 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 42de2ba4c..fa14b36b7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "dioxus-cli" -version = "0.1.4" +version = "0.1.5" authors = ["Jonathan Kelley"] edition = "2021" description = "CLI tool for developing, testing, and publishing Dioxus apps" @@ -14,6 +14,7 @@ license = "MIT/Apache-2.0" clap = { version = "3.0.14", features = ["derive"] } thiserror = "1.0.30" wasm-bindgen-cli-support = "0.2.79" +colored = "2.0.0" # features log = "0.4.14" diff --git a/src/cli/mod.rs b/src/cli/mod.rs index d639d28a7..b456d4705 100644 --- a/src/cli/mod.rs +++ b/src/cli/mod.rs @@ -27,7 +27,7 @@ use std::{ /// Build, bundle, & ship your Dioxus app. #[derive(Parser)] -#[clap(name = "dioxus")] +#[clap(name = "dioxus", version)] pub struct Cli { #[clap(subcommand)] pub action: Commands, @@ -35,10 +35,6 @@ pub struct Cli { /// Enable verbose logging. #[clap(short)] pub v: bool, - // // note: dioxus is still roughly compatible with trunk - // /// Path to the Trunk config file [default: Trunk.toml] - // #[clap(long, parse(from_os_str), env = "TRUNK_CONFIG")] - // pub config: Option, } #[derive(Parser)] diff --git a/src/lib.rs b/src/lib.rs index 6d009c18c..9956989b7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,3 +1,5 @@ +pub const DIOXUS_CLI_VERSION: &'static str = "0.1.5"; + pub mod builder; pub mod server; pub mod tools; @@ -19,4 +21,4 @@ pub use error::*; pub mod logging; pub use logging::*; -pub mod hot_reload; +pub mod hot_reload; \ No newline at end of file diff --git a/src/server/mod.rs b/src/server/mod.rs index 446d9d75c..886088fd9 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -6,11 +6,12 @@ use axum::{ routing::{get, get_service}, Router, }; +use colored::Colorize; use dioxus::rsx_interpreter::SetRsxMessage; use notify::{RecommendedWatcher, Watcher}; use syn::spanned::Spanned; -use std::{path::PathBuf, sync::Arc}; +use std::{path::PathBuf, process::Command, sync::Arc}; use tower::ServiceBuilder; use tower_http::services::fs::{ServeDir, ServeFileSystemResponseBody}; @@ -180,7 +181,7 @@ pub async fn startup_hot_reload(port: u16, config: CrateConfig) -> Result<()> { } // start serve dev-server at 0.0.0.0:8080 - log::info!("📡 Dev-Server is started at: http://127.0.0.1:{}/", port); + print_console_info(port, &config); let file_service_config = config.clone(); let file_service = ServiceBuilder::new() @@ -290,7 +291,7 @@ pub async fn startup_default(port: u16, config: CrateConfig) -> Result<()> { } // start serve dev-server at 0.0.0.0 - log::info!("📡 Dev-Server is started at: http://127.0.0.1:{}/", port); + print_console_info(port, &config); let file_service_config = config.clone(); let file_service = ServiceBuilder::new() @@ -348,6 +349,44 @@ pub async fn startup_default(port: u16, config: CrateConfig) -> Result<()> { Ok(()) } +fn print_console_info(port: u16, config: &CrateConfig) { + print!( + "{}", + String::from_utf8_lossy( + &Command::new(if cfg!(target_os = "windows") { + "cls" + } else { + "clear" + }) + .output() + .unwrap() + .stdout + ) + ); + + let mut profile = if config.release { "Release" } else { "Debug" }.to_string(); + if config.custom_profile.is_some() { + profile = config.custom_profile.as_ref().unwrap().to_string(); + } + let hot_reload = if config.hot_reload { "RSX" } else { "Normal" }; + let workspace = config.workspace_dir.to_str().unwrap().to_string(); + + println!( + "{} @ v{}\n", + "Dioxus".bold().green(), + crate::DIOXUS_CLI_VERSION + ); + println!( + "\t> Local: {}", + format!("https://localhost:{}/", port).blue() + ); + println!("\t> Profile: {}", profile.green()); + println!("\t> Hot Reload: {}", hot_reload.green()); + println!("\t> Workspace: {}", workspace.yellow()); + + println!("\n{}", "Server startup completed.".bold()); +} + async fn ws_handler( ws: WebSocketUpgrade, _: Option>, From b2c5141fa6f62b4eaf3e4918dc5b6e29c2209785 Mon Sep 17 00:00:00 2001 From: YuKun Liu <41265098+mrxiaozhuox@users.noreply.github.com> Date: Wed, 6 Jul 2022 17:36:14 +0800 Subject: [PATCH 058/170] feat: commit code --- src/server/mod.rs | 46 +++++++++++++++++++++++++++++++++++++++------- 1 file changed, 39 insertions(+), 7 deletions(-) diff --git a/src/server/mod.rs b/src/server/mod.rs index 886088fd9..b1e527b86 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -369,22 +369,54 @@ fn print_console_info(port: u16, config: &CrateConfig) { profile = config.custom_profile.as_ref().unwrap().to_string(); } let hot_reload = if config.hot_reload { "RSX" } else { "Normal" }; - let workspace = config.workspace_dir.to_str().unwrap().to_string(); + let tools_str = format!( + "{:?}", + config + .dioxus_config + .application + .tools + .clone() + .unwrap_or_default() + .iter() + .map(|d| d.0.clone()) + .collect::>() + ); + let crate_root = crate::cargo::crate_root().unwrap(); + let custom_html_file = if crate_root.join("index.html").is_file() { + "Custom [index.html]" + } else { + "Default" + }; + let url_rewrite = if config + .dioxus_config + .web + .watcher + .index_on_404 + .unwrap_or(false) + { + "True" + } else { + "False" + }; println!( "{} @ v{}\n", "Dioxus".bold().green(), - crate::DIOXUS_CLI_VERSION + crate::DIOXUS_CLI_VERSION, ); println!( - "\t> Local: {}", + "\t> Local : {}", format!("https://localhost:{}/", port).blue() ); - println!("\t> Profile: {}", profile.green()); - println!("\t> Hot Reload: {}", hot_reload.green()); - println!("\t> Workspace: {}", workspace.yellow()); + println!("\t> NetWork : {}", "use --host to expose".white().dimmed()); + println!(""); + println!("\t> Profile : {}", profile.green()); + println!("\t> Hot Reload : {}", hot_reload.cyan()); + println!("\t> Enabled Tools : {}", tools_str.yellow()); + println!("\t> Index Template : {}", custom_html_file.green()); + println!("\t> URL Rewrite : {}", url_rewrite.purple()); - println!("\n{}", "Server startup completed.".bold()); + println!("\n{}", "Server startup completed.\n".bold()); } async fn ws_handler( From 9e64b5dde88609d43ac14cccc571b39318356c05 Mon Sep 17 00:00:00 2001 From: YuKun Liu <41265098+mrxiaozhuox@users.noreply.github.com> Date: Wed, 6 Jul 2022 17:46:46 +0800 Subject: [PATCH 059/170] feat: commit code --- src/server/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/server/mod.rs b/src/server/mod.rs index b1e527b86..87448cda9 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -416,7 +416,7 @@ fn print_console_info(port: u16, config: &CrateConfig) { println!("\t> Index Template : {}", custom_html_file.green()); println!("\t> URL Rewrite : {}", url_rewrite.purple()); - println!("\n{}", "Server startup completed.\n".bold()); + println!("\n{}\n", "Server startup completed.".green().bold()); } async fn ws_handler( From 8dbf571891bad849eb54c57bddd3849f1c02e8bf Mon Sep 17 00:00:00 2001 From: YuKun Liu <41265098+mrxiaozhuox@users.noreply.github.com> Date: Wed, 6 Jul 2022 18:11:25 +0800 Subject: [PATCH 060/170] feat: commit console print --- src/server/mod.rs | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/src/server/mod.rs b/src/server/mod.rs index 87448cda9..93e81ea33 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -11,7 +11,7 @@ use dioxus::rsx_interpreter::SetRsxMessage; use notify::{RecommendedWatcher, Watcher}; use syn::spanned::Spanned; -use std::{path::PathBuf, process::Command, sync::Arc}; +use std::{path::PathBuf, process::Command, sync::Arc, net::UdpSocket}; use tower::ServiceBuilder; use tower_http::services::fs::{ServeDir, ServeFileSystemResponseBody}; @@ -408,17 +408,41 @@ fn print_console_info(port: u16, config: &CrateConfig) { "\t> Local : {}", format!("https://localhost:{}/", port).blue() ); - println!("\t> NetWork : {}", "use --host to expose".white().dimmed()); + println!( + "\t> NetWork : {}", + format!( + "http://{}:{}/", + get_ip().unwrap_or(String::from("0.0.0.0")), + port + ).blue() + ); println!(""); println!("\t> Profile : {}", profile.green()); println!("\t> Hot Reload : {}", hot_reload.cyan()); println!("\t> Enabled Tools : {}", tools_str.yellow()); println!("\t> Index Template : {}", custom_html_file.green()); - println!("\t> URL Rewrite : {}", url_rewrite.purple()); + println!("\t> URL Rewrite [index_on_404] : {}", url_rewrite.purple()); println!("\n{}\n", "Server startup completed.".green().bold()); } +fn get_ip() -> Option { + let socket = match UdpSocket::bind("0.0.0.0:0") { + Ok(s) => s, + Err(_) => return None, + }; + + match socket.connect("8.8.8.8:80") { + Ok(()) => (), + Err(_) => return None, + }; + + match socket.local_addr() { + Ok(addr) => return Some(addr.ip().to_string()), + Err(_) => return None, + }; +} + async fn ws_handler( ws: WebSocketUpgrade, _: Option>, From 81b712ec0baab63186769cfa62b1962bfd90af24 Mon Sep 17 00:00:00 2001 From: YuKun Liu <41265098+mrxiaozhuox@users.noreply.github.com> Date: Wed, 6 Jul 2022 21:08:46 +0800 Subject: [PATCH 061/170] feat: commit code --- src/server/mod.rs | 44 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 36 insertions(+), 8 deletions(-) diff --git a/src/server/mod.rs b/src/server/mod.rs index 93e81ea33..c5b438768 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -11,7 +11,7 @@ use dioxus::rsx_interpreter::SetRsxMessage; use notify::{RecommendedWatcher, Watcher}; use syn::spanned::Spanned; -use std::{path::PathBuf, process::Command, sync::Arc, net::UdpSocket}; +use std::{net::UdpSocket, path::PathBuf, process::Command, sync::Arc}; use tower::ServiceBuilder; use tower_http::services::fs::{ServeDir, ServeFileSystemResponseBody}; @@ -270,12 +270,17 @@ pub async fn startup_default(port: u16, config: CrateConfig) -> Result<()> { .clone() .unwrap_or_else(|| vec![PathBuf::from("src")]); - let mut watcher = RecommendedWatcher::new(move |_: notify::Result| { - // log::info!("🚧 reload required"); - if chrono::Local::now().timestamp() > last_update_time { - match build_manager.build() { - Ok(_) => last_update_time = chrono::Local::now().timestamp(), - Err(e) => log::error!("{}", e), + let mut watcher = RecommendedWatcher::new(move |info: notify::Result| { + if info.is_ok() { + let info = info.unwrap(); + if chrono::Local::now().timestamp() > last_update_time { + match build_manager.build() { + Ok(_) => { + last_update_time = chrono::Local::now().timestamp(); + print_rebuild_info(info.paths); + } + Err(e) => log::error!("{}", e), + } } } }) @@ -414,7 +419,8 @@ fn print_console_info(port: u16, config: &CrateConfig) { "http://{}:{}/", get_ip().unwrap_or(String::from("0.0.0.0")), port - ).blue() + ) + .blue() ); println!(""); println!("\t> Profile : {}", profile.green()); @@ -426,6 +432,28 @@ fn print_console_info(port: u16, config: &CrateConfig) { println!("\n{}\n", "Server startup completed.".green().bold()); } +fn print_rebuild_info(paths: Vec) { + print!( + "{}", + String::from_utf8_lossy( + &Command::new(if cfg!(target_os = "windows") { + "cls" + } else { + "clear" + }) + .output() + .unwrap() + .stdout + ) + ); + + for path in paths { + let path = path.strip_prefix(crate::crate_root().unwrap()).unwrap().to_path_buf(); + log::info!("Updated {}", format!("{}", path.to_str().unwrap()).green()); + } + log::info!("Project rebuild done.") +} + fn get_ip() -> Option { let socket = match UdpSocket::bind("0.0.0.0:0") { Ok(s) => s, From 61c06ea5987ada72528d7625380c69a0cea5c5d2 Mon Sep 17 00:00:00 2001 From: YuKun Liu <41265098+mrxiaozhuox@users.noreply.github.com> Date: Wed, 6 Jul 2022 21:23:35 +0800 Subject: [PATCH 062/170] feat: commit console log --- src/builder.rs | 6 +++++- src/cli/build/mod.rs | 2 +- src/cli/serve/mod.rs | 2 +- src/server/hot_reload.rs | 2 +- src/server/mod.rs | 36 ++++++++++++++++++------------------ 5 files changed, 26 insertions(+), 22 deletions(-) diff --git a/src/builder.rs b/src/builder.rs index 02add84ad..f69ce3637 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -13,7 +13,7 @@ use std::{ }; use wasm_bindgen_cli_support::Bindgen; -pub fn build(config: &CrateConfig) -> Result<()> { +pub fn build(config: &CrateConfig, quiet: bool) -> Result<()> { // [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 // [3] Wasm-bindgen the .wasm fiile, and move it into the {builddir}/modules/xxxx/xxxx_bg.wasm @@ -52,6 +52,10 @@ pub fn build(config: &CrateConfig) -> Result<()> { cmd.arg("--verbose"); } + if quiet { + cmd.arg("--quiet"); + } + if config.custom_profile.is_some() { let custom_profile = config.custom_profile.as_ref().unwrap(); cmd.arg("--profile"); diff --git a/src/cli/build/mod.rs b/src/cli/build/mod.rs index 661f17a5a..f857bfc13 100644 --- a/src/cli/build/mod.rs +++ b/src/cli/build/mod.rs @@ -34,7 +34,7 @@ impl Build { match platform.as_str() { "web" => { - crate::builder::build(&crate_config)?; + crate::builder::build(&crate_config, false)?; } "desktop" => { crate::builder::build_desktop(&crate_config, false)?; diff --git a/src/cli/serve/mod.rs b/src/cli/serve/mod.rs index 5528ebade..62843d653 100644 --- a/src/cli/serve/mod.rs +++ b/src/cli/serve/mod.rs @@ -40,7 +40,7 @@ impl Serve { match platform.as_str() { "web" => { - crate::builder::build(&crate_config)?; + crate::builder::build(&crate_config, false)?; } "desktop" => { crate::builder::build_desktop(&crate_config, true)?; diff --git a/src/server/hot_reload.rs b/src/server/hot_reload.rs index 0338dacc5..3b7812834 100644 --- a/src/server/hot_reload.rs +++ b/src/server/hot_reload.rs @@ -154,7 +154,7 @@ pub async fn hot_reload_handler( log::error!("parse error:\n--> at {}:{}:{}\n\t{:?}", parse_error.location.file_path, parse_error.location.line, parse_error.location.column, parse_error.message); }, Error::RecompileRequiredError(_) => { - if let Err(err) = state.build_manager.build(){ + if let Err(err) = state.build_manager.rebuild(){ log::error!("{}", err); } } diff --git a/src/server/mod.rs b/src/server/mod.rs index c5b438768..6b0b90a68 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -27,9 +27,9 @@ pub struct BuildManager { } impl BuildManager { - fn build(&self) -> Result<()> { - log::info!("🪁 Rebuild code"); - builder::build(&self.config)?; + fn rebuild(&self) -> Result<()> { + log::info!("🪁 Rebuild project"); + builder::build(&self.config, true)?; // change the websocket reload state to true; // the page will auto-reload. if self @@ -158,7 +158,7 @@ pub async fn startup_hot_reload(port: u16, config: CrateConfig) -> Result<()> { } if needs_rebuild { log::info!("reload required"); - if let Err(err) = build_manager.build() { + if let Err(err) = build_manager.rebuild() { log::error!("{}", err); } } @@ -274,7 +274,7 @@ pub async fn startup_default(port: u16, config: CrateConfig) -> Result<()> { if info.is_ok() { let info = info.unwrap(); if chrono::Local::now().timestamp() > last_update_time { - match build_manager.build() { + match build_manager.rebuild() { Ok(_) => { last_update_time = chrono::Local::now().timestamp(); print_rebuild_info(info.paths); @@ -433,19 +433,19 @@ fn print_console_info(port: u16, config: &CrateConfig) { } fn print_rebuild_info(paths: Vec) { - print!( - "{}", - String::from_utf8_lossy( - &Command::new(if cfg!(target_os = "windows") { - "cls" - } else { - "clear" - }) - .output() - .unwrap() - .stdout - ) - ); + // print!( + // "{}", + // String::from_utf8_lossy( + // &Command::new(if cfg!(target_os = "windows") { + // "cls" + // } else { + // "clear" + // }) + // .output() + // .unwrap() + // .stdout + // ) + // ); for path in paths { let path = path.strip_prefix(crate::crate_root().unwrap()).unwrap().to_path_buf(); From 14a2ec306eb64e1ad8a5a293c0225dbfd1d29487 Mon Sep 17 00:00:00 2001 From: YuKun Liu <41265098+mrxiaozhuox@users.noreply.github.com> Date: Wed, 6 Jul 2022 22:37:27 +0800 Subject: [PATCH 063/170] feat: commit code --- src/server/mod.rs | 62 +++++++++++++++++++++-------------------------- 1 file changed, 27 insertions(+), 35 deletions(-) diff --git a/src/server/mod.rs b/src/server/mod.rs index 6b0b90a68..ba9a853f6 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -181,7 +181,7 @@ pub async fn startup_hot_reload(port: u16, config: CrateConfig) -> Result<()> { } // start serve dev-server at 0.0.0.0:8080 - print_console_info(port, &config); + print_console_info(port, &config, vec![]); let file_service_config = config.clone(); let file_service = ServiceBuilder::new() @@ -270,15 +270,14 @@ pub async fn startup_default(port: u16, config: CrateConfig) -> Result<()> { .clone() .unwrap_or_else(|| vec![PathBuf::from("src")]); + let watcher_config = config.clone(); let mut watcher = RecommendedWatcher::new(move |info: notify::Result| { + let config = watcher_config.clone(); if info.is_ok() { - let info = info.unwrap(); + print_console_info(port, &config, info.unwrap().paths); if chrono::Local::now().timestamp() > last_update_time { match build_manager.rebuild() { - Ok(_) => { - last_update_time = chrono::Local::now().timestamp(); - print_rebuild_info(info.paths); - } + Ok(_) => last_update_time = chrono::Local::now().timestamp(), Err(e) => log::error!("{}", e), } } @@ -296,7 +295,7 @@ pub async fn startup_default(port: u16, config: CrateConfig) -> Result<()> { } // start serve dev-server at 0.0.0.0 - print_console_info(port, &config); + print_console_info(port, &config, vec![]); let file_service_config = config.clone(); let file_service = ServiceBuilder::new() @@ -354,7 +353,7 @@ pub async fn startup_default(port: u16, config: CrateConfig) -> Result<()> { Ok(()) } -fn print_console_info(port: u16, config: &CrateConfig) { +fn print_console_info(port: u16, config: &CrateConfig, changed: Vec) { print!( "{}", String::from_utf8_lossy( @@ -369,6 +368,14 @@ fn print_console_info(port: u16, config: &CrateConfig) { ) ); + // for path in &changed { + // let path = path + // .strip_prefix(crate::crate_root().unwrap()) + // .unwrap() + // .to_path_buf(); + // log::info!("Updated {}", format!("{}", path.to_str().unwrap()).green()); + // } + let mut profile = if config.release { "Release" } else { "Debug" }.to_string(); if config.custom_profile.is_some() { profile = config.custom_profile.as_ref().unwrap().to_string(); @@ -404,11 +411,18 @@ fn print_console_info(port: u16, config: &CrateConfig) { "False" }; - println!( - "{} @ v{}\n", - "Dioxus".bold().green(), - crate::DIOXUS_CLI_VERSION, - ); + if changed.len() <= 0 { + println!( + "{} @ v{}\n", + "Dioxus".bold().green(), + crate::DIOXUS_CLI_VERSION, + ); + } else { + println!( + "Project Reloaded: {}\n", + format!("Changed {} files.", changed.len()).purple().bold() + ); + } println!( "\t> Local : {}", format!("https://localhost:{}/", port).blue() @@ -432,28 +446,6 @@ fn print_console_info(port: u16, config: &CrateConfig) { println!("\n{}\n", "Server startup completed.".green().bold()); } -fn print_rebuild_info(paths: Vec) { - // print!( - // "{}", - // String::from_utf8_lossy( - // &Command::new(if cfg!(target_os = "windows") { - // "cls" - // } else { - // "clear" - // }) - // .output() - // .unwrap() - // .stdout - // ) - // ); - - for path in paths { - let path = path.strip_prefix(crate::crate_root().unwrap()).unwrap().to_path_buf(); - log::info!("Updated {}", format!("{}", path.to_str().unwrap()).green()); - } - log::info!("Project rebuild done.") -} - fn get_ip() -> Option { let socket = match UdpSocket::bind("0.0.0.0:0") { Ok(s) => s, From 3551d1b6a0aeeebc3d52e5399f4f0e70703df325 Mon Sep 17 00:00:00 2001 From: YuKun Liu <41265098+mrxiaozhuox@users.noreply.github.com> Date: Wed, 6 Jul 2022 22:44:50 +0800 Subject: [PATCH 064/170] feat: commit code --- src/server/mod.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/server/mod.rs b/src/server/mod.rs index ba9a853f6..d6efab958 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -94,14 +94,16 @@ pub async fn startup_hot_reload(port: u16, config: CrateConfig) -> Result<()> { .clone() .unwrap_or_else(|| vec![PathBuf::from("src")]); + let watcher_config = config.clone(); let mut watcher = RecommendedWatcher::new(move |evt: notify::Result| { + let config = watcher_config.clone(); if chrono::Local::now().timestamp() > last_update_time { // Give time for the change to take effect before reading the file std::thread::sleep(std::time::Duration::from_millis(100)); if let Ok(evt) = evt { let mut messages = Vec::new(); let mut needs_rebuild = false; - for path in evt.paths { + for path in evt.paths.clone() { let mut file = File::open(path.clone()).unwrap(); if path.extension().map(|p| p.to_str()).flatten() != Some("rs") { continue; @@ -157,7 +159,7 @@ pub async fn startup_hot_reload(port: u16, config: CrateConfig) -> Result<()> { } } if needs_rebuild { - log::info!("reload required"); + print_console_info(port, &config, evt.paths); if let Err(err) = build_manager.rebuild() { log::error!("{}", err); } From b642dcd739a0403837ca43cd661d8d24ac22012d Mon Sep 17 00:00:00 2001 From: YuKun Liu <41265098+mrxiaozhuox@users.noreply.github.com> Date: Wed, 6 Jul 2022 22:45:08 +0800 Subject: [PATCH 065/170] fix: format code --- src/builder.rs | 4 +++- src/lib.rs | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/builder.rs b/src/builder.rs index f69ce3637..4feb87839 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -433,7 +433,9 @@ fn build_assets(config: &CrateConfig) -> Result> { let temp = entry.path(); if temp.is_file() { let suffix = temp.extension(); - if suffix.is_none() { continue; } + if suffix.is_none() { + continue; + } let suffix = suffix.unwrap().to_str().unwrap(); if suffix == "scss" || suffix == "sass" { // if file suffix is `scss` / `sass` we need transform it. diff --git a/src/lib.rs b/src/lib.rs index 9956989b7..1b651acee 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -21,4 +21,4 @@ pub use error::*; pub mod logging; pub use logging::*; -pub mod hot_reload; \ No newline at end of file +pub mod hot_reload; From f57dc5212b37bcc799feded01468c0251f60822a Mon Sep 17 00:00:00 2001 From: YuKun Liu <41265098+mrxiaozhuox@users.noreply.github.com> Date: Wed, 6 Jul 2022 23:01:39 +0800 Subject: [PATCH 066/170] fix: change local `https` to `http` --- src/server/mod.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/server/mod.rs b/src/server/mod.rs index d6efab958..3ecce6c26 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -427,7 +427,7 @@ fn print_console_info(port: u16, config: &CrateConfig, changed: Vec) { } println!( "\t> Local : {}", - format!("https://localhost:{}/", port).blue() + format!("http://localhost:{}/", port).blue() ); println!( "\t> NetWork : {}", @@ -444,8 +444,14 @@ fn print_console_info(port: u16, config: &CrateConfig, changed: Vec) { println!("\t> Enabled Tools : {}", tools_str.yellow()); println!("\t> Index Template : {}", custom_html_file.green()); println!("\t> URL Rewrite [index_on_404] : {}", url_rewrite.purple()); + println!(""); - println!("\n{}\n", "Server startup completed.".green().bold()); + if changed.len() <= 0 { + log::info!("{}", "Server startup completed.".green().bold()); + } else { + log::info!("{}", "Project rebuild completed.".green().bold()); + } + } fn get_ip() -> Option { From 7860f8b931ecf7d5757433f53868561929d95e74 Mon Sep 17 00:00:00 2001 From: YuKun Liu <41265098+mrxiaozhuox@users.noreply.github.com> Date: Thu, 7 Jul 2022 23:03:30 +0800 Subject: [PATCH 067/170] feat: commit code --- Cargo.toml | 1 + src/builder.rs | 14 +++++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index fa14b36b7..7e982bc78 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,6 +36,7 @@ regex = "1.5.4" chrono = "0.4.19" anyhow = "1.0.53" hyper = "0.14.17" +loading = "0.3.0" axum = { version = "0.5.1", features = ["ws", "headers"] } tower-http = { version = "0.2.2", features = ["fs", "trace"] } diff --git a/src/builder.rs b/src/builder.rs index 4feb87839..0dce6d71d 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -6,7 +6,7 @@ use crate::{ }; use std::{ fs::{copy, create_dir_all, remove_dir_all, File}, - io::Read, + io::{Read, BufRead}, panic, path::PathBuf, process::Command, @@ -42,8 +42,9 @@ pub fn build(config: &CrateConfig, quiet: bool) -> Result<()> { .arg("build") .arg("--target") .arg("wasm32-unknown-unknown") - .stdout(std::process::Stdio::inherit()) - .stderr(std::process::Stdio::inherit()); + .arg("--message-format=json") + .stdout(std::process::Stdio::piped()) + .stderr(std::process::Stdio::piped()); if config.release { cmd.arg("--release"); @@ -74,7 +75,14 @@ pub fn build(config: &CrateConfig, quiet: bool) -> Result<()> { ExecutableType::Example(name) => cmd.arg("--example").arg(name), }; + let loading = loading::Loading::default(); + loading.text("Building"); let output = cmd.output()?; + for i in output.stdout.lines() { + // println!("{:?}", i); + } + loading.success("OK"); + loading.end(); if !output.status.success() { log::error!("Build failed!"); From 5edcb9238c33c253ca62831bbd8947d4e8b49c05 Mon Sep 17 00:00:00 2001 From: YuKun Liu <41265098+mrxiaozhuox@users.noreply.github.com> Date: Fri, 8 Jul 2022 09:26:05 +0800 Subject: [PATCH 068/170] feat: cargo format struct --- src/builder.rs | 26 ++++++++++++++++++-------- src/cargo.rs | 25 +++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 8 deletions(-) diff --git a/src/builder.rs b/src/builder.rs index 0dce6d71d..a662f8a20 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -77,18 +77,28 @@ pub fn build(config: &CrateConfig, quiet: bool) -> Result<()> { let loading = loading::Loading::default(); loading.text("Building"); - let output = cmd.output()?; - for i in output.stdout.lines() { - // println!("{:?}", i); + let mut child = cmd.spawn()?; + let out = child.stdout.take().unwrap(); + let mut out = std::io::BufReader::new(out); + let mut s = String::new(); + let mut n = 0; + while let Ok(_) = out.read_line(&mut s) { + // 进程退出后结束循环 + if let Ok(Some(_)) = child.try_wait() { + break; + } + println!("\n{}\n", s); + loading.text(format!("Building {}", n)); + n += 1; } loading.success("OK"); loading.end(); - if !output.status.success() { - log::error!("Build failed!"); - let reason = String::from_utf8_lossy(&output.stderr).to_string(); - return Err(Error::BuildFailed(reason)); - } + // if !output.status.success() { + // log::error!("Build failed!"); + // let reason = String::from_utf8_lossy(&output.stderr).to_string(); + // return Err(Error::BuildFailed(reason)); + // } // [2] Establish the output directory structure let bindgen_outdir = out_dir.join("assets").join("dioxus"); diff --git a/src/cargo.rs b/src/cargo.rs index 251e9d848..9994d5be5 100644 --- a/src/cargo.rs +++ b/src/cargo.rs @@ -1,4 +1,6 @@ //! Utilities for working with cargo and rust files +use serde::Serialize; + use crate::error::{Error, Result}; use std::{ env, fs, @@ -90,3 +92,26 @@ impl Metadata { Err(Error::CargoError("InvalidOutput".to_string())) } } + +#[derive(Serialize, Debug, Clone)] +pub struct CargoFormatInfo { + pub reason: CargoFormatReason, + #[serde(default)] + pub package_id: String, + #[serde(default)] + manifest_path: String, + #[serde(default)] + message: Option +} + +#[derive(Serialize, Debug, Clone)] +pub enum CargoFormatReason { + #[serde(rename = "compiler-message")] + CompilerMessage, + #[serde(rename = "compiler-artifact")] + CompilerArtifact, + #[serde(rename = "build-script-executed")] + BuildScriptExecuted, + #[serde(rename = "build-finished")] + BuildFinished, +} \ No newline at end of file From 0a2bac87154f8c867fc0427fabe21ce04fd3b026 Mon Sep 17 00:00:00 2001 From: YuKun Liu <41265098+mrxiaozhuox@users.noreply.github.com> Date: Sat, 9 Jul 2022 00:28:00 +0800 Subject: [PATCH 069/170] feat: commit code --- src/builder.rs | 21 +++++++++++++-------- src/cargo.rs | 10 ++++++---- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/src/builder.rs b/src/builder.rs index a662f8a20..bdb82fc45 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -2,11 +2,11 @@ use crate::{ config::{CrateConfig, ExecutableType}, error::{Error, Result}, tools::Tool, - DioxusConfig, + CargoFormatInfo, DioxusConfig, }; use std::{ fs::{copy, create_dir_all, remove_dir_all, File}, - io::{Read, BufRead}, + io::{BufRead, Read}, panic, path::PathBuf, process::Command, @@ -80,16 +80,21 @@ pub fn build(config: &CrateConfig, quiet: bool) -> Result<()> { let mut child = cmd.spawn()?; let out = child.stdout.take().unwrap(); let mut out = std::io::BufReader::new(out); - let mut s = String::new(); - let mut n = 0; - while let Ok(_) = out.read_line(&mut s) { + let mut content = String::new(); + while let Ok(_) = out.read_line(&mut content) { // 进程退出后结束循环 if let Ok(Some(_)) = child.try_wait() { break; } - println!("\n{}\n", s); - loading.text(format!("Building {}", n)); - n += 1; + let content = content.split('\n').collect::>(); + for json in content { + let d = serde_json::from_str::(&json); + if let Ok(d) = d { + println!("\n{:#?}\n", d); + } else { + println!("\n\n{:?}\n\n", json); + } + } } loading.success("OK"); loading.end(); diff --git a/src/cargo.rs b/src/cargo.rs index 9994d5be5..6c5085066 100644 --- a/src/cargo.rs +++ b/src/cargo.rs @@ -1,5 +1,5 @@ //! Utilities for working with cargo and rust files -use serde::Serialize; +use serde::{Serialize, Deserialize}; use crate::error::{Error, Result}; use std::{ @@ -93,7 +93,7 @@ impl Metadata { } } -#[derive(Serialize, Debug, Clone)] +#[derive(Serialize, Deserialize, Debug, Clone)] pub struct CargoFormatInfo { pub reason: CargoFormatReason, #[serde(default)] @@ -101,10 +101,12 @@ pub struct CargoFormatInfo { #[serde(default)] manifest_path: String, #[serde(default)] - message: Option + target: Option, + #[serde(default)] + message: Option, } -#[derive(Serialize, Debug, Clone)] +#[derive(Serialize, Deserialize, Debug, Clone)] pub enum CargoFormatReason { #[serde(rename = "compiler-message")] CompilerMessage, From eb0145173d0f8d5db715875d3213499172e89ea8 Mon Sep 17 00:00:00 2001 From: YuKun Liu <41265098+mrxiaozhuox@users.noreply.github.com> Date: Sat, 9 Jul 2022 00:32:23 +0800 Subject: [PATCH 070/170] feat: add `indicatif` crate --- Cargo.toml | 2 +- src/builder.rs | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 7e982bc78..a50a06fde 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,7 +36,7 @@ regex = "1.5.4" chrono = "0.4.19" anyhow = "1.0.53" hyper = "0.14.17" -loading = "0.3.0" +indicatif = "0.16.2" axum = { version = "0.5.1", features = ["ws", "headers"] } tower-http = { version = "0.2.2", features = ["fs", "trace"] } diff --git a/src/builder.rs b/src/builder.rs index bdb82fc45..ed0921cd1 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -75,8 +75,6 @@ pub fn build(config: &CrateConfig, quiet: bool) -> Result<()> { ExecutableType::Example(name) => cmd.arg("--example").arg(name), }; - let loading = loading::Loading::default(); - loading.text("Building"); let mut child = cmd.spawn()?; let out = child.stdout.take().unwrap(); let mut out = std::io::BufReader::new(out); @@ -96,8 +94,6 @@ pub fn build(config: &CrateConfig, quiet: bool) -> Result<()> { } } } - loading.success("OK"); - loading.end(); // if !output.status.success() { // log::error!("Build failed!"); From dfe571df1a6260f31eff5f3e83113c448786e3b1 Mon Sep 17 00:00:00 2001 From: YuKun Liu <41265098+mrxiaozhuox@users.noreply.github.com> Date: Sat, 9 Jul 2022 10:09:25 +0800 Subject: [PATCH 071/170] feat: commit prettier_build --- Cargo.toml | 2 +- src/builder.rs | 58 ++++++++++++++++++++++++++++++++------------------ src/cargo.rs | 27 ----------------------- 3 files changed, 38 insertions(+), 49 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index a50a06fde..7e982bc78 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,7 +36,7 @@ regex = "1.5.4" chrono = "0.4.19" anyhow = "1.0.53" hyper = "0.14.17" -indicatif = "0.16.2" +loading = "0.3.0" axum = { version = "0.5.1", features = ["ws", "headers"] } tower-http = { version = "0.2.2", features = ["fs", "trace"] } diff --git a/src/builder.rs b/src/builder.rs index ed0921cd1..5ef084326 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -2,11 +2,14 @@ use crate::{ config::{CrateConfig, ExecutableType}, error::{Error, Result}, tools::Tool, - CargoFormatInfo, DioxusConfig, + DioxusConfig, }; +use cargo_metadata::Message; +use loading::Loading; use std::{ + collections::HashMap, fs::{copy, create_dir_all, remove_dir_all, File}, - io::{BufRead, Read}, + io::Read, panic, path::PathBuf, process::Command, @@ -75,25 +78,7 @@ pub fn build(config: &CrateConfig, quiet: bool) -> Result<()> { ExecutableType::Example(name) => cmd.arg("--example").arg(name), }; - let mut child = cmd.spawn()?; - let out = child.stdout.take().unwrap(); - let mut out = std::io::BufReader::new(out); - let mut content = String::new(); - while let Ok(_) = out.read_line(&mut content) { - // 进程退出后结束循环 - if let Ok(Some(_)) = child.try_wait() { - break; - } - let content = content.split('\n').collect::>(); - for json in content { - let d = serde_json::from_str::(&json); - if let Ok(d) = d { - println!("\n{:#?}\n", d); - } else { - println!("\n\n{:?}\n\n", json); - } - } - } + prettier_build(cmd).unwrap(); // if !output.status.success() { // log::error!("Build failed!"); @@ -342,6 +327,37 @@ pub fn build_desktop(config: &CrateConfig, is_serve: bool) -> Result<()> { Ok(()) } +fn prettier_build(mut cmd: Command) -> anyhow::Result<()> { + let loading = Loading::default(); + let mut record: HashMap = HashMap::new(); + let mut command = cmd.spawn()?; + let reader = std::io::BufReader::new(command.stdout.take().unwrap()); + for message in cargo_metadata::Message::parse_stream(reader) { + match message.unwrap() { + Message::CompilerMessage(_msg) => { + // println!("{:#?}", msg); + } + Message::CompilerArtifact(artifact) => { + record.insert(artifact.package_id.to_string(), artifact.target.name); + } + Message::BuildScriptExecuted(script) => { + let package_id = script.package_id.to_string(); + if let Some(name) = record.get(&package_id) { + loading.text(format!("[{}] build done", name)); + } + } + Message::BuildFinished(finished) => { + if finished.success { + } else { + std::process::exit(1); + } + } + _ => (), // Unknown message + } + } + Ok(()) +} + pub fn gen_page(config: &DioxusConfig, serve: bool) -> String { let crate_root = crate::cargo::crate_root().unwrap(); let custom_html_file = crate_root.join("index.html"); diff --git a/src/cargo.rs b/src/cargo.rs index 6c5085066..251e9d848 100644 --- a/src/cargo.rs +++ b/src/cargo.rs @@ -1,6 +1,4 @@ //! Utilities for working with cargo and rust files -use serde::{Serialize, Deserialize}; - use crate::error::{Error, Result}; use std::{ env, fs, @@ -92,28 +90,3 @@ impl Metadata { Err(Error::CargoError("InvalidOutput".to_string())) } } - -#[derive(Serialize, Deserialize, Debug, Clone)] -pub struct CargoFormatInfo { - pub reason: CargoFormatReason, - #[serde(default)] - pub package_id: String, - #[serde(default)] - manifest_path: String, - #[serde(default)] - target: Option, - #[serde(default)] - message: Option, -} - -#[derive(Serialize, Deserialize, Debug, Clone)] -pub enum CargoFormatReason { - #[serde(rename = "compiler-message")] - CompilerMessage, - #[serde(rename = "compiler-artifact")] - CompilerArtifact, - #[serde(rename = "build-script-executed")] - BuildScriptExecuted, - #[serde(rename = "build-finished")] - BuildFinished, -} \ No newline at end of file From 98134cfe1ce33d12ab1dcba2fa1ca71b05e8a682 Mon Sep 17 00:00:00 2001 From: YuKun Liu <41265098+mrxiaozhuox@users.noreply.github.com> Date: Sat, 9 Jul 2022 10:09:44 +0800 Subject: [PATCH 072/170] feat: commit Cargo.lock --- .gitignore | 1 - Cargo.lock | 4684 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 4684 insertions(+), 1 deletion(-) create mode 100644 Cargo.lock diff --git a/.gitignore b/.gitignore index 2e049011e..6b39d31a9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,2 @@ /target -Cargo.lock .idea/ \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 000000000..086673b7a --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,4684 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "addr2line" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9ecd88a8c8378ca913a680cd98f0f13ac67383d35993f86c90a70e3f137816b" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + +[[package]] +name = "aes" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e8b47f52ea9bae42228d07ec09eb676433d7c4ed1ebdf0f1d1c29ed446f1ab8" +dependencies = [ + "cfg-if", + "cipher", + "cpufeatures", + "opaque-debug 0.3.0", +] + +[[package]] +name = "aho-corasick" +version = "0.7.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f" +dependencies = [ + "memchr", +] + +[[package]] +name = "anyhow" +version = "1.0.58" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb07d2053ccdbe10e2af2995a2f116c1330396493dc1269f6a91d0ae82e19704" + +[[package]] +name = "arrayref" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" + +[[package]] +name = "arrayvec" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" + +[[package]] +name = "async-channel" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2114d64672151c0c5eaa5e131ec84a74f06e1e559830dabba01ca30605d66319" +dependencies = [ + "concurrent-queue", + "event-listener", + "futures-core", +] + +[[package]] +name = "async-task" +version = "4.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30696a84d817107fc028e049980e09d5e140e8da8f1caeb17e8e950658a3cea9" + +[[package]] +name = "async-trait" +version = "0.1.56" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96cf8829f67d2eab0b2dfa42c5d0ef737e0724e4a82b01b3e292456202b19716" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "atk" +version = "0.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c3d816ce6f0e2909a96830d6911c2aff044370b1ef92d7f267b43bae5addedd" +dependencies = [ + "atk-sys", + "bitflags", + "glib", + "libc", +] + +[[package]] +name = "atk-sys" +version = "0.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58aeb089fb698e06db8089971c7ee317ab9644bade33383f63631437b03aafb6" +dependencies = [ + "glib-sys", + "gobject-sys", + "libc", + "system-deps 6.0.2", +] + +[[package]] +name = "atomic-waker" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "065374052e7df7ee4047b1160cca5e1467a12351a40b3da123c870ba0b8eda2a" + +[[package]] +name = "atty" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +dependencies = [ + "hermit-abi", + "libc", + "winapi", +] + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "axum" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2cc6e8e8c993cb61a005fab8c1e5093a29199b7253b05a6883999312935c1ff" +dependencies = [ + "async-trait", + "axum-core", + "base64 0.13.0", + "bitflags", + "bytes", + "futures-util", + "headers", + "http", + "http-body", + "hyper", + "itoa", + "matchit", + "memchr", + "mime", + "percent-encoding", + "pin-project-lite", + "serde", + "serde_json", + "serde_urlencoded", + "sha-1 0.10.0", + "sync_wrapper", + "tokio", + "tokio-tungstenite", + "tower", + "tower-http 0.3.4", + "tower-layer", + "tower-service", +] + +[[package]] +name = "axum-core" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf4d047478b986f14a13edad31a009e2e05cb241f9805d0d75e4cba4e129ad4d" +dependencies = [ + "async-trait", + "bytes", + "futures-util", + "http", + "http-body", + "mime", +] + +[[package]] +name = "backtrace" +version = "0.3.65" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11a17d453482a265fd5f8479f2a3f405566e6ca627837aaddb85af8b1ab8ef61" +dependencies = [ + "addr2line", + "cc", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", +] + +[[package]] +name = "base64" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "489d6c0ed21b11d038c31b6ceccca973e65d73ba3bd8ecb9a2babf5546164643" +dependencies = [ + "byteorder", + "safemem", +] + +[[package]] +name = "base64" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" + +[[package]] +name = "base64ct" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a32fd6af2b5827bce66c29053ba0e7c42b9dcab01835835058558c10851a46b" + +[[package]] +name = "binary-install" +version = "0.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b5bc5f8c50dd6a80d0b303ddab79f42ddcb52fd43d68107ecf622c551fd4cd4" +dependencies = [ + "curl", + "dirs 1.0.5", + "failure", + "flate2", + "hex", + "is_executable", + "siphasher", + "tar", + "zip 0.5.13", +] + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "blake2b_simd" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "afa748e348ad3be8263be728124b24a24f268266f6f5d58af9d75f6a40b5c587" +dependencies = [ + "arrayref", + "arrayvec", + "constant_time_eq", +] + +[[package]] +name = "block" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a" + +[[package]] +name = "block-buffer" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" +dependencies = [ + "block-padding", + "byte-tools", + "byteorder", + "generic-array 0.12.4", +] + +[[package]] +name = "block-buffer" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bf7fe51849ea569fd452f37822f606a5cabb684dc918707a0193fd4664ff324" +dependencies = [ + "generic-array 0.14.5", +] + +[[package]] +name = "block-padding" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5" +dependencies = [ + "byte-tools", +] + +[[package]] +name = "blocking" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6ccb65d468978a086b69884437ded69a90faab3bbe6e67f242173ea728acccc" +dependencies = [ + "async-channel", + "async-task", + "atomic-waker", + "fastrand", + "futures-lite", + "once_cell", +] + +[[package]] +name = "bumpalo" +version = "3.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37ccbd214614c6783386c1af30caf03192f17891059cecc394b4fb119e363de3" + +[[package]] +name = "byte-tools" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" + +[[package]] +name = "byteorder" +version = "1.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" + +[[package]] +name = "bytes" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4872d67bab6358e59559027aa3b9157c53d9358c51423c17554809a8858e0f8" + +[[package]] +name = "bzip2" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6afcd980b5f3a45017c57e57a2fcccbb351cc43a356ce117ef760ef8052b89b0" +dependencies = [ + "bzip2-sys", + "libc", +] + +[[package]] +name = "bzip2-sys" +version = "0.1.11+1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "736a955f3fa7875102d57c82b8cac37ec45224a07fd32d58f9f7a186b6cd4cdc" +dependencies = [ + "cc", + "libc", + "pkg-config", +] + +[[package]] +name = "cache-padded" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1db59621ec70f09c5e9b597b220c7a2b43611f4710dc03ceb8748637775692c" + +[[package]] +name = "cairo-rs" +version = "0.15.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c76ee391b03d35510d9fa917357c7f1855bd9a6659c95a1b392e33f49b3369bc" +dependencies = [ + "bitflags", + "cairo-sys-rs", + "glib", + "libc", + "thiserror", +] + +[[package]] +name = "cairo-sys-rs" +version = "0.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c55d429bef56ac9172d25fecb85dc8068307d17acd74b377866b7a1ef25d3c8" +dependencies = [ + "glib-sys", + "libc", + "system-deps 6.0.2", +] + +[[package]] +name = "camino" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "869119e97797867fd90f5e22af7d0bd274bd4635ebb9eb68c04f3f513ae6c412" +dependencies = [ + "serde", +] + +[[package]] +name = "cargo-platform" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cbdb825da8a5df079a43676dbe042702f1707b1109f713a01420fbb4cc71fa27" +dependencies = [ + "serde", +] + +[[package]] +name = "cargo_metadata" +version = "0.14.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4acbb09d9ee8e23699b9634375c72795d095bf268439da88562cf9b501f181fa" +dependencies = [ + "camino", + "cargo-platform", + "semver 1.0.12", + "serde", + "serde_json", +] + +[[package]] +name = "cargo_toml" +version = "0.11.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5809dd3e6444651fd1cdd3dbec71eca438c439a0fcc8081674a14da0afe50185" +dependencies = [ + "serde", + "serde_derive", + "toml", +] + +[[package]] +name = "cc" +version = "1.0.73" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" +dependencies = [ + "jobserver", +] + +[[package]] +name = "cesu8" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c" + +[[package]] +name = "cfg-expr" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3431df59f28accaf4cb4eed4a9acc66bea3f3c3753aa6cdc2f024174ef232af7" +dependencies = [ + "smallvec", +] + +[[package]] +name = "cfg-expr" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0aacacf4d96c24b2ad6eb8ee6df040e4f27b0d0b39a5710c30091baa830485db" +dependencies = [ + "smallvec", +] + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "chrono" +version = "0.4.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73" +dependencies = [ + "libc", + "num-integer", + "num-traits", + "time 0.1.44", + "winapi", +] + +[[package]] +name = "cipher" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ee52072ec15386f770805afd189a01c8841be8696bed250fa2f13c4c0d6dfb7" +dependencies = [ + "generic-array 0.14.5", +] + +[[package]] +name = "clap" +version = "3.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "190814073e85d238f31ff738fcb0bf6910cedeb73376c87cd69291028966fd83" +dependencies = [ + "atty", + "bitflags", + "clap_derive", + "clap_lex", + "indexmap", + "once_cell", + "strsim 0.10.0", + "termcolor", + "textwrap", +] + +[[package]] +name = "clap_derive" +version = "3.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "759bf187376e1afa7b85b959e6a664a3e7a95203415dba952ad19139e798f902" +dependencies = [ + "heck 0.4.0", + "proc-macro-error", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "clap_lex" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5" +dependencies = [ + "os_str_bytes", +] + +[[package]] +name = "cocoa" +version = "0.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f63902e9223530efb4e26ccd0cf55ec30d592d3b42e21a28defc42a9586e832" +dependencies = [ + "bitflags", + "block", + "cocoa-foundation", + "core-foundation", + "core-graphics", + "foreign-types", + "libc", + "objc", +] + +[[package]] +name = "cocoa-foundation" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ade49b65d560ca58c403a479bb396592b155c0185eada742ee323d1d68d6318" +dependencies = [ + "bitflags", + "block", + "core-foundation", + "core-graphics-types", + "foreign-types", + "libc", + "objc", +] + +[[package]] +name = "colored" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4ffc801dacf156c5854b9df4f425a626539c3a6ef7893cc0c5084a23f0b6c59" +dependencies = [ + "atty", + "lazy_static", + "winapi", +] + +[[package]] +name = "colored" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3616f750b84d8f0de8a58bda93e08e2a81ad3f523089b05f1dffecab48c6cbd" +dependencies = [ + "atty", + "lazy_static", + "winapi", +] + +[[package]] +name = "combine" +version = "4.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a604e93b79d1808327a6fca85a6f2d69de66461e7620f5a4cbf5fb4d1d7c948" +dependencies = [ + "bytes", + "memchr", +] + +[[package]] +name = "concurrent-queue" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30ed07550be01594c6026cff2a1d7fe9c8f683caa798e12b68694ac9e88286a3" +dependencies = [ + "cache-padded", +] + +[[package]] +name = "console_error_panic_hook" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a06aeb73f470f66dcdbf7223caeebb85984942f22f1adb2a088cf9668146bbbc" +dependencies = [ + "cfg-if", + "wasm-bindgen", +] + +[[package]] +name = "constant_time_eq" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" + +[[package]] +name = "convert_case" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb4a24b1aaf0fd0ce8b45161144d6f42cd91677fd5940fd431183eb023b3a2b8" + +[[package]] +name = "core-foundation" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" + +[[package]] +name = "core-graphics" +version = "0.22.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2581bbab3b8ffc6fcbd550bf46c355135d16e9ff2a6ea032ad6b9bf1d7efe4fb" +dependencies = [ + "bitflags", + "core-foundation", + "core-graphics-types", + "foreign-types", + "libc", +] + +[[package]] +name = "core-graphics-types" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a68b68b3446082644c91ac778bf50cd4104bfb002b5a6a7c44cca5a2c70788b" +dependencies = [ + "bitflags", + "core-foundation", + "foreign-types", + "libc", +] + +[[package]] +name = "cpufeatures" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59a6001667ab124aebae2a495118e11d30984c3a653e99d86d58971708cf5e4b" +dependencies = [ + "libc", +] + +[[package]] +name = "crc32fast" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "crossbeam-channel" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c02a4d71819009c192cf4872265391563fd6a84c81ff2c0f2a7026ca4c1d85c" +dependencies = [ + "cfg-if", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d82ee10ce34d7bc12c2122495e7593a9c41347ecdd64185af4ecf72cb1a7f83" +dependencies = [ + "cfg-if", + "once_cell", +] + +[[package]] +name = "crypto-common" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5999502d32b9c48d492abe66392408144895020ec4709e549e840799f3bb74c0" +dependencies = [ + "generic-array 0.14.5", + "typenum", +] + +[[package]] +name = "cty" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b365fabc795046672053e29c954733ec3b05e4be654ab130fe8f1f94d7051f35" + +[[package]] +name = "curl" +version = "0.4.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37d855aeef205b43f65a5001e0997d81f8efca7badad4fad7d897aa7f0d0651f" +dependencies = [ + "curl-sys", + "libc", + "openssl-probe", + "openssl-sys", + "schannel", + "socket2", + "winapi", +] + +[[package]] +name = "curl-sys" +version = "0.4.55+curl-7.83.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23734ec77368ec583c2e61dd3f0b0e5c98b93abe6d2a004ca06b91dd7e3e2762" +dependencies = [ + "cc", + "libc", + "libz-sys", + "openssl-sys", + "pkg-config", + "vcpkg", + "winapi", +] + +[[package]] +name = "darling" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d706e75d87e35569db781a9b5e2416cff1236a47ed380831f959382ccd5f858" +dependencies = [ + "darling_core 0.10.2", + "darling_macro 0.10.2", +] + +[[package]] +name = "darling" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a01d95850c592940db9b8194bc39f4bc0e89dee5c4265e4b1807c34a9aba453c" +dependencies = [ + "darling_core 0.13.4", + "darling_macro 0.13.4", +] + +[[package]] +name = "darling_core" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0c960ae2da4de88a91b2d920c2a7233b400bc33cb28453a2987822d8392519b" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim 0.9.3", + "syn", +] + +[[package]] +name = "darling_core" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "859d65a907b6852c9361e3185c862aae7fafd2887876799fa55f5f99dc40d610" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim 0.10.0", + "syn", +] + +[[package]] +name = "darling_macro" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b5a2f4ac4969822c62224815d069952656cadc7084fdca9751e6d959189b72" +dependencies = [ + "darling_core 0.10.2", + "quote", + "syn", +] + +[[package]] +name = "darling_macro" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c972679f83bdf9c42bd905396b6c3588a843a17f0f16dfcfa3e2c5d57441835" +dependencies = [ + "darling_core 0.13.4", + "quote", + "syn", +] + +[[package]] +name = "data-encoding" +version = "2.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ee2393c4a91429dffb4bedf19f4d6abf27d8a732c8ce4980305d782e5426d57" + +[[package]] +name = "digest" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" +dependencies = [ + "generic-array 0.12.4", +] + +[[package]] +name = "digest" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2fb860ca6fafa5552fb6d0e816a69c8e49f0908bf524e30a90d97c85892d506" +dependencies = [ + "block-buffer 0.10.2", + "crypto-common", + "subtle", +] + +[[package]] +name = "dioxus" +version = "0.2.4" +source = "git+https://github.com/dioxuslabs/dioxus/#baaa1752d3ccd5918fc472b1071b95a12b019687" +dependencies = [ + "dioxus-core", + "dioxus-core-macro", + "dioxus-desktop", + "dioxus-hooks", + "dioxus-html", + "dioxus-router", + "dioxus-rsx", + "dioxus-rsx-interpreter", + "dioxus-web", +] + +[[package]] +name = "dioxus-cli" +version = "0.1.5" +dependencies = [ + "anyhow", + "atty", + "axum", + "binary-install", + "cargo_metadata", + "cargo_toml", + "chrono", + "clap", + "colored 2.0.0", + "convert_case", + "dioxus", + "dirs 4.0.0", + "fern", + "flate2", + "fs_extra", + "futures", + "headers", + "html_parser", + "hyper", + "loading", + "log", + "notify", + "proc-macro2", + "regex", + "reqwest", + "serde", + "serde_json", + "syn", + "tar", + "thiserror", + "tokio", + "toml", + "tower", + "tower-http 0.2.5", + "walkdir", + "wasm-bindgen-cli-support", + "zip 0.6.2", +] + +[[package]] +name = "dioxus-core" +version = "0.2.1" +source = "git+https://github.com/dioxuslabs/dioxus/#baaa1752d3ccd5918fc472b1071b95a12b019687" +dependencies = [ + "backtrace", + "bumpalo", + "futures-channel", + "futures-util", + "fxhash", + "indexmap", + "log", + "longest-increasing-subsequence", + "once_cell", + "serde", + "slab", + "smallvec", +] + +[[package]] +name = "dioxus-core-macro" +version = "0.2.1" +source = "git+https://github.com/dioxuslabs/dioxus/#baaa1752d3ccd5918fc472b1071b95a12b019687" +dependencies = [ + "dioxus-rsx", + "dioxus-rsx-interpreter", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "dioxus-desktop" +version = "0.2.3" +source = "git+https://github.com/dioxuslabs/dioxus/#baaa1752d3ccd5918fc472b1071b95a12b019687" +dependencies = [ + "core-foundation", + "dioxus-core", + "dioxus-html", + "dioxus-interpreter-js", + "dioxus-rsx-interpreter", + "dunce", + "futures-channel", + "interprocess", + "log", + "mime_guess", + "serde", + "serde_json", + "thiserror", + "tokio", + "webbrowser", + "wry", +] + +[[package]] +name = "dioxus-hooks" +version = "0.2.1" +source = "git+https://github.com/dioxuslabs/dioxus/#baaa1752d3ccd5918fc472b1071b95a12b019687" +dependencies = [ + "dioxus-core", + "futures-channel", + "log", +] + +[[package]] +name = "dioxus-html" +version = "0.2.1" +source = "git+https://github.com/dioxuslabs/dioxus/#baaa1752d3ccd5918fc472b1071b95a12b019687" +dependencies = [ + "dioxus-core", + "enumset", + "euclid", + "keyboard-types", + "serde", + "serde_repr", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "dioxus-interpreter-js" +version = "0.2.1" +source = "git+https://github.com/dioxuslabs/dioxus/#baaa1752d3ccd5918fc472b1071b95a12b019687" +dependencies = [ + "js-sys", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "dioxus-router" +version = "0.2.3" +source = "git+https://github.com/dioxuslabs/dioxus/#baaa1752d3ccd5918fc472b1071b95a12b019687" +dependencies = [ + "futures-channel", + "futures-util", + "log", + "rsx-prelude", + "serde", + "serde_urlencoded", + "thiserror", + "url", +] + +[[package]] +name = "dioxus-rsx" +version = "0.0.0" +source = "git+https://github.com/dioxuslabs/dioxus/#baaa1752d3ccd5918fc472b1071b95a12b019687" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "dioxus-rsx-interpreter" +version = "0.1.0" +source = "git+https://github.com/dioxuslabs/dioxus/#baaa1752d3ccd5918fc472b1071b95a12b019687" +dependencies = [ + "dioxus-core", + "dioxus-hooks", + "dioxus-html", + "dioxus-rsx", + "dioxus-ssr", + "lazy_static", + "proc-macro2", + "quote", + "serde", + "serde_json", + "syn", +] + +[[package]] +name = "dioxus-ssr" +version = "0.2.1" +source = "git+https://github.com/dioxuslabs/dioxus/#baaa1752d3ccd5918fc472b1071b95a12b019687" +dependencies = [ + "dioxus-core", +] + +[[package]] +name = "dioxus-web" +version = "0.2.1" +source = "git+https://github.com/dioxuslabs/dioxus/#baaa1752d3ccd5918fc472b1071b95a12b019687" +dependencies = [ + "anyhow", + "console_error_panic_hook", + "dioxus-core", + "dioxus-html", + "dioxus-interpreter-js", + "dioxus-rsx-interpreter", + "futures-channel", + "futures-util", + "fxhash", + "gloo-timers", + "js-sys", + "log", + "once_cell", + "serde-wasm-bindgen", + "serde_json", + "smallstr", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + +[[package]] +name = "dirs" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fd78930633bd1c6e35c4b42b1df7b0cbc6bc191146e512bb3bedf243fcc3901" +dependencies = [ + "libc", + "redox_users 0.3.5", + "winapi", +] + +[[package]] +name = "dirs" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3aa72a6f96ea37bbc5aa912f6788242832f75369bdfdadcb0e38423f100059" +dependencies = [ + "dirs-sys", +] + +[[package]] +name = "dirs-sys" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6" +dependencies = [ + "libc", + "redox_users 0.4.3", + "winapi", +] + +[[package]] +name = "dispatch" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd0c93bb4b0c6d9b77f4435b0ae98c24d17f1c45b2ff844c6151a07256ca923b" + +[[package]] +name = "dunce" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "453440c271cf5577fd2a40e4942540cb7d0d2f85e27c8d07dd0023c925a67541" + +[[package]] +name = "encoding_rs" +version = "0.8.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9852635589dc9f9ea1b6fe9f05b50ef208c85c834a562f0c6abb1c475736ec2b" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "enum-as-inner" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21cdad81446a7f7dc43f6a77409efeb9733d2fa65553efef6018ef257c959b73" +dependencies = [ + "heck 0.4.0", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "enumset" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4799cdb24d48f1f8a7a98d06b7fde65a85a2d1e42b25a889f5406aa1fbefe074" +dependencies = [ + "enumset_derive", +] + +[[package]] +name = "enumset_derive" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea83a3fbdc1d999ccfbcbee717eab36f8edf2d71693a23ce0d7cca19e085304c" +dependencies = [ + "darling 0.13.4", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "euclid" +version = "0.22.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b52c2ef4a78da0ba68fbe1fd920627411096d2ac478f7f4c9f3a54ba6705bade" +dependencies = [ + "num-traits", + "serde", +] + +[[package]] +name = "event-listener" +version = "2.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77f3309417938f28bf8228fcff79a4a37103981e3e186d2ccd19c74b38f4eb71" + +[[package]] +name = "failure" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d32e9bd16cc02eae7db7ef620b392808b89f6a5e16bb3497d159c6b92a0f4f86" +dependencies = [ + "backtrace", + "failure_derive", +] + +[[package]] +name = "failure_derive" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa4da3c766cd7a0db8242e326e9e4e081edd567072893ed320008189715366a4" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] +name = "fake-simd" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" + +[[package]] +name = "fastrand" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3fcf0cee53519c866c09b5de1f6c56ff9d647101f81c1964fa632e148896cdf" +dependencies = [ + "instant", +] + +[[package]] +name = "fern" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3bdd7b0849075e79ee9a1836df22c717d1eba30451796fdc631b04565dd11e2a" +dependencies = [ + "colored 1.9.3", + "log", +] + +[[package]] +name = "field-offset" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e1c54951450cbd39f3dbcf1005ac413b49487dabf18a720ad2383eccfeffb92" +dependencies = [ + "memoffset", + "rustc_version", +] + +[[package]] +name = "filetime" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e94a7bbaa59354bc20dd75b67f23e2797b4490e9d6928203fb105c79e448c86c" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall 0.2.13", + "windows-sys", +] + +[[package]] +name = "flate2" +version = "1.0.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f82b0f4c27ad9f8bfd1f3208d882da2b09c301bc1c828fd3a00d0216d2fbbff6" +dependencies = [ + "crc32fast", + "miniz_oxide", +] + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + +[[package]] +name = "form_urlencoded" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fc25a87fa4fd2094bffb06925852034d90a17f0d1e05197d4956d3555752191" +dependencies = [ + "matches", + "percent-encoding", +] + +[[package]] +name = "fs_extra" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2022715d62ab30faffd124d40b76f4134a550a87792276512b18d63272333394" + +[[package]] +name = "fsevent-sys" +version = "4.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76ee7a02da4d231650c7cea31349b889be2f45ddb3ef3032d2ec8185f6313fd2" +dependencies = [ + "libc", +] + +[[package]] +name = "futures" +version = "0.3.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f73fe65f54d1e12b726f517d3e2135ca3125a437b6d998caf1962961f7172d9e" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3083ce4b914124575708913bca19bfe887522d6e2e6d0952943f5eac4a74010" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c09fd04b7e4073ac7156a9539b57a484a8ea920f79c7c675d05d289ab6110d3" + +[[package]] +name = "futures-executor" +version = "0.3.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9420b90cfa29e327d0429f19be13e7ddb68fa1cccb09d65e5706b8c7a749b8a6" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-io" +version = "0.3.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc4045962a5a5e935ee2fdedaa4e08284547402885ab326734432bed5d12966b" + +[[package]] +name = "futures-lite" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7694489acd39452c77daa48516b894c153f192c3578d5a839b62c58099fcbf48" +dependencies = [ + "fastrand", + "futures-core", + "futures-io", + "memchr", + "parking", + "pin-project-lite", + "waker-fn", +] + +[[package]] +name = "futures-macro" +version = "0.3.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33c1e13800337f4d4d7a316bf45a567dbcb6ffe087f16424852d97e97a91f512" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "futures-sink" +version = "0.3.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21163e139fa306126e6eedaf49ecdb4588f939600f0b1e770f4205ee4b7fa868" + +[[package]] +name = "futures-task" +version = "0.3.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57c66a976bf5909d801bbef33416c41372779507e7a6b3a5e25e4749c58f776a" + +[[package]] +name = "futures-util" +version = "0.3.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8b7abd5d659d9b90c8cba917f6ec750a74e2dc23902ef9cd4cc8c8b22e6036a" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "pin-utils", + "slab", +] + +[[package]] +name = "fxhash" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c" +dependencies = [ + "byteorder", +] + +[[package]] +name = "gdk" +version = "0.15.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6e05c1f572ab0e1f15be94217f0dc29088c248b14f792a5ff0af0d84bcda9e8" +dependencies = [ + "bitflags", + "cairo-rs", + "gdk-pixbuf", + "gdk-sys", + "gio", + "glib", + "libc", + "pango", +] + +[[package]] +name = "gdk-pixbuf" +version = "0.15.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad38dd9cc8b099cceecdf41375bb6d481b1b5a7cd5cd603e10a69a9383f8619a" +dependencies = [ + "bitflags", + "gdk-pixbuf-sys", + "gio", + "glib", + "libc", +] + +[[package]] +name = "gdk-pixbuf-sys" +version = "0.15.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "140b2f5378256527150350a8346dbdb08fadc13453a7a2d73aecd5fab3c402a7" +dependencies = [ + "gio-sys", + "glib-sys", + "gobject-sys", + "libc", + "system-deps 6.0.2", +] + +[[package]] +name = "gdk-sys" +version = "0.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32e7a08c1e8f06f4177fb7e51a777b8c1689f743a7bc11ea91d44d2226073a88" +dependencies = [ + "cairo-sys-rs", + "gdk-pixbuf-sys", + "gio-sys", + "glib-sys", + "gobject-sys", + "libc", + "pango-sys", + "pkg-config", + "system-deps 6.0.2", +] + +[[package]] +name = "gdkx11-sys" +version = "0.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4b7f8c7a84b407aa9b143877e267e848ff34106578b64d1e0a24bf550716178" +dependencies = [ + "gdk-sys", + "glib-sys", + "libc", + "system-deps 6.0.2", + "x11", +] + +[[package]] +name = "generic-array" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd" +dependencies = [ + "typenum", +] + +[[package]] +name = "generic-array" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd48d33ec7f05fbfa152300fdad764757cbded343c1aa1cff2fbaf4134851803" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" +dependencies = [ + "cfg-if", + "libc", + "wasi 0.9.0+wasi-snapshot-preview1", +] + +[[package]] +name = "getrandom" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4eb1a864a501629691edf6c15a593b7a51eebaa1e8468e9ddc623de7c9b58ec6" +dependencies = [ + "cfg-if", + "libc", + "wasi 0.11.0+wasi-snapshot-preview1", +] + +[[package]] +name = "gimli" +version = "0.26.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78cc372d058dcf6d5ecd98510e7fbc9e5aec4d21de70f65fea8fecebcd881bd4" + +[[package]] +name = "gio" +version = "0.15.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68fdbc90312d462781a395f7a16d96a2b379bb6ef8cd6310a2df272771c4283b" +dependencies = [ + "bitflags", + "futures-channel", + "futures-core", + "futures-io", + "gio-sys", + "glib", + "libc", + "once_cell", + "thiserror", +] + +[[package]] +name = "gio-sys" +version = "0.15.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32157a475271e2c4a023382e9cab31c4584ee30a97da41d3c4e9fdd605abcf8d" +dependencies = [ + "glib-sys", + "gobject-sys", + "libc", + "system-deps 6.0.2", + "winapi", +] + +[[package]] +name = "glib" +version = "0.15.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edb0306fbad0ab5428b0ca674a23893db909a98582969c9b537be4ced78c505d" +dependencies = [ + "bitflags", + "futures-channel", + "futures-core", + "futures-executor", + "futures-task", + "glib-macros", + "glib-sys", + "gobject-sys", + "libc", + "once_cell", + "smallvec", + "thiserror", +] + +[[package]] +name = "glib-macros" +version = "0.15.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25a68131a662b04931e71891fb14aaf65ee4b44d08e8abc10f49e77418c86c64" +dependencies = [ + "anyhow", + "heck 0.4.0", + "proc-macro-crate 1.1.3", + "proc-macro-error", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "glib-sys" +version = "0.15.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef4b192f8e65e9cf76cbf4ea71fa8e3be4a0e18ffe3d68b8da6836974cc5bad4" +dependencies = [ + "libc", + "system-deps 6.0.2", +] + +[[package]] +name = "gloo-timers" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fb7d06c1c8cc2a29bee7ec961009a0b2caa0793ee4900c2ffb348734ba1c8f9" +dependencies = [ + "futures-channel", + "futures-core", + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "gobject-sys" +version = "0.15.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d57ce44246becd17153bd035ab4d32cfee096a657fc01f2231c9278378d1e0a" +dependencies = [ + "glib-sys", + "libc", + "system-deps 6.0.2", +] + +[[package]] +name = "gtk" +version = "0.15.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92e3004a2d5d6d8b5057d2b57b3712c9529b62e82c77f25c1fecde1fd5c23bd0" +dependencies = [ + "atk", + "bitflags", + "cairo-rs", + "field-offset", + "futures-channel", + "gdk", + "gdk-pixbuf", + "gio", + "glib", + "gtk-sys", + "gtk3-macros", + "libc", + "once_cell", + "pango", + "pkg-config", +] + +[[package]] +name = "gtk-sys" +version = "0.15.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5bc2f0587cba247f60246a0ca11fe25fb733eabc3de12d1965fc07efab87c84" +dependencies = [ + "atk-sys", + "cairo-sys-rs", + "gdk-pixbuf-sys", + "gdk-sys", + "gio-sys", + "glib-sys", + "gobject-sys", + "libc", + "pango-sys", + "system-deps 6.0.2", +] + +[[package]] +name = "gtk3-macros" +version = "0.15.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24f518afe90c23fba585b2d7697856f9e6a7bbc62f65588035e66f6afb01a2e9" +dependencies = [ + "anyhow", + "proc-macro-crate 1.1.3", + "proc-macro-error", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "h2" +version = "0.3.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37a82c6d637fc9515a4694bbf1cb2457b79d81ce52b3108bdeea58b07dd34a57" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http", + "indexmap", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "hashbrown" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db0d4cf898abf0081f964436dc980e96670a0f36863e4b83aaacdb65c9d7ccc3" + +[[package]] +name = "headers" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cff78e5788be1e0ab65b04d306b2ed5092c815ec97ec70f4ebd5aee158aa55d" +dependencies = [ + "base64 0.13.0", + "bitflags", + "bytes", + "headers-core", + "http", + "httpdate", + "mime", + "sha-1 0.10.0", +] + +[[package]] +name = "headers-core" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7f66481bfee273957b1f20485a4ff3362987f85b2c236580d81b4eb7a326429" +dependencies = [ + "http", +] + +[[package]] +name = "heck" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" +dependencies = [ + "unicode-segmentation", +] + +[[package]] +name = "heck" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9" + +[[package]] +name = "hermit-abi" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" +dependencies = [ + "libc", +] + +[[package]] +name = "hex" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "805026a5d0141ffc30abb3be3173848ad46a1b1664fe632428479619a3644d77" + +[[package]] +name = "hmac" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" +dependencies = [ + "digest 0.10.3", +] + +[[package]] +name = "hostname" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c731c3e10504cc8ed35cfe2f1db4c9274c3d35fa486e3b31df46f068ef3e867" +dependencies = [ + "libc", + "match_cfg", + "winapi", +] + +[[package]] +name = "html_parser" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec016cabcf7c9c48f9d5fdc6b03f273585bfce640a0f47a69552039e92b1959a" +dependencies = [ + "pest", + "pest_derive", + "serde", + "serde_derive", + "serde_json", + "thiserror", +] + +[[package]] +name = "http" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75f43d41e26995c17e71ee126451dd3941010b0514a81a9d11f3b341debc2399" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http-body" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" +dependencies = [ + "bytes", + "http", + "pin-project-lite", +] + +[[package]] +name = "http-range-header" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bfe8eed0a9285ef776bb792479ea3834e8b94e13d615c2f66d03dd50a435a29" + +[[package]] +name = "httparse" +version = "1.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "496ce29bb5a52785b44e0f7ca2847ae0bb839c9bd28f69acac9b99d461c0c04c" + +[[package]] +name = "httpdate" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" + +[[package]] +name = "hyper" +version = "0.14.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42dc3c131584288d375f2d07f822b0cb012d8c6fb899a5b9fdb3cb7eb9b6004f" +dependencies = [ + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "socket2", + "tokio", + "tower-service", + "tracing", + "want", +] + +[[package]] +name = "hyper-rustls" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d87c48c02e0dc5e3b849a2041db3029fd066650f8f717c07bf8ed78ccb895cac" +dependencies = [ + "http", + "hyper", + "rustls", + "tokio", + "tokio-rustls", +] + +[[package]] +name = "hyper-tls" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" +dependencies = [ + "bytes", + "hyper", + "native-tls", + "tokio", + "tokio-native-tls", +] + +[[package]] +name = "id-arena" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25a2bc672d1148e28034f176e01fffebb08b35768468cc954630da77a1449005" + +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + +[[package]] +name = "idna" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "418a0a6fab821475f634efe3ccc45c013f742efe03d853e8d3355d5cb850ecf8" +dependencies = [ + "matches", + "unicode-bidi", + "unicode-normalization", +] + +[[package]] +name = "indexmap" +version = "1.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10a35a97730320ffe8e2d410b5d3b69279b98d2c14bdb8b70ea89ecf7888d41e" +dependencies = [ + "autocfg", + "hashbrown", +] + +[[package]] +name = "inotify" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8069d3ec154eb856955c1c0fbffefbf5f3c40a104ec912d4797314c1801abff" +dependencies = [ + "bitflags", + "inotify-sys", + "libc", +] + +[[package]] +name = "inotify-sys" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e05c02b5e89bff3b946cedeca278abc628fe811e604f027c45a8aa3cf793d0eb" +dependencies = [ + "libc", +] + +[[package]] +name = "instant" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "interprocess" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c58ec7fbda1df9a93f587b780659db3c99f61f4be27f9c82c9b37684ffd0366" +dependencies = [ + "blocking", + "cfg-if", + "futures", + "intmap", + "libc", + "once_cell", + "spinning", + "thiserror", + "winapi", +] + +[[package]] +name = "intmap" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae52f28f45ac2bc96edb7714de995cffc174a395fb0abf5bff453587c980d7b9" + +[[package]] +name = "ipconfig" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "723519edce41262b05d4143ceb95050e4c614f483e78e9fd9e39a8275a84ad98" +dependencies = [ + "socket2", + "widestring", + "winapi", + "winreg 0.7.0", +] + +[[package]] +name = "ipnet" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "879d54834c8c76457ef4293a689b2a8c59b076067ad77b15efafbb05f92a592b" + +[[package]] +name = "is_executable" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "302d553b8abc8187beb7d663e34c065ac4570b273bc9511a50e940e99409c577" +dependencies = [ + "winapi", +] + +[[package]] +name = "itoa" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "112c678d4050afce233f4f2852bb2eb519230b3cf12f33585275537d7e41578d" + +[[package]] +name = "javascriptcore-rs" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf053e7843f2812ff03ef5afe34bb9c06ffee120385caad4f6b9967fcd37d41c" +dependencies = [ + "bitflags", + "glib", + "javascriptcore-rs-sys", +] + +[[package]] +name = "javascriptcore-rs-sys" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "905fbb87419c5cde6e3269537e4ea7d46431f3008c5d057e915ef3f115e7793c" +dependencies = [ + "glib-sys", + "gobject-sys", + "libc", + "system-deps 5.0.0", +] + +[[package]] +name = "jni" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24967112a1e4301ca5342ea339763613a37592b8a6ce6cf2e4494537c7a42faf" +dependencies = [ + "cesu8", + "combine", + "jni-sys", + "log", + "thiserror", + "walkdir", +] + +[[package]] +name = "jni" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6df18c2e3db7e453d3c6ac5b3e9d5182664d28788126d39b91f2d1e22b017ec" +dependencies = [ + "cesu8", + "combine", + "jni-sys", + "log", + "thiserror", + "walkdir", +] + +[[package]] +name = "jni-sys" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" + +[[package]] +name = "jobserver" +version = "0.1.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af25a77299a7f711a01975c35a6a424eb6862092cc2d6c72c4ed6cbc56dfc1fa" +dependencies = [ + "libc", +] + +[[package]] +name = "js-sys" +version = "0.3.58" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3fac17f7123a73ca62df411b1bf727ccc805daa070338fda671c86dac1bdc27" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "keyboard-types" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7668b7cff6a51fe61cdde64cd27c8a220786f399501b57ebe36f7d8112fd68" +dependencies = [ + "bitflags", + "serde", + "unicode-segmentation", +] + +[[package]] +name = "kqueue" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d6112e8f37b59803ac47a42d14f1f3a59bbf72fc6857ffc5be455e28a691f8e" +dependencies = [ + "kqueue-sys", + "libc", +] + +[[package]] +name = "kqueue-sys" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8367585489f01bc55dd27404dcf56b95e6da061a256a666ab23be9ba96a2e587" +dependencies = [ + "bitflags", + "libc", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "leb128" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" + +[[package]] +name = "libayatana-appindicator" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0379d22a323947cb27b4dbe3b14fc1dcde07c9e9c3eca52ddf97ca0819c28cc4" +dependencies = [ + "glib", + "gtk", + "gtk-sys", + "log", +] + +[[package]] +name = "libc" +version = "0.2.126" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836" + +[[package]] +name = "libz-sys" +version = "1.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9702761c3935f8cc2f101793272e202c72b99da8f4224a19ddcf1279a6450bbf" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "linked-hash-map" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" + +[[package]] +name = "loading" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "676420b03272176423578148eee61319e893422694f6d96a394841cb0901357f" + +[[package]] +name = "lock_api" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "327fa5b6a6940e4699ec49a9beae1ea4845c6bab9314e4f84ac68742139d8c53" +dependencies = [ + "autocfg", + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "longest-increasing-subsequence" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3bd0dd2cd90571056fdb71f6275fada10131182f84899f4b2a916e565d81d86" + +[[package]] +name = "lru-cache" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31e24f1ad8321ca0e8a1e0ac13f23cb668e6f5466c2c57319f6a5cf1cc8e3b1c" +dependencies = [ + "linked-hash-map", +] + +[[package]] +name = "malloc_buf" +version = "0.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62bb907fe88d54d8d9ce32a3cceab4218ed2f6b7d35617cafe9adf84e43919cb" +dependencies = [ + "libc", +] + +[[package]] +name = "maplit" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d" + +[[package]] +name = "match_cfg" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffbee8634e0d45d258acb448e7eaab3fce7a0a467395d4d9f228e3c1f01fb2e4" + +[[package]] +name = "matches" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f" + +[[package]] +name = "matchit" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73cbba799671b762df5a175adf59ce145165747bb891505c43d09aefbbf38beb" + +[[package]] +name = "memchr" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" + +[[package]] +name = "memoffset" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" +dependencies = [ + "autocfg", +] + +[[package]] +name = "mime" +version = "0.3.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" + +[[package]] +name = "mime_guess" +version = "2.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4192263c238a5f0d0c6bfd21f336a313a4ce1c450542449ca191bb657b4642ef" +dependencies = [ + "mime", + "unicase", +] + +[[package]] +name = "miniz_oxide" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f5c75688da582b8ffc1f1799e9db273f32133c49e048f614d22ec3256773ccc" +dependencies = [ + "adler", +] + +[[package]] +name = "mio" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57ee1c23c7c63b0c9250c339ffdc69255f110b298b901b9f6c82547b7b87caaf" +dependencies = [ + "libc", + "log", + "wasi 0.11.0+wasi-snapshot-preview1", + "windows-sys", +] + +[[package]] +name = "native-tls" +version = "0.2.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd7e2f3618557f980e0b17e8856252eee3c97fa12c54dff0ca290fb6266ca4a9" +dependencies = [ + "lazy_static", + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", +] + +[[package]] +name = "ndk" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d64d6af06fde0e527b1ba5c7b79a6cc89cfc46325b0b2887dffe8f70197e0c3c" +dependencies = [ + "bitflags", + "jni-sys", + "ndk-sys 0.2.2", + "num_enum", + "thiserror", +] + +[[package]] +name = "ndk" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2032c77e030ddee34a6787a64166008da93f6a352b629261d0fee232b8742dd4" +dependencies = [ + "bitflags", + "jni-sys", + "ndk-sys 0.3.0", + "num_enum", + "thiserror", +] + +[[package]] +name = "ndk-context" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27b02d87554356db9e9a873add8782d4ea6e3e58ea071a9adb9a2e8ddb884a8b" + +[[package]] +name = "ndk-glue" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3648f3609716eb7dbf5f5b5d4b84fcd67dd4c34efcdb12e4a6c0929c2ac48349" +dependencies = [ + "lazy_static", + "libc", + "log", + "ndk 0.4.0", + "ndk-context", + "ndk-macro 0.2.0", + "ndk-sys 0.2.2", +] + +[[package]] +name = "ndk-glue" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d0c4a7b83860226e6b4183edac21851f05d5a51756e97a1144b7f5a6b63e65f" +dependencies = [ + "lazy_static", + "libc", + "log", + "ndk 0.6.0", + "ndk-context", + "ndk-macro 0.3.0", + "ndk-sys 0.3.0", +] + +[[package]] +name = "ndk-macro" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05d1c6307dc424d0f65b9b06e94f88248e6305726b14729fd67a5e47b2dc481d" +dependencies = [ + "darling 0.10.2", + "proc-macro-crate 0.1.5", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "ndk-macro" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0df7ac00c4672f9d5aece54ee3347520b7e20f158656c7db2e6de01902eb7a6c" +dependencies = [ + "darling 0.13.4", + "proc-macro-crate 1.1.3", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "ndk-sys" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1bcdd74c20ad5d95aacd60ef9ba40fdf77f767051040541df557b7a9b2a2121" + +[[package]] +name = "ndk-sys" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e5a6ae77c8ee183dcbbba6150e2e6b9f3f4196a7666c02a715a95692ec1fa97" +dependencies = [ + "jni-sys", +] + +[[package]] +name = "notify" +version = "5.0.0-pre.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "553f9844ad0b0824605c20fb55a661679782680410abfb1a8144c2e7e437e7a7" +dependencies = [ + "bitflags", + "crossbeam-channel", + "filetime", + "fsevent-sys", + "inotify", + "kqueue", + "libc", + "mio", + "serde", + "walkdir", + "winapi", +] + +[[package]] +name = "num-integer" +version = "0.1.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" +dependencies = [ + "autocfg", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +dependencies = [ + "autocfg", +] + +[[package]] +name = "num_cpus" +version = "1.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19e64526ebdee182341572e50e9ad03965aa510cd94427a4549448f285e957a1" +dependencies = [ + "hermit-abi", + "libc", +] + +[[package]] +name = "num_enum" +version = "0.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf5395665662ef45796a4ff5486c5d41d29e0c09640af4c5f17fd94ee2c119c9" +dependencies = [ + "num_enum_derive", +] + +[[package]] +name = "num_enum_derive" +version = "0.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b0498641e53dd6ac1a4f22547548caa6864cc4933784319cd1775271c5a46ce" +dependencies = [ + "proc-macro-crate 1.1.3", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "num_threads" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2819ce041d2ee131036f4fc9d6ae7ae125a3a40e97ba64d04fe799ad9dabbb44" +dependencies = [ + "libc", +] + +[[package]] +name = "objc" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "915b1b472bc21c53464d6c8461c9d3af805ba1ef837e1cac254428f4a77177b1" +dependencies = [ + "malloc_buf", + "objc_exception", +] + +[[package]] +name = "objc_exception" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad970fb455818ad6cba4c122ad012fae53ae8b4795f86378bce65e4f6bab2ca4" +dependencies = [ + "cc", +] + +[[package]] +name = "objc_id" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c92d4ddb4bd7b50d730c215ff871754d0da6b2178849f8a2a2ab69712d0c073b" +dependencies = [ + "objc", +] + +[[package]] +name = "object" +version = "0.28.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e42c982f2d955fac81dd7e1d0e1426a7d702acd9c98d19ab01083a6a0328c424" +dependencies = [ + "memchr", +] + +[[package]] +name = "once_cell" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18a6dbe30758c9f83eb00cbea4ac95966305f5a7772f3f42ebfc7fc7eddbd8e1" + +[[package]] +name = "opaque-debug" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" + +[[package]] +name = "opaque-debug" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" + +[[package]] +name = "openssl" +version = "0.10.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb81a6430ac911acb25fe5ac8f1d2af1b4ea8a4fdfda0f1ee4292af2e2d8eb0e" +dependencies = [ + "bitflags", + "cfg-if", + "foreign-types", + "libc", + "once_cell", + "openssl-macros", + "openssl-sys", +] + +[[package]] +name = "openssl-macros" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b501e44f11665960c7e7fcf062c7d96a14ade4aa98116c004b2e37b5be7d736c" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "openssl-probe" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" + +[[package]] +name = "openssl-sys" +version = "0.9.74" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "835363342df5fba8354c5b453325b110ffd54044e588c539cf2f20a8014e4cb1" +dependencies = [ + "autocfg", + "cc", + "libc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "os_str_bytes" +version = "6.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21326818e99cfe6ce1e524c2a805c189a99b5ae555a35d19f9a284b427d86afa" + +[[package]] +name = "pango" +version = "0.15.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22e4045548659aee5313bde6c582b0d83a627b7904dd20dc2d9ef0895d414e4f" +dependencies = [ + "bitflags", + "glib", + "libc", + "once_cell", + "pango-sys", +] + +[[package]] +name = "pango-sys" +version = "0.15.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2a00081cde4661982ed91d80ef437c20eacaf6aa1a5962c0279ae194662c3aa" +dependencies = [ + "glib-sys", + "gobject-sys", + "libc", + "system-deps 6.0.2", +] + +[[package]] +name = "parking" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "427c3892f9e783d91cc128285287e70a59e206ca452770ece88a76f7a3eddd72" + +[[package]] +name = "parking_lot" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" +dependencies = [ + "instant", + "lock_api", + "parking_lot_core 0.8.5", +] + +[[package]] +name = "parking_lot" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +dependencies = [ + "lock_api", + "parking_lot_core 0.9.3", +] + +[[package]] +name = "parking_lot_core" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d76e8e1493bcac0d2766c42737f34458f1c8c50c0d23bcb24ea953affb273216" +dependencies = [ + "cfg-if", + "instant", + "libc", + "redox_syscall 0.2.13", + "smallvec", + "winapi", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09a279cbf25cb0757810394fbc1e359949b59e348145c643a939a525692e6929" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall 0.2.13", + "smallvec", + "windows-sys", +] + +[[package]] +name = "password-hash" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d791538a6dcc1e7cb7fe6f6b58aca40e7f79403c45b2bc274008b5e647af1d8" +dependencies = [ + "base64ct", + "rand_core", + "subtle", +] + +[[package]] +name = "pbkdf2" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "271779f35b581956db91a3e55737327a03aa051e90b1c47aeb189508533adfd7" +dependencies = [ + "digest 0.10.3", + "hmac", + "password-hash", + "sha2", +] + +[[package]] +name = "percent-encoding" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" + +[[package]] +name = "pest" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10f4872ae94d7b90ae48754df22fd42ad52ce740b8f370b03da4835417403e53" +dependencies = [ + "ucd-trie", +] + +[[package]] +name = "pest_derive" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "833d1ae558dc601e9a60366421196a8d94bc0ac980476d0b67e1d0988d72b2d0" +dependencies = [ + "pest", + "pest_generator", +] + +[[package]] +name = "pest_generator" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99b8db626e31e5b81787b9783425769681b347011cc59471e33ea46d2ea0cf55" +dependencies = [ + "pest", + "pest_meta", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "pest_meta" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "54be6e404f5317079812fc8f9f5279de376d8856929e21c184ecf6bbd692a11d" +dependencies = [ + "maplit", + "pest", + "sha-1 0.8.2", +] + +[[package]] +name = "pin-project" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78203e83c48cffbe01e4a2d35d566ca4de445d79a85372fc64e378bfc812a260" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "710faf75e1b33345361201d36d04e98ac1ed8909151a017ed384700836104c74" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "pkg-config" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1df8c4ec4b0627e53bdf214615ad287367e482558cf84b109250b37464dc03ae" + +[[package]] +name = "ppv-lite86" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" + +[[package]] +name = "proc-macro-crate" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d6ea3c4595b96363c13943497db34af4460fb474a95c43f4446ad341b8c9785" +dependencies = [ + "toml", +] + +[[package]] +name = "proc-macro-crate" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e17d47ce914bf4de440332250b0edd23ce48c005f59fab39d3335866b114f11a" +dependencies = [ + "thiserror", + "toml", +] + +[[package]] +name = "proc-macro-error" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" +dependencies = [ + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn", + "version_check", +] + +[[package]] +name = "proc-macro-error-attr" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" +dependencies = [ + "proc-macro2", + "quote", + "version_check", +] + +[[package]] +name = "proc-macro2" +version = "1.0.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd96a1e8ed2596c337f8eae5f24924ec83f5ad5ab21ea8e455d3566c69fbcaf7" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quick-error" +version = "1.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" + +[[package]] +name = "quote" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3bcdf212e9776fbcb2d23ab029360416bb1706b1aea2d1a5ba002727cbcab804" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7" +dependencies = [ + "getrandom 0.2.7", +] + +[[package]] +name = "raw-window-handle" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b800beb9b6e7d2df1fe337c9e3d04e3af22a124460fb4c30fcc22c9117cefb41" +dependencies = [ + "cty", +] + +[[package]] +name = "redox_syscall" +version = "0.1.57" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" + +[[package]] +name = "redox_syscall" +version = "0.2.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62f25bc4c7e55e0b0b7a1d43fb893f4fa1361d0abe38b9ce4f323c2adfe6ef42" +dependencies = [ + "bitflags", +] + +[[package]] +name = "redox_users" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de0737333e7a9502c789a36d7c7fa6092a49895d4faa31ca5df163857ded2e9d" +dependencies = [ + "getrandom 0.1.16", + "redox_syscall 0.1.57", + "rust-argon2", +] + +[[package]] +name = "redox_users" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" +dependencies = [ + "getrandom 0.2.7", + "redox_syscall 0.2.13", + "thiserror", +] + +[[package]] +name = "regex" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c4eb3267174b8c6c2f654116623910a0fef09c4753f8dd83db29c48a0df988b" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.6.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244" + +[[package]] +name = "remove_dir_all" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" +dependencies = [ + "winapi", +] + +[[package]] +name = "reqwest" +version = "0.11.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b75aa69a3f06bbcc66ede33af2af253c6f7a86b1ca0033f60c580a27074fbf92" +dependencies = [ + "base64 0.13.0", + "bytes", + "encoding_rs", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "hyper", + "hyper-rustls", + "hyper-tls", + "ipnet", + "js-sys", + "lazy_static", + "log", + "mime", + "native-tls", + "percent-encoding", + "pin-project-lite", + "rustls", + "rustls-pemfile", + "serde", + "serde_json", + "serde_urlencoded", + "tokio", + "tokio-native-tls", + "tokio-rustls", + "tokio-util", + "tower-service", + "trust-dns-resolver", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "webpki-roots", + "winreg 0.10.1", +] + +[[package]] +name = "resolv-conf" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52e44394d2086d010551b14b53b1f24e31647570cd1deb0379e2c21b329aba00" +dependencies = [ + "hostname", + "quick-error", +] + +[[package]] +name = "ring" +version = "0.16.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc" +dependencies = [ + "cc", + "libc", + "once_cell", + "spin", + "untrusted", + "web-sys", + "winapi", +] + +[[package]] +name = "rsx-prelude" +version = "0.1.0" +source = "git+https://github.com/dioxuslabs/dioxus/#baaa1752d3ccd5918fc472b1071b95a12b019687" +dependencies = [ + "dioxus-core", + "dioxus-core-macro", + "dioxus-hooks", + "dioxus-html", + "dioxus-rsx-interpreter", +] + +[[package]] +name = "rust-argon2" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b18820d944b33caa75a71378964ac46f58517c92b6ae5f762636247c09e78fb" +dependencies = [ + "base64 0.13.0", + "blake2b_simd", + "constant_time_eq", + "crossbeam-utils", +] + +[[package]] +name = "rustc-demangle" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342" + +[[package]] +name = "rustc_version" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0dfe2087c51c460008730de8b57e6a320782fbfb312e1f4d520e6c6fae155ee" +dependencies = [ + "semver 0.11.0", +] + +[[package]] +name = "rustls" +version = "0.20.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5aab8ee6c7097ed6057f43c187a62418d0c05a4bd5f18b3571db50ee0f9ce033" +dependencies = [ + "log", + "ring", + "sct", + "webpki", +] + +[[package]] +name = "rustls-pemfile" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7522c9de787ff061458fe9a829dc790a3f5b22dc571694fc5883f448b94d9a9" +dependencies = [ + "base64 0.13.0", +] + +[[package]] +name = "ryu" +version = "1.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3f6f92acf49d1b98f7a81226834412ada05458b7364277387724a237f062695" + +[[package]] +name = "safemem" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef703b7cb59335eae2eb93ceb664c0eb7ea6bf567079d843e09420219668e072" + +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "schannel" +version = "0.1.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88d6731146462ea25d9244b2ed5fd1d716d25c52e4d54aa4fb0f3c4e9854dbe2" +dependencies = [ + "lazy_static", + "windows-sys", +] + +[[package]] +name = "scopeguard" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" + +[[package]] +name = "sct" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d53dcdb7c9f8158937a7981b48accfd39a43af418591a5d008c7b22b5e1b7ca4" +dependencies = [ + "ring", + "untrusted", +] + +[[package]] +name = "security-framework" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dc14f172faf8a0194a3aded622712b0de276821addc574fa54fc0a1167e10dc" +dependencies = [ + "bitflags", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0160a13a177a45bfb43ce71c01580998474f556ad854dcbca936dd2841a5c556" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "semver" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6" +dependencies = [ + "semver-parser", +] + +[[package]] +name = "semver" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2333e6df6d6598f2b1974829f853c2b4c5f4a6e503c10af918081aa6f8564e1" +dependencies = [ + "serde", +] + +[[package]] +name = "semver-parser" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0bef5b7f9e0df16536d3961cfb6e84331c065b4066afb39768d0e319411f7" +dependencies = [ + "pest", +] + +[[package]] +name = "serde" +version = "1.0.138" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1578c6245786b9d168c5447eeacfb96856573ca56c9d68fdcf394be134882a47" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde-wasm-bindgen" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cfc62771e7b829b517cb213419236475f434fb480eddd76112ae182d274434a" +dependencies = [ + "js-sys", + "serde", + "wasm-bindgen", +] + +[[package]] +name = "serde_derive" +version = "1.0.138" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "023e9b1467aef8a10fb88f25611870ada9800ef7e22afce356bb0d2387b6f27c" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.82" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82c2c1fdcd807d1098552c5b9a36e425e42e9fbd7c6a37a8425f390f781f7fa7" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "serde_repr" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2ad84e47328a31223de7fed7a4f5087f2d6ddfe586cf3ca25b7a165bc0a5aed" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_urlencoded" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" +dependencies = [ + "form_urlencoded", + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "sha-1" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7d94d0bede923b3cea61f3f1ff57ff8cdfd77b400fb8f9998949e0cf04163df" +dependencies = [ + "block-buffer 0.7.3", + "digest 0.8.1", + "fake-simd", + "opaque-debug 0.2.3", +] + +[[package]] +name = "sha-1" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "028f48d513f9678cda28f6e4064755b3fbb2af6acd672f2c209b62323f7aea0f" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest 0.10.3", +] + +[[package]] +name = "sha1" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c77f4e7f65455545c2153c1253d25056825e77ee2533f0e41deb65a93a34852f" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest 0.10.3", +] + +[[package]] +name = "sha2" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55deaec60f81eefe3cce0dc50bda92d6d8e88f2a27df7c5033b42afeb1ed2676" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest 0.10.3", +] + +[[package]] +name = "signal-hook-registry" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e51e73328dc4ac0c7ccbda3a494dfa03df1de2f46018127f60c693f2648455b0" +dependencies = [ + "libc", +] + +[[package]] +name = "siphasher" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b8de496cf83d4ed58b6be86c3a275b8602f6ffe98d3024a869e124147a9a3ac" + +[[package]] +name = "slab" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb703cfe953bccee95685111adeedb76fabe4e97549a58d16f03ea7b9367bb32" + +[[package]] +name = "smallstr" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e922794d168678729ffc7e07182721a14219c65814e66e91b839a272fe5ae4f" +dependencies = [ + "smallvec", +] + +[[package]] +name = "smallvec" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2fd0db749597d91ff862fd1d55ea87f7855a744a8425a64695b6fca237d1dad1" + +[[package]] +name = "socket2" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "66d72b759436ae32898a2af0a14218dbf55efde3feeb170eb623637db85ee1e0" +dependencies = [ + "libc", + "winapi", +] + +[[package]] +name = "soup2" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2b4d76501d8ba387cf0fefbe055c3e0a59891d09f0f995ae4e4b16f6b60f3c0" +dependencies = [ + "bitflags", + "gio", + "glib", + "libc", + "once_cell", + "soup2-sys", +] + +[[package]] +name = "soup2-sys" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "009ef427103fcb17f802871647a7fa6c60cbb654b4c4e4c0ac60a31c5f6dc9cf" +dependencies = [ + "bitflags", + "gio-sys", + "glib-sys", + "gobject-sys", + "libc", + "system-deps 5.0.0", +] + +[[package]] +name = "spin" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" + +[[package]] +name = "spinning" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d4f0e86297cad2658d92a707320d87bf4e6ae1050287f51d19b67ef3f153a7b" +dependencies = [ + "lock_api", +] + +[[package]] +name = "strsim" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6446ced80d6c486436db5c078dde11a9f73d42b57fb273121e160b84f63d894c" + +[[package]] +name = "strsim" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" + +[[package]] +name = "subtle" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" + +[[package]] +name = "syn" +version = "1.0.98" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c50aef8a904de4c23c788f104b7dddc7d6f79c647c7c8ce4cc8f73eb0ca773dd" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "sync_wrapper" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20518fe4a4c9acf048008599e464deb21beeae3d3578418951a189c235a7a9a8" + +[[package]] +name = "synstructure" +version = "0.12.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "unicode-xid", +] + +[[package]] +name = "system-deps" +version = "5.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18db855554db7bd0e73e06cf7ba3df39f97812cb11d3f75e71c39bf45171797e" +dependencies = [ + "cfg-expr 0.9.1", + "heck 0.3.3", + "pkg-config", + "toml", + "version-compare 0.0.11", +] + +[[package]] +name = "system-deps" +version = "6.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1a45a1c4c9015217e12347f2a411b57ce2c4fc543913b14b6fe40483328e709" +dependencies = [ + "cfg-expr 0.10.3", + "heck 0.4.0", + "pkg-config", + "toml", + "version-compare 0.1.0", +] + +[[package]] +name = "tao" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df895eb66ff23d1824055114d6fbdd2c297bf70ad85349a4adaee0f8b2a860d1" +dependencies = [ + "bitflags", + "cairo-rs", + "cc", + "cocoa", + "core-foundation", + "core-graphics", + "crossbeam-channel", + "dispatch", + "gdk", + "gdk-pixbuf", + "gdk-sys", + "gdkx11-sys", + "gio", + "glib", + "glib-sys", + "gtk", + "instant", + "lazy_static", + "libayatana-appindicator", + "libc", + "log", + "ndk 0.4.0", + "ndk-glue 0.4.2", + "ndk-sys 0.2.2", + "objc", + "parking_lot 0.11.2", + "raw-window-handle", + "scopeguard", + "serde", + "tao-core-video-sys", + "unicode-segmentation", + "windows", + "windows_macros", + "x11-dl", +] + +[[package]] +name = "tao-core-video-sys" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "271450eb289cb4d8d0720c6ce70c72c8c858c93dd61fc625881616752e6b98f6" +dependencies = [ + "cfg-if", + "core-foundation-sys", + "libc", + "objc", +] + +[[package]] +name = "tar" +version = "0.4.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b55807c0344e1e6c04d7c965f5289c39a8d94ae23ed5c0b57aabac549f871c6" +dependencies = [ + "filetime", + "libc", + "xattr", +] + +[[package]] +name = "tempfile" +version = "3.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4" +dependencies = [ + "cfg-if", + "fastrand", + "libc", + "redox_syscall 0.2.13", + "remove_dir_all", + "winapi", +] + +[[package]] +name = "termcolor" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "textwrap" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1141d4d61095b28419e22cb0bbf02755f5e54e0526f97f1e3d1d160e60885fb" + +[[package]] +name = "thiserror" +version = "1.0.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd829fe32373d27f76265620b5309d0340cb8550f523c1dda251d6298069069a" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0396bc89e626244658bef819e22d0cc459e795a5ebe878e6ec336d1674a8d79a" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "time" +version = "0.1.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255" +dependencies = [ + "libc", + "wasi 0.10.0+wasi-snapshot-preview1", + "winapi", +] + +[[package]] +name = "time" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72c91f41dcb2f096c05f0873d667dceec1087ce5bcf984ec8ffb19acddbb3217" +dependencies = [ + "itoa", + "libc", + "num_threads", + "time-macros", +] + +[[package]] +name = "time-macros" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42657b1a6f4d817cda8e7a0ace261fe0cc946cf3a80314390b22cc61ae080792" + +[[package]] +name = "tinyvec" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" + +[[package]] +name = "tokio" +version = "1.19.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c51a52ed6686dd62c320f9b89299e9dfb46f730c7a48e635c19f21d116cb1439" +dependencies = [ + "bytes", + "libc", + "memchr", + "mio", + "num_cpus", + "once_cell", + "parking_lot 0.12.1", + "pin-project-lite", + "signal-hook-registry", + "socket2", + "tokio-macros", + "winapi", +] + +[[package]] +name = "tokio-macros" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9724f9a975fb987ef7a3cd9be0350edcbe130698af5b8f7a631e23d42d052484" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tokio-native-tls" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7d995660bd2b7f8c1568414c1126076c13fbb725c40112dc0120b78eb9b717b" +dependencies = [ + "native-tls", + "tokio", +] + +[[package]] +name = "tokio-rustls" +version = "0.23.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c43ee83903113e03984cb9e5cebe6c04a5116269e900e3ddba8f068a62adda59" +dependencies = [ + "rustls", + "tokio", + "webpki", +] + +[[package]] +name = "tokio-tungstenite" +version = "0.17.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06cda1232a49558c46f8a504d5b93101d42c0bf7f911f12a105ba48168f821ae" +dependencies = [ + "futures-util", + "log", + "tokio", + "tungstenite", +] + +[[package]] +name = "tokio-util" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc463cd8deddc3770d20f9852143d50bf6094e640b485cb2e189a2099085ff45" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", + "tracing", +] + +[[package]] +name = "toml" +version = "0.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d82e1a7758622a465f8cee077614c73484dac5b836c02ff6a40d5d1010324d7" +dependencies = [ + "serde", +] + +[[package]] +name = "tower" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" +dependencies = [ + "futures-core", + "futures-util", + "pin-project", + "pin-project-lite", + "tokio", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tower-http" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aba3f3efabf7fb41fae8534fc20a817013dd1c12cb45441efb6c82e6556b4cd8" +dependencies = [ + "bitflags", + "bytes", + "futures-core", + "futures-util", + "http", + "http-body", + "http-range-header", + "httpdate", + "mime", + "mime_guess", + "percent-encoding", + "pin-project-lite", + "tokio", + "tokio-util", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tower-http" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c530c8675c1dbf98facee631536fa116b5fb6382d7dd6dc1b118d970eafe3ba" +dependencies = [ + "bitflags", + "bytes", + "futures-core", + "futures-util", + "http", + "http-body", + "http-range-header", + "pin-project-lite", + "tower", + "tower-layer", + "tower-service", +] + +[[package]] +name = "tower-layer" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "343bc9466d3fe6b0f960ef45960509f84480bf4fd96f92901afe7ff3df9d3a62" + +[[package]] +name = "tower-service" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" + +[[package]] +name = "tracing" +version = "0.1.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a400e31aa60b9d44a52a8ee0343b5b18566b03a8321e0d321f695cf56e940160" +dependencies = [ + "cfg-if", + "log", + "pin-project-lite", + "tracing-core", +] + +[[package]] +name = "tracing-core" +version = "0.1.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b7358be39f2f274f322d2aaed611acc57f382e8eb1e5b48cb9ae30933495ce7" +dependencies = [ + "once_cell", +] + +[[package]] +name = "trust-dns-proto" +version = "0.21.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c31f240f59877c3d4bb3b3ea0ec5a6a0cff07323580ff8c7a605cd7d08b255d" +dependencies = [ + "async-trait", + "cfg-if", + "data-encoding", + "enum-as-inner", + "futures-channel", + "futures-io", + "futures-util", + "idna", + "ipnet", + "lazy_static", + "log", + "rand", + "smallvec", + "thiserror", + "tinyvec", + "tokio", + "url", +] + +[[package]] +name = "trust-dns-resolver" +version = "0.21.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4ba72c2ea84515690c9fcef4c6c660bb9df3036ed1051686de84605b74fd558" +dependencies = [ + "cfg-if", + "futures-util", + "ipconfig", + "lazy_static", + "log", + "lru-cache", + "parking_lot 0.12.1", + "resolv-conf", + "smallvec", + "thiserror", + "tokio", + "trust-dns-proto", +] + +[[package]] +name = "try-lock" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" + +[[package]] +name = "tungstenite" +version = "0.17.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d96a2dea40e7570482f28eb57afbe42d97551905da6a9400acc5c328d24004f5" +dependencies = [ + "base64 0.13.0", + "byteorder", + "bytes", + "http", + "httparse", + "log", + "rand", + "sha-1 0.10.0", + "thiserror", + "url", + "utf-8", +] + +[[package]] +name = "typenum" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" + +[[package]] +name = "ucd-trie" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89570599c4fe5585de2b388aab47e99f7fa4e9238a1399f707a02e356058141c" + +[[package]] +name = "unicase" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6" +dependencies = [ + "version_check", +] + +[[package]] +name = "unicode-bidi" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "099b7128301d285f79ddd55b9a83d5e6b9e97c92e0ea0daebee7263e932de992" + +[[package]] +name = "unicode-ident" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5bd2fe26506023ed7b5e1e315add59d6f584c621d037f9368fea9cfb988f368c" + +[[package]] +name = "unicode-normalization" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "854cbdc4f7bc6ae19c820d44abdc3277ac3e1b2b93db20a636825d9322fb60e6" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "unicode-segmentation" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e8820f5d777f6224dc4be3632222971ac30164d4a258d595640799554ebfd99" + +[[package]] +name = "unicode-xid" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "957e51f3646910546462e67d5f7599b9e4fb8acdd304b087a6494730f9eebf04" + +[[package]] +name = "untrusted" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" + +[[package]] +name = "url" +version = "2.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a507c383b2d33b5fc35d1861e77e6b383d158b2da5e14fe51b83dfedf6fd578c" +dependencies = [ + "form_urlencoded", + "idna", + "matches", + "percent-encoding", +] + +[[package]] +name = "utf-8" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" + +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + +[[package]] +name = "version-compare" +version = "0.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c18c859eead79d8b95d09e4678566e8d70105c4e7b251f707a03df32442661b" + +[[package]] +name = "version-compare" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe88247b92c1df6b6de80ddc290f3976dbdf2f5f5d3fd049a9fb598c6dd5ca73" + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "waker-fn" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d5b2c62b4012a3e1eca5a7e077d13b3bf498c4073e33ccd58626607748ceeca" + +[[package]] +name = "walkdir" +version = "2.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56" +dependencies = [ + "same-file", + "winapi", + "winapi-util", +] + +[[package]] +name = "walrus" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4eb08e48cde54c05f363d984bb54ce374f49e242def9468d2e1b6c2372d291f8" +dependencies = [ + "anyhow", + "id-arena", + "leb128", + "log", + "walrus-macro", + "wasmparser 0.77.0", +] + +[[package]] +name = "walrus-macro" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a6e5bd22c71e77d60140b0bd5be56155a37e5bd14e24f5f87298040d0cc40d7" +dependencies = [ + "heck 0.3.3", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "want" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ce8a968cb1cd110d136ff8b819a556d6fb6d919363c61534f6860c7eb172ba0" +dependencies = [ + "log", + "try-lock", +] + +[[package]] +name = "wasi" +version = "0.9.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" + +[[package]] +name = "wasi" +version = "0.10.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "wasm-bindgen" +version = "0.2.81" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c53b543413a17a202f4be280a7e5c62a1c69345f5de525ee64f8cfdbc954994" +dependencies = [ + "cfg-if", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.81" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5491a68ab4500fa6b4d726bd67408630c3dbe9c4fe7bda16d5c82a1fd8c7340a" +dependencies = [ + "bumpalo", + "lazy_static", + "log", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-cli-support" +version = "0.2.81" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4016fbd42224de21aab2f009aeaec61067d278a298ba7f8f7f8d40fbffea0822" +dependencies = [ + "anyhow", + "base64 0.9.3", + "log", + "rustc-demangle", + "serde_json", + "tempfile", + "walrus", + "wasm-bindgen-externref-xform", + "wasm-bindgen-multi-value-xform", + "wasm-bindgen-shared", + "wasm-bindgen-threads-xform", + "wasm-bindgen-wasm-conventions", + "wasm-bindgen-wasm-interpreter", + "wit-text", + "wit-validator", + "wit-walrus", +] + +[[package]] +name = "wasm-bindgen-externref-xform" +version = "0.2.81" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f33c8e2d3f3b6f6647f982911eb4cb44998c8cca97a4fe7afc99f616ebb33a73" +dependencies = [ + "anyhow", + "walrus", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de9a9cec1733468a8c657e57fa2413d2ae2c0129b95e87c5b72b8ace4d13f31f" +dependencies = [ + "cfg-if", + "js-sys", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.81" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c441e177922bc58f1e12c022624b6216378e5febc2f0533e41ba443d505b80aa" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.81" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d94ac45fcf608c1f45ef53e748d35660f168490c10b23704c7779ab8f5c3048" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-multi-value-xform" +version = "0.2.81" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7015b54357604811162710d5cf274ab85d974fe1e324222dd5b2133afdefe9b9" +dependencies = [ + "anyhow", + "walrus", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.81" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a89911bd99e5f3659ec4acf9c4d93b0a90fe4a2a11f15328472058edc5261be" + +[[package]] +name = "wasm-bindgen-threads-xform" +version = "0.2.81" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6961b838d9a9c121ba4a1eea1628014cc759469e3defb42bbac9c5ed0f65be14" +dependencies = [ + "anyhow", + "walrus", + "wasm-bindgen-wasm-conventions", +] + +[[package]] +name = "wasm-bindgen-wasm-conventions" +version = "0.2.81" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0a0eca38fe89471f57d6903f3e17e732d2d6f995a7af5b23f27df7fee0f0d18" +dependencies = [ + "anyhow", + "walrus", +] + +[[package]] +name = "wasm-bindgen-wasm-interpreter" +version = "0.2.81" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b1c9fb7f71137840932bbb853ef1f83d68c88584b716c9bbae38675c9fb8b86" +dependencies = [ + "anyhow", + "log", + "walrus", + "wasm-bindgen-wasm-conventions", +] + +[[package]] +name = "wasmparser" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a950e6a618f62147fd514ff445b2a0b53120d382751960797f85f058c7eda9b9" + +[[package]] +name = "wasmparser" +version = "0.77.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b35c86d22e720a07d954ebbed772d01180501afe7d03d464f413bb5f8914a8d6" + +[[package]] +name = "wast" +version = "21.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b1844f66a2bc8526d71690104c0e78a8e59ffa1597b7245769d174ebb91deb5" +dependencies = [ + "leb128", +] + +[[package]] +name = "web-sys" +version = "0.3.58" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2fed94beee57daf8dd7d51f2b15dc2bcde92d7a72304cdf662a4371008b71b90" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "webbrowser" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc6a3cffdb686fbb24d9fb8f03a213803277ed2300f11026a3afe1f108dc021b" +dependencies = [ + "jni 0.19.0", + "ndk-glue 0.6.2", + "url", + "web-sys", + "widestring", + "winapi", +] + +[[package]] +name = "webkit2gtk" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29952969fb5e10fe834a52eb29ad0814ccdfd8387159b0933edf1344a1c9cdcc" +dependencies = [ + "bitflags", + "cairo-rs", + "gdk", + "gdk-sys", + "gio", + "gio-sys", + "glib", + "glib-sys", + "gobject-sys", + "gtk", + "gtk-sys", + "javascriptcore-rs", + "libc", + "once_cell", + "soup2", + "webkit2gtk-sys", +] + +[[package]] +name = "webkit2gtk-sys" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d76ca6ecc47aeba01ec61e480139dda143796abcae6f83bcddf50d6b5b1dcf3" +dependencies = [ + "atk-sys", + "bitflags", + "cairo-sys-rs", + "gdk-pixbuf-sys", + "gdk-sys", + "gio-sys", + "glib-sys", + "gobject-sys", + "gtk-sys", + "javascriptcore-rs-sys", + "libc", + "pango-sys", + "pkg-config", + "soup2-sys", + "system-deps 6.0.2", +] + +[[package]] +name = "webpki" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f095d78192e208183081cc07bc5515ef55216397af48b873e5edcd72637fa1bd" +dependencies = [ + "ring", + "untrusted", +] + +[[package]] +name = "webpki-roots" +version = "0.22.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44d8de8415c823c8abd270ad483c6feeac771fad964890779f9a8cb24fbbc1bf" +dependencies = [ + "webpki", +] + +[[package]] +name = "webview2-com" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb8e90ac2d9ce39cdb70017aaec641be09fbdd702b7b332b9896d053eb469524" +dependencies = [ + "webview2-com-macros", + "webview2-com-sys", + "windows", + "windows_macros", +] + +[[package]] +name = "webview2-com-macros" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1515c6c82fcee93f6edaacc72c8e233dbe4ff3ca569dce1901dfc36c404a3e99" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "webview2-com-sys" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92160310b3322397e4ff8a8285a7429d73a07a68fda44ee80879605b93e53f76" +dependencies = [ + "regex", + "serde", + "serde_json", + "thiserror", + "windows", + "windows-bindgen", +] + +[[package]] +name = "widestring" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17882f045410753661207383517a6f62ec3dbeb6a4ed2acce01f0728238d1983" + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +dependencies = [ + "winapi", +] + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows" +version = "0.30.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b749ebd2304aa012c5992d11a25d07b406bdbe5f79d371cb7a918ce501a19eb0" +dependencies = [ + "windows_aarch64_msvc 0.30.0", + "windows_i686_gnu 0.30.0", + "windows_i686_msvc 0.30.0", + "windows_x86_64_gnu 0.30.0", + "windows_x86_64_msvc 0.30.0", +] + +[[package]] +name = "windows-bindgen" +version = "0.30.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "944c545fcae9dd66488308f8b69aa3ba34f53714416ecfcdcbbfa4b6821e27c6" +dependencies = [ + "windows_quote", + "windows_reader", +] + +[[package]] +name = "windows-sys" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea04155a16a59f9eab786fe12a4a450e75cdb175f9e0d80da1e17db09f55b8d2" +dependencies = [ + "windows_aarch64_msvc 0.36.1", + "windows_i686_gnu 0.36.1", + "windows_i686_msvc 0.36.1", + "windows_x86_64_gnu 0.36.1", + "windows_x86_64_msvc 0.36.1", +] + +[[package]] +name = "windows_aarch64_msvc" +version = "0.30.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29277a4435d642f775f63c7d1faeb927adba532886ce0287bd985bffb16b6bca" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47" + +[[package]] +name = "windows_gen" +version = "0.30.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30dff4d91d22520628bb94b66f2bb313cb16a09a515a32320a84a1b449bc94c0" +dependencies = [ + "windows_quote", + "windows_reader", +] + +[[package]] +name = "windows_i686_gnu" +version = "0.30.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1145e1989da93956c68d1864f32fb97c8f561a8f89a5125f6a2b7ea75524e4b8" + +[[package]] +name = "windows_i686_gnu" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6" + +[[package]] +name = "windows_i686_msvc" +version = "0.30.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4a09e3a0d4753b73019db171c1339cd4362c8c44baf1bcea336235e955954a6" + +[[package]] +name = "windows_i686_msvc" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024" + +[[package]] +name = "windows_macros" +version = "0.30.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62ae44ab917e9005fe710d99d52d227ca0164b10a09be90649142cc3fab825d3" +dependencies = [ + "syn", + "windows_gen", + "windows_quote", + "windows_reader", +] + +[[package]] +name = "windows_quote" +version = "0.30.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71f02c51a77e6248c1206aaa920802c32d50a05205e229b118d7f3afd3036667" + +[[package]] +name = "windows_reader" +version = "0.30.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e44e6df0da993cda589c5ac852272fbb2a0ead67a031a017dd3eac11528a2d72" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.30.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ca64fcb0220d58db4c119e050e7af03c69e6f4f415ef69ec1773d9aab422d5a" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.30.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08cabc9f0066848fef4bc6a1c1668e6efce38b661d2aeec75d18d8617eebb5f1" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680" + +[[package]] +name = "winreg" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0120db82e8a1e0b9fb3345a539c478767c0048d842860994d96113d5b667bd69" +dependencies = [ + "winapi", +] + +[[package]] +name = "winreg" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d" +dependencies = [ + "winapi", +] + +[[package]] +name = "wit-parser" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f5fd97866f4b9c8e1ed57bcf9446f3d0d8ba37e2dd01c3c612c046c053b06f7" +dependencies = [ + "anyhow", + "leb128", + "wit-schema-version", +] + +[[package]] +name = "wit-schema-version" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfee4a6a4716eefa0682e7a3b836152e894a3e4f34a9d6c2c3e1c94429bfe36a" + +[[package]] +name = "wit-text" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33358e95c77d660f1c7c07f4a93c2bd89768965e844e3c50730bb4b42658df5f" +dependencies = [ + "anyhow", + "wast", + "wit-writer", +] + +[[package]] +name = "wit-validator" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c11d93d925420e7872b226c4161849c32be38385ccab026b88df99d8ddc6ba6" +dependencies = [ + "anyhow", + "wasmparser 0.59.0", + "wit-parser", + "wit-schema-version", +] + +[[package]] +name = "wit-walrus" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad559e3e4c6404b2a6a675d44129d62a3836e3b951b90112fa1c5feb852757cd" +dependencies = [ + "anyhow", + "id-arena", + "walrus", + "wit-parser", + "wit-schema-version", + "wit-writer", +] + +[[package]] +name = "wit-writer" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2ad01ba5e9cbcff799a0689e56a153776ea694cec777f605938cb9880d41a09" +dependencies = [ + "leb128", + "wit-schema-version", +] + +[[package]] +name = "wry" +version = "0.16.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5676092e1a33448ed0f268717bcbb2e928354b78f4c1f60f3d43641eedea0d9" +dependencies = [ + "block", + "cocoa", + "core-graphics", + "gdk", + "gio", + "glib", + "gtk", + "http", + "jni 0.18.0", + "libc", + "log", + "objc", + "objc_id", + "once_cell", + "serde", + "serde_json", + "tao", + "thiserror", + "url", + "webkit2gtk", + "webkit2gtk-sys", + "webview2-com", + "windows", + "windows_macros", +] + +[[package]] +name = "x11" +version = "2.19.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6dd0565fa8bfba8c5efe02725b14dff114c866724eff2cfd44d76cea74bcd87a" +dependencies = [ + "libc", + "pkg-config", +] + +[[package]] +name = "x11-dl" +version = "2.19.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea26926b4ce81a6f5d9d0f3a0bc401e5a37c6ae14a1bfaa8ff6099ca80038c59" +dependencies = [ + "lazy_static", + "libc", + "pkg-config", +] + +[[package]] +name = "xattr" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d1526bbe5aaeb5eb06885f4d987bcdfa5e23187055de9b83fe00156a821fabc" +dependencies = [ + "libc", +] + +[[package]] +name = "zip" +version = "0.5.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93ab48844d61251bb3835145c521d88aa4031d7139e8485990f60ca911fa0815" +dependencies = [ + "byteorder", + "bzip2", + "crc32fast", + "flate2", + "thiserror", + "time 0.1.44", +] + +[[package]] +name = "zip" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf225bcf73bb52cbb496e70475c7bd7a3f769df699c0020f6c7bd9a96dcf0b8d" +dependencies = [ + "aes", + "byteorder", + "bzip2", + "constant_time_eq", + "crc32fast", + "crossbeam-utils", + "flate2", + "hmac", + "pbkdf2", + "sha1", + "time 0.3.11", + "zstd", +] + +[[package]] +name = "zstd" +version = "0.10.2+zstd.1.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f4a6bd64f22b5e3e94b4e238669ff9f10815c27a5180108b849d24174a83847" +dependencies = [ + "zstd-safe", +] + +[[package]] +name = "zstd-safe" +version = "4.1.6+zstd.1.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94b61c51bb270702d6167b8ce67340d2754b088d0c091b06e593aa772c3ee9bb" +dependencies = [ + "libc", + "zstd-sys", +] + +[[package]] +name = "zstd-sys" +version = "1.6.3+zstd.1.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc49afa5c8d634e75761feda8c592051e7eeb4683ba827211eb0d731d3402ea8" +dependencies = [ + "cc", + "libc", +] From 526a88cab16045cf6b8acba75471cc62f17dca10 Mon Sep 17 00:00:00 2001 From: YuKun Liu <41265098+mrxiaozhuox@users.noreply.github.com> Date: Sat, 9 Jul 2022 14:16:19 +0800 Subject: [PATCH 073/170] feat: commit code --- Cargo.lock | 66 +++++++++++++++++++++++++++++----- Cargo.toml | 4 +-- src/builder.rs | 73 +++++++++++++++++++++++-------------- src/cli/serve/mod.rs | 36 ++++++++----------- src/server/mod.rs | 86 +++++++++++++++++++++++++++++++++++--------- 5 files changed, 190 insertions(+), 75 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 086673b7a..4c4720564 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -396,9 +396,9 @@ dependencies = [ [[package]] name = "cargo_metadata" -version = "0.14.2" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4acbb09d9ee8e23699b9634375c72795d095bf268439da88562cf9b501f181fa" +checksum = "3abb7553d5b9b8421c6de7cb02606ff15e0c6eea7d8eadd75ef013fd636bec36" dependencies = [ "camino", "cargo-platform", @@ -590,6 +590,21 @@ dependencies = [ "cache-padded", ] +[[package]] +name = "console" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a28b32d32ca44b70c3e4acd7db1babf555fa026e385fb95f18028f88848b3c31" +dependencies = [ + "encode_unicode", + "libc", + "once_cell", + "regex", + "terminal_size", + "unicode-width", + "winapi", +] + [[package]] name = "console_error_panic_hook" version = "0.1.7" @@ -872,7 +887,7 @@ dependencies = [ "headers", "html_parser", "hyper", - "loading", + "indicatif", "log", "notify", "proc-macro2", @@ -1101,6 +1116,12 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "453440c271cf5577fd2a40e4942540cb7d0d2f85e27c8d07dd0023c925a67541" +[[package]] +name = "encode_unicode" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" + [[package]] name = "encoding_rs" version = "0.8.31" @@ -1906,6 +1927,17 @@ dependencies = [ "hashbrown", ] +[[package]] +name = "indicatif" +version = "0.17.0-rc.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4017d0ce94b8e91e29d2c78ed891e57e5ec3dc4371820a9d96abab4af09eb8ad" +dependencies = [ + "console", + "number_prefix", + "unicode-width", +] + [[package]] name = "inotify" version = "0.9.6" @@ -2145,12 +2177,6 @@ version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" -[[package]] -name = "loading" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "676420b03272176423578148eee61319e893422694f6d96a394841cb0901357f" - [[package]] name = "lock_api" version = "0.4.7" @@ -2469,6 +2495,12 @@ dependencies = [ "libc", ] +[[package]] +name = "number_prefix" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" + [[package]] name = "objc" version = "0.2.7" @@ -3525,6 +3557,16 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "terminal_size" +version = "0.1.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "633c1a546cee861a1a6d0dc69ebeca693bf4296661ba7852b9d21d159e0506df" +dependencies = [ + "libc", + "winapi", +] + [[package]] name = "textwrap" version = "0.15.0" @@ -3893,6 +3935,12 @@ version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7e8820f5d777f6224dc4be3632222971ac30164d4a258d595640799554ebfd99" +[[package]] +name = "unicode-width" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973" + [[package]] name = "unicode-xid" version = "0.2.3" diff --git a/Cargo.toml b/Cargo.toml index 7e982bc78..da2467fc2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,14 +29,14 @@ notify = { version = "5.0.0-pre.13", features = ["serde"] } html_parser = "0.6.2" binary-install = "0.0.2" convert_case = "0.5.0" -cargo_metadata = "0.14.1" +cargo_metadata = "0.15.0" tokio = { version = "1.16.1", features = ["full"] } atty = "0.2.14" regex = "1.5.4" chrono = "0.4.19" anyhow = "1.0.53" hyper = "0.14.17" -loading = "0.3.0" +indicatif = "0.17.0-rc.11" axum = { version = "0.5.1", features = ["ws", "headers"] } tower-http = { version = "0.2.2", features = ["fs", "trace"] } diff --git a/src/builder.rs b/src/builder.rs index 5ef084326..d164e5418 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -4,19 +4,26 @@ use crate::{ tools::Tool, DioxusConfig, }; -use cargo_metadata::Message; -use loading::Loading; +use cargo_metadata::{diagnostic::Diagnostic, Message}; +use indicatif::{ProgressBar, ProgressStyle}; +use serde::Serialize; use std::{ - collections::HashMap, fs::{copy, create_dir_all, remove_dir_all, File}, io::Read, panic, path::PathBuf, process::Command, + time::Duration, }; use wasm_bindgen_cli_support::Bindgen; -pub fn build(config: &CrateConfig, quiet: bool) -> Result<()> { +#[derive(Serialize, Debug, Clone)] +pub struct BuildResult { + pub warnings: Vec, + pub elapsed_time: u128, +} + +pub fn build(config: &CrateConfig, quiet: bool) -> Result { // [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 // [3] Wasm-bindgen the .wasm fiile, and move it into the {builddir}/modules/xxxx/xxxx_bg.wasm @@ -78,13 +85,7 @@ pub fn build(config: &CrateConfig, quiet: bool) -> Result<()> { ExecutableType::Example(name) => cmd.arg("--example").arg(name), }; - prettier_build(cmd).unwrap(); - - // if !output.status.success() { - // log::error!("Build failed!"); - // let reason = String::from_utf8_lossy(&output.stderr).to_string(); - // return Err(Error::BuildFailed(reason)); - // } + let warning_messages = prettier_build(cmd)?; // [2] Establish the output directory structure let bindgen_outdir = out_dir.join("assets").join("dioxus"); @@ -122,8 +123,7 @@ pub fn build(config: &CrateConfig, quiet: bool) -> Result<()> { .unwrap(); }); if bindgen_result.is_err() { - log::error!("Bindgen build failed! \nThis is probably due to the Bindgen version, dioxus-cli using `0.2.79` Bindgen crate."); - return Ok(()); + return Err(Error::BuildFailed("Bindgen build failed! \nThis is probably due to the Bindgen version, dioxus-cli using `0.2.79` Bindgen crate.".to_string())); } // check binaryen:wasm-opt tool @@ -193,8 +193,10 @@ pub fn build(config: &CrateConfig, quiet: bool) -> Result<()> { } let t_end = std::time::Instant::now(); - log::info!("🏁 Done in {}ms!", (t_end - t_start).as_millis()); - Ok(()) + Ok(BuildResult { + warnings: warning_messages, + elapsed_time: (t_end - t_start).as_millis() + }) } pub fn build_desktop(config: &CrateConfig, is_serve: bool) -> Result<()> { @@ -327,27 +329,46 @@ pub fn build_desktop(config: &CrateConfig, is_serve: bool) -> Result<()> { Ok(()) } -fn prettier_build(mut cmd: Command) -> anyhow::Result<()> { - let loading = Loading::default(); - let mut record: HashMap = HashMap::new(); +fn prettier_build(mut cmd: Command) -> anyhow::Result> { + let mut warning_messages: Vec = vec![]; + + let pb = ProgressBar::new_spinner(); + pb.enable_steady_tick(Duration::from_millis(200)); + pb.set_style( + ProgressStyle::with_template("{spinner:.dim.bold} {wide_msg}") + .unwrap() + .tick_chars("/|\\- "), + ); + pb.set_message("Start to build project"); + let mut command = cmd.spawn()?; let reader = std::io::BufReader::new(command.stdout.take().unwrap()); for message in cargo_metadata::Message::parse_stream(reader) { match message.unwrap() { - Message::CompilerMessage(_msg) => { - // println!("{:#?}", msg); + Message::CompilerMessage(msg) => { + let message = msg.message; + match message.level { + cargo_metadata::diagnostic::DiagnosticLevel::Error => { + log::error!("Build Failed: {}", message.message); + std::process::exit(1); + } + cargo_metadata::diagnostic::DiagnosticLevel::Warning => { + warning_messages.push(message.clone()); + } + _ => {} + } } Message::CompilerArtifact(artifact) => { - record.insert(artifact.package_id.to_string(), artifact.target.name); + pb.set_message(format!("Compiling {} ", artifact.package_id)); + pb.tick(); } Message::BuildScriptExecuted(script) => { - let package_id = script.package_id.to_string(); - if let Some(name) = record.get(&package_id) { - loading.text(format!("[{}] build done", name)); - } + let _package_id = script.package_id.to_string(); } Message::BuildFinished(finished) => { if finished.success { + pb.finish_and_clear(); + println!("Done in"); } else { std::process::exit(1); } @@ -355,7 +376,7 @@ fn prettier_build(mut cmd: Command) -> anyhow::Result<()> { _ => (), // Unknown message } } - Ok(()) + Ok(warning_messages) } pub fn gen_page(config: &DioxusConfig, serve: bool) -> String { diff --git a/src/cli/serve/mod.rs b/src/cli/serve/mod.rs index 62843d653..93770b6ed 100644 --- a/src/cli/serve/mod.rs +++ b/src/cli/serve/mod.rs @@ -38,31 +38,25 @@ impl Serve { .clone() }); - match platform.as_str() { - "web" => { - crate::builder::build(&crate_config, false)?; - } - "desktop" => { - crate::builder::build_desktop(&crate_config, true)?; + if platform.as_str() == "desktop" { + crate::builder::build_desktop(&crate_config, true)?; - match &crate_config.executable { - crate::ExecutableType::Binary(name) - | crate::ExecutableType::Lib(name) - | crate::ExecutableType::Example(name) => { - let mut file = crate_config.out_dir.join(name); - if cfg!(windows) { - file.set_extension("exe"); - } - Command::new(crate_config.out_dir.join(file).to_str().unwrap()) - .stdout(Stdio::inherit()) - .output()?; + match &crate_config.executable { + crate::ExecutableType::Binary(name) + | crate::ExecutableType::Lib(name) + | crate::ExecutableType::Example(name) => { + let mut file = crate_config.out_dir.join(name); + if cfg!(windows) { + file.set_extension("exe"); } + Command::new(crate_config.out_dir.join(file).to_str().unwrap()) + .stdout(Stdio::inherit()) + .output()?; } - return Ok(()); - } - _ => { - return custom_error!("Unsoppurt platform target."); } + return Ok(()); + } else if platform != "web" { + return custom_error!("Unsoppurt platform target."); } // generate dev-index page diff --git a/src/server/mod.rs b/src/server/mod.rs index 3ecce6c26..b20d84db3 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -6,6 +6,7 @@ use axum::{ routing::{get, get_service}, Router, }; +use cargo_metadata::diagnostic::Diagnostic; use colored::Colorize; use dioxus::rsx_interpreter::SetRsxMessage; use notify::{RecommendedWatcher, Watcher}; @@ -15,7 +16,7 @@ use std::{net::UdpSocket, path::PathBuf, process::Command, sync::Arc}; use tower::ServiceBuilder; use tower_http::services::fs::{ServeDir, ServeFileSystemResponseBody}; -use crate::{builder, serve::Serve, CrateConfig, Result}; +use crate::{builder, serve::Serve, BuildResult, CrateConfig, Result}; use tokio::sync::broadcast; mod hot_reload; @@ -27,9 +28,9 @@ pub struct BuildManager { } impl BuildManager { - fn rebuild(&self) -> Result<()> { + fn rebuild(&self) -> Result { log::info!("🪁 Rebuild project"); - builder::build(&self.config, true)?; + let result = builder::build(&self.config, true)?; // change the websocket reload state to true; // the page will auto-reload. if self @@ -43,7 +44,7 @@ impl BuildManager { let _ = Serve::regen_dev_page(&self.config); } let _ = self.reload_tx.send(()); - Ok(()) + Ok(result) } } @@ -61,6 +62,8 @@ pub async fn startup(port: u16, config: CrateConfig) -> Result<()> { } pub async fn startup_hot_reload(port: u16, config: CrateConfig) -> Result<()> { + let first_build_result = crate::builder::build(&config, false)?; + log::info!("🚀 Starting development server..."); let dist_path = config.out_dir.clone(); @@ -159,9 +162,22 @@ pub async fn startup_hot_reload(port: u16, config: CrateConfig) -> Result<()> { } } if needs_rebuild { - print_console_info(port, &config, evt.paths); - if let Err(err) = build_manager.rebuild() { - log::error!("{}", err); + match build_manager.rebuild() { + Ok(res) => { + print_console_info( + port, + &config, + PrettierOptions { + changed: evt.paths, + warnings: res.warnings, + elapsed_time: res.elapsed_time, + }, + ); + } + Err(err) => { + log::error!("{}", err); + std::process::exit(1); + } } } if !messages.is_empty() { @@ -183,7 +199,15 @@ pub async fn startup_hot_reload(port: u16, config: CrateConfig) -> Result<()> { } // start serve dev-server at 0.0.0.0:8080 - print_console_info(port, &config, vec![]); + print_console_info( + port, + &config, + PrettierOptions { + changed: vec![], + warnings: first_build_result.warnings, + elapsed_time: first_build_result.elapsed_time, + }, + ); let file_service_config = config.clone(); let file_service = ServiceBuilder::new() @@ -246,6 +270,8 @@ pub async fn startup_hot_reload(port: u16, config: CrateConfig) -> Result<()> { } pub async fn startup_default(port: u16, config: CrateConfig) -> Result<()> { + let first_build_result = crate::builder::build(&config, false)?; + log::info!("🚀 Starting development server..."); let dist_path = config.out_dir.clone(); @@ -276,10 +302,20 @@ pub async fn startup_default(port: u16, config: CrateConfig) -> Result<()> { let mut watcher = RecommendedWatcher::new(move |info: notify::Result| { let config = watcher_config.clone(); if info.is_ok() { - print_console_info(port, &config, info.unwrap().paths); if chrono::Local::now().timestamp() > last_update_time { match build_manager.rebuild() { - Ok(_) => last_update_time = chrono::Local::now().timestamp(), + Ok(res) => { + last_update_time = chrono::Local::now().timestamp(); + print_console_info( + port, + &config, + PrettierOptions { + changed: info.unwrap().paths, + warnings: res.warnings, + elapsed_time: res.elapsed_time, + }, + ); + } Err(e) => log::error!("{}", e), } } @@ -297,8 +333,16 @@ pub async fn startup_default(port: u16, config: CrateConfig) -> Result<()> { } // start serve dev-server at 0.0.0.0 - print_console_info(port, &config, vec![]); - + print_console_info( + port, + &config, + PrettierOptions { + changed: vec![], + warnings: first_build_result.warnings, + elapsed_time: first_build_result.elapsed_time, + }, + ); + let file_service_config = config.clone(); let file_service = ServiceBuilder::new() .and_then( @@ -355,7 +399,14 @@ pub async fn startup_default(port: u16, config: CrateConfig) -> Result<()> { Ok(()) } -fn print_console_info(port: u16, config: &CrateConfig, changed: Vec) { +#[derive(Debug, Default)] +pub struct PrettierOptions { + changed: Vec, + warnings: Vec, + elapsed_time: u128, +} + +fn print_console_info(port: u16, config: &CrateConfig, options: PrettierOptions) { print!( "{}", String::from_utf8_lossy( @@ -413,7 +464,7 @@ fn print_console_info(port: u16, config: &CrateConfig, changed: Vec) { "False" }; - if changed.len() <= 0 { + if options.changed.len() <= 0 { println!( "{} @ v{}\n", "Dioxus".bold().green(), @@ -422,7 +473,9 @@ fn print_console_info(port: u16, config: &CrateConfig, changed: Vec) { } else { println!( "Project Reloaded: {}\n", - format!("Changed {} files.", changed.len()).purple().bold() + format!("Changed {} files.", options.changed.len()) + .purple() + .bold() ); } println!( @@ -446,12 +499,11 @@ fn print_console_info(port: u16, config: &CrateConfig, changed: Vec) { println!("\t> URL Rewrite [index_on_404] : {}", url_rewrite.purple()); println!(""); - if changed.len() <= 0 { + if options.changed.len() <= 0 { log::info!("{}", "Server startup completed.".green().bold()); } else { log::info!("{}", "Project rebuild completed.".green().bold()); } - } fn get_ip() -> Option { From 78c78548e80c1be44589409f3b99f065aa77c781 Mon Sep 17 00:00:00 2001 From: YuKun Liu <41265098+mrxiaozhuox@users.noreply.github.com> Date: Sat, 9 Jul 2022 16:41:53 +0800 Subject: [PATCH 074/170] feat: commit prettier_build --- src/builder.rs | 2 +- src/server/mod.rs | 42 +++++++++++++++++++++++++----------------- 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/src/builder.rs b/src/builder.rs index d164e5418..33ce411f6 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -368,7 +368,7 @@ fn prettier_build(mut cmd: Command) -> anyhow::Result> { Message::BuildFinished(finished) => { if finished.success { pb.finish_and_clear(); - println!("Done in"); + log::info!("Build done."); } else { std::process::exit(1); } diff --git a/src/server/mod.rs b/src/server/mod.rs index b20d84db3..5cd5cdcb7 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -342,7 +342,7 @@ pub async fn startup_default(port: u16, config: CrateConfig) -> Result<()> { elapsed_time: first_build_result.elapsed_time, }, ); - + let file_service_config = config.clone(); let file_service = ServiceBuilder::new() .and_then( @@ -434,18 +434,6 @@ fn print_console_info(port: u16, config: &CrateConfig, options: PrettierOptions) profile = config.custom_profile.as_ref().unwrap().to_string(); } let hot_reload = if config.hot_reload { "RSX" } else { "Normal" }; - let tools_str = format!( - "{:?}", - config - .dioxus_config - .application - .tools - .clone() - .unwrap_or_default() - .iter() - .map(|d| d.0.clone()) - .collect::>() - ); let crate_root = crate::cargo::crate_root().unwrap(); let custom_html_file = if crate_root.join("index.html").is_file() { "Custom [index.html]" @@ -494,15 +482,35 @@ fn print_console_info(port: u16, config: &CrateConfig, options: PrettierOptions) println!(""); println!("\t> Profile : {}", profile.green()); println!("\t> Hot Reload : {}", hot_reload.cyan()); - println!("\t> Enabled Tools : {}", tools_str.yellow()); println!("\t> Index Template : {}", custom_html_file.green()); println!("\t> URL Rewrite [index_on_404] : {}", url_rewrite.purple()); println!(""); + println!( + "\t> Build Time Use : {} millis", + options.elapsed_time.to_string().green().bold() + ); + println!(""); - if options.changed.len() <= 0 { - log::info!("{}", "Server startup completed.".green().bold()); + if options.warnings.len() == 0 { + log::info!("{}\n", "A perfect compilation!".green().bold()); } else { - log::info!("{}", "Project rebuild completed.".green().bold()); + log::warn!( + "{}\n", + format!( + "There were {} warning messages during the build: ", + options.warnings.len() - 1 + ) + .yellow() + .bold() + ); + for info in &options.warnings { + if info.message == format!("{} warnings emitted", options.warnings.len() - 1) { + continue; + } + if let Some(val) = info.rendered.clone() { + log::warn!("{}", val); + } + } } } From 8613518c40e722f5e9abfbb53ed7df034ab2b7a3 Mon Sep 17 00:00:00 2001 From: YuKun Liu <41265098+mrxiaozhuox@users.noreply.github.com> Date: Sat, 9 Jul 2022 20:00:17 +0800 Subject: [PATCH 075/170] feat: commit code --- src/server/mod.rs | 58 +++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 54 insertions(+), 4 deletions(-) diff --git a/src/server/mod.rs b/src/server/mod.rs index 5cd5cdcb7..614e8fa7a 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -495,7 +495,7 @@ fn print_console_info(port: u16, config: &CrateConfig, options: PrettierOptions) log::info!("{}\n", "A perfect compilation!".green().bold()); } else { log::warn!( - "{}\n", + "{}", format!( "There were {} warning messages during the build: ", options.warnings.len() - 1 @@ -504,13 +504,63 @@ fn print_console_info(port: u16, config: &CrateConfig, options: PrettierOptions) .bold() ); for info in &options.warnings { - if info.message == format!("{} warnings emitted", options.warnings.len() - 1) { + let message = info.message.clone(); + if message == format!("{} warnings emitted", options.warnings.len() - 1) { continue; } - if let Some(val) = info.rendered.clone() { - log::warn!("{}", val); + let mut console = String::new(); + for span in &info.spans { + let file = &span.file_name; + let line = (span.line_start, span.line_end); + let line_str = if line.0 == line.1 { + line.0.to_string() + } else { + format!("{}~{}", line.0, line.1) + }; + let code = span.text.clone(); + // let span_info = format!( + // "[{}: {}]: {} --> {}", + // file, + // if line.0 == line.1 { + // line.0.to_string() + // } else { + // format!("{}~{}", line.0, line.1) + // }, + // if code.len() == 1 { + // code.get(0).unwrap().text.trim().blue().bold().to_string() + // } else { + // format!("\n{}",code.iter() + // .enumerate() + // .map(|(_i, s)| format!("\t{}\n", s.text).blue().bold().to_string()) + // .collect::()) + // }, + // message.yellow().bold() + // ); + let span_info = if code.len() == 1 { + let code = code.get(0).unwrap().text.trim().blue().bold().to_string(); + format!( + "[{}: {}]: '{}' --> {}", + file, + line_str, + code, + message.yellow().bold() + ) + } else { + let code = code + .iter() + .enumerate() + .map(|(_i, s)| format!("\t{}\n", s.text).blue().bold().to_string()) + .collect::(); + format!("[{}: {}]:\n{}", file, line_str, code) + }; + console = format!("{console}\n\t{span_info}"); } + println!("{console}"); } + println!( + "\n{}\n", + "Resolving all warnings will help your code run better!".yellow() + ); } } From bfaa8e3c74aa82d2ad6a5b917af98f9e6cc729f8 Mon Sep 17 00:00:00 2001 From: YuKun Liu <41265098+mrxiaozhuox@users.noreply.github.com> Date: Sat, 9 Jul 2022 20:54:16 +0800 Subject: [PATCH 076/170] feat: commit code --- src/server/mod.rs | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/src/server/mod.rs b/src/server/mod.rs index 614e8fa7a..e5bffc17e 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -518,24 +518,6 @@ fn print_console_info(port: u16, config: &CrateConfig, options: PrettierOptions) format!("{}~{}", line.0, line.1) }; let code = span.text.clone(); - // let span_info = format!( - // "[{}: {}]: {} --> {}", - // file, - // if line.0 == line.1 { - // line.0.to_string() - // } else { - // format!("{}~{}", line.0, line.1) - // }, - // if code.len() == 1 { - // code.get(0).unwrap().text.trim().blue().bold().to_string() - // } else { - // format!("\n{}",code.iter() - // .enumerate() - // .map(|(_i, s)| format!("\t{}\n", s.text).blue().bold().to_string()) - // .collect::()) - // }, - // message.yellow().bold() - // ); let span_info = if code.len() == 1 { let code = code.get(0).unwrap().text.trim().blue().bold().to_string(); format!( @@ -551,7 +533,7 @@ fn print_console_info(port: u16, config: &CrateConfig, options: PrettierOptions) .enumerate() .map(|(_i, s)| format!("\t{}\n", s.text).blue().bold().to_string()) .collect::(); - format!("[{}: {}]:\n{}", file, line_str, code) + format!("[{}: {}]:\n{}\n#:{}", file, line_str, code, message) }; console = format!("{console}\n\t{span_info}"); } From d543ea19d0f2647a795b1cd32c243f0591e5f8f1 Mon Sep 17 00:00:00 2001 From: YuKun Liu <41265098+mrxiaozhuox@users.noreply.github.com> Date: Sat, 9 Jul 2022 22:02:33 +0800 Subject: [PATCH 077/170] feat: commit some thing --- src/builder.rs | 9 ++++----- src/main.rs | 10 +++++----- src/server/mod.rs | 1 - 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/builder.rs b/src/builder.rs index 33ce411f6..31b99b5f4 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -195,7 +195,7 @@ pub fn build(config: &CrateConfig, quiet: bool) -> Result { let t_end = std::time::Instant::now(); Ok(BuildResult { warnings: warning_messages, - elapsed_time: (t_end - t_start).as_millis() + elapsed_time: (t_end - t_start).as_millis(), }) } @@ -339,7 +339,7 @@ fn prettier_build(mut cmd: Command) -> anyhow::Result> { .unwrap() .tick_chars("/|\\- "), ); - pb.set_message("Start to build project"); + pb.set_message("💼 Waiting to strart build the project..."); let mut command = cmd.spawn()?; let reader = std::io::BufReader::new(command.stdout.take().unwrap()); @@ -349,8 +349,7 @@ fn prettier_build(mut cmd: Command) -> anyhow::Result> { let message = msg.message; match message.level { cargo_metadata::diagnostic::DiagnosticLevel::Error => { - log::error!("Build Failed: {}", message.message); - std::process::exit(1); + return Err(anyhow::anyhow!(message.rendered.unwrap_or("Unknown".into()))); } cargo_metadata::diagnostic::DiagnosticLevel::Warning => { warning_messages.push(message.clone()); @@ -368,7 +367,7 @@ fn prettier_build(mut cmd: Command) -> anyhow::Result> { Message::BuildFinished(finished) => { if finished.success { pb.finish_and_clear(); - log::info!("Build done."); + log::info!("👑 Build done."); } else { std::process::exit(1); } diff --git a/src/main.rs b/src/main.rs index 099ff74c0..39b360f7d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -9,31 +9,31 @@ async fn main() -> Result<()> { match args.action { Commands::Translate(opts) => { if let Err(e) = opts.translate() { - log::error!("translate error: {}", e); + log::error!("🚫 Translate failed: {}", e); } } Commands::Build(opts) => { if let Err(e) = opts.build() { - log::error!("build error: {}", e); + log::error!("🚫 Build project failed: {}", e); } } Commands::Clean(opts) => { if let Err(e) = opts.clean() { - log::error!("clean error: {}", e); + log::error!("🚫 Clean project failed: {}", e); } } Commands::Serve(opts) => { if let Err(e) = opts.serve().await { - log::error!("serve error: {}", e); + log::error!("🚫 Serve startup failed: {}", e); } } Commands::Create(opts) => { if let Err(e) = opts.create() { - log::error!("create error: {}", e); + log::error!("🚫 Create project failed: {}", e); } } diff --git a/src/server/mod.rs b/src/server/mod.rs index e5bffc17e..8f50a6cc3 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -176,7 +176,6 @@ pub async fn startup_hot_reload(port: u16, config: CrateConfig) -> Result<()> { } Err(err) => { log::error!("{}", err); - std::process::exit(1); } } } From dfcf4e1f88e6f8296a5691e13bd6a5122c64996d Mon Sep 17 00:00:00 2001 From: YuKun Liu <41265098+mrxiaozhuox@users.noreply.github.com> Date: Sat, 9 Jul 2022 22:17:32 +0800 Subject: [PATCH 078/170] feat: change default config --- README.md | 2 +- src/assets/dioxus.toml | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index a939dfcaf..f8515f390 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@
-

📦✨ dioxus-cli

+

📦✨ Dioxus CLI

Tooling to supercharge dioxus projects

diff --git a/src/assets/dioxus.toml b/src/assets/dioxus.toml index a5e849bfb..5c4f49f98 100644 --- a/src/assets/dioxus.toml +++ b/src/assets/dioxus.toml @@ -19,6 +19,8 @@ asset_dir = "public" # HTML title tag content title = "dioxus | ⛺" +index_on_404 = true + [web.watcher] watch_path = ["src"] @@ -45,10 +47,12 @@ script = [] binaryen = { wasm_opt = true } # use sass auto will auto check sass file and build it. -[application.tools.sass] + + +# [application.tools.sass] # auto will check the assets dirs, and auto to transform all scss file to css file. -input = "*" +# input = "*" # or you can specify some scss file -> css file # input = [ @@ -57,4 +61,4 @@ input = "*" # "/css/test.scss" # ] -source_map = true \ No newline at end of file +# source_map = true \ No newline at end of file From c97d7f263a4e785db533f726c80aee548d6f1cc0 Mon Sep 17 00:00:00 2001 From: YuKun Liu <41265098+mrxiaozhuox@users.noreply.github.com> Date: Sat, 9 Jul 2022 22:21:21 +0800 Subject: [PATCH 079/170] feat: commit code --- src/assets/dioxus.toml | 2 +- src/assets/index.html | 5 ++--- src/cli/create/mod.rs | 1 + 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/assets/dioxus.toml b/src/assets/dioxus.toml index 5c4f49f98..649aa2c3c 100644 --- a/src/assets/dioxus.toml +++ b/src/assets/dioxus.toml @@ -17,7 +17,7 @@ asset_dir = "public" [web.app] # HTML title tag content -title = "dioxus | ⛺" +title = "Dioxus | An elegant GUI library for Rust" index_on_404 = true diff --git a/src/assets/index.html b/src/assets/index.html index 87d447816..ed3d48135 100644 --- a/src/assets/index.html +++ b/src/assets/index.html @@ -9,10 +9,9 @@
-