Skip to content

Commit

Permalink
Merge branch 'v2' into v2
Browse files Browse the repository at this point in the history
  • Loading branch information
bicarlsen authored Aug 6, 2024
2 parents e29862f + 115009d commit e72a028
Show file tree
Hide file tree
Showing 36 changed files with 920 additions and 0 deletions.
3 changes: 3 additions & 0 deletions examples/leptos/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/dist/
/target/
/Cargo.lock
3 changes: 3 additions & 0 deletions examples/leptos/.taurignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/src
/public
/Cargo.toml
3 changes: 3 additions & 0 deletions examples/leptos/.vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"recommendations": ["tauri-apps.tauri-vscode", "rust-lang.rust-analyzer"]
}
5 changes: 5 additions & 0 deletions examples/leptos/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"emmet.includeLanguages": {
"rust": "html"
}
}
22 changes: 22 additions & 0 deletions examples/leptos/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[package]
name = "test-tauri-events-ui"
version = "0.0.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
leptos = { version = "0.6", features = ["csr", "nightly"] }
wasm-bindgen = "0.2"
wasm-bindgen-futures = "0.4"
js-sys = "0.3"
serde = { version = "1", features = ["derive"] }
serde-wasm-bindgen = "0.6"
console_error_panic_hook = "0.1.7"
tauri-sys = { path = "../tauri-sys", features = ["all"] }
futures = "0.3"
tracing = "0.1.40"
tracing-subscriber = "0.3.18"
tracing-web = "0.1.3"

[workspace]
members = ["src-tauri"]
7 changes: 7 additions & 0 deletions examples/leptos/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Tauri + Leptos

This template should help get you started developing with Tauri and Leptos.

## Recommended IDE Setup

[VS Code](https://code.visualstudio.com/) + [Tauri](https://marketplace.visualstudio.com/items?itemName=tauri-apps.tauri-vscode) + [rust-analyzer](https://marketplace.visualstudio.com/items?itemName=rust-lang.rust-analyzer).
10 changes: 10 additions & 0 deletions examples/leptos/Trunk.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[build]
target = "./index.html"

[watch]
ignore = ["./src-tauri"]

[serve]
address = "127.0.0.1"
port = 1420
open = false
11 changes: 11 additions & 0 deletions examples/leptos/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<title>Tauri + Leptos App</title>
<link data-trunk rel="css" href="styles.css" />
<link data-trunk rel="copy-dir" href="public" />
<link data-trunk rel="rust" data-wasm-opt="z" />
</head>
<body></body>
</html>
64 changes: 64 additions & 0 deletions examples/leptos/public/leptos.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions examples/leptos/public/tauri.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions examples/leptos/src-tauri/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Generated by Cargo
# will have compiled files and executables
/target/

# Generated by Tauri
# will have schema files for capabilities auto-completion
/gen/schemas
20 changes: 20 additions & 0 deletions examples/leptos/src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[package]
name = "test-tauri-events"
version = "0.0.0"
description = "A Tauri App"
authors = ["you"]
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[build-dependencies]
# tauri-build = { version = "2.0.0-beta", features = [] }
tauri-build = { path = "../../tauri/core/tauri-build", features = [] }

[dependencies]
tauri = { path = "../../tauri/core/tauri", features = [] }
tauri-plugin-shell = { path = "../../plugins-workspace/plugins/shell" }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
tracing = "0.1.40"
tracing-subscriber = "0.3.18"
3 changes: 3 additions & 0 deletions examples/leptos/src-tauri/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() {
tauri_build::build()
}
17 changes: 17 additions & 0 deletions examples/leptos/src-tauri/capabilities/default.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"$schema": "../gen/schemas/desktop-schema.json",
"identifier": "default",
"description": "Capability for the main window",
"windows": ["main"],
"permissions": [
"core:path:default",
"core:event:default",
"core:window:default",
"core:app:default",
"core:image:default",
"core:resources:default",
"core:menu:default",
"core:tray:default",
"shell:allow-open"
]
}
Binary file added examples/leptos/src-tauri/icons/128x128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/leptos/src-tauri/icons/32x32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/leptos/src-tauri/icons/Square30x30Logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/leptos/src-tauri/icons/StoreLogo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/leptos/src-tauri/icons/icon.icns
Binary file not shown.
Binary file added examples/leptos/src-tauri/icons/icon.ico
Binary file not shown.
Binary file added examples/leptos/src-tauri/icons/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
41 changes: 41 additions & 0 deletions examples/leptos/src-tauri/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Prevents additional console window on Windows in release, DO NOT REMOVE!!
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]

use tauri::{Emitter, Manager};

fn main() {
logging::enable();
tauri::Builder::default()
.invoke_handler(tauri::generate_handler![trigger_listen_events,])
.run(tauri::generate_context!())
.expect("error while running tauri application");
}

#[tauri::command]
fn trigger_listen_events(app: tauri::AppHandle) {
tracing::debug!("trigger_listen_event");
std::thread::spawn({
move || {
for i in 1..=100 {
app.emit("event::listen", i).unwrap();
std::thread::sleep(std::time::Duration::from_millis(500));
}
}
});
}

mod logging {
use tracing_subscriber::{filter::LevelFilter, fmt, prelude::*, Layer, Registry};

const MAX_LOG_LEVEL: LevelFilter = LevelFilter::DEBUG;

pub fn enable() {
let console_logger = fmt::layer()
.with_writer(std::io::stdout)
.pretty()
.with_filter(MAX_LOG_LEVEL);

let subscriber = Registry::default().with(console_logger);
tracing::subscriber::set_global_default(subscriber).unwrap();
}
}
35 changes: 35 additions & 0 deletions examples/leptos/src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"productName": "test-tauri-events",
"version": "0.0.0",
"identifier": "com.tauri.dev",
"build": {
"beforeDevCommand": "trunk serve",
"devUrl": "http://localhost:1420",
"beforeBuildCommand": "trunk build",
"frontendDist": "../dist"
},
"app": {
"withGlobalTauri": true,
"windows": [
{
"title": "test-tauri-events",
"width": 800,
"height": 600
}
],
"security": {
"csp": null
}
},
"bundle": {
"active": true,
"targets": "all",
"icon": [
"icons/32x32.png",
"icons/128x128.png",
"icons/[email protected]",
"icons/icon.icns",
"icons/icon.ico"
]
}
}
Loading

0 comments on commit e72a028

Please sign in to comment.