From 80fbcb50d317184f03fd0e1cea401758c8b05667 Mon Sep 17 00:00:00 2001 From: FabianLars Date: Tue, 3 Sep 2024 10:37:56 +0200 Subject: [PATCH] chore: Run prettier formatting (No visibile changes) --- .github/workflows/msrv-check.yml | 114 ++++----- README.md | 72 +++--- plugins/autostart/README.md | 178 ++++++------- plugins/fs-extra/README.md | 166 ++++++------ plugins/fs-watch/README.md | 196 +++++++------- plugins/localhost/README.md | 180 ++++++------- plugins/persisted-scope/CHANGELOG.md | 34 +-- plugins/persisted-scope/README.md | 130 +++++----- plugins/positioner/README.md | 220 ++++++++-------- plugins/single-instance/README.md | 150 +++++------ plugins/sql/README.md | 368 +++++++++++++-------------- plugins/stronghold/README.md | 304 +++++++++++----------- plugins/upload/README.md | 200 +++++++-------- plugins/websocket/README.md | 174 ++++++------- plugins/window-state/README.md | 222 ++++++++-------- shared/template/README.md | 166 ++++++------ 16 files changed, 1437 insertions(+), 1437 deletions(-) diff --git a/.github/workflows/msrv-check.yml b/.github/workflows/msrv-check.yml index 9370fe12a..ef227fb58 100644 --- a/.github/workflows/msrv-check.yml +++ b/.github/workflows/msrv-check.yml @@ -1,57 +1,57 @@ -name: Check MSRV - -on: - push: - branches: - - v1 - - v2 - paths: - - ".github/workflows/msrv-check.yml" - - "plugins/*/src/**" - - "**/Cargo.toml" - - "**/Cargo.lock" - pull_request: - branches: - - v1 - - v2 - paths: - - ".github/workflows/msrv-check.yml" - - "plugins/*/src/**" - - "**/Cargo.toml" - - "**/Cargo.lock" - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - msrv: - runs-on: ubuntu-latest - strategy: - fail-fast: false - - steps: - - uses: actions/checkout@v3 - - - name: install webkit2gtk - run: | - sudo apt-get update - sudo apt-get install -y libwebkit2gtk-4.0-dev libwebkit2gtk-4.1-dev - - - uses: dtolnay/rust-toolchain@1.67.0 - - - uses: Swatinem/rust-cache@v2 - - - name: build - run: cargo build --workspace --exclude 'tauri-plugin-sql' --all-targets --all-features - - - uses: dtolnay/rust-toolchain@1.80.1 - - - name: build sql:sqlite - run: cargo build --package 'tauri-plugin-sql' --all-targets --features sqlite - - - name: build sql:mysql - run: cargo build --package 'tauri-plugin-sql' --all-targets --features mysql - - - name: build sql:postgres - run: cargo build --package 'tauri-plugin-sql' --all-targets --features postgres +name: Check MSRV + +on: + push: + branches: + - v1 + - v2 + paths: + - ".github/workflows/msrv-check.yml" + - "plugins/*/src/**" + - "**/Cargo.toml" + - "**/Cargo.lock" + pull_request: + branches: + - v1 + - v2 + paths: + - ".github/workflows/msrv-check.yml" + - "plugins/*/src/**" + - "**/Cargo.toml" + - "**/Cargo.lock" + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + msrv: + runs-on: ubuntu-latest + strategy: + fail-fast: false + + steps: + - uses: actions/checkout@v3 + + - name: install webkit2gtk + run: | + sudo apt-get update + sudo apt-get install -y libwebkit2gtk-4.0-dev libwebkit2gtk-4.1-dev + + - uses: dtolnay/rust-toolchain@1.67.0 + + - uses: Swatinem/rust-cache@v2 + + - name: build + run: cargo build --workspace --exclude 'tauri-plugin-sql' --all-targets --all-features + + - uses: dtolnay/rust-toolchain@1.80.1 + + - name: build sql:sqlite + run: cargo build --package 'tauri-plugin-sql' --all-targets --features sqlite + + - name: build sql:mysql + run: cargo build --package 'tauri-plugin-sql' --all-targets --features mysql + + - name: build sql:postgres + run: cargo build --package 'tauri-plugin-sql' --all-targets --features postgres diff --git a/README.md b/README.md index 932e7b1d9..4d4c80f42 100644 --- a/README.md +++ b/README.md @@ -1,36 +1,36 @@ -## Plugins Found Here - -| | | Win | Mac | Lin | iOS | And | -| ------------------------------------------ | --------------------------------------------------------- | --- | --- | --- | --- | --- | -| [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-watch](plugins/fs-watch) | Watch the filesystem for changes. | ✅ | ✅ | ✅ | ? | ? | -| [localhost](plugins/localhost) | Use a localhost server in production apps. | ✅ | ✅ | ✅ | ? | ? | -| [log](plugins/log) | Configurable logging. | ✅ | ✅ | ✅ | ✅ | ✅ | -| [persisted-scope](plugins/persisted-scope) | Persist runtime scope changes on the filesystem. | ✅ | ✅ | ✅ | ? | ? | -| [positioner](plugins/positioner) | Move windows to common locations. | ✅ | ✅ | ✅ | ? | ? | -| [single-instance](plugins/single-instance) | Ensure a single instance of your tauri app is running. | ✅ | ? | ✅ | ? | ? | -| [sql](plugins/sql) | Interface with SQL databases. | ✅ | ✅ | ✅ | ? | ? | -| [store](plugins/store) | Persistent key value storage. | ✅ | ✅ | ✅ | ? | ? | -| [stronghold](plugins/stronghold) | Encrypted, secure database. | ✅ | ✅ | ✅ | ? | ? | -| [upload](plugins/upload) | Tauri plugin for file uploads through HTTP. | ✅ | ✅ | ✅ | ? | ? | -| [websocket](plugins/websocket) | Open a WebSocket connection using a Rust client in JS. | ✅ | ✅ | ✅ | ? | ? | -| [window-state](plugins/window-state) | Persist window sizes and positions. | ✅ | ✅ | ✅ | ? | ? | - -_This repo and all plugins require a Rust version of at least **1.67**_ - -## Partners - - - - - - - -
- - CrabNebula - -
- -For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri). +## Plugins Found Here + +| | | Win | Mac | Lin | iOS | And | +| ------------------------------------------ | --------------------------------------------------------- | --- | --- | --- | --- | --- | +| [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-watch](plugins/fs-watch) | Watch the filesystem for changes. | ✅ | ✅ | ✅ | ? | ? | +| [localhost](plugins/localhost) | Use a localhost server in production apps. | ✅ | ✅ | ✅ | ? | ? | +| [log](plugins/log) | Configurable logging. | ✅ | ✅ | ✅ | ✅ | ✅ | +| [persisted-scope](plugins/persisted-scope) | Persist runtime scope changes on the filesystem. | ✅ | ✅ | ✅ | ? | ? | +| [positioner](plugins/positioner) | Move windows to common locations. | ✅ | ✅ | ✅ | ? | ? | +| [single-instance](plugins/single-instance) | Ensure a single instance of your tauri app is running. | ✅ | ? | ✅ | ? | ? | +| [sql](plugins/sql) | Interface with SQL databases. | ✅ | ✅ | ✅ | ? | ? | +| [store](plugins/store) | Persistent key value storage. | ✅ | ✅ | ✅ | ? | ? | +| [stronghold](plugins/stronghold) | Encrypted, secure database. | ✅ | ✅ | ✅ | ? | ? | +| [upload](plugins/upload) | Tauri plugin for file uploads through HTTP. | ✅ | ✅ | ✅ | ? | ? | +| [websocket](plugins/websocket) | Open a WebSocket connection using a Rust client in JS. | ✅ | ✅ | ✅ | ? | ? | +| [window-state](plugins/window-state) | Persist window sizes and positions. | ✅ | ✅ | ✅ | ? | ? | + +_This repo and all plugins require a Rust version of at least **1.67**_ + +## Partners + + + + + + + +
+ + CrabNebula + +
+ +For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri). diff --git a/plugins/autostart/README.md b/plugins/autostart/README.md index a95dd1cd8..d0965f382 100644 --- a/plugins/autostart/README.md +++ b/plugins/autostart/README.md @@ -1,89 +1,89 @@ -![plugin-autostart](https://github.com/tauri-apps/plugins-workspace/raw/v1/plugins/autostart/banner.png) - -Automatically launch your application at startup. Supports Windows, Mac (via AppleScript or Launch Agent), and Linux. - -## Install - -_This plugin requires a Rust version of at least **1.67**_ - -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) -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) - -Install the Core plugin by adding the following to your `Cargo.toml` file: - -`src-tauri/Cargo.toml` - -```toml -[dependencies] -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: - -> 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 -pnpm add https://github.com/tauri-apps/tauri-plugin-autostart#v1 -# or -npm add https://github.com/tauri-apps/tauri-plugin-autostart#v1 -# or -yarn add https://github.com/tauri-apps/tauri-plugin-autostart#v1 -``` - -## Usage - -First you need to register the core plugin with Tauri: - -`src-tauri/src/main.rs` - -```rust -use tauri_plugin_autostart::MacosLauncher; - -fn main() { - tauri::Builder::default() - .plugin(tauri_plugin_autostart::init(MacosLauncher::LaunchAgent, Some(vec!["--flag1", "--flag2"]) /* arbitrary number of args to pass to your app */)) - .run(tauri::generate_context!()) - .expect("error while running tauri application"); -} -``` - -Afterwards all the plugin's APIs are available through the JavaScript guest bindings: - -```javascript -import { enable, isEnabled, disable } from "tauri-plugin-autostart-api"; - -await enable(); - -console.log(`registered for autostart? ${await isEnabled()}`); - -disable(); -``` - -## Contributing - -PRs accepted. Please make sure to read the Contributing Guide before making a pull request. - -## Partners - - - - - - - -
- - CrabNebula - -
- -For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri). - -## License - -Code: (c) 2015 - Present - The Tauri Programme within The Commons Conservancy. - -MIT or MIT/Apache 2.0 where applicable. +![plugin-autostart](https://github.com/tauri-apps/plugins-workspace/raw/v1/plugins/autostart/banner.png) + +Automatically launch your application at startup. Supports Windows, Mac (via AppleScript or Launch Agent), and Linux. + +## Install + +_This plugin requires a Rust version of at least **1.67**_ + +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) +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) + +Install the Core plugin by adding the following to your `Cargo.toml` file: + +`src-tauri/Cargo.toml` + +```toml +[dependencies] +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: + +> 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 +pnpm add https://github.com/tauri-apps/tauri-plugin-autostart#v1 +# or +npm add https://github.com/tauri-apps/tauri-plugin-autostart#v1 +# or +yarn add https://github.com/tauri-apps/tauri-plugin-autostart#v1 +``` + +## Usage + +First you need to register the core plugin with Tauri: + +`src-tauri/src/main.rs` + +```rust +use tauri_plugin_autostart::MacosLauncher; + +fn main() { + tauri::Builder::default() + .plugin(tauri_plugin_autostart::init(MacosLauncher::LaunchAgent, Some(vec!["--flag1", "--flag2"]) /* arbitrary number of args to pass to your app */)) + .run(tauri::generate_context!()) + .expect("error while running tauri application"); +} +``` + +Afterwards all the plugin's APIs are available through the JavaScript guest bindings: + +```javascript +import { enable, isEnabled, disable } from "tauri-plugin-autostart-api"; + +await enable(); + +console.log(`registered for autostart? ${await isEnabled()}`); + +disable(); +``` + +## Contributing + +PRs accepted. Please make sure to read the Contributing Guide before making a pull request. + +## Partners + + + + + + + +
+ + CrabNebula + +
+ +For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri). + +## License + +Code: (c) 2015 - Present - The Tauri Programme within The Commons Conservancy. + +MIT or MIT/Apache 2.0 where applicable. diff --git a/plugins/fs-extra/README.md b/plugins/fs-extra/README.md index e4cc66b87..70ff9baf9 100644 --- a/plugins/fs-extra/README.md +++ b/plugins/fs-extra/README.md @@ -1,83 +1,83 @@ -![plugin-fs-extra](https://github.com/tauri-apps/plugins-workspace/raw/v1/plugins/fs-extra/banner.png) - -Additional file system methods not included in the core API. - -## Install - -_This plugin requires a Rust version of at least **1.67**_ - -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) -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) - -Install the Core plugin by adding the following to your `Cargo.toml` file: - -`src-tauri/Cargo.toml` - -```toml -[dependencies] -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: - -> 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 -pnpm add https://github.com/tauri-apps/tauri-plugin-fs-extra#v1 -# or -npm add https://github.com/tauri-apps/tauri-plugin-fs-extra#v1 -# or -yarn add https://github.com/tauri-apps/tauri-plugin-fs-extra#v1 -``` - -## Usage - -First you need to register the core plugin with Tauri: - -`src-tauri/src/main.rs` - -```rust -fn main() { - tauri::Builder::default() - .plugin(tauri_plugin_fs_extra::init()) - .run(tauri::generate_context!()) - .expect("error while running tauri application"); -} -``` - -Afterwards all the plugin's APIs are available through the JavaScript guest bindings: - -```javascript -import { metadata } from "tauri-plugin-fs-extra-api"; - -await metadata("/path/to/file"); -``` - -## Contributing - -PRs accepted. Please make sure to read the Contributing Guide before making a pull request. - -## Partners - - - - - - - -
- - CrabNebula - -
- -For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri). - -## License - -Code: (c) 2015 - Present - The Tauri Programme within The Commons Conservancy. - -MIT or MIT/Apache 2.0 where applicable. +![plugin-fs-extra](https://github.com/tauri-apps/plugins-workspace/raw/v1/plugins/fs-extra/banner.png) + +Additional file system methods not included in the core API. + +## Install + +_This plugin requires a Rust version of at least **1.67**_ + +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) +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) + +Install the Core plugin by adding the following to your `Cargo.toml` file: + +`src-tauri/Cargo.toml` + +```toml +[dependencies] +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: + +> 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 +pnpm add https://github.com/tauri-apps/tauri-plugin-fs-extra#v1 +# or +npm add https://github.com/tauri-apps/tauri-plugin-fs-extra#v1 +# or +yarn add https://github.com/tauri-apps/tauri-plugin-fs-extra#v1 +``` + +## Usage + +First you need to register the core plugin with Tauri: + +`src-tauri/src/main.rs` + +```rust +fn main() { + tauri::Builder::default() + .plugin(tauri_plugin_fs_extra::init()) + .run(tauri::generate_context!()) + .expect("error while running tauri application"); +} +``` + +Afterwards all the plugin's APIs are available through the JavaScript guest bindings: + +```javascript +import { metadata } from "tauri-plugin-fs-extra-api"; + +await metadata("/path/to/file"); +``` + +## Contributing + +PRs accepted. Please make sure to read the Contributing Guide before making a pull request. + +## Partners + + + + + + + +
+ + CrabNebula + +
+ +For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri). + +## License + +Code: (c) 2015 - Present - The Tauri Programme within The Commons Conservancy. + +MIT or MIT/Apache 2.0 where applicable. diff --git a/plugins/fs-watch/README.md b/plugins/fs-watch/README.md index 90b9c4874..f33f351b4 100644 --- a/plugins/fs-watch/README.md +++ b/plugins/fs-watch/README.md @@ -1,98 +1,98 @@ -![plugin-fs-watch](https://github.com/tauri-apps/plugins-workspace/raw/v1/plugins/fs-watch/banner.png) - -Watch files and directories for changes using [notify](https://github.com/notify-rs/notify). - -## Install - -_This plugin requires a Rust version of at least **1.67**_ - -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) -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) - -Install the Core plugin by adding the following to your `Cargo.toml` file: - -`src-tauri/Cargo.toml` - -```toml -[dependencies] -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: - -> 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 -pnpm add https://github.com/tauri-apps/tauri-plugin-fs-watch#v1 -# or -npm add https://github.com/tauri-apps/tauri-plugin-fs-watch#v1 -# or -yarn add https://github.com/tauri-apps/tauri-plugin-fs-watch#v1 -``` - -## Usage - -First you need to register the core plugin with Tauri: - -`src-tauri/src/main.rs` - -```rust -fn main() { - tauri::Builder::default() - .plugin(tauri_plugin_fs_watch::init()) - .run(tauri::generate_context!()) - .expect("error while running tauri application"); -} -``` - -Afterwards all the plugin's APIs are available through the JavaScript guest bindings: - -```javascript -import { watch, watchImmediate } from "tauri-plugin-fs-watch-api"; - -// can also watch an array of paths -const stopWatching = await watch( - "/path/to/something", - (event) => { - const { kind, path } = event; - }, - { recursive: true }, -); - -const stopRawWatcher = await watchImmediate( - ["/path/a", "/path/b"], - (event) => { - const { type, paths, attrs } = event; - }, - {}, -); -``` - -## Contributing - -PRs accepted. Please make sure to read the Contributing Guide before making a pull request. - -## Partners - - - - - - - -
- - CrabNebula - -
- -For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri). - -## License - -Code: (c) 2015 - Present - The Tauri Programme within The Commons Conservancy. - -MIT or MIT/Apache 2.0 where applicable. +![plugin-fs-watch](https://github.com/tauri-apps/plugins-workspace/raw/v1/plugins/fs-watch/banner.png) + +Watch files and directories for changes using [notify](https://github.com/notify-rs/notify). + +## Install + +_This plugin requires a Rust version of at least **1.67**_ + +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) +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) + +Install the Core plugin by adding the following to your `Cargo.toml` file: + +`src-tauri/Cargo.toml` + +```toml +[dependencies] +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: + +> 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 +pnpm add https://github.com/tauri-apps/tauri-plugin-fs-watch#v1 +# or +npm add https://github.com/tauri-apps/tauri-plugin-fs-watch#v1 +# or +yarn add https://github.com/tauri-apps/tauri-plugin-fs-watch#v1 +``` + +## Usage + +First you need to register the core plugin with Tauri: + +`src-tauri/src/main.rs` + +```rust +fn main() { + tauri::Builder::default() + .plugin(tauri_plugin_fs_watch::init()) + .run(tauri::generate_context!()) + .expect("error while running tauri application"); +} +``` + +Afterwards all the plugin's APIs are available through the JavaScript guest bindings: + +```javascript +import { watch, watchImmediate } from "tauri-plugin-fs-watch-api"; + +// can also watch an array of paths +const stopWatching = await watch( + "/path/to/something", + (event) => { + const { kind, path } = event; + }, + { recursive: true }, +); + +const stopRawWatcher = await watchImmediate( + ["/path/a", "/path/b"], + (event) => { + const { type, paths, attrs } = event; + }, + {}, +); +``` + +## Contributing + +PRs accepted. Please make sure to read the Contributing Guide before making a pull request. + +## Partners + + + + + + + +
+ + CrabNebula + +
+ +For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri). + +## License + +Code: (c) 2015 - Present - The Tauri Programme within The Commons Conservancy. + +MIT or MIT/Apache 2.0 where applicable. diff --git a/plugins/localhost/README.md b/plugins/localhost/README.md index f5c98bc27..90dd6b7c0 100644 --- a/plugins/localhost/README.md +++ b/plugins/localhost/README.md @@ -1,90 +1,90 @@ -![plugin-localhost](https://github.com/tauri-apps/plugins-workspace/raw/v1/plugins/localhost/banner.png) - -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. - -## Install - -_This plugin requires a Rust version of at least **1.67**_ - -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) -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) - -Install the Core plugin by adding the following to your `Cargo.toml` file: - -`src-tauri/Cargo.toml` - -```toml -[dependencies] -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 -``` - -## Usage - -First you need to register the core plugin with Tauri: - -`src-tauri/src/main.rs` - -```rust -use tauri::{utils::config::AppUrl, window::WindowBuilder, WindowUrl}; - -fn main() { - let port = portpicker::pick_unused_port().expect("failed to find unused port"); - - let mut context = tauri::generate_context!(); - let url = format!("http://localhost:{}", port).parse().unwrap(); - let window_url = WindowUrl::External(url); - // rewrite the config so the IPC is enabled on this URL - context.config_mut().build.dist_dir = AppUrl::Url(window_url.clone()); - - tauri::Builder::default() - .plugin(tauri_plugin_localhost::Builder::new(port).build()) - .setup(move |app| { - WindowBuilder::new( - app, - "main".to_string(), - if cfg!(dev) { - Default::default() - } else { - window_url - } - ) - .title("Localhost Example") - .build()?; - Ok(()) - }) - .run(context) - .expect("error while running tauri application"); -} -``` - -## Contributing - -PRs accepted. Please make sure to read the Contributing Guide before making a pull request. - -## Partners - - - - - - - -
- - CrabNebula - -
- -For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri). - -## License - -Code: (c) 2015 - Present - The Tauri Programme within The Commons Conservancy. - -MIT or MIT/Apache 2.0 where applicable. +![plugin-localhost](https://github.com/tauri-apps/plugins-workspace/raw/v1/plugins/localhost/banner.png) + +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. + +## Install + +_This plugin requires a Rust version of at least **1.67**_ + +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) +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) + +Install the Core plugin by adding the following to your `Cargo.toml` file: + +`src-tauri/Cargo.toml` + +```toml +[dependencies] +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 +``` + +## Usage + +First you need to register the core plugin with Tauri: + +`src-tauri/src/main.rs` + +```rust +use tauri::{utils::config::AppUrl, window::WindowBuilder, WindowUrl}; + +fn main() { + let port = portpicker::pick_unused_port().expect("failed to find unused port"); + + let mut context = tauri::generate_context!(); + let url = format!("http://localhost:{}", port).parse().unwrap(); + let window_url = WindowUrl::External(url); + // rewrite the config so the IPC is enabled on this URL + context.config_mut().build.dist_dir = AppUrl::Url(window_url.clone()); + + tauri::Builder::default() + .plugin(tauri_plugin_localhost::Builder::new(port).build()) + .setup(move |app| { + WindowBuilder::new( + app, + "main".to_string(), + if cfg!(dev) { + Default::default() + } else { + window_url + } + ) + .title("Localhost Example") + .build()?; + Ok(()) + }) + .run(context) + .expect("error while running tauri application"); +} +``` + +## Contributing + +PRs accepted. Please make sure to read the Contributing Guide before making a pull request. + +## Partners + + + + + + + +
+ + CrabNebula + +
+ +For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri). + +## License + +Code: (c) 2015 - Present - The Tauri Programme within The Commons Conservancy. + +MIT or MIT/Apache 2.0 where applicable. diff --git a/plugins/persisted-scope/CHANGELOG.md b/plugins/persisted-scope/CHANGELOG.md index af175267b..4f3cb005d 100644 --- a/plugins/persisted-scope/CHANGELOG.md +++ b/plugins/persisted-scope/CHANGELOG.md @@ -1,17 +1,17 @@ -# Changelog - -## \[0.1.3] - -- 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 - -## \[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. - - [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] - -- 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. - - [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 +# Changelog + +## \[0.1.3] + +- 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 + +## \[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. + - [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] + +- 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. + - [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 diff --git a/plugins/persisted-scope/README.md b/plugins/persisted-scope/README.md index 10552e0d1..7330a7f89 100644 --- a/plugins/persisted-scope/README.md +++ b/plugins/persisted-scope/README.md @@ -1,65 +1,65 @@ -![plugin-persisted-scope](https://github.com/tauri-apps/plugins-workspace/raw/v1/plugins/persisted-scope/banner.png) - -Save filesystem and asset scopes and restore them when the app is reopened. - -## Install - -_This plugin requires a Rust version of at least **1.67**_ - -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) -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) - -Install the Core plugin by adding the following to your `Cargo.toml` file: - -`src-tauri/Cargo.toml` - -```toml -[dependencies] -tauri-plugin-persisted-scope = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" } -``` - -## Usage - -First you need to register the core plugin with Tauri: - -`src-tauri/src/main.rs` - -```rust -fn main() { - tauri::Builder::default() - .plugin(tauri_plugin_persisted_scope::init()) - .run(tauri::generate_context!()) - .expect("error while running tauri application"); -} -``` - -Afterwards the plugin will automatically save and restore filesystem and asset scopes. - -## Contributing - -PRs accepted. Please make sure to read the Contributing Guide before making a pull request. - -## Partners - - - - - - - -
- - CrabNebula - -
- -For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri). - -## License - -Code: (c) 2015 - Present - The Tauri Programme within The Commons Conservancy. - -MIT or MIT/Apache 2.0 where applicable. +![plugin-persisted-scope](https://github.com/tauri-apps/plugins-workspace/raw/v1/plugins/persisted-scope/banner.png) + +Save filesystem and asset scopes and restore them when the app is reopened. + +## Install + +_This plugin requires a Rust version of at least **1.67**_ + +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) +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) + +Install the Core plugin by adding the following to your `Cargo.toml` file: + +`src-tauri/Cargo.toml` + +```toml +[dependencies] +tauri-plugin-persisted-scope = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" } +``` + +## Usage + +First you need to register the core plugin with Tauri: + +`src-tauri/src/main.rs` + +```rust +fn main() { + tauri::Builder::default() + .plugin(tauri_plugin_persisted_scope::init()) + .run(tauri::generate_context!()) + .expect("error while running tauri application"); +} +``` + +Afterwards the plugin will automatically save and restore filesystem and asset scopes. + +## Contributing + +PRs accepted. Please make sure to read the Contributing Guide before making a pull request. + +## Partners + + + + + + + +
+ + CrabNebula + +
+ +For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri). + +## License + +Code: (c) 2015 - Present - The Tauri Programme within The Commons Conservancy. + +MIT or MIT/Apache 2.0 where applicable. diff --git a/plugins/positioner/README.md b/plugins/positioner/README.md index e8f7cc344..6fa40a506 100644 --- a/plugins/positioner/README.md +++ b/plugins/positioner/README.md @@ -1,110 +1,110 @@ -![plugin-positioner](https://github.com/tauri-apps/plugins-workspace/raw/v1/plugins/positioner/banner.png) - -Position your windows at well-known locations. - -This plugin is a port of [electron-positioner](https://github.com/jenslind/electron-positioner) for Tauri. - -## Install - -_This plugin requires a Rust version of at least **1.67**_ - -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) -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) - -Install the Core plugin by adding the following to your `Cargo.toml` file: - -`src-tauri/Cargo.toml` - -```toml -[dependencies] -tauri-plugin-positioner = "1.0" -# or through git -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: - -> 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 -pnpm add tauri-plugin-positioner-api -# or -npm add tauri-plugin-positioner-api -# or -yarn add tauri-plugin-positioner-api -``` - -Or through git: - -```sh -pnpm add https://github.com/tauri-apps/tauri-plugin-positioner#v1 -# or -npm add https://github.com/tauri-apps/tauri-plugin-positioner#v1 -# or -yarn add https://github.com/tauri-apps/tauri-plugin-positioner#v1 -``` - -## Usage - -First you need to register the core plugin with Tauri: - -`src-tauri/src/main.rs` - -```rust -fn main() { - tauri::Builder::default() - .plugin(tauri_plugin_positioner::init()) - // This is required to get tray-relative positions to work - .on_system_tray_event(|app, event| { - tauri_plugin_positioner::on_tray_event(app, &event); - }) - .run(tauri::generate_context!()) - .expect("error while running tauri application"); -} -``` - -Afterwards all the plugin's APIs are available through the JavaScript guest bindings: - -```javascript -import { move_window, Position } from "tauri-plugin-positioner-api"; - -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: - -```rust -use tauri_plugin_positioner::{WindowExt, Position}; - -let mut win = app.get_window("main").unwrap(); -let _ = win.move_window(Position::TopRight); -``` - -## Contributing - -PRs accepted. Please make sure to read the Contributing Guide before making a pull request. - -## Partners - - - - - - - -
- - CrabNebula - -
- -For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri). - -## License - -Code: (c) 2021 - Jonas Kruckenberg. 2021 - Present - The Tauri Programme within The Commons Conservancy. - -MIT or MIT/Apache 2.0 where applicable. +![plugin-positioner](https://github.com/tauri-apps/plugins-workspace/raw/v1/plugins/positioner/banner.png) + +Position your windows at well-known locations. + +This plugin is a port of [electron-positioner](https://github.com/jenslind/electron-positioner) for Tauri. + +## Install + +_This plugin requires a Rust version of at least **1.67**_ + +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) +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) + +Install the Core plugin by adding the following to your `Cargo.toml` file: + +`src-tauri/Cargo.toml` + +```toml +[dependencies] +tauri-plugin-positioner = "1.0" +# or through git +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: + +> 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 +pnpm add tauri-plugin-positioner-api +# or +npm add tauri-plugin-positioner-api +# or +yarn add tauri-plugin-positioner-api +``` + +Or through git: + +```sh +pnpm add https://github.com/tauri-apps/tauri-plugin-positioner#v1 +# or +npm add https://github.com/tauri-apps/tauri-plugin-positioner#v1 +# or +yarn add https://github.com/tauri-apps/tauri-plugin-positioner#v1 +``` + +## Usage + +First you need to register the core plugin with Tauri: + +`src-tauri/src/main.rs` + +```rust +fn main() { + tauri::Builder::default() + .plugin(tauri_plugin_positioner::init()) + // This is required to get tray-relative positions to work + .on_system_tray_event(|app, event| { + tauri_plugin_positioner::on_tray_event(app, &event); + }) + .run(tauri::generate_context!()) + .expect("error while running tauri application"); +} +``` + +Afterwards all the plugin's APIs are available through the JavaScript guest bindings: + +```javascript +import { move_window, Position } from "tauri-plugin-positioner-api"; + +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: + +```rust +use tauri_plugin_positioner::{WindowExt, Position}; + +let mut win = app.get_window("main").unwrap(); +let _ = win.move_window(Position::TopRight); +``` + +## Contributing + +PRs accepted. Please make sure to read the Contributing Guide before making a pull request. + +## Partners + + + + + + + +
+ + CrabNebula + +
+ +For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri). + +## License + +Code: (c) 2021 - Jonas Kruckenberg. 2021 - Present - The Tauri Programme within The Commons Conservancy. + +MIT or MIT/Apache 2.0 where applicable. diff --git a/plugins/single-instance/README.md b/plugins/single-instance/README.md index 84b32cc03..03ee0f348 100644 --- a/plugins/single-instance/README.md +++ b/plugins/single-instance/README.md @@ -1,75 +1,75 @@ -![plugin-single-instance](https://github.com/tauri-apps/plugins-workspace/raw/v1/plugins/single-instance/banner.png) - -Ensure a single instance of your tauri app is running. - -## Install - -_This plugin requires a Rust version of at least **1.67**_ - -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) -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) - -Install the Core plugin by adding the following to your `Cargo.toml` file: - -`src-tauri/Cargo.toml` - -```toml -[dependencies] -tauri-plugin-single-instance = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" } -``` - -## Usage - -First you need to register the core plugin with Tauri: - -`src-tauri/src/main.rs` - -```rust -use tauri::{Manager}; - -#[derive(Clone, serde::Serialize)] -struct Payload { - args: Vec, - cwd: String, -} - -fn main() { - tauri::Builder::default() - .plugin(tauri_plugin_single_instance::init(|app, argv, cwd| { - println!("{}, {argv:?}, {cwd}", app.package_info().name); - - app.emit_all("single-instance", Payload { args: argv, cwd }).unwrap(); - })) - .run(tauri::generate_context!()) - .expect("error while running tauri application"); -} -``` - -## Contributing - -PRs accepted. Please make sure to read the Contributing Guide before making a pull request. - -## Partners - - - - - - - -
- - CrabNebula - -
- -For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri). - -## License - -Code: (c) 2015 - Present - The Tauri Programme within The Commons Conservancy. - -MIT or MIT/Apache 2.0 where applicable. +![plugin-single-instance](https://github.com/tauri-apps/plugins-workspace/raw/v1/plugins/single-instance/banner.png) + +Ensure a single instance of your tauri app is running. + +## Install + +_This plugin requires a Rust version of at least **1.67**_ + +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) +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) + +Install the Core plugin by adding the following to your `Cargo.toml` file: + +`src-tauri/Cargo.toml` + +```toml +[dependencies] +tauri-plugin-single-instance = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" } +``` + +## Usage + +First you need to register the core plugin with Tauri: + +`src-tauri/src/main.rs` + +```rust +use tauri::{Manager}; + +#[derive(Clone, serde::Serialize)] +struct Payload { + args: Vec, + cwd: String, +} + +fn main() { + tauri::Builder::default() + .plugin(tauri_plugin_single_instance::init(|app, argv, cwd| { + println!("{}, {argv:?}, {cwd}", app.package_info().name); + + app.emit_all("single-instance", Payload { args: argv, cwd }).unwrap(); + })) + .run(tauri::generate_context!()) + .expect("error while running tauri application"); +} +``` + +## Contributing + +PRs accepted. Please make sure to read the Contributing Guide before making a pull request. + +## Partners + + + + + + + +
+ + CrabNebula + +
+ +For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri). + +## License + +Code: (c) 2015 - Present - The Tauri Programme within The Commons Conservancy. + +MIT or MIT/Apache 2.0 where applicable. diff --git a/plugins/sql/README.md b/plugins/sql/README.md index ec1bbc8c3..c18326a8d 100644 --- a/plugins/sql/README.md +++ b/plugins/sql/README.md @@ -1,184 +1,184 @@ -![plugin-sql](https://github.com/tauri-apps/plugins-workspace/raw/v1/plugins/sql/banner.png) - -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 - -_This plugin requires a Rust version of at least **1.80**_ - -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) -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) - -Install the Core plugin by adding the following to your `Cargo.toml` file: - -`src-tauri/Cargo.toml` - -```toml -[dependencies.tauri-plugin-sql] -git = "https://github.com/tauri-apps/plugins-workspace" -branch = "v1" -features = ["sqlite"] # or "postgres", or "mysql" -``` - -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. - -```sh -pnpm add https://github.com/tauri-apps/tauri-plugin-sql#v1 -# or -npm add https://github.com/tauri-apps/tauri-plugin-sql#v1 -# or -yarn add https://github.com/tauri-apps/tauri-plugin-sql#v1 -``` - -## Usage - -First you need to register the core plugin with Tauri: - -`src-tauri/src/main.rs` - -```rust -fn main() { - tauri::Builder::default() - .plugin(tauri_plugin_sql::Builder::default().build()) - .run(tauri::generate_context!()) - .expect("error while running tauri application"); -} -``` - -Afterwards all the plugin's APIs are available through the JavaScript guest bindings: - -```javascript -import Database from "tauri-plugin-sql-api"; - -// sqlite. The path is relative to `tauri::api::path::BaseDirectory::App`. -const db = await Database.load("sqlite:test.db"); -// mysql -const db = await Database.load("mysql://user:pass@host/database"); -// postgres -const db = await Database.load("postgres://postgres:password@localhost/test"); - -await db.execute("INSERT INTO ..."); -``` - -## Syntax - -We use sqlx as our underlying library, adopting their query syntax: - -- sqlite and postgres use the "$#" syntax when substituting query data -- mysql uses "?" when substituting query data - -```javascript -// INSERT and UPDATE examples for sqlite and postgres -const result = await db.execute( - "INSERT into todos (id, title, status) VALUES ($1, $2, $3)", - [todos.id, todos.title, todos.status], -); - -const result = await db.execute( - "UPDATE todos SET title = $1, completed = $2 WHERE id = $3", - [todos.title, todos.status, todos.id], -); - -// INSERT and UPDATE examples for mysql -const result = await db.execute( - "INSERT into todos (id, title, status) VALUES (?, ?, ?)", - [todos.id, todos.title, todos.status], -); - -const result = await db.execute( - "UPDATE todos SET title = ?, completed = ? WHERE id = ?", - [todos.title, todos.status, todos.id], -); -``` - -## Migrations - -This plugin supports database migrations, allowing you to manage database schema evolution over time. - -### 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). - -Example of a migration: - -```rust -use tauri_plugin_sql::{Migration, MigrationKind}; - -let migration = Migration { - version: 1, - description: "create_initial_tables", - sql: "CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT);", - kind: MigrationKind::Up, -}; -``` - -### 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. - -Example of adding migrations: - -```rust -use tauri_plugin_sql::{Builder, Migration, MigrationKind}; - -fn main() { - let migrations = vec![ - // Define your migrations here - Migration { - version: 1, - description: "create_initial_tables", - sql: "CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT);", - kind: MigrationKind::Up, - } - ]; - - tauri::Builder::default() - .plugin( - tauri_plugin_sql::Builder::default() - .add_migrations("sqlite:mydatabase.db", migrations) - .build(), - ) - ... -} -``` - -### 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). - -### 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. -- **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. - -## Contributing - -PRs accepted. Please make sure to read the Contributing Guide before making a pull request. - -## Partners - - - - - - - -
- - CrabNebula - -
- -For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri). - -## License - -Code: (c) 2015 - Present - The Tauri Programme within The Commons Conservancy. - -MIT or MIT/Apache 2.0 where applicable. +![plugin-sql](https://github.com/tauri-apps/plugins-workspace/raw/v1/plugins/sql/banner.png) + +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 + +_This plugin requires a Rust version of at least **1.80**_ + +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) +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) + +Install the Core plugin by adding the following to your `Cargo.toml` file: + +`src-tauri/Cargo.toml` + +```toml +[dependencies.tauri-plugin-sql] +git = "https://github.com/tauri-apps/plugins-workspace" +branch = "v1" +features = ["sqlite"] # or "postgres", or "mysql" +``` + +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. + +```sh +pnpm add https://github.com/tauri-apps/tauri-plugin-sql#v1 +# or +npm add https://github.com/tauri-apps/tauri-plugin-sql#v1 +# or +yarn add https://github.com/tauri-apps/tauri-plugin-sql#v1 +``` + +## Usage + +First you need to register the core plugin with Tauri: + +`src-tauri/src/main.rs` + +```rust +fn main() { + tauri::Builder::default() + .plugin(tauri_plugin_sql::Builder::default().build()) + .run(tauri::generate_context!()) + .expect("error while running tauri application"); +} +``` + +Afterwards all the plugin's APIs are available through the JavaScript guest bindings: + +```javascript +import Database from "tauri-plugin-sql-api"; + +// sqlite. The path is relative to `tauri::api::path::BaseDirectory::App`. +const db = await Database.load("sqlite:test.db"); +// mysql +const db = await Database.load("mysql://user:pass@host/database"); +// postgres +const db = await Database.load("postgres://postgres:password@localhost/test"); + +await db.execute("INSERT INTO ..."); +``` + +## Syntax + +We use sqlx as our underlying library, adopting their query syntax: + +- sqlite and postgres use the "$#" syntax when substituting query data +- mysql uses "?" when substituting query data + +```javascript +// INSERT and UPDATE examples for sqlite and postgres +const result = await db.execute( + "INSERT into todos (id, title, status) VALUES ($1, $2, $3)", + [todos.id, todos.title, todos.status], +); + +const result = await db.execute( + "UPDATE todos SET title = $1, completed = $2 WHERE id = $3", + [todos.title, todos.status, todos.id], +); + +// INSERT and UPDATE examples for mysql +const result = await db.execute( + "INSERT into todos (id, title, status) VALUES (?, ?, ?)", + [todos.id, todos.title, todos.status], +); + +const result = await db.execute( + "UPDATE todos SET title = ?, completed = ? WHERE id = ?", + [todos.title, todos.status, todos.id], +); +``` + +## Migrations + +This plugin supports database migrations, allowing you to manage database schema evolution over time. + +### 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). + +Example of a migration: + +```rust +use tauri_plugin_sql::{Migration, MigrationKind}; + +let migration = Migration { + version: 1, + description: "create_initial_tables", + sql: "CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT);", + kind: MigrationKind::Up, +}; +``` + +### 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. + +Example of adding migrations: + +```rust +use tauri_plugin_sql::{Builder, Migration, MigrationKind}; + +fn main() { + let migrations = vec![ + // Define your migrations here + Migration { + version: 1, + description: "create_initial_tables", + sql: "CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT);", + kind: MigrationKind::Up, + } + ]; + + tauri::Builder::default() + .plugin( + tauri_plugin_sql::Builder::default() + .add_migrations("sqlite:mydatabase.db", migrations) + .build(), + ) + ... +} +``` + +### 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). + +### 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. +- **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. + +## Contributing + +PRs accepted. Please make sure to read the Contributing Guide before making a pull request. + +## Partners + + + + + + + +
+ + CrabNebula + +
+ +For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri). + +## License + +Code: (c) 2015 - Present - The Tauri Programme within The Commons Conservancy. + +MIT or MIT/Apache 2.0 where applicable. diff --git a/plugins/stronghold/README.md b/plugins/stronghold/README.md index 598fda604..af624cec5 100644 --- a/plugins/stronghold/README.md +++ b/plugins/stronghold/README.md @@ -1,152 +1,152 @@ -![plugin-stronghold](https://github.com/tauri-apps/plugins-workspace/raw/v1/plugins/stronghold/banner.png) - -Store secrets and keys using the [IOTA Stronghold](https://github.com/iotaledger/stronghold.rs) encrypted database and secure runtime. - -## Install - -_This plugin requires a Rust version of at least **1.67**_ - -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) -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) - -Install the Core plugin by adding the following to your `Cargo.toml` file: - -`src-tauri/Cargo.toml` - -```toml -[dependencies] -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: - -> 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 -pnpm add https://github.com/tauri-apps/tauri-plugin-stronghold#v1 -# or -npm add https://github.com/tauri-apps/tauri-plugin-stronghold#v1 -# or -yarn add https://github.com/tauri-apps/tauri-plugin-stronghold#v1 -``` - -## Usage - -First you need to register the core plugin with Tauri: - -`src-tauri/src/main.rs` - -```rust -fn main() { - tauri::Builder::default() - .plugin(tauri_plugin_stronghold::Builder::new(|password| { - // 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 - - use argon2::{hash_raw, Config, Variant, Version}; - - let config = Config { - lanes: 4, - mem_cost: 10_000, - time_cost: 10, - variant: Variant::Argon2id, - version: Version::Version13, - ..Default::default() - }; - - let salt = "your-salt".as_bytes(); - - let key = hash_raw(password.as_ref(), salt, &config).expect("failed to hash password"); - - key.to_vec() - }) - .build()) - .run(tauri::generate_context!()) - .expect("error while running tauri application"); -} -``` - -Afterwards all the plugin's APIs are available through the JavaScript guest bindings: - -```javascript -import { Stronghold, Location, Client } from "tauri-plugin-stronghold-api"; -import { appDataDir } from "@tauri-apps/api/path"; - -const initStronghold = async () => { - const vaultPath = `${await appDataDir()}/vault.hold`; - - const vaultKey = "The key to the vault"; - - const stronghold = await Stronghold.load(vaultPath, vaultKey); - - let client: Client; - - const clientName = "name your client"; - - try { - client = await hold.loadClient(clientName); - } catch { - client = await hold.createClient(clientName); - } - - return { - stronghold, - client, - }; -}; - -const { stronghold, client } = await initStronghold(); - -const store = client.getStore(); - -const key = "my_key"; - -// Insert a record to the store - -const data = Array.from(new TextEncoder().encode("Hello, World!")); - -await store.insert(key, data); - -// Read a record from store - -const data = await store.get(key); - -const value = new TextDecoder().decode(new Uint8Array(data)); - -// Save your updates - -await stronghold.save(); - -// Remove a record from store - -await store.remove(key); -``` - -## Contributing - -PRs accepted. Please make sure to read the Contributing Guide before making a pull request. - -## Partners - - - - - - - -
- - CrabNebula - -
- -For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri). - -## License - -Code: (c) 2015 - Present - The Tauri Programme within The Commons Conservancy. - -MIT or MIT/Apache 2.0 where applicable. +![plugin-stronghold](https://github.com/tauri-apps/plugins-workspace/raw/v1/plugins/stronghold/banner.png) + +Store secrets and keys using the [IOTA Stronghold](https://github.com/iotaledger/stronghold.rs) encrypted database and secure runtime. + +## Install + +_This plugin requires a Rust version of at least **1.67**_ + +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) +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) + +Install the Core plugin by adding the following to your `Cargo.toml` file: + +`src-tauri/Cargo.toml` + +```toml +[dependencies] +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: + +> 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 +pnpm add https://github.com/tauri-apps/tauri-plugin-stronghold#v1 +# or +npm add https://github.com/tauri-apps/tauri-plugin-stronghold#v1 +# or +yarn add https://github.com/tauri-apps/tauri-plugin-stronghold#v1 +``` + +## Usage + +First you need to register the core plugin with Tauri: + +`src-tauri/src/main.rs` + +```rust +fn main() { + tauri::Builder::default() + .plugin(tauri_plugin_stronghold::Builder::new(|password| { + // 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 + + use argon2::{hash_raw, Config, Variant, Version}; + + let config = Config { + lanes: 4, + mem_cost: 10_000, + time_cost: 10, + variant: Variant::Argon2id, + version: Version::Version13, + ..Default::default() + }; + + let salt = "your-salt".as_bytes(); + + let key = hash_raw(password.as_ref(), salt, &config).expect("failed to hash password"); + + key.to_vec() + }) + .build()) + .run(tauri::generate_context!()) + .expect("error while running tauri application"); +} +``` + +Afterwards all the plugin's APIs are available through the JavaScript guest bindings: + +```javascript +import { Stronghold, Location, Client } from "tauri-plugin-stronghold-api"; +import { appDataDir } from "@tauri-apps/api/path"; + +const initStronghold = async () => { + const vaultPath = `${await appDataDir()}/vault.hold`; + + const vaultKey = "The key to the vault"; + + const stronghold = await Stronghold.load(vaultPath, vaultKey); + + let client: Client; + + const clientName = "name your client"; + + try { + client = await hold.loadClient(clientName); + } catch { + client = await hold.createClient(clientName); + } + + return { + stronghold, + client, + }; +}; + +const { stronghold, client } = await initStronghold(); + +const store = client.getStore(); + +const key = "my_key"; + +// Insert a record to the store + +const data = Array.from(new TextEncoder().encode("Hello, World!")); + +await store.insert(key, data); + +// Read a record from store + +const data = await store.get(key); + +const value = new TextDecoder().decode(new Uint8Array(data)); + +// Save your updates + +await stronghold.save(); + +// Remove a record from store + +await store.remove(key); +``` + +## Contributing + +PRs accepted. Please make sure to read the Contributing Guide before making a pull request. + +## Partners + + + + + + + +
+ + CrabNebula + +
+ +For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri). + +## License + +Code: (c) 2015 - Present - The Tauri Programme within The Commons Conservancy. + +MIT or MIT/Apache 2.0 where applicable. diff --git a/plugins/upload/README.md b/plugins/upload/README.md index 91844dc1c..c0c8a4f7b 100644 --- a/plugins/upload/README.md +++ b/plugins/upload/README.md @@ -1,100 +1,100 @@ -![plugin-upload](https://github.com/tauri-apps/plugins-workspace/raw/v1/plugins/upload/banner.png) - -Upload files from disk to a remote server over HTTP. -Download files from a remote HTTP server to disk. - -## Install - -_This plugin requires a Rust version of at least **1.67**_ - -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) -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) - -Install the Core plugin by adding the following to your `Cargo.toml` file: - -`src-tauri/Cargo.toml` - -```toml -[dependencies] -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: - -> 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 -pnpm add https://github.com/tauri-apps/tauri-plugin-upload#v1 -# or -npm add https://github.com/tauri-apps/tauri-plugin-upload#v1 -# or -yarn add https://github.com/tauri-apps/tauri-plugin-upload#v1 -``` - -## Usage - -First you need to register the core plugin with Tauri: - -`src-tauri/src/main.rs` - -```rust -fn main() { - tauri::Builder::default() - .plugin(tauri_plugin_upload::init()) - .run(tauri::generate_context!()) - .expect("error while running tauri application"); -} -``` - -Afterwards all the plugin's APIs are available through the JavaScript guest bindings: - -```javascript -import { upload } from "tauri-plugin-upload-api"; - -upload( - "https://example.com/file-upload", - "./path/to/my/file.txt", - (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 -); -``` - -```javascript -import { download } from "tauri-plugin-upload-api"; - -download( - "https://example.com/file-download-link", - "./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 - { "Content-Type": "text/plain" }, // optional headers to send with the request -); -``` - -## Contributing - -PRs accepted. Please make sure to read the Contributing Guide before making a pull request. - -## Partners - - - - - - - -
- - CrabNebula - -
- -For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri). - -## License - -Code: (c) 2015 - Present - The Tauri Programme within The Commons Conservancy. - -MIT or MIT/Apache 2.0 where applicable. +![plugin-upload](https://github.com/tauri-apps/plugins-workspace/raw/v1/plugins/upload/banner.png) + +Upload files from disk to a remote server over HTTP. +Download files from a remote HTTP server to disk. + +## Install + +_This plugin requires a Rust version of at least **1.67**_ + +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) +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) + +Install the Core plugin by adding the following to your `Cargo.toml` file: + +`src-tauri/Cargo.toml` + +```toml +[dependencies] +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: + +> 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 +pnpm add https://github.com/tauri-apps/tauri-plugin-upload#v1 +# or +npm add https://github.com/tauri-apps/tauri-plugin-upload#v1 +# or +yarn add https://github.com/tauri-apps/tauri-plugin-upload#v1 +``` + +## Usage + +First you need to register the core plugin with Tauri: + +`src-tauri/src/main.rs` + +```rust +fn main() { + tauri::Builder::default() + .plugin(tauri_plugin_upload::init()) + .run(tauri::generate_context!()) + .expect("error while running tauri application"); +} +``` + +Afterwards all the plugin's APIs are available through the JavaScript guest bindings: + +```javascript +import { upload } from "tauri-plugin-upload-api"; + +upload( + "https://example.com/file-upload", + "./path/to/my/file.txt", + (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 +); +``` + +```javascript +import { download } from "tauri-plugin-upload-api"; + +download( + "https://example.com/file-download-link", + "./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 + { "Content-Type": "text/plain" }, // optional headers to send with the request +); +``` + +## Contributing + +PRs accepted. Please make sure to read the Contributing Guide before making a pull request. + +## Partners + + + + + + + +
+ + CrabNebula + +
+ +For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri). + +## License + +Code: (c) 2015 - Present - The Tauri Programme within The Commons Conservancy. + +MIT or MIT/Apache 2.0 where applicable. diff --git a/plugins/websocket/README.md b/plugins/websocket/README.md index 0c27d5a31..34981f322 100644 --- a/plugins/websocket/README.md +++ b/plugins/websocket/README.md @@ -1,87 +1,87 @@ -![plugin-websocket](https://github.com/tauri-apps/plugins-workspace/raw/v1/plugins/websocket/banner.png) - - - -## Install - -_This plugin requires a Rust version of at least **1.67**_ - -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) -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) - -Install the Core plugin by adding the following to your `Cargo.toml` file: - -`src-tauri/Cargo.toml` - -```toml -[dependencies] -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: - -> 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 -pnpm add https://github.com/tauri-apps/tauri-plugin-websocket#v1 -# or -npm add https://github.com/tauri-apps/tauri-plugin-websocket#v1 -# or -yarn add https://github.com/tauri-apps/tauri-plugin-websocket#v1 -``` - -## Usage - -First you need to register the core plugin with Tauri: - -`src-tauri/src/main.rs` - -```rust -fn main() { - tauri::Builder::default() - .plugin(tauri_plugin_websocket::init()) - .run(tauri::generate_context!()) - .expect("error while running tauri application"); -} -``` - -Afterwards all the plugin's APIs are available through the JavaScript guest bindings: - -```javascript -import WebSocket from "tauri-plugin-websocket-api"; - -const ws = await WebSocket.connect("wss://example.com"); - -await ws.send("Hello World"); - -await ws.disconnect(); -``` - -## Contributing - -PRs accepted. Please make sure to read the Contributing Guide before making a pull request. - -## Partners - - - - - - - -
- - CrabNebula - -
- -For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri). - -## License - -Code: (c) 2015 - Present - The Tauri Programme within The Commons Conservancy. - -MIT or MIT/Apache 2.0 where applicable. +![plugin-websocket](https://github.com/tauri-apps/plugins-workspace/raw/v1/plugins/websocket/banner.png) + + + +## Install + +_This plugin requires a Rust version of at least **1.67**_ + +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) +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) + +Install the Core plugin by adding the following to your `Cargo.toml` file: + +`src-tauri/Cargo.toml` + +```toml +[dependencies] +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: + +> 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 +pnpm add https://github.com/tauri-apps/tauri-plugin-websocket#v1 +# or +npm add https://github.com/tauri-apps/tauri-plugin-websocket#v1 +# or +yarn add https://github.com/tauri-apps/tauri-plugin-websocket#v1 +``` + +## Usage + +First you need to register the core plugin with Tauri: + +`src-tauri/src/main.rs` + +```rust +fn main() { + tauri::Builder::default() + .plugin(tauri_plugin_websocket::init()) + .run(tauri::generate_context!()) + .expect("error while running tauri application"); +} +``` + +Afterwards all the plugin's APIs are available through the JavaScript guest bindings: + +```javascript +import WebSocket from "tauri-plugin-websocket-api"; + +const ws = await WebSocket.connect("wss://example.com"); + +await ws.send("Hello World"); + +await ws.disconnect(); +``` + +## Contributing + +PRs accepted. Please make sure to read the Contributing Guide before making a pull request. + +## Partners + + + + + + + +
+ + CrabNebula + +
+ +For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri). + +## License + +Code: (c) 2015 - Present - The Tauri Programme within The Commons Conservancy. + +MIT or MIT/Apache 2.0 where applicable. diff --git a/plugins/window-state/README.md b/plugins/window-state/README.md index 2995cf507..fb8f4cb69 100644 --- a/plugins/window-state/README.md +++ b/plugins/window-state/README.md @@ -1,111 +1,111 @@ -![plugin-window-state](https://github.com/tauri-apps/plugins-workspace/raw/v1/plugins/window-state/banner.png) - -Save window positions and sizes and restore them when the app is reopened. - -## Install - -_This plugin requires a Rust version of at least **1.67**_ - -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) -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) - -Install the Core plugin by adding the following to your `Cargo.toml` file: - -`src-tauri/Cargo.toml` - -```toml -[dependencies] -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: - -> 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 -pnpm add https://github.com/tauri-apps/tauri-plugin-window-state#v1 -# or -npm add https://github.com/tauri-apps/tauri-plugin-window-state#v1 -# or -yarn add https://github.com/tauri-apps/tauri-plugin-window-state#v1 -``` - -## Usage - -First you need to register the core plugin with Tauri: - -`src-tauri/src/main.rs` - -```rust -fn main() { - tauri::Builder::default() - .plugin(tauri_plugin_window_state::Builder::default().build()) - .run(tauri::generate_context!()) - .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. - -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 -use tauri_plugin_window_state::{AppHandleExt, StateFlags}; - -// `tauri::AppHandle` now has the following additional method -app.save_window_state(StateFlags::all()); // will save the state of all open windows to disk -``` - -or through Javascript - -```javascript -import { saveWindowState, StateFlags } from "tauri-plugin-window-state-api"; - -saveWindowState(StateFlags.ALL); -``` - -To manually restore a windows state from disk you can call the `restore_state()` method exposed by the `WindowExt` trait: - -```rust -use tauri_plugin_window_state::{WindowExt, StateFlags}; - -// all `Window` types now have the following additional method -window.restore_state(StateFlags::all()); // will restore the windows state from disk -``` - -or through Javascript - -```javascript -import { restoreStateCurrent, StateFlags } from "tauri-plugin-window-state-api"; - -restoreStateCurrent(StateFlags.ALL); -``` - -## Contributing - -PRs accepted. Please make sure to read the Contributing Guide before making a pull request. - -## Partners - - - - - - - -
- - CrabNebula - -
- -For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri). - -## License - -Code: (c) 2015 - Present - The Tauri Programme within The Commons Conservancy. - -MIT or MIT/Apache 2.0 where applicable. +![plugin-window-state](https://github.com/tauri-apps/plugins-workspace/raw/v1/plugins/window-state/banner.png) + +Save window positions and sizes and restore them when the app is reopened. + +## Install + +_This plugin requires a Rust version of at least **1.67**_ + +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) +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) + +Install the Core plugin by adding the following to your `Cargo.toml` file: + +`src-tauri/Cargo.toml` + +```toml +[dependencies] +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: + +> 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 +pnpm add https://github.com/tauri-apps/tauri-plugin-window-state#v1 +# or +npm add https://github.com/tauri-apps/tauri-plugin-window-state#v1 +# or +yarn add https://github.com/tauri-apps/tauri-plugin-window-state#v1 +``` + +## Usage + +First you need to register the core plugin with Tauri: + +`src-tauri/src/main.rs` + +```rust +fn main() { + tauri::Builder::default() + .plugin(tauri_plugin_window_state::Builder::default().build()) + .run(tauri::generate_context!()) + .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. + +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 +use tauri_plugin_window_state::{AppHandleExt, StateFlags}; + +// `tauri::AppHandle` now has the following additional method +app.save_window_state(StateFlags::all()); // will save the state of all open windows to disk +``` + +or through Javascript + +```javascript +import { saveWindowState, StateFlags } from "tauri-plugin-window-state-api"; + +saveWindowState(StateFlags.ALL); +``` + +To manually restore a windows state from disk you can call the `restore_state()` method exposed by the `WindowExt` trait: + +```rust +use tauri_plugin_window_state::{WindowExt, StateFlags}; + +// all `Window` types now have the following additional method +window.restore_state(StateFlags::all()); // will restore the windows state from disk +``` + +or through Javascript + +```javascript +import { restoreStateCurrent, StateFlags } from "tauri-plugin-window-state-api"; + +restoreStateCurrent(StateFlags.ALL); +``` + +## Contributing + +PRs accepted. Please make sure to read the Contributing Guide before making a pull request. + +## Partners + + + + + + + +
+ + CrabNebula + +
+ +For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri). + +## License + +Code: (c) 2015 - Present - The Tauri Programme within The Commons Conservancy. + +MIT or MIT/Apache 2.0 where applicable. diff --git a/shared/template/README.md b/shared/template/README.md index 5f5794722..f84bd8f5f 100644 --- a/shared/template/README.md +++ b/shared/template/README.md @@ -1,83 +1,83 @@ -![PLUGIN_NAME](https://github.com/tauri-apps/plugins-workspace/raw/v1/plugins/PLUGIN_NAME/banner.png) - - - -## Install - -_This plugin requires a Rust version of at least **1.67**_ - -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) -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) - -Install the Core plugin by adding the following to your `Cargo.toml` file: - -`src-tauri/Cargo.toml` - -```toml -[dependencies] - = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" } -``` - -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. - - - -```sh -pnpm add -# or -npm add -# or -yarn add -``` - -## Usage - -First you need to register the core plugin with Tauri: - -`src-tauri/src/main.rs` - -```rust -fn main() { - tauri::Builder::default() - .plugin() - .run(tauri::generate_context!()) - .expect("error while running tauri application"); -} -``` - -Afterwards all the plugin's APIs are available through the JavaScript guest bindings: - -```javascript - -``` - -## Contributing - -PRs accepted. Please make sure to read the Contributing Guide before making a pull request. - -## Partners - - - - - - - -
- - CrabNebula - -
- -For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri). - -## License - -Code: (c) 2015 - Present - The Tauri Programme within The Commons Conservancy. - -MIT or MIT/Apache 2.0 where applicable. +![PLUGIN_NAME](https://github.com/tauri-apps/plugins-workspace/raw/v1/plugins/PLUGIN_NAME/banner.png) + + + +## Install + +_This plugin requires a Rust version of at least **1.67**_ + +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) +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) + +Install the Core plugin by adding the following to your `Cargo.toml` file: + +`src-tauri/Cargo.toml` + +```toml +[dependencies] + = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" } +``` + +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. + + + +```sh +pnpm add +# or +npm add +# or +yarn add +``` + +## Usage + +First you need to register the core plugin with Tauri: + +`src-tauri/src/main.rs` + +```rust +fn main() { + tauri::Builder::default() + .plugin() + .run(tauri::generate_context!()) + .expect("error while running tauri application"); +} +``` + +Afterwards all the plugin's APIs are available through the JavaScript guest bindings: + +```javascript + +``` + +## Contributing + +PRs accepted. Please make sure to read the Contributing Guide before making a pull request. + +## Partners + + + + + + + +
+ + CrabNebula + +
+ +For the complete list of sponsors please visit our [website](https://tauri.app#sponsors) and [Open Collective](https://opencollective.com/tauri). + +## License + +Code: (c) 2015 - Present - The Tauri Programme within The Commons Conservancy. + +MIT or MIT/Apache 2.0 where applicable.