diff --git a/.changes/add-progress-bar.md b/.changes/add-progress-bar.md new file mode 100644 index 000000000000..951b5eafd60d --- /dev/null +++ b/.changes/add-progress-bar.md @@ -0,0 +1,8 @@ +--- +"tauri": 'patch:feat' +"tauri-runtime": 'patch:feat' +"tauri-runtime-wry": 'patch:feat' +"tauri-utils": 'patch:feat' +--- + +Added `set_progress_bar` to `Window`. diff --git a/.changes/set-progress-bar-api.md b/.changes/set-progress-bar-api.md new file mode 100644 index 000000000000..f709d61b96ae --- /dev/null +++ b/.changes/set-progress-bar-api.md @@ -0,0 +1,5 @@ +--- +"@tauri-apps/api": patch:feat +--- + +Added the `setProgressBar` API on the `Window` class. diff --git a/core/tauri-runtime-wry/src/lib.rs b/core/tauri-runtime-wry/src/lib.rs index 367dcb9d01fb..b864ee888c89 100644 --- a/core/tauri-runtime-wry/src/lib.rs +++ b/core/tauri-runtime-wry/src/lib.rs @@ -41,7 +41,9 @@ use wry::webview::WebViewBuilderExtWindows; #[cfg(target_os = "macos")] use tauri_utils::TitleBarStyle; -use tauri_utils::{config::WindowConfig, debug_eprintln, Theme}; +use tauri_utils::{ + config::WindowConfig, debug_eprintln, ProgressBarState, ProgressBarStatus, Theme, +}; use wry::{ application::{ dpi::{ @@ -56,8 +58,9 @@ use wry::{ }, monitor::MonitorHandle, window::{ - CursorIcon as WryCursorIcon, Fullscreen, Icon as WryWindowIcon, Theme as WryTheme, - UserAttentionType as WryUserAttentionType, + CursorIcon as WryCursorIcon, Fullscreen, Icon as WryWindowIcon, + ProgressBarState as WryProgressBarState, ProgressState as WryProgressState, + Theme as WryTheme, UserAttentionType as WryUserAttentionType, }, }, webview::{FileDropEvent as WryFileDropEvent, Url, WebContext, WebView, WebViewBuilder}, @@ -520,6 +523,35 @@ impl From for CursorIconWrapper { } } +pub struct ProgressStateWrapper(pub WryProgressState); + +impl From for ProgressStateWrapper { + fn from(status: ProgressBarStatus) -> Self { + let state = match status { + ProgressBarStatus::None => WryProgressState::None, + ProgressBarStatus::Normal => WryProgressState::Normal, + ProgressBarStatus::Indeterminate => WryProgressState::Indeterminate, + ProgressBarStatus::Paused => WryProgressState::Paused, + ProgressBarStatus::Error => WryProgressState::Error, + }; + Self(state) + } +} + +pub struct ProgressBarStateWrapper(pub WryProgressBarState); + +impl From for ProgressBarStateWrapper { + fn from(progress_state: ProgressBarState) -> Self { + Self(WryProgressBarState { + progress: progress_state.progress, + state: progress_state + .status + .map(|state| ProgressStateWrapper::from(state).0), + unity_uri: progress_state.unity_uri, + }) + } +} + #[derive(Clone, Default)] pub struct WindowBuilderWrapper { inner: WryWindowBuilder, @@ -1006,6 +1038,7 @@ pub enum WindowMessage { SetCursorIcon(CursorIcon), SetCursorPosition(Position), SetIgnoreCursorEvents(bool), + SetProgressBar(ProgressBarState), DragWindow, RequestRedraw, } @@ -1520,6 +1553,16 @@ impl Dispatch for WryDispatcher { ), ) } + + fn set_progress_bar(&self, progress_state: ProgressBarState) -> Result<()> { + send_user_message( + &self.context, + Message::Window( + self.window_id, + WindowMessage::SetProgressBar(progress_state), + ), + ) + } } #[derive(Clone)] @@ -2302,6 +2345,9 @@ fn handle_user_message( WindowMessage::RequestRedraw => { window.request_redraw(); } + WindowMessage::SetProgressBar(progress_state) => { + window.set_progress_bar(ProgressBarStateWrapper::from(progress_state).0); + } } } } diff --git a/core/tauri-runtime/src/lib.rs b/core/tauri-runtime/src/lib.rs index 8f4385df250e..8c7f3645e8bc 100644 --- a/core/tauri-runtime/src/lib.rs +++ b/core/tauri-runtime/src/lib.rs @@ -15,7 +15,7 @@ use raw_window_handle::RawDisplayHandle; use serde::Deserialize; use std::{fmt::Debug, sync::mpsc::Sender}; -use tauri_utils::Theme; +use tauri_utils::{ProgressBarState, Theme}; use url::Url; /// Types useful for interacting with a user's monitors. @@ -589,4 +589,12 @@ pub trait Dispatch: Debug + Clone + Send + Sync + Sized + 'static /// Executes javascript on the window this [`Dispatch`] represents. fn eval_script>(&self, script: S) -> Result<()>; + + /// Sets the taskbar progress state. + /// + /// ## Platform-specific + /// + /// - **Linux / macOS**: Progress bar is app-wide and not specific to this window. Only supported desktop environments with `libunity` (e.g. GNOME). + /// - **iOS / Android:** Unsupported. + fn set_progress_bar(&self, progress_state: ProgressBarState) -> Result<()>; } diff --git a/core/tauri-utils/src/lib.rs b/core/tauri-utils/src/lib.rs index 3821f80003b0..d09c0f15978e 100644 --- a/core/tauri-utils/src/lib.rs +++ b/core/tauri-utils/src/lib.rs @@ -416,3 +416,31 @@ pub fn display_path>(p: P) -> String { .display() .to_string() } + +/// Progress bar status. +#[derive(Debug, Clone, Copy, Deserialize)] +#[serde(rename_all = "camelCase")] +pub enum ProgressBarStatus { + /// Hide progress bar. + None, + /// Normal state. + Normal, + /// Indeterminate state. **Treated as Normal on Linux and macOS** + Indeterminate, + /// Paused state. **Treated as Normal on Linux** + Paused, + /// Error state. **Treated as Normal on Linux** + Error, +} + +/// Progress Bar State +#[derive(Debug, Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct ProgressBarState { + /// The progress bar status. + pub status: Option, + /// The progress bar progress. This can be a value ranging from `0` to `100` + pub progress: Option, + /// The identifier for your app to communicate with the Unity desktop window manager **Linux Only** + pub unity_uri: Option, +} diff --git a/core/tauri/scripts/bundle.global.js b/core/tauri/scripts/bundle.global.js index b7da6cc796c8..410fc0e266d4 100644 --- a/core/tauri/scripts/bundle.global.js +++ b/core/tauri/scripts/bundle.global.js @@ -1,2 +1,2 @@ -"use strict";var __TAURI_IIFE__=(()=>{var D=Object.defineProperty;var Q=Object.getOwnPropertyDescriptor;var Z=Object.getOwnPropertyNames;var J=Object.prototype.hasOwnProperty;var p=(t,e)=>{for(var n in e)D(t,n,{get:e[n],enumerable:!0})},K=(t,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of Z(e))!J.call(t,a)&&a!==n&&D(t,a,{get:()=>e[a],enumerable:!(o=Q(e,a))||o.enumerable});return t};var Y=t=>K(D({},"__esModule",{value:!0}),t);var N=(t,e,n)=>{if(!e.has(t))throw TypeError("Cannot "+n)};var C=(t,e,n)=>(N(t,e,"read from private field"),n?n.call(t):e.get(t)),O=(t,e,n)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,n)},x=(t,e,n,o)=>(N(t,e,"write to private field"),o?o.call(t,n):e.set(t,n),n);var He={};p(He,{app:()=>L,dpi:()=>W,event:()=>S,path:()=>A,primitives:()=>z,window:()=>R});var L={};p(L,{getName:()=>ie,getTauriVersion:()=>ne,getVersion:()=>ee,hide:()=>re,show:()=>te});var z={};p(z,{Channel:()=>y,PluginListener:()=>w,addPluginListener:()=>X,convertFileSrc:()=>B,invoke:()=>i,transformCallback:()=>P});function P(t,e=!1){return window.__TAURI_INTERNALS__.transformCallback(t,e)}var h,y=class{constructor(){this.__TAURI_CHANNEL_MARKER__=!0;O(this,h,()=>{});this.id=P(e=>{C(this,h).call(this,e)})}set onmessage(e){x(this,h,e)}get onmessage(){return C(this,h)}toJSON(){return`__CHANNEL__:${this.id}`}};h=new WeakMap;var w=class{constructor(e,n,o){this.plugin=e,this.event=n,this.channelId=o}async unregister(){return i(`plugin:${this.plugin}|remove_listener`,{event:this.event,channelId:this.channelId})}};async function X(t,e,n){let o=new y;return o.onmessage=n,i(`plugin:${t}|register_listener`,{event:e,handler:o}).then(()=>new w(t,e,o.id))}async function i(t,e={},n){return window.__TAURI_INTERNALS__.invoke(t,e,n)}function B(t,e="asset"){return window.__TAURI_INTERNALS__.convertFileSrc(t,e)}async function ee(){return i("plugin:app|version")}async function ie(){return i("plugin:app|name")}async function ne(){return i("plugin:app|tauri_version")}async function te(){return i("plugin:app|app_show")}async function re(){return i("plugin:app|app_hide")}var S={};p(S,{TauriEvent:()=>I,emit:()=>T,listen:()=>v,once:()=>E});var I=(l=>(l.WINDOW_RESIZED="tauri://resize",l.WINDOW_MOVED="tauri://move",l.WINDOW_CLOSE_REQUESTED="tauri://close-requested",l.WINDOW_CREATED="tauri://window-created",l.WINDOW_DESTROYED="tauri://destroyed",l.WINDOW_FOCUS="tauri://focus",l.WINDOW_BLUR="tauri://blur",l.WINDOW_SCALE_FACTOR_CHANGED="tauri://scale-change",l.WINDOW_THEME_CHANGED="tauri://theme-changed",l.WINDOW_FILE_DROP="tauri://file-drop",l.WINDOW_FILE_DROP_HOVER="tauri://file-drop-hover",l.WINDOW_FILE_DROP_CANCELLED="tauri://file-drop-cancelled",l.MENU="tauri://menu",l))(I||{});async function F(t,e){await i("plugin:event|unlisten",{event:t,eventId:e})}async function v(t,e,n){return i("plugin:event|listen",{event:t,windowLabel:n?.target,handler:P(e)}).then(o=>async()=>F(t,o))}async function E(t,e,n){return v(t,o=>{e(o),F(t,o.id).catch(()=>{})},n)}async function T(t,e,n){await i("plugin:event|emit",{event:t,windowLabel:n?.target,payload:e})}var R={};p(R,{CloseRequestedEvent:()=>f,Effect:()=>V,EffectState:()=>G,LogicalPosition:()=>g,LogicalSize:()=>b,PhysicalPosition:()=>c,PhysicalSize:()=>u,UserAttentionType:()=>U,Window:()=>m,availableMonitors:()=>le,currentMonitor:()=>oe,getAll:()=>_,getCurrent:()=>H,primaryMonitor:()=>se});var W={};p(W,{LogicalPosition:()=>g,LogicalSize:()=>b,PhysicalPosition:()=>c,PhysicalSize:()=>u});var b=class{constructor(e,n){this.type="Logical";this.width=e,this.height=n}},u=class{constructor(e,n){this.type="Physical";this.width=e,this.height=n}toLogical(e){return new b(this.width/e,this.height/e)}},g=class{constructor(e,n){this.type="Logical";this.x=e,this.y=n}},c=class{constructor(e,n){this.type="Physical";this.x=e,this.y=n}toLogical(e){return new g(this.x/e,this.y/e)}};var U=(n=>(n[n.Critical=1]="Critical",n[n.Informational=2]="Informational",n))(U||{}),f=class{constructor(e){this._preventDefault=!1;this.event=e.event,this.windowLabel=e.windowLabel,this.id=e.id}preventDefault(){this._preventDefault=!0}isPreventDefault(){return this._preventDefault}};function H(){return new m(window.__TAURI_INTERNALS__.metadata.currentWindow.label,{skip:!0})}function _(){return window.__TAURI_INTERNALS__.metadata.windows.map(t=>new m(t.label,{skip:!0}))}var M=["tauri://created","tauri://error"],m=class{constructor(e,n={}){this.label=e,this.listeners=Object.create(null),n?.skip||i("plugin:window|create",{options:{...n,label:e}}).then(async()=>this.emit("tauri://created")).catch(async o=>this.emit("tauri://error",o))}static getByLabel(e){return _().some(n=>n.label===e)?new m(e,{skip:!0}):null}static getCurrent(){return H()}static getAll(){return _()}static async getFocusedWindow(){for(let e of _())if(await e.isFocused())return e;return null}async listen(e,n){return this._handleTauriEvent(e,n)?Promise.resolve(()=>{let o=this.listeners[e];o.splice(o.indexOf(n),1)}):v(e,n,{target:this.label})}async once(e,n){return this._handleTauriEvent(e,n)?Promise.resolve(()=>{let o=this.listeners[e];o.splice(o.indexOf(n),1)}):E(e,n,{target:this.label})}async emit(e,n){if(M.includes(e)){for(let o of this.listeners[e]||[])o({event:e,id:-1,windowLabel:this.label,payload:n});return Promise.resolve()}return T(e,n,{target:this.label})}_handleTauriEvent(e,n){return M.includes(e)?(e in this.listeners?this.listeners[e].push(n):this.listeners[e]=[n],!0):!1}async scaleFactor(){return i("plugin:window|scale_factor",{label:this.label})}async innerPosition(){return i("plugin:window|inner_position",{label:this.label}).then(({x:e,y:n})=>new c(e,n))}async outerPosition(){return i("plugin:window|outer_position",{label:this.label}).then(({x:e,y:n})=>new c(e,n))}async innerSize(){return i("plugin:window|inner_size",{label:this.label}).then(({width:e,height:n})=>new u(e,n))}async outerSize(){return i("plugin:window|outer_size",{label:this.label}).then(({width:e,height:n})=>new u(e,n))}async isFullscreen(){return i("plugin:window|is_fullscreen",{label:this.label})}async isMinimized(){return i("plugin:window|is_minimized",{label:this.label})}async isMaximized(){return i("plugin:window|is_maximized",{label:this.label})}async isFocused(){return i("plugin:window|is_focused",{label:this.label})}async isDecorated(){return i("plugin:window|is_decorated",{label:this.label})}async isResizable(){return i("plugin:window|is_resizable",{label:this.label})}async isMaximizable(){return i("plugin:window|is_maximizable",{label:this.label})}async isMinimizable(){return i("plugin:window|is_minimizable",{label:this.label})}async isClosable(){return i("plugin:window|is_closable",{label:this.label})}async isVisible(){return i("plugin:window|is_visible",{label:this.label})}async title(){return i("plugin:window|title",{label:this.label})}async theme(){return i("plugin:window|theme",{label:this.label})}async center(){return i("plugin:window|center",{label:this.label})}async requestUserAttention(e){let n=null;return e&&(e===1?n={type:"Critical"}:n={type:"Informational"}),i("plugin:window|request_user_attention",{label:this.label,value:n})}async setResizable(e){return i("plugin:window|set_resizable",{label:this.label,value:e})}async setMaximizable(e){return i("plugin:window|set_maximizable",{label:this.label,value:e})}async setMinimizable(e){return i("plugin:window|set_minimizable",{label:this.label,value:e})}async setClosable(e){return i("plugin:window|set_closable",{label:this.label,value:e})}async setTitle(e){return i("plugin:window|set_title",{label:this.label,value:e})}async maximize(){return i("plugin:window|maximize",{label:this.label})}async unmaximize(){return i("plugin:window|unmaximize",{label:this.label})}async toggleMaximize(){return i("plugin:window|toggle_maximize",{label:this.label})}async minimize(){return i("plugin:window|minimize",{label:this.label})}async unminimize(){return i("plugin:window|unminimize",{label:this.label})}async show(){return i("plugin:window|show",{label:this.label})}async hide(){return i("plugin:window|hide",{label:this.label})}async close(){return i("plugin:window|close",{label:this.label})}async setDecorations(e){return i("plugin:window|set_decorations",{label:this.label,value:e})}async setShadow(e){return i("plugin:window|set_shadow",{label:this.label,value:e})}async setEffects(e){return i("plugin:window|set_effects",{label:this.label,value:e})}async clearEffects(){return i("plugin:window|set_effects",{label:this.label,value:null})}async setAlwaysOnTop(e){return i("plugin:window|set_always_on_top",{label:this.label,value:e})}async setContentProtected(e){return i("plugin:window|set_content_protected",{label:this.label,value:e})}async setSize(e){if(!e||e.type!=="Logical"&&e.type!=="Physical")throw new Error("the `size` argument must be either a LogicalSize or a PhysicalSize instance");return i("plugin:window|set_size",{label:this.label,value:{type:e.type,data:{width:e.width,height:e.height}}})}async setMinSize(e){if(e&&e.type!=="Logical"&&e.type!=="Physical")throw new Error("the `size` argument must be either a LogicalSize or a PhysicalSize instance");return i("plugin:window|set_min_size",{label:this.label,value:e?{type:e.type,data:{width:e.width,height:e.height}}:null})}async setMaxSize(e){if(e&&e.type!=="Logical"&&e.type!=="Physical")throw new Error("the `size` argument must be either a LogicalSize or a PhysicalSize instance");return i("plugin:window|set_max_size",{label:this.label,value:e?{type:e.type,data:{width:e.width,height:e.height}}:null})}async setPosition(e){if(!e||e.type!=="Logical"&&e.type!=="Physical")throw new Error("the `position` argument must be either a LogicalPosition or a PhysicalPosition instance");return i("plugin:window|set_position",{label:this.label,value:{type:e.type,data:{x:e.x,y:e.y}}})}async setFullscreen(e){return i("plugin:window|set_fullscreen",{label:this.label,value:e})}async setFocus(){return i("plugin:window|set_focus",{label:this.label})}async setIcon(e){return i("plugin:window|set_icon",{label:this.label,value:typeof e=="string"?e:Array.from(e)})}async setSkipTaskbar(e){return i("plugin:window|set_skip_taskbar",{label:this.label,value:e})}async setCursorGrab(e){return i("plugin:window|set_cursor_grab",{label:this.label,value:e})}async setCursorVisible(e){return i("plugin:window|set_cursor_visible",{label:this.label,value:e})}async setCursorIcon(e){return i("plugin:window|set_cursor_icon",{label:this.label,value:e})}async setCursorPosition(e){if(!e||e.type!=="Logical"&&e.type!=="Physical")throw new Error("the `position` argument must be either a LogicalPosition or a PhysicalPosition instance");return i("plugin:window|set_cursor_position",{label:this.label,value:{type:e.type,data:{x:e.x,y:e.y}}})}async setIgnoreCursorEvents(e){return i("plugin:window|set_ignore_cursor_events",{label:this.label,value:e})}async startDragging(){return i("plugin:window|start_dragging",{label:this.label})}async onResized(e){return this.listen("tauri://resize",n=>{n.payload=$(n.payload),e(n)})}async onMoved(e){return this.listen("tauri://move",n=>{n.payload=q(n.payload),e(n)})}async onCloseRequested(e){return this.listen("tauri://close-requested",n=>{let o=new f(n);Promise.resolve(e(o)).then(()=>{if(!o.isPreventDefault())return this.close()})})}async onFocusChanged(e){let n=await this.listen("tauri://focus",a=>{e({...a,payload:!0})}),o=await this.listen("tauri://blur",a=>{e({...a,payload:!1})});return()=>{n(),o()}}async onScaleChanged(e){return this.listen("tauri://scale-change",e)}async onMenuClicked(e){return this.listen("tauri://menu",e)}async onFileDropEvent(e){let n=await this.listen("tauri://file-drop",d=>{e({...d,payload:{type:"drop",paths:d.payload}})}),o=await this.listen("tauri://file-drop-hover",d=>{e({...d,payload:{type:"hover",paths:d.payload}})}),a=await this.listen("tauri://file-drop-cancelled",d=>{e({...d,payload:{type:"cancel"}})});return()=>{n(),o(),a()}}async onThemeChanged(e){return this.listen("tauri://theme-changed",e)}},V=(s=>(s.AppearanceBased="appearanceBased",s.Light="light",s.Dark="dark",s.MediumLight="mediumLight",s.UltraDark="ultraDark",s.Titlebar="titlebar",s.Selection="selection",s.Menu="menu",s.Popover="popover",s.Sidebar="sidebar",s.HeaderView="headerView",s.Sheet="sheet",s.WindowBackground="windowBackground",s.HudWindow="hudWindow",s.FullScreenUI="fullScreenUI",s.Tooltip="tooltip",s.ContentBackground="contentBackground",s.UnderWindowBackground="underWindowBackground",s.UnderPageBackground="underPageBackground",s.Mica="mica",s.Blur="blur",s.Acrylic="acrylic",s.Tabbed="tabbed",s.TabbedDark="tabbedDark",s.TabbedLight="tabbedLight",s))(V||{}),G=(o=>(o.FollowsWindowActiveState="followsWindowActiveState",o.Active="active",o.Inactive="inactive",o))(G||{});function k(t){return t===null?null:{name:t.name,scaleFactor:t.scaleFactor,position:q(t.position),size:$(t.size)}}function q(t){return new c(t.x,t.y)}function $(t){return new u(t.width,t.height)}async function oe(){return i("plugin:window|current_monitor").then(k)}async function se(){return i("plugin:window|primary_monitor").then(k)}async function le(){return i("plugin:window|available_monitors").then(t=>t.map(k))}var A={};p(A,{BaseDirectory:()=>j,appCacheDir:()=>de,appConfigDir:()=>ae,appDataDir:()=>ue,appLocalDataDir:()=>ce,appLogDir:()=>Se,audioDir:()=>pe,basename:()=>Me,cacheDir:()=>me,configDir:()=>he,dataDir:()=>be,delimiter:()=>Re,desktopDir:()=>ge,dirname:()=>xe,documentDir:()=>ye,downloadDir:()=>we,executableDir:()=>Pe,extname:()=>Fe,fontDir:()=>ve,homeDir:()=>_e,isAbsolute:()=>Ue,join:()=>Oe,localDataDir:()=>fe,normalize:()=>Ne,pictureDir:()=>De,publicDir:()=>Ce,resolve:()=>Ae,resolveResource:()=>Le,resourceDir:()=>ze,runtimeDir:()=>Ie,sep:()=>ke,tempDir:()=>We,templateDir:()=>Ee,videoDir:()=>Te});var j=(r=>(r[r.Audio=1]="Audio",r[r.Cache=2]="Cache",r[r.Config=3]="Config",r[r.Data=4]="Data",r[r.LocalData=5]="LocalData",r[r.Document=6]="Document",r[r.Download=7]="Download",r[r.Picture=8]="Picture",r[r.Public=9]="Public",r[r.Video=10]="Video",r[r.Resource=11]="Resource",r[r.Temp=12]="Temp",r[r.AppConfig=13]="AppConfig",r[r.AppData=14]="AppData",r[r.AppLocalData=15]="AppLocalData",r[r.AppCache=16]="AppCache",r[r.AppLog=17]="AppLog",r[r.Desktop=18]="Desktop",r[r.Executable=19]="Executable",r[r.Font=20]="Font",r[r.Home=21]="Home",r[r.Runtime=22]="Runtime",r[r.Template=23]="Template",r))(j||{});async function ae(){return i("plugin:path|resolve_directory",{directory:13})}async function ue(){return i("plugin:path|resolve_directory",{directory:14})}async function ce(){return i("plugin:path|resolve_directory",{directory:15})}async function de(){return i("plugin:path|resolve_directory",{directory:16})}async function pe(){return i("plugin:path|resolve_directory",{directory:1})}async function me(){return i("plugin:path|resolve_directory",{directory:2})}async function he(){return i("plugin:path|resolve_directory",{directory:3})}async function be(){return i("plugin:path|resolve_directory",{directory:4})}async function ge(){return i("plugin:path|resolve_directory",{directory:18})}async function ye(){return i("plugin:path|resolve_directory",{directory:6})}async function we(){return i("plugin:path|resolve_directory",{directory:7})}async function Pe(){return i("plugin:path|resolve_directory",{directory:19})}async function ve(){return i("plugin:path|resolve_directory",{directory:20})}async function _e(){return i("plugin:path|resolve_directory",{directory:21})}async function fe(){return i("plugin:path|resolve_directory",{directory:5})}async function De(){return i("plugin:path|resolve_directory",{directory:8})}async function Ce(){return i("plugin:path|resolve_directory",{directory:9})}async function ze(){return i("plugin:path|resolve_directory",{directory:11})}async function Le(t){return i("plugin:path|resolve_directory",{directory:11,path:t})}async function Ie(){return i("plugin:path|resolve_directory",{directory:22})}async function Ee(){return i("plugin:path|resolve_directory",{directory:23})}async function Te(){return i("plugin:path|resolve_directory",{directory:10})}async function Se(){return i("plugin:path|resolve_directory",{directory:17})}async function We(t){return i("plugin:path|resolve_directory",{directory:12})}function ke(){return window.__TAURI_INTERNALS__.plugins.path.sep}function Re(){return window.__TAURI_INTERNALS__.plugins.path.delimiter}async function Ae(...t){return i("plugin:path|resolve",{paths:t})}async function Ne(t){return i("plugin:path|normalize",{path:t})}async function Oe(...t){return i("plugin:path|join",{paths:t})}async function xe(t){return i("plugin:path|dirname",{path:t})}async function Fe(t){return i("plugin:path|extname",{path:t})}async function Me(t,e){return i("plugin:path|basename",{path:t,ext:e})}async function Ue(t){return i("plugin:path|isAbsolute",{path:t})}return Y(He);})(); +"use strict";var __TAURI_IIFE__=(()=>{var D=Object.defineProperty;var Z=Object.getOwnPropertyDescriptor;var J=Object.getOwnPropertyNames;var K=Object.prototype.hasOwnProperty;var p=(t,e)=>{for(var n in e)D(t,n,{get:e[n],enumerable:!0})},Y=(t,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let u of J(e))!K.call(t,u)&&u!==n&&D(t,u,{get:()=>e[u],enumerable:!(o=Z(e,u))||o.enumerable});return t};var X=t=>Y(D({},"__esModule",{value:!0}),t);var N=(t,e,n)=>{if(!e.has(t))throw TypeError("Cannot "+n)};var C=(t,e,n)=>(N(t,e,"read from private field"),n?n.call(t):e.get(t)),O=(t,e,n)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,n)},x=(t,e,n,o)=>(N(t,e,"write to private field"),o?o.call(t,n):e.set(t,n),n);var Ve={};p(Ve,{app:()=>L,dpi:()=>k,event:()=>W,path:()=>A,primitives:()=>z,window:()=>S});var L={};p(L,{getName:()=>ne,getTauriVersion:()=>te,getVersion:()=>ie,hide:()=>oe,show:()=>re});var z={};p(z,{Channel:()=>y,PluginListener:()=>w,addPluginListener:()=>B,convertFileSrc:()=>ee,invoke:()=>i,transformCallback:()=>P});function P(t,e=!1){return window.__TAURI_INTERNALS__.transformCallback(t,e)}var h,y=class{constructor(){this.__TAURI_CHANNEL_MARKER__=!0;O(this,h,()=>{});this.id=P(e=>{C(this,h).call(this,e)})}set onmessage(e){x(this,h,e)}get onmessage(){return C(this,h)}toJSON(){return`__CHANNEL__:${this.id}`}};h=new WeakMap;var w=class{constructor(e,n,o){this.plugin=e,this.event=n,this.channelId=o}async unregister(){return i(`plugin:${this.plugin}|remove_listener`,{event:this.event,channelId:this.channelId})}};async function B(t,e,n){let o=new y;return o.onmessage=n,i(`plugin:${t}|register_listener`,{event:e,handler:o}).then(()=>new w(t,e,o.id))}async function i(t,e={},n){return window.__TAURI_INTERNALS__.invoke(t,e,n)}function ee(t,e="asset"){return window.__TAURI_INTERNALS__.convertFileSrc(t,e)}async function ie(){return i("plugin:app|version")}async function ne(){return i("plugin:app|name")}async function te(){return i("plugin:app|tauri_version")}async function re(){return i("plugin:app|app_show")}async function oe(){return i("plugin:app|app_hide")}var W={};p(W,{TauriEvent:()=>I,emit:()=>T,listen:()=>v,once:()=>E});var I=(a=>(a.WINDOW_RESIZED="tauri://resize",a.WINDOW_MOVED="tauri://move",a.WINDOW_CLOSE_REQUESTED="tauri://close-requested",a.WINDOW_CREATED="tauri://window-created",a.WINDOW_DESTROYED="tauri://destroyed",a.WINDOW_FOCUS="tauri://focus",a.WINDOW_BLUR="tauri://blur",a.WINDOW_SCALE_FACTOR_CHANGED="tauri://scale-change",a.WINDOW_THEME_CHANGED="tauri://theme-changed",a.WINDOW_FILE_DROP="tauri://file-drop",a.WINDOW_FILE_DROP_HOVER="tauri://file-drop-hover",a.WINDOW_FILE_DROP_CANCELLED="tauri://file-drop-cancelled",a.MENU="tauri://menu",a))(I||{});async function F(t,e){await i("plugin:event|unlisten",{event:t,eventId:e})}async function v(t,e,n){return i("plugin:event|listen",{event:t,windowLabel:n?.target,handler:P(e)}).then(o=>async()=>F(t,o))}async function E(t,e,n){return v(t,o=>{e(o),F(t,o.id).catch(()=>{})},n)}async function T(t,e,n){await i("plugin:event|emit",{event:t,windowLabel:n?.target,payload:e})}var S={};p(S,{CloseRequestedEvent:()=>f,Effect:()=>G,EffectState:()=>q,LogicalPosition:()=>g,LogicalSize:()=>b,PhysicalPosition:()=>d,PhysicalSize:()=>c,ProgressBarStatus:()=>H,UserAttentionType:()=>M,Window:()=>m,availableMonitors:()=>ae,currentMonitor:()=>se,getAll:()=>_,getCurrent:()=>V,primaryMonitor:()=>le});var k={};p(k,{LogicalPosition:()=>g,LogicalSize:()=>b,PhysicalPosition:()=>d,PhysicalSize:()=>c});var b=class{constructor(e,n){this.type="Logical";this.width=e,this.height=n}},c=class{constructor(e,n){this.type="Physical";this.width=e,this.height=n}toLogical(e){return new b(this.width/e,this.height/e)}},g=class{constructor(e,n){this.type="Logical";this.x=e,this.y=n}},d=class{constructor(e,n){this.type="Physical";this.x=e,this.y=n}toLogical(e){return new g(this.x/e,this.y/e)}};var M=(n=>(n[n.Critical=1]="Critical",n[n.Informational=2]="Informational",n))(M||{}),f=class{constructor(e){this._preventDefault=!1;this.event=e.event,this.windowLabel=e.windowLabel,this.id=e.id}preventDefault(){this._preventDefault=!0}isPreventDefault(){return this._preventDefault}},H=(l=>(l.None="none",l.Normal="normal",l.Indeterminate="indeterminate",l.Paused="paused",l.Error="error",l))(H||{});function V(){return new m(window.__TAURI_INTERNALS__.metadata.currentWindow.label,{skip:!0})}function _(){return window.__TAURI_INTERNALS__.metadata.windows.map(t=>new m(t.label,{skip:!0}))}var U=["tauri://created","tauri://error"],m=class{constructor(e,n={}){this.label=e,this.listeners=Object.create(null),n?.skip||i("plugin:window|create",{options:{...n,label:e}}).then(async()=>this.emit("tauri://created")).catch(async o=>this.emit("tauri://error",o))}static getByLabel(e){return _().some(n=>n.label===e)?new m(e,{skip:!0}):null}static getCurrent(){return V()}static getAll(){return _()}static async getFocusedWindow(){for(let e of _())if(await e.isFocused())return e;return null}async listen(e,n){return this._handleTauriEvent(e,n)?Promise.resolve(()=>{let o=this.listeners[e];o.splice(o.indexOf(n),1)}):v(e,n,{target:this.label})}async once(e,n){return this._handleTauriEvent(e,n)?Promise.resolve(()=>{let o=this.listeners[e];o.splice(o.indexOf(n),1)}):E(e,n,{target:this.label})}async emit(e,n){if(U.includes(e)){for(let o of this.listeners[e]||[])o({event:e,id:-1,windowLabel:this.label,payload:n});return Promise.resolve()}return T(e,n,{target:this.label})}_handleTauriEvent(e,n){return U.includes(e)?(e in this.listeners?this.listeners[e].push(n):this.listeners[e]=[n],!0):!1}async scaleFactor(){return i("plugin:window|scale_factor",{label:this.label})}async innerPosition(){return i("plugin:window|inner_position",{label:this.label}).then(({x:e,y:n})=>new d(e,n))}async outerPosition(){return i("plugin:window|outer_position",{label:this.label}).then(({x:e,y:n})=>new d(e,n))}async innerSize(){return i("plugin:window|inner_size",{label:this.label}).then(({width:e,height:n})=>new c(e,n))}async outerSize(){return i("plugin:window|outer_size",{label:this.label}).then(({width:e,height:n})=>new c(e,n))}async isFullscreen(){return i("plugin:window|is_fullscreen",{label:this.label})}async isMinimized(){return i("plugin:window|is_minimized",{label:this.label})}async isMaximized(){return i("plugin:window|is_maximized",{label:this.label})}async isFocused(){return i("plugin:window|is_focused",{label:this.label})}async isDecorated(){return i("plugin:window|is_decorated",{label:this.label})}async isResizable(){return i("plugin:window|is_resizable",{label:this.label})}async isMaximizable(){return i("plugin:window|is_maximizable",{label:this.label})}async isMinimizable(){return i("plugin:window|is_minimizable",{label:this.label})}async isClosable(){return i("plugin:window|is_closable",{label:this.label})}async isVisible(){return i("plugin:window|is_visible",{label:this.label})}async title(){return i("plugin:window|title",{label:this.label})}async theme(){return i("plugin:window|theme",{label:this.label})}async center(){return i("plugin:window|center",{label:this.label})}async requestUserAttention(e){let n=null;return e&&(e===1?n={type:"Critical"}:n={type:"Informational"}),i("plugin:window|request_user_attention",{label:this.label,value:n})}async setResizable(e){return i("plugin:window|set_resizable",{label:this.label,value:e})}async setMaximizable(e){return i("plugin:window|set_maximizable",{label:this.label,value:e})}async setMinimizable(e){return i("plugin:window|set_minimizable",{label:this.label,value:e})}async setClosable(e){return i("plugin:window|set_closable",{label:this.label,value:e})}async setTitle(e){return i("plugin:window|set_title",{label:this.label,value:e})}async maximize(){return i("plugin:window|maximize",{label:this.label})}async unmaximize(){return i("plugin:window|unmaximize",{label:this.label})}async toggleMaximize(){return i("plugin:window|toggle_maximize",{label:this.label})}async minimize(){return i("plugin:window|minimize",{label:this.label})}async unminimize(){return i("plugin:window|unminimize",{label:this.label})}async show(){return i("plugin:window|show",{label:this.label})}async hide(){return i("plugin:window|hide",{label:this.label})}async close(){return i("plugin:window|close",{label:this.label})}async setDecorations(e){return i("plugin:window|set_decorations",{label:this.label,value:e})}async setShadow(e){return i("plugin:window|set_shadow",{label:this.label,value:e})}async setEffects(e){return i("plugin:window|set_effects",{label:this.label,value:e})}async clearEffects(){return i("plugin:window|set_effects",{label:this.label,value:null})}async setAlwaysOnTop(e){return i("plugin:window|set_always_on_top",{label:this.label,value:e})}async setContentProtected(e){return i("plugin:window|set_content_protected",{label:this.label,value:e})}async setSize(e){if(!e||e.type!=="Logical"&&e.type!=="Physical")throw new Error("the `size` argument must be either a LogicalSize or a PhysicalSize instance");return i("plugin:window|set_size",{label:this.label,value:{type:e.type,data:{width:e.width,height:e.height}}})}async setMinSize(e){if(e&&e.type!=="Logical"&&e.type!=="Physical")throw new Error("the `size` argument must be either a LogicalSize or a PhysicalSize instance");return i("plugin:window|set_min_size",{label:this.label,value:e?{type:e.type,data:{width:e.width,height:e.height}}:null})}async setMaxSize(e){if(e&&e.type!=="Logical"&&e.type!=="Physical")throw new Error("the `size` argument must be either a LogicalSize or a PhysicalSize instance");return i("plugin:window|set_max_size",{label:this.label,value:e?{type:e.type,data:{width:e.width,height:e.height}}:null})}async setPosition(e){if(!e||e.type!=="Logical"&&e.type!=="Physical")throw new Error("the `position` argument must be either a LogicalPosition or a PhysicalPosition instance");return i("plugin:window|set_position",{label:this.label,value:{type:e.type,data:{x:e.x,y:e.y}}})}async setFullscreen(e){return i("plugin:window|set_fullscreen",{label:this.label,value:e})}async setFocus(){return i("plugin:window|set_focus",{label:this.label})}async setIcon(e){return i("plugin:window|set_icon",{label:this.label,value:typeof e=="string"?e:Array.from(e)})}async setSkipTaskbar(e){return i("plugin:window|set_skip_taskbar",{label:this.label,value:e})}async setCursorGrab(e){return i("plugin:window|set_cursor_grab",{label:this.label,value:e})}async setCursorVisible(e){return i("plugin:window|set_cursor_visible",{label:this.label,value:e})}async setCursorIcon(e){return i("plugin:window|set_cursor_icon",{label:this.label,value:e})}async setCursorPosition(e){if(!e||e.type!=="Logical"&&e.type!=="Physical")throw new Error("the `position` argument must be either a LogicalPosition or a PhysicalPosition instance");return i("plugin:window|set_cursor_position",{label:this.label,value:{type:e.type,data:{x:e.x,y:e.y}}})}async setIgnoreCursorEvents(e){return i("plugin:window|set_ignore_cursor_events",{label:this.label,value:e})}async startDragging(){return i("plugin:window|start_dragging",{label:this.label})}async setProgressBar(e){return i("plugin:window|set_progress_bar",{label:this.label,value:e})}async onResized(e){return this.listen("tauri://resize",n=>{n.payload=j(n.payload),e(n)})}async onMoved(e){return this.listen("tauri://move",n=>{n.payload=$(n.payload),e(n)})}async onCloseRequested(e){return this.listen("tauri://close-requested",n=>{let o=new f(n);Promise.resolve(e(o)).then(()=>{if(!o.isPreventDefault())return this.close()})})}async onFocusChanged(e){let n=await this.listen("tauri://focus",u=>{e({...u,payload:!0})}),o=await this.listen("tauri://blur",u=>{e({...u,payload:!1})});return()=>{n(),o()}}async onScaleChanged(e){return this.listen("tauri://scale-change",e)}async onMenuClicked(e){return this.listen("tauri://menu",e)}async onFileDropEvent(e){let n=await this.listen("tauri://file-drop",l=>{e({...l,payload:{type:"drop",paths:l.payload}})}),o=await this.listen("tauri://file-drop-hover",l=>{e({...l,payload:{type:"hover",paths:l.payload}})}),u=await this.listen("tauri://file-drop-cancelled",l=>{e({...l,payload:{type:"cancel"}})});return()=>{n(),o(),u()}}async onThemeChanged(e){return this.listen("tauri://theme-changed",e)}},G=(s=>(s.AppearanceBased="appearanceBased",s.Light="light",s.Dark="dark",s.MediumLight="mediumLight",s.UltraDark="ultraDark",s.Titlebar="titlebar",s.Selection="selection",s.Menu="menu",s.Popover="popover",s.Sidebar="sidebar",s.HeaderView="headerView",s.Sheet="sheet",s.WindowBackground="windowBackground",s.HudWindow="hudWindow",s.FullScreenUI="fullScreenUI",s.Tooltip="tooltip",s.ContentBackground="contentBackground",s.UnderWindowBackground="underWindowBackground",s.UnderPageBackground="underPageBackground",s.Mica="mica",s.Blur="blur",s.Acrylic="acrylic",s.Tabbed="tabbed",s.TabbedDark="tabbedDark",s.TabbedLight="tabbedLight",s))(G||{}),q=(o=>(o.FollowsWindowActiveState="followsWindowActiveState",o.Active="active",o.Inactive="inactive",o))(q||{});function R(t){return t===null?null:{name:t.name,scaleFactor:t.scaleFactor,position:$(t.position),size:j(t.size)}}function $(t){return new d(t.x,t.y)}function j(t){return new c(t.width,t.height)}async function se(){return i("plugin:window|current_monitor").then(R)}async function le(){return i("plugin:window|primary_monitor").then(R)}async function ae(){return i("plugin:window|available_monitors").then(t=>t.map(R))}var A={};p(A,{BaseDirectory:()=>Q,appCacheDir:()=>pe,appConfigDir:()=>ue,appDataDir:()=>ce,appLocalDataDir:()=>de,appLogDir:()=>ke,audioDir:()=>me,basename:()=>Me,cacheDir:()=>he,configDir:()=>be,dataDir:()=>ge,delimiter:()=>Ae,desktopDir:()=>ye,dirname:()=>Fe,documentDir:()=>we,downloadDir:()=>Pe,executableDir:()=>ve,extname:()=>Ue,fontDir:()=>_e,homeDir:()=>fe,isAbsolute:()=>He,join:()=>xe,localDataDir:()=>De,normalize:()=>Oe,pictureDir:()=>Ce,publicDir:()=>ze,resolve:()=>Ne,resolveResource:()=>Ie,resourceDir:()=>Le,runtimeDir:()=>Ee,sep:()=>Se,tempDir:()=>Re,templateDir:()=>Te,videoDir:()=>We});var Q=(r=>(r[r.Audio=1]="Audio",r[r.Cache=2]="Cache",r[r.Config=3]="Config",r[r.Data=4]="Data",r[r.LocalData=5]="LocalData",r[r.Document=6]="Document",r[r.Download=7]="Download",r[r.Picture=8]="Picture",r[r.Public=9]="Public",r[r.Video=10]="Video",r[r.Resource=11]="Resource",r[r.Temp=12]="Temp",r[r.AppConfig=13]="AppConfig",r[r.AppData=14]="AppData",r[r.AppLocalData=15]="AppLocalData",r[r.AppCache=16]="AppCache",r[r.AppLog=17]="AppLog",r[r.Desktop=18]="Desktop",r[r.Executable=19]="Executable",r[r.Font=20]="Font",r[r.Home=21]="Home",r[r.Runtime=22]="Runtime",r[r.Template=23]="Template",r))(Q||{});async function ue(){return i("plugin:path|resolve_directory",{directory:13})}async function ce(){return i("plugin:path|resolve_directory",{directory:14})}async function de(){return i("plugin:path|resolve_directory",{directory:15})}async function pe(){return i("plugin:path|resolve_directory",{directory:16})}async function me(){return i("plugin:path|resolve_directory",{directory:1})}async function he(){return i("plugin:path|resolve_directory",{directory:2})}async function be(){return i("plugin:path|resolve_directory",{directory:3})}async function ge(){return i("plugin:path|resolve_directory",{directory:4})}async function ye(){return i("plugin:path|resolve_directory",{directory:18})}async function we(){return i("plugin:path|resolve_directory",{directory:6})}async function Pe(){return i("plugin:path|resolve_directory",{directory:7})}async function ve(){return i("plugin:path|resolve_directory",{directory:19})}async function _e(){return i("plugin:path|resolve_directory",{directory:20})}async function fe(){return i("plugin:path|resolve_directory",{directory:21})}async function De(){return i("plugin:path|resolve_directory",{directory:5})}async function Ce(){return i("plugin:path|resolve_directory",{directory:8})}async function ze(){return i("plugin:path|resolve_directory",{directory:9})}async function Le(){return i("plugin:path|resolve_directory",{directory:11})}async function Ie(t){return i("plugin:path|resolve_directory",{directory:11,path:t})}async function Ee(){return i("plugin:path|resolve_directory",{directory:22})}async function Te(){return i("plugin:path|resolve_directory",{directory:23})}async function We(){return i("plugin:path|resolve_directory",{directory:10})}async function ke(){return i("plugin:path|resolve_directory",{directory:17})}async function Re(t){return i("plugin:path|resolve_directory",{directory:12})}function Se(){return window.__TAURI_INTERNALS__.plugins.path.sep}function Ae(){return window.__TAURI_INTERNALS__.plugins.path.delimiter}async function Ne(...t){return i("plugin:path|resolve",{paths:t})}async function Oe(t){return i("plugin:path|normalize",{path:t})}async function xe(...t){return i("plugin:path|join",{paths:t})}async function Fe(t){return i("plugin:path|dirname",{path:t})}async function Ue(t){return i("plugin:path|extname",{path:t})}async function Me(t,e){return i("plugin:path|basename",{path:t,ext:e})}async function He(t){return i("plugin:path|isAbsolute",{path:t})}return X(Ve);})(); window.__TAURI__ = __TAURI_IIFE__ diff --git a/core/tauri/src/test/mock_runtime.rs b/core/tauri/src/test/mock_runtime.rs index 9631cbaf386b..adfe8228bfd3 100644 --- a/core/tauri/src/test/mock_runtime.rs +++ b/core/tauri/src/test/mock_runtime.rs @@ -18,7 +18,7 @@ use tauri_runtime::{ #[cfg(target_os = "macos")] use tauri_utils::TitleBarStyle; -use tauri_utils::{config::WindowConfig, Theme}; +use tauri_utils::{config::WindowConfig, ProgressBarState, Theme}; use url::Url; #[cfg(windows)] @@ -676,6 +676,10 @@ impl Dispatch for MockDispatcher { .replace(script.into()); Ok(()) } + + fn set_progress_bar(&self, progress_state: ProgressBarState) -> Result<()> { + Ok(()) + } } #[derive(Debug, Clone)] diff --git a/core/tauri/src/window/mod.rs b/core/tauri/src/window/mod.rs index 635071d4b3f9..8a358c012901 100644 --- a/core/tauri/src/window/mod.rs +++ b/core/tauri/src/window/mod.rs @@ -32,7 +32,10 @@ use crate::{ }, sealed::ManagerBase, sealed::RuntimeOrDispatch, - utils::config::{WindowConfig, WindowEffectsConfig, WindowUrl}, + utils::{ + config::{WindowConfig, WindowEffectsConfig, WindowUrl}, + ProgressBarState, + }, EventLoopMessage, Manager, Runtime, Theme, WindowEvent, }; #[cfg(desktop)] @@ -2044,6 +2047,21 @@ impl Window { pub fn start_dragging(&self) -> crate::Result<()> { self.window.dispatcher.start_dragging().map_err(Into::into) } + + /// Sets the taskbar progress state. + /// + /// ## Platform-specific + /// + /// - **Linux / macOS**: Progress bar is app-wide and not specific to this window. + /// - **Linux**: Only supported desktop environments with `libunity` (e.g. GNOME). + /// - **iOS / Android:** Unsupported. + pub fn set_progress_bar(&self, progress_state: ProgressBarState) -> crate::Result<()> { + self + .window + .dispatcher + .set_progress_bar(progress_state) + .map_err(Into::into) + } } /// Webview APIs. diff --git a/core/tauri/src/window/plugin.rs b/core/tauri/src/window/plugin.rs index f9caaf419cc0..f9c56d4665b7 100644 --- a/core/tauri/src/window/plugin.rs +++ b/core/tauri/src/window/plugin.rs @@ -12,6 +12,7 @@ use crate::{ #[cfg(desktop)] mod desktop_commands { use serde::Deserialize; + use tauri_utils::ProgressBarState; use super::*; use crate::{ @@ -153,6 +154,7 @@ mod desktop_commands { setter!(set_cursor_position, Position); setter!(set_ignore_cursor_events, bool); setter!(start_dragging); + setter!(set_progress_bar, ProgressBarState); setter!(print); #[command(root = "crate")] @@ -302,6 +304,7 @@ pub fn init() -> TauriPlugin { desktop_commands::set_cursor_position, desktop_commands::set_ignore_cursor_events, desktop_commands::start_dragging, + desktop_commands::set_progress_bar, desktop_commands::print, desktop_commands::set_icon, desktop_commands::toggle_maximize, diff --git a/examples/api/dist/assets/index.js b/examples/api/dist/assets/index.js index 798e5e1e470c..c77ff47b7794 100644 --- a/examples/api/dist/assets/index.js +++ b/examples/api/dist/assets/index.js @@ -1,38 +1,40 @@ -var Rs=Object.defineProperty;var Ds=(e,t,i)=>t in e?Rs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i;var ot=(e,t,i)=>(Ds(e,typeof t!="symbol"?t+"":t,i),i);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))l(s);new MutationObserver(s=>{for(const r of s)if(r.type==="childList")for(const _ of r.addedNodes)_.tagName==="LINK"&&_.rel==="modulepreload"&&l(_)}).observe(document,{childList:!0,subtree:!0});function i(s){const r={};return s.integrity&&(r.integrity=s.integrity),s.referrerPolicy&&(r.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?r.credentials="include":s.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function l(s){if(s.ep)return;s.ep=!0;const r=i(s);fetch(s.href,r)}})();function $(){}function _s(e){return e()}function Yl(){return Object.create(null)}function He(e){e.forEach(_s)}function ms(e){return typeof e=="function"}function yt(e,t){return e!=e?t==t:e!==t||e&&typeof e=="object"||typeof e=="function"}let ci;function Hs(e,t){return e===t?!0:(ci||(ci=document.createElement("a")),ci.href=t,e===ci.href)}function Us(e){return Object.keys(e).length===0}function qs(e,...t){if(e==null){for(const l of t)l(void 0);return $}const i=e.subscribe(...t);return i.unsubscribe?()=>i.unsubscribe():i}function Fs(e,t,i){e.$$.on_destroy.push(qs(t,i))}function n(e,t){e.appendChild(t)}function v(e,t,i){e.insertBefore(t,i||null)}function m(e){e.parentNode&&e.parentNode.removeChild(e)}function Bt(e,t){for(let i=0;ie.removeEventListener(t,i,l)}function Kl(e){return function(t){return t.preventDefault(),e.call(this,t)}}function a(e,t,i){i==null?e.removeAttribute(t):e.getAttribute(t)!==i&&e.setAttribute(t,i)}function j(e){return e===""?null:+e}function Bs(e){return Array.from(e.childNodes)}function ie(e,t){t=""+t,e.data!==t&&(e.data=t)}function A(e,t){e.value=t??""}function Ht(e,t,i,l){i==null?e.style.removeProperty(t):e.style.setProperty(t,i,l?"important":"")}function at(e,t,i){for(let l=0;le.indexOf(l)===-1?t.push(l):i.push(l)),i.forEach(l=>l()),jt=t}const fi=new Set;let wt;function Js(){wt={r:0,c:[],p:wt}}function Qs(){wt.r||He(wt.c),wt=wt.p}function Yi(e,t){e&&e.i&&(fi.delete(e),e.i(t))}function Zl(e,t,i,l){if(e&&e.o){if(fi.has(e))return;fi.add(e),wt.c.push(()=>{fi.delete(e),l&&(i&&e.d(1),l())}),e.o(t)}else l&&l()}function Te(e){return(e==null?void 0:e.length)!==void 0?e:Array.from(e)}function xl(e){e&&e.c()}function Ki(e,t,i){const{fragment:l,after_update:s}=e.$$;l&&l.m(t,i),vt(()=>{const r=e.$$.on_mount.map(_s).filter(ms);e.$$.on_destroy?e.$$.on_destroy.push(...r):He(r),e.$$.on_mount=[]}),s.forEach(vt)}function Ji(e,t){const i=e.$$;i.fragment!==null&&(Ks(i.after_update),He(i.on_destroy),i.fragment&&i.fragment.d(t),i.on_destroy=i.fragment=null,i.ctx=[])}function Zs(e,t){e.$$.dirty[0]===-1&&(Ft.push(e),Xs(),e.$$.dirty.fill(0)),e.$$.dirty[t/31|0]|=1<{const C=E.length?E[0]:G;return d.ctx&&s(d.ctx[k],d.ctx[k]=C)&&(!d.skip_bound&&d.bound[k]&&d.bound[k](C),I&&Zs(e,k)),G}):[],d.update(),I=!0,He(d.before_update),d.fragment=l?l(d.ctx):!1,t.target){if(t.hydrate){const k=Bs(t.target);d.fragment&&d.fragment.l(k),k.forEach(m)}else d.fragment&&d.fragment.c();t.intro&&Yi(e.$$.fragment),Ki(e,t.target,t.anchor),ys()}an(b)}class Gt{constructor(){ot(this,"$$");ot(this,"$$set")}$destroy(){Ji(this,1),this.$destroy=$}$on(t,i){if(!ms(i))return $;const l=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return l.push(i),()=>{const s=l.indexOf(i);s!==-1&&l.splice(s,1)}}$set(t){this.$$set&&!Us(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}const xs="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(xs);const qt=[];function $s(e,t=$){let i;const l=new Set;function s(f){if(yt(e,f)&&(e=f,i)){const b=!qt.length;for(const d of l)d[1](),qt.push(d,e);if(b){for(let d=0;d{l.delete(d),l.size===0&&i&&(i(),i=null)}}return{set:s,update:r,subscribe:_}}var eo=Object.defineProperty,cn=(e,t)=>{for(var i in t)eo(e,i,{get:t[i],enumerable:!0})},ks=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)},$l=(e,t,i)=>(ks(e,t,"read from private field"),i?i.call(e):t.get(e)),to=(e,t,i)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,i)},no=(e,t,i,l)=>(ks(e,t,"write to private field"),l?l.call(e,i):t.set(e,i),i),io={};cn(io,{Channel:()=>zs,PluginListener:()=>Ls,addPluginListener:()=>lo,convertFileSrc:()=>so,invoke:()=>g,transformCallback:()=>Zi});function Zi(e,t=!1){return window.__TAURI_INTERNALS__.transformCallback(e,t)}var on,zs=class{constructor(){this.__TAURI_CHANNEL_MARKER__=!0,to(this,on,()=>{}),this.id=Zi(t=>{$l(this,on).call(this,t)})}set onmessage(t){no(this,on,t)}get onmessage(){return $l(this,on)}toJSON(){return`__CHANNEL__:${this.id}`}};on=new WeakMap;var Ls=class{constructor(t,i,l){this.plugin=t,this.event=i,this.channelId=l}async unregister(){return g(`plugin:${this.plugin}|remove_listener`,{event:this.event,channelId:this.channelId})}};async function lo(e,t,i){let l=new zs;return l.onmessage=i,g(`plugin:${e}|register_listener`,{event:t,handler:l}).then(()=>new Ls(e,t,l.id))}async function g(e,t={},i){return window.__TAURI_INTERNALS__.invoke(e,t,i)}function so(e,t="asset"){return window.__TAURI_INTERNALS__.convertFileSrc(e,t)}var oo={};cn(oo,{getName:()=>Ss,getTauriVersion:()=>Cs,getVersion:()=>Es,hide:()=>Ts,show:()=>Ps});async function Es(){return g("plugin:app|version")}async function Ss(){return g("plugin:app|name")}async function Cs(){return g("plugin:app|tauri_version")}async function Ps(){return g("plugin:app|app_show")}async function Ts(){return g("plugin:app|app_hide")}function ao(e){let t,i,l,s,r,_,f,b,d,I,k,G,E,C,O,N,oe,D,R,B,V,P,F,Z;return{c(){t=o("div"),i=o("p"),i.innerHTML=`This is a demo of Tauri's API capabilities using the @tauri-apps/api package. It's used as the main validation app, serving as the test bed of our +var Zs=Object.defineProperty;var xs=(e,t,i)=>t in e?Zs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i;var ft=(e,t,i)=>(xs(e,typeof t!="symbol"?t+"":t,i),i);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))l(s);new MutationObserver(s=>{for(const r of s)if(r.type==="childList")for(const _ of r.addedNodes)_.tagName==="LINK"&&_.rel==="modulepreload"&&l(_)}).observe(document,{childList:!0,subtree:!0});function i(s){const r={};return s.integrity&&(r.integrity=s.integrity),s.referrerPolicy&&(r.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?r.credentials="include":s.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function l(s){if(s.ep)return;s.ep=!0;const r=i(s);fetch(s.href,r)}})();function $(){}function Is(e){return e()}function os(){return Object.create(null)}function Fe(e){e.forEach(Is)}function Os(e){return typeof e=="function"}function Ct(e,t){return e!=e?t==t:e!==t||e&&typeof e=="object"||typeof e=="function"}let Li;function $s(e,t){return e===t?!0:(Li||(Li=document.createElement("a")),Li.href=t,e===Li.href)}function eo(e){return Object.keys(e).length===0}function to(e,...t){if(e==null){for(const l of t)l(void 0);return $}const i=e.subscribe(...t);return i.unsubscribe?()=>i.unsubscribe():i}function no(e,t,i){e.$$.on_destroy.push(to(t,i))}function n(e,t){e.appendChild(t)}function w(e,t,i){e.insertBefore(t,i||null)}function m(e){e.parentNode&&e.parentNode.removeChild(e)}function St(e,t){for(let i=0;ie.removeEventListener(t,i,l)}function as(e){return function(t){return t.preventDefault(),e.call(this,t)}}function a(e,t,i){i==null?e.removeAttribute(t):e.getAttribute(t)!==i&&e.setAttribute(t,i)}function F(e){return e===""?null:+e}function lo(e){return Array.from(e.childNodes)}function ne(e,t){t=""+t,e.data!==t&&(e.data=t)}function C(e,t){e.value=t??""}function Yt(e,t,i,l){i==null?e.style.removeProperty(t):e.style.setProperty(t,i,l?"important":"")}function Xe(e,t,i){for(let l=0;le.indexOf(l)===-1?t.push(l):i.push(l)),i.forEach(l=>l()),Zt=t}const Ei=new Set;let Et;function co(){Et={r:0,c:[],p:Et}}function fo(){Et.r||Fe(Et.c),Et=Et.p}function ol(e,t){e&&e.i&&(Ei.delete(e),e.i(t))}function cs(e,t,i,l){if(e&&e.o){if(Ei.has(e))return;Ei.add(e),Et.c.push(()=>{Ei.delete(e),l&&(i&&e.d(1),l())}),e.o(t)}else l&&l()}function Ee(e){return(e==null?void 0:e.length)!==void 0?e:Array.from(e)}function ds(e){e&&e.c()}function al(e,t,i){const{fragment:l,after_update:s}=e.$$;l&&l.m(t,i),pt(()=>{const r=e.$$.on_mount.map(Is).filter(Os);e.$$.on_destroy?e.$$.on_destroy.push(...r):Fe(r),e.$$.on_mount=[]}),s.forEach(pt)}function rl(e,t){const i=e.$$;i.fragment!==null&&(uo(i.after_update),Fe(i.on_destroy),i.fragment&&i.fragment.d(t),i.on_destroy=i.fragment=null,i.ctx=[])}function ho(e,t){e.$$.dirty[0]===-1&&(Qt.push(e),ao(),e.$$.dirty.fill(0)),e.$$.dirty[t/31|0]|=1<{const M=E.length?E[0]:K;return d.ctx&&s(d.ctx[k],d.ctx[k]=M)&&(!d.skip_bound&&d.bound[k]&&d.bound[k](M),I&&ho(e,k)),K}):[],d.update(),I=!0,Fe(d.before_update),d.fragment=l?l(d.ctx):!1,t.target){if(t.hydrate){const k=lo(t.target);d.fragment&&d.fragment.l(k),k.forEach(m)}else d.fragment&&d.fragment.c();t.intro&&ol(e.$$.fragment),al(e,t.target,t.anchor),Rs()}vn(b)}class $t{constructor(){ft(this,"$$");ft(this,"$$set")}$destroy(){rl(this,1),this.$destroy=$}$on(t,i){if(!Os(i))return $;const l=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return l.push(i),()=>{const s=l.indexOf(i);s!==-1&&l.splice(s,1)}}$set(t){this.$$set&&!eo(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}const po="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(po);const Jt=[];function bo(e,t=$){let i;const l=new Set;function s(h){if(Ct(e,h)&&(e=h,i)){const b=!Jt.length;for(const d of l)d[1](),Jt.push(d,e);if(b){for(let d=0;d{l.delete(d),l.size===0&&i&&(i(),i=null)}}return{set:s,update:r,subscribe:_}}var go=Object.defineProperty,Ln=(e,t)=>{for(var i in t)go(e,i,{get:t[i],enumerable:!0})},Ds=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)},fs=(e,t,i)=>(Ds(e,t,"read from private field"),i?i.call(e):t.get(e)),_o=(e,t,i)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,i)},mo=(e,t,i,l)=>(Ds(e,t,"write to private field"),l?l.call(e,i):t.set(e,i),i),wo={};Ln(wo,{Channel:()=>Hs,PluginListener:()=>Us,addPluginListener:()=>vo,convertFileSrc:()=>yo,invoke:()=>g,transformCallback:()=>cl});function cl(e,t=!1){return window.__TAURI_INTERNALS__.transformCallback(e,t)}var wn,Hs=class{constructor(){this.__TAURI_CHANNEL_MARKER__=!0,_o(this,wn,()=>{}),this.id=cl(t=>{fs(this,wn).call(this,t)})}set onmessage(t){mo(this,wn,t)}get onmessage(){return fs(this,wn)}toJSON(){return`__CHANNEL__:${this.id}`}};wn=new WeakMap;var Us=class{constructor(t,i,l){this.plugin=t,this.event=i,this.channelId=l}async unregister(){return g(`plugin:${this.plugin}|remove_listener`,{event:this.event,channelId:this.channelId})}};async function vo(e,t,i){let l=new Hs;return l.onmessage=i,g(`plugin:${e}|register_listener`,{event:t,handler:l}).then(()=>new Us(e,t,l.id))}async function g(e,t={},i){return window.__TAURI_INTERNALS__.invoke(e,t,i)}function yo(e,t="asset"){return window.__TAURI_INTERNALS__.convertFileSrc(e,t)}var ko={};Ln(ko,{getName:()=>Fs,getTauriVersion:()=>js,getVersion:()=>qs,hide:()=>Vs,show:()=>Bs});async function qs(){return g("plugin:app|version")}async function Fs(){return g("plugin:app|name")}async function js(){return g("plugin:app|tauri_version")}async function Bs(){return g("plugin:app|app_show")}async function Vs(){return g("plugin:app|app_hide")}function zo(e){let t,i,l,s,r,_,h,b,d,I,k,K,E,M,A,W,se,H,R,V,G,P,j,oe;return{c(){t=o("div"),i=o("p"),i.innerHTML=`This is a demo of Tauri's API capabilities using the @tauri-apps/api package. It's used as the main validation app, serving as the test bed of our development process. In the future, this app will be used on Tauri's integration - tests.`,l=c(),s=o("br"),r=c(),_=o("br"),f=c(),b=o("pre"),d=p(" App name: "),I=o("code"),k=p(e[2]),G=p(` - App version: `),E=o("code"),C=p(e[0]),O=p(` - Tauri version: `),N=o("code"),oe=p(e[1]),D=p(` - `),R=c(),B=o("br"),V=c(),P=o("button"),P.textContent="Context menu",a(P,"class","btn")},m(W,ee){v(W,t,ee),n(t,i),n(t,l),n(t,s),n(t,r),n(t,_),n(t,f),n(t,b),n(b,d),n(b,I),n(I,k),n(b,G),n(b,E),n(E,C),n(b,O),n(b,N),n(N,oe),n(b,D),n(t,R),n(t,B),n(t,V),n(t,P),F||(Z=L(P,"click",e[3]),F=!0)},p(W,[ee]){ee&4&&ie(k,W[2]),ee&1&&ie(C,W[0]),ee&2&&ie(oe,W[1])},i:$,o:$,d(W){W&&m(t),F=!1,Z()}}}function ro(e,t,i){let l="1.0.0",s="1.0.0",r="Unknown";Ss().then(f=>{i(2,r=f)}),Es().then(f=>{i(0,l=f)}),Cs().then(f=>{i(1,s=f)});function _(){g("popup_context_menu")}return[l,s,r,_]}class uo extends Gt{constructor(t){super(),Vt(this,t,ro,ao,yt,{})}}var co={};cn(co,{TauriEvent:()=>Ms,emit:()=>xi,listen:()=>_i,once:()=>Is});var Ms=(e=>(e.WINDOW_RESIZED="tauri://resize",e.WINDOW_MOVED="tauri://move",e.WINDOW_CLOSE_REQUESTED="tauri://close-requested",e.WINDOW_CREATED="tauri://window-created",e.WINDOW_DESTROYED="tauri://destroyed",e.WINDOW_FOCUS="tauri://focus",e.WINDOW_BLUR="tauri://blur",e.WINDOW_SCALE_FACTOR_CHANGED="tauri://scale-change",e.WINDOW_THEME_CHANGED="tauri://theme-changed",e.WINDOW_FILE_DROP="tauri://file-drop",e.WINDOW_FILE_DROP_HOVER="tauri://file-drop-hover",e.WINDOW_FILE_DROP_CANCELLED="tauri://file-drop-cancelled",e.MENU="tauri://menu",e))(Ms||{});async function As(e,t){await g("plugin:event|unlisten",{event:e,eventId:t})}async function _i(e,t,i){return g("plugin:event|listen",{event:e,windowLabel:i==null?void 0:i.target,handler:Zi(t)}).then(l=>async()=>As(e,l))}async function Is(e,t,i){return _i(e,l=>{t(l),As(e,l.id).catch(()=>{})},i)}async function xi(e,t,i){await g("plugin:event|emit",{event:e,windowLabel:i==null?void 0:i.target,payload:t})}function fo(e){let t,i,l,s,r,_,f,b;return{c(){t=o("div"),i=o("button"),i.textContent="Call Log API",l=c(),s=o("button"),s.textContent="Call Request (async) API",r=c(),_=o("button"),_.textContent="Send event to Rust",a(i,"class","btn"),a(i,"id","log"),a(s,"class","btn"),a(s,"id","request"),a(_,"class","btn"),a(_,"id","event")},m(d,I){v(d,t,I),n(t,i),n(t,l),n(t,s),n(t,r),n(t,_),f||(b=[L(i,"click",e[0]),L(s,"click",e[1]),L(_,"click",e[2])],f=!0)},p:$,i:$,o:$,d(d){d&&m(t),f=!1,He(b)}}}function ho(e,t,i){let{onMessage:l}=t,s;pi(async()=>{s=await _i("rust-event",l)}),vs(()=>{s&&s()});function r(){g("log_operation",{event:"tauri-click",payload:"this payload is optional because we used Option in Rust"})}function _(){g("perform_request",{endpoint:"dummy endpoint arg",body:{id:5,name:"test"}}).then(l).catch(l)}function f(){xi("js-event","this is the payload string")}return e.$$set=b=>{"onMessage"in b&&i(3,l=b.onMessage)},[r,_,f,l]}class po extends Gt{constructor(t){super(),Vt(this,t,ho,fo,yt,{onMessage:3})}}var bo={};cn(bo,{LogicalPosition:()=>$i,LogicalSize:()=>un,PhysicalPosition:()=>Ye,PhysicalSize:()=>rt});var un=class{constructor(e,t){this.type="Logical",this.width=e,this.height=t}},rt=class{constructor(e,t){this.type="Physical",this.width=e,this.height=t}toLogical(e){return new un(this.width/e,this.height/e)}},$i=class{constructor(t,i){this.type="Logical",this.x=t,this.y=i}},Ye=class{constructor(e,t){this.type="Physical",this.x=e,this.y=t}toLogical(e){return new $i(this.x/e,this.y/e)}},go={};cn(go,{CloseRequestedEvent:()=>Os,Effect:()=>bi,EffectState:()=>gi,LogicalPosition:()=>$i,LogicalSize:()=>un,PhysicalPosition:()=>Ye,PhysicalSize:()=>rt,UserAttentionType:()=>el,Window:()=>dn,availableMonitors:()=>wo,currentMonitor:()=>_o,getAll:()=>hi,getCurrent:()=>tl,primaryMonitor:()=>mo});var el=(e=>(e[e.Critical=1]="Critical",e[e.Informational=2]="Informational",e))(el||{}),Os=class{constructor(e){this._preventDefault=!1,this.event=e.event,this.windowLabel=e.windowLabel,this.id=e.id}preventDefault(){this._preventDefault=!0}isPreventDefault(){return this._preventDefault}};function tl(){return new dn(window.__TAURI_INTERNALS__.metadata.currentWindow.label,{skip:!0})}function hi(){return window.__TAURI_INTERNALS__.metadata.windows.map(e=>new dn(e.label,{skip:!0}))}var es=["tauri://created","tauri://error"],dn=class{constructor(e,t={}){this.label=e,this.listeners=Object.create(null),t!=null&&t.skip||g("plugin:window|create",{options:{...t,label:e}}).then(async()=>this.emit("tauri://created")).catch(async i=>this.emit("tauri://error",i))}static getByLabel(e){return hi().some(t=>t.label===e)?new dn(e,{skip:!0}):null}static getCurrent(){return tl()}static getAll(){return hi()}static async getFocusedWindow(){for(let e of hi())if(await e.isFocused())return e;return null}async listen(e,t){return this._handleTauriEvent(e,t)?Promise.resolve(()=>{let i=this.listeners[e];i.splice(i.indexOf(t),1)}):_i(e,t,{target:this.label})}async once(e,t){return this._handleTauriEvent(e,t)?Promise.resolve(()=>{let i=this.listeners[e];i.splice(i.indexOf(t),1)}):Is(e,t,{target:this.label})}async emit(e,t){if(es.includes(e)){for(let i of this.listeners[e]||[])i({event:e,id:-1,windowLabel:this.label,payload:t});return Promise.resolve()}return xi(e,t,{target:this.label})}_handleTauriEvent(e,t){return es.includes(e)?(e in this.listeners?this.listeners[e].push(t):this.listeners[e]=[t],!0):!1}async scaleFactor(){return g("plugin:window|scale_factor",{label:this.label})}async innerPosition(){return g("plugin:window|inner_position",{label:this.label}).then(({x:e,y:t})=>new Ye(e,t))}async outerPosition(){return g("plugin:window|outer_position",{label:this.label}).then(({x:e,y:t})=>new Ye(e,t))}async innerSize(){return g("plugin:window|inner_size",{label:this.label}).then(({width:e,height:t})=>new rt(e,t))}async outerSize(){return g("plugin:window|outer_size",{label:this.label}).then(({width:e,height:t})=>new rt(e,t))}async isFullscreen(){return g("plugin:window|is_fullscreen",{label:this.label})}async isMinimized(){return g("plugin:window|is_minimized",{label:this.label})}async isMaximized(){return g("plugin:window|is_maximized",{label:this.label})}async isFocused(){return g("plugin:window|is_focused",{label:this.label})}async isDecorated(){return g("plugin:window|is_decorated",{label:this.label})}async isResizable(){return g("plugin:window|is_resizable",{label:this.label})}async isMaximizable(){return g("plugin:window|is_maximizable",{label:this.label})}async isMinimizable(){return g("plugin:window|is_minimizable",{label:this.label})}async isClosable(){return g("plugin:window|is_closable",{label:this.label})}async isVisible(){return g("plugin:window|is_visible",{label:this.label})}async title(){return g("plugin:window|title",{label:this.label})}async theme(){return g("plugin:window|theme",{label:this.label})}async center(){return g("plugin:window|center",{label:this.label})}async requestUserAttention(e){let t=null;return e&&(e===1?t={type:"Critical"}:t={type:"Informational"}),g("plugin:window|request_user_attention",{label:this.label,value:t})}async setResizable(e){return g("plugin:window|set_resizable",{label:this.label,value:e})}async setMaximizable(e){return g("plugin:window|set_maximizable",{label:this.label,value:e})}async setMinimizable(e){return g("plugin:window|set_minimizable",{label:this.label,value:e})}async setClosable(e){return g("plugin:window|set_closable",{label:this.label,value:e})}async setTitle(e){return g("plugin:window|set_title",{label:this.label,value:e})}async maximize(){return g("plugin:window|maximize",{label:this.label})}async unmaximize(){return g("plugin:window|unmaximize",{label:this.label})}async toggleMaximize(){return g("plugin:window|toggle_maximize",{label:this.label})}async minimize(){return g("plugin:window|minimize",{label:this.label})}async unminimize(){return g("plugin:window|unminimize",{label:this.label})}async show(){return g("plugin:window|show",{label:this.label})}async hide(){return g("plugin:window|hide",{label:this.label})}async close(){return g("plugin:window|close",{label:this.label})}async setDecorations(e){return g("plugin:window|set_decorations",{label:this.label,value:e})}async setShadow(e){return g("plugin:window|set_shadow",{label:this.label,value:e})}async setEffects(e){return g("plugin:window|set_effects",{label:this.label,value:e})}async clearEffects(){return g("plugin:window|set_effects",{label:this.label,value:null})}async setAlwaysOnTop(e){return g("plugin:window|set_always_on_top",{label:this.label,value:e})}async setContentProtected(e){return g("plugin:window|set_content_protected",{label:this.label,value:e})}async setSize(e){if(!e||e.type!=="Logical"&&e.type!=="Physical")throw new Error("the `size` argument must be either a LogicalSize or a PhysicalSize instance");return g("plugin:window|set_size",{label:this.label,value:{type:e.type,data:{width:e.width,height:e.height}}})}async setMinSize(e){if(e&&e.type!=="Logical"&&e.type!=="Physical")throw new Error("the `size` argument must be either a LogicalSize or a PhysicalSize instance");return g("plugin:window|set_min_size",{label:this.label,value:e?{type:e.type,data:{width:e.width,height:e.height}}:null})}async setMaxSize(e){if(e&&e.type!=="Logical"&&e.type!=="Physical")throw new Error("the `size` argument must be either a LogicalSize or a PhysicalSize instance");return g("plugin:window|set_max_size",{label:this.label,value:e?{type:e.type,data:{width:e.width,height:e.height}}:null})}async setPosition(e){if(!e||e.type!=="Logical"&&e.type!=="Physical")throw new Error("the `position` argument must be either a LogicalPosition or a PhysicalPosition instance");return g("plugin:window|set_position",{label:this.label,value:{type:e.type,data:{x:e.x,y:e.y}}})}async setFullscreen(e){return g("plugin:window|set_fullscreen",{label:this.label,value:e})}async setFocus(){return g("plugin:window|set_focus",{label:this.label})}async setIcon(e){return g("plugin:window|set_icon",{label:this.label,value:typeof e=="string"?e:Array.from(e)})}async setSkipTaskbar(e){return g("plugin:window|set_skip_taskbar",{label:this.label,value:e})}async setCursorGrab(e){return g("plugin:window|set_cursor_grab",{label:this.label,value:e})}async setCursorVisible(e){return g("plugin:window|set_cursor_visible",{label:this.label,value:e})}async setCursorIcon(e){return g("plugin:window|set_cursor_icon",{label:this.label,value:e})}async setCursorPosition(e){if(!e||e.type!=="Logical"&&e.type!=="Physical")throw new Error("the `position` argument must be either a LogicalPosition or a PhysicalPosition instance");return g("plugin:window|set_cursor_position",{label:this.label,value:{type:e.type,data:{x:e.x,y:e.y}}})}async setIgnoreCursorEvents(e){return g("plugin:window|set_ignore_cursor_events",{label:this.label,value:e})}async startDragging(){return g("plugin:window|start_dragging",{label:this.label})}async onResized(e){return this.listen("tauri://resize",t=>{t.payload=Ns(t.payload),e(t)})}async onMoved(e){return this.listen("tauri://move",t=>{t.payload=Ws(t.payload),e(t)})}async onCloseRequested(e){return this.listen("tauri://close-requested",t=>{let i=new Os(t);Promise.resolve(e(i)).then(()=>{if(!i.isPreventDefault())return this.close()})})}async onFocusChanged(e){let t=await this.listen("tauri://focus",l=>{e({...l,payload:!0})}),i=await this.listen("tauri://blur",l=>{e({...l,payload:!1})});return()=>{t(),i()}}async onScaleChanged(e){return this.listen("tauri://scale-change",e)}async onMenuClicked(e){return this.listen("tauri://menu",e)}async onFileDropEvent(e){let t=await this.listen("tauri://file-drop",s=>{e({...s,payload:{type:"drop",paths:s.payload}})}),i=await this.listen("tauri://file-drop-hover",s=>{e({...s,payload:{type:"hover",paths:s.payload}})}),l=await this.listen("tauri://file-drop-cancelled",s=>{e({...s,payload:{type:"cancel"}})});return()=>{t(),i(),l()}}async onThemeChanged(e){return this.listen("tauri://theme-changed",e)}},bi=(e=>(e.AppearanceBased="appearanceBased",e.Light="light",e.Dark="dark",e.MediumLight="mediumLight",e.UltraDark="ultraDark",e.Titlebar="titlebar",e.Selection="selection",e.Menu="menu",e.Popover="popover",e.Sidebar="sidebar",e.HeaderView="headerView",e.Sheet="sheet",e.WindowBackground="windowBackground",e.HudWindow="hudWindow",e.FullScreenUI="fullScreenUI",e.Tooltip="tooltip",e.ContentBackground="contentBackground",e.UnderWindowBackground="underWindowBackground",e.UnderPageBackground="underPageBackground",e.Mica="mica",e.Blur="blur",e.Acrylic="acrylic",e.Tabbed="tabbed",e.TabbedDark="tabbedDark",e.TabbedLight="tabbedLight",e))(bi||{}),gi=(e=>(e.FollowsWindowActiveState="followsWindowActiveState",e.Active="active",e.Inactive="inactive",e))(gi||{});function nl(e){return e===null?null:{name:e.name,scaleFactor:e.scaleFactor,position:Ws(e.position),size:Ns(e.size)}}function Ws(e){return new Ye(e.x,e.y)}function Ns(e){return new rt(e.width,e.height)}async function _o(){return g("plugin:window|current_monitor").then(nl)}async function mo(){return g("plugin:window|primary_monitor").then(nl)}async function wo(){return g("plugin:window|available_monitors").then(e=>e.map(nl))}function ts(e,t,i){const l=e.slice();return l[98]=t[i],l}function ns(e,t,i){const l=e.slice();return l[101]=t[i],l}function is(e,t,i){const l=e.slice();return l[104]=t[i],l}function ls(e,t,i){const l=e.slice();return l[107]=t[i],l}function ss(e){let t,i,l,s,r,_,f=Te(Object.keys(e[1])),b=[];for(let d=0;de[55].call(l))},m(d,I){v(d,t,I),v(d,i,I),v(d,l,I),n(l,s);for(let k=0;ke[78].call(Xe)),a(it,"class","input"),a(it,"type","number"),a(lt,"class","input"),a(lt,"type","number"),a(Ge,"class","flex gap-2"),a(st,"class","input grow"),a(st,"id","title"),a(sn,"class","btn"),a(sn,"type","submit"),a(_t,"class","flex gap-1"),a(ln,"class","flex flex-col gap-1")},m(u,h){v(u,t,h),v(u,i,h),v(u,l,h),n(l,s),n(l,r),n(l,_),n(_,f),A(f,e[40]),n(_,b),n(_,d),v(u,I,h),v(u,k,h),v(u,G,h),v(u,E,h),n(E,C),n(E,O),n(E,N),n(E,oe),n(E,D),n(E,R),n(E,B),v(u,V,h),v(u,P,h),n(P,F),n(F,Z),n(F,W),W.checked=e[6],n(P,ee),n(P,ae),n(ae,y),n(ae,U),U.checked=e[2],n(P,q),n(P,X),n(X,ye),n(X,le),le.checked=e[3],n(P,ce),n(P,_e),n(_e,de),n(_e,re),re.checked=e[4],n(P,Y),n(P,ue),n(ue,H),n(ue,x),x.checked=e[5],n(P,K),n(P,w),n(w,J),n(w,S),S.checked=e[7],n(P,se),n(P,ke),n(ke,ze),n(ke,fe),fe.checked=e[8],n(P,Se),n(P,Le),n(Le,Me),n(Le,he),he.checked=e[9],n(P,me),n(P,Fe),n(Fe,je),n(Fe,pe),pe.checked=e[10],v(u,Ce,h),v(u,te,h),v(u,Ee,h),v(u,ge,h),n(ge,we),n(we,ne),n(ne,z),n(ne,Q),A(Q,e[17]),n(we,T),n(we,Pe),n(Pe,fn),n(Pe,Ae),A(Ae,e[18]),n(ge,hn),n(ge,Ke),n(Ke,kt),n(kt,pn),n(kt,Ie),A(Ie,e[11]),n(Ke,bn),n(Ke,zt),n(zt,gn),n(zt,Oe),A(Oe,e[12]),n(ge,_n),n(ge,Je),n(Je,Lt),n(Lt,mn),n(Lt,Ue),A(Ue,e[13]),n(Je,wn),n(Je,Et),n(Et,vn),n(Et,qe),A(qe,e[14]),n(ge,yn),n(ge,Qe),n(Qe,St),n(St,kn),n(St,We),A(We,e[15]),n(Qe,zn),n(Qe,Ct),n(Ct,Ln),n(Ct,Ne),A(Ne,e[16]),v(u,Xt,h),v(u,Yt,h),v(u,Kt,h),v(u,M,h),n(M,Be),n(Be,Re),n(Re,ut),n(Re,Jt),n(Re,ct),n(ct,Qt),n(ct,Pt),n(Re,Zt),n(Re,ft),n(ft,xt),n(ft,Tt),n(Be,$t),n(Be,De),n(De,pt),n(De,en),n(De,bt),n(bt,tn),n(bt,Mt),n(De,En),n(De,Sn),n(Sn,il),n(Sn,mi),n(M,ll),n(M,At),n(At,Ze),n(Ze,Pn),n(Ze,sl),n(Ze,Tn),n(Tn,ol),n(Tn,wi),n(Ze,al),n(Ze,An),n(An,rl),n(An,vi),n(At,ul),n(At,xe),n(xe,On),n(xe,cl),n(xe,Wn),n(Wn,dl),n(Wn,yi),n(xe,fl),n(xe,Rn),n(Rn,hl),n(Rn,ki),n(M,pl),n(M,It),n(It,$e),n($e,Hn),n($e,bl),n($e,Un),n(Un,gl),n(Un,zi),n($e,_l),n($e,Fn),n(Fn,ml),n(Fn,Li),n(It,wl),n(It,et),n(et,Bn),n(et,vl),n(et,Vn),n(Vn,yl),n(Vn,Ei),n(et,kl),n(et,Xn),n(Xn,zl),n(Xn,Si),n(M,Ll),n(M,Ot),n(Ot,tt),n(tt,Kn),n(tt,El),n(tt,Jn),n(Jn,Sl),n(Jn,Ci),n(tt,Cl),n(tt,Zn),n(Zn,Pl),n(Zn,Pi),n(Ot,Tl),n(Ot,nt),n(nt,$n),n(nt,Ml),n(nt,ei),n(ei,Al),n(ei,Ti),n(nt,Il),n(nt,ni),n(ni,Ol),n(ni,Mi),v(u,Ai,h),v(u,Ii,h),v(u,Oi,h),v(u,nn,h),v(u,Wi,h),v(u,Ve,h),n(Ve,li),n(li,Wt),Wt.checked=e[19],n(li,Wl),n(Ve,Nl),n(Ve,si),n(si,Nt),Nt.checked=e[20],n(si,Rl),n(Ve,Dl),n(Ve,oi),n(oi,Rt),Rt.checked=e[24],n(oi,Hl),v(u,Ni,h),v(u,Ge,h),n(Ge,ai),n(ai,Ul),n(ai,Xe);for(let be=0;bee[82].call(r)),a(d,"class","input"),e[34]===void 0&&vt(()=>e[83].call(d)),a(E,"class","input"),a(E,"type","number"),a(i,"class","flex"),Ht(R,"max-width","120px"),a(R,"class","input"),a(R,"type","number"),a(R,"placeholder","R"),Ht(V,"max-width","120px"),a(V,"class","input"),a(V,"type","number"),a(V,"placeholder","G"),Ht(F,"max-width","120px"),a(F,"class","input"),a(F,"type","number"),a(F,"placeholder","B"),Ht(W,"max-width","120px"),a(W,"class","input"),a(W,"type","number"),a(W,"placeholder","A"),a(D,"class","flex"),a(O,"class","flex"),a(y,"class","btn"),Ht(y,"width","80px"),a(ae,"class","flex"),a(de,"class","btn"),Ht(de,"width","80px"),a(q,"class","flex"),a(t,"class","flex flex-col gap-1")},m(w,J){v(w,t,J),n(t,i),n(i,l),n(l,s),n(l,r);for(let S=0;S=1,I,k,G,E=d&&ss(e),C=e[1][e[0]]&&as(e);return{c(){t=o("div"),i=o("div"),l=o("input"),s=c(),r=o("button"),r.textContent="New window",_=c(),f=o("br"),b=c(),E&&E.c(),I=c(),C&&C.c(),a(l,"class","input grow"),a(l,"type","text"),a(l,"placeholder","New Window label.."),a(r,"class","btn"),a(i,"class","flex gap-1"),a(t,"class","flex flex-col children:grow gap-2")},m(O,N){v(O,t,N),n(t,i),n(i,l),A(l,e[25]),n(i,s),n(i,r),n(t,_),n(t,f),n(t,b),E&&E.m(t,null),n(t,I),C&&C.m(t,null),k||(G=[L(l,"input",e[54]),L(r,"click",e[49])],k=!0)},p(O,N){N[0]&33554432&&l.value!==O[25]&&A(l,O[25]),N[0]&2&&(d=Object.keys(O[1]).length>=1),d?E?E.p(O,N):(E=ss(O),E.c(),E.m(t,I)):E&&(E.d(1),E=null),O[1][O[0]]?C?C.p(O,N):(C=as(O),C.c(),C.m(t,null)):C&&(C.d(1),C=null)},i:$,o:$,d(O){O&&m(t),E&&E.d(),C&&C.d(),k=!1,He(G)}}}function ko(e,t,i){const l=tl();let s=l.label;const r={[l.label]:l},_=["default","crosshair","hand","arrow","move","text","wait","help","progress","notAllowed","contextMenu","cell","verticalText","alias","copy","noDrop","grab","grabbing","allScroll","zoomIn","zoomOut","eResize","nResize","neResize","nwResize","sResize","seResize","swResize","wResize","ewResize","nsResize","neswResize","nwseResize","colResize","rowResize"],f=["mica","blur","acrylic","tabbed","tabbedDark","tabbedLight"],b=navigator.appVersion.includes("Windows"),d=navigator.appVersion.includes("Macintosh");let I=b?f:Object.keys(bi).map(M=>bi[M]).filter(M=>!f.includes(M));const k=Object.keys(gi).map(M=>gi[M]);let{onMessage:G}=t;const E=document.querySelector("main");let C,O=!0,N=!0,oe=!0,D=!0,R=!1,B=!0,V=!1,P=!0,F=!1,Z=null,W=null,ee=null,ae=null,y=null,U=null,q=null,X=null,ye=1,le=new Ye(q,X),ce=new Ye(q,X),_e=new rt(Z,W),de=new rt(Z,W),re,Y,ue=!1,H=!0,x=null,K=null,w="default",J=!1,S="Awesome Tauri Example!",se=[],ke,ze,fe,Se,Le,Me,he,me;function Fe(){r[s].setTitle(S)}function je(){r[s].hide(),setTimeout(r[s].show,2e3)}function pe(){r[s].minimize(),setTimeout(r[s].unminimize,2e3)}function Ce(){if(!C)return;const M=new dn(C);i(1,r[C]=M,r),M.once("tauri://error",function(){G("Error creating new webview")})}function te(){r[s].innerSize().then(M=>{i(29,_e=M),i(11,Z=_e.width),i(12,W=_e.height)}),r[s].outerSize().then(M=>{i(30,de=M)})}function Ee(){r[s].innerPosition().then(M=>{i(27,le=M)}),r[s].outerPosition().then(M=>{i(28,ce=M),i(17,q=ce.x),i(18,X=ce.y)})}async function ge(M){M&&(re&&re(),Y&&Y(),Y=await M.listen("tauri://move",Ee),re=await M.listen("tauri://resize",te))}async function we(){await r[s].minimize(),await r[s].requestUserAttention(el.Critical),await new Promise(M=>setTimeout(M,3e3)),await r[s].requestUserAttention(null)}async function ne(){se.includes(ke)||i(32,se=[...se,ke]);const M={effects:se,state:ze,radius:fe};Number.isInteger(Se)&&Number.isInteger(Le)&&Number.isInteger(Me)&&Number.isInteger(he)&&(M.color=[Se,Le,Me,he]),E.classList.remove("bg-primary"),E.classList.remove("dark:bg-darkPrimary"),await r[s].clearEffects(),await r[s].setEffects(M)}async function z(){i(32,se=[]),await r[s].clearEffects(),E.classList.add("bg-primary"),E.classList.add("dark:bg-darkPrimary")}function Q(){C=this.value,i(25,C)}function T(){s=di(this),i(0,s),i(1,r)}function Pe(){me=this.value,i(40,me)}const fn=()=>r[s].center();function Ae(){R=this.checked,i(6,R)}function hn(){O=this.checked,i(2,O)}function Ke(){N=this.checked,i(3,N)}function kt(){oe=this.checked,i(4,oe)}function pn(){D=this.checked,i(5,D)}function Ie(){B=this.checked,i(7,B)}function bn(){V=this.checked,i(8,V)}function zt(){P=this.checked,i(9,P)}function gn(){F=this.checked,i(10,F)}function Oe(){q=j(this.value),i(17,q)}function _n(){X=j(this.value),i(18,X)}function Je(){Z=j(this.value),i(11,Z)}function Lt(){W=j(this.value),i(12,W)}function mn(){ee=j(this.value),i(13,ee)}function Ue(){ae=j(this.value),i(14,ae)}function wn(){y=j(this.value),i(15,y)}function Et(){U=j(this.value),i(16,U)}function vn(){ue=this.checked,i(19,ue)}function qe(){H=this.checked,i(20,H)}function yn(){J=this.checked,i(24,J)}function Qe(){w=di(this),i(23,w),i(41,_)}function St(){x=j(this.value),i(21,x)}function kn(){K=j(this.value),i(22,K)}function We(){S=this.value,i(31,S)}function zn(){ke=di(this),i(33,ke),i(44,I)}function Ct(){ze=di(this),i(34,ze),i(45,k)}function Ln(){fe=j(this.value),i(35,fe)}function Ne(){Se=j(this.value),i(36,Se)}function Xt(){Le=j(this.value),i(37,Le)}function Yt(){Me=j(this.value),i(38,Me)}function Kt(){he=j(this.value),i(39,he)}return e.$$set=M=>{"onMessage"in M&&i(53,G=M.onMessage)},e.$$.update=()=>{var M,Be,Re,ut,Jt,ct,Qt,dt,Pt,Zt,ft,xt,ht,Tt,$t,De,pt,en,bt,tn,gt,Mt;e.$$.dirty[0]&3&&(r[s],Ee(),te()),e.$$.dirty[0]&7&&((M=r[s])==null||M.setResizable(O)),e.$$.dirty[0]&11&&((Be=r[s])==null||Be.setMaximizable(N)),e.$$.dirty[0]&19&&((Re=r[s])==null||Re.setMinimizable(oe)),e.$$.dirty[0]&35&&((ut=r[s])==null||ut.setClosable(D)),e.$$.dirty[0]&67&&(R?(Jt=r[s])==null||Jt.maximize():(ct=r[s])==null||ct.unmaximize()),e.$$.dirty[0]&131&&((Qt=r[s])==null||Qt.setDecorations(B)),e.$$.dirty[0]&259&&((dt=r[s])==null||dt.setAlwaysOnTop(V)),e.$$.dirty[0]&515&&((Pt=r[s])==null||Pt.setContentProtected(P)),e.$$.dirty[0]&1027&&((Zt=r[s])==null||Zt.setFullscreen(F)),e.$$.dirty[0]&6147&&Z&&W&&((ft=r[s])==null||ft.setSize(new rt(Z,W))),e.$$.dirty[0]&24579&&(ee&&ae?(xt=r[s])==null||xt.setMinSize(new un(ee,ae)):(ht=r[s])==null||ht.setMinSize(null)),e.$$.dirty[0]&98307&&(y>800&&U>400?(Tt=r[s])==null||Tt.setMaxSize(new un(y,U)):($t=r[s])==null||$t.setMaxSize(null)),e.$$.dirty[0]&393219&&q!==null&&X!==null&&((De=r[s])==null||De.setPosition(new Ye(q,X))),e.$$.dirty[0]&3&&((pt=r[s])==null||pt.scaleFactor().then(En=>i(26,ye=En))),e.$$.dirty[0]&3&&ge(r[s]),e.$$.dirty[0]&524291&&((en=r[s])==null||en.setCursorGrab(ue)),e.$$.dirty[0]&1048579&&((bt=r[s])==null||bt.setCursorVisible(H)),e.$$.dirty[0]&8388611&&((tn=r[s])==null||tn.setCursorIcon(w)),e.$$.dirty[0]&6291459&&x!==null&&K!==null&&((gt=r[s])==null||gt.setCursorPosition(new Ye(x,K))),e.$$.dirty[0]&16777219&&((Mt=r[s])==null||Mt.setIgnoreCursorEvents(J))},[s,r,O,N,oe,D,R,B,V,P,F,Z,W,ee,ae,y,U,q,X,ue,H,x,K,w,J,C,ye,le,ce,_e,de,S,se,ke,ze,fe,Se,Le,Me,he,me,_,b,d,I,k,Fe,je,pe,Ce,we,ne,z,G,Q,T,Pe,fn,Ae,hn,Ke,kt,pn,Ie,bn,zt,gn,Oe,_n,Je,Lt,mn,Ue,wn,Et,vn,qe,yn,Qe,St,kn,We,zn,Ct,Ln,Ne,Xt,Yt,Kt]}class zo extends Gt{constructor(t){super(),Vt(this,t,ko,yo,yt,{onMessage:53},null,[-1,-1,-1,-1])}}function Lo(e){let t;return{c(){t=o("div"),t.innerHTML='
Not available for Linux
',a(t,"class","flex flex-col gap-2")},m(i,l){v(i,t,l)},p:$,i:$,o:$,d(i){i&&m(t)}}}function Eo(e,t,i){let{onMessage:l}=t;const s=window.constraints={audio:!0,video:!0};function r(f){const b=document.querySelector("video"),d=f.getVideoTracks();l("Got stream with constraints:",s),l(`Using video device: ${d[0].label}`),window.stream=f,b.srcObject=f}function _(f){if(f.name==="ConstraintNotSatisfiedError"){const b=s.video;l(`The resolution ${b.width.exact}x${b.height.exact} px is not supported by your device.`)}else f.name==="PermissionDeniedError"&&l("Permissions have not been granted to use your camera and microphone, you need to allow the page access to your devices in order for the demo to work.");l(`getUserMedia error: ${f.name}`,f)}return pi(async()=>{try{const f=await navigator.mediaDevices.getUserMedia(s);r(f)}catch(f){_(f)}}),vs(()=>{window.stream.getTracks().forEach(function(f){f.stop()})}),e.$$set=f=>{"onMessage"in f&&i(0,l=f.onMessage)},[l]}class So extends Gt{constructor(t){super(),Vt(this,t,Eo,Lo,yt,{onMessage:0})}}function Co(e){let t,i,l,s,r,_;return{c(){t=o("div"),i=o("button"),i.textContent="Show",l=c(),s=o("button"),s.textContent="Hide",a(i,"class","btn"),a(i,"id","show"),a(i,"title","Hides and shows the app after 2 seconds"),a(s,"class","btn"),a(s,"id","hide")},m(f,b){v(f,t,b),n(t,i),n(t,l),n(t,s),r||(_=[L(i,"click",e[0]),L(s,"click",e[1])],r=!0)},p:$,i:$,o:$,d(f){f&&m(t),r=!1,He(_)}}}function Po(e,t,i){let{onMessage:l}=t;function s(){r().then(()=>{setTimeout(()=>{Ps().then(()=>l("Shown app")).catch(l)},2e3)}).catch(l)}function r(){return Ts().then(()=>l("Hide app")).catch(l)}return e.$$set=_=>{"onMessage"in _&&i(2,l=_.onMessage)},[s,r,l]}class To extends Gt{constructor(t){super(),Vt(this,t,Po,Co,yt,{onMessage:2})}}function ds(e,t,i){const l=e.slice();return l[25]=t[i],l}function fs(e,t,i){const l=e.slice();return l[28]=t[i],l}function Mo(e){let t;return{c(){t=o("span"),a(t,"class","i-codicon-menu animate-duration-300ms animate-fade-in")},m(i,l){v(i,t,l)},d(i){i&&m(t)}}}function Ao(e){let t;return{c(){t=o("span"),a(t,"class","i-codicon-close animate-duration-300ms animate-fade-in")},m(i,l){v(i,t,l)},d(i){i&&m(t)}}}function Io(e){let t,i;return{c(){t=p(`Switch to Dark mode - `),i=o("div"),a(i,"class","i-ph-moon")},m(l,s){v(l,t,s),v(l,i,s)},d(l){l&&(m(t),m(i))}}}function Oo(e){let t,i;return{c(){t=p(`Switch to Light mode - `),i=o("div"),a(i,"class","i-ph-sun")},m(l,s){v(l,t,s),v(l,i,s)},d(l){l&&(m(t),m(i))}}}function Wo(e){let t,i,l,s,r,_,f;function b(){return e[14](e[28])}return{c(){t=o("a"),i=o("div"),l=c(),s=o("p"),s.textContent=`${e[28].label}`,a(i,"class",e[28].icon+" mr-2"),a(t,"href","##"),a(t,"class",r="nv "+(e[1]===e[28]?"nv_selected":""))},m(d,I){v(d,t,I),n(t,i),n(t,l),n(t,s),_||(f=L(t,"click",b),_=!0)},p(d,I){e=d,I&2&&r!==(r="nv "+(e[1]===e[28]?"nv_selected":""))&&a(t,"class",r)},d(d){d&&m(t),_=!1,f()}}}function hs(e){let t,i=e[28]&&Wo(e);return{c(){i&&i.c(),t=Qi()},m(l,s){i&&i.m(l,s),v(l,t,s)},p(l,s){l[28]&&i.p(l,s)},d(l){l&&m(t),i&&i.d(l)}}}function ps(e){let t,i=e[25].html+"",l;return{c(){t=new Vs(!1),l=Qi(),t.a=l},m(s,r){t.m(i,s,r),v(s,l,r)},p(s,r){r&16&&i!==(i=s[25].html+"")&&t.p(i)},d(s){s&&(m(l),t.d())}}}function No(e){let t,i,l,s,r,_,f,b,d,I,k,G,E,C,O,N,oe,D,R,B,V,P,F,Z,W,ee,ae,y,U,q,X,ye,le=e[1].label+"",ce,_e,de,re,Y,ue,H,x,K,w,J,S,se,ke,ze,fe,Se,Le;function Me(z,Q){return z[0]?Ao:Mo}let he=Me(e),me=he(e);function Fe(z,Q){return z[2]?Oo:Io}let je=Fe(e),pe=je(e),Ce=Te(e[5]),te=[];for(let z=0;z`,oe=c(),D=o("a"),D.innerHTML=`GitHub - `,R=c(),B=o("a"),B.innerHTML=`Source - `,V=c(),P=o("br"),F=c(),Z=o("div"),W=c(),ee=o("br"),ae=c(),y=o("div");for(let z=0;z',ke=c(),ze=o("div");for(let z=0;z{Ji(T,1)}),Qs()}Ee?(Y=Jl(Ee,ge(z)),xl(Y.$$.fragment),Yi(Y.$$.fragment,1),Ki(Y,re,null)):Y=null}if(Q&16){we=Te(z[4]);let T;for(T=0;T{y.ctrlKey&&y.key==="b"&&g("toggle_menu")});const s=navigator.userAgent.toLowerCase(),r=s.includes("android")||s.includes("iphone"),_=[{label:"Welcome",component:uo,icon:"i-ph-hand-waving"},{label:"Communication",component:po,icon:"i-codicon-radio-tower"},!r&&{label:"App",component:To,icon:"i-codicon-hubot"},{label:"Window",component:zo,icon:"i-codicon-window"},{label:"WebRTC",component:So,icon:"i-ph-broadcast"}];let f=_[0];function b(y){i(1,f=y)}let d;pi(()=>{i(2,d=localStorage&&localStorage.getItem("theme")=="dark"),gs(d)});function I(){i(2,d=!d),gs(d)}let k=$s([]);Fs(e,k,y=>i(4,l=y));function G(y){k.update(U=>[{html:`
[${new Date().toLocaleTimeString()}]: `+(typeof y=="string"?y:JSON.stringify(y,null,1))+"
"},...U])}function E(y){k.update(U=>[{html:`
[${new Date().toLocaleTimeString()}]: `+y+"
"},...U])}function C(){k.update(()=>[])}let O,N,oe;function D(y){oe=y.clientY;const U=window.getComputedStyle(O);N=parseInt(U.height,10);const q=ye=>{const le=ye.clientY-oe,ce=N-le;i(3,O.style.height=`${ce{document.removeEventListener("mouseup",X),document.removeEventListener("mousemove",q)};document.addEventListener("mouseup",X),document.addEventListener("mousemove",q)}let R=!1,B,V,P=!1,F=0,Z=0;const W=(y,U,q)=>Math.min(Math.max(U,y),q);pi(()=>{i(13,B=document.querySelector("#sidebar")),V=document.querySelector("#sidebarToggle"),document.addEventListener("click",y=>{V.contains(y.target)?i(0,R=!R):R&&!B.contains(y.target)&&i(0,R=!1)}),document.addEventListener("touchstart",y=>{if(V.contains(y.target))return;const U=y.touches[0].clientX;(0{if(P){const U=y.touches[0].clientX;Z=U;const q=(U-F)/10;B.style.setProperty("--translate-x",`-${W(0,R?0-q:18.75-q,18.75)}rem`)}}),document.addEventListener("touchend",()=>{if(P){const y=(Z-F)/10;i(0,R=R?y>-(18.75/2):y>18.75/2)}P=!1})});const ee=y=>{b(y),i(0,R=!1)};function ae(y){Gi[y?"unshift":"push"](()=>{O=y,i(3,O)})}return e.$$.update=()=>{if(e.$$.dirty&1){const y=document.querySelector("#sidebar");y&&Ro(y,R)}},[R,f,d,O,l,_,b,I,k,G,E,C,D,B,ee,ae]}class Ho extends Gt{constructor(t){super(),Vt(this,t,Do,No,yt,{})}}new Ho({target:document.querySelector("#app")}); + tests.`,l=c(),s=o("br"),r=c(),_=o("br"),h=c(),b=o("pre"),d=p(" App name: "),I=o("code"),k=p(e[2]),K=p(` + App version: `),E=o("code"),M=p(e[0]),A=p(` + Tauri version: `),W=o("code"),se=p(e[1]),H=p(` + `),R=c(),V=o("br"),G=c(),P=o("button"),P.textContent="Context menu",a(P,"class","btn")},m(O,Z){w(O,t,Z),n(t,i),n(t,l),n(t,s),n(t,r),n(t,_),n(t,h),n(t,b),n(b,d),n(b,I),n(I,k),n(b,K),n(b,E),n(E,M),n(b,A),n(b,W),n(W,se),n(b,H),n(t,R),n(t,V),n(t,G),n(t,P),j||(oe=z(P,"click",e[3]),j=!0)},p(O,[Z]){Z&4&&ne(k,O[2]),Z&1&&ne(M,O[0]),Z&2&&ne(se,O[1])},i:$,o:$,d(O){O&&m(t),j=!1,oe()}}}function Lo(e,t,i){let l="1.0.0",s="1.0.0",r="Unknown";Fs().then(h=>{i(2,r=h)}),qs().then(h=>{i(0,l=h)}),js().then(h=>{i(1,s=h)});function _(){g("popup_context_menu")}return[l,s,r,_]}class Eo extends $t{constructor(t){super(),xt(this,t,Lo,zo,Ct,{})}}var So={};Ln(So,{TauriEvent:()=>Gs,emit:()=>dl,listen:()=>Mi,once:()=>Ys});var Gs=(e=>(e.WINDOW_RESIZED="tauri://resize",e.WINDOW_MOVED="tauri://move",e.WINDOW_CLOSE_REQUESTED="tauri://close-requested",e.WINDOW_CREATED="tauri://window-created",e.WINDOW_DESTROYED="tauri://destroyed",e.WINDOW_FOCUS="tauri://focus",e.WINDOW_BLUR="tauri://blur",e.WINDOW_SCALE_FACTOR_CHANGED="tauri://scale-change",e.WINDOW_THEME_CHANGED="tauri://theme-changed",e.WINDOW_FILE_DROP="tauri://file-drop",e.WINDOW_FILE_DROP_HOVER="tauri://file-drop-hover",e.WINDOW_FILE_DROP_CANCELLED="tauri://file-drop-cancelled",e.MENU="tauri://menu",e))(Gs||{});async function Xs(e,t){await g("plugin:event|unlisten",{event:e,eventId:t})}async function Mi(e,t,i){return g("plugin:event|listen",{event:e,windowLabel:i==null?void 0:i.target,handler:cl(t)}).then(l=>async()=>Xs(e,l))}async function Ys(e,t,i){return Mi(e,l=>{t(l),Xs(e,l.id).catch(()=>{})},i)}async function dl(e,t,i){await g("plugin:event|emit",{event:e,windowLabel:i==null?void 0:i.target,payload:t})}function Co(e){let t,i,l,s,r,_,h,b;return{c(){t=o("div"),i=o("button"),i.textContent="Call Log API",l=c(),s=o("button"),s.textContent="Call Request (async) API",r=c(),_=o("button"),_.textContent="Send event to Rust",a(i,"class","btn"),a(i,"id","log"),a(s,"class","btn"),a(s,"id","request"),a(_,"class","btn"),a(_,"id","event")},m(d,I){w(d,t,I),n(t,i),n(t,l),n(t,s),n(t,r),n(t,_),h||(b=[z(i,"click",e[0]),z(s,"click",e[1]),z(_,"click",e[2])],h=!0)},p:$,i:$,o:$,d(d){d&&m(t),h=!1,Fe(b)}}}function Po(e,t,i){let{onMessage:l}=t,s;Ci(async()=>{s=await Mi("rust-event",l)}),Ws(()=>{s&&s()});function r(){g("log_operation",{event:"tauri-click",payload:"this payload is optional because we used Option in Rust"})}function _(){g("perform_request",{endpoint:"dummy endpoint arg",body:{id:5,name:"test"}}).then(l).catch(l)}function h(){dl("js-event","this is the payload string")}return e.$$set=b=>{"onMessage"in b&&i(3,l=b.onMessage)},[r,_,h,l]}class To extends $t{constructor(t){super(),xt(this,t,Po,Co,Ct,{onMessage:3})}}var Mo={};Ln(Mo,{LogicalPosition:()=>fl,LogicalSize:()=>zn,PhysicalPosition:()=>Ze,PhysicalSize:()=>ht});var zn=class{constructor(e,t){this.type="Logical",this.width=e,this.height=t}},ht=class{constructor(e,t){this.type="Physical",this.width=e,this.height=t}toLogical(e){return new zn(this.width/e,this.height/e)}},fl=class{constructor(t,i){this.type="Logical",this.x=t,this.y=i}},Ze=class{constructor(e,t){this.type="Physical",this.x=e,this.y=t}toLogical(e){return new fl(this.x/e,this.y/e)}},Ao={};Ln(Ao,{CloseRequestedEvent:()=>Ks,Effect:()=>Pi,EffectState:()=>Ti,LogicalPosition:()=>fl,LogicalSize:()=>zn,PhysicalPosition:()=>Ze,PhysicalSize:()=>ht,ProgressBarStatus:()=>yn,UserAttentionType:()=>hl,Window:()=>En,availableMonitors:()=>No,currentMonitor:()=>Io,getAll:()=>Si,getCurrent:()=>pl,primaryMonitor:()=>Oo});var hl=(e=>(e[e.Critical=1]="Critical",e[e.Informational=2]="Informational",e))(hl||{}),Ks=class{constructor(e){this._preventDefault=!1,this.event=e.event,this.windowLabel=e.windowLabel,this.id=e.id}preventDefault(){this._preventDefault=!0}isPreventDefault(){return this._preventDefault}},yn=(e=>(e.None="none",e.Normal="normal",e.Indeterminate="indeterminate",e.Paused="paused",e.Error="error",e))(yn||{});function pl(){return new En(window.__TAURI_INTERNALS__.metadata.currentWindow.label,{skip:!0})}function Si(){return window.__TAURI_INTERNALS__.metadata.windows.map(e=>new En(e.label,{skip:!0}))}var hs=["tauri://created","tauri://error"],En=class{constructor(e,t={}){this.label=e,this.listeners=Object.create(null),t!=null&&t.skip||g("plugin:window|create",{options:{...t,label:e}}).then(async()=>this.emit("tauri://created")).catch(async i=>this.emit("tauri://error",i))}static getByLabel(e){return Si().some(t=>t.label===e)?new En(e,{skip:!0}):null}static getCurrent(){return pl()}static getAll(){return Si()}static async getFocusedWindow(){for(let e of Si())if(await e.isFocused())return e;return null}async listen(e,t){return this._handleTauriEvent(e,t)?Promise.resolve(()=>{let i=this.listeners[e];i.splice(i.indexOf(t),1)}):Mi(e,t,{target:this.label})}async once(e,t){return this._handleTauriEvent(e,t)?Promise.resolve(()=>{let i=this.listeners[e];i.splice(i.indexOf(t),1)}):Ys(e,t,{target:this.label})}async emit(e,t){if(hs.includes(e)){for(let i of this.listeners[e]||[])i({event:e,id:-1,windowLabel:this.label,payload:t});return Promise.resolve()}return dl(e,t,{target:this.label})}_handleTauriEvent(e,t){return hs.includes(e)?(e in this.listeners?this.listeners[e].push(t):this.listeners[e]=[t],!0):!1}async scaleFactor(){return g("plugin:window|scale_factor",{label:this.label})}async innerPosition(){return g("plugin:window|inner_position",{label:this.label}).then(({x:e,y:t})=>new Ze(e,t))}async outerPosition(){return g("plugin:window|outer_position",{label:this.label}).then(({x:e,y:t})=>new Ze(e,t))}async innerSize(){return g("plugin:window|inner_size",{label:this.label}).then(({width:e,height:t})=>new ht(e,t))}async outerSize(){return g("plugin:window|outer_size",{label:this.label}).then(({width:e,height:t})=>new ht(e,t))}async isFullscreen(){return g("plugin:window|is_fullscreen",{label:this.label})}async isMinimized(){return g("plugin:window|is_minimized",{label:this.label})}async isMaximized(){return g("plugin:window|is_maximized",{label:this.label})}async isFocused(){return g("plugin:window|is_focused",{label:this.label})}async isDecorated(){return g("plugin:window|is_decorated",{label:this.label})}async isResizable(){return g("plugin:window|is_resizable",{label:this.label})}async isMaximizable(){return g("plugin:window|is_maximizable",{label:this.label})}async isMinimizable(){return g("plugin:window|is_minimizable",{label:this.label})}async isClosable(){return g("plugin:window|is_closable",{label:this.label})}async isVisible(){return g("plugin:window|is_visible",{label:this.label})}async title(){return g("plugin:window|title",{label:this.label})}async theme(){return g("plugin:window|theme",{label:this.label})}async center(){return g("plugin:window|center",{label:this.label})}async requestUserAttention(e){let t=null;return e&&(e===1?t={type:"Critical"}:t={type:"Informational"}),g("plugin:window|request_user_attention",{label:this.label,value:t})}async setResizable(e){return g("plugin:window|set_resizable",{label:this.label,value:e})}async setMaximizable(e){return g("plugin:window|set_maximizable",{label:this.label,value:e})}async setMinimizable(e){return g("plugin:window|set_minimizable",{label:this.label,value:e})}async setClosable(e){return g("plugin:window|set_closable",{label:this.label,value:e})}async setTitle(e){return g("plugin:window|set_title",{label:this.label,value:e})}async maximize(){return g("plugin:window|maximize",{label:this.label})}async unmaximize(){return g("plugin:window|unmaximize",{label:this.label})}async toggleMaximize(){return g("plugin:window|toggle_maximize",{label:this.label})}async minimize(){return g("plugin:window|minimize",{label:this.label})}async unminimize(){return g("plugin:window|unminimize",{label:this.label})}async show(){return g("plugin:window|show",{label:this.label})}async hide(){return g("plugin:window|hide",{label:this.label})}async close(){return g("plugin:window|close",{label:this.label})}async setDecorations(e){return g("plugin:window|set_decorations",{label:this.label,value:e})}async setShadow(e){return g("plugin:window|set_shadow",{label:this.label,value:e})}async setEffects(e){return g("plugin:window|set_effects",{label:this.label,value:e})}async clearEffects(){return g("plugin:window|set_effects",{label:this.label,value:null})}async setAlwaysOnTop(e){return g("plugin:window|set_always_on_top",{label:this.label,value:e})}async setContentProtected(e){return g("plugin:window|set_content_protected",{label:this.label,value:e})}async setSize(e){if(!e||e.type!=="Logical"&&e.type!=="Physical")throw new Error("the `size` argument must be either a LogicalSize or a PhysicalSize instance");return g("plugin:window|set_size",{label:this.label,value:{type:e.type,data:{width:e.width,height:e.height}}})}async setMinSize(e){if(e&&e.type!=="Logical"&&e.type!=="Physical")throw new Error("the `size` argument must be either a LogicalSize or a PhysicalSize instance");return g("plugin:window|set_min_size",{label:this.label,value:e?{type:e.type,data:{width:e.width,height:e.height}}:null})}async setMaxSize(e){if(e&&e.type!=="Logical"&&e.type!=="Physical")throw new Error("the `size` argument must be either a LogicalSize or a PhysicalSize instance");return g("plugin:window|set_max_size",{label:this.label,value:e?{type:e.type,data:{width:e.width,height:e.height}}:null})}async setPosition(e){if(!e||e.type!=="Logical"&&e.type!=="Physical")throw new Error("the `position` argument must be either a LogicalPosition or a PhysicalPosition instance");return g("plugin:window|set_position",{label:this.label,value:{type:e.type,data:{x:e.x,y:e.y}}})}async setFullscreen(e){return g("plugin:window|set_fullscreen",{label:this.label,value:e})}async setFocus(){return g("plugin:window|set_focus",{label:this.label})}async setIcon(e){return g("plugin:window|set_icon",{label:this.label,value:typeof e=="string"?e:Array.from(e)})}async setSkipTaskbar(e){return g("plugin:window|set_skip_taskbar",{label:this.label,value:e})}async setCursorGrab(e){return g("plugin:window|set_cursor_grab",{label:this.label,value:e})}async setCursorVisible(e){return g("plugin:window|set_cursor_visible",{label:this.label,value:e})}async setCursorIcon(e){return g("plugin:window|set_cursor_icon",{label:this.label,value:e})}async setCursorPosition(e){if(!e||e.type!=="Logical"&&e.type!=="Physical")throw new Error("the `position` argument must be either a LogicalPosition or a PhysicalPosition instance");return g("plugin:window|set_cursor_position",{label:this.label,value:{type:e.type,data:{x:e.x,y:e.y}}})}async setIgnoreCursorEvents(e){return g("plugin:window|set_ignore_cursor_events",{label:this.label,value:e})}async startDragging(){return g("plugin:window|start_dragging",{label:this.label})}async setProgressBar(e){return g("plugin:window|set_progress_bar",{label:this.label,value:e})}async onResized(e){return this.listen("tauri://resize",t=>{t.payload=Qs(t.payload),e(t)})}async onMoved(e){return this.listen("tauri://move",t=>{t.payload=Js(t.payload),e(t)})}async onCloseRequested(e){return this.listen("tauri://close-requested",t=>{let i=new Ks(t);Promise.resolve(e(i)).then(()=>{if(!i.isPreventDefault())return this.close()})})}async onFocusChanged(e){let t=await this.listen("tauri://focus",l=>{e({...l,payload:!0})}),i=await this.listen("tauri://blur",l=>{e({...l,payload:!1})});return()=>{t(),i()}}async onScaleChanged(e){return this.listen("tauri://scale-change",e)}async onMenuClicked(e){return this.listen("tauri://menu",e)}async onFileDropEvent(e){let t=await this.listen("tauri://file-drop",s=>{e({...s,payload:{type:"drop",paths:s.payload}})}),i=await this.listen("tauri://file-drop-hover",s=>{e({...s,payload:{type:"hover",paths:s.payload}})}),l=await this.listen("tauri://file-drop-cancelled",s=>{e({...s,payload:{type:"cancel"}})});return()=>{t(),i(),l()}}async onThemeChanged(e){return this.listen("tauri://theme-changed",e)}},Pi=(e=>(e.AppearanceBased="appearanceBased",e.Light="light",e.Dark="dark",e.MediumLight="mediumLight",e.UltraDark="ultraDark",e.Titlebar="titlebar",e.Selection="selection",e.Menu="menu",e.Popover="popover",e.Sidebar="sidebar",e.HeaderView="headerView",e.Sheet="sheet",e.WindowBackground="windowBackground",e.HudWindow="hudWindow",e.FullScreenUI="fullScreenUI",e.Tooltip="tooltip",e.ContentBackground="contentBackground",e.UnderWindowBackground="underWindowBackground",e.UnderPageBackground="underPageBackground",e.Mica="mica",e.Blur="blur",e.Acrylic="acrylic",e.Tabbed="tabbed",e.TabbedDark="tabbedDark",e.TabbedLight="tabbedLight",e))(Pi||{}),Ti=(e=>(e.FollowsWindowActiveState="followsWindowActiveState",e.Active="active",e.Inactive="inactive",e))(Ti||{});function bl(e){return e===null?null:{name:e.name,scaleFactor:e.scaleFactor,position:Js(e.position),size:Qs(e.size)}}function Js(e){return new Ze(e.x,e.y)}function Qs(e){return new ht(e.width,e.height)}async function Io(){return g("plugin:window|current_monitor").then(bl)}async function Oo(){return g("plugin:window|primary_monitor").then(bl)}async function No(){return g("plugin:window|available_monitors").then(e=>e.map(bl))}function ps(e,t,i){const l=e.slice();return l[103]=t[i],l}function bs(e,t,i){const l=e.slice();return l[106]=t[i],l}function gs(e,t,i){const l=e.slice();return l[109]=t[i],l}function _s(e,t,i){const l=e.slice();return l[112]=t[i],l}function ms(e,t,i){const l=e.slice();return l[115]=t[i],l}function ws(e){let t,i,l,s,r,_,h=Ee(Object.keys(e[1])),b=[];for(let d=0;de[58].call(l))},m(d,I){w(d,t,I),w(d,i,I),w(d,l,I),n(l,s);for(let k=0;ke[81].call(Je)),a(ut,"class","input"),a(ut,"type","number"),a(ct,"class","input"),a(ct,"type","number"),a(Ke,"class","flex gap-2"),a(dt,"class","input grow"),a(dt,"id","title"),a(bn,"class","btn"),a(bn,"type","submit"),a(zt,"class","flex gap-1"),a(pn,"class","flex flex-col gap-1"),a(Qe,"class","input"),e[25]===void 0&&pt(()=>e[85].call(Qe)),a(Ge,"class","input"),a(Ge,"type","number"),a(Ge,"min","0"),a(Ge,"max","100"),a(Vt,"class","flex gap-2"),a(gn,"class","flex flex-col gap-1")},m(u,f){w(u,t,f),w(u,i,f),w(u,l,f),n(l,s),n(l,r),n(l,_),n(_,h),C(h,e[42]),n(_,b),n(_,d),w(u,I,f),w(u,k,f),w(u,K,f),w(u,E,f),n(E,M),n(E,A),n(E,W),n(E,se),n(E,H),n(E,R),n(E,V),w(u,G,f),w(u,P,f),n(P,j),n(j,oe),n(j,O),O.checked=e[6],n(P,Z),n(P,ae),n(ae,y),n(ae,q),q.checked=e[2],n(P,B),n(P,X),n(X,re),n(X,ie),ie.checked=e[3],n(P,_e),n(P,ve),n(ve,ue),n(ve,ce),ce.checked=e[4],n(P,Y),n(P,he),n(he,U),n(he,ee),ee.checked=e[5],n(P,J),n(P,v),n(v,Q),n(v,S),S.checked=e[7],n(P,de),n(P,ze),n(ze,Le),n(ze,pe),pe.checked=e[8],n(P,Oe),n(P,Se),n(Se,Ne),n(Se,be),be.checked=e[9],n(P,ge),n(P,Ce),n(Ce,Pe),n(Ce,fe),fe.checked=e[10],w(u,Te,f),w(u,le,f),w(u,Me,f),w(u,me,f),n(me,we),n(we,te),n(te,L),n(te,x),C(x,e[17]),n(we,T),n(we,Ae),n(Ae,Sn),n(Ae,We),C(We,e[18]),n(me,Cn),n(me,xe),n(xe,Pt),n(Pt,Pn),n(Pt,Re),C(Re,e[11]),n(xe,Tn),n(xe,Tt),n(Tt,Mn),n(Tt,De),C(De,e[12]),n(me,An),n(me,$e),n($e,Mt),n(Mt,In),n(Mt,je),C(je,e[13]),n($e,On),n($e,At),n(At,Nn),n(At,Be),C(Be,e[14]),n(me,Wn),n(me,et),n(et,It),n(It,Rn),n(It,He),C(He,e[15]),n(et,Dn),n(et,Ot),n(Ot,Hn),n(Ot,Ue),C(Ue,e[16]),w(u,en,f),w(u,tn,f),w(u,nn,f),w(u,Ie,f),n(Ie,tt),n(tt,Ve),n(Ve,Nt),n(Ve,Un),n(Ve,N),n(N,ln),n(N,Wt),n(Ve,sn),n(Ve,gt),n(gt,on),n(gt,Rt),n(tt,an),n(tt,qe),n(qe,mt),n(qe,rn),n(qe,wt),n(wt,un),n(wt,Dt),n(qe,cn),n(qe,yt),n(yt,dn),n(yt,Ht),n(Ie,fn),n(Ie,nt),n(nt,it),n(it,qn),n(it,gl),n(it,Fn),n(Fn,_l),n(Fn,Ai),n(it,ml),n(it,Bn),n(Bn,wl),n(Bn,Ii),n(nt,vl),n(nt,lt),n(lt,Gn),n(lt,yl),n(lt,Xn),n(Xn,kl),n(Xn,Oi),n(lt,zl),n(lt,Kn),n(Kn,Ll),n(Kn,Ni),n(Ie,El),n(Ie,Ut),n(Ut,st),n(st,Qn),n(st,Sl),n(st,Zn),n(Zn,Cl),n(Zn,Wi),n(st,Pl),n(st,$n),n($n,Tl),n($n,Ri),n(Ut,Ml),n(Ut,ot),n(ot,ti),n(ot,Al),n(ot,ni),n(ni,Il),n(ni,Di),n(ot,Ol),n(ot,li),n(li,Nl),n(li,Hi),n(Ie,Wl),n(Ie,qt),n(qt,at),n(at,oi),n(at,Rl),n(at,ai),n(ai,Dl),n(ai,Ui),n(at,Hl),n(at,ui),n(ui,Ul),n(ui,qi),n(qt,ql),n(qt,rt),n(rt,di),n(rt,Fl),n(rt,fi),n(fi,jl),n(fi,Fi),n(rt,Bl),n(rt,pi),n(pi,Vl),n(pi,ji),w(u,Bi,f),w(u,Vi,f),w(u,Gi,f),w(u,hn,f),w(u,Xi,f),w(u,Ye,f),n(Ye,gi),n(gi,Ft),Ft.checked=e[19],n(gi,Gl),n(Ye,Xl),n(Ye,_i),n(_i,jt),jt.checked=e[20],n(_i,Yl),n(Ye,Kl),n(Ye,mi),n(mi,Bt),Bt.checked=e[24],n(mi,Jl),w(u,Yi,f),w(u,Ke,f),n(Ke,wi),n(wi,Ql),n(wi,Je);for(let D=0;De[87].call(r)),a(d,"class","input"),e[36]===void 0&&pt(()=>e[88].call(d)),a(E,"class","input"),a(E,"type","number"),a(i,"class","flex"),Yt(R,"max-width","120px"),a(R,"class","input"),a(R,"type","number"),a(R,"placeholder","R"),Yt(G,"max-width","120px"),a(G,"class","input"),a(G,"type","number"),a(G,"placeholder","G"),Yt(j,"max-width","120px"),a(j,"class","input"),a(j,"type","number"),a(j,"placeholder","B"),Yt(O,"max-width","120px"),a(O,"class","input"),a(O,"type","number"),a(O,"placeholder","A"),a(H,"class","flex"),a(A,"class","flex"),a(y,"class","btn"),Yt(y,"width","80px"),a(ae,"class","flex"),a(ue,"class","btn"),Yt(ue,"width","80px"),a(B,"class","flex"),a(t,"class","flex flex-col gap-1")},m(v,Q){w(v,t,Q),n(t,i),n(i,l),n(l,s),n(l,r);for(let S=0;S=1,I,k,K,E=d&&ws(e),M=e[1][e[0]]&&ys(e);return{c(){t=o("div"),i=o("div"),l=o("input"),s=c(),r=o("button"),r.textContent="New window",_=c(),h=o("br"),b=c(),E&&E.c(),I=c(),M&&M.c(),a(l,"class","input grow"),a(l,"type","text"),a(l,"placeholder","New Window label.."),a(r,"class","btn"),a(i,"class","flex gap-1"),a(t,"class","flex flex-col children:grow gap-2")},m(A,W){w(A,t,W),n(t,i),n(i,l),C(l,e[27]),n(i,s),n(i,r),n(t,_),n(t,h),n(t,b),E&&E.m(t,null),n(t,I),M&&M.m(t,null),k||(K=[z(l,"input",e[57]),z(r,"click",e[52])],k=!0)},p(A,W){W[0]&134217728&&l.value!==A[27]&&C(l,A[27]),W[0]&2&&(d=Object.keys(A[1]).length>=1),d?E?E.p(A,W):(E=ws(A),E.c(),E.m(t,I)):E&&(E.d(1),E=null),A[1][A[0]]?M?M.p(A,W):(M=ys(A),M.c(),M.m(t,null)):M&&(M.d(1),M=null)},i:$,o:$,d(A){A&&m(t),E&&E.d(),M&&M.d(),k=!1,Fe(K)}}}function Do(e,t,i){const l=pl();let s=l.label;const r={[l.label]:l},_=["default","crosshair","hand","arrow","move","text","wait","help","progress","notAllowed","contextMenu","cell","verticalText","alias","copy","noDrop","grab","grabbing","allScroll","zoomIn","zoomOut","eResize","nResize","neResize","nwResize","sResize","seResize","swResize","wResize","ewResize","nsResize","neswResize","nwseResize","colResize","rowResize"],h=["mica","blur","acrylic","tabbed","tabbedDark","tabbedLight"],b=navigator.appVersion.includes("Windows"),d=navigator.appVersion.includes("Macintosh");let I=b?h:Object.keys(Pi).map(N=>Pi[N]).filter(N=>!h.includes(N));const k=Object.keys(Ti).map(N=>Ti[N]),K=Object.keys(yn).map(N=>yn[N]);let{onMessage:E}=t;const M=document.querySelector("main");let A,W=!0,se=!0,H=!0,R=!0,V=!1,G=!0,P=!1,j=!0,oe=!1,O=null,Z=null,ae=null,y=null,q=null,B=null,X=null,re=null,ie=1,_e=new Ze(X,re),ve=new Ze(X,re),ue=new ht(O,Z),ce=new ht(O,Z),Y,he,U=!1,ee=!0,J=null,v=null,Q="default",S=!1,de="Awesome Tauri Example!",ze=[],Le,pe,Oe,Se,Ne,be,ge,Ce="none",Pe=0,fe;function Te(){r[s].setTitle(de)}function le(){r[s].hide(),setTimeout(r[s].show,2e3)}function Me(){r[s].minimize(),setTimeout(r[s].unminimize,2e3)}function me(){if(!A)return;const N=new En(A);i(1,r[A]=N,r),N.once("tauri://error",function(){E("Error creating new webview")})}function we(){r[s].innerSize().then(N=>{i(31,ue=N),i(11,O=ue.width),i(12,Z=ue.height)}),r[s].outerSize().then(N=>{i(32,ce=N)})}function te(){r[s].innerPosition().then(N=>{i(29,_e=N)}),r[s].outerPosition().then(N=>{i(30,ve=N),i(17,X=ve.x),i(18,re=ve.y)})}async function L(N){N&&(Y&&Y(),he&&he(),he=await N.listen("tauri://move",te),Y=await N.listen("tauri://resize",we))}async function x(){await r[s].minimize(),await r[s].requestUserAttention(hl.Critical),await new Promise(N=>setTimeout(N,3e3)),await r[s].requestUserAttention(null)}async function T(){ze.includes(Le)||i(34,ze=[...ze,Le]);const N={effects:ze,state:pe,radius:Oe};Number.isInteger(Se)&&Number.isInteger(Ne)&&Number.isInteger(be)&&Number.isInteger(ge)&&(N.color=[Se,Ne,be,ge]),M.classList.remove("bg-primary"),M.classList.remove("dark:bg-darkPrimary"),await r[s].clearEffects(),await r[s].setEffects(N)}async function Ae(){i(34,ze=[]),await r[s].clearEffects(),M.classList.add("bg-primary"),M.classList.add("dark:bg-darkPrimary")}function Sn(){A=this.value,i(27,A)}function We(){s=mn(this),i(0,s),i(1,r)}function Cn(){fe=this.value,i(42,fe)}const xe=()=>r[s].center();function Pt(){V=this.checked,i(6,V)}function Pn(){W=this.checked,i(2,W)}function Re(){se=this.checked,i(3,se)}function Tn(){H=this.checked,i(4,H)}function Tt(){R=this.checked,i(5,R)}function Mn(){G=this.checked,i(7,G)}function De(){P=this.checked,i(8,P)}function An(){j=this.checked,i(9,j)}function $e(){oe=this.checked,i(10,oe)}function Mt(){X=F(this.value),i(17,X)}function In(){re=F(this.value),i(18,re)}function je(){O=F(this.value),i(11,O)}function On(){Z=F(this.value),i(12,Z)}function At(){ae=F(this.value),i(13,ae)}function Nn(){y=F(this.value),i(14,y)}function Be(){q=F(this.value),i(15,q)}function Wn(){B=F(this.value),i(16,B)}function et(){U=this.checked,i(19,U)}function It(){ee=this.checked,i(20,ee)}function Rn(){S=this.checked,i(24,S)}function He(){Q=mn(this),i(23,Q),i(43,_)}function Dn(){J=F(this.value),i(21,J)}function Ot(){v=F(this.value),i(22,v)}function Hn(){de=this.value,i(33,de)}function Ue(){Ce=mn(this),i(25,Ce),i(48,K)}function en(){Pe=F(this.value),i(26,Pe)}function tn(){Le=mn(this),i(35,Le),i(46,I)}function nn(){pe=mn(this),i(36,pe),i(47,k)}function Ie(){Oe=F(this.value),i(37,Oe)}function tt(){Se=F(this.value),i(38,Se)}function Ve(){Ne=F(this.value),i(39,Ne)}function Nt(){be=F(this.value),i(40,be)}function Un(){ge=F(this.value),i(41,ge)}return e.$$set=N=>{"onMessage"in N&&i(56,E=N.onMessage)},e.$$.update=()=>{var N,ln,bt,Wt,sn,gt,on,_t,Rt,an,qe,mt,rn,wt,un,vt,Dt,cn,yt,dn,kt,Ht,fn;e.$$.dirty[0]&3&&(r[s],te(),we()),e.$$.dirty[0]&7&&((N=r[s])==null||N.setResizable(W)),e.$$.dirty[0]&11&&((ln=r[s])==null||ln.setMaximizable(se)),e.$$.dirty[0]&19&&((bt=r[s])==null||bt.setMinimizable(H)),e.$$.dirty[0]&35&&((Wt=r[s])==null||Wt.setClosable(R)),e.$$.dirty[0]&67&&(V?(sn=r[s])==null||sn.maximize():(gt=r[s])==null||gt.unmaximize()),e.$$.dirty[0]&131&&((on=r[s])==null||on.setDecorations(G)),e.$$.dirty[0]&259&&((_t=r[s])==null||_t.setAlwaysOnTop(P)),e.$$.dirty[0]&515&&((Rt=r[s])==null||Rt.setContentProtected(j)),e.$$.dirty[0]&1027&&((an=r[s])==null||an.setFullscreen(oe)),e.$$.dirty[0]&6147&&O&&Z&&((qe=r[s])==null||qe.setSize(new ht(O,Z))),e.$$.dirty[0]&24579&&(ae&&y?(mt=r[s])==null||mt.setMinSize(new zn(ae,y)):(rn=r[s])==null||rn.setMinSize(null)),e.$$.dirty[0]&98307&&(q>800&&B>400?(wt=r[s])==null||wt.setMaxSize(new zn(q,B)):(un=r[s])==null||un.setMaxSize(null)),e.$$.dirty[0]&393219&&X!==null&&re!==null&&((vt=r[s])==null||vt.setPosition(new Ze(X,re))),e.$$.dirty[0]&3&&((Dt=r[s])==null||Dt.scaleFactor().then(nt=>i(28,ie=nt))),e.$$.dirty[0]&3&&L(r[s]),e.$$.dirty[0]&524291&&((cn=r[s])==null||cn.setCursorGrab(U)),e.$$.dirty[0]&1048579&&((yt=r[s])==null||yt.setCursorVisible(ee)),e.$$.dirty[0]&8388611&&((dn=r[s])==null||dn.setCursorIcon(Q)),e.$$.dirty[0]&6291459&&J!==null&&v!==null&&((kt=r[s])==null||kt.setCursorPosition(new Ze(J,v))),e.$$.dirty[0]&16777219&&((Ht=r[s])==null||Ht.setIgnoreCursorEvents(S)),e.$$.dirty[0]&100663299&&((fn=r[s])==null||fn.setProgressBar({status:yn[Ce],progress:Pe}))},[s,r,W,se,H,R,V,G,P,j,oe,O,Z,ae,y,q,B,X,re,U,ee,J,v,Q,S,Ce,Pe,A,ie,_e,ve,ue,ce,de,ze,Le,pe,Oe,Se,Ne,be,ge,fe,_,b,d,I,k,K,Te,le,Me,me,x,T,Ae,E,Sn,We,Cn,xe,Pt,Pn,Re,Tn,Tt,Mn,De,An,$e,Mt,In,je,On,At,Nn,Be,Wn,et,It,Rn,He,Dn,Ot,Hn,Ue,en,tn,nn,Ie,tt,Ve,Nt,Un]}class Ho extends $t{constructor(t){super(),xt(this,t,Do,Ro,Ct,{onMessage:56},null,[-1,-1,-1,-1])}}function Uo(e){let t;return{c(){t=o("div"),t.innerHTML='
Not available for Linux
',a(t,"class","flex flex-col gap-2")},m(i,l){w(i,t,l)},p:$,i:$,o:$,d(i){i&&m(t)}}}function qo(e,t,i){let{onMessage:l}=t;const s=window.constraints={audio:!0,video:!0};function r(h){const b=document.querySelector("video"),d=h.getVideoTracks();l("Got stream with constraints:",s),l(`Using video device: ${d[0].label}`),window.stream=h,b.srcObject=h}function _(h){if(h.name==="ConstraintNotSatisfiedError"){const b=s.video;l(`The resolution ${b.width.exact}x${b.height.exact} px is not supported by your device.`)}else h.name==="PermissionDeniedError"&&l("Permissions have not been granted to use your camera and microphone, you need to allow the page access to your devices in order for the demo to work.");l(`getUserMedia error: ${h.name}`,h)}return Ci(async()=>{try{const h=await navigator.mediaDevices.getUserMedia(s);r(h)}catch(h){_(h)}}),Ws(()=>{window.stream.getTracks().forEach(function(h){h.stop()})}),e.$$set=h=>{"onMessage"in h&&i(0,l=h.onMessage)},[l]}class Fo extends $t{constructor(t){super(),xt(this,t,qo,Uo,Ct,{onMessage:0})}}function jo(e){let t,i,l,s,r,_;return{c(){t=o("div"),i=o("button"),i.textContent="Show",l=c(),s=o("button"),s.textContent="Hide",a(i,"class","btn"),a(i,"id","show"),a(i,"title","Hides and shows the app after 2 seconds"),a(s,"class","btn"),a(s,"id","hide")},m(h,b){w(h,t,b),n(t,i),n(t,l),n(t,s),r||(_=[z(i,"click",e[0]),z(s,"click",e[1])],r=!0)},p:$,i:$,o:$,d(h){h&&m(t),r=!1,Fe(_)}}}function Bo(e,t,i){let{onMessage:l}=t;function s(){r().then(()=>{setTimeout(()=>{Bs().then(()=>l("Shown app")).catch(l)},2e3)}).catch(l)}function r(){return Vs().then(()=>l("Hide app")).catch(l)}return e.$$set=_=>{"onMessage"in _&&i(2,l=_.onMessage)},[s,r,l]}class Vo extends $t{constructor(t){super(),xt(this,t,Bo,jo,Ct,{onMessage:2})}}function Ss(e,t,i){const l=e.slice();return l[25]=t[i],l}function Cs(e,t,i){const l=e.slice();return l[28]=t[i],l}function Go(e){let t;return{c(){t=o("span"),a(t,"class","i-codicon-menu animate-duration-300ms animate-fade-in")},m(i,l){w(i,t,l)},d(i){i&&m(t)}}}function Xo(e){let t;return{c(){t=o("span"),a(t,"class","i-codicon-close animate-duration-300ms animate-fade-in")},m(i,l){w(i,t,l)},d(i){i&&m(t)}}}function Yo(e){let t,i;return{c(){t=p(`Switch to Dark mode + `),i=o("div"),a(i,"class","i-ph-moon")},m(l,s){w(l,t,s),w(l,i,s)},d(l){l&&(m(t),m(i))}}}function Ko(e){let t,i;return{c(){t=p(`Switch to Light mode + `),i=o("div"),a(i,"class","i-ph-sun")},m(l,s){w(l,t,s),w(l,i,s)},d(l){l&&(m(t),m(i))}}}function Jo(e){let t,i,l,s,r,_,h;function b(){return e[14](e[28])}return{c(){t=o("a"),i=o("div"),l=c(),s=o("p"),s.textContent=`${e[28].label}`,a(i,"class",e[28].icon+" mr-2"),a(t,"href","##"),a(t,"class",r="nv "+(e[1]===e[28]?"nv_selected":""))},m(d,I){w(d,t,I),n(t,i),n(t,l),n(t,s),_||(h=z(t,"click",b),_=!0)},p(d,I){e=d,I&2&&r!==(r="nv "+(e[1]===e[28]?"nv_selected":""))&&a(t,"class",r)},d(d){d&&m(t),_=!1,h()}}}function Ps(e){let t,i=e[28]&&Jo(e);return{c(){i&&i.c(),t=ul()},m(l,s){i&&i.m(l,s),w(l,t,s)},p(l,s){l[28]&&i.p(l,s)},d(l){l&&m(t),i&&i.d(l)}}}function Ts(e){let t,i=e[25].html+"",l;return{c(){t=new so(!1),l=ul(),t.a=l},m(s,r){t.m(i,s,r),w(s,l,r)},p(s,r){r&16&&i!==(i=s[25].html+"")&&t.p(i)},d(s){s&&(m(l),t.d())}}}function Qo(e){let t,i,l,s,r,_,h,b,d,I,k,K,E,M,A,W,se,H,R,V,G,P,j,oe,O,Z,ae,y,q,B,X,re,ie=e[1].label+"",_e,ve,ue,ce,Y,he,U,ee,J,v,Q,S,de,ze,Le,pe,Oe,Se;function Ne(L,x){return L[0]?Xo:Go}let be=Ne(e),ge=be(e);function Ce(L,x){return L[2]?Ko:Yo}let Pe=Ce(e),fe=Pe(e),Te=Ee(e[5]),le=[];for(let L=0;L`,se=c(),H=o("a"),H.innerHTML=`GitHub + `,R=c(),V=o("a"),V.innerHTML=`Source + `,G=c(),P=o("br"),j=c(),oe=o("div"),O=c(),Z=o("br"),ae=c(),y=o("div");for(let L=0;L',ze=c(),Le=o("div");for(let L=0;L{rl(T,1)}),fo()}Me?(Y=rs(Me,me(L)),ds(Y.$$.fragment),ol(Y.$$.fragment,1),al(Y,ce,null)):Y=null}if(x&16){we=Ee(L[4]);let T;for(T=0;T{y.ctrlKey&&y.key==="b"&&g("toggle_menu")});const s=navigator.userAgent.toLowerCase(),r=s.includes("android")||s.includes("iphone"),_=[{label:"Welcome",component:Eo,icon:"i-ph-hand-waving"},{label:"Communication",component:To,icon:"i-codicon-radio-tower"},!r&&{label:"App",component:Vo,icon:"i-codicon-hubot"},{label:"Window",component:Ho,icon:"i-codicon-window"},{label:"WebRTC",component:Fo,icon:"i-ph-broadcast"}];let h=_[0];function b(y){i(1,h=y)}let d;Ci(()=>{i(2,d=localStorage&&localStorage.getItem("theme")=="dark"),As(d)});function I(){i(2,d=!d),As(d)}let k=bo([]);no(e,k,y=>i(4,l=y));function K(y){k.update(q=>[{html:`
[${new Date().toLocaleTimeString()}]: `+(typeof y=="string"?y:JSON.stringify(y,null,1))+"
"},...q])}function E(y){k.update(q=>[{html:`
[${new Date().toLocaleTimeString()}]: `+y+"
"},...q])}function M(){k.update(()=>[])}let A,W,se;function H(y){se=y.clientY;const q=window.getComputedStyle(A);W=parseInt(q.height,10);const B=re=>{const ie=re.clientY-se,_e=W-ie;i(3,A.style.height=`${_e{document.removeEventListener("mouseup",X),document.removeEventListener("mousemove",B)};document.addEventListener("mouseup",X),document.addEventListener("mousemove",B)}let R=!1,V,G,P=!1,j=0,oe=0;const O=(y,q,B)=>Math.min(Math.max(q,y),B);Ci(()=>{i(13,V=document.querySelector("#sidebar")),G=document.querySelector("#sidebarToggle"),document.addEventListener("click",y=>{G.contains(y.target)?i(0,R=!R):R&&!V.contains(y.target)&&i(0,R=!1)}),document.addEventListener("touchstart",y=>{if(G.contains(y.target))return;const q=y.touches[0].clientX;(0{if(P){const q=y.touches[0].clientX;oe=q;const B=(q-j)/10;V.style.setProperty("--translate-x",`-${O(0,R?0-B:18.75-B,18.75)}rem`)}}),document.addEventListener("touchend",()=>{if(P){const y=(oe-j)/10;i(0,R=R?y>-(18.75/2):y>18.75/2)}P=!1})});const Z=y=>{b(y),i(0,R=!1)};function ae(y){ll[y?"unshift":"push"](()=>{A=y,i(3,A)})}return e.$$.update=()=>{if(e.$$.dirty&1){const y=document.querySelector("#sidebar");y&&Zo(y,R)}},[R,h,d,A,l,_,b,I,k,K,E,M,H,V,Z,ae]}class $o extends $t{constructor(t){super(),xt(this,t,xo,Qo,Ct,{})}}new $o({target:document.querySelector("#app")}); diff --git a/examples/api/src/views/Window.svelte b/examples/api/src/views/Window.svelte index f72b174a175e..646d238800e9 100644 --- a/examples/api/src/views/Window.svelte +++ b/examples/api/src/views/Window.svelte @@ -7,267 +7,281 @@ PhysicalPosition, Effect, EffectState, + ProgressBarStatus, Window - } from "@tauri-apps/api/window"; - import { invoke } from "@tauri-apps/api/primitives"; + } from '@tauri-apps/api/window' + import { invoke } from '@tauri-apps/api/primitives' - const appWindow = getCurrent(); + const appWindow = getCurrent() - let selectedWindow = appWindow.label; + let selectedWindow = appWindow.label const windowMap = { - [appWindow.label]: appWindow, - }; + [appWindow.label]: appWindow + } const cursorIconOptions = [ - "default", - "crosshair", - "hand", - "arrow", - "move", - "text", - "wait", - "help", - "progress", + 'default', + 'crosshair', + 'hand', + 'arrow', + 'move', + 'text', + 'wait', + 'help', + 'progress', // something cannot be done - "notAllowed", - "contextMenu", - "cell", - "verticalText", - "alias", - "copy", - "noDrop", + 'notAllowed', + 'contextMenu', + 'cell', + 'verticalText', + 'alias', + 'copy', + 'noDrop', // something can be grabbed - "grab", + 'grab', /// something is grabbed - "grabbing", - "allScroll", - "zoomIn", - "zoomOut", + 'grabbing', + 'allScroll', + 'zoomIn', + 'zoomOut', // edge is to be moved - "eResize", - "nResize", - "neResize", - "nwResize", - "sResize", - "seResize", - "swResize", - "wResize", - "ewResize", - "nsResize", - "neswResize", - "nwseResize", - "colResize", - "rowResize", - ]; - - const windowsEffects = ["mica", "blur", "acrylic", "tabbed", "tabbedDark", "tabbedLight"]; - const isWindows = navigator.appVersion.includes("Windows"); - const isMacOS = navigator.appVersion.includes("Macintosh"); + 'eResize', + 'nResize', + 'neResize', + 'nwResize', + 'sResize', + 'seResize', + 'swResize', + 'wResize', + 'ewResize', + 'nsResize', + 'neswResize', + 'nwseResize', + 'colResize', + 'rowResize' + ] + + const windowsEffects = [ + 'mica', + 'blur', + 'acrylic', + 'tabbed', + 'tabbedDark', + 'tabbedLight' + ] + const isWindows = navigator.appVersion.includes('Windows') + const isMacOS = navigator.appVersion.includes('Macintosh') let effectOptions = isWindows ? windowsEffects : Object.keys(Effect) .map((effect) => Effect[effect]) - .filter((e) => !windowsEffects.includes(e)); + .filter((e) => !windowsEffects.includes(e)) const effectStateOptions = Object.keys(EffectState).map( (state) => EffectState[state] - ); - - export let onMessage; - const mainEl = document.querySelector("main"); - - let newWindowLabel; - - let urlValue = "https://tauri.app"; - let resizable = true; - let maximizable = true; - let minimizable = true; - let closable = true; - let maximized = false; - let decorations = true; - let alwaysOnTop = false; - let contentProtected = true; - let fullscreen = false; - let width = null; - let height = null; - let minWidth = null; - let minHeight = null; - let maxWidth = null; - let maxHeight = null; - let x = null; - let y = null; - let scaleFactor = 1; - let innerPosition = new PhysicalPosition(x, y); - let outerPosition = new PhysicalPosition(x, y); - let innerSize = new PhysicalSize(width, height); - let outerSize = new PhysicalSize(width, height); - let resizeEventUnlisten; - let moveEventUnlisten; - let cursorGrab = false; - let cursorVisible = true; - let cursorX = null; - let cursorY = null; - let cursorIcon = "default"; - let cursorIgnoreEvents = false; - let windowTitle = "Awesome Tauri Example!"; - - let effects = []; - let selectedEffect; - let effectState; - let effectRadius; - let effectR, effectG, effectB, effectA; - - let windowIconPath; + ) + + const progressBarStatusOptions = Object.keys(ProgressBarStatus).map(s => ProgressBarStatus[s]) + + export let onMessage + const mainEl = document.querySelector('main') + + let newWindowLabel + + let urlValue = 'https://tauri.app' + let resizable = true + let maximizable = true + let minimizable = true + let closable = true + let maximized = false + let decorations = true + let alwaysOnTop = false + let contentProtected = true + let fullscreen = false + let width = null + let height = null + let minWidth = null + let minHeight = null + let maxWidth = null + let maxHeight = null + let x = null + let y = null + let scaleFactor = 1 + let innerPosition = new PhysicalPosition(x, y) + let outerPosition = new PhysicalPosition(x, y) + let innerSize = new PhysicalSize(width, height) + let outerSize = new PhysicalSize(width, height) + let resizeEventUnlisten + let moveEventUnlisten + let cursorGrab = false + let cursorVisible = true + let cursorX = null + let cursorY = null + let cursorIcon = 'default' + let cursorIgnoreEvents = false + let windowTitle = 'Awesome Tauri Example!' + + let effects = [] + let selectedEffect + let effectState + let effectRadius + let effectR, effectG, effectB, effectA + + let selectedProgressBarStatus = 'none' + let progress = 0 + + let windowIconPath function setTitle_() { - windowMap[selectedWindow].setTitle(windowTitle); + windowMap[selectedWindow].setTitle(windowTitle) } function hide_() { - windowMap[selectedWindow].hide(); - setTimeout(windowMap[selectedWindow].show, 2000); + windowMap[selectedWindow].hide() + setTimeout(windowMap[selectedWindow].show, 2000) } function minimize_() { - windowMap[selectedWindow].minimize(); - setTimeout(windowMap[selectedWindow].unminimize, 2000); + windowMap[selectedWindow].minimize() + setTimeout(windowMap[selectedWindow].unminimize, 2000) } function changeIcon() { - windowMap[selectedWindow].setIcon(path); + windowMap[selectedWindow].setIcon(path) } function createWindow() { - if (!newWindowLabel) return; + if (!newWindowLabel) return - const webview = new Window(newWindowLabel); - windowMap[newWindowLabel] = webview; - webview.once("tauri://error", function () { - onMessage("Error creating new webview"); - }); + const webview = new Window(newWindowLabel) + windowMap[newWindowLabel] = webview + webview.once('tauri://error', function () { + onMessage('Error creating new webview') + }) } function loadWindowSize() { windowMap[selectedWindow].innerSize().then((response) => { - innerSize = response; - width = innerSize.width; - height = innerSize.height; - }); + innerSize = response + width = innerSize.width + height = innerSize.height + }) windowMap[selectedWindow].outerSize().then((response) => { - outerSize = response; - }); + outerSize = response + }) } function loadWindowPosition() { windowMap[selectedWindow].innerPosition().then((response) => { - innerPosition = response; - }); + innerPosition = response + }) windowMap[selectedWindow].outerPosition().then((response) => { - outerPosition = response; - x = outerPosition.x; - y = outerPosition.y; - }); + outerPosition = response + x = outerPosition.x + y = outerPosition.y + }) } async function addWindowEventListeners(window) { - if (!window) return; + if (!window) return if (resizeEventUnlisten) { - resizeEventUnlisten(); + resizeEventUnlisten() } if (moveEventUnlisten) { - moveEventUnlisten(); + moveEventUnlisten() } - moveEventUnlisten = await window.listen("tauri://move", loadWindowPosition); - resizeEventUnlisten = await window.listen("tauri://resize", loadWindowSize); + moveEventUnlisten = await window.listen('tauri://move', loadWindowPosition) + resizeEventUnlisten = await window.listen('tauri://resize', loadWindowSize) } async function requestUserAttention_() { - await windowMap[selectedWindow].minimize(); + await windowMap[selectedWindow].minimize() await windowMap[selectedWindow].requestUserAttention( UserAttentionType.Critical - ); - await new Promise((resolve) => setTimeout(resolve, 3000)); - await windowMap[selectedWindow].requestUserAttention(null); + ) + await new Promise((resolve) => setTimeout(resolve, 3000)) + await windowMap[selectedWindow].requestUserAttention(null) } async function addEffect() { if (!effects.includes(selectedEffect)) { - effects = [...effects, selectedEffect]; + effects = [...effects, selectedEffect] } const payload = { effects, state: effectState, - radius: effectRadius, - }; + radius: effectRadius + } if ( Number.isInteger(effectR) && Number.isInteger(effectG) && Number.isInteger(effectB) && Number.isInteger(effectA) ) { - payload.color = [effectR, effectG, effectB, effectA]; + payload.color = [effectR, effectG, effectB, effectA] } - mainEl.classList.remove("bg-primary"); - mainEl.classList.remove("dark:bg-darkPrimary"); - await windowMap[selectedWindow].clearEffects(); - await windowMap[selectedWindow].setEffects(payload); + mainEl.classList.remove('bg-primary') + mainEl.classList.remove('dark:bg-darkPrimary') + await windowMap[selectedWindow].clearEffects() + await windowMap[selectedWindow].setEffects(payload) } async function clearEffects() { - effects = []; - await windowMap[selectedWindow].clearEffects(); - mainEl.classList.add("bg-primary"); - mainEl.classList.add("dark:bg-darkPrimary"); + effects = [] + await windowMap[selectedWindow].clearEffects() + mainEl.classList.add('bg-primary') + mainEl.classList.add('dark:bg-darkPrimary') } $: { - windowMap[selectedWindow]; - loadWindowPosition(); - loadWindowSize(); + windowMap[selectedWindow] + loadWindowPosition() + loadWindowSize() } - $: windowMap[selectedWindow]?.setResizable(resizable); - $: windowMap[selectedWindow]?.setMaximizable(maximizable); - $: windowMap[selectedWindow]?.setMinimizable(minimizable); - $: windowMap[selectedWindow]?.setClosable(closable); + $: windowMap[selectedWindow]?.setResizable(resizable) + $: windowMap[selectedWindow]?.setMaximizable(maximizable) + $: windowMap[selectedWindow]?.setMinimizable(minimizable) + $: windowMap[selectedWindow]?.setClosable(closable) $: maximized ? windowMap[selectedWindow]?.maximize() - : windowMap[selectedWindow]?.unmaximize(); - $: windowMap[selectedWindow]?.setDecorations(decorations); - $: windowMap[selectedWindow]?.setAlwaysOnTop(alwaysOnTop); - $: windowMap[selectedWindow]?.setContentProtected(contentProtected); - $: windowMap[selectedWindow]?.setFullscreen(fullscreen); + : windowMap[selectedWindow]?.unmaximize() + $: windowMap[selectedWindow]?.setDecorations(decorations) + $: windowMap[selectedWindow]?.setAlwaysOnTop(alwaysOnTop) + $: windowMap[selectedWindow]?.setContentProtected(contentProtected) + $: windowMap[selectedWindow]?.setFullscreen(fullscreen) $: width && height && - windowMap[selectedWindow]?.setSize(new PhysicalSize(width, height)); + windowMap[selectedWindow]?.setSize(new PhysicalSize(width, height)) $: minWidth && minHeight ? windowMap[selectedWindow]?.setMinSize( new LogicalSize(minWidth, minHeight) ) - : windowMap[selectedWindow]?.setMinSize(null); + : windowMap[selectedWindow]?.setMinSize(null) $: maxWidth > 800 && maxHeight > 400 ? windowMap[selectedWindow]?.setMaxSize( new LogicalSize(maxWidth, maxHeight) ) - : windowMap[selectedWindow]?.setMaxSize(null); + : windowMap[selectedWindow]?.setMaxSize(null) $: x !== null && y !== null && - windowMap[selectedWindow]?.setPosition(new PhysicalPosition(x, y)); + windowMap[selectedWindow]?.setPosition(new PhysicalPosition(x, y)) $: windowMap[selectedWindow] ?.scaleFactor() - .then((factor) => (scaleFactor = factor)); - $: addWindowEventListeners(windowMap[selectedWindow]); + .then((factor) => (scaleFactor = factor)) + $: addWindowEventListeners(windowMap[selectedWindow]) - $: windowMap[selectedWindow]?.setCursorGrab(cursorGrab); - $: windowMap[selectedWindow]?.setCursorVisible(cursorVisible); - $: windowMap[selectedWindow]?.setCursorIcon(cursorIcon); + $: windowMap[selectedWindow]?.setCursorGrab(cursorGrab) + $: windowMap[selectedWindow]?.setCursorVisible(cursorVisible) + $: windowMap[selectedWindow]?.setCursorIcon(cursorIcon) $: cursorX !== null && cursorY !== null && windowMap[selectedWindow]?.setCursorPosition( new PhysicalPosition(cursorX, cursorY) - ); - $: windowMap[selectedWindow]?.setIgnoreCursorEvents(cursorIgnoreEvents); + ) + $: windowMap[selectedWindow]?.setIgnoreCursorEvents(cursorIgnoreEvents) + $: windowMap[selectedWindow]?.setProgressBar({ status: selectedProgressBarStatus, progress })
@@ -293,9 +307,7 @@ {#if windowMap[selectedWindow]}
- +
@@ -527,6 +539,24 @@
+
+
+ + + +
+
+ {#if isWindows || isMacOS}
@@ -598,7 +628,7 @@
- Applied effects: {effects.length ? effects.join(",") : "None"} + Applied effects: {effects.length ? effects.join(',') : 'None'}