-
-
Notifications
You must be signed in to change notification settings - Fork 960
Add initial Tauri v2 support #4379
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for origin-betaflight-app ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
I haven't tested it, but two questions or confirmations:
I'm right? |
For now this is for evaluation purpose |
4ba0507
to
eff5f85
Compare
I'm new to PWA , I want use tauri to communite with mavsdk , I want to base this project, I have no idea with this PWA , I don't know how to add tauri callback in this PWA,Can you give me some ideas. |
|
WalkthroughThis change introduces Tauri 2.0 support to the project. It adds Tauri configuration, build scripts, Rust source files, and updates the JavaScript codebase to detect Tauri as a native platform. The build process and dependencies are adjusted to support building and running the application as a Tauri-based desktop app. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant TauriApp (Rust)
participant Frontend (JS)
participant OS
User->>TauriApp (Rust): Launch application
TauriApp (Rust)->>Frontend (JS): Initialize webview and load frontend
Frontend (JS)->>Frontend (JS): checkBrowserCompatibility()
Frontend (JS)->>Frontend (JS): isTauri() → true
Frontend (JS)->>TauriApp (Rust): (if needed) Use Tauri API for native features
TauriApp (Rust)->>OS: Invoke native capabilities (via plugins)
OS-->>TauriApp (Rust): Respond to native requests
TauriApp (Rust)-->>Frontend (JS): Return results
Possibly related issues
📜 Recent review detailsConfiguration used: .coderabbit.yaml ⛔ Files ignored due to path filters (3)
📒 Files selected for processing (8)
🚧 Files skipped from review as they are similar to previous changes (8)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Nitpick comments (1)
src-tauri/src/main.rs (1)
6-11
: Consider improving error handling for production use.The main function structure is correct and follows Tauri best practices. However, using
.expect()
will cause the application to panic on startup errors.For production use, consider implementing more graceful error handling:
fn main() { - tauri::Builder::default() - .plugin(tauri_plugin_shell::init()) - .run(tauri::generate_context!()) - .expect("error while running tauri application"); + if let Err(e) = tauri::Builder::default() + .plugin(tauri_plugin_shell::init()) + .run(tauri::generate_context!()) { + eprintln!("Failed to start application: {}", e); + std::process::exit(1); + } }Given this is experimental/evaluation code, the current approach is acceptable for now.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (3)
src-tauri/Cargo.lock
is excluded by!**/*.lock
src-tauri/icons/bf_icon_128.png
is excluded by!**/*.png
yarn.lock
is excluded by!**/yarn.lock
,!**/*.lock
📒 Files selected for processing (8)
.gitignore
(1 hunks)package.json
(2 hunks)src-tauri/Cargo.toml
(1 hunks)src-tauri/build.rs
(1 hunks)src-tauri/src/main.rs
(1 hunks)src-tauri/tauri.conf.json
(1 hunks)src/js/utils/checkBrowserCompatibility.js
(1 hunks)vite.config.js
(2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
src-tauri/src/main.rs (1)
src-tauri/build.rs (1)
main
(1-3)
src-tauri/build.rs (1)
src-tauri/src/main.rs (1)
main
(6-11)
🔇 Additional comments (16)
.gitignore (1)
45-47
: LGTM! Standard Tauri ignore patterns added.The added entries correctly exclude Tauri build artifacts:
src-tauri/target/
for Rust/Cargo compilation artifactssrc-tauri/gen/
for Tauri-generated codeThese are essential for keeping build outputs out of version control.
src-tauri/build.rs (1)
1-3
: LGTM! Standard minimal Tauri build script.This is the correct minimal implementation for a Tauri build script. The
tauri_build::build()
call handles all necessary Tauri-specific build steps during compilation.vite.config.js (2)
59-60
: LGTM! Build configuration aligned with Tauri requirements.The explicit
outDir: "dist"
andemptyOutDir: true
settings ensure that the frontend build outputs are correctly placed and cleaned for Tauri consumption.
120-120
: LGTM! Convenient alias for source directory.The
"@": resolve(__dirname, "src")
alias provides a clean way to reference the source directory in imports, which is a common pattern in Vue.js projects.src-tauri/src/main.rs (1)
1-4
: LGTM! Correct Windows subsystem configuration.The conditional compilation attribute properly suppresses the console window on Windows in release builds, which is appropriate for a desktop GUI application.
src/js/utils/checkBrowserCompatibility.js (2)
63-65
: LGTM! Standard Tauri detection implementation.The function correctly uses the
__TAURI_INTERNALS__
global variable to detect when running in a Tauri environment, which is the recommended approach according to Tauri documentation.
73-73
: Good integration with existing platform detection.Correctly treats Tauri as a native platform alongside Capacitor, which makes sense since both provide native desktop/mobile app capabilities that don't require web browser APIs like WebSerial or WebUSB.
src-tauri/tauri.conf.json (3)
25-28
:❓ Verification inconclusive
Bundle targets are Linux-focused - confirm platform strategy.
The bundle configuration only targets Linux packages (deb, appimage). Given that the PR mentions this is for evaluation purposes, confirm whether Windows and macOS targets will be added later or if Linux-only distribution is intentional.
🌐 Web query:
What are the recommended bundle targets for Tauri v2 cross-platform desktop applications?
💡 Result:
In Tauri v2, when configuring your cross-platform desktop application, you can specify the bundle targets in the
tauri.conf.json
configuration file under thebundle
section. Thetargets
property defines the formats in which your application will be bundled. By default, this is set to"all"
, which includes all available targets. You can customize this to include specific targets as needed.The available bundle targets are:
Windows:
"nsis"
: NSIS installer (.exe
)"msi"
: Microsoft Installer (.msi
)"app"
: Windows application bundle (.app
)"dmg"
: Apple Disk Image (.dmg
)macOS:
"app"
: macOS application bundle (.app
)"dmg"
: Apple Disk Image (.dmg
)Linux:
"deb"
: Debian package (.deb
)"rpm"
: RPM package (.rpm
)"appimage"
: AppImage bundle (.appimage
)Cross-Platform:
"all"
: Bundles all available targetsTo specify the bundle targets in your
tauri.conf.json
file, you can set thetargets
property under thebundle
section. For example, to bundle your application for Windows and macOS, you would configure it as follows:{ "bundle": { "targets": ["nsis", "app", "dmg"] } }This configuration will generate installers for Windows (
.exe
), and application bundles for macOS (.app
and.dmg
). For a comprehensive list of all available bundle targets and their configurations, refer to the Tauri documentation. (tauri.app)Citations:
Clarify cross-platform bundle targets
Currently in
src-tauri/tauri.conf.json
(around lines 25–28) your bundle targets are set to:"bundle": { "active": true, "targets": ["deb", "appimage"], "icon": ["icons/bf_icon_128.png"] }– those are Linux-only formats. Tauri v2 also supports Windows (
"nsis"
,"msi"
,"app"
,"dmg"
) and macOS ("app"
,"dmg"
) bundles, or a single"all"
target to cover everything.Please confirm whether you intend to ship Linux-only (for evaluation) or if you’ll add Windows/macOS targets (or switch to
"all"
) before release.
5-9
:✅ Verification successful
Verify build commands consistency.
The build commands reference
yarn dev
andyarn build
scripts. Ensure these correspond to the scripts defined in package.json and that the development server runs on the configured port (8000).
🏁 Script executed:
#!/bin/bash # Verify that the referenced yarn scripts exist in package.json echo "Checking for yarn scripts referenced in tauri.conf.json..." jq -r '.scripts | keys[]' package.json | grep -E "^(dev|build)$" || echo "Missing required scripts" # Check if dev script uses port 8000 echo "Checking dev script configuration..." jq -r '.scripts.dev' package.jsonLength of output: 325
🏁 Script executed:
#!/bin/bash # Locate any Vite config files in the repo echo "Locating vite config files..." vite_configs=$(fd -t f -H "vite.config.*") if [ -z "$vite_configs" ]; then echo "No vite.config.* files found." else for cfg in $vite_configs; do echo "Inspecting $cfg for server port settings:" grep -R "server" -n "$cfg" -A3 || echo "No 'server' block in $cfg" grep -R "port" -n "$cfg" || echo "No explicit port setting in $cfg" done fiLength of output: 1222
Build commands and devUrl verified
- Both
dev
andbuild
scripts exist in package.json.- The Vite dev server is explicitly configured with
which matchesserver: { port: 8000, strictPort: true, }"devUrl": "http://localhost:8000"
in tauri.conf.json.- The frontend build output defaults to
dist
, so"frontendDist": "../dist"
is correct.No changes required.
30-34
:❓ Verification inconclusive
Shell plugin enabled - verify security implications.
The shell plugin with
open: true
allows the application to execute system commands and open files/URLs. Ensure this is necessary for the application's functionality and that proper input validation is implemented wherever this plugin is used.
🏁 Script executed:
#!/bin/bash # Search for usage of Tauri shell plugin in the codebase echo "Searching for shell plugin usage..." rg -A 3 -B 3 "shell|invoke.*shell|@tauri-apps.*shell" --type jsLength of output: 146
This will confirm whether the shell plugin is actually referenced in your Rust code.
🏁 Script executed:
#!/bin/bash echo "Searching for shell plugin usage in Rust code..." # Look for direct imports of the shell plugin rg -n "use .*shell" --type rs # Look for any references to the plugin namespace rg -n "tauri_plugin_shell" --type rs # Look for any invocation or initialization calls rg -A3 -B3 "shell::" --type rsLength of output: 287
🏁 Script executed:
#!/bin/bash echo "Locating Cargo.toml files..." find . -maxdepth 4 -type f -name Cargo.toml echo echo "Checking for tauri-plugin-shell in Cargo.toml dependencies..." rg -n "tauri-plugin-shell" -g "*.toml" echo echo "Searching Rust source for plugin initialization or references..." rg -n "tauri_plugin_shell" -g "*.rs" rg -n "shell::init" -g "*.rs" rg -n "plugin(" -g "*.rs" | grep shell || true echo echo "Searching front-end code for shell plugin invocations..." rg -n "plugin:shell" -g "*.js" -g "*.ts" -g "*.tsx"Length of output: 1014
Verify Shell Plugin Necessity and Usage
The Tauri Shell plugin is enabled in your configuration and initialized in the Rust backend, but we didn’t find any front-end invocations. Please confirm whether you actually need this plugin, and if so, ensure every call is properly validated to avoid command injection or unintended file/URL access.
• src-tauri/tauri.conf.json (lines 30–34):
"plugins": { "shell": { "open": true } }
• src-tauri/Cargo.toml (line 15):tauri-plugin-shell = "2.0.0"
• src-tauri/src/main.rs (line 8):.plugin(tauri_plugin_shell::init())
If the shell plugin isn’t used, remove it to reduce your attack surface. Otherwise, audit all places where you call into the shell API and enforce strict input validation.
package.json (2)
26-27
: LGTM! Standard Tauri script integration.The script names follow Tauri conventions and integrate well with the existing build workflow. These scripts correspond to the build commands configured in
tauri.conf.json
.
25-25
: Minor modification to prepare script looks correct.The husky install preparation remains intact, which is good for maintaining git hooks functionality.
src-tauri/Cargo.toml (4)
1-8
: Excellent version consistency across the project.The package metadata properly matches the version (11.0.0) and project details from
package.json
andtauri.conf.json
, ensuring consistency across the Tauri integration.
13-17
: Standard and appropriate Tauri dependencies.The dependency selection is correct for a basic Tauri v2 application:
- Core Tauri framework
- Shell plugin for system interactions
- Serde for JSON serialization (standard for Tauri apps)
19-21
: Custom protocol feature is a good security practice.Enabling the
custom-protocol
feature is recommended for production Tauri applications as it provides better security than the default localhost-based approach during development.
10-11
:✅ Verification successful
Verify Tauri build dependency version compatibility.
Let's ensure the tauri-build version is compatible with the runtime tauri dependency version (both should be from the same major.minor release).
🌐 Web query:
Are tauri-build 2.0.6 and tauri 2.0.6 compatible versions for Tauri v2 applications?
💡 Result:
Yes, tauri-build 2.0.6 and tauri 2.0.6 are compatible versions for Tauri v2 applications. The Tauri framework follows semantic versioning principles where the major version number is incremented for breaking changes, and minor or patch updates are backward compatible within the same major version. This means you should always be able to safely upgrade to the latest minor or patch versions without compatibility issues between related crates like tauri and tauri-build[2][8].
Specifically, at version 2.0.6, tauri and tauri-build are aligned as part of the Tauri 2.x stable release series, ensuring compatibility for building and running Tauri v2 applications[1][6]. It is recommended to keep the versions of the Tauri core crates (like tauri and tauri-build) in sync, generally using the exact same version number, to avoid any subtle incompatibilities[8].
Therefore, using tauri 2.0.6 together with tauri-build 2.0.6 is the correct approach for Tauri v2 apps.
Citations:
- 1: https://v2.tauri.app/blog/tauri-20/
- 2: https://v2.tauri.app/develop/configuration-files/
- 3: https://github.com/tauri-apps/tauri
- 4: Adding capabilities in tauri v2 beta for my custom plugin tauri-apps/tauri#8813
- 5: https://v2.tauri.app/distribute/windows-installer/
- 6: https://tauri.app/release/@tauri-apps/cli/v2.0.0-alpha.6/
- 7: [bug] Tauri v2 has constrained compatibility on Linux tauri-apps/tauri#9039
- 8: https://v2.tauri.app/develop/updating-dependencies/
- 9: package conflict problem tauri-apps/tauri#8563
- 10: https://v2.tauri.app/plugin/updater/
Tauri build dependency version compatibility confirmed
The tauri-build entry in
src-tauri/Cargo.toml
is already at version 2.0.6, matching the runtimetauri = "2.0.6"
release. Since Tauri follows semantic versioning within the 2.x series, these versions are fully compatible—no changes needed.
|
Preview URL: https://7455b580.betaflight-configurator.pages.dev |
This pull request introduces the integration of Tauri into the project, along with some configuration and dependency updates. The most important changes include adding new scripts and dependencies to
package.json
, creating Tauri-specific configuration files, and updating build settings invite.config.js
.Requirements
Docker
Tauri Integration:
package.json
: Added new scripts for Tauri development and build, and included Tauri dependencies (@tauri-apps/api
and@tauri-apps/cli
). [1] [2]src-tauri/Cargo.toml
: Created a new Cargo configuration file for the Tauri application.src-tauri/build.rs
: Added a build script for Tauri.src-tauri/src/main.rs
: Set up the main entry point for the Tauri application.src-tauri/tauri.conf.json
: Created a Tauri configuration file with application settings and build commands.Build Configuration:
vite.config.js
: Updated the build output directory and added an alias for thesrc
directory. [1] [2]Summary by CodeRabbit
New Features
Chores