فهرست منبع

refactor(core): remove window endpoints (#6947)

Lucas Fernandes Nogueira 2 سال پیش
والد
کامیت
9a79dc0858

+ 6 - 0
.changes/ipc-scope-remove-enable-tauri-api.md

@@ -0,0 +1,6 @@
+---
+"tauri": patch
+"tauri-utils": patch
+---
+
+Remove `enable_tauri_api` from the IPC scope.

+ 5 - 0
.changes/remove-macros-command-module.md

@@ -0,0 +1,5 @@
+---
+"tauri-macros": patch
+---
+
+Removed the module command macros.

+ 6 - 0
.changes/remove-window.md

@@ -0,0 +1,6 @@
+---
+"tauri": patch
+"api": patch
+---
+
+Moved the `window` JS APIs to its own plugin in the plugins-workspace repository.

+ 0 - 5
core/tauri-config-schema/schema.json

@@ -2508,11 +2508,6 @@
           "items": {
             "type": "string"
           }
-        },
-        "enableTauriAPI": {
-          "description": "Enables access to the Tauri API.",
-          "default": false,
-          "type": "boolean"
         }
       },
       "additionalProperties": false

+ 0 - 303
core/tauri-macros/src/command_module.rs

@@ -1,303 +0,0 @@
-// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
-// SPDX-License-Identifier: Apache-2.0
-// SPDX-License-Identifier: MIT
-
-use heck::{ToLowerCamelCase, ToSnakeCase};
-use proc_macro::TokenStream;
-use proc_macro2::{Span, TokenStream as TokenStream2};
-
-use quote::{format_ident, quote, quote_spanned};
-use syn::{
-  parse::{Parse, ParseStream},
-  parse_quote,
-  spanned::Spanned,
-  Data, DeriveInput, Error, Fields, Ident, ItemFn, LitStr, Token,
-};
-
-pub(crate) fn generate_command_enum(mut input: DeriveInput) -> TokenStream {
-  let mut deserialize_functions = TokenStream2::new();
-  let mut errors = TokenStream2::new();
-
-  input.attrs.push(parse_quote!(#[allow(dead_code)]));
-
-  match &mut input.data {
-    Data::Enum(data_enum) => {
-      for variant in &mut data_enum.variants {
-        let mut feature: Option<Ident> = None;
-        let mut error_message: Option<String> = None;
-
-        for attr in &variant.attrs {
-          if attr.path.is_ident("cmd") {
-            let r = attr
-              .parse_args_with(|input: ParseStream| {
-                if let Ok(f) = input.parse::<Ident>() {
-                  feature.replace(f);
-                  input.parse::<Token![,]>()?;
-                  let error_message_raw: LitStr = input.parse()?;
-                  error_message.replace(error_message_raw.value());
-                }
-                Ok(quote!())
-              })
-              .unwrap_or_else(syn::Error::into_compile_error);
-            errors.extend(r);
-          }
-        }
-
-        if let Some(f) = feature {
-          let error_message = if let Some(e) = error_message {
-            let e = e.to_string();
-            quote!(#e)
-          } else {
-            quote!("This API is not enabled in the allowlist.")
-          };
-
-          let deserialize_function_name = quote::format_ident!("__{}_deserializer", variant.ident);
-          deserialize_functions.extend(quote! {
-            #[cfg(not(#f))]
-            #[allow(non_snake_case)]
-            fn #deserialize_function_name<'de, D, T>(deserializer: D) -> ::std::result::Result<T, D::Error>
-            where
-              D: ::serde::de::Deserializer<'de>,
-            {
-              ::std::result::Result::Err(::serde::de::Error::custom(crate::Error::ApiNotAllowlisted(#error_message.into()).to_string()))
-            }
-          });
-
-          let deserialize_function_name = deserialize_function_name.to_string();
-
-          variant
-          .attrs
-          .push(parse_quote!(#[cfg_attr(not(#f), serde(deserialize_with = #deserialize_function_name))]));
-        }
-      }
-    }
-    _ => {
-      return Error::new(
-        Span::call_site(),
-        "`command_enum` is only implemented for enums",
-      )
-      .to_compile_error()
-      .into()
-    }
-  };
-
-  TokenStream::from(quote! {
-    #errors
-    #input
-    #deserialize_functions
-  })
-}
-
-pub(crate) fn generate_run_fn(input: DeriveInput) -> TokenStream {
-  let name = &input.ident;
-  let data = &input.data;
-
-  let mut errors = TokenStream2::new();
-
-  let mut is_async = false;
-
-  let attrs = input.attrs;
-  for attr in attrs {
-    if attr.path.is_ident("cmd") {
-      let r = attr
-        .parse_args_with(|input: ParseStream| {
-          if let Ok(token) = input.parse::<Ident>() {
-            is_async = token == "async";
-          }
-          Ok(quote!())
-        })
-        .unwrap_or_else(syn::Error::into_compile_error);
-      errors.extend(r);
-    }
-  }
-
-  let maybe_await = if is_async { quote!(.await) } else { quote!() };
-  let maybe_async = if is_async { quote!(async) } else { quote!() };
-
-  let mut matcher;
-
-  match data {
-    Data::Enum(data_enum) => {
-      matcher = TokenStream2::new();
-
-      for variant in &data_enum.variants {
-        let variant_name = &variant.ident;
-
-        let mut feature = None;
-
-        for attr in &variant.attrs {
-          if attr.path.is_ident("cmd") {
-            let r = attr
-              .parse_args_with(|input: ParseStream| {
-                if let Ok(f) = input.parse::<Ident>() {
-                  feature.replace(f);
-                  input.parse::<Token![,]>()?;
-                  let _: LitStr = input.parse()?;
-                }
-                Ok(quote!())
-              })
-              .unwrap_or_else(syn::Error::into_compile_error);
-            errors.extend(r);
-          }
-        }
-
-        let maybe_feature_check = if let Some(f) = feature {
-          quote!(#[cfg(#f)])
-        } else {
-          quote!()
-        };
-
-        let (fields_in_variant, variables) = match &variant.fields {
-          Fields::Unit => (quote_spanned! { variant.span() => }, quote!()),
-          Fields::Unnamed(fields) => {
-            let mut variables = TokenStream2::new();
-            for i in 0..fields.unnamed.len() {
-              let variable_name = format_ident!("value{}", i);
-              variables.extend(quote!(#variable_name,));
-            }
-            (quote_spanned! { variant.span() => (#variables) }, variables)
-          }
-          Fields::Named(fields) => {
-            let mut variables = TokenStream2::new();
-            for field in &fields.named {
-              let ident = field.ident.as_ref().unwrap();
-              variables.extend(quote!(#ident,));
-            }
-            (
-              quote_spanned! { variant.span() => { #variables } },
-              variables,
-            )
-          }
-        };
-
-        let mut variant_execute_function_name = format_ident!(
-          "{}",
-          variant_name.to_string().to_snake_case().to_lowercase()
-        );
-        variant_execute_function_name.set_span(variant_name.span());
-
-        matcher.extend(quote_spanned! {
-          variant.span() => #maybe_feature_check #name::#variant_name #fields_in_variant => #name::#variant_execute_function_name(context, #variables)#maybe_await.map(Into::into),
-        });
-      }
-
-      matcher.extend(quote! {
-        _ => Err(crate::error::into_anyhow("API not in the allowlist (https://tauri.app/docs/api/config#tauri.allowlist)")),
-      });
-    }
-    _ => {
-      return Error::new(
-        Span::call_site(),
-        "CommandModule is only implemented for enums",
-      )
-      .to_compile_error()
-      .into()
-    }
-  };
-
-  let (impl_generics, ty_generics, where_clause) = input.generics.split_for_impl();
-
-  let expanded = quote! {
-    #errors
-    impl #impl_generics #name #ty_generics #where_clause {
-        pub #maybe_async fn run<R: crate::Runtime>(self, context: crate::endpoints::InvokeContext<R>) -> super::Result<crate::endpoints::InvokeResponse> {
-          match self {
-            #matcher
-          }
-        }
-      }
-  };
-
-  TokenStream::from(expanded)
-}
-
-/// Attributes for the module enum variant handler.
-pub struct HandlerAttributes {
-  allowlist: Ident,
-}
-
-impl Parse for HandlerAttributes {
-  fn parse(input: ParseStream) -> syn::Result<Self> {
-    Ok(Self {
-      allowlist: input.parse()?,
-    })
-  }
-}
-
-pub enum AllowlistCheckKind {
-  Runtime,
-  Serde,
-}
-
-pub struct HandlerTestAttributes {
-  allowlist: Ident,
-  error_message: String,
-  allowlist_check_kind: AllowlistCheckKind,
-}
-
-impl Parse for HandlerTestAttributes {
-  fn parse(input: ParseStream) -> syn::Result<Self> {
-    let allowlist = input.parse()?;
-    input.parse::<Token![,]>()?;
-    let error_message_raw: LitStr = input.parse()?;
-    let error_message = error_message_raw.value();
-    let allowlist_check_kind =
-      if let (Ok(_), Ok(i)) = (input.parse::<Token![,]>(), input.parse::<Ident>()) {
-        if i == "runtime" {
-          AllowlistCheckKind::Runtime
-        } else {
-          AllowlistCheckKind::Serde
-        }
-      } else {
-        AllowlistCheckKind::Serde
-      };
-
-    Ok(Self {
-      allowlist,
-      error_message,
-      allowlist_check_kind,
-    })
-  }
-}
-
-pub fn command_handler(attributes: HandlerAttributes, function: ItemFn) -> TokenStream2 {
-  let allowlist = attributes.allowlist;
-
-  quote!(
-    #[cfg(#allowlist)]
-    #function
-  )
-}
-
-pub fn command_test(attributes: HandlerTestAttributes, function: ItemFn) -> TokenStream2 {
-  let allowlist = attributes.allowlist;
-  let error_message = attributes.error_message.as_str();
-  let signature = function.sig.clone();
-
-  let enum_variant_name = function.sig.ident.to_string().to_lower_camel_case();
-  let response = match attributes.allowlist_check_kind {
-    AllowlistCheckKind::Runtime => {
-      let test_name = function.sig.ident.clone();
-      quote!(super::Cmd::#test_name(crate::test::mock_invoke_context()))
-    }
-    AllowlistCheckKind::Serde => quote! {
-      serde_json::from_str::<super::Cmd>(&format!(r#"{{ "cmd": "{}", "data": null }}"#, #enum_variant_name))
-    },
-  };
-
-  quote!(
-    #[cfg(#allowlist)]
-    #function
-
-    #[cfg(not(#allowlist))]
-    #[allow(unused_variables)]
-    #[quickcheck_macros::quickcheck]
-    #signature {
-      if let Err(e) = #response {
-        assert!(e.to_string().contains(#error_message));
-      } else {
-        panic!("unexpected response");
-      }
-    }
-  )
-}

+ 1 - 39
core/tauri-macros/src/lib.rs

@@ -4,10 +4,9 @@
 
 use crate::context::ContextItems;
 use proc_macro::TokenStream;
-use syn::{parse_macro_input, DeriveInput, ItemFn};
+use syn::{parse_macro_input, DeriveInput};
 
 mod command;
-mod command_module;
 mod mobile;
 mod runtime;
 
@@ -81,40 +80,3 @@ pub fn default_runtime(attributes: TokenStream, input: TokenStream) -> TokenStre
   let input = parse_macro_input!(input as DeriveInput);
   runtime::default_runtime(attributes, input).into()
 }
-
-/// Prepares the command module enum.
-#[doc(hidden)]
-#[proc_macro_derive(CommandModule, attributes(cmd))]
-pub fn derive_command_module(input: TokenStream) -> TokenStream {
-  let input = parse_macro_input!(input as DeriveInput);
-  command_module::generate_run_fn(input)
-}
-
-/// Adds a `run` method to an enum (one of the tauri endpoint modules).
-/// The `run` method takes a `tauri::endpoints::InvokeContext`
-/// and returns a `tauri::Result<tauri::endpoints::InvokeResponse>`.
-/// It matches on each enum variant and call a method with name equal to the variant name, lowercased and snake_cased,
-/// passing the context and the variant's fields as arguments.
-/// That function must also return the same `Result<InvokeResponse>`.
-#[doc(hidden)]
-#[proc_macro_attribute]
-pub fn command_enum(_: TokenStream, input: TokenStream) -> TokenStream {
-  let input = parse_macro_input!(input as DeriveInput);
-  command_module::generate_command_enum(input)
-}
-
-#[doc(hidden)]
-#[proc_macro_attribute]
-pub fn module_command_handler(attributes: TokenStream, input: TokenStream) -> TokenStream {
-  let attributes = parse_macro_input!(attributes as command_module::HandlerAttributes);
-  let input = parse_macro_input!(input as ItemFn);
-  command_module::command_handler(attributes, input).into()
-}
-
-#[doc(hidden)]
-#[proc_macro_attribute]
-pub fn module_command_test(attributes: TokenStream, input: TokenStream) -> TokenStream {
-  let attributes = parse_macro_input!(attributes as command_module::HandlerTestAttributes);
-  let input = parse_macro_input!(input as ItemFn);
-  command_module::command_test(attributes, input).into()
-}

+ 1 - 6
core/tauri-utils/src/config.rs

@@ -1019,9 +1019,6 @@ pub struct RemoteDomainAccessScope {
   /// The list of plugins that are allowed in this scope.
   #[serde(default)]
   pub plugins: Vec<String>,
-  /// Enables access to the Tauri API.
-  #[serde(default, rename = "enableTauriAPI", alias = "enable-tauri-api")]
-  pub enable_tauri_api: bool,
 }
 
 /// Security configuration.
@@ -3344,7 +3341,6 @@ mod build {
       let domain = str_lit(&self.domain);
       let windows = vec_lit(&self.windows, str_lit);
       let plugins = vec_lit(&self.plugins, str_lit);
-      let enable_tauri_api = self.enable_tauri_api;
 
       literal_struct!(
         tokens,
@@ -3352,8 +3348,7 @@ mod build {
         scheme,
         domain,
         windows,
-        plugins,
-        enable_tauri_api
+        plugins
       );
     }
   }

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 0 - 0
core/tauri/scripts/bundle.global.js


+ 0 - 116
core/tauri/src/endpoints.rs

@@ -1,116 +0,0 @@
-// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
-// SPDX-License-Identifier: Apache-2.0
-// SPDX-License-Identifier: MIT
-
-use crate::{
-  hooks::{InvokeError, InvokeMessage, InvokeResolver},
-  Config, Invoke, PackageInfo, Runtime, Window,
-};
-pub use anyhow::Result;
-use serde::{Deserialize, Serialize};
-use serde_json::Value as JsonValue;
-
-use std::sync::Arc;
-
-mod window;
-
-/// The context passed to the invoke handler.
-pub struct InvokeContext<R: Runtime> {
-  pub window: Window<R>,
-  pub config: Arc<Config>,
-  pub package_info: PackageInfo,
-}
-
-#[cfg(test)]
-impl<R: Runtime> Clone for InvokeContext<R> {
-  fn clone(&self) -> Self {
-    Self {
-      window: self.window.clone(),
-      config: self.config.clone(),
-      package_info: self.package_info.clone(),
-    }
-  }
-}
-
-/// The response for a JS `invoke` call.
-pub struct InvokeResponse {
-  json: Result<JsonValue>,
-}
-
-impl<T: Serialize> From<T> for InvokeResponse {
-  fn from(value: T) -> Self {
-    Self {
-      json: serde_json::to_value(value).map_err(Into::into),
-    }
-  }
-}
-
-#[derive(Deserialize)]
-#[serde(tag = "module", content = "message")]
-enum Module {
-  Window(Box<window::Cmd>),
-}
-
-impl Module {
-  fn run<R: Runtime>(
-    self,
-    window: Window<R>,
-    resolver: InvokeResolver<R>,
-    config: Arc<Config>,
-    package_info: PackageInfo,
-  ) {
-    let context = InvokeContext {
-      window,
-      config,
-      package_info,
-    };
-    match self {
-      Self::Window(cmd) => resolver.respond_async(async move {
-        cmd
-          .run(context)
-          .await
-          .and_then(|r| r.json)
-          .map_err(InvokeError::from_anyhow)
-      }),
-    }
-  }
-}
-
-pub(crate) fn handle<R: Runtime>(
-  module: String,
-  invoke: Invoke<R>,
-  config: Arc<Config>,
-  package_info: &PackageInfo,
-) {
-  let Invoke { message, resolver } = invoke;
-  let InvokeMessage {
-    mut payload,
-    window,
-    ..
-  } = message;
-
-  if let JsonValue::Object(ref mut obj) = payload {
-    obj.insert("module".to_string(), JsonValue::String(module.clone()));
-  }
-
-  match serde_json::from_value::<Module>(payload) {
-    Ok(module) => module.run(window, resolver, config, package_info.clone()),
-    Err(e) => {
-      let message = e.to_string();
-      if message.starts_with("unknown variant") {
-        let mut s = message.split('`');
-        s.next();
-        if let Some(unknown_variant_name) = s.next() {
-          if unknown_variant_name == module {
-            return resolver.reject(format!(
-              "The `{module}` module is not enabled. You must enable one of its APIs in the allowlist.",
-            ));
-          } else if module == "Window" {
-            return resolver.reject(window::into_allowlist_error(unknown_variant_name).to_string());
-          }
-        }
-      }
-      resolver.reject(message);
-    }
-  }
-}

+ 0 - 364
core/tauri/src/endpoints/window.rs

@@ -1,364 +0,0 @@
-// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
-// SPDX-License-Identifier: Apache-2.0
-// SPDX-License-Identifier: MIT
-
-#![allow(unused_imports)]
-
-use super::{InvokeContext, InvokeResponse};
-#[cfg(window_create)]
-use crate::runtime::{webview::WindowBuilder, Dispatch};
-use crate::{
-  runtime::{
-    window::dpi::{Position, Size},
-    UserAttentionType,
-  },
-  utils::config::WindowConfig,
-  CursorIcon, Icon, Manager, Runtime,
-};
-use serde::Deserialize;
-use tauri_macros::{command_enum, module_command_handler, CommandModule};
-
-#[derive(Deserialize)]
-#[serde(untagged)]
-pub enum IconDto {
-  #[cfg(any(feature = "icon-png", feature = "icon-ico"))]
-  File(std::path::PathBuf),
-  #[cfg(any(feature = "icon-png", feature = "icon-ico"))]
-  Raw(Vec<u8>),
-  Rgba {
-    rgba: Vec<u8>,
-    width: u32,
-    height: u32,
-  },
-}
-
-impl From<IconDto> for Icon {
-  fn from(icon: IconDto) -> Self {
-    match icon {
-      #[cfg(any(feature = "icon-png", feature = "icon-ico"))]
-      IconDto::File(path) => Self::File(path),
-      #[cfg(any(feature = "icon-png", feature = "icon-ico"))]
-      IconDto::Raw(raw) => Self::Raw(raw),
-      IconDto::Rgba {
-        rgba,
-        width,
-        height,
-      } => Self::Rgba {
-        rgba,
-        width,
-        height,
-      },
-    }
-  }
-}
-
-/// Window management API descriptor.
-#[derive(Deserialize)]
-#[serde(tag = "type", content = "payload", rename_all = "camelCase")]
-pub enum WindowManagerCmd {
-  // Getters
-  ScaleFactor,
-  InnerPosition,
-  OuterPosition,
-  InnerSize,
-  OuterSize,
-  IsFullscreen,
-  IsMinimized,
-  IsMaximized,
-  IsDecorated,
-  IsResizable,
-  IsVisible,
-  Title,
-  CurrentMonitor,
-  PrimaryMonitor,
-  AvailableMonitors,
-  Theme,
-  // Setters
-  #[cfg(window_center)]
-  Center,
-  #[cfg(window_request_user_attention)]
-  RequestUserAttention(Option<UserAttentionType>),
-  #[cfg(window_set_resizable)]
-  SetResizable(bool),
-  #[cfg(window_set_title)]
-  SetTitle(String),
-  #[cfg(window_maximize)]
-  Maximize,
-  #[cfg(window_unmaximize)]
-  Unmaximize,
-  #[cfg(all(window_maximize, window_unmaximize))]
-  ToggleMaximize,
-  #[cfg(window_minimize)]
-  Minimize,
-  #[cfg(window_unminimize)]
-  Unminimize,
-  #[cfg(window_show)]
-  Show,
-  #[cfg(window_hide)]
-  Hide,
-  #[cfg(window_close)]
-  Close,
-  #[cfg(window_set_decorations)]
-  SetDecorations(bool),
-  #[cfg(window_set_shadow)]
-  SetShadow(bool),
-  #[cfg(window_set_always_on_top)]
-  #[serde(rename_all = "camelCase")]
-  SetAlwaysOnTop(bool),
-  #[cfg(window_set_content_protected)]
-  SetContentProtected(bool),
-  #[cfg(window_set_size)]
-  SetSize(Size),
-  #[cfg(window_set_min_size)]
-  SetMinSize(Option<Size>),
-  #[cfg(window_set_max_size)]
-  SetMaxSize(Option<Size>),
-  #[cfg(window_set_position)]
-  SetPosition(Position),
-  #[cfg(window_set_fullscreen)]
-  SetFullscreen(bool),
-  #[cfg(window_set_focus)]
-  SetFocus,
-  #[cfg(window_set_icon)]
-  SetIcon {
-    icon: IconDto,
-  },
-  #[cfg(window_set_skip_taskbar)]
-  SetSkipTaskbar(bool),
-  #[cfg(window_set_cursor_grab)]
-  SetCursorGrab(bool),
-  #[cfg(window_set_cursor_visible)]
-  SetCursorVisible(bool),
-  #[cfg(window_set_cursor_icon)]
-  SetCursorIcon(CursorIcon),
-  #[cfg(window_set_cursor_position)]
-  SetCursorPosition(Position),
-  #[cfg(window_set_ignore_cursor_events)]
-  SetIgnoreCursorEvents(bool),
-  #[cfg(window_start_dragging)]
-  StartDragging,
-  #[cfg(window_print)]
-  Print,
-  // internals
-  #[cfg(all(window_maximize, window_unmaximize))]
-  #[serde(rename = "__toggleMaximize")]
-  InternalToggleMaximize,
-  #[cfg(any(debug_assertions, feature = "devtools"))]
-  #[serde(rename = "__toggleDevtools")]
-  InternalToggleDevtools,
-}
-
-pub fn into_allowlist_error(variant: &str) -> crate::Error {
-  match variant {
-    "center" => crate::Error::ApiNotAllowlisted("window > center".to_string()),
-    "requestUserAttention" => {
-      crate::Error::ApiNotAllowlisted("window > requestUserAttention".to_string())
-    }
-    "setResizable" => crate::Error::ApiNotAllowlisted("window > setResizable".to_string()),
-    "setTitle" => crate::Error::ApiNotAllowlisted("window > setTitle".to_string()),
-    "maximize" => crate::Error::ApiNotAllowlisted("window > maximize".to_string()),
-    "unmaximize" => crate::Error::ApiNotAllowlisted("window > unmaximize".to_string()),
-    "toggleMaximize" => {
-      crate::Error::ApiNotAllowlisted("window > maximize and window > unmaximize".to_string())
-    }
-    "minimize" => crate::Error::ApiNotAllowlisted("window > minimize".to_string()),
-    "unminimize" => crate::Error::ApiNotAllowlisted("window > unminimize".to_string()),
-    "show" => crate::Error::ApiNotAllowlisted("window > show".to_string()),
-    "hide" => crate::Error::ApiNotAllowlisted("window > hide".to_string()),
-    "close" => crate::Error::ApiNotAllowlisted("window > close".to_string()),
-    "setDecorations" => crate::Error::ApiNotAllowlisted("window > setDecorations".to_string()),
-    "setShadow" => crate::Error::ApiNotAllowlisted("window > setShadow".to_string()),
-    "setAlwaysOnTop" => crate::Error::ApiNotAllowlisted("window > setAlwaysOnTop".to_string()),
-    "setContentProtected" => {
-      crate::Error::ApiNotAllowlisted("window > setContentProtected".to_string())
-    }
-    "setSize" => crate::Error::ApiNotAllowlisted("window > setSize".to_string()),
-    "setMinSize" => crate::Error::ApiNotAllowlisted("window > setMinSize".to_string()),
-    "setMaxSize" => crate::Error::ApiNotAllowlisted("window > setMaxSize".to_string()),
-    "setPosition" => crate::Error::ApiNotAllowlisted("window > setPosition".to_string()),
-    "setFullscreen" => crate::Error::ApiNotAllowlisted("window > setFullscreen".to_string()),
-    "setIcon" => crate::Error::ApiNotAllowlisted("window > setIcon".to_string()),
-    "setSkipTaskbar" => crate::Error::ApiNotAllowlisted("window > setSkipTaskbar".to_string()),
-    "setCursorGrab" => crate::Error::ApiNotAllowlisted("window > setCursorGrab".to_string()),
-    "setCursorVisible" => crate::Error::ApiNotAllowlisted("window > setCursorVisible".to_string()),
-    "setCursorIcon" => crate::Error::ApiNotAllowlisted("window > setCursorIcon".to_string()),
-    "setCursorPosition" => {
-      crate::Error::ApiNotAllowlisted("window > setCursorPosition".to_string())
-    }
-    "setIgnoreCursorEvents" => {
-      crate::Error::ApiNotAllowlisted("window > setIgnoreCursorEvents".to_string())
-    }
-    "startDragging" => crate::Error::ApiNotAllowlisted("window > startDragging".to_string()),
-    "print" => crate::Error::ApiNotAllowlisted("window > print".to_string()),
-    "__toggleMaximize" => {
-      crate::Error::ApiNotAllowlisted("window > maximize and window > unmaximize".to_string())
-    }
-    "__toggleDevtools" => crate::Error::ApiNotAllowlisted("devtools".to_string()),
-    _ => crate::Error::ApiNotAllowlisted("window".to_string()),
-  }
-}
-
-/// The API descriptor.
-#[command_enum]
-#[derive(Deserialize, CommandModule)]
-#[cmd(async)]
-#[serde(tag = "cmd", content = "data", rename_all = "camelCase")]
-pub enum Cmd {
-  #[cmd(window_create, "window > create")]
-  CreateWebview { options: Box<WindowConfig> },
-  Manage {
-    label: Option<String>,
-    cmd: WindowManagerCmd,
-  },
-}
-
-impl Cmd {
-  #[module_command_handler(window_create)]
-  async fn create_webview<R: Runtime>(
-    context: InvokeContext<R>,
-    mut options: Box<WindowConfig>,
-  ) -> super::Result<()> {
-    options.additional_browser_args = None;
-    crate::window::WindowBuilder::from_config(&context.window, *options)
-      .build()
-      .map_err(crate::error::into_anyhow)?;
-    Ok(())
-  }
-
-  async fn manage<R: Runtime>(
-    context: InvokeContext<R>,
-    label: Option<String>,
-    cmd: WindowManagerCmd,
-  ) -> super::Result<InvokeResponse> {
-    Self::_manage(context, label, cmd)
-      .await
-      .map_err(crate::error::into_anyhow)
-  }
-
-  async fn _manage<R: Runtime>(
-    context: InvokeContext<R>,
-    label: Option<String>,
-    cmd: WindowManagerCmd,
-  ) -> crate::Result<InvokeResponse> {
-    let window = match label {
-      Some(l) if !l.is_empty() => context
-        .window
-        .get_window(&l)
-        .ok_or(crate::Error::WebviewNotFound)?,
-      _ => context.window,
-    };
-    match cmd {
-      // Getters
-      WindowManagerCmd::ScaleFactor => return Ok(window.scale_factor()?.into()),
-      WindowManagerCmd::InnerPosition => return Ok(window.inner_position()?.into()),
-      WindowManagerCmd::OuterPosition => return Ok(window.outer_position()?.into()),
-      WindowManagerCmd::InnerSize => return Ok(window.inner_size()?.into()),
-      WindowManagerCmd::OuterSize => return Ok(window.outer_size()?.into()),
-      WindowManagerCmd::IsFullscreen => return Ok(window.is_fullscreen()?.into()),
-      WindowManagerCmd::IsMinimized => return Ok(window.is_minimized()?.into()),
-      WindowManagerCmd::IsMaximized => return Ok(window.is_maximized()?.into()),
-      WindowManagerCmd::IsDecorated => return Ok(window.is_decorated()?.into()),
-      WindowManagerCmd::IsResizable => return Ok(window.is_resizable()?.into()),
-      WindowManagerCmd::IsVisible => return Ok(window.is_visible()?.into()),
-      WindowManagerCmd::Title => return Ok(window.title()?.into()),
-      WindowManagerCmd::CurrentMonitor => return Ok(window.current_monitor()?.into()),
-      WindowManagerCmd::PrimaryMonitor => return Ok(window.primary_monitor()?.into()),
-      WindowManagerCmd::AvailableMonitors => return Ok(window.available_monitors()?.into()),
-      WindowManagerCmd::Theme => return Ok(window.theme()?.into()),
-      // Setters
-      #[cfg(all(desktop, window_center))]
-      WindowManagerCmd::Center => window.center()?,
-      #[cfg(all(desktop, window_request_user_attention))]
-      WindowManagerCmd::RequestUserAttention(request_type) => {
-        window.request_user_attention(request_type)?
-      }
-      #[cfg(all(desktop, window_set_resizable))]
-      WindowManagerCmd::SetResizable(resizable) => window.set_resizable(resizable)?,
-      #[cfg(all(desktop, window_set_title))]
-      WindowManagerCmd::SetTitle(title) => window.set_title(&title)?,
-      #[cfg(all(desktop, window_maximize))]
-      WindowManagerCmd::Maximize => window.maximize()?,
-      #[cfg(all(desktop, window_unmaximize))]
-      WindowManagerCmd::Unmaximize => window.unmaximize()?,
-      #[cfg(all(desktop, window_maximize, window_unmaximize))]
-      WindowManagerCmd::ToggleMaximize => match window.is_maximized()? {
-        true => window.unmaximize()?,
-        false => window.maximize()?,
-      },
-      #[cfg(all(desktop, window_minimize))]
-      WindowManagerCmd::Minimize => window.minimize()?,
-      #[cfg(all(desktop, window_unminimize))]
-      WindowManagerCmd::Unminimize => window.unminimize()?,
-      #[cfg(all(desktop, window_show))]
-      WindowManagerCmd::Show => window.show()?,
-      #[cfg(all(desktop, window_hide))]
-      WindowManagerCmd::Hide => window.hide()?,
-      #[cfg(all(desktop, window_close))]
-      WindowManagerCmd::Close => window.close()?,
-      #[cfg(all(desktop, window_set_decorations))]
-      WindowManagerCmd::SetDecorations(decorations) => window.set_decorations(decorations)?,
-      #[cfg(all(desktop, window_set_shadow))]
-      WindowManagerCmd::SetShadow(enable) => window.set_shadow(enable)?,
-      #[cfg(all(desktop, window_set_always_on_top))]
-      WindowManagerCmd::SetAlwaysOnTop(always_on_top) => window.set_always_on_top(always_on_top)?,
-      #[cfg(all(desktop, window_set_content_protected))]
-      WindowManagerCmd::SetContentProtected(protected) => {
-        window.set_content_protected(protected)?
-      }
-      #[cfg(all(desktop, window_set_size))]
-      WindowManagerCmd::SetSize(size) => window.set_size(size)?,
-      #[cfg(all(desktop, window_set_min_size))]
-      WindowManagerCmd::SetMinSize(size) => window.set_min_size(size)?,
-      #[cfg(all(desktop, window_set_max_size))]
-      WindowManagerCmd::SetMaxSize(size) => window.set_max_size(size)?,
-      #[cfg(all(desktop, window_set_position))]
-      WindowManagerCmd::SetPosition(position) => window.set_position(position)?,
-      #[cfg(all(desktop, window_set_fullscreen))]
-      WindowManagerCmd::SetFullscreen(fullscreen) => window.set_fullscreen(fullscreen)?,
-      #[cfg(all(desktop, window_set_focus))]
-      WindowManagerCmd::SetFocus => window.set_focus()?,
-      #[cfg(all(desktop, window_set_icon))]
-      WindowManagerCmd::SetIcon { icon } => window.set_icon(icon.into())?,
-      #[cfg(all(desktop, window_set_skip_taskbar))]
-      WindowManagerCmd::SetSkipTaskbar(skip) => window.set_skip_taskbar(skip)?,
-      #[cfg(all(desktop, window_set_cursor_grab))]
-      WindowManagerCmd::SetCursorGrab(grab) => window.set_cursor_grab(grab)?,
-      #[cfg(all(desktop, window_set_cursor_visible))]
-      WindowManagerCmd::SetCursorVisible(visible) => window.set_cursor_visible(visible)?,
-      #[cfg(all(desktop, window_set_cursor_icon))]
-      WindowManagerCmd::SetCursorIcon(icon) => window.set_cursor_icon(icon)?,
-      #[cfg(all(desktop, window_set_cursor_position))]
-      WindowManagerCmd::SetCursorPosition(position) => window.set_cursor_position(position)?,
-      #[cfg(all(desktop, window_set_ignore_cursor_events))]
-      WindowManagerCmd::SetIgnoreCursorEvents(ignore_cursor) => {
-        window.set_ignore_cursor_events(ignore_cursor)?
-      }
-      #[cfg(all(desktop, window_start_dragging))]
-      WindowManagerCmd::StartDragging => window.start_dragging()?,
-      #[cfg(all(desktop, window_print))]
-      WindowManagerCmd::Print => window.print()?,
-      // internals
-      #[cfg(all(desktop, window_maximize, window_unmaximize))]
-      WindowManagerCmd::InternalToggleMaximize => {
-        if window.is_resizable()? {
-          match window.is_maximized()? {
-            true => window.unmaximize()?,
-            false => window.maximize()?,
-          }
-        }
-      }
-      #[cfg(all(desktop, any(debug_assertions, feature = "devtools")))]
-      WindowManagerCmd::InternalToggleDevtools => {
-        if window.is_devtools_open() {
-          window.close_devtools();
-        } else {
-          window.open_devtools();
-        }
-      }
-      #[allow(unreachable_patterns)]
-      _ => (),
-    }
-    #[allow(unreachable_code)]
-    Ok(().into())
-  }
-}

+ 1 - 25
core/tauri/src/error.rs

@@ -51,10 +51,7 @@ pub enum Error {
   AssetNotFound(String),
   /// Failed to serialize/deserialize.
   #[error("JSON error: {0}")]
-  Json(serde_json::Error),
-  /// Unknown API type.
-  #[error("unknown API: {0:?}")]
-  UnknownApi(Option<serde_json::Error>),
+  Json(#[from] serde_json::Error),
   /// Failed to execute tauri API.
   #[error("failed to execute API: {0}")]
   FailedToExecuteApi(#[from] crate::api::Error),
@@ -105,24 +102,3 @@ pub enum Error {
   #[error("jni error: {0}")]
   Jni(#[from] jni::errors::Error),
 }
-
-pub(crate) fn into_anyhow<T: std::fmt::Display>(err: T) -> anyhow::Error {
-  anyhow::anyhow!(err.to_string())
-}
-
-impl Error {
-  #[allow(dead_code)]
-  pub(crate) fn into_anyhow(self) -> anyhow::Error {
-    anyhow::anyhow!(self.to_string())
-  }
-}
-
-impl From<serde_json::Error> for Error {
-  fn from(error: serde_json::Error) -> Self {
-    if error.to_string().contains("unknown variant") {
-      Self::UnknownApi(Some(error))
-    } else {
-      Self::Json(error)
-    }
-  }
-}

+ 0 - 3
core/tauri/src/hooks.rs

@@ -61,9 +61,6 @@ impl PageLoadPayload {
 pub struct InvokePayload {
   /// The invoke command.
   pub cmd: String,
-  #[serde(rename = "__tauriModule")]
-  #[doc(hidden)]
-  pub tauri_module: Option<String>,
   /// The success callback.
   pub callback: CallbackFn,
   /// The error callback.

+ 0 - 2
core/tauri/src/lib.rs

@@ -179,8 +179,6 @@ pub mod api;
 pub(crate) mod app;
 pub mod async_runtime;
 pub mod command;
-/// The Tauri API endpoints.
-mod endpoints;
 mod error;
 mod event;
 mod hooks;

+ 14 - 26
core/tauri/src/scope/ipc.rs

@@ -14,7 +14,6 @@ pub struct RemoteDomainAccessScope {
   domain: String,
   windows: Vec<String>,
   plugins: Vec<String>,
-  enable_tauri_api: bool,
 }
 
 impl RemoteDomainAccessScope {
@@ -25,7 +24,6 @@ impl RemoteDomainAccessScope {
       domain: domain.into(),
       windows: Vec::new(),
       plugins: Vec::new(),
-      enable_tauri_api: false,
     }
   }
 
@@ -47,9 +45,13 @@ impl RemoteDomainAccessScope {
     self
   }
 
-  /// Enables access to the Tauri API.
-  pub fn enable_tauri_api(mut self) -> Self {
-    self.enable_tauri_api = true;
+  /// Adds the given list of plugins to the allowed plugin list.
+  pub fn add_plugins<I, S>(mut self, plugins: I) -> Self
+  where
+    I: IntoIterator<Item = S>,
+    S: Into<String>,
+  {
+    self.plugins.extend(plugins.into_iter().map(Into::into));
     self
   }
 
@@ -67,11 +69,6 @@ impl RemoteDomainAccessScope {
   pub fn plugins(&self) -> &Vec<String> {
     &self.plugins
   }
-
-  /// Whether this scope enables Tauri API access or not.
-  pub fn enables_tauri_api(&self) -> bool {
-    self.enable_tauri_api
-  }
 }
 
 pub(crate) struct RemoteAccessError {
@@ -99,7 +96,6 @@ impl Scope {
         domain: s.domain,
         windows: s.windows,
         plugins: s.plugins,
-        enable_tauri_api: s.enable_tauri_api,
       })
       .collect();
 
@@ -119,7 +115,7 @@ impl Scope {
   ///     app.ipc_scope().configure_remote_access(
   ///       RemoteDomainAccessScope::new("tauri.app")
   ///         .add_window("main")
-  ///         .enable_tauri_api()
+  ///         .add_plugins(["path", "event"])
   ///       );
   ///     Ok(())
   ///   });
@@ -238,7 +234,6 @@ mod tests {
 
     InvokePayload {
       cmd: "plugin:path|is_absolute".into(),
-      tauri_module: None,
       callback,
       error,
       inner: serde_json::Value::Object(payload),
@@ -251,7 +246,6 @@ mod tests {
 
     InvokePayload {
       cmd: format!("plugin:{PLUGIN_NAME}|doSomething"),
-      tauri_module: None,
       callback,
       error,
       inner: Default::default(),
@@ -262,8 +256,7 @@ mod tests {
   fn scope_not_defined() {
     let (_app, window) = test_context(vec![RemoteDomainAccessScope::new("app.tauri.app")
       .add_window("other")
-      .add_plugin("path")
-      .enable_tauri_api()]);
+      .add_plugin("path")]);
 
     window.navigate("https://tauri.app".parse().unwrap());
     assert_ipc_response::<()>(
@@ -280,8 +273,7 @@ mod tests {
   fn scope_not_defined_for_window() {
     let (_app, window) = test_context(vec![RemoteDomainAccessScope::new("tauri.app")
       .add_window("second")
-      .add_plugin("path")
-      .enable_tauri_api()]);
+      .add_plugin("path")]);
 
     window.navigate("https://tauri.app".parse().unwrap());
     assert_ipc_response::<()>(
@@ -295,8 +287,7 @@ mod tests {
   fn scope_not_defined_for_url() {
     let (_app, window) = test_context(vec![RemoteDomainAccessScope::new("github.com")
       .add_window("main")
-      .add_plugin("path")
-      .enable_tauri_api()]);
+      .add_plugin("path")]);
 
     window.navigate("https://tauri.app".parse().unwrap());
     assert_ipc_response::<()>(
@@ -313,12 +304,10 @@ mod tests {
     let (_app, mut window) = test_context(vec![
       RemoteDomainAccessScope::new("tauri.app")
         .add_window("main")
-        .add_plugin("path")
-        .enable_tauri_api(),
+        .add_plugin("path"),
       RemoteDomainAccessScope::new("sub.tauri.app")
         .add_window("main")
-        .add_plugin("path")
-        .enable_tauri_api(),
+        .add_plugin("path"),
     ]);
 
     window.navigate("https://tauri.app".parse().unwrap());
@@ -352,8 +341,7 @@ mod tests {
   fn subpath_is_allowed() {
     let (_app, window) = test_context(vec![RemoteDomainAccessScope::new("tauri.app")
       .add_window("main")
-      .add_plugin("path")
-      .enable_tauri_api()]);
+      .add_plugin("path")]);
 
     window.navigate("https://tauri.app/inner/path".parse().unwrap());
     assert_ipc_response(&window, path_is_absolute_payload(), Ok(true));

+ 1 - 11
core/tauri/src/test/mod.rs

@@ -9,7 +9,7 @@ pub use mock_runtime::*;
 
 use std::{borrow::Cow, sync::Arc};
 
-use crate::{Manager, Pattern, WindowBuilder};
+use crate::{Pattern, WindowBuilder};
 use tauri_utils::{
   assets::{AssetKey, Assets, CspHash},
   config::{Config, PatternKind, TauriConfig, WindowUrl},
@@ -81,13 +81,3 @@ pub fn mock_app() -> crate::App<MockRuntime> {
 
   app
 }
-
-#[allow(dead_code)]
-pub(crate) fn mock_invoke_context() -> crate::endpoints::InvokeContext<MockRuntime> {
-  let app = mock_app();
-  crate::endpoints::InvokeContext {
-    window: app.get_window("main").unwrap(),
-    config: app.config(),
-    package_info: app.package_info().clone(),
-  }
-}

+ 1 - 12
core/tauri/src/window.rs

@@ -1516,18 +1516,7 @@ impl<R: Runtime> Window<R> {
           return Ok(());
         }
 
-        if let Some(module) = &payload.tauri_module {
-          if !is_local && scope.map(|s| !s.enables_tauri_api()).unwrap_or_default() {
-            invoke.resolver.reject(IPC_SCOPE_DOES_NOT_ALLOW);
-            return Ok(());
-          }
-          crate::endpoints::handle(
-            module.to_string(),
-            invoke,
-            manager.config(),
-            manager.package_info(),
-          );
-        } else if payload.cmd.starts_with("plugin:") {
+        if payload.cmd.starts_with("plugin:") {
           if !is_local {
             let command = invoke.message.command.replace("plugin:", "");
             let plugin_name = command.split('|').next().unwrap().to_string();

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 0 - 0
examples/api/dist/assets/index.css


تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 0 - 0
examples/api/dist/assets/index.js


+ 0 - 5
examples/api/src-tauri/src/lib.rs

@@ -52,11 +52,6 @@ pub fn run() {
           .content_protected(true);
       }
 
-      #[cfg(target_os = "windows")]
-      {
-        window_builder = window_builder.transparent(true).decorations(false);
-      }
-
       let window = window_builder.build().unwrap();
 
       #[cfg(debug_assertions)]

+ 12 - 99
examples/api/src/App.svelte

@@ -1,19 +1,11 @@
 <script>
   import { writable } from 'svelte/store'
-  import { appWindow, getCurrent } from '@tauri-apps/api/window'
 
   import Welcome from './views/Welcome.svelte'
-  import Cli from './views/Cli.svelte'
   import Communication from './views/Communication.svelte'
-  import Window from './views/Window.svelte'
   import WebRTC from './views/WebRTC.svelte'
 
   import { onMount } from 'svelte'
-  import { listen } from '@tauri-apps/api/event'
-
-  appWindow.onFileDropEvent((event) => {
-    onMessage(`File drop: ${JSON.stringify(event.payload)}`)
-  })
 
   const userAgent = navigator.userAgent.toLowerCase()
   const isMobile = userAgent.includes('android') || userAgent.includes('iphone')
@@ -29,16 +21,6 @@
       component: Communication,
       icon: 'i-codicon-radio-tower'
     },
-    !isMobile && {
-      label: 'CLI',
-      component: Cli,
-      icon: 'i-codicon-terminal'
-    },
-    !isMobile && {
-      label: 'Window',
-      component: Window,
-      icon: 'i-codicon-window'
-    },
     {
       label: 'WebRTC',
       component: WebRTC,
@@ -51,25 +33,6 @@
     selected = view
   }
 
-  // Window controls
-  let isWindowMaximized
-  onMount(async () => {
-    const window = getCurrent()
-    isWindowMaximized = await window.isMaximized()
-    listen('tauri://resize', async () => {
-      isWindowMaximized = await window.isMaximized()
-    })
-  })
-
-  function minimize() {
-    getCurrent().minimize()
-  }
-
-  async function toggleMaximize() {
-    const window = getCurrent()
-    ;(await window.isMaximized()) ? window.unmaximize() : window.maximize()
-  }
-
   // dark/light
   let isDark
   onMount(() => {
@@ -141,8 +104,6 @@
     document.addEventListener('mousemove', moveHandler)
   }
 
-  const isWindows = navigator.appVersion.includes('Win')
-
   // mobile
   let isSideBarOpen = false
   let sidebar
@@ -211,52 +172,6 @@
   }
 </script>
 
-<!-- custom titlebar for Windows -->
-{#if isWindows}
-  <div
-    class="w-screen select-none h-8 pl-2 flex justify-between items-center absolute text-primaryText dark:text-darkPrimaryText"
-    data-tauri-drag-region
-  >
-    <span class="lt-sm:pl-10 text-darkPrimaryText">Tauri API Validation</span>
-    <span
-      class="
-      h-100%
-      children:h-100% children:w-12 children:inline-flex
-      children:items-center children:justify-center"
-    >
-      <span
-        title={isDark ? 'Switch to Light mode' : 'Switch to Dark mode'}
-        class="hover:bg-hoverOverlay active:bg-hoverOverlayDarker dark:hover:bg-darkHoverOverlay dark:active:bg-darkHoverOverlayDarker"
-        on:click={toggleDark}
-      >
-        {#if isDark}
-          <div class="i-ph-sun" />
-        {:else}
-          <div class="i-ph-moon" />
-        {/if}
-      </span>
-      <span
-        title="Minimize"
-        class="hover:bg-hoverOverlay active:bg-hoverOverlayDarker dark:hover:bg-darkHoverOverlay dark:active:bg-darkHoverOverlayDarker"
-        on:click={minimize}
-      >
-        <div class="i-codicon-chrome-minimize" />
-      </span>
-      <span
-        title={isWindowMaximized ? 'Restore' : 'Maximize'}
-        class="hover:bg-hoverOverlay active:bg-hoverOverlayDarker dark:hover:bg-darkHoverOverlay dark:active:bg-darkHoverOverlayDarker"
-        on:click={toggleMaximize}
-      >
-        {#if isWindowMaximized}
-          <div class="i-codicon-chrome-restore" />
-        {:else}
-          <div class="i-codicon-chrome-maximize" />
-        {/if}
-      </span>
-    </span>
-  </div>
-{/if}
-
 <!-- Sidebar toggle, only visible on small screens -->
 <div
   id="sidebarToggle"
@@ -283,20 +198,18 @@
       src="tauri_logo.png"
       alt="Tauri logo"
     />
-    {#if !isWindows}
-      <a href="##" class="nv justify-between h-8" on:click={toggleDark}>
-        {#if isDark}
-          Switch to Light mode
-          <div class="i-ph-sun" />
-        {:else}
-          Switch to Dark mode
-          <div class="i-ph-moon" />
-        {/if}
-      </a>
-      <br />
-      <div class="bg-white/5 h-2px" />
-      <br />
-    {/if}
+    <a href="##" class="nv justify-between h-8" on:click={toggleDark}>
+      {#if isDark}
+        Switch to Light mode
+        <div class="i-ph-sun" />
+      {:else}
+        Switch to Dark mode
+        <div class="i-ph-moon" />
+      {/if}
+    </a>
+    <br />
+    <div class="bg-white/5 h-2px" />
+    <br />
 
     <a
       class="nv justify-between h-8"

+ 0 - 29
examples/api/src/views/Cli.svelte

@@ -1,29 +0,0 @@
-<script>
-  import { invoke } from '@tauri-apps/api/tauri'
-
-  export let onMessage
-
-  function cliMatches() {
-    invoke('plugin:cli|cli_matches').then(onMessage).catch(onMessage)
-  }
-</script>
-
-<p>
-  This binary can be run from the terminal and takes the following arguments:
-  <code class="code-block flex flex-wrap my-2">
-    <pre>
-  --config &lt;PATH&gt;
-  --theme &lt;light|dark|system&gt;
-  --verbose</pre>
-  </code>
-  Additionally, it has a <code>update --background</code> subcommand.
-</p>
-<br />
-<div class="note">
-  Note that the arguments are only parsed, not implemented.
-</div>
-<br />
-<br />
-<button class="btn" id="cli-matches" on:click={cliMatches}>
-  Get matches
-</button>

+ 0 - 438
examples/api/src/views/Window.svelte

@@ -1,438 +0,0 @@
-<script>
-  import {
-    appWindow,
-    WebviewWindow,
-    LogicalSize,
-    UserAttentionType,
-    PhysicalSize,
-    PhysicalPosition
-  } from '@tauri-apps/api/window'
-
-  let selectedWindow = appWindow.label
-  const windowMap = {
-    [appWindow.label]: appWindow
-  }
-
-  const cursorIconOptions = [
-    'default',
-    'crosshair',
-    'hand',
-    'arrow',
-    'move',
-    'text',
-    'wait',
-    'help',
-    'progress',
-    // something cannot be done
-    'notAllowed',
-    'contextMenu',
-    'cell',
-    'verticalText',
-    'alias',
-    'copy',
-    'noDrop',
-    // something can be grabbed
-    'grab',
-    /// something is grabbed
-    'grabbing',
-    'allScroll',
-    'zoomIn',
-    'zoomOut',
-    // edge is to be moved
-    'eResize',
-    'nResize',
-    'neResize',
-    'nwResize',
-    'sResize',
-    'seResize',
-    'swResize',
-    'wResize',
-    'ewResize',
-    'nsResize',
-    'neswResize',
-    'nwseResize',
-    'colResize',
-    'rowResize'
-  ]
-
-  export let onMessage
-
-  let newWindowLabel
-
-  let urlValue = 'https://tauri.app'
-  let resizable = true
-  let maximized = false
-  let decorations = true
-  let alwaysOnTop = false
-  let contentProtected = true
-  let fullscreen = false
-  let width = null
-  let height = null
-  let minWidth = null
-  let minHeight = null
-  let maxWidth = null
-  let maxHeight = null
-  let x = null
-  let y = null
-  let scaleFactor = 1
-  let innerPosition = new PhysicalPosition(x, y)
-  let outerPosition = new PhysicalPosition(x, y)
-  let innerSize = new PhysicalSize(width, height)
-  let outerSize = new PhysicalSize(width, height)
-  let resizeEventUnlisten
-  let moveEventUnlisten
-  let cursorGrab = false
-  let cursorVisible = true
-  let cursorX = null
-  let cursorY = null
-  let cursorIcon = 'default'
-  let cursorIgnoreEvents = false
-  let windowTitle = 'Awesome Tauri Example!'
-
-  function setTitle_() {
-    windowMap[selectedWindow].setTitle(windowTitle)
-  }
-
-  function hide_() {
-    windowMap[selectedWindow].hide()
-    setTimeout(windowMap[selectedWindow].show, 2000)
-  }
-
-  function minimize_() {
-    windowMap[selectedWindow].minimize()
-    setTimeout(windowMap[selectedWindow].unminimize, 2000)
-  }
-
-  function createWindow() {
-    if (!newWindowLabel) return
-
-    const webview = new WebviewWindow(newWindowLabel)
-    windowMap[newWindowLabel] = webview
-    webview.once('tauri://error', function () {
-      onMessage('Error creating new webview')
-    })
-  }
-
-  function loadWindowSize() {
-    windowMap[selectedWindow].innerSize().then((response) => {
-      innerSize = response
-      width = innerSize.width
-      height = innerSize.height
-    })
-    windowMap[selectedWindow].outerSize().then((response) => {
-      outerSize = response
-    })
-  }
-
-  function loadWindowPosition() {
-    windowMap[selectedWindow].innerPosition().then((response) => {
-      innerPosition = response
-    })
-    windowMap[selectedWindow].outerPosition().then((response) => {
-      outerPosition = response
-      x = outerPosition.x
-      y = outerPosition.y
-    })
-  }
-
-  async function addWindowEventListeners(window) {
-    if (!window) return
-    if (resizeEventUnlisten) {
-      resizeEventUnlisten()
-    }
-    if (moveEventUnlisten) {
-      moveEventUnlisten()
-    }
-    moveEventUnlisten = await window.listen('tauri://move', loadWindowPosition)
-    resizeEventUnlisten = await window.listen('tauri://resize', loadWindowSize)
-  }
-
-  async function requestUserAttention_() {
-    await windowMap[selectedWindow].minimize()
-    await windowMap[selectedWindow].requestUserAttention(
-      UserAttentionType.Critical
-    )
-    await new Promise((resolve) => setTimeout(resolve, 3000))
-    await windowMap[selectedWindow].requestUserAttention(null)
-  }
-
-  $: {
-    windowMap[selectedWindow]
-    loadWindowPosition()
-    loadWindowSize()
-  }
-  $: windowMap[selectedWindow]?.setResizable(resizable)
-  $: maximized
-    ? windowMap[selectedWindow]?.maximize()
-    : windowMap[selectedWindow]?.unmaximize()
-  $: windowMap[selectedWindow]?.setDecorations(decorations)
-  $: windowMap[selectedWindow]?.setAlwaysOnTop(alwaysOnTop)
-  $: windowMap[selectedWindow]?.setContentProtected(contentProtected)
-  $: windowMap[selectedWindow]?.setFullscreen(fullscreen)
-
-  $: width &&
-    height &&
-    windowMap[selectedWindow]?.setSize(new PhysicalSize(width, height))
-  $: minWidth && minHeight
-    ? windowMap[selectedWindow]?.setMinSize(
-        new LogicalSize(minWidth, minHeight)
-      )
-    : windowMap[selectedWindow]?.setMinSize(null)
-  $: maxWidth > 800 && maxHeight > 400
-    ? windowMap[selectedWindow]?.setMaxSize(
-        new LogicalSize(maxWidth, maxHeight)
-      )
-    : windowMap[selectedWindow]?.setMaxSize(null)
-  $: x !== null &&
-    y !== null &&
-    windowMap[selectedWindow]?.setPosition(new PhysicalPosition(x, y))
-  $: windowMap[selectedWindow]
-    ?.scaleFactor()
-    .then((factor) => (scaleFactor = factor))
-  $: addWindowEventListeners(windowMap[selectedWindow])
-
-  $: windowMap[selectedWindow]?.setCursorGrab(cursorGrab)
-  $: windowMap[selectedWindow]?.setCursorVisible(cursorVisible)
-  $: windowMap[selectedWindow]?.setCursorIcon(cursorIcon)
-  $: cursorX !== null &&
-    cursorY !== null &&
-    windowMap[selectedWindow]?.setCursorPosition(
-      new PhysicalPosition(cursorX, cursorY)
-    )
-  $: windowMap[selectedWindow]?.setIgnoreCursorEvents(cursorIgnoreEvents)
-</script>
-
-<div class="flex flex-col children:grow gap-2">
-  <div class="flex gap-1">
-    <input
-      class="input grow"
-      type="text"
-      placeholder="New Window label.."
-      bind:value={newWindowLabel}
-    />
-    <button class="btn" on:click={createWindow}>New window</button>
-  </div>
-  <br />
-  {#if Object.keys(windowMap).length >= 1}
-    <span class="font-700 text-sm">Selected window:</span>
-    <select class="input" bind:value={selectedWindow}>
-      <option value="" disabled selected>Choose a window...</option>
-      {#each Object.keys(windowMap) as label}
-        <option value={label}>{label}</option>
-      {/each}
-    </select>
-  {/if}
-  {#if windowMap[selectedWindow]}
-    <br />
-    <div class="flex flex-wrap gap-2">
-      <button
-        class="btn"
-        title="Unminimizes after 2 seconds"
-        on:click={() => windowMap[selectedWindow].center()}
-      >
-        Center
-      </button>
-      <button
-        class="btn"
-        title="Unminimizes after 2 seconds"
-        on:click={minimize_}
-      >
-        Minimize
-      </button>
-      <button
-        class="btn"
-        title="Visible again after 2 seconds"
-        on:click={hide_}
-      >
-        Hide
-      </button>
-      <button
-        class="btn"
-        on:click={requestUserAttention_}
-        title="Minimizes the window, requests attention for 3s and then resets it"
-        >Request attention</button
-      >
-    </div>
-    <br />
-    <div class="flex flex-wrap gap-2">
-      <label>
-        Maximized
-        <input type="checkbox" bind:checked={maximized} />
-      </label>
-      <label>
-        Resizable
-        <input type="checkbox" bind:checked={resizable} />
-      </label>
-      <label>
-        Has decorations
-        <input type="checkbox" bind:checked={decorations} />
-      </label>
-      <label>
-        Always on top
-        <input type="checkbox" bind:checked={alwaysOnTop} />
-      </label>
-      <label>
-        Content protected
-        <input type="checkbox" bind:checked={contentProtected} />
-      </label>
-      <label>
-        Fullscreen
-        <input type="checkbox" bind:checked={fullscreen} />
-      </label>
-    </div>
-    <br />
-    <div class="flex flex-row gap-2 flex-wrap">
-      <div class="flex children:grow flex-col">
-        <div>
-          X
-          <input class="input" type="number" bind:value={x} min="0" />
-        </div>
-        <div>
-          Y
-          <input class="input" type="number" bind:value={y} min="0" />
-        </div>
-      </div>
-
-      <div class="flex children:grow flex-col">
-        <div>
-          Width
-          <input class="input" type="number" bind:value={width} min="400" />
-        </div>
-        <div>
-          Height
-          <input class="input" type="number" bind:value={height} min="400" />
-        </div>
-      </div>
-
-      <div class="flex children:grow flex-col">
-        <div>
-          Min width
-          <input class="input" type="number" bind:value={minWidth} />
-        </div>
-        <div>
-          Min height
-          <input class="input" type="number" bind:value={minHeight} />
-        </div>
-      </div>
-
-      <div class="flex children:grow flex-col">
-        <div>
-          Max width
-          <input class="input" type="number" bind:value={maxWidth} min="800" />
-        </div>
-        <div>
-          Max height
-          <input class="input" type="number" bind:value={maxHeight} min="400" />
-        </div>
-      </div>
-    </div>
-    <br />
-    <div>
-      <div class="flex">
-        <div class="grow">
-          <div class="text-accent dark:text-darkAccent font-700">
-            Inner Size
-          </div>
-          <span>Width: {innerSize.width}</span>
-          <span>Height: {innerSize.height}</span>
-        </div>
-        <div class="grow">
-          <div class="text-accent dark:text-darkAccent font-700">
-            Outer Size
-          </div>
-          <span>Width: {outerSize.width}</span>
-          <span>Height: {outerSize.height}</span>
-        </div>
-      </div>
-      <div class="flex">
-        <div class="grow">
-          <div class="text-accent dark:text-darkAccent font-700">
-            Inner Logical Size
-          </div>
-          <span>Width: {innerSize.toLogical(scaleFactor).width}</span>
-          <span>Height: {innerSize.toLogical(scaleFactor).height}</span>
-        </div>
-        <div class="grow">
-          <div class="text-accent dark:text-darkAccent font-700">
-            Outer Logical Size
-          </div>
-          <span>Width: {outerSize.toLogical(scaleFactor).width}</span>
-          <span>Height: {outerSize.toLogical(scaleFactor).height}</span>
-        </div>
-      </div>
-      <div class="flex">
-        <div class="grow">
-          <div class="text-accent dark:text-darkAccent font-700">
-            Inner Position
-          </div>
-          <span>x: {innerPosition.x}</span>
-          <span>y: {innerPosition.y}</span>
-        </div>
-        <div class="grow">
-          <div class="text-accent dark:text-darkAccent font-700">
-            Outer Position
-          </div>
-          <span>x: {outerPosition.x}</span>
-          <span>y: {outerPosition.y}</span>
-        </div>
-      </div>
-      <div class="flex">
-        <div class="grow">
-          <div class="text-accent dark:text-darkAccent font-700">
-            Inner Logical Position
-          </div>
-          <span>x: {innerPosition.toLogical(scaleFactor).x}</span>
-          <span>y: {innerPosition.toLogical(scaleFactor).y}</span>
-        </div>
-        <div class="grow">
-          <div class="text-accent dark:text-darkAccent font-700">
-            Outer Logical Position
-          </div>
-          <span>x: {outerPosition.toLogical(scaleFactor).x}</span>
-          <span>y: {outerPosition.toLogical(scaleFactor).y}</span>
-        </div>
-      </div>
-    </div>
-    <br />
-    <h4 class="mb-2">Cursor</h4>
-    <div class="flex gap-2">
-      <label>
-        <input type="checkbox" bind:checked={cursorGrab} />
-        Grab
-      </label>
-      <label>
-        <input type="checkbox" bind:checked={cursorVisible} />
-        Visible
-      </label>
-      <label>
-        <input type="checkbox" bind:checked={cursorIgnoreEvents} />
-        Ignore events
-      </label>
-    </div>
-    <div class="flex gap-2">
-      <label>
-        Icon
-        <select class="input" bind:value={cursorIcon}>
-          {#each cursorIconOptions as kind}
-            <option value={kind}>{kind}</option>
-          {/each}
-        </select>
-      </label>
-      <label>
-        X position
-        <input class="input" type="number" bind:value={cursorX} />
-      </label>
-      <label>
-        Y position
-        <input class="input" type="number" bind:value={cursorY} />
-      </label>
-    </div>
-    <br />
-    <div class="flex flex-col gap-1">
-      <form class="flex gap-1" on:submit|preventDefault={setTitle_}>
-        <input class="input grow" id="title" bind:value={windowTitle} />
-        <button class="btn" type="submit">Set title</button>
-      </form>
-    </div>
-  {/if}
-</div>

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 0 - 0
tooling/api/docs/js-api.json


+ 1 - 2
tooling/api/src/helpers/event.ts

@@ -2,7 +2,6 @@
 // SPDX-License-Identifier: Apache-2.0
 // SPDX-License-Identifier: MIT
 
-import { type WindowLabel } from '../window'
 import { invoke, transformCallback } from '../tauri'
 import { type EventName } from '../event'
 
@@ -46,7 +45,7 @@ async function _unlisten(event: string, eventId: number): Promise<void> {
  */
 async function emit(
   event: string,
-  windowLabel?: WindowLabel,
+  windowLabel?: string,
   payload?: unknown
 ): Promise<void> {
   await invoke('plugin:event|emit', {

+ 0 - 37
tooling/api/src/helpers/tauri.ts

@@ -1,37 +0,0 @@
-// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
-// SPDX-License-Identifier: Apache-2.0
-// SPDX-License-Identifier: MIT
-
-/** @ignore */
-
-import { invoke } from '../tauri'
-
-type TauriModule =
-  | 'App'
-  | 'Fs'
-  | 'Path'
-  | 'Os'
-  | 'Window'
-  | 'Shell'
-  | 'Event'
-  | 'Internal'
-  | 'Dialog'
-  | 'Cli'
-  | 'Notification'
-  | 'Http'
-  | 'GlobalShortcut'
-  | 'Process'
-  | 'Clipboard'
-
-interface TauriCommand {
-  __tauriModule: TauriModule
-  [key: string]: unknown
-}
-
-async function invokeTauriCommand<T>(command: TauriCommand): Promise<T> {
-  return invoke('tauri', command)
-}
-
-export type { TauriModule, TauriCommand }
-
-export { invokeTauriCommand }

+ 1 - 2
tooling/api/src/index.ts

@@ -16,9 +16,8 @@
 import * as event from './event'
 import * as path from './path'
 import * as tauri from './tauri'
-import * as window from './window'
 
 /** @ignore */
 const invoke = tauri.invoke
 
-export { invoke, event, path, tauri, window }
+export { invoke, event, path, tauri }

+ 15 - 0
tooling/api/src/mocks.ts

@@ -2,6 +2,21 @@
 // SPDX-License-Identifier: Apache-2.0
 // SPDX-License-Identifier: MIT
 
+/** @ignore */
+declare global {
+  interface Window {
+    __TAURI_METADATA__: {
+      __windows: WindowDef[]
+      __currentWindow: WindowDef
+    }
+  }
+}
+
+/** @ignore */
+interface WindowDef {
+  label: string
+}
+
 interface IPCMessage {
   cmd: string
   callback: number

+ 0 - 2327
tooling/api/src/window.ts

@@ -1,2327 +0,0 @@
-// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
-// SPDX-License-Identifier: Apache-2.0
-// SPDX-License-Identifier: MIT
-
-/**
- * Provides APIs to create windows, communicate with other windows and manipulate the current window.
- *
- * This package is also accessible with `window.__TAURI__.window` when [`build.withGlobalTauri`](https://tauri.app/v1/api/config/#buildconfig.withglobaltauri) in `tauri.conf.json` is set to `true`.
- *
- * The APIs must be added to [`tauri.allowlist.window`](https://tauri.app/v1/api/config/#allowlistconfig.window) in `tauri.conf.json`:
- * ```json
- * {
- *   "tauri": {
- *     "allowlist": {
- *       "window": {
- *         "all": true, // enable all window APIs
- *         "create": true, // enable window creation
- *         "center": true,
- *         "requestUserAttention": true,
- *         "setResizable": true,
- *         "setTitle": true,
- *         "maximize": true,
- *         "unmaximize": true,
- *         "minimize": true,
- *         "unminimize": true,
- *         "show": true,
- *         "hide": true,
- *         "close": true,
- *         "setDecorations": true,
- *         "setShadow": true,
- *         "setAlwaysOnTop": true,
- *         "setContentProtected": true,
- *         "setSize": true,
- *         "setMinSize": true,
- *         "setMaxSize": true,
- *         "setPosition": true,
- *         "setFullscreen": true,
- *         "setFocus": true,
- *         "setIcon": true,
- *         "setSkipTaskbar": true,
- *         "setCursorGrab": true,
- *         "setCursorVisible": true,
- *         "setCursorIcon": true,
- *         "setCursorPosition": true,
- *         "setIgnoreCursorEvents": true,
- *         "startDragging": true,
- *         "print": true
- *       }
- *     }
- *   }
- * }
- * ```
- * It is recommended to allowlist only the APIs you use for optimal bundle size and security.
- *
- * ## Window events
- *
- * Events can be listened to using `appWindow.listen`:
- * ```typescript
- * import { appWindow } from "@tauri-apps/api/window";
- * appWindow.listen("my-window-event", ({ event, payload }) => { });
- * ```
- *
- * @module
- */
-
-import { invokeTauriCommand } from './helpers/tauri'
-import type { EventName, EventCallback, UnlistenFn } from './event'
-import { emit, type Event, listen, once } from './helpers/event'
-import { TauriEvent } from './event'
-
-type Theme = 'light' | 'dark'
-type TitleBarStyle = 'visible' | 'transparent' | 'overlay'
-
-/**
- * Allows you to retrieve information about a given monitor.
- *
- * @since 1.0.0
- */
-interface Monitor {
-  /** Human-readable name of the monitor */
-  name: string | null
-  /** The monitor's resolution. */
-  size: PhysicalSize
-  /** the Top-left corner position of the monitor relative to the larger full screen area. */
-  position: PhysicalPosition
-  /** The scale factor that can be used to map physical pixels to logical pixels. */
-  scaleFactor: number
-}
-
-/**
- * The payload for the `scaleChange` event.
- *
- * @since 1.0.2
- */
-interface ScaleFactorChanged {
-  /** The new window scale factor. */
-  scaleFactor: number
-  /** The new window size */
-  size: PhysicalSize
-}
-
-/** The file drop event types. */
-type FileDropEvent =
-  | { type: 'hover'; paths: string[] }
-  | { type: 'drop'; paths: string[] }
-  | { type: 'cancel' }
-
-/**
- * A size represented in logical pixels.
- *
- * @since 1.0.0
- */
-class LogicalSize {
-  type = 'Logical'
-  width: number
-  height: number
-
-  constructor(width: number, height: number) {
-    this.width = width
-    this.height = height
-  }
-}
-
-/**
- * A size represented in physical pixels.
- *
- * @since 1.0.0
- */
-class PhysicalSize {
-  type = 'Physical'
-  width: number
-  height: number
-
-  constructor(width: number, height: number) {
-    this.width = width
-    this.height = height
-  }
-
-  /**
-   * Converts the physical size to a logical one.
-   * @example
-   * ```typescript
-   * import { appWindow } from '@tauri-apps/api/window';
-   * const factor = await appWindow.scaleFactor();
-   * const size = await appWindow.innerSize();
-   * const logical = size.toLogical(factor);
-   * ```
-   *  */
-  toLogical(scaleFactor: number): LogicalSize {
-    return new LogicalSize(this.width / scaleFactor, this.height / scaleFactor)
-  }
-}
-
-/**
- *  A position represented in logical pixels.
- *
- * @since 1.0.0
- */
-class LogicalPosition {
-  type = 'Logical'
-  x: number
-  y: number
-
-  constructor(x: number, y: number) {
-    this.x = x
-    this.y = y
-  }
-}
-
-/**
- *  A position represented in physical pixels.
- *
- * @since 1.0.0
- */
-class PhysicalPosition {
-  type = 'Physical'
-  x: number
-  y: number
-
-  constructor(x: number, y: number) {
-    this.x = x
-    this.y = y
-  }
-
-  /**
-   * Converts the physical position to a logical one.
-   * @example
-   * ```typescript
-   * import { appWindow } from '@tauri-apps/api/window';
-   * const factor = await appWindow.scaleFactor();
-   * const position = await appWindow.innerPosition();
-   * const logical = position.toLogical(factor);
-   * ```
-   * */
-  toLogical(scaleFactor: number): LogicalPosition {
-    return new LogicalPosition(this.x / scaleFactor, this.y / scaleFactor)
-  }
-}
-
-/** @ignore */
-interface WindowDef {
-  label: string
-}
-
-/** @ignore */
-declare global {
-  interface Window {
-    __TAURI_METADATA__: {
-      __windows: WindowDef[]
-      __currentWindow: WindowDef
-    }
-  }
-}
-
-/**
- * Attention type to request on a window.
- *
- * @since 1.0.0
- */
-enum UserAttentionType {
-  /**
-   * #### Platform-specific
-   * - **macOS:** Bounces the dock icon until the application is in focus.
-   * - **Windows:** Flashes both the window and the taskbar button until the application is in focus.
-   */
-  Critical = 1,
-  /**
-   * #### Platform-specific
-   * - **macOS:** Bounces the dock icon once.
-   * - **Windows:** Flashes the taskbar button until the application is in focus.
-   */
-  Informational
-}
-
-export type CursorIcon =
-  | 'default'
-  | 'crosshair'
-  | 'hand'
-  | 'arrow'
-  | 'move'
-  | 'text'
-  | 'wait'
-  | 'help'
-  | 'progress'
-  // something cannot be done
-  | 'notAllowed'
-  | 'contextMenu'
-  | 'cell'
-  | 'verticalText'
-  | 'alias'
-  | 'copy'
-  | 'noDrop'
-  // something can be grabbed
-  | 'grab'
-  /// something is grabbed
-  | 'grabbing'
-  | 'allScroll'
-  | 'zoomIn'
-  | 'zoomOut'
-  // edge is to be moved
-  | 'eResize'
-  | 'nResize'
-  | 'neResize'
-  | 'nwResize'
-  | 'sResize'
-  | 'seResize'
-  | 'swResize'
-  | 'wResize'
-  | 'ewResize'
-  | 'nsResize'
-  | 'neswResize'
-  | 'nwseResize'
-  | 'colResize'
-  | 'rowResize'
-
-/**
- * Get an instance of `WebviewWindow` for the current webview window.
- *
- * @since 1.0.0
- */
-function getCurrent(): WebviewWindow {
-  return new WebviewWindow(window.__TAURI_METADATA__.__currentWindow.label, {
-    // @ts-expect-error `skip` is not defined in the public API but it is handled by the constructor
-    skip: true
-  })
-}
-
-/**
- * Gets a list of instances of `WebviewWindow` for all available webview windows.
- *
- * @since 1.0.0
- */
-function getAll(): WebviewWindow[] {
-  return window.__TAURI_METADATA__.__windows.map(
-    (w) =>
-      new WebviewWindow(w.label, {
-        // @ts-expect-error `skip` is not defined in the public API but it is handled by the constructor
-        skip: true
-      })
-  )
-}
-
-/** @ignore */
-// events that are emitted right here instead of by the created webview
-const localTauriEvents = ['tauri://created', 'tauri://error']
-/** @ignore */
-export type WindowLabel = string
-/**
- * A webview window handle allows emitting and listening to events from the backend that are tied to the window.
- *
- * @ignore
- * @since 1.0.0
- */
-class WebviewWindowHandle {
-  /** The window label. It is a unique identifier for the window, can be used to reference it later. */
-  label: WindowLabel
-  /** Local event listeners. */
-  listeners: Record<string, Array<EventCallback<any>>>
-
-  constructor(label: WindowLabel) {
-    this.label = label
-    // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
-    this.listeners = Object.create(null)
-  }
-
-  /**
-   * Listen to an event emitted by the backend that is tied to the webview window.
-   *
-   * @example
-   * ```typescript
-   * import { appWindow } from '@tauri-apps/api/window';
-   * const unlisten = await appWindow.listen<string>('state-changed', (event) => {
-   *   console.log(`Got error: ${payload}`);
-   * });
-   *
-   * // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
-   * unlisten();
-   * ```
-   *
-   * @param event Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`.
-   * @param handler Event handler.
-   * @returns A promise resolving to a function to unlisten to the event.
-   * Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
-   */
-  async listen<T>(
-    event: EventName,
-    handler: EventCallback<T>
-  ): Promise<UnlistenFn> {
-    if (this._handleTauriEvent(event, handler)) {
-      return Promise.resolve(() => {
-        // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, security/detect-object-injection
-        const listeners = this.listeners[event]
-        listeners.splice(listeners.indexOf(handler), 1)
-      })
-    }
-    return listen(event, this.label, handler)
-  }
-
-  /**
-   * Listen to an one-off event emitted by the backend that is tied to the webview window.
-   *
-   * @example
-   * ```typescript
-   * import { appWindow } from '@tauri-apps/api/window';
-   * const unlisten = await appWindow.once<null>('initialized', (event) => {
-   *   console.log(`Window initialized!`);
-   * });
-   *
-   * // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
-   * unlisten();
-   * ```
-   *
-   * @param event Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`.
-   * @param handler Event handler.
-   * @returns A promise resolving to a function to unlisten to the event.
-   * Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
-   */
-  async once<T>(event: string, handler: EventCallback<T>): Promise<UnlistenFn> {
-    if (this._handleTauriEvent(event, handler)) {
-      return Promise.resolve(() => {
-        // eslint-disable-next-line security/detect-object-injection
-        const listeners = this.listeners[event]
-        listeners.splice(listeners.indexOf(handler), 1)
-      })
-    }
-    return once(event, this.label, handler)
-  }
-
-  /**
-   * Emits an event to the backend, tied to the webview window.
-   * @example
-   * ```typescript
-   * import { appWindow } from '@tauri-apps/api/window';
-   * await appWindow.emit('window-loaded', { loggedIn: true, token: 'authToken' });
-   * ```
-   *
-   * @param event Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`.
-   * @param payload Event payload.
-   */
-  async emit(event: string, payload?: unknown): Promise<void> {
-    if (localTauriEvents.includes(event)) {
-      // eslint-disable-next-line
-      for (const handler of this.listeners[event] || []) {
-        handler({ event, id: -1, windowLabel: this.label, payload })
-      }
-      return Promise.resolve()
-    }
-    return emit(event, this.label, payload)
-  }
-
-  /** @ignore */
-  _handleTauriEvent<T>(event: string, handler: EventCallback<T>): boolean {
-    if (localTauriEvents.includes(event)) {
-      if (!(event in this.listeners)) {
-        // eslint-disable-next-line
-        this.listeners[event] = [handler]
-      } else {
-        // eslint-disable-next-line
-        this.listeners[event].push(handler)
-      }
-      return true
-    }
-    return false
-  }
-}
-
-/**
- * Manage the current window object.
- *
- * @ignore
- * @since 1.0.0
- */
-class WindowManager extends WebviewWindowHandle {
-  // Getters
-  /**
-   * The scale factor that can be used to map physical pixels to logical pixels.
-   * @example
-   * ```typescript
-   * import { appWindow } from '@tauri-apps/api/window';
-   * const factor = await appWindow.scaleFactor();
-   * ```
-   *
-   * @returns The window's monitor scale factor.
-   * */
-  async scaleFactor(): Promise<number> {
-    return invokeTauriCommand({
-      __tauriModule: 'Window',
-      message: {
-        cmd: 'manage',
-        data: {
-          label: this.label,
-          cmd: {
-            type: 'scaleFactor'
-          }
-        }
-      }
-    })
-  }
-
-  /**
-   * The position of the top-left hand corner of the window's client area relative to the top-left hand corner of the desktop.
-   * @example
-   * ```typescript
-   * import { appWindow } from '@tauri-apps/api/window';
-   * const position = await appWindow.innerPosition();
-   * ```
-   *
-   * @returns The window's inner position.
-   *  */
-  async innerPosition(): Promise<PhysicalPosition> {
-    return invokeTauriCommand<{ x: number; y: number }>({
-      __tauriModule: 'Window',
-      message: {
-        cmd: 'manage',
-        data: {
-          label: this.label,
-          cmd: {
-            type: 'innerPosition'
-          }
-        }
-      }
-    }).then(({ x, y }) => new PhysicalPosition(x, y))
-  }
-
-  /**
-   * The position of the top-left hand corner of the window relative to the top-left hand corner of the desktop.
-   * @example
-   * ```typescript
-   * import { appWindow } from '@tauri-apps/api/window';
-   * const position = await appWindow.outerPosition();
-   * ```
-   *
-   * @returns The window's outer position.
-   *  */
-  async outerPosition(): Promise<PhysicalPosition> {
-    return invokeTauriCommand<{ x: number; y: number }>({
-      __tauriModule: 'Window',
-      message: {
-        cmd: 'manage',
-        data: {
-          label: this.label,
-          cmd: {
-            type: 'outerPosition'
-          }
-        }
-      }
-    }).then(({ x, y }) => new PhysicalPosition(x, y))
-  }
-
-  /**
-   * The physical size of the window's client area.
-   * The client area is the content of the window, excluding the title bar and borders.
-   * @example
-   * ```typescript
-   * import { appWindow } from '@tauri-apps/api/window';
-   * const size = await appWindow.innerSize();
-   * ```
-   *
-   * @returns The window's inner size.
-   */
-  async innerSize(): Promise<PhysicalSize> {
-    return invokeTauriCommand<{ width: number; height: number }>({
-      __tauriModule: 'Window',
-      message: {
-        cmd: 'manage',
-        data: {
-          label: this.label,
-          cmd: {
-            type: 'innerSize'
-          }
-        }
-      }
-    }).then(({ width, height }) => new PhysicalSize(width, height))
-  }
-
-  /**
-   * The physical size of the entire window.
-   * These dimensions include the title bar and borders. If you don't want that (and you usually don't), use inner_size instead.
-   * @example
-   * ```typescript
-   * import { appWindow } from '@tauri-apps/api/window';
-   * const size = await appWindow.outerSize();
-   * ```
-   *
-   * @returns The window's outer size.
-   */
-  async outerSize(): Promise<PhysicalSize> {
-    return invokeTauriCommand<{ width: number; height: number }>({
-      __tauriModule: 'Window',
-      message: {
-        cmd: 'manage',
-        data: {
-          label: this.label,
-          cmd: {
-            type: 'outerSize'
-          }
-        }
-      }
-    }).then(({ width, height }) => new PhysicalSize(width, height))
-  }
-
-  /**
-   * Gets the window's current fullscreen state.
-   * @example
-   * ```typescript
-   * import { appWindow } from '@tauri-apps/api/window';
-   * const fullscreen = await appWindow.isFullscreen();
-   * ```
-   *
-   * @returns Whether the window is in fullscreen mode or not.
-   *  */
-  async isFullscreen(): Promise<boolean> {
-    return invokeTauriCommand({
-      __tauriModule: 'Window',
-      message: {
-        cmd: 'manage',
-        data: {
-          label: this.label,
-          cmd: {
-            type: 'isFullscreen'
-          }
-        }
-      }
-    })
-  }
-
-  /**
-   * Gets the window's current minimized state.
-   * @example
-   * ```typescript
-   * import { appWindow } from '@tauri-apps/api/window';
-   * const minimized = await appWindow.isMinimized();
-   * ```
-   *
-   * @since 1.3.0
-   * */
-  async isMinimized(): Promise<boolean> {
-    return invokeTauriCommand({
-      __tauriModule: 'Window',
-      message: {
-        cmd: 'manage',
-        data: {
-          label: this.label,
-          cmd: {
-            type: 'isMinimized'
-          }
-        }
-      }
-    })
-  }
-
-  /**
-   * Gets the window's current maximized state.
-   * @example
-   * ```typescript
-   * import { appWindow } from '@tauri-apps/api/window';
-   * const maximized = await appWindow.isMaximized();
-   * ```
-   *
-   * @returns Whether the window is maximized or not.
-   * */
-  async isMaximized(): Promise<boolean> {
-    return invokeTauriCommand({
-      __tauriModule: 'Window',
-      message: {
-        cmd: 'manage',
-        data: {
-          label: this.label,
-          cmd: {
-            type: 'isMaximized'
-          }
-        }
-      }
-    })
-  }
-
-  /**
-   * Gets the window's current decorated state.
-   * @example
-   * ```typescript
-   * import { appWindow } from '@tauri-apps/api/window';
-   * const decorated = await appWindow.isDecorated();
-   * ```
-   *
-   * @returns Whether the window is decorated or not.
-   *  */
-  async isDecorated(): Promise<boolean> {
-    return invokeTauriCommand({
-      __tauriModule: 'Window',
-      message: {
-        cmd: 'manage',
-        data: {
-          label: this.label,
-          cmd: {
-            type: 'isDecorated'
-          }
-        }
-      }
-    })
-  }
-
-  /**
-   * Gets the window's current resizable state.
-   * @example
-   * ```typescript
-   * import { appWindow } from '@tauri-apps/api/window';
-   * const resizable = await appWindow.isResizable();
-   * ```
-   *
-   * @returns Whether the window is resizable or not.
-   *  */
-  async isResizable(): Promise<boolean> {
-    return invokeTauriCommand({
-      __tauriModule: 'Window',
-      message: {
-        cmd: 'manage',
-        data: {
-          label: this.label,
-          cmd: {
-            type: 'isResizable'
-          }
-        }
-      }
-    })
-  }
-
-  /**
-   * Gets the window's current visible state.
-   * @example
-   * ```typescript
-   * import { appWindow } from '@tauri-apps/api/window';
-   * const visible = await appWindow.isVisible();
-   * ```
-   *
-   * @returns Whether the window is visible or not.
-   *  */
-  async isVisible(): Promise<boolean> {
-    return invokeTauriCommand({
-      __tauriModule: 'Window',
-      message: {
-        cmd: 'manage',
-        data: {
-          label: this.label,
-          cmd: {
-            type: 'isVisible'
-          }
-        }
-      }
-    })
-  }
-
-  /**
-   * Gets the window's current title.
-   * @example
-   * ```typescript
-   * import { appWindow } from '@tauri-apps/api/window';
-   * const title = await appWindow.title();
-   * ```
-   *
-   * @since 1.3.0
-   * */
-  async title(): Promise<string> {
-    return invokeTauriCommand({
-      __tauriModule: 'Window',
-      message: {
-        cmd: 'manage',
-        data: {
-          label: this.label,
-          cmd: {
-            type: 'title'
-          }
-        }
-      }
-    })
-  }
-
-  /**
-   * Gets the window's current theme.
-   *
-   * #### Platform-specific
-   *
-   * - **macOS:** Theme was introduced on macOS 10.14. Returns `light` on macOS 10.13 and below.
-   *
-   * @example
-   * ```typescript
-   * import { appWindow } from '@tauri-apps/api/window';
-   * const theme = await appWindow.theme();
-   * ```
-   *
-   * @returns The window theme.
-   * */
-  async theme(): Promise<Theme | null> {
-    return invokeTauriCommand({
-      __tauriModule: 'Window',
-      message: {
-        cmd: 'manage',
-        data: {
-          label: this.label,
-          cmd: {
-            type: 'theme'
-          }
-        }
-      }
-    })
-  }
-
-  // Setters
-
-  /**
-   * Centers the window.
-   * @example
-   * ```typescript
-   * import { appWindow } from '@tauri-apps/api/window';
-   * await appWindow.center();
-   * ```
-   *
-   * @param resizable
-   * @returns A promise indicating the success or failure of the operation.
-   */
-  async center(): Promise<void> {
-    return invokeTauriCommand({
-      __tauriModule: 'Window',
-      message: {
-        cmd: 'manage',
-        data: {
-          label: this.label,
-          cmd: {
-            type: 'center'
-          }
-        }
-      }
-    })
-  }
-
-  /**
-   *  Requests user attention to the window, this has no effect if the application
-   * is already focused. How requesting for user attention manifests is platform dependent,
-   * see `UserAttentionType` for details.
-   *
-   * Providing `null` will unset the request for user attention. Unsetting the request for
-   * user attention might not be done automatically by the WM when the window receives input.
-   *
-   * #### Platform-specific
-   *
-   * - **macOS:** `null` has no effect.
-   * - **Linux:** Urgency levels have the same effect.
-   * @example
-   * ```typescript
-   * import { appWindow } from '@tauri-apps/api/window';
-   * await appWindow.requestUserAttention();
-   * ```
-   *
-   * @param resizable
-   * @returns A promise indicating the success or failure of the operation.
-   */
-  async requestUserAttention(
-    requestType: UserAttentionType | null
-  ): Promise<void> {
-    let requestType_ = null
-    if (requestType) {
-      if (requestType === UserAttentionType.Critical) {
-        requestType_ = { type: 'Critical' }
-      } else {
-        requestType_ = { type: 'Informational' }
-      }
-    }
-    return invokeTauriCommand({
-      __tauriModule: 'Window',
-      message: {
-        cmd: 'manage',
-        data: {
-          label: this.label,
-          cmd: {
-            type: 'requestUserAttention',
-            payload: requestType_
-          }
-        }
-      }
-    })
-  }
-
-  /**
-   * Updates the window resizable flag.
-   * @example
-   * ```typescript
-   * import { appWindow } from '@tauri-apps/api/window';
-   * await appWindow.setResizable(false);
-   * ```
-   *
-   * @param resizable
-   * @returns A promise indicating the success or failure of the operation.
-   */
-  async setResizable(resizable: boolean): Promise<void> {
-    return invokeTauriCommand({
-      __tauriModule: 'Window',
-      message: {
-        cmd: 'manage',
-        data: {
-          label: this.label,
-          cmd: {
-            type: 'setResizable',
-            payload: resizable
-          }
-        }
-      }
-    })
-  }
-
-  /**
-   * Sets the window title.
-   * @example
-   * ```typescript
-   * import { appWindow } from '@tauri-apps/api/window';
-   * await appWindow.setTitle('Tauri');
-   * ```
-   *
-   * @param title The new title
-   * @returns A promise indicating the success or failure of the operation.
-   */
-  async setTitle(title: string): Promise<void> {
-    return invokeTauriCommand({
-      __tauriModule: 'Window',
-      message: {
-        cmd: 'manage',
-        data: {
-          label: this.label,
-          cmd: {
-            type: 'setTitle',
-            payload: title
-          }
-        }
-      }
-    })
-  }
-
-  /**
-   * Maximizes the window.
-   * @example
-   * ```typescript
-   * import { appWindow } from '@tauri-apps/api/window';
-   * await appWindow.maximize();
-   * ```
-   *
-   * @returns A promise indicating the success or failure of the operation.
-   */
-  async maximize(): Promise<void> {
-    return invokeTauriCommand({
-      __tauriModule: 'Window',
-      message: {
-        cmd: 'manage',
-        data: {
-          label: this.label,
-          cmd: {
-            type: 'maximize'
-          }
-        }
-      }
-    })
-  }
-
-  /**
-   * Unmaximizes the window.
-   * @example
-   * ```typescript
-   * import { appWindow } from '@tauri-apps/api/window';
-   * await appWindow.unmaximize();
-   * ```
-   *
-   * @returns A promise indicating the success or failure of the operation.
-   */
-  async unmaximize(): Promise<void> {
-    return invokeTauriCommand({
-      __tauriModule: 'Window',
-      message: {
-        cmd: 'manage',
-        data: {
-          label: this.label,
-          cmd: {
-            type: 'unmaximize'
-          }
-        }
-      }
-    })
-  }
-
-  /**
-   * Toggles the window maximized state.
-   * @example
-   * ```typescript
-   * import { appWindow } from '@tauri-apps/api/window';
-   * await appWindow.toggleMaximize();
-   * ```
-   *
-   * @returns A promise indicating the success or failure of the operation.
-   */
-  async toggleMaximize(): Promise<void> {
-    return invokeTauriCommand({
-      __tauriModule: 'Window',
-      message: {
-        cmd: 'manage',
-        data: {
-          label: this.label,
-          cmd: {
-            type: 'toggleMaximize'
-          }
-        }
-      }
-    })
-  }
-
-  /**
-   * Minimizes the window.
-   * @example
-   * ```typescript
-   * import { appWindow } from '@tauri-apps/api/window';
-   * await appWindow.minimize();
-   * ```
-   *
-   * @returns A promise indicating the success or failure of the operation.
-   */
-  async minimize(): Promise<void> {
-    return invokeTauriCommand({
-      __tauriModule: 'Window',
-      message: {
-        cmd: 'manage',
-        data: {
-          label: this.label,
-          cmd: {
-            type: 'minimize'
-          }
-        }
-      }
-    })
-  }
-
-  /**
-   * Unminimizes the window.
-   * @example
-   * ```typescript
-   * import { appWindow } from '@tauri-apps/api/window';
-   * await appWindow.unminimize();
-   * ```
-   *
-   * @returns A promise indicating the success or failure of the operation.
-   */
-  async unminimize(): Promise<void> {
-    return invokeTauriCommand({
-      __tauriModule: 'Window',
-      message: {
-        cmd: 'manage',
-        data: {
-          label: this.label,
-          cmd: {
-            type: 'unminimize'
-          }
-        }
-      }
-    })
-  }
-
-  /**
-   * Sets the window visibility to true.
-   * @example
-   * ```typescript
-   * import { appWindow } from '@tauri-apps/api/window';
-   * await appWindow.show();
-   * ```
-   *
-   * @returns A promise indicating the success or failure of the operation.
-   */
-  async show(): Promise<void> {
-    return invokeTauriCommand({
-      __tauriModule: 'Window',
-      message: {
-        cmd: 'manage',
-        data: {
-          label: this.label,
-          cmd: {
-            type: 'show'
-          }
-        }
-      }
-    })
-  }
-
-  /**
-   * Sets the window visibility to false.
-   * @example
-   * ```typescript
-   * import { appWindow } from '@tauri-apps/api/window';
-   * await appWindow.hide();
-   * ```
-   *
-   * @returns A promise indicating the success or failure of the operation.
-   */
-  async hide(): Promise<void> {
-    return invokeTauriCommand({
-      __tauriModule: 'Window',
-      message: {
-        cmd: 'manage',
-        data: {
-          label: this.label,
-          cmd: {
-            type: 'hide'
-          }
-        }
-      }
-    })
-  }
-
-  /**
-   * Closes the window.
-   * @example
-   * ```typescript
-   * import { appWindow } from '@tauri-apps/api/window';
-   * await appWindow.close();
-   * ```
-   *
-   * @returns A promise indicating the success or failure of the operation.
-   */
-  async close(): Promise<void> {
-    return invokeTauriCommand({
-      __tauriModule: 'Window',
-      message: {
-        cmd: 'manage',
-        data: {
-          label: this.label,
-          cmd: {
-            type: 'close'
-          }
-        }
-      }
-    })
-  }
-
-  /**
-   * Whether the window should have borders and bars.
-   * @example
-   * ```typescript
-   * import { appWindow } from '@tauri-apps/api/window';
-   * await appWindow.setDecorations(false);
-   * ```
-   *
-   * @param decorations Whether the window should have borders and bars.
-   * @returns A promise indicating the success or failure of the operation.
-   */
-  async setDecorations(decorations: boolean): Promise<void> {
-    return invokeTauriCommand({
-      __tauriModule: 'Window',
-      message: {
-        cmd: 'manage',
-        data: {
-          label: this.label,
-          cmd: {
-            type: 'setDecorations',
-            payload: decorations
-          }
-        }
-      }
-    })
-  }
-
-  /**
-   * Whether or not the window should have shadow.
-   *
-   * #### Platform-specific
-   *
-   * - **Windows:**
-   *   - `false` has no effect on decorated window, shadows are always ON.
-   *   - `true` will make ndecorated window have a 1px white border,
-   * and on Windows 11, it will have a rounded corners.
-   * - **Linux:** Unsupported.
-   *
-   * @example
-   * ```typescript
-   * import { appWindow } from '@tauri-apps/api/window';
-   * await appWindow.setShadow(false);
-   * ```
-   *
-   * @returns A promise indicating the success or failure of the operation.
-   *
-   * @since 2.0
-   */
-  async setShadow(enable: boolean): Promise<void> {
-    return invokeTauriCommand({
-      __tauriModule: 'Window',
-      message: {
-        cmd: 'manage',
-        data: {
-          label: this.label,
-          cmd: {
-            type: 'setShadow',
-            payload: enable
-          }
-        }
-      }
-    })
-  }
-
-  /**
-   * Whether the window should always be on top of other windows.
-   * @example
-   * ```typescript
-   * import { appWindow } from '@tauri-apps/api/window';
-   * await appWindow.setAlwaysOnTop(true);
-   * ```
-   *
-   * @param alwaysOnTop Whether the window should always be on top of other windows or not.
-   * @returns A promise indicating the success or failure of the operation.
-   */
-  async setAlwaysOnTop(alwaysOnTop: boolean): Promise<void> {
-    return invokeTauriCommand({
-      __tauriModule: 'Window',
-      message: {
-        cmd: 'manage',
-        data: {
-          label: this.label,
-          cmd: {
-            type: 'setAlwaysOnTop',
-            payload: alwaysOnTop
-          }
-        }
-      }
-    })
-  }
-
-  /**
-   * Prevents the window contents from being captured by other apps.
-   * @example
-   * ```typescript
-   * import { appWindow } from '@tauri-apps/api/window';
-   * await appWindow.setContentProtected(true);
-   * ```
-   *
-   * @returns A promise indicating the success or failure of the operation.
-   *
-   * @since 1.2.0
-   */
-  async setContentProtected(protected_: boolean): Promise<void> {
-    return invokeTauriCommand({
-      __tauriModule: 'Window',
-      message: {
-        cmd: 'manage',
-        data: {
-          label: this.label,
-          cmd: {
-            type: 'setContentProtected',
-            payload: protected_
-          }
-        }
-      }
-    })
-  }
-
-  /**
-   * Resizes the window with a new inner size.
-   * @example
-   * ```typescript
-   * import { appWindow, LogicalSize } from '@tauri-apps/api/window';
-   * await appWindow.setSize(new LogicalSize(600, 500));
-   * ```
-   *
-   * @param size The logical or physical inner size.
-   * @returns A promise indicating the success or failure of the operation.
-   */
-  async setSize(size: LogicalSize | PhysicalSize): Promise<void> {
-    if (!size || (size.type !== 'Logical' && size.type !== 'Physical')) {
-      throw new Error(
-        'the `size` argument must be either a LogicalSize or a PhysicalSize instance'
-      )
-    }
-    return invokeTauriCommand({
-      __tauriModule: 'Window',
-      message: {
-        cmd: 'manage',
-        data: {
-          label: this.label,
-          cmd: {
-            type: 'setSize',
-            payload: {
-              type: size.type,
-              data: {
-                width: size.width,
-                height: size.height
-              }
-            }
-          }
-        }
-      }
-    })
-  }
-
-  /**
-   * Sets the window minimum inner size. If the `size` argument is not provided, the constraint is unset.
-   * @example
-   * ```typescript
-   * import { appWindow, PhysicalSize } from '@tauri-apps/api/window';
-   * await appWindow.setMinSize(new PhysicalSize(600, 500));
-   * ```
-   *
-   * @param size The logical or physical inner size, or `null` to unset the constraint.
-   * @returns A promise indicating the success or failure of the operation.
-   */
-  async setMinSize(
-    size: LogicalSize | PhysicalSize | null | undefined
-  ): Promise<void> {
-    if (size && size.type !== 'Logical' && size.type !== 'Physical') {
-      throw new Error(
-        'the `size` argument must be either a LogicalSize or a PhysicalSize instance'
-      )
-    }
-    return invokeTauriCommand({
-      __tauriModule: 'Window',
-      message: {
-        cmd: 'manage',
-        data: {
-          label: this.label,
-          cmd: {
-            type: 'setMinSize',
-            payload: size
-              ? {
-                  type: size.type,
-                  data: {
-                    width: size.width,
-                    height: size.height
-                  }
-                }
-              : null
-          }
-        }
-      }
-    })
-  }
-
-  /**
-   * Sets the window maximum inner size. If the `size` argument is undefined, the constraint is unset.
-   * @example
-   * ```typescript
-   * import { appWindow, LogicalSize } from '@tauri-apps/api/window';
-   * await appWindow.setMaxSize(new LogicalSize(600, 500));
-   * ```
-   *
-   * @param size The logical or physical inner size, or `null` to unset the constraint.
-   * @returns A promise indicating the success or failure of the operation.
-   */
-  async setMaxSize(
-    size: LogicalSize | PhysicalSize | null | undefined
-  ): Promise<void> {
-    if (size && size.type !== 'Logical' && size.type !== 'Physical') {
-      throw new Error(
-        'the `size` argument must be either a LogicalSize or a PhysicalSize instance'
-      )
-    }
-    return invokeTauriCommand({
-      __tauriModule: 'Window',
-      message: {
-        cmd: 'manage',
-        data: {
-          label: this.label,
-          cmd: {
-            type: 'setMaxSize',
-            payload: size
-              ? {
-                  type: size.type,
-                  data: {
-                    width: size.width,
-                    height: size.height
-                  }
-                }
-              : null
-          }
-        }
-      }
-    })
-  }
-
-  /**
-   * Sets the window outer position.
-   * @example
-   * ```typescript
-   * import { appWindow, LogicalPosition } from '@tauri-apps/api/window';
-   * await appWindow.setPosition(new LogicalPosition(600, 500));
-   * ```
-   *
-   * @param position The new position, in logical or physical pixels.
-   * @returns A promise indicating the success or failure of the operation.
-   */
-  async setPosition(
-    position: LogicalPosition | PhysicalPosition
-  ): Promise<void> {
-    if (
-      !position ||
-      (position.type !== 'Logical' && position.type !== 'Physical')
-    ) {
-      throw new Error(
-        'the `position` argument must be either a LogicalPosition or a PhysicalPosition instance'
-      )
-    }
-    return invokeTauriCommand({
-      __tauriModule: 'Window',
-      message: {
-        cmd: 'manage',
-        data: {
-          label: this.label,
-          cmd: {
-            type: 'setPosition',
-            payload: {
-              type: position.type,
-              data: {
-                x: position.x,
-                y: position.y
-              }
-            }
-          }
-        }
-      }
-    })
-  }
-
-  /**
-   * Sets the window fullscreen state.
-   * @example
-   * ```typescript
-   * import { appWindow } from '@tauri-apps/api/window';
-   * await appWindow.setFullscreen(true);
-   * ```
-   *
-   * @param fullscreen Whether the window should go to fullscreen or not.
-   * @returns A promise indicating the success or failure of the operation.
-   */
-  async setFullscreen(fullscreen: boolean): Promise<void> {
-    return invokeTauriCommand({
-      __tauriModule: 'Window',
-      message: {
-        cmd: 'manage',
-        data: {
-          label: this.label,
-          cmd: {
-            type: 'setFullscreen',
-            payload: fullscreen
-          }
-        }
-      }
-    })
-  }
-
-  /**
-   * Bring the window to front and focus.
-   * @example
-   * ```typescript
-   * import { appWindow } from '@tauri-apps/api/window';
-   * await appWindow.setFocus();
-   * ```
-   *
-   * @returns A promise indicating the success or failure of the operation.
-   */
-  async setFocus(): Promise<void> {
-    return invokeTauriCommand({
-      __tauriModule: 'Window',
-      message: {
-        cmd: 'manage',
-        data: {
-          label: this.label,
-          cmd: {
-            type: 'setFocus'
-          }
-        }
-      }
-    })
-  }
-
-  /**
-   * Sets the window icon.
-   * @example
-   * ```typescript
-   * import { appWindow } from '@tauri-apps/api/window';
-   * await appWindow.setIcon('/tauri/awesome.png');
-   * ```
-   *
-   * Note that you need the `icon-ico` or `icon-png` Cargo features to use this API.
-   * To enable it, change your Cargo.toml file:
-   * ```toml
-   * [dependencies]
-   * tauri = { version = "...", features = ["...", "icon-png"] }
-   * ```
-   *
-   * @param icon Icon bytes or path to the icon file.
-   * @returns A promise indicating the success or failure of the operation.
-   */
-  async setIcon(icon: string | Uint8Array): Promise<void> {
-    return invokeTauriCommand({
-      __tauriModule: 'Window',
-      message: {
-        cmd: 'manage',
-        data: {
-          label: this.label,
-          cmd: {
-            type: 'setIcon',
-            payload: {
-              // correctly serialize Uint8Arrays
-              icon: typeof icon === 'string' ? icon : Array.from(icon)
-            }
-          }
-        }
-      }
-    })
-  }
-
-  /**
-   * Whether the window icon should be hidden from the taskbar or not.
-   *
-   * #### Platform-specific
-   *
-   * - **macOS:** Unsupported.
-   * @example
-   * ```typescript
-   * import { appWindow } from '@tauri-apps/api/window';
-   * await appWindow.setSkipTaskbar(true);
-   * ```
-   *
-   * @param skip true to hide window icon, false to show it.
-   * @returns A promise indicating the success or failure of the operation.
-   */
-  async setSkipTaskbar(skip: boolean): Promise<void> {
-    return invokeTauriCommand({
-      __tauriModule: 'Window',
-      message: {
-        cmd: 'manage',
-        data: {
-          label: this.label,
-          cmd: {
-            type: 'setSkipTaskbar',
-            payload: skip
-          }
-        }
-      }
-    })
-  }
-
-  /**
-   * Grabs the cursor, preventing it from leaving the window.
-   *
-   * There's no guarantee that the cursor will be hidden. You should
-   * hide it by yourself if you want so.
-   *
-   * #### Platform-specific
-   *
-   * - **Linux:** Unsupported.
-   * - **macOS:** This locks the cursor in a fixed location, which looks visually awkward.
-   * @example
-   * ```typescript
-   * import { appWindow } from '@tauri-apps/api/window';
-   * await appWindow.setCursorGrab(true);
-   * ```
-   *
-   * @param grab `true` to grab the cursor icon, `false` to release it.
-   * @returns A promise indicating the success or failure of the operation.
-   */
-  async setCursorGrab(grab: boolean): Promise<void> {
-    return invokeTauriCommand({
-      __tauriModule: 'Window',
-      message: {
-        cmd: 'manage',
-        data: {
-          label: this.label,
-          cmd: {
-            type: 'setCursorGrab',
-            payload: grab
-          }
-        }
-      }
-    })
-  }
-
-  /**
-   * Modifies the cursor's visibility.
-   *
-   * #### Platform-specific
-   *
-   * - **Windows:** The cursor is only hidden within the confines of the window.
-   * - **macOS:** The cursor is hidden as long as the window has input focus, even if the cursor is
-   *   outside of the window.
-   * @example
-   * ```typescript
-   * import { appWindow } from '@tauri-apps/api/window';
-   * await appWindow.setCursorVisible(false);
-   * ```
-   *
-   * @param visible If `false`, this will hide the cursor. If `true`, this will show the cursor.
-   * @returns A promise indicating the success or failure of the operation.
-   */
-  async setCursorVisible(visible: boolean): Promise<void> {
-    return invokeTauriCommand({
-      __tauriModule: 'Window',
-      message: {
-        cmd: 'manage',
-        data: {
-          label: this.label,
-          cmd: {
-            type: 'setCursorVisible',
-            payload: visible
-          }
-        }
-      }
-    })
-  }
-
-  /**
-   * Modifies the cursor icon of the window.
-   * @example
-   * ```typescript
-   * import { appWindow } from '@tauri-apps/api/window';
-   * await appWindow.setCursorIcon('help');
-   * ```
-   *
-   * @param icon The new cursor icon.
-   * @returns A promise indicating the success or failure of the operation.
-   */
-  async setCursorIcon(icon: CursorIcon): Promise<void> {
-    return invokeTauriCommand({
-      __tauriModule: 'Window',
-      message: {
-        cmd: 'manage',
-        data: {
-          label: this.label,
-          cmd: {
-            type: 'setCursorIcon',
-            payload: icon
-          }
-        }
-      }
-    })
-  }
-
-  /**
-   * Changes the position of the cursor in window coordinates.
-   * @example
-   * ```typescript
-   * import { appWindow, LogicalPosition } from '@tauri-apps/api/window';
-   * await appWindow.setCursorPosition(new LogicalPosition(600, 300));
-   * ```
-   *
-   * @param position The new cursor position.
-   * @returns A promise indicating the success or failure of the operation.
-   */
-  async setCursorPosition(
-    position: LogicalPosition | PhysicalPosition
-  ): Promise<void> {
-    if (
-      !position ||
-      (position.type !== 'Logical' && position.type !== 'Physical')
-    ) {
-      throw new Error(
-        'the `position` argument must be either a LogicalPosition or a PhysicalPosition instance'
-      )
-    }
-    return invokeTauriCommand({
-      __tauriModule: 'Window',
-      message: {
-        cmd: 'manage',
-        data: {
-          label: this.label,
-          cmd: {
-            type: 'setCursorPosition',
-            payload: {
-              type: position.type,
-              data: {
-                x: position.x,
-                y: position.y
-              }
-            }
-          }
-        }
-      }
-    })
-  }
-
-  /**
-   * Changes the cursor events behavior.
-   *
-   * @example
-   * ```typescript
-   * import { appWindow } from '@tauri-apps/api/window';
-   * await appWindow.setIgnoreCursorEvents(true);
-   * ```
-   *
-   * @param ignore `true` to ignore the cursor events; `false` to process them as usual.
-   * @returns A promise indicating the success or failure of the operation.
-   */
-  async setIgnoreCursorEvents(ignore: boolean): Promise<void> {
-    return invokeTauriCommand({
-      __tauriModule: 'Window',
-      message: {
-        cmd: 'manage',
-        data: {
-          label: this.label,
-          cmd: {
-            type: 'setIgnoreCursorEvents',
-            payload: ignore
-          }
-        }
-      }
-    })
-  }
-
-  /**
-   * Starts dragging the window.
-   * @example
-   * ```typescript
-   * import { appWindow } from '@tauri-apps/api/window';
-   * await appWindow.startDragging();
-   * ```
-   *
-   * @return A promise indicating the success or failure of the operation.
-   */
-  async startDragging(): Promise<void> {
-    return invokeTauriCommand({
-      __tauriModule: 'Window',
-      message: {
-        cmd: 'manage',
-        data: {
-          label: this.label,
-          cmd: {
-            type: 'startDragging'
-          }
-        }
-      }
-    })
-  }
-
-  // Listeners
-
-  /**
-   * Listen to window resize.
-   *
-   * @example
-   * ```typescript
-   * import { appWindow } from "@tauri-apps/api/window";
-   * const unlisten = await appWindow.onResized(({ payload: size }) => {
-   *  console.log('Window resized', size);
-   * });
-   *
-   * // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
-   * unlisten();
-   * ```
-   *
-   * @returns A promise resolving to a function to unlisten to the event.
-   * Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
-   *
-   * @since 1.0.2
-   */
-  async onResized(handler: EventCallback<PhysicalSize>): Promise<UnlistenFn> {
-    return this.listen<PhysicalSize>(TauriEvent.WINDOW_RESIZED, (e) => {
-      e.payload = mapPhysicalSize(e.payload)
-      handler(e)
-    })
-  }
-
-  /**
-   * Listen to window move.
-   *
-   * @example
-   * ```typescript
-   * import { appWindow } from "@tauri-apps/api/window";
-   * const unlisten = await appWindow.onMoved(({ payload: position }) => {
-   *  console.log('Window moved', position);
-   * });
-   *
-   * // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
-   * unlisten();
-   * ```
-   *
-   * @returns A promise resolving to a function to unlisten to the event.
-   * Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
-   *
-   * @since 1.0.2
-   */
-  async onMoved(handler: EventCallback<PhysicalPosition>): Promise<UnlistenFn> {
-    return this.listen<PhysicalPosition>(TauriEvent.WINDOW_MOVED, (e) => {
-      e.payload = mapPhysicalPosition(e.payload)
-      handler(e)
-    })
-  }
-
-  /**
-   * Listen to window close requested. Emitted when the user requests to closes the window.
-   *
-   * @example
-   * ```typescript
-   * import { appWindow } from "@tauri-apps/api/window";
-   * import { confirm } from '@tauri-apps/api/dialog';
-   * const unlisten = await appWindow.onCloseRequested(async (event) => {
-   *   const confirmed = await confirm('Are you sure?');
-   *   if (!confirmed) {
-   *     // user did not confirm closing the window; let's prevent it
-   *     event.preventDefault();
-   *   }
-   * });
-   *
-   * // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
-   * unlisten();
-   * ```
-   *
-   * @returns A promise resolving to a function to unlisten to the event.
-   * Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
-   *
-   * @since 1.0.2
-   */
-  /* eslint-disable @typescript-eslint/promise-function-async */
-  async onCloseRequested(
-    handler: (event: CloseRequestedEvent) => void | Promise<void>
-  ): Promise<UnlistenFn> {
-    return this.listen<null>(TauriEvent.WINDOW_CLOSE_REQUESTED, (event) => {
-      const evt = new CloseRequestedEvent(event)
-      void Promise.resolve(handler(evt)).then(() => {
-        if (!evt.isPreventDefault()) {
-          return this.close()
-        }
-      })
-    })
-  }
-  /* eslint-enable */
-
-  /**
-   * Listen to window focus change.
-   *
-   * @example
-   * ```typescript
-   * import { appWindow } from "@tauri-apps/api/window";
-   * const unlisten = await appWindow.onFocusChanged(({ payload: focused }) => {
-   *  console.log('Focus changed, window is focused? ' + focused);
-   * });
-   *
-   * // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
-   * unlisten();
-   * ```
-   *
-   * @returns A promise resolving to a function to unlisten to the event.
-   * Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
-   *
-   * @since 1.0.2
-   */
-  async onFocusChanged(handler: EventCallback<boolean>): Promise<UnlistenFn> {
-    const unlistenFocus = await this.listen<PhysicalPosition>(
-      TauriEvent.WINDOW_FOCUS,
-      (event) => {
-        handler({ ...event, payload: true })
-      }
-    )
-    const unlistenBlur = await this.listen<PhysicalPosition>(
-      TauriEvent.WINDOW_BLUR,
-      (event) => {
-        handler({ ...event, payload: false })
-      }
-    )
-    return () => {
-      unlistenFocus()
-      unlistenBlur()
-    }
-  }
-
-  /**
-   * Listen to window scale change. Emitted when the window's scale factor has changed.
-   * The following user actions can cause DPI changes:
-   * - Changing the display's resolution.
-   * - Changing the display's scale factor (e.g. in Control Panel on Windows).
-   * - Moving the window to a display with a different scale factor.
-   *
-   * @example
-   * ```typescript
-   * import { appWindow } from "@tauri-apps/api/window";
-   * const unlisten = await appWindow.onScaleChanged(({ payload }) => {
-   *  console.log('Scale changed', payload.scaleFactor, payload.size);
-   * });
-   *
-   * // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
-   * unlisten();
-   * ```
-   *
-   * @returns A promise resolving to a function to unlisten to the event.
-   * Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
-   *
-   * @since 1.0.2
-   */
-  async onScaleChanged(
-    handler: EventCallback<ScaleFactorChanged>
-  ): Promise<UnlistenFn> {
-    return this.listen<ScaleFactorChanged>(
-      TauriEvent.WINDOW_SCALE_FACTOR_CHANGED,
-      handler
-    )
-  }
-
-  /**
-   * Listen to the window menu item click. The payload is the item id.
-   *
-   * @example
-   * ```typescript
-   * import { appWindow } from "@tauri-apps/api/window";
-   * const unlisten = await appWindow.onMenuClicked(({ payload: menuId }) => {
-   *  console.log('Menu clicked: ' + menuId);
-   * });
-   *
-   * // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
-   * unlisten();
-   * ```
-   *
-   * @returns A promise resolving to a function to unlisten to the event.
-   * Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
-   *
-   * @since 1.0.2
-   */
-  async onMenuClicked(handler: EventCallback<string>): Promise<UnlistenFn> {
-    return this.listen<string>(TauriEvent.MENU, handler)
-  }
-
-  /**
-   * Listen to a file drop event.
-   * The listener is triggered when the user hovers the selected files on the window,
-   * drops the files or cancels the operation.
-   *
-   * @example
-   * ```typescript
-   * import { appWindow } from "@tauri-apps/api/window";
-   * const unlisten = await appWindow.onFileDropEvent((event) => {
-   *  if (event.payload.type === 'hover') {
-   *    console.log('User hovering', event.payload.paths);
-   *  } else if (event.payload.type === 'drop') {
-   *    console.log('User dropped', event.payload.paths);
-   *  } else {
-   *    console.log('File drop cancelled');
-   *  }
-   * });
-   *
-   * // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
-   * unlisten();
-   * ```
-   *
-   * @returns A promise resolving to a function to unlisten to the event.
-   * Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
-   *
-   * @since 1.0.2
-   */
-  async onFileDropEvent(
-    handler: EventCallback<FileDropEvent>
-  ): Promise<UnlistenFn> {
-    const unlistenFileDrop = await this.listen<string[]>(
-      TauriEvent.WINDOW_FILE_DROP,
-      (event) => {
-        handler({ ...event, payload: { type: 'drop', paths: event.payload } })
-      }
-    )
-
-    const unlistenFileHover = await this.listen<string[]>(
-      TauriEvent.WINDOW_FILE_DROP_HOVER,
-      (event) => {
-        handler({ ...event, payload: { type: 'hover', paths: event.payload } })
-      }
-    )
-
-    const unlistenCancel = await this.listen<null>(
-      TauriEvent.WINDOW_FILE_DROP_CANCELLED,
-      (event) => {
-        handler({ ...event, payload: { type: 'cancel' } })
-      }
-    )
-
-    return () => {
-      unlistenFileDrop()
-      unlistenFileHover()
-      unlistenCancel()
-    }
-  }
-
-  /**
-   * Listen to the system theme change.
-   *
-   * @example
-   * ```typescript
-   * import { appWindow } from "@tauri-apps/api/window";
-   * const unlisten = await appWindow.onThemeChanged(({ payload: theme }) => {
-   *  console.log('New theme: ' + theme);
-   * });
-   *
-   * // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
-   * unlisten();
-   * ```
-   *
-   * @returns A promise resolving to a function to unlisten to the event.
-   * Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
-   *
-   * @since 1.0.2
-   */
-  async onThemeChanged(handler: EventCallback<Theme>): Promise<UnlistenFn> {
-    return this.listen<Theme>(TauriEvent.WINDOW_THEME_CHANGED, handler)
-  }
-}
-
-/**
- * @since 1.0.2
- */
-class CloseRequestedEvent {
-  /** Event name */
-  event: EventName
-  /** The label of the window that emitted this event. */
-  windowLabel: string
-  /** Event identifier used to unlisten */
-  id: number
-  private _preventDefault = false
-
-  constructor(event: Event<null>) {
-    this.event = event.event
-    this.windowLabel = event.windowLabel
-    this.id = event.id
-  }
-
-  preventDefault(): void {
-    this._preventDefault = true
-  }
-
-  isPreventDefault(): boolean {
-    return this._preventDefault
-  }
-}
-
-/**
- * Create new webview windows and get a handle to existing ones.
- *
- * Windows are identified by a *label*  a unique identifier that can be used to reference it later.
- * It may only contain alphanumeric characters `a-zA-Z` plus the following special characters `-`, `/`, `:` and `_`.
- *
- * @example
- * ```typescript
- * // loading embedded asset:
- * const webview = new WebviewWindow('theUniqueLabel', {
- *   url: 'path/to/page.html'
- * });
- * // alternatively, load a remote URL:
- * const webview = new WebviewWindow('theUniqueLabel', {
- *   url: 'https://github.com/tauri-apps/tauri'
- * });
- *
- * webview.once('tauri://created', function () {
- *  // webview window successfully created
- * });
- * webview.once('tauri://error', function (e) {
- *  // an error happened creating the webview window
- * });
- *
- * // emit an event to the backend
- * await webview.emit("some event", "data");
- * // listen to an event from the backend
- * const unlisten = await webview.listen("event name", e => {});
- * unlisten();
- * ```
- *
- * @since 1.0.2
- */
-class WebviewWindow extends WindowManager {
-  /**
-   * Creates a new WebviewWindow.
-   * @example
-   * ```typescript
-   * import { WebviewWindow } from '@tauri-apps/api/window';
-   * const webview = new WebviewWindow('my-label', {
-   *   url: 'https://github.com/tauri-apps/tauri'
-   * });
-   * webview.once('tauri://created', function () {
-   *  // webview window successfully created
-   * });
-   * webview.once('tauri://error', function (e) {
-   *  // an error happened creating the webview window
-   * });
-   * ```
-   *
-   * * @param label The unique webview window label. Must be alphanumeric: `a-zA-Z-/:_`.
-   * @returns The WebviewWindow instance to communicate with the webview.
-   */
-  constructor(label: WindowLabel, options: WindowOptions = {}) {
-    super(label)
-    // @ts-expect-error `skip` is not a public API so it is not defined in WindowOptions
-    if (!options?.skip) {
-      invokeTauriCommand({
-        __tauriModule: 'Window',
-        message: {
-          cmd: 'createWebview',
-          data: {
-            options: {
-              label,
-              ...options
-            }
-          }
-        }
-      })
-        .then(async () => this.emit('tauri://created'))
-        .catch(async (e: string) => this.emit('tauri://error', e))
-    }
-  }
-
-  /**
-   * Gets the WebviewWindow for the webview associated with the given label.
-   * @example
-   * ```typescript
-   * import { WebviewWindow } from '@tauri-apps/api/window';
-   * const mainWindow = WebviewWindow.getByLabel('main');
-   * ```
-   *
-   * @param label The webview window label.
-   * @returns The WebviewWindow instance to communicate with the webview or null if the webview doesn't exist.
-   */
-  static getByLabel(label: string): WebviewWindow | null {
-    if (getAll().some((w) => w.label === label)) {
-      // @ts-expect-error `skip` is not defined in the public API but it is handled by the constructor
-      return new WebviewWindow(label, { skip: true })
-    }
-    return null
-  }
-}
-
-/** The WebviewWindow for the current window. */
-let appWindow: WebviewWindow
-if ('__TAURI_METADATA__' in window) {
-  appWindow = new WebviewWindow(
-    window.__TAURI_METADATA__.__currentWindow.label,
-    {
-      // @ts-expect-error `skip` is not defined in the public API but it is handled by the constructor
-      skip: true
-    }
-  )
-} else {
-  console.warn(
-    `Could not find "window.__TAURI_METADATA__". The "appWindow" value will reference the "main" window label.\nNote that this is not an issue if running this frontend on a browser instead of a Tauri window.`
-  )
-  appWindow = new WebviewWindow('main', {
-    // @ts-expect-error `skip` is not defined in the public API but it is handled by the constructor
-    skip: true
-  })
-}
-
-/**
- * Configuration for the window to create.
- *
- * @since 1.0.0
- */
-interface WindowOptions {
-  /**
-   * Remote URL or local file path to open.
-   *
-   * - URL such as `https://github.com/tauri-apps` is opened directly on a Tauri window.
-   * - data: URL such as `data:text/html,<html>...` is only supported with the `window-data-url` Cargo feature for the `tauri` dependency.
-   * - local file path or route such as `/path/to/page.html` or `/users` is appended to the application URL (the devServer URL on development, or `tauri://localhost/` and `https://tauri.localhost/` on production).
-   */
-  url?: string
-  /** Show window in the center of the screen.. */
-  center?: boolean
-  /** The initial vertical position. Only applies if `y` is also set. */
-  x?: number
-  /** The initial horizontal position. Only applies if `x` is also set. */
-  y?: number
-  /** The initial width. */
-  width?: number
-  /** The initial height. */
-  height?: number
-  /** The minimum width. Only applies if `minHeight` is also set. */
-  minWidth?: number
-  /** The minimum height. Only applies if `minWidth` is also set. */
-  minHeight?: number
-  /** The maximum width. Only applies if `maxHeight` is also set. */
-  maxWidth?: number
-  /** The maximum height. Only applies if `maxWidth` is also set. */
-  maxHeight?: number
-  /** Whether the window is resizable or not. */
-  resizable?: boolean
-  /** Window title. */
-  title?: string
-  /** Whether the window is in fullscreen mode or not. */
-  fullscreen?: boolean
-  /** Whether the window will be initially focused or not. */
-  focus?: boolean
-  /**
-   * Whether the window is transparent or not.
-   * Note that on `macOS` this requires the `macos-private-api` feature flag, enabled under `tauri.conf.json > tauri > macOSPrivateApi`.
-   * WARNING: Using private APIs on `macOS` prevents your application from being accepted to the `App Store`.
-   */
-  transparent?: boolean
-  /** Whether the window should be maximized upon creation or not. */
-  maximized?: boolean
-  /** Whether the window should be immediately visible upon creation or not. */
-  visible?: boolean
-  /** Whether the window should have borders and bars or not. */
-  decorations?: boolean
-  /** Whether the window should always be on top of other windows or not. */
-  alwaysOnTop?: boolean
-  /** Prevents the window contents from being captured by other apps. */
-  contentProtected?: boolean
-  /** Whether or not the window icon should be added to the taskbar. */
-  skipTaskbar?: boolean
-  /**
-   *  Whether or not the window has shadow.
-   *
-   * #### Platform-specific
-   *
-   * - **Windows:**
-   *   - `false` has no effect on decorated window, shadows are always ON.
-   *   - `true` will make ndecorated window have a 1px white border,
-   * and on Windows 11, it will have a rounded corners.
-   * - **Linux:** Unsupported.
-   *
-   * @since 2.0
-   */
-  shadow?: boolean
-  /**
-   * Whether the file drop is enabled or not on the webview. By default it is enabled.
-   *
-   * Disabling it is required to use drag and drop on the frontend on Windows.
-   */
-  fileDropEnabled?: boolean
-  /**
-   * The initial window theme. Defaults to the system theme.
-   *
-   * Only implemented on Windows and macOS 10.14+.
-   */
-  theme?: Theme
-  /**
-   * The style of the macOS title bar.
-   */
-  titleBarStyle?: TitleBarStyle
-  /**
-   * If `true`, sets the window title to be hidden on macOS.
-   */
-  hiddenTitle?: boolean
-  /**
-   * Whether clicking an inactive window also clicks through to the webview on macOS.
-   */
-  acceptFirstMouse?: boolean
-  /**
-   * Defines the window [tabbing identifier](https://developer.apple.com/documentation/appkit/nswindow/1644704-tabbingidentifier) on macOS.
-   *
-   * Windows with the same tabbing identifier will be grouped together.
-   * If the tabbing identifier is not set, automatic tabbing will be disabled.
-   */
-  tabbingIdentifier?: string
-  /**
-   * The user agent for the webview.
-   */
-  userAgent?: string
-}
-
-function mapMonitor(m: Monitor | null): Monitor | null {
-  return m === null
-    ? null
-    : {
-        name: m.name,
-        scaleFactor: m.scaleFactor,
-        position: mapPhysicalPosition(m.position),
-        size: mapPhysicalSize(m.size)
-      }
-}
-
-function mapPhysicalPosition(m: PhysicalPosition): PhysicalPosition {
-  return new PhysicalPosition(m.x, m.y)
-}
-
-function mapPhysicalSize(m: PhysicalSize): PhysicalSize {
-  return new PhysicalSize(m.width, m.height)
-}
-
-/**
- * Returns the monitor on which the window currently resides.
- * Returns `null` if current monitor can't be detected.
- * @example
- * ```typescript
- * import { currentMonitor } from '@tauri-apps/api/window';
- * const monitor = currentMonitor();
- * ```
- *
- * @since 1.0.0
- */
-async function currentMonitor(): Promise<Monitor | null> {
-  return invokeTauriCommand<Monitor | null>({
-    __tauriModule: 'Window',
-    message: {
-      cmd: 'manage',
-      data: {
-        cmd: {
-          type: 'currentMonitor'
-        }
-      }
-    }
-  }).then(mapMonitor)
-}
-
-/**
- * Returns the primary monitor of the system.
- * Returns `null` if it can't identify any monitor as a primary one.
- * @example
- * ```typescript
- * import { primaryMonitor } from '@tauri-apps/api/window';
- * const monitor = primaryMonitor();
- * ```
- *
- * @since 1.0.0
- */
-async function primaryMonitor(): Promise<Monitor | null> {
-  return invokeTauriCommand<Monitor | null>({
-    __tauriModule: 'Window',
-    message: {
-      cmd: 'manage',
-      data: {
-        cmd: {
-          type: 'primaryMonitor'
-        }
-      }
-    }
-  }).then(mapMonitor)
-}
-
-/**
- * Returns the list of all the monitors available on the system.
- * @example
- * ```typescript
- * import { availableMonitors } from '@tauri-apps/api/window';
- * const monitors = availableMonitors();
- * ```
- *
- * @since 1.0.0
- */
-async function availableMonitors(): Promise<Monitor[]> {
-  return invokeTauriCommand<Monitor[]>({
-    __tauriModule: 'Window',
-    message: {
-      cmd: 'manage',
-      data: {
-        cmd: {
-          type: 'availableMonitors'
-        }
-      }
-    }
-  }).then((ms) => ms.map(mapMonitor) as Monitor[])
-}
-
-export {
-  WebviewWindow,
-  WebviewWindowHandle,
-  WindowManager,
-  CloseRequestedEvent,
-  getCurrent,
-  getAll,
-  appWindow,
-  LogicalSize,
-  PhysicalSize,
-  LogicalPosition,
-  PhysicalPosition,
-  UserAttentionType,
-  currentMonitor,
-  primaryMonitor,
-  availableMonitors
-}
-
-export type {
-  Theme,
-  TitleBarStyle,
-  Monitor,
-  ScaleFactorChanged,
-  FileDropEvent,
-  WindowOptions
-}

+ 0 - 5
tooling/cli/schema.json

@@ -2508,11 +2508,6 @@
           "items": {
             "type": "string"
           }
-        },
-        "enableTauriAPI": {
-          "description": "Enables access to the Tauri API.",
-          "default": false,
-          "type": "boolean"
         }
       },
       "additionalProperties": false

برخی فایل ها در این مقایسه diff نمایش داده نمی شوند زیرا تعداد فایل ها بسیار زیاد است