tauri2-guide/base.md
Z User 01fb4e9405 add base.md — LLM index with raw Gitea links for agents
Contains clickable URLs to every guide/doc file so agents can fetch
individual files via HTTP without cloning the repo.
2026-05-30 21:07:06 +00:00

173 lines
7.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Tauri 2.0 Reference Library — LLM Index
This file is a navigation index for LLMs and AI agents. Each document listed below is hosted as a raw Markdown file on Gitea. Fetch individual files via their URLs instead of cloning the entire repository.
**Base URL pattern**: `https://git.client.guacamolebox.net/butterfly/tauri2-vin-ws-temp/raw/branch/main/`
**Official Tauri 2.0 Docs**: https://v2.tauri.app
**Rust API Docs**: https://docs.rs/tauri/latest/tauri/
---
## Constraints for Agents
- You **cannot compile or run code** in a sandbox. Verify correctness using logic, API pattern matching, and cross-referencing these documents.
- All code in this repository is **Tauri 2.0 only** — do NOT use v1 patterns (see migration section for full v1-to-v2 diff).
- Every plugin requires 4 things: (1) Rust crate in `Cargo.toml`, (2) `.plugin()` registration in the Builder, (3) npm package, (4) permissions in capabilities.
---
## Definitive Developer Guide
### Part 1: Core Architecture, Config, Commands, IPC (Sections 17)
https://git.client.guacamolebox.net/butterfly/tauri2-vin-ws-temp/raw/branch/main/tauri2-guide/01-core-architecture-config-commands-ipc.md
| Topic | Section |
|-------|----------|
| Architecture overview, project structure, scaffolding | 12 |
| Configuration (`tauri.conf.json` v2 schema) | 3 |
| Capabilities & permissions (ACL security model) | 4 |
| Rust backend: `lib.rs`, commands, Builder pattern | 5 |
| Frontend integration (JS imports, invoke, plugins) | 6 |
| IPC: commands, events, channels, streaming | 7 |
### Part 2: Windows, Plugins, WebSocket, State, Migration (Sections 815)
https://git.client.guacamolebox.net/butterfly/tauri2-vin-ws-temp/raw/branch/main/tauri2-guide/02-windows-plugins-websocket-state-migration.md
| Topic | Section |
|-------|----------|
| Window management (multi-window, external URLs) | 8 |
| Plugin ecosystem (all 33+ official plugins) | 9 |
| Native WebSocket server (Tokio + broadcast) | 10 |
| Script injection into webview windows | 11 |
| State management (Mutex, managed state) | 12 |
| v1 to v2 migration (full API diff) | 13 |
| Anti-patterns to avoid | 14 |
| Quick reference cheat sheet | 15 |
---
## Agent Prompts
### Part 1: System Prompt + Common Prompts (Sections 17)
https://git.client.guacamolebox.net/butterfly/tauri2-vin-ws-temp/raw/branch/main/tauri2-guide/01-system-prompt-and-common-prompts.md
| Topic | Section |
|-------|----------|
| Universal system prompt (REQUIRED prefix) | 1 |
| Scaffold a new Tauri 2.0 project | 2 |
| Add a Tauri plugin | 3 |
| Create a custom command (IPC) | 4 |
| Add state management | 5 |
| Implement event-based communication | 6 |
| Create multi-window app | 7 |
### Part 2: Advanced Prompts, Checklist, Migration (Sections 815)
https://git.client.guacamolebox.net/butterfly/tauri2-vin-ws-temp/raw/branch/main/tauri2-guide/02-advanced-prompts-checklist-migration.md
| Topic | Section |
|-------|----------|
| Build a WebSocket server in Rust | 8 |
| Implement script injection | 9 |
| Set up capabilities & permissions | 10 |
| Migrate a v1 app to v2 | 11 |
| Full app build (end-to-end) | 12 |
| Verification checklist for agents | 13 |
| v1 vs v2 API map | 14 |
| Debug a Tauri 2.0 build/compile error | 15 |
---
## Error Resolution Guide
### Part 1: Build, Config, Permission, Plugin Errors (Categories AH)
https://git.client.guacamolebox.net/butterfly/tauri2-vin-ws-temp/raw/branch/main/tauri2-guide/01-build-config-permission-plugin-errors.md
| Topic | Category |
|-------|----------|
| Rust compilation errors (Cargo build failures) | A |
| v1-to-v2 migration compile errors | B |
| Async/thread safety errors (Mutex, Send, lifetime) | C |
| Config errors (`tauri.conf.json` validation) | D |
| Permission/capability errors ("not allowed") | E |
| Plugin integration errors | F |
| IPC / command runtime errors | G |
| Webview & window runtime errors | H |
### Part 2: Runtime, Platform, Mobile Errors (Categories IR)
https://git.client.guacamolebox.net/butterfly/tauri2-vin-ws-temp/raw/branch/main/tauri2-guide/02-runtime-platform-mobile-errors.md
| Topic | Category |
|-------|----------|
| Event system errors | I |
| Content Security Policy (CSP) errors | J |
| Frontend integration errors (Vite, Next.js, SvelteKit) | K |
| WebSocket errors | L |
| Path & asset protocol errors | M |
| Shell & sidecar errors | N |
| Mobile build errors (iOS & Android) | O |
| Platform-specific build errors | P |
| Panics & runtime crashes | Q |
| Error handling best practices | R |
| Top 25 most common errors (quick lookup) | Quick-Reference |
---
## Supplementary References
### Quick-Reference Cheat Sheet
https://git.client.guacamolebox.net/butterfly/tauri2-vin-ws-temp/raw/branch/main/tauri2-docs/cheatsheet.md
Commands, config, IPC, and WebSocket patterns in condensed form.
### WebSocket Server + Client + Injection Deep-Dive
https://git.client.guacamolebox.net/butterfly/tauri2-vin-ws-temp/raw/branch/main/tauri2-docs/ws_server_client_inject_guide.md
Comprehensive guide for native WebSocket server implementation, client-side JS integration, and script injection patterns.
### Official Docs Links
https://git.client.guacamolebox.net/butterfly/tauri2-vin-ws-temp/raw/branch/main/tauri2-docs/tauri2-links.md
Curated links to official Tauri 2.0 documentation for migration, security, configuration, and more.
---
## Quick Reference — v1 vs v2
| Area | v1 (WRONG in v2) | v2 (Correct) |
|------|-------------------|---------------|
| Window type | `tauri::Window` | `tauri::WebviewWindow` |
| Window builder | `tauri::WindowBuilder` | `tauri::WebviewWindowBuilder` |
| Window URL | `tauri::WindowUrl` | `tauri::WebviewUrl` |
| Get window | `get_window("main")` | `get_webview_window("main")` |
| JS invoke import | `@tauri-apps/api/tauri` | `@tauri-apps/api/core` |
| JS window import | `@tauri-apps/api/window` | `@tauri-apps/api/webviewWindow` |
| Plugin JS imports | `@tauri-apps/api/<name>` | `@tauri-apps/plugin-<name>` |
| Config app section | `tauri` key | `app` key |
| Config dist dir | `build.distDir` | `build.frontendDist` |
| Security model | `allowlist` in config | Capabilities + Permissions (ACL) |
| Core logic file | `main.rs` only | `lib.rs` + `main.rs` pattern |
| Event emit | `window.emit()` | `app.emit()` (global) / `app.emit_to()` (targeted) |
| Rust APIs | `tauri::api::*` modules | Everything moved to plugins |
---
## Search Keywords for LLMs
- **Error messages**: Search exact error string (e.g., `"unresolved import tauri::api"`, `"not allowed"`) in Error Resolution Guide parts
- **API names**: Search type names (e.g., `WebviewWindowBuilder`, `Emitter`, `Channel`) in Definitive Guide parts
- **Config keys**: Search JSON key names (e.g., `frontendDist`, `withGlobalTauri`, `capabilities`) in Part 1 of Definitive Guide
- **Plugin names**: Search identifiers (e.g., `tauri-plugin-fs`, `fs:default`) in Part 2 of Definitive Guide
- **Migration**: Search old v1 names (e.g., `WindowBuilder`, `allowlist`) to find v2 replacements
- **Patterns**: Search keywords (e.g., `initialization_script`, `run_on_main_thread`, `broadcast channel`) in WebSocket guide
- **Permissions**: Search permission strings (e.g., `core:event:allow-listen`, `fs:allow-read`) in Part 1 Definitive Guide Section 4 and Error Resolution Part 1 Category E