mirror of
https://github.com/wavetermdev/wails.git
synced 2026-04-22 15:26:15 -07:00
Compare commits
202 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ee194f3e46 | |||
| 82a9c5b1dd | |||
| fdd8875986 | |||
| 3b50e0cbc5 | |||
| fb7fda2256 | |||
| d9beb6126e | |||
| a81581129a | |||
| e95a91861a | |||
| fa5948f40e | |||
| ad4c8aacfb | |||
| afbc09f1e7 | |||
| 1a1e5b743a | |||
| 24853a7e3b | |||
| 1ce83913bd | |||
| 1650e26da7 | |||
| bc01fd8ea3 | |||
| 3422c40e19 | |||
| e661052c89 | |||
| ff08a5ca2b | |||
| f8250fb0d8 | |||
| d1c3f8af7a | |||
| 36b4b3695b | |||
| fb17ec8064 | |||
| 51f52656cc | |||
| 18746c7819 | |||
| 8463c01123 | |||
| 8e0671306a | |||
| 131a6da554 | |||
| 59273fcdab | |||
| 7795a2a46f | |||
| 2269f64b0a | |||
| 439da97573 | |||
| 2b478a4608 | |||
| 3b95725f09 | |||
| 3a23ad1382 | |||
| 61a7f1fba5 | |||
| a8641672cd | |||
| 320fc20461 | |||
| 69f05c39ec | |||
| e55ffedc35 | |||
| 0577fefd75 | |||
| 02713670c9 | |||
| e6de878395 | |||
| 4c75b288bb | |||
| 263e1b527a | |||
| 3d88bf8795 | |||
| 740b2b0979 | |||
| 2b843fc12e | |||
| 473cf1cae3 | |||
| 65d4266400 | |||
| 8d5b86fff7 | |||
| 92843c8237 | |||
| 13b588b555 | |||
| 839a9ff498 | |||
| ef8c16d773 | |||
| 602fafafea | |||
| 83ed7fd2df | |||
| f07e4093be | |||
| bf13afd895 | |||
| 9ffc06d42e | |||
| ebe91ba11d | |||
| 48aef46f57 | |||
| c77c823c3c | |||
| ccccea1e50 | |||
| a6163849c6 | |||
| 130aab3598 | |||
| 78b85ce0cc | |||
| dbcf65b2d6 | |||
| d8e27aa5f9 | |||
| ce6d587771 | |||
| 81d7bc2d68 | |||
| a49350f300 | |||
| 9ac6359e56 | |||
| 5958d9c646 | |||
| 9b88c8afda | |||
| 1b71fef89f | |||
| 8ddd29d285 | |||
| dc8cbcf410 | |||
| 757a4383e6 | |||
| 7c98ee329a | |||
| 9d615463f4 | |||
| 1c9765096d | |||
| aea0db5919 | |||
| fc593d90cf | |||
| 2524f7b5a0 | |||
| 5a0cb1baef | |||
| 18ee469c47 | |||
| 255690eee0 | |||
| 86b6e10620 | |||
| b757292211 | |||
| af54419a0b | |||
| 7b84b1c79c | |||
| d047c22526 | |||
| 6feab70a72 | |||
| 5e1b5ca4e8 | |||
| 1726cdb0ad | |||
| 2b2828ea41 | |||
| 29859ceedf | |||
| 8e2527ad35 | |||
| 92b26488da | |||
| efa67cb01c | |||
| 71fc222059 | |||
| fa6adad4ab | |||
| 1c48d567e1 | |||
| 2c3216ba36 | |||
| 74e2a7e225 | |||
| ff2c92451d | |||
| 2a83402d4a | |||
| 2449b473c0 | |||
| 60c44c44ff | |||
| 7e1d685167 | |||
| a9d4a393ba | |||
| a0953fea93 | |||
| 02d76835c9 | |||
| dfe03f1347 | |||
| c87489adf3 | |||
| a428a730d5 | |||
| 7f7c642339 | |||
| 03b79e9a67 | |||
| 56b0fcebba | |||
| e31ad83472 | |||
| 3f9067c815 | |||
| d9a5130311 | |||
| 4663a45e59 | |||
| ab0b0f8a7f | |||
| 6d1489bf8e | |||
| 05eddc65b1 | |||
| fb820bcdad | |||
| 31c167b412 | |||
| 7cdab16ba9 | |||
| 787ca80770 | |||
| d228b2ad37 | |||
| 05262134ca | |||
| fe48b9d03d | |||
| e9519269ca | |||
| 013ec1d726 | |||
| 27b4a984d5 | |||
| d6b6111395 | |||
| 5a7b868e80 | |||
| d370f72ede | |||
| af8ee6703e | |||
| 3369327ad2 | |||
| eca6afc18c | |||
| 34c725231c | |||
| db519de1cd | |||
| 6aa6762f12 | |||
| 64e44b1b51 | |||
| 793191a479 | |||
| efc86c1056 | |||
| 39d44d2644 | |||
| 9584a2ce5a | |||
| 95b8ceb87a | |||
| 37b99b9cb8 | |||
| 3116c1a622 | |||
| 86354e9fc0 | |||
| b49f135e31 | |||
| c26f3ad7d1 | |||
| 40f645a864 | |||
| fff266f50d | |||
| 7cfea7c22c | |||
| 6141e5a8ce | |||
| ed58949d24 | |||
| c1d85bd3d9 | |||
| 8d3324465e | |||
| 8c72746edb | |||
| ea3509d2e7 | |||
| bb3a0cc54f | |||
| d808654d99 | |||
| a6cfdbb403 | |||
| 2f7c6834d0 | |||
| ebdd57a7c4 | |||
| 4ff6d74054 | |||
| 0d8b4aafd5 | |||
| 0cca7e9189 | |||
| a5812578c5 | |||
| a419721dcd | |||
| e731e2591a | |||
| 350b411afe | |||
| 9ca86c6093 | |||
| 01729ae22a | |||
| 9196dc2216 | |||
| b925335bbb | |||
| 59b25edb5c | |||
| 965f939967 | |||
| 00feccbb77 | |||
| b6fc66ba0d | |||
| c40debc0e9 | |||
| 3b31d70865 | |||
| afa8b62de7 | |||
| 70fd15de2d | |||
| c54d330f89 | |||
| 4028560d12 | |||
| 3c28c28623 | |||
| a958fa06e7 | |||
| 4d39e9e15a | |||
| 647bc87600 | |||
| ebf56f6585 | |||
| 1644ee152e | |||
| 069fe18b9d | |||
| acf8dea170 | |||
| 7a87b0476e | |||
| 886bcc7b47 |
@@ -3,6 +3,8 @@ name: Build + Test v3 alpha
|
||||
on:
|
||||
push:
|
||||
branches: [v3-alpha]
|
||||
paths-ignore:
|
||||
- 'mkdocs-website/**/*'
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
@@ -12,7 +14,7 @@ jobs:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
||||
os: [windows-latest, macos-latest, ubuntu-latest]
|
||||
go-version: [1.21]
|
||||
|
||||
steps:
|
||||
@@ -21,13 +23,23 @@ jobs:
|
||||
|
||||
- name: Install linux dependencies
|
||||
if: matrix.os == 'ubuntu-latest'
|
||||
run: sudo apt-get update -y && sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.0-dev build-essential pkg-config
|
||||
run: sudo apt-get update -y && sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.0-dev libayatana-appindicator3-dev build-essential pkg-config
|
||||
|
||||
- name: Setup Go
|
||||
uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: ${{ matrix.go-version }}
|
||||
|
||||
- name: Install Task
|
||||
uses: arduino/setup-task@v1
|
||||
with:
|
||||
version: 3.x
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Build Examples
|
||||
working-directory: ./v3
|
||||
run: task test:examples
|
||||
|
||||
- name: Run tests (mac)
|
||||
if: matrix.os == 'macos-latest'
|
||||
env:
|
||||
@@ -87,7 +99,6 @@ jobs:
|
||||
lit-ts,
|
||||
vanilla,
|
||||
vanilla-ts,
|
||||
plain,
|
||||
]
|
||||
go-version: [1.21]
|
||||
steps:
|
||||
@@ -99,6 +110,16 @@ jobs:
|
||||
with:
|
||||
go-version: ${{ matrix.go-version }}
|
||||
|
||||
- name: Setup Golang caches
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: |
|
||||
~/.cache/go-build
|
||||
~/go/pkg/mod
|
||||
key: ${{ runner.os }}-golang-${{ hashFiles('**/go.sum') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-golang-
|
||||
|
||||
- name: Build Wails3 CLI
|
||||
run: |
|
||||
cd ./v3/cmd/wails3
|
||||
@@ -107,13 +128,13 @@ jobs:
|
||||
|
||||
- name: Install linux dependencies
|
||||
if: matrix.os == 'ubuntu-latest'
|
||||
run: sudo apt-get update -y && sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.0-dev build-essential pkg-config
|
||||
run: sudo apt-get update -y && sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.0-dev libayatana-appindicator3-dev build-essential pkg-config
|
||||
|
||||
- name: Generate template '${{ matrix.template }}'
|
||||
run: |
|
||||
go install github.com/go-task/task/v3/cmd/task@latest
|
||||
mkdir -p ./test-${{ matrix.template }}
|
||||
cd ./test-${{ matrix.template }}
|
||||
wails3 init -n ${{ matrix.template }} -t ${{ matrix.template }} -ci
|
||||
wails3 init -n ${{ matrix.template }} -t ${{ matrix.template }}
|
||||
cd ${{ matrix.template }}
|
||||
wails3 build
|
||||
|
||||
@@ -3,11 +3,14 @@ on:
|
||||
push:
|
||||
branches:
|
||||
- v3-alpha
|
||||
paths:
|
||||
- 'mkdocs-website/**/*'
|
||||
permissions:
|
||||
contents: write
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
if: github.event.repository.fork == false
|
||||
defaults:
|
||||
run:
|
||||
working-directory: ./mkdocs-website
|
||||
@@ -23,6 +26,10 @@ jobs:
|
||||
path: .cache
|
||||
restore-keys: |
|
||||
mkdocs-material-
|
||||
- run: pip install -r requirements.insiders.txt
|
||||
- run: sudo apt-get install pngquant
|
||||
- run: pip install pillow cairosvg
|
||||
- run: pip install git+https://${GH_TOKEN}@github.com/squidfunk/mkdocs-material-insiders.git
|
||||
- run: mkdocs build --config-file mkdocs.insiders.yml
|
||||
- run: mkdocs gh-deploy --force
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GH_TOKEN }}
|
||||
|
||||
+15
-11
@@ -2,6 +2,9 @@
|
||||
|
||||
This is the documentation for Wails v3. It is currently a work in progress.
|
||||
|
||||
If you do not wish to build it locally, it is available online at
|
||||
[https://wailsapp.github.io/wails/](https://wailsapp.github.io/wails/).
|
||||
|
||||
## Recommended Setup Steps
|
||||
|
||||
Install the wails3 CLI if you haven't already:
|
||||
@@ -10,16 +13,18 @@ Install the wails3 CLI if you haven't already:
|
||||
go install github.com/wailsapp/wails/v3/cmd/wails3@latest
|
||||
```
|
||||
|
||||
The documentation uses mkdocs, so you will need to install [Python](https://www.python.org/). Once installed,
|
||||
you can setup the documentation by running the following command:
|
||||
The documentation uses mkdocs, so you will need to install
|
||||
[Python](https://www.python.org/). Once installed, you can setup the
|
||||
documentation by running the following command:
|
||||
|
||||
```bash
|
||||
wails3 task docs:setup
|
||||
```
|
||||
|
||||
This will install the required dependencies for you.
|
||||
This will install the required dependencies for you.
|
||||
|
||||
If you have installed the wails3 CLI, you can run the following command to build the documentation and serve it locally:
|
||||
If you have installed the wails3 CLI, you can run the following command to build
|
||||
the documentation and serve it locally:
|
||||
|
||||
```bash
|
||||
wails3 task docs:serve
|
||||
@@ -29,13 +34,12 @@ wails3 task docs:serve
|
||||
|
||||
To install manually, you will need to do the following:
|
||||
|
||||
- Install [Python](https://www.python.org/)
|
||||
- Run `pip install -r requirements.txt` to install the required dependencies
|
||||
- Run `mkdocs serve` to serve the documentation locally
|
||||
- Run `mkdocs build` to build the documentation
|
||||
|
||||
- Install [Python](https://www.python.org/)
|
||||
- Run `pip install -r requirements.txt` to install the required dependencies
|
||||
- Run `mkdocs serve` to serve the documentation locally
|
||||
- Run `mkdocs build` to build the documentation
|
||||
|
||||
## Contributing
|
||||
|
||||
If you would like to contribute to the documentation, please feel free to open a PR!
|
||||
|
||||
If you would like to contribute to the documentation, please feel free to open a
|
||||
PR!
|
||||
|
||||
@@ -51,3 +51,9 @@ tasks:
|
||||
msg: "Looks like mkdocs isn't installed. Run `wails3 task setup` or `task setup` in the documentation directory to install it."
|
||||
cmds:
|
||||
- mkdocs serve --config-file mkdocs.insiders.yml
|
||||
|
||||
update:api:
|
||||
summary: Updates the API documentation
|
||||
dir: generate
|
||||
cmds:
|
||||
- go run .
|
||||
|
||||
@@ -0,0 +1,359 @@
|
||||
# Application
|
||||
|
||||
The application API assists in creating an application using the Wails
|
||||
framework.
|
||||
|
||||
### New
|
||||
|
||||
API: `New(appOptions Options) *App`
|
||||
|
||||
`New(appOptions Options)` creates a new application using the given application
|
||||
options . It applies default values for unspecified options, merges them with
|
||||
the provided ones, initializes and returns an instance of the application.
|
||||
|
||||
In case of an error during initialization, the application is stopped with the
|
||||
error message provided.
|
||||
|
||||
It should be noted that if a global application instance already exists, that
|
||||
instance will be returned instead of creating a new one.
|
||||
|
||||
```go title="main.go" hl_lines="6-9"
|
||||
package main
|
||||
|
||||
import "github.com/wailsapp/wails/v3/pkg/application"
|
||||
|
||||
func main() {
|
||||
app := application.New(application.Options{
|
||||
Name: "WebviewWindow Demo",
|
||||
// Other options
|
||||
})
|
||||
|
||||
// Rest of application
|
||||
}
|
||||
```
|
||||
|
||||
### Get
|
||||
|
||||
`Get()` returns the global application instance. It's useful when you need to
|
||||
access the application from different parts of your code.
|
||||
|
||||
```go
|
||||
// Get the application instance
|
||||
app := application.Get()
|
||||
```
|
||||
|
||||
### Capabilities
|
||||
|
||||
API: `Capabilities() capabilities.Capabilities`
|
||||
|
||||
`Capabilities()` retrieves a map of capabilities that the application currently
|
||||
has. Capabilities can be about different features the operating system provides,
|
||||
like webview features.
|
||||
|
||||
```go
|
||||
// Get the application capabilities
|
||||
capabilities := app.Capabilities()
|
||||
if capabilities.HasNativeDrag {
|
||||
// Do something
|
||||
}
|
||||
```
|
||||
|
||||
### GetPID
|
||||
|
||||
API: `GetPID() int`
|
||||
|
||||
`GetPID()` returns the Process ID of the application.
|
||||
|
||||
```go
|
||||
pid := app.GetPID()
|
||||
```
|
||||
|
||||
### Run
|
||||
|
||||
API: `Run() error`
|
||||
|
||||
`Run()` starts the execution of the application and its components.
|
||||
|
||||
```go
|
||||
app := application.New(application.Options{
|
||||
//options
|
||||
})
|
||||
// Run the application
|
||||
err := application.Run()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
}
|
||||
```
|
||||
|
||||
### Quit
|
||||
|
||||
API: `Quit()`
|
||||
|
||||
`Quit()` quits the application by destroying windows and potentially other
|
||||
components.
|
||||
|
||||
```go
|
||||
// Quit the application
|
||||
app.Quit()
|
||||
```
|
||||
|
||||
### IsDarkMode
|
||||
|
||||
API: `IsDarkMode() bool`
|
||||
|
||||
`IsDarkMode()` checks if the application is running in dark mode. It returns a
|
||||
boolean indicating whether dark mode is enabled.
|
||||
|
||||
```go
|
||||
// Check if dark mode is enabled
|
||||
if app.IsDarkMode() {
|
||||
// Do something
|
||||
}
|
||||
```
|
||||
|
||||
### Hide
|
||||
|
||||
API: `Hide()`
|
||||
|
||||
`Hide()` hides the application window.
|
||||
|
||||
```go
|
||||
// Hide the application window
|
||||
app.Hide()
|
||||
```
|
||||
|
||||
### Show
|
||||
|
||||
API: `Show()`
|
||||
|
||||
`Show()` shows the application window.
|
||||
|
||||
```go
|
||||
// Show the application window
|
||||
app.Show()
|
||||
```
|
||||
|
||||
### NewWebviewWindow
|
||||
|
||||
API: `NewWebviewWindow() *WebviewWindow`
|
||||
|
||||
`NewWebviewWindow()` creates a new Webview window with default options, and
|
||||
returns it.
|
||||
|
||||
```go
|
||||
// Create a new webview window
|
||||
window := app.NewWebviewWindow()
|
||||
```
|
||||
|
||||
### NewWebviewWindowWithOptions
|
||||
|
||||
API:
|
||||
`NewWebviewWindowWithOptions(windowOptions WebviewWindowOptions) *WebviewWindow`
|
||||
|
||||
`NewWebviewWindowWithOptions()` creates a new webview window with custom
|
||||
options. The newly created window is added to a map of windows managed by the
|
||||
application.
|
||||
|
||||
```go
|
||||
// Create a new webview window with custom options
|
||||
window := app.NewWebviewWindowWithOptions(WebviewWindowOptions{
|
||||
Name: "Main",
|
||||
Title: "My Window",
|
||||
Width: 800,
|
||||
Height: 600,
|
||||
})
|
||||
```
|
||||
|
||||
### OnWindowCreation
|
||||
|
||||
API: `OnWindowCreation(callback func(window *WebviewWindow))`
|
||||
|
||||
`OnWindowCreation()` registers a callback function to be called when a window is
|
||||
created.
|
||||
|
||||
```go
|
||||
// Register a callback to be called when a window is created
|
||||
app.OnWindowCreation(func(window *WebviewWindow) {
|
||||
// Do something
|
||||
})
|
||||
```
|
||||
|
||||
### GetWindowByName
|
||||
|
||||
API: `GetWindowByName(name string) *WebviewWindow`
|
||||
|
||||
`GetWindowByName()` fetches and returns a window with a specific name.
|
||||
|
||||
```go
|
||||
// Get a window by name
|
||||
window := app.GetWindowByName("Main")
|
||||
```
|
||||
|
||||
### CurrentWindow
|
||||
|
||||
API: `CurrentWindow() *WebviewWindow`
|
||||
|
||||
`CurrentWindow()` fetches and returns a pointer to the currently active window
|
||||
in the application. If there is no window, it returns nil.
|
||||
|
||||
```go
|
||||
// Get the current window
|
||||
window := app.CurrentWindow()
|
||||
```
|
||||
|
||||
### RegisterContextMenu
|
||||
|
||||
API: `RegisterContextMenu(name string, menu *Menu)`
|
||||
|
||||
`RegisterContextMenu()` registers a context menu with a given name. This menu
|
||||
can be used later in the application.
|
||||
|
||||
```go
|
||||
|
||||
// Create a new menu
|
||||
ctxmenu := app.NewMenu()
|
||||
|
||||
// Register the menu as a context menu
|
||||
app.RegisterContextMenu("MyContextMenu", ctxmenu)
|
||||
```
|
||||
|
||||
### SetMenu
|
||||
|
||||
API: `SetMenu(menu *Menu)`
|
||||
|
||||
`SetMenu()` sets the menu for the application. On Mac, this will be the global
|
||||
menu. For Windows and Linux, this will be the default menu for any new window
|
||||
created.
|
||||
|
||||
```go
|
||||
// Create a new menu
|
||||
menu := app.NewMenu()
|
||||
|
||||
// Set the menu for the application
|
||||
app.SetMenu(menu)
|
||||
```
|
||||
|
||||
### ShowAboutDialog
|
||||
|
||||
API: `ShowAboutDialog()`
|
||||
|
||||
`ShowAboutDialog()` shows an "About" dialog box. It can show the application's
|
||||
name, description and icon.
|
||||
|
||||
```go
|
||||
// Show the about dialog
|
||||
app.ShowAboutDialog()
|
||||
```
|
||||
|
||||
### Info
|
||||
|
||||
API: `InfoDialog()`
|
||||
|
||||
`InfoDialog()` creates and returns a new instance of `MessageDialog` with an
|
||||
`InfoDialogType`. This dialog is typically used to display informational
|
||||
messages to the user.
|
||||
|
||||
### Question
|
||||
|
||||
API: `QuestionDialog()`
|
||||
|
||||
`QuestionDialog()` creates and returns a new instance of `MessageDialog` with a
|
||||
`QuestionDialogType`. This dialog is often used to ask a question to the user
|
||||
and expect a response.
|
||||
|
||||
### Warning
|
||||
|
||||
API: `WarningDialog()`
|
||||
|
||||
`WarningDialog()` creates and returns a new instance of `MessageDialog` with a
|
||||
`WarningDialogType`. As the name suggests, this dialog is primarily used to
|
||||
display warning messages to the user.
|
||||
|
||||
### Error
|
||||
|
||||
API: `ErrorDialog()`
|
||||
|
||||
`ErrorDialog()` creates and returns a new instance of `MessageDialog` with an
|
||||
`ErrorDialogType`. This dialog is designed to be used when you need to display
|
||||
an error message to the user.
|
||||
|
||||
### OpenFile
|
||||
|
||||
API: `OpenFileDialog()`
|
||||
|
||||
`OpenFileDialog()` creates and returns a new `OpenFileDialogStruct`. This dialog
|
||||
prompts the user to select one or more files from their file system.
|
||||
|
||||
### SaveFile
|
||||
|
||||
API: `SaveFileDialog()`
|
||||
|
||||
`SaveFileDialog()` creates and returns a new `SaveFileDialogStruct`. This dialog
|
||||
prompts the user to choose a location on their file system where a file should
|
||||
be saved.
|
||||
|
||||
### OpenDirectory
|
||||
|
||||
API: `OpenDirectoryDialog()`
|
||||
|
||||
`OpenDirectoryDialog()` creates and returns a new instance of `MessageDialog`
|
||||
with an `OpenDirectoryDialogType`. This dialog enables the user to choose a
|
||||
directory from their file system.
|
||||
|
||||
### On
|
||||
|
||||
API:
|
||||
`On(eventType events.ApplicationEventType, callback func(event *Event)) func()`
|
||||
|
||||
`On()` registers an event listener for specific application events. The callback
|
||||
function provided will be triggered when the corresponding event occurs. The
|
||||
function returns a function that can be called to remove the listener.
|
||||
|
||||
### RegisterHook
|
||||
|
||||
API:
|
||||
`RegisterHook(eventType events.ApplicationEventType, callback func(event *Event)) func()`
|
||||
|
||||
`RegisterHook()` registers a callback to be run as a hook during specific
|
||||
events. These hooks are run before listeners attached with `On()`. The function
|
||||
returns a function that can be called to remove the hook.
|
||||
|
||||
### GetPrimaryScreen
|
||||
|
||||
API: `GetPrimaryScreen() (*Screen, error)`
|
||||
|
||||
`GetPrimaryScreen()` returns the primary screen of the system.
|
||||
|
||||
### GetScreens
|
||||
|
||||
API: `GetScreens() ([]*Screen, error)`
|
||||
|
||||
`GetScreens()` returns information about all screens attached to the system.
|
||||
|
||||
This is a brief summary of the exported methods in the provided `App` struct. Do
|
||||
note that for more detailed functionality or considerations, refer to the actual
|
||||
Go code or further internal documentation.
|
||||
|
||||
## Options
|
||||
|
||||
```go title="application_options.go"
|
||||
--8<--
|
||||
../v3/pkg/application/options_application.go
|
||||
--8<--
|
||||
```
|
||||
|
||||
### Windows Options
|
||||
|
||||
```go title="application_options_windows.go"
|
||||
--8<--
|
||||
../v3/pkg/application/options_application_win.go
|
||||
--8<--
|
||||
```
|
||||
|
||||
### Mac Options
|
||||
|
||||
```go title="options_application_mac.go"
|
||||
--8<--
|
||||
../v3/pkg/application/options_application_mac.go
|
||||
--8<--
|
||||
```
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,50 @@
|
||||
# Main Thread Functions
|
||||
|
||||
These methods are utility functions to run code on the main thread. This is
|
||||
required when you want to run custom code on the UI thread.
|
||||
|
||||
### InvokeSync
|
||||
|
||||
API: `InvokeSync(fn func())`
|
||||
|
||||
This function runs the passed function (`fn`) synchronously. It uses a WaitGroup
|
||||
(`wg`) to ensure that the main thread waits for the `fn` function to finish
|
||||
before it continues. If a panic occurs inside `fn`, it will be passed to the
|
||||
handler function `PanicHandler`, defined in the application options.
|
||||
|
||||
### InvokeSyncWithResult
|
||||
|
||||
API: `InvokeSyncWithResult[T any](fn func() T) (res T)`
|
||||
|
||||
This function works similarly to `InvokeSync(fn func())`, however, it yields a
|
||||
result. Use this for calling any function with a single return.
|
||||
|
||||
### InvokeSyncWithError
|
||||
|
||||
API: `InvokeSyncWithError(fn func() error) (err error)`
|
||||
|
||||
This function runs `fn` synchronously and returns any error that `fn` produces.
|
||||
Note that this function will recover from a panic if one occurs during `fn`'s
|
||||
execution.
|
||||
|
||||
### InvokeSyncWithResultAndError
|
||||
|
||||
API:
|
||||
`InvokeSyncWithResultAndError[T any](fn func() (T, error)) (res T, err error)`
|
||||
|
||||
This function runs `fn` synchronously and returns both a result of type `T` and
|
||||
an error.
|
||||
|
||||
### InvokeAsync
|
||||
|
||||
API: `InvokeAsync(fn func())`
|
||||
|
||||
This function runs `fn` asynchronously. It runs the given function on the main
|
||||
thread. If a panic occurs inside `fn`, it will be passed to the handler function
|
||||
`PanicHandler`, defined in the application options.
|
||||
|
||||
---
|
||||
|
||||
_Note_: These functions will block execution until `fn` has finished. It's
|
||||
critical to ensure that `fn` doesn't block. If you need to run a function that
|
||||
blocks, use `InvokeAsync` instead.
|
||||
@@ -0,0 +1,69 @@
|
||||
# Menu
|
||||
|
||||
Menus can be created and added to the application. They can be used to create
|
||||
context menus, system tray menus and application menus.
|
||||
|
||||
To create a new menu, call:
|
||||
|
||||
```go
|
||||
// Create a new menu
|
||||
menu := app.NewMenu()
|
||||
```
|
||||
|
||||
The following operations are then available on the `Menu` type:
|
||||
|
||||
### Add
|
||||
|
||||
API: `Add(label string) *MenuItem`
|
||||
|
||||
This method takes a `label` of type `string` as an input and adds a new
|
||||
`MenuItem` with the given label to the menu. It returns the `MenuItem` added.
|
||||
|
||||
### AddSeparator
|
||||
|
||||
API: `AddSeparator()`
|
||||
|
||||
This method adds a new separator `MenuItem` to the menu.
|
||||
|
||||
### AddCheckbox
|
||||
|
||||
API: `AddCheckbox(label string, enabled bool) *MenuItem`
|
||||
|
||||
This method takes a `label` of type `string` and `enabled` of type `bool` as
|
||||
inputs and adds a new checkbox `MenuItem` with the given label and enabled state
|
||||
to the menu. It returns the `MenuItem` added.
|
||||
|
||||
### AddRadio
|
||||
|
||||
API: `AddRadio(label string, enabled bool) *MenuItem`
|
||||
|
||||
This method takes a `label` of type `string` and `enabled` of type `bool` as
|
||||
inputs and adds a new radio `MenuItem` with the given label and enabled state to
|
||||
the menu. It returns the `MenuItem` added.
|
||||
|
||||
### Update
|
||||
|
||||
API: `Update()`
|
||||
|
||||
This method processes any radio groups and updates the menu if a menu
|
||||
implementation is not initialized.
|
||||
|
||||
### AddSubmenu
|
||||
|
||||
API: `AddSubmenu(s string) *Menu`
|
||||
|
||||
This method takes a `s` of type `string` as input and adds a new submenu
|
||||
`MenuItem` with the given label to the menu. It returns the submenu added.
|
||||
|
||||
### AddRole
|
||||
|
||||
API: `AddRole(role Role) *Menu`
|
||||
|
||||
This method takes `role` of type `Role` as input, adds it to the menu if it is
|
||||
not `nil` and returns the `Menu`.
|
||||
|
||||
### SetLabel
|
||||
|
||||
API: `SetLabel(label string)`
|
||||
|
||||
This method sets the `label` of the `Menu`.
|
||||
@@ -0,0 +1,112 @@
|
||||
# System Tray
|
||||
|
||||
The system tray houses notification area on a desktop environment, which can
|
||||
contain both icons of currently-running applications and specific system
|
||||
notifications.
|
||||
|
||||
You create a system tray by calling `app.NewSystemTray()`:
|
||||
|
||||
```go
|
||||
// Create a new system tray
|
||||
tray := app.NewSystemTray()
|
||||
```
|
||||
|
||||
The following methods are available on the `SystemTray` type:
|
||||
|
||||
### SetLabel
|
||||
|
||||
API: `SetLabel(label string)`
|
||||
|
||||
The `SetLabel` method sets the tray's label.
|
||||
|
||||
### Label
|
||||
|
||||
API: `Label() string`
|
||||
|
||||
The `Label` method retrieves the tray's label.
|
||||
|
||||
### PositionWindow
|
||||
|
||||
API: `PositionWindow(*WebviewWindow, offset int) error`
|
||||
|
||||
The `PositionWindow` method calls both `AttachWindow` and `WindowOffset`
|
||||
methods.
|
||||
|
||||
### SetIcon
|
||||
|
||||
API: `SetIcon(icon []byte) *SystemTray`
|
||||
|
||||
The `SetIcon` method sets the system tray's icon.
|
||||
|
||||
### SetDarkModeIcon
|
||||
|
||||
API: `SetDarkModeIcon(icon []byte) *SystemTray`
|
||||
|
||||
The `SetDarkModeIcon` method sets the system tray's icon when in dark mode.
|
||||
|
||||
### SetMenu
|
||||
|
||||
API: `SetMenu(menu *Menu) *SystemTray`
|
||||
|
||||
The `SetMenu` method sets the system tray's menu.
|
||||
|
||||
### Destroy
|
||||
|
||||
API: `Destroy()`
|
||||
|
||||
The `Destroy` method destroys the system tray instance.
|
||||
|
||||
### OnClick
|
||||
|
||||
API: `OnClick(handler func()) *SystemTray`
|
||||
|
||||
The `OnClick` method sets the function to execute when the tray icon is clicked.
|
||||
|
||||
### OnRightClick
|
||||
|
||||
API: `OnRightClick(handler func()) *SystemTray`
|
||||
|
||||
The `OnRightClick` method sets the function to execute when right-clicking the
|
||||
tray icon.
|
||||
|
||||
### OnDoubleClick
|
||||
|
||||
API: `OnDoubleClick(handler func()) *SystemTray`
|
||||
|
||||
The `OnDoubleClick` method sets the function to execute when double-clicking the
|
||||
tray icon.
|
||||
|
||||
### OnRightDoubleClick
|
||||
|
||||
API: `OnRightDoubleClick(handler func()) *SystemTray`
|
||||
|
||||
The `OnRightDoubleClick` method sets the function to execute when right
|
||||
double-clicking the tray icon.
|
||||
|
||||
### AttachWindow
|
||||
|
||||
API: `AttachWindow(window *WebviewWindow) *SystemTray`
|
||||
|
||||
The `AttachWindow` method attaches a window to the system tray. The window will
|
||||
be shown when the system tray icon is clicked.
|
||||
|
||||
### WindowOffset
|
||||
|
||||
API: `WindowOffset(offset int) *SystemTray`
|
||||
|
||||
The `WindowOffset` method sets the gap in pixels between the system tray and the
|
||||
window.
|
||||
|
||||
### WindowDebounce
|
||||
|
||||
API: `WindowDebounce(debounce time.Duration) *SystemTray`
|
||||
|
||||
The `WindowDebounce` method sets a debounce time. In the context of Windows,
|
||||
this is used to specify how long to wait before responding to a mouse up event
|
||||
on the notification icon.
|
||||
|
||||
### OpenMenu
|
||||
|
||||
API: `OpenMenu()`
|
||||
|
||||
The `OpenMenu` method opens the menu associated with the system tray.
|
||||
@@ -0,0 +1,114 @@
|
||||
# Window
|
||||
|
||||
To create a window, use
|
||||
[Application.NewWebviewWindow](application.md#newwebviewwindow) or
|
||||
[Application.NewWebviewWindowWithOptions](application.md#newwebviewwindowwithoptions).
|
||||
The former creates a window with default options, while the latter allows you to
|
||||
specify custom options.
|
||||
|
||||
These methods are callable on the returned WebviewWindow object:
|
||||
|
||||
### SetTitle
|
||||
|
||||
API: `SetTitle(title string) *WebviewWindow`
|
||||
|
||||
This method updates the window title to the provided string. It returns the
|
||||
WebviewWindow object, allowing for method chaining.
|
||||
|
||||
### Name
|
||||
|
||||
API: `Name() string`
|
||||
|
||||
This function returns the name of the WebviewWindow.
|
||||
|
||||
### SetSize
|
||||
|
||||
API: `SetSize(width, height int) *WebviewWindow`
|
||||
|
||||
This method sets the size of the WebviewWindow to the provided width and height
|
||||
parameters. If the dimensions provided exceed the constraints, they are adjusted
|
||||
appropriately.
|
||||
|
||||
### SetAlwaysOnTop
|
||||
|
||||
API: `SetAlwaysOnTop(b bool) *WebviewWindow`
|
||||
|
||||
This function sets the window to stay on top based on the boolean flag provided.
|
||||
|
||||
### Show
|
||||
|
||||
API: `Show() *WebviewWindow`
|
||||
|
||||
`Show` method is used to make the window visible. If the window is not running,
|
||||
it first invokes the `run` method to start the window and then makes it visible.
|
||||
|
||||
### Hide
|
||||
|
||||
API: `Hide() *WebviewWindow`
|
||||
|
||||
`Hide` method is used to hide the window. It sets the hidden status of the
|
||||
window to true and emits the window hide event.
|
||||
|
||||
### SetURL
|
||||
|
||||
API: `SetURL(s string) *WebviewWindow`
|
||||
|
||||
`SetURL` method is used to set the URL of the window to the given URL string.
|
||||
|
||||
### SetZoom
|
||||
|
||||
API: `SetZoom(magnification float64) *WebviewWindow`
|
||||
|
||||
`SetZoom` method sets the zoom level of the window content to the provided
|
||||
magnification level.
|
||||
|
||||
### GetZoom
|
||||
|
||||
API: `GetZoom() float64`
|
||||
|
||||
`GetZoom` function returns the current zoom level of the window content.
|
||||
|
||||
### GetScreen
|
||||
|
||||
API: `GetScreen() (*Screen, error)`
|
||||
|
||||
`GetScreen` method returns the screen on which the window is displayed.
|
||||
|
||||
#### SetFrameless
|
||||
|
||||
API: `SetFrameless(frameless bool) *WebviewWindow`
|
||||
|
||||
This function is used to remove the window frame and title bar. It toggles the
|
||||
framelessness of the window according to the boolean value provided (true for
|
||||
frameless, false for framed).
|
||||
|
||||
#### RegisterContextMenu
|
||||
|
||||
API: `RegisterContextMenu(name string, menu *Menu)`
|
||||
|
||||
This function is used to register a context menu and assigns it the given name.
|
||||
|
||||
#### NativeWindowHandle
|
||||
|
||||
API: `NativeWindowHandle() (uintptr, error)`
|
||||
|
||||
This function is used to fetch the platform native window handle for the window.
|
||||
|
||||
#### Focus
|
||||
|
||||
API: `Focus()`
|
||||
|
||||
This function is used to focus the window.
|
||||
|
||||
#### SetEnabled
|
||||
|
||||
API: `SetEnabled(enabled bool)`
|
||||
|
||||
This function is used to enable/disable the window based on the provided boolean
|
||||
value.
|
||||
|
||||
#### SetAbsolutePosition
|
||||
|
||||
API: `SetAbsolutePosition(x int, y int)`
|
||||
|
||||
This function sets the absolute position of the window in the screen.
|
||||
@@ -17,15 +17,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
|
||||
### Added
|
||||
* [darwin] add getPrimaryScreen/getScreens to impl by @tmclane in https://github.com/wailsapp/wails/pull/2618
|
||||
|
||||
- [darwin] add Event ApplicationShouldHandleReopen to able handle dock icon click by @5aaee9 in [#2991](https://github.com/wailsapp/wails/pull/2991)
|
||||
- [darwin] add getPrimaryScreen/getScreens to impl by @tmclane in [#2618](https://github.com/wailsapp/wails/pull/2618)
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed Doctor apt package verify by [Atterpac](https://github.com/Atterpac) in [#2972](https://github.com/wailsapp/wails/pull/2972).
|
||||
- Fixed application frozen when quit (Darwin) by @5aaee9 in [#2982](https://github.com/wailsapp/wails/pull/2982)
|
||||
- Fixed background colours of examples on Windows by [mmgvh](https://github.com/mmghv) in [#2750](https://github.com/wailsapp/wails/pull/2750).
|
||||
- Fixed default context menus by [mmgvh](https://github.com/mmghv) in [#2753](https://github.com/wailsapp/wails/pull/2753).
|
||||
|
||||
|
||||
### Changed
|
||||
|
||||
### Removed
|
||||
@@ -33,4 +37,3 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
### Deprecated
|
||||
|
||||
### Security
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,32 +1,35 @@
|
||||
# Introduction
|
||||
|
||||
!!! note
|
||||
This guide is a work in progress.
|
||||
!!! note This guide is a work in progress.
|
||||
|
||||
Thanks for wanting to help out with development of Wails! This guide will help you get started.
|
||||
Thanks for wanting to help out with development of Wails! This guide will help
|
||||
you get started.
|
||||
|
||||
## Getting Started
|
||||
|
||||
- Git clone this repository. Checkout the `v3-alpha` branch.
|
||||
- Install the CLI: `cd v3/cmd/wails3 && go install`
|
||||
|
||||
- Optional: If you are wanting to use the build system to build frontend code, you will need to install [npm](https://nodejs.org/en/download).
|
||||
- Optional: If you are wanting to use the build system to build frontend code,
|
||||
you will need to install [npm](https://nodejs.org/en/download).
|
||||
|
||||
## Building
|
||||
|
||||
For simple programs, you can use the standard `go build` command. It's also possible to use `go run`.
|
||||
For simple programs, you can use the standard `go build` command. It's also
|
||||
possible to use `go run`.
|
||||
|
||||
Wails also comes with a build system that can be used to build more complex projects. It utilises the awesome [Task](https://taskfile.dev) build system.
|
||||
For more information, check out the task homepage or run `wails task --help`.
|
||||
Wails also comes with a build system that can be used to build more complex
|
||||
projects. It utilises the awesome [Task](https://taskfile.dev) build system. For
|
||||
more information, check out the task homepage or run `wails task --help`.
|
||||
|
||||
## Project layout
|
||||
|
||||
The project has the following structure:
|
||||
|
||||
|
||||
```
|
||||
v3
|
||||
├── cmd/wails3 // CLI
|
||||
├── examples // Examples of Wails apps
|
||||
├── examples // Examples of Wails apps
|
||||
├── internal // Internal packages
|
||||
| ├── runtime // The Wails JS runtime
|
||||
| └── templates // The supported project templates
|
||||
@@ -44,18 +47,27 @@ The project has the following structure:
|
||||
|
||||
### Adding window functionality
|
||||
|
||||
The preferred way to add window functionality is to add a new function to the `pkg/application/webview_window.go` file. This should implement all the functionality required for all platforms. Any platform specific code should be called via a `webviewWindowImpl` interface method. This interface is implemented by each of the target platforms to provide the platform specific functionality. In some cases, this may do nothing.
|
||||
Once you've added the interface method, ensure each platform implements it. A good example of this is the `SetMinSize` method.
|
||||
The preferred way to add window functionality is to add a new function to the
|
||||
`pkg/application/webview_window.go` file. This should implement all the
|
||||
functionality required for all platforms. Any platform specific code should be
|
||||
called via a `webviewWindowImpl` interface method. This interface is implemented
|
||||
by each of the target platforms to provide the platform specific functionality.
|
||||
In some cases, this may do nothing. Once you've added the interface method,
|
||||
ensure each platform implements it. A good example of this is the `SetMinSize`
|
||||
method.
|
||||
|
||||
- Mac: `webview_window_darwin.go`
|
||||
- Windows: `webview_window_windows.go`
|
||||
- Linux: `webview_window_linux.go`
|
||||
|
||||
Most, if not all, of the platform specific code should be run on the main thread. To simplify this, there are a number of `invokeSync` methods defined in `application.go`.
|
||||
Most, if not all, of the platform specific code should be run on the main
|
||||
thread. To simplify this, there are a number of `invokeSync` methods defined in
|
||||
`application.go`.
|
||||
|
||||
### Updating the runtime
|
||||
|
||||
The runtime is located in `v3/internal/runtime`. When the runtime is updated, the following steps need to be taken:
|
||||
The runtime is located in `v3/internal/runtime`. When the runtime is updated,
|
||||
the following steps need to be taken:
|
||||
|
||||
```shell
|
||||
wails3 task runtime:build
|
||||
@@ -63,14 +75,19 @@ wails3 task runtime:build
|
||||
|
||||
### Events
|
||||
|
||||
Events are defined in `v3/pkg/events`. When adding a new event, the following steps need to be taken:
|
||||
Events are defined in `v3/pkg/events`. When adding a new event, the following
|
||||
steps need to be taken:
|
||||
|
||||
- Add the event to the `events.txt` file
|
||||
- Run `wails3 task events:generate`
|
||||
|
||||
There are a number of types of events: platform specific application and window events + common events. The common events are useful for cross-platform event handling, but you aren't limited to the "lowest common denominator". You can use the platform specific events if you need to.
|
||||
There are a number of types of events: platform specific application and window
|
||||
events + common events. The common events are useful for cross-platform event
|
||||
handling, but you aren't limited to the "lowest common denominator". You can use
|
||||
the platform specific events if you need to.
|
||||
|
||||
When adding a common event, ensure that the platform specific events are mapped. An example of this is in `window_webview_darwin.go`:
|
||||
When adding a common event, ensure that the platform specific events are mapped.
|
||||
An example of this is in `window_webview_darwin.go`:
|
||||
|
||||
```go
|
||||
// Translate ShouldClose to common WindowClosing event
|
||||
@@ -79,7 +96,8 @@ When adding a common event, ensure that the platform specific events are mapped.
|
||||
})
|
||||
```
|
||||
|
||||
NOTE: We may try to automate this in the future by adding the mapping to the event definition.
|
||||
NOTE: We may try to automate this in the future by adding the mapping to the
|
||||
event definition.
|
||||
|
||||
### Plugins
|
||||
|
||||
@@ -93,35 +111,42 @@ Plugins are standard Go structure that adhere to the following interface:
|
||||
type Plugin interface {
|
||||
Name() string
|
||||
Init(*application.App) error
|
||||
Shutdown()
|
||||
Shutdown()
|
||||
CallableByJS() []string
|
||||
InjectJS() string
|
||||
}
|
||||
```
|
||||
|
||||
The `Name()` method returns the name of the plugin. This is used for logging purposes.
|
||||
The `Name()` method returns the name of the plugin. This is used for logging
|
||||
purposes.
|
||||
|
||||
The `Init(*application.App) error` method is called when the plugin is loaded. The `*application.App`
|
||||
parameter is the application that the plugin is being loaded into. Any errors will prevent
|
||||
the application from starting.
|
||||
The `Init(*application.App) error` method is called when the plugin is loaded.
|
||||
The `*application.App` parameter is the application that the plugin is being
|
||||
loaded into. Any errors will prevent the application from starting.
|
||||
|
||||
The `Shutdown()` method is called when the application is shutting down.
|
||||
|
||||
The `CallableByJS()` method returns a list of exported functions that can be called from
|
||||
the frontend. These method names must exactly match the names of the methods exported
|
||||
by the plugin.
|
||||
The `CallableByJS()` method returns a list of exported functions that can be
|
||||
called from the frontend. These method names must exactly match the names of the
|
||||
methods exported by the plugin.
|
||||
|
||||
The `InjectJS()` method returns JavaScript that should be injected into all windows as they are created. This is useful for adding custom JavaScript functions that complement the plugin.
|
||||
The `InjectJS()` method returns JavaScript that should be injected into all
|
||||
windows as they are created. This is useful for adding custom JavaScript
|
||||
functions that complement the plugin.
|
||||
|
||||
The built-in plugins can be found in the `v3/plugins` directory.
|
||||
Check them out for inspiration.
|
||||
|
||||
## Misc Tasks
|
||||
## Tasks
|
||||
|
||||
The Wails CLI uses the [Task](https://taskfile.dev) build system. It is imported
|
||||
as a library and used to run the tasks defined in `Taskfile.yaml`. The main
|
||||
interfacing with Task happens in `v3/internal/commands/task.go`.
|
||||
|
||||
### Upgrading Taskfile
|
||||
|
||||
The Wails CLI uses the [Task](https://taskfile.dev) build system. It is imported as a library and used to run the tasks defined in `Taskfile.yaml`.
|
||||
The main interfacing with Task happens in `v3/internal/commands/task.go`.
|
||||
|
||||
To check if there's an upgrade for Taskfile, run `wails3 task -version` and check against the Task website.
|
||||
To check if there's an upgrade for Taskfile, run `wails3 task -version` and
|
||||
check against the Task website.
|
||||
|
||||
To upgrade the version of Taskfile used, run:
|
||||
|
||||
@@ -129,11 +154,15 @@ To upgrade the version of Taskfile used, run:
|
||||
wails3 task taskfile:upgrade
|
||||
```
|
||||
|
||||
If there are incompatibilities then they should appear in the `v3/internal/commands/task.go` file.
|
||||
If there are incompatibilities then they should appear in the
|
||||
`v3/internal/commands/task.go` file.
|
||||
|
||||
Usually the best way to fix incompatibilities is to clone the task repo at `https://github.com/go-task/task` and look at the git history to determine what has changed and why.
|
||||
Usually the best way to fix incompatibilities is to clone the task repo at
|
||||
`https://github.com/go-task/task` and look at the git history to determine what
|
||||
has changed and why.
|
||||
|
||||
To check all changes have worked correctly, re-install the CLI and check the version again:
|
||||
To check all changes have worked correctly, re-install the CLI and check the
|
||||
version again:
|
||||
|
||||
```shell
|
||||
wails3 task cli:install
|
||||
@@ -142,18 +171,21 @@ wails3 task -version
|
||||
|
||||
## Opening a PR
|
||||
|
||||
Make sure that all PRs have a ticket associated with them providing context to the change. If there is no ticket, please create one first.
|
||||
Ensure that all PRs have updated the CHANGELOG.md file with the changes made. The CHANGELOG.md file is located in the `v3` directory.
|
||||
|
||||
Make sure that all PRs have a ticket associated with them providing context to
|
||||
the change. If there is no ticket, please create one first. Ensure that all PRs
|
||||
have updated the CHANGELOG.md file with the changes made. The CHANGELOG.md file
|
||||
is located in the `mkdocs-website/docs` directory.
|
||||
|
||||
## Misc Tasks
|
||||
|
||||
### Upgrading Taskfile
|
||||
|
||||
The Wails CLI uses the [Task](https://taskfile.dev) build system. It is imported as a library and used to run the tasks defined in `Taskfile.yaml`.
|
||||
The main interfacing with Task happens in `v3/internal/commands/task.go`.
|
||||
The Wails CLI uses the [Task](https://taskfile.dev) build system. It is imported
|
||||
as a library and used to run the tasks defined in `Taskfile.yaml`. The main
|
||||
interfacing with Task happens in `v3/internal/commands/task.go`.
|
||||
|
||||
To check if there's an upgrade for Taskfile, run `wails3 task -version` and check against the Task website.
|
||||
To check if there's an upgrade for Taskfile, run `wails3 task -version` and
|
||||
check against the Task website.
|
||||
|
||||
To upgrade the version of Taskfile used, run:
|
||||
|
||||
@@ -161,14 +193,17 @@ To upgrade the version of Taskfile used, run:
|
||||
wails3 task taskfile:upgrade
|
||||
```
|
||||
|
||||
If there are incompatibilities then they should appear in the `v3/internal/commands/task.go` file.
|
||||
If there are incompatibilities then they should appear in the
|
||||
`v3/internal/commands/task.go` file.
|
||||
|
||||
Usually the best way to fix incompatibilities is to clone the task repo at `https://github.com/go-task/task` and look at the git history to determine what has changed and why.
|
||||
Usually the best way to fix incompatibilities is to clone the task repo at
|
||||
`https://github.com/go-task/task` and look at the git history to determine what
|
||||
has changed and why.
|
||||
|
||||
To check all changes have worked correctly, re-install the CLI and check the version again:
|
||||
To check all changes have worked correctly, re-install the CLI and check the
|
||||
version again:
|
||||
|
||||
```shell
|
||||
wails3 task cli:install
|
||||
wails3 task -version
|
||||
```
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ Application interface methods
|
||||
|---------------------------------------------------------------|---------|-------|-----|-------|
|
||||
| run() error | Y | Y | Y | |
|
||||
| destroy() | | Y | Y | |
|
||||
| setApplicationMenu(menu *Menu) | Y | Y | Y | |
|
||||
| setApplicationMenu(menu \*Menu) | Y | Y | Y | |
|
||||
| name() string | | Y | Y | |
|
||||
| getCurrentWindowID() uint | Y | Y | Y | |
|
||||
| showAboutDialog(name string, description string, icon []byte) | | Y | Y | |
|
||||
@@ -28,8 +28,8 @@ Application interface methods
|
||||
| dispatchOnMainThread(fn func()) | Y | Y | Y | |
|
||||
| hide() | Y | Y | Y | |
|
||||
| show() | Y | Y | Y | |
|
||||
| getPrimaryScreen() (*Screen, error) | | Y | Y | |
|
||||
| getScreens() ([]*Screen, error) | | Y | Y | |
|
||||
| getPrimaryScreen() (\*Screen, error) | | Y | Y | |
|
||||
| getScreens() ([]\*Screen, error) | | Y | Y | |
|
||||
|
||||
## Webview Window
|
||||
|
||||
@@ -44,7 +44,7 @@ Webview Window Interface Methods
|
||||
| focus() | Y | Y | | |
|
||||
| forceReload() | | Y | Y | |
|
||||
| fullscreen() | Y | Y | Y | |
|
||||
| getScreen() (*Screen, error) | y | Y | Y | |
|
||||
| getScreen() (\*Screen, error) | y | Y | Y | |
|
||||
| getZoom() float64 | | Y | Y | |
|
||||
| height() int | Y | Y | Y | |
|
||||
| hide() | Y | Y | Y | |
|
||||
@@ -121,13 +121,15 @@ Webview Window Interface Methods
|
||||
| On By Default | | | | |
|
||||
| Control via HTML | Y | | | |
|
||||
|
||||
The default context menu is enabled by default for all elements that are `contentEditable: true`, `<input>`
|
||||
or `<textarea>` tags or have the `--default-contextmenu: true` style set.
|
||||
The `--default-contextmenu: show` style will always show the context menu
|
||||
The `--default-contextmenu: hide` style will always hide the context menu
|
||||
The default context menu is enabled by default for all elements that are
|
||||
`contentEditable: true`, `<input>` or `<textarea>` tags or have the
|
||||
`--default-contextmenu: true` style set. The `--default-contextmenu: show` style
|
||||
will always show the context menu The `--default-contextmenu: hide` style will
|
||||
always hide the context menu
|
||||
|
||||
Anything nested under a tag with `--default-contextmenu: hide` style will not show the context menu unless it is
|
||||
explicitly set with `--default-contextmenu: show`.
|
||||
Anything nested under a tag with `--default-contextmenu: hide` style will not
|
||||
show the context menu unless it is explicitly set with
|
||||
`--default-contextmenu: show`.
|
||||
|
||||
### Screens
|
||||
|
||||
@@ -145,8 +147,7 @@ explicitly set with `--default-contextmenu: show`.
|
||||
|
||||
### Window
|
||||
|
||||
Y = Supported
|
||||
U = Untested
|
||||
Y = Supported U = Untested
|
||||
|
||||
- = Not available
|
||||
|
||||
@@ -164,7 +165,7 @@ U = Untested
|
||||
| Screen | Y | Y | Y | Get screen for window |
|
||||
| SetAlwaysOnTop | Y | Y | Y | |
|
||||
| SetBackgroundColour | Y | Y | Y | https://github.com/MicrosoftEdge/WebView2Feedback/issues/1621#issuecomment-938234294 |
|
||||
| SetEnabled | Y | U | U | Set the window to be enabled/disabled |
|
||||
| SetEnabled | Y | U | - | Set the window to be enabled/disabled |
|
||||
| SetMaxSize | Y | Y | Y | |
|
||||
| SetMinSize | Y | Y | Y | |
|
||||
| SetRelativePosition | Y | Y | Y | |
|
||||
@@ -184,8 +185,9 @@ U = Untested
|
||||
|
||||
### Window Options
|
||||
|
||||
A 'Y' in the table below indicates that the option has been tested and is applied when the window is created.
|
||||
An 'X' indicates that the option is not supported by the platform.
|
||||
A 'Y' in the table below indicates that the option has been tested and is
|
||||
applied when the window is created. An 'X' indicates that the option is not
|
||||
supported by the platform.
|
||||
|
||||
| Feature | Windows | Linux | Mac | Notes |
|
||||
|---------------------------------|---------|-------|-----|--------------------------------------------|
|
||||
@@ -247,7 +249,7 @@ To log or not to log? System logger vs custom logger.
|
||||
| setLabel(label string) | - | | Y | |
|
||||
| run() | Y | | Y | |
|
||||
| setIcon(icon []byte) | Y | | Y | |
|
||||
| setMenu(menu *Menu) | Y | | Y | |
|
||||
| setMenu(menu \*Menu) | Y | | Y | |
|
||||
| setIconPosition(position int) | - | | Y | |
|
||||
| setTemplateIcon(icon []byte) | - | | Y | |
|
||||
| destroy() | Y | | Y | |
|
||||
@@ -364,15 +366,17 @@ TODO:
|
||||
|
||||
## Linux Specific
|
||||
|
||||
Implementation details for the functions utilized by the `*_linux.go` files are located in the following files:
|
||||
Implementation details for the functions utilized by the `*_linux.go` files are
|
||||
located in the following files:
|
||||
|
||||
- linux_cgo.go: CGo implementation
|
||||
- linux_purego.go: PureGo implementation
|
||||
|
||||
### CGO
|
||||
|
||||
By default CGO is utilized to compile the Linux port. This prevents easy cross-compilation and so the PureGo
|
||||
implementation is also being simultaneously developed.
|
||||
By default CGO is utilized to compile the Linux port. This prevents easy
|
||||
cross-compilation and so the PureGo implementation is also being simultaneously
|
||||
developed.
|
||||
|
||||
### Purego
|
||||
|
||||
@@ -382,32 +386,3 @@ The examples can be compiled using the following command:
|
||||
|
||||
Note: things are currently not working after the refactor
|
||||
|
||||
## Examples
|
||||
|
||||
| Example | Windows | Linux | Mac |
|
||||
|--------------|----------------------|-------|-----|
|
||||
| binding | NO | | |
|
||||
| build | Yes (Debug + Prod) | | |
|
||||
| clipboard | Yes | | |
|
||||
| contextmenus | Yes | | |
|
||||
| dialogs | Almost | | |
|
||||
| drag-n-drop | NO | | |
|
||||
| events | NO | | |
|
||||
| frameless | Yes | | |
|
||||
| kitchensink | Yes | | |
|
||||
| menu | Yes | | |
|
||||
| plain | Yes | | |
|
||||
| plugins | Yes | | |
|
||||
| screen | Yes | | |
|
||||
| systray | Yes | | Yes |
|
||||
| window | Yes | | |
|
||||
| windowjs | Example not complete | | |
|
||||
| wml | Yes | | |
|
||||
|
||||
# Alpha Release TODO
|
||||
|
||||
- [ ] Check all runtime methods are available in the JS runtime
|
||||
|
||||
# Beta Release TODO
|
||||
|
||||
- [ ] Make better looking examples
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 109 KiB After Width: | Height: | Size: 15 KiB |
@@ -1,11 +1,12 @@
|
||||
# Feedback
|
||||
|
||||
We welcome (and encourage) your feedback! Here are the different ways to provide feedback:
|
||||
We welcome (and encourage) your feedback! Please search for existing tickets or posts before creating new ones.
|
||||
Here are the different ways to provide feedback:
|
||||
|
||||
=== "Bugs"
|
||||
|
||||
If you find a bug, please let us know by posting into the [v3 Alpha Feedback](https://discord.gg/3mgVyGua) channel on Discord:
|
||||
|
||||
|
||||
- The post should clearly state what the bug is and have a simple reproducible example. If the docs are unclear what *should* happen, please include that in the post.
|
||||
- The post should be given the `Bug` tag.
|
||||
- Please include the output of `wails doctor` in your post.
|
||||
@@ -14,12 +15,12 @@ We welcome (and encourage) your feedback! Here are the different ways to provide
|
||||
=== "Fixes"
|
||||
|
||||
If you have a fix for a bug or an update for documentation, please do the following:
|
||||
|
||||
- Open a pull request on the [Wails repository](https://github.com/wailsapp/wails). The title of the PR should start with `[v3]`.
|
||||
|
||||
- Open a pull request on the [Wails repository](https://github.com/wailsapp/wails). The title of the PR should start with `[v3 alpha]`.
|
||||
- Create a post in the [v3 Alpha Feedback](https://discord.gg/3mgVyGua) channel.
|
||||
- The post should be given the `PR` tag.
|
||||
- Please include a link to the PR in your post.
|
||||
|
||||
|
||||
=== "Suggestions"
|
||||
|
||||
If you have a suggestion, please let us know by posting into the [v3 Alpha Feedback](https://discord.gg/3mgVyGua) channel on Discord:
|
||||
@@ -30,27 +31,28 @@ We welcome (and encourage) your feedback! Here are the different ways to provide
|
||||
|
||||
=== "Upvoting"
|
||||
|
||||
- Posts can be "upvoted" by using the :thumbsup: emoji. Please apply to any posts that are a priority for you.
|
||||
- Please *don't* just add comments like "+1" or "me too".
|
||||
- Posts can be "upvoted" by using the :thumbsup: emoji. Please apply to any posts that are a priority for you.
|
||||
- Please *don't* just add comments like "+1" or "me too".
|
||||
- Please feel free to comment if there is more to add to the post, such as "this bug also affect ARM builds" or "Another option would be to ....."
|
||||
|
||||
There is a list of known issues & work in progress can be found [here](https://github.com/orgs/wailsapp/projects/6).
|
||||
|
||||
Things we are looking for feedback on:
|
||||
## Things we are looking for feedback on
|
||||
|
||||
- The API
|
||||
- Is it easy to use?
|
||||
- Does it do what you expect?
|
||||
- Is it missing anything?
|
||||
- Is there anything that should be removed?
|
||||
- Is it consistent between Go and JS?
|
||||
- The build system
|
||||
- Is it easy to use?
|
||||
- Can we improve it?
|
||||
- The API
|
||||
- Is it easy to use?
|
||||
- Does it do what you expect?
|
||||
- Is it missing anything?
|
||||
- Is there anything that should be removed?
|
||||
- Is it consistent between Go and JS?
|
||||
- The build system
|
||||
- Is it easy to use?
|
||||
- Can we improve it?
|
||||
- The examples
|
||||
- Are they clear?
|
||||
- Do they cover the basics?
|
||||
- Are they clear?
|
||||
- Do they cover the basics?
|
||||
- Features
|
||||
- What features are missing?
|
||||
- What features are not needed?
|
||||
- What features are missing?
|
||||
- What features are not needed?
|
||||
- Documentation
|
||||
- What could be clearer?
|
||||
- What could be clearer?
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
# Installation
|
||||
|
||||
|
||||
To install the Wails CLI, ensure you have [Go 1.21+](https://go.dev/dl/) installed and run:
|
||||
To install the Wails CLI, ensure you have [Go 1.21+](https://go.dev/dl/)
|
||||
installed and run:
|
||||
|
||||
```shell
|
||||
go install github.com/wailsapp/wails/v3/cmd/wails3@latest
|
||||
git clone https://github.com/wailsapp/wails.git
|
||||
cd wails/cmd/wails3
|
||||
go install
|
||||
```
|
||||
|
||||
## Supported Platforms
|
||||
@@ -21,9 +23,9 @@ Wails has a number of common dependencies that are required before installation:
|
||||
=== "Go 1.21+"
|
||||
|
||||
Download Go from the [Go Downloads Page](https://go.dev/dl/).
|
||||
|
||||
|
||||
Ensure that you follow the official [Go installation instructions](https://go.dev/doc/install). You will also need to ensure that your `PATH` environment variable also includes the path to your `~/go/bin` directory. Restart your terminal and do the following checks:
|
||||
|
||||
|
||||
- Check Go is installed correctly: `go version`
|
||||
- Check `~/go/bin` is in your PATH variable: `echo $PATH | grep go/bin`
|
||||
|
||||
@@ -32,7 +34,7 @@ Wails has a number of common dependencies that are required before installation:
|
||||
Although Wails doesn't require npm to be installed, it is needed if you want to use the bundled templates.
|
||||
|
||||
Download the latest node installer from the [Node Downloads Page](https://nodejs.org/en/download/). It is best to use the latest release as that is what we generally test against.
|
||||
|
||||
|
||||
Run `npm --version` to verify.
|
||||
|
||||
=== "Task (Optional)"
|
||||
@@ -63,12 +65,15 @@ You will also need to install platform specific dependencies:
|
||||
|
||||
## System Check
|
||||
|
||||
Running `wails3 doctor` will check if you have the correct dependencies installed. If not, it will advise on what is missing and help on how to rectify any problems.
|
||||
Running `wails3 doctor` will check if you have the correct dependencies
|
||||
installed. If not, it will advise on what is missing and help on how to rectify
|
||||
any problems.
|
||||
|
||||
## The `wails3` command appears to be missing?
|
||||
|
||||
If your system is reporting that the `wails3` command is missing, check the following:
|
||||
|
||||
- Make sure you have followed the Go installation guide correctly.
|
||||
- Check that the `go/bin` directory is in the `PATH` environment variable.
|
||||
- Close/Reopen current terminals to pick up the new `PATH` variable.
|
||||
If your system is reporting that the `wails3` command is missing, check the
|
||||
following:
|
||||
|
||||
- Make sure you have followed the Go installation guide correctly.
|
||||
- Check that the `go/bin` directory is in the `PATH` environment variable.
|
||||
- Close/Reopen current terminals to pick up the new `PATH` variable.
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
|
||||
Now that you have Wails installed, you can start exploring the alpha version.
|
||||
|
||||
The best place to start is the `examples` directory in the Wails repository. This contains a number of examples that you can run and play with.
|
||||
The best place to start is the `examples` directory in the Wails repository.
|
||||
This contains a number of examples that you can run and play with.
|
||||
|
||||
## Running an example
|
||||
|
||||
@@ -11,23 +12,28 @@ To run an example, you can simply use:
|
||||
```shell
|
||||
go run .
|
||||
```
|
||||
|
||||
in the example directory.
|
||||
|
||||
The status of the examples is on the [roadmap](/roadmap).
|
||||
|
||||
## Creating a new project
|
||||
|
||||
To create a new project, you can use the `wails3 init` command. This will create a new project in the current directory.
|
||||
To create a new project, you can use the `wails3 init` command. This will create
|
||||
a new project in the current directory.
|
||||
|
||||
Wails3 uses [Task](https://taskfile.dev) as its build system by default, although there is no reason why you can't
|
||||
use your own build system, or use `go build` directly. Wails has the task build system built in and can be run using `wails3 task`.
|
||||
Wails3 uses [Task](https://taskfile.dev) as its build system by default,
|
||||
although there is no reason why you can't use your own build system, or use
|
||||
`go build` directly. Wails has the task build system built in and can be run
|
||||
using `wails3 task`.
|
||||
|
||||
If you look through the `Taskfile.yaml` file, you will see that there are a number of tasks defined. The most important
|
||||
one is the `build` task. This is the task that is run when you use `wails3 build`.
|
||||
If you look through the `Taskfile.yaml` file, you will see that there are a
|
||||
number of tasks defined. The most important one is the `build` task. This is the
|
||||
task that is run when you use `wails3 build`.
|
||||
|
||||
The task file is unlikely to be complete and is subject to change over time.
|
||||
|
||||
## Building a project
|
||||
|
||||
To build a project, you can use the `wails3 build` command. This is a shortcut for `wails3 task build`.
|
||||
|
||||
|
||||
|
||||
To build a project, you can use the `wails3 build` command. This is a shortcut
|
||||
for `wails3 task build`.
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
# Roadmap
|
||||
|
||||
The roadmap is a living document and is subject to change. If you have any suggestions, please open an issue.
|
||||
Each milestone will have a set of goals that we are aiming to achieve. These are subject to change.
|
||||
|
||||
## Alpha milestones
|
||||
|
||||
### Alpha 1
|
||||
|
||||
#### Goals
|
||||
|
||||
Alpha 1 is the initial release. It is intended to get feedback on the new API and to get people experimenting with it.
|
||||
The main goal is to get most of the examples working on all platforms.
|
||||
|
||||
#### Status
|
||||
|
||||
- W - Working
|
||||
- P - Partially working
|
||||
- N - Not working
|
||||
|
||||
| Example | Mac | Windows | Linux |
|
||||
|---------------|-----|---------|-------|
|
||||
| binding | W | W | |
|
||||
| build | W | W | |
|
||||
| clipboard | W | W | |
|
||||
| context menus | W | W | |
|
||||
| dialogs | P | W | |
|
||||
| drag-n-drop | W | N | |
|
||||
| events | W | W | |
|
||||
| frameless | W | W | |
|
||||
| keybindings | W | W | |
|
||||
| plain | W | W | |
|
||||
| screen | W | W | |
|
||||
| systray | W | W | |
|
||||
| video | | W | |
|
||||
| window | P | W | |
|
||||
| wml | W | W | |
|
||||
|
||||
- Mac Dialogs work, however the file dialogs issue a warning that needs to be fixed.
|
||||
|
||||
#### TODO:
|
||||
|
||||
- [ ] Fix `+[CATransaction synchronize] called within transaction` warnings on Mac
|
||||
- [ ] When hiding window, application terminates
|
||||
|
||||
### Alpha 2
|
||||
|
||||
- [ ] Most examples working on Linux
|
||||
- [ ] Project creation via `wails init`
|
||||
|
||||
@@ -0,0 +1,337 @@
|
||||
# What's new in v3?
|
||||
|
||||
!!! note
|
||||
The features that will be included in the v3 release may change from this list.
|
||||
|
||||
## Multiple Windows
|
||||
|
||||
It's now possible to create multiple windows and configure each one
|
||||
independently.
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"log"
|
||||
|
||||
"github.com/wailsapp/wails/v3/pkg/application"
|
||||
)
|
||||
|
||||
//go:embed assets/*
|
||||
var assets embed.FS
|
||||
|
||||
func main() {
|
||||
|
||||
app := application.New(application.Options{
|
||||
Name: "Multi Window Demo",
|
||||
Assets: application.AssetOptions{
|
||||
FS: assets,
|
||||
},
|
||||
})
|
||||
|
||||
window1 := app.NewWebviewWindowWithOptions(application.WebviewWindowOptions{
|
||||
Title: "Window 1",
|
||||
})
|
||||
|
||||
window2 := app.NewWebviewWindowWithOptions(application.WebviewWindowOptions{
|
||||
Title: "Window 2",
|
||||
})
|
||||
|
||||
// load the embedded html from the embed.FS
|
||||
window1.SetURL("/")
|
||||
window1.Center()
|
||||
|
||||
// Load an external URL
|
||||
window2.SetURL("https://wails.app")
|
||||
|
||||
err := app.Run()
|
||||
|
||||
if err != nil {
|
||||
log.Fatal(err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
## Systrays
|
||||
|
||||
Systrays allow you to add an icon in the system tray area of your desktop and
|
||||
have the following features:
|
||||
|
||||
- Attach window (the window will be centered to the systray icon)
|
||||
- Full menu support
|
||||
- Light/Dark mode icons
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"log"
|
||||
"runtime"
|
||||
|
||||
"github.com/wailsapp/wails/v3/pkg/application"
|
||||
"github.com/wailsapp/wails/v3/pkg/icons"
|
||||
)
|
||||
|
||||
func main() {
|
||||
app := application.New(application.Options{
|
||||
Name: "Systray Demo",
|
||||
Mac: application.MacOptions{
|
||||
ActivationPolicy: application.ActivationPolicyAccessory,
|
||||
},
|
||||
})
|
||||
|
||||
window := app.NewWebviewWindowWithOptions(application.WebviewWindowOptions{
|
||||
Width: 500,
|
||||
Height: 800,
|
||||
Frameless: true,
|
||||
AlwaysOnTop: true,
|
||||
Hidden: true,
|
||||
Windows: application.WindowsWindow{
|
||||
HiddenOnTaskbar: true,
|
||||
},
|
||||
})
|
||||
|
||||
systemTray := app.NewSystemTray()
|
||||
|
||||
// Support for template icons on macOS
|
||||
if runtime.GOOS == "darwin" {
|
||||
systemTray.SetTemplateIcon(icons.SystrayMacTemplate)
|
||||
} else {
|
||||
// Support for light/dark mode icons
|
||||
systemTray.SetDarkModeIcon(icons.SystrayDark)
|
||||
systemTray.SetIcon(icons.SystrayLight)
|
||||
}
|
||||
|
||||
// Support for menu
|
||||
myMenu := app.NewMenu()
|
||||
myMenu.Add("Hello World!").OnClick(func(_ *application.Context) {
|
||||
println("Hello World!")
|
||||
})
|
||||
systemTray.SetMenu(myMenu)
|
||||
|
||||
// This will center the window to the systray icon with a 5px offset
|
||||
// It will automatically be shown when the systray icon is clicked
|
||||
// and hidden when the window loses focus
|
||||
systemTray.AttachWindow(window).WindowOffset(5)
|
||||
|
||||
err := app.Run()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
## Plugins
|
||||
|
||||
Plugins allow you to extend the functionality of the Wails system. Not only can
|
||||
plugin methods be used in Go, but also called from Javascript. Included plugins:
|
||||
|
||||
- kvstore - A key/value store
|
||||
- browser - open links in a browser
|
||||
- log - custom logger
|
||||
- oauth - handles oauth authentication and supports 60 providers
|
||||
- single_instance - only allow one copy of your app to be run
|
||||
- sqlite - add a sqlite db to your app. Uses the modernc pure go library
|
||||
- start_at_login - Register/Unregister your application to start at login
|
||||
|
||||
## Improved bindings generation
|
||||
|
||||
v3 uses a new static analyser to generate bindings. This makes it extremely fast
|
||||
and maintains comments and parameter names in your bindings. By default,
|
||||
bindings are generated with calls using IDs instead of strings. This provides a
|
||||
performance boost and allows for using obfuscation tools such as
|
||||
[garble](https://github.com/burrowers/garble).
|
||||
|
||||
Bindings are generated by simply running `wails3 generate bindings` in the
|
||||
project directory.
|
||||
|
||||
```js
|
||||
// @ts-check
|
||||
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Ă‚ MODIWL
|
||||
// This file is automatically generated. DO NOT EDIT
|
||||
|
||||
import { main } from "./models";
|
||||
|
||||
window.go = window.go || {};
|
||||
window.go.main = {
|
||||
GreetService: {
|
||||
/**
|
||||
* GreetService.Greet
|
||||
* Greet greets a person
|
||||
* @param name {string}
|
||||
* @returns {Promise<string>}
|
||||
**/
|
||||
Greet: function (name) {
|
||||
wails.CallByID(1411160069, ...Array.prototype.slice.call(arguments, 0));
|
||||
},
|
||||
|
||||
/**
|
||||
* GreetService.GreetPerson
|
||||
* GreetPerson greets a person
|
||||
* @param person {main.Person}
|
||||
* @returns {Promise<string>}
|
||||
**/
|
||||
GreetPerson: function (person) {
|
||||
wails.CallByID(4021313248, ...Array.prototype.slice.call(arguments, 0));
|
||||
},
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
## Improved build system
|
||||
|
||||
In v2, the build system was completely opaque and hard to customise. In v3, it's
|
||||
possible to build everything using standard Go tooling.
|
||||
|
||||
All the heavy lifting that the v2 build system did, such as icon generation,
|
||||
have been added as tool commands in the CLI. We have incorporated
|
||||
[Taskfile](https://taskfile.dev) into the CLI to orchestrate these calls to
|
||||
bring the same developer experience as v2. However, this approach brings the
|
||||
ultimate balance of flexibility and ease of use as you can now customise the
|
||||
build process to your needs.
|
||||
|
||||
You can even use make if that's your thing!
|
||||
|
||||
```yaml title="Snippet from Taskfile.yml"
|
||||
build:darwin:
|
||||
summary: Builds the application
|
||||
platforms:
|
||||
- darwin
|
||||
cmds:
|
||||
- task: pre-build
|
||||
- task: build-frontend
|
||||
- go build -gcflags=all="-N -l" -o bin/{{.APP_NAME}}
|
||||
- task: post-build
|
||||
env:
|
||||
CGO_CFLAGS: "-mmacosx-version-min=10.13"
|
||||
CGO_LDFLAGS: "-mmacosx-version-min=10.13"
|
||||
MACOSX_DEPLOYMENT_TARGET: "10.13"
|
||||
```
|
||||
|
||||
## Improved events
|
||||
|
||||
Events are now emitted for a lot of the runtime operations, allowing you to hook
|
||||
into application/system events. Cross-platform (common) events are also emitted
|
||||
where there are common platform events, allowing you to write the same event
|
||||
handling methods cross platform.
|
||||
|
||||
Event hooks can also be registered. These are like the `On` method but are
|
||||
synchronous and allow you to cancel the event. An example of this would be to
|
||||
show a confirmation dialog before closing a window.
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"log"
|
||||
"time"
|
||||
|
||||
"github.com/wailsapp/wails/v3/pkg/application"
|
||||
"github.com/wailsapp/wails/v3/pkg/events"
|
||||
)
|
||||
|
||||
//go:embed assets
|
||||
var assets embed.FS
|
||||
|
||||
func main() {
|
||||
|
||||
app := application.New(application.Options{
|
||||
Name: "Events Demo",
|
||||
Description: "A demo of the Events API",
|
||||
Assets: application.AssetOptions{
|
||||
FS: assets,
|
||||
},
|
||||
Mac: application.MacOptions{
|
||||
ApplicationShouldTerminateAfterLastWindowClosed: true,
|
||||
},
|
||||
})
|
||||
|
||||
// Custom event handling
|
||||
app.Events.On("myevent", func(e *application.WailsEvent) {
|
||||
log.Printf("[Go] WailsEvent received: %+v\n", e)
|
||||
})
|
||||
|
||||
// OS specific application events
|
||||
app.On(events.Mac.ApplicationDidFinishLaunching, func(event *application.Event) {
|
||||
println("events.Mac.ApplicationDidFinishLaunching fired!")
|
||||
})
|
||||
|
||||
// Platform agnostic events
|
||||
app.On(events.Common.ApplicationStarted, func(event *application.Event) {
|
||||
println("events.Common.ApplicationStarted fired!")
|
||||
})
|
||||
|
||||
win1 := app.NewWebviewWindowWithOptions(application.WebviewWindowOptions{
|
||||
Title: "Takes 3 attempts to close me!",
|
||||
})
|
||||
|
||||
var countdown = 3
|
||||
|
||||
// Register a hook to cancel the window closing
|
||||
win1.RegisterHook(events.Common.WindowClosing, func(e *application.WindowEvent) {
|
||||
countdown--
|
||||
if countdown == 0 {
|
||||
println("Closing!")
|
||||
return
|
||||
}
|
||||
println("Nope! Not closing!")
|
||||
e.Cancel()
|
||||
})
|
||||
|
||||
win1.On(events.Common.WindowFocus, func(e *application.WindowEvent) {
|
||||
println("[Event] Window focus!")
|
||||
})
|
||||
|
||||
err := app.Run()
|
||||
|
||||
if err != nil {
|
||||
log.Fatal(err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
## Wails Markup Language (wml)
|
||||
|
||||
An experimental feature to call runtime methods using plain html, similar to
|
||||
[htmx](https://htmx.org).
|
||||
|
||||
```html
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>Wails ML Demo</title>
|
||||
</head>
|
||||
<body style="margin-top:50px; color: white; background-color: #191919">
|
||||
<h2>Wails ML Demo</h2>
|
||||
<p>This application contains no Javascript!</p>
|
||||
<button wml-event="button-pressed">Press me!</button>
|
||||
<button wml-event="delete-things" wml-confirm="Are you sure?">
|
||||
Delete all the things!
|
||||
</button>
|
||||
<button wml-window="Close" wml-confirm="Are you sure?">
|
||||
Close the Window?
|
||||
</button>
|
||||
<button wml-window="Center">Center</button>
|
||||
<button wml-window="Minimise">Minimise</button>
|
||||
<button wml-window="Maximise">Maximise</button>
|
||||
<button wml-window="UnMaximise">UnMaximise</button>
|
||||
<button wml-window="Fullscreen">Fullscreen</button>
|
||||
<button wml-window="UnFullscreen">UnFullscreen</button>
|
||||
<button wml-window="Restore">Restore</button>
|
||||
<div
|
||||
style="width: 200px; height: 200px; border: 2px solid white;"
|
||||
wml-event="hover"
|
||||
wml-trigger="mouseover"
|
||||
>
|
||||
Hover over me
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
```
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user