Skip to content

Commit

Permalink
refactor(core): remove deprecated APIs (#3834)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasfernog committed Apr 1, 2022
1 parent 6a5ff08 commit 7c7d854
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 110 deletions.
5 changes: 5 additions & 0 deletions .changes/remove-depracated.md
@@ -0,0 +1,5 @@
---
"tauri": patch
---

**Breaking change:** Removed `App::create_window`, `AppHandle::create_window`, `Builder::create_window` and `Window::create_window`.
81 changes: 3 additions & 78 deletions core/tauri/src/app.rs
Expand Up @@ -15,15 +15,14 @@ use crate::{
plugin::{Plugin, PluginStore},
runtime::{
http::{Request as HttpRequest, Response as HttpResponse},
webview::{WebviewAttributes, WindowBuilder as _},
webview::WebviewAttributes,
window::{PendingWindow, WindowEvent as RuntimeWindowEvent},
Dispatch, ExitRequestedEventAction, RunEvent as RuntimeRunEvent,
ExitRequestedEventAction, RunEvent as RuntimeRunEvent,
},
scope::FsScope,
sealed::{ManagerBase, RuntimeOrDispatch},
utils::config::{Config, WindowUrl},
utils::config::Config,
utils::{assets::Assets, Env},
window::WindowBuilder,
Context, EventLoopMessage, Invoke, InvokeError, InvokeResponse, Manager, Runtime, Scopes,
StateManager, Window,
};
Expand Down Expand Up @@ -481,38 +480,6 @@ macro_rules! shared_app_impl {
updater::builder(self.app_handle())
}

/// Creates a new webview window.
///
/// Data URLs are only supported with the `window-data-url` feature flag.
///
/// See [`crate::window::WindowBuilder::new`] for an API with extended functionality.
#[deprecated(
since = "1.0.0-rc.4",
note = "The `window_builder` function offers an easier API with extended functionality"
)]
pub fn create_window<F>(
&self,
label: impl Into<String>,
url: WindowUrl,
setup: F,
) -> crate::Result<Window<R>>
where
F: FnOnce(
<R::Dispatcher as Dispatch<EventLoopMessage>>::WindowBuilder,
WebviewAttributes,
) -> (
<R::Dispatcher as Dispatch<EventLoopMessage>>::WindowBuilder,
WebviewAttributes,
),
{
let mut builder = WindowBuilder::<R>::new(self, label, url);
let (window_builder, webview_attributes) =
setup(builder.window_builder, builder.webview_attributes);
builder.window_builder = window_builder;
builder.webview_attributes = webview_attributes;
builder.build()
}

#[cfg(feature = "system-tray")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "system-tray")))]
/// Gets a handle handle to the system tray.
Expand Down Expand Up @@ -979,48 +946,6 @@ impl<R: Runtime> Builder<R> {
self
}

/// Creates a new webview window.
///
/// # Examples
/// ```rust,no_run
/// use tauri::WindowBuilder;
/// tauri::Builder::default()
/// .create_window("main", tauri::WindowUrl::default(), |win, webview| {
/// let win = win
/// .title("My Main Window")
/// .resizable(true)
/// .inner_size(800.0, 550.0)
/// .min_inner_size(400.0, 200.0);
/// return (win, webview);
/// });
/// ```
pub fn create_window<F>(
mut self,
label: impl Into<String>,
url: WindowUrl,
setup: F,
) -> crate::Result<Self>
where
F: FnOnce(
<R::Dispatcher as Dispatch<EventLoopMessage>>::WindowBuilder,
WebviewAttributes,
) -> (
<R::Dispatcher as Dispatch<EventLoopMessage>>::WindowBuilder,
WebviewAttributes,
),
{
let (window_builder, webview_attributes) = setup(
<R::Dispatcher as Dispatch<EventLoopMessage>>::WindowBuilder::new(),
WebviewAttributes::new(url),
);
self.pending_windows.push(PendingWindow::new(
window_builder,
webview_attributes,
label,
)?);
Ok(self)
}

/// Adds the icon configured on `tauri.conf.json` to the system tray with the specified menu items.
#[cfg(feature = "system-tray")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "system-tray")))]
Expand Down
32 changes: 0 additions & 32 deletions core/tauri/src/window.rs
Expand Up @@ -557,38 +557,6 @@ impl<R: Runtime> Window<R> {
WindowBuilder::<R>::new(manager, label.into(), url)
}

/// Creates a new webview window.
///
/// Data URLs are only supported with the `window-data-url` feature flag.
///
/// See [`Self::builder`] for an API with extended functionality.
#[deprecated(
since = "1.0.0-rc.4",
note = "The `builder` function offers an easier API with extended functionality"
)]
pub fn create_window<F>(
&mut self,
label: String,
url: WindowUrl,
setup: F,
) -> crate::Result<Window<R>>
where
F: FnOnce(
<R::Dispatcher as Dispatch<EventLoopMessage>>::WindowBuilder,
WebviewAttributes,
) -> (
<R::Dispatcher as Dispatch<EventLoopMessage>>::WindowBuilder,
WebviewAttributes,
),
{
let mut builder = WindowBuilder::<R>::new(self, label, url);
let (window_builder, webview_attributes) =
setup(builder.window_builder, builder.webview_attributes);
builder.window_builder = window_builder;
builder.webview_attributes = webview_attributes;
builder.build()
}

pub(crate) fn invoke_responder(&self) -> Arc<InvokeResponder<R>> {
self.manager.invoke_responder()
}
Expand Down

0 comments on commit 7c7d854

Please sign in to comment.