Skip to content

Commit

Permalink
refactor(core): remove the clipboard APIs (#6728)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasfernog committed Apr 17, 2023
1 parent 276e4a3 commit cebd752
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 192 deletions.
6 changes: 6 additions & 0 deletions .changes/remove-clipboard.md
@@ -0,0 +1,6 @@
---
"tauri": patch
"api": patch
---

Moved the `clipboard` feature to its own plugin in the plugins-workspace repository.
10 changes: 5 additions & 5 deletions core/tauri/scripts/bundle.global.js

Large diffs are not rendered by default.

22 changes: 0 additions & 22 deletions core/tauri/src/app.rs
Expand Up @@ -264,8 +264,6 @@ pub struct AppHandle<R: Runtime> {
pub(crate) manager: WindowManager<R>,
#[cfg(all(desktop, feature = "global-shortcut"))]
global_shortcut_manager: R::GlobalShortcutManager,
#[cfg(feature = "clipboard")]
clipboard_manager: R::ClipboardManager,
/// The updater configuration.
#[cfg(updater)]
pub(crate) updater_settings: UpdaterSettings,
Expand Down Expand Up @@ -320,8 +318,6 @@ impl<R: Runtime> Clone for AppHandle<R> {
manager: self.manager.clone(),
#[cfg(all(desktop, feature = "global-shortcut"))]
global_shortcut_manager: self.global_shortcut_manager.clone(),
#[cfg(feature = "clipboard")]
clipboard_manager: self.clipboard_manager.clone(),
#[cfg(updater)]
updater_settings: self.updater_settings.clone(),
}
Expand Down Expand Up @@ -480,8 +476,6 @@ pub struct App<R: Runtime> {
manager: WindowManager<R>,
#[cfg(all(desktop, feature = "global-shortcut"))]
global_shortcut_manager: R::GlobalShortcutManager,
#[cfg(feature = "clipboard")]
clipboard_manager: R::ClipboardManager,
handle: AppHandle<R>,
}

Expand All @@ -494,8 +488,6 @@ impl<R: Runtime> fmt::Debug for App<R> {

#[cfg(all(desktop, feature = "global-shortcut"))]
d.field("global_shortcut_manager", &self.global_shortcut_manager);
#[cfg(feature = "clipboard")]
d.field("clipboard_manager", &self.clipboard_manager);

d.finish()
}
Expand Down Expand Up @@ -639,13 +631,6 @@ macro_rules! shared_app_impl {
self.global_shortcut_manager.clone()
}

/// Gets a copy of the clipboard manager instance.
#[cfg(feature = "clipboard")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "clipboard")))]
pub fn clipboard_manager(&self) -> R::ClipboardManager {
self.clipboard_manager.clone()
}

/// Gets the app's configuration, defined on the `tauri.conf.json` file.
pub fn config(&self) -> Arc<Config> {
self.manager.config()
Expand Down Expand Up @@ -1513,9 +1498,6 @@ impl<R: Runtime> Builder<R> {
#[cfg(all(desktop, feature = "global-shortcut"))]
let global_shortcut_manager = runtime.global_shortcut_manager();

#[cfg(feature = "clipboard")]
let clipboard_manager = runtime.clipboard_manager();

#[allow(unused_mut)]
let mut app = App {
runtime: Some(runtime),
Expand All @@ -1524,15 +1506,11 @@ impl<R: Runtime> Builder<R> {
manager: manager.clone(),
#[cfg(all(desktop, feature = "global-shortcut"))]
global_shortcut_manager: global_shortcut_manager.clone(),
#[cfg(feature = "clipboard")]
clipboard_manager: clipboard_manager.clone(),
handle: AppHandle {
runtime_handle,
manager,
#[cfg(all(desktop, feature = "global-shortcut"))]
global_shortcut_manager,
#[cfg(feature = "clipboard")]
clipboard_manager,
#[cfg(updater)]
updater_settings: self.updater_settings,
},
Expand Down
11 changes: 0 additions & 11 deletions core/tauri/src/endpoints.rs
Expand Up @@ -13,8 +13,6 @@ use serde_json::Value as JsonValue;
use std::sync::Arc;

mod app;
#[cfg(clipboard_any)]
mod clipboard;
#[cfg(dialog_any)]
mod dialog;
mod event;
Expand Down Expand Up @@ -81,8 +79,6 @@ enum Module {
Http(http::Cmd),
#[cfg(global_shortcut_any)]
GlobalShortcut(global_shortcut::Cmd),
#[cfg(clipboard_any)]
Clipboard(clipboard::Cmd),
}

impl Module {
Expand Down Expand Up @@ -167,13 +163,6 @@ impl Module {
.and_then(|r| r.json)
.map_err(InvokeError::from_anyhow)
}),
#[cfg(clipboard_any)]
Self::Clipboard(cmd) => resolver.respond_async(async move {
cmd
.run(context)
.and_then(|r| r.json)
.map_err(InvokeError::from_anyhow)
}),
}
}
}
Expand Down
76 changes: 0 additions & 76 deletions core/tauri/src/endpoints/clipboard.rs

This file was deleted.

2 changes: 1 addition & 1 deletion tooling/api/docs/js-api.json

Large diffs are not rendered by default.

75 changes: 0 additions & 75 deletions tooling/api/src/clipboard.ts

This file was deleted.

2 changes: 0 additions & 2 deletions tooling/api/src/index.ts
Expand Up @@ -14,7 +14,6 @@
*/

import * as app from './app'
import * as clipboard from './clipboard'
import * as dialog from './dialog'
import * as event from './event'
import * as globalShortcut from './globalShortcut'
Expand All @@ -34,7 +33,6 @@ const invoke = tauri.invoke
export {
invoke,
app,
clipboard,
dialog,
event,
globalShortcut,
Expand Down

0 comments on commit cebd752

Please sign in to comment.