Compare commits

...

5 Commits

Author SHA1 Message Date
Lea Anthony db2745e453 Rename main.tmpl.go to main.go.tmpl to remove IDE warnings 2023-01-22 16:29:14 +11:00
Lea Anthony 56dba5c3a4 Initial template support (likely to change) 2023-01-22 15:29:53 +11:00
Lea Anthony 3ccf027624 Initial template support (likely to change) 2023-01-22 15:28:45 +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
430 changed files with 24079 additions and 1 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
+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!
+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.
+28
View File
@@ -0,0 +1,28 @@
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("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

+15
View File
@@ -0,0 +1,15 @@
{
"fixed": {
"file_version": "v1.0.0"
},
"info": {
"0000": {
"ProductVersion": "v1.0.0",
"CompanyName": "My Company Name",
"FileDescription": "A thing that does a thing",
"LegalCopyright": "(c) 2023 My Company Name",
"ProductName": "My Product Name",
"Comments": "This is a comment"
}
}
}
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
<assemblyIdentity type="win32" name="com.wails.myproductname" version="v1.0.0.0" processorArchitecture="*"/>
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*"/>
</dependentAssembly>
</dependency>
<asmv3:application>
<asmv3:windowsSettings>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true/pm</dpiAware> <!-- fallback for Windows 7 and 8 -->
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">permonitorv2,permonitor</dpiAwareness> <!-- falls back to per-monitor if per-monitor v2 is not supported -->
</asmv3:windowsSettings>
</asmv3:application>
</assembly>
@@ -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>

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