From 31e86d3cce3446072ed1a03fbf2a06ef856aeced Mon Sep 17 00:00:00 2001 From: Amr Bashir Date: Tue, 16 Apr 2024 00:56:42 +0200 Subject: [PATCH] chore: update tauri example to v2 (#132) * chore: update tauri example to v2 closes #131 * Update test.yml * Update test.yml --- .github/workflows/test.yml | 6 +- examples/tauri/src-tauri/.gitignore | 1 + examples/tauri/src-tauri/Cargo.toml | 15 ++--- examples/tauri/src-tauri/src/main.rs | 32 +++++----- examples/tauri/src-tauri/tauri.conf.json | 77 ++++++------------------ 5 files changed, 47 insertions(+), 84 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6f68155..93834c3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -21,7 +21,11 @@ jobs: if: matrix.platform == 'ubuntu-latest' run: | sudo apt-get update - sudo apt-get install -y libgtk-3-dev + sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.1-dev - uses: dtolnay/rust-toolchain@stable - run: cargo test + - name: test tauri example + run: | + cd examples/tauri/src-tauri + cargo test --features tauri/custom-protocol diff --git a/examples/tauri/src-tauri/.gitignore b/examples/tauri/src-tauri/.gitignore index 79bbe81..ef60fe3 100644 --- a/examples/tauri/src-tauri/.gitignore +++ b/examples/tauri/src-tauri/.gitignore @@ -5,3 +5,4 @@ # Generated by Cargo # will have compiled files and executables /target/ +gen/schemas \ No newline at end of file diff --git a/examples/tauri/src-tauri/Cargo.toml b/examples/tauri/src-tauri/Cargo.toml index 189052c..29b5b17 100644 --- a/examples/tauri/src-tauri/Cargo.toml +++ b/examples/tauri/src-tauri/Cargo.toml @@ -1,21 +1,16 @@ [package] name = "app" -version = "0.1.0" +version = "0.0.0" description = "A Tauri App" authors = ["Tauri Programme within The Commons Conservancy"] license = "MIT OR Apache-2.0" edition = "2021" +[build-dependencies] +tauri-build = { version = "2.0.0-beta" } + [dependencies] serde_json = "1" serde = { version = "1", features = ["derive"] } -tauri = { version = "1", features = ["api-all"] } +tauri = { version = "2.0.0-beta", features = ["macos-private-api"] } window-vibrancy = { path = "../../../" } - - -[build-dependencies] -tauri-build = { version = "1" } - -[features] -default = ["custom-protocol"] -custom-protocol = ["tauri/custom-protocol"] diff --git a/examples/tauri/src-tauri/src/main.rs b/examples/tauri/src-tauri/src/main.rs index a691cb6..8c36889 100644 --- a/examples/tauri/src-tauri/src/main.rs +++ b/examples/tauri/src-tauri/src/main.rs @@ -3,28 +3,28 @@ // SPDX-License-Identifier: MIT #![cfg_attr( - all(not(debug_assertions), target_os = "windows"), - windows_subsystem = "windows" + all(not(debug_assertions), target_os = "windows"), + windows_subsystem = "windows" )] use tauri::Manager; -use window_vibrancy::{apply_blur, apply_vibrancy, NSVisualEffectMaterial}; +use window_vibrancy::*; fn main() { - tauri::Builder::default() - .setup(|app| { - let window = app.get_window("main").unwrap(); + tauri::Builder::default() + .setup(|app| { + let window = app.get_webview_window("main").unwrap(); - #[cfg(target_os = "macos")] - apply_vibrancy(&window, NSVisualEffectMaterial::HudWindow, None, None) - .expect("Unsupported platform! 'apply_vibrancy' is only supported on macOS"); + #[cfg(target_os = "macos")] + apply_vibrancy(&window, NSVisualEffectMaterial::HudWindow, None, None) + .expect("Unsupported platform! 'apply_vibrancy' is only supported on macOS"); - #[cfg(target_os = "windows")] - apply_blur(&window, Some((18, 18, 18, 125))) - .expect("Unsupported platform! 'apply_blur' is only supported on Windows"); + #[cfg(target_os = "windows")] + apply_blur(&window, Some((18, 18, 18, 125))) + .expect("Unsupported platform! 'apply_blur' is only supported on Windows"); - Ok(()) - }) - .run(tauri::generate_context!()) - .expect("error while running tauri application"); + Ok(()) + }) + .run(tauri::generate_context!()) + .expect("error while running tauri application"); } diff --git a/examples/tauri/src-tauri/tauri.conf.json b/examples/tauri/src-tauri/tauri.conf.json index 3d48630..9bd24ae 100644 --- a/examples/tauri/src-tauri/tauri.conf.json +++ b/examples/tauri/src-tauri/tauri.conf.json @@ -1,65 +1,28 @@ { - "package": { - "productName": "app", - "version": "0.1.0" - }, + "productName": "TauriApp", + "version": "0.0.0", + "identifier": "com.tauri.dev", "build": { - "distDir": "../public", - "devPath": "../public" + "frontendDist": "../public" }, - "tauri": { - "bundle": { - "active": true, - "targets": "all", - "identifier": "com.tauri.window-vibrancy", - "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": [] - }, - "macOS": { - "frameworks": [], - "exceptionDomain": "", - "signingIdentity": null, - "entitlements": null - }, - "windows": { - "certificateThumbprint": null, - "digestAlgorithm": "sha256", - "timestampUrl": "" - } - }, - "updater": { - "active": false - }, - "allowlist": { - "all": true - }, + "app": { + "withGlobalTauri": true, + "windows": [{ "decorations": false, "transparent": true }], "macOSPrivateApi": true, - "windows": [ - { - "title": "app", - "width": 800, - "height": 600, - "resizable": true, - "fullscreen": false, - "transparent": true, - "decorations": false - } - ], "security": { - "csp": "default-src blob: data: filesystem: ws: wss: http: https: tauri: 'unsafe-eval' 'unsafe-inline' 'self' img-src: 'self'" + "csp": null } + }, + "bundle": { + "active": true, + "targets": "all", + "icon": [ + "icons/32x32.png", + "icons/128x128.png", + "icons/128x128@2x.png", + "icons/icon.icns", + "icons/icon.ico" + ], + "resources": ["icons/32x32.png"] } }