1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
// Copyright 2019-2024 Tauri Programme within The Commons Conservancy
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
//! Interface for building Tauri plugins.
//!
//! A Tauri plugin is a Rust crate that extends a Tauri application with commands, state,
//! lifecycle hooks and - optionally - Android and iOS native code. This crate holds the pieces
//! of that interface that are not part of the [`tauri`] crate itself, split in two Cargo
//! features:
//!
//! - **`build`**: helpers for the plugin `build.rs`. [`Builder`] checks the crate against the
//! Tauri plugin conventions (the `links` key must be set and match the crate name, the name
//! cannot contain underscores or be a reserved one), autogenerates the
//! `allow-$command`/`deny-$command` permissions for the plugin commands, parses the
//! permission files, generates their JSON schema and reference documentation, defines the
//! global scope schema and links the Android/iOS projects of the plugin.
//! [`plugin_config`] reads the plugin configuration the Tauri CLI forwards to the build
//! script, and the [`mobile`] module has helpers to patch the generated iOS `Info.plist` and
//! entitlements and the Android manifest.
//! - **`runtime`**: reserved for the runtime side of the plugin interface. It currently
//! exports nothing - use [`tauri::plugin`] to define the plugin itself.
//!
//! # Examples
//!
//! A typical plugin `build.rs`:
//!
//! ```rust,ignore
//! const COMMANDS: &[&str] = &["ping", "execute"];
//!
//! fn main() {
//! tauri_plugin::Builder::new(COMMANDS)
//! .android_path("android")
//! .ios_path("ios")
//! .build();
//! }
//! ```
//!
//! With a configuration type and an iOS `Info.plist` change:
//!
//! ```rust,ignore
//! #[derive(serde::Deserialize)]
//! #[serde(rename_all = "camelCase")]
//! struct Config {
//! camera_usage_description: Option<String>,
//! }
//!
//! fn main() {
//! if let Some(config) = tauri_plugin::plugin_config::<Config>("my-plugin") {
//! if let Some(description) = config.camera_usage_description {
//! tauri_plugin::mobile::update_info_plist(|plist| {
//! plist.insert("NSCameraUsageDescription".into(), description.into());
//! })
//! .expect("failed to update Info.plist");
//! }
//! }
//!
//! tauri_plugin::Builder::new(&["take_picture"]).build();
//! }
//! ```
//!
//! [`tauri`]: https://docs.rs/tauri/latest/tauri/
//! [`tauri::plugin`]: https://docs.rs/tauri/latest/tauri/plugin/index.html
//! [`Builder`]: https://docs.rs/tauri-plugin/latest/tauri_plugin/struct.Builder.html
//! [`plugin_config`]: https://docs.rs/tauri-plugin/latest/tauri_plugin/fn.plugin_config.html
//! [`mobile`]: https://docs.rs/tauri-plugin/latest/tauri_plugin/mobile/index.html
pub use *;
pub use *;