Compare commits

...

9 Commits

Author SHA1 Message Date
Lea Anthony 37b395c308 [v3] Add Naive build command 2023-01-22 20:40:35 +11:00
Lea Anthony 428584d583 [v3] Add TODO 2023-01-22 16:52:26 +11:00
Lea Anthony ee1978aa42 [v3] Initial template support (likely to change) 2023-01-22 15:39:57 +11:00
Sebastian Bauer 895d6d4b80 Size() calculates DPIs back to default space. (#2325) 2023-01-22 15:25:26 +11:00
github-actions[bot] a5ddce2c7c chore: update sponsors.svg (#2317)
Co-authored-by: leaanthony <leaanthony@users.noreply.github.com>
2023-01-22 15:25:04 +11:00
Richard Guay e4789750c8 Updating and Adding (#2324)
* Adding Tutorial link

* Fixed EmailIt, Modal File Manager, and ScriptBar descriptions and added BulletinBoard

Co-authored-by: Lea Anthony <lea.anthony@gmail.com>
2023-01-22 07:28:51 +11:00
Brian Dwyer f8c673874b Fix memory leak on Darwin when toggling system tray icon (#2322) 2023-01-21 15:46:06 +11:00
Lea Anthony 5ef32760f0 Update task 2023-01-18 22:08:25 +11:00
Lea Anthony 81645190f0 merge exp branch 2023-01-18 21:42:49 +11:00
442 changed files with 24169 additions and 23 deletions
+3
View File
@@ -31,3 +31,6 @@ v2/test/kitchensink/frontend/package.json.md5
v2/cmd/wails/internal/commands/initialise/templates/testtemplates/
.env
/website/static/img/.cache.json
/v3/.task
/v3/examples/build/bin/testapp
+2 -1
View File
@@ -4,12 +4,13 @@ import (
"context"
"embed"
"fmt"
"time"
"github.com/wailsapp/wails/v2/pkg/application"
"github.com/wailsapp/wails/v2/pkg/menu"
"github.com/wailsapp/wails/v2/pkg/options"
"github.com/wailsapp/wails/v2/pkg/options/windows"
"github.com/wailsapp/wails/v2/pkg/runtime"
"time"
)
//go:embed all:frontend/dist
@@ -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)
}
+8
View File
@@ -0,0 +1,8 @@
examples/kitchensink/kitchensink
cmd/wails/wails
/examples/systray/systray
/examples/window/window
/examples/dialogs/dialogs
/examples/menu/menu
/examples/clipboard/clipboard
/examples/plain/plain
+3
View File
@@ -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
View File
@@ -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`
+220
View File
@@ -0,0 +1,220 @@
# https://taskfile.dev
version: '3'
tasks:
build-runtime-debug:
dir: internal/runtime
internal: true
cmds:
- 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}}
build-runtime-debug-windows:
cmds:
- task: build-runtime-debug
vars:
WINDOWS: true
DARWIN: false
LINUX: false
PLATFORM: windows
build-runtime-debug-linux:
cmds:
- task: build-runtime-debug
vars:
WINDOWS: false
DARWIN: false
LINUX: true
PLATFORM: linux
build-runtime-debug-darwin:
cmds:
- task: build-runtime-debug
vars:
WINDOWS: false
DARWIN: true
LINUX: false
PLATFORM: darwin
build-runtime-production:
dir: internal/runtime
internal: true
cmds:
- 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}}
build-runtime-production-windows:
cmds:
- task: build-runtime-production
vars:
WINDOWS: true
DARWIN: false
LINUX: false
PLATFORM: windows
build-runtime-production-linux:
cmds:
- task: build-runtime-production
vars:
WINDOWS: false
DARWIN: false
LINUX: true
PLATFORM: linux
build-runtime-production-darwin:
cmds:
- task: build-runtime-production
vars:
WINDOWS: false
DARWIN: true
LINUX: false
PLATFORM: darwin
install-runtime-dev-deps:
dir: internal/runtime/dev
internal: true
sources:
- package.json
cmds:
- npm install
install-runtime-deps:
dir: internal/runtime
internal: true
sources:
- package.json
cmds:
- npm install
build-runtime-dev:
dir: internal/runtime/dev
deps:
- install-runtime-dev-deps
sources:
- ./*.js
generates:
- ../ipc_websocket.js
cmds:
- node build.js
build-runtime-ipc:
dir: internal/runtime
deps:
- install-runtime-dev-deps
sources:
- ./desktop/ipc.js
generates:
- ipc.js
cmds:
- npx esbuild desktop/ipc.js --bundle --minify --outfile=ipc.js
test-runtime:
dir: internal/runtime
cmds:
- npx vitest
build-runtime-all:
dir: internal/runtime
deps:
- build-runtime-production-darwin
- build-runtime-production-windows
- build-runtime-production-linux
- build-runtime-debug-darwin
- build-runtime-debug-windows
- build-runtime-debug-linux
- build-runtime-dev
- build-runtime-ipc
cmds:
- task: test-runtime
build-runtime:
dir: internal/runtime
deps:
- 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"
+87
View File
@@ -0,0 +1,87 @@
# The Wails CLI
The Wails CLI is a command line tool that allows you to create, build and run Wails applications.
There are a number of commands related to tooling, such as icon generation and asset bundling.
## Commands
### run
The run command is for running tasks defined in `Taskfile.yml`.
| Flag | Type | Description | Default |
|--------------------|--------|------------------------------------------------------|-----------------------|
| `-t` | string | The name of the task to run | |
### generate
The `generate` command is used to generate resources and assets for your Wails project.
It can be used to generate many things including:
- application icons,
- resource files for Windows applications
- Info.plist files for macOS deployments
#### icon
The `icon` command generates icons for your project.
| Flag | Type | Description | Default |
|--------------------|--------|------------------------------------------------------|-----------------------|
| `-example` | bool | Generates example icon file (appicon.png) | |
| `-input` | string | The input image file | |
| `-sizes` | string | The sizes to generate in .ico file (comma separated) | "256,128,64,48,32,16" |
| `-windowsFilename` | string | The output filename for the Windows icon | icons.ico |
| `-macFilename` | string | The output filename for the Mac icon bundle | icons.icns |
```bash
wails generate icon -input myicon.png -sizes "32,64,128" -windowsFilename myicon.ico -macFilename myicon.icns
```
This will generate icons for mac and windows and save them in the current directory as `myicon.ico`
and `myicons.icns`.
#### syso
The `syso` command generates a Windows resource file (aka `.syso`).
```bash
wails generate syso <options>
```
| Flag | Type | Description | Default |
|-------------|--------|--------------------------------------------|------------------|
| `-example` | bool | Generates example manifest & info files | |
| `-manifest` | string | The manifest file | |
| `-info` | string | The info.json file | |
| `-icon` | string | The icon file | |
| `-out` | string | The output filename for the syso file | `wails.exe.syso` |
| `-arch` | string | The target architecture (amd64,arm64,386) | `runtime.GOOS` |
If `-example` is provided, the command will generate example manifest and info files
in the current directory and exit.
If `-manifest` is provided, the command will use the provided manifest file to generate
the syso file.
If `-info` is provided, the command will use the provided info.json file to set the version
information in the syso file.
NOTE: We use [winres](https://github.com/tc-hib/winres) to generate the syso file. Please
refer to the winres documentation for more information.
NOTE: Whilst the tool will work for 32-bit Windows, it is not supported. Please use 64-bit.
#### defaults
```bash
wails generate defaults
```
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.
+29
View File
@@ -0,0 +1,29 @@
package main
import (
"os"
"github.com/pterm/pterm"
"github.com/leaanthony/clir"
"github.com/wailsapp/wails/v3/internal/commands"
)
func main() {
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)
task.NewSubCommandFunction("list", "List tasks", commands.ListTasks)
generate := app.NewSubCommand("generate", "Generation tools")
generate.NewSubCommandFunction("defaults", "Generate default build assets", commands.Defaults)
generate.NewSubCommandFunction("icons", "Generate icons", commands.GenerateIcons)
generate.NewSubCommandFunction("syso", "Generate Windows .syso file", commands.GenerateSyso)
generate.NewSubCommandFunction("bindings", "Generate bindings + models", commands.GenerateBindings)
err := app.Run()
if err != nil {
pterm.Error.Println(err)
os.Exit(1)
}
}
+31
View File
@@ -0,0 +1,31 @@
package main
import (
_ "embed"
"log"
"github.com/wailsapp/wails/v3/examples/binding/services"
"github.com/wailsapp/wails/v3/pkg/application"
"github.com/wailsapp/wails/v3/pkg/options"
)
type localStruct struct{}
func main() {
app := application.New(options.Application{
Bind: []interface{}{
&localStruct{},
&services.GreetService{},
},
})
app.NewWebviewWindow()
err := app.Run()
if err != nil {
log.Fatal(err)
}
}
+5
View File
@@ -0,0 +1,5 @@
package models
type Person struct {
Name string
}
@@ -0,0 +1,23 @@
package services
import (
"github.com/wailsapp/wails/v3/examples/binding/models"
)
type GreetService struct {
SomeVariable int
lowercase string
Parent *models.Person
}
func (*GreetService) Greet(name string) string {
return "Hello " + name
}
func (g *GreetService) GetPerson() *models.Person {
return g.Parent
}
func (g *GreetService) SetPerson(person *models.Person) {
g.Parent = person
}
+15
View File
@@ -0,0 +1,15 @@
# Build
Wails has adopted [Taskfile](https://taskfile.dev) as its build tool. This is optional
and any build tool can be used. However, Taskfile is a great tool, and we recommend it.
The Wails CLI has built-in integration with Taskfile so the standalone version is not a
requirement.
## Building
To build the example, run:
```bash
wails run -t build
```
+41
View File
@@ -0,0 +1,41 @@
version: '3'
tasks:
pre-build:
summary: Pre-build hooks
post-build:
summary: Post-build hooks
build:
summary: Builds the application
cmds:
- task: pre-build
- go build -gcflags=all="-N -l" -o bin/testapp main.go
- task: post-build
env:
CGO_CFLAGS: "-mmacosx-version-min=10.13"
CGO_LDFLAGS: "-mmacosx-version-min=10.13"
generate-icons:
summary: Generates Windows `.ico` and Mac `.icns` files from an image
cmds:
# Generates both .ico and .icns files
- wails generate icons -input appicon.png
build-prod:
summary: Creates a production build of the application
cmds:
- go build -tags production -ldflags="-w -s" -o bin/testapp
package-darwin:
summary: Packages a production build of the application into a `.app` bundle
deps:
- build-prod
- generate-icons
cmds:
- mkdir -p buildtest.app/Contents/{MacOS,Resources}
- cp build/icons.icns buildtest.app/Contents/Resources
- cp bin/testapp buildtest.app/Contents/MacOS
- cp build/Info.plist buildtest.app/Contents
+35
View File
@@ -0,0 +1,35 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleName</key>
<string>My App</string>
<key>CFBundleExecutable</key>
<string>app</string>
<key>CFBundleIdentifier</key>
<string>com.wails.app</string>
<key>CFBundleVersion</key>
<string>v1.0.0</string>
<key>CFBundleGetInfoString</key>
<string>The ultimate thing</string>
<key>CFBundleShortVersionString</key>
<string>v1</string>
<key>CFBundleIconFile</key>
<string>icons</string>
<key>LSMinimumSystemVersion</key>
<string>10.13.0</string>
<key>NSHighResolutionCapable</key>
<string>true</string>
<key>NSHumanReadableCopyright</key>
<string>(c) Me</string>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsLocalNetworking</key>
<true/>
</dict>
</dict>
</plist>
</dict>
</plist>
+27
View File
@@ -0,0 +1,27 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleName</key>
<string>My App</string>
<key>CFBundleExecutable</key>
<string>app</string>
<key>CFBundleIdentifier</key>
<string>com.wails.app</string>
<key>CFBundleVersion</key>
<string>v1.0.0</string>
<key>CFBundleGetInfoString</key>
<string>The ultimate thing</string>
<key>CFBundleShortVersionString</key>
<string>v1</string>
<key>CFBundleIconFile</key>
<string>icons</string>
<key>LSMinimumSystemVersion</key>
<string>10.13.0</string>
<key>NSHighResolutionCapable</key>
<string>true</string>
<key>NSHumanReadableCopyright</key>
<string>(c) Me</string>
</dict>
</plist>
Binary file not shown.

After

Width:  |  Height:  |  Size: 130 KiB

Binary file not shown.
Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Some files were not shown because too many files have changed in this diff Show More