diff --git a/v2/pkg/commands/build/build.go b/v2/pkg/commands/build/build.go index f48872cf5..26beea575 100644 --- a/v2/pkg/commands/build/build.go +++ b/v2/pkg/commands/build/build.go @@ -113,10 +113,10 @@ func Build(options *Options) (string, error) { } // Build the base assets - err = builder.BuildAssets(options) - if err != nil { - return "", err - } + //err = builder.BuildAssets(options) + //if err != nil { + // return "", err + //} // If we are building for windows, we will need to generate the asset bundle before // compilation. This will be a .syso file in the project root diff --git a/v2/pkg/commands/build/desktop.go b/v2/pkg/commands/build/desktop.go index 54e248c6b..76623c01a 100644 --- a/v2/pkg/commands/build/desktop.go +++ b/v2/pkg/commands/build/desktop.go @@ -2,7 +2,6 @@ package build import ( "fmt" - "github.com/leaanthony/slicer" "github.com/wailsapp/wails/v2/pkg/buildassets" "io/ioutil" "path/filepath" @@ -24,7 +23,6 @@ func newDesktopBuilder(options *Options) *DesktopBuilder { // BuildAssets builds the assets for the desktop application func (d *DesktopBuilder) BuildAssets(options *Options) error { - var err error // Check assets directory exists if !fs.DirExists(options.ProjectData.BuildDir) { @@ -36,22 +34,20 @@ func (d *DesktopBuilder) BuildAssets(options *Options) error { } // We only build assets for cgo builds - userTags := slicer.String(options.UserTags) - if userTags.Contains("experimental") { - return nil - } - - // Get a list of assets from the HTML - assets, err := d.BaseBuilder.ExtractAssets() - if err != nil { - return err - } - - // Build base assets (HTML/JS/CSS/etc) - err = d.BuildBaseAssets(assets, options) - if err != nil { - return err - } + //userTags := slicer.String(options.UserTags) + //if userTags.Contains("cgo") { + // // Get a list of assets from the HTML + // assets, err := d.BaseBuilder.ExtractAssets() + // if err != nil { + // return err + // } + // + // // Build base assets (HTML/JS/CSS/etc) + // err = d.BuildBaseAssets(assets, options) + // if err != nil { + // return err + // } + //} return nil } diff --git a/v2/pkg/commands/build/desktop_windows.go b/v2/pkg/commands/build/desktop_windows.go index 842b8409a..afb2e011f 100644 --- a/v2/pkg/commands/build/desktop_windows.go +++ b/v2/pkg/commands/build/desktop_windows.go @@ -2,24 +2,16 @@ package build -import ( - "github.com/leaanthony/slicer" - "github.com/wailsapp/wails/v2/internal/ffenestri/windows/x64" - "os" - "path/filepath" -) - // PostCompilation is called after the compilation step, if successful func (d *DesktopBuilder) PostCompilation(options *Options) error { // Dump the DLLs - userTags := slicer.String(options.UserTags) - if userTags.Contains("experimental") { - return nil - } - err := os.WriteFile(filepath.Join(options.BuildDirectory, "WebView2Loader.dll"), x64.WebView2Loader, 0755) - if err != nil { - return err - } + //userTags := slicer.String(options.UserTags) + //if userTags.Contains("cgo") { + // err := os.WriteFile(filepath.Join(options.BuildDirectory, "WebView2Loader.dll"), x64.WebView2Loader, 0755) + // if err != nil { + // return err + // } + //} return nil } diff --git a/v2/pkg/runtime/dialog-x.go b/v2/pkg/runtime/dialog-x.go deleted file mode 100644 index 6f26b664e..000000000 --- a/v2/pkg/runtime/dialog-x.go +++ /dev/null @@ -1,59 +0,0 @@ -//+build experimental - -package runtime - -import ( - "context" - "github.com/wailsapp/wails/v2/internal/frontend" -) - -// FileFilter defines a filter for dialog boxes -type FileFilter = frontend.FileFilter - -// OpenDialogOptions contains the options for the OpenDialogOptions runtime method -type OpenDialogOptions = frontend.OpenDialogOptions - -// SaveDialogOptions contains the options for the SaveDialog runtime method -type SaveDialogOptions = frontend.SaveDialogOptions - -type DialogType = frontend.DialogType - -const ( - InfoDialog = frontend.InfoDialog - WarningDialog = frontend.WarningDialog - ErrorDialog = frontend.ErrorDialog - QuestionDialog = frontend.QuestionDialog -) - -// MessageDialogOptions contains the options for the Message dialogs, EG Info, Warning, etc runtime methods -type MessageDialogOptions = frontend.MessageDialogOptions - -// OpenDirectoryDialog prompts the user to select a directory -func OpenDirectoryDialog(ctx context.Context, dialogOptions OpenDialogOptions) (string, error) { - frontend := getFrontend(ctx) - return frontend.OpenDirectoryDialog(dialogOptions) -} - -// OpenFileDialog prompts the user to select a file -func OpenFileDialog(ctx context.Context, dialogOptions OpenDialogOptions) (string, error) { - frontend := getFrontend(ctx) - return frontend.OpenFileDialog(dialogOptions) -} - -// OpenMultipleFilesDialog prompts the user to select a file -func OpenMultipleFilesDialog(ctx context.Context, dialogOptions OpenDialogOptions) ([]string, error) { - frontend := getFrontend(ctx) - return frontend.OpenMultipleFilesDialog(dialogOptions) -} - -// SaveFileDialog prompts the user to select a file -func SaveFileDialog(ctx context.Context, dialogOptions SaveDialogOptions) (string, error) { - frontend := getFrontend(ctx) - return frontend.SaveFileDialog(dialogOptions) -} - -// MessageDialog show a message dialog to the user -func MessageDialog(ctx context.Context, dialogOptions MessageDialogOptions) (string, error) { - frontend := getFrontend(ctx) - return frontend.MessageDialog(dialogOptions) -} diff --git a/v2/pkg/runtime/dialog.go b/v2/pkg/runtime/dialog.go index ba2f560b5..c8b6333a8 100644 --- a/v2/pkg/runtime/dialog.go +++ b/v2/pkg/runtime/dialog.go @@ -1,192 +1,57 @@ -// +build !experimental - package runtime import ( "context" - "fmt" - "github.com/wailsapp/wails/v2/internal/crypto" - "github.com/wailsapp/wails/v2/internal/servicebus" + "github.com/wailsapp/wails/v2/internal/frontend" ) // FileFilter defines a filter for dialog boxes -type FileFilter struct { - DisplayName string // Filter information EG: "Image Files (*.jpg, *.png)" - Pattern string // semi-colon separated list of extensions, EG: "*.jpg;*.png" -} +type FileFilter = frontend.FileFilter // OpenDialogOptions contains the options for the OpenDialogOptions runtime method -type OpenDialogOptions struct { - DefaultDirectory string - DefaultFilename string - Title string - Filters []FileFilter - AllowFiles bool - AllowDirectories bool - ShowHiddenFiles bool - CanCreateDirectories bool - ResolvesAliases bool - TreatPackagesAsDirectories bool -} +type OpenDialogOptions = frontend.OpenDialogOptions // SaveDialogOptions contains the options for the SaveDialog runtime method -type SaveDialogOptions struct { - DefaultDirectory string - DefaultFilename string - Title string - Filters []FileFilter - ShowHiddenFiles bool - CanCreateDirectories bool - TreatPackagesAsDirectories bool -} +type SaveDialogOptions = frontend.SaveDialogOptions -type DialogType string +type DialogType = frontend.DialogType const ( - InfoDialog DialogType = "info" - WarningDialog DialogType = "warning" - ErrorDialog DialogType = "error" - QuestionDialog DialogType = "question" + InfoDialog = frontend.InfoDialog + WarningDialog = frontend.WarningDialog + ErrorDialog = frontend.ErrorDialog + QuestionDialog = frontend.QuestionDialog ) // MessageDialogOptions contains the options for the Message dialogs, EG Info, Warning, etc runtime methods -type MessageDialogOptions struct { - Type DialogType - Title string - Message string - Buttons []string - DefaultButton string - CancelButton string - Icon string -} +type MessageDialogOptions = frontend.MessageDialogOptions // OpenDirectoryDialog prompts the user to select a directory func OpenDirectoryDialog(ctx context.Context, dialogOptions OpenDialogOptions) (string, error) { - - bus := servicebus.ExtractBus(ctx) - - // Create unique dialog callback - uniqueCallback := crypto.RandomID() - - // Subscribe to the respose channel - responseTopic := "dialog:opendirectoryselected:" + uniqueCallback - dialogResponseChannel, err := bus.Subscribe(responseTopic) - if err != nil { - return "", fmt.Errorf("ERROR: Cannot subscribe to bus topic: %+v\n", err.Error()) - } - - message := "dialog:select:directory:" + uniqueCallback - bus.Publish(message, dialogOptions) - - // Wait for result - var result = <-dialogResponseChannel - - // Delete subscription to response topic - bus.UnSubscribe(responseTopic) - - return result.Data().(string), nil + appFrontend := getFrontend(ctx) + return appFrontend.OpenDirectoryDialog(dialogOptions) } // OpenFileDialog prompts the user to select a file func OpenFileDialog(ctx context.Context, dialogOptions OpenDialogOptions) (string, error) { - - bus := servicebus.ExtractBus(ctx) - - // Create unique dialog callback - uniqueCallback := crypto.RandomID() - - // Subscribe to the respose channel - responseTopic := "dialog:openselected:" + uniqueCallback - dialogResponseChannel, err := bus.Subscribe(responseTopic) - if err != nil { - return "", fmt.Errorf("ERROR: Cannot subscribe to bus topic: %+v\n", err.Error()) - } - - message := "dialog:select:open:" + uniqueCallback - bus.Publish(message, dialogOptions) - - // Wait for result - var result = <-dialogResponseChannel - - // Delete subscription to response topic - bus.UnSubscribe(responseTopic) - - return result.Data().(string), nil + appFrontend := getFrontend(ctx) + return appFrontend.OpenFileDialog(dialogOptions) } // OpenMultipleFilesDialog prompts the user to select a file func OpenMultipleFilesDialog(ctx context.Context, dialogOptions OpenDialogOptions) ([]string, error) { - - bus := servicebus.ExtractBus(ctx) - uniqueCallback := crypto.RandomID() - - // Subscribe to the respose channel - responseTopic := "dialog:openmultipleselected:" + uniqueCallback - dialogResponseChannel, err := bus.Subscribe(responseTopic) - if err != nil { - return nil, fmt.Errorf("ERROR: Cannot subscribe to bus topic: %+v\n", err.Error()) - } - - message := "dialog:select:openmultiple:" + uniqueCallback - bus.Publish(message, dialogOptions) - - // Wait for result - var result = <-dialogResponseChannel - - // Delete subscription to response topic - bus.UnSubscribe(responseTopic) - - return result.Data().([]string), nil + appFrontend := getFrontend(ctx) + return appFrontend.OpenMultipleFilesDialog(dialogOptions) } // SaveFileDialog prompts the user to select a file func SaveFileDialog(ctx context.Context, dialogOptions SaveDialogOptions) (string, error) { - - bus := servicebus.ExtractBus(ctx) - uniqueCallback := crypto.RandomID() - - // Subscribe to the respose channel - responseTopic := "dialog:saveselected:" + uniqueCallback - dialogResponseChannel, err := bus.Subscribe(responseTopic) - if err != nil { - return "", fmt.Errorf("ERROR: Cannot subscribe to bus topic: %+v\n", err.Error()) - } - - message := "dialog:select:save:" + uniqueCallback - bus.Publish(message, dialogOptions) - - // Wait for result - var result = <-dialogResponseChannel - - // Delete subscription to response topic - bus.UnSubscribe(responseTopic) - - return result.Data().(string), nil + appFrontend := getFrontend(ctx) + return appFrontend.SaveFileDialog(dialogOptions) } // MessageDialog show a message dialog to the user func MessageDialog(ctx context.Context, dialogOptions MessageDialogOptions) (string, error) { - - bus := servicebus.ExtractBus(ctx) - - // Create unique dialog callback - uniqueCallback := crypto.RandomID() - - // Subscribe to the respose channel - responseTopic := "dialog:messageselected:" + uniqueCallback - dialogResponseChannel, err := bus.Subscribe(responseTopic) - if err != nil { - return "", fmt.Errorf("ERROR: Cannot subscribe to bus topic: %+v\n", err.Error()) - } - - message := "dialog:select:message:" + uniqueCallback - bus.Publish(message, dialogOptions) - - // Wait for result - var result = <-dialogResponseChannel - - // Delete subscription to response topic - bus.UnSubscribe(responseTopic) - - return result.Data().(string), nil + appFrontend := getFrontend(ctx) + return appFrontend.MessageDialog(dialogOptions) } diff --git a/v2/pkg/runtime/events-x.go b/v2/pkg/runtime/events-x.go deleted file mode 100644 index 5da22ff83..000000000 --- a/v2/pkg/runtime/events-x.go +++ /dev/null @@ -1,38 +0,0 @@ -// +build experimental - -package runtime - -import ( - "context" -) - -// EventsOn registers a listener for the given event name -func EventsOn(ctx context.Context, eventName string, callback func(optionalData ...interface{})) { - events := getEvents(ctx) - events.On(eventName, callback) -} - -// EventsOff unregisters a listener for the given event name -func EventsOff(ctx context.Context, eventName string) { - events := getEvents(ctx) - events.Off(eventName) -} - -// EventsOnce registers a listener for the given event name. After the first callback, the -// listener is deleted. -func EventsOnce(ctx context.Context, eventName string, callback func(optionalData ...interface{})) { - events := getEvents(ctx) - events.Once(eventName, callback) -} - -// EventsOnMultiple registers a listener for the given event name, that may be called a maximum of 'counter' times -func EventsOnMultiple(ctx context.Context, eventName string, callback func(optionalData ...interface{}), counter int) { - events := getEvents(ctx) - events.OnMultiple(eventName, callback, counter) -} - -// EventsEmit pass through -func EventsEmit(ctx context.Context, eventName string, optionalData ...interface{}) { - events := getEvents(ctx) - events.Emit(eventName, optionalData...) -} diff --git a/v2/pkg/runtime/events.go b/v2/pkg/runtime/events.go index e65d9d73d..440c7bdf6 100644 --- a/v2/pkg/runtime/events.go +++ b/v2/pkg/runtime/events.go @@ -1,45 +1,36 @@ -// +build !experimental - package runtime import ( "context" - "github.com/wailsapp/wails/v2/internal/messagedispatcher/message" - "github.com/wailsapp/wails/v2/internal/servicebus" ) -// On registers a listener for a particular event -func On(ctx context.Context, eventName string, callback func(optionalData ...interface{})) { - - bus := servicebus.ExtractBus(ctx) - - eventMessage := &message.OnEventMessage{ - Name: eventName, - Callback: callback, - Counter: -1, - } - bus.Publish("event:on", eventMessage) +// EventsOn registers a listener for the given event name +func EventsOn(ctx context.Context, eventName string, callback func(optionalData ...interface{})) { + events := getEvents(ctx) + events.On(eventName, callback) } -// Once registers a listener for a particular event. After the first callback, the +// EventsOff unregisters a listener for the given event name +func EventsOff(ctx context.Context, eventName string) { + events := getEvents(ctx) + events.Off(eventName) +} + +// EventsOnce registers a listener for the given event name. After the first callback, the // listener is deleted. -func Once(ctx context.Context, eventName string, callback func(optionalData ...interface{})) { - bus := servicebus.ExtractBus(ctx) - eventMessage := &message.OnEventMessage{ - Name: eventName, - Callback: callback, - Counter: 1, - } - bus.Publish("event:on", eventMessage) +func EventsOnce(ctx context.Context, eventName string, callback func(optionalData ...interface{})) { + events := getEvents(ctx) + events.Once(eventName, callback) } -// Emit pass through -func Emit(ctx context.Context, eventName string, optionalData ...interface{}) { - bus := servicebus.ExtractBus(ctx) - eventMessage := &message.EventMessage{ - Name: eventName, - Data: optionalData, - } - - bus.Publish("event:emit:from:g", eventMessage) +// EventsOnMultiple registers a listener for the given event name, that may be called a maximum of 'counter' times +func EventsOnMultiple(ctx context.Context, eventName string, callback func(optionalData ...interface{}), counter int) { + events := getEvents(ctx) + events.OnMultiple(eventName, callback, counter) +} + +// EventsEmit pass through +func EventsEmit(ctx context.Context, eventName string, optionalData ...interface{}) { + events := getEvents(ctx) + events.Emit(eventName, optionalData...) } diff --git a/v2/pkg/runtime/log.go b/v2/pkg/runtime/log.go index 423f719f3..c3b4832af 100644 --- a/v2/pkg/runtime/log.go +++ b/v2/pkg/runtime/log.go @@ -1,4 +1,4 @@ -// +build !experimental +// +build cgo package runtime diff --git a/v2/pkg/runtime/menu-x.go b/v2/pkg/runtime/menu-x.go deleted file mode 100644 index 96aa0b378..000000000 --- a/v2/pkg/runtime/menu-x.go +++ /dev/null @@ -1,34 +0,0 @@ -//+build experimental - -package runtime - -import ( - "context" -) - -func UpdateApplicationMenu(ctx context.Context) { - frontend := getFrontend(ctx) - frontend.UpdateApplicationMenu() -} - -/* -func UpdateContextMenu(ctx context.Context, contextMenu *menu.ContextMenu) { - frontend := getFrontend(ctx) - bus.Publish("menu:updatecontextmenu", contextMenu) -} - -func SetTrayMenu(ctx context.Context, trayMenu *menu.TrayMenu) { - frontend := getFrontend(ctx) - bus.Publish("menu:settraymenu", trayMenu) -} - -func UpdateTrayMenuLabel(ctx context.Context, trayMenu *menu.TrayMenu) { - frontend := getFrontend(ctx) - bus.Publish("menu:updatetraymenulabel", trayMenu) -} - -func DeleteTrayMenu(ctx context.Context, trayMenu *menu.TrayMenu) { - frontend := getFrontend(ctx) - bus.Publish("menu:deletetraymenu", trayMenu) -} -*/ diff --git a/v2/pkg/runtime/menu.go b/v2/pkg/runtime/menu.go index 325fb3575..b81641941 100644 --- a/v2/pkg/runtime/menu.go +++ b/v2/pkg/runtime/menu.go @@ -1,34 +1,32 @@ -// +build !experimental - package runtime import ( "context" - "github.com/wailsapp/wails/v2/internal/servicebus" - "github.com/wailsapp/wails/v2/pkg/menu" ) func UpdateApplicationMenu(ctx context.Context) { - bus := servicebus.ExtractBus(ctx) - bus.Publish("menu:updateappmenu", nil) + frontend := getFrontend(ctx) + frontend.UpdateApplicationMenu() } +/* func UpdateContextMenu(ctx context.Context, contextMenu *menu.ContextMenu) { - bus := servicebus.ExtractBus(ctx) + frontend := getFrontend(ctx) bus.Publish("menu:updatecontextmenu", contextMenu) } func SetTrayMenu(ctx context.Context, trayMenu *menu.TrayMenu) { - bus := servicebus.ExtractBus(ctx) + frontend := getFrontend(ctx) bus.Publish("menu:settraymenu", trayMenu) } func UpdateTrayMenuLabel(ctx context.Context, trayMenu *menu.TrayMenu) { - bus := servicebus.ExtractBus(ctx) + frontend := getFrontend(ctx) bus.Publish("menu:updatetraymenulabel", trayMenu) } func DeleteTrayMenu(ctx context.Context, trayMenu *menu.TrayMenu) { - bus := servicebus.ExtractBus(ctx) + frontend := getFrontend(ctx) bus.Publish("menu:deletetraymenu", trayMenu) } +*/ diff --git a/v2/pkg/runtime/runtime-x.go b/v2/pkg/runtime/runtime-x.go deleted file mode 100644 index 53c9514d4..000000000 --- a/v2/pkg/runtime/runtime-x.go +++ /dev/null @@ -1,38 +0,0 @@ -//+build experimental - -package runtime - -import ( - "context" - "github.com/wailsapp/wails/v2/internal/frontend" - "log" - goruntime "runtime" -) - -func getFrontend(ctx context.Context) frontend.Frontend { - result := ctx.Value("frontend") - if result != nil { - return result.(frontend.Frontend) - } - pc, _, _, _ := goruntime.Caller(1) - funcName := goruntime.FuncForPC(pc).Name() - log.Fatalf("cannot call '%s': Application not initialised", funcName) - return nil -} - -func getEvents(ctx context.Context) frontend.Events { - result := ctx.Value("events") - if result != nil { - return result.(frontend.Events) - } - pc, _, _, _ := goruntime.Caller(1) - funcName := goruntime.FuncForPC(pc).Name() - log.Fatalf("cannot call '%s': Application not initialised", funcName) - return nil -} - -// Quit the application -func Quit(ctx context.Context) { - appFrontend := getFrontend(ctx) - appFrontend.Quit() -} diff --git a/v2/pkg/runtime/runtime.go b/v2/pkg/runtime/runtime.go index 4926c8c6b..2448c9f22 100644 --- a/v2/pkg/runtime/runtime.go +++ b/v2/pkg/runtime/runtime.go @@ -1,15 +1,36 @@ -// +build !experimental - package runtime import ( "context" - "github.com/wailsapp/wails/v2/internal/servicebus" + "github.com/wailsapp/wails/v2/internal/frontend" + "log" + goruntime "runtime" ) +func getFrontend(ctx context.Context) frontend.Frontend { + result := ctx.Value("frontend") + if result != nil { + return result.(frontend.Frontend) + } + pc, _, _, _ := goruntime.Caller(1) + funcName := goruntime.FuncForPC(pc).Name() + log.Fatalf("cannot call '%s': Application not initialised", funcName) + return nil +} + +func getEvents(ctx context.Context) frontend.Events { + result := ctx.Value("events") + if result != nil { + return result.(frontend.Events) + } + pc, _, _, _ := goruntime.Caller(1) + funcName := goruntime.FuncForPC(pc).Name() + log.Fatalf("cannot call '%s': Application not initialised", funcName) + return nil +} + // Quit the application func Quit(ctx context.Context) { - bus := servicebus.ExtractBus(ctx) - // Start shutdown of Wails - bus.Publish("quit", "runtime.Quit()") + appFrontend := getFrontend(ctx) + appFrontend.Quit() } diff --git a/v2/pkg/runtime/window.go b/v2/pkg/runtime/window.go index fe0a68ae9..50c05d8f3 100644 --- a/v2/pkg/runtime/window.go +++ b/v2/pkg/runtime/window.go @@ -1,98 +1,89 @@ -// +build !experimental - package runtime import ( "context" - "fmt" - - "github.com/wailsapp/wails/v2/internal/servicebus" ) // WindowSetTitle sets the title of the window func WindowSetTitle(ctx context.Context, title string) { - bus := servicebus.ExtractBus(ctx) - bus.Publish("window:settitle", title) + appFrontend := getFrontend(ctx) + appFrontend.WindowSetTitle(title) } // WindowFullscreen makes the window fullscreen func WindowFullscreen(ctx context.Context) { - bus := servicebus.ExtractBus(ctx) - bus.Publish("window:fullscreen", "") + appFrontend := getFrontend(ctx) + appFrontend.WindowFullscreen() } // WindowUnFullscreen makes the window UnFullscreen func WindowUnFullscreen(ctx context.Context) { - bus := servicebus.ExtractBus(ctx) - bus.Publish("window:unfullscreen", "") + appFrontend := getFrontend(ctx) + appFrontend.WindowUnFullscreen() } // WindowCenter the window on the current screen func WindowCenter(ctx context.Context) { - bus := servicebus.ExtractBus(ctx) - bus.Publish("window:center", "") + appFrontend := getFrontend(ctx) + appFrontend.WindowCenter() } // WindowShow shows the window if hidden func WindowShow(ctx context.Context) { - bus := servicebus.ExtractBus(ctx) - bus.Publish("window:show", "") + appFrontend := getFrontend(ctx) + appFrontend.WindowShow() } // WindowHide the window func WindowHide(ctx context.Context) { - bus := servicebus.ExtractBus(ctx) - bus.Publish("window:hide", "") + appFrontend := getFrontend(ctx) + appFrontend.WindowHide() } // WindowSetSize sets the size of the window func WindowSetSize(ctx context.Context, width int, height int) { - bus := servicebus.ExtractBus(ctx) - message := fmt.Sprintf("window:size:%d:%d", width, height) - bus.Publish(message, "") + appFrontend := getFrontend(ctx) + appFrontend.WindowSetSize(width, height) } -// WindowSetSize sets the size of the window +// WindowSetMinSize sets the minimum size of the window func WindowSetMinSize(ctx context.Context, width int, height int) { - bus := servicebus.ExtractBus(ctx) - message := fmt.Sprintf("window:minsize:%d:%d", width, height) - bus.Publish(message, "") + appFrontend := getFrontend(ctx) + appFrontend.WindowSetMinSize(width, height) } -// WindowSetSize sets the size of the window +// WindowSetMaxSize sets the maximum size of the window func WindowSetMaxSize(ctx context.Context, width int, height int) { - bus := servicebus.ExtractBus(ctx) - message := fmt.Sprintf("window:maxsize:%d:%d", width, height) - bus.Publish(message, "") + appFrontend := getFrontend(ctx) + appFrontend.WindowSetMaxSize(width, height) } // WindowSetPosition sets the position of the window func WindowSetPosition(ctx context.Context, x int, y int) { - bus := servicebus.ExtractBus(ctx) - message := fmt.Sprintf("window:position:%d:%d", x, y) - bus.Publish(message, "") + appFrontend := getFrontend(ctx) + appFrontend.WindowSetPos(x, y) } // WindowMaximise the window func WindowMaximise(ctx context.Context) { - bus := servicebus.ExtractBus(ctx) - bus.Publish("window:maximise", "") + appFrontend := getFrontend(ctx) + appFrontend.WindowMaximise() } // WindowUnmaximise the window func WindowUnmaximise(ctx context.Context) { - bus := servicebus.ExtractBus(ctx) - bus.Publish("window:unmaximise", "") + appFrontend := getFrontend(ctx) + appFrontend.WindowUnmaximise() } // WindowMinimise the window func WindowMinimise(ctx context.Context) { - bus := servicebus.ExtractBus(ctx) - bus.Publish("window:minimise", "") + appFrontend := getFrontend(ctx) + appFrontend.WindowMinimise() } // WindowUnminimise the window func WindowUnminimise(ctx context.Context) { - bus := servicebus.ExtractBus(ctx) - bus.Publish("window:unminimise", "") + appFrontend := getFrontend(ctx) + appFrontend.WindowUnminimise() } diff --git a/v2/wails.go b/v2/wails.go index 631bc83c1..33d07a561 100644 --- a/v2/wails.go +++ b/v2/wails.go @@ -1,11 +1,9 @@ -// +build !experimental - // Package wails is the main package of the Wails project. // It is used by client applications. package wails import ( - "github.com/wailsapp/wails/v2/internal/app" + app "github.com/wailsapp/wails/v2/internal/appng" "github.com/wailsapp/wails/v2/pkg/options" ) diff --git a/v2/wails_windows.go b/v2/wails_windows.go deleted file mode 100644 index ebdccaac3..000000000 --- a/v2/wails_windows.go +++ /dev/null @@ -1,28 +0,0 @@ -// +build windows -// +build experimental - -// Package wails is the main package of the Wails project. -// It is used by client applications. -package wails - -import ( - app "github.com/wailsapp/wails/v2/internal/appng" - "github.com/wailsapp/wails/v2/pkg/options" -) - -// Run creates an application based on the given config and executes it -func Run(options *options.App) error { - - // Call an Init method manually - err := Init() - if err != nil { - return err - } - - mainapp, err := app.CreateApp(options) - if err != nil { - return err - } - - return mainapp.Run() -}