├── Cargo.toml ├── .gitignore ├── app-screenshot.png ├── .gitmodules ├── src-tauri ├── icons │ └── 32x32.png ├── src │ ├── cmd.rs │ ├── build.rs │ └── main.rs ├── Cargo.toml └── tauri.conf.json ├── package.json ├── Makefile ├── README.md ├── LICENSE └── scripts └── build.sh /Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | members = [ 3 | "src-tauri", 4 | ] 5 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | Cargo.lock 2 | **/node_modules 3 | yarn.lock 4 | target/ 5 | 6 | -------------------------------------------------------------------------------- /app-screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbucek/tauri-yewprint-desktop-app/HEAD/app-screenshot.png -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "yewprint"] 2 | path = yewprint 3 | url = https://github.com/cecton/yewprint.git 4 | -------------------------------------------------------------------------------- /src-tauri/icons/32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fbucek/tauri-yewprint-desktop-app/HEAD/src-tauri/icons/32x32.png -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "tauri-yew", 3 | "version": "0.1.0", 4 | "main": "index.js", 5 | "license": "MIT", 6 | "dependencies": { 7 | "tauri": "^0.12.0" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: dev yewprint-doc tauri run 2 | 3 | all: yewprint-doc run 4 | 5 | # Deploy yewprint-doc to public folder 6 | yewprint-doc: 7 | cd yewprint && ./build.sh 8 | 9 | # Requirements: cargo install simple-http-server 10 | dev: 11 | cd yewprint && ./dev.sh 12 | 13 | run: #yewprint-doc 14 | scripts/build.sh 15 | -------------------------------------------------------------------------------- /src-tauri/src/cmd.rs: -------------------------------------------------------------------------------- 1 | use serde::Deserialize; 2 | 3 | #[derive(Deserialize)] 4 | #[serde(tag = "cmd", rename_all = "camelCase")] 5 | pub enum Cmd { 6 | // your custom commands 7 | // multiple arguments are allowed 8 | // note that rename_all = "camelCase": you need to use "myCustomCommand" on JS 9 | MyCustomCommand { argument: String }, 10 | } 11 | -------------------------------------------------------------------------------- /src-tauri/src/build.rs: -------------------------------------------------------------------------------- 1 | #[cfg(windows)] 2 | extern crate winres; 3 | 4 | #[cfg(windows)] 5 | fn main() { 6 | if std::path::Path::new("icons/icon.ico").exists() { 7 | let mut res = winres::WindowsResource::new(); 8 | res.set_icon("icons/icon.ico"); 9 | res.compile().expect("Unable to find visual studio tools"); 10 | } else { 11 | panic!("No Icon.ico found. Please add one or check the path"); 12 | } 13 | } 14 | 15 | #[cfg(not(windows))] 16 | fn main() {} 17 | -------------------------------------------------------------------------------- /src-tauri/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "tauriapp" 3 | version = "0.1.0" 4 | description = "A Tauri App" 5 | author = [ "you" ] 6 | license = "" 7 | repository = "" 8 | default-run = "tauriapp" 9 | edition = "2018" 10 | build = "src/build.rs" 11 | 12 | [dependencies] 13 | serde_json = "1.0" 14 | serde = { version = "1.0", features = [ "derive" ] } 15 | tauri = { version = "0.9", features = [ "all-api" ] } 16 | 17 | [target."cfg(windows)".build-dependencies] 18 | winres = "0.1" 19 | 20 | [features] 21 | embedded-server = [ "tauri/embedded-server" ] 22 | no-server = [ "tauri/no-server" ] 23 | 24 | [[bin]] 25 | name = "tauriapp" 26 | path = "src/main.rs" 27 | -------------------------------------------------------------------------------- /src-tauri/tauri.conf.json: -------------------------------------------------------------------------------- 1 | { 2 | "build": { 3 | "distDir": "../yewprint/public", 4 | "devPath": "http://localhost:8000" 5 | }, 6 | "ctx": {}, 7 | "tauri": { 8 | "embeddedServer": { 9 | "active": true 10 | }, 11 | "bundle": { 12 | "active": true, 13 | "identifier": "com.tauri.dev", 14 | "icon": ["icons/32x32.png"], 15 | "targets": ["deb", "osx", "msi", "appimage"] 16 | }, 17 | "allowlist": { 18 | "all": true 19 | }, 20 | "window": { 21 | "title": "Tauri App - Yew" 22 | }, 23 | "security": { 24 | "csp": "default-src blob: data: filesystem: ws: http: https: 'unsafe-eval' 'unsafe-inline'" 25 | }, 26 | "inliner": { 27 | "active": true 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src-tauri/src/main.rs: -------------------------------------------------------------------------------- 1 | #![cfg_attr( 2 | all(not(debug_assertions), target_os = "windows"), 3 | windows_subsystem = "windows" 4 | )] 5 | 6 | mod cmd; 7 | 8 | fn main() { 9 | tauri::AppBuilder::new() 10 | .invoke_handler(|_webview, arg| { 11 | use cmd::Cmd::*; 12 | match serde_json::from_str(arg) { 13 | Err(e) => { 14 | Err(e.to_string()) 15 | } 16 | Ok(command) => { 17 | match command { 18 | // definitions for your custom commands from Cmd here 19 | MyCustomCommand { argument } => { 20 | // your command code 21 | println!("{}", argument); 22 | } 23 | } 24 | Ok(()) 25 | } 26 | } 27 | }) 28 | .build() 29 | .run(); 30 | } 31 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Tauri Yewprint desktop app 2 | 3 | Example how to combine [Tauri toolkit](https://tauri.studio/), [Yew](https://github.com/yewstack/yew) and [Yewprint](https://github.com/cecton/yewprint) into small desktop application with clean UI. 4 | 5 | Size of application without additional optimization (Mac): 4.7MB 6 | 7 | ![app screenshot](app-screenshot.png) 8 | 9 | | Tested on | Mac | Win | Lin | 10 | |---|---|---|--- 11 | | Tauri | ✅ | ❌ | ❌ | 12 | 13 | Application is using: 14 | 15 | - [Tauri toolkit](https://tauri.studio/) that helps developers make applications for the major desktop platforms. 16 | - [Yewprint](https://github.com/cecton/yewprint) port of [Blueprint.js](https://blueprintjs.com), but for 17 | [Yew](https://github.com/yewstack/yew) in [Rust](https://www.rust-lang.org/). 18 | 19 | - macOS requirements: `brew install yarn` 20 | 21 | ## How to run 22 | 23 | - `make` -> see Makefile for details 24 | 25 | ## Requirements 26 | 27 | Requirements for [Yew](https://github.com/yewstack/yew) and [Tauri toolkit](https://tauri.studio/) 28 | 29 | ### Mac 30 | 31 | - `brew install yarn` 32 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Filip Bucek 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /scripts/build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # src: https://gist.github.com/fbucek/f986da3cc3a9bbbd1573bdcb23fed2e1 4 | set -e # error -> trap -> exit 5 | function info() { echo -e "[\033[0;34m $@ \033[0m]"; } # blue: [ info message ] 6 | function pass() { echo -e "[\033[0;32mPASS\033[0m] $@"; } # green: [PASS] 7 | function fail() { FAIL="true"; echo -e "[\033[0;31mFAIL\033[0m] $@"; } # red: [FAIL] 8 | trap 'LASTRES=$?; LAST=$BASH_COMMAND; if [[ LASTRES -ne 0 ]]; then fail "Command: \"$LAST\" exited with exit code: $LASTRES"; elif [ "$FAIL" == "true" ]; then fail finished with error; else echo -e "[\033[0;32m Finished $@ \033[0m]";fi' EXIT 9 | SRCDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" # this source dir 10 | 11 | ROOT_DIR=$SRCDIR/.. 12 | 13 | cd ${ROOT_DIR} 14 | 15 | # When CARGO_TARGET_DIR is not used -> setup to actuall target dir 16 | if [ -z ${CARGO_TARGET_DIR} ]; then 17 | export CARGO_TARGET_DIR=${ROOT_DIR}/target; 18 | fi 19 | 20 | info "yarn install" 21 | yarn install 22 | 23 | info "Build tauri app" 24 | # Have to remove binary in order to rebuild 25 | rm -f ${CARGO_TARGET_DIR}/release/tauriapp 26 | yarn tauri build 27 | 28 | info "Run tauri app" 29 | ${CARGO_TARGET_DIR}/release/tauriapp 30 | --------------------------------------------------------------------------------