fix(deps): update rust crate sqlx to 0.8 [security] (v1) (#1687)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: FabianLars <fabianlars@fabianlars.de>pull/1601/head
parent
64e42b23bf
commit
20d2f5448b
@ -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 and libudev for [authenticator]
|
- name: install webkit2gtk and libudev for [authenticator]
|
||||||
run: |
|
run: |
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install -y libwebkit2gtk-4.0-dev libwebkit2gtk-4.1-dev libudev-dev
|
sudo apt-get install -y libwebkit2gtk-4.0-dev libwebkit2gtk-4.1-dev libudev-dev
|
||||||
|
|
||||||
- uses: dtolnay/rust-toolchain@1.64.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.65.0
|
- 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,37 +1,37 @@
|
|||||||
## Plugins Found Here
|
## Plugins Found Here
|
||||||
|
|
||||||
| | | Win | Mac | Lin | iOS | And |
|
| | | Win | Mac | Lin | iOS | And |
|
||||||
| ------------------------------------------ | --------------------------------------------------------- | --- | --- | --- | --- | --- |
|
| ------------------------------------------ | --------------------------------------------------------- | --- | --- | --- | --- | --- |
|
||||||
| [authenticator](plugins/authenticator) | Interface with hardware security keys. | ✅ | ✅ | ✅ | ? | ? |
|
| [authenticator](plugins/authenticator) | Interface with hardware security keys. | ✅ | ✅ | ✅ | ? | ? |
|
||||||
| [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.64**_
|
_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,126 +1,126 @@
|
|||||||

|

|
||||||
|
|
||||||
Use hardware security-keys in your Tauri App.
|
Use hardware security-keys in your Tauri App.
|
||||||
|
|
||||||
## Install
|
## Install
|
||||||
|
|
||||||
_This plugin requires a Rust version of at least **1.64**_
|
_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 the 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 the file protocol to ingest the source (most secure, but inconvenient to use)
|
||||||
|
|
||||||
Install the authenticator plugin by adding the following lines to your `Cargo.toml` file:
|
Install the authenticator plugin by adding the following lines to your `Cargo.toml` file:
|
||||||
|
|
||||||
`src-tauri/Cargo.toml`
|
`src-tauri/Cargo.toml`
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
[dependencies]
|
[dependencies]
|
||||||
tauri-plugin-authenticator = "0.1"
|
tauri-plugin-authenticator = "0.1"
|
||||||
# or through git
|
# or through git
|
||||||
tauri-plugin-authenticator = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" }
|
tauri-plugin-authenticator = { 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-authenticator#v1
|
pnpm add https://github.com/tauri-apps/tauri-plugin-authenticator#v1
|
||||||
# or
|
# or
|
||||||
npm add https://github.com/tauri-apps/tauri-plugin-authenticator#v1
|
npm add https://github.com/tauri-apps/tauri-plugin-authenticator#v1
|
||||||
# or
|
# or
|
||||||
yarn add https://github.com/tauri-apps/tauri-plugin-authenticator#v1
|
yarn add https://github.com/tauri-apps/tauri-plugin-authenticator#v1
|
||||||
```
|
```
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
First, you need to register the authenticator plugin with Tauri:
|
First, you need to register the authenticator 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_authenticator::init())
|
.plugin(tauri_plugin_authenticator::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 { Authenticator } from "tauri-plugin-authenticator-api";
|
import { Authenticator } from "tauri-plugin-authenticator-api";
|
||||||
|
|
||||||
const auth = new Authenticator();
|
const auth = new Authenticator();
|
||||||
auth.init(); // initialize transports
|
auth.init(); // initialize transports
|
||||||
|
|
||||||
// generate a 32-bytes long random challenge
|
// generate a 32-bytes long random challenge
|
||||||
const arr = new Uint32Array(32);
|
const arr = new Uint32Array(32);
|
||||||
window.crypto.getRandomValues(arr);
|
window.crypto.getRandomValues(arr);
|
||||||
const b64 = btoa(String.fromCharCode.apply(null, arr));
|
const b64 = btoa(String.fromCharCode.apply(null, arr));
|
||||||
// web-safe base64
|
// web-safe base64
|
||||||
const challenge = b64.replace(/\+/g, "-").replace(/\//g, "_");
|
const challenge = b64.replace(/\+/g, "-").replace(/\//g, "_");
|
||||||
|
|
||||||
const domain = "https://tauri.app";
|
const domain = "https://tauri.app";
|
||||||
|
|
||||||
// attempt to register with the security key
|
// attempt to register with the security key
|
||||||
const json = await auth.register(challenge, domain);
|
const json = await auth.register(challenge, domain);
|
||||||
const registerResult = JSON.parse(json);
|
const registerResult = JSON.parse(json);
|
||||||
|
|
||||||
// verify the registration was successful
|
// verify the registration was successful
|
||||||
const r2 = await auth.verifyRegistration(
|
const r2 = await auth.verifyRegistration(
|
||||||
challenge,
|
challenge,
|
||||||
app,
|
app,
|
||||||
registerResult.registerData,
|
registerResult.registerData,
|
||||||
registerResult.clientData,
|
registerResult.clientData,
|
||||||
);
|
);
|
||||||
const j2 = JSON.parse(r2);
|
const j2 = JSON.parse(r2);
|
||||||
|
|
||||||
// sign some data
|
// sign some data
|
||||||
const json = await auth.sign(challenge, app, keyHandle);
|
const json = await auth.sign(challenge, app, keyHandle);
|
||||||
const signData = JSON.parse(json);
|
const signData = JSON.parse(json);
|
||||||
|
|
||||||
// verify the signature again
|
// verify the signature again
|
||||||
const counter = await auth.verifySignature(
|
const counter = await auth.verifySignature(
|
||||||
challenge,
|
challenge,
|
||||||
app,
|
app,
|
||||||
signData.signData,
|
signData.signData,
|
||||||
clientData,
|
clientData,
|
||||||
keyHandle,
|
keyHandle,
|
||||||
pubkey,
|
pubkey,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (counter && counter > 0) {
|
if (counter && counter > 0) {
|
||||||
console.log("SUCCESS!");
|
console.log("SUCCESS!");
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
## 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,54 +1,55 @@
|
|||||||
// Copyright 2021 Flavio Oliveira
|
// Copyright 2021 Flavio Oliveira
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
// As defined by FIDO U2F Javascript API.
|
// As defined by FIDO U2F Javascript API.
|
||||||
// https://fidoalliance.org/specs/fido-u2f-v1.0-nfc-bt-amendment-20150514/fido-u2f-javascript-api.html#registration
|
// https://fidoalliance.org/specs/fido-u2f-v1.0-nfc-bt-amendment-20150514/fido-u2f-javascript-api.html#registration
|
||||||
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct U2fRegisterRequest {
|
pub struct U2fRegisterRequest {
|
||||||
pub app_id: String,
|
pub app_id: String,
|
||||||
pub register_requests: Vec<RegisterRequest>,
|
pub register_requests: Vec<RegisterRequest>,
|
||||||
pub registered_keys: Vec<RegisteredKey>,
|
pub registered_keys: Vec<RegisteredKey>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
pub struct RegisterRequest {
|
pub struct RegisterRequest {
|
||||||
pub version: String,
|
pub version: String,
|
||||||
pub challenge: String,
|
pub challenge: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct RegisteredKey {
|
pub struct RegisteredKey {
|
||||||
pub version: String,
|
pub version: String,
|
||||||
pub key_handle: Option<String>,
|
pub key_handle: Option<String>,
|
||||||
pub app_id: String,
|
pub app_id: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct RegisterResponse {
|
pub struct RegisterResponse {
|
||||||
pub registration_data: String,
|
pub registration_data: String,
|
||||||
pub version: String,
|
#[allow(dead_code)]
|
||||||
pub client_data: String,
|
pub version: String,
|
||||||
}
|
pub client_data: String,
|
||||||
|
}
|
||||||
#[derive(Serialize)]
|
|
||||||
#[serde(rename_all = "camelCase")]
|
#[derive(Serialize)]
|
||||||
pub struct U2fSignRequest {
|
#[serde(rename_all = "camelCase")]
|
||||||
pub app_id: String,
|
pub struct U2fSignRequest {
|
||||||
pub challenge: String,
|
pub app_id: String,
|
||||||
pub registered_keys: Vec<RegisteredKey>,
|
pub challenge: String,
|
||||||
}
|
pub registered_keys: Vec<RegisteredKey>,
|
||||||
|
}
|
||||||
#[derive(Clone, Deserialize)]
|
|
||||||
#[serde(rename_all = "camelCase")]
|
#[derive(Clone, Deserialize)]
|
||||||
pub struct SignResponse {
|
#[serde(rename_all = "camelCase")]
|
||||||
pub key_handle: String,
|
pub struct SignResponse {
|
||||||
pub signature_data: String,
|
pub key_handle: String,
|
||||||
pub client_data: String,
|
pub signature_data: String,
|
||||||
}
|
pub client_data: String,
|
||||||
|
}
|
||||||
|
@ -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.64**_
|
_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.64**_
|
_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.64**_
|
_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.64**_
|
_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.64!
|
- 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.64**_
|
_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.64**_
|
_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.64**_
|
_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,12 +1,10 @@
|
|||||||
#![cfg(target_os = "macos")]
|
use crate::SingleInstanceCallback;
|
||||||
|
use tauri::{
|
||||||
use crate::SingleInstanceCallback;
|
plugin::{self, TauriPlugin},
|
||||||
use tauri::{
|
Manager, Runtime,
|
||||||
plugin::{self, TauriPlugin},
|
};
|
||||||
Manager, Runtime,
|
pub fn init<R: Runtime>(_f: Box<SingleInstanceCallback<R>>) -> TauriPlugin<R> {
|
||||||
};
|
plugin::Builder::new("single-instance").build()
|
||||||
pub fn init<R: Runtime>(_f: Box<SingleInstanceCallback<R>>) -> TauriPlugin<R> {
|
}
|
||||||
plugin::Builder::new("single-instance").build()
|
|
||||||
}
|
pub fn destroy<R: Runtime, M: Manager<R>>(_manager: &M) {}
|
||||||
|
|
||||||
pub fn destroy<R: Runtime, M: Manager<R>>(_manager: &M) {}
|
|
||||||
|
@ -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.65**_
|
_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,336 +1,337 @@
|
|||||||
// Copyright 2021 Tauri Programme within The Commons Conservancy
|
// Copyright 2021 Tauri Programme within The Commons Conservancy
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
use futures_core::future::BoxFuture;
|
use futures_core::future::BoxFuture;
|
||||||
use serde::{ser::Serializer, Deserialize, Serialize};
|
use serde::{ser::Serializer, Deserialize, Serialize};
|
||||||
use serde_json::Value as JsonValue;
|
use serde_json::Value as JsonValue;
|
||||||
use sqlx::{
|
use sqlx::{
|
||||||
error::BoxDynError,
|
error::BoxDynError,
|
||||||
migrate::{
|
migrate::{
|
||||||
MigrateDatabase, Migration as SqlxMigration, MigrationSource, MigrationType, Migrator,
|
MigrateDatabase, Migration as SqlxMigration, MigrationSource, MigrationType, Migrator,
|
||||||
},
|
},
|
||||||
Column, Pool, Row,
|
Column, Pool, Row,
|
||||||
};
|
};
|
||||||
use tauri::{
|
use tauri::{
|
||||||
command,
|
command,
|
||||||
plugin::{Builder as PluginBuilder, TauriPlugin},
|
plugin::{Builder as PluginBuilder, TauriPlugin},
|
||||||
AppHandle, Manager, RunEvent, Runtime, State,
|
AppHandle, Manager, RunEvent, Runtime, State,
|
||||||
};
|
};
|
||||||
use tokio::sync::Mutex;
|
use tokio::sync::Mutex;
|
||||||
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
#[cfg(feature = "sqlite")]
|
#[cfg(feature = "sqlite")]
|
||||||
use std::{fs::create_dir_all, path::PathBuf};
|
use std::{fs::create_dir_all, path::PathBuf};
|
||||||
|
|
||||||
#[cfg(feature = "sqlite")]
|
#[cfg(feature = "sqlite")]
|
||||||
type Db = sqlx::sqlite::Sqlite;
|
type Db = sqlx::sqlite::Sqlite;
|
||||||
#[cfg(feature = "mysql")]
|
#[cfg(feature = "mysql")]
|
||||||
type Db = sqlx::mysql::MySql;
|
type Db = sqlx::mysql::MySql;
|
||||||
#[cfg(feature = "postgres")]
|
#[cfg(feature = "postgres")]
|
||||||
type Db = sqlx::postgres::Postgres;
|
type Db = sqlx::postgres::Postgres;
|
||||||
|
|
||||||
#[cfg(feature = "sqlite")]
|
#[cfg(feature = "sqlite")]
|
||||||
type LastInsertId = i64;
|
type LastInsertId = i64;
|
||||||
#[cfg(not(feature = "sqlite"))]
|
#[cfg(not(feature = "sqlite"))]
|
||||||
type LastInsertId = u64;
|
type LastInsertId = u64;
|
||||||
|
|
||||||
#[derive(Debug, thiserror::Error)]
|
#[derive(Debug, thiserror::Error)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
Sql(#[from] sqlx::Error),
|
Sql(#[from] sqlx::Error),
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
Migration(#[from] sqlx::migrate::MigrateError),
|
Migration(#[from] sqlx::migrate::MigrateError),
|
||||||
#[error("database {0} not loaded")]
|
#[error("database {0} not loaded")]
|
||||||
DatabaseNotLoaded(String),
|
DatabaseNotLoaded(String),
|
||||||
#[error("unsupported datatype: {0}")]
|
#[error("unsupported datatype: {0}")]
|
||||||
UnsupportedDatatype(String),
|
UnsupportedDatatype(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Serialize for Error {
|
impl Serialize for Error {
|
||||||
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
|
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
|
||||||
where
|
where
|
||||||
S: Serializer,
|
S: Serializer,
|
||||||
{
|
{
|
||||||
serializer.serialize_str(self.to_string().as_ref())
|
serializer.serialize_str(self.to_string().as_ref())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type Result<T> = std::result::Result<T, Error>;
|
type Result<T> = std::result::Result<T, Error>;
|
||||||
|
|
||||||
#[cfg(feature = "sqlite")]
|
#[cfg(feature = "sqlite")]
|
||||||
/// Resolves the App's **file path** from the `AppHandle` context
|
/// Resolves the App's **file path** from the `AppHandle` context
|
||||||
/// object
|
/// object
|
||||||
fn app_path<R: Runtime>(app: &AppHandle<R>) -> PathBuf {
|
fn app_path<R: Runtime>(app: &AppHandle<R>) -> PathBuf {
|
||||||
#[allow(deprecated)] // FIXME: Change to non-deprecated function in Tauri v2
|
#[allow(deprecated)] // FIXME: Change to non-deprecated function in Tauri v2
|
||||||
app.path_resolver()
|
app.path_resolver()
|
||||||
.app_dir()
|
.app_dir()
|
||||||
.expect("No App path was found!")
|
.expect("No App path was found!")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "sqlite")]
|
#[cfg(feature = "sqlite")]
|
||||||
/// Maps the user supplied DB connection string to a connection string
|
/// Maps the user supplied DB connection string to a connection string
|
||||||
/// with a fully qualified file path to the App's designed "app_path"
|
/// with a fully qualified file path to the App's designed "app_path"
|
||||||
fn path_mapper(mut app_path: PathBuf, connection_string: &str) -> String {
|
fn path_mapper(mut app_path: PathBuf, connection_string: &str) -> String {
|
||||||
app_path.push(
|
app_path.push(
|
||||||
connection_string
|
connection_string
|
||||||
.split_once(':')
|
.split_once(':')
|
||||||
.expect("Couldn't parse the connection string for DB!")
|
.expect("Couldn't parse the connection string for DB!")
|
||||||
.1,
|
.1,
|
||||||
);
|
);
|
||||||
|
|
||||||
format!(
|
format!(
|
||||||
"sqlite:{}",
|
"sqlite:{}",
|
||||||
app_path
|
app_path
|
||||||
.to_str()
|
.to_str()
|
||||||
.expect("Problem creating fully qualified path to Database file!")
|
.expect("Problem creating fully qualified path to Database file!")
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
struct DbInstances(Mutex<HashMap<String, Pool<Db>>>);
|
struct DbInstances(Mutex<HashMap<String, Pool<Db>>>);
|
||||||
|
|
||||||
struct Migrations(Mutex<HashMap<String, MigrationList>>);
|
struct Migrations(Mutex<HashMap<String, MigrationList>>);
|
||||||
|
|
||||||
#[derive(Default, Deserialize)]
|
#[derive(Default, Deserialize)]
|
||||||
pub struct PluginConfig {
|
pub struct PluginConfig {
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
preload: Vec<String>,
|
preload: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum MigrationKind {
|
pub enum MigrationKind {
|
||||||
Up,
|
Up,
|
||||||
Down,
|
Down,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<MigrationKind> for MigrationType {
|
impl From<MigrationKind> for MigrationType {
|
||||||
fn from(kind: MigrationKind) -> Self {
|
fn from(kind: MigrationKind) -> Self {
|
||||||
match kind {
|
match kind {
|
||||||
MigrationKind::Up => Self::ReversibleUp,
|
MigrationKind::Up => Self::ReversibleUp,
|
||||||
MigrationKind::Down => Self::ReversibleDown,
|
MigrationKind::Down => Self::ReversibleDown,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A migration definition.
|
/// A migration definition.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Migration {
|
pub struct Migration {
|
||||||
pub version: i64,
|
pub version: i64,
|
||||||
pub description: &'static str,
|
pub description: &'static str,
|
||||||
pub sql: &'static str,
|
pub sql: &'static str,
|
||||||
pub kind: MigrationKind,
|
pub kind: MigrationKind,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
struct MigrationList(Vec<Migration>);
|
struct MigrationList(Vec<Migration>);
|
||||||
|
|
||||||
impl MigrationSource<'static> for MigrationList {
|
impl MigrationSource<'static> for MigrationList {
|
||||||
fn resolve(self) -> BoxFuture<'static, std::result::Result<Vec<SqlxMigration>, BoxDynError>> {
|
fn resolve(self) -> BoxFuture<'static, std::result::Result<Vec<SqlxMigration>, BoxDynError>> {
|
||||||
Box::pin(async move {
|
Box::pin(async move {
|
||||||
let mut migrations = Vec::new();
|
let mut migrations = Vec::new();
|
||||||
for migration in self.0 {
|
for migration in self.0 {
|
||||||
if matches!(migration.kind, MigrationKind::Up) {
|
if matches!(migration.kind, MigrationKind::Up) {
|
||||||
migrations.push(SqlxMigration::new(
|
migrations.push(SqlxMigration::new(
|
||||||
migration.version,
|
migration.version,
|
||||||
migration.description.into(),
|
migration.description.into(),
|
||||||
migration.kind.into(),
|
migration.kind.into(),
|
||||||
migration.sql.into(),
|
migration.sql.into(),
|
||||||
));
|
false,
|
||||||
}
|
));
|
||||||
}
|
}
|
||||||
Ok(migrations)
|
}
|
||||||
})
|
Ok(migrations)
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#[command]
|
|
||||||
async fn load<R: Runtime>(
|
#[command]
|
||||||
#[allow(unused_variables)] app: AppHandle<R>,
|
async fn load<R: Runtime>(
|
||||||
db_instances: State<'_, DbInstances>,
|
#[allow(unused_variables)] app: AppHandle<R>,
|
||||||
migrations: State<'_, Migrations>,
|
db_instances: State<'_, DbInstances>,
|
||||||
db: String,
|
migrations: State<'_, Migrations>,
|
||||||
) -> Result<String> {
|
db: String,
|
||||||
#[cfg(feature = "sqlite")]
|
) -> Result<String> {
|
||||||
let fqdb = path_mapper(app_path(&app), &db);
|
#[cfg(feature = "sqlite")]
|
||||||
#[cfg(not(feature = "sqlite"))]
|
let fqdb = path_mapper(app_path(&app), &db);
|
||||||
let fqdb = db.clone();
|
#[cfg(not(feature = "sqlite"))]
|
||||||
|
let fqdb = db.clone();
|
||||||
#[cfg(feature = "sqlite")]
|
|
||||||
create_dir_all(app_path(&app)).expect("Problem creating App directory!");
|
#[cfg(feature = "sqlite")]
|
||||||
|
create_dir_all(app_path(&app)).expect("Problem creating App directory!");
|
||||||
if !Db::database_exists(&fqdb).await.unwrap_or(false) {
|
|
||||||
Db::create_database(&fqdb).await?;
|
if !Db::database_exists(&fqdb).await.unwrap_or(false) {
|
||||||
}
|
Db::create_database(&fqdb).await?;
|
||||||
let pool = Pool::connect(&fqdb).await?;
|
}
|
||||||
|
let pool = Pool::connect(&fqdb).await?;
|
||||||
if let Some(migrations) = migrations.0.lock().await.remove(&db) {
|
|
||||||
let migrator = Migrator::new(migrations).await?;
|
if let Some(migrations) = migrations.0.lock().await.remove(&db) {
|
||||||
migrator.run(&pool).await?;
|
let migrator = Migrator::new(migrations).await?;
|
||||||
}
|
migrator.run(&pool).await?;
|
||||||
|
}
|
||||||
db_instances.0.lock().await.insert(db.clone(), pool);
|
|
||||||
Ok(db)
|
db_instances.0.lock().await.insert(db.clone(), pool);
|
||||||
}
|
Ok(db)
|
||||||
|
}
|
||||||
/// Allows the database connection(s) to be closed; if no database
|
|
||||||
/// name is passed in then _all_ database connection pools will be
|
/// Allows the database connection(s) to be closed; if no database
|
||||||
/// shut down.
|
/// name is passed in then _all_ database connection pools will be
|
||||||
#[command]
|
/// shut down.
|
||||||
async fn close(db_instances: State<'_, DbInstances>, db: Option<String>) -> Result<bool> {
|
#[command]
|
||||||
let mut instances = db_instances.0.lock().await;
|
async fn close(db_instances: State<'_, DbInstances>, db: Option<String>) -> Result<bool> {
|
||||||
|
let mut instances = db_instances.0.lock().await;
|
||||||
let pools = if let Some(db) = db {
|
|
||||||
vec![db]
|
let pools = if let Some(db) = db {
|
||||||
} else {
|
vec![db]
|
||||||
instances.keys().cloned().collect()
|
} else {
|
||||||
};
|
instances.keys().cloned().collect()
|
||||||
|
};
|
||||||
for pool in pools {
|
|
||||||
let db = instances
|
for pool in pools {
|
||||||
.get_mut(&pool) //
|
let db = instances
|
||||||
.ok_or(Error::DatabaseNotLoaded(pool))?;
|
.get_mut(&pool) //
|
||||||
db.close().await;
|
.ok_or(Error::DatabaseNotLoaded(pool))?;
|
||||||
}
|
db.close().await;
|
||||||
|
}
|
||||||
Ok(true)
|
|
||||||
}
|
Ok(true)
|
||||||
|
}
|
||||||
/// Execute a command against the database
|
|
||||||
#[command]
|
/// Execute a command against the database
|
||||||
async fn execute(
|
#[command]
|
||||||
db_instances: State<'_, DbInstances>,
|
async fn execute(
|
||||||
db: String,
|
db_instances: State<'_, DbInstances>,
|
||||||
query: String,
|
db: String,
|
||||||
values: Vec<JsonValue>,
|
query: String,
|
||||||
) -> Result<(u64, LastInsertId)> {
|
values: Vec<JsonValue>,
|
||||||
let mut instances = db_instances.0.lock().await;
|
) -> Result<(u64, LastInsertId)> {
|
||||||
|
let mut instances = db_instances.0.lock().await;
|
||||||
let db = instances.get_mut(&db).ok_or(Error::DatabaseNotLoaded(db))?;
|
|
||||||
let mut query = sqlx::query(&query);
|
let db = instances.get_mut(&db).ok_or(Error::DatabaseNotLoaded(db))?;
|
||||||
for value in values {
|
let mut query = sqlx::query(&query);
|
||||||
if value.is_null() {
|
for value in values {
|
||||||
query = query.bind(None::<JsonValue>);
|
if value.is_null() {
|
||||||
} else if value.is_string() {
|
query = query.bind(None::<JsonValue>);
|
||||||
query = query.bind(value.as_str().unwrap().to_owned())
|
} else if value.is_string() {
|
||||||
} else {
|
query = query.bind(value.as_str().unwrap().to_owned())
|
||||||
query = query.bind(value);
|
} else {
|
||||||
}
|
query = query.bind(value);
|
||||||
}
|
}
|
||||||
let result = query.execute(&*db).await?;
|
}
|
||||||
#[cfg(feature = "sqlite")]
|
let result = query.execute(&*db).await?;
|
||||||
let r = Ok((result.rows_affected(), result.last_insert_rowid()));
|
#[cfg(feature = "sqlite")]
|
||||||
#[cfg(feature = "mysql")]
|
let r = Ok((result.rows_affected(), result.last_insert_rowid()));
|
||||||
let r = Ok((result.rows_affected(), result.last_insert_id()));
|
#[cfg(feature = "mysql")]
|
||||||
#[cfg(feature = "postgres")]
|
let r = Ok((result.rows_affected(), result.last_insert_id()));
|
||||||
let r = Ok((result.rows_affected(), 0));
|
#[cfg(feature = "postgres")]
|
||||||
r
|
let r = Ok((result.rows_affected(), 0));
|
||||||
}
|
r
|
||||||
|
}
|
||||||
#[command]
|
|
||||||
async fn select(
|
#[command]
|
||||||
db_instances: State<'_, DbInstances>,
|
async fn select(
|
||||||
db: String,
|
db_instances: State<'_, DbInstances>,
|
||||||
query: String,
|
db: String,
|
||||||
values: Vec<JsonValue>,
|
query: String,
|
||||||
) -> Result<Vec<HashMap<String, JsonValue>>> {
|
values: Vec<JsonValue>,
|
||||||
let mut instances = db_instances.0.lock().await;
|
) -> Result<Vec<HashMap<String, JsonValue>>> {
|
||||||
let db = instances.get_mut(&db).ok_or(Error::DatabaseNotLoaded(db))?;
|
let mut instances = db_instances.0.lock().await;
|
||||||
let mut query = sqlx::query(&query);
|
let db = instances.get_mut(&db).ok_or(Error::DatabaseNotLoaded(db))?;
|
||||||
for value in values {
|
let mut query = sqlx::query(&query);
|
||||||
if value.is_null() {
|
for value in values {
|
||||||
query = query.bind(None::<JsonValue>);
|
if value.is_null() {
|
||||||
} else if value.is_string() {
|
query = query.bind(None::<JsonValue>);
|
||||||
query = query.bind(value.as_str().unwrap().to_owned())
|
} else if value.is_string() {
|
||||||
} else {
|
query = query.bind(value.as_str().unwrap().to_owned())
|
||||||
query = query.bind(value);
|
} else {
|
||||||
}
|
query = query.bind(value);
|
||||||
}
|
}
|
||||||
let rows = query.fetch_all(&*db).await?;
|
}
|
||||||
let mut values = Vec::new();
|
let rows = query.fetch_all(&*db).await?;
|
||||||
for row in rows {
|
let mut values = Vec::new();
|
||||||
let mut value = HashMap::default();
|
for row in rows {
|
||||||
for (i, column) in row.columns().iter().enumerate() {
|
let mut value = HashMap::default();
|
||||||
let v = row.try_get_raw(i)?;
|
for (i, column) in row.columns().iter().enumerate() {
|
||||||
|
let v = row.try_get_raw(i)?;
|
||||||
let v = crate::decode::to_json(v)?;
|
|
||||||
|
let v = crate::decode::to_json(v)?;
|
||||||
value.insert(column.name().to_string(), v);
|
|
||||||
}
|
value.insert(column.name().to_string(), v);
|
||||||
|
}
|
||||||
values.push(value);
|
|
||||||
}
|
values.push(value);
|
||||||
|
}
|
||||||
Ok(values)
|
|
||||||
}
|
Ok(values)
|
||||||
|
}
|
||||||
/// Tauri SQL plugin builder.
|
|
||||||
#[derive(Default)]
|
/// Tauri SQL plugin builder.
|
||||||
pub struct Builder {
|
#[derive(Default)]
|
||||||
migrations: Option<HashMap<String, MigrationList>>,
|
pub struct Builder {
|
||||||
}
|
migrations: Option<HashMap<String, MigrationList>>,
|
||||||
|
}
|
||||||
impl Builder {
|
|
||||||
/// Add migrations to a database.
|
impl Builder {
|
||||||
#[must_use]
|
/// Add migrations to a database.
|
||||||
pub fn add_migrations(mut self, db_url: &str, migrations: Vec<Migration>) -> Self {
|
#[must_use]
|
||||||
self.migrations
|
pub fn add_migrations(mut self, db_url: &str, migrations: Vec<Migration>) -> Self {
|
||||||
.get_or_insert(Default::default())
|
self.migrations
|
||||||
.insert(db_url.to_string(), MigrationList(migrations));
|
.get_or_insert(Default::default())
|
||||||
self
|
.insert(db_url.to_string(), MigrationList(migrations));
|
||||||
}
|
self
|
||||||
|
}
|
||||||
pub fn build<R: Runtime>(mut self) -> TauriPlugin<R, Option<PluginConfig>> {
|
|
||||||
PluginBuilder::new("sql")
|
pub fn build<R: Runtime>(mut self) -> TauriPlugin<R, Option<PluginConfig>> {
|
||||||
.invoke_handler(tauri::generate_handler![load, execute, select, close])
|
PluginBuilder::new("sql")
|
||||||
.setup_with_config(|app, config: Option<PluginConfig>| {
|
.invoke_handler(tauri::generate_handler![load, execute, select, close])
|
||||||
let config = config.unwrap_or_default();
|
.setup_with_config(|app, config: Option<PluginConfig>| {
|
||||||
|
let config = config.unwrap_or_default();
|
||||||
#[cfg(feature = "sqlite")]
|
|
||||||
create_dir_all(app_path(app)).expect("problems creating App directory!");
|
#[cfg(feature = "sqlite")]
|
||||||
|
create_dir_all(app_path(app)).expect("problems creating App directory!");
|
||||||
tauri::async_runtime::block_on(async move {
|
|
||||||
let instances = DbInstances::default();
|
tauri::async_runtime::block_on(async move {
|
||||||
let mut lock = instances.0.lock().await;
|
let instances = DbInstances::default();
|
||||||
for db in config.preload {
|
let mut lock = instances.0.lock().await;
|
||||||
#[cfg(feature = "sqlite")]
|
for db in config.preload {
|
||||||
let fqdb = path_mapper(app_path(app), &db);
|
#[cfg(feature = "sqlite")]
|
||||||
#[cfg(not(feature = "sqlite"))]
|
let fqdb = path_mapper(app_path(app), &db);
|
||||||
let fqdb = db.clone();
|
#[cfg(not(feature = "sqlite"))]
|
||||||
|
let fqdb = db.clone();
|
||||||
if !Db::database_exists(&fqdb).await.unwrap_or(false) {
|
|
||||||
Db::create_database(&fqdb).await?;
|
if !Db::database_exists(&fqdb).await.unwrap_or(false) {
|
||||||
}
|
Db::create_database(&fqdb).await?;
|
||||||
let pool = Pool::connect(&fqdb).await?;
|
}
|
||||||
|
let pool = Pool::connect(&fqdb).await?;
|
||||||
if let Some(migrations) = self.migrations.as_mut().unwrap().remove(&db) {
|
|
||||||
let migrator = Migrator::new(migrations).await?;
|
if let Some(migrations) = self.migrations.as_mut().unwrap().remove(&db) {
|
||||||
migrator.run(&pool).await?;
|
let migrator = Migrator::new(migrations).await?;
|
||||||
}
|
migrator.run(&pool).await?;
|
||||||
lock.insert(db, pool);
|
}
|
||||||
}
|
lock.insert(db, pool);
|
||||||
drop(lock);
|
}
|
||||||
|
drop(lock);
|
||||||
app.manage(instances);
|
|
||||||
app.manage(Migrations(Mutex::new(
|
app.manage(instances);
|
||||||
self.migrations.take().unwrap_or_default(),
|
app.manage(Migrations(Mutex::new(
|
||||||
)));
|
self.migrations.take().unwrap_or_default(),
|
||||||
|
)));
|
||||||
Ok(())
|
|
||||||
})
|
Ok(())
|
||||||
})
|
})
|
||||||
.on_event(|app, event| {
|
})
|
||||||
if let RunEvent::Exit = event {
|
.on_event(|app, event| {
|
||||||
tauri::async_runtime::block_on(async move {
|
if let RunEvent::Exit = event {
|
||||||
let instances = &*app.state::<DbInstances>();
|
tauri::async_runtime::block_on(async move {
|
||||||
let instances = instances.0.lock().await;
|
let instances = &*app.state::<DbInstances>();
|
||||||
for value in instances.values() {
|
let instances = instances.0.lock().await;
|
||||||
value.close().await;
|
for value in instances.values() {
|
||||||
}
|
value.close().await;
|
||||||
});
|
}
|
||||||
}
|
});
|
||||||
})
|
}
|
||||||
.build()
|
})
|
||||||
}
|
.build()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
@ -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.64**_
|
_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.64**_
|
_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.64**_
|
_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.64**_
|
_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.64**_
|
_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