Skip to content

Commit 24a5749

Browse files
lucasfernogLaegelnothingismagick
authored
tauri beta documentation (tauri-apps#202)
* feat(guides): update splashscreen `waiting for webpage` guide * refactor: `get_window` accepts &str * `with_window` is no longer needed * add command state guide * `"resizable": false` on splashscreen config * fix: splashscreen code * fix splashscreen docs * update linux deps * update window.emit * update drag region attribute * links * plugin interface updates * add system tray config * add async command alert * update migration guide * update contributor guide * update roadmap * fix config formatting * menu guide * add system tray guide * update usage intro * fix: Wrong quotes * Apply suggestions from code review * use default <P: Params> * fix command alert Co-authored-by: Laegel <[email protected]> Co-authored-by: nothingismagick <[email protected]>
1 parent 4e727a3 commit 24a5749

File tree

17 files changed

+590
-144
lines changed

17 files changed

+590
-144
lines changed

docs/en/api/config.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,12 @@ It's composed of the following properties:
269269
]}/>
270270
</Array>
271271
},
272+
{
273+
property: "systemTray", type: "object",
274+
child: <Properties anchorRoot="tauri.systemTray" rows={[
275+
{ property: "iconPath", type: "string", description: `The path of the icon to use on the system tray. On macOS and Linux, the ".png" extension is enforced; on Windows, a ".ico" file with the same name must exist.` }
276+
]}/>
277+
},
272278
{
273279
property: "security", type: "object",
274280
child: <Properties anchorRoot="tauri.security" rows={[

docs/en/getting-started/setup-linux.md

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ import TabItem from '@theme/TabItem';
1212

1313
## 1. System Dependencies&nbsp;<Icon title="alert" color="danger"/>
1414

15+
- `wget` and `squashfs-tools` are used on AppImage bundling.
16+
- `libssl-dev` is used on the HTTP API.
17+
- GTK is used by `tao`[https://github.com/tauri-apps/tao] to create windows.
18+
- `webkit2gtk-4.0` is the webview provider used by [wry](https://github.com/tauri-apps/wry).
19+
- `libgtksourceview-3.0-dev` is needed when creating window menus or system tray menus.
20+
- `libappindicator3-dev` is needed for system tray.
21+
1522
<Tabs
1623
defaultValue="debian"
1724
values={[
@@ -26,36 +33,42 @@ $ sudo apt update && sudo apt install libwebkit2gtk-4.0-dev \
2633
build-essential \
2734
curl \
2835
wget \
36+
squashfs-tools \
2937
libssl-dev \
30-
appmenu-gtk3-module \
3138
libgtk-3-dev \
32-
squashfs-tools
39+
webkit2gtk-4.0 \
40+
libgtksourceview-3.0-dev \
41+
libappindicator3-dev
3342
```
3443

3544
</TabItem>
3645
<TabItem value="arch">
3746

3847
```sh
39-
$ sudo pacman -Syy && sudo pacman -S webkit2gtk \
40-
base-devel \
48+
$ sudo pacman -S base-devel \
4149
curl \
4250
wget \
51+
squashfs-tools \
4352
openssl \
44-
appmenu-gtk-module \
4553
gtk3 \
46-
squashfs-tools
54+
webkit2gtk \
55+
gtksourceview3 \
56+
libappindicator-gtk3 \
4757
```
4858

4959
</TabItem>
5060
<TabItem value="fedora">
5161

5262
```sh
53-
$ sudo dnf check-update && sudo dnf install webkit2gtk3-devel.x86_64 \
54-
openssl-devel \
55-
curl \
56-
wget \
57-
squashfs-tools \
58-
&& sudo dnf group install "C Development Tools and Libraries"
63+
$ sudo dnf group install "C Development Tools and Libraries" && \
64+
sudo dnf check-update && sudo dnf install curl \
65+
wget \
66+
squashfs-tools \
67+
openssl-devel \
68+
gtk3 \
69+
webkit2gtk3-devel.x86_64 \
70+
gtksourceview-3.0 \
71+
libappindicator-devel
5972
```
6073

6174
</TabItem>

docs/en/usage/contributor-guide.md

Lines changed: 76 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2,51 +2,94 @@
22
title: Contributor Guide
33
---
44

5-
todo: make this friendlier and more complete
5+
Hi! We, the maintainers, are really excited that you are interested in contributing to Tauri. Before submitting your contribution though, please make sure to take a moment and read through the [Code of Conduct](https://github.com/tauri-apps/tauri/blob/dev/.github/CODE_OF_CONDUCT.md), as well as the appropriate section for the contribution you intend to make:
66

7-
Tauri is a polyglot system that uses:
7+
- [Issue Reporting Guidelines](#issue-reporting-guidelines)
8+
- [Pull Request Guidelines](#pull-request-guidelines)
9+
- [Development Guide](#development-guide)
810

9-
- git
10-
- Node.js
11-
- Rust
12-
- GitHub actions
11+
## Issue Reporting Guidelines
1312

14-
It can be developed on macOS, Linux and Windows.
13+
- The issue list of this repo is **exclusively** for bug reports and feature requests. Non-conforming issues will be closed immediately.
1514

16-
## Contribution Flow
15+
- If you have a question, you can get quick answers from the [Tauri Discord chat](https://discord.gg/SpmNs4S).
1716

18-
1. File an Issue
19-
2. Fork the Repository
20-
3. Make Your Changes
21-
4. Make a PR
17+
- Try to search for your issue, it may have already been answered or even fixed in the development branch (`dev`).
2218

23-
### A Note About Contributions to the Rust Libraries
19+
- Check if the issue is reproducible with the latest stable version of Tauri. If you are using a pre-release, please indicate the specific version you are using.
2420

25-
When contributing to the Rust libraries `tauri`, `tauri-api`, and `tauri-updater`; you will want to setup an environment for RLS (the Rust Language Server). In the Tauri root directory, there is a `.scripts` folder that contains a set of scripts to automate adding a couple temporary environment variables to your shell/terminal. These environment variables point to directories in the test fixture which will prevent RLS from crashing on compile-time. This is a necessary step for setting up a development environment for Tauri's Rust libraries.
21+
- It is **required** that you clearly describe the steps necessary to reproduce the issue you are running into. Although we would love to help our users as much as possible, diagnosing issues without clear reproduction steps is extremely time-consuming and simply not sustainable.
2622

27-
##### _Example Instructions_
23+
- Use only the minimum amount of code necessary to reproduce the unexpected behavior. A good bug report should isolate specific methods that exhibit unexpected behavior and precisely define how expectations were violated. What did you expect the method or methods to do, and how did the observed behavior differ? The more precisely you isolate the issue, the faster we can investigate.
2824

29-
1. Navigate to the Tauri Root directory.
30-
2. Execute a script based on your Operating System from this folder: `.scripts/init_env.bat` for Windows Cmd, `.scripts/init_env.ps1` for Windows Powershell, `. .scripts/init_env.sh` for Linux/macOS bash (note the first `.` in this command).
31-
3. Open your text editor/IDE from this shell/terminal.
25+
- Issues with no clear repro steps will not be triaged. If an issue labeled "need repro" receives no further input from the issue author for more than 5 days, it will be closed.
3226

33-
## Hands On Example
27+
- If your issue is resolved but still open, don’t hesitate to close it. In case you found a solution by yourself, it could be helpful to explain how you fixed it.
3428

35-
Let's make a new example. That's a great way to learn. We are going to assume you are on a nixy type of environment like Linux or macOS and have all of your development dependencies like rust and node already sorted out.
29+
- Most importantly, we beg your patience: the team must balance your request against many other responsibilities — fixing other bugs, answering other questions, new features, new documentation, etc. The issue list is not paid support and we cannot make guarantees about how fast your issue can be resolved.
3630

37-
```sh
38-
git clone [email protected]:tauri-apps/tauri.git
39-
cd tauri/cli/tauri.js
40-
yarn
41-
mkdir ../../examples/vanillajs && cd "$_"
42-
```
31+
## Pull Request Guidelines
4332

44-
```json
45-
"tauri:source": "node ../../../cli/tauri.js/bin/tauri",
46-
```
33+
- It's OK to have multiple small commits as you work on the PR - we will let GitHub automatically squash it before merging.
34+
35+
- If adding new feature:
36+
37+
- Provide a convincing reason to add this feature. Ideally you should open a suggestion issue first and have it greenlighted before working on it.
38+
39+
- If fixing a bug:
40+
- If you are resolving a special issue, add `(fix: #xxxx[,#xxx])` (#xxxx is the issue id) in your PR title for a better release log, e.g. `fix: update entities encoding/decoding (fix #3899)`.
41+
- Provide a detailed description of the bug in the PR, or link to an issue that does.
42+
43+
## Development Guide
44+
45+
**NOTE: Tauri is undergoing rapid development right now, and the docs match the latest published version of Tauri. This contributor guide is up-to-date, but it doesn't cover all of Tauri's functions in depth. If you have any questions, don't hesitate to ask in our Discord server.**
46+
47+
### General Setup
48+
49+
First, [join our Discord server](https://discord.gg/SpmNs4S) and let us know that you want to contribute. This way we can point you in the right direction and help ensure your contribution will be as helpful as possible.
50+
51+
To set up your machine for development, follow the [Tauri setup guide](https://tauri.studio/en/docs/getting-started/intro#setting-up-your-environment) to get all the tools you need to develop Tauri apps. The only additional tool you may need is [Yarn](https://yarnpkg.com/), it is only required if you are developing the Node CLI/API (`tooling/cli.js` and `api`). Next, fork and clone this repo. It is structured as a monorepo, which means that all the various Tauri packages are under the same repository. The development process varies depending on what part of Tauri you are contributing to, see the guides below for per-package instructions.
52+
53+
Some Tauri packages will be automatically built when running one of the examples. Others, however, will need to be built beforehand. To build these automatically, run the `.scripts/setup.sh` (Linux and macOS) or `.scripts/setup.ps1` (Windows) script. This will install the Rust and Node.js CLI and build the JS API. After that, you should be able to run all the examples.
54+
55+
### Packages Overview
56+
57+
- The JS API (`/tooling/api`) contains JS bindings to the builtin Rust functions in the Rust API.
58+
- The Rust CLI (`/tooling/cli.rs`) is the primary CLI for creating and developing Tauri apps.
59+
- cli.js (`/tooling/cli.js`) is a Node.js CLI wrapper for `cli.rs`.
60+
- Tauri Bundler (`/tooling/bundler`) is used by the Rust CLI to package executables into installers.
61+
- Tauri Core (`/core/tauri`) is the heart of Tauri. It contains the code that starts the app, configures communication between Rust and the Webview, and ties all the other packages together.
62+
- The Macros (`/core/tauri-macros`) are used by Tauri Core for various functions.
4763

48-
```ini
49-
[dependencies.tauri]
50-
path = "../../../../core/tauri"
51-
features = [ "all-api" ]
64+
### Developing The Node.js CLI (cli.js)
65+
66+
`cli.js` is a CLI tool that houses the `icon`, and `deps` command. The code for cli.js is located in `[Tauri repo root]/tooling/cli.js`. There are a few package scripts you should be aware of:
67+
68+
- `build` builds the CLI
69+
- `test` runs the unit and e2e test suite
70+
- `lint` runs ESLint to catch linting errors
71+
- `format` formats code with Prettier to match the style guide
72+
73+
To test your changes, we recommend using the helloworld example app, located in `[Tauri repo root]/examples/helloworld`. Run `yarn tauri [COMMAND]` to run a command using your local cli.js copy. You will need to rebuild cli.js after every change by running `yarn build` in the cli.js directory.
74+
75+
If you want to use your local copy of cli.js in another app, we recommend using [yarn link](https://classic.yarnpkg.com/en/docs/cli/link/). First, make sure you have don't have cli.js installed globally by running `npm uninstall -g tauri && yarn global remove tauri`. Then, run `yarn link` in the cli.js directory (note that the setup script will do this for you, so you can skip this step if you ran that). Now, you can just run `tauri [COMMAND]` anywhere, and your local copy will be used.
76+
77+
### Developing Tauri Bundler and Rust CLI
78+
79+
The code for the bundler is located in `[Tauri repo root]/tooling/bundler`, and the code for the Rust CLI is located in `[Tauri repo root]/tooling/cli.rs`. If you are using your local copy of cli.js (see above), any changes you make to the bundler and CLI will be automatically built and applied when running the build or dev command. Otherwise, running `cargo install --path .` in the Rust CLI directory will allow you to run `cargo tauri build` and `cargo tauri dev` anywhere, using the updated copy of the bundler and cli. You will have to run this command each time you make a change in either package.
80+
81+
### Developing Tauri Core and Related Components (Rust API, Macros, Codegen, and Utils)
82+
83+
The code for Tauri Core is located in `[Tauri repo root]/core/tauri`, and the Rust API, Macros, and Utils are in `[Tauri repo root]/core/tauri-(api/macros/utils)`. The easiest way to test your changes is to use the `[Tauri repo root]/examples/helloworld` app. It automatically rebuilds and uses your local copy of the Tauri core packages. Just run `yarn tauri build` or `yarn tauri dev` in the helloworld app directory after making changes to test them out. To use your local changes in another project, edit its `src-tauri/Cargo.toml` file so that the `tauri` key looks like `tauri = { path = "PATH", features = [ "api-all", "cli" ] }`, where `PATH` is the relative path to `[Tauri repo root]/core/tauri`. Then, your local copy of the Tauri core packages will be rebuilt and used whenever you build that project.
84+
85+
#### Building the documentation locally
86+
87+
You can build the Rust documentation locally running the following script:
88+
89+
```bash
90+
$ RUSTDOCFLAGS="--cfg doc_cfg" cargo +nightly doc --all-features --open
5291
```
92+
93+
### Developing the JS API
94+
95+
The JS API provides bindings between the developer's JS in the Webview and the builtin Tauri APIs, written in Rust. Its code is located in `[Tauri repo root]/tooling/api`. After making changes to the code, run `yarn build` to build it. To test your changes, we recommend using the API example app, located in `[Tauri repo root]/examples/api`. It will automatically use your local copy of the JS API and provides a helpful UI to test the various commands.

docs/en/usage/guides/command.md

Lines changed: 43 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
title: Create Rust Commands
33
---
44

5+
import Alert from '@theme/Alert'
6+
57
Tauri provides a simple yet powerful "command" system for calling Rust functions from your web app. Commands can accept arguments and return values. They can also return errors and be `async`.
68

79
## Basic Example
@@ -102,6 +104,11 @@ invoke('my_custom_command')
102104

103105
## Async Commands
104106

107+
<Alert title="Note">
108+
Async commands are executed on a separate thread using the <a href="https://tauri.studio/en/docs/api/rust/tauri/async_runtime/fn.spawn">async runtime</a>.
109+
Commands without the <i>async</i> keyword are executed on the main thread, unless defined with <i>#[tauri::command(async)]</i>.
110+
</Alert>
111+
105112
If your command needs to run asynchronously, simply declare it as `async`:
106113

107114
```rust
@@ -121,32 +128,61 @@ invoke('my_custom_command').then(() => console.log('Completed!'))
121128

122129
## Accessing the Window in Commands
123130

124-
If your command needs access to the Window (TODO: add link), add `with_window` to the `command` annotation:
131+
Commands can access the `Window` instance that invoked the message:
125132

126133
```rust
127-
#[tauri::command(with_window)]
128-
async fn my_custom_command<M: tauri::Params>(window: tauri::Window<M>) {
134+
#[tauri::command]
135+
async fn my_custom_command(window: tauri::Window) {
129136
println!("Window: {}", window.label());
130137
}
131138
```
132139

140+
## Accessing managed state
141+
142+
Tauri can manage state using the `manage` function on `tauri::Builder`.
143+
The state can be accessed on a command using `tauri::State`:
144+
145+
```rust
146+
struct MyState(String);
147+
148+
#[tauri::command]
149+
fn my_custom_command(state: tauri::State<'_, MyState>) {
150+
assert_eq!(state.0 == "some state value", true);
151+
}
152+
153+
fn main() {
154+
tauri::Builder::default()
155+
.manage(MyState("some state value".into()))
156+
.invoke_handler(tauri::generate_handler![my_custom_command])
157+
.run(tauri::generate_context!())
158+
.expect("error while running tauri application");
159+
}
160+
```
161+
133162
## Complete Example
134163

135164
Any or all of the above features can be combined:
136165

137166
```rust title=main.rs
138167
// Definition in main.rs
139168

169+
struct Database;
170+
140171
#[derive(serde::Serialize)]
141172
struct CustomResponse {
142173
message: String,
143174
other_val: usize,
144175
}
145176

146-
#[tauri::command(with_window)]
147-
async fn my_custom_command<M: tauri::Params>(
148-
window: tauri::Window<M>,
177+
async fn some_other_function() -> Option<String> {
178+
Some("response".into())
179+
}
180+
181+
#[tauri::command]
182+
async fn my_custom_command(
183+
window: tauri::Window,
149184
number: usize,
185+
database: tauri::State<'_, Database>,
150186
) -> Result<CustomResponse, String> {
151187
println!("Called from {}", window.label());
152188
let result: Option<String> = some_other_function().await;
@@ -162,6 +198,7 @@ async fn my_custom_command<M: tauri::Params>(
162198

163199
fn main() {
164200
tauri::Builder::default()
201+
.manage(Database {})
165202
.invoke_handler(tauri::generate_handler![my_custom_command])
166203
.run(tauri::generate_context!())
167204
.expect("error while running tauri application");
@@ -172,7 +209,6 @@ fn main() {
172209
// Invocation from JS
173210

174211
invoke('my_custom_command', {
175-
message: 'Hi',
176212
number: 42,
177213
})
178214
.then((res) =>

docs/en/usage/guides/migration.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ For example:
1010

1111
```diff
1212
- "tauri": "^0.14.1"
13-
+ "@tauri-apps/cli": "^1.0.0-beta-rc.4"
13+
+ "@tauri-apps/cli": "^1.0.0-beta.0"
1414
```
1515

1616
Next update your `Cargo.toml`:
@@ -19,13 +19,13 @@ Next update your `Cargo.toml`:
1919

2020
```diff
2121
+ [build-dependencies]
22-
+ tauri-build = { version = "1.0.0-beta-rc.0" }
22+
+ tauri-build = { version = "1.0.0-beta.0" }
2323

2424
- [target."cfg(windows)".build-dependencies]
2525
- winres = "0.1"
2626
```
2727

28-
- update the version of `tauri` to e.g. `1.0.0-beta-rc.4`
28+
- update the version of `tauri` to e.g. `1.0.0-beta.0`
2929
- remove all old features of the `tauri` dependency
3030
- remove all features, that tauri added and add `custom-protocol` as a new one:
3131

@@ -86,7 +86,7 @@ Update your `tauri.conf.json` like this:
8686
- "window": {
8787
+ "windows": [
8888
{
89-
"title": "Calciumdibromid",
89+
"title": "Tauri App",
9090
"width": 800,
9191
"height": 600,
9292
"resizable": true,

0 commit comments

Comments
 (0)