Skip to content

Commit 8164519

Browse files
committed
merge exp branch
1 parent 18d0ed8 commit 8164519

File tree

138 files changed

+17055
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

138 files changed

+17055
-1
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,6 @@ v2/test/kitchensink/frontend/package.json.md5
3131
v2/cmd/wails/internal/commands/initialise/templates/testtemplates/
3232
.env
3333
/website/static/img/.cache.json
34+
35+
/v3/.task
36+
/v3/examples/build/bin/testapp

v2/examples/systray/main.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@ import (
44
"context"
55
"embed"
66
"fmt"
7+
"time"
8+
79
"github.com/wailsapp/wails/v2/pkg/application"
810
"github.com/wailsapp/wails/v2/pkg/menu"
911
"github.com/wailsapp/wails/v2/pkg/options"
1012
"github.com/wailsapp/wails/v2/pkg/options/windows"
1113
"github.com/wailsapp/wails/v2/pkg/runtime"
12-
"time"
1314
)
1415

1516
//go:embed all:frontend/dist

v3/.gitignore

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
examples/kitchensink/kitchensink
2+
cmd/wails/wails
3+
/examples/systray/systray
4+
/examples/window/window
5+
/examples/dialogs/dialogs
6+
/examples/menu/menu
7+
/examples/clipboard/clipboard
8+
/examples/plain/plain

v3/Taskfile.yaml

+136
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
# https://taskfile.dev
2+
3+
version: '3'
4+
5+
tasks:
6+
7+
build-runtime-debug:
8+
dir: internal/runtime
9+
internal: true
10+
cmds:
11+
- npx esbuild desktop/main.js --bundle --sourcemap=inline --outfile=runtime_debug_desktop_{{.PLATFORM}}.js --define:DEBUG=true --define:WINDOWS={{.WINDOWS}} --define:DARWIN={{.DARWIN}} --define:LINUX={{.LINUX}} --define:PLATFORM={{.PLATFORM}}
12+
13+
build-runtime-debug-windows:
14+
cmds:
15+
- task: build-runtime-debug
16+
vars:
17+
WINDOWS: true
18+
DARWIN: false
19+
LINUX: false
20+
PLATFORM: windows
21+
22+
build-runtime-debug-linux:
23+
cmds:
24+
- task: build-runtime-debug
25+
vars:
26+
WINDOWS: false
27+
DARWIN: false
28+
LINUX: true
29+
PLATFORM: linux
30+
31+
build-runtime-debug-darwin:
32+
cmds:
33+
- task: build-runtime-debug
34+
vars:
35+
WINDOWS: false
36+
DARWIN: true
37+
LINUX: false
38+
PLATFORM: darwin
39+
40+
build-runtime-production:
41+
dir: internal/runtime
42+
internal: true
43+
cmds:
44+
- npx esbuild desktop/main.js --bundle --minify --outfile=runtime_production_desktop_{{.PLATFORM}}.js --define:DEBUG=true --define:WINDOWS={{.WINDOWS}} --define:DARWIN={{.DARWIN}} --define:LINUX={{.LINUX}} --define:PLATFORM={{.PLATFORM}}
45+
46+
build-runtime-production-windows:
47+
cmds:
48+
- task: build-runtime-production
49+
vars:
50+
WINDOWS: true
51+
DARWIN: false
52+
LINUX: false
53+
PLATFORM: windows
54+
55+
build-runtime-production-linux:
56+
cmds:
57+
- task: build-runtime-production
58+
vars:
59+
WINDOWS: false
60+
DARWIN: false
61+
LINUX: true
62+
PLATFORM: linux
63+
64+
build-runtime-production-darwin:
65+
cmds:
66+
- task: build-runtime-production
67+
vars:
68+
WINDOWS: false
69+
DARWIN: true
70+
LINUX: false
71+
PLATFORM: darwin
72+
73+
install-runtime-dev-deps:
74+
dir: internal/runtime/dev
75+
internal: true
76+
sources:
77+
- package.json
78+
cmds:
79+
- npm install
80+
81+
82+
install-runtime-deps:
83+
dir: internal/runtime
84+
internal: true
85+
sources:
86+
- package.json
87+
cmds:
88+
- npm install
89+
90+
build-runtime-dev:
91+
dir: internal/runtime/dev
92+
deps:
93+
- install-runtime-dev-deps
94+
sources:
95+
- ./*.js
96+
generates:
97+
- ../ipc_websocket.js
98+
cmds:
99+
- node build.js
100+
101+
build-runtime-ipc:
102+
dir: internal/runtime
103+
deps:
104+
- install-runtime-dev-deps
105+
sources:
106+
- ./desktop/ipc.js
107+
generates:
108+
- ipc.js
109+
cmds:
110+
- npx esbuild desktop/ipc.js --bundle --minify --outfile=ipc.js
111+
112+
test-runtime:
113+
dir: internal/runtime
114+
cmds:
115+
- npx vitest
116+
117+
build-runtime-all:
118+
dir: internal/runtime
119+
deps:
120+
- build-runtime-production-darwin
121+
- build-runtime-production-windows
122+
- build-runtime-production-linux
123+
- build-runtime-debug-darwin
124+
- build-runtime-debug-windows
125+
- build-runtime-debug-linux
126+
- build-runtime-dev
127+
- build-runtime-ipc
128+
cmds:
129+
- task: test-runtime
130+
131+
build-runtime:
132+
dir: internal/runtime
133+
deps:
134+
- install-runtime-deps
135+
cmds:
136+
- task: build-runtime-all

v3/cmd/wails/README.md

+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# The Wails CLI
2+
3+
The Wails CLI is a command line tool that allows you to create, build and run Wails applications.
4+
There are a number of commands related to tooling, such as icon generation and asset bundling.
5+
6+
## Commands
7+
8+
### run
9+
10+
The run command is for running tasks defined in `Taskfile.yml`.
11+
12+
| Flag | Type | Description | Default |
13+
|--------------------|--------|------------------------------------------------------|-----------------------|
14+
| `-t` | string | The name of the task to run | |
15+
16+
### generate
17+
18+
The `generate` command is used to generate resources and assets for your Wails project.
19+
It can be used to generate many things including:
20+
- application icons,
21+
- resource files for Windows applications
22+
- Info.plist files for macOS deployments
23+
24+
#### icon
25+
26+
The `icon` command generates icons for your project.
27+
28+
| Flag | Type | Description | Default |
29+
|--------------------|--------|------------------------------------------------------|-----------------------|
30+
| `-example` | bool | Generates example icon file (appicon.png) | |
31+
| `-input` | string | The input image file | |
32+
| `-sizes` | string | The sizes to generate in .ico file (comma separated) | "256,128,64,48,32,16" |
33+
| `-windowsFilename` | string | The output filename for the Windows icon | icons.ico |
34+
| `-macFilename` | string | The output filename for the Mac icon bundle | icons.icns |
35+
36+
```bash
37+
wails generate icon -input myicon.png -sizes "32,64,128" -windowsFilename myicon.ico -macFilename myicon.icns
38+
```
39+
40+
This will generate icons for mac and windows and save them in the current directory as `myicon.ico`
41+
and `myicons.icns`.
42+
43+
#### syso
44+
45+
The `syso` command generates a Windows resource file (aka `.syso`).
46+
47+
```bash
48+
wails generate syso <options>
49+
```
50+
51+
| Flag | Type | Description | Default |
52+
|-------------|--------|--------------------------------------------|------------------|
53+
| `-example` | bool | Generates example manifest & info files | |
54+
| `-manifest` | string | The manifest file | |
55+
| `-info` | string | The info.json file | |
56+
| `-icon` | string | The icon file | |
57+
| `-out` | string | The output filename for the syso file | `wails.exe.syso` |
58+
| `-arch` | string | The target architecture (amd64,arm64,386) | `runtime.GOOS` |
59+
60+
If `-example` is provided, the command will generate example manifest and info files
61+
in the current directory and exit.
62+
63+
If `-manifest` is provided, the command will use the provided manifest file to generate
64+
the syso file.
65+
66+
If `-info` is provided, the command will use the provided info.json file to set the version
67+
information in the syso file.
68+
69+
NOTE: We use [winres](https://github.com/tc-hib/winres) to generate the syso file. Please
70+
refer to the winres documentation for more information.
71+
72+
NOTE: Whilst the tool will work for 32-bit Windows, it is not supported. Please use 64-bit.
73+
74+
#### defaults
75+
76+
```bash
77+
wails icon -input myicon.png -sizes "32,64,128" -windowsFilename myicon.ico -macFilename myicon.icns
78+
```
79+
This will generate all the default assets and resources in the current directory. I

v3/cmd/wails/main.go

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package main
2+
3+
import (
4+
"os"
5+
6+
"github.com/pterm/pterm"
7+
8+
"github.com/leaanthony/clir"
9+
"github.com/wailsapp/wails/v3/internal/commands"
10+
)
11+
12+
func main() {
13+
app := clir.NewCli("wails", "The Wails CLI", "v3")
14+
app.NewSubCommandFunction("init", "Initialise a new project", commands.Init)
15+
task := app.NewSubCommand("task", "Run and list tasks")
16+
task.NewSubCommandFunction("run", "Run a task", commands.RunTask)
17+
task.NewSubCommandFunction("list", "List tasks", commands.ListTasks)
18+
generate := app.NewSubCommand("generate", "Generation tools")
19+
generate.NewSubCommandFunction("defaults", "Generate default build assets", commands.Defaults)
20+
generate.NewSubCommandFunction("icons", "Generate icons", commands.GenerateIcons)
21+
generate.NewSubCommandFunction("syso", "Generate Windows .syso file", commands.GenerateSyso)
22+
generate.NewSubCommandFunction("bindings", "Generate bindings + models", commands.GenerateBindings)
23+
err := app.Run()
24+
if err != nil {
25+
pterm.Error.Println(err)
26+
os.Exit(1)
27+
}
28+
}

v3/examples/binding/main.go

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package main
2+
3+
import (
4+
_ "embed"
5+
"log"
6+
7+
"github.com/wailsapp/wails/v3/examples/binding/services"
8+
9+
"github.com/wailsapp/wails/v3/pkg/application"
10+
"github.com/wailsapp/wails/v3/pkg/options"
11+
)
12+
13+
type localStruct struct{}
14+
15+
func main() {
16+
app := application.New(options.Application{
17+
Bind: []interface{}{
18+
&localStruct{},
19+
&services.GreetService{},
20+
},
21+
})
22+
23+
app.NewWebviewWindow()
24+
25+
err := app.Run()
26+
27+
if err != nil {
28+
log.Fatal(err)
29+
}
30+
31+
}

v3/examples/binding/models/person.go

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package models
2+
3+
type Person struct {
4+
Name string
5+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package services
2+
3+
import (
4+
"github.com/wailsapp/wails/v3/examples/binding/models"
5+
)
6+
7+
type GreetService struct {
8+
SomeVariable int
9+
lowercase string
10+
Parent *models.Person
11+
}
12+
13+
func (*GreetService) Greet(name string) string {
14+
return "Hello " + name
15+
}
16+
17+
func (g *GreetService) GetPerson() *models.Person {
18+
return g.Parent
19+
}
20+
21+
func (g *GreetService) SetPerson(person *models.Person) {
22+
g.Parent = person
23+
}

v3/examples/build/README.md

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Build
2+
3+
Wails has adopted [Taskfile](https://taskfile.dev) as its build tool. This is optional
4+
and any build tool can be used. However, Taskfile is a great tool, and we recommend it.
5+
6+
The Wails CLI has built-in integration with Taskfile so the standalone version is not a
7+
requirement.
8+
9+
## Building
10+
11+
To build the example, run:
12+
13+
```bash
14+
wails run -t build
15+
```

v3/examples/build/Taskfile.yml

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
version: '3'
2+
3+
tasks:
4+
5+
pre-build:
6+
summary: Pre-build hooks
7+
8+
post-build:
9+
summary: Post-build hooks
10+
11+
build:
12+
summary: Builds the application
13+
cmds:
14+
- task: pre-build
15+
- go build -gcflags=all="-N -l" -o bin/testapp main.go
16+
- task: post-build
17+
env:
18+
CGO_CFLAGS: "-mmacosx-version-min=10.13"
19+
CGO_LDFLAGS: "-mmacosx-version-min=10.13"
20+
21+
generate-icons:
22+
summary: Generates Windows `.ico` and Mac `.icns` files from an image
23+
dir: build
24+
cmds:
25+
# Generates both .ico and .icns files
26+
- wails generate icon -input appicon.png
27+
28+
build-prod:
29+
summary: Creates a production build of the application
30+
cmds:
31+
- go build -tags production -ldflags="-w -s" -o bin/testapp
32+
33+
package-darwin:
34+
summary: Packages a production build of the application into a `.app` bundle
35+
deps:
36+
- build-prod
37+
- generate-icons
38+
cmds:
39+
- mkdir -p buildtest.app/Contents/{MacOS,Resources}
40+
- cp build/icons.icns buildtest.app/Contents/Resources
41+
- cp bin/testapp buildtest.app/Contents/MacOS
42+
- cp build/Info.plist buildtest.app/Contents

0 commit comments

Comments
 (0)