|
| 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) |
0 commit comments