parent
b4c503c116
commit
80fbcb50d3
@ -1,57 +1,57 @@
|
|||||||
name: Check MSRV
|
name: Check MSRV
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- v1
|
- v1
|
||||||
- v2
|
- v2
|
||||||
paths:
|
paths:
|
||||||
- ".github/workflows/msrv-check.yml"
|
- ".github/workflows/msrv-check.yml"
|
||||||
- "plugins/*/src/**"
|
- "plugins/*/src/**"
|
||||||
- "**/Cargo.toml"
|
- "**/Cargo.toml"
|
||||||
- "**/Cargo.lock"
|
- "**/Cargo.lock"
|
||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
branches:
|
||||||
- v1
|
- v1
|
||||||
- v2
|
- v2
|
||||||
paths:
|
paths:
|
||||||
- ".github/workflows/msrv-check.yml"
|
- ".github/workflows/msrv-check.yml"
|
||||||
- "plugins/*/src/**"
|
- "plugins/*/src/**"
|
||||||
- "**/Cargo.toml"
|
- "**/Cargo.toml"
|
||||||
- "**/Cargo.lock"
|
- "**/Cargo.lock"
|
||||||
|
|
||||||
concurrency:
|
concurrency:
|
||||||
group: ${{ github.workflow }}-${{ github.ref }}
|
group: ${{ github.workflow }}-${{ github.ref }}
|
||||||
cancel-in-progress: true
|
cancel-in-progress: true
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
msrv:
|
msrv:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: install webkit2gtk
|
- name: install webkit2gtk
|
||||||
run: |
|
run: |
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install -y libwebkit2gtk-4.0-dev libwebkit2gtk-4.1-dev
|
sudo apt-get install -y libwebkit2gtk-4.0-dev libwebkit2gtk-4.1-dev
|
||||||
|
|
||||||
- uses: dtolnay/rust-toolchain@1.67.0
|
- uses: dtolnay/rust-toolchain@1.67.0
|
||||||
|
|
||||||
- uses: Swatinem/rust-cache@v2
|
- uses: Swatinem/rust-cache@v2
|
||||||
|
|
||||||
- name: build
|
- name: build
|
||||||
run: cargo build --workspace --exclude 'tauri-plugin-sql' --all-targets --all-features
|
run: cargo build --workspace --exclude 'tauri-plugin-sql' --all-targets --all-features
|
||||||
|
|
||||||
- uses: dtolnay/rust-toolchain@1.80.1
|
- uses: dtolnay/rust-toolchain@1.80.1
|
||||||
|
|
||||||
- name: build sql:sqlite
|
- name: build sql:sqlite
|
||||||
run: cargo build --package 'tauri-plugin-sql' --all-targets --features sqlite
|
run: cargo build --package 'tauri-plugin-sql' --all-targets --features sqlite
|
||||||
|
|
||||||
- name: build sql:mysql
|
- name: build sql:mysql
|
||||||
run: cargo build --package 'tauri-plugin-sql' --all-targets --features mysql
|
run: cargo build --package 'tauri-plugin-sql' --all-targets --features mysql
|
||||||
|
|
||||||
- name: build sql:postgres
|
- name: build sql:postgres
|
||||||
run: cargo build --package 'tauri-plugin-sql' --all-targets --features postgres
|
run: cargo build --package 'tauri-plugin-sql' --all-targets --features postgres
|
||||||
|
@ -1,36 +1,36 @@
|
|||||||
## Plugins Found Here
|
## Plugins Found Here
|
||||||
|
|
||||||
| | | Win | Mac | Lin | iOS | And |
|
| | | Win | Mac | Lin | iOS | And |
|
||||||
| ------------------------------------------ | --------------------------------------------------------- | --- | --- | --- | --- | --- |
|
| ------------------------------------------ | --------------------------------------------------------- | --- | --- | --- | --- | --- |
|
||||||
| [autostart](plugins/autostart) | Automatically launch your app at system startup. | ✅ | ✅ | ✅ | ? | ? |
|
| [autostart](plugins/autostart) | Automatically launch your app at system startup. | ✅ | ✅ | ✅ | ? | ? |
|
||||||
| [fs-extra](plugins/fs-extra) | File system methods that aren't included in the core API. | ✅ | ✅ | ✅ | ? | ? |
|
| [fs-extra](plugins/fs-extra) | File system methods that aren't included in the core API. | ✅ | ✅ | ✅ | ? | ? |
|
||||||
| [fs-watch](plugins/fs-watch) | Watch the filesystem for changes. | ✅ | ✅ | ✅ | ? | ? |
|
| [fs-watch](plugins/fs-watch) | Watch the filesystem for changes. | ✅ | ✅ | ✅ | ? | ? |
|
||||||
| [localhost](plugins/localhost) | Use a localhost server in production apps. | ✅ | ✅ | ✅ | ? | ? |
|
| [localhost](plugins/localhost) | Use a localhost server in production apps. | ✅ | ✅ | ✅ | ? | ? |
|
||||||
| [log](plugins/log) | Configurable logging. | ✅ | ✅ | ✅ | ✅ | ✅ |
|
| [log](plugins/log) | Configurable logging. | ✅ | ✅ | ✅ | ✅ | ✅ |
|
||||||
| [persisted-scope](plugins/persisted-scope) | Persist runtime scope changes on the filesystem. | ✅ | ✅ | ✅ | ? | ? |
|
| [persisted-scope](plugins/persisted-scope) | Persist runtime scope changes on the filesystem. | ✅ | ✅ | ✅ | ? | ? |
|
||||||
| [positioner](plugins/positioner) | Move windows to common locations. | ✅ | ✅ | ✅ | ? | ? |
|
| [positioner](plugins/positioner) | Move windows to common locations. | ✅ | ✅ | ✅ | ? | ? |
|
||||||
| [single-instance](plugins/single-instance) | Ensure a single instance of your tauri app is running. | ✅ | ? | ✅ | ? | ? |
|
| [single-instance](plugins/single-instance) | Ensure a single instance of your tauri app is running. | ✅ | ? | ✅ | ? | ? |
|
||||||
| [sql](plugins/sql) | Interface with SQL databases. | ✅ | ✅ | ✅ | ? | ? |
|
| [sql](plugins/sql) | Interface with SQL databases. | ✅ | ✅ | ✅ | ? | ? |
|
||||||
| [store](plugins/store) | Persistent key value storage. | ✅ | ✅ | ✅ | ? | ? |
|
| [store](plugins/store) | Persistent key value storage. | ✅ | ✅ | ✅ | ? | ? |
|
||||||
| [stronghold](plugins/stronghold) | Encrypted, secure database. | ✅ | ✅ | ✅ | ? | ? |
|
| [stronghold](plugins/stronghold) | Encrypted, secure database. | ✅ | ✅ | ✅ | ? | ? |
|
||||||
| [upload](plugins/upload) | Tauri plugin for file uploads through HTTP. | ✅ | ✅ | ✅ | ? | ? |
|
| [upload](plugins/upload) | Tauri plugin for file uploads through HTTP. | ✅ | ✅ | ✅ | ? | ? |
|
||||||
| [websocket](plugins/websocket) | Open a WebSocket connection using a Rust client in JS. | ✅ | ✅ | ✅ | ? | ? |
|
| [websocket](plugins/websocket) | Open a WebSocket connection using a Rust client in JS. | ✅ | ✅ | ✅ | ? | ? |
|
||||||
| [window-state](plugins/window-state) | Persist window sizes and positions. | ✅ | ✅ | ✅ | ? | ? |
|
| [window-state](plugins/window-state) | Persist window sizes and positions. | ✅ | ✅ | ✅ | ? | ? |
|
||||||
|
|
||||||
_This repo and all plugins require a Rust version of at least **1.67**_
|
_This repo and all plugins require a Rust version of at least **1.67**_
|
||||||
|
|
||||||
## Partners
|
## Partners
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td align="center" valign="middle">
|
<td align="center" valign="middle">
|
||||||
<a href="https://crabnebula.dev" target="_blank">
|
<a href="https://crabnebula.dev" target="_blank">
|
||||||
<img src=".github/sponsors/crabnebula.svg" alt="CrabNebula" width="283">
|
<img src=".github/sponsors/crabnebula.svg" alt="CrabNebula" width="283">
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri).
|
For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri).
|
||||||
|
@ -1,89 +1,89 @@
|
|||||||

|

|
||||||
|
|
||||||
Automatically launch your application at startup. Supports Windows, Mac (via AppleScript or Launch Agent), and Linux.
|
Automatically launch your application at startup. Supports Windows, Mac (via AppleScript or Launch Agent), and Linux.
|
||||||
|
|
||||||
## Install
|
## Install
|
||||||
|
|
||||||
_This plugin requires a Rust version of at least **1.67**_
|
_This plugin requires a Rust version of at least **1.67**_
|
||||||
|
|
||||||
There are three general methods of installation that we can recommend.
|
There are three general methods of installation that we can recommend.
|
||||||
|
|
||||||
1. Use crates.io and npm (easiest, and requires you to trust that our publishing pipeline worked)
|
1. Use crates.io and npm (easiest, and requires you to trust that our publishing pipeline worked)
|
||||||
2. Pull sources directly from Github using git tags / revision hashes (most secure)
|
2. Pull sources directly from Github using git tags / revision hashes (most secure)
|
||||||
3. Git submodule install this repo in your tauri project and then use file protocol to ingest the source (most secure, but inconvenient to use)
|
3. Git submodule install this repo in your tauri project and then use file protocol to ingest the source (most secure, but inconvenient to use)
|
||||||
|
|
||||||
Install the Core plugin by adding the following to your `Cargo.toml` file:
|
Install the Core plugin by adding the following to your `Cargo.toml` file:
|
||||||
|
|
||||||
`src-tauri/Cargo.toml`
|
`src-tauri/Cargo.toml`
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
[dependencies]
|
[dependencies]
|
||||||
tauri-plugin-autostart = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" }
|
tauri-plugin-autostart = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" }
|
||||||
```
|
```
|
||||||
|
|
||||||
You can install the JavaScript Guest bindings using your preferred JavaScript package manager:
|
You can install the JavaScript Guest bindings using your preferred JavaScript package manager:
|
||||||
|
|
||||||
> Note: Since most JavaScript package managers are unable to install packages from git monorepos we provide read-only mirrors of each plugin. This makes installation option 2 more ergonomic to use.
|
> Note: Since most JavaScript package managers are unable to install packages from git monorepos we provide read-only mirrors of each plugin. This makes installation option 2 more ergonomic to use.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
pnpm add https://github.com/tauri-apps/tauri-plugin-autostart#v1
|
pnpm add https://github.com/tauri-apps/tauri-plugin-autostart#v1
|
||||||
# or
|
# or
|
||||||
npm add https://github.com/tauri-apps/tauri-plugin-autostart#v1
|
npm add https://github.com/tauri-apps/tauri-plugin-autostart#v1
|
||||||
# or
|
# or
|
||||||
yarn add https://github.com/tauri-apps/tauri-plugin-autostart#v1
|
yarn add https://github.com/tauri-apps/tauri-plugin-autostart#v1
|
||||||
```
|
```
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
First you need to register the core plugin with Tauri:
|
First you need to register the core plugin with Tauri:
|
||||||
|
|
||||||
`src-tauri/src/main.rs`
|
`src-tauri/src/main.rs`
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
use tauri_plugin_autostart::MacosLauncher;
|
use tauri_plugin_autostart::MacosLauncher;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
tauri::Builder::default()
|
tauri::Builder::default()
|
||||||
.plugin(tauri_plugin_autostart::init(MacosLauncher::LaunchAgent, Some(vec!["--flag1", "--flag2"]) /* arbitrary number of args to pass to your app */))
|
.plugin(tauri_plugin_autostart::init(MacosLauncher::LaunchAgent, Some(vec!["--flag1", "--flag2"]) /* arbitrary number of args to pass to your app */))
|
||||||
.run(tauri::generate_context!())
|
.run(tauri::generate_context!())
|
||||||
.expect("error while running tauri application");
|
.expect("error while running tauri application");
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Afterwards all the plugin's APIs are available through the JavaScript guest bindings:
|
Afterwards all the plugin's APIs are available through the JavaScript guest bindings:
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
import { enable, isEnabled, disable } from "tauri-plugin-autostart-api";
|
import { enable, isEnabled, disable } from "tauri-plugin-autostart-api";
|
||||||
|
|
||||||
await enable();
|
await enable();
|
||||||
|
|
||||||
console.log(`registered for autostart? ${await isEnabled()}`);
|
console.log(`registered for autostart? ${await isEnabled()}`);
|
||||||
|
|
||||||
disable();
|
disable();
|
||||||
```
|
```
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
PRs accepted. Please make sure to read the Contributing Guide before making a pull request.
|
PRs accepted. Please make sure to read the Contributing Guide before making a pull request.
|
||||||
|
|
||||||
## Partners
|
## Partners
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td align="center" valign="middle">
|
<td align="center" valign="middle">
|
||||||
<a href="https://crabnebula.dev" target="_blank">
|
<a href="https://crabnebula.dev" target="_blank">
|
||||||
<img src="https://github.com/tauri-apps/plugins-workspace/raw/v1/.github/sponsors/crabnebula.svg" alt="CrabNebula" width="283">
|
<img src="https://github.com/tauri-apps/plugins-workspace/raw/v1/.github/sponsors/crabnebula.svg" alt="CrabNebula" width="283">
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri).
|
For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri).
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
Code: (c) 2015 - Present - The Tauri Programme within The Commons Conservancy.
|
Code: (c) 2015 - Present - The Tauri Programme within The Commons Conservancy.
|
||||||
|
|
||||||
MIT or MIT/Apache 2.0 where applicable.
|
MIT or MIT/Apache 2.0 where applicable.
|
||||||
|
@ -1,83 +1,83 @@
|
|||||||

|

|
||||||
|
|
||||||
Additional file system methods not included in the core API.
|
Additional file system methods not included in the core API.
|
||||||
|
|
||||||
## Install
|
## Install
|
||||||
|
|
||||||
_This plugin requires a Rust version of at least **1.67**_
|
_This plugin requires a Rust version of at least **1.67**_
|
||||||
|
|
||||||
There are three general methods of installation that we can recommend.
|
There are three general methods of installation that we can recommend.
|
||||||
|
|
||||||
1. Use crates.io and npm (easiest, and requires you to trust that our publishing pipeline worked)
|
1. Use crates.io and npm (easiest, and requires you to trust that our publishing pipeline worked)
|
||||||
2. Pull sources directly from Github using git tags / revision hashes (most secure)
|
2. Pull sources directly from Github using git tags / revision hashes (most secure)
|
||||||
3. Git submodule install this repo in your tauri project and then use file protocol to ingest the source (most secure, but inconvenient to use)
|
3. Git submodule install this repo in your tauri project and then use file protocol to ingest the source (most secure, but inconvenient to use)
|
||||||
|
|
||||||
Install the Core plugin by adding the following to your `Cargo.toml` file:
|
Install the Core plugin by adding the following to your `Cargo.toml` file:
|
||||||
|
|
||||||
`src-tauri/Cargo.toml`
|
`src-tauri/Cargo.toml`
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
[dependencies]
|
[dependencies]
|
||||||
tauri-plugin-fs-extra = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" }
|
tauri-plugin-fs-extra = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" }
|
||||||
```
|
```
|
||||||
|
|
||||||
You can install the JavaScript Guest bindings using your preferred JavaScript package manager:
|
You can install the JavaScript Guest bindings using your preferred JavaScript package manager:
|
||||||
|
|
||||||
> Note: Since most JavaScript package managers are unable to install packages from git monorepos we provide read-only mirrors of each plugin. This makes installation option 2 more ergonomic to use.
|
> Note: Since most JavaScript package managers are unable to install packages from git monorepos we provide read-only mirrors of each plugin. This makes installation option 2 more ergonomic to use.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
pnpm add https://github.com/tauri-apps/tauri-plugin-fs-extra#v1
|
pnpm add https://github.com/tauri-apps/tauri-plugin-fs-extra#v1
|
||||||
# or
|
# or
|
||||||
npm add https://github.com/tauri-apps/tauri-plugin-fs-extra#v1
|
npm add https://github.com/tauri-apps/tauri-plugin-fs-extra#v1
|
||||||
# or
|
# or
|
||||||
yarn add https://github.com/tauri-apps/tauri-plugin-fs-extra#v1
|
yarn add https://github.com/tauri-apps/tauri-plugin-fs-extra#v1
|
||||||
```
|
```
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
First you need to register the core plugin with Tauri:
|
First you need to register the core plugin with Tauri:
|
||||||
|
|
||||||
`src-tauri/src/main.rs`
|
`src-tauri/src/main.rs`
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
fn main() {
|
fn main() {
|
||||||
tauri::Builder::default()
|
tauri::Builder::default()
|
||||||
.plugin(tauri_plugin_fs_extra::init())
|
.plugin(tauri_plugin_fs_extra::init())
|
||||||
.run(tauri::generate_context!())
|
.run(tauri::generate_context!())
|
||||||
.expect("error while running tauri application");
|
.expect("error while running tauri application");
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Afterwards all the plugin's APIs are available through the JavaScript guest bindings:
|
Afterwards all the plugin's APIs are available through the JavaScript guest bindings:
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
import { metadata } from "tauri-plugin-fs-extra-api";
|
import { metadata } from "tauri-plugin-fs-extra-api";
|
||||||
|
|
||||||
await metadata("/path/to/file");
|
await metadata("/path/to/file");
|
||||||
```
|
```
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
PRs accepted. Please make sure to read the Contributing Guide before making a pull request.
|
PRs accepted. Please make sure to read the Contributing Guide before making a pull request.
|
||||||
|
|
||||||
## Partners
|
## Partners
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td align="center" valign="middle">
|
<td align="center" valign="middle">
|
||||||
<a href="https://crabnebula.dev" target="_blank">
|
<a href="https://crabnebula.dev" target="_blank">
|
||||||
<img src="https://github.com/tauri-apps/plugins-workspace/raw/v1/.github/sponsors/crabnebula.svg" alt="CrabNebula" width="283">
|
<img src="https://github.com/tauri-apps/plugins-workspace/raw/v1/.github/sponsors/crabnebula.svg" alt="CrabNebula" width="283">
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri).
|
For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri).
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
Code: (c) 2015 - Present - The Tauri Programme within The Commons Conservancy.
|
Code: (c) 2015 - Present - The Tauri Programme within The Commons Conservancy.
|
||||||
|
|
||||||
MIT or MIT/Apache 2.0 where applicable.
|
MIT or MIT/Apache 2.0 where applicable.
|
||||||
|
@ -1,98 +1,98 @@
|
|||||||

|

|
||||||
|
|
||||||
Watch files and directories for changes using [notify](https://github.com/notify-rs/notify).
|
Watch files and directories for changes using [notify](https://github.com/notify-rs/notify).
|
||||||
|
|
||||||
## Install
|
## Install
|
||||||
|
|
||||||
_This plugin requires a Rust version of at least **1.67**_
|
_This plugin requires a Rust version of at least **1.67**_
|
||||||
|
|
||||||
There are three general methods of installation that we can recommend.
|
There are three general methods of installation that we can recommend.
|
||||||
|
|
||||||
1. Use crates.io and npm (easiest, and requires you to trust that our publishing pipeline worked)
|
1. Use crates.io and npm (easiest, and requires you to trust that our publishing pipeline worked)
|
||||||
2. Pull sources directly from Github using git tags / revision hashes (most secure)
|
2. Pull sources directly from Github using git tags / revision hashes (most secure)
|
||||||
3. Git submodule install this repo in your tauri project and then use file protocol to ingest the source (most secure, but inconvenient to use)
|
3. Git submodule install this repo in your tauri project and then use file protocol to ingest the source (most secure, but inconvenient to use)
|
||||||
|
|
||||||
Install the Core plugin by adding the following to your `Cargo.toml` file:
|
Install the Core plugin by adding the following to your `Cargo.toml` file:
|
||||||
|
|
||||||
`src-tauri/Cargo.toml`
|
`src-tauri/Cargo.toml`
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
[dependencies]
|
[dependencies]
|
||||||
tauri-plugin-fs-watch = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" }
|
tauri-plugin-fs-watch = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" }
|
||||||
```
|
```
|
||||||
|
|
||||||
You can install the JavaScript Guest bindings using your preferred JavaScript package manager:
|
You can install the JavaScript Guest bindings using your preferred JavaScript package manager:
|
||||||
|
|
||||||
> Note: Since most JavaScript package managers are unable to install packages from git monorepos we provide read-only mirrors of each plugin. This makes installation option 2 more ergonomic to use.
|
> Note: Since most JavaScript package managers are unable to install packages from git monorepos we provide read-only mirrors of each plugin. This makes installation option 2 more ergonomic to use.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
pnpm add https://github.com/tauri-apps/tauri-plugin-fs-watch#v1
|
pnpm add https://github.com/tauri-apps/tauri-plugin-fs-watch#v1
|
||||||
# or
|
# or
|
||||||
npm add https://github.com/tauri-apps/tauri-plugin-fs-watch#v1
|
npm add https://github.com/tauri-apps/tauri-plugin-fs-watch#v1
|
||||||
# or
|
# or
|
||||||
yarn add https://github.com/tauri-apps/tauri-plugin-fs-watch#v1
|
yarn add https://github.com/tauri-apps/tauri-plugin-fs-watch#v1
|
||||||
```
|
```
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
First you need to register the core plugin with Tauri:
|
First you need to register the core plugin with Tauri:
|
||||||
|
|
||||||
`src-tauri/src/main.rs`
|
`src-tauri/src/main.rs`
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
fn main() {
|
fn main() {
|
||||||
tauri::Builder::default()
|
tauri::Builder::default()
|
||||||
.plugin(tauri_plugin_fs_watch::init())
|
.plugin(tauri_plugin_fs_watch::init())
|
||||||
.run(tauri::generate_context!())
|
.run(tauri::generate_context!())
|
||||||
.expect("error while running tauri application");
|
.expect("error while running tauri application");
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Afterwards all the plugin's APIs are available through the JavaScript guest bindings:
|
Afterwards all the plugin's APIs are available through the JavaScript guest bindings:
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
import { watch, watchImmediate } from "tauri-plugin-fs-watch-api";
|
import { watch, watchImmediate } from "tauri-plugin-fs-watch-api";
|
||||||
|
|
||||||
// can also watch an array of paths
|
// can also watch an array of paths
|
||||||
const stopWatching = await watch(
|
const stopWatching = await watch(
|
||||||
"/path/to/something",
|
"/path/to/something",
|
||||||
(event) => {
|
(event) => {
|
||||||
const { kind, path } = event;
|
const { kind, path } = event;
|
||||||
},
|
},
|
||||||
{ recursive: true },
|
{ recursive: true },
|
||||||
);
|
);
|
||||||
|
|
||||||
const stopRawWatcher = await watchImmediate(
|
const stopRawWatcher = await watchImmediate(
|
||||||
["/path/a", "/path/b"],
|
["/path/a", "/path/b"],
|
||||||
(event) => {
|
(event) => {
|
||||||
const { type, paths, attrs } = event;
|
const { type, paths, attrs } = event;
|
||||||
},
|
},
|
||||||
{},
|
{},
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
PRs accepted. Please make sure to read the Contributing Guide before making a pull request.
|
PRs accepted. Please make sure to read the Contributing Guide before making a pull request.
|
||||||
|
|
||||||
## Partners
|
## Partners
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td align="center" valign="middle">
|
<td align="center" valign="middle">
|
||||||
<a href="https://crabnebula.dev" target="_blank">
|
<a href="https://crabnebula.dev" target="_blank">
|
||||||
<img src="https://github.com/tauri-apps/plugins-workspace/raw/v1/.github/sponsors/crabnebula.svg" alt="CrabNebula" width="283">
|
<img src="https://github.com/tauri-apps/plugins-workspace/raw/v1/.github/sponsors/crabnebula.svg" alt="CrabNebula" width="283">
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri).
|
For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri).
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
Code: (c) 2015 - Present - The Tauri Programme within The Commons Conservancy.
|
Code: (c) 2015 - Present - The Tauri Programme within The Commons Conservancy.
|
||||||
|
|
||||||
MIT or MIT/Apache 2.0 where applicable.
|
MIT or MIT/Apache 2.0 where applicable.
|
||||||
|
@ -1,90 +1,90 @@
|
|||||||

|

|
||||||
|
|
||||||
Expose your apps assets through a localhost server instead of the default custom protocol.
|
Expose your apps assets through a localhost server instead of the default custom protocol.
|
||||||
|
|
||||||
> Note: This plugins brings considerable security risks and you should only use it if you know what your are doing. If in doubt, use the default custom protocol implementation.
|
> Note: This plugins brings considerable security risks and you should only use it if you know what your are doing. If in doubt, use the default custom protocol implementation.
|
||||||
|
|
||||||
## Install
|
## Install
|
||||||
|
|
||||||
_This plugin requires a Rust version of at least **1.67**_
|
_This plugin requires a Rust version of at least **1.67**_
|
||||||
|
|
||||||
There are three general methods of installation that we can recommend.
|
There are three general methods of installation that we can recommend.
|
||||||
|
|
||||||
1. Use crates.io and npm (easiest, and requires you to trust that our publishing pipeline worked)
|
1. Use crates.io and npm (easiest, and requires you to trust that our publishing pipeline worked)
|
||||||
2. Pull sources directly from Github using git tags / revision hashes (most secure)
|
2. Pull sources directly from Github using git tags / revision hashes (most secure)
|
||||||
3. Git submodule install this repo in your tauri project and then use file protocol to ingest the source (most secure, but inconvenient to use)
|
3. Git submodule install this repo in your tauri project and then use file protocol to ingest the source (most secure, but inconvenient to use)
|
||||||
|
|
||||||
Install the Core plugin by adding the following to your `Cargo.toml` file:
|
Install the Core plugin by adding the following to your `Cargo.toml` file:
|
||||||
|
|
||||||
`src-tauri/Cargo.toml`
|
`src-tauri/Cargo.toml`
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
[dependencies]
|
[dependencies]
|
||||||
tauri-plugin-localhost = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" }
|
tauri-plugin-localhost = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" }
|
||||||
portpicker = "0.1" # used in the example to pick a random free port
|
portpicker = "0.1" # used in the example to pick a random free port
|
||||||
```
|
```
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
First you need to register the core plugin with Tauri:
|
First you need to register the core plugin with Tauri:
|
||||||
|
|
||||||
`src-tauri/src/main.rs`
|
`src-tauri/src/main.rs`
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
use tauri::{utils::config::AppUrl, window::WindowBuilder, WindowUrl};
|
use tauri::{utils::config::AppUrl, window::WindowBuilder, WindowUrl};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let port = portpicker::pick_unused_port().expect("failed to find unused port");
|
let port = portpicker::pick_unused_port().expect("failed to find unused port");
|
||||||
|
|
||||||
let mut context = tauri::generate_context!();
|
let mut context = tauri::generate_context!();
|
||||||
let url = format!("http://localhost:{}", port).parse().unwrap();
|
let url = format!("http://localhost:{}", port).parse().unwrap();
|
||||||
let window_url = WindowUrl::External(url);
|
let window_url = WindowUrl::External(url);
|
||||||
// rewrite the config so the IPC is enabled on this URL
|
// rewrite the config so the IPC is enabled on this URL
|
||||||
context.config_mut().build.dist_dir = AppUrl::Url(window_url.clone());
|
context.config_mut().build.dist_dir = AppUrl::Url(window_url.clone());
|
||||||
|
|
||||||
tauri::Builder::default()
|
tauri::Builder::default()
|
||||||
.plugin(tauri_plugin_localhost::Builder::new(port).build())
|
.plugin(tauri_plugin_localhost::Builder::new(port).build())
|
||||||
.setup(move |app| {
|
.setup(move |app| {
|
||||||
WindowBuilder::new(
|
WindowBuilder::new(
|
||||||
app,
|
app,
|
||||||
"main".to_string(),
|
"main".to_string(),
|
||||||
if cfg!(dev) {
|
if cfg!(dev) {
|
||||||
Default::default()
|
Default::default()
|
||||||
} else {
|
} else {
|
||||||
window_url
|
window_url
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.title("Localhost Example")
|
.title("Localhost Example")
|
||||||
.build()?;
|
.build()?;
|
||||||
Ok(())
|
Ok(())
|
||||||
})
|
})
|
||||||
.run(context)
|
.run(context)
|
||||||
.expect("error while running tauri application");
|
.expect("error while running tauri application");
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
PRs accepted. Please make sure to read the Contributing Guide before making a pull request.
|
PRs accepted. Please make sure to read the Contributing Guide before making a pull request.
|
||||||
|
|
||||||
## Partners
|
## Partners
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td align="center" valign="middle">
|
<td align="center" valign="middle">
|
||||||
<a href="https://crabnebula.dev" target="_blank">
|
<a href="https://crabnebula.dev" target="_blank">
|
||||||
<img src="https://github.com/tauri-apps/plugins-workspace/raw/v1/.github/sponsors/crabnebula.svg" alt="CrabNebula" width="283">
|
<img src="https://github.com/tauri-apps/plugins-workspace/raw/v1/.github/sponsors/crabnebula.svg" alt="CrabNebula" width="283">
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri).
|
For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri).
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
Code: (c) 2015 - Present - The Tauri Programme within The Commons Conservancy.
|
Code: (c) 2015 - Present - The Tauri Programme within The Commons Conservancy.
|
||||||
|
|
||||||
MIT or MIT/Apache 2.0 where applicable.
|
MIT or MIT/Apache 2.0 where applicable.
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
## \[0.1.3]
|
## \[0.1.3]
|
||||||
|
|
||||||
- Split up fs and asset scopes. **This will reset the asset protocol scope once!**
|
- Split up fs and asset scopes. **This will reset the asset protocol scope once!**
|
||||||
- [ad30286](https://github.com/tauri-apps/plugins-workspace/commit/ad3028646c96ed213a2f483823ffdc3c17b5fc1e) fix(persisted-scope): separately save asset protocol patterns ([#459](https://github.com/tauri-apps/plugins-workspace/pull/459)) on 2023-07-10
|
- [ad30286](https://github.com/tauri-apps/plugins-workspace/commit/ad3028646c96ed213a2f483823ffdc3c17b5fc1e) fix(persisted-scope): separately save asset protocol patterns ([#459](https://github.com/tauri-apps/plugins-workspace/pull/459)) on 2023-07-10
|
||||||
|
|
||||||
## \[0.1.2]
|
## \[0.1.2]
|
||||||
|
|
||||||
- Fix usage of directory patterns by removing glob asterisks at the end before allowing/forbidding them. This was causing them to be escaped, and so undesirable paths were allowed/forbidden while polluting the `.persisted_scope` file.
|
- Fix usage of directory patterns by removing glob asterisks at the end before allowing/forbidding them. This was causing them to be escaped, and so undesirable paths were allowed/forbidden while polluting the `.persisted_scope` file.
|
||||||
- [9174b80](https://github.com/tauri-apps/plugins-workspace/commit/9174b808dc37154999c119fcc3f31258a9c5a3fb) \[persisted scope] fix: handle recursive directory correctly ([#455](https://github.com/tauri-apps/plugins-workspace/pull/455)) on 2023-06-29
|
- [9174b80](https://github.com/tauri-apps/plugins-workspace/commit/9174b808dc37154999c119fcc3f31258a9c5a3fb) \[persisted scope] fix: handle recursive directory correctly ([#455](https://github.com/tauri-apps/plugins-workspace/pull/455)) on 2023-06-29
|
||||||
|
|
||||||
## \[0.1.1]
|
## \[0.1.1]
|
||||||
|
|
||||||
- The MSRV was raised to 1.67!
|
- The MSRV was raised to 1.67!
|
||||||
- The plugin now recursively unescapes saved patterns before allowing/forbidding them. This effectively prevents `.persisted-scope` files from blowing up, which caused Out-Of-Memory issues, while automatically fixing existing broken files seamlessly.
|
- The plugin now recursively unescapes saved patterns before allowing/forbidding them. This effectively prevents `.persisted-scope` files from blowing up, which caused Out-Of-Memory issues, while automatically fixing existing broken files seamlessly.
|
||||||
- [ebb2eb2](https://github.com/tauri-apps/plugins-workspace/commit/ebb2eb2fe2ebfbb70530d16a983d396aa5829aa1) fix(persisted-scope): Prevent out-of-memory issues, fixes [#274](https://github.com/tauri-apps/plugins-workspace/pull/274) ([#328](https://github.com/tauri-apps/plugins-workspace/pull/328)) on 2023-04-26
|
- [ebb2eb2](https://github.com/tauri-apps/plugins-workspace/commit/ebb2eb2fe2ebfbb70530d16a983d396aa5829aa1) fix(persisted-scope): Prevent out-of-memory issues, fixes [#274](https://github.com/tauri-apps/plugins-workspace/pull/274) ([#328](https://github.com/tauri-apps/plugins-workspace/pull/328)) on 2023-04-26
|
||||||
|
@ -1,65 +1,65 @@
|
|||||||

|

|
||||||
|
|
||||||
Save filesystem and asset scopes and restore them when the app is reopened.
|
Save filesystem and asset scopes and restore them when the app is reopened.
|
||||||
|
|
||||||
## Install
|
## Install
|
||||||
|
|
||||||
_This plugin requires a Rust version of at least **1.67**_
|
_This plugin requires a Rust version of at least **1.67**_
|
||||||
|
|
||||||
There are three general methods of installation that we can recommend.
|
There are three general methods of installation that we can recommend.
|
||||||
|
|
||||||
1. Use crates.io and npm (easiest, and requires you to trust that our publishing pipeline worked)
|
1. Use crates.io and npm (easiest, and requires you to trust that our publishing pipeline worked)
|
||||||
2. Pull sources directly from Github using git tags / revision hashes (most secure)
|
2. Pull sources directly from Github using git tags / revision hashes (most secure)
|
||||||
3. Git submodule install this repo in your tauri project and then use file protocol to ingest the source (most secure, but inconvenient to use)
|
3. Git submodule install this repo in your tauri project and then use file protocol to ingest the source (most secure, but inconvenient to use)
|
||||||
|
|
||||||
Install the Core plugin by adding the following to your `Cargo.toml` file:
|
Install the Core plugin by adding the following to your `Cargo.toml` file:
|
||||||
|
|
||||||
`src-tauri/Cargo.toml`
|
`src-tauri/Cargo.toml`
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
[dependencies]
|
[dependencies]
|
||||||
tauri-plugin-persisted-scope = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" }
|
tauri-plugin-persisted-scope = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" }
|
||||||
```
|
```
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
First you need to register the core plugin with Tauri:
|
First you need to register the core plugin with Tauri:
|
||||||
|
|
||||||
`src-tauri/src/main.rs`
|
`src-tauri/src/main.rs`
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
fn main() {
|
fn main() {
|
||||||
tauri::Builder::default()
|
tauri::Builder::default()
|
||||||
.plugin(tauri_plugin_persisted_scope::init())
|
.plugin(tauri_plugin_persisted_scope::init())
|
||||||
.run(tauri::generate_context!())
|
.run(tauri::generate_context!())
|
||||||
.expect("error while running tauri application");
|
.expect("error while running tauri application");
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Afterwards the plugin will automatically save and restore filesystem and asset scopes.
|
Afterwards the plugin will automatically save and restore filesystem and asset scopes.
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
PRs accepted. Please make sure to read the Contributing Guide before making a pull request.
|
PRs accepted. Please make sure to read the Contributing Guide before making a pull request.
|
||||||
|
|
||||||
## Partners
|
## Partners
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td align="center" valign="middle">
|
<td align="center" valign="middle">
|
||||||
<a href="https://crabnebula.dev" target="_blank">
|
<a href="https://crabnebula.dev" target="_blank">
|
||||||
<img src="https://github.com/tauri-apps/plugins-workspace/raw/v1/.github/sponsors/crabnebula.svg" alt="CrabNebula" width="283">
|
<img src="https://github.com/tauri-apps/plugins-workspace/raw/v1/.github/sponsors/crabnebula.svg" alt="CrabNebula" width="283">
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri).
|
For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri).
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
Code: (c) 2015 - Present - The Tauri Programme within The Commons Conservancy.
|
Code: (c) 2015 - Present - The Tauri Programme within The Commons Conservancy.
|
||||||
|
|
||||||
MIT or MIT/Apache 2.0 where applicable.
|
MIT or MIT/Apache 2.0 where applicable.
|
||||||
|
@ -1,110 +1,110 @@
|
|||||||

|

|
||||||
|
|
||||||
Position your windows at well-known locations.
|
Position your windows at well-known locations.
|
||||||
|
|
||||||
This plugin is a port of [electron-positioner](https://github.com/jenslind/electron-positioner) for Tauri.
|
This plugin is a port of [electron-positioner](https://github.com/jenslind/electron-positioner) for Tauri.
|
||||||
|
|
||||||
## Install
|
## Install
|
||||||
|
|
||||||
_This plugin requires a Rust version of at least **1.67**_
|
_This plugin requires a Rust version of at least **1.67**_
|
||||||
|
|
||||||
There are three general methods of installation that we can recommend.
|
There are three general methods of installation that we can recommend.
|
||||||
|
|
||||||
1. Use crates.io and npm (easiest, and requires you to trust that our publishing pipeline worked)
|
1. Use crates.io and npm (easiest, and requires you to trust that our publishing pipeline worked)
|
||||||
2. Pull sources directly from Github using git tags / revision hashes (most secure)
|
2. Pull sources directly from Github using git tags / revision hashes (most secure)
|
||||||
3. Git submodule install this repo in your tauri project and then use file protocol to ingest the source (most secure, but inconvenient to use)
|
3. Git submodule install this repo in your tauri project and then use file protocol to ingest the source (most secure, but inconvenient to use)
|
||||||
|
|
||||||
Install the Core plugin by adding the following to your `Cargo.toml` file:
|
Install the Core plugin by adding the following to your `Cargo.toml` file:
|
||||||
|
|
||||||
`src-tauri/Cargo.toml`
|
`src-tauri/Cargo.toml`
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
[dependencies]
|
[dependencies]
|
||||||
tauri-plugin-positioner = "1.0"
|
tauri-plugin-positioner = "1.0"
|
||||||
# or through git
|
# or through git
|
||||||
tauri-plugin-positioner = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" }
|
tauri-plugin-positioner = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" }
|
||||||
```
|
```
|
||||||
|
|
||||||
You can install the JavaScript Guest bindings using your preferred JavaScript package manager:
|
You can install the JavaScript Guest bindings using your preferred JavaScript package manager:
|
||||||
|
|
||||||
> Note: Since most JavaScript package managers are unable to install packages from git monorepos we provide read-only mirrors of each plugin. This makes installation option 2 more ergonomic to use.
|
> Note: Since most JavaScript package managers are unable to install packages from git monorepos we provide read-only mirrors of each plugin. This makes installation option 2 more ergonomic to use.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
pnpm add tauri-plugin-positioner-api
|
pnpm add tauri-plugin-positioner-api
|
||||||
# or
|
# or
|
||||||
npm add tauri-plugin-positioner-api
|
npm add tauri-plugin-positioner-api
|
||||||
# or
|
# or
|
||||||
yarn add tauri-plugin-positioner-api
|
yarn add tauri-plugin-positioner-api
|
||||||
```
|
```
|
||||||
|
|
||||||
Or through git:
|
Or through git:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
pnpm add https://github.com/tauri-apps/tauri-plugin-positioner#v1
|
pnpm add https://github.com/tauri-apps/tauri-plugin-positioner#v1
|
||||||
# or
|
# or
|
||||||
npm add https://github.com/tauri-apps/tauri-plugin-positioner#v1
|
npm add https://github.com/tauri-apps/tauri-plugin-positioner#v1
|
||||||
# or
|
# or
|
||||||
yarn add https://github.com/tauri-apps/tauri-plugin-positioner#v1
|
yarn add https://github.com/tauri-apps/tauri-plugin-positioner#v1
|
||||||
```
|
```
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
First you need to register the core plugin with Tauri:
|
First you need to register the core plugin with Tauri:
|
||||||
|
|
||||||
`src-tauri/src/main.rs`
|
`src-tauri/src/main.rs`
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
fn main() {
|
fn main() {
|
||||||
tauri::Builder::default()
|
tauri::Builder::default()
|
||||||
.plugin(tauri_plugin_positioner::init())
|
.plugin(tauri_plugin_positioner::init())
|
||||||
// This is required to get tray-relative positions to work
|
// This is required to get tray-relative positions to work
|
||||||
.on_system_tray_event(|app, event| {
|
.on_system_tray_event(|app, event| {
|
||||||
tauri_plugin_positioner::on_tray_event(app, &event);
|
tauri_plugin_positioner::on_tray_event(app, &event);
|
||||||
})
|
})
|
||||||
.run(tauri::generate_context!())
|
.run(tauri::generate_context!())
|
||||||
.expect("error while running tauri application");
|
.expect("error while running tauri application");
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Afterwards all the plugin's APIs are available through the JavaScript guest bindings:
|
Afterwards all the plugin's APIs are available through the JavaScript guest bindings:
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
import { move_window, Position } from "tauri-plugin-positioner-api";
|
import { move_window, Position } from "tauri-plugin-positioner-api";
|
||||||
|
|
||||||
move_window(Position.TopRight);
|
move_window(Position.TopRight);
|
||||||
```
|
```
|
||||||
|
|
||||||
If you only intend on moving the window from rust code, you can import the Window trait extension instead of registering the plugin:
|
If you only intend on moving the window from rust code, you can import the Window trait extension instead of registering the plugin:
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
use tauri_plugin_positioner::{WindowExt, Position};
|
use tauri_plugin_positioner::{WindowExt, Position};
|
||||||
|
|
||||||
let mut win = app.get_window("main").unwrap();
|
let mut win = app.get_window("main").unwrap();
|
||||||
let _ = win.move_window(Position::TopRight);
|
let _ = win.move_window(Position::TopRight);
|
||||||
```
|
```
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
PRs accepted. Please make sure to read the Contributing Guide before making a pull request.
|
PRs accepted. Please make sure to read the Contributing Guide before making a pull request.
|
||||||
|
|
||||||
## Partners
|
## Partners
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td align="center" valign="middle">
|
<td align="center" valign="middle">
|
||||||
<a href="https://crabnebula.dev" target="_blank">
|
<a href="https://crabnebula.dev" target="_blank">
|
||||||
<img src="https://github.com/tauri-apps/plugins-workspace/raw/v1/.github/sponsors/crabnebula.svg" alt="CrabNebula" width="283">
|
<img src="https://github.com/tauri-apps/plugins-workspace/raw/v1/.github/sponsors/crabnebula.svg" alt="CrabNebula" width="283">
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri).
|
For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri).
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
Code: (c) 2021 - Jonas Kruckenberg. 2021 - Present - The Tauri Programme within The Commons Conservancy.
|
Code: (c) 2021 - Jonas Kruckenberg. 2021 - Present - The Tauri Programme within The Commons Conservancy.
|
||||||
|
|
||||||
MIT or MIT/Apache 2.0 where applicable.
|
MIT or MIT/Apache 2.0 where applicable.
|
||||||
|
@ -1,75 +1,75 @@
|
|||||||

|

|
||||||
|
|
||||||
Ensure a single instance of your tauri app is running.
|
Ensure a single instance of your tauri app is running.
|
||||||
|
|
||||||
## Install
|
## Install
|
||||||
|
|
||||||
_This plugin requires a Rust version of at least **1.67**_
|
_This plugin requires a Rust version of at least **1.67**_
|
||||||
|
|
||||||
There are three general methods of installation that we can recommend.
|
There are three general methods of installation that we can recommend.
|
||||||
|
|
||||||
1. Use crates.io and npm (easiest, and requires you to trust that our publishing pipeline worked)
|
1. Use crates.io and npm (easiest, and requires you to trust that our publishing pipeline worked)
|
||||||
2. Pull sources directly from Github using git tags / revision hashes (most secure)
|
2. Pull sources directly from Github using git tags / revision hashes (most secure)
|
||||||
3. Git submodule install this repo in your tauri project and then use file protocol to ingest the source (most secure, but inconvenient to use)
|
3. Git submodule install this repo in your tauri project and then use file protocol to ingest the source (most secure, but inconvenient to use)
|
||||||
|
|
||||||
Install the Core plugin by adding the following to your `Cargo.toml` file:
|
Install the Core plugin by adding the following to your `Cargo.toml` file:
|
||||||
|
|
||||||
`src-tauri/Cargo.toml`
|
`src-tauri/Cargo.toml`
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
[dependencies]
|
[dependencies]
|
||||||
tauri-plugin-single-instance = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" }
|
tauri-plugin-single-instance = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" }
|
||||||
```
|
```
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
First you need to register the core plugin with Tauri:
|
First you need to register the core plugin with Tauri:
|
||||||
|
|
||||||
`src-tauri/src/main.rs`
|
`src-tauri/src/main.rs`
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
use tauri::{Manager};
|
use tauri::{Manager};
|
||||||
|
|
||||||
#[derive(Clone, serde::Serialize)]
|
#[derive(Clone, serde::Serialize)]
|
||||||
struct Payload {
|
struct Payload {
|
||||||
args: Vec<String>,
|
args: Vec<String>,
|
||||||
cwd: String,
|
cwd: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
tauri::Builder::default()
|
tauri::Builder::default()
|
||||||
.plugin(tauri_plugin_single_instance::init(|app, argv, cwd| {
|
.plugin(tauri_plugin_single_instance::init(|app, argv, cwd| {
|
||||||
println!("{}, {argv:?}, {cwd}", app.package_info().name);
|
println!("{}, {argv:?}, {cwd}", app.package_info().name);
|
||||||
|
|
||||||
app.emit_all("single-instance", Payload { args: argv, cwd }).unwrap();
|
app.emit_all("single-instance", Payload { args: argv, cwd }).unwrap();
|
||||||
}))
|
}))
|
||||||
.run(tauri::generate_context!())
|
.run(tauri::generate_context!())
|
||||||
.expect("error while running tauri application");
|
.expect("error while running tauri application");
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
PRs accepted. Please make sure to read the Contributing Guide before making a pull request.
|
PRs accepted. Please make sure to read the Contributing Guide before making a pull request.
|
||||||
|
|
||||||
## Partners
|
## Partners
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td align="center" valign="middle">
|
<td align="center" valign="middle">
|
||||||
<a href="https://crabnebula.dev" target="_blank">
|
<a href="https://crabnebula.dev" target="_blank">
|
||||||
<img src="https://github.com/tauri-apps/plugins-workspace/raw/v1/.github/sponsors/crabnebula.svg" alt="CrabNebula" width="283">
|
<img src="https://github.com/tauri-apps/plugins-workspace/raw/v1/.github/sponsors/crabnebula.svg" alt="CrabNebula" width="283">
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri).
|
For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri).
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
Code: (c) 2015 - Present - The Tauri Programme within The Commons Conservancy.
|
Code: (c) 2015 - Present - The Tauri Programme within The Commons Conservancy.
|
||||||
|
|
||||||
MIT or MIT/Apache 2.0 where applicable.
|
MIT or MIT/Apache 2.0 where applicable.
|
||||||
|
@ -1,184 +1,184 @@
|
|||||||

|

|
||||||
|
|
||||||
Interface with SQL databases through [sqlx](https://github.com/launchbadge/sqlx). It supports the `sqlite`, `mysql` and `postgres` drivers, enabled by a Cargo feature.
|
Interface with SQL databases through [sqlx](https://github.com/launchbadge/sqlx). It supports the `sqlite`, `mysql` and `postgres` drivers, enabled by a Cargo feature.
|
||||||
|
|
||||||
## Install
|
## Install
|
||||||
|
|
||||||
_This plugin requires a Rust version of at least **1.80**_
|
_This plugin requires a Rust version of at least **1.80**_
|
||||||
|
|
||||||
There are three general methods of installation that we can recommend.
|
There are three general methods of installation that we can recommend.
|
||||||
|
|
||||||
1. Use crates.io and npm (easiest, and requires you to trust that our publishing pipeline worked)
|
1. Use crates.io and npm (easiest, and requires you to trust that our publishing pipeline worked)
|
||||||
2. Pull sources directly from Github using git tags / revision hashes (most secure)
|
2. Pull sources directly from Github using git tags / revision hashes (most secure)
|
||||||
3. Git submodule install this repo in your tauri project and then use file protocol to ingest the source (most secure, but inconvenient to use)
|
3. Git submodule install this repo in your tauri project and then use file protocol to ingest the source (most secure, but inconvenient to use)
|
||||||
|
|
||||||
Install the Core plugin by adding the following to your `Cargo.toml` file:
|
Install the Core plugin by adding the following to your `Cargo.toml` file:
|
||||||
|
|
||||||
`src-tauri/Cargo.toml`
|
`src-tauri/Cargo.toml`
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
[dependencies.tauri-plugin-sql]
|
[dependencies.tauri-plugin-sql]
|
||||||
git = "https://github.com/tauri-apps/plugins-workspace"
|
git = "https://github.com/tauri-apps/plugins-workspace"
|
||||||
branch = "v1"
|
branch = "v1"
|
||||||
features = ["sqlite"] # or "postgres", or "mysql"
|
features = ["sqlite"] # or "postgres", or "mysql"
|
||||||
```
|
```
|
||||||
|
|
||||||
You can install the JavaScript Guest bindings using your preferred JavaScript package manager:
|
You can install the JavaScript Guest bindings using your preferred JavaScript package manager:
|
||||||
|
|
||||||
> Note: Since most JavaScript package managers are unable to install packages from git monorepos we provide read-only mirrors of each plugin. This makes installation option 2 more ergonomic to use.
|
> Note: Since most JavaScript package managers are unable to install packages from git monorepos we provide read-only mirrors of each plugin. This makes installation option 2 more ergonomic to use.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
pnpm add https://github.com/tauri-apps/tauri-plugin-sql#v1
|
pnpm add https://github.com/tauri-apps/tauri-plugin-sql#v1
|
||||||
# or
|
# or
|
||||||
npm add https://github.com/tauri-apps/tauri-plugin-sql#v1
|
npm add https://github.com/tauri-apps/tauri-plugin-sql#v1
|
||||||
# or
|
# or
|
||||||
yarn add https://github.com/tauri-apps/tauri-plugin-sql#v1
|
yarn add https://github.com/tauri-apps/tauri-plugin-sql#v1
|
||||||
```
|
```
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
First you need to register the core plugin with Tauri:
|
First you need to register the core plugin with Tauri:
|
||||||
|
|
||||||
`src-tauri/src/main.rs`
|
`src-tauri/src/main.rs`
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
fn main() {
|
fn main() {
|
||||||
tauri::Builder::default()
|
tauri::Builder::default()
|
||||||
.plugin(tauri_plugin_sql::Builder::default().build())
|
.plugin(tauri_plugin_sql::Builder::default().build())
|
||||||
.run(tauri::generate_context!())
|
.run(tauri::generate_context!())
|
||||||
.expect("error while running tauri application");
|
.expect("error while running tauri application");
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Afterwards all the plugin's APIs are available through the JavaScript guest bindings:
|
Afterwards all the plugin's APIs are available through the JavaScript guest bindings:
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
import Database from "tauri-plugin-sql-api";
|
import Database from "tauri-plugin-sql-api";
|
||||||
|
|
||||||
// sqlite. The path is relative to `tauri::api::path::BaseDirectory::App`.
|
// sqlite. The path is relative to `tauri::api::path::BaseDirectory::App`.
|
||||||
const db = await Database.load("sqlite:test.db");
|
const db = await Database.load("sqlite:test.db");
|
||||||
// mysql
|
// mysql
|
||||||
const db = await Database.load("mysql://user:pass@host/database");
|
const db = await Database.load("mysql://user:pass@host/database");
|
||||||
// postgres
|
// postgres
|
||||||
const db = await Database.load("postgres://postgres:password@localhost/test");
|
const db = await Database.load("postgres://postgres:password@localhost/test");
|
||||||
|
|
||||||
await db.execute("INSERT INTO ...");
|
await db.execute("INSERT INTO ...");
|
||||||
```
|
```
|
||||||
|
|
||||||
## Syntax
|
## Syntax
|
||||||
|
|
||||||
We use sqlx as our underlying library, adopting their query syntax:
|
We use sqlx as our underlying library, adopting their query syntax:
|
||||||
|
|
||||||
- sqlite and postgres use the "$#" syntax when substituting query data
|
- sqlite and postgres use the "$#" syntax when substituting query data
|
||||||
- mysql uses "?" when substituting query data
|
- mysql uses "?" when substituting query data
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
// INSERT and UPDATE examples for sqlite and postgres
|
// INSERT and UPDATE examples for sqlite and postgres
|
||||||
const result = await db.execute(
|
const result = await db.execute(
|
||||||
"INSERT into todos (id, title, status) VALUES ($1, $2, $3)",
|
"INSERT into todos (id, title, status) VALUES ($1, $2, $3)",
|
||||||
[todos.id, todos.title, todos.status],
|
[todos.id, todos.title, todos.status],
|
||||||
);
|
);
|
||||||
|
|
||||||
const result = await db.execute(
|
const result = await db.execute(
|
||||||
"UPDATE todos SET title = $1, completed = $2 WHERE id = $3",
|
"UPDATE todos SET title = $1, completed = $2 WHERE id = $3",
|
||||||
[todos.title, todos.status, todos.id],
|
[todos.title, todos.status, todos.id],
|
||||||
);
|
);
|
||||||
|
|
||||||
// INSERT and UPDATE examples for mysql
|
// INSERT and UPDATE examples for mysql
|
||||||
const result = await db.execute(
|
const result = await db.execute(
|
||||||
"INSERT into todos (id, title, status) VALUES (?, ?, ?)",
|
"INSERT into todos (id, title, status) VALUES (?, ?, ?)",
|
||||||
[todos.id, todos.title, todos.status],
|
[todos.id, todos.title, todos.status],
|
||||||
);
|
);
|
||||||
|
|
||||||
const result = await db.execute(
|
const result = await db.execute(
|
||||||
"UPDATE todos SET title = ?, completed = ? WHERE id = ?",
|
"UPDATE todos SET title = ?, completed = ? WHERE id = ?",
|
||||||
[todos.title, todos.status, todos.id],
|
[todos.title, todos.status, todos.id],
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
## Migrations
|
## Migrations
|
||||||
|
|
||||||
This plugin supports database migrations, allowing you to manage database schema evolution over time.
|
This plugin supports database migrations, allowing you to manage database schema evolution over time.
|
||||||
|
|
||||||
### Defining Migrations
|
### Defining Migrations
|
||||||
|
|
||||||
Migrations are defined in Rust using the `Migration` struct. Each migration should include a unique version number, a description, the SQL to be executed, and the type of migration (Up or Down).
|
Migrations are defined in Rust using the `Migration` struct. Each migration should include a unique version number, a description, the SQL to be executed, and the type of migration (Up or Down).
|
||||||
|
|
||||||
Example of a migration:
|
Example of a migration:
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
use tauri_plugin_sql::{Migration, MigrationKind};
|
use tauri_plugin_sql::{Migration, MigrationKind};
|
||||||
|
|
||||||
let migration = Migration {
|
let migration = Migration {
|
||||||
version: 1,
|
version: 1,
|
||||||
description: "create_initial_tables",
|
description: "create_initial_tables",
|
||||||
sql: "CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT);",
|
sql: "CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT);",
|
||||||
kind: MigrationKind::Up,
|
kind: MigrationKind::Up,
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
### Adding Migrations to the Plugin Builder
|
### Adding Migrations to the Plugin Builder
|
||||||
|
|
||||||
Migrations are registered with the `Builder` struct provided by the plugin. Use the `add_migrations` method to add your migrations to the plugin for a specific database connection.
|
Migrations are registered with the `Builder` struct provided by the plugin. Use the `add_migrations` method to add your migrations to the plugin for a specific database connection.
|
||||||
|
|
||||||
Example of adding migrations:
|
Example of adding migrations:
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
use tauri_plugin_sql::{Builder, Migration, MigrationKind};
|
use tauri_plugin_sql::{Builder, Migration, MigrationKind};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let migrations = vec![
|
let migrations = vec![
|
||||||
// Define your migrations here
|
// Define your migrations here
|
||||||
Migration {
|
Migration {
|
||||||
version: 1,
|
version: 1,
|
||||||
description: "create_initial_tables",
|
description: "create_initial_tables",
|
||||||
sql: "CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT);",
|
sql: "CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT);",
|
||||||
kind: MigrationKind::Up,
|
kind: MigrationKind::Up,
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
tauri::Builder::default()
|
tauri::Builder::default()
|
||||||
.plugin(
|
.plugin(
|
||||||
tauri_plugin_sql::Builder::default()
|
tauri_plugin_sql::Builder::default()
|
||||||
.add_migrations("sqlite:mydatabase.db", migrations)
|
.add_migrations("sqlite:mydatabase.db", migrations)
|
||||||
.build(),
|
.build(),
|
||||||
)
|
)
|
||||||
...
|
...
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Applying Migrations
|
### Applying Migrations
|
||||||
|
|
||||||
Migrations are applied automatically when the plugin is initialized. The plugin runs these migrations against the database specified by the connection string. Ensure that the migrations are defined in the correct order and are idempotent (safe to run multiple times).
|
Migrations are applied automatically when the plugin is initialized. The plugin runs these migrations against the database specified by the connection string. Ensure that the migrations are defined in the correct order and are idempotent (safe to run multiple times).
|
||||||
|
|
||||||
### Migration Management
|
### Migration Management
|
||||||
|
|
||||||
- **Version Control**: Each migration must have a unique version number. This is crucial for ensuring the migrations are applied in the correct order.
|
- **Version Control**: Each migration must have a unique version number. This is crucial for ensuring the migrations are applied in the correct order.
|
||||||
- **Idempotency**: Write migrations in a way that they can be safely re-run without causing errors or unintended consequences.
|
- **Idempotency**: Write migrations in a way that they can be safely re-run without causing errors or unintended consequences.
|
||||||
- **Testing**: Thoroughly test migrations to ensure they work as expected and do not compromise the integrity of your database.
|
- **Testing**: Thoroughly test migrations to ensure they work as expected and do not compromise the integrity of your database.
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
PRs accepted. Please make sure to read the Contributing Guide before making a pull request.
|
PRs accepted. Please make sure to read the Contributing Guide before making a pull request.
|
||||||
|
|
||||||
## Partners
|
## Partners
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td align="center" valign="middle">
|
<td align="center" valign="middle">
|
||||||
<a href="https://crabnebula.dev" target="_blank">
|
<a href="https://crabnebula.dev" target="_blank">
|
||||||
<img src="https://github.com/tauri-apps/plugins-workspace/raw/v1/.github/sponsors/crabnebula.svg" alt="CrabNebula" width="283">
|
<img src="https://github.com/tauri-apps/plugins-workspace/raw/v1/.github/sponsors/crabnebula.svg" alt="CrabNebula" width="283">
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri).
|
For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri).
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
Code: (c) 2015 - Present - The Tauri Programme within The Commons Conservancy.
|
Code: (c) 2015 - Present - The Tauri Programme within The Commons Conservancy.
|
||||||
|
|
||||||
MIT or MIT/Apache 2.0 where applicable.
|
MIT or MIT/Apache 2.0 where applicable.
|
||||||
|
@ -1,152 +1,152 @@
|
|||||||

|

|
||||||
|
|
||||||
Store secrets and keys using the [IOTA Stronghold](https://github.com/iotaledger/stronghold.rs) encrypted database and secure runtime.
|
Store secrets and keys using the [IOTA Stronghold](https://github.com/iotaledger/stronghold.rs) encrypted database and secure runtime.
|
||||||
|
|
||||||
## Install
|
## Install
|
||||||
|
|
||||||
_This plugin requires a Rust version of at least **1.67**_
|
_This plugin requires a Rust version of at least **1.67**_
|
||||||
|
|
||||||
There are three general methods of installation that we can recommend.
|
There are three general methods of installation that we can recommend.
|
||||||
|
|
||||||
1. Use crates.io and npm (easiest, and requires you to trust that our publishing pipeline worked)
|
1. Use crates.io and npm (easiest, and requires you to trust that our publishing pipeline worked)
|
||||||
2. Pull sources directly from Github using git tags / revision hashes (most secure)
|
2. Pull sources directly from Github using git tags / revision hashes (most secure)
|
||||||
3. Git submodule install this repo in your tauri project and then use file protocol to ingest the source (most secure, but inconvenient to use)
|
3. Git submodule install this repo in your tauri project and then use file protocol to ingest the source (most secure, but inconvenient to use)
|
||||||
|
|
||||||
Install the Core plugin by adding the following to your `Cargo.toml` file:
|
Install the Core plugin by adding the following to your `Cargo.toml` file:
|
||||||
|
|
||||||
`src-tauri/Cargo.toml`
|
`src-tauri/Cargo.toml`
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
[dependencies]
|
[dependencies]
|
||||||
tauri-plugin-stronghold = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" }
|
tauri-plugin-stronghold = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" }
|
||||||
```
|
```
|
||||||
|
|
||||||
You can install the JavaScript Guest bindings using your preferred JavaScript package manager:
|
You can install the JavaScript Guest bindings using your preferred JavaScript package manager:
|
||||||
|
|
||||||
> Note: If your JavaScript package manager cannot install packages from git monorepos, you can still use the code by manually copying the [Guest bindings](./guest-js/index.ts) into your source files.
|
> Note: If your JavaScript package manager cannot install packages from git monorepos, you can still use the code by manually copying the [Guest bindings](./guest-js/index.ts) into your source files.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
pnpm add https://github.com/tauri-apps/tauri-plugin-stronghold#v1
|
pnpm add https://github.com/tauri-apps/tauri-plugin-stronghold#v1
|
||||||
# or
|
# or
|
||||||
npm add https://github.com/tauri-apps/tauri-plugin-stronghold#v1
|
npm add https://github.com/tauri-apps/tauri-plugin-stronghold#v1
|
||||||
# or
|
# or
|
||||||
yarn add https://github.com/tauri-apps/tauri-plugin-stronghold#v1
|
yarn add https://github.com/tauri-apps/tauri-plugin-stronghold#v1
|
||||||
```
|
```
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
First you need to register the core plugin with Tauri:
|
First you need to register the core plugin with Tauri:
|
||||||
|
|
||||||
`src-tauri/src/main.rs`
|
`src-tauri/src/main.rs`
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
fn main() {
|
fn main() {
|
||||||
tauri::Builder::default()
|
tauri::Builder::default()
|
||||||
.plugin(tauri_plugin_stronghold::Builder::new(|password| {
|
.plugin(tauri_plugin_stronghold::Builder::new(|password| {
|
||||||
// Hash the password here with e.g. argon2, blake2b or any other secure algorithm
|
// Hash the password here with e.g. argon2, blake2b or any other secure algorithm
|
||||||
// Here is an example implementation using the `rust-argon2` crate for hashing the password
|
// Here is an example implementation using the `rust-argon2` crate for hashing the password
|
||||||
|
|
||||||
use argon2::{hash_raw, Config, Variant, Version};
|
use argon2::{hash_raw, Config, Variant, Version};
|
||||||
|
|
||||||
let config = Config {
|
let config = Config {
|
||||||
lanes: 4,
|
lanes: 4,
|
||||||
mem_cost: 10_000,
|
mem_cost: 10_000,
|
||||||
time_cost: 10,
|
time_cost: 10,
|
||||||
variant: Variant::Argon2id,
|
variant: Variant::Argon2id,
|
||||||
version: Version::Version13,
|
version: Version::Version13,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
let salt = "your-salt".as_bytes();
|
let salt = "your-salt".as_bytes();
|
||||||
|
|
||||||
let key = hash_raw(password.as_ref(), salt, &config).expect("failed to hash password");
|
let key = hash_raw(password.as_ref(), salt, &config).expect("failed to hash password");
|
||||||
|
|
||||||
key.to_vec()
|
key.to_vec()
|
||||||
})
|
})
|
||||||
.build())
|
.build())
|
||||||
.run(tauri::generate_context!())
|
.run(tauri::generate_context!())
|
||||||
.expect("error while running tauri application");
|
.expect("error while running tauri application");
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Afterwards all the plugin's APIs are available through the JavaScript guest bindings:
|
Afterwards all the plugin's APIs are available through the JavaScript guest bindings:
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
import { Stronghold, Location, Client } from "tauri-plugin-stronghold-api";
|
import { Stronghold, Location, Client } from "tauri-plugin-stronghold-api";
|
||||||
import { appDataDir } from "@tauri-apps/api/path";
|
import { appDataDir } from "@tauri-apps/api/path";
|
||||||
|
|
||||||
const initStronghold = async () => {
|
const initStronghold = async () => {
|
||||||
const vaultPath = `${await appDataDir()}/vault.hold`;
|
const vaultPath = `${await appDataDir()}/vault.hold`;
|
||||||
|
|
||||||
const vaultKey = "The key to the vault";
|
const vaultKey = "The key to the vault";
|
||||||
|
|
||||||
const stronghold = await Stronghold.load(vaultPath, vaultKey);
|
const stronghold = await Stronghold.load(vaultPath, vaultKey);
|
||||||
|
|
||||||
let client: Client;
|
let client: Client;
|
||||||
|
|
||||||
const clientName = "name your client";
|
const clientName = "name your client";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
client = await hold.loadClient(clientName);
|
client = await hold.loadClient(clientName);
|
||||||
} catch {
|
} catch {
|
||||||
client = await hold.createClient(clientName);
|
client = await hold.createClient(clientName);
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
stronghold,
|
stronghold,
|
||||||
client,
|
client,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
const { stronghold, client } = await initStronghold();
|
const { stronghold, client } = await initStronghold();
|
||||||
|
|
||||||
const store = client.getStore();
|
const store = client.getStore();
|
||||||
|
|
||||||
const key = "my_key";
|
const key = "my_key";
|
||||||
|
|
||||||
// Insert a record to the store
|
// Insert a record to the store
|
||||||
|
|
||||||
const data = Array.from(new TextEncoder().encode("Hello, World!"));
|
const data = Array.from(new TextEncoder().encode("Hello, World!"));
|
||||||
|
|
||||||
await store.insert(key, data);
|
await store.insert(key, data);
|
||||||
|
|
||||||
// Read a record from store
|
// Read a record from store
|
||||||
|
|
||||||
const data = await store.get(key);
|
const data = await store.get(key);
|
||||||
|
|
||||||
const value = new TextDecoder().decode(new Uint8Array(data));
|
const value = new TextDecoder().decode(new Uint8Array(data));
|
||||||
|
|
||||||
// Save your updates
|
// Save your updates
|
||||||
|
|
||||||
await stronghold.save();
|
await stronghold.save();
|
||||||
|
|
||||||
// Remove a record from store
|
// Remove a record from store
|
||||||
|
|
||||||
await store.remove(key);
|
await store.remove(key);
|
||||||
```
|
```
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
PRs accepted. Please make sure to read the Contributing Guide before making a pull request.
|
PRs accepted. Please make sure to read the Contributing Guide before making a pull request.
|
||||||
|
|
||||||
## Partners
|
## Partners
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td align="center" valign="middle">
|
<td align="center" valign="middle">
|
||||||
<a href="https://crabnebula.dev" target="_blank">
|
<a href="https://crabnebula.dev" target="_blank">
|
||||||
<img src="https://github.com/tauri-apps/plugins-workspace/raw/v1/.github/sponsors/crabnebula.svg" alt="CrabNebula" width="283">
|
<img src="https://github.com/tauri-apps/plugins-workspace/raw/v1/.github/sponsors/crabnebula.svg" alt="CrabNebula" width="283">
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri).
|
For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri).
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
Code: (c) 2015 - Present - The Tauri Programme within The Commons Conservancy.
|
Code: (c) 2015 - Present - The Tauri Programme within The Commons Conservancy.
|
||||||
|
|
||||||
MIT or MIT/Apache 2.0 where applicable.
|
MIT or MIT/Apache 2.0 where applicable.
|
||||||
|
@ -1,100 +1,100 @@
|
|||||||

|

|
||||||
|
|
||||||
Upload files from disk to a remote server over HTTP.
|
Upload files from disk to a remote server over HTTP.
|
||||||
Download files from a remote HTTP server to disk.
|
Download files from a remote HTTP server to disk.
|
||||||
|
|
||||||
## Install
|
## Install
|
||||||
|
|
||||||
_This plugin requires a Rust version of at least **1.67**_
|
_This plugin requires a Rust version of at least **1.67**_
|
||||||
|
|
||||||
There are three general methods of installation that we can recommend.
|
There are three general methods of installation that we can recommend.
|
||||||
|
|
||||||
1. Use crates.io and npm (easiest, and requires you to trust that our publishing pipeline worked)
|
1. Use crates.io and npm (easiest, and requires you to trust that our publishing pipeline worked)
|
||||||
2. Pull sources directly from Github using git tags / revision hashes (most secure)
|
2. Pull sources directly from Github using git tags / revision hashes (most secure)
|
||||||
3. Git submodule install this repo in your tauri project and then use file protocol to ingest the source (most secure, but inconvenient to use)
|
3. Git submodule install this repo in your tauri project and then use file protocol to ingest the source (most secure, but inconvenient to use)
|
||||||
|
|
||||||
Install the Core plugin by adding the following to your `Cargo.toml` file:
|
Install the Core plugin by adding the following to your `Cargo.toml` file:
|
||||||
|
|
||||||
`src-tauri/Cargo.toml`
|
`src-tauri/Cargo.toml`
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
[dependencies]
|
[dependencies]
|
||||||
tauri-plugin-upload = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" }
|
tauri-plugin-upload = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" }
|
||||||
```
|
```
|
||||||
|
|
||||||
You can install the JavaScript Guest bindings using your preferred JavaScript package manager:
|
You can install the JavaScript Guest bindings using your preferred JavaScript package manager:
|
||||||
|
|
||||||
> Note: Since most JavaScript package managers are unable to install packages from git monorepos we provide read-only mirrors of each plugin. This makes installation option 2 more ergonomic to use.
|
> Note: Since most JavaScript package managers are unable to install packages from git monorepos we provide read-only mirrors of each plugin. This makes installation option 2 more ergonomic to use.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
pnpm add https://github.com/tauri-apps/tauri-plugin-upload#v1
|
pnpm add https://github.com/tauri-apps/tauri-plugin-upload#v1
|
||||||
# or
|
# or
|
||||||
npm add https://github.com/tauri-apps/tauri-plugin-upload#v1
|
npm add https://github.com/tauri-apps/tauri-plugin-upload#v1
|
||||||
# or
|
# or
|
||||||
yarn add https://github.com/tauri-apps/tauri-plugin-upload#v1
|
yarn add https://github.com/tauri-apps/tauri-plugin-upload#v1
|
||||||
```
|
```
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
First you need to register the core plugin with Tauri:
|
First you need to register the core plugin with Tauri:
|
||||||
|
|
||||||
`src-tauri/src/main.rs`
|
`src-tauri/src/main.rs`
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
fn main() {
|
fn main() {
|
||||||
tauri::Builder::default()
|
tauri::Builder::default()
|
||||||
.plugin(tauri_plugin_upload::init())
|
.plugin(tauri_plugin_upload::init())
|
||||||
.run(tauri::generate_context!())
|
.run(tauri::generate_context!())
|
||||||
.expect("error while running tauri application");
|
.expect("error while running tauri application");
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Afterwards all the plugin's APIs are available through the JavaScript guest bindings:
|
Afterwards all the plugin's APIs are available through the JavaScript guest bindings:
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
import { upload } from "tauri-plugin-upload-api";
|
import { upload } from "tauri-plugin-upload-api";
|
||||||
|
|
||||||
upload(
|
upload(
|
||||||
"https://example.com/file-upload",
|
"https://example.com/file-upload",
|
||||||
"./path/to/my/file.txt",
|
"./path/to/my/file.txt",
|
||||||
(progress, total) => console.log(`Uploaded ${progress} of ${total} bytes`), // a callback that will be called with the upload progress
|
(progress, total) => console.log(`Uploaded ${progress} of ${total} bytes`), // a callback that will be called with the upload progress
|
||||||
{ "Content-Type": "text/plain" }, // optional headers to send with the request
|
{ "Content-Type": "text/plain" }, // optional headers to send with the request
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
import { download } from "tauri-plugin-upload-api";
|
import { download } from "tauri-plugin-upload-api";
|
||||||
|
|
||||||
download(
|
download(
|
||||||
"https://example.com/file-download-link",
|
"https://example.com/file-download-link",
|
||||||
"./path/to/save/my/file.txt",
|
"./path/to/save/my/file.txt",
|
||||||
(progress, total) => console.log(`Downloaded ${progress} of ${total} bytes`), // a callback that will be called with the download progress
|
(progress, total) => console.log(`Downloaded ${progress} of ${total} bytes`), // a callback that will be called with the download progress
|
||||||
{ "Content-Type": "text/plain" }, // optional headers to send with the request
|
{ "Content-Type": "text/plain" }, // optional headers to send with the request
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
PRs accepted. Please make sure to read the Contributing Guide before making a pull request.
|
PRs accepted. Please make sure to read the Contributing Guide before making a pull request.
|
||||||
|
|
||||||
## Partners
|
## Partners
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td align="center" valign="middle">
|
<td align="center" valign="middle">
|
||||||
<a href="https://crabnebula.dev" target="_blank">
|
<a href="https://crabnebula.dev" target="_blank">
|
||||||
<img src="https://github.com/tauri-apps/plugins-workspace/raw/v1/.github/sponsors/crabnebula.svg" alt="CrabNebula" width="283">
|
<img src="https://github.com/tauri-apps/plugins-workspace/raw/v1/.github/sponsors/crabnebula.svg" alt="CrabNebula" width="283">
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri).
|
For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri).
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
Code: (c) 2015 - Present - The Tauri Programme within The Commons Conservancy.
|
Code: (c) 2015 - Present - The Tauri Programme within The Commons Conservancy.
|
||||||
|
|
||||||
MIT or MIT/Apache 2.0 where applicable.
|
MIT or MIT/Apache 2.0 where applicable.
|
||||||
|
@ -1,87 +1,87 @@
|
|||||||

|

|
||||||
|
|
||||||
<!-- description -->
|
<!-- description -->
|
||||||
|
|
||||||
## Install
|
## Install
|
||||||
|
|
||||||
_This plugin requires a Rust version of at least **1.67**_
|
_This plugin requires a Rust version of at least **1.67**_
|
||||||
|
|
||||||
There are three general methods of installation that we can recommend.
|
There are three general methods of installation that we can recommend.
|
||||||
|
|
||||||
1. Use crates.io and npm (easiest, and requires you to trust that our publishing pipeline worked)
|
1. Use crates.io and npm (easiest, and requires you to trust that our publishing pipeline worked)
|
||||||
2. Pull sources directly from Github using git tags / revision hashes (most secure)
|
2. Pull sources directly from Github using git tags / revision hashes (most secure)
|
||||||
3. Git submodule install this repo in your tauri project and then use file protocol to ingest the source (most secure, but inconvenient to use)
|
3. Git submodule install this repo in your tauri project and then use file protocol to ingest the source (most secure, but inconvenient to use)
|
||||||
|
|
||||||
Install the Core plugin by adding the following to your `Cargo.toml` file:
|
Install the Core plugin by adding the following to your `Cargo.toml` file:
|
||||||
|
|
||||||
`src-tauri/Cargo.toml`
|
`src-tauri/Cargo.toml`
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
[dependencies]
|
[dependencies]
|
||||||
tauri-plugin-websocket = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" }
|
tauri-plugin-websocket = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" }
|
||||||
```
|
```
|
||||||
|
|
||||||
You can install the JavaScript Guest bindings using your preferred JavaScript package manager:
|
You can install the JavaScript Guest bindings using your preferred JavaScript package manager:
|
||||||
|
|
||||||
> Note: Since most JavaScript package managers are unable to install packages from git monorepos we provide read-only mirrors of each plugin. This makes installation option 2 more ergonomic to use.
|
> Note: Since most JavaScript package managers are unable to install packages from git monorepos we provide read-only mirrors of each plugin. This makes installation option 2 more ergonomic to use.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
pnpm add https://github.com/tauri-apps/tauri-plugin-websocket#v1
|
pnpm add https://github.com/tauri-apps/tauri-plugin-websocket#v1
|
||||||
# or
|
# or
|
||||||
npm add https://github.com/tauri-apps/tauri-plugin-websocket#v1
|
npm add https://github.com/tauri-apps/tauri-plugin-websocket#v1
|
||||||
# or
|
# or
|
||||||
yarn add https://github.com/tauri-apps/tauri-plugin-websocket#v1
|
yarn add https://github.com/tauri-apps/tauri-plugin-websocket#v1
|
||||||
```
|
```
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
First you need to register the core plugin with Tauri:
|
First you need to register the core plugin with Tauri:
|
||||||
|
|
||||||
`src-tauri/src/main.rs`
|
`src-tauri/src/main.rs`
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
fn main() {
|
fn main() {
|
||||||
tauri::Builder::default()
|
tauri::Builder::default()
|
||||||
.plugin(tauri_plugin_websocket::init())
|
.plugin(tauri_plugin_websocket::init())
|
||||||
.run(tauri::generate_context!())
|
.run(tauri::generate_context!())
|
||||||
.expect("error while running tauri application");
|
.expect("error while running tauri application");
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Afterwards all the plugin's APIs are available through the JavaScript guest bindings:
|
Afterwards all the plugin's APIs are available through the JavaScript guest bindings:
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
import WebSocket from "tauri-plugin-websocket-api";
|
import WebSocket from "tauri-plugin-websocket-api";
|
||||||
|
|
||||||
const ws = await WebSocket.connect("wss://example.com");
|
const ws = await WebSocket.connect("wss://example.com");
|
||||||
|
|
||||||
await ws.send("Hello World");
|
await ws.send("Hello World");
|
||||||
|
|
||||||
await ws.disconnect();
|
await ws.disconnect();
|
||||||
```
|
```
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
PRs accepted. Please make sure to read the Contributing Guide before making a pull request.
|
PRs accepted. Please make sure to read the Contributing Guide before making a pull request.
|
||||||
|
|
||||||
## Partners
|
## Partners
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td align="center" valign="middle">
|
<td align="center" valign="middle">
|
||||||
<a href="https://crabnebula.dev" target="_blank">
|
<a href="https://crabnebula.dev" target="_blank">
|
||||||
<img src="https://github.com/tauri-apps/plugins-workspace/raw/v1/.github/sponsors/crabnebula.svg" alt="CrabNebula" width="283">
|
<img src="https://github.com/tauri-apps/plugins-workspace/raw/v1/.github/sponsors/crabnebula.svg" alt="CrabNebula" width="283">
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri).
|
For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri).
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
Code: (c) 2015 - Present - The Tauri Programme within The Commons Conservancy.
|
Code: (c) 2015 - Present - The Tauri Programme within The Commons Conservancy.
|
||||||
|
|
||||||
MIT or MIT/Apache 2.0 where applicable.
|
MIT or MIT/Apache 2.0 where applicable.
|
||||||
|
@ -1,111 +1,111 @@
|
|||||||

|

|
||||||
|
|
||||||
Save window positions and sizes and restore them when the app is reopened.
|
Save window positions and sizes and restore them when the app is reopened.
|
||||||
|
|
||||||
## Install
|
## Install
|
||||||
|
|
||||||
_This plugin requires a Rust version of at least **1.67**_
|
_This plugin requires a Rust version of at least **1.67**_
|
||||||
|
|
||||||
There are three general methods of installation that we can recommend.
|
There are three general methods of installation that we can recommend.
|
||||||
|
|
||||||
1. Use crates.io and npm (easiest, and requires you to trust that our publishing pipeline worked)
|
1. Use crates.io and npm (easiest, and requires you to trust that our publishing pipeline worked)
|
||||||
2. Pull sources directly from Github using git tags / revision hashes (most secure)
|
2. Pull sources directly from Github using git tags / revision hashes (most secure)
|
||||||
3. Git submodule install this repo in your tauri project and then use file protocol to ingest the source (most secure, but inconvenient to use)
|
3. Git submodule install this repo in your tauri project and then use file protocol to ingest the source (most secure, but inconvenient to use)
|
||||||
|
|
||||||
Install the Core plugin by adding the following to your `Cargo.toml` file:
|
Install the Core plugin by adding the following to your `Cargo.toml` file:
|
||||||
|
|
||||||
`src-tauri/Cargo.toml`
|
`src-tauri/Cargo.toml`
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
[dependencies]
|
[dependencies]
|
||||||
tauri-plugin-window-state = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" }
|
tauri-plugin-window-state = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" }
|
||||||
```
|
```
|
||||||
|
|
||||||
You can install the JavaScript Guest bindings using your preferred JavaScript package manager:
|
You can install the JavaScript Guest bindings using your preferred JavaScript package manager:
|
||||||
|
|
||||||
> Note: Since most JavaScript package managers are unable to install packages from git monorepos we provide read-only mirrors of each plugin. This makes installation option 2 more ergonomic to use.
|
> Note: Since most JavaScript package managers are unable to install packages from git monorepos we provide read-only mirrors of each plugin. This makes installation option 2 more ergonomic to use.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
pnpm add https://github.com/tauri-apps/tauri-plugin-window-state#v1
|
pnpm add https://github.com/tauri-apps/tauri-plugin-window-state#v1
|
||||||
# or
|
# or
|
||||||
npm add https://github.com/tauri-apps/tauri-plugin-window-state#v1
|
npm add https://github.com/tauri-apps/tauri-plugin-window-state#v1
|
||||||
# or
|
# or
|
||||||
yarn add https://github.com/tauri-apps/tauri-plugin-window-state#v1
|
yarn add https://github.com/tauri-apps/tauri-plugin-window-state#v1
|
||||||
```
|
```
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
First you need to register the core plugin with Tauri:
|
First you need to register the core plugin with Tauri:
|
||||||
|
|
||||||
`src-tauri/src/main.rs`
|
`src-tauri/src/main.rs`
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
fn main() {
|
fn main() {
|
||||||
tauri::Builder::default()
|
tauri::Builder::default()
|
||||||
.plugin(tauri_plugin_window_state::Builder::default().build())
|
.plugin(tauri_plugin_window_state::Builder::default().build())
|
||||||
.run(tauri::generate_context!())
|
.run(tauri::generate_context!())
|
||||||
.expect("error while running tauri application");
|
.expect("error while running tauri application");
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Afterwards all windows will remember their state when the app is being closed and will restore to their previous state on the next launch.
|
Afterwards all windows will remember their state when the app is being closed and will restore to their previous state on the next launch.
|
||||||
|
|
||||||
Optionally you can also tell the plugin to save the state of all open window to disk by using the `save_window_state()` method exposed by the `AppHandleExt` trait:
|
Optionally you can also tell the plugin to save the state of all open window to disk by using the `save_window_state()` method exposed by the `AppHandleExt` trait:
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
use tauri_plugin_window_state::{AppHandleExt, StateFlags};
|
use tauri_plugin_window_state::{AppHandleExt, StateFlags};
|
||||||
|
|
||||||
// `tauri::AppHandle` now has the following additional method
|
// `tauri::AppHandle` now has the following additional method
|
||||||
app.save_window_state(StateFlags::all()); // will save the state of all open windows to disk
|
app.save_window_state(StateFlags::all()); // will save the state of all open windows to disk
|
||||||
```
|
```
|
||||||
|
|
||||||
or through Javascript
|
or through Javascript
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
import { saveWindowState, StateFlags } from "tauri-plugin-window-state-api";
|
import { saveWindowState, StateFlags } from "tauri-plugin-window-state-api";
|
||||||
|
|
||||||
saveWindowState(StateFlags.ALL);
|
saveWindowState(StateFlags.ALL);
|
||||||
```
|
```
|
||||||
|
|
||||||
To manually restore a windows state from disk you can call the `restore_state()` method exposed by the `WindowExt` trait:
|
To manually restore a windows state from disk you can call the `restore_state()` method exposed by the `WindowExt` trait:
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
use tauri_plugin_window_state::{WindowExt, StateFlags};
|
use tauri_plugin_window_state::{WindowExt, StateFlags};
|
||||||
|
|
||||||
// all `Window` types now have the following additional method
|
// all `Window` types now have the following additional method
|
||||||
window.restore_state(StateFlags::all()); // will restore the windows state from disk
|
window.restore_state(StateFlags::all()); // will restore the windows state from disk
|
||||||
```
|
```
|
||||||
|
|
||||||
or through Javascript
|
or through Javascript
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
import { restoreStateCurrent, StateFlags } from "tauri-plugin-window-state-api";
|
import { restoreStateCurrent, StateFlags } from "tauri-plugin-window-state-api";
|
||||||
|
|
||||||
restoreStateCurrent(StateFlags.ALL);
|
restoreStateCurrent(StateFlags.ALL);
|
||||||
```
|
```
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
PRs accepted. Please make sure to read the Contributing Guide before making a pull request.
|
PRs accepted. Please make sure to read the Contributing Guide before making a pull request.
|
||||||
|
|
||||||
## Partners
|
## Partners
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td align="center" valign="middle">
|
<td align="center" valign="middle">
|
||||||
<a href="https://crabnebula.dev" target="_blank">
|
<a href="https://crabnebula.dev" target="_blank">
|
||||||
<img src="https://github.com/tauri-apps/plugins-workspace/raw/v1/.github/sponsors/crabnebula.svg" alt="CrabNebula" width="283">
|
<img src="https://github.com/tauri-apps/plugins-workspace/raw/v1/.github/sponsors/crabnebula.svg" alt="CrabNebula" width="283">
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri).
|
For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri).
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
Code: (c) 2015 - Present - The Tauri Programme within The Commons Conservancy.
|
Code: (c) 2015 - Present - The Tauri Programme within The Commons Conservancy.
|
||||||
|
|
||||||
MIT or MIT/Apache 2.0 where applicable.
|
MIT or MIT/Apache 2.0 where applicable.
|
||||||
|
@ -1,83 +1,83 @@
|
|||||||

|

|
||||||
|
|
||||||
<!-- description -->
|
<!-- description -->
|
||||||
|
|
||||||
## Install
|
## Install
|
||||||
|
|
||||||
_This plugin requires a Rust version of at least **1.67**_
|
_This plugin requires a Rust version of at least **1.67**_
|
||||||
|
|
||||||
There are three general methods of installation that we can recommend.
|
There are three general methods of installation that we can recommend.
|
||||||
|
|
||||||
1. Use crates.io and npm (easiest, and requires you to trust that our publishing pipeline worked)
|
1. Use crates.io and npm (easiest, and requires you to trust that our publishing pipeline worked)
|
||||||
2. Pull sources directly from Github using git tags / revision hashes (most secure)
|
2. Pull sources directly from Github using git tags / revision hashes (most secure)
|
||||||
3. Git submodule install this repo in your tauri project and then use file protocol to ingest the source (most secure, but inconvenient to use)
|
3. Git submodule install this repo in your tauri project and then use file protocol to ingest the source (most secure, but inconvenient to use)
|
||||||
|
|
||||||
Install the Core plugin by adding the following to your `Cargo.toml` file:
|
Install the Core plugin by adding the following to your `Cargo.toml` file:
|
||||||
|
|
||||||
`src-tauri/Cargo.toml`
|
`src-tauri/Cargo.toml`
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
[dependencies]
|
[dependencies]
|
||||||
<!-- plugin here --> = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" }
|
<!-- plugin here --> = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" }
|
||||||
```
|
```
|
||||||
|
|
||||||
You can install the JavaScript Guest bindings using your preferred JavaScript package manager:
|
You can install the JavaScript Guest bindings using your preferred JavaScript package manager:
|
||||||
|
|
||||||
> Note: Since most JavaScript package managers are unable to install packages from git monorepos we provide read-only mirrors of each plugin. This makes installation option 2 more ergonomic to use.
|
> Note: Since most JavaScript package managers are unable to install packages from git monorepos we provide read-only mirrors of each plugin. This makes installation option 2 more ergonomic to use.
|
||||||
|
|
||||||
<!-- Add the branch for installations using git! -->
|
<!-- Add the branch for installations using git! -->
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
pnpm add <!-- plugin here -->
|
pnpm add <!-- plugin here -->
|
||||||
# or
|
# or
|
||||||
npm add <!-- plugin here -->
|
npm add <!-- plugin here -->
|
||||||
# or
|
# or
|
||||||
yarn add <!-- plugin here -->
|
yarn add <!-- plugin here -->
|
||||||
```
|
```
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
First you need to register the core plugin with Tauri:
|
First you need to register the core plugin with Tauri:
|
||||||
|
|
||||||
`src-tauri/src/main.rs`
|
`src-tauri/src/main.rs`
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
fn main() {
|
fn main() {
|
||||||
tauri::Builder::default()
|
tauri::Builder::default()
|
||||||
.plugin(<!-- plugin here -->)
|
.plugin(<!-- plugin here -->)
|
||||||
.run(tauri::generate_context!())
|
.run(tauri::generate_context!())
|
||||||
.expect("error while running tauri application");
|
.expect("error while running tauri application");
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Afterwards all the plugin's APIs are available through the JavaScript guest bindings:
|
Afterwards all the plugin's APIs are available through the JavaScript guest bindings:
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
PRs accepted. Please make sure to read the Contributing Guide before making a pull request.
|
PRs accepted. Please make sure to read the Contributing Guide before making a pull request.
|
||||||
|
|
||||||
## Partners
|
## Partners
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td align="center" valign="middle">
|
<td align="center" valign="middle">
|
||||||
<a href="https://crabnebula.dev" target="_blank">
|
<a href="https://crabnebula.dev" target="_blank">
|
||||||
<img src="https://github.com/tauri-apps/plugins-workspace/raw/v1/.github/sponsors/crabnebula.svg" alt="CrabNebula" width="283">
|
<img src="https://github.com/tauri-apps/plugins-workspace/raw/v1/.github/sponsors/crabnebula.svg" alt="CrabNebula" width="283">
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri).
|
For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri).
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
Code: (c) 2015 - Present - The Tauri Programme within The Commons Conservancy.
|
Code: (c) 2015 - Present - The Tauri Programme within The Commons Conservancy.
|
||||||
|
|
||||||
MIT or MIT/Apache 2.0 where applicable.
|
MIT or MIT/Apache 2.0 where applicable.
|
||||||
|
Loading…
Reference in new issue