From c23f139ba86628fe0217a966bc8676afe7202a05 Mon Sep 17 00:00:00 2001 From: Lucas Fernandes Nogueira Date: Sun, 24 Apr 2022 10:08:05 -0700 Subject: [PATCH] perf(core): improve binary size with api enum serde refactor (#3952) --- .changes/binary-size-perf.md | 5 + Cargo.toml | 1 + core/tauri-macros/src/command_module.rs | 203 ++++++++++++++----- core/tauri-macros/src/lib.rs | 14 +- core/tauri/build.rs | 2 + core/tauri/scripts/bundle.js | 2 +- core/tauri/src/endpoints.rs | 1 - core/tauri/src/endpoints/app.rs | 3 +- core/tauri/src/endpoints/cli.rs | 18 +- core/tauri/src/endpoints/clipboard.rs | 27 ++- core/tauri/src/endpoints/dialog.rs | 32 +-- core/tauri/src/endpoints/event.rs | 5 +- core/tauri/src/endpoints/file_system.rs | 32 ++- core/tauri/src/endpoints/global_shortcut.rs | 26 ++- core/tauri/src/endpoints/http.rs | 19 +- core/tauri/src/endpoints/notification.rs | 8 +- core/tauri/src/endpoints/operating_system.rs | 45 +++- core/tauri/src/endpoints/path.rs | 58 +++--- core/tauri/src/endpoints/process.rs | 17 +- core/tauri/src/endpoints/shell.rs | 44 ++-- core/tauri/src/endpoints/window.rs | 12 +- core/tauri/src/error.rs | 6 +- tooling/api/src/clipboard.ts | 5 +- 23 files changed, 388 insertions(+), 197 deletions(-) create mode 100644 .changes/binary-size-perf.md diff --git a/.changes/binary-size-perf.md b/.changes/binary-size-perf.md new file mode 100644 index 000000000..ae94d94a3 --- /dev/null +++ b/.changes/binary-size-perf.md @@ -0,0 +1,5 @@ +--- +"tauri": patch +--- + +Reduce the amount of generated code for the API endpoints. diff --git a/Cargo.toml b/Cargo.toml index 338e785b7..318929490 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,6 +24,7 @@ exclude = [ # default to small, optimized workspace release binaries [profile.release] +strip = true panic = "abort" codegen-units = 1 lto = true diff --git a/core/tauri-macros/src/command_module.rs b/core/tauri-macros/src/command_module.rs index b28887058..1203b351e 100644 --- a/core/tauri-macros/src/command_module.rs +++ b/core/tauri-macros/src/command_module.rs @@ -2,35 +2,115 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -use heck::ToSnakeCase; +use heck::{ToLowerCamelCase, ToSnakeCase}; use proc_macro::TokenStream; -use proc_macro2::{Span, TokenStream as TokenStream2, TokenTree}; +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, FnArg, Ident, ItemFn, LitStr, Pat, Token, + Data, DeriveInput, Error, Fields, Ident, ItemFn, LitStr, Token, }; -pub fn generate_run_fn(input: DeriveInput) -> TokenStream { +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 = None; + let mut error_message: Option = 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::() { + feature.replace(f); + input.parse::()?; + 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 + 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 _ = attr.parse_args_with(|input: ParseStream| { - while let Some(token) = input.parse()? { - if let TokenTree::Ident(ident) = token { - is_async |= ident == "async"; + let r = attr + .parse_args_with(|input: ParseStream| { + if let Ok(token) = input.parse::() { + is_async = token == "async"; } - } - Ok(()) - }); + 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!() }; @@ -43,6 +123,30 @@ pub fn generate_run_fn(input: DeriveInput) -> TokenStream { 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::() { + feature.replace(f); + input.parse::()?; + 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) => { @@ -73,9 +177,13 @@ pub fn generate_run_fn(input: DeriveInput) -> TokenStream { variant_execute_function_name.set_span(variant_name.span()); matcher.extend(quote_spanned! { - variant.span() => #name::#variant_name #fields_in_variant => #name::#variant_execute_function_name(context, #variables)#maybe_await.map(Into::into), + 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.studio/docs/api/config#tauri.allowlist)")), + }); } _ => { return Error::new( @@ -90,7 +198,8 @@ pub fn generate_run_fn(input: DeriveInput) -> TokenStream { let (impl_generics, ty_generics, where_clause) = input.generics.split_for_impl(); let expanded = quote! { - impl #impl_generics #name #ty_generics #where_clause { + #errors + impl #impl_generics #name #ty_generics #where_clause { pub #maybe_async fn run(self, context: crate::endpoints::InvokeContext) -> super::Result { match self { #matcher @@ -105,26 +214,25 @@ pub fn generate_run_fn(input: DeriveInput) -> TokenStream { /// Attributes for the module enum variant handler. pub struct HandlerAttributes { allowlist: Ident, - error_message: String, } impl Parse for HandlerAttributes { fn parse(input: ParseStream) -> syn::Result { - let allowlist = input.parse()?; - input.parse::()?; - let raw: LitStr = input.parse()?; - let error_message = raw.value(); Ok(Self { - allowlist, - error_message, + allowlist: input.parse()?, }) } } +pub enum AllowlistCheckKind { + Runtime, + Serde, +} + pub struct HandlerTestAttributes { allowlist: Ident, error_message: String, - is_async: bool, + allowlist_check_kind: AllowlistCheckKind, } impl Parse for HandlerTestAttributes { @@ -133,60 +241,48 @@ impl Parse for HandlerTestAttributes { input.parse::()?; let error_message_raw: LitStr = input.parse()?; let error_message = error_message_raw.value(); - let _ = input.parse::(); - let is_async = input - .parse::() - .map(|i| i == "async") - .unwrap_or_default(); + let allowlist_check_kind = + if let (Ok(_), Ok(i)) = (input.parse::(), input.parse::()) { + if i == "runtime" { + AllowlistCheckKind::Runtime + } else { + AllowlistCheckKind::Serde + } + } else { + AllowlistCheckKind::Serde + }; Ok(Self { allowlist, error_message, - is_async, + allowlist_check_kind, }) } } pub fn command_handler(attributes: HandlerAttributes, function: ItemFn) -> TokenStream2 { let allowlist = attributes.allowlist; - let error_message = attributes.error_message.as_str(); - let signature = function.sig.clone(); quote!( #[cfg(#allowlist)] #function - - #[cfg(not(#allowlist))] - #[allow(unused_variables)] - #[allow(unused_mut)] - #signature { - Err(anyhow::anyhow!(crate::Error::ApiNotAllowlisted(#error_message.to_string()).to_string())) - } ) } pub fn command_test(attributes: HandlerTestAttributes, function: ItemFn) -> TokenStream2 { let allowlist = attributes.allowlist; - let is_async = attributes.is_async; let error_message = attributes.error_message.as_str(); let signature = function.sig.clone(); - let test_name = function.sig.ident.clone(); - let mut args = quote!(); - for arg in &function.sig.inputs { - if let FnArg::Typed(t) = arg { - if let Pat::Ident(i) = &*t.pat { - let ident = &i.ident; - args.extend(quote!(#ident,)) - } - } - } - let response = if is_async { - quote!(crate::async_runtime::block_on( - super::Cmd::#test_name(crate::test::mock_invoke_context(), #args) - )) - } else { - quote!(super::Cmd::#test_name(crate::test::mock_invoke_context(), #args)) + 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::(&format!(r#"{{ "cmd": "{}", "data": null }}"#, #enum_variant_name)) + }, }; quote!( @@ -194,6 +290,7 @@ pub fn command_test(attributes: HandlerTestAttributes, function: ItemFn) -> Toke #function #[cfg(not(#allowlist))] + #[allow(unused_variables)] #[quickcheck_macros::quickcheck] #signature { if let Err(e) = #response { diff --git a/core/tauri-macros/src/lib.rs b/core/tauri-macros/src/lib.rs index 1adae76ac..3af378078 100644 --- a/core/tauri-macros/src/lib.rs +++ b/core/tauri-macros/src/lib.rs @@ -76,6 +76,14 @@ pub fn default_runtime(attributes: TokenStream, input: TokenStream) -> TokenStre 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`. @@ -83,10 +91,10 @@ pub fn default_runtime(attributes: TokenStream, input: TokenStream) -> TokenStre /// passing the the context and the variant's fields as arguments. /// That function must also return the same `Result`. #[doc(hidden)] -#[proc_macro_derive(CommandModule, attributes(cmd))] -pub fn derive_command_module(input: TokenStream) -> TokenStream { +#[proc_macro_attribute] +pub fn command_enum(_: TokenStream, input: TokenStream) -> TokenStream { let input = parse_macro_input!(input as DeriveInput); - command_module::generate_run_fn(input) + command_module::generate_command_enum(input) } #[doc(hidden)] diff --git a/core/tauri/build.rs b/core/tauri/build.rs index c1ffed5b1..e0a798284 100644 --- a/core/tauri/build.rs +++ b/core/tauri/build.rs @@ -60,6 +60,8 @@ fn main() { shell_execute: { any(shell_all, feature = "shell-execute") }, shell_sidecar: { any(shell_all, feature = "shell-sidecar") }, shell_open: { any(shell_all, feature = "shell-open") }, + // helper for the command module macro + shell_script: { any(shell_execute, shell_sidecar) }, // helper for the shell scope functionality shell_scope: { any(shell_execute, shell_sidecar, feature = "shell-open-api") }, diff --git a/core/tauri/scripts/bundle.js b/core/tauri/scripts/bundle.js index d3bef2111..a56de0c3d 100644 --- a/core/tauri/scripts/bundle.js +++ b/core/tauri/scripts/bundle.js @@ -1 +1 @@ -function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&_setPrototypeOf(e,t)}function _setPrototypeOf(e,t){return(_setPrototypeOf=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function _createSuper(e){var t=_isNativeReflectConstruct();return function(){var r,n=_getPrototypeOf(e);if(t){var a=_getPrototypeOf(this).constructor;r=Reflect.construct(n,arguments,a)}else r=n.apply(this,arguments);return _possibleConstructorReturn(this,r)}}function _possibleConstructorReturn(e,t){if(t&&("object"===_typeof(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(e)}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function _getPrototypeOf(e){return(_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function _createForOfIteratorHelper(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=_unsupportedIterableToArray(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,a=function(){};return{s:a,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,i=!0,u=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return i=e.done,e},e:function(e){u=!0,o=e},f:function(){try{i||null==r.return||r.return()}finally{if(u)throw o}}}}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(e,t):void 0}}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r=0;--o){var i=this.tryEntries[o],u=i.completion;if("root"===i.tryLoc)return a("end");if(i.tryLoc<=this.prev){var s=n.call(i,"catchLoc"),c=n.call(i,"finallyLoc");if(s&&c){if(this.prev=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&n.call(a,"finallyLoc")&&this.prev=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),P(r),d}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var a=n.arg;P(r)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:O(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),d}},e}("object"===("undefined"==typeof module?"undefined":_typeof(module))?module.exports:{});try{regeneratorRuntime=t}catch(e){"object"===("undefined"==typeof globalThis?"undefined":_typeof(globalThis))?globalThis.regeneratorRuntime=t:Function("r","regeneratorRuntime = r")(t)}function r(e){for(var t=void 0,r=e[0],n=1;n1&&void 0!==arguments[1]&&arguments[1],a=n(),o="_".concat(a);return Object.defineProperty(window,o,{value:function(n){return t&&Reflect.deleteProperty(window,o),r([e,"optionalCall",function(e){return e(n)}])},writable:!1,configurable:!0}),a}function o(e){return i.apply(this,arguments)}function i(){return(i=_asyncToGenerator(regeneratorRuntime.mark((function e(t){var r,n=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=n.length>1&&void 0!==n[1]?n[1]:{},e.abrupt("return",new Promise((function(e,n){var o=a((function(t){e(t),Reflect.deleteProperty(window,i)}),!0),i=a((function(e){n(e),Reflect.deleteProperty(window,o)}),!0);window.__TAURI_IPC__(_objectSpread({cmd:t,callback:o,error:i},r))})));case 2:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var u=Object.freeze({__proto__:null,transformCallback:a,invoke:o,convertFileSrc:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"asset",r=encodeURIComponent(e);return navigator.userAgent.includes("Windows")?"https://".concat(t,".localhost/").concat(r):"".concat(t,"://").concat(r)}});function s(e){return c.apply(this,arguments)}function c(){return(c=_asyncToGenerator(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",o("tauri",t));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function p(){return(p=_asyncToGenerator(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"App",message:{cmd:"getAppVersion"}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function l(){return(l=_asyncToGenerator(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"App",message:{cmd:"getAppName"}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function f(){return(f=_asyncToGenerator(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"App",message:{cmd:"getTauriVersion"}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var h=Object.freeze({__proto__:null,getName:function(){return l.apply(this,arguments)},getVersion:function(){return p.apply(this,arguments)},getTauriVersion:function(){return f.apply(this,arguments)}});function m(){return(m=_asyncToGenerator(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"Cli",message:{cmd:"cliMatches"}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var d=Object.freeze({__proto__:null,getMatches:function(){return m.apply(this,arguments)}});function y(){return(y=_asyncToGenerator(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"Clipboard",message:{cmd:"writeText",data:t}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function g(){return(g=_asyncToGenerator(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"Clipboard",message:{cmd:"readText"}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var _=Object.freeze({__proto__:null,writeText:function(e){return y.apply(this,arguments)},readText:function(){return g.apply(this,arguments)}});function w(){return(w=_asyncToGenerator(regeneratorRuntime.mark((function e(){var t,r=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return"object"===_typeof(t=r.length>0&&void 0!==r[0]?r[0]:{})&&Object.freeze(t),e.abrupt("return",s({__tauriModule:"Dialog",message:{cmd:"openDialog",options:t}}));case 3:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function v(){return(v=_asyncToGenerator(regeneratorRuntime.mark((function e(){var t,r=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return"object"===_typeof(t=r.length>0&&void 0!==r[0]?r[0]:{})&&Object.freeze(t),e.abrupt("return",s({__tauriModule:"Dialog",message:{cmd:"saveDialog",options:t}}));case 3:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function b(){return(b=_asyncToGenerator(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"Dialog",message:{cmd:"messageDialog",message:t}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function R(){return(R=_asyncToGenerator(regeneratorRuntime.mark((function e(t,r){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"Dialog",message:{cmd:"askDialog",title:r,message:t}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function k(){return(k=_asyncToGenerator(regeneratorRuntime.mark((function e(t,r){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"Dialog",message:{cmd:"confirmDialog",title:r,message:t}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var x=Object.freeze({__proto__:null,open:function(){return w.apply(this,arguments)},save:function(){return v.apply(this,arguments)},message:function(e){return b.apply(this,arguments)},ask:function(e,t){return R.apply(this,arguments)},confirm:function(e,t){return k.apply(this,arguments)}});function T(e,t){return G.apply(this,arguments)}function G(){return(G=_asyncToGenerator(regeneratorRuntime.mark((function e(t,r){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"Event",message:{cmd:"unlisten",event:t,eventId:r}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function P(e,t,r){return M.apply(this,arguments)}function M(){return(M=_asyncToGenerator(regeneratorRuntime.mark((function e(t,r,n){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,s({__tauriModule:"Event",message:{cmd:"emit",event:t,windowLabel:r,payload:"string"==typeof n?n:JSON.stringify(n)}});case 2:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function O(e,t,r){return A.apply(this,arguments)}function A(){return(A=_asyncToGenerator(regeneratorRuntime.mark((function e(t,r,n){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"Event",message:{cmd:"listen",event:t,windowLabel:r,handler:a(n)}}).then((function(e){return _asyncToGenerator(regeneratorRuntime.mark((function r(){return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",T(t,e));case 1:case"end":return r.stop()}}),r)})))})));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function C(e,t,r){return j.apply(this,arguments)}function j(){return(j=_asyncToGenerator(regeneratorRuntime.mark((function e(t,r,n){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",O(t,r,(function(e){n(e),T(t,e.id).catch((function(){}))})));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function S(e,t){return D.apply(this,arguments)}function D(){return(D=_asyncToGenerator(regeneratorRuntime.mark((function e(t,r){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",O(t,null,r));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function L(e,t){return z.apply(this,arguments)}function z(){return(z=_asyncToGenerator(regeneratorRuntime.mark((function e(t,r){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",C(t,null,r));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function E(e,t){return W.apply(this,arguments)}function W(){return(W=_asyncToGenerator(regeneratorRuntime.mark((function e(t,r){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",P(t,void 0,r));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var F,I=Object.freeze({__proto__:null,listen:S,once:L,emit:E});function N(){return(N=_asyncToGenerator(regeneratorRuntime.mark((function e(t){var r,n=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=n.length>1&&void 0!==n[1]?n[1]:{},e.abrupt("return",s({__tauriModule:"Fs",message:{cmd:"readTextFile",path:t,options:r}}));case 2:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function U(){return(U=_asyncToGenerator(regeneratorRuntime.mark((function e(t){var r,n,a=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=a.length>1&&void 0!==a[1]?a[1]:{},e.next=3,s({__tauriModule:"Fs",message:{cmd:"readFile",path:t,options:r}});case 3:return n=e.sent,e.abrupt("return",Uint8Array.from(n));case 5:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function H(){return(H=_asyncToGenerator(regeneratorRuntime.mark((function e(t){var r,n=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return"object"===_typeof(r=n.length>1&&void 0!==n[1]?n[1]:{})&&Object.freeze(r),"object"===_typeof(t)&&Object.freeze(t),e.abrupt("return",s({__tauriModule:"Fs",message:{cmd:"writeFile",path:t.path,contents:Array.from((new TextEncoder).encode(t.contents)),options:r}}));case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function V(){return(V=_asyncToGenerator(regeneratorRuntime.mark((function e(t){var r,n=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return"object"===_typeof(r=n.length>1&&void 0!==n[1]?n[1]:{})&&Object.freeze(r),"object"===_typeof(t)&&Object.freeze(t),e.abrupt("return",s({__tauriModule:"Fs",message:{cmd:"writeFile",path:t.path,contents:Array.from(t.contents),options:r}}));case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function q(){return(q=_asyncToGenerator(regeneratorRuntime.mark((function e(t){var r,n=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=n.length>1&&void 0!==n[1]?n[1]:{},e.abrupt("return",s({__tauriModule:"Fs",message:{cmd:"readDir",path:t,options:r}}));case 2:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function B(){return(B=_asyncToGenerator(regeneratorRuntime.mark((function e(t){var r,n=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=n.length>1&&void 0!==n[1]?n[1]:{},e.abrupt("return",s({__tauriModule:"Fs",message:{cmd:"createDir",path:t,options:r}}));case 2:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function J(){return(J=_asyncToGenerator(regeneratorRuntime.mark((function e(t){var r,n=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=n.length>1&&void 0!==n[1]?n[1]:{},e.abrupt("return",s({__tauriModule:"Fs",message:{cmd:"removeDir",path:t,options:r}}));case 2:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function K(){return(K=_asyncToGenerator(regeneratorRuntime.mark((function e(t,r){var n,a=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=a.length>2&&void 0!==a[2]?a[2]:{},e.abrupt("return",s({__tauriModule:"Fs",message:{cmd:"copyFile",source:t,destination:r,options:n}}));case 2:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Y(){return(Y=_asyncToGenerator(regeneratorRuntime.mark((function e(t){var r,n=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=n.length>1&&void 0!==n[1]?n[1]:{},e.abrupt("return",s({__tauriModule:"Fs",message:{cmd:"removeFile",path:t,options:r}}));case 2:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function $(){return($=_asyncToGenerator(regeneratorRuntime.mark((function e(t,r){var n,a=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=a.length>2&&void 0!==a[2]?a[2]:{},e.abrupt("return",s({__tauriModule:"Fs",message:{cmd:"renameFile",oldPath:t,newPath:r,options:n}}));case 2:case"end":return e.stop()}}),e)})))).apply(this,arguments)}!function(e){e[e.Audio=1]="Audio";e[e.Cache=2]="Cache";e[e.Config=3]="Config";e[e.Data=4]="Data";e[e.LocalData=5]="LocalData";e[e.Desktop=6]="Desktop";e[e.Document=7]="Document";e[e.Download=8]="Download";e[e.Executable=9]="Executable";e[e.Font=10]="Font";e[e.Home=11]="Home";e[e.Picture=12]="Picture";e[e.Public=13]="Public";e[e.Runtime=14]="Runtime";e[e.Template=15]="Template";e[e.Video=16]="Video";e[e.Resource=17]="Resource";e[e.App=18]="App";e[e.Log=19]="Log";e[e.Temp=20]="Temp"}(F||(F={}));var Q=Object.freeze({__proto__:null,get BaseDirectory(){return F},get Dir(){return F},readTextFile:function(e){return N.apply(this,arguments)},readBinaryFile:function(e){return U.apply(this,arguments)},writeFile:function(e){return H.apply(this,arguments)},writeBinaryFile:function(e){return V.apply(this,arguments)},readDir:function(e){return q.apply(this,arguments)},createDir:function(e){return B.apply(this,arguments)},removeDir:function(e){return J.apply(this,arguments)},copyFile:function(e,t){return K.apply(this,arguments)},removeFile:function(e){return Y.apply(this,arguments)},renameFile:function(e,t){return $.apply(this,arguments)}});function X(){return(X=_asyncToGenerator(regeneratorRuntime.mark((function e(t,r){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"GlobalShortcut",message:{cmd:"register",shortcut:t,handler:a(r)}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Z(){return(Z=_asyncToGenerator(regeneratorRuntime.mark((function e(t,r){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"GlobalShortcut",message:{cmd:"registerAll",shortcuts:t,handler:a(r)}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function ee(){return(ee=_asyncToGenerator(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"GlobalShortcut",message:{cmd:"isRegistered",shortcut:t}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function te(){return(te=_asyncToGenerator(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"GlobalShortcut",message:{cmd:"unregister",shortcut:t}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function re(){return(re=_asyncToGenerator(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"GlobalShortcut",message:{cmd:"unregisterAll"}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var ne,ae=Object.freeze({__proto__:null,register:function(e,t){return X.apply(this,arguments)},registerAll:function(e,t){return Z.apply(this,arguments)},isRegistered:function(e){return ee.apply(this,arguments)},unregister:function(e){return te.apply(this,arguments)},unregisterAll:function(){return re.apply(this,arguments)}});function oe(e,t){return null!=e?e:t()}function ie(e){for(var t=void 0,r=e[0],n=1;n=200&&this.status<300,this.headers=t.headers,this.rawHeaders=t.rawHeaders,this.data=t.data})),ce=function(){function e(t){_classCallCheck(this,e),this.id=t}var t,r,n,a,o,i,u;return _createClass(e,[{key:"drop",value:(u=_asyncToGenerator(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"Http",message:{cmd:"dropClient",client:this.id}}));case 1:case"end":return e.stop()}}),e,this)}))),function(){return u.apply(this,arguments)})},{key:"request",value:(i=_asyncToGenerator(regeneratorRuntime.mark((function e(t){var r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(r=!t.responseType||t.responseType===ne.JSON)&&(t.responseType=ne.Text),e.abrupt("return",s({__tauriModule:"Http",message:{cmd:"httpRequest",client:this.id,options:t}}).then((function(e){var t=new se(e);if(r){try{t.data=JSON.parse(t.data)}catch(e){if(t.ok&&""===t.data)t.data={};else if(t.ok)throw Error("Failed to parse response `".concat(t.data,"` as JSON: ").concat(e,";\n try setting the `responseType` option to `ResponseType.Text` or `ResponseType.Binary` if the API does not return a JSON response."))}return t}return t})));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"get",value:(o=_asyncToGenerator(regeneratorRuntime.mark((function e(t,r){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.request(_objectSpread({method:"GET",url:t},r)));case 1:case"end":return e.stop()}}),e,this)}))),function(e,t){return o.apply(this,arguments)})},{key:"post",value:(a=_asyncToGenerator(regeneratorRuntime.mark((function e(t,r,n){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.request(_objectSpread({method:"POST",url:t,body:r},n)));case 1:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return a.apply(this,arguments)})},{key:"put",value:(n=_asyncToGenerator(regeneratorRuntime.mark((function e(t,r,n){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.request(_objectSpread({method:"PUT",url:t,body:r},n)));case 1:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return n.apply(this,arguments)})},{key:"patch",value:(r=_asyncToGenerator(regeneratorRuntime.mark((function e(t,r){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.request(_objectSpread({method:"PATCH",url:t},r)));case 1:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"delete",value:(t=_asyncToGenerator(regeneratorRuntime.mark((function e(t,r){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.request(_objectSpread({method:"DELETE",url:t},r)));case 1:case"end":return e.stop()}}),e,this)}))),function(e,r){return t.apply(this,arguments)})}]),e}();function pe(e){return le.apply(this,arguments)}function le(){return(le=_asyncToGenerator(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"Http",message:{cmd:"createClient",options:t}}).then((function(e){return new ce(e)})));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var fe=null;function he(){return(he=_asyncToGenerator(regeneratorRuntime.mark((function e(t,r){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null!==fe){e.next=4;break}return e.next=3,pe();case 3:fe=e.sent;case 4:return e.abrupt("return",fe.request(_objectSpread({url:t,method:oe(ie([r,"optionalAccess",function(e){return e.method}]),(function(){return"GET"}))},r)));case 5:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var me=Object.freeze({__proto__:null,getClient:pe,fetch:function(e,t){return he.apply(this,arguments)},Body:ue,Client:ce,Response:se,get ResponseType(){return ne}});function de(){return(de=_asyncToGenerator(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("default"===window.Notification.permission){e.next=2;break}return e.abrupt("return",Promise.resolve("granted"===window.Notification.permission));case 2:return e.abrupt("return",s({__tauriModule:"Notification",message:{cmd:"isNotificationPermissionGranted"}}));case 3:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function ye(){return(ye=_asyncToGenerator(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",window.Notification.requestPermission());case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var ge=Object.freeze({__proto__:null,sendNotification:function(e){"string"==typeof e?new window.Notification(e):new window.Notification(e.title,e)},requestPermission:function(){return ye.apply(this,arguments)},isPermissionGranted:function(){return de.apply(this,arguments)}});function _e(){return navigator.appVersion.includes("Win")}function we(){return(we=_asyncToGenerator(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"Path",message:{cmd:"resolvePath",path:"",directory:F.App}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function ve(){return(ve=_asyncToGenerator(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"Path",message:{cmd:"resolvePath",path:"",directory:F.Audio}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function be(){return(be=_asyncToGenerator(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"Path",message:{cmd:"resolvePath",path:"",directory:F.Cache}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Re(){return(Re=_asyncToGenerator(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"Path",message:{cmd:"resolvePath",path:"",directory:F.Config}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function ke(){return(ke=_asyncToGenerator(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"Path",message:{cmd:"resolvePath",path:"",directory:F.Data}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function xe(){return(xe=_asyncToGenerator(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"Path",message:{cmd:"resolvePath",path:"",directory:F.Desktop}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Te(){return(Te=_asyncToGenerator(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"Path",message:{cmd:"resolvePath",path:"",directory:F.Document}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Ge(){return(Ge=_asyncToGenerator(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"Path",message:{cmd:"resolvePath",path:"",directory:F.Download}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Pe(){return(Pe=_asyncToGenerator(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"Path",message:{cmd:"resolvePath",path:"",directory:F.Executable}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Me(){return(Me=_asyncToGenerator(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"Path",message:{cmd:"resolvePath",path:"",directory:F.Font}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Oe(){return(Oe=_asyncToGenerator(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"Path",message:{cmd:"resolvePath",path:"",directory:F.Home}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Ae(){return(Ae=_asyncToGenerator(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"Path",message:{cmd:"resolvePath",path:"",directory:F.LocalData}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Ce(){return(Ce=_asyncToGenerator(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"Path",message:{cmd:"resolvePath",path:"",directory:F.Picture}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function je(){return(je=_asyncToGenerator(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"Path",message:{cmd:"resolvePath",path:"",directory:F.Public}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Se(){return(Se=_asyncToGenerator(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"Path",message:{cmd:"resolvePath",path:"",directory:F.Resource}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function De(){return(De=_asyncToGenerator(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"Path",message:{cmd:"resolvePath",path:"",directory:F.Runtime}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Le(){return(Le=_asyncToGenerator(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"Path",message:{cmd:"resolvePath",path:"",directory:F.Template}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function ze(){return(ze=_asyncToGenerator(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"Path",message:{cmd:"resolvePath",path:"",directory:F.Video}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Ee(){return(Ee=_asyncToGenerator(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"Path",message:{cmd:"resolvePath",path:"",directory:F.Log}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var We=_e()?"\\":"/",Fe=_e()?";":":";function Ie(){return(Ie=_asyncToGenerator(regeneratorRuntime.mark((function e(){var t,r,n,a=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(t=a.length,r=new Array(t),n=0;n0&&void 0!==r[0]?r[0]:0,e.abrupt("return",s({__tauriModule:"Process",message:{cmd:"exit",exitCode:t}}));case 2:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Ye(){return(Ye=_asyncToGenerator(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"Process",message:{cmd:"relaunch"}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var $e=Object.freeze({__proto__:null,exit:function(){return Ke.apply(this,arguments)},relaunch:function(){return Ye.apply(this,arguments)}});function Qe(e,t){return null!=e?e:t()}function Xe(e,t){return Ze.apply(this,arguments)}function Ze(){return(Ze=_asyncToGenerator(regeneratorRuntime.mark((function e(t,r){var n,o,i=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=i.length>2&&void 0!==i[2]?i[2]:[],o=i.length>3?i[3]:void 0,"object"===_typeof(n)&&Object.freeze(n),e.abrupt("return",s({__tauriModule:"Shell",message:{cmd:"execute",program:r,args:n,options:o,onEventFn:a(t)}}));case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var et=function(){function e(){_classCallCheck(this,e),e.prototype.__init.call(this)}return _createClass(e,[{key:"__init",value:function(){this.eventListeners=Object.create(null)}},{key:"addEventListener",value:function(e,t){e in this.eventListeners?this.eventListeners[e].push(t):this.eventListeners[e]=[t]}},{key:"_emit",value:function(e,t){if(e in this.eventListeners){var r,n=_createForOfIteratorHelper(this.eventListeners[e]);try{for(n.s();!(r=n.n()).done;){(0,r.value)(t)}}catch(e){n.e(e)}finally{n.f()}}}},{key:"on",value:function(e,t){return this.addEventListener(e,t),this}}]),e}(),tt=function(){function e(t){_classCallCheck(this,e),this.pid=t}var t,r;return _createClass(e,[{key:"write",value:(r=_asyncToGenerator(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"Shell",message:{cmd:"stdinWrite",pid:this.pid,buffer:"string"==typeof t?t:Array.from(t)}}));case 1:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"kill",value:(t=_asyncToGenerator(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"Shell",message:{cmd:"killChild",pid:this.pid}}));case 1:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),e}(),rt=function(e){_inherits(a,e);var t,r,n=_createSuper(a);function a(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],o=arguments.length>2?arguments[2]:void 0;return _classCallCheck(this,a),t=n.call(this),a.prototype.__init2.call(_assertThisInitialized(t)),a.prototype.__init3.call(_assertThisInitialized(t)),t.program=e,t.args="string"==typeof r?[r]:r,t.options=Qe(o,(function(){return{}})),t}return _createClass(a,[{key:"__init2",value:function(){this.stdout=new et}},{key:"__init3",value:function(){this.stderr=new et}},{key:"spawn",value:(r=_asyncToGenerator(regeneratorRuntime.mark((function e(){var t=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",Xe((function(e){switch(e.event){case"Error":t._emit("error",e.payload);break;case"Terminated":t._emit("close",e.payload);break;case"Stdout":t.stdout._emit("data",e.payload);break;case"Stderr":t.stderr._emit("data",e.payload)}}),this.program,this.args,this.options).then((function(e){return new tt(e)})));case 1:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"execute",value:(t=_asyncToGenerator(regeneratorRuntime.mark((function e(){var t=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise((function(e,r){t.on("error",r);var n=[],a=[];t.stdout.on("data",(function(e){n.push(e)})),t.stderr.on("data",(function(e){a.push(e)})),t.on("close",(function(t){e({code:t.code,signal:t.signal,stdout:n.join("\n"),stderr:a.join("\n")})})),t.spawn().catch(r)})));case 1:case"end":return e.stop()}}),e)}))),function(){return t.apply(this,arguments)})}],[{key:"sidecar",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],r=arguments.length>2?arguments[2]:void 0,n=new a(e,t,r);return n.options.sidecar=!0,n}}]),a}(et);function nt(){return(nt=_asyncToGenerator(regeneratorRuntime.mark((function e(t,r){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"Shell",message:{cmd:"open",path:t,with:r}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var at=Object.freeze({__proto__:null,Command:rt,Child:tt,EventEmitter:et,open:function(e,t){return nt.apply(this,arguments)}});function ot(e){for(var t=void 0,r=e[0],n=1;n1&&void 0!==arguments[1]?arguments[1]:{};return _classCallCheck(this,r),n=t.call(this,e),ct([a,"optionalAccess",function(e){return e.skip}])||s({__tauriModule:"Window",message:{cmd:"createWebview",data:{options:_objectSpread({label:e},a)}}}).then(_asyncToGenerator(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",n.emit("tauri://created"));case 1:case"end":return e.stop()}}),e)})))).catch(function(){var e=_asyncToGenerator(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",n.emit("tauri://error",t));case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()),n}return _createClass(r,null,[{key:"getByLabel",value:function(e){return dt().some((function(t){return t.label===e}))?new r(e,{skip:!0}):null}}]),r}(wt);function bt(){return(bt=_asyncToGenerator(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"Window",message:{cmd:"manage",data:{cmd:{type:"currentMonitor"}}}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Rt(){return(Rt=_asyncToGenerator(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"Window",message:{cmd:"manage",data:{cmd:{type:"primaryMonitor"}}}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function kt(){return(kt=_asyncToGenerator(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"Window",message:{cmd:"manage",data:{cmd:{type:"availableMonitors"}}}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}"__TAURI_METADATA__"in window?yt=new vt(window.__TAURI_METADATA__.__currentWindow.label,{skip:!0}):(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.'),yt=new vt("main",{skip:!0}));var xt=Object.freeze({__proto__:null,WebviewWindow:vt,WebviewWindowHandle:_t,WindowManager:wt,getCurrent:function(){return new vt(window.__TAURI_METADATA__.__currentWindow.label,{skip:!0})},getAll:dt,get appWindow(){return yt},LogicalSize:lt,PhysicalSize:ft,LogicalPosition:ht,PhysicalPosition:mt,get UserAttentionType(){return pt},currentMonitor:function(){return bt.apply(this,arguments)},primaryMonitor:function(){return Rt.apply(this,arguments)},availableMonitors:function(){return kt.apply(this,arguments)}}),Tt=_e()?"\r\n":"\n";function Gt(){return(Gt=_asyncToGenerator(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"Os",message:{cmd:"platform"}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Pt(){return(Pt=_asyncToGenerator(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"Os",message:{cmd:"version"}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Mt(){return(Mt=_asyncToGenerator(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"Os",message:{cmd:"osType"}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Ot(){return(Ot=_asyncToGenerator(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"Os",message:{cmd:"arch"}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function At(){return(At=_asyncToGenerator(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"Os",message:{cmd:"tempdir"}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var Ct=Object.freeze({__proto__:null,EOL:Tt,platform:function(){return Gt.apply(this,arguments)},version:function(){return Pt.apply(this,arguments)},type:function(){return Mt.apply(this,arguments)},arch:function(){return Ot.apply(this,arguments)},tempdir:function(){return At.apply(this,arguments)}}),jt=o;e.app=h,e.cli=d,e.clipboard=_,e.dialog=x,e.event=I,e.fs=Q,e.globalShortcut=ae,e.http=me,e.invoke=jt,e.notification=ge,e.os=Ct,e.path=Je,e.process=$e,e.shell=at,e.tauri=u,e.updater=st,e.window=xt,Object.defineProperty(e,"__esModule",{value:!0})})); +function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&_setPrototypeOf(e,t)}function _setPrototypeOf(e,t){return(_setPrototypeOf=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function _createSuper(e){var t=_isNativeReflectConstruct();return function(){var r,n=_getPrototypeOf(e);if(t){var a=_getPrototypeOf(this).constructor;r=Reflect.construct(n,arguments,a)}else r=n.apply(this,arguments);return _possibleConstructorReturn(this,r)}}function _possibleConstructorReturn(e,t){if(t&&("object"===_typeof(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(e)}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function _getPrototypeOf(e){return(_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function _createForOfIteratorHelper(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=_unsupportedIterableToArray(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,a=function(){};return{s:a,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,i=!0,u=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return i=e.done,e},e:function(e){u=!0,o=e},f:function(){try{i||null==r.return||r.return()}finally{if(u)throw o}}}}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(e,t):void 0}}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r=0;--o){var i=this.tryEntries[o],u=i.completion;if("root"===i.tryLoc)return a("end");if(i.tryLoc<=this.prev){var s=n.call(i,"catchLoc"),c=n.call(i,"finallyLoc");if(s&&c){if(this.prev=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&n.call(a,"finallyLoc")&&this.prev=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),P(r),d}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var a=n.arg;P(r)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:O(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),d}},e}("object"===("undefined"==typeof module?"undefined":_typeof(module))?module.exports:{});try{regeneratorRuntime=t}catch(e){"object"===("undefined"==typeof globalThis?"undefined":_typeof(globalThis))?globalThis.regeneratorRuntime=t:Function("r","regeneratorRuntime = r")(t)}function r(e){for(var t=void 0,r=e[0],n=1;n1&&void 0!==arguments[1]&&arguments[1],a=n(),o="_".concat(a);return Object.defineProperty(window,o,{value:function(n){return t&&Reflect.deleteProperty(window,o),r([e,"optionalCall",function(e){return e(n)}])},writable:!1,configurable:!0}),a}function o(e){return i.apply(this,arguments)}function i(){return(i=_asyncToGenerator(regeneratorRuntime.mark((function e(t){var r,n=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=n.length>1&&void 0!==n[1]?n[1]:{},e.abrupt("return",new Promise((function(e,n){var o=a((function(t){e(t),Reflect.deleteProperty(window,i)}),!0),i=a((function(e){n(e),Reflect.deleteProperty(window,o)}),!0);window.__TAURI_IPC__(_objectSpread({cmd:t,callback:o,error:i},r))})));case 2:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var u=Object.freeze({__proto__:null,transformCallback:a,invoke:o,convertFileSrc:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"asset",r=encodeURIComponent(e);return navigator.userAgent.includes("Windows")?"https://".concat(t,".localhost/").concat(r):"".concat(t,"://").concat(r)}});function s(e){return c.apply(this,arguments)}function c(){return(c=_asyncToGenerator(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",o("tauri",t));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function p(){return(p=_asyncToGenerator(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"App",message:{cmd:"getAppVersion"}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function l(){return(l=_asyncToGenerator(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"App",message:{cmd:"getAppName"}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function f(){return(f=_asyncToGenerator(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"App",message:{cmd:"getTauriVersion"}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var h=Object.freeze({__proto__:null,getName:function(){return l.apply(this,arguments)},getVersion:function(){return p.apply(this,arguments)},getTauriVersion:function(){return f.apply(this,arguments)}});function m(){return(m=_asyncToGenerator(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"Cli",message:{cmd:"cliMatches"}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var d=Object.freeze({__proto__:null,getMatches:function(){return m.apply(this,arguments)}});function y(){return(y=_asyncToGenerator(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"Clipboard",message:{cmd:"writeText",data:t}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function g(){return(g=_asyncToGenerator(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"Clipboard",message:{cmd:"readText",data:null}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var _=Object.freeze({__proto__:null,writeText:function(e){return y.apply(this,arguments)},readText:function(){return g.apply(this,arguments)}});function w(){return(w=_asyncToGenerator(regeneratorRuntime.mark((function e(){var t,r=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return"object"===_typeof(t=r.length>0&&void 0!==r[0]?r[0]:{})&&Object.freeze(t),e.abrupt("return",s({__tauriModule:"Dialog",message:{cmd:"openDialog",options:t}}));case 3:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function v(){return(v=_asyncToGenerator(regeneratorRuntime.mark((function e(){var t,r=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return"object"===_typeof(t=r.length>0&&void 0!==r[0]?r[0]:{})&&Object.freeze(t),e.abrupt("return",s({__tauriModule:"Dialog",message:{cmd:"saveDialog",options:t}}));case 3:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function b(){return(b=_asyncToGenerator(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"Dialog",message:{cmd:"messageDialog",message:t}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function R(){return(R=_asyncToGenerator(regeneratorRuntime.mark((function e(t,r){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"Dialog",message:{cmd:"askDialog",title:r,message:t}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function k(){return(k=_asyncToGenerator(regeneratorRuntime.mark((function e(t,r){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"Dialog",message:{cmd:"confirmDialog",title:r,message:t}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var x=Object.freeze({__proto__:null,open:function(){return w.apply(this,arguments)},save:function(){return v.apply(this,arguments)},message:function(e){return b.apply(this,arguments)},ask:function(e,t){return R.apply(this,arguments)},confirm:function(e,t){return k.apply(this,arguments)}});function T(e,t){return G.apply(this,arguments)}function G(){return(G=_asyncToGenerator(regeneratorRuntime.mark((function e(t,r){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"Event",message:{cmd:"unlisten",event:t,eventId:r}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function P(e,t,r){return M.apply(this,arguments)}function M(){return(M=_asyncToGenerator(regeneratorRuntime.mark((function e(t,r,n){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,s({__tauriModule:"Event",message:{cmd:"emit",event:t,windowLabel:r,payload:"string"==typeof n?n:JSON.stringify(n)}});case 2:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function O(e,t,r){return A.apply(this,arguments)}function A(){return(A=_asyncToGenerator(regeneratorRuntime.mark((function e(t,r,n){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"Event",message:{cmd:"listen",event:t,windowLabel:r,handler:a(n)}}).then((function(e){return _asyncToGenerator(regeneratorRuntime.mark((function r(){return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.abrupt("return",T(t,e));case 1:case"end":return r.stop()}}),r)})))})));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function C(e,t,r){return j.apply(this,arguments)}function j(){return(j=_asyncToGenerator(regeneratorRuntime.mark((function e(t,r,n){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",O(t,r,(function(e){n(e),T(t,e.id).catch((function(){}))})));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function S(e,t){return D.apply(this,arguments)}function D(){return(D=_asyncToGenerator(regeneratorRuntime.mark((function e(t,r){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",O(t,null,r));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function L(e,t){return z.apply(this,arguments)}function z(){return(z=_asyncToGenerator(regeneratorRuntime.mark((function e(t,r){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",C(t,null,r));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function E(e,t){return W.apply(this,arguments)}function W(){return(W=_asyncToGenerator(regeneratorRuntime.mark((function e(t,r){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",P(t,void 0,r));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var F,I=Object.freeze({__proto__:null,listen:S,once:L,emit:E});function N(){return(N=_asyncToGenerator(regeneratorRuntime.mark((function e(t){var r,n=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=n.length>1&&void 0!==n[1]?n[1]:{},e.abrupt("return",s({__tauriModule:"Fs",message:{cmd:"readTextFile",path:t,options:r}}));case 2:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function U(){return(U=_asyncToGenerator(regeneratorRuntime.mark((function e(t){var r,n,a=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=a.length>1&&void 0!==a[1]?a[1]:{},e.next=3,s({__tauriModule:"Fs",message:{cmd:"readFile",path:t,options:r}});case 3:return n=e.sent,e.abrupt("return",Uint8Array.from(n));case 5:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function H(){return(H=_asyncToGenerator(regeneratorRuntime.mark((function e(t){var r,n=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return"object"===_typeof(r=n.length>1&&void 0!==n[1]?n[1]:{})&&Object.freeze(r),"object"===_typeof(t)&&Object.freeze(t),e.abrupt("return",s({__tauriModule:"Fs",message:{cmd:"writeFile",path:t.path,contents:Array.from((new TextEncoder).encode(t.contents)),options:r}}));case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function V(){return(V=_asyncToGenerator(regeneratorRuntime.mark((function e(t){var r,n=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return"object"===_typeof(r=n.length>1&&void 0!==n[1]?n[1]:{})&&Object.freeze(r),"object"===_typeof(t)&&Object.freeze(t),e.abrupt("return",s({__tauriModule:"Fs",message:{cmd:"writeFile",path:t.path,contents:Array.from(t.contents),options:r}}));case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function q(){return(q=_asyncToGenerator(regeneratorRuntime.mark((function e(t){var r,n=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=n.length>1&&void 0!==n[1]?n[1]:{},e.abrupt("return",s({__tauriModule:"Fs",message:{cmd:"readDir",path:t,options:r}}));case 2:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function B(){return(B=_asyncToGenerator(regeneratorRuntime.mark((function e(t){var r,n=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=n.length>1&&void 0!==n[1]?n[1]:{},e.abrupt("return",s({__tauriModule:"Fs",message:{cmd:"createDir",path:t,options:r}}));case 2:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function J(){return(J=_asyncToGenerator(regeneratorRuntime.mark((function e(t){var r,n=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=n.length>1&&void 0!==n[1]?n[1]:{},e.abrupt("return",s({__tauriModule:"Fs",message:{cmd:"removeDir",path:t,options:r}}));case 2:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function K(){return(K=_asyncToGenerator(regeneratorRuntime.mark((function e(t,r){var n,a=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=a.length>2&&void 0!==a[2]?a[2]:{},e.abrupt("return",s({__tauriModule:"Fs",message:{cmd:"copyFile",source:t,destination:r,options:n}}));case 2:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Y(){return(Y=_asyncToGenerator(regeneratorRuntime.mark((function e(t){var r,n=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=n.length>1&&void 0!==n[1]?n[1]:{},e.abrupt("return",s({__tauriModule:"Fs",message:{cmd:"removeFile",path:t,options:r}}));case 2:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function $(){return($=_asyncToGenerator(regeneratorRuntime.mark((function e(t,r){var n,a=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=a.length>2&&void 0!==a[2]?a[2]:{},e.abrupt("return",s({__tauriModule:"Fs",message:{cmd:"renameFile",oldPath:t,newPath:r,options:n}}));case 2:case"end":return e.stop()}}),e)})))).apply(this,arguments)}!function(e){e[e.Audio=1]="Audio";e[e.Cache=2]="Cache";e[e.Config=3]="Config";e[e.Data=4]="Data";e[e.LocalData=5]="LocalData";e[e.Desktop=6]="Desktop";e[e.Document=7]="Document";e[e.Download=8]="Download";e[e.Executable=9]="Executable";e[e.Font=10]="Font";e[e.Home=11]="Home";e[e.Picture=12]="Picture";e[e.Public=13]="Public";e[e.Runtime=14]="Runtime";e[e.Template=15]="Template";e[e.Video=16]="Video";e[e.Resource=17]="Resource";e[e.App=18]="App";e[e.Log=19]="Log";e[e.Temp=20]="Temp"}(F||(F={}));var Q=Object.freeze({__proto__:null,get BaseDirectory(){return F},get Dir(){return F},readTextFile:function(e){return N.apply(this,arguments)},readBinaryFile:function(e){return U.apply(this,arguments)},writeFile:function(e){return H.apply(this,arguments)},writeBinaryFile:function(e){return V.apply(this,arguments)},readDir:function(e){return q.apply(this,arguments)},createDir:function(e){return B.apply(this,arguments)},removeDir:function(e){return J.apply(this,arguments)},copyFile:function(e,t){return K.apply(this,arguments)},removeFile:function(e){return Y.apply(this,arguments)},renameFile:function(e,t){return $.apply(this,arguments)}});function X(){return(X=_asyncToGenerator(regeneratorRuntime.mark((function e(t,r){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"GlobalShortcut",message:{cmd:"register",shortcut:t,handler:a(r)}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Z(){return(Z=_asyncToGenerator(regeneratorRuntime.mark((function e(t,r){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"GlobalShortcut",message:{cmd:"registerAll",shortcuts:t,handler:a(r)}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function ee(){return(ee=_asyncToGenerator(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"GlobalShortcut",message:{cmd:"isRegistered",shortcut:t}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function te(){return(te=_asyncToGenerator(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"GlobalShortcut",message:{cmd:"unregister",shortcut:t}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function re(){return(re=_asyncToGenerator(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"GlobalShortcut",message:{cmd:"unregisterAll"}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var ne,ae=Object.freeze({__proto__:null,register:function(e,t){return X.apply(this,arguments)},registerAll:function(e,t){return Z.apply(this,arguments)},isRegistered:function(e){return ee.apply(this,arguments)},unregister:function(e){return te.apply(this,arguments)},unregisterAll:function(){return re.apply(this,arguments)}});function oe(e,t){return null!=e?e:t()}function ie(e){for(var t=void 0,r=e[0],n=1;n=200&&this.status<300,this.headers=t.headers,this.rawHeaders=t.rawHeaders,this.data=t.data})),ce=function(){function e(t){_classCallCheck(this,e),this.id=t}var t,r,n,a,o,i,u;return _createClass(e,[{key:"drop",value:(u=_asyncToGenerator(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"Http",message:{cmd:"dropClient",client:this.id}}));case 1:case"end":return e.stop()}}),e,this)}))),function(){return u.apply(this,arguments)})},{key:"request",value:(i=_asyncToGenerator(regeneratorRuntime.mark((function e(t){var r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(r=!t.responseType||t.responseType===ne.JSON)&&(t.responseType=ne.Text),e.abrupt("return",s({__tauriModule:"Http",message:{cmd:"httpRequest",client:this.id,options:t}}).then((function(e){var t=new se(e);if(r){try{t.data=JSON.parse(t.data)}catch(e){if(t.ok&&""===t.data)t.data={};else if(t.ok)throw Error("Failed to parse response `".concat(t.data,"` as JSON: ").concat(e,";\n try setting the `responseType` option to `ResponseType.Text` or `ResponseType.Binary` if the API does not return a JSON response."))}return t}return t})));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"get",value:(o=_asyncToGenerator(regeneratorRuntime.mark((function e(t,r){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.request(_objectSpread({method:"GET",url:t},r)));case 1:case"end":return e.stop()}}),e,this)}))),function(e,t){return o.apply(this,arguments)})},{key:"post",value:(a=_asyncToGenerator(regeneratorRuntime.mark((function e(t,r,n){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.request(_objectSpread({method:"POST",url:t,body:r},n)));case 1:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return a.apply(this,arguments)})},{key:"put",value:(n=_asyncToGenerator(regeneratorRuntime.mark((function e(t,r,n){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.request(_objectSpread({method:"PUT",url:t,body:r},n)));case 1:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return n.apply(this,arguments)})},{key:"patch",value:(r=_asyncToGenerator(regeneratorRuntime.mark((function e(t,r){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.request(_objectSpread({method:"PATCH",url:t},r)));case 1:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"delete",value:(t=_asyncToGenerator(regeneratorRuntime.mark((function e(t,r){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.request(_objectSpread({method:"DELETE",url:t},r)));case 1:case"end":return e.stop()}}),e,this)}))),function(e,r){return t.apply(this,arguments)})}]),e}();function pe(e){return le.apply(this,arguments)}function le(){return(le=_asyncToGenerator(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"Http",message:{cmd:"createClient",options:t}}).then((function(e){return new ce(e)})));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var fe=null;function he(){return(he=_asyncToGenerator(regeneratorRuntime.mark((function e(t,r){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null!==fe){e.next=4;break}return e.next=3,pe();case 3:fe=e.sent;case 4:return e.abrupt("return",fe.request(_objectSpread({url:t,method:oe(ie([r,"optionalAccess",function(e){return e.method}]),(function(){return"GET"}))},r)));case 5:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var me=Object.freeze({__proto__:null,getClient:pe,fetch:function(e,t){return he.apply(this,arguments)},Body:ue,Client:ce,Response:se,get ResponseType(){return ne}});function de(){return(de=_asyncToGenerator(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("default"===window.Notification.permission){e.next=2;break}return e.abrupt("return",Promise.resolve("granted"===window.Notification.permission));case 2:return e.abrupt("return",s({__tauriModule:"Notification",message:{cmd:"isNotificationPermissionGranted"}}));case 3:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function ye(){return(ye=_asyncToGenerator(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",window.Notification.requestPermission());case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var ge=Object.freeze({__proto__:null,sendNotification:function(e){"string"==typeof e?new window.Notification(e):new window.Notification(e.title,e)},requestPermission:function(){return ye.apply(this,arguments)},isPermissionGranted:function(){return de.apply(this,arguments)}});function _e(){return navigator.appVersion.includes("Win")}function we(){return(we=_asyncToGenerator(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"Path",message:{cmd:"resolvePath",path:"",directory:F.App}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function ve(){return(ve=_asyncToGenerator(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"Path",message:{cmd:"resolvePath",path:"",directory:F.Audio}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function be(){return(be=_asyncToGenerator(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"Path",message:{cmd:"resolvePath",path:"",directory:F.Cache}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Re(){return(Re=_asyncToGenerator(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"Path",message:{cmd:"resolvePath",path:"",directory:F.Config}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function ke(){return(ke=_asyncToGenerator(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"Path",message:{cmd:"resolvePath",path:"",directory:F.Data}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function xe(){return(xe=_asyncToGenerator(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"Path",message:{cmd:"resolvePath",path:"",directory:F.Desktop}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Te(){return(Te=_asyncToGenerator(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"Path",message:{cmd:"resolvePath",path:"",directory:F.Document}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Ge(){return(Ge=_asyncToGenerator(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"Path",message:{cmd:"resolvePath",path:"",directory:F.Download}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Pe(){return(Pe=_asyncToGenerator(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"Path",message:{cmd:"resolvePath",path:"",directory:F.Executable}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Me(){return(Me=_asyncToGenerator(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"Path",message:{cmd:"resolvePath",path:"",directory:F.Font}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Oe(){return(Oe=_asyncToGenerator(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"Path",message:{cmd:"resolvePath",path:"",directory:F.Home}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Ae(){return(Ae=_asyncToGenerator(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"Path",message:{cmd:"resolvePath",path:"",directory:F.LocalData}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Ce(){return(Ce=_asyncToGenerator(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"Path",message:{cmd:"resolvePath",path:"",directory:F.Picture}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function je(){return(je=_asyncToGenerator(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"Path",message:{cmd:"resolvePath",path:"",directory:F.Public}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Se(){return(Se=_asyncToGenerator(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"Path",message:{cmd:"resolvePath",path:"",directory:F.Resource}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function De(){return(De=_asyncToGenerator(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"Path",message:{cmd:"resolvePath",path:"",directory:F.Runtime}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Le(){return(Le=_asyncToGenerator(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"Path",message:{cmd:"resolvePath",path:"",directory:F.Template}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function ze(){return(ze=_asyncToGenerator(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"Path",message:{cmd:"resolvePath",path:"",directory:F.Video}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Ee(){return(Ee=_asyncToGenerator(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"Path",message:{cmd:"resolvePath",path:"",directory:F.Log}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var We=_e()?"\\":"/",Fe=_e()?";":":";function Ie(){return(Ie=_asyncToGenerator(regeneratorRuntime.mark((function e(){var t,r,n,a=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(t=a.length,r=new Array(t),n=0;n0&&void 0!==r[0]?r[0]:0,e.abrupt("return",s({__tauriModule:"Process",message:{cmd:"exit",exitCode:t}}));case 2:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Ye(){return(Ye=_asyncToGenerator(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"Process",message:{cmd:"relaunch"}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var $e=Object.freeze({__proto__:null,exit:function(){return Ke.apply(this,arguments)},relaunch:function(){return Ye.apply(this,arguments)}});function Qe(e,t){return null!=e?e:t()}function Xe(e,t){return Ze.apply(this,arguments)}function Ze(){return(Ze=_asyncToGenerator(regeneratorRuntime.mark((function e(t,r){var n,o,i=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=i.length>2&&void 0!==i[2]?i[2]:[],o=i.length>3?i[3]:void 0,"object"===_typeof(n)&&Object.freeze(n),e.abrupt("return",s({__tauriModule:"Shell",message:{cmd:"execute",program:r,args:n,options:o,onEventFn:a(t)}}));case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var et=function(){function e(){_classCallCheck(this,e),e.prototype.__init.call(this)}return _createClass(e,[{key:"__init",value:function(){this.eventListeners=Object.create(null)}},{key:"addEventListener",value:function(e,t){e in this.eventListeners?this.eventListeners[e].push(t):this.eventListeners[e]=[t]}},{key:"_emit",value:function(e,t){if(e in this.eventListeners){var r,n=_createForOfIteratorHelper(this.eventListeners[e]);try{for(n.s();!(r=n.n()).done;){(0,r.value)(t)}}catch(e){n.e(e)}finally{n.f()}}}},{key:"on",value:function(e,t){return this.addEventListener(e,t),this}}]),e}(),tt=function(){function e(t){_classCallCheck(this,e),this.pid=t}var t,r;return _createClass(e,[{key:"write",value:(r=_asyncToGenerator(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"Shell",message:{cmd:"stdinWrite",pid:this.pid,buffer:"string"==typeof t?t:Array.from(t)}}));case 1:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"kill",value:(t=_asyncToGenerator(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"Shell",message:{cmd:"killChild",pid:this.pid}}));case 1:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),e}(),rt=function(e){_inherits(a,e);var t,r,n=_createSuper(a);function a(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],o=arguments.length>2?arguments[2]:void 0;return _classCallCheck(this,a),t=n.call(this),a.prototype.__init2.call(_assertThisInitialized(t)),a.prototype.__init3.call(_assertThisInitialized(t)),t.program=e,t.args="string"==typeof r?[r]:r,t.options=Qe(o,(function(){return{}})),t}return _createClass(a,[{key:"__init2",value:function(){this.stdout=new et}},{key:"__init3",value:function(){this.stderr=new et}},{key:"spawn",value:(r=_asyncToGenerator(regeneratorRuntime.mark((function e(){var t=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",Xe((function(e){switch(e.event){case"Error":t._emit("error",e.payload);break;case"Terminated":t._emit("close",e.payload);break;case"Stdout":t.stdout._emit("data",e.payload);break;case"Stderr":t.stderr._emit("data",e.payload)}}),this.program,this.args,this.options).then((function(e){return new tt(e)})));case 1:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"execute",value:(t=_asyncToGenerator(regeneratorRuntime.mark((function e(){var t=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise((function(e,r){t.on("error",r);var n=[],a=[];t.stdout.on("data",(function(e){n.push(e)})),t.stderr.on("data",(function(e){a.push(e)})),t.on("close",(function(t){e({code:t.code,signal:t.signal,stdout:n.join("\n"),stderr:a.join("\n")})})),t.spawn().catch(r)})));case 1:case"end":return e.stop()}}),e)}))),function(){return t.apply(this,arguments)})}],[{key:"sidecar",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],r=arguments.length>2?arguments[2]:void 0,n=new a(e,t,r);return n.options.sidecar=!0,n}}]),a}(et);function nt(){return(nt=_asyncToGenerator(regeneratorRuntime.mark((function e(t,r){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"Shell",message:{cmd:"open",path:t,with:r}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var at=Object.freeze({__proto__:null,Command:rt,Child:tt,EventEmitter:et,open:function(e,t){return nt.apply(this,arguments)}});function ot(e){for(var t=void 0,r=e[0],n=1;n1&&void 0!==arguments[1]?arguments[1]:{};return _classCallCheck(this,r),n=t.call(this,e),ct([a,"optionalAccess",function(e){return e.skip}])||s({__tauriModule:"Window",message:{cmd:"createWebview",data:{options:_objectSpread({label:e},a)}}}).then(_asyncToGenerator(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",n.emit("tauri://created"));case 1:case"end":return e.stop()}}),e)})))).catch(function(){var e=_asyncToGenerator(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",n.emit("tauri://error",t));case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()),n}return _createClass(r,null,[{key:"getByLabel",value:function(e){return dt().some((function(t){return t.label===e}))?new r(e,{skip:!0}):null}}]),r}(wt);function bt(){return(bt=_asyncToGenerator(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"Window",message:{cmd:"manage",data:{cmd:{type:"currentMonitor"}}}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Rt(){return(Rt=_asyncToGenerator(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"Window",message:{cmd:"manage",data:{cmd:{type:"primaryMonitor"}}}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function kt(){return(kt=_asyncToGenerator(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"Window",message:{cmd:"manage",data:{cmd:{type:"availableMonitors"}}}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}"__TAURI_METADATA__"in window?yt=new vt(window.__TAURI_METADATA__.__currentWindow.label,{skip:!0}):(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.'),yt=new vt("main",{skip:!0}));var xt=Object.freeze({__proto__:null,WebviewWindow:vt,WebviewWindowHandle:_t,WindowManager:wt,getCurrent:function(){return new vt(window.__TAURI_METADATA__.__currentWindow.label,{skip:!0})},getAll:dt,get appWindow(){return yt},LogicalSize:lt,PhysicalSize:ft,LogicalPosition:ht,PhysicalPosition:mt,get UserAttentionType(){return pt},currentMonitor:function(){return bt.apply(this,arguments)},primaryMonitor:function(){return Rt.apply(this,arguments)},availableMonitors:function(){return kt.apply(this,arguments)}}),Tt=_e()?"\r\n":"\n";function Gt(){return(Gt=_asyncToGenerator(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"Os",message:{cmd:"platform"}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Pt(){return(Pt=_asyncToGenerator(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"Os",message:{cmd:"version"}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Mt(){return(Mt=_asyncToGenerator(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"Os",message:{cmd:"osType"}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Ot(){return(Ot=_asyncToGenerator(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"Os",message:{cmd:"arch"}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function At(){return(At=_asyncToGenerator(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s({__tauriModule:"Os",message:{cmd:"tempdir"}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var Ct=Object.freeze({__proto__:null,EOL:Tt,platform:function(){return Gt.apply(this,arguments)},version:function(){return Pt.apply(this,arguments)},type:function(){return Mt.apply(this,arguments)},arch:function(){return Ot.apply(this,arguments)},tempdir:function(){return At.apply(this,arguments)}}),jt=o;e.app=h,e.cli=d,e.clipboard=_,e.dialog=x,e.event=I,e.fs=Q,e.globalShortcut=ae,e.http=me,e.invoke=jt,e.notification=ge,e.os=Ct,e.path=Je,e.process=$e,e.shell=at,e.tauri=u,e.updater=st,e.window=xt,Object.defineProperty(e,"__esModule",{value:!0})})); diff --git a/core/tauri/src/endpoints.rs b/core/tauri/src/endpoints.rs index 001c06475..af79c43cc 100644 --- a/core/tauri/src/endpoints.rs +++ b/core/tauri/src/endpoints.rs @@ -17,7 +17,6 @@ mod cli; mod clipboard; mod dialog; mod event; -#[allow(unused_imports)] mod file_system; mod global_shortcut; mod http; diff --git a/core/tauri/src/endpoints/app.rs b/core/tauri/src/endpoints/app.rs index 57bdbc33d..58e6fe4bc 100644 --- a/core/tauri/src/endpoints/app.rs +++ b/core/tauri/src/endpoints/app.rs @@ -5,9 +5,10 @@ use super::InvokeContext; use crate::Runtime; use serde::Deserialize; -use tauri_macros::CommandModule; +use tauri_macros::{command_enum, CommandModule}; /// The API descriptor. +#[command_enum] #[derive(Deserialize, CommandModule)] #[serde(tag = "cmd", rename_all = "camelCase")] #[allow(clippy::enum_variant_names)] diff --git a/core/tauri/src/endpoints/cli.rs b/core/tauri/src/endpoints/cli.rs index ad6217695..ef9f7b44f 100644 --- a/core/tauri/src/endpoints/cli.rs +++ b/core/tauri/src/endpoints/cli.rs @@ -2,13 +2,16 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT +#![allow(unused_imports)] + use super::{InvokeContext, InvokeResponse}; use crate::Runtime; use serde::Deserialize; -use tauri_macros::{module_command_handler, CommandModule}; +use tauri_macros::{command_enum, module_command_handler, CommandModule}; /// The API descriptor. -#[derive(Deserialize, CommandModule)] +#[command_enum] +#[derive(CommandModule, Deserialize)] #[serde(tag = "cmd", rename_all = "camelCase")] pub enum Cmd { /// The get CLI matches API. @@ -16,21 +19,26 @@ pub enum Cmd { } impl Cmd { - #[module_command_handler(cli, "CLI definition not set under tauri.conf.json > tauri > cli (https://tauri.studio/docs/api/config#tauri.cli)")] + #[module_command_handler(cli)] fn cli_matches(context: InvokeContext) -> super::Result { if let Some(cli) = &context.config.tauri.cli { crate::api::cli::get_matches(cli, &context.package_info) .map(Into::into) .map_err(Into::into) } else { - Err(crate::Error::ApiNotAllowlisted("CLI definition not set under tauri.conf.json > tauri > cli (https://tauri.studio/docs/api/config#tauri.cli)".into()).into_anyhow()) + Err(crate::error::into_anyhow("CLI definition not set under tauri.conf.json > tauri > cli (https://tauri.studio/docs/api/config#tauri.cli)")) } } + + #[cfg(not(cli))] + fn cli_matches(_: InvokeContext) -> super::Result { + Err(crate::error::into_anyhow("CLI definition not set under tauri.conf.json > tauri > cli (https://tauri.studio/docs/api/config#tauri.cli)")) + } } #[cfg(test)] mod tests { - #[tauri_macros::module_command_test(cli, "CLI definition not set under tauri.conf.json > tauri > cli (https://tauri.studio/docs/api/config#tauri.cli)")] + #[tauri_macros::module_command_test(cli, "CLI definition not set under tauri.conf.json > tauri > cli (https://tauri.studio/docs/api/config#tauri.cli)", runtime)] #[quickcheck_macros::quickcheck] fn cli_matches() { let res = super::Cmd::cli_matches(crate::test::mock_invoke_context()); diff --git a/core/tauri/src/endpoints/clipboard.rs b/core/tauri/src/endpoints/clipboard.rs index 491703a2c..396061b93 100644 --- a/core/tauri/src/endpoints/clipboard.rs +++ b/core/tauri/src/endpoints/clipboard.rs @@ -2,25 +2,29 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT +#![allow(unused_imports)] + use super::InvokeContext; #[cfg(any(clipboard_write_text, clipboard_read_text))] use crate::runtime::ClipboardManager; use crate::Runtime; use serde::Deserialize; -use tauri_macros::{module_command_handler, CommandModule}; +use tauri_macros::{command_enum, module_command_handler, CommandModule}; /// The API descriptor. +#[command_enum] #[derive(Deserialize, CommandModule)] #[serde(tag = "cmd", content = "data", rename_all = "camelCase")] pub enum Cmd { /// Write a text string to the clipboard. + #[cmd(clipboard_write_text, "clipboard > writeText")] WriteText(String), /// Read clipboard content as text. ReadText, } impl Cmd { - #[module_command_handler(clipboard_write_text, "clipboard > writeText")] + #[module_command_handler(clipboard_write_text)] fn write_text(context: InvokeContext, text: String) -> super::Result<()> { context .window @@ -30,7 +34,7 @@ impl Cmd { .map_err(crate::error::into_anyhow) } - #[module_command_handler(clipboard_read_text, "clipboard > readText")] + #[module_command_handler(clipboard_read_text)] fn read_text(context: InvokeContext) -> super::Result> { context .window @@ -39,6 +43,11 @@ impl Cmd { .read_text() .map_err(crate::error::into_anyhow) } + + #[cfg(not(clipboard_read_text))] + fn read_text(_: InvokeContext) -> super::Result<()> { + Err(crate::Error::ApiNotAllowlisted("clipboard > readText".into()).into_anyhow()) + } } #[cfg(test)] @@ -48,16 +57,20 @@ mod tests { fn write_text(text: String) { let ctx = crate::test::mock_invoke_context(); super::Cmd::write_text(ctx.clone(), text.clone()).unwrap(); + #[cfg(clipboard_read_text)] assert_eq!(super::Cmd::read_text(ctx).unwrap(), Some(text)); } - #[tauri_macros::module_command_test(clipboard_read_text, "clipboard > readText")] + #[tauri_macros::module_command_test(clipboard_read_text, "clipboard > readText", runtime)] #[quickcheck_macros::quickcheck] fn read_text() { let ctx = crate::test::mock_invoke_context(); assert_eq!(super::Cmd::read_text(ctx.clone()).unwrap(), None); - let text = "Tauri!".to_string(); - super::Cmd::write_text(ctx.clone(), text.clone()).unwrap(); - assert_eq!(super::Cmd::read_text(ctx).unwrap(), Some(text)); + #[cfg(clipboard_write_text)] + { + let text = "Tauri!".to_string(); + super::Cmd::write_text(ctx.clone(), text.clone()).unwrap(); + assert_eq!(super::Cmd::read_text(ctx).unwrap(), Some(text)); + } } } diff --git a/core/tauri/src/endpoints/dialog.rs b/core/tauri/src/endpoints/dialog.rs index 29708beb4..51435bf47 100644 --- a/core/tauri/src/endpoints/dialog.rs +++ b/core/tauri/src/endpoints/dialog.rs @@ -2,12 +2,14 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT +#![allow(unused_imports)] + use super::{InvokeContext, InvokeResponse}; use crate::Runtime; #[cfg(any(dialog_open, dialog_save))] use crate::{api::dialog::blocking::FileDialogBuilder, Manager, Scopes}; use serde::Deserialize; -use tauri_macros::{module_command_handler, CommandModule}; +use tauri_macros::{command_enum, module_command_handler, CommandModule}; use std::path::PathBuf; @@ -56,25 +58,25 @@ pub struct SaveDialogOptions { } /// The API descriptor. +#[command_enum] #[derive(Deserialize, CommandModule)] #[serde(tag = "cmd", rename_all = "camelCase")] #[allow(clippy::enum_variant_names)] pub enum Cmd { /// The open dialog API. - OpenDialog { - options: OpenDialogOptions, - }, + #[cmd(dialog_open, "dialog > open")] + OpenDialog { options: OpenDialogOptions }, /// The save dialog API. - SaveDialog { - options: SaveDialogOptions, - }, - MessageDialog { - message: String, - }, + #[cmd(dialog_save, "dialog > save")] + SaveDialog { options: SaveDialogOptions }, + #[cmd(dialog_message, "dialog > message")] + MessageDialog { message: String }, + #[cmd(dialog_ask, "dialog > ask")] AskDialog { title: Option, message: String, }, + #[cmd(dialog_confirm, "dialog > confirm")] ConfirmDialog { title: Option, message: String, @@ -82,7 +84,7 @@ pub enum Cmd { } impl Cmd { - #[module_command_handler(dialog_open, "dialog > open")] + #[module_command_handler(dialog_open)] #[allow(unused_variables)] fn open_dialog( context: InvokeContext, @@ -130,7 +132,7 @@ impl Cmd { Ok(res) } - #[module_command_handler(dialog_save, "dialog > save")] + #[module_command_handler(dialog_save)] #[allow(unused_variables)] fn save_dialog( context: InvokeContext, @@ -159,7 +161,7 @@ impl Cmd { Ok(path) } - #[module_command_handler(dialog_message, "dialog > message")] + #[module_command_handler(dialog_message)] fn message_dialog(context: InvokeContext, message: String) -> super::Result<()> { crate::api::dialog::blocking::message( Some(&context.window), @@ -169,7 +171,7 @@ impl Cmd { Ok(()) } - #[module_command_handler(dialog_ask, "dialog > ask")] + #[module_command_handler(dialog_ask)] fn ask_dialog( context: InvokeContext, title: Option, @@ -182,7 +184,7 @@ impl Cmd { )) } - #[module_command_handler(dialog_confirm, "dialog > confirm")] + #[module_command_handler(dialog_confirm)] fn confirm_dialog( context: InvokeContext, title: Option, diff --git a/core/tauri/src/endpoints/event.rs b/core/tauri/src/endpoints/event.rs index b1adea0ab..8b0522562 100644 --- a/core/tauri/src/endpoints/event.rs +++ b/core/tauri/src/endpoints/event.rs @@ -2,6 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT +#![allow(unused_imports)] + use super::InvokeContext; use crate::{ api::ipc::CallbackFn, @@ -12,7 +14,7 @@ use crate::{ Manager, Runtime, }; use serde::{de::Deserializer, Deserialize}; -use tauri_macros::CommandModule; +use tauri_macros::{command_enum, CommandModule}; pub struct EventId(String); @@ -51,6 +53,7 @@ impl<'de> Deserialize<'de> for WindowLabel { } /// The API descriptor. +#[command_enum] #[derive(Deserialize, CommandModule)] #[serde(tag = "cmd", rename_all = "camelCase")] pub enum Cmd { diff --git a/core/tauri/src/endpoints/file_system.rs b/core/tauri/src/endpoints/file_system.rs index 53d6c2a5c..c54c3cfc9 100644 --- a/core/tauri/src/endpoints/file_system.rs +++ b/core/tauri/src/endpoints/file_system.rs @@ -2,6 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT +#![allow(unused_imports)] + use crate::{ api::{ dir, @@ -19,7 +21,7 @@ use serde::{ de::{Deserializer, Error as DeError}, Deserialize, Serialize, }; -use tauri_macros::{module_command_handler, CommandModule}; +use tauri_macros::{command_enum, module_command_handler, CommandModule}; use std::fmt::{Debug, Formatter}; use std::{ @@ -50,52 +52,62 @@ pub struct FileOperationOptions { } /// The API descriptor. +#[command_enum] #[derive(Deserialize, CommandModule)] #[serde(tag = "cmd", rename_all = "camelCase")] pub(crate) enum Cmd { /// The read binary file API. + #[cmd(fs_read_file, "fs > readFile")] ReadFile { path: SafePathBuf, options: Option, }, /// The read binary file API. + #[cmd(fs_read_file, "fs > readFile")] ReadTextFile { path: SafePathBuf, options: Option, }, /// The write file API. + #[cmd(fs_write_file, "fs > writeFile")] WriteFile { path: SafePathBuf, contents: Vec, options: Option, }, /// The read dir API. + #[cmd(fs_read_dir, "fs > readDir")] ReadDir { path: SafePathBuf, options: Option, }, /// The copy file API. + #[cmd(fs_copy_file, "fs > copyFile")] CopyFile { source: SafePathBuf, destination: SafePathBuf, options: Option, }, /// The create dir API. + #[cmd(fs_create_dir, "fs > createDir")] CreateDir { path: SafePathBuf, options: Option, }, /// The remove dir API. + #[cmd(fs_remove_dir, "fs > removeDir")] RemoveDir { path: SafePathBuf, options: Option, }, /// The remove file API. + #[cmd(fs_remove_file, "fs > removeFile")] RemoveFile { path: SafePathBuf, options: Option, }, /// The rename file API. + #[cmd(fs_rename_file, "fs > renameFile")] #[serde(rename_all = "camelCase")] RenameFile { old_path: SafePathBuf, @@ -105,7 +117,7 @@ pub(crate) enum Cmd { } impl Cmd { - #[module_command_handler(fs_read_file, "fs > readFile")] + #[module_command_handler(fs_read_file)] fn read_file( context: InvokeContext, path: SafePathBuf, @@ -123,7 +135,7 @@ impl Cmd { .map_err(Into::into) } - #[module_command_handler(fs_read_file, "fs > readFile")] + #[module_command_handler(fs_read_file)] fn read_text_file( context: InvokeContext, path: SafePathBuf, @@ -141,7 +153,7 @@ impl Cmd { .map_err(Into::into) } - #[module_command_handler(fs_write_file, "fs > writeFile")] + #[module_command_handler(fs_write_file)] fn write_file( context: InvokeContext, path: SafePathBuf, @@ -161,7 +173,7 @@ impl Cmd { .and_then(|mut f| f.write_all(&contents).map_err(|err| err.into())) } - #[module_command_handler(fs_read_dir, "fs > readDir")] + #[module_command_handler(fs_read_dir)] fn read_dir( context: InvokeContext, path: SafePathBuf, @@ -184,7 +196,7 @@ impl Cmd { .map_err(Into::into) } - #[module_command_handler(fs_copy_file, "fs > copyFile")] + #[module_command_handler(fs_copy_file)] fn copy_file( context: InvokeContext, source: SafePathBuf, @@ -215,7 +227,7 @@ impl Cmd { Ok(()) } - #[module_command_handler(fs_create_dir, "fs > createDir")] + #[module_command_handler(fs_create_dir)] fn create_dir( context: InvokeContext, path: SafePathBuf, @@ -244,7 +256,7 @@ impl Cmd { Ok(()) } - #[module_command_handler(fs_remove_dir, "fs > removeDir")] + #[module_command_handler(fs_remove_dir)] fn remove_dir( context: InvokeContext, path: SafePathBuf, @@ -273,7 +285,7 @@ impl Cmd { Ok(()) } - #[module_command_handler(fs_remove_file, "fs > removeFile")] + #[module_command_handler(fs_remove_file)] fn remove_file( context: InvokeContext, path: SafePathBuf, @@ -291,7 +303,7 @@ impl Cmd { Ok(()) } - #[module_command_handler(fs_rename_file, "fs > renameFile")] + #[module_command_handler(fs_rename_file)] fn rename_file( context: InvokeContext, old_path: SafePathBuf, diff --git a/core/tauri/src/endpoints/global_shortcut.rs b/core/tauri/src/endpoints/global_shortcut.rs index f74a42166..dbde64b71 100644 --- a/core/tauri/src/endpoints/global_shortcut.rs +++ b/core/tauri/src/endpoints/global_shortcut.rs @@ -2,38 +2,45 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT +#![allow(unused_imports)] + use super::InvokeContext; use crate::{api::ipc::CallbackFn, Runtime}; use serde::Deserialize; -use tauri_macros::{module_command_handler, CommandModule}; +use tauri_macros::{command_enum, module_command_handler, CommandModule}; #[cfg(global_shortcut_all)] use crate::runtime::GlobalShortcutManager; /// The API descriptor. +#[command_enum] #[derive(Deserialize, CommandModule)] #[serde(tag = "cmd", rename_all = "camelCase")] pub enum Cmd { /// Register a global shortcut. + #[cmd(global_shortcut_all, "globalShortcut > all")] Register { shortcut: String, handler: CallbackFn, }, /// Register a list of global shortcuts. + #[cmd(global_shortcut_all, "globalShortcut > all")] RegisterAll { shortcuts: Vec, handler: CallbackFn, }, /// Unregister a global shortcut. + #[cmd(global_shortcut_all, "globalShortcut > all")] Unregister { shortcut: String }, /// Unregisters all registered shortcuts. UnregisterAll, /// Determines whether the given hotkey is registered or not. + #[cmd(global_shortcut_all, "globalShortcut > all")] IsRegistered { shortcut: String }, } impl Cmd { - #[module_command_handler(global_shortcut_all, "globalShortcut > all")] + #[module_command_handler(global_shortcut_all)] fn register( context: InvokeContext, shortcut: String, @@ -44,7 +51,7 @@ impl Cmd { Ok(()) } - #[module_command_handler(global_shortcut_all, "globalShortcut > all")] + #[module_command_handler(global_shortcut_all)] fn register_all( context: InvokeContext, shortcuts: Vec, @@ -57,7 +64,7 @@ impl Cmd { Ok(()) } - #[module_command_handler(global_shortcut_all, "globalShortcut > all")] + #[module_command_handler(global_shortcut_all)] fn unregister(context: InvokeContext, shortcut: String) -> super::Result<()> { context .window @@ -68,7 +75,7 @@ impl Cmd { Ok(()) } - #[module_command_handler(global_shortcut_all, "globalShortcut > all")] + #[module_command_handler(global_shortcut_all)] fn unregister_all(context: InvokeContext) -> super::Result<()> { context .window @@ -79,7 +86,12 @@ impl Cmd { Ok(()) } - #[module_command_handler(global_shortcut_all, "globalShortcut > all")] + #[cfg(not(global_shortcut_all))] + fn unregister_all(_: InvokeContext) -> super::Result<()> { + Err(crate::Error::ApiNotAllowlisted("globalShortcut > all".into()).into_anyhow()) + } + + #[module_command_handler(global_shortcut_all)] fn is_registered(context: InvokeContext, shortcut: String) -> super::Result { context .window @@ -139,7 +151,7 @@ mod tests { assert!(!super::Cmd::is_registered(ctx, shortcut).unwrap()); } - #[tauri_macros::module_command_test(global_shortcut_all, "globalShortcut > all")] + #[tauri_macros::module_command_test(global_shortcut_all, "globalShortcut > all", runtime)] #[quickcheck_macros::quickcheck] fn unregister_all() { let shortcuts = vec!["CTRL+X".to_string(), "SUPER+C".to_string(), "D".to_string()]; diff --git a/core/tauri/src/endpoints/http.rs b/core/tauri/src/endpoints/http.rs index 751af8761..05a7d4e44 100644 --- a/core/tauri/src/endpoints/http.rs +++ b/core/tauri/src/endpoints/http.rs @@ -2,10 +2,12 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT +#![allow(unused_imports)] + use super::InvokeContext; use crate::Runtime; use serde::Deserialize; -use tauri_macros::{module_command_handler, CommandModule}; +use tauri_macros::{command_enum, module_command_handler, CommandModule}; #[cfg(http_request)] use std::{ @@ -20,6 +22,7 @@ type ClientBuilder = (); #[cfg(not(http_request))] type HttpRequestBuilder = (); #[cfg(not(http_request))] +#[allow(dead_code)] type ResponseData = (); type ClientId = u32; @@ -34,15 +37,19 @@ fn clients() -> &'static ClientStore { } /// The API descriptor. +#[command_enum] #[derive(Deserialize, CommandModule)] #[cmd(async)] #[serde(tag = "cmd", rename_all = "camelCase")] pub enum Cmd { /// Create a new HTTP client. + #[cmd(http_request, "http > request")] CreateClient { options: Option }, /// Drop a HTTP client. + #[cmd(http_request, "http > request")] DropClient { client: ClientId }, /// The HTTP request API. + #[cmd(http_request, "http > request")] HttpRequest { client: ClientId, options: Box, @@ -50,7 +57,7 @@ pub enum Cmd { } impl Cmd { - #[module_command_handler(http_request, "http > request")] + #[module_command_handler(http_request)] async fn create_client( _context: InvokeContext, options: Option, @@ -62,7 +69,7 @@ impl Cmd { Ok(id) } - #[module_command_handler(http_request, "http > request")] + #[module_command_handler(http_request)] async fn drop_client( _context: InvokeContext, client: ClientId, @@ -72,7 +79,7 @@ impl Cmd { Ok(()) } - #[module_command_handler(http_request, "http > request")] + #[module_command_handler(http_request)] async fn http_request( context: InvokeContext, client_id: ClientId, @@ -115,7 +122,7 @@ impl Cmd { mod tests { use super::{ClientBuilder, ClientId}; - #[tauri_macros::module_command_test(http_request, "http > request", async)] + #[tauri_macros::module_command_test(http_request, "http > request")] #[quickcheck_macros::quickcheck] fn create_client(options: Option) { assert!(crate::async_runtime::block_on(super::Cmd::create_client( @@ -125,7 +132,7 @@ mod tests { .is_ok()); } - #[tauri_macros::module_command_test(http_request, "http > request", async)] + #[tauri_macros::module_command_test(http_request, "http > request")] #[quickcheck_macros::quickcheck] fn drop_client(client_id: ClientId) { crate::async_runtime::block_on(async move { diff --git a/core/tauri/src/endpoints/notification.rs b/core/tauri/src/endpoints/notification.rs index 826fd7e3c..f07bc142c 100644 --- a/core/tauri/src/endpoints/notification.rs +++ b/core/tauri/src/endpoints/notification.rs @@ -2,10 +2,12 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT +#![allow(unused_imports)] + use super::InvokeContext; use crate::Runtime; use serde::Deserialize; -use tauri_macros::{module_command_handler, CommandModule}; +use tauri_macros::{command_enum, module_command_handler, CommandModule}; #[cfg(notification_all)] use crate::{api::notification::Notification, Env, Manager}; @@ -28,10 +30,12 @@ pub struct NotificationOptions { } /// The API descriptor. +#[command_enum] #[derive(Deserialize, CommandModule)] #[serde(tag = "cmd", rename_all = "camelCase")] pub enum Cmd { /// The show notification API. + #[cmd(notification_all, "notification > all")] Notification { options: NotificationOptions }, /// The request notification permission API. RequestNotificationPermission, @@ -40,7 +44,7 @@ pub enum Cmd { } impl Cmd { - #[module_command_handler(notification_all, "notification > all")] + #[module_command_handler(notification_all)] fn notification( context: InvokeContext, options: NotificationOptions, diff --git a/core/tauri/src/endpoints/operating_system.rs b/core/tauri/src/endpoints/operating_system.rs index 010eac78c..984f8c5ab 100644 --- a/core/tauri/src/endpoints/operating_system.rs +++ b/core/tauri/src/endpoints/operating_system.rs @@ -2,13 +2,16 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT +#![allow(unused_imports)] + use super::InvokeContext; use crate::Runtime; use serde::Deserialize; use std::path::PathBuf; -use tauri_macros::{module_command_handler, CommandModule}; +use tauri_macros::{command_enum, module_command_handler, CommandModule}; /// The API descriptor. +#[command_enum] #[derive(Deserialize, CommandModule)] #[serde(tag = "cmd", rename_all = "camelCase")] pub enum Cmd { @@ -19,33 +22,52 @@ pub enum Cmd { Tempdir, } +#[cfg(os_all)] impl Cmd { - #[module_command_handler(os_all, "os > all")] fn platform(_context: InvokeContext) -> super::Result<&'static str> { Ok(os_platform()) } - #[module_command_handler(os_all, "os > all")] fn version(_context: InvokeContext) -> super::Result { Ok(os_info::get().version().to_string()) } - #[module_command_handler(os_all, "os > all")] fn os_type(_context: InvokeContext) -> super::Result<&'static str> { Ok(os_type()) } - #[module_command_handler(os_all, "os > all")] fn arch(_context: InvokeContext) -> super::Result<&'static str> { Ok(std::env::consts::ARCH) } - #[module_command_handler(os_all, "os > all")] fn tempdir(_context: InvokeContext) -> super::Result { Ok(std::env::temp_dir()) } } +#[cfg(not(os_all))] +impl Cmd { + fn platform(_context: InvokeContext) -> super::Result<&'static str> { + Err(crate::Error::ApiNotAllowlisted("os > all".into()).into_anyhow()) + } + + fn version(_context: InvokeContext) -> super::Result { + Err(crate::Error::ApiNotAllowlisted("os > all".into()).into_anyhow()) + } + + fn os_type(_context: InvokeContext) -> super::Result<&'static str> { + Err(crate::Error::ApiNotAllowlisted("os > all".into()).into_anyhow()) + } + + fn arch(_context: InvokeContext) -> super::Result<&'static str> { + Err(crate::Error::ApiNotAllowlisted("os > all".into()).into_anyhow()) + } + + fn tempdir(_context: InvokeContext) -> super::Result { + Err(crate::Error::ApiNotAllowlisted("os > all".into()).into_anyhow()) + } +} + #[cfg(os_all)] fn os_type() -> &'static str { #[cfg(target_os = "linux")] @@ -55,6 +77,7 @@ fn os_type() -> &'static str { #[cfg(target_os = "macos")] return "Darwin"; } + #[cfg(os_all)] fn os_platform() -> &'static str { match std::env::consts::OS { @@ -66,23 +89,23 @@ fn os_platform() -> &'static str { #[cfg(test)] mod tests { - #[tauri_macros::module_command_test(os_all, "os > all")] + #[tauri_macros::module_command_test(os_all, "os > all", runtime)] #[quickcheck_macros::quickcheck] fn platform() {} - #[tauri_macros::module_command_test(os_all, "os > all")] + #[tauri_macros::module_command_test(os_all, "os > all", runtime)] #[quickcheck_macros::quickcheck] fn version() {} - #[tauri_macros::module_command_test(os_all, "os > all")] + #[tauri_macros::module_command_test(os_all, "os > all", runtime)] #[quickcheck_macros::quickcheck] fn os_type() {} - #[tauri_macros::module_command_test(os_all, "os > all")] + #[tauri_macros::module_command_test(os_all, "os > all", runtime)] #[quickcheck_macros::quickcheck] fn arch() {} - #[tauri_macros::module_command_test(os_all, "os > all")] + #[tauri_macros::module_command_test(os_all, "os > all", runtime)] #[quickcheck_macros::quickcheck] fn tempdir() {} } diff --git a/core/tauri/src/endpoints/path.rs b/core/tauri/src/endpoints/path.rs index f66d7c088..6d0c3038a 100644 --- a/core/tauri/src/endpoints/path.rs +++ b/core/tauri/src/endpoints/path.rs @@ -2,6 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT +#![allow(unused_imports)] + use crate::{api::path::BaseDirectory, Runtime}; #[cfg(path_all)] use crate::{Env, Manager}; @@ -11,42 +13,36 @@ use std::path::{Component, Path, MAIN_SEPARATOR}; use super::InvokeContext; use serde::Deserialize; -use tauri_macros::{module_command_handler, CommandModule}; +use tauri_macros::{command_enum, module_command_handler, CommandModule}; /// The API descriptor. +#[command_enum] #[derive(Deserialize, CommandModule)] #[serde(tag = "cmd", rename_all = "camelCase")] pub enum Cmd { + #[cmd(path_all, "path > all")] ResolvePath { path: String, directory: Option, }, - Resolve { - paths: Vec, - }, - Normalize { - path: String, - }, - Join { - paths: Vec, - }, - Dirname { - path: String, - }, - Extname { - path: String, - }, - Basename { - path: String, - ext: Option, - }, - IsAbsolute { - path: String, - }, + #[cmd(path_all, "path > all")] + Resolve { paths: Vec }, + #[cmd(path_all, "path > all")] + Normalize { path: String }, + #[cmd(path_all, "path > all")] + Join { paths: Vec }, + #[cmd(path_all, "path > all")] + Dirname { path: String }, + #[cmd(path_all, "path > all")] + Extname { path: String }, + #[cmd(path_all, "path > all")] + Basename { path: String, ext: Option }, + #[cmd(path_all, "path > all")] + IsAbsolute { path: String }, } impl Cmd { - #[module_command_handler(path_all, "path > all")] + #[module_command_handler(path_all)] fn resolve_path( context: InvokeContext, path: String, @@ -62,7 +58,7 @@ impl Cmd { .map_err(Into::into) } - #[module_command_handler(path_all, "path > all")] + #[module_command_handler(path_all)] fn resolve(_context: InvokeContext, paths: Vec) -> super::Result { // Start with current directory then start adding paths from the vector one by one using `PathBuf.push()` which // will ensure that if an absolute path is encountered in the iteration, it will be used as the current full path. @@ -77,7 +73,7 @@ impl Cmd { Ok(normalize_path(&path)) } - #[module_command_handler(path_all, "path > all")] + #[module_command_handler(path_all)] fn normalize(_context: InvokeContext, path: String) -> super::Result { let mut p = normalize_path_no_absolute(Path::new(&path)) .to_string_lossy() @@ -101,7 +97,7 @@ impl Cmd { ) } - #[module_command_handler(path_all, "path > all")] + #[module_command_handler(path_all)] fn join(_context: InvokeContext, mut paths: Vec) -> super::Result { let path = PathBuf::from( paths @@ -125,7 +121,7 @@ impl Cmd { Ok(if p.is_empty() { ".".into() } else { p }) } - #[module_command_handler(path_all, "path > all")] + #[module_command_handler(path_all)] fn dirname(_context: InvokeContext, path: String) -> super::Result { match Path::new(&path).parent() { Some(p) => Ok(p.to_path_buf()), @@ -135,7 +131,7 @@ impl Cmd { } } - #[module_command_handler(path_all, "path > all")] + #[module_command_handler(path_all)] fn extname(_context: InvokeContext, path: String) -> super::Result { match Path::new(&path) .extension() @@ -148,7 +144,7 @@ impl Cmd { } } - #[module_command_handler(path_all, "path > all")] + #[module_command_handler(path_all)] fn basename( _context: InvokeContext, path: String, @@ -169,7 +165,7 @@ impl Cmd { } } - #[module_command_handler(path_all, "path > all")] + #[module_command_handler(path_all)] fn is_absolute(_context: InvokeContext, path: String) -> super::Result { Ok(Path::new(&path).is_absolute()) } diff --git a/core/tauri/src/endpoints/process.rs b/core/tauri/src/endpoints/process.rs index 8383eca0d..76f5279a6 100644 --- a/core/tauri/src/endpoints/process.rs +++ b/core/tauri/src/endpoints/process.rs @@ -2,32 +2,41 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT +#![allow(unused_imports)] + use super::InvokeContext; #[cfg(process_relaunch)] use crate::Manager; use crate::Runtime; use serde::Deserialize; -use tauri_macros::{module_command_handler, CommandModule}; +use tauri_macros::{command_enum, module_command_handler, CommandModule}; /// The API descriptor. +#[command_enum] #[derive(Deserialize, CommandModule)] #[serde(tag = "cmd", rename_all = "camelCase")] pub enum Cmd { /// Relaunch application Relaunch, /// Close application with provided exit_code + #[cmd(process_exit, "process > exit")] #[serde(rename_all = "camelCase")] Exit { exit_code: i32 }, } impl Cmd { - #[module_command_handler(process_relaunch, "process > relaunch")] + #[module_command_handler(process_relaunch)] fn relaunch(context: InvokeContext) -> super::Result<()> { context.window.app_handle().restart(); Ok(()) } - #[module_command_handler(process_exit, "process > exit")] + #[cfg(not(process_relaunch))] + fn relaunch(_: InvokeContext) -> super::Result<()> { + Err(crate::Error::ApiNotAllowlisted("process > relaunch".into()).into_anyhow()) + } + + #[module_command_handler(process_exit)] fn exit(_context: InvokeContext, exit_code: i32) -> super::Result<()> { // would be great if we can have a handler inside tauri // who close all window and emit an event that user can catch @@ -38,7 +47,7 @@ impl Cmd { #[cfg(test)] mod tests { - #[tauri_macros::module_command_test(process_relaunch, "process > relaunch")] + #[tauri_macros::module_command_test(process_relaunch, "process > relaunch", runtime)] #[quickcheck_macros::quickcheck] fn relaunch() {} diff --git a/core/tauri/src/endpoints/shell.rs b/core/tauri/src/endpoints/shell.rs index 6e208dcb1..abd55644d 100644 --- a/core/tauri/src/endpoints/shell.rs +++ b/core/tauri/src/endpoints/shell.rs @@ -2,12 +2,14 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT +#![allow(unused_imports)] + use super::InvokeContext; use crate::{api::ipc::CallbackFn, Runtime}; #[cfg(shell_scope)] use crate::{Manager, Scopes}; use serde::Deserialize; -use tauri_macros::{module_command_handler, CommandModule}; +use tauri_macros::{command_enum, module_command_handler, CommandModule}; #[cfg(shell_scope)] use crate::ExecuteArgs; @@ -55,10 +57,12 @@ pub struct CommandOptions { } /// The API descriptor. +#[command_enum] #[derive(Deserialize, CommandModule)] #[serde(tag = "cmd", rename_all = "camelCase")] pub enum Cmd { /// The execute script API. + #[cmd(shell_script, "shell > execute or shell > sidecar")] #[serde(rename_all = "camelCase")] Execute { program: String, @@ -67,20 +71,16 @@ pub enum Cmd { #[serde(default)] options: CommandOptions, }, - StdinWrite { - pid: ChildId, - buffer: Buffer, - }, - KillChild { - pid: ChildId, - }, - Open { - path: String, - with: Option, - }, + #[cmd(shell_script, "shell > execute or shell > sidecar")] + StdinWrite { pid: ChildId, buffer: Buffer }, + #[cmd(shell_script, "shell > execute or shell > sidecar")] + KillChild { pid: ChildId }, + #[cmd(shell_open, "shell > open")] + Open { path: String, with: Option }, } impl Cmd { + #[module_command_handler(shell_script)] #[allow(unused_variables)] fn execute( context: InvokeContext, @@ -169,7 +169,7 @@ impl Cmd { } } - #[cfg(any(shell_execute, shell_sidecar))] + #[module_command_handler(shell_script)] fn stdin_write( _context: InvokeContext, pid: ChildId, @@ -184,16 +184,7 @@ impl Cmd { Ok(()) } - #[cfg(not(any(shell_execute, shell_sidecar)))] - fn stdin_write( - _context: InvokeContext, - _pid: ChildId, - _buffer: Buffer, - ) -> super::Result<()> { - Err(crate::Error::ApiNotAllowlisted("shell > execute or shell > sidecar".into()).into_anyhow()) - } - - #[cfg(any(shell_execute, shell_sidecar))] + #[module_command_handler(shell_script)] fn kill_child(_context: InvokeContext, pid: ChildId) -> super::Result<()> { if let Some(child) = command_childs().lock().unwrap().remove(&pid) { child.kill()?; @@ -201,15 +192,10 @@ impl Cmd { Ok(()) } - #[cfg(not(any(shell_execute, shell_sidecar)))] - fn kill_child(_context: InvokeContext, _pid: ChildId) -> super::Result<()> { - Err(crate::Error::ApiNotAllowlisted("shell > execute or shell > sidecar".into()).into_anyhow()) - } - /// Open a (url) path with a default or specific browser opening program. /// /// See [`crate::api::shell::open`] for how it handles security-related measures. - #[module_command_handler(shell_open, "shell > open")] + #[module_command_handler(shell_open)] fn open( context: InvokeContext, path: String, diff --git a/core/tauri/src/endpoints/window.rs b/core/tauri/src/endpoints/window.rs index 662a77e56..85e69d689 100644 --- a/core/tauri/src/endpoints/window.rs +++ b/core/tauri/src/endpoints/window.rs @@ -2,6 +2,8 @@ // 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}; @@ -14,7 +16,7 @@ use crate::{ CursorIcon, Icon, Manager, Runtime, }; use serde::Deserialize; -use tauri_macros::{module_command_handler, CommandModule}; +use tauri_macros::{command_enum, module_command_handler, CommandModule}; #[derive(Deserialize)] #[serde(untagged)] @@ -168,13 +170,13 @@ impl WindowManagerCmd { } /// The API descriptor. +#[command_enum] #[derive(Deserialize, CommandModule)] #[cmd(async)] #[serde(tag = "cmd", content = "data", rename_all = "camelCase")] pub enum Cmd { - CreateWebview { - options: Box, - }, + #[cmd(window_create, "window > create")] + CreateWebview { options: Box }, Manage { label: Option, cmd: WindowManagerCmd, @@ -182,7 +184,7 @@ pub enum Cmd { } impl Cmd { - #[module_command_handler(window_create, "window > create")] + #[module_command_handler(window_create)] async fn create_webview( context: InvokeContext, options: Box, diff --git a/core/tauri/src/error.rs b/core/tauri/src/error.rs index 16d7a3fcf..fb084a918 100644 --- a/core/tauri/src/error.rs +++ b/core/tauri/src/error.rs @@ -71,11 +71,8 @@ pub enum Error { /// Client with specified ID not found. #[error("http client dropped or not initialized")] HttpClientNotInitialized, - /// API not enabled by Tauri. - #[error("{0}")] - ApiNotEnabled(String), /// API not whitelisted on tauri.conf.json - #[error("'{0}' not on the allowlist (https://tauri.studio/docs/api/config#tauri.allowlist)")] + #[error("'{0}' not in the allowlist (https://tauri.studio/docs/api/config#tauri.allowlist)")] ApiNotAllowlisted(String), /// Invalid args when running a command. #[error("invalid args `{1}` for command `{0}`: {2}")] @@ -138,6 +135,7 @@ pub(crate) fn into_anyhow(err: T) -> anyhow::Error { } impl Error { + #[allow(dead_code)] pub(crate) fn into_anyhow(self) -> anyhow::Error { anyhow::anyhow!(self.to_string()) } diff --git a/tooling/api/src/clipboard.ts b/tooling/api/src/clipboard.ts index 84f5c4d25..ac456c5ce 100644 --- a/tooling/api/src/clipboard.ts +++ b/tooling/api/src/clipboard.ts @@ -35,7 +35,10 @@ async function readText(): Promise { return invokeTauriCommand({ __tauriModule: 'Clipboard', message: { - cmd: 'readText' + cmd: 'readText', + // if data is not set, `serde` will ignore the custom deserializer + // that is set when the API is not allowlisted + data: null } }) }