From 29912785fa22ab6fff8e76c3166787a5510d6e57 Mon Sep 17 00:00:00 2001 From: Lea Anthony Date: Wed, 20 Jul 2022 20:59:49 +1000 Subject: [PATCH] Add Show() and Hide() to runtime to show/hide application (#1599) * Add Show() and Hide() to runtime to show/hide application * Fix devserver * Update API docs --- .../frontend/desktop/darwin/Application.h | 2 ++ .../frontend/desktop/darwin/Application.m | 15 +++++++++ .../frontend/desktop/darwin/WailsContext.h | 2 ++ .../frontend/desktop/darwin/WailsContext.m | 10 ++++++ .../frontend/desktop/darwin/frontend.go | 7 +++++ v2/internal/frontend/desktop/darwin/window.go | 7 +++++ .../frontend/desktop/linux/frontend.go | 8 +++++ .../frontend/desktop/windows/frontend.go | 31 ++++++++++++------- v2/internal/frontend/devserver/devserver.go | 8 +++++ v2/internal/frontend/dispatcher/dispatcher.go | 7 +++++ v2/internal/frontend/frontend.go | 2 ++ v2/internal/frontend/runtime/desktop/main.js | 10 ++++++ v2/internal/frontend/runtime/ipc_websocket.js | 8 ++--- .../frontend/runtime/runtime_dev_desktop.js | 12 +++++-- .../frontend/runtime/runtime_prod_desktop.js | 2 +- .../frontend/runtime/wrapper/runtime.d.ts | 8 +++++ .../frontend/runtime/wrapper/runtime.js | 8 +++++ v2/pkg/runtime/runtime.go | 23 ++++++++++++-- website/docs/reference/runtime/intro.mdx | 23 ++++++++++++++ 19 files changed, 173 insertions(+), 20 deletions(-) diff --git a/v2/internal/frontend/desktop/darwin/Application.h b/v2/internal/frontend/desktop/darwin/Application.h index d61fd639..7e53c36e 100644 --- a/v2/internal/frontend/desktop/darwin/Application.h +++ b/v2/internal/frontend/desktop/darwin/Application.h @@ -36,6 +36,8 @@ void Maximise(void* ctx); void UnMaximise(void* ctx); void Hide(void* ctx); void Show(void* ctx); +void HideApplication(void* ctx); +void ShowApplication(void* ctx); void SetBackgroundColour(void* ctx, int r, int g, int b, int a); void ExecJS(void* ctx, const char*); void Quit(void*); diff --git a/v2/internal/frontend/desktop/darwin/Application.m b/v2/internal/frontend/desktop/darwin/Application.m index 6673d07c..ddb39716 100644 --- a/v2/internal/frontend/desktop/darwin/Application.m +++ b/v2/internal/frontend/desktop/darwin/Application.m @@ -219,6 +219,21 @@ void Show(void *inctx) { ); } + +void HideApplication(void *inctx) { + WailsContext *ctx = (__bridge WailsContext*) inctx; + ON_MAIN_THREAD( + [ctx HideApplication]; + ); +} + +void ShowApplication(void *inctx) { + WailsContext *ctx = (__bridge WailsContext*) inctx; + ON_MAIN_THREAD( + [ctx ShowApplication]; + ); +} + NSString* safeInit(const char* input) { NSString *result = nil; if (input != nil) { diff --git a/v2/internal/frontend/desktop/darwin/WailsContext.h b/v2/internal/frontend/desktop/darwin/WailsContext.h index 8982615d..4325e5fb 100644 --- a/v2/internal/frontend/desktop/darwin/WailsContext.h +++ b/v2/internal/frontend/desktop/darwin/WailsContext.h @@ -75,6 +75,8 @@ - (void) ShowMouse; - (void) Hide; - (void) Show; +- (void) HideApplication; +- (void) ShowApplication; - (void) Quit; -(void) MessageDialog :(NSString*)dialogType :(NSString*)title :(NSString*)message :(NSString*)button1 :(NSString*)button2 :(NSString*)button3 :(NSString*)button4 :(NSString*)defaultButton :(NSString*)cancelButton :(void*)iconData :(int)iconDataLength; diff --git a/v2/internal/frontend/desktop/darwin/WailsContext.m b/v2/internal/frontend/desktop/darwin/WailsContext.m index cc92902e..f92fb314 100644 --- a/v2/internal/frontend/desktop/darwin/WailsContext.m +++ b/v2/internal/frontend/desktop/darwin/WailsContext.m @@ -356,6 +356,16 @@ [NSApp activateIgnoringOtherApps:YES]; } +- (void) HideApplication { + [[NSApplication sharedApplication] hide:self]; +} + +- (void) ShowApplication { + [[NSApplication sharedApplication] unhide:self]; + [[NSApplication sharedApplication] activateIgnoringOtherApps:TRUE]; + +} + - (void) Maximise { if (![self.mainWindow isZoomed]) { [self.mainWindow zoom:nil]; diff --git a/v2/internal/frontend/desktop/darwin/frontend.go b/v2/internal/frontend/desktop/darwin/frontend.go index cc50bff1..b497489d 100644 --- a/v2/internal/frontend/desktop/darwin/frontend.go +++ b/v2/internal/frontend/desktop/darwin/frontend.go @@ -194,6 +194,13 @@ func (f *Frontend) WindowShow() { func (f *Frontend) WindowHide() { f.mainWindow.Hide() } +func (f *Frontend) Show() { + f.mainWindow.ShowApplication() +} + +func (f *Frontend) Hide() { + f.mainWindow.HideApplication() +} func (f *Frontend) WindowMaximise() { f.mainWindow.Maximise() } diff --git a/v2/internal/frontend/desktop/darwin/window.go b/v2/internal/frontend/desktop/darwin/window.go index cbb79c32..abbd604f 100644 --- a/v2/internal/frontend/desktop/darwin/window.go +++ b/v2/internal/frontend/desktop/darwin/window.go @@ -199,6 +199,13 @@ func (w *Window) Show() { func (w *Window) Hide() { C.Hide(w.context) } +func (w *Window) ShowApplication() { + C.ShowApplication(w.context) +} + +func (w *Window) HideApplication() { + C.HideApplication(w.context) +} func parseIntDuo(temp string) (int, int) { split := strings.Split(temp, ",") diff --git a/v2/internal/frontend/desktop/linux/frontend.go b/v2/internal/frontend/desktop/linux/frontend.go index 841ab867..a863fef8 100644 --- a/v2/internal/frontend/desktop/linux/frontend.go +++ b/v2/internal/frontend/desktop/linux/frontend.go @@ -186,6 +186,14 @@ func (f *Frontend) WindowShow() { func (f *Frontend) WindowHide() { f.mainWindow.Hide() } + +func (f *Frontend) Show() { + f.mainWindow.Show() +} + +func (f *Frontend) Hide() { + f.mainWindow.Hide() +} func (f *Frontend) WindowMaximise() { f.mainWindow.Maximise() } diff --git a/v2/internal/frontend/desktop/windows/frontend.go b/v2/internal/frontend/desktop/windows/frontend.go index c18f95da..442169de 100644 --- a/v2/internal/frontend/desktop/windows/frontend.go +++ b/v2/internal/frontend/desktop/windows/frontend.go @@ -7,6 +7,18 @@ import ( "context" "encoding/json" "fmt" + "io" + "log" + "net/http" + "net/http/httptest" + "net/url" + "runtime" + "strconv" + "strings" + "sync" + "text/template" + "time" + "github.com/bep/debounce" "github.com/wailsapp/wails/v2/internal/binding" "github.com/wailsapp/wails/v2/internal/frontend" @@ -19,17 +31,6 @@ import ( "github.com/wailsapp/wails/v2/internal/system/operatingsystem" "github.com/wailsapp/wails/v2/pkg/options" "github.com/wailsapp/wails/v2/pkg/options/windows" - "io" - "log" - "net/http" - "net/http/httptest" - "net/url" - "runtime" - "strconv" - "strings" - "sync" - "text/template" - "time" ) const startURL = "http://wails.localhost/" @@ -357,6 +358,14 @@ func (f *Frontend) ScreenGetAll() ([]Screen, error) { return screens, err } +func (f *Frontend) Show() { + f.mainWindow.Show() +} + +func (f *Frontend) Hide() { + f.mainWindow.Hide() +} + func (f *Frontend) Quit() { if f.frontendOptions.OnBeforeClose != nil && f.frontendOptions.OnBeforeClose(f.ctx) { return diff --git a/v2/internal/frontend/devserver/devserver.go b/v2/internal/frontend/devserver/devserver.go index bfbfb91a..241fd066 100644 --- a/v2/internal/frontend/devserver/devserver.go +++ b/v2/internal/frontend/devserver/devserver.go @@ -48,6 +48,14 @@ type DevWebServer struct { devServerAddr string } +func (d *DevWebServer) Hide() { + d.desktopFrontend.Hide() +} + +func (d *DevWebServer) Show() { + d.desktopFrontend.Show() +} + func (d *DevWebServer) WindowSetSystemDefaultTheme() { d.desktopFrontend.WindowSetSystemDefaultTheme() } diff --git a/v2/internal/frontend/dispatcher/dispatcher.go b/v2/internal/frontend/dispatcher/dispatcher.go index 2c6444dc..76ff2d76 100644 --- a/v2/internal/frontend/dispatcher/dispatcher.go +++ b/v2/internal/frontend/dispatcher/dispatcher.go @@ -2,6 +2,7 @@ package dispatcher import ( "context" + "github.com/pkg/errors" "github.com/wailsapp/wails/v2/internal/binding" "github.com/wailsapp/wails/v2/internal/frontend" @@ -44,6 +45,12 @@ func (d *Dispatcher) ProcessMessage(message string, sender frontend.Frontend) (s case 'Q': sender.Quit() return "", nil + case 'S': + sender.Show() + return "", nil + case 'H': + sender.Hide() + return "", nil default: return "", errors.New("Unknown message from front end: " + message) } diff --git a/v2/internal/frontend/frontend.go b/v2/internal/frontend/frontend.go index 51500428..0821eefd 100644 --- a/v2/internal/frontend/frontend.go +++ b/v2/internal/frontend/frontend.go @@ -65,6 +65,8 @@ type MessageDialogOptions struct { type Frontend interface { Run(context.Context) error + Hide() + Show() Quit() // Dialog diff --git a/v2/internal/frontend/runtime/desktop/main.js b/v2/internal/frontend/runtime/desktop/main.js index 3ed4ce7a..ce89b92e 100644 --- a/v2/internal/frontend/runtime/desktop/main.js +++ b/v2/internal/frontend/runtime/desktop/main.js @@ -21,6 +21,14 @@ export function Quit() { window.WailsInvoke('Q'); } +export function Show() { + window.WailsInvoke('S'); +} + +export function Hide() { + window.WailsInvoke('H'); +} + export function Environment() { return Call(":wails:Environment"); } @@ -37,6 +45,8 @@ window.runtime = { EventsEmit, EventsOff, Environment, + Show, + Hide, Quit }; diff --git a/v2/internal/frontend/runtime/ipc_websocket.js b/v2/internal/frontend/runtime/ipc_websocket.js index 1769739c..c8ffaaef 100644 --- a/v2/internal/frontend/runtime/ipc_websocket.js +++ b/v2/internal/frontend/runtime/ipc_websocket.js @@ -1,9 +1,9 @@ (()=>{function O(t){console.log("%c wails dev %c "+t+" ","background: #aa0000; color: #fff; border-radius: 3px 0px 0px 3px; padding: 1px; font-size: 0.7rem","background: #009900; color: #fff; border-radius: 0px 3px 3px 0px; padding: 1px; font-size: 0.7rem")}function _(){}var D=t=>t;function P(t){return t()}function it(){return Object.create(null)}function b(t){t.forEach(P)}function $(t){return typeof t=="function"}function A(t,e){return t!=t?e==e:t!==e||t&&typeof t=="object"||typeof t=="function"}function ot(t){return Object.keys(t).length===0}function rt(t,...e){if(t==null)return _;let n=t.subscribe(...e);return n.unsubscribe?()=>n.unsubscribe():n}function st(t,e,n){t.$$.on_destroy.push(rt(e,n))}var ct=typeof window!="undefined",Ot=ct?()=>window.performance.now():()=>Date.now(),R=ct?t=>requestAnimationFrame(t):_;var F=new Set;function lt(t){F.forEach(e=>{e.c(t)||(F.delete(e),e.f())}),F.size!==0&&R(lt)}function Dt(t){let e;return F.size===0&&R(lt),{promise:new Promise(n=>{F.add(e={c:t,f:n})}),abort(){F.delete(e)}}}var ut=!1;function At(){ut=!0}function Lt(){ut=!1}function Bt(t,e){t.appendChild(e)}function at(t,e,n){let i=N(t);if(!i.getElementById(e)){let o=B("style");o.id=e,o.textContent=n,ft(i,o)}}function N(t){if(!t)return document;let e=t.getRootNode?t.getRootNode():t.ownerDocument;return e&&e.host?e:t.ownerDocument}function Tt(t){let e=B("style");return ft(N(t),e),e.sheet}function ft(t,e){Bt(t.head||t,e)}function W(t,e,n){t.insertBefore(e,n||null)}function L(t){t.parentNode.removeChild(t)}function B(t){return document.createElement(t)}function Jt(t){return document.createTextNode(t)}function dt(){return Jt("")}function ht(t,e,n){n==null?t.removeAttribute(e):t.getAttribute(e)!==n&&t.setAttribute(e,n)}function zt(t){return Array.from(t.childNodes)}function Ht(t,e,{bubbles:n=!1,cancelable:i=!1}={}){let o=document.createEvent("CustomEvent");return o.initCustomEvent(t,n,i,e),o}var T=new Map,J=0;function Gt(t){let e=5381,n=t.length;for(;n--;)e=(e<<5)-e^t.charCodeAt(n);return e>>>0}function qt(t,e){let n={stylesheet:Tt(e),rules:{}};return T.set(t,n),n}function pt(t,e,n,i,o,c,s,l=0){let a=16.666/i,r=`{ `;for(let g=0;g<=1;g+=a){let v=e+(n-e)*c(g);r+=g*100+`%{${s(v,1-v)}} `}let y=r+`100% {${s(n,1-n)}} -}`,f=`__svelte_${Gt(y)}_${l}`,u=N(t),{stylesheet:h,rules:p}=T.get(u)||qt(u,t);p[f]||(p[f]=!0,h.insertRule(`@keyframes ${f} ${y}`,h.cssRules.length));let w=t.style.animation||"";return t.style.animation=`${w?`${w}, `:""}${f} ${i}ms linear ${o}ms 1 both`,J+=1,f}function Kt(t,e){let n=(t.style.animation||"").split(", "),i=n.filter(e?c=>c.indexOf(e)<0:c=>c.indexOf("__svelte")===-1),o=n.length-i.length;o&&(t.style.animation=i.join(", "),J-=o,J||Pt())}function Pt(){R(()=>{J||(T.forEach(t=>{let{stylesheet:e}=t,n=e.cssRules.length;for(;n--;)e.deleteRule(n);t.rules={}}),T.clear())})}var V;function S(t){V=t}var k=[];var _t=[],z=[],mt=[],Rt=Promise.resolve(),U=!1;function Nt(){U||(U=!0,Rt.then(yt))}function x(t){z.push(t)}var X=new Set,H=0;function yt(){let t=V;do{for(;H{C=null})),C}function Z(t,e,n){t.dispatchEvent(Ht(`${e?"intro":"outro"}${n}`))}var G=new Set,m;function gt(){m={r:0,c:[],p:m}}function bt(){m.r||b(m.c),m=m.p}function I(t,e){t&&t.i&&(G.delete(t),t.i(e))}function Q(t,e,n,i){if(t&&t.o){if(G.has(t))return;G.add(t),m.c.push(()=>{G.delete(t),i&&(n&&t.d(1),i())}),t.o(e)}else i&&i()}var Ut={duration:0};function Y(t,e,n,i){let o=e(t,n),c=i?0:1,s=null,l=null,a=null;function r(){a&&Kt(t,a)}function y(u,h){let p=u.b-c;return h*=Math.abs(p),{a:c,b:u.b,d:p,duration:h,start:u.start,end:u.start+h,group:u.group}}function f(u){let{delay:h=0,duration:p=300,easing:w=D,tick:g=_,css:v}=o||Ut,K={start:Ot()+h,b:u};u||(K.group=m,m.r+=1),s||l?l=K:(v&&(r(),a=pt(t,c,u,p,h,w,v)),u&&g(0,1),s=y(K,p),x(()=>Z(t,u,"start")),Dt(j=>{if(l&&j>l.start&&(s=y(l,p),l=null,Z(t,s.b,"start"),v&&(r(),a=pt(t,c,s.b,s.duration,0,w,o.css))),s){if(j>=s.end)g(c=s.b,1-c),Z(t,s.b,"end"),l||(s.b?r():--s.group.r||b(s.group.c)),s=null;else if(j>=s.start){let jt=j-s.start;c=s.a+s.d*w(jt/s.duration),g(c,1-c)}}return!!(s||l)}))}return{run(u){$(o)?Vt().then(()=>{o=o(),f(u)}):f(u)},end(){r(),s=l=null}}}var le=typeof window!="undefined"?window:typeof globalThis!="undefined"?globalThis:global;var ue=new Set(["allowfullscreen","allowpaymentrequest","async","autofocus","autoplay","checked","controls","default","defer","disabled","formnovalidate","hidden","ismap","loop","multiple","muted","nomodule","novalidate","open","playsinline","readonly","required","reversed","selected"]);function Xt(t,e,n,i){let{fragment:o,on_mount:c,on_destroy:s,after_update:l}=t.$$;o&&o.m(e,n),i||x(()=>{let a=c.map(P).filter($);s?s.push(...a):b(a),t.$$.on_mount=[]}),l.forEach(x)}function wt(t,e){let n=t.$$;n.fragment!==null&&(b(n.on_destroy),n.fragment&&n.fragment.d(e),n.on_destroy=n.fragment=null,n.ctx=[])}function Zt(t,e){t.$$.dirty[0]===-1&&(k.push(t),Nt(),t.$$.dirty.fill(0)),t.$$.dirty[e/31|0]|=1<{let p=h.length?h[0]:u;return r.ctx&&o(r.ctx[f],r.ctx[f]=p)&&(!r.skip_bound&&r.bound[f]&&r.bound[f](p),y&&Zt(t,f)),u}):[],r.update(),y=!0,b(r.before_update),r.fragment=i?i(r.ctx):!1,e.target){if(e.hydrate){At();let f=zt(e.target);r.fragment&&r.fragment.l(f),f.forEach(L)}else r.fragment&&r.fragment.c();e.intro&&I(t.$$.fragment),Xt(t,e.target,e.anchor,e.customElement),Lt(),yt()}S(a)}var Qt;typeof HTMLElement=="function"&&(Qt=class extends HTMLElement{constructor(){super();this.attachShadow({mode:"open"})}connectedCallback(){let{on_mount:t}=this.$$;this.$$.on_disconnect=t.map(P).filter($);for(let e in this.$$.slotted)this.appendChild(this.$$.slotted[e])}attributeChangedCallback(t,e,n){this[t]=n}disconnectedCallback(){b(this.$$.on_disconnect)}$destroy(){wt(this,1),this.$destroy=_}$on(t,e){let n=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return n.push(e),()=>{let i=n.indexOf(e);i!==-1&&n.splice(i,1)}}$set(t){this.$$set&&!ot(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}});var tt=class{$destroy(){wt(this,1),this.$destroy=_}$on(e,n){let i=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return i.push(n),()=>{let o=i.indexOf(n);o!==-1&&i.splice(o,1)}}$set(e){this.$$set&&!ot(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}};var M=[];function Ft(t,e=_){let n,i=new Set;function o(l){if(A(t,l)&&(t=l,n)){let a=!M.length;for(let r of i)r[1](),M.push(r,t);if(a){for(let r=0;r{i.delete(r),i.size===0&&(n(),n=null)}}return{set:o,update:c,subscribe:s}}var q=Ft(!1);function xt(){q.set(!0)}function Mt(){q.set(!1)}function et(t,{delay:e=0,duration:n=400,easing:i=D}={}){let o=+getComputedStyle(t).opacity;return{delay:e,duration:n,easing:i,css:c=>`opacity: ${c*o}`}}function Yt(t){at(t,"svelte-181h7z",`.wails-reconnect-overlay.svelte-181h7z{position:fixed;top:0;left:0;width:100%;height:100%;backdrop-filter:blur(2px) saturate(0%) contrast(50%) brightness(25%);z-index:999999\r - }.wails-reconnect-overlay-content.svelte-181h7z{position:relative;top:50%;transform:translateY(-50%);margin:0;background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEsAAAA7CAMAAAAEsocZAAAC91BMVEUAAACzQ0PjMjLkMjLZLS7XLS+vJCjkMjKlEx6uGyHjMDGiFx7GJyrAISjUKy3mMzPlMjLjMzOsGyDKJirkMjK6HyXmMjLgMDC6IiLcMjLULC3MJyrRKSy+IibmMzPmMjK7ISXlMjLIJimzHSLkMjKtGiHZLC7BIifgMDCpGSDFIivcLy+yHSKoGR+eFBzNKCvlMjKxHSPkMTKxHSLmMjLKJyq5ICXDJCe6ISXdLzDkMjLmMzPFJSm2HyTlMTLhMDGyHSKUEBmhFx24HyTCJCjHJijjMzOiFh7mMjJ6BhDaLDCuGyOKABjnMzPGJinJJiquHCGEChSmGB/pMzOiFh7VKy3OKCu1HiSvHCLjMTLMKCrBIyeICxWxHCLDIyjSKizBIyh+CBO9ISa6ISWDChS9Iie1HyXVLC7FJSrLKCrlMjLiMTGPDhicFRywGyKXFBuhFx1/BxO7IiXkMTGeFBx8BxLkMTGnGR/GJCi4ICWsGyGJDxXSLS2yGiHSKi3CJCfnMzPQKiyECRTKJiq6ISWUERq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Dv76Tf/PgOBmeNiiLG1pcKo1HAq8jLpY4JU1yWEixVNaOgoRJAKBSZHTZTU+wJOMtUDZvlVITC6FTlksyrEBoPHXpxxbzdaqzigUtVDkJVIOtVQ9UEOR4VGUh/kHWq0edJ6CxnZ+eePXva2bnY/cF/I1RLLf8vvwDANdMSMegxcAAAAABJRU5ErkJggg==);background-repeat:no-repeat;background-position:center\r - }.wails-reconnect-overlay-loadingspinner.svelte-181h7z{pointer-events:none;width:2.5em;height:2.5em;border:.4em solid transparent;border-color:#f00 #eee0 #f00 #eee0;border-radius:50%;animation:svelte-181h7z-loadingspin 1s linear infinite;margin:auto;padding:2.5em\r +}`,f=`__svelte_${Gt(y)}_${l}`,u=N(t),{stylesheet:h,rules:p}=T.get(u)||qt(u,t);p[f]||(p[f]=!0,h.insertRule(`@keyframes ${f} ${y}`,h.cssRules.length));let w=t.style.animation||"";return t.style.animation=`${w?`${w}, `:""}${f} ${i}ms linear ${o}ms 1 both`,J+=1,f}function Kt(t,e){let n=(t.style.animation||"").split(", "),i=n.filter(e?c=>c.indexOf(e)<0:c=>c.indexOf("__svelte")===-1),o=n.length-i.length;o&&(t.style.animation=i.join(", "),J-=o,J||Pt())}function Pt(){R(()=>{J||(T.forEach(t=>{let{stylesheet:e}=t,n=e.cssRules.length;for(;n--;)e.deleteRule(n);t.rules={}}),T.clear())})}var V;function S(t){V=t}var k=[];var _t=[],z=[],mt=[],Rt=Promise.resolve(),U=!1;function Nt(){U||(U=!0,Rt.then(yt))}function x(t){z.push(t)}var X=new Set,H=0;function yt(){let t=V;do{for(;H{C=null})),C}function Z(t,e,n){t.dispatchEvent(Ht(`${e?"intro":"outro"}${n}`))}var G=new Set,m;function gt(){m={r:0,c:[],p:m}}function bt(){m.r||b(m.c),m=m.p}function I(t,e){t&&t.i&&(G.delete(t),t.i(e))}function Q(t,e,n,i){if(t&&t.o){if(G.has(t))return;G.add(t),m.c.push(()=>{G.delete(t),i&&(n&&t.d(1),i())}),t.o(e)}else i&&i()}var Ut={duration:0};function Y(t,e,n,i){let o=e(t,n),c=i?0:1,s=null,l=null,a=null;function r(){a&&Kt(t,a)}function y(u,h){let p=u.b-c;return h*=Math.abs(p),{a:c,b:u.b,d:p,duration:h,start:u.start,end:u.start+h,group:u.group}}function f(u){let{delay:h=0,duration:p=300,easing:w=D,tick:g=_,css:v}=o||Ut,K={start:Ot()+h,b:u};u||(K.group=m,m.r+=1),s||l?l=K:(v&&(r(),a=pt(t,c,u,p,h,w,v)),u&&g(0,1),s=y(K,p),x(()=>Z(t,u,"start")),Dt(j=>{if(l&&j>l.start&&(s=y(l,p),l=null,Z(t,s.b,"start"),v&&(r(),a=pt(t,c,s.b,s.duration,0,w,o.css))),s){if(j>=s.end)g(c=s.b,1-c),Z(t,s.b,"end"),l||(s.b?r():--s.group.r||b(s.group.c)),s=null;else if(j>=s.start){let jt=j-s.start;c=s.a+s.d*w(jt/s.duration),g(c,1-c)}}return!!(s||l)}))}return{run(u){$(o)?Vt().then(()=>{o=o(),f(u)}):f(u)},end(){r(),s=l=null}}}var le=typeof window!="undefined"?window:typeof globalThis!="undefined"?globalThis:global;var ue=new Set(["allowfullscreen","allowpaymentrequest","async","autofocus","autoplay","checked","controls","default","defer","disabled","formnovalidate","hidden","ismap","loop","multiple","muted","nomodule","novalidate","open","playsinline","readonly","required","reversed","selected"]);function Xt(t,e,n,i){let{fragment:o,on_mount:c,on_destroy:s,after_update:l}=t.$$;o&&o.m(e,n),i||x(()=>{let a=c.map(P).filter($);s?s.push(...a):b(a),t.$$.on_mount=[]}),l.forEach(x)}function wt(t,e){let n=t.$$;n.fragment!==null&&(b(n.on_destroy),n.fragment&&n.fragment.d(e),n.on_destroy=n.fragment=null,n.ctx=[])}function Zt(t,e){t.$$.dirty[0]===-1&&(k.push(t),Nt(),t.$$.dirty.fill(0)),t.$$.dirty[e/31|0]|=1<{let p=h.length?h[0]:u;return r.ctx&&o(r.ctx[f],r.ctx[f]=p)&&(!r.skip_bound&&r.bound[f]&&r.bound[f](p),y&&Zt(t,f)),u}):[],r.update(),y=!0,b(r.before_update),r.fragment=i?i(r.ctx):!1,e.target){if(e.hydrate){At();let f=zt(e.target);r.fragment&&r.fragment.l(f),f.forEach(L)}else r.fragment&&r.fragment.c();e.intro&&I(t.$$.fragment),Xt(t,e.target,e.anchor,e.customElement),Lt(),yt()}S(a)}var Qt;typeof HTMLElement=="function"&&(Qt=class extends HTMLElement{constructor(){super();this.attachShadow({mode:"open"})}connectedCallback(){let{on_mount:t}=this.$$;this.$$.on_disconnect=t.map(P).filter($);for(let e in this.$$.slotted)this.appendChild(this.$$.slotted[e])}attributeChangedCallback(t,e,n){this[t]=n}disconnectedCallback(){b(this.$$.on_disconnect)}$destroy(){wt(this,1),this.$destroy=_}$on(t,e){let n=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return n.push(e),()=>{let i=n.indexOf(e);i!==-1&&n.splice(i,1)}}$set(t){this.$$set&&!ot(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}});var tt=class{$destroy(){wt(this,1),this.$destroy=_}$on(e,n){let i=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return i.push(n),()=>{let o=i.indexOf(n);o!==-1&&i.splice(o,1)}}$set(e){this.$$set&&!ot(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}};var M=[];function Ft(t,e=_){let n,i=new Set;function o(l){if(A(t,l)&&(t=l,n)){let a=!M.length;for(let r of i)r[1](),M.push(r,t);if(a){for(let r=0;r{i.delete(r),i.size===0&&(n(),n=null)}}return{set:o,update:c,subscribe:s}}var q=Ft(!1);function xt(){q.set(!0)}function Mt(){q.set(!1)}function et(t,{delay:e=0,duration:n=400,easing:i=D}={}){let o=+getComputedStyle(t).opacity;return{delay:e,duration:n,easing:i,css:c=>`opacity: ${c*o}`}}function Yt(t){at(t,"svelte-181h7z",`.wails-reconnect-overlay.svelte-181h7z{position:fixed;top:0;left:0;width:100%;height:100%;backdrop-filter:blur(2px) saturate(0%) contrast(50%) brightness(25%);z-index:999999 + }.wails-reconnect-overlay-content.svelte-181h7z{position:relative;top:50%;transform:translateY(-50%);margin:0;background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEsAAAA7CAMAAAAEsocZAAAC91BMVEUAAACzQ0PjMjLkMjLZLS7XLS+vJCjkMjKlEx6uGyHjMDGiFx7GJyrAISjUKy3mMzPlMjLjMzOsGyDKJirkMjK6HyXmMjLgMDC6IiLcMjLULC3MJyrRKSy+IibmMzPmMjK7ISXlMjLIJimzHSLkMjKtGiHZLC7BIifgMDCpGSDFIivcLy+yHSKoGR+eFBzNKCvlMjKxHSPkMTKxHSLmMjLKJyq5ICXDJCe6ISXdLzDkMjLmMzPFJSm2HyTlMTLhMDGyHSKUEBmhFx24HyTCJCjHJijjMzOiFh7mMjJ6BhDaLDCuGyOKABjnMzPGJinJJiquHCGEChSmGB/pMzOiFh7VKy3OKCu1HiSvHCLjMTLMKCrBIyeICxWxHCLDIyjSKizBIyh+CBO9ISa6ISWDChS9Iie1HyXVLC7FJSrLKCrlMjLiMTGPDhicFRywGyKXFBuhFx1/BxO7IiXkMTGeFBx8BxLkMTGnGR/GJCi4ICWsGyGJDxXSLS2yGiHSKi3CJCfnMzPQKiyECRTKJiq6ISWUERq/Iye0HiPDJCjGJSm6ICaPDxiTEBrdLy+3HyXSKiy0HyOQEBi4ICWhFh1+CBO9IieODhfSKyzWLC2LDhh8BxHKKCq7ISWaFBzkMzPqNDTTLC3EJSiHDBacExyvGyO1HyTPKCy+IieoGSC7ISaVEhrMKCvQKyusGyG0HiKACBPIJSq/JCaABxR5BRLEJCnkMzPJJinEJimPDRZ2BRKqHx/jMjLnMzPgMDHULC3NKSvQKSzsNDTWLS7SKyy3HyTKJyrDJSjbLzDYLC6mGB/GJSnVLC61HiPLKCrHJSm/Iye8Iia6ICWzHSKxHCLaLi/PKSupGR+7ICXpMzPbLi/IJinJJSmsGyGrGiCkFx6PDheJCxaFChXBIy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hlJ2rJCiUjIZCByItXg8sHJijuvT64CuMTABUYvb6NN1Jdp1PH7D7f3bo2eS5KvW4RJr7atWT5w4MBBg9zdBw9+37BS7QIoFS5WnIaj12dr1DEXFgdvr4fh4eFl+u/wz8uf3jjHic8s4DL2Dal0IANyUBeCRCcwOBJV26JsjSpGwHVuSai69jvqD+jr56OgtKy0zAAK5mLTVBKVKL5tNthGAR9JneJQ/bFsHNzy+U7IlCYROxtMpIjR0ceoQVnowracLLpAQWETqV361bPoFo3cEbz2zYLZM7t3HWXcxmiBOgttS1ycWkTXMWh4mGigdug9DFdttqCFgTN6nD0q1XEVSoCxEjyFCi2eNC6Z69MRVIImJ6JQSf5gcFVCuF+aDhCa1F6MJFDaiNBQAh2TMfWBjhmLsAxUjG/fmjs0qjJck8D0GPBcuUuZW1LS/tIsPzqmQt17PvZQknlwnf4tHDBc+7t5VV3QQCkdc+Ur8/hdrz0but0RCumWiYbiKmLJ7EVbRomj4Q7+y5wsaXvfTGFpQcHB7n2WbG4MGdniw2Tm8xl5Yhr7MrSYHQ3uampz10aWyHyuzxvqaW/6W4MjXAUD3QV2aw97ZxhGjxCohYf5TpTHMXU1BbsAuoFnkRygVieIGAbqiF7rrH4rfWpKJouBCtyHJF8ctEyGubBa+C6NsMYEUonJFITHZqWBxXUA12Dv76Tf/PgOBmeNiiLG1pcKo1HAq8jLpY4JU1yWEixVNaOgoRJAKBSZHTZTU+wJOMtUDZvlVITC6FTlksyrEBoPHXpxxbzdaqzigUtVDkJVIOtVQ9UEOR4VGUh/kHWq0edJ6CxnZ+eePXva2bnY/cF/I1RLLf8vvwDANdMSMegxcAAAAABJRU5ErkJggg==);background-repeat:no-repeat;background-position:center + }.wails-reconnect-overlay-loadingspinner.svelte-181h7z{pointer-events:none;width:2.5em;height:2.5em;border:.4em solid transparent;border-color:#f00 #eee0 #f00 #eee0;border-radius:50%;animation:svelte-181h7z-loadingspin 1s linear infinite;margin:auto;padding:2.5em }@keyframes svelte-181h7z-loadingspin{100%{transform:rotate(360deg)}}`)}function $t(t){let e,n,i;return{c(){e=B("div"),e.innerHTML='
',ht(e,"class","wails-reconnect-overlay svelte-181h7z")},m(o,c){W(o,e,c),i=!0},i(o){i||(x(()=>{n||(n=Y(e,et,{duration:300},!0)),n.run(1)}),i=!0)},o(o){n||(n=Y(e,et,{duration:300},!1)),n.run(0),i=!1},d(o){o&&L(e),o&&n&&n.end()}}}function te(t){let e,n,i=t[0]&&$t(t);return{c(){i&&i.c(),e=dt()},m(o,c){i&&i.m(o,c),W(o,e,c),n=!0},p(o,[c]){o[0]?i?c&1&&I(i,1):(i=$t(o),i.c(),I(i,1),i.m(e.parentNode,e)):i&&(gt(),Q(i,1,1,()=>{i=null}),bt())},i(o){n||(I(i),n=!0)},o(o){Q(i),n=!1},d(o){i&&i.d(o),o&&L(e)}}}function ee(t,e,n){let i;return st(t,q,o=>n(0,i=o)),[i]}var St=class extends tt{constructor(e){super();vt(this,e,ee,te,A,{},Yt)}},kt=St;var ne={},nt=null,E=[];window.WailsInvoke=t=>{if(!nt){console.log("Queueing: "+t),E.push(t);return}nt(t)};window.addEventListener("DOMContentLoaded",()=>{ne.overlay=new kt({target:document.body,anchor:document.querySelector("#wails-spinner")})});var d=null,Ct;window.onbeforeunload=function(){d&&(d.onclose=function(){},d.close(),d=null)};Et();function ie(){nt=t=>{d.send(t)};for(let t=0;t{var k=Object.defineProperty;var D=e=>k(e,"__esModule",{value:!0});var f=(e,n)=>{D(e);for(var o in n)k(e,o,{get:n[o],enumerable:!0})};var g={};f(g,{LogDebug:()=>B,LogError:()=>J,LogFatal:()=>M,LogInfo:()=>G,LogLevel:()=>U,LogPrint:()=>A,LogTrace:()=>R,LogWarning:()=>H,SetLogLevel:()=>P});function a(e,n){window.WailsInvoke("L"+e+n)}function R(e){a("T",e)}function A(e){a("P",e)}function B(e){a("D",e)}function G(e){a("I",e)}function H(e){a("W",e)}function J(e){a("E",e)}function M(e){a("F",e)}function P(e){a("S",e)}var U={TRACE:1,DEBUG:2,INFO:3,WARNING:4,ERROR:5};var b=class{constructor(n,o){o=o||-1,this.Callback=i=>(n.apply(null,i),o===-1?!1:(o-=1,o===0))}},s={};function u(e,n,o){s[e]=s[e]||[];let i=new b(n,o);s[e].push(i)}function E(e,n){u(e,n,-1)}function I(e,n){u(e,n,1)}function S(e){let n=e.name;if(s[n]){let o=s[n].slice();for(let i=0;i0&&(d=setTimeout(function(){t(Error("Call to "+e+" timed out. Request ID: "+r))},o)),c[r]={timeoutHandle:d,reject:t,resolve:i};try{let W={name:e,args:n,callbackID:r};window.WailsInvoke("C"+JSON.stringify(W))}catch(W){console.error(W)}})}function L(e){let n;try{n=JSON.parse(e)}catch(t){let r=`Invalid JSON passed to callback: ${t.message}. Message: ${e}`;throw runtime.LogDebug(r),new Error(r)}let o=n.callbackid,i=c[o];if(!i){let t=`Callback '${o}' not registered!!!`;throw console.error(t),new Error(t)}clearTimeout(i.timeoutHandle),delete c[o],n.error?i.reject(n.error):i.resolve(n.result)}window.go={};function O(e){try{e=JSON.parse(e)}catch(n){console.error(n)}window.go=window.go||{},Object.keys(e).forEach(n=>{window.go[n]=window.go[n]||{},Object.keys(e[n]).forEach(o=>{window.go[n][o]=window.go[n][o]||{},Object.keys(e[n][o]).forEach(i=>{window.go[n][o][i]=function(){let t=0;function r(){let d=[].slice.call(arguments);return l([n,o,i].join("."),d,t)}return r.setTimeout=function(d){t=d},r.getTimeout=function(){return t},r}()})})})}var v={};f(v,{WindowCenter:()=>q,WindowFullscreen:()=>Z,WindowGetPosition:()=>re,WindowGetSize:()=>ee,WindowHide:()=>se,WindowMaximise:()=>we,WindowMinimise:()=>ce,WindowReload:()=>X,WindowReloadApp:()=>Y,WindowSetAlwaysOnTop:()=>ie,WindowSetBackgroundColour:()=>ue,WindowSetDarkTheme:()=>V,WindowSetLightTheme:()=>Q,WindowSetMaxSize:()=>ne,WindowSetMinSize:()=>oe,WindowSetPosition:()=>te,WindowSetSize:()=>_,WindowSetSystemDefaultTheme:()=>$,WindowSetTitle:()=>N,WindowShow:()=>le,WindowToggleMaximise:()=>ae,WindowUnfullscreen:()=>K,WindowUnmaximise:()=>de,WindowUnminimise:()=>fe});function X(){window.location.reload()}function Y(){window.WailsInvoke("WR")}function $(){window.WailsInvoke("WASDT")}function Q(){window.WailsInvoke("WALT")}function V(){window.WailsInvoke("WADT")}function q(){window.WailsInvoke("Wc")}function N(e){window.WailsInvoke("WT"+e)}function Z(){window.WailsInvoke("WF")}function K(){window.WailsInvoke("Wf")}function _(e,n){window.WailsInvoke("Ws:"+e+":"+n)}function ee(){return l(":wails:WindowGetSize")}function ne(e,n){window.WailsInvoke("WZ:"+e+":"+n)}function oe(e,n){window.WailsInvoke("Wz:"+e+":"+n)}function ie(e){window.WailsInvoke("WATP:"+(e?"1":"0"))}function te(e,n){window.WailsInvoke("Wp:"+e+":"+n)}function re(){return l(":wails:WindowGetPos")}function se(){window.WailsInvoke("WH")}function le(){window.WailsInvoke("WS")}function we(){window.WailsInvoke("WM")}function ae(){window.WailsInvoke("Wt")}function de(){window.WailsInvoke("WU")}function ce(){window.WailsInvoke("Wm")}function fe(){window.WailsInvoke("Wu")}function ue(e,n,o,i){let t=JSON.stringify({r:e||0,g:n||0,b:o||0,a:i||255});window.WailsInvoke("Wr:"+t)}var m={};f(m,{ScreenGetAll:()=>We});function We(){return l(":wails:ScreenGetAll")}var x={};f(x,{BrowserOpenURL:()=>ge});function ge(e){window.WailsInvoke("BO:"+e)}function pe(){window.WailsInvoke("Q")}function ve(){return l(":wails:Environment")}window.runtime={...g,...v,...x,...m,EventsOn:E,EventsOnce:I,EventsOnMultiple:u,EventsEmit:y,EventsOff:T,Environment:ve,Quit:pe};window.wails={Callback:L,EventsNotify:h,SetBindings:O,eventListeners:s,callbacks:c,flags:{disableScrollbarDrag:!1,disableWailsDefaultContextMenu:!1,enableResize:!1,defaultCursor:null,borderThickness:6,dbClickInterval:100}};window.wails.SetBindings(window.wailsbindings);delete window.wails.SetBindings;var z,C=0;function me(){window.WailsInvoke("drag")}window.addEventListener("mousedown",e=>{if(window.wails.flags.resizeEdge){window.WailsInvoke("resize:"+window.wails.flags.resizeEdge),e.preventDefault();return}let n=e.target;for(;n!=null&&!n.hasAttribute("data-wails-no-drag");){if(n.hasAttribute("data-wails-drag")){if(window.wails.flags.disableScrollbarDrag&&(e.offsetX>e.target.clientWidth||e.offsetY>e.target.clientHeight))break;if(new Date().getTime()-C{var k=Object.defineProperty;var D=e=>k(e,"__esModule",{value:!0});var f=(e,n)=>{D(e);for(var o in n)k(e,o,{get:n[o],enumerable:!0})};var g={};f(g,{LogDebug:()=>B,LogError:()=>J,LogFatal:()=>M,LogInfo:()=>H,LogLevel:()=>U,LogPrint:()=>A,LogTrace:()=>R,LogWarning:()=>G,SetLogLevel:()=>P});function a(e,n){window.WailsInvoke("L"+e+n)}function R(e){a("T",e)}function A(e){a("P",e)}function B(e){a("D",e)}function H(e){a("I",e)}function G(e){a("W",e)}function J(e){a("E",e)}function M(e){a("F",e)}function P(e){a("S",e)}var U={TRACE:1,DEBUG:2,INFO:3,WARNING:4,ERROR:5};var b=class{constructor(n,o){o=o||-1,this.Callback=i=>(n.apply(null,i),o===-1?!1:(o-=1,o===0))}},s={};function u(e,n,o){s[e]=s[e]||[];let i=new b(n,o);s[e].push(i)}function I(e,n){u(e,n,-1)}function E(e,n){u(e,n,1)}function S(e){let n=e.name;if(s[n]){let o=s[n].slice();for(let i=0;i0&&(d=setTimeout(function(){t(Error("Call to "+e+" timed out. Request ID: "+r))},o)),c[r]={timeoutHandle:d,reject:t,resolve:i};try{let W={name:e,args:n,callbackID:r};window.WailsInvoke("C"+JSON.stringify(W))}catch(W){console.error(W)}})}function L(e){let n;try{n=JSON.parse(e)}catch(t){let r=`Invalid JSON passed to callback: ${t.message}. Message: ${e}`;throw runtime.LogDebug(r),new Error(r)}let o=n.callbackid,i=c[o];if(!i){let t=`Callback '${o}' not registered!!!`;throw console.error(t),new Error(t)}clearTimeout(i.timeoutHandle),delete c[o],n.error?i.reject(n.error):i.resolve(n.result)}window.go={};function O(e){try{e=JSON.parse(e)}catch(n){console.error(n)}window.go=window.go||{},Object.keys(e).forEach(n=>{window.go[n]=window.go[n]||{},Object.keys(e[n]).forEach(o=>{window.go[n][o]=window.go[n][o]||{},Object.keys(e[n][o]).forEach(i=>{window.go[n][o][i]=function(){let t=0;function r(){let d=[].slice.call(arguments);return l([n,o,i].join("."),d,t)}return r.setTimeout=function(d){t=d},r.getTimeout=function(){return t},r}()})})})}var v={};f(v,{WindowCenter:()=>q,WindowFullscreen:()=>Z,WindowGetPosition:()=>re,WindowGetSize:()=>ee,WindowHide:()=>se,WindowMaximise:()=>we,WindowMinimise:()=>ce,WindowReload:()=>X,WindowReloadApp:()=>Y,WindowSetAlwaysOnTop:()=>ie,WindowSetBackgroundColour:()=>ue,WindowSetDarkTheme:()=>V,WindowSetLightTheme:()=>Q,WindowSetMaxSize:()=>ne,WindowSetMinSize:()=>oe,WindowSetPosition:()=>te,WindowSetSize:()=>_,WindowSetSystemDefaultTheme:()=>$,WindowSetTitle:()=>N,WindowShow:()=>le,WindowToggleMaximise:()=>ae,WindowUnfullscreen:()=>K,WindowUnmaximise:()=>de,WindowUnminimise:()=>fe});function X(){window.location.reload()}function Y(){window.WailsInvoke("WR")}function $(){window.WailsInvoke("WASDT")}function Q(){window.WailsInvoke("WALT")}function V(){window.WailsInvoke("WADT")}function q(){window.WailsInvoke("Wc")}function N(e){window.WailsInvoke("WT"+e)}function Z(){window.WailsInvoke("WF")}function K(){window.WailsInvoke("Wf")}function _(e,n){window.WailsInvoke("Ws:"+e+":"+n)}function ee(){return l(":wails:WindowGetSize")}function ne(e,n){window.WailsInvoke("WZ:"+e+":"+n)}function oe(e,n){window.WailsInvoke("Wz:"+e+":"+n)}function ie(e){window.WailsInvoke("WATP:"+(e?"1":"0"))}function te(e,n){window.WailsInvoke("Wp:"+e+":"+n)}function re(){return l(":wails:WindowGetPos")}function se(){window.WailsInvoke("WH")}function le(){window.WailsInvoke("WS")}function we(){window.WailsInvoke("WM")}function ae(){window.WailsInvoke("Wt")}function de(){window.WailsInvoke("WU")}function ce(){window.WailsInvoke("Wm")}function fe(){window.WailsInvoke("Wu")}function ue(e,n,o,i){let t=JSON.stringify({r:e||0,g:n||0,b:o||0,a:i||255});window.WailsInvoke("Wr:"+t)}var x={};f(x,{ScreenGetAll:()=>We});function We(){return l(":wails:ScreenGetAll")}var m={};f(m,{BrowserOpenURL:()=>ge});function ge(e){window.WailsInvoke("BO:"+e)}function pe(){window.WailsInvoke("Q")}function ve(){window.WailsInvoke("S")}function xe(){window.WailsInvoke("H")}function me(){return l(":wails:Environment")}window.runtime={...g,...v,...m,...x,EventsOn:I,EventsOnce:E,EventsOnMultiple:u,EventsEmit:y,EventsOff:T,Environment:me,Show:ve,Hide:xe,Quit:pe};window.wails={Callback:L,EventsNotify:h,SetBindings:O,eventListeners:s,callbacks:c,flags:{disableScrollbarDrag:!1,disableWailsDefaultContextMenu:!1,enableResize:!1,defaultCursor:null,borderThickness:6,dbClickInterval:100}};window.wails.SetBindings(window.wailsbindings);delete window.wails.SetBindings;var z,C=0;function ke(){window.WailsInvoke("drag")}window.addEventListener("mousedown",e=>{if(window.wails.flags.resizeEdge){window.WailsInvoke("resize:"+window.wails.flags.resizeEdge),e.preventDefault();return}let n=e.target;for(;n!=null&&!n.hasAttribute("data-wails-no-drag");){if(n.hasAttribute("data-wails-drag")){if(window.wails.flags.disableScrollbarDrag&&(e.offsetX>e.target.clientWidth||e.offsetY>e.target.clientHeight))break;if(new Date().getTime()-C; // [Quit](https://wails.io/docs/reference/runtime/intro#quit) // Quits the application. export function Quit(): void; + +// [Hide](https://wails.io/docs/reference/runtime/intro#hide) +// Hides the application. +export function Hide(): void; + +// [Show](https://wails.io/docs/reference/runtime/intro#show) +// Shows the application. +export function Show(): void; diff --git a/v2/internal/frontend/runtime/wrapper/runtime.js b/v2/internal/frontend/runtime/wrapper/runtime.js index cdd0dfa6..26dbb224 100644 --- a/v2/internal/frontend/runtime/wrapper/runtime.js +++ b/v2/internal/frontend/runtime/wrapper/runtime.js @@ -164,3 +164,11 @@ export function Environment() { export function Quit() { window.runtime.Quit(); } + +export function Hide() { + window.runtime.Hide(); +} + +export function Show() { + window.runtime.Show(); +} diff --git a/v2/pkg/runtime/runtime.go b/v2/pkg/runtime/runtime.go index 6dc61f36..243ff16c 100644 --- a/v2/pkg/runtime/runtime.go +++ b/v2/pkg/runtime/runtime.go @@ -2,10 +2,11 @@ package runtime import ( "context" - "github.com/wailsapp/wails/v2/internal/frontend" - "github.com/wailsapp/wails/v2/internal/logger" "log" goruntime "runtime" + + "github.com/wailsapp/wails/v2/internal/frontend" + "github.com/wailsapp/wails/v2/internal/logger" ) const contextError = `An invalid context was passed. This method requires the specific context given in the lifecycle hooks: @@ -67,6 +68,24 @@ func Quit(ctx context.Context) { appFrontend.Quit() } +// Hide the application +func Hide(ctx context.Context) { + if ctx == nil { + log.Fatalf("cannot call Hide: context is nil") + } + appFrontend := getFrontend(ctx) + appFrontend.Hide() +} + +// Show the application if it is hidden +func Show(ctx context.Context) { + if ctx == nil { + log.Fatalf("cannot call Show: context is nil") + } + appFrontend := getFrontend(ctx) + appFrontend.Show() +} + // EnvironmentInfo contains information about the environment type EnvironmentInfo struct { BuildType string `json:"buildType"` diff --git a/website/docs/reference/runtime/intro.mdx b/website/docs/reference/runtime/intro.mdx index 583c8479..0a33acdf 100644 --- a/website/docs/reference/runtime/intro.mdx +++ b/website/docs/reference/runtime/intro.mdx @@ -24,6 +24,29 @@ The Javascript library is available to the frontend via the `window.runtime` map mode that provides Typescript declarations for the runtime. This should be located in the `wailsjs` directory in your frontend directory. +### Hide + +Go Signature: `Hide(ctx context.Context)` + +Hides the application. + +:::info Note +On Mac, this will hide the application in the same way as the `Hide` menu item in standard Mac applications. +This is different to hiding the window, but the application still being in the foreground. +For Windows and Linux, this is currently the same as `WindowHide`. +::: + +### Show + +Go Signature: `Show(ctx context.Context)` + +Shows the application. + +:::info Note +On Mac, this will bring the application back into the foreground. +For Windows and Linux, this is currently the same as `WindowShow`. +::: + ### Quit Go Signature: `Quit(ctx context.Context)`