diff --git a/.changes/api-format-callback.md b/.changes/api-format-callback.md new file mode 100644 index 00000000000..a517cff7c26 --- /dev/null +++ b/.changes/api-format-callback.md @@ -0,0 +1,5 @@ +--- +"api": patch +--- + +The `formatCallback` helper function now returns a number instead of a string. diff --git a/.changes/callback-validation.md b/.changes/callback-validation.md new file mode 100644 index 00000000000..4aa93397bf8 --- /dev/null +++ b/.changes/callback-validation.md @@ -0,0 +1,5 @@ +--- +"tauri": patch +--- + +The `callback` and `error` invoke fields, along with other `transformCallback` usages, are now validated to be numeric. diff --git a/.changes/validate-event-name.md b/.changes/validate-event-name.md new file mode 100644 index 00000000000..43badb3fa53 --- /dev/null +++ b/.changes/validate-event-name.md @@ -0,0 +1,6 @@ +--- +"tauri": "patch" +--- + +The event name is now validated. On a IPC message, it returns an error if it fails validation; on the Rust side, it panics. +It must include only alphanumeric characters, `-`, `/`, `:` and `_`. diff --git a/core/tauri-runtime/src/webview.rs b/core/tauri-runtime/src/webview.rs index be95df1a5b8..0aac7e72db5 100644 --- a/core/tauri-runtime/src/webview.rs +++ b/core/tauri-runtime/src/webview.rs @@ -4,12 +4,8 @@ //! Items specific to the [`Runtime`](crate::Runtime)'s webview. -use crate::{window::DetachedWindow, Icon}; +use crate::{menu::Menu, window::DetachedWindow, Icon}; -use crate::menu::Menu; - -use serde::Deserialize; -use serde_json::Value as JsonValue; use tauri_utils::config::{WindowConfig, WindowUrl}; #[cfg(windows)] @@ -184,16 +180,3 @@ pub type WebviewIpcHandler = Box, String) + Send>; /// File drop handler callback /// Return `true` in the callback to block the OS' default behavior of handling a file drop. pub type FileDropHandler = Box) -> bool + Send>; - -#[derive(Debug, Deserialize)] -pub struct InvokePayload { - pub command: String, - #[serde(rename = "__tauriModule")] - pub tauri_module: Option, - pub callback: String, - pub error: String, - #[serde(rename = "__invokeKey")] - pub key: u32, - #[serde(flatten)] - pub inner: JsonValue, -} diff --git a/core/tauri/scripts/bundle.js b/core/tauri/scripts/bundle.js index 61438ed49f8..59b08bbb845 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();return Object.defineProperty(window,a,{value:function(n){return t&&Reflect.deleteProperty(window,a),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_POST_MESSAGE__(t,_objectSpread({__invokeKey:__TAURI_INVOKE_KEY__,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){return navigator.userAgent.includes("Windows")?"https://asset.localhost/".concat(e):"asset://".concat(e)}});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,r){return G.apply(this,arguments)}function G(){return(G=_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 P(e){return M.apply(this,arguments)}function M(){return(M=_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:"Event",message:{cmd:"unlisten",eventId:t}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function O(e,t){return j.apply(this,arguments)}function j(){return(j=_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:"listen",event:t,handler:a(r)}}).then((function(e){return _asyncToGenerator(regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",P(e));case 1:case"end":return t.stop()}}),t)})))})));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function C(e,t){return S.apply(this,arguments)}function S(){return(S=_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,(function(e){r(e),P(e.id).catch((function(){}))})));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function A(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",T(t,null,r));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var z,L=Object.freeze({__proto__:null,listen:O,once:C,emit:A});function E(){return(E=_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 W(){return(W=_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:"readBinaryFile",path:t,options:r}}));case 2:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function F(){return(F=_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:t.contents,options:r}}));case 4: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.Current=19]="Current";e[e.Log=20]="Log"}(z||(z={}));var I=65536;function N(e){var t=function(e){if(e.length1&&void 0!==n[1]?n[1]:{})&&Object.freeze(r),"object"===_typeof(t)&&Object.freeze(t),e.abrupt("return",s({__tauriModule:"Fs",message:{cmd:"writeBinaryFile",path:t.path,contents:N(t.contents),options:r}}));case 4: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:"readDir",path:t,options:r}}));case 2: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 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 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 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 q(){return(q=_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 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:"removeFile",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:"renameFile",oldPath:t,newPath:r,options:n}}));case 2:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var Y=Object.freeze({__proto__:null,get BaseDirectory(){return z},get Dir(){return z},readTextFile:function(e){return E.apply(this,arguments)},readBinaryFile:function(e){return W.apply(this,arguments)},writeFile:function(e){return F.apply(this,arguments)},writeBinaryFile:function(e){return U.apply(this,arguments)},readDir:function(e){return B.apply(this,arguments)},createDir:function(e){return H.apply(this,arguments)},removeDir:function(e){return V.apply(this,arguments)},copyFile:function(e,t){return q.apply(this,arguments)},removeFile:function(e){return J.apply(this,arguments)},renameFile:function(e,t){return K.apply(this,arguments)}});function $(){return($=_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 Q(){return(Q=_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 X(){return(X=_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 Z(){return(Z=_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 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:"GlobalShortcut",message:{cmd:"unregisterAll"}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var te,re=Object.freeze({__proto__:null,register:function(e,t){return $.apply(this,arguments)},registerAll:function(e,t){return Q.apply(this,arguments)},isRegistered:function(e){return X.apply(this,arguments)},unregister:function(e){return Z.apply(this,arguments)},unregisterAll:function(){return ee.apply(this,arguments)}});function ne(e,t){return null!=e?e:t()}function ae(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})),ue=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===te.JSON)&&(t.responseType=te.Text),e.abrupt("return",s({__tauriModule:"Http",message:{cmd:"httpRequest",client:this.id,options:t}}).then((function(e){var t=new ie(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 se(e){return ce.apply(this,arguments)}function ce(){return(ce=_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 ue(e)})));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var pe=null;function le(){return(le=_asyncToGenerator(regeneratorRuntime.mark((function e(t,r){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null!==pe){e.next=4;break}return e.next=3,se();case 3:pe=e.sent;case 4:return e.abrupt("return",pe.request(_objectSpread({url:t,method:ne(ae([r,"optionalAccess",function(e){return e.method}]),(function(){return"GET"}))},r)));case 5:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var fe=Object.freeze({__proto__:null,getClient:se,fetch:function(e,t){return le.apply(this,arguments)},Body:oe,Client:ue,Response:ie,get ResponseType(){return te}});function he(){return(he=_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 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",window.Notification.requestPermission());case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var de=Object.freeze({__proto__:null,sendNotification:function(e){"string"==typeof e?new window.Notification(e):new window.Notification(e.title,e)},requestPermission:function(){return me.apply(this,arguments)},isPermissionGranted:function(){return he.apply(this,arguments)}});function ye(){return navigator.appVersion.includes("Win")}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:z.App}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function _e(){return(_e=_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:z.Audio}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}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:z.Cache}}));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:z.Config}}));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:z.Data}}));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:z.Desktop}}));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:z.Document}}));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:z.Download}}));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:z.Executable}}));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:z.Font}}));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:z.Home}}));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:z.LocalData}}));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:z.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:z.Public}}));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:z.Resource}}));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:z.Runtime}}));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:z.Template}}));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:z.Video}}));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:z.Current}}));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:z.Log}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var Ee=ye()?"\\":"/",We=ye()?";":":";function Fe(){return(Fe=_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 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:"Process",message:{cmd:"relaunch"}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var Ye=Object.freeze({__proto__:null,exit:function(){return Je.apply(this,arguments)},relaunch:function(){return Ke.apply(this,arguments)}});function $e(e,t){return null!=e?e:t()}function Qe(e,t,r,n){return Xe.apply(this,arguments)}function Xe(){return(Xe=_asyncToGenerator(regeneratorRuntime.mark((function e(t,r,n,o){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return"object"===_typeof(n)&&Object.freeze(n),e.abrupt("return",s({__tauriModule:"Shell",message:{cmd:"execute",program:r,args:"string"==typeof n?[n]:n,options:o,onEventFn:a(t)}}));case 2:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var Ze=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}(),et=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: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}(),tt=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=$e(o,(function(){return{}})),t}return _createClass(a,[{key:"__init2",value:function(){this.stdout=new Ze}},{key:"__init3",value:function(){this.stderr=new Ze}},{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",Qe((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 et(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}(Ze);function rt(){return(rt=_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 nt=Object.freeze({__proto__:null,Command:tt,Child:et,open:function(e,t){return rt.apply(this,arguments)}});function at(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),st([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 mt().some((function(t){return t.label===e}))?new r(e,{skip:!0}):null}}]),r}(gt),wt=new _t(null,{skip:!0});function vt(){return(vt=_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 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:"primaryMonitor"}}}}));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:"availableMonitors"}}}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var kt=Object.freeze({__proto__:null,WebviewWindow:_t,WebviewWindowHandle:yt,WindowManager:gt,getCurrent:function(){return new _t(window.__TAURI__.__currentWindow.label,{skip:!0})},getAll:mt,appWindow:wt,LogicalSize:pt,PhysicalSize:lt,LogicalPosition:ft,PhysicalPosition:ht,get UserAttentionType(){return ct},currentMonitor:function(){return vt.apply(this,arguments)},primaryMonitor:function(){return bt.apply(this,arguments)},availableMonitors:function(){return Rt.apply(this,arguments)}}),xt=ye()?"\r\n":"\n";function Tt(){return(Tt=_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 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:"version"}}));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:"osType"}}));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:"arch"}}));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:"tempdir"}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var jt=Object.freeze({__proto__:null,EOL:xt,platform:function(){return Tt.apply(this,arguments)},version:function(){return Gt.apply(this,arguments)},type:function(){return Pt.apply(this,arguments)},arch:function(){return Mt.apply(this,arguments)},tempdir:function(){return Ot.apply(this,arguments)}}),Ct=o;e.app=h,e.cli=d,e.clipboard=_,e.dialog=x,e.event=L,e.fs=Y,e.globalShortcut=re,e.http=fe,e.invoke=Ct,e.notification=de,e.os=jt,e.path=qe,e.process=Ye,e.shell=nt,e.tauri=u,e.updater=ut,e.window=kt,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();return Object.defineProperty(window,a,{value:function(n){return t&&Reflect.deleteProperty(window,a),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_POST_MESSAGE__(t,_objectSpread({__invokeKey:__TAURI_INVOKE_KEY__,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){return navigator.userAgent.includes("Windows")?"https://asset.localhost/".concat(e):"asset://".concat(e)}});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,r){return G.apply(this,arguments)}function G(){return(G=_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 P(e){return M.apply(this,arguments)}function M(){return(M=_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:"Event",message:{cmd:"unlisten",eventId:t}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function O(e,t){return C.apply(this,arguments)}function C(){return(C=_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:"listen",event:t,handler:a(r)}}).then((function(e){return _asyncToGenerator(regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",P(e));case 1:case"end":return t.stop()}}),t)})))})));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function j(e,t){return S.apply(this,arguments)}function S(){return(S=_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,(function(e){r(e),P(e.id).catch((function(){}))})));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function A(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",T(t,null,r));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var z,L=Object.freeze({__proto__:null,listen:O,once:j,emit:A});function E(){return(E=_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 W(){return(W=_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:"readBinaryFile",path:t,options:r}}));case 2:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function F(){return(F=_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:t.contents,options:r}}));case 4: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.Current=19]="Current";e[e.Log=20]="Log"}(z||(z={}));var I=65536;function N(e){var t=function(e){if(e.length1&&void 0!==n[1]?n[1]:{})&&Object.freeze(r),"object"===_typeof(t)&&Object.freeze(t),e.abrupt("return",s({__tauriModule:"Fs",message:{cmd:"writeBinaryFile",path:t.path,contents:N(t.contents),options:r}}));case 4: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:"readDir",path:t,options:r}}));case 2: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 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 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:"removeDir",path:t,options:r}}));case 2:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function V(){return(V=_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 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:"removeFile",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:"renameFile",oldPath:t,newPath:r,options:n}}));case 2:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var Y=Object.freeze({__proto__:null,get BaseDirectory(){return z},get Dir(){return z},readTextFile:function(e){return E.apply(this,arguments)},readBinaryFile:function(e){return W.apply(this,arguments)},writeFile:function(e){return F.apply(this,arguments)},writeBinaryFile:function(e){return U.apply(this,arguments)},readDir:function(e){return B.apply(this,arguments)},createDir:function(e){return H.apply(this,arguments)},removeDir:function(e){return q.apply(this,arguments)},copyFile:function(e,t){return V.apply(this,arguments)},removeFile:function(e){return J.apply(this,arguments)},renameFile:function(e,t){return K.apply(this,arguments)}});function $(){return($=_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 Q(){return(Q=_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 X(){return(X=_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 Z(){return(Z=_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 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:"GlobalShortcut",message:{cmd:"unregisterAll"}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var te,re=Object.freeze({__proto__:null,register:function(e,t){return $.apply(this,arguments)},registerAll:function(e,t){return Q.apply(this,arguments)},isRegistered:function(e){return X.apply(this,arguments)},unregister:function(e){return Z.apply(this,arguments)},unregisterAll:function(){return ee.apply(this,arguments)}});function ne(e,t){return null!=e?e:t()}function ae(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})),ue=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===te.JSON)&&(t.responseType=te.Text),e.abrupt("return",s({__tauriModule:"Http",message:{cmd:"httpRequest",client:this.id,options:t}}).then((function(e){var t=new ie(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 se(e){return ce.apply(this,arguments)}function ce(){return(ce=_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 ue(e)})));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var pe=null;function le(){return(le=_asyncToGenerator(regeneratorRuntime.mark((function e(t,r){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null!==pe){e.next=4;break}return e.next=3,se();case 3:pe=e.sent;case 4:return e.abrupt("return",pe.request(_objectSpread({url:t,method:ne(ae([r,"optionalAccess",function(e){return e.method}]),(function(){return"GET"}))},r)));case 5:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var fe=Object.freeze({__proto__:null,getClient:se,fetch:function(e,t){return le.apply(this,arguments)},Body:oe,Client:ue,Response:ie,get ResponseType(){return te}});function he(){return(he=_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 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",window.Notification.requestPermission());case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var de=Object.freeze({__proto__:null,sendNotification:function(e){"string"==typeof e?new window.Notification(e):new window.Notification(e.title,e)},requestPermission:function(){return me.apply(this,arguments)},isPermissionGranted:function(){return he.apply(this,arguments)}});function ye(){return navigator.appVersion.includes("Win")}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:z.App}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function _e(){return(_e=_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:z.Audio}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}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:z.Cache}}));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:z.Config}}));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:z.Data}}));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:z.Desktop}}));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:z.Document}}));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:z.Download}}));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:z.Executable}}));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:z.Font}}));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:z.Home}}));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:z.LocalData}}));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:z.Picture}}));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:z.Public}}));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:z.Resource}}));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:z.Runtime}}));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:z.Template}}));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:z.Video}}));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:z.Current}}));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:z.Log}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var Ee=ye()?"\\":"/",We=ye()?";":":";function Fe(){return(Fe=_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 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:"Process",message:{cmd:"relaunch"}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var Ye=Object.freeze({__proto__:null,exit:function(){return Je.apply(this,arguments)},relaunch:function(){return Ke.apply(this,arguments)}});function $e(e,t){return null!=e?e:t()}function Qe(e,t,r,n){return Xe.apply(this,arguments)}function Xe(){return(Xe=_asyncToGenerator(regeneratorRuntime.mark((function e(t,r,n,o){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return"object"===_typeof(n)&&Object.freeze(n),e.abrupt("return",s({__tauriModule:"Shell",message:{cmd:"execute",program:r,args:"string"==typeof n?[n]:n,options:o,onEventFn:a(t)}}));case 2:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var Ze=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}(),et=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: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}(),tt=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=$e(o,(function(){return{}})),t}return _createClass(a,[{key:"__init2",value:function(){this.stdout=new Ze}},{key:"__init3",value:function(){this.stderr=new Ze}},{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",Qe((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 et(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}(Ze);function rt(){return(rt=_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 nt=Object.freeze({__proto__:null,Command:tt,Child:et,open:function(e,t){return rt.apply(this,arguments)}});function at(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),st([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 mt().some((function(t){return t.label===e}))?new r(e,{skip:!0}):null}}]),r}(gt),wt=new _t(null,{skip:!0});function vt(){return(vt=_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 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:"primaryMonitor"}}}}));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:"availableMonitors"}}}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var kt=Object.freeze({__proto__:null,WebviewWindow:_t,WebviewWindowHandle:yt,WindowManager:gt,getCurrent:function(){return new _t(window.__TAURI__.__currentWindow.label,{skip:!0})},getAll:mt,appWindow:wt,LogicalSize:pt,PhysicalSize:lt,LogicalPosition:ft,PhysicalPosition:ht,get UserAttentionType(){return ct},currentMonitor:function(){return vt.apply(this,arguments)},primaryMonitor:function(){return bt.apply(this,arguments)},availableMonitors:function(){return Rt.apply(this,arguments)}}),xt=ye()?"\r\n":"\n";function Tt(){return(Tt=_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 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:"version"}}));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:"osType"}}));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:"arch"}}));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:"tempdir"}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var Ct=Object.freeze({__proto__:null,EOL:xt,platform:function(){return Tt.apply(this,arguments)},version:function(){return Gt.apply(this,arguments)},type:function(){return Pt.apply(this,arguments)},arch:function(){return Mt.apply(this,arguments)},tempdir:function(){return Ot.apply(this,arguments)}}),jt=o;e.app=h,e.cli=d,e.clipboard=_,e.dialog=x,e.event=L,e.fs=Y,e.globalShortcut=re,e.http=fe,e.invoke=jt,e.notification=de,e.os=Ct,e.path=Ve,e.process=Ye,e.shell=nt,e.tauri=u,e.updater=ut,e.window=kt,Object.defineProperty(e,"__esModule",{value:!0})})); diff --git a/core/tauri/scripts/core.js b/core/tauri/scripts/core.js index 9533827c3d8..a0c13253f68 100644 --- a/core/tauri/scripts/core.js +++ b/core/tauri/scripts/core.js @@ -4,11 +4,7 @@ ;(function () { function uid() { - const length = new Int8Array(1) - window.crypto.getRandomValues(length) - const array = new Uint8Array(Math.max(16, Math.abs(length[0]))) - window.crypto.getRandomValues(array) - return array.join('') + return window.crypto.getRandomValues(new Uint32Array(1))[0] } if (!window.__TAURI__) { diff --git a/core/tauri/src/api/ipc.rs b/core/tauri/src/api/ipc.rs index 44ad9ed2522..e1c8ce0d678 100644 --- a/core/tauri/src/api/ipc.rs +++ b/core/tauri/src/api/ipc.rs @@ -6,9 +6,13 @@ //! //! This module includes utilities to send messages to the JS layer of the webview. -use serde::Serialize; +use serde::{Deserialize, Serialize}; use serde_json::value::RawValue; +/// The `Callback` type is the return value of the `transformCallback` JavaScript function. +#[derive(Debug, Clone, Copy, Eq, PartialEq, Serialize, Deserialize)] +pub struct CallbackFn(pub usize); + /// The information about this is quite limited. On Chrome/Edge and Firefox, [the maximum string size is approximately 1 GB](https://stackoverflow.com/a/34958490). /// /// [From MDN:](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/length#description) @@ -70,8 +74,8 @@ fn escape_json_parse(json: &RawValue) -> String { /// ``` /// use tauri::api::ipc::format_callback; /// // callback with a string argument -/// let cb = format_callback("callback-function-name", &"the string response").unwrap(); -/// assert!(cb.contains(r#"window["callback-function-name"]("the string response")"#)); +/// let cb = format_callback(12345, &"the string response").unwrap(); +/// assert!(cb.contains(r#"window["12345"]("the string response")"#)); /// ``` /// /// - With types implement [`serde::Serialize`]: @@ -86,14 +90,14 @@ fn escape_json_parse(json: &RawValue) -> String { /// } /// /// let cb = format_callback( -/// "callback-function-name", +/// 6789, /// &MyResponse { value: String::from_utf8(vec![b'X'; 10_240]).unwrap() /// }).expect("failed to serialize"); /// -/// assert!(cb.contains(r#"window["callback-function-name"](JSON.parse('{"value":"XXXXXXXXX"#)); +/// assert!(cb.contains(r#"window["6789"](JSON.parse('{"value":"XXXXXXXXX"#)); /// ``` -pub fn format_callback>( - function_name: S, +pub fn format_callback( + function_name: CallbackFn, arg: &T, ) -> crate::api::Result { macro_rules! format_callback { @@ -106,7 +110,7 @@ pub fn format_callback>( console.warn("[TAURI] Couldn't find callback id {fn} in window. This happens when the app is reloaded while Rust is running an asynchronous operation.") }} "#, - fn = function_name.as_ref(), + fn = function_name.0, arg = $arg ) } @@ -169,8 +173,8 @@ pub fn format_callback>( // TODO: better example to explain pub fn format_callback_result( result: Result, - success_callback: impl AsRef, - error_callback: impl AsRef, + success_callback: CallbackFn, + error_callback: CallbackFn, ) -> crate::api::Result { match result { Ok(res) => format_callback(success_callback, &res), @@ -181,8 +185,15 @@ pub fn format_callback_result( #[cfg(test)] mod test { use crate::api::ipc::*; + use quickcheck::{Arbitrary, Gen}; use quickcheck_macros::quickcheck; + impl Arbitrary for CallbackFn { + fn arbitrary(g: &mut Gen) -> CallbackFn { + CallbackFn(usize::arbitrary(g)) + } + } + #[test] fn test_escape_json_parse() { let dangerous_json = RawValue::from_string( @@ -205,30 +216,25 @@ mod test { // check abritrary strings in the format callback function #[quickcheck] - fn qc_formating(f: String, a: String) -> bool { - // can not accept empty strings - if !f.is_empty() && !a.is_empty() { - // call format callback - let fc = format_callback(f.clone(), &a).unwrap(); - fc.contains(&format!( - r#"window["{}"](JSON.parse('{}'))"#, - f, - serde_json::Value::String(a.clone()), - )) || fc.contains(&format!( - r#"window["{}"]({})"#, - f, - serde_json::Value::String(a), - )) - } else { - true - } + fn qc_formating(f: CallbackFn, a: String) -> bool { + // call format callback + let fc = format_callback(f, &a).unwrap(); + fc.contains(&format!( + r#"window["{}"](JSON.parse('{}'))"#, + f.0, + serde_json::Value::String(a.clone()), + )) || fc.contains(&format!( + r#"window["{}"]({})"#, + f.0, + serde_json::Value::String(a), + )) } // check arbitrary strings in format_callback_result #[quickcheck] - fn qc_format_res(result: Result, c: String, ec: String) -> bool { - let resp = format_callback_result(result.clone(), c.clone(), ec.clone()) - .expect("failed to format callback result"); + fn qc_format_res(result: Result, c: CallbackFn, ec: CallbackFn) -> bool { + let resp = + format_callback_result(result.clone(), c, ec).expect("failed to format callback result"); let (function, value) = match result { Ok(v) => (c, v), Err(e) => (ec, e), @@ -236,7 +242,7 @@ mod test { resp.contains(&format!( r#"window["{}"]({})"#, - function, + function.0, serde_json::Value::String(value), )) } diff --git a/core/tauri/src/app.rs b/core/tauri/src/app.rs index 1d2f57b93cb..e4830c6c8ca 100644 --- a/core/tauri/src/app.rs +++ b/core/tauri/src/app.rs @@ -6,6 +6,7 @@ pub(crate) mod tray; use crate::{ + api::ipc::CallbackFn, command::{CommandArg, CommandItem}, hooks::{ window_invoke_responder, InvokeHandler, InvokeResponder, OnPageLoad, PageLoadPayload, SetupHook, @@ -702,7 +703,7 @@ impl Builder { /// That function must take the `command: string` and `args: object` types and send a message to the backend. pub fn invoke_system(mut self, initialization_script: String, responder: F) -> Self where - F: Fn(Window, InvokeResponse, String, String) + Send + Sync + 'static, + F: Fn(Window, InvokeResponse, CallbackFn, CallbackFn) + Send + Sync + 'static, { self.invoke_initialization_script = initialization_script; self.invoke_responder = Arc::new(responder); diff --git a/core/tauri/src/endpoints/event.rs b/core/tauri/src/endpoints/event.rs index 758d58ff70a..38cdfe967bb 100644 --- a/core/tauri/src/endpoints/event.rs +++ b/core/tauri/src/endpoints/event.rs @@ -3,16 +3,36 @@ // SPDX-License-Identifier: MIT use super::InvokeContext; -use crate::{sealed::ManagerBase, Manager, Runtime, Window}; -use serde::Deserialize; +use crate::{ + api::ipc::CallbackFn, event::is_event_name_valid, sealed::ManagerBase, Manager, Runtime, Window, +}; +use serde::{de::Deserializer, Deserialize}; use tauri_macros::CommandModule; +pub struct EventId(String); + +impl<'de> Deserialize<'de> for EventId { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let event_id = String::deserialize(deserializer)?; + if is_event_name_valid(&event_id) { + Ok(EventId(event_id)) + } else { + Err(serde::de::Error::custom( + "Event name must include only alphanumeric characters, `-`, `/`, `:` and `_`.", + )) + } + } +} + /// The API descriptor. #[derive(Deserialize, CommandModule)] #[serde(tag = "cmd", rename_all = "camelCase")] pub enum Cmd { /// Listen to an event. - Listen { event: String, handler: String }, + Listen { event: EventId, handler: CallbackFn }, /// Unlisten to an event. #[serde(rename_all = "camelCase")] Unlisten { event_id: u64 }, @@ -20,7 +40,7 @@ pub enum Cmd { /// If the window_label is omitted, the event will be triggered on all listeners. #[serde(rename_all = "camelCase")] Emit { - event: String, + event: EventId, window_label: Option, payload: Option, }, @@ -29,14 +49,17 @@ pub enum Cmd { impl Cmd { fn listen( context: InvokeContext, - event: String, - handler: String, + event: EventId, + handler: CallbackFn, ) -> crate::Result { let event_id = rand::random(); - context - .window - .eval(&listen_js(&context.window, event.clone(), event_id, handler))?; - context.window.register_js_listener(event, event_id); + context.window.eval(&listen_js( + &context.window, + event.0.clone(), + event_id, + handler, + ))?; + context.window.register_js_listener(event.0, event_id); Ok(event_id) } @@ -50,17 +73,17 @@ impl Cmd { fn emit( context: InvokeContext, - event: String, + event: EventId, window_label: Option, payload: Option, ) -> crate::Result<()> { // dispatch the event to Rust listeners - context.window.trigger(&event, payload.clone()); + context.window.trigger(&event.0, payload.clone()); if let Some(target) = window_label { - context.window.emit_to(&target, &event, payload)?; + context.window.emit_to(&target, &event.0, payload)?; } else { - context.window.emit_all(&event, payload)?; + context.window.emit_all(&event.0, payload)?; } Ok(()) } @@ -85,7 +108,7 @@ pub fn listen_js( window: &Window, event: String, event_id: u64, - handler: String, + handler: CallbackFn, ) -> String { format!( "if (window['{listeners}'] === void 0) {{ @@ -102,6 +125,6 @@ pub fn listen_js( listeners = window.manager().event_listeners_object_name(), event = event, event_id = event_id, - handler = handler + handler = handler.0 ) } diff --git a/core/tauri/src/endpoints/global_shortcut.rs b/core/tauri/src/endpoints/global_shortcut.rs index e44b11ee343..6593198f814 100644 --- a/core/tauri/src/endpoints/global_shortcut.rs +++ b/core/tauri/src/endpoints/global_shortcut.rs @@ -3,7 +3,7 @@ // SPDX-License-Identifier: MIT use super::InvokeContext; -use crate::Runtime; +use crate::{api::ipc::CallbackFn, Runtime}; use serde::Deserialize; use tauri_macros::{module_command_handler, CommandModule}; @@ -15,11 +15,14 @@ use crate::runtime::GlobalShortcutManager; #[serde(tag = "cmd", rename_all = "camelCase")] pub enum Cmd { /// Register a global shortcut. - Register { shortcut: String, handler: String }, + Register { + shortcut: String, + handler: CallbackFn, + }, /// Register a list of global shortcuts. RegisterAll { shortcuts: Vec, - handler: String, + handler: CallbackFn, }, /// Unregister a global shortcut. Unregister { shortcut: String }, @@ -34,7 +37,7 @@ impl Cmd { fn register( context: InvokeContext, shortcut: String, - handler: String, + handler: CallbackFn, ) -> crate::Result<()> { let mut manager = context.window.app_handle.global_shortcut_manager(); register_shortcut(context.window, &mut manager, shortcut, handler)?; @@ -45,16 +48,11 @@ impl Cmd { fn register_all( context: InvokeContext, shortcuts: Vec, - handler: String, + handler: CallbackFn, ) -> crate::Result<()> { let mut manager = context.window.app_handle.global_shortcut_manager(); for shortcut in shortcuts { - register_shortcut( - context.window.clone(), - &mut manager, - shortcut, - handler.clone(), - )?; + register_shortcut(context.window.clone(), &mut manager, shortcut, handler)?; } Ok(()) } @@ -96,11 +94,11 @@ fn register_shortcut( window: crate::Window, manager: &mut R::GlobalShortcutManager, shortcut: String, - handler: String, + handler: CallbackFn, ) -> crate::Result<()> { let accelerator = shortcut.clone(); manager.register(&shortcut, move || { - let callback_string = crate::api::ipc::format_callback(&handler, &accelerator) + let callback_string = crate::api::ipc::format_callback(handler, &accelerator) .expect("unable to serialize shortcut string to json"); let _ = window.eval(callback_string.as_str()); })?; diff --git a/core/tauri/src/endpoints/shell.rs b/core/tauri/src/endpoints/shell.rs index d5a25bfdb2a..74572251d97 100644 --- a/core/tauri/src/endpoints/shell.rs +++ b/core/tauri/src/endpoints/shell.rs @@ -3,7 +3,7 @@ // SPDX-License-Identifier: MIT use super::InvokeContext; -use crate::Runtime; +use crate::{api::ipc::CallbackFn, Runtime}; use serde::Deserialize; use tauri_macros::{module_command_handler, CommandModule}; @@ -56,7 +56,7 @@ pub enum Cmd { Execute { program: String, args: Vec, - on_event_fn: String, + on_event_fn: CallbackFn, #[serde(default)] options: CommandOptions, }, @@ -79,7 +79,7 @@ impl Cmd { context: InvokeContext, program: String, args: Vec, - on_event_fn: String, + on_event_fn: CallbackFn, options: CommandOptions, ) -> crate::Result { let mut command = if options.sidecar { @@ -118,7 +118,7 @@ impl Cmd { if matches!(event, crate::api::process::CommandEvent::Terminated(_)) { command_childs().lock().unwrap().remove(&pid); } - let js = crate::api::ipc::format_callback(on_event_fn.clone(), &event) + let js = crate::api::ipc::format_callback(on_event_fn, &event) .expect("unable to serialize CommandEvent"); let _ = context.window.eval(js.as_str()); diff --git a/core/tauri/src/event.rs b/core/tauri/src/event.rs index 0b12f9814cd..12bc4d57386 100644 --- a/core/tauri/src/event.rs +++ b/core/tauri/src/event.rs @@ -11,6 +11,13 @@ use std::{ }; use uuid::Uuid; +/// Checks if an event name is valid. +pub fn is_event_name_valid(event: &str) -> bool { + event + .chars() + .all(|c| c.is_alphanumeric() || c == '-' || c == '/' || c == ':' || c == '_') +} + /// Represents an event handler. #[derive(Debug, Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)] pub struct EventHandler(Uuid); diff --git a/core/tauri/src/hooks.rs b/core/tauri/src/hooks.rs index 2841177acca..aaf4d8cec47 100644 --- a/core/tauri/src/hooks.rs +++ b/core/tauri/src/hooks.rs @@ -3,7 +3,7 @@ // SPDX-License-Identifier: MIT use crate::{ - api::ipc::{format_callback, format_callback_result}, + api::ipc::{format_callback, format_callback_result, CallbackFn}, app::App, runtime::Runtime, StateManager, Window, @@ -23,7 +23,7 @@ pub type InvokeHandler = dyn Fn(Invoke) + Send + Sync + 'static; /// A closure that is responsible for respond a JS message. pub type InvokeResponder = - dyn Fn(Window, InvokeResponse, String, String) + Send + Sync + 'static; + dyn Fn(Window, InvokeResponse, CallbackFn, CallbackFn) + Send + Sync + 'static; /// A closure that is run once every time a window is created and loaded. pub type OnPageLoad = dyn Fn(Window, PageLoadPayload) + Send + Sync + 'static; @@ -41,6 +41,26 @@ impl PageLoadPayload { } } +/// The payload used on the IPC invoke. +#[derive(Debug, Deserialize)] +pub struct InvokePayload { + /// The invoke command. + pub command: String, + #[serde(rename = "__tauriModule")] + #[doc(hidden)] + pub tauri_module: Option, + /// The success callback. + pub callback: CallbackFn, + /// The error callback. + pub error: CallbackFn, + /// The invoke key. + #[serde(rename = "__invokeKey")] + pub key: u32, + /// The payload of the message. + #[serde(flatten)] + pub inner: JsonValue, +} + /// The message and resolver given to a custom command. #[default_runtime(crate::Wry, wry)] #[derive(Debug)] @@ -124,12 +144,12 @@ impl From for InvokeResponse { #[derive(Debug)] pub struct InvokeResolver { window: Window, - pub(crate) callback: String, - pub(crate) error: String, + pub(crate) callback: CallbackFn, + pub(crate) error: CallbackFn, } impl InvokeResolver { - pub(crate) fn new(window: Window, callback: String, error: String) -> Self { + pub(crate) fn new(window: Window, callback: CallbackFn, error: CallbackFn) -> Self { Self { window, callback, @@ -144,7 +164,7 @@ impl InvokeResolver { F: Future> + Send + 'static, { crate::async_runtime::spawn(async move { - self.return_task(task).await; + Self::return_task(self.window, task, self.callback, self.error).await; }); } @@ -154,28 +174,33 @@ impl InvokeResolver { F: Future> + Send + 'static, { crate::async_runtime::spawn(async move { - self.return_result(task.await.into()); + Self::return_result(self.window, task.await.into(), self.callback, self.error) }); } /// Reply to the invoke promise with a serializable value. pub fn respond(self, value: Result) { - self.return_result(value.into()) + Self::return_result(self.window, value.into(), self.callback, self.error) } /// Resolve the invoke promise with a value. pub fn resolve(self, value: T) { - self.return_result(Ok(value).into()) + Self::return_result(self.window, Ok(value).into(), self.callback, self.error) } /// Reject the invoke promise with a value. pub fn reject(self, value: T) { - self.return_result(Result::<(), _>::Err(value.into()).into()) + Self::return_result( + self.window, + Result::<(), _>::Err(value.into()).into(), + self.callback, + self.error, + ) } /// Reject the invoke promise with an [`InvokeError`]. pub fn invoke_error(self, error: InvokeError) { - self.return_result(error.into()) + Self::return_result(self.window, error.into(), self.callback, self.error) } /// Asynchronously executes the given task @@ -183,39 +208,50 @@ impl InvokeResolver { /// /// If the Result `is_ok()`, the callback will be the `success_callback` function name and the argument will be the Ok value. /// If the Result `is_err()`, the callback will be the `error_callback` function name and the argument will be the Err value. - pub async fn return_task(self, task: F) - where + pub async fn return_task( + window: Window, + task: F, + success_callback: CallbackFn, + error_callback: CallbackFn, + ) where T: Serialize, F: Future> + Send + 'static, { let result = task.await; - self.return_closure(|| result) + Self::return_closure(window, || result, success_callback, error_callback) } - pub(crate) fn return_closure Result>(self, f: F) { - self.return_result(f().into()) + pub(crate) fn return_closure Result>( + window: Window, + f: F, + success_callback: CallbackFn, + error_callback: CallbackFn, + ) { + Self::return_result(window, f().into(), success_callback, error_callback) } - fn return_result(self, response: InvokeResponse) { - (self.window.invoke_responder())(self.window, response, self.callback, self.error); + pub(crate) fn return_result( + window: Window, + response: InvokeResponse, + success_callback: CallbackFn, + error_callback: CallbackFn, + ) { + (window.invoke_responder())(window, response, success_callback, error_callback); } } pub fn window_invoke_responder( window: Window, response: InvokeResponse, - success_callback: String, - error_callback: String, + success_callback: CallbackFn, + error_callback: CallbackFn, ) { - let callback_string = match format_callback_result( - response.into_result(), - success_callback, - error_callback.clone(), - ) { - Ok(callback_string) => callback_string, - Err(e) => format_callback(error_callback, &e.to_string()) - .expect("unable to serialize shortcut string to json"), - }; + let callback_string = + match format_callback_result(response.into_result(), success_callback, error_callback) { + Ok(callback_string) => callback_string, + Err(e) => format_callback(error_callback, &e.to_string()) + .expect("unable to serialize response string to json"), + }; let _ = window.eval(&callback_string); } diff --git a/core/tauri/src/lib.rs b/core/tauri/src/lib.rs index 2d34897deaa..34aac087e43 100644 --- a/core/tauri/src/lib.rs +++ b/core/tauri/src/lib.rs @@ -94,12 +94,12 @@ pub use { App, AppHandle, AssetResolver, Builder, CloseRequestApi, Event, GlobalWindowEvent, PathResolver, }, self::hooks::{ - Invoke, InvokeError, InvokeHandler, InvokeMessage, InvokeResolver, InvokeResponder, - InvokeResponse, OnPageLoad, PageLoadPayload, SetupHook, + Invoke, InvokeError, InvokeHandler, InvokeMessage, InvokePayload, InvokeResolver, + InvokeResponder, InvokeResponse, OnPageLoad, PageLoadPayload, SetupHook, }, self::manager::Asset, self::runtime::{ - webview::{InvokePayload, WebviewAttributes, WindowBuilder}, + webview::{WebviewAttributes, WindowBuilder}, window::{ dpi::{LogicalPosition, LogicalSize, PhysicalPosition, PhysicalSize, Pixel, Position, Size}, WindowEvent, diff --git a/core/tauri/src/manager.rs b/core/tauri/src/manager.rs index 59779415447..94657b5f96f 100644 --- a/core/tauri/src/manager.rs +++ b/core/tauri/src/manager.rs @@ -4,15 +4,15 @@ use crate::{ app::{AppHandle, GlobalWindowEvent, GlobalWindowEventListener}, - event::{Event, EventHandler, Listeners}, - hooks::{InvokeHandler, InvokeResponder, OnPageLoad, PageLoadPayload}, + event::{is_event_name_valid, Event, EventHandler, Listeners}, + hooks::{InvokeHandler, InvokePayload, InvokeResponder, OnPageLoad, PageLoadPayload}, plugin::PluginStore, runtime::{ http::{ MimeType, Request as HttpRequest, Response as HttpResponse, ResponseBuilder as HttpResponseBuilder, }, - webview::{FileDropEvent, FileDropHandler, InvokePayload, WebviewIpcHandler, WindowBuilder}, + webview::{FileDropEvent, FileDropHandler, WebviewIpcHandler, WindowBuilder}, window::{dpi::PhysicalSize, DetachedWindow, PendingWindow, WindowEvent}, Icon, Runtime, }, @@ -902,6 +902,7 @@ impl WindowManager { S: Serialize + Clone, F: Fn(&Window) -> bool, { + assert!(is_event_name_valid(event)); self .windows_lock() .values() @@ -926,6 +927,7 @@ impl WindowManager { } pub fn trigger(&self, event: &str, window: Option, data: Option) { + assert!(is_event_name_valid(event)); self.inner.listeners.trigger(event, window, data) } @@ -935,14 +937,17 @@ impl WindowManager { window: Option, handler: F, ) -> EventHandler { + assert!(is_event_name_valid(&event)); self.inner.listeners.listen(event, window, handler) } + pub fn once( &self, event: String, window: Option, handler: F, ) -> EventHandler { + assert!(is_event_name_valid(&event)); self.inner.listeners.once(event, window, handler) } diff --git a/core/tauri/src/window.rs b/core/tauri/src/window.rs index 60a8afb3301..8ec4074b727 100644 --- a/core/tauri/src/window.rs +++ b/core/tauri/src/window.rs @@ -12,11 +12,11 @@ use crate::{ app::AppHandle, command::{CommandArg, CommandItem}, event::{Event, EventHandler}, - hooks::InvokeResponder, + hooks::{InvokePayload, InvokeResponder}, manager::WindowManager, runtime::{ monitor::Monitor as RuntimeMonitor, - webview::{InvokePayload, WebviewAttributes, WindowBuilder}, + webview::{WebviewAttributes, WindowBuilder}, window::{ dpi::{PhysicalPosition, PhysicalSize, Position, Size}, DetachedWindow, PendingWindow, WindowEvent, diff --git a/tooling/api/src/event.ts b/tooling/api/src/event.ts index 0aeeb0767f1..89c829700d2 100644 --- a/tooling/api/src/event.ts +++ b/tooling/api/src/event.ts @@ -65,8 +65,8 @@ async function _unlisten(eventId: number): Promise { /** * Listen to an event from the backend. * - * @param event Event name - * @param handler Event handler callback + * @param event Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`. + * @param handler Event handler callback. * @return A promise resolving to a function to unlisten to the event. */ async function listen( @@ -88,8 +88,8 @@ async function listen( /** * Listen to an one-off event from the backend. * - * @param event Event name - * @param handler Event handler callback + * @param event Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`. + * @param handler Event handler callback. * @returns A promise resolving to a function to unlisten to the event. */ async function once( @@ -105,7 +105,7 @@ async function once( /** * Emits an event to the backend. * - * @param event Event name + * @param event Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`. * @param [payload] Event payload * @returns */ diff --git a/tooling/api/src/helpers/event.ts b/tooling/api/src/helpers/event.ts index 3cea4bc5a02..e6dd3b86cc1 100644 --- a/tooling/api/src/helpers/event.ts +++ b/tooling/api/src/helpers/event.ts @@ -8,15 +8,15 @@ import { invokeTauriCommand } from './tauri' /** * Emits an event to the backend. * - * @param event Event name + * @param event Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`. * @param [windowLabel] The label of the window to which the event is sent, if null/undefined the event will be sent to all windows * @param [payload] Event payload * @returns */ async function emit( event: string, - windowLabel: WindowLabel | null, - payload?: unknown + windowLabel?: WindowLabel, + payload?: string ): Promise { await invokeTauriCommand({ __tauriModule: 'Event', diff --git a/tooling/api/src/tauri.ts b/tooling/api/src/tauri.ts index 939d341493d..9063e1b66c6 100644 --- a/tooling/api/src/tauri.ts +++ b/tooling/api/src/tauri.ts @@ -25,12 +25,8 @@ declare global { declare let __TAURI_INVOKE_KEY__: number /** @ignore */ -function uid(): string { - const length = new Int8Array(1) - window.crypto.getRandomValues(length) - const array = new Uint8Array(Math.max(16, Math.abs(length[0]))) - window.crypto.getRandomValues(array) - return array.join('') +function uid(): number { + return window.crypto.getRandomValues(new Uint32Array(1))[0] } /** @@ -42,7 +38,7 @@ function uid(): string { function transformCallback( callback?: (response: any) => void, once = false -): string { +): number { const identifier = uid() Object.defineProperty(window, identifier, { diff --git a/tooling/api/src/window.ts b/tooling/api/src/window.ts index 8d64a159b97..8c75dd3daab 100644 --- a/tooling/api/src/window.ts +++ b/tooling/api/src/window.ts @@ -241,7 +241,7 @@ class WebviewWindowHandle { /** * Listen to an event emitted by the backend that is tied to the webview window. * - * @param event Event name. + * @param event Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`. * @param handler Event handler. * @returns A promise resolving to a function to unlisten to the event. */ @@ -262,7 +262,7 @@ class WebviewWindowHandle { /** * Listen to an one-off event emitted by the backend that is tied to the webview window. * - * @param event Event name. + * @param event Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`. * @param handler Event handler. * @returns A promise resolving to a function to unlisten to the event. */ @@ -280,7 +280,7 @@ class WebviewWindowHandle { /** * Emits an event to the backend, tied to the webview window. * - * @param event Event name. + * @param event Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`. * @param payload Event payload. */ async emit(event: string, payload?: unknown): Promise {