Skip to content

Commit 06956de

Browse files
authored
Merge pull request #11 from pnstack/copilot/fix-0c20064d-b8b9-4dd5-a60c-63ad3e8c80b0
Upgrade Tauri to v2.8 and Vite to v5.4
2 parents 58f44c8 + 403c36d commit 06956de

27 files changed

Lines changed: 17322 additions & 1959 deletions

File tree

UPGRADE_NOTES.md

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
# Tauri v2 and Vite v5 Upgrade Notes
2+
3+
## Overview
4+
This document summarizes the upgrade from Tauri v1.6 to v2.8 and Vite v4.4 to v5.4.20.
5+
6+
## Version Changes
7+
8+
### Frontend
9+
- **Vite**: v4.4.4 → v5.4.20
10+
- **@vitejs/plugin-react**: v4.0.4 → v4.7.0
11+
- **@vitejs/plugin-react-swc**: v3.3.2 → v3.11.0
12+
- **@tauri-apps/api**: v1.6.0 → v2.8.0
13+
- **@tauri-apps/cli**: v1.6.1 → v2.8.4
14+
15+
### Backend (Rust)
16+
- **tauri**: v1.7.2 → v2.8.5
17+
- **tauri-build**: v1.5.4 → v2.8.5
18+
19+
### New Dependencies
20+
- **dirs**: v5.0 (for home directory access)
21+
- **Multiple Tauri plugins**: All migrated to v2 versions
22+
23+
## Breaking Changes Fixed
24+
25+
### Rust/Backend Changes
26+
27+
1. **Path API Migration**
28+
- Changed from: `tauri::api::path::home_dir()`
29+
- Changed to: `dirs::home_dir()`
30+
- Files affected: `src-tauri/src/db/mod.rs`, `src-tauri/src/modules/python/mod.rs`, `src-tauri/src/modules/node/mod.rs`
31+
32+
2. **Event Handling**
33+
- Changed from: `app.listen_global()`
34+
- Changed to: Event handling via app context (temporarily commented out)
35+
- File: `src-tauri/src/main.rs`
36+
37+
3. **Window API**
38+
- Changed from: `app.get_window()`
39+
- Changed to: `app.get_webview_window()`
40+
- File: `src-tauri/src/main.rs`
41+
42+
4. **RunEvent Import**
43+
- Now part of: `tauri::RunEvent` (direct usage)
44+
- File: `src-tauri/src/main.rs`
45+
46+
5. **Configuration Changes**
47+
- `tauri.conf.json` migrated to v2 format
48+
- `distDir``frontendDist`
49+
- `devPath``devUrl`
50+
- Removed `trayIcon` from config (needs plugin reimplementation)
51+
52+
### TypeScript/Frontend Changes
53+
54+
1. **HTTP Plugin API**
55+
- Changed from: `fetch<string>(url, { responseType: ResponseType.Text }).then(res => res.data)`
56+
- Changed to: `fetch(url, { method: 'GET' }).then(res => res.text())`
57+
- File: `src/modules/dictionary/index.tsx`
58+
59+
2. **Shell Command API**
60+
- Changed from: `new Command('cmd', args)`
61+
- Changed to: `Command.create('cmd', args)`
62+
- File: `src/modules/tauri/components/shell/index.tsx`
63+
64+
3. **FS writeTextFile API**
65+
- Changed from: `writeTextFile({ contents, path }, { dir: BaseDirectory.Home })`
66+
- Changed to: `writeTextFile(path, contents, { baseDir: BaseDirectory.Home })`
67+
- File: `src/modules/tauri/components/shell/index.tsx`
68+
69+
4. **Import Path Updates**
70+
- Changed from: `import { invoke } from '@tauri-apps/api'`
71+
- Changed to: `import { invoke } from '@tauri-apps/api/core'`
72+
- File: `src/modules/tauri/components/storage/index.tsx`
73+
74+
## Features Temporarily Disabled
75+
76+
### Menu System
77+
- **Status**: Disabled during migration
78+
- **Reason**: Tauri v2 completely redesigned the menu API
79+
- **Files affected**: `src-tauri/src/menus/mod.rs`, `src-tauri/src/main.rs`
80+
- **TODO**: Reimplement using Tauri v2's new menu API
81+
82+
### System Tray
83+
- **Status**: Disabled during migration
84+
- **Reason**: Tauri v2 moved system tray to a plugin-based system
85+
- **Files affected**: `src-tauri/src/main.rs`, `src-tauri/tauri.conf.json`
86+
- **TODO**: Install and configure `tauri-plugin-tray` and reimplement tray functionality
87+
88+
## New Capabilities System
89+
90+
Tauri v2 introduces a new permissions/capabilities system. Migration created:
91+
- `src-tauri/capabilities/migrated.json` - Migrated v1 permissions
92+
- `src-tauri/capabilities/desktop.json` - Desktop-specific capabilities
93+
94+
## Build Status
95+
96+
**All builds successful:**
97+
- Frontend build: `pnpm run build`
98+
- Rust check: `cargo check`
99+
- Rust release build: `cargo build --release`
100+
101+
## Known Warnings
102+
103+
Minor warnings remain but don't affect functionality:
104+
- Unused variables in Rust code
105+
- Browserslist outdated warning (cosmetic)
106+
107+
## Future Work
108+
109+
1. **Reimplement Menu System**
110+
- Use `tauri::menu` API
111+
- Refer to Tauri v2 menu documentation
112+
113+
2. **Reimplement System Tray**
114+
- Add `tauri-plugin-tray` dependency
115+
- Implement using plugin API
116+
117+
3. **Consider Additional Optimizations**
118+
- Code splitting for frontend bundle size
119+
- Update browserslist database
120+
121+
## Testing Recommendations
122+
123+
Before deploying to production:
124+
1. Test all Tauri commands (greet, db operations, blockchain commands)
125+
2. Test shell execution features
126+
3. Test file system operations
127+
4. Test HTTP fetch functionality
128+
5. Test event system if reimplemented
129+
6. Test on all target platforms (Windows, macOS, Linux)
130+
131+
## References
132+
133+
- [Tauri v2 Migration Guide](https://v2.tauri.app/start/migrate/)
134+
- [Tauri v2 API Documentation](https://v2.tauri.app/reference/)
135+
- [Vite v5 Migration Guide](https://vitejs.dev/guide/migration.html)

package.json

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,16 @@
1515
"@ant-design/icons": "^5.2.6",
1616
"@emotion/react": "^11.11.1",
1717
"@monaco-editor/react": "^4.6.0",
18-
"@tauri-apps/api": "^1.6.0",
18+
"@tauri-apps/api": "^2.8.0",
19+
"@tauri-apps/plugin-clipboard-manager": "~2.3.0",
20+
"@tauri-apps/plugin-dialog": "~2.4.0",
21+
"@tauri-apps/plugin-fs": "~2.4.2",
22+
"@tauri-apps/plugin-global-shortcut": "~2.3.0",
23+
"@tauri-apps/plugin-http": "~2.5.2",
24+
"@tauri-apps/plugin-notification": "~2.3.1",
25+
"@tauri-apps/plugin-os": "~2.3.1",
26+
"@tauri-apps/plugin-process": "~2.3.0",
27+
"@tauri-apps/plugin-shell": "~2.3.1",
1928
"antd": "^5.9.0",
2029
"cheerio": "1.0.0-rc.12",
2130
"localforage": "^1.10.0",
@@ -31,15 +40,15 @@
3140
},
3241
"devDependencies": {
3342
"@tailwindcss/typography": "^0.5.9",
34-
"@tauri-apps/cli": "^1.6.1",
43+
"@tauri-apps/cli": "^2.8.4",
3544
"@types/lodash": "^4.14.201",
3645
"@types/node": "^20.3.3",
3746
"@types/react": "^18.2.15",
3847
"@types/react-dom": "^18.2.7",
3948
"@typescript-eslint/eslint-plugin": "^5.59.0",
4049
"@typescript-eslint/parser": "^5.59.0",
41-
"@vitejs/plugin-react": "^4.0.3",
42-
"@vitejs/plugin-react-swc": "^3.0.0",
50+
"@vitejs/plugin-react": "^4.7.0",
51+
"@vitejs/plugin-react-swc": "^3.11.0",
4352
"autoprefixer": "^10.4.14",
4453
"eslint": "^8.38.0",
4554
"eslint-plugin-react-hooks": "^4.6.0",
@@ -49,6 +58,6 @@
4958
"prettier-plugin-tailwindcss": "^0.3.0",
5059
"tailwindcss": "^3.3.2",
5160
"typescript": "^5.0.2",
52-
"vite": "^4.4.4"
61+
"vite": "^5.4.20"
5362
}
5463
}

0 commit comments

Comments
 (0)