diff --git a/v3/examples/window/main.go b/v3/examples/window/main.go
index 241e8151..d930399d 100644
--- a/v3/examples/window/main.go
+++ b/v3/examples/window/main.go
@@ -21,7 +21,7 @@ func main() {
Description: "A demo of the WebviewWindow API",
Assets: application.AlphaAssets,
Mac: application.MacOptions{
- ApplicationShouldTerminateAfterLastWindowClosed: true,
+ ApplicationShouldTerminateAfterLastWindowClosed: false,
},
})
app.On(events.Mac.ApplicationDidFinishLaunching, func(event *application.Event) {
diff --git a/v3/examples/wml/assets/index.html b/v3/examples/wml/assets/index.html
index 8c2e28a0..1dca07b2 100644
--- a/v3/examples/wml/assets/index.html
+++ b/v3/examples/wml/assets/index.html
@@ -129,6 +129,7 @@
font-size: large;
}
+
{var J=Object.defineProperty;var c=(e,i)=>{for(var n in i)J(e,n,{get:i[n],enumerable:!0})};var v={};c(v,{Hide:()=>te,Quit:()=>re,Show:()=>ae});var Y="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var p=(e=21)=>{let i="",n=e;for(;n--;)i+=Y[Math.random()*64|0];return i};var X=window.location.origin+"/wails/runtime",r={Call:0,Clipboard:1,Application:2,Events:3,ContextMenu:4,Dialog:5,Window:6,Screens:7,System:8,Browser:9},$=p();function d(e,i){return function(n,o=null){return ee(e,n,i,o)}}function ee(e,i,n,o){let t=new URL(X);t.searchParams.append("object",e),t.searchParams.append("method",i);let l={headers:{}};return n&&(l.headers["x-wails-window-name"]=n),o&&t.searchParams.append("args",JSON.stringify(o)),l.headers["x-wails-client-id"]=$,new Promise((m,D)=>{fetch(t,l).then(s=>{if(s.ok)return s.headers.get("Content-Type")&&s.headers.get("Content-Type").indexOf("application/json")!==-1?s.json():s.text();D(Error(s.statusText))}).then(s=>m(s)).catch(s=>D(s))})}var A=d(r.Application,""),ie=0,ne=1,oe=2;function te(){return A(ie)}function ae(){return A(ne)}function re(){return A(oe)}var R={};c(R,{OpenURL:()=>S});var de=d(r.Browser,""),le=0;function S(e){return de(le,{url:e})}var b={};c(b,{SetText:()=>we,Text:()=>me});var Z=d(r.Clipboard,""),ce=0,se=1;function we(e){return Z(ce,{text:e})}function me(){return Z(se)}var U={};c(U,{GetFlag:()=>ue});function ue(e){try{return window._wails.flags[e]}catch(i){throw new Error("Unable to retrieve flag '"+e+"': "+i)}}var O={};c(O,{GetAll:()=>he,GetCurrent:()=>De,GetPrimary:()=>fe});var E=d(r.Screens,""),pe=0,We=1,ge=2;function he(){return E(pe)}function fe(){return E(We)}function De(){return E(ge)}var B={};c(B,{Capabilities:()=>xe,Environment:()=>Ae,IsAMD64:()=>Ue,IsARM:()=>Ee,IsARM64:()=>Oe,IsDarkMode:()=>Ce,IsDebug:()=>Te,IsLinux:()=>Re,IsMac:()=>be,IsWindows:()=>ve,invoke:()=>T});var V=d(r.System,""),Se=0,Me=1;function T(e){return window.chrome?window.chrome.webview.postMessage(e):window.webkit.messageHandlers.external.postMessage}function Ce(){return V(Se)}function xe(){return fetch("/wails/capabilities").json()}function Ae(){return V(Me)}function ve(){return window._wails.environment.OS==="windows"}function Re(){return window._wails.environment.OS==="linux"}function be(){return window._wails.environment.OS==="darwin"}function Ue(){return window._wails.environment.Arch==="amd64"}function Ee(){return window._wails.environment.Arch==="arm"}function Oe(){return window._wails.environment.Arch==="arm64"}function Te(){return window._wails.environment.Debug===!0}var P={};c(P,{Center:()=>li,Close:()=>bi,Fullscreen:()=>si,Get:()=>M,GetZoomLevel:()=>Fi,Height:()=>Ti,Hide:()=>Di,Maximise:()=>Si,Minimise:()=>xi,RelativePosition:()=>hi,Restore:()=>vi,Screen:()=>fi,SetAlwaysOnTop:()=>Wi,SetBackgroundColour:()=>Ui,SetMaxSize:()=>ui,SetMinSize:()=>pi,SetRelativePosition:()=>gi,SetResizable:()=>Ei,SetSize:()=>wi,SetTitle:()=>ci,SetZoomLevel:()=>yi,Show:()=>Ri,Size:()=>mi,ToggleMaximise:()=>Ci,UnMaximise:()=>Mi,UnMinimise:()=>Ai,Width:()=>Oi,ZoomIn:()=>Bi,ZoomOut:()=>Pi,ZoomReset:()=>Ii});var Be=0,Pe=1,Ie=2,Fe=3,ye=4,Le=5,ke=6,Ne=7,ze=8,He=9,Ze=10,Ve=11,_e=12,je=13,Ge=14,Ke=15,Qe=16,qe=17,Je=18,Ye=19,Xe=20,$e=21,ei=22,ii=23,ni=24,oi=25,ti=26,ai=27,ri=28,di=29,a=M("");function _(e){return{Get:i=>_(d(r.Window,i)),Center:()=>e(Be),SetTitle:i=>e(Pe,{title:i}),Fullscreen:()=>e(Ie),UnFullscreen:()=>e(Fe),SetSize:(i,n)=>e(ye,{width:i,height:n}),Size:()=>e(Le),SetMaxSize:(i,n)=>e(ke,{width:i,height:n}),SetMinSize:(i,n)=>e(Ne,{width:i,height:n}),SetAlwaysOnTop:i=>e(ze,{alwaysOnTop:i}),SetRelativePosition:(i,n)=>e(He,{x:i,y:n}),RelativePosition:()=>e(Ze),Screen:()=>e(Ve),Hide:()=>e(_e),Maximise:()=>e(je),UnMaximise:()=>e(Ge),ToggleMaximise:()=>e(Ke),Minimise:()=>e(Qe),UnMinimise:()=>e(qe),Restore:()=>e(Je),Show:()=>e(Ye),Close:()=>e(Xe),SetBackgroundColour:(i,n,o,t)=>e($e,{r:i,g:n,b:o,a:t}),SetResizable:i=>e(ei,{resizable:i}),Width:()=>e(ii),Height:()=>e(ni),ZoomIn:()=>e(oi),ZoomOut:()=>e(ti),ZoomReset:()=>e(ai),GetZoomLevel:()=>e(ri),SetZoomLevel:i=>e(di,{zoomLevel:i})}}function M(e){return _(d(r.Window,e))}function li(){a.Center()}function ci(e){a.SetTitle(e)}function si(){a.Fullscreen()}function wi(e,i){a.SetSize(e,i)}function mi(){return a.Size()}function ui(e,i){a.SetMaxSize(e,i)}function pi(e,i){a.SetMinSize(e,i)}function Wi(e){a.SetAlwaysOnTop(e)}function gi(e,i){a.SetRelativePosition(e,i)}function hi(){return a.RelativePosition()}function fi(){return a.Screen()}function Di(){a.Hide()}function Si(){a.Maximise()}function Mi(){a.UnMaximise()}function Ci(){a.ToggleMaximise()}function xi(){a.Minimise()}function Ai(){a.UnMinimise()}function vi(){a.Restore()}function Ri(){a.Show()}function bi(){a.Close()}function Ui(e,i,n,o){a.SetBackgroundColour(e,i,n,o)}function Ei(e){a.SetResizable(e)}function Oi(){return a.Width()}function Ti(){return a.Height()}function Bi(){a.ZoomIn()}function Pi(){a.ZoomOut()}function Ii(){a.ZoomReset()}function Fi(){return a.GetZoomLevel()}function yi(e){a.SetZoomLevel(e)}var z={};c(z,{Reload:()=>N});var L={};c(L,{Emit:()=>y,Off:()=>ji,OffAll:()=>Gi,On:()=>Zi,OnMultiple:()=>F,Once:()=>Vi,Types:()=>Li,WailsEvent:()=>g,setup:()=>zi});var j={Windows:{SystemThemeChanged:"windows:SystemThemeChanged",APMPowerStatusChange:"windows:APMPowerStatusChange",APMSuspend:"windows:APMSuspend",APMResumeAutomatic:"windows:APMResumeAutomatic",APMResumeSuspend:"windows:APMResumeSuspend",APMPowerSettingChange:"windows:APMPowerSettingChange",ApplicationStarted:"windows:ApplicationStarted",WebViewNavigationCompleted:"windows:WebViewNavigationCompleted",WindowInactive:"windows:WindowInactive",WindowActive:"windows:WindowActive",WindowClickActive:"windows:WindowClickActive",WindowMaximise:"windows:WindowMaximise",WindowUnMaximise:"windows:WindowUnMaximise",WindowFullscreen:"windows:WindowFullscreen",WindowUnFullscreen:"windows:WindowUnFullscreen",WindowRestore:"windows:WindowRestore",WindowMinimise:"windows:WindowMinimise",WindowUnMinimise:"windows:WindowUnMinimise",WindowClose:"windows:WindowClose",WindowSetFocus:"windows:WindowSetFocus",WindowKillFocus:"windows:WindowKillFocus",WindowDragDrop:"windows:WindowDragDrop",WindowDragEnter:"windows:WindowDragEnter",WindowDragLeave:"windows:WindowDragLeave",WindowDragOver:"windows:WindowDragOver"},Mac:{ApplicationDidBecomeActive:"mac:ApplicationDidBecomeActive",ApplicationDidChangeBackingProperties:"mac:ApplicationDidChangeBackingProperties",ApplicationDidChangeEffectiveAppearance:"mac:ApplicationDidChangeEffectiveAppearance",ApplicationDidChangeIcon:"mac:ApplicationDidChangeIcon",ApplicationDidChangeOcclusionState:"mac:ApplicationDidChangeOcclusionState",ApplicationDidChangeScreenParameters:"mac:ApplicationDidChangeScreenParameters",ApplicationDidChangeStatusBarFrame:"mac:ApplicationDidChangeStatusBarFrame",ApplicationDidChangeStatusBarOrientation:"mac:ApplicationDidChangeStatusBarOrientation",ApplicationDidFinishLaunching:"mac:ApplicationDidFinishLaunching",ApplicationDidHide:"mac:ApplicationDidHide",ApplicationDidResignActiveNotification:"mac:ApplicationDidResignActiveNotification",ApplicationDidUnhide:"mac:ApplicationDidUnhide",ApplicationDidUpdate:"mac:ApplicationDidUpdate",ApplicationWillBecomeActive:"mac:ApplicationWillBecomeActive",ApplicationWillFinishLaunching:"mac:ApplicationWillFinishLaunching",ApplicationWillHide:"mac:ApplicationWillHide",ApplicationWillResignActive:"mac:ApplicationWillResignActive",ApplicationWillTerminate:"mac:ApplicationWillTerminate",ApplicationWillUnhide:"mac:ApplicationWillUnhide",ApplicationWillUpdate:"mac:ApplicationWillUpdate",ApplicationDidChangeTheme:"mac:ApplicationDidChangeTheme!",ApplicationShouldHandleReopen:"mac:ApplicationShouldHandleReopen!",WindowDidBecomeKey:"mac:WindowDidBecomeKey",WindowDidBecomeMain:"mac:WindowDidBecomeMain",WindowDidBeginSheet:"mac:WindowDidBeginSheet",WindowDidChangeAlpha:"mac:WindowDidChangeAlpha",WindowDidChangeBackingLocation:"mac:WindowDidChangeBackingLocation",WindowDidChangeBackingProperties:"mac:WindowDidChangeBackingProperties",WindowDidChangeCollectionBehavior:"mac:WindowDidChangeCollectionBehavior",WindowDidChangeEffectiveAppearance:"mac:WindowDidChangeEffectiveAppearance",WindowDidChangeOcclusionState:"mac:WindowDidChangeOcclusionState",WindowDidChangeOrderingMode:"mac:WindowDidChangeOrderingMode",WindowDidChangeScreen:"mac:WindowDidChangeScreen",WindowDidChangeScreenParameters:"mac:WindowDidChangeScreenParameters",WindowDidChangeScreenProfile:"mac:WindowDidChangeScreenProfile",WindowDidChangeScreenSpace:"mac:WindowDidChangeScreenSpace",WindowDidChangeScreenSpaceProperties:"mac:WindowDidChangeScreenSpaceProperties",WindowDidChangeSharingType:"mac:WindowDidChangeSharingType",WindowDidChangeSpace:"mac:WindowDidChangeSpace",WindowDidChangeSpaceOrderingMode:"mac:WindowDidChangeSpaceOrderingMode",WindowDidChangeTitle:"mac:WindowDidChangeTitle",WindowDidChangeToolbar:"mac:WindowDidChangeToolbar",WindowDidChangeVisibility:"mac:WindowDidChangeVisibility",WindowDidDeminiaturize:"mac:WindowDidDeminiaturize",WindowDidEndSheet:"mac:WindowDidEndSheet",WindowDidEnterFullScreen:"mac:WindowDidEnterFullScreen",WindowDidEnterVersionBrowser:"mac:WindowDidEnterVersionBrowser",WindowDidExitFullScreen:"mac:WindowDidExitFullScreen",WindowDidExitVersionBrowser:"mac:WindowDidExitVersionBrowser",WindowDidExpose:"mac:WindowDidExpose",WindowDidFocus:"mac:WindowDidFocus",WindowDidMiniaturize:"mac:WindowDidMiniaturize",WindowDidMove:"mac:WindowDidMove",WindowDidOrderOffScreen:"mac:WindowDidOrderOffScreen",WindowDidOrderOnScreen:"mac:WindowDidOrderOnScreen",WindowDidResignKey:"mac:WindowDidResignKey",WindowDidResignMain:"mac:WindowDidResignMain",WindowDidResize:"mac:WindowDidResize",WindowDidUpdate:"mac:WindowDidUpdate",WindowDidUpdateAlpha:"mac:WindowDidUpdateAlpha",WindowDidUpdateCollectionBehavior:"mac:WindowDidUpdateCollectionBehavior",WindowDidUpdateCollectionProperties:"mac:WindowDidUpdateCollectionProperties",WindowDidUpdateShadow:"mac:WindowDidUpdateShadow",WindowDidUpdateTitle:"mac:WindowDidUpdateTitle",WindowDidUpdateToolbar:"mac:WindowDidUpdateToolbar",WindowDidUpdateVisibility:"mac:WindowDidUpdateVisibility",WindowShouldClose:"mac:WindowShouldClose!",WindowWillBecomeKey:"mac:WindowWillBecomeKey",WindowWillBecomeMain:"mac:WindowWillBecomeMain",WindowWillBeginSheet:"mac:WindowWillBeginSheet",WindowWillChangeOrderingMode:"mac:WindowWillChangeOrderingMode",WindowWillClose:"mac:WindowWillClose",WindowWillDeminiaturize:"mac:WindowWillDeminiaturize",WindowWillEnterFullScreen:"mac:WindowWillEnterFullScreen",WindowWillEnterVersionBrowser:"mac:WindowWillEnterVersionBrowser",WindowWillExitFullScreen:"mac:WindowWillExitFullScreen",WindowWillExitVersionBrowser:"mac:WindowWillExitVersionBrowser",WindowWillFocus:"mac:WindowWillFocus",WindowWillMiniaturize:"mac:WindowWillMiniaturize",WindowWillMove:"mac:WindowWillMove",WindowWillOrderOffScreen:"mac:WindowWillOrderOffScreen",WindowWillOrderOnScreen:"mac:WindowWillOrderOnScreen",WindowWillResignMain:"mac:WindowWillResignMain",WindowWillResize:"mac:WindowWillResize",WindowWillUnfocus:"mac:WindowWillUnfocus",WindowWillUpdate:"mac:WindowWillUpdate",WindowWillUpdateAlpha:"mac:WindowWillUpdateAlpha",WindowWillUpdateCollectionBehavior:"mac:WindowWillUpdateCollectionBehavior",WindowWillUpdateCollectionProperties:"mac:WindowWillUpdateCollectionProperties",WindowWillUpdateShadow:"mac:WindowWillUpdateShadow",WindowWillUpdateTitle:"mac:WindowWillUpdateTitle",WindowWillUpdateToolbar:"mac:WindowWillUpdateToolbar",WindowWillUpdateVisibility:"mac:WindowWillUpdateVisibility",WindowWillUseStandardFrame:"mac:WindowWillUseStandardFrame",MenuWillOpen:"mac:MenuWillOpen",MenuDidOpen:"mac:MenuDidOpen",MenuDidClose:"mac:MenuDidClose",MenuWillSendAction:"mac:MenuWillSendAction",MenuDidSendAction:"mac:MenuDidSendAction",MenuWillHighlightItem:"mac:MenuWillHighlightItem",MenuDidHighlightItem:"mac:MenuDidHighlightItem",MenuWillDisplayItem:"mac:MenuWillDisplayItem",MenuDidDisplayItem:"mac:MenuDidDisplayItem",MenuWillAddItem:"mac:MenuWillAddItem",MenuDidAddItem:"mac:MenuDidAddItem",MenuWillRemoveItem:"mac:MenuWillRemoveItem",MenuDidRemoveItem:"mac:MenuDidRemoveItem",MenuWillBeginTracking:"mac:MenuWillBeginTracking",MenuDidBeginTracking:"mac:MenuDidBeginTracking",MenuWillEndTracking:"mac:MenuWillEndTracking",MenuDidEndTracking:"mac:MenuDidEndTracking",MenuWillUpdate:"mac:MenuWillUpdate",MenuDidUpdate:"mac:MenuDidUpdate",MenuWillPopUp:"mac:MenuWillPopUp",MenuDidPopUp:"mac:MenuDidPopUp",MenuWillSendActionToItem:"mac:MenuWillSendActionToItem",MenuDidSendActionToItem:"mac:MenuDidSendActionToItem",WebViewDidStartProvisionalNavigation:"mac:WebViewDidStartProvisionalNavigation",WebViewDidReceiveServerRedirectForProvisionalNavigation:"mac:WebViewDidReceiveServerRedirectForProvisionalNavigation",WebViewDidFinishNavigation:"mac:WebViewDidFinishNavigation",WebViewDidCommitNavigation:"mac:WebViewDidCommitNavigation",WindowFileDraggingEntered:"mac:WindowFileDraggingEntered",WindowFileDraggingPerformed:"mac:WindowFileDraggingPerformed",WindowFileDraggingExited:"mac:WindowFileDraggingExited"},Linux:{SystemThemeChanged:"linux:SystemThemeChanged"},Common:{ApplicationStarted:"common:ApplicationStarted",WindowMaximise:"common:WindowMaximise",WindowUnMaximise:"common:WindowUnMaximise",WindowFullscreen:"common:WindowFullscreen",WindowUnFullscreen:"common:WindowUnFullscreen",WindowRestore:"common:WindowRestore",WindowMinimise:"common:WindowMinimise",WindowUnMinimise:"common:WindowUnMinimise",WindowClosing:"common:WindowClosing",WindowZoom:"common:WindowZoom",WindowZoomIn:"common:WindowZoomIn",WindowZoomOut:"common:WindowZoomOut",WindowZoomReset:"common:WindowZoomReset",WindowFocus:"common:WindowFocus",WindowLostFocus:"common:WindowLostFocus",WindowShow:"common:WindowShow",WindowHide:"common:WindowHide",WindowDPIChanged:"common:WindowDPIChanged",WindowFilesDropped:"common:WindowFilesDropped",WindowRuntimeReady:"common:WindowRuntimeReady",ThemeChanged:"common:ThemeChanged"}};var Li=j;window._wails=window._wails||{};window._wails.dispatchWailsEvent=Hi;var ki=d(r.Events,""),Ni=0,w=new Map,I=class{constructor(i,n,o){this.eventName=i,this.maxCallbacks=o||-1,this.Callback=t=>(n(t),this.maxCallbacks===-1?!1:(this.maxCallbacks-=1,this.maxCallbacks===0))}},g=class{constructor(i,n=null){this.name=i,this.data=n}};function zi(){}function Hi(e){let i=w.get(e.name);if(i){let n=i.filter(o=>{if(o.Callback(e))return!0});n.length>0&&(i=i.filter(o=>!n.includes(o)),i.length===0?w.delete(e.name):w.set(e.name,i))}}function F(e,i,n){let o=w.get(e)||[],t=new I(e,i,n);return o.push(t),w.set(e,o),()=>_i(t)}function Zi(e,i){return F(e,i,-1)}function Vi(e,i){return F(e,i,1)}function _i(e){let i=e.eventName,n=w.get(i).filter(o=>o!==e);n.length===0?w.delete(i):w.set(i,n)}function ji(e,...i){[e,...i].forEach(o=>w.delete(o))}function Gi(){w.clear()}function y(e){return ki(Ni,e)}var k={};c(k,{Error:()=>rn,Info:()=>tn,OpenFile:()=>dn,Question:()=>h,SaveFile:()=>ln,Warning:()=>an});window._wails=window._wails||{};window._wails.dialogErrorCallback=on;window._wails.dialogResultCallback=nn;var Ki=0,Qi=1,qi=2,Ji=3,Yi=4,Xi=5,$i=d(r.Dialog,""),u=new Map;function en(){let e;do e=p();while(u.has(e));return e}function W(e,i={}){let n=en();return i["dialog-id"]=n,new Promise((o,t)=>{u.set(n,{resolve:o,reject:t}),$i(e,i).catch(l=>{t(l),u.delete(n)})})}function nn(e,i,n){let o=u.get(e);o&&(n?o.resolve(JSON.parse(i)):o.resolve(i),u.delete(e))}function on(e,i){let n=u.get(e);n&&(n.reject(i),u.delete(e))}var tn=e=>W(Ki,e),an=e=>W(Qi,e),rn=e=>W(qi,e),h=e=>W(Ji,e),dn=e=>W(Yi,e),ln=e=>W(Xi,e);function G(e,i=null){let n=new g(e,i);y(n)}function cn(){document.querySelectorAll("[wml-event]").forEach(function(i){let n=i.getAttribute("wml-event"),o=i.getAttribute("wml-confirm"),t=i.getAttribute("wml-trigger")||"click",l=function(){if(o){h({Title:"Confirm",Message:o,Detached:!1,Buttons:[{Label:"Yes"},{Label:"No",IsDefault:!0}]}).then(function(m){m!=="No"&&G(n)});return}G(n)};i.removeEventListener(t,l),i.addEventListener(t,l)})}function K(e,i){let n=M(e),o=mn(n);o.has(i);try{o.get(i)()}catch{}}function sn(){document.querySelectorAll("[wml-window]").forEach(function(i){let n=i.getAttribute("wml-window"),o=i.getAttribute("wml-confirm"),t=i.getAttribute("wml-trigger")||"click",l=i.getAttribute("wml-target-window")||"",m=function(){if(o){h({Title:"Confirm",Message:o,Buttons:[{Label:"Yes"},{Label:"No",IsDefault:!0}]}).then(function(D){D!=="No"&&K(l,n)});return}K(l,n)};i.removeEventListener(t,m),i.addEventListener(t,m)})}function wn(){document.querySelectorAll("[wml-openurl]").forEach(function(i){let n=i.getAttribute("wml-openurl"),o=i.getAttribute("wml-confirm"),t=i.getAttribute("wml-trigger")||"click",l=function(){if(o){h({Title:"Confirm",Message:o,Buttons:[{Label:"Yes"},{Label:"No",IsDefault:!0}]}).then(function(m){m!=="No"&&S(n)});return}S(n)};i.removeEventListener(t,l),i.addEventListener(t,l)})}function N(){cn(),sn(),wn()}function mn(e){let i=new Map;for(let n in e)typeof e[n]=="function"&&i.set(n,e[n]);return i}var H={};c(H,{ByID:()=>Dn,ByName:()=>fn,Call:()=>hn,Plugin:()=>Sn});window._wails=window._wails||{};window._wails.callResultHandler=Wn;window._wails.callErrorHandler=gn;var C=0,un=d(r.Call,""),f=new Map;function pn(){let e;do e=p();while(f.has(e));return e}function Wn(e,i,n){let o=Q(e);o&&o.resolve(n?JSON.parse(i):i)}function gn(e,i){let n=Q(e);n&&n.reject(i)}function Q(e){let i=f.get(e);return f.delete(e),i}function x(e,i={}){return new Promise((n,o)=>{let t=pn();i["call-id"]=t,f.set(t,{resolve:n,reject:o}),un(e,i).catch(l=>{o(l),f.delete(t)})})}function hn(e){return x(C,e)}function fn(e,...i){if(typeof e!="string"||e.split(".").length!==3)throw new Error("CallByName requires a string in the format 'package.struct.method'");let[n,o,t]=e.split(".");return x(C,{packageName:n,structName:o,methodName:t,args:i})}function Dn(e,...i){return x(C,{methodID:e,args:i})}function Sn(e,i,...n){return x(C,{packageName:"wails-plugins",structName:e,methodName:i,args:n})}window._wails=window._wails||{};window._wails.invoke=T;window.wails=window.wails||{};window.wails.Application=v;window.wails.Browser=R;window.wails.Call=H;window.wails.Clipboard=b;window.wails.Dialogs=k;window.wails.Events=L;window.wails.Flags=U;window.wails.Screens=O;window.wails.System=B;window.wails.Window=P;window.wails.WML=z;var q=!1;document.addEventListener("DOMContentLoaded",function(){q=!0,window._wails.invoke("wails:runtime:ready")});function Mn(e){q||document.readyState==="complete"?e():document.addEventListener("DOMContentLoaded",e)}Mn(()=>{N()});})();
diff --git a/v3/internal/commands/build_assets/runtime/compiled.go b/v3/internal/commands/build_assets/runtime/compiled.go
new file mode 100644
index 00000000..5a7c2466
--- /dev/null
+++ b/v3/internal/commands/build_assets/runtime/compiled.go
@@ -0,0 +1,9 @@
+package runtime
+
+import _ "embed"
+
+//go:embed runtime.js
+var runtimeJS []byte
+
+//go:embed runtime.debug.js
+var runtimeDebugJS []byte
diff --git a/v3/internal/runtime/Taskfile.yaml b/v3/internal/runtime/Taskfile.yaml
index 3cddd9c6..5ad93cab 100644
--- a/v3/internal/runtime/Taskfile.yaml
+++ b/v3/internal/runtime/Taskfile.yaml
@@ -21,12 +21,12 @@ tasks:
build:debug:
internal: true
cmds:
- - npx esbuild@latest desktop/main.js --bundle --tree-shaking=true --sourcemap=inline --outfile=runtime_debug.js --define:DEBUG=true
+ - npx esbuild@latest desktop/compiled/main.js --bundle --tree-shaking=true --sourcemap=inline --outfile=../commands/build_assets/runtime/runtime.debug.js --define:DEBUG=true
build:production:
internal: true
cmds:
- - npx esbuild@latest desktop/main.js --bundle --tree-shaking=true --minify --outfile=runtime.js --drop:console
+ - npx esbuild@latest desktop/compiled/main.js --bundle --tree-shaking=true --minify --outfile=../commands/build_assets/runtime/runtime.js --define:DEBUG=false --drop:console
build:all:
internal: true
diff --git a/v3/internal/runtime/assets.go b/v3/internal/runtime/assets.go
deleted file mode 100644
index 5d63f2c4..00000000
--- a/v3/internal/runtime/assets.go
+++ /dev/null
@@ -1,28 +0,0 @@
-//go:build production
-
-package runtime
-
-import _ "embed"
-
-//go:embed runtime.js
-var DesktopRuntime []byte
-
-var RuntimeAssetsBundle = &RuntimeAssets{
- runtimeDesktopJS: DesktopRuntime,
-}
-
-type RuntimeAssets struct {
- runtimeDesktopJS []byte
-}
-
-func (r *RuntimeAssets) DesktopIPC() []byte {
- return []byte("")
-}
-
-func (r *RuntimeAssets) WebsocketIPC() []byte {
- return []byte("")
-}
-
-func (r *RuntimeAssets) RuntimeDesktopJS() []byte {
- return r.runtimeDesktopJS
-}
diff --git a/v3/internal/runtime/assets_dev.go b/v3/internal/runtime/assets_dev.go
deleted file mode 100644
index ef12f467..00000000
--- a/v3/internal/runtime/assets_dev.go
+++ /dev/null
@@ -1,28 +0,0 @@
-//go:build !production
-
-package runtime
-
-import _ "embed"
-
-//go:embed runtime_debug.js
-var DesktopRuntime []byte
-
-var RuntimeAssetsBundle = &RuntimeAssets{
- runtimeDesktopJS: DesktopRuntime,
-}
-
-type RuntimeAssets struct {
- runtimeDesktopJS []byte
-}
-
-func (r *RuntimeAssets) DesktopIPC() []byte {
- return []byte("")
-}
-
-func (r *RuntimeAssets) WebsocketIPC() []byte {
- return []byte("")
-}
-
-func (r *RuntimeAssets) RuntimeDesktopJS() []byte {
- return r.runtimeDesktopJS
-}
diff --git a/v3/internal/runtime/desktop/@wailsio/runtime/.npmignore b/v3/internal/runtime/desktop/@wailsio/runtime/.npmignore
index 79979966..bf2b35cf 100644
--- a/v3/internal/runtime/desktop/@wailsio/runtime/.npmignore
+++ b/v3/internal/runtime/desktop/@wailsio/runtime/.npmignore
@@ -1,2 +1,4 @@
events.test.js
-node_modules
\ No newline at end of file
+node_modules
+types/drag.d.ts
+types/contextmenu.d.ts
\ No newline at end of file
diff --git a/v3/internal/runtime/desktop/@wailsio/runtime/src/calls.js b/v3/internal/runtime/desktop/@wailsio/runtime/src/calls.js
index 3585441e..7b2456e4 100644
--- a/v3/internal/runtime/desktop/@wailsio/runtime/src/calls.js
+++ b/v3/internal/runtime/desktop/@wailsio/runtime/src/calls.js
@@ -12,14 +12,16 @@ The electron alternative for Go
import { newRuntimeCallerWithID, objectNames } from "./runtime";
import { nanoid } from 'nanoid/non-secure';
-const CallBinding = 0;
-const call = newRuntimeCallerWithID(objectNames.Call, '');
-let callResponses = new Map();
-
+// Setup
window._wails = window._wails || {};
window._wails.callResultHandler = resultHandler;
window._wails.callErrorHandler = errorHandler;
+
+const CallBinding = 0;
+const call = newRuntimeCallerWithID(objectNames.Call, '');
+let callResponses = new Map();
+
/**
* Generates a unique ID using the nanoid library.
*
diff --git a/v3/internal/runtime/desktop/@wailsio/runtime/src/contextmenu.js b/v3/internal/runtime/desktop/@wailsio/runtime/src/contextmenu.js
index dbe9d425..ab074990 100644
--- a/v3/internal/runtime/desktop/@wailsio/runtime/src/contextmenu.js
+++ b/v3/internal/runtime/desktop/@wailsio/runtime/src/contextmenu.js
@@ -13,6 +13,9 @@ The electron alternative for Go
import {newRuntimeCallerWithID, objectNames} from "./runtime";
import {IsDebug} from "./system";
+// setup
+window.addEventListener('contextmenu', contextMenuHandler);
+
const call = newRuntimeCallerWithID(objectNames.ContextMenu, '');
const ContextMenuOpen = 0;
@@ -20,10 +23,6 @@ function openContextMenu(id, x, y, data) {
void call(ContextMenuOpen, {id, x, y, data});
}
-export function setupContextMenus() {
- window.addEventListener('contextmenu', contextMenuHandler);
-}
-
function contextMenuHandler(event) {
// Check for custom context menu
let element = event.target;
diff --git a/v3/internal/runtime/desktop/@wailsio/runtime/src/dialogs.js b/v3/internal/runtime/desktop/@wailsio/runtime/src/dialogs.js
index 500a4df2..0987331b 100644
--- a/v3/internal/runtime/desktop/@wailsio/runtime/src/dialogs.js
+++ b/v3/internal/runtime/desktop/@wailsio/runtime/src/dialogs.js
@@ -73,6 +73,11 @@ The electron alternative for Go
* @property {string} [Pattern] - Pattern to match for the filter, e.g. "*.txt;*.md" for text markdown files.
*/
+// setup
+window._wails = window._wails || {};
+window._wails.dialogErrorCallback = dialogErrorCallback;
+window._wails.dialogResultCallback = dialogResultCallback;
+
import {newRuntimeCallerWithID, objectNames} from "./runtime";
import { nanoid } from 'nanoid/non-secure';
@@ -118,10 +123,6 @@ function dialog(type, options = {}) {
});
}
-window._wails = window._wails || {};
-window._wails.dialogErrorCallback = dialogErrorCallback;
-window._wails.dialogResultCallback = dialogResultCallback;
-
/**
* Handles the callback from a dialog.
*
diff --git a/v3/internal/runtime/desktop/@wailsio/runtime/src/drag.js b/v3/internal/runtime/desktop/@wailsio/runtime/src/drag.js
index 3eb50bee..66b4b8b0 100644
--- a/v3/internal/runtime/desktop/@wailsio/runtime/src/drag.js
+++ b/v3/internal/runtime/desktop/@wailsio/runtime/src/drag.js
@@ -13,15 +13,20 @@ The electron alternative for Go
import {invoke, IsWindows} from "./system";
import {GetFlag} from "./flags";
+// Setup
+window._wails = window._wails || {};
+window._wails.setResizable = setResizable;
+window._wails.endDrag = endDrag;
+window.addEventListener('mousedown', onMouseDown);
+window.addEventListener('mousemove', onMouseMove);
+window.addEventListener('mouseup', onMouseUp);
+
let shouldDrag = false;
let resizeEdge = null;
let resizable = false;
let defaultCursor = "auto";
-window._wails = window._wails || {};
-window._wails.setResizable = setResizable;
-window._wails.endDrag = endDrag;
-export function dragTest(e) {
+function dragTest(e) {
let val = window.getComputedStyle(e.target).getPropertyValue("--webkit-app-region");
if (!val || val === "" || val.trim() !== "drag" || e.buttons !== 1) {
return false;
@@ -29,17 +34,11 @@ export function dragTest(e) {
return e.detail === 1;
}
-export function setupDrag() {
- window.addEventListener('mousedown', onMouseDown);
- window.addEventListener('mousemove', onMouseMove);
- window.addEventListener('mouseup', onMouseUp);
-}
-
-export function setResizable(value) {
+function setResizable(value) {
resizable = value;
}
-export function endDrag() {
+function endDrag() {
document.body.style.cursor = 'default';
shouldDrag = false;
}
diff --git a/v3/internal/runtime/desktop/@wailsio/runtime/src/event_types.js b/v3/internal/runtime/desktop/@wailsio/runtime/src/event_types.js
index 9c4cfabf..76aa8135 100644
--- a/v3/internal/runtime/desktop/@wailsio/runtime/src/event_types.js
+++ b/v3/internal/runtime/desktop/@wailsio/runtime/src/event_types.js
@@ -176,6 +176,7 @@ export const EventTypes = {
WindowHide: "common:WindowHide",
WindowDPIChanged: "common:WindowDPIChanged",
WindowFilesDropped: "common:WindowFilesDropped",
+ WindowRuntimeReady: "common:WindowRuntimeReady",
ThemeChanged: "common:ThemeChanged",
},
};
diff --git a/v3/internal/runtime/desktop/@wailsio/runtime/src/events.js b/v3/internal/runtime/desktop/@wailsio/runtime/src/events.js
index 605888b7..afbcbb92 100644
--- a/v3/internal/runtime/desktop/@wailsio/runtime/src/events.js
+++ b/v3/internal/runtime/desktop/@wailsio/runtime/src/events.js
@@ -18,6 +18,10 @@ import {newRuntimeCallerWithID, objectNames} from "./runtime";
import {EventTypes} from "./event_types";
export const Types = EventTypes;
+// Setup
+window._wails = window._wails || {};
+window._wails.dispatchWailsEvent = dispatchWailsEvent;
+
const call = newRuntimeCallerWithID(objectNames.Events, '');
const EmitMethod = 0;
const eventListeners = new Map();
@@ -42,19 +46,7 @@ export class WailsEvent {
}
}
-/**
- * Sets up event callbacks for Wails.
- *
- * @function setupEventCallbacks
- *
- * @description This method is responsible for setting up event callbacks for Wails. It checks if the global object `_wails` exists on the `window` object, and if not, initializes it
- *. It then assigns the `dispatchWailsEvent` function as a property on the `_wails` object.
- *
- * @returns {undefined} Returns nothing.
- */
-export function setupEventCallbacks() {
- window._wails = window._wails || {};
- window._wails.dispatchWailsEvent = dispatchWailsEvent;
+export function setup() {
}
function dispatchWailsEvent(event) {
diff --git a/v3/internal/runtime/desktop/@wailsio/runtime/src/events.test.js b/v3/internal/runtime/desktop/@wailsio/runtime/src/events.test.js
index ed11c33e..c46868cb 100644
--- a/v3/internal/runtime/desktop/@wailsio/runtime/src/events.test.js
+++ b/v3/internal/runtime/desktop/@wailsio/runtime/src/events.test.js
@@ -58,28 +58,7 @@ describe('Once', () => {
cancel();
})
})
-//
-// describe('EventsNotify', () => {
-// it('should inform a listener', () => {
-// const cb = vi.fn()
-// EventsOn('a', cb)
-// EventsNotify(JSON.stringify({name: 'a', data: ["one", "two", "three"]}))
-// expect(cb).toBeCalledTimes(1);
-// expect(cb).toHaveBeenLastCalledWith("one", "two", "three");
-// expect(window.WailsInvoke).toBeCalledTimes(0);
-// })
-// })
-//
-// describe('EventsEmit', () => {
-// it('should emit an event', () => {
-// EventsEmit('a', 'one', 'two', 'three')
-// expect(window.WailsInvoke).toBeCalledTimes(1);
-// const calledWith = window.WailsInvoke.calls[0][0];
-// expect(calledWith.slice(0, 2)).toBe('EE')
-// expect(JSON.parse(calledWith.slice(2))).toStrictEqual({data: ["one", "two", "three"], name: "a"})
-// })
-// })
-//
+
describe('Off', () => {
beforeEach(() => {
On('a', () => {})
diff --git a/v3/internal/runtime/desktop/@wailsio/runtime/src/flags.js b/v3/internal/runtime/desktop/@wailsio/runtime/src/flags.js
index 153373f5..26be59d7 100644
--- a/v3/internal/runtime/desktop/@wailsio/runtime/src/flags.js
+++ b/v3/internal/runtime/desktop/@wailsio/runtime/src/flags.js
@@ -10,48 +10,6 @@ The electron alternative for Go
/* jshint esversion: 9 */
-let flags = new Map();
-
-function convertToMap(obj) {
- const map = new Map();
-
- for (const [key, value] of Object.entries(obj)) {
- if (typeof value === 'object' && value !== null) {
- map.set(key, convertToMap(value)); // Recursively convert nested object
- } else {
- map.set(key, value);
- }
- }
-
- return map;
-}
-
-fetch("/wails/flags").then((response) => {
- response.json().then((data) => {
- flags = convertToMap(data);
- });
-});
-
-
-function getValueFromMap(keyString) {
- const keys = keyString.split('.');
- let value = flags;
-
- for (const key of keys) {
- if (value instanceof Map) {
- value = value.get(key);
- } else {
- value = value[key];
- }
-
- if (value === undefined) {
- break;
- }
- }
-
- return value;
-}
-
/**
* Retrieves the value associated with the specified key from the flag map.
*
@@ -59,5 +17,9 @@ function getValueFromMap(keyString) {
* @return {*} - The value associated with the specified key.
*/
export function GetFlag(keyString) {
- return getValueFromMap(keyString);
+ try {
+ return window._wails.flags[keyString];
+ } catch (e) {
+ throw new Error("Unable to retrieve flag '" + keyString + "': " + e);
+ }
}
diff --git a/v3/internal/runtime/desktop/@wailsio/runtime/src/index.js b/v3/internal/runtime/desktop/@wailsio/runtime/src/index.js
index 7a983300..75499500 100644
--- a/v3/internal/runtime/desktop/@wailsio/runtime/src/index.js
+++ b/v3/internal/runtime/desktop/@wailsio/runtime/src/index.js
@@ -8,9 +8,9 @@ The electron alternative for Go
(c) Lea Anthony 2019-present
*/
-import {setupContextMenus} from "./contextmenu";
-import {setupDrag} from "./drag";
-import {ByID, ByName, Plugin} from "./calls";
+// Setup
+window.wails = window.wails || {};
+window._wails = window._wails || {};
import * as Application from "./application";
import * as Browser from "./browser";
@@ -23,7 +23,8 @@ import * as WML from './wml';
import * as Events from "./events";
import * as Dialogs from "./dialogs";
import * as Call from "./calls";
-import {setupEventCallbacks} from "./events";
+import {invoke} from "./system";
+
export { Application, Browser, Call, Clipboard, Dialogs, Events, Flags, Screens, System, Window, WML};
@@ -59,7 +60,22 @@ export { Application, Browser, Call, Clipboard, Dialogs, Events, Flags, Screens,
***/
-let isReady = false
+window.wails = {
+ Application,
+ Browser,
+ Call,
+ Clipboard,
+ Dialogs,
+ Events,
+ Flags,
+ Screens,
+ System,
+ Window,
+ WML,
+};
+invoke('wails:runtime:ready');
+
+let isReady = false;
document.addEventListener('DOMContentLoaded', function() {
isReady = true
})
@@ -73,8 +89,5 @@ function whenReady(fn) {
}
whenReady(() => {
- setupContextMenus();
- setupDrag();
- setupEventCallbacks();
WML.Reload();
});
diff --git a/v3/internal/runtime/desktop/@wailsio/runtime/src/log.js b/v3/internal/runtime/desktop/@wailsio/runtime/src/log.js
new file mode 100644
index 00000000..f21e0653
--- /dev/null
+++ b/v3/internal/runtime/desktop/@wailsio/runtime/src/log.js
@@ -0,0 +1,13 @@
+/**
+ * Logs a message to the console with custom formatting.
+ * @param {string} message - The message to be logged.
+ * @return {void}
+ */
+export function debugLog(message) {
+ // eslint-disable-next-line
+ console.log(
+ '%c wails3 %c ' + message + ' ',
+ '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'
+ );
+}
\ No newline at end of file
diff --git a/v3/internal/runtime/desktop/@wailsio/runtime/src/system.js b/v3/internal/runtime/desktop/@wailsio/runtime/src/system.js
index 54d2e238..e8677e09 100644
--- a/v3/internal/runtime/desktop/@wailsio/runtime/src/system.js
+++ b/v3/internal/runtime/desktop/@wailsio/runtime/src/system.js
@@ -15,6 +15,13 @@ let call = newRuntimeCallerWithID(objectNames.System, '');
const systemIsDarkMode = 0;
const environment = 1;
+export function invoke(msg) {
+ if(window.chrome) {
+ return window.chrome.webview.postMessage(msg);
+ }
+ return window.webkit.messageHandlers.external.postMessage;
+}
+
/**
* @function
* Retrieves the system dark mode status.
@@ -24,7 +31,6 @@ export function IsDarkMode() {
return call(systemIsDarkMode);
}
-
/**
* Fetches the capabilities of the application from the server.
*
@@ -32,7 +38,7 @@ export function IsDarkMode() {
* @function Capabilities
* @returns {Promise