diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1c79af5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,15 @@ +# .gitignore for tauri-events-minimal + +# will have compiled files and executables +/target/ + +# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries +# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html +Cargo.lock + +# These are backup files generated by rustfmt +**/*.rs.bk + +# Front-end-specific exclusions +node_modules/ +yarn.lock diff --git a/package.json b/package.json new file mode 100644 index 0000000..9577f5b --- /dev/null +++ b/package.json @@ -0,0 +1,14 @@ +{ + "name": "tauri-events-minimal", + "version": "0.1.0", + "description": "Minimal Tauri events example", + "main": "index.html", + "repository": "https://github.com/yassen-damyanov/tauri-events-minimal.git", + "author": "Yassen Damyanov ", + "license": "Apache-2.0", + "private": false, + "devDependencies": { + "@tauri-apps/api": "^1.0.0-beta.5", + "@tauri-apps/cli": "^1.0.0-beta.6" + } +} diff --git a/src-tauri/.gitignore b/src-tauri/.gitignore new file mode 100644 index 0000000..e5ec572 --- /dev/null +++ b/src-tauri/.gitignore @@ -0,0 +1,7 @@ +# Generated by Cargo +# will have compiled files and executables +/target/ +WixTools + +# Exclude the auto-genrated icons for now +/icons/ diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml new file mode 100644 index 0000000..1a75ef4 --- /dev/null +++ b/src-tauri/Cargo.toml @@ -0,0 +1,24 @@ +[package] +name = "app" +version = "0.1.0" +description = "A Tauri App" +authors = ["you"] +license = "" +repository = "" +default-run = "app" +edition = "2018" +build = "src/build.rs" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[build-dependencies] +tauri-build = { version = "1.0.0-beta.3" } + +[dependencies] +serde_json = "1.0" +serde = { version = "1.0", features = ["derive"] } +tauri = { version = "1.0.0-beta.5", features = ["api-all"] } + +[features] +default = [ "custom-protocol" ] +custom-protocol = [ "tauri/custom-protocol" ] diff --git a/src-tauri/rustfmt.toml b/src-tauri/rustfmt.toml new file mode 100644 index 0000000..16ef4db --- /dev/null +++ b/src-tauri/rustfmt.toml @@ -0,0 +1,14 @@ +max_width = 99 +hard_tabs = false +tab_spaces = 3 +newline_style = "Auto" +use_small_heuristics = "Default" +reorder_imports = true +reorder_modules = true +remove_nested_parens = true +edition = "2018" +merge_derives = true +use_try_shorthand = false +use_field_init_shorthand = false +force_explicit_abi = true +imports_granularity = "Crate" diff --git a/src-tauri/src/build.rs b/src-tauri/src/build.rs new file mode 100644 index 0000000..795b9b7 --- /dev/null +++ b/src-tauri/src/build.rs @@ -0,0 +1,3 @@ +fn main() { + tauri_build::build() +} diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs new file mode 100644 index 0000000..d375c1b --- /dev/null +++ b/src-tauri/src/main.rs @@ -0,0 +1,19 @@ +#![cfg_attr( + all(not(debug_assertions), target_os = "windows"), + windows_subsystem = "windows" +)] + +#[tauri::command] +fn say_hello(name: String) -> String { + let response = format!("Hello, {}!", name); + println!("{:?}", response); + response.into() +} + +fn main() { + println!("** Tauri app about to start"); + tauri::Builder::default() + .invoke_handler(tauri::generate_handler![say_hello,]) + .run(tauri::generate_context!()) + .expect("error while running tauri application"); +} diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json new file mode 100644 index 0000000..6fc6519 --- /dev/null +++ b/src-tauri/tauri.conf.json @@ -0,0 +1,68 @@ +{ + "package": { + "productName": "tauri-events-minimal", + "version": "0.1.0" + }, + "build": { + "distDir": "../www", + "devPath": "../www", + "beforeDevCommand": "", + "beforeBuildCommand": "", + "withGlobalTauri": true + }, + "tauri": { + "bundle": { + "active": true, + "targets": "all", + "identifier": "com.tauri.dev", + "icon": [ + "icons/32x32.png", + "icons/128x128.png", + "icons/128x128@2x.png", + "icons/icon.icns", + "icons/icon.ico" + ], + "resources": [], + "externalBin": [], + "copyright": "", + "category": "DeveloperTool", + "shortDescription": "", + "longDescription": "", + "deb": { + "depends": [], + "useBootstrapper": false + }, + "macOS": { + "frameworks": [], + "minimumSystemVersion": "", + "useBootstrapper": false, + "exceptionDomain": "", + "signingIdentity": null, + "entitlements": null + }, + "windows": { + "certificateThumbprint": null, + "digestAlgorithm": "sha256", + "timestampUrl": "" + } + }, + "updater": { + "active": false + }, + "allowlist": { + "all": true + }, + "windows": [ + { + "title": "Tauri Events (Minimal Sample App)", + "width": 800, + "height": 600, + "resizable": true, + "fullscreen": false + } + ], + "security": { + "csp": "default-src blob: data: filesystem: ws: wss: http: https: tauri: 'unsafe-eval' 'unsafe-inline' 'self' img-src: 'self'" + } + } +} diff --git a/www/index.html b/www/index.html new file mode 100644 index 0000000..1c16b29 --- /dev/null +++ b/www/index.html @@ -0,0 +1,30 @@ + + + + + Tauri Events (Minimal Example) + + + + + + + +

Tauri Events (Minimal Example)

+

Minimal example for a Tauri events-based application.

+ + + diff --git a/www/invoke.js b/www/invoke.js new file mode 100644 index 0000000..a5a3a0c --- /dev/null +++ b/www/invoke.js @@ -0,0 +1,11 @@ +/** + * Setup the bridge for invoking rust functions. + * (See https://tauri.studio/en/docs/usage/guides/command) + */ + +// With the Tauri API npm package: +import { invoke } from '/modules/@tauri-apps/api/tauri.js'; + +// With the Tauri global script, enabled when +// `tauri.conf.json > build > withGlobalTauri` is set to true: +export const invoke_cmd = window.__TAURI__.invoke; diff --git a/www/modules b/www/modules new file mode 120000 index 0000000..68a084a --- /dev/null +++ b/www/modules @@ -0,0 +1 @@ +../node_modules \ No newline at end of file diff --git a/www/styles.css b/www/styles.css new file mode 100644 index 0000000..2a887d5 --- /dev/null +++ b/www/styles.css @@ -0,0 +1,5 @@ +body { + background-color: #eee; + font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif; + font-size: 1.4em; +}