mirror of
https://github.com/wavetermdev/wails.git
synced 2026-04-22 15:26:15 -07:00
Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 37b395c308 | |||
| 428584d583 | |||
| ee1978aa42 | |||
| 895d6d4b80 | |||
| a5ddce2c7c | |||
| e4789750c8 | |||
| f8c673874b | |||
| 5ef32760f0 | |||
| 81645190f0 |
@@ -141,7 +141,7 @@ func (a *App) start() error {
|
||||
// Defer the shutdown
|
||||
defer a.shutdown()
|
||||
|
||||
// run the renderer
|
||||
// Run the renderer
|
||||
err = a.renderer.Run()
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
+1
-1
@@ -55,7 +55,7 @@ func newIPCMessage(incomingMessage string, responseFunction func(*ipcResponse) e
|
||||
// hasCallbackID checks if the message can send an error back to the frontend
|
||||
func (m *ipcMessage) hasCallbackID() error {
|
||||
if m.CallbackID == "" {
|
||||
return fmt.Errorf("attempted to return error to message with no callback ID")
|
||||
return fmt.Errorf("attempted to return error to message with no Callback ID")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -186,7 +186,7 @@ func (w *WebView) evalJSSync(js string) error {
|
||||
|
||||
go func() {
|
||||
exit := false
|
||||
// We are done when we receive the callback ID
|
||||
// We are done when we receive the Callback ID
|
||||
w.log.Debug("SyncJS: sending with ID = " + ID)
|
||||
w.eventManager.On(ID, func(...interface{}) {
|
||||
w.log.Debug("SyncJS: Got callback ID = " + ID)
|
||||
@@ -361,7 +361,7 @@ func (w *WebView) focus() {
|
||||
|
||||
// callback sends a callback to the frontend
|
||||
func (w *WebView) callback(data string) error {
|
||||
callbackCMD := fmt.Sprintf("window.wails._.callback('%s');", data)
|
||||
callbackCMD := fmt.Sprintf("window.wails._.Callback('%s');", data)
|
||||
return w.evalJS(callbackCMD)
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ func main() {
|
||||
// create windows programmatically and be able to show/hide
|
||||
// them from the systray with something like:
|
||||
//
|
||||
// myWindow := mainApp.NewWebviewWindow(...)
|
||||
// myWindow := mainApp.NewWindow(...)
|
||||
// mainApp.NewSystemTray(&options.SystemTray{
|
||||
// OnLeftClick: func() {
|
||||
// myWindow.SetVisibility(!myWindow.IsVisible())
|
||||
|
||||
@@ -26,8 +26,6 @@ import (
|
||||
"github.com/wailsapp/wails/v2/pkg/assetserver"
|
||||
"github.com/wailsapp/wails/v2/pkg/assetserver/webview"
|
||||
|
||||
"github.com/wailsapp/wails/v2/pkg/assetserver"
|
||||
|
||||
"github.com/wailsapp/wails/v2/internal/binding"
|
||||
"github.com/wailsapp/wails/v2/internal/frontend"
|
||||
"github.com/wailsapp/wails/v2/internal/frontend/runtime"
|
||||
@@ -329,7 +327,7 @@ func (f *Frontend) processMessage(message string) {
|
||||
|
||||
switch result[0] {
|
||||
case 'c':
|
||||
// callback from a method call
|
||||
// Callback from a method call
|
||||
f.Callback(result[1:])
|
||||
default:
|
||||
f.logger.Info("Unknown message returned from dispatcher: %+v", result)
|
||||
@@ -339,7 +337,7 @@ func (f *Frontend) processMessage(message string) {
|
||||
}
|
||||
|
||||
func (f *Frontend) Callback(message string) {
|
||||
f.ExecJS(`window.wails.callback(` + strconv.Quote(message) + `);`)
|
||||
f.ExecJS(`window.wails.Callback(` + strconv.Quote(message) + `);`)
|
||||
}
|
||||
|
||||
func (f *Frontend) ExecJS(js string) {
|
||||
|
||||
@@ -428,7 +428,7 @@ func (f *Frontend) processMessage(message string) {
|
||||
|
||||
switch result[0] {
|
||||
case 'c':
|
||||
// callback from a method call
|
||||
// Callback from a method call
|
||||
f.Callback(result[1:])
|
||||
default:
|
||||
f.logger.Info("Unknown message returned from dispatcher: %+v", result)
|
||||
@@ -437,7 +437,7 @@ func (f *Frontend) processMessage(message string) {
|
||||
}
|
||||
|
||||
func (f *Frontend) Callback(message string) {
|
||||
f.ExecJS(`window.wails.callback(` + strconv.Quote(message) + `);`)
|
||||
f.ExecJS(`window.wails.Callback(` + strconv.Quote(message) + `);`)
|
||||
}
|
||||
|
||||
func (f *Frontend) startDrag() {
|
||||
|
||||
@@ -628,7 +628,7 @@ func (f *Frontend) processMessage(message string) {
|
||||
|
||||
switch result[0] {
|
||||
case 'c':
|
||||
// callback from a method call
|
||||
// Callback from a method call
|
||||
f.Callback(result[1:])
|
||||
default:
|
||||
f.logger.Info("Unknown message returned from dispatcher: %+v", result)
|
||||
@@ -638,7 +638,7 @@ func (f *Frontend) processMessage(message string) {
|
||||
|
||||
func (f *Frontend) Callback(message string) {
|
||||
f.mainWindow.Invoke(func() {
|
||||
f.chromium.Eval(`window.wails.callback(` + strconv.Quote(message) + `);`)
|
||||
f.chromium.Eval(`window.wails.Callback(` + strconv.Quote(message) + `);`)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -250,6 +250,7 @@ func (cba *ControlBase) Size() (width, height int) {
|
||||
rect := w32.GetWindowRect(cba.hwnd)
|
||||
width = int(rect.Right - rect.Left)
|
||||
height = int(rect.Bottom - rect.Top)
|
||||
width, height = cba.scaleToDefaultDPI(width, height)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -498,6 +499,14 @@ func (cba *ControlBase) scaleWithWindowDPI(width, height int) (int, int) {
|
||||
return scaledWidth, scaledHeight
|
||||
}
|
||||
|
||||
func (cba *ControlBase) scaleToDefaultDPI(width, height int) (int, int) {
|
||||
dpix, dpiy := cba.GetWindowDPI()
|
||||
scaledWidth := ScaleToDefaultDPI(width, dpix)
|
||||
scaledHeight := ScaleToDefaultDPI(height, dpiy)
|
||||
|
||||
return scaledWidth, scaledHeight
|
||||
}
|
||||
|
||||
func (cba *ControlBase) tryInvokeOnCurrentGoRoutine(f func()) bool {
|
||||
runtime.LockOSThread()
|
||||
defer runtime.UnlockOSThread()
|
||||
|
||||
@@ -149,3 +149,8 @@ func ScreenToClientRect(hwnd w32.HWND, rect *w32.RECT) *Rect {
|
||||
func ScaleWithDPI(pixels int, dpi uint) int {
|
||||
return (pixels * int(dpi)) / 96
|
||||
}
|
||||
|
||||
// ScaleToDefaultDPI scales the pixels from scaled DPI-Space to default DPI-Space (96).
|
||||
func ScaleToDefaultDPI(pixels int, dpi uint) int {
|
||||
return (pixels * 96) / int(dpi)
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ func (e *Events) notifyBackend(eventName string, data ...interface{}) {
|
||||
// We have a dirty flag to indicate that there are items to delete
|
||||
itemsToDelete := false
|
||||
|
||||
// callback in goroutine
|
||||
// Callback in goroutine
|
||||
for _, listener := range listeners {
|
||||
if listener.counter > 0 {
|
||||
listener.counter--
|
||||
|
||||
@@ -2,7 +2,6 @@ package menumanager
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/wailsapp/wails/v2/pkg/menu"
|
||||
)
|
||||
|
||||
@@ -91,7 +90,7 @@ func (m *Manager) ProcessClick(menuID string, data string, menuType string, pare
|
||||
return fmt.Errorf("No callback for menu '%s'", menuItem.Label)
|
||||
}
|
||||
|
||||
// Create new callback struct
|
||||
// Create new Callback struct
|
||||
callbackData := &menu.CallbackData{
|
||||
MenuItem: menuItem,
|
||||
//ContextData: data,
|
||||
|
||||
+2
-2
@@ -26,8 +26,8 @@ type TrayMenu struct {
|
||||
// Tooltip
|
||||
Tooltip string
|
||||
|
||||
// callback function when menu clicked
|
||||
//Click callback `json:"-"`
|
||||
// Callback function when menu clicked
|
||||
//Click Callback `json:"-"`
|
||||
|
||||
// Disabled makes the item unselectable
|
||||
Disabled bool
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
# v3
|
||||
|
||||
This directory is experimental. It probably won't work for you. There's no support for this directory. Dragons be here. You have been warned!
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
# TODO
|
||||
|
||||
Informal and incomplete list of things needed in v3.
|
||||
|
||||
## General
|
||||
|
||||
- [ ] Generate Bindings
|
||||
- [ ] Generate TS Models
|
||||
- [ ] Port NSIS creation
|
||||
- [ ] Dev Mode
|
||||
- [ ] Generate Info.Plist from `info.json`
|
||||
|
||||
- [ ] Windows Port
|
||||
- [ ] Linux Port
|
||||
|
||||
## Runtime
|
||||
|
||||
- [ ] Pass window ID with runtime calls in JS
|
||||
- [ ] Implement alias for `window` in JS
|
||||
- [ ] Implement runtime dispatcher
|
||||
|
||||
## Templates
|
||||
|
||||
- [ ] Create plain template
|
||||
- [ ] Improve default template
|
||||
|
||||
## Runtime
|
||||
|
||||
- [ ] To log or not to log?
|
||||
- [ ] Unify cross-platform events, eg. `onClose`
|
||||
@@ -134,3 +134,87 @@ tasks:
|
||||
- install-runtime-deps
|
||||
cmds:
|
||||
- task: build-runtime-all
|
||||
|
||||
recreate-template-dir:
|
||||
dir: internal/templates
|
||||
internal: true
|
||||
silent: true
|
||||
cmds:
|
||||
- rm -rf {{.TEMPLATE_DIR}}
|
||||
- mkdir -p {{.TEMPLATE_DIR}}
|
||||
|
||||
generate-template:
|
||||
dir: internal/templates/{{.TEMPLATE}}
|
||||
deps:
|
||||
- task: recreate-template-dir
|
||||
vars:
|
||||
TEMPLATE_DIR: "{{.TEMPLATE}}"
|
||||
silent: true
|
||||
cmds:
|
||||
- cmd: pnpm create vite frontend --template {{.TEMPLATE}}
|
||||
- cmd: cp -rf ../_base/{{.TEMPLATE}}/* .
|
||||
ignore_error: true
|
||||
- cmd: cp -rf ../_base/default/* .
|
||||
ignore_error: true
|
||||
- cmd: rm frontend/public/vite.svg
|
||||
- cmd: go run ../../../tasks/sed/sed.go replace -dir frontend -old Vite -new Wails -ext .ts,.js,.html -ignore vite.config.js,vite.config.ts,vite-env.d.ts
|
||||
- cmd: go run ../../../tasks/sed/sed.go replace -dir frontend -old vite -new wails -ext .ts,.js,.html -ignore vite.config.js,vite.config.ts,vite-env.d.ts
|
||||
- cmd: go run ../../../tasks/sed/sed.go replace -dir frontend -old wails.svg -new wails.png -ext .ts,.js,.html -ignore vite.config.js,vite.config.ts,vite-env.d.ts
|
||||
- cmd: go run ../../../tasks/sed/sed.go replace -dir frontend -old wailsjs.dev -new wails.io -ext .ts,.js,.html -ignore vite.config.js,vite.config.ts,vite-env.d.ts
|
||||
- cmd: go run ../../../tasks/sed/sed.go replace -dir frontend -old "framework powered by Wails" -new "framework powered by Vite" -ext .ts,.js,.html,.svelte -ignore vite.config.js,vite.config.ts,vite-env.d.ts
|
||||
|
||||
reinstall-cli:
|
||||
dir: cmd/wails
|
||||
internal: true
|
||||
cmds:
|
||||
- go install
|
||||
- echo "Reinstalled wails CLI"
|
||||
|
||||
generate-templates:
|
||||
dir: internal/templates/
|
||||
deps:
|
||||
- task: generate-template
|
||||
vars:
|
||||
TEMPLATE: svelte
|
||||
- task: generate-template
|
||||
vars:
|
||||
TEMPLATE: svelte-ts
|
||||
- task: generate-template
|
||||
vars:
|
||||
TEMPLATE: vue
|
||||
- task: generate-template
|
||||
vars:
|
||||
TEMPLATE: vue-ts
|
||||
- task: generate-template
|
||||
vars:
|
||||
TEMPLATE: react
|
||||
- task: generate-template
|
||||
vars:
|
||||
TEMPLATE: react-ts
|
||||
- task: generate-template
|
||||
vars:
|
||||
TEMPLATE: preact
|
||||
- task: generate-template
|
||||
vars:
|
||||
TEMPLATE: preact-ts
|
||||
- task: generate-template
|
||||
vars:
|
||||
TEMPLATE: lit
|
||||
- task: generate-template
|
||||
vars:
|
||||
TEMPLATE: lit-ts
|
||||
- task: generate-template
|
||||
vars:
|
||||
TEMPLATE: vanilla
|
||||
- task: generate-template
|
||||
vars:
|
||||
TEMPLATE: vanilla-ts
|
||||
- task: generate-template
|
||||
vars:
|
||||
TEMPLATE: react-swc
|
||||
- task: generate-template
|
||||
vars:
|
||||
TEMPLATE: react-swc-ts
|
||||
cmds:
|
||||
- task: reinstall-cli
|
||||
- echo "Generated templates"
|
||||
|
||||
+10
-2
@@ -74,6 +74,14 @@ NOTE: Whilst the tool will work for 32-bit Windows, it is not supported. Please
|
||||
#### defaults
|
||||
|
||||
```bash
|
||||
wails icon -input myicon.png -sizes "32,64,128" -windowsFilename myicon.ico -macFilename myicon.icns
|
||||
wails generate defaults
|
||||
```
|
||||
This will generate all the default assets and resources in the current directory. I
|
||||
This will generate all the default assets and resources in the current directory.
|
||||
|
||||
#### bindings
|
||||
|
||||
```bash
|
||||
wails generate bindings
|
||||
```
|
||||
|
||||
Generates bindings and models for your bound Go methods and structs.
|
||||
@@ -10,7 +10,8 @@ import (
|
||||
)
|
||||
|
||||
func main() {
|
||||
app := clir.NewCli("wails", "The Wails CLI", "v3")
|
||||
app := clir.NewCli("Wails", "The Wails CLI", "v3")
|
||||
app.NewSubCommandFunction("build", "Build the project", commands.Build)
|
||||
app.NewSubCommandFunction("init", "Initialise a new project", commands.Init)
|
||||
task := app.NewSubCommand("task", "Run and list tasks")
|
||||
task.NewSubCommandFunction("run", "Run a task", commands.RunTask)
|
||||
|
||||
@@ -20,10 +20,9 @@ tasks:
|
||||
|
||||
generate-icons:
|
||||
summary: Generates Windows `.ico` and Mac `.icns` files from an image
|
||||
dir: build
|
||||
cmds:
|
||||
# Generates both .ico and .icns files
|
||||
- wails generate icon -input appicon.png
|
||||
- wails generate icons -input appicon.png
|
||||
|
||||
build-prod:
|
||||
summary: Creates a production build of the application
|
||||
|
||||
@@ -3,9 +3,10 @@ module github.com/wailsapp/wails/v3
|
||||
go 1.19
|
||||
|
||||
require (
|
||||
github.com/go-task/task/v3 v3.19.1
|
||||
github.com/go-task/task/v3 v3.20.0
|
||||
github.com/jackmordaunt/icns/v2 v2.2.1
|
||||
github.com/leaanthony/clir v1.5.0
|
||||
github.com/leaanthony/gosod v1.0.3
|
||||
github.com/leaanthony/winicon v1.0.0
|
||||
github.com/pterm/pterm v0.12.51
|
||||
github.com/samber/lo v1.37.0
|
||||
@@ -52,5 +53,3 @@ require (
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
mvdan.cc/sh/v3 v3.6.0 // indirect
|
||||
)
|
||||
|
||||
replace github.com/go-task/task/v3 v3.19.1 => github.com/wailsapp/task/v3 v3.19.1
|
||||
|
||||
@@ -23,6 +23,8 @@ github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYF
|
||||
github.com/frankban/quicktest v1.14.4 h1:g2rn0vABPOOXmZUj+vbmUp0lPoXEMuhTpIluN0XL9UY=
|
||||
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 h1:p104kn46Q8WdvHunIJ9dAyjPVtrBPhSr3KT2yUst43I=
|
||||
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE=
|
||||
github.com/go-task/task/v3 v3.20.0 h1:pTavuhP+AiEpKLzh5I6Lja9Ux7ypYO5QMsEPTbhYEDc=
|
||||
github.com/go-task/task/v3 v3.20.0/go.mod h1:y7rWakbLR5gFElGgo6rA2dyr6vU/zNIDVfn3S4Of6OI=
|
||||
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
|
||||
github.com/gookit/color v1.4.2/go.mod h1:fqRyamkC1W8uxl+lxCQxOT09l/vYfZ+QeiX3rKQHCoQ=
|
||||
github.com/gookit/color v1.5.0/go.mod h1:43aQb+Zerm/BWh2GnrgOQm7ffz7tvQXEKV6BFMl7wAo=
|
||||
@@ -47,6 +49,10 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
github.com/leaanthony/clir v1.0.4/go.mod h1:k/RBkdkFl18xkkACMCLt09bhiZnrGORoxmomeMvDpE0=
|
||||
github.com/leaanthony/clir v1.5.0 h1:zaH7fgsZ5OLfr0YwJBwQ+EYxCjXQsHF+CRudIiZb0KQ=
|
||||
github.com/leaanthony/clir v1.5.0/go.mod h1:k/RBkdkFl18xkkACMCLt09bhiZnrGORoxmomeMvDpE0=
|
||||
github.com/leaanthony/debme v1.2.1 h1:9Tgwf+kjcrbMQ4WnPcEIUcQuIZYqdWftzZkBr+i/oOc=
|
||||
github.com/leaanthony/debme v1.2.1/go.mod h1:3V+sCm5tYAgQymvSOfYQ5Xx2JCr+OXiD9Jkw3otUjiA=
|
||||
github.com/leaanthony/gosod v1.0.3 h1:Fnt+/B6NjQOVuCWOKYRREZnjGyvg+mEhd1nkkA04aTQ=
|
||||
github.com/leaanthony/gosod v1.0.3/go.mod h1:BJ2J+oHsQIyIQpnLPjnqFGTMnOZXDbvWtRCSG7jGxs4=
|
||||
github.com/leaanthony/slicer v1.5.0 h1:aHYTN8xbCCLxJmkNKiLB6tgcMARl4eWmH9/F+S/0HtY=
|
||||
github.com/leaanthony/slicer v1.5.0/go.mod h1:FwrApmf8gOrpzEWM2J/9Lh79tyq8KTX5AzRtwV7m4AY=
|
||||
github.com/leaanthony/winicon v1.0.0 h1:ZNt5U5dY71oEoKZ97UVwJRT4e+5xo5o/ieKuHuk8NqQ=
|
||||
@@ -54,6 +60,7 @@ github.com/leaanthony/winicon v1.0.0/go.mod h1:en5xhijl92aphrJdmRPlh4NI1L6wq3gEm
|
||||
github.com/lithammer/fuzzysearch v1.1.5 h1:Ag7aKU08wp0R9QCfF4GoGST9HbmAIeLP7xwMrOBEp1c=
|
||||
github.com/lithammer/fuzzysearch v1.1.5/go.mod h1:1R1LRNk7yKid1BaQkmuLQaHruxcC4HmAH30Dh61Ih1Q=
|
||||
github.com/matryer/is v1.4.0 h1:sosSmIWwkYITGrxZ25ULNDeKiMNzFSr4V/eqBQP0PeE=
|
||||
github.com/matryer/is v1.4.0/go.mod h1:8I/i5uYgLzgsgEloJE1U6xx5HkBQpAZvepWuujKwMRU=
|
||||
github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
|
||||
github.com/mattn/go-colorable v0.1.11 h1:nQ+aFkoE2TMGc0b68U2OKSexC+eq46+XwZzWXHRmPYs=
|
||||
github.com/mattn/go-colorable v0.1.11/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
|
||||
@@ -112,8 +119,6 @@ github.com/tc-hib/winres v0.1.6 h1:qgsYHze+BxQPEYilxIz/KCQGaClvI2+yLBAZs+3+0B8=
|
||||
github.com/tc-hib/winres v0.1.6/go.mod h1:pe6dOR40VOrGz8PkzreVKNvEKnlE8t4yR8A8naL+t7A=
|
||||
github.com/wailsapp/mimetype v1.4.1 h1:pQN9ycO7uo4vsUUuPeHEYoUkLVkaRntMnHJxVwYhwHs=
|
||||
github.com/wailsapp/mimetype v1.4.1/go.mod h1:9aV5k31bBOv5z6u+QP8TltzvNGJPmNJD4XlAL3U+j3o=
|
||||
github.com/wailsapp/task/v3 v3.19.1 h1:syDKYaPBXgrXKKSJVEWcOEoSFtZzpvxqlHf90YRukRc=
|
||||
github.com/wailsapp/task/v3 v3.19.1/go.mod h1:y7rWakbLR5gFElGgo6rA2dyr6vU/zNIDVfn3S4Of6OI=
|
||||
github.com/wailsapp/wails/v2 v2.3.2-0.20230117193915-45c3a501d9e6 h1:Wn+nhnS+VytzE0PegUzSh4T3hXJCtggKGD/4U5H9+wQ=
|
||||
github.com/wailsapp/wails/v2 v2.3.2-0.20230117193915-45c3a501d9e6/go.mod h1:zlNLI0E2c2qA6miiuAHtp0Bac8FaGH0tlhA19OssR/8=
|
||||
github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 h1:QldyIu/L63oPpyvQmHgvgickp1Yw510KJOqX7H24mg8=
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user