mirror of
https://github.com/wavetermdev/wails.git
synced 2026-04-22 15:26:15 -07:00
Compare commits
109 Commits
v2.0.0-beta.36
...
exp
| Author | SHA1 | Date | |
|---|---|---|---|
| a11655c452 | |||
| 11cbfb68f1 | |||
| 7a63464997 | |||
| bf2d83d939 | |||
| 1cd31573a9 | |||
| 39cebffa87 | |||
| f4b4e4cdb8 | |||
| 73f5cc3b92 | |||
| c48ad9be67 | |||
| 4726b72708 | |||
| 4c312b155d | |||
| cd35536a79 | |||
| 91d6c23c71 | |||
| 59f84b8905 | |||
| a1a06a6198 | |||
| 5292721517 | |||
| 41d1bf3d10 | |||
| 3e42d2da05 | |||
| 7141c972fd | |||
| 7cc3652a39 | |||
| 95082336cd | |||
| b2cec41fbf | |||
| 66f79c2e51 | |||
| f8e6fa4bf3 | |||
| d9888ce6af | |||
| 0531645377 | |||
| c22f59adb9 | |||
| 2065600096 | |||
| c61ce1e2de | |||
| 16581ceff9 | |||
| beb909fc0f | |||
| 5cddf8864e | |||
| e504d1124a | |||
| 91afa396ba | |||
| 08eee061ab | |||
| 072929689c | |||
| 72d019cb48 | |||
| 91ed594049 | |||
| 4493a05fb9 | |||
| f8eac34212 | |||
| 1687906376 | |||
| 381909696b | |||
| c477100374 | |||
| cb169611b1 | |||
| 4dd1be5252 | |||
| a7f1ea21ef | |||
| e4f2bfe699 | |||
| 9bd765d2c8 | |||
| d77c556c4e | |||
| 9a01c757bd | |||
| 41051e8848 | |||
| 884773a218 | |||
| 1e54eb2eaf | |||
| cb4ba5bca6 | |||
| 664f6a952c | |||
| fe341741b5 | |||
| cd162918d4 | |||
| 6a07cbd505 | |||
| 614f50d5d3 | |||
| f292e221f1 | |||
| 2a0673f99f | |||
| 794a8ce19f | |||
| f6425a64a6 | |||
| b49dce8676 | |||
| 6a88568f0a | |||
| a10a9e5b36 | |||
| e7f9e2f267 | |||
| 316a24f6da | |||
| c874e30339 | |||
| 043d83e39e | |||
| 7e64038265 | |||
| d4ecaad0e1 | |||
| 953bc09343 | |||
| 935f6871ab | |||
| 0d793124fd | |||
| c97e1c50af | |||
| 319d59296e | |||
| 35b1dfdd2a | |||
| 368733b7cc | |||
| e705c20de9 | |||
| ae25b38f9e | |||
| ec2202765c | |||
| e0e55e6e76 | |||
| 4d5f31ab84 | |||
| b84fd76e86 | |||
| 55115742c1 | |||
| f2f8ed2e99 | |||
| d59bec171e | |||
| bff0ece017 | |||
| 7c0d1019f2 | |||
| ee5ca1a84a | |||
| a3de4577dd | |||
| 4986f9cea5 | |||
| 0f2fc1ab7a | |||
| 5f612301f9 | |||
| 84b6273baf | |||
| 1947a9a17a | |||
| 9c8a3a62da | |||
| 6224d3aa82 | |||
| 2d66d2146a | |||
| e5cc18cfc5 | |||
| 13fb5352d8 | |||
| 531d7cfb62 | |||
| 58b6e4c335 | |||
| ae0933c82a | |||
| c1d4aeb3cd | |||
| 1830c64c79 | |||
| ee50170374 | |||
| 3f82ceabba |
@@ -11,7 +11,9 @@ body:
|
||||
Before submitting this issue, please do the following:
|
||||
- Do a web search for your error. This usually leads to a much better understanding of the issue.
|
||||
- Prove that the error is indeed a Wails bug and not an application bug, with a specific set of steps to reproduce.
|
||||
- Search both the issue tracker (even closed issues) and discussion forums.
|
||||
- Search the issue tracker using [this link](https://github.com/wailsapp/wails/issues?q=is%3Aissue+).
|
||||
- Search the [discussion forums](https://github.com/wailsapp/wails/discussions?discussions_q=type+your+issue+here).
|
||||
- Read the [Troubleshooting Guide](https://wails.io/docs/next/guides/troubleshooting).
|
||||
- Try to fix it yourself. Keep a list of things you have done to fix the problem.
|
||||
|
||||
If after doing all the above, the problem remains, please continue with this ticket providing *all* the information requested.
|
||||
|
||||
@@ -7,6 +7,7 @@ body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
Before opening a feature request, please check the [Roadmap](https://github.com/wailsapp/wails/discussions/1484) to see if it has already been requested.
|
||||
***Please note: No new feature requests are being accepted for Wails v1***
|
||||
|
||||
- type: textarea
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ exemptLabels:
|
||||
- security
|
||||
- onhold
|
||||
- inprogress
|
||||
- "Selected for development"
|
||||
- "Selected For Development"
|
||||
# Label to use when marking an issue as stale
|
||||
staleLabel: wontfix
|
||||
# Comment to post when marking an issue as stale. Set to `false` to disable
|
||||
|
||||
@@ -32,3 +32,4 @@ v2/test/kitchensink/frontend/package.json.md5
|
||||
!v2/internal/ffenestri/windows/x64/WebView2Loader.dll
|
||||
.idea/
|
||||
v2/cmd/wails/internal/commands/initialise/templates/testtemplates/
|
||||
v2/internal/frontend/desktop/darwin/test.xcodeproj
|
||||
@@ -106,8 +106,8 @@ This project is supported by these kind people / companies:
|
||||
<a href="https://github.com/sponsors/leaanthony" style="width:100px;">
|
||||
<img src="/img/silver%20sponsor.png" width="100"/>
|
||||
</a>
|
||||
<a href="https://github.com/letheanVPN" style="width:100px;">
|
||||
<img src="https://github.com/letheanVPN.png?size=100" width="100"/>
|
||||
<a href="https://github.com/selvindev" style="width:100px;">
|
||||
<img src="https://github.com/selvindev.png?size=100" width="100"/>
|
||||
</a>
|
||||
<br/>
|
||||
<br/>
|
||||
@@ -158,9 +158,6 @@ This project is supported by these kind people / companies:
|
||||
<a href="https://github.com/bglw" style="width:65px">
|
||||
<img src="https://github.com/bglw.png?size=65" width="65"/>
|
||||
</a>
|
||||
<a href="https://github.com/jugglingjsons" style="width:50px">
|
||||
<img src="https://github.com/jugglingjsons.png?size=50" width="50"/>
|
||||
</a>
|
||||
<a href="https://github.com/marcus-crane" style="width:65px">
|
||||
<img src="https://github.com/marcus-crane.png?size=65" width="65"/>
|
||||
</a>
|
||||
@@ -194,12 +191,23 @@ This project is supported by these kind people / companies:
|
||||
<a href="https://github.com/GargantuaX" style="width:45px">
|
||||
<img src="https://github.com/GargantuaX.png?size=45" width="45"/>
|
||||
</a>
|
||||
<a href="https://github.com/brodyover" style="width:45px">
|
||||
<img src="https://github.com/brodyover.png?size=45" width="45"/>
|
||||
<a href="https://github.com/CharlieGo88" style="width:55px">
|
||||
<img src="https://github.com/CharlieGo88.png?size=55" width="55"/>
|
||||
</a>
|
||||
<a href="https://github.com/Bironou" style="width:55px">
|
||||
<img src="https://github.com/Bironou.png?size=55" width="55"/>
|
||||
</a>
|
||||
<a href="https://github.com/Shackelford-Arden" style="width:55px">
|
||||
<img src="https://github.com/Shackelford-Arden.png?size=55" width="55"/>
|
||||
</a>
|
||||
|
||||
<span id="nav-6"></span>
|
||||
|
||||
## Roadmap
|
||||
|
||||
The project roadmap may be found [here](https://github.com/wailsapp/wails/discussions/1484). Please consult
|
||||
this before open up an enhancement request.
|
||||
|
||||
## Installation
|
||||
|
||||
The installation instructions are on the [official website](https://wails.io/docs/gettingstarted/installation).
|
||||
@@ -211,8 +219,8 @@ The installation instructions are on the [official website](https://wails.io/doc
|
||||
- Is this an alternative to Electron?
|
||||
|
||||
Depends on your requirements. It's designed to make it easy for Go programmers to make lightweight desktop
|
||||
applications or add a frontend to their existing applications. Whilst Wails does not currently offer hooks into native
|
||||
elements such as menus, this may change in the future.
|
||||
applications or add a frontend to their existing applications. Wails v2 does offer native elements such as menus
|
||||
and dialogs, so it is becoming a lightweight electron alternative.
|
||||
|
||||
- Who is this project aimed at?
|
||||
|
||||
|
||||
+10
-7
@@ -116,8 +116,8 @@ Wails v2 已针对所有 3 个平台发布了 Beta 版。如果您有兴趣尝
|
||||
<a href="https://github.com/sponsors/leaanthony" style="width:100px;">
|
||||
<img src="/img/silver%20sponsor.png" width="100"/>
|
||||
</a>
|
||||
<a href="https://github.com/letheanVPN" style="width:100px;">
|
||||
<img src="https://github.com/letheanVPN.png?size=100" width="100"/>
|
||||
<a href="https://github.com/selvindev" style="width:100px;">
|
||||
<img src="https://github.com/selvindev.png?size=100" width="100"/>
|
||||
</a>
|
||||
<br/>
|
||||
<br/>
|
||||
@@ -168,9 +168,6 @@ Wails v2 已针对所有 3 个平台发布了 Beta 版。如果您有兴趣尝
|
||||
<a href="https://github.com/bglw" style="width:65px">
|
||||
<img src="https://github.com/bglw.png?size=65" width="65"/>
|
||||
</a>
|
||||
<a href="https://github.com/jugglingjsons" style="width:50px">
|
||||
<img src="https://github.com/jugglingjsons.png?size=50" width="50"/>
|
||||
</a>
|
||||
<a href="https://github.com/marcus-crane" style="width:65px">
|
||||
<img src="https://github.com/marcus-crane.png?size=65" width="65"/>
|
||||
</a>
|
||||
@@ -204,8 +201,14 @@ Wails v2 已针对所有 3 个平台发布了 Beta 版。如果您有兴趣尝
|
||||
<a href="https://github.com/GargantuaX" style="width:45px">
|
||||
<img src="https://github.com/GargantuaX.png?size=45" width="45"/>
|
||||
</a>
|
||||
<a href="https://github.com/brodyover" style="width:45px">
|
||||
<img src="https://github.com/brodyover.png?size=45" width="45"/>
|
||||
<a href="https://github.com/CharlieGo88" style="width:55px">
|
||||
<img src="https://github.com/CharlieGo88.png?size=55" width="55"/>
|
||||
</a>
|
||||
<a href="https://github.com/Bironou" style="width:55px">
|
||||
<img src="https://github.com/Bironou.png?size=55" width="55"/>
|
||||
</a>
|
||||
<a href="https://github.com/Shackelford-Arden" style="width:55px">
|
||||
<img src="https://github.com/Shackelford-Arden.png?size=55" width="55"/>
|
||||
</a>
|
||||
<span id="nav-6"></span>
|
||||
|
||||
|
||||
@@ -99,6 +99,12 @@ func AddBuildSubcommand(app *clir.Cli, w io.Writer) {
|
||||
trimpath := false
|
||||
command.BoolFlag("trimpath", "Remove all file system paths from the resulting executable", &trimpath)
|
||||
|
||||
raceDetector := false
|
||||
command.BoolFlag("race", "Build with Go's race detector", &raceDetector)
|
||||
|
||||
windowsConsole := false
|
||||
command.BoolFlag("windowsconsole", "Keep the console when building for Windows", &windowsConsole)
|
||||
|
||||
command.Action(func() error {
|
||||
|
||||
quiet := verbosity == 0
|
||||
@@ -180,6 +186,8 @@ func AddBuildSubcommand(app *clir.Cli, w io.Writer) {
|
||||
UserTags: userTags,
|
||||
WebView2Strategy: wv2rtstrategy,
|
||||
TrimPath: trimpath,
|
||||
RaceDetector: raceDetector,
|
||||
WindowsConsole: windowsConsole,
|
||||
}
|
||||
|
||||
// Start a new tabwriter
|
||||
@@ -197,6 +205,7 @@ func AddBuildSubcommand(app *clir.Cli, w io.Writer) {
|
||||
_, _ = fmt.Fprintf(w, "Clean Build Dir: \t%t\n", buildOptions.CleanBuildDirectory)
|
||||
_, _ = fmt.Fprintf(w, "LDFlags: \t\"%s\"\n", buildOptions.LDFlags)
|
||||
_, _ = fmt.Fprintf(w, "Tags: \t[%s]\n", strings.Join(buildOptions.UserTags, ","))
|
||||
_, _ = fmt.Fprintf(w, "Race Detector: \t%t\n", buildOptions.RaceDetector)
|
||||
if len(buildOptions.OutputFile) > 0 && targets.Length() == 1 {
|
||||
_, _ = fmt.Fprintf(w, "Output File: \t%s\n", buildOptions.OutputFile)
|
||||
}
|
||||
@@ -229,6 +238,7 @@ func AddBuildSubcommand(app *clir.Cli, w io.Writer) {
|
||||
"linux",
|
||||
"linux/amd64",
|
||||
"linux/arm64",
|
||||
"linux/arm",
|
||||
"windows",
|
||||
"windows/amd64",
|
||||
"windows/arm64",
|
||||
@@ -259,10 +269,9 @@ func AddBuildSubcommand(app *clir.Cli, w io.Writer) {
|
||||
// Calculate platform and arch
|
||||
platformSplit := strings.Split(platform, "/")
|
||||
buildOptions.Platform = platformSplit[0]
|
||||
buildOptions.Arch = runtime.GOARCH
|
||||
if system.IsAppleSilicon {
|
||||
buildOptions.Arch = "arm64"
|
||||
} else {
|
||||
buildOptions.Arch = runtime.GOARCH
|
||||
}
|
||||
if len(platformSplit) == 2 {
|
||||
buildOptions.Arch = platformSplit[1]
|
||||
@@ -330,7 +339,7 @@ func AddBuildSubcommand(app *clir.Cli, w io.Writer) {
|
||||
// Output stats
|
||||
buildOptions.Logger.Println(fmt.Sprintf("Built '%s' in %s.\n", outputFilename, time.Since(start).Round(time.Millisecond).String()))
|
||||
|
||||
outputBinaries[platform] = outputFilename
|
||||
outputBinaries[buildOptions.Platform+"/"+buildOptions.Arch] = outputFilename
|
||||
})
|
||||
|
||||
if targetErr != nil {
|
||||
|
||||
@@ -2,6 +2,7 @@ package dev
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"net"
|
||||
@@ -36,16 +37,25 @@ import (
|
||||
)
|
||||
|
||||
func LogGreen(message string, args ...interface{}) {
|
||||
if len(message) == 0 {
|
||||
return
|
||||
}
|
||||
text := fmt.Sprintf(message, args...)
|
||||
println(colour.Green(text))
|
||||
}
|
||||
|
||||
func LogRed(message string, args ...interface{}) {
|
||||
if len(message) == 0 {
|
||||
return
|
||||
}
|
||||
text := fmt.Sprintf(message, args...)
|
||||
println(colour.Red(text))
|
||||
}
|
||||
|
||||
func LogDarkYellow(message string, args ...interface{}) {
|
||||
if len(message) == 0 {
|
||||
return
|
||||
}
|
||||
text := fmt.Sprintf(message, args...)
|
||||
println(colour.DarkYellow(text))
|
||||
}
|
||||
@@ -66,6 +76,7 @@ type devFlags struct {
|
||||
reloadDirs string
|
||||
openBrowser bool
|
||||
noReload bool
|
||||
noGen bool
|
||||
wailsjsdir string
|
||||
tags string
|
||||
verbosity int
|
||||
@@ -75,6 +86,7 @@ type devFlags struct {
|
||||
devServer string
|
||||
appargs string
|
||||
saveConfig bool
|
||||
raceDetector bool
|
||||
|
||||
frontendDevServerURL string
|
||||
}
|
||||
@@ -92,6 +104,7 @@ func AddSubcommand(app *clir.Cli, w io.Writer) error {
|
||||
command.StringFlag("reloaddirs", "Additional directories to trigger reloads (comma separated)", &flags.reloadDirs)
|
||||
command.BoolFlag("browser", "Open application in browser", &flags.openBrowser)
|
||||
command.BoolFlag("noreload", "Disable reload on asset change", &flags.noReload)
|
||||
command.BoolFlag("nogen", "Disable generate module", &flags.noGen)
|
||||
command.StringFlag("wailsjsdir", "Directory to generate the Wails JS modules", &flags.wailsjsdir)
|
||||
command.StringFlag("tags", "tags to pass to Go compiler (quoted and space separated)", &flags.tags)
|
||||
command.IntFlag("v", "Verbosity level (0 - silent, 1 - standard, 2 - verbose)", &flags.verbosity)
|
||||
@@ -100,8 +113,9 @@ func AddSubcommand(app *clir.Cli, w io.Writer) error {
|
||||
command.IntFlag("debounce", "The amount of time to wait to trigger a reload on change", &flags.debounceMS)
|
||||
command.StringFlag("devserver", "The address of the wails dev server", &flags.devServer)
|
||||
command.StringFlag("frontenddevserverurl", "The url of the external frontend dev server to use", &flags.frontendDevServerURL)
|
||||
command.StringFlag("appargs", "arguments to pass to the underlying app (quoted and space searated)", &flags.appargs)
|
||||
command.StringFlag("appargs", "arguments to pass to the underlying app (quoted and space separated)", &flags.appargs)
|
||||
command.BoolFlag("save", "Save given flags as defaults", &flags.saveConfig)
|
||||
command.BoolFlag("race", "Build with Go's race detector", &flags.raceDetector)
|
||||
|
||||
command.Action(func() error {
|
||||
// Create logger
|
||||
@@ -148,22 +162,22 @@ func AddSubcommand(app *clir.Cli, w io.Writer) error {
|
||||
return err
|
||||
}
|
||||
|
||||
self := os.Args[0]
|
||||
if flags.tags != "" {
|
||||
err = runCommand(cwd, true, self, "generate", "module", "-tags", flags.tags)
|
||||
} else {
|
||||
err = runCommand(cwd, true, self, "generate", "module")
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
if !flags.noGen {
|
||||
self := os.Args[0]
|
||||
if flags.tags != "" {
|
||||
err = runCommand(cwd, true, self, "generate", "module", "-tags", flags.tags)
|
||||
} else {
|
||||
err = runCommand(cwd, true, self, "generate", "module")
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
buildOptions := generateBuildOptions(flags)
|
||||
buildOptions.Logger = logger
|
||||
buildOptions.UserTags = internal.ParseUserTags(flags.tags)
|
||||
|
||||
var debugBinaryProcess *process.Process = nil
|
||||
|
||||
// Setup signal handler
|
||||
quitChannel := make(chan os.Signal, 1)
|
||||
signal.Notify(quitChannel, os.Interrupt, os.Kill, syscall.SIGTERM)
|
||||
@@ -171,19 +185,23 @@ func AddSubcommand(app *clir.Cli, w io.Writer) error {
|
||||
|
||||
// Do initial build
|
||||
logger.Println("Building application for development...")
|
||||
newProcess, appBinary, err := restartApp(buildOptions, debugBinaryProcess, flags, exitCodeChannel)
|
||||
debugBinaryProcess, appBinary, err := restartApp(buildOptions, nil, flags, exitCodeChannel)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if newProcess != nil {
|
||||
debugBinaryProcess = newProcess
|
||||
}
|
||||
defer func() {
|
||||
if err := killProcessAndCleanupBinary(debugBinaryProcess, appBinary); err != nil {
|
||||
LogDarkYellow("Unable to kill process and cleanup binary: %s", err)
|
||||
}
|
||||
}()
|
||||
|
||||
// frontend:dev:watcher command.
|
||||
if command := projectConfig.DevWatcherCommand; command != "" {
|
||||
var devCommandWaitGroup sync.WaitGroup
|
||||
closer := runFrontendDevWatcherCommand(cwd, command, &devCommandWaitGroup)
|
||||
defer closer(&devCommandWaitGroup)
|
||||
closer, err := runFrontendDevWatcherCommand(cwd, command)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer closer()
|
||||
}
|
||||
|
||||
// open browser
|
||||
@@ -215,22 +233,17 @@ func AddSubcommand(app *clir.Cli, w io.Writer) error {
|
||||
LogGreen("Using reload debounce setting of %d milliseconds", flags.debounceMS)
|
||||
|
||||
// Watch for changes and trigger restartApp()
|
||||
doWatcherLoop(buildOptions, debugBinaryProcess, flags, watcher, exitCodeChannel, quitChannel, devServerURL)
|
||||
debugBinaryProcess = doWatcherLoop(buildOptions, debugBinaryProcess, flags, watcher, exitCodeChannel, quitChannel, devServerURL)
|
||||
|
||||
// Kill the current program if running
|
||||
if debugBinaryProcess != nil {
|
||||
err := debugBinaryProcess.Kill()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
// Remove dev binary
|
||||
err = os.Remove(appBinary)
|
||||
if err != nil {
|
||||
// Kill the current program if running and remove dev binary
|
||||
if err := killProcessAndCleanupBinary(debugBinaryProcess, appBinary); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Reset the process and the binary so the defer knows about it and is a nop.
|
||||
debugBinaryProcess = nil
|
||||
appBinary = ""
|
||||
|
||||
LogGreen("Development mode exited")
|
||||
|
||||
return nil
|
||||
@@ -238,6 +251,22 @@ func AddSubcommand(app *clir.Cli, w io.Writer) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func killProcessAndCleanupBinary(process *process.Process, binary string) error {
|
||||
if process != nil && process.Running {
|
||||
if err := process.Kill(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if binary != "" {
|
||||
err := os.Remove(binary)
|
||||
if err != nil && !errors.Is(err, os.ErrNotExist) {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func syncGoModVersion(cwd string) error {
|
||||
gomodFilename := filepath.Join(cwd, "go.mod")
|
||||
gomodData, err := os.ReadFile(gomodFilename)
|
||||
@@ -299,6 +328,7 @@ func generateBuildOptions(flags devFlags) *build.Options {
|
||||
IgnoreFrontend: false,
|
||||
Verbosity: flags.verbosity,
|
||||
WailsJSDir: flags.wailsjsdir,
|
||||
RaceDetector: flags.raceDetector,
|
||||
}
|
||||
|
||||
return result
|
||||
@@ -381,35 +411,39 @@ func loadAndMergeProjectConfig(cwd string, flags *devFlags) (*project.Project, e
|
||||
}
|
||||
|
||||
// runFrontendDevWatcherCommand will run the `frontend:dev:watcher` command if it was given, ex- `npm run dev`
|
||||
func runFrontendDevWatcherCommand(cwd string, devCommand string, wg *sync.WaitGroup) func(group *sync.WaitGroup) {
|
||||
LogGreen("Running frontend dev watcher command: '%s'", devCommand)
|
||||
func runFrontendDevWatcherCommand(cwd string, devCommand string) (func(), error) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
dir := filepath.Join(cwd, "frontend")
|
||||
cmdSlice := strings.Split(devCommand, " ")
|
||||
wg.Add(1)
|
||||
cmd := exec.CommandContext(ctx, cmdSlice[0], cmdSlice[1:]...)
|
||||
cmd.Stderr = os.Stderr
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Dir = dir
|
||||
|
||||
setParentGID(cmd)
|
||||
go func(ctx context.Context, devCommand string, cwd string, wg *sync.WaitGroup) {
|
||||
err := cmd.Run()
|
||||
if err != nil {
|
||||
if err := cmd.Start(); err != nil {
|
||||
cancel()
|
||||
return nil, fmt.Errorf("Unable to start frontend DevWatcher: %w", err)
|
||||
}
|
||||
|
||||
LogGreen("Running frontend DevWatcher command: '%s'", devCommand)
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
if err := cmd.Wait(); err != nil {
|
||||
if err.Error() != "exit status 1" {
|
||||
LogRed("Error from '%s': %s", devCommand, err.Error())
|
||||
LogRed("Error from DevWatcher '%s': %s", devCommand, err.Error())
|
||||
}
|
||||
}
|
||||
LogGreen("Dev command exited!")
|
||||
LogGreen("DevWatcher command exited!")
|
||||
wg.Done()
|
||||
}(ctx, devCommand, cwd, wg)
|
||||
}()
|
||||
|
||||
return func(wg *sync.WaitGroup) {
|
||||
return func() {
|
||||
killProc(cmd, devCommand)
|
||||
LogGreen("Dev command killed!")
|
||||
LogGreen("DevWatcher command killed!")
|
||||
cancel()
|
||||
wg.Wait()
|
||||
}
|
||||
}, nil
|
||||
}
|
||||
|
||||
// initialiseWatcher creates the project directory watcher that will trigger recompile
|
||||
@@ -456,8 +490,13 @@ func restartApp(buildOptions *build.Options, debugBinaryProcess *process.Process
|
||||
appBinary, err := build.Build(buildOptions)
|
||||
println()
|
||||
if err != nil {
|
||||
LogRed("Build error - continuing to run current version")
|
||||
LogDarkYellow(err.Error())
|
||||
LogRed("Build error - " + err.Error())
|
||||
|
||||
msg := "Continuing to run current version"
|
||||
if debugBinaryProcess == nil {
|
||||
msg = "No version running, build will be retriggered as soon as changes have been detected"
|
||||
}
|
||||
LogDarkYellow(msg)
|
||||
return nil, "", nil
|
||||
}
|
||||
|
||||
@@ -503,12 +542,8 @@ func restartApp(buildOptions *build.Options, debugBinaryProcess *process.Process
|
||||
}
|
||||
|
||||
// doWatcherLoop is the main watch loop that runs while dev is active
|
||||
func doWatcherLoop(buildOptions *build.Options, debugBinaryProcess *process.Process, flags devFlags, watcher *fsnotify.Watcher, exitCodeChannel chan int, quitChannel chan os.Signal, devServerURL *url.URL) {
|
||||
func doWatcherLoop(buildOptions *build.Options, debugBinaryProcess *process.Process, flags devFlags, watcher *fsnotify.Watcher, exitCodeChannel chan int, quitChannel chan os.Signal, devServerURL *url.URL) *process.Process {
|
||||
// Main Loop
|
||||
var (
|
||||
err error
|
||||
newBinaryProcess *process.Process
|
||||
)
|
||||
var extensionsThatTriggerARebuild = sliceToMap(strings.Split(flags.extensions, ","))
|
||||
var dirsThatTriggerAReload []string
|
||||
for _, dir := range strings.Split(flags.reloadDirs, ",") {
|
||||
@@ -534,7 +569,7 @@ func doWatcherLoop(buildOptions *build.Options, debugBinaryProcess *process.Proc
|
||||
assetDirURL := joinPath(devServerURL, "/wails/assetdir")
|
||||
reloadURL := joinPath(devServerURL, "/wails/reload")
|
||||
for quit == false {
|
||||
//reload := false
|
||||
// reload := false
|
||||
select {
|
||||
case exitCode := <-exitCodeChannel:
|
||||
if exitCode == 0 {
|
||||
@@ -579,7 +614,7 @@ func doWatcherLoop(buildOptions *build.Options, debugBinaryProcess *process.Proc
|
||||
if item.Op&fsnotify.Create == fsnotify.Create {
|
||||
// If this is a folder, add it to our watch list
|
||||
if fs.DirExists(item.Name) {
|
||||
//node_modules is BANNED!
|
||||
// node_modules is BANNED!
|
||||
if !strings.Contains(item.Name, "node_modules") {
|
||||
err := watcher.Add(item.Name)
|
||||
if err != nil {
|
||||
@@ -594,7 +629,7 @@ func doWatcherLoop(buildOptions *build.Options, debugBinaryProcess *process.Proc
|
||||
rebuild = false
|
||||
LogGreen("[Rebuild triggered] files updated")
|
||||
// Try and build the app
|
||||
newBinaryProcess, _, err = restartApp(buildOptions, debugBinaryProcess, flags, exitCodeChannel)
|
||||
newBinaryProcess, _, err := restartApp(buildOptions, debugBinaryProcess, flags, exitCodeChannel)
|
||||
if err != nil {
|
||||
LogRed("Error during build: %s", err.Error())
|
||||
continue
|
||||
@@ -640,7 +675,7 @@ func doWatcherLoop(buildOptions *build.Options, debugBinaryProcess *process.Proc
|
||||
}
|
||||
if reload {
|
||||
reload = false
|
||||
_, err = http.Get(reloadURL)
|
||||
_, err := http.Get(reloadURL)
|
||||
if err != nil {
|
||||
LogRed("Error during refresh: %s", err.Error())
|
||||
}
|
||||
@@ -650,6 +685,7 @@ func doWatcherLoop(buildOptions *build.Options, debugBinaryProcess *process.Proc
|
||||
quit = true
|
||||
}
|
||||
}
|
||||
return debugBinaryProcess
|
||||
}
|
||||
|
||||
func joinPath(url *url.URL, subPath string) string {
|
||||
|
||||
@@ -6,6 +6,8 @@ package dev
|
||||
import (
|
||||
"os/exec"
|
||||
"syscall"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
func setParentGID(cmd *exec.Cmd) {
|
||||
@@ -15,6 +17,10 @@ func setParentGID(cmd *exec.Cmd) {
|
||||
}
|
||||
|
||||
func killProc(cmd *exec.Cmd, devCommand string) {
|
||||
if cmd == nil || cmd.Process == nil {
|
||||
return
|
||||
}
|
||||
|
||||
// Experiencing the same issue on macOS BigSur
|
||||
// I'm using Vite, but I would imagine this could be an issue with Node (npm) in general
|
||||
// Also, after several edit/rebuild cycles any abnormal shutdown (crash or CTRL-C) may still leave Node running
|
||||
@@ -22,7 +28,7 @@ func killProc(cmd *exec.Cmd, devCommand string) {
|
||||
// Not tested on *nix
|
||||
pgid, err := syscall.Getpgid(cmd.Process.Pid)
|
||||
if err == nil {
|
||||
err := syscall.Kill(-pgid, 15) // note the minus sign
|
||||
err := syscall.Kill(-pgid, unix.SIGTERM) // note the minus sign
|
||||
if err != nil {
|
||||
LogRed("Error from '%s' when attempting to kill the process: %s", devCommand, err.Error())
|
||||
}
|
||||
|
||||
@@ -50,10 +50,8 @@ func AddModuleCommand(app *clir.Cli, parent *clir.Command, w io.Writer) error {
|
||||
return fmt.Errorf("%s\n%s\n%s", stdout, stderr, err)
|
||||
}
|
||||
|
||||
err = os.Remove(filename)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// Best effort removal of temp file
|
||||
_ = os.Remove(filename)
|
||||
|
||||
return nil
|
||||
})
|
||||
|
||||
@@ -53,8 +53,6 @@ github.com/leaanthony/debme v1.2.1 h1:9Tgwf+kjcrbMQ4WnPcEIUcQuIZYqdWftzZkBr+i/oO
|
||||
github.com/leaanthony/debme v1.2.1/go.mod h1:3V+sCm5tYAgQymvSOfYQ5Xx2JCr+OXiD9Jkw3otUjiA=
|
||||
github.com/leaanthony/go-ansi-parser v1.0.1 h1:97v6c5kYppVsbScf4r/VZdXyQ21KQIfeQOk2DgKxGG4=
|
||||
github.com/leaanthony/go-ansi-parser v1.0.1/go.mod h1:7arTzgVI47srICYhvgUV4CGd063sGEeoSlych5yeSPM=
|
||||
github.com/leaanthony/go-common-file-dialog v1.0.3 h1:O0uGjKnWtdEADGrkg+TyAAbZylykMwwx/MNEXn9fp+Y=
|
||||
github.com/leaanthony/go-common-file-dialog v1.0.3/go.mod h1:TGhEc9eSJgRsupZ+iH1ZgAOnEo9zp05cRH2j08RPrF0=
|
||||
github.com/leaanthony/gosod v1.0.3 h1:Fnt+/B6NjQOVuCWOKYRREZnjGyvg+mEhd1nkkA04aTQ=
|
||||
github.com/leaanthony/gosod v1.0.3/go.mod h1:BJ2J+oHsQIyIQpnLPjnqFGTMnOZXDbvWtRCSG7jGxs4=
|
||||
github.com/leaanthony/idgen v1.0.0/go.mod h1:4nBZnt8ml/f/ic/EVQuLxuj817RccT2fyrUaZFxrcVA=
|
||||
|
||||
@@ -12,7 +12,6 @@ module changeme
|
||||
github.com/labstack/echo/v4 v4.7.2 // indirect
|
||||
github.com/labstack/gommon v0.3.1 // indirect
|
||||
github.com/leaanthony/go-ansi-parser v1.0.1 // indirect
|
||||
github.com/leaanthony/go-common-file-dialog v1.0.3 // indirect
|
||||
github.com/leaanthony/gosod v1.0.3 // indirect
|
||||
github.com/leaanthony/slicer v1.5.0 // indirect
|
||||
github.com/leaanthony/typescriptify-golang-structs v0.1.7 // indirect
|
||||
|
||||
@@ -35,7 +35,7 @@ func main() {
|
||||
Frameless: false,
|
||||
StartHidden: false,
|
||||
HideWindowOnClose: false,
|
||||
RGBA: &options.RGBA{R: 255, G: 255, B: 255, A: 255},
|
||||
BackgroundColour: &options.RGBA{R: 255, G: 255, B: 255, A: 255},
|
||||
Assets: assets,
|
||||
Menu: nil,
|
||||
Logger: nil,
|
||||
|
||||
@@ -216,6 +216,16 @@ func initGit(options *templates.Options) error {
|
||||
return errors.Wrap(err, "Unable to initialise git repository:")
|
||||
}
|
||||
|
||||
ignore := []string{
|
||||
"build/bin",
|
||||
"frontend/dist",
|
||||
"frontend/node_modules",
|
||||
}
|
||||
err = os.WriteFile(filepath.Join(options.TargetDir, ".gitignore"), []byte(strings.Join(ignore, "\n")), 0644)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "Unable to create gitignore")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -16,11 +16,12 @@ func main() {
|
||||
|
||||
// Create application with options
|
||||
err := wails.Run(&options.App{
|
||||
Title: "{{.ProjectName}}",
|
||||
Width: 1024,
|
||||
Height: 768,
|
||||
Assets: assets,
|
||||
OnStartup: app.startup,
|
||||
Title: "{{.ProjectName}}",
|
||||
Width: 1024,
|
||||
Height: 768,
|
||||
Assets: assets,
|
||||
BackgroundColour: &options.RGBA{R: 27, G: 38, B: 54, A: 1},
|
||||
OnStartup: app.startup,
|
||||
Bind: []interface{}{
|
||||
app,
|
||||
},
|
||||
|
||||
+3
-3
@@ -167,9 +167,9 @@ export function WindowMinimise(): void;
|
||||
// Restores the window to the dimensions and position prior to minimising.
|
||||
export function WindowUnminimise(): void;
|
||||
|
||||
// [WindowSetRGBA](https://wails.io/docs/reference/runtime/window#windowsetrgba)
|
||||
// [WindowSetBackgroundColour](https://wails.io/docs/reference/runtime/window#windowsetbackgroundcolour)
|
||||
// Sets the background colour of the window to the given RGBA colour definition. This colour will show through for all transparent pixels.
|
||||
export function WindowSetRGBA(R: number, G: number, B: number, A: number): void;
|
||||
export function WindowSetBackgroundColour(R: number, G: number, B: number, A: number): void;
|
||||
|
||||
// [BrowserOpenURL](https://wails.io/docs/reference/runtime/browser#browseropenurl)
|
||||
// Opens the given URL in the system browser.
|
||||
@@ -177,7 +177,7 @@ export function BrowserOpenURL(url: string): void;
|
||||
|
||||
// [Environment](https://wails.io/docs/reference/runtime/intro#environment)
|
||||
// Returns information about the environment
|
||||
export function Environment(): EnvironmentInfo;
|
||||
export function Environment(): Promise<EnvironmentInfo>;
|
||||
|
||||
// [Quit](https://wails.io/docs/reference/runtime/intro#quit)
|
||||
// Quits the application.
|
||||
|
||||
+4
-4
@@ -41,7 +41,7 @@ export function EventsOnMultiple(eventName, callback, maxCallbacks) {
|
||||
}
|
||||
|
||||
export function EventsOn(eventName, callback) {
|
||||
OnMultiple(eventName, callback, -1);
|
||||
EventsOnMultiple(eventName, callback, -1);
|
||||
}
|
||||
|
||||
export function EventsOff(eventName) {
|
||||
@@ -49,7 +49,7 @@ export function EventsOff(eventName) {
|
||||
}
|
||||
|
||||
export function EventsOnce(eventName, callback) {
|
||||
OnMultiple(eventName, callback, 1);
|
||||
EventsOnMultiple(eventName, callback, 1);
|
||||
}
|
||||
|
||||
export function EventsEmit(eventName) {
|
||||
@@ -145,8 +145,8 @@ export function WindowUnminimise() {
|
||||
window.runtime.WindowUnminimise();
|
||||
}
|
||||
|
||||
export function WindowSetRGBA(RGBA) {
|
||||
window.runtime.WindowSetRGBA(RGBA);
|
||||
export function WindowSetBackgroundColour(R, G, B, A) {
|
||||
window.runtime.WindowSetBackgroundColour(R, G, B, A);
|
||||
}
|
||||
|
||||
export function BrowserOpenURL(url) {
|
||||
|
||||
+22
-23
@@ -68,32 +68,31 @@ export class MyElement extends LitElement {
|
||||
}
|
||||
|
||||
`
|
||||
}
|
||||
|
||||
@property()
|
||||
resultText = "Please enter your name below 👇"
|
||||
@property()
|
||||
resultText = "Please enter your name below 👇"
|
||||
|
||||
greet()
|
||||
{
|
||||
let thisName = this.shadowRoot.getElementById('name').value
|
||||
Greet(thisName).then(result => {
|
||||
this.resultText = result
|
||||
});
|
||||
}
|
||||
greet() {
|
||||
let thisName = (this.shadowRoot.getElementById('name') as HTMLInputElement)?.value;
|
||||
if (thisName) {
|
||||
Greet(thisName).then(result => {
|
||||
this.resultText = result
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
render()
|
||||
{
|
||||
return html`
|
||||
<main>
|
||||
<img id="logo" src=${logo} alt="Wails logo">
|
||||
<div class="result" id="result">${this.resultText}</div>
|
||||
<div class="input-box" id="input">
|
||||
<input class="input" id="name" type="text" autocomplete="off"/>
|
||||
<button @click=${this.greet} class="btn">Greet</button>
|
||||
</div>
|
||||
</main>
|
||||
`
|
||||
}
|
||||
render() {
|
||||
return html`
|
||||
<main>
|
||||
<img id="logo" src=${logo} alt="Wails logo">
|
||||
<div class="result" id="result">${this.resultText}</div>
|
||||
<div class="input-box" id="input">
|
||||
<input class="input" id="name" type="text" autocomplete="off"/>
|
||||
<button @click=${this.greet} class="btn">Greet</button>
|
||||
</div>
|
||||
</main>
|
||||
`
|
||||
}
|
||||
}
|
||||
|
||||
declare global {
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ export function App(props: any) {
|
||||
<img src={logo} id="logo" alt="logo"/>
|
||||
<div id="result" className="result">{resultText}</div>
|
||||
<div id="input" className="input-box">
|
||||
<input id="name" onChange={updateName} autoComplete="off" name="input" type="text"/>
|
||||
<input id="name" className="input" onChange={updateName} autoComplete="off" name="input" type="text"/>
|
||||
<button className="btn" onClick={greet}>Greet</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ export function App(props) {
|
||||
<img src={logo} id="logo" alt="logo"/>
|
||||
<div id="result" className="result">{resultText}</div>
|
||||
<div id="input" className="input-box">
|
||||
<input id="name" onChange={updateName} autoComplete="off" name="input" type="text"/>
|
||||
<input id="name" className="input" onChange={updateName} autoComplete="off" name="input" type="text"/>
|
||||
<button className="btn" onClick={greet}>Greet</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user