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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
//! # tauri-plugin-vnidrop-share
//!
//! A Tauri plugin to share content using the native sharing dialog on Windows, macOS, and mobile platforms.
//!
//! On desktop, the plugin handles sharing text, URLs, and files. For files, it manages their lifecycle by creating
//! temporary files from Base64 content and cleaning them up once the share dialog is closed or the application exits.
//!
//! ## Installation
//!
//! ```sh
//! # Cargo.toml
//! [dependencies]
//! tauri-plugin-vnidrop-share = { git = "[https://github.com/vnidrop/plugin-share](https://github.com/vnidrop/plugin-share)" }
//! ```
//!
//! ## Usage
//!
//! ### Rust
//!
//! You need to initialize the plugin in your `main.rs` or `lib.rs` to register the commands and set up state management.
//!
//! ```rust
//! // src/main.rs
//! fn main() {
//! tauri::Builder::default()
//! .plugin(tauri_plugin_vnidrop_share::init())
//! .run(tauri::generate_context!())
//! .expect("error while running tauri application");
//! }
//! ```
//!
//! ### Frontend (JavaScript/TypeScript)
//!
//! The plugin provides a JavaScript API to call the commands.
//!
//! ```js
//! import { share, canShare } from '@vnidrop/tauri-plugin-share';
//!
//! // Check if sharing is available
//! const canShareResult = await canShare();
//! console.log(`Can share on this platform: ${canShareResult}`);
//!
//! // Share text and a URL
//! if (canShareResult) {
//! await share({
//! title: 'Check this out!',
//! text: 'I found this cool project built with Tauri.',
//! url: '[https://tauri.app](https://tauri.app)',
//! });
//! }
//!
//! // Share a file from Base64 content
//! // The file will be created as a temporary file and cleaned up automatically.
//! const fileContent = '...'; // Your Base64-encoded file data
//! const blob = new Blob([fileContent], { type: 'text/plain' });
//! await share({
//! files: [new File([blob], 'document.txt')],
//! });
//! ```
//!
use ;
pub use *;
pub use ;
use Share;
use Share;
/// Extensions to [`tauri::App`], [`tauri::AppHandle`] and [`tauri::Window`] to access the share APIs.
/// Initializes the plugin.
///
/// This function sets up the plugin, registers its commands, and configures the
/// state management for temporary files. The cleanup of these files is
/// automatically handled when the application exits.