mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-03 07:29:07 +08:00
[chore] lint fixes
This commit is contained in:
parent
d88a741ce7
commit
9ce0ddb4f8
@ -18,7 +18,6 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func buildApplication(f *flags.Build) error {
|
func buildApplication(f *flags.Build) error {
|
||||||
|
|
||||||
if f.NoColour {
|
if f.NoColour {
|
||||||
pterm.DisableColor()
|
pterm.DisableColor()
|
||||||
colour.ColourEnabled = false
|
colour.ColourEnabled = false
|
||||||
@ -255,5 +254,4 @@ func buildApplication(f *flags.Build) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"os"
|
||||||
|
|
||||||
"github.com/pterm/pterm"
|
"github.com/pterm/pterm"
|
||||||
"github.com/wailsapp/wails/v2/cmd/wails/flags"
|
"github.com/wailsapp/wails/v2/cmd/wails/flags"
|
||||||
"github.com/wailsapp/wails/v2/cmd/wails/internal/dev"
|
"github.com/wailsapp/wails/v2/cmd/wails/internal/dev"
|
||||||
"github.com/wailsapp/wails/v2/internal/colour"
|
"github.com/wailsapp/wails/v2/internal/colour"
|
||||||
"github.com/wailsapp/wails/v2/pkg/clilogger"
|
"github.com/wailsapp/wails/v2/pkg/clilogger"
|
||||||
"os"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func devApplication(f *flags.Dev) error {
|
func devApplication(f *flags.Dev) error {
|
||||||
|
|
||||||
if f.NoColour {
|
if f.NoColour {
|
||||||
pterm.DisableColor()
|
pterm.DisableColor()
|
||||||
colour.ColourEnabled = false
|
colour.ColourEnabled = false
|
||||||
@ -34,5 +34,4 @@ func devApplication(f *flags.Dev) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return dev.Application(f, logger)
|
return dev.Application(f, logger)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -128,8 +128,8 @@ func diagnoseEnvironment(f *flags.Doctor) error {
|
|||||||
// Output Dependencies Status
|
// Output Dependencies Status
|
||||||
var dependenciesMissing []string
|
var dependenciesMissing []string
|
||||||
var externalPackages []*packagemanager.Dependency
|
var externalPackages []*packagemanager.Dependency
|
||||||
var dependenciesAvailableRequired = 0
|
dependenciesAvailableRequired := 0
|
||||||
var dependenciesAvailableOptional = 0
|
dependenciesAvailableOptional := 0
|
||||||
|
|
||||||
dependenciesTableData := pterm.TableData{
|
dependenciesTableData := pterm.TableData{
|
||||||
{"Dependency", "Package Name", "Status", "Version"},
|
{"Dependency", "Package Name", "Status", "Version"},
|
||||||
|
@ -47,7 +47,6 @@ func (*Dev) Default() *Dev {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (d *Dev) Process() error {
|
func (d *Dev) Process() error {
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
err = d.loadAndMergeProjectConfig()
|
err = d.loadAndMergeProjectConfig()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -113,7 +112,6 @@ func (d *Dev) loadAndMergeProjectConfig() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GenerateBuildOptions creates a build.Options using the flags
|
// GenerateBuildOptions creates a build.Options using the flags
|
||||||
|
@ -14,7 +14,6 @@ type Init struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (i *Init) Default() *Init {
|
func (i *Init) Default() *Init {
|
||||||
|
|
||||||
result := &Init{
|
result := &Init{
|
||||||
TemplateName: "vanilla",
|
TemplateName: "vanilla",
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,9 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/leaanthony/debme"
|
"github.com/leaanthony/debme"
|
||||||
"github.com/leaanthony/gosod"
|
"github.com/leaanthony/gosod"
|
||||||
"github.com/pterm/pterm"
|
"github.com/pterm/pterm"
|
||||||
@ -14,12 +17,9 @@ import (
|
|||||||
"github.com/wailsapp/wails/v2/pkg/clilogger"
|
"github.com/wailsapp/wails/v2/pkg/clilogger"
|
||||||
"github.com/wailsapp/wails/v2/pkg/commands/bindings"
|
"github.com/wailsapp/wails/v2/pkg/commands/bindings"
|
||||||
"github.com/wailsapp/wails/v2/pkg/commands/buildtags"
|
"github.com/wailsapp/wails/v2/pkg/commands/buildtags"
|
||||||
"os"
|
|
||||||
"path/filepath"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func generateModule(f *flags.GenerateModule) error {
|
func generateModule(f *flags.GenerateModule) error {
|
||||||
|
|
||||||
if f.NoColour {
|
if f.NoColour {
|
||||||
pterm.DisableColor()
|
pterm.DisableColor()
|
||||||
colour.ColourEnabled = false
|
colour.ColourEnabled = false
|
||||||
@ -55,7 +55,6 @@ func generateModule(f *flags.GenerateModule) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func generateTemplate(f *flags.GenerateTemplate) error {
|
func generateTemplate(f *flags.GenerateTemplate) error {
|
||||||
|
|
||||||
if f.NoColour {
|
if f.NoColour {
|
||||||
pterm.DisableColor()
|
pterm.DisableColor()
|
||||||
colour.ColourEnabled = false
|
colour.ColourEnabled = false
|
||||||
@ -77,7 +76,7 @@ func generateTemplate(f *flags.GenerateTemplate) error {
|
|||||||
}
|
}
|
||||||
templateDir := filepath.Join(cwd, f.Name)
|
templateDir := filepath.Join(cwd, f.Name)
|
||||||
if !fs.DirExists(templateDir) {
|
if !fs.DirExists(templateDir) {
|
||||||
err := os.MkdirAll(templateDir, 0755)
|
err := os.MkdirAll(templateDir, 0o755)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -200,7 +199,7 @@ func processPackageJSON(frontendDir string) error {
|
|||||||
json, _ = sjson.SetBytes(json, "name", "{{.ProjectName}}")
|
json, _ = sjson.SetBytes(json, "name", "{{.ProjectName}}")
|
||||||
json, _ = sjson.SetBytes(json, "author", "{{.AuthorName}}")
|
json, _ = sjson.SetBytes(json, "author", "{{.AuthorName}}")
|
||||||
|
|
||||||
err = os.WriteFile(packageJSON, json, 0644)
|
err = os.WriteFile(packageJSON, json, 0o644)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -231,7 +230,7 @@ func processPackageLockJSON(frontendDir string) error {
|
|||||||
printBulletPoint("Updating package-lock.json data...")
|
printBulletPoint("Updating package-lock.json data...")
|
||||||
json, _ = sjson.Set(json, "name", "{{.ProjectName}}")
|
json, _ = sjson.Set(json, "name", "{{.ProjectName}}")
|
||||||
|
|
||||||
err = os.WriteFile(filename, []byte(json), 0644)
|
err = os.WriteFile(filename, []byte(json), 0o644)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,12 @@ package main
|
|||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"os/exec"
|
||||||
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/flytam/filenamify"
|
"github.com/flytam/filenamify"
|
||||||
"github.com/leaanthony/slicer"
|
"github.com/leaanthony/slicer"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
@ -13,15 +19,9 @@ import (
|
|||||||
"github.com/wailsapp/wails/v2/pkg/clilogger"
|
"github.com/wailsapp/wails/v2/pkg/clilogger"
|
||||||
"github.com/wailsapp/wails/v2/pkg/git"
|
"github.com/wailsapp/wails/v2/pkg/git"
|
||||||
"github.com/wailsapp/wails/v2/pkg/templates"
|
"github.com/wailsapp/wails/v2/pkg/templates"
|
||||||
"os"
|
|
||||||
"os/exec"
|
|
||||||
"path/filepath"
|
|
||||||
"strings"
|
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func initProject(f *flags.Init) error {
|
func initProject(f *flags.Init) error {
|
||||||
|
|
||||||
if f.NoColour {
|
if f.NoColour {
|
||||||
pterm.DisableColor()
|
pterm.DisableColor()
|
||||||
colour.ColourEnabled = false
|
colour.ColourEnabled = false
|
||||||
@ -215,7 +215,7 @@ func initGit(options *templates.Options) error {
|
|||||||
"frontend/dist",
|
"frontend/dist",
|
||||||
"frontend/node_modules",
|
"frontend/node_modules",
|
||||||
}
|
}
|
||||||
err = os.WriteFile(filepath.Join(options.TargetDir, ".gitignore"), []byte(strings.Join(ignore, "\n")), 0644)
|
err = os.WriteFile(filepath.Join(options.TargetDir, ".gitignore"), []byte(strings.Join(ignore, "\n")), 0o644)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "Unable to create gitignore")
|
return errors.Wrap(err, "Unable to create gitignore")
|
||||||
}
|
}
|
||||||
@ -271,7 +271,7 @@ func updateReplaceLine(targetPath string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
err = os.WriteFile("go.mod", []byte(strings.Join(lines, "\n")), 0644)
|
err = os.WriteFile("go.mod", []byte(strings.Join(lines, "\n")), 0o644)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fatal(err.Error())
|
fatal(err.Error())
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,6 @@ func sliceToMap(input []string) map[string]struct{} {
|
|||||||
|
|
||||||
// Application runs the application in dev mode
|
// Application runs the application in dev mode
|
||||||
func Application(f *flags.Dev, logger *clilogger.CLILogger) error {
|
func Application(f *flags.Dev, logger *clilogger.CLILogger) error {
|
||||||
|
|
||||||
cwd := lo.Must(os.Getwd())
|
cwd := lo.Must(os.Getwd())
|
||||||
|
|
||||||
// Update go.mod to use current wails version
|
// Update go.mod to use current wails version
|
||||||
@ -271,7 +270,6 @@ func runFrontendDevWatcherCommand(frontendDirectory string, devCommand string, d
|
|||||||
|
|
||||||
// restartApp does the actual rebuilding of the application when files change
|
// restartApp does the actual rebuilding of the application when files change
|
||||||
func restartApp(buildOptions *build.Options, debugBinaryProcess *process.Process, f *flags.Dev, exitCodeChannel chan int, legacyUseDevServerInsteadofCustomScheme bool) (*process.Process, string, error) {
|
func restartApp(buildOptions *build.Options, debugBinaryProcess *process.Process, f *flags.Dev, exitCodeChannel chan int, legacyUseDevServerInsteadofCustomScheme bool) (*process.Process, string, error) {
|
||||||
|
|
||||||
appBinary, err := build.Build(buildOptions)
|
appBinary, err := build.Build(buildOptions)
|
||||||
println()
|
println()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -298,7 +296,6 @@ func restartApp(buildOptions *build.Options, debugBinaryProcess *process.Process
|
|||||||
|
|
||||||
// parse appargs if any
|
// parse appargs if any
|
||||||
args, err := shlex.Split(f.AppArgs)
|
args, err := shlex.Split(f.AppArgs)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
buildOptions.Logger.Fatal("Unable to parse appargs: %s", err.Error())
|
buildOptions.Logger.Fatal("Unable to parse appargs: %s", err.Error())
|
||||||
}
|
}
|
||||||
@ -345,7 +342,7 @@ func doWatcherLoop(cwd string, buildOptions *build.Options, debugBinaryProcess *
|
|||||||
logutils.LogGreen("Watching (sub)/directory: %s", cwd)
|
logutils.LogGreen("Watching (sub)/directory: %s", cwd)
|
||||||
|
|
||||||
// Main Loop
|
// Main Loop
|
||||||
var extensionsThatTriggerARebuild = sliceToMap(strings.Split(f.Extensions, ","))
|
extensionsThatTriggerARebuild := sliceToMap(strings.Split(f.Extensions, ","))
|
||||||
var dirsThatTriggerAReload []string
|
var dirsThatTriggerAReload []string
|
||||||
for _, dir := range strings.Split(f.ReloadDirs, ",") {
|
for _, dir := range strings.Split(f.ReloadDirs, ",") {
|
||||||
if dir == "" {
|
if dir == "" {
|
||||||
|
@ -18,7 +18,6 @@ type Watcher interface {
|
|||||||
|
|
||||||
// initialiseWatcher creates the project directory watcher that will trigger recompile
|
// initialiseWatcher creates the project directory watcher that will trigger recompile
|
||||||
func initialiseWatcher(cwd string) (*fsnotify.Watcher, error) {
|
func initialiseWatcher(cwd string) (*fsnotify.Watcher, error) {
|
||||||
|
|
||||||
// Ignore dot files, node_modules and build directories by default
|
// Ignore dot files, node_modules and build directories by default
|
||||||
ignoreDirs := getIgnoreDirs(cwd)
|
ignoreDirs := getIgnoreDirs(cwd)
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ func SyncGoMod(logger *clilogger.CLILogger, updateWailsVersion bool) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if updated {
|
if updated {
|
||||||
return os.WriteFile(gomodFilename, gomodData, 0755)
|
return os.WriteFile(gomodFilename, gomodData, 0o755)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
@ -66,7 +66,6 @@ func bool2Str(b bool) string {
|
|||||||
var app *clir.Cli
|
var app *clir.Cli
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
app = clir.NewCli("Wails", "Go/HTML Appkit", internal.Version)
|
app = clir.NewCli("Wails", "Go/HTML Appkit", internal.Version)
|
||||||
|
@ -15,7 +15,6 @@ import (
|
|||||||
|
|
||||||
// AddSubcommand adds the `init` command for the Wails application
|
// AddSubcommand adds the `init` command for the Wails application
|
||||||
func update(f *flags.Update) error {
|
func update(f *flags.Update) error {
|
||||||
|
|
||||||
if f.NoColour {
|
if f.NoColour {
|
||||||
colour.ColourEnabled = false
|
colour.ColourEnabled = false
|
||||||
pterm.DisableColor()
|
pterm.DisableColor()
|
||||||
@ -73,8 +72,7 @@ func update(f *flags.Update) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func updateToVersion(targetVersion *github.SemanticVersion, force bool, currentVersion string) error {
|
func updateToVersion(targetVersion *github.SemanticVersion, force bool, currentVersion string) error {
|
||||||
|
targetVersionString := "v" + targetVersion.String()
|
||||||
var targetVersionString = "v" + targetVersion.String()
|
|
||||||
|
|
||||||
if targetVersionString == currentVersion {
|
if targetVersionString == currentVersion {
|
||||||
pterm.Println("\nLooks like you're up to date!")
|
pterm.Println("\nLooks like you're up to date!")
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
module changeme
|
module changeme
|
||||||
|
|
||||||
go 1.18
|
go 1.21
|
||||||
|
|
||||||
|
toolchain go1.21.0
|
||||||
|
|
||||||
require github.com/wailsapp/wails/v2 v2.1.0
|
require github.com/wailsapp/wails/v2 v2.1.0
|
||||||
|
|
||||||
@ -24,7 +26,7 @@ require (
|
|||||||
github.com/tkrajina/go-reflector v0.5.6 // indirect
|
github.com/tkrajina/go-reflector v0.5.6 // indirect
|
||||||
github.com/valyala/bytebufferpool v1.0.0 // indirect
|
github.com/valyala/bytebufferpool v1.0.0 // indirect
|
||||||
github.com/valyala/fasttemplate v1.2.2 // indirect
|
github.com/valyala/fasttemplate v1.2.2 // indirect
|
||||||
github.com/wailsapp/go-webview2 v1.0.7 // indirect
|
github.com/wailsapp/go-webview2 v1.0.10 // indirect
|
||||||
github.com/wailsapp/mimetype v1.4.1 // indirect
|
github.com/wailsapp/mimetype v1.4.1 // indirect
|
||||||
golang.org/x/crypto v0.14.0 // indirect
|
golang.org/x/crypto v0.14.0 // indirect
|
||||||
golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 // indirect
|
golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 // indirect
|
||||||
|
@ -56,6 +56,7 @@ github.com/valyala/fasttemplate v1.2.2 h1:lxLXG0uE3Qnshl9QyaK6XJxMXlQZELvChBOCmQ
|
|||||||
github.com/valyala/fasttemplate v1.2.2/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ=
|
github.com/valyala/fasttemplate v1.2.2/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ=
|
||||||
github.com/wailsapp/go-webview2 v1.0.7 h1:s95+7irJsAsTy1RsjJ6N0cYX7tZ4gP7Uzawds0L2urs=
|
github.com/wailsapp/go-webview2 v1.0.7 h1:s95+7irJsAsTy1RsjJ6N0cYX7tZ4gP7Uzawds0L2urs=
|
||||||
github.com/wailsapp/go-webview2 v1.0.7/go.mod h1:Uk2BePfCRzttBBjFrBmqKGJd41P6QIHeV9kTgIeOZNo=
|
github.com/wailsapp/go-webview2 v1.0.7/go.mod h1:Uk2BePfCRzttBBjFrBmqKGJd41P6QIHeV9kTgIeOZNo=
|
||||||
|
github.com/wailsapp/go-webview2 v1.0.10/go.mod h1:Uk2BePfCRzttBBjFrBmqKGJd41P6QIHeV9kTgIeOZNo=
|
||||||
github.com/wailsapp/mimetype v1.4.1 h1:pQN9ycO7uo4vsUUuPeHEYoUkLVkaRntMnHJxVwYhwHs=
|
github.com/wailsapp/mimetype v1.4.1 h1:pQN9ycO7uo4vsUUuPeHEYoUkLVkaRntMnHJxVwYhwHs=
|
||||||
github.com/wailsapp/mimetype v1.4.1/go.mod h1:9aV5k31bBOv5z6u+QP8TltzvNGJPmNJD4XlAL3U+j3o=
|
github.com/wailsapp/mimetype v1.4.1/go.mod h1:9aV5k31bBOv5z6u+QP8TltzvNGJPmNJD4XlAL3U+j3o=
|
||||||
golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc=
|
golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc=
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
module github.com/wailsapp/wails/v2
|
module github.com/wailsapp/wails/v2
|
||||||
|
|
||||||
go 1.18
|
go 1.21
|
||||||
|
|
||||||
|
toolchain go1.21.0
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/Masterminds/semver v1.5.0
|
github.com/Masterminds/semver v1.5.0
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
package app
|
package app
|
||||||
|
|
||||||
|
// IsDevtoolsEnabled returns true if devtools should be enabled
|
||||||
// Note: devtools flag is also added in debug builds
|
// Note: devtools flag is also added in debug builds
|
||||||
func IsDevtoolsEnabled() bool {
|
func IsDevtoolsEnabled() bool {
|
||||||
return false
|
return false
|
||||||
|
4
v2/internal/binding/binding.go
Executable file → Normal file
4
v2/internal/binding/binding.go
Executable file → Normal file
@ -60,7 +60,6 @@ func NewBindings(logger *logger.Logger, structPointersToBind []interface{}, exem
|
|||||||
|
|
||||||
// Add the given struct methods to the Bindings
|
// Add the given struct methods to the Bindings
|
||||||
func (b *Bindings) Add(structPtr interface{}) error {
|
func (b *Bindings) Add(structPtr interface{}) error {
|
||||||
|
|
||||||
methods, err := b.getMethods(structPtr)
|
methods, err := b.getMethods(structPtr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("cannot bind value to app: %s", err.Error())
|
return fmt.Errorf("cannot bind value to app: %s", err.Error())
|
||||||
@ -146,7 +145,6 @@ func (b *Bindings) GenerateModels() ([]byte, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (b *Bindings) WriteModels(modelsDir string) error {
|
func (b *Bindings) WriteModels(modelsDir string) error {
|
||||||
|
|
||||||
modelsData, err := b.GenerateModels()
|
modelsData, err := b.GenerateModels()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -157,7 +155,7 @@ func (b *Bindings) WriteModels(modelsDir string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
filename := filepath.Join(modelsDir, "models.ts")
|
filename := filepath.Join(modelsDir, "models.ts")
|
||||||
err = os.WriteFile(filename, modelsData, 0755)
|
err = os.WriteFile(filename, modelsData, 0o755)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,6 @@ func (b *BoundMethod) OutputCount() int {
|
|||||||
|
|
||||||
// ParseArgs method converts the input json into the types expected by the method
|
// ParseArgs method converts the input json into the types expected by the method
|
||||||
func (b *BoundMethod) ParseArgs(args []json.RawMessage) ([]interface{}, error) {
|
func (b *BoundMethod) ParseArgs(args []json.RawMessage) ([]interface{}, error) {
|
||||||
|
|
||||||
result := make([]interface{}, b.InputCount())
|
result := make([]interface{}, b.InputCount())
|
||||||
if len(args) != b.InputCount() {
|
if len(args) != b.InputCount() {
|
||||||
return nil, fmt.Errorf("received %d arguments to method '%s', expected %d", len(args), b.Name, b.InputCount())
|
return nil, fmt.Errorf("received %d arguments to method '%s', expected %d", len(args), b.Name, b.InputCount())
|
||||||
|
@ -34,7 +34,6 @@ func newDB() *DB {
|
|||||||
// GetMethodFromStore returns the method for the given package/struct/method names
|
// GetMethodFromStore returns the method for the given package/struct/method names
|
||||||
// nil is returned if any one of those does not exist
|
// nil is returned if any one of those does not exist
|
||||||
func (d *DB) GetMethodFromStore(packageName string, structName string, methodName string) *BoundMethod {
|
func (d *DB) GetMethodFromStore(packageName string, structName string, methodName string) *BoundMethod {
|
||||||
|
|
||||||
// Lock the db whilst processing and unlock on return
|
// Lock the db whilst processing and unlock on return
|
||||||
d.lock.RLock()
|
d.lock.RLock()
|
||||||
defer d.lock.RUnlock()
|
defer d.lock.RUnlock()
|
||||||
@ -53,7 +52,6 @@ func (d *DB) GetMethodFromStore(packageName string, structName string, methodNam
|
|||||||
// GetMethod returns the method for the given qualified method name
|
// GetMethod returns the method for the given qualified method name
|
||||||
// qualifiedMethodName is "packagename.structname.methodname"
|
// qualifiedMethodName is "packagename.structname.methodname"
|
||||||
func (d *DB) GetMethod(qualifiedMethodName string) *BoundMethod {
|
func (d *DB) GetMethod(qualifiedMethodName string) *BoundMethod {
|
||||||
|
|
||||||
// Lock the db whilst processing and unlock on return
|
// Lock the db whilst processing and unlock on return
|
||||||
d.lock.RLock()
|
d.lock.RLock()
|
||||||
defer d.lock.RUnlock()
|
defer d.lock.RUnlock()
|
||||||
@ -72,7 +70,6 @@ func (d *DB) GetObfuscatedMethod(id int) *BoundMethod {
|
|||||||
|
|
||||||
// AddMethod adds the given method definition to the db using the given qualified path: packageName.structName.methodName
|
// AddMethod adds the given method definition to the db using the given qualified path: packageName.structName.methodName
|
||||||
func (d *DB) AddMethod(packageName string, structName string, methodName string, methodDefinition *BoundMethod) {
|
func (d *DB) AddMethod(packageName string, structName string, methodName string, methodDefinition *BoundMethod) {
|
||||||
|
|
||||||
// Lock the db whilst processing and unlock on return
|
// Lock the db whilst processing and unlock on return
|
||||||
d.lock.Lock()
|
d.lock.Lock()
|
||||||
defer d.lock.Unlock()
|
defer d.lock.Unlock()
|
||||||
@ -99,12 +96,10 @@ func (d *DB) AddMethod(packageName string, structName string, methodName string,
|
|||||||
// Store in the methodMap
|
// Store in the methodMap
|
||||||
key := packageName + "." + structName + "." + methodName
|
key := packageName + "." + structName + "." + methodName
|
||||||
d.methodMap[key] = methodDefinition
|
d.methodMap[key] = methodDefinition
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToJSON converts the method map to JSON
|
// ToJSON converts the method map to JSON
|
||||||
func (d *DB) ToJSON() (string, error) {
|
func (d *DB) ToJSON() (string, error) {
|
||||||
|
|
||||||
// Lock the db whilst processing and unlock on return
|
// Lock the db whilst processing and unlock on return
|
||||||
d.lock.RLock()
|
d.lock.RLock()
|
||||||
defer d.lock.RUnlock()
|
defer d.lock.RUnlock()
|
||||||
@ -120,8 +115,7 @@ func (d *DB) ToJSON() (string, error) {
|
|||||||
|
|
||||||
// UpdateObfuscatedCallMap sets up the secure call mappings
|
// UpdateObfuscatedCallMap sets up the secure call mappings
|
||||||
func (d *DB) UpdateObfuscatedCallMap() map[string]int {
|
func (d *DB) UpdateObfuscatedCallMap() map[string]int {
|
||||||
|
mappings := make(map[string]int)
|
||||||
var mappings = make(map[string]int)
|
|
||||||
|
|
||||||
// Iterate map keys and sort them
|
// Iterate map keys and sort them
|
||||||
keys := make([]string, 0, len(d.methodMap))
|
keys := make([]string, 0, len(d.methodMap))
|
||||||
|
@ -15,12 +15,14 @@ import (
|
|||||||
"github.com/leaanthony/slicer"
|
"github.com/leaanthony/slicer"
|
||||||
)
|
)
|
||||||
|
|
||||||
var mapRegex *regexp.Regexp
|
var (
|
||||||
var keyPackageIndex int
|
mapRegex *regexp.Regexp
|
||||||
var keyTypeIndex int
|
keyPackageIndex int
|
||||||
var valueArrayIndex int
|
keyTypeIndex int
|
||||||
var valuePackageIndex int
|
valueArrayIndex int
|
||||||
var valueTypeIndex int
|
valuePackageIndex int
|
||||||
|
valueTypeIndex int
|
||||||
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
mapRegex = regexp.MustCompile(`(?:map\[(?:(?P<keyPackage>\w+)\.)?(?P<keyType>\w+)])?(?P<valueArray>\[])?(?:\*?(?P<valuePackage>\w+)\.)?(?P<valueType>.+)`)
|
mapRegex = regexp.MustCompile(`(?:map\[(?:(?P<keyPackage>\w+)\.)?(?P<keyType>\w+)])?(?P<valueArray>\[])?(?:\*?(?P<valuePackage>\w+)\.)?(?P<valueType>.+)`)
|
||||||
@ -81,9 +83,7 @@ func (b *Bindings) GenerateGoBindings(baseDir string) error {
|
|||||||
} else {
|
} else {
|
||||||
jsoutput.WriteString(fmt.Sprintf(" return window['go']['%s']['%s']['%s'](%s);", packageName, structName, methodName, argsString))
|
jsoutput.WriteString(fmt.Sprintf(" return window['go']['%s']['%s']['%s'](%s);", packageName, structName, methodName, argsString))
|
||||||
}
|
}
|
||||||
jsoutput.WriteString("\n")
|
jsoutput.WriteString("\n}\n")
|
||||||
jsoutput.WriteString(fmt.Sprintf("}"))
|
|
||||||
jsoutput.WriteString("\n")
|
|
||||||
|
|
||||||
// Generate TS
|
// Generate TS
|
||||||
tsBody.WriteString(fmt.Sprintf("\nexport function %s(", methodName))
|
tsBody.WriteString(fmt.Sprintf("\nexport function %s(", methodName))
|
||||||
@ -127,12 +127,12 @@ func (b *Bindings) GenerateGoBindings(baseDir string) error {
|
|||||||
tsContent.WriteString(tsBody.String())
|
tsContent.WriteString(tsBody.String())
|
||||||
|
|
||||||
jsfilename := filepath.Join(packageDir, structName+".js")
|
jsfilename := filepath.Join(packageDir, structName+".js")
|
||||||
err = os.WriteFile(jsfilename, jsoutput.Bytes(), 0755)
|
err = os.WriteFile(jsfilename, jsoutput.Bytes(), 0o755)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
tsfilename := filepath.Join(packageDir, structName+".d.ts")
|
tsfilename := filepath.Join(packageDir, structName+".d.ts")
|
||||||
err = os.WriteFile(tsfilename, tsContent.Bytes(), 0755)
|
err = os.WriteFile(tsfilename, tsContent.Bytes(), 0o755)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
2
v2/internal/binding/reflect.go
Executable file → Normal file
2
v2/internal/binding/reflect.go
Executable file → Normal file
@ -25,7 +25,6 @@ func isStruct(value interface{}) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (b *Bindings) getMethods(value interface{}) ([]*BoundMethod, error) {
|
func (b *Bindings) getMethods(value interface{}) ([]*BoundMethod, error) {
|
||||||
|
|
||||||
// Create result placeholder
|
// Create result placeholder
|
||||||
var result []*BoundMethod
|
var result []*BoundMethod
|
||||||
|
|
||||||
@ -169,7 +168,6 @@ func getPackageName(in string) string {
|
|||||||
func getSplitReturn(in string) (string, string) {
|
func getSplitReturn(in string) (string, string) {
|
||||||
result := strings.Split(in, ".")
|
result := strings.Split(in, ".")
|
||||||
return result[0], result[1]
|
return result[0], result[1]
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func hasElements(typ reflect.Type) bool {
|
func hasElements(typ reflect.Type) bool {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
package frontend
|
package frontend
|
||||||
|
|
||||||
type Calls interface {
|
type Calls interface {
|
||||||
Callback(string)
|
Callback(message string)
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@ package darwin
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
*/
|
*/
|
||||||
import "C"
|
import "C"
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"strconv"
|
"strconv"
|
||||||
@ -20,7 +21,6 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (f *Frontend) handleCallback(menuItemID uint) error {
|
func (f *Frontend) handleCallback(menuItemID uint) error {
|
||||||
|
|
||||||
menuItem := getMenuItemForID(menuItemID)
|
menuItem := getMenuItemForID(menuItemID)
|
||||||
if menuItem == nil {
|
if menuItem == nil {
|
||||||
return errors.New("unknown menuItem ID: " + strconv.Itoa(int(menuItemID)))
|
return errors.New("unknown menuItem ID: " + strconv.Itoa(int(menuItemID)))
|
||||||
|
@ -16,7 +16,6 @@ func (f *Frontend) ClipboardGetText() (string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (f *Frontend) ClipboardSetText(text string) error {
|
func (f *Frontend) ClipboardSetText(text string) error {
|
||||||
|
|
||||||
copyCmd := exec.Command("pbcopy")
|
copyCmd := exec.Command("pbcopy")
|
||||||
in, err := copyCmd.StdinPipe()
|
in, err := copyCmd.StdinPipe()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -11,6 +11,7 @@ package darwin
|
|||||||
#import "WailsContext.h"
|
#import "WailsContext.h"
|
||||||
*/
|
*/
|
||||||
import "C"
|
import "C"
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
@ -23,10 +24,12 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// Obj-C dialog methods send the response to this channel
|
// Obj-C dialog methods send the response to this channel
|
||||||
var messageDialogResponse = make(chan int)
|
var (
|
||||||
var openFileDialogResponse = make(chan string)
|
messageDialogResponse = make(chan int)
|
||||||
var saveFileDialogResponse = make(chan string)
|
openFileDialogResponse = make(chan string)
|
||||||
var dialogLock sync.Mutex
|
saveFileDialogResponse = make(chan string)
|
||||||
|
dialogLock sync.Mutex
|
||||||
|
)
|
||||||
|
|
||||||
// OpenDirectoryDialog prompts the user to select a directory
|
// OpenDirectoryDialog prompts the user to select a directory
|
||||||
func (f *Frontend) OpenDirectoryDialog(options frontend.OpenDialogOptions) (string, error) {
|
func (f *Frontend) OpenDirectoryDialog(options frontend.OpenDialogOptions) (string, error) {
|
||||||
@ -74,7 +77,7 @@ func (f *Frontend) openDialog(options *frontend.OpenDialogOptions, multiple bool
|
|||||||
filters := filterStrings.Join(";")
|
filters := filterStrings.Join(";")
|
||||||
C.OpenFileDialog(f.mainWindow.context, title, defaultFilename, defaultDirectory, allowDirectories, allowFiles, canCreateDirectories, treatPackagesAsDirectories, resolveAliases, showHiddenFiles, allowMultipleFileSelection, c.String(filters))
|
C.OpenFileDialog(f.mainWindow.context, title, defaultFilename, defaultDirectory, allowDirectories, allowFiles, canCreateDirectories, treatPackagesAsDirectories, resolveAliases, showHiddenFiles, allowMultipleFileSelection, c.String(filters))
|
||||||
|
|
||||||
var result = <-openFileDialogResponse
|
result := <-openFileDialogResponse
|
||||||
|
|
||||||
var parsedResults []string
|
var parsedResults []string
|
||||||
err := json.Unmarshal([]byte(result), &parsedResults)
|
err := json.Unmarshal([]byte(result), &parsedResults)
|
||||||
@ -130,7 +133,7 @@ func (f *Frontend) SaveFileDialog(options frontend.SaveDialogOptions) (string, e
|
|||||||
filters := filterStrings.Join(";")
|
filters := filterStrings.Join(";")
|
||||||
C.SaveFileDialog(f.mainWindow.context, title, defaultFilename, defaultDirectory, canCreateDirectories, treatPackagesAsDirectories, showHiddenFiles, c.String(filters))
|
C.SaveFileDialog(f.mainWindow.context, title, defaultFilename, defaultDirectory, canCreateDirectories, treatPackagesAsDirectories, showHiddenFiles, c.String(filters))
|
||||||
|
|
||||||
var result = <-saveFileDialogResponse
|
result := <-saveFileDialogResponse
|
||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
@ -165,7 +168,7 @@ func (f *Frontend) MessageDialog(options frontend.MessageDialogOptions) (string,
|
|||||||
|
|
||||||
C.MessageDialog(f.mainWindow.context, dialogType, title, message, buttons[0], buttons[1], buttons[2], buttons[3], defaultButton, cancelButton, iconData, iconDataLength)
|
C.MessageDialog(f.mainWindow.context, dialogType, title, message, buttons[0], buttons[1], buttons[2], buttons[3], defaultButton, cancelButton, iconData, iconDataLength)
|
||||||
|
|
||||||
var result = <-messageDialogResponse
|
result := <-messageDialogResponse
|
||||||
|
|
||||||
selectedC := buttons[result]
|
selectedC := buttons[result]
|
||||||
var selected string
|
var selected string
|
||||||
|
@ -14,6 +14,7 @@ package darwin
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
*/
|
*/
|
||||||
import "C"
|
import "C"
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
@ -36,15 +37,16 @@ import (
|
|||||||
|
|
||||||
const startURL = "wails://wails/"
|
const startURL = "wails://wails/"
|
||||||
|
|
||||||
var messageBuffer = make(chan string, 100)
|
var (
|
||||||
var requestBuffer = make(chan webview.Request, 100)
|
messageBuffer = make(chan string, 100)
|
||||||
var callbackBuffer = make(chan uint, 10)
|
requestBuffer = make(chan webview.Request, 100)
|
||||||
var openFilepathBuffer = make(chan string, 100)
|
callbackBuffer = make(chan uint, 10)
|
||||||
var openUrlBuffer = make(chan string, 100)
|
openFilepathBuffer = make(chan string, 100)
|
||||||
var secondInstanceBuffer = make(chan options.SecondInstanceData, 1)
|
openUrlBuffer = make(chan string, 100)
|
||||||
|
secondInstanceBuffer = make(chan options.SecondInstanceData, 1)
|
||||||
|
)
|
||||||
|
|
||||||
type Frontend struct {
|
type Frontend struct {
|
||||||
|
|
||||||
// Context
|
// Context
|
||||||
ctx context.Context
|
ctx context.Context
|
||||||
|
|
||||||
@ -153,6 +155,7 @@ func (f *Frontend) startRequestProcessor() {
|
|||||||
f.assets.ServeWebViewRequest(request)
|
f.assets.ServeWebViewRequest(request)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *Frontend) startCallbackProcessor() {
|
func (f *Frontend) startCallbackProcessor() {
|
||||||
for callback := range callbackBuffer {
|
for callback := range callbackBuffer {
|
||||||
err := f.handleCallback(callback)
|
err := f.handleCallback(callback)
|
||||||
@ -171,15 +174,12 @@ func (f *Frontend) WindowReloadApp() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (f *Frontend) WindowSetSystemDefaultTheme() {
|
func (f *Frontend) WindowSetSystemDefaultTheme() {
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *Frontend) WindowSetLightTheme() {
|
func (f *Frontend) WindowSetLightTheme() {
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *Frontend) WindowSetDarkTheme() {
|
func (f *Frontend) WindowSetDarkTheme() {
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *Frontend) Run(ctx context.Context) error {
|
func (f *Frontend) Run(ctx context.Context) error {
|
||||||
@ -189,8 +189,8 @@ func (f *Frontend) Run(ctx context.Context) error {
|
|||||||
SetupSingleInstance(f.frontendOptions.SingleInstanceLock.UniqueId)
|
SetupSingleInstance(f.frontendOptions.SingleInstanceLock.UniqueId)
|
||||||
}
|
}
|
||||||
|
|
||||||
var _debug = ctx.Value("debug")
|
_debug := ctx.Value("debug")
|
||||||
var _devtoolsEnabled = ctx.Value("devtoolsEnabled")
|
_devtoolsEnabled := ctx.Value("devtoolsEnabled")
|
||||||
|
|
||||||
if _debug != nil {
|
if _debug != nil {
|
||||||
f.debug = _debug.(bool)
|
f.debug = _debug.(bool)
|
||||||
@ -215,6 +215,7 @@ func (f *Frontend) Run(ctx context.Context) error {
|
|||||||
func (f *Frontend) WindowCenter() {
|
func (f *Frontend) WindowCenter() {
|
||||||
f.mainWindow.Center()
|
f.mainWindow.Center()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *Frontend) WindowSetAlwaysOnTop(onTop bool) {
|
func (f *Frontend) WindowSetAlwaysOnTop(onTop bool) {
|
||||||
f.mainWindow.SetAlwaysOnTop(onTop)
|
f.mainWindow.SetAlwaysOnTop(onTop)
|
||||||
}
|
}
|
||||||
@ -222,6 +223,7 @@ func (f *Frontend) WindowSetAlwaysOnTop(onTop bool) {
|
|||||||
func (f *Frontend) WindowSetPosition(x, y int) {
|
func (f *Frontend) WindowSetPosition(x, y int) {
|
||||||
f.mainWindow.SetPosition(x, y)
|
f.mainWindow.SetPosition(x, y)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *Frontend) WindowGetPosition() (int, int) {
|
func (f *Frontend) WindowGetPosition() (int, int) {
|
||||||
return f.mainWindow.GetPosition()
|
return f.mainWindow.GetPosition()
|
||||||
}
|
}
|
||||||
@ -253,6 +255,7 @@ func (f *Frontend) WindowShow() {
|
|||||||
func (f *Frontend) WindowHide() {
|
func (f *Frontend) WindowHide() {
|
||||||
f.mainWindow.Hide()
|
f.mainWindow.Hide()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *Frontend) Show() {
|
func (f *Frontend) Show() {
|
||||||
f.mainWindow.ShowApplication()
|
f.mainWindow.ShowApplication()
|
||||||
}
|
}
|
||||||
@ -260,18 +263,23 @@ func (f *Frontend) Show() {
|
|||||||
func (f *Frontend) Hide() {
|
func (f *Frontend) Hide() {
|
||||||
f.mainWindow.HideApplication()
|
f.mainWindow.HideApplication()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *Frontend) WindowMaximise() {
|
func (f *Frontend) WindowMaximise() {
|
||||||
f.mainWindow.Maximise()
|
f.mainWindow.Maximise()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *Frontend) WindowToggleMaximise() {
|
func (f *Frontend) WindowToggleMaximise() {
|
||||||
f.mainWindow.ToggleMaximise()
|
f.mainWindow.ToggleMaximise()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *Frontend) WindowUnmaximise() {
|
func (f *Frontend) WindowUnmaximise() {
|
||||||
f.mainWindow.UnMaximise()
|
f.mainWindow.UnMaximise()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *Frontend) WindowMinimise() {
|
func (f *Frontend) WindowMinimise() {
|
||||||
f.mainWindow.Minimise()
|
f.mainWindow.Minimise()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *Frontend) WindowUnminimise() {
|
func (f *Frontend) WindowUnminimise() {
|
||||||
f.mainWindow.UnMinimise()
|
f.mainWindow.UnMinimise()
|
||||||
}
|
}
|
||||||
@ -279,6 +287,7 @@ func (f *Frontend) WindowUnminimise() {
|
|||||||
func (f *Frontend) WindowSetMinSize(width int, height int) {
|
func (f *Frontend) WindowSetMinSize(width int, height int) {
|
||||||
f.mainWindow.SetMinSize(width, height)
|
f.mainWindow.SetMinSize(width, height)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *Frontend) WindowSetMaxSize(width int, height int) {
|
func (f *Frontend) WindowSetMaxSize(width int, height int) {
|
||||||
f.mainWindow.SetMaxSize(width, height)
|
f.mainWindow.SetMaxSize(width, height)
|
||||||
}
|
}
|
||||||
@ -345,7 +354,6 @@ func (f *Frontend) Notify(name string, data ...interface{}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (f *Frontend) processMessage(message string) {
|
func (f *Frontend) processMessage(message string) {
|
||||||
|
|
||||||
if message == "DomReady" {
|
if message == "DomReady" {
|
||||||
if f.frontendOptions.OnDomReady != nil {
|
if f.frontendOptions.OnDomReady != nil {
|
||||||
f.frontendOptions.OnDomReady(f.ctx)
|
f.frontendOptions.OnDomReady(f.ctx)
|
||||||
@ -388,7 +396,6 @@ func (f *Frontend) processMessage(message string) {
|
|||||||
f.logger.Info("Unknown message returned from dispatcher: %+v", result)
|
f.logger.Info("Unknown message returned from dispatcher: %+v", result)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *Frontend) ProcessOpenFileEvent(filePath string) {
|
func (f *Frontend) ProcessOpenFileEvent(filePath string) {
|
||||||
|
@ -7,5 +7,4 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func showInspector(_ unsafe.Pointer) {
|
func showInspector(_ unsafe.Pointer) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@ package darwin
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
*/
|
*/
|
||||||
import "C"
|
import "C"
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
@ -122,7 +123,6 @@ func processMenuItem(parent *NSMenu, menuItem *menu.MenuItem) *MenuItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return parent.AddMenuItem(menuItem)
|
return parent.AddMenuItem(menuItem)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *Frontend) MenuSetApplicationMenu(menu *menu.Menu) {
|
func (f *Frontend) MenuSetApplicationMenu(menu *menu.Menu) {
|
||||||
|
@ -13,16 +13,19 @@ package darwin
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
*/
|
*/
|
||||||
import "C"
|
import "C"
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
"math"
|
"math"
|
||||||
"sync"
|
"sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
var menuItemToID = make(map[*MenuItem]uint)
|
var (
|
||||||
var idToMenuItem = make(map[uint]*MenuItem)
|
menuItemToID = make(map[*MenuItem]uint)
|
||||||
var menuItemLock sync.Mutex
|
idToMenuItem = make(map[uint]*MenuItem)
|
||||||
var menuItemIDCounter uint = 0
|
menuItemLock sync.Mutex
|
||||||
|
menuItemIDCounter uint = 0
|
||||||
|
)
|
||||||
|
|
||||||
func createMenuItemID(item *MenuItem) uint {
|
func createMenuItemID(item *MenuItem) uint {
|
||||||
menuItemLock.Lock()
|
menuItemLock.Lock()
|
||||||
|
@ -82,6 +82,7 @@ Screen GetNthScreen(int nth, void *inctx){
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
import "C"
|
import "C"
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
|
@ -10,21 +10,22 @@ package darwin
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
import "C"
|
import "C"
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/wailsapp/wails/v2/pkg/options"
|
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
|
"github.com/wailsapp/wails/v2/pkg/options"
|
||||||
)
|
)
|
||||||
|
|
||||||
func SetupSingleInstance(uniqueID string) {
|
func SetupSingleInstance(uniqueID string) {
|
||||||
lockFilePath := getTempDir()
|
lockFilePath := getTempDir()
|
||||||
lockFileName := uniqueID + ".lock"
|
lockFileName := uniqueID + ".lock"
|
||||||
_, err := createLockFile(lockFilePath + "/" + lockFileName)
|
_, err := createLockFile(lockFilePath + "/" + lockFileName)
|
||||||
|
|
||||||
// if lockFile exist – send notification to second instance
|
// if lockFile exist – send notification to second instance
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c := NewCalloc()
|
c := NewCalloc()
|
||||||
@ -63,7 +64,7 @@ func HandleSecondInstanceData(secondInstanceMessage *C.char) {
|
|||||||
// exclusive lock on it. If the file already exists AND is still locked, it will
|
// exclusive lock on it. If the file already exists AND is still locked, it will
|
||||||
// fail.
|
// fail.
|
||||||
func createLockFile(filename string) (*os.File, error) {
|
func createLockFile(filename string) (*os.File, error) {
|
||||||
file, err := os.OpenFile(filename, os.O_WRONLY|os.O_CREATE, 0600)
|
file, err := os.OpenFile(filename, os.O_WRONLY|os.O_CREATE, 0o600)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("Failed to open lockfile %s: %s", filename, err)
|
fmt.Printf("Failed to open lockfile %s: %s", filename, err)
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -13,6 +13,7 @@ package darwin
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
*/
|
*/
|
||||||
import "C"
|
import "C"
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
"runtime"
|
"runtime"
|
||||||
@ -46,7 +47,6 @@ func bool2CboolPtr(value bool) *C.bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewWindow(frontendOptions *options.App, debug bool, devtools bool) *Window {
|
func NewWindow(frontendOptions *options.App, debug bool, devtools bool) *Window {
|
||||||
|
|
||||||
c := NewCalloc()
|
c := NewCalloc()
|
||||||
defer c.Free()
|
defer c.Free()
|
||||||
|
|
||||||
@ -196,6 +196,7 @@ func (w *Window) SetTitle(title string) {
|
|||||||
func (w *Window) Maximise() {
|
func (w *Window) Maximise() {
|
||||||
C.Maximise(w.context)
|
C.Maximise(w.context)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *Window) ToggleMaximise() {
|
func (w *Window) ToggleMaximise() {
|
||||||
C.ToggleMaximise(w.context)
|
C.ToggleMaximise(w.context)
|
||||||
}
|
}
|
||||||
@ -251,6 +252,7 @@ func (w *Window) Show() {
|
|||||||
func (w *Window) Hide() {
|
func (w *Window) Hide() {
|
||||||
C.Hide(w.context)
|
C.Hide(w.context)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *Window) ShowApplication() {
|
func (w *Window) ShowApplication() {
|
||||||
C.ShowApplication(w.context)
|
C.ShowApplication(w.context)
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ func (f *Frontend) OpenDirectoryDialog(options frontend.OpenDialogOptions) (stri
|
|||||||
return cfd.NewSelectFolderDialog(config)
|
return cfd.NewSelectFolderDialog(config)
|
||||||
}, false)
|
}, false)
|
||||||
|
|
||||||
if err != nil && err != cfd.ErrorCancelled {
|
if err != nil && err != cfd.ErrCancelled {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
return result.(string), nil
|
return result.(string), nil
|
||||||
@ -72,7 +72,7 @@ func (f *Frontend) OpenFileDialog(options frontend.OpenDialogOptions) (string, e
|
|||||||
return cfd.NewOpenFileDialog(config)
|
return cfd.NewOpenFileDialog(config)
|
||||||
}, false)
|
}, false)
|
||||||
|
|
||||||
if err != nil && err != cfd.ErrorCancelled {
|
if err != nil && err != cfd.ErrCancelled {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
return result.(string), nil
|
return result.(string), nil
|
||||||
@ -99,7 +99,7 @@ func (f *Frontend) OpenMultipleFilesDialog(options frontend.OpenDialogOptions) (
|
|||||||
return cfd.NewOpenMultipleFilesDialog(config)
|
return cfd.NewOpenMultipleFilesDialog(config)
|
||||||
}, true)
|
}, true)
|
||||||
|
|
||||||
if err != nil && err != cfd.ErrorCancelled {
|
if err != nil && err != cfd.ErrCancelled {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return result.([]string), nil
|
return result.([]string), nil
|
||||||
@ -126,7 +126,7 @@ func (f *Frontend) SaveFileDialog(options frontend.SaveDialogOptions) (string, e
|
|||||||
return cfd.NewSaveFileDialog(config)
|
return cfd.NewSaveFileDialog(config)
|
||||||
}, false)
|
}, false)
|
||||||
|
|
||||||
if err != nil && err != cfd.ErrorCancelled {
|
if err != nil && err != cfd.ErrCancelled {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
return result.(string), nil
|
return result.(string), nil
|
||||||
|
@ -15,7 +15,6 @@ type callMessage struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (d *Dispatcher) processCallMessage(message string, sender frontend.Frontend) (string, error) {
|
func (d *Dispatcher) processCallMessage(message string, sender frontend.Frontend) (string, error) {
|
||||||
|
|
||||||
var payload callMessage
|
var payload callMessage
|
||||||
err := json.Unmarshal([]byte(message[1:]), &payload)
|
err := json.Unmarshal([]byte(message[1:]), &payload)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -3,6 +3,7 @@ package dispatcher
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
"github.com/wailsapp/wails/v2/internal/frontend"
|
"github.com/wailsapp/wails/v2/internal/frontend"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ package dispatcher
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/wailsapp/wails/v2/internal/frontend"
|
"github.com/wailsapp/wails/v2/internal/frontend"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -13,7 +14,6 @@ type secureCallMessage struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (d *Dispatcher) processSecureCallMessage(message string, sender frontend.Frontend) (string, error) {
|
func (d *Dispatcher) processSecureCallMessage(message string, sender frontend.Frontend) (string, error) {
|
||||||
|
|
||||||
var payload secureCallMessage
|
var payload secureCallMessage
|
||||||
err := json.Unmarshal([]byte(message[1:]), &payload)
|
err := json.Unmarshal([]byte(message[1:]), &payload)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -4,9 +4,10 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/wailsapp/wails/v2/pkg/runtime"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/wailsapp/wails/v2/pkg/runtime"
|
||||||
|
|
||||||
"github.com/wailsapp/wails/v2/internal/frontend"
|
"github.com/wailsapp/wails/v2/internal/frontend"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -23,7 +24,6 @@ type size struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (d *Dispatcher) processSystemCall(payload callMessage, sender frontend.Frontend) (interface{}, error) {
|
func (d *Dispatcher) processSystemCall(payload callMessage, sender frontend.Frontend) (interface{}, error) {
|
||||||
|
|
||||||
// Strip prefix
|
// Strip prefix
|
||||||
name := strings.TrimPrefix(payload.Name, systemCallPrefix)
|
name := strings.TrimPrefix(payload.Name, systemCallPrefix)
|
||||||
|
|
||||||
@ -64,5 +64,4 @@ func (d *Dispatcher) processSystemCall(payload callMessage, sender frontend.Fron
|
|||||||
default:
|
default:
|
||||||
return nil, fmt.Errorf("unknown systemcall message: %s", payload.Name)
|
return nil, fmt.Errorf("unknown systemcall message: %s", payload.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,7 @@ type MessageDialogOptions struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Frontend interface {
|
type Frontend interface {
|
||||||
Run(context.Context) error
|
Run(ctx context.Context) error
|
||||||
RunMainLoop()
|
RunMainLoop()
|
||||||
ExecJS(js string)
|
ExecJS(js string)
|
||||||
Hide()
|
Hide()
|
||||||
|
@ -143,7 +143,7 @@ func (e *Events) notifyBackend(eventName string, data ...interface{}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Do we have items to delete?
|
// Do we have items to delete?
|
||||||
if itemsToDelete == true {
|
if itemsToDelete {
|
||||||
|
|
||||||
// Create a new Listeners slice
|
// Create a new Listeners slice
|
||||||
var newListeners []*eventListener
|
var newListeners []*eventListener
|
||||||
|
@ -2,6 +2,7 @@ package fs
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/md5"
|
"crypto/md5"
|
||||||
|
"encoding/hex"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/fs"
|
"io/fs"
|
||||||
@ -27,14 +28,14 @@ func RelativeToCwd(relativePath string) (string, error) {
|
|||||||
|
|
||||||
// Mkdir will create the given directory
|
// Mkdir will create the given directory
|
||||||
func Mkdir(dirname string) error {
|
func Mkdir(dirname string) error {
|
||||||
return os.Mkdir(dirname, 0755)
|
return os.Mkdir(dirname, 0o755)
|
||||||
}
|
}
|
||||||
|
|
||||||
// MkDirs creates the given nested directories.
|
// MkDirs creates the given nested directories.
|
||||||
// Returns error on failure
|
// Returns error on failure
|
||||||
func MkDirs(fullPath string, mode ...os.FileMode) error {
|
func MkDirs(fullPath string, mode ...os.FileMode) error {
|
||||||
var perms os.FileMode
|
var perms os.FileMode
|
||||||
perms = 0755
|
perms = 0o755
|
||||||
if len(mode) == 1 {
|
if len(mode) == 1 {
|
||||||
perms = mode[0]
|
perms = mode[0]
|
||||||
}
|
}
|
||||||
@ -111,7 +112,7 @@ func RelativePath(relativepath string, optionalpaths ...string) string {
|
|||||||
// I'm allowing this for 1 reason only: It's fatal if the path
|
// I'm allowing this for 1 reason only: It's fatal if the path
|
||||||
// supplied is wrong as it's only used internally in Wails. If we get
|
// supplied is wrong as it's only used internally in Wails. If we get
|
||||||
// that path wrong, we should know about it immediately. The other reason is
|
// that path wrong, we should know about it immediately. The other reason is
|
||||||
// that it cuts down a ton of unnecassary error handling.
|
// that it cuts down a ton of unnecessary error handling.
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
@ -141,7 +142,7 @@ func MD5File(filename string) (string, error) {
|
|||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
return fmt.Sprintf("%x", h.Sum(nil)), nil
|
return hex.EncodeToString(h.Sum(nil)), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// MustMD5File will call MD5File and abort the program on error
|
// MustMD5File will call MD5File and abort the program on error
|
||||||
@ -157,7 +158,7 @@ func MustMD5File(filename string) string {
|
|||||||
// MustWriteString will attempt to write the given data to the given filename
|
// MustWriteString will attempt to write the given data to the given filename
|
||||||
// It will abort the program in the event of a failure
|
// It will abort the program in the event of a failure
|
||||||
func MustWriteString(filename string, data string) {
|
func MustWriteString(filename string, data string) {
|
||||||
err := os.WriteFile(filename, []byte(data), 0755)
|
err := os.WriteFile(filename, []byte(data), 0o755)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fatal("Unable to write file", filename, ":", err.Error())
|
fatal("Unable to write file", filename, ":", err.Error())
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
@ -194,7 +195,6 @@ func GetSubdirectories(rootDir string) (*slicer.StringSlicer, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func DirIsEmpty(dir string) (bool, error) {
|
func DirIsEmpty(dir string) (bool, error) {
|
||||||
|
|
||||||
// CREDIT: https://stackoverflow.com/a/30708914/8325411
|
// CREDIT: https://stackoverflow.com/a/30708914/8325411
|
||||||
f, err := os.Open(dir)
|
f, err := os.Open(dir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -284,7 +284,6 @@ func SetPermissions(dir string, perm os.FileMode) error {
|
|||||||
// Symlinks are ignored and skipped.
|
// Symlinks are ignored and skipped.
|
||||||
// Credit: https://gist.github.com/r0l1/92462b38df26839a3ca324697c8cba04
|
// Credit: https://gist.github.com/r0l1/92462b38df26839a3ca324697c8cba04
|
||||||
func CopyDirExtended(src string, dst string, ignore []string) (err error) {
|
func CopyDirExtended(src string, dst string, ignore []string) (err error) {
|
||||||
|
|
||||||
ignoreList := slicer.String(ignore)
|
ignoreList := slicer.String(ignore)
|
||||||
src = filepath.Clean(src)
|
src = filepath.Clean(src)
|
||||||
dst = filepath.Clean(dst)
|
dst = filepath.Clean(dst)
|
||||||
@ -382,7 +381,6 @@ func FindPathToFile(fsys fs.FS, file string) (string, error) {
|
|||||||
// FindFileInParents searches for a file in the current directory and all parent directories.
|
// FindFileInParents searches for a file in the current directory and all parent directories.
|
||||||
// Returns the absolute path to the file if found, otherwise an empty string
|
// Returns the absolute path to the file if found, otherwise an empty string
|
||||||
func FindFileInParents(path string, filename string) string {
|
func FindFileInParents(path string, filename string) string {
|
||||||
|
|
||||||
// Check for bad paths
|
// Check for bad paths
|
||||||
if _, err := os.Stat(path); err != nil {
|
if _, err := os.Stat(path); err != nil {
|
||||||
return ""
|
return ""
|
||||||
|
@ -3,13 +3,14 @@ package github
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/charmbracelet/glamour"
|
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"runtime"
|
"runtime"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/charmbracelet/glamour"
|
||||||
)
|
)
|
||||||
|
|
||||||
func GetReleaseNotes(tagVersion string, noColour bool) string {
|
func GetReleaseNotes(tagVersion string, noColour bool) string {
|
||||||
@ -57,7 +58,6 @@ func GetReleaseNotes(tagVersion string, noColour bool) string {
|
|||||||
// GetVersionTags gets the list of tags on the Wails repo
|
// GetVersionTags gets the list of tags on the Wails repo
|
||||||
// It returns a list of sorted tags in descending order
|
// It returns a list of sorted tags in descending order
|
||||||
func GetVersionTags() ([]*SemanticVersion, error) {
|
func GetVersionTags() ([]*SemanticVersion, error) {
|
||||||
|
|
||||||
result := []*SemanticVersion{}
|
result := []*SemanticVersion{}
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
@ -97,7 +97,6 @@ func GetVersionTags() ([]*SemanticVersion, error) {
|
|||||||
|
|
||||||
// GetLatestStableRelease gets the latest stable release on GitHub
|
// GetLatestStableRelease gets the latest stable release on GitHub
|
||||||
func GetLatestStableRelease() (result *SemanticVersion, err error) {
|
func GetLatestStableRelease() (result *SemanticVersion, err error) {
|
||||||
|
|
||||||
tags, err := GetVersionTags()
|
tags, err := GetVersionTags()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -114,7 +113,6 @@ func GetLatestStableRelease() (result *SemanticVersion, err error) {
|
|||||||
|
|
||||||
// GetLatestPreRelease gets the latest prerelease on GitHub
|
// GetLatestPreRelease gets the latest prerelease on GitHub
|
||||||
func GetLatestPreRelease() (result *SemanticVersion, err error) {
|
func GetLatestPreRelease() (result *SemanticVersion, err error) {
|
||||||
|
|
||||||
tags, err := GetVersionTags()
|
tags, err := GetVersionTags()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -5,24 +5,24 @@ package cfd
|
|||||||
|
|
||||||
import "fmt"
|
import "fmt"
|
||||||
|
|
||||||
var unsupportedError = fmt.Errorf("common file dialogs are only available on windows")
|
var errUnsupported = fmt.Errorf("common file dialogs are only available on windows")
|
||||||
|
|
||||||
// TODO doc
|
// TODO doc
|
||||||
func NewOpenFileDialog(config DialogConfig) (OpenFileDialog, error) {
|
func NewOpenFileDialog(config DialogConfig) (OpenFileDialog, error) {
|
||||||
return nil, unsupportedError
|
return nil, errUnsupported
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO doc
|
// TODO doc
|
||||||
func NewOpenMultipleFilesDialog(config DialogConfig) (OpenMultipleFilesDialog, error) {
|
func NewOpenMultipleFilesDialog(config DialogConfig) (OpenMultipleFilesDialog, error) {
|
||||||
return nil, unsupportedError
|
return nil, errUnsupported
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO doc
|
// TODO doc
|
||||||
func NewSelectFolderDialog(config DialogConfig) (SelectFolderDialog, error) {
|
func NewSelectFolderDialog(config DialogConfig) (SelectFolderDialog, error) {
|
||||||
return nil, unsupportedError
|
return nil, errUnsupported
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO doc
|
// TODO doc
|
||||||
func NewSaveFileDialog(config DialogConfig) (SaveFileDialog, error) {
|
func NewSaveFileDialog(config DialogConfig) (SaveFileDialog, error) {
|
||||||
return nil, unsupportedError
|
return nil, errUnsupported
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,4 @@ package cfd
|
|||||||
|
|
||||||
import "errors"
|
import "errors"
|
||||||
|
|
||||||
var (
|
var ErrCancelled = errors.New("cancelled by user")
|
||||||
ErrorCancelled = errors.New("cancelled by user")
|
|
||||||
)
|
|
||||||
|
@ -178,7 +178,7 @@ func (vtbl *iFileOpenDialogVtbl) getResultsStrings(objPtr unsafe.Pointer) ([]str
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if shellItemArray == nil {
|
if shellItemArray == nil {
|
||||||
return nil, ErrorCancelled
|
return nil, ErrCancelled
|
||||||
}
|
}
|
||||||
defer shellItemArray.vtbl.release(unsafe.Pointer(shellItemArray))
|
defer shellItemArray.vtbl.release(unsafe.Pointer(shellItemArray))
|
||||||
count, err := shellItemArray.vtbl.getCount(unsafe.Pointer(shellItemArray))
|
count, err := shellItemArray.vtbl.getCount(unsafe.Pointer(shellItemArray))
|
||||||
|
@ -60,7 +60,7 @@ func (vtbl *iShellItemArrayVtbl) getItemAt(objPtr unsafe.Pointer, index uintptr)
|
|||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
if shellItem == nil {
|
if shellItem == nil {
|
||||||
return "", ErrorCancelled
|
return "", ErrCancelled
|
||||||
}
|
}
|
||||||
defer shellItem.vtbl.release(unsafe.Pointer(shellItem))
|
defer shellItem.vtbl.release(unsafe.Pointer(shellItem))
|
||||||
return shellItem.vtbl.getDisplayName(unsafe.Pointer(shellItem))
|
return shellItem.vtbl.getDisplayName(unsafe.Pointer(shellItem))
|
||||||
|
@ -179,7 +179,7 @@ func (vtbl *iFileDialogVtbl) getResultString(objPtr unsafe.Pointer) (string, err
|
|||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
if shellItem == nil {
|
if shellItem == nil {
|
||||||
return "", ErrorCancelled
|
return "", ErrCancelled
|
||||||
}
|
}
|
||||||
defer shellItem.vtbl.release(unsafe.Pointer(shellItem))
|
defer shellItem.vtbl.release(unsafe.Pointer(shellItem))
|
||||||
return shellItem.vtbl.getDisplayName(unsafe.Pointer(shellItem))
|
return shellItem.vtbl.getDisplayName(unsafe.Pointer(shellItem))
|
||||||
|
@ -10,7 +10,9 @@ func ShowOpenFileDialog(config cfd.DialogConfig) (string, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
defer dialog.Release()
|
defer func() {
|
||||||
|
_ = dialog.Release()
|
||||||
|
}()
|
||||||
return dialog.ShowAndGetResult()
|
return dialog.ShowAndGetResult()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -20,7 +22,9 @@ func ShowOpenMultipleFilesDialog(config cfd.DialogConfig) ([]string, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
defer dialog.Release()
|
defer func() {
|
||||||
|
_ = dialog.Release()
|
||||||
|
}()
|
||||||
return dialog.ShowAndGetResults()
|
return dialog.ShowAndGetResults()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,7 +34,9 @@ func ShowPickFolderDialog(config cfd.DialogConfig) (string, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
defer dialog.Release()
|
defer func() {
|
||||||
|
_ = dialog.Release()
|
||||||
|
}()
|
||||||
return dialog.ShowAndGetResult()
|
return dialog.ShowAndGetResult()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,6 +46,8 @@ func ShowSaveFileDialog(config cfd.DialogConfig) (string, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
defer dialog.Release()
|
defer func() {
|
||||||
|
_ = dialog.Release()
|
||||||
|
}()
|
||||||
return dialog.ShowAndGetResult()
|
return dialog.ShowAndGetResult()
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package gomod
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/Masterminds/semver"
|
"github.com/Masterminds/semver"
|
||||||
"golang.org/x/mod/modfile"
|
"golang.org/x/mod/modfile"
|
||||||
)
|
)
|
||||||
|
@ -10,6 +10,7 @@ require github.com/wailsapp/wails/v2 v2.0.0-beta.7
|
|||||||
|
|
||||||
//replace github.com/wailsapp/wails/v2 v2.0.0-beta.7 => /home/lea/wails/v2
|
//replace github.com/wailsapp/wails/v2 v2.0.0-beta.7 => /home/lea/wails/v2
|
||||||
`
|
`
|
||||||
|
|
||||||
const basicUpdated string = `module changeme
|
const basicUpdated string = `module changeme
|
||||||
|
|
||||||
go 1.17
|
go 1.17
|
||||||
@ -29,6 +30,7 @@ require (
|
|||||||
|
|
||||||
//replace github.com/wailsapp/wails/v2 v2.0.0-beta.7 => /home/lea/wails/v2
|
//replace github.com/wailsapp/wails/v2 v2.0.0-beta.7 => /home/lea/wails/v2
|
||||||
`
|
`
|
||||||
|
|
||||||
const multilineReplace = `module changeme
|
const multilineReplace = `module changeme
|
||||||
|
|
||||||
go 1.17
|
go 1.17
|
||||||
@ -98,6 +100,7 @@ require (
|
|||||||
|
|
||||||
replace github.com/wailsapp/wails/v2 v2.0.0-beta.20 => /home/lea/wails/v2
|
replace github.com/wailsapp/wails/v2 v2.0.0-beta.20 => /home/lea/wails/v2
|
||||||
`
|
`
|
||||||
|
|
||||||
const multilineReplaceNoVersionUpdated = `module changeme
|
const multilineReplaceNoVersionUpdated = `module changeme
|
||||||
|
|
||||||
go 1.17
|
go 1.17
|
||||||
@ -108,6 +111,7 @@ require (
|
|||||||
|
|
||||||
replace github.com/wailsapp/wails/v2 => /home/lea/wails/v2
|
replace github.com/wailsapp/wails/v2 => /home/lea/wails/v2
|
||||||
`
|
`
|
||||||
|
|
||||||
const multilineReplaceNoVersionBlockUpdated = `module changeme
|
const multilineReplaceNoVersionBlockUpdated = `module changeme
|
||||||
|
|
||||||
go 1.17
|
go 1.17
|
||||||
|
@ -86,7 +86,6 @@ func (l *customLogger) Warning(format string, args ...interface{}) {
|
|||||||
func (l *customLogger) Error(format string, args ...interface{}) {
|
func (l *customLogger) Error(format string, args ...interface{}) {
|
||||||
format = fmt.Sprintf("%s | %s", l.name, format)
|
format = fmt.Sprintf("%s | %s", l.name, format)
|
||||||
l.logger.Error(format, args...)
|
l.logger.Error(format, args...)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fatal level logging. Works like Sprintf.
|
// Fatal level logging. Works like Sprintf.
|
||||||
|
@ -84,7 +84,6 @@ func (l *Logger) Info(format string, args ...interface{}) {
|
|||||||
if l.logLevel <= logger.INFO {
|
if l.logLevel <= logger.INFO {
|
||||||
l.output.Info(fmt.Sprintf(format, args...))
|
l.output.Info(fmt.Sprintf(format, args...))
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Warning level logging. Works like Sprintf.
|
// Warning level logging. Works like Sprintf.
|
||||||
@ -99,7 +98,6 @@ func (l *Logger) Error(format string, args ...interface{}) {
|
|||||||
if l.logLevel <= logger.ERROR {
|
if l.logLevel <= logger.ERROR {
|
||||||
l.output.Error(fmt.Sprintf(format, args...))
|
l.output.Error(fmt.Sprintf(format, args...))
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fatal level logging. Works like Sprintf.
|
// Fatal level logging. Works like Sprintf.
|
||||||
|
@ -3,7 +3,6 @@ package menumanager
|
|||||||
import "github.com/wailsapp/wails/v2/pkg/menu"
|
import "github.com/wailsapp/wails/v2/pkg/menu"
|
||||||
|
|
||||||
func (m *Manager) SetApplicationMenu(applicationMenu *menu.Menu) error {
|
func (m *Manager) SetApplicationMenu(applicationMenu *menu.Menu) error {
|
||||||
|
|
||||||
if applicationMenu == nil {
|
if applicationMenu == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -38,7 +37,6 @@ func (m *Manager) UpdateApplicationMenu() (string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *Manager) processApplicationMenu() error {
|
func (m *Manager) processApplicationMenu() error {
|
||||||
|
|
||||||
// Process the menu
|
// Process the menu
|
||||||
m.processedApplicationMenu = NewWailsMenu(m.applicationMenuItemMap, m.applicationMenu)
|
m.processedApplicationMenu = NewWailsMenu(m.applicationMenuItemMap, m.applicationMenu)
|
||||||
m.processRadioGroups(m.processedApplicationMenu, m.applicationMenuItemMap)
|
m.processRadioGroups(m.processedApplicationMenu, m.applicationMenuItemMap)
|
||||||
|
@ -23,7 +23,6 @@ func (t *ContextMenu) AsJSON() (string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewContextMenu(contextMenu *menu.ContextMenu) *ContextMenu {
|
func NewContextMenu(contextMenu *menu.ContextMenu) *ContextMenu {
|
||||||
|
|
||||||
result := &ContextMenu{
|
result := &ContextMenu{
|
||||||
ID: contextMenu.ID,
|
ID: contextMenu.ID,
|
||||||
menu: contextMenu.Menu,
|
menu: contextMenu.Menu,
|
||||||
@ -37,7 +36,6 @@ func NewContextMenu(contextMenu *menu.ContextMenu) *ContextMenu {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *Manager) AddContextMenu(contextMenu *menu.ContextMenu) {
|
func (m *Manager) AddContextMenu(contextMenu *menu.ContextMenu) {
|
||||||
|
|
||||||
newContextMenu := NewContextMenu(contextMenu)
|
newContextMenu := NewContextMenu(contextMenu)
|
||||||
|
|
||||||
// Save the references
|
// Save the references
|
||||||
|
@ -2,8 +2,10 @@ package menumanager
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/wailsapp/wails/v2/pkg/menu"
|
"strconv"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
|
"github.com/wailsapp/wails/v2/pkg/menu"
|
||||||
)
|
)
|
||||||
|
|
||||||
// MenuItemMap holds a mapping between menuIDs and menu items
|
// MenuItemMap holds a mapping between menuIDs and menu items
|
||||||
@ -48,14 +50,13 @@ func (m *MenuItemMap) Dump() {
|
|||||||
// GenerateMenuID returns a unique string ID for a menu item
|
// GenerateMenuID returns a unique string ID for a menu item
|
||||||
func (m *MenuItemMap) generateMenuID() string {
|
func (m *MenuItemMap) generateMenuID() string {
|
||||||
m.menuIDCounterMutex.Lock()
|
m.menuIDCounterMutex.Lock()
|
||||||
result := fmt.Sprintf("%d", m.menuIDCounter)
|
result := strconv.FormatInt(m.menuIDCounter, 10)
|
||||||
m.menuIDCounter++
|
m.menuIDCounter++
|
||||||
m.menuIDCounterMutex.Unlock()
|
m.menuIDCounterMutex.Unlock()
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *MenuItemMap) processMenuItem(item *menu.MenuItem) {
|
func (m *MenuItemMap) processMenuItem(item *menu.MenuItem) {
|
||||||
|
|
||||||
if item.SubMenu != nil {
|
if item.SubMenu != nil {
|
||||||
for _, submenuitem := range item.SubMenu.Items {
|
for _, submenuitem := range item.SubMenu.Items {
|
||||||
m.processMenuItem(submenuitem)
|
m.processMenuItem(submenuitem)
|
||||||
|
@ -2,11 +2,11 @@ package menumanager
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/wailsapp/wails/v2/pkg/menu"
|
"github.com/wailsapp/wails/v2/pkg/menu"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Manager struct {
|
type Manager struct {
|
||||||
|
|
||||||
// The application menu.
|
// The application menu.
|
||||||
applicationMenu *menu.Menu
|
applicationMenu *menu.Menu
|
||||||
applicationMenuJSON string
|
applicationMenuJSON string
|
||||||
@ -43,7 +43,6 @@ func (m *Manager) getMenuItemByID(menuMap *MenuItemMap, menuId string) *menu.Men
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *Manager) ProcessClick(menuID string, data string, menuType string, parentID string) error {
|
func (m *Manager) ProcessClick(menuID string, data string, menuType string, parentID string) error {
|
||||||
|
|
||||||
var menuItemMap *MenuItemMap
|
var menuItemMap *MenuItemMap
|
||||||
|
|
||||||
switch menuType {
|
switch menuType {
|
||||||
|
@ -2,6 +2,7 @@ package menumanager
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/wailsapp/wails/v2/pkg/menu"
|
"github.com/wailsapp/wails/v2/pkg/menu"
|
||||||
"github.com/wailsapp/wails/v2/pkg/menu/keys"
|
"github.com/wailsapp/wails/v2/pkg/menu/keys"
|
||||||
)
|
)
|
||||||
@ -47,7 +48,6 @@ type ProcessedMenuItem struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewProcessedMenuItem(menuItemMap *MenuItemMap, menuItem *menu.MenuItem) *ProcessedMenuItem {
|
func NewProcessedMenuItem(menuItemMap *MenuItemMap, menuItem *menu.MenuItem) *ProcessedMenuItem {
|
||||||
|
|
||||||
ID := menuItemMap.menuItemToIDMap[menuItem]
|
ID := menuItemMap.menuItemToIDMap[menuItem]
|
||||||
|
|
||||||
// Parse ANSI text
|
// Parse ANSI text
|
||||||
@ -92,7 +92,6 @@ type ProcessedMenu struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewProcessedMenu(menuItemMap *MenuItemMap, menu *menu.Menu) *ProcessedMenu {
|
func NewProcessedMenu(menuItemMap *MenuItemMap, menu *menu.Menu) *ProcessedMenu {
|
||||||
|
|
||||||
result := &ProcessedMenu{}
|
result := &ProcessedMenu{}
|
||||||
if menu != nil {
|
if menu != nil {
|
||||||
for _, item := range menu.Items {
|
for _, item := range menu.Items {
|
||||||
@ -131,7 +130,6 @@ func NewWailsMenu(menuItemMap *MenuItemMap, menu *menu.Menu) *WailsMenu {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (w *WailsMenu) AsJSON() (string, error) {
|
func (w *WailsMenu) AsJSON() (string, error) {
|
||||||
|
|
||||||
menuAsJSON, err := json.Marshal(w)
|
menuAsJSON, err := json.Marshal(w)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
@ -150,7 +148,6 @@ func (w *WailsMenu) processRadioGroups() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (w *WailsMenu) processMenuItem(item *ProcessedMenuItem) {
|
func (w *WailsMenu) processMenuItem(item *ProcessedMenuItem) {
|
||||||
|
|
||||||
switch item.Type {
|
switch item.Type {
|
||||||
|
|
||||||
// We need to recurse submenus
|
// We need to recurse submenus
|
||||||
@ -172,7 +169,6 @@ func (w *WailsMenu) processMenuItem(item *ProcessedMenuItem) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (w *WailsMenu) finaliseRadioGroup() {
|
func (w *WailsMenu) finaliseRadioGroup() {
|
||||||
|
|
||||||
// If we were processing a radio group, fix up the references
|
// If we were processing a radio group, fix up the references
|
||||||
if len(w.currentRadioGroup) > 0 {
|
if len(w.currentRadioGroup) > 0 {
|
||||||
|
|
||||||
|
@ -13,8 +13,10 @@ import (
|
|||||||
"github.com/wailsapp/wails/v2/pkg/menu"
|
"github.com/wailsapp/wails/v2/pkg/menu"
|
||||||
)
|
)
|
||||||
|
|
||||||
var trayMenuID int
|
var (
|
||||||
var trayMenuIDMutex sync.Mutex
|
trayMenuID int
|
||||||
|
trayMenuIDMutex sync.Mutex
|
||||||
|
)
|
||||||
|
|
||||||
func generateTrayID() string {
|
func generateTrayID() string {
|
||||||
var idStr string
|
var idStr string
|
||||||
@ -51,7 +53,6 @@ func (t *TrayMenu) AsJSON() (string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewTrayMenu(trayMenu *menu.TrayMenu) *TrayMenu {
|
func NewTrayMenu(trayMenu *menu.TrayMenu) *TrayMenu {
|
||||||
|
|
||||||
// Parse ANSI text
|
// Parse ANSI text
|
||||||
var styledLabel []*ansi.StyledText
|
var styledLabel []*ansi.StyledText
|
||||||
tempLabel := trayMenu.Label
|
tempLabel := trayMenu.Label
|
||||||
@ -205,7 +206,6 @@ func (m *Manager) UpdateTrayMenuLabel(trayMenu *menu.TrayMenu) (string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return string(data), nil
|
return string(data), nil
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Manager) GetContextMenus() ([]string, error) {
|
func (m *Manager) GetContextMenus() ([]string, error) {
|
||||||
|
@ -25,7 +25,6 @@ func NewProcess(cmd string, args ...string) *Process {
|
|||||||
|
|
||||||
// Start the process
|
// Start the process
|
||||||
func (p *Process) Start(exitCodeChannel chan int) error {
|
func (p *Process) Start(exitCodeChannel chan int) error {
|
||||||
|
|
||||||
err := p.cmd.Start()
|
err := p.cmd.Start()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -12,7 +12,6 @@ import (
|
|||||||
|
|
||||||
// Project holds the data related to a Wails project
|
// Project holds the data related to a Wails project
|
||||||
type Project struct {
|
type Project struct {
|
||||||
|
|
||||||
/*** Application Data ***/
|
/*** Application Data ***/
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
AssetDirectory string `json:"assetdir,omitempty"`
|
AssetDirectory string `json:"assetdir,omitempty"`
|
||||||
@ -144,11 +143,10 @@ func (p *Project) Save() error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return os.WriteFile(p.filename, data, 0755)
|
return os.WriteFile(p.filename, data, 0o755)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Project) setDefaults() {
|
func (p *Project) setDefaults() {
|
||||||
|
|
||||||
if p.Path == "" {
|
if p.Path == "" {
|
||||||
p.Path = lo.Must(os.Getwd())
|
p.Path = lo.Must(os.Getwd())
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package s
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/md5"
|
"crypto/md5"
|
||||||
|
"encoding/hex"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
@ -74,9 +75,10 @@ func CD(dir string) {
|
|||||||
checkError(err)
|
checkError(err)
|
||||||
log("CD %s [%s]", dir, CWD())
|
log("CD %s [%s]", dir, CWD())
|
||||||
}
|
}
|
||||||
|
|
||||||
func MKDIR(path string, mode ...os.FileMode) {
|
func MKDIR(path string, mode ...os.FileMode) {
|
||||||
var perms os.FileMode
|
var perms os.FileMode
|
||||||
perms = 0755
|
perms = 0o755
|
||||||
if len(mode) == 1 {
|
if len(mode) == 1 {
|
||||||
perms = mode[0]
|
perms = mode[0]
|
||||||
}
|
}
|
||||||
@ -88,7 +90,7 @@ func MKDIR(path string, mode ...os.FileMode) {
|
|||||||
// ENDIR ensures that the path gets created if it doesn't exist
|
// ENDIR ensures that the path gets created if it doesn't exist
|
||||||
func ENDIR(path string, mode ...os.FileMode) {
|
func ENDIR(path string, mode ...os.FileMode) {
|
||||||
var perms os.FileMode
|
var perms os.FileMode
|
||||||
perms = 0755
|
perms = 0o755
|
||||||
if len(mode) == 1 {
|
if len(mode) == 1 {
|
||||||
perms = mode[0]
|
perms = mode[0]
|
||||||
}
|
}
|
||||||
@ -210,17 +212,13 @@ func ISDIR(path string) bool {
|
|||||||
|
|
||||||
// ISDIREMPTY returns true if the given directory is empty
|
// ISDIREMPTY returns true if the given directory is empty
|
||||||
func ISDIREMPTY(dir string) bool {
|
func ISDIREMPTY(dir string) bool {
|
||||||
|
|
||||||
// CREDIT: https://stackoverflow.com/a/30708914/8325411
|
// CREDIT: https://stackoverflow.com/a/30708914/8325411
|
||||||
f, err := os.Open(dir)
|
f, err := os.Open(dir)
|
||||||
checkError(err)
|
checkError(err)
|
||||||
defer closefile(f)
|
defer closefile(f)
|
||||||
|
|
||||||
_, err = f.Readdirnames(1) // Or f.Readdir(1)
|
_, err = f.Readdirnames(1) // Or f.Readdir(1)
|
||||||
if err == io.EOF {
|
return err == io.EOF
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ISFILE returns true if the given file exists
|
// ISFILE returns true if the given file exists
|
||||||
@ -270,7 +268,7 @@ func LOADSTRING(filename string) string {
|
|||||||
// SAVEBYTES will create a file with the given string
|
// SAVEBYTES will create a file with the given string
|
||||||
func SAVEBYTES(filename string, data []byte) {
|
func SAVEBYTES(filename string, data []byte) {
|
||||||
log("SAVEBYTES %s", filename)
|
log("SAVEBYTES %s", filename)
|
||||||
err := os.WriteFile(filename, data, 0755)
|
err := os.WriteFile(filename, data, 0o755)
|
||||||
checkError(err)
|
checkError(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -297,7 +295,7 @@ func MD5FILE(filename string) string {
|
|||||||
_, err = io.Copy(h, f)
|
_, err = io.Copy(h, f)
|
||||||
checkError(err)
|
checkError(err)
|
||||||
|
|
||||||
return fmt.Sprintf("%x", h.Sum(nil))
|
return hex.EncodeToString(h.Sum(nil))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sub is the substitution type
|
// Sub is the substitution type
|
||||||
|
@ -42,6 +42,7 @@ func (c *Command) Run() error {
|
|||||||
func (c *Command) Stdout() string {
|
func (c *Command) Stdout() string {
|
||||||
return c.stdo.String()
|
return c.stdo.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Command) Stderr() string {
|
func (c *Command) Stderr() string {
|
||||||
return c.stde.String()
|
return c.stde.String()
|
||||||
}
|
}
|
||||||
@ -93,8 +94,5 @@ func RunCommandVerbose(directory string, command string, args ...string) error {
|
|||||||
// CommandExists returns true if the given command can be found on the shell
|
// CommandExists returns true if the given command can be found on the shell
|
||||||
func CommandExists(name string) bool {
|
func CommandExists(name string) bool {
|
||||||
_, err := exec.LookPath(name)
|
_, err := exec.LookPath(name)
|
||||||
if err != nil {
|
return err == nil
|
||||||
return false
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
|
@ -9,8 +9,10 @@ import (
|
|||||||
|
|
||||||
var signalChannel = make(chan os.Signal, 2)
|
var signalChannel = make(chan os.Signal, 2)
|
||||||
|
|
||||||
var callbacks []func()
|
var (
|
||||||
var lock sync.Mutex
|
callbacks []func()
|
||||||
|
lock sync.Mutex
|
||||||
|
)
|
||||||
|
|
||||||
func OnShutdown(callback func()) {
|
func OnShutdown(callback func()) {
|
||||||
lock.Lock()
|
lock.Lock()
|
||||||
@ -20,20 +22,17 @@ func OnShutdown(callback func()) {
|
|||||||
|
|
||||||
// Start the Signal Manager
|
// Start the Signal Manager
|
||||||
func Start() {
|
func Start() {
|
||||||
|
|
||||||
// Hook into interrupts
|
// Hook into interrupts
|
||||||
gosignal.Notify(signalChannel, os.Interrupt, syscall.SIGTERM, syscall.SIGINT)
|
gosignal.Notify(signalChannel, os.Interrupt, syscall.SIGTERM, syscall.SIGINT)
|
||||||
|
|
||||||
// Spin off signal listener and wait for either a cancellation
|
// Spin off signal listener and wait for either a cancellation
|
||||||
// or signal
|
// or signal
|
||||||
go func() {
|
go func() {
|
||||||
select {
|
<-signalChannel
|
||||||
case <-signalChannel:
|
|
||||||
println("")
|
println("")
|
||||||
println("Ctrl+C detected. Shutting down...")
|
println("Ctrl+C detected. Shutting down...")
|
||||||
for _, callback := range callbacks {
|
for _, callback := range callbacks {
|
||||||
callback()
|
callback()
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
@ -2,9 +2,10 @@ package staticanalysis
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"go/ast"
|
"go/ast"
|
||||||
"golang.org/x/tools/go/packages"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"golang.org/x/tools/go/packages"
|
||||||
)
|
)
|
||||||
|
|
||||||
type EmbedDetails struct {
|
type EmbedDetails struct {
|
||||||
|
@ -16,9 +16,9 @@ type packagemap = map[string][]*Package
|
|||||||
type PackageManager interface {
|
type PackageManager interface {
|
||||||
Name() string
|
Name() string
|
||||||
Packages() packagemap
|
Packages() packagemap
|
||||||
PackageInstalled(*Package) (bool, error)
|
PackageInstalled(pkg *Package) (bool, error)
|
||||||
PackageAvailable(*Package) (bool, error)
|
PackageAvailable(pkg *Package) (bool, error)
|
||||||
InstallCommand(*Package) string
|
InstallCommand(pkg *Package) string
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dependency represents a system package that we require
|
// Dependency represents a system package that we require
|
||||||
@ -37,7 +37,6 @@ type DependencyList []*Dependency
|
|||||||
|
|
||||||
// InstallAllRequiredCommand returns the command you need to use to install all required dependencies
|
// InstallAllRequiredCommand returns the command you need to use to install all required dependencies
|
||||||
func (d DependencyList) InstallAllRequiredCommand() string {
|
func (d DependencyList) InstallAllRequiredCommand() string {
|
||||||
|
|
||||||
result := ""
|
result := ""
|
||||||
for _, dependency := range d {
|
for _, dependency := range d {
|
||||||
if !dependency.Installed && !dependency.Optional {
|
if !dependency.Installed && !dependency.Optional {
|
||||||
@ -50,7 +49,6 @@ func (d DependencyList) InstallAllRequiredCommand() string {
|
|||||||
|
|
||||||
// InstallAllOptionalCommand returns the command you need to use to install all optional dependencies
|
// InstallAllOptionalCommand returns the command you need to use to install all optional dependencies
|
||||||
func (d DependencyList) InstallAllOptionalCommand() string {
|
func (d DependencyList) InstallAllOptionalCommand() string {
|
||||||
|
|
||||||
result := ""
|
result := ""
|
||||||
for _, dependency := range d {
|
for _, dependency := range d {
|
||||||
if !dependency.Installed && dependency.Optional {
|
if !dependency.Installed && dependency.Optional {
|
||||||
|
@ -9,12 +9,10 @@ import (
|
|||||||
"github.com/wailsapp/wails/v2/internal/system/packagemanager"
|
"github.com/wailsapp/wails/v2/internal/system/packagemanager"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var IsAppleSilicon bool
|
||||||
IsAppleSilicon bool
|
|
||||||
)
|
|
||||||
|
|
||||||
// Info holds information about the current operating system,
|
// Info holds information about the current operating system,
|
||||||
// package manager and required dependancies
|
// package manager and required dependencies
|
||||||
type Info struct {
|
type Info struct {
|
||||||
OS *operatingsystem.OS
|
OS *operatingsystem.OS
|
||||||
PM packagemanager.PackageManager
|
PM packagemanager.PackageManager
|
||||||
@ -23,7 +21,7 @@ type Info struct {
|
|||||||
|
|
||||||
// GetInfo scans the system for operating system details,
|
// GetInfo scans the system for operating system details,
|
||||||
// the system package manager and the status of required
|
// the system package manager and the status of required
|
||||||
// dependancies.
|
// dependencies.
|
||||||
func GetInfo() (*Info, error) {
|
func GetInfo() (*Info, error) {
|
||||||
var result Info
|
var result Info
|
||||||
err := result.discover()
|
err := result.discover()
|
||||||
@ -34,7 +32,6 @@ func GetInfo() (*Info, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func checkNodejs() *packagemanager.Dependency {
|
func checkNodejs() *packagemanager.Dependency {
|
||||||
|
|
||||||
// Check for Nodejs
|
// Check for Nodejs
|
||||||
output, err := exec.Command("node", "-v").Output()
|
output, err := exec.Command("node", "-v").Output()
|
||||||
installed := true
|
installed := true
|
||||||
@ -58,7 +55,6 @@ func checkNodejs() *packagemanager.Dependency {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func checkNPM() *packagemanager.Dependency {
|
func checkNPM() *packagemanager.Dependency {
|
||||||
|
|
||||||
// Check for npm
|
// Check for npm
|
||||||
output, err := exec.Command("npm", "-version").Output()
|
output, err := exec.Command("npm", "-version").Output()
|
||||||
installed := true
|
installed := true
|
||||||
@ -80,7 +76,6 @@ func checkNPM() *packagemanager.Dependency {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func checkUPX() *packagemanager.Dependency {
|
func checkUPX() *packagemanager.Dependency {
|
||||||
|
|
||||||
// Check for npm
|
// Check for npm
|
||||||
output, err := exec.Command("upx", "-V").Output()
|
output, err := exec.Command("upx", "-V").Output()
|
||||||
installed := true
|
installed := true
|
||||||
@ -102,7 +97,6 @@ func checkUPX() *packagemanager.Dependency {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func checkNSIS() *packagemanager.Dependency {
|
func checkNSIS() *packagemanager.Dependency {
|
||||||
|
|
||||||
// Check for nsis installer
|
// Check for nsis installer
|
||||||
output, err := exec.Command("makensis", "-VERSION").Output()
|
output, err := exec.Command("makensis", "-VERSION").Output()
|
||||||
installed := true
|
installed := true
|
||||||
@ -141,7 +135,6 @@ func checkLibrary(name string) func() *packagemanager.Dependency {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func checkDocker() *packagemanager.Dependency {
|
func checkDocker() *packagemanager.Dependency {
|
||||||
|
|
||||||
// Check for npm
|
// Check for npm
|
||||||
output, err := exec.Command("docker", "version").Output()
|
output, err := exec.Command("docker", "version").Output()
|
||||||
installed := true
|
installed := true
|
||||||
|
@ -439,7 +439,7 @@ func (t TypeScriptify) backup(fileName string) error {
|
|||||||
backupFn = path.Join(t.BackupDir, backupFn)
|
backupFn = path.Join(t.BackupDir, backupFn)
|
||||||
}
|
}
|
||||||
|
|
||||||
return ioutil.WriteFile(backupFn, bytes, os.FileMode(0700))
|
return ioutil.WriteFile(backupFn, bytes, os.FileMode(0o700))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t TypeScriptify) ConvertToFile(fileName string, packageName string) error {
|
func (t TypeScriptify) ConvertToFile(fileName string, packageName string) error {
|
||||||
@ -935,6 +935,6 @@ func typeClashWithReservedKeyword(input string) bool {
|
|||||||
func warnAboutTypesClash(entity string) {
|
func warnAboutTypesClash(entity string) {
|
||||||
// TODO: Refactor logging
|
// TODO: Refactor logging
|
||||||
l := log.New(os.Stderr, "", 0)
|
l := log.New(os.Stderr, "", 0)
|
||||||
l.Println(fmt.Sprintf("Usage of reserved keyword found and not supported: %s", entity))
|
l.Printf("Usage of reserved keyword found and not supported: %s", entity)
|
||||||
log.Println("Please rename returned type or consider adding bindings config to your wails.json")
|
log.Println("Please rename returned type or consider adding bindings config to your wails.json")
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ var setupexe []byte
|
|||||||
|
|
||||||
// WriteInstallerToFile writes the installer file to the given file.
|
// WriteInstallerToFile writes the installer file to the given file.
|
||||||
func WriteInstallerToFile(targetFile string) error {
|
func WriteInstallerToFile(targetFile string) error {
|
||||||
return os.WriteFile(targetFile, setupexe, 0755)
|
return os.WriteFile(targetFile, setupexe, 0o755)
|
||||||
}
|
}
|
||||||
|
|
||||||
// WriteInstaller writes the installer exe file to the given directory and returns the path to it.
|
// WriteInstaller writes the installer exe file to the given directory and returns the path to it.
|
||||||
|
@ -2,11 +2,12 @@ package application
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"sync"
|
||||||
|
|
||||||
"github.com/wailsapp/wails/v2/internal/app"
|
"github.com/wailsapp/wails/v2/internal/app"
|
||||||
"github.com/wailsapp/wails/v2/internal/signal"
|
"github.com/wailsapp/wails/v2/internal/signal"
|
||||||
"github.com/wailsapp/wails/v2/pkg/menu"
|
"github.com/wailsapp/wails/v2/pkg/menu"
|
||||||
"github.com/wailsapp/wails/v2/pkg/options"
|
"github.com/wailsapp/wails/v2/pkg/options"
|
||||||
"sync"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Application is the main Wails application
|
// Application is the main Wails application
|
||||||
@ -86,7 +87,6 @@ func (a *Application) Bind(boundStruct any) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *Application) On(eventType EventType, callback func()) {
|
func (a *Application) On(eventType EventType, callback func()) {
|
||||||
|
|
||||||
c := func(ctx context.Context) {
|
c := func(ctx context.Context) {
|
||||||
callback()
|
callback()
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/wailsapp/wails/v2/pkg/options/assetserver"
|
"github.com/wailsapp/wails/v2/pkg/options/assetserver"
|
||||||
@ -37,7 +38,6 @@ type assetHandler struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewAssetHandler(options assetserver.Options, log Logger) (http.Handler, error) {
|
func NewAssetHandler(options assetserver.Options, log Logger) (http.Handler, error) {
|
||||||
|
|
||||||
vfs := options.Assets
|
vfs := options.Assets
|
||||||
if vfs != nil {
|
if vfs != nil {
|
||||||
if _, err := vfs.Open("."); err != nil {
|
if _, err := vfs.Open("."); err != nil {
|
||||||
@ -178,7 +178,8 @@ func (d *assetHandler) serveFSFile(rw http.ResponseWriter, req *http.Request, fi
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
rw.Header().Set(HeaderContentLength, fmt.Sprintf("%d", statInfo.Size()))
|
size := strconv.FormatInt(statInfo.Size(), 10)
|
||||||
|
rw.Header().Set(HeaderContentLength, size)
|
||||||
|
|
||||||
// Write the first 512 bytes used for MimeType sniffing
|
// Write the first 512 bytes used for MimeType sniffing
|
||||||
_, err = io.Copy(rw, bytes.NewReader(buf[:n]))
|
_, err = io.Copy(rw, bytes.NewReader(buf[:n]))
|
||||||
|
@ -123,10 +123,8 @@ func (d *AssetServer) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
|
|||||||
path := req.URL.Path
|
path := req.URL.Path
|
||||||
if path == runtimeJSPath {
|
if path == runtimeJSPath {
|
||||||
d.writeBlob(rw, path, d.runtimeJS)
|
d.writeBlob(rw, path, d.runtimeJS)
|
||||||
|
|
||||||
} else if path == runtimePath && d.runtimeHandler != nil {
|
} else if path == runtimePath && d.runtimeHandler != nil {
|
||||||
d.runtimeHandler.HandleRuntimeCall(rw, req)
|
d.runtimeHandler.HandleRuntimeCall(rw, req)
|
||||||
|
|
||||||
} else if path == ipcJSPath {
|
} else if path == ipcJSPath {
|
||||||
content := d.runtime.DesktopIPC()
|
content := d.runtime.DesktopIPC()
|
||||||
if d.ipcJS != nil {
|
if d.ipcJS != nil {
|
||||||
@ -136,7 +134,6 @@ func (d *AssetServer) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
|
|||||||
|
|
||||||
} else if script, ok := d.pluginScripts[path]; ok {
|
} else if script, ok := d.pluginScripts[path]; ok {
|
||||||
d.writeBlob(rw, path, []byte(script))
|
d.writeBlob(rw, path, []byte(script))
|
||||||
|
|
||||||
} else if d.isRuntimeInjectionMatch(path) {
|
} else if d.isRuntimeInjectionMatch(path) {
|
||||||
recorder := &bodyRecorder{
|
recorder := &bodyRecorder{
|
||||||
ResponseWriter: rw,
|
ResponseWriter: rw,
|
||||||
@ -150,7 +147,8 @@ func (d *AssetServer) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return strings.Contains(h.Get(HeaderContentType), "text/html")
|
return strings.Contains(h.Get(HeaderContentType), "text/html")
|
||||||
}}
|
},
|
||||||
|
}
|
||||||
|
|
||||||
handler.ServeHTTP(recorder, req)
|
handler.ServeHTTP(recorder, req)
|
||||||
|
|
||||||
|
@ -133,7 +133,8 @@ func (d *AssetServer) processWebViewRequestInternal(r webview.Request) {
|
|||||||
if req.ContentLength == 0 {
|
if req.ContentLength == 0 {
|
||||||
req.ContentLength, _ = strconv.ParseInt(req.Header.Get(HeaderContentLength), 10, 64)
|
req.ContentLength, _ = strconv.ParseInt(req.Header.Get(HeaderContentLength), 10, 64)
|
||||||
} else {
|
} else {
|
||||||
req.Header.Set(HeaderContentLength, fmt.Sprintf("%d", req.ContentLength))
|
size := strconv.FormatInt(req.ContentLength, 10)
|
||||||
|
req.Header.Set(HeaderContentLength, size)
|
||||||
}
|
}
|
||||||
|
|
||||||
if host := req.Header.Get(HeaderHost); host != "" {
|
if host := req.Header.Get(HeaderHost); host != "" {
|
||||||
|
@ -3,9 +3,9 @@ package assetserver
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/wailsapp/wails/v2/pkg/options"
|
"github.com/wailsapp/wails/v2/pkg/options"
|
||||||
@ -44,7 +44,7 @@ const (
|
|||||||
|
|
||||||
func serveFile(rw http.ResponseWriter, filename string, blob []byte) error {
|
func serveFile(rw http.ResponseWriter, filename string, blob []byte) error {
|
||||||
header := rw.Header()
|
header := rw.Header()
|
||||||
header.Set(HeaderContentLength, fmt.Sprintf("%d", len(blob)))
|
header.Set(HeaderContentLength, strconv.Itoa(len(blob)))
|
||||||
if mimeType := header.Get(HeaderContentType); mimeType == "" {
|
if mimeType := header.Get(HeaderContentType); mimeType == "" {
|
||||||
mimeType = GetMimetype(filename, blob)
|
mimeType = GetMimetype(filename, blob)
|
||||||
header.Set(HeaderContentType, mimeType)
|
header.Set(HeaderContentType, mimeType)
|
||||||
|
@ -197,7 +197,10 @@ func (r *request) Close() error {
|
|||||||
if r.body != nil {
|
if r.body != nil {
|
||||||
err = r.body.Close()
|
err = r.body.Close()
|
||||||
}
|
}
|
||||||
r.Response().Finish()
|
err = r.Response().Finish()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
C.URLSchemeTaskRelease(r.task)
|
C.URLSchemeTaskRelease(r.task)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -128,12 +128,12 @@ func writeFileSystemFile(projectData *project.Project, file string, content []by
|
|||||||
targetPath := GetLocalPath(projectData, file)
|
targetPath := GetLocalPath(projectData, file)
|
||||||
|
|
||||||
if dir := filepath.Dir(targetPath); !fs.DirExists(dir) {
|
if dir := filepath.Dir(targetPath); !fs.DirExists(dir) {
|
||||||
if err := fs.MkDirs(dir, 0755); err != nil {
|
if err := fs.MkDirs(dir, 0o755); err != nil {
|
||||||
return fmt.Errorf("Unable to create directory: %w", err)
|
return fmt.Errorf("Unable to create directory: %w", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := os.WriteFile(targetPath, content, 0644); err != nil {
|
if err := os.WriteFile(targetPath, content, 0o644); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
@ -26,7 +26,6 @@ type Options struct {
|
|||||||
// GenerateBindings generates bindings for the Wails project in the given ProjectDirectory.
|
// GenerateBindings generates bindings for the Wails project in the given ProjectDirectory.
|
||||||
// If no project directory is given then the current working directory is used.
|
// If no project directory is given then the current working directory is used.
|
||||||
func GenerateBindings(options Options) (string, error) {
|
func GenerateBindings(options Options) (string, error) {
|
||||||
|
|
||||||
filename, _ := lo.Coalesce(options.Filename, "wailsbindings")
|
filename, _ := lo.Coalesce(options.Filename, "wailsbindings")
|
||||||
if runtime.GOOS == "windows" {
|
if runtime.GOOS == "windows" {
|
||||||
filename += ".exe"
|
filename += ".exe"
|
||||||
|
@ -74,7 +74,6 @@ func (b *BaseBuilder) convertFileToIntegerString(filename string) (string, error
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (b *BaseBuilder) convertByteSliceToIntegerString(data []byte) string {
|
func (b *BaseBuilder) convertByteSliceToIntegerString(data []byte) string {
|
||||||
|
|
||||||
// Create string builder
|
// Create string builder
|
||||||
var result strings.Builder
|
var result strings.Builder
|
||||||
|
|
||||||
@ -85,8 +84,7 @@ func (b *BaseBuilder) convertByteSliceToIntegerString(data []byte) string {
|
|||||||
result.WriteString(fmt.Sprintf("%v,", data[i]))
|
result.WriteString(fmt.Sprintf("%v,", data[i]))
|
||||||
}
|
}
|
||||||
|
|
||||||
result.WriteString(fmt.Sprintf("%v", data[len(data)-1]))
|
result.WriteString(strconv.FormatUint(uint64(data[len(data)-1]), 10))
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result.String()
|
return result.String()
|
||||||
@ -94,10 +92,8 @@ func (b *BaseBuilder) convertByteSliceToIntegerString(data []byte) string {
|
|||||||
|
|
||||||
// CleanUp does post-build housekeeping
|
// CleanUp does post-build housekeeping
|
||||||
func (b *BaseBuilder) CleanUp() {
|
func (b *BaseBuilder) CleanUp() {
|
||||||
|
|
||||||
// Delete all the files
|
// Delete all the files
|
||||||
b.filesToDelete.Each(func(filename string) {
|
b.filesToDelete.Each(func(filename string) {
|
||||||
|
|
||||||
// if file doesn't exist, ignore
|
// if file doesn't exist, ignore
|
||||||
if !b.fileExists(filename) {
|
if !b.fileExists(filename) {
|
||||||
return
|
return
|
||||||
@ -106,7 +102,6 @@ func (b *BaseBuilder) CleanUp() {
|
|||||||
// Delete file. We ignore errors because these files will be overwritten
|
// Delete file. We ignore errors because these files will be overwritten
|
||||||
// by the next build anyway.
|
// by the next build anyway.
|
||||||
_ = os.Remove(filename)
|
_ = os.Remove(filename)
|
||||||
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -159,7 +154,6 @@ func (b *BaseBuilder) OutputFilename(options *Options) string {
|
|||||||
|
|
||||||
// CompileProject compiles the project
|
// CompileProject compiles the project
|
||||||
func (b *BaseBuilder) CompileProject(options *Options) error {
|
func (b *BaseBuilder) CompileProject(options *Options) error {
|
||||||
|
|
||||||
// Check if the runtime wrapper exists
|
// Check if the runtime wrapper exists
|
||||||
err := generateRuntimeWrapper(options)
|
err := generateRuntimeWrapper(options)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -402,7 +396,7 @@ Please reinstall by doing the following:
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var args = []string{"--best", "--no-color", "--no-progress", options.CompiledBinary}
|
args := []string{"--best", "--no-color", "--no-progress", options.CompiledBinary}
|
||||||
|
|
||||||
if options.CompressFlags != "" {
|
if options.CompressFlags != "" {
|
||||||
args = strings.Split(options.CompressFlags, " ")
|
args = strings.Split(options.CompressFlags, " ")
|
||||||
@ -426,7 +420,6 @@ Please reinstall by doing the following:
|
|||||||
}
|
}
|
||||||
|
|
||||||
func generateRuntimeWrapper(options *Options) error {
|
func generateRuntimeWrapper(options *Options) error {
|
||||||
|
|
||||||
if options.WailsJSDir == "" {
|
if options.WailsJSDir == "" {
|
||||||
cwd, err := os.Getwd()
|
cwd, err := os.Getwd()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -452,7 +445,6 @@ func (b *BaseBuilder) NpmInstall(sourceDir string, verbose bool) error {
|
|||||||
|
|
||||||
// NpmInstallUsingCommand runs the given install command in the specified npm project directory
|
// NpmInstallUsingCommand runs the given install command in the specified npm project directory
|
||||||
func (b *BaseBuilder) NpmInstallUsingCommand(sourceDir string, installCommand string, verbose bool) error {
|
func (b *BaseBuilder) NpmInstallUsingCommand(sourceDir string, installCommand string, verbose bool) error {
|
||||||
|
|
||||||
packageJSON := filepath.Join(sourceDir, "package.json")
|
packageJSON := filepath.Join(sourceDir, "package.json")
|
||||||
|
|
||||||
// Check package.json exists
|
// Check package.json exists
|
||||||
@ -492,7 +484,7 @@ func (b *BaseBuilder) NpmInstallUsingCommand(sourceDir string, installCommand st
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Shortcut installation
|
// Shortcut installation
|
||||||
if install == false {
|
if !install {
|
||||||
if verbose {
|
if verbose {
|
||||||
pterm.Println("Skipping npm install")
|
pterm.Println("Skipping npm install")
|
||||||
}
|
}
|
||||||
@ -549,7 +541,6 @@ func (b *BaseBuilder) NpmRunWithEnvironment(projectDir, buildTarget string, verb
|
|||||||
|
|
||||||
// BuildFrontend executes the `npm build` command for the frontend directory
|
// BuildFrontend executes the `npm build` command for the frontend directory
|
||||||
func (b *BaseBuilder) BuildFrontend(outputLogger *clilogger.CLILogger) error {
|
func (b *BaseBuilder) BuildFrontend(outputLogger *clilogger.CLILogger) error {
|
||||||
|
|
||||||
verbose := b.options.Verbosity == VERBOSE
|
verbose := b.options.Verbosity == VERBOSE
|
||||||
|
|
||||||
frontendDir := b.projectData.GetFrontendDir()
|
frontendDir := b.projectData.GetFrontendDir()
|
||||||
|
@ -73,7 +73,6 @@ type Options struct {
|
|||||||
|
|
||||||
// Build the project!
|
// Build the project!
|
||||||
func Build(options *Options) (string, error) {
|
func Build(options *Options) (string, error) {
|
||||||
|
|
||||||
// Extract logger
|
// Extract logger
|
||||||
outputLogger := options.Logger
|
outputLogger := options.Logger
|
||||||
|
|
||||||
@ -171,7 +170,7 @@ func CreateEmbedDirectories(cwd string, buildOptions *Options) error {
|
|||||||
for _, embedDetail := range embedDetails {
|
for _, embedDetail := range embedDetails {
|
||||||
fullPath := embedDetail.GetFullPath()
|
fullPath := embedDetail.GetFullPath()
|
||||||
if _, err := os.Stat(fullPath); os.IsNotExist(err) {
|
if _, err := os.Stat(fullPath); os.IsNotExist(err) {
|
||||||
err := os.MkdirAll(fullPath, 0755)
|
err := os.MkdirAll(fullPath, 0o755)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -184,7 +183,6 @@ func CreateEmbedDirectories(cwd string, buildOptions *Options) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func fatal(message string) {
|
func fatal(message string) {
|
||||||
@ -213,7 +211,6 @@ func printBulletPoint(text string, args ...any) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func GenerateBindings(buildOptions *Options) error {
|
func GenerateBindings(buildOptions *Options) error {
|
||||||
|
|
||||||
obfuscated := buildOptions.Obfuscated
|
obfuscated := buildOptions.Obfuscated
|
||||||
if obfuscated {
|
if obfuscated {
|
||||||
printBulletPoint("Generating obfuscated bindings: ")
|
printBulletPoint("Generating obfuscated bindings: ")
|
||||||
@ -371,7 +368,6 @@ func execPostBuildHook(outputLogger *clilogger.CLILogger, options *Options, hook
|
|||||||
}
|
}
|
||||||
|
|
||||||
return executeBuildHook(outputLogger, options, hookIdentifier, argReplacements, postBuildHook, "post")
|
return executeBuildHook(outputLogger, options, hookIdentifier, argReplacements, postBuildHook, "post")
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func executeBuildHook(_ *clilogger.CLILogger, options *Options, hookIdentifier string, argReplacements map[string]string, buildHook string, hookName string) error {
|
func executeBuildHook(_ *clilogger.CLILogger, options *Options, hookIdentifier string, argReplacements map[string]string, buildHook string, hookName string) error {
|
||||||
@ -407,7 +403,6 @@ func executeBuildHook(_ *clilogger.CLILogger, options *Options, hookIdentifier s
|
|||||||
|
|
||||||
if options.Verbosity == VERBOSE {
|
if options.Verbosity == VERBOSE {
|
||||||
pterm.Info.Println(strings.Join(args, " "))
|
pterm.Info.Println(strings.Join(args, " "))
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if !fs.DirExists(options.BinDirectory) {
|
if !fs.DirExists(options.BinDirectory) {
|
||||||
|
@ -8,8 +8,8 @@ import (
|
|||||||
// Builder defines a builder that can build Wails applications
|
// Builder defines a builder that can build Wails applications
|
||||||
type Builder interface {
|
type Builder interface {
|
||||||
SetProjectData(projectData *project.Project)
|
SetProjectData(projectData *project.Project)
|
||||||
BuildFrontend(*clilogger.CLILogger) error
|
BuildFrontend(logger *clilogger.CLILogger) error
|
||||||
CompileProject(*Options) error
|
CompileProject(options *Options) error
|
||||||
OutputFilename(*Options) string
|
OutputFilename(options *Options) string
|
||||||
CleanUp()
|
CleanUp()
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,7 @@ func GenerateNSISInstaller(options *Options, amd64Binary string, arm64Binary str
|
|||||||
// Write the WebView2 SetupFile
|
// Write the WebView2 SetupFile
|
||||||
webviewSetup := buildassets.GetLocalPath(options.ProjectData, path.Join(nsisFolder, nsisWebView2SetupFile))
|
webviewSetup := buildassets.GetLocalPath(options.ProjectData, path.Join(nsisFolder, nsisWebView2SetupFile))
|
||||||
if dir := filepath.Dir(webviewSetup); !fs.DirExists(dir) {
|
if dir := filepath.Dir(webviewSetup); !fs.DirExists(dir) {
|
||||||
if err := fs.MkDirs(dir, 0755); err != nil {
|
if err := fs.MkDirs(dir, 0o755); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -92,7 +92,7 @@ func makeNSIS(options *Options, installerKind string, amd64Binary string, arm64B
|
|||||||
outputLogger := options.Logger
|
outputLogger := options.Logger
|
||||||
|
|
||||||
outputLogger.Print(" - Building '%s' installer: ", installerKind)
|
outputLogger.Print(" - Building '%s' installer: ", installerKind)
|
||||||
var args = []string{}
|
args := []string{}
|
||||||
if amd64Binary != "" {
|
if amd64Binary != "" {
|
||||||
args = append(args, "-DARG_WAILS_AMD64_BINARY="+amd64Binary)
|
args = append(args, "-DARG_WAILS_AMD64_BINARY="+amd64Binary)
|
||||||
}
|
}
|
||||||
|
@ -3,13 +3,14 @@ package build
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"image"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/leaanthony/winicon"
|
"github.com/leaanthony/winicon"
|
||||||
"github.com/tc-hib/winres"
|
"github.com/tc-hib/winres"
|
||||||
"github.com/tc-hib/winres/version"
|
"github.com/tc-hib/winres/version"
|
||||||
"github.com/wailsapp/wails/v2/internal/project"
|
"github.com/wailsapp/wails/v2/internal/project"
|
||||||
"image"
|
|
||||||
"os"
|
|
||||||
"path/filepath"
|
|
||||||
|
|
||||||
"github.com/jackmordaunt/icns"
|
"github.com/jackmordaunt/icns"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
@ -20,7 +21,6 @@ import (
|
|||||||
|
|
||||||
// PackageProject packages the application
|
// PackageProject packages the application
|
||||||
func packageProject(options *Options, platform string) error {
|
func packageProject(options *Options, platform string) error {
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
switch platform {
|
switch platform {
|
||||||
case "darwin":
|
case "darwin":
|
||||||
@ -42,7 +42,6 @@ func packageProject(options *Options, platform string) error {
|
|||||||
|
|
||||||
// cleanBinDirectory will remove an existing bin directory and recreate it
|
// cleanBinDirectory will remove an existing bin directory and recreate it
|
||||||
func cleanBinDirectory(options *Options) error {
|
func cleanBinDirectory(options *Options) error {
|
||||||
|
|
||||||
buildDirectory := options.BinDirectory
|
buildDirectory := options.BinDirectory
|
||||||
|
|
||||||
// Clear out old builds
|
// Clear out old builds
|
||||||
@ -54,7 +53,7 @@ func cleanBinDirectory(options *Options) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create clean directory
|
// Create clean directory
|
||||||
err := os.MkdirAll(buildDirectory, 0700)
|
err := os.MkdirAll(buildDirectory, 0o700)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -63,7 +62,6 @@ func cleanBinDirectory(options *Options) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func packageApplicationForDarwin(options *Options) error {
|
func packageApplicationForDarwin(options *Options) error {
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
// Create directory structure
|
// Create directory structure
|
||||||
@ -74,12 +72,12 @@ func packageApplicationForDarwin(options *Options) error {
|
|||||||
|
|
||||||
contentsDirectory := filepath.Join(options.BinDirectory, bundlename, "/Contents")
|
contentsDirectory := filepath.Join(options.BinDirectory, bundlename, "/Contents")
|
||||||
exeDir := filepath.Join(contentsDirectory, "/MacOS")
|
exeDir := filepath.Join(contentsDirectory, "/MacOS")
|
||||||
err = fs.MkDirs(exeDir, 0755)
|
err = fs.MkDirs(exeDir, 0o755)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
resourceDir := filepath.Join(contentsDirectory, "/Resources")
|
resourceDir := filepath.Join(contentsDirectory, "/Resources")
|
||||||
err = fs.MkDirs(resourceDir, 0755)
|
err = fs.MkDirs(resourceDir, 0o755)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -116,7 +114,6 @@ func packageApplicationForDarwin(options *Options) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func processPList(options *Options, contentsDirectory string) error {
|
func processPList(options *Options, contentsDirectory string) error {
|
||||||
|
|
||||||
sourcePList := "Info.plist"
|
sourcePList := "Info.plist"
|
||||||
if options.Mode == Dev {
|
if options.Mode == Dev {
|
||||||
// Use Info.dev.plist if using build mode
|
// Use Info.dev.plist if using build mode
|
||||||
@ -130,7 +127,7 @@ func processPList(options *Options, contentsDirectory string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
targetFile := filepath.Join(contentsDirectory, "Info.plist")
|
targetFile := filepath.Join(contentsDirectory, "Info.plist")
|
||||||
return os.WriteFile(targetFile, content, 0644)
|
return os.WriteFile(targetFile, content, 0o644)
|
||||||
}
|
}
|
||||||
|
|
||||||
func processDarwinIcon(projectData *project.Project, iconName string, resourceDir string, destIconName string) (err error) {
|
func processDarwinIcon(projectData *project.Project, iconName string, resourceDir string, destIconName string) (err error) {
|
||||||
@ -152,7 +149,6 @@ func processDarwinIcon(projectData *project.Project, iconName string, resourceDi
|
|||||||
dest, err := os.Create(tgtBundle)
|
dest, err := os.Create(tgtBundle)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
err = dest.Close()
|
err = dest.Close()
|
||||||
@ -206,12 +202,12 @@ func generateIcoFile(options *Options, iconName string, destIconName string) err
|
|||||||
icoFile := buildassets.GetLocalPath(options.ProjectData, "windows/"+destIconName+".ico")
|
icoFile := buildassets.GetLocalPath(options.ProjectData, "windows/"+destIconName+".ico")
|
||||||
if !fs.FileExists(icoFile) {
|
if !fs.FileExists(icoFile) {
|
||||||
if dir := filepath.Dir(icoFile); !fs.DirExists(dir) {
|
if dir := filepath.Dir(icoFile); !fs.DirExists(dir) {
|
||||||
if err := fs.MkDirs(dir, 0755); err != nil {
|
if err := fs.MkDirs(dir, 0o755); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
output, err := os.OpenFile(icoFile, os.O_CREATE|os.O_WRONLY, 0644)
|
output, err := os.OpenFile(icoFile, os.O_CREATE|os.O_WRONLY, 0o644)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -226,13 +222,12 @@ func generateIcoFile(options *Options, iconName string, destIconName string) err
|
|||||||
}
|
}
|
||||||
|
|
||||||
func compileResources(options *Options) error {
|
func compileResources(options *Options) error {
|
||||||
|
|
||||||
currentDir, err := os.Getwd()
|
currentDir, err := os.Getwd()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
os.Chdir(currentDir)
|
_ = os.Chdir(currentDir)
|
||||||
}()
|
}()
|
||||||
windowsDir := filepath.Join(options.ProjectData.GetBuildDir(), "windows")
|
windowsDir := filepath.Join(options.ProjectData.GetBuildDir(), "windows")
|
||||||
err = os.Chdir(windowsDir)
|
err = os.Chdir(windowsDir)
|
||||||
|
@ -19,7 +19,7 @@ func NewFileLogger(filename string) Logger {
|
|||||||
|
|
||||||
// Print works like Sprintf.
|
// Print works like Sprintf.
|
||||||
func (l *FileLogger) Print(message string) {
|
func (l *FileLogger) Print(message string) {
|
||||||
f, err := os.OpenFile(l.filename, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
|
f, err := os.OpenFile(l.filename, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0o644)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ func StartAtLogin(enabled bool) error {
|
|||||||
}
|
}
|
||||||
_, stde, err := shell.RunCommand("/tmp", "osascript", "-e", command)
|
_, stde, err := shell.RunCommand("/tmp", "osascript", "-e", command)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errors.Wrap(err, stde)
|
return errors.Wrap(err, stde)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ func ShowNotification(title string, subtitle string, message string, sound strin
|
|||||||
}
|
}
|
||||||
_, stde, err := shell.RunCommand("/tmp", "osascript", "-e", command)
|
_, stde, err := shell.RunCommand("/tmp", "osascript", "-e", command)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errors.Wrap(err, stde)
|
return errors.Wrap(err, stde)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,6 @@ type InputCol struct {
|
|||||||
var Template string
|
var Template string
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
||||||
var Cols []InputCol
|
var Cols []InputCol
|
||||||
|
|
||||||
resp, err := http.Get("https://jonasjacek.github.io/colors/data.json")
|
resp, err := http.Get("https://jonasjacek.github.io/colors/data.json")
|
||||||
@ -62,5 +61,8 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
os.WriteFile(filepath.Join("..", "cols.go"), buffer.Bytes(), 0755)
|
err = os.WriteFile(filepath.Join("..", "cols.go"), buffer.Bytes(), 0o755)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,6 @@ import (
|
|||||||
var namedKeys = slicer.String([]string{"backspace", "tab", "return", "enter", "escape", "left", "right", "up", "down", "space", "delete", "home", "end", "page up", "page down", "f1", "f2", "f3", "f4", "f5", "f6", "f7", "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15", "f16", "f17", "f18", "f19", "f20", "f21", "f22", "f23", "f24", "f25", "f26", "f27", "f28", "f29", "f30", "f31", "f32", "f33", "f34", "f35", "numlock"})
|
var namedKeys = slicer.String([]string{"backspace", "tab", "return", "enter", "escape", "left", "right", "up", "down", "space", "delete", "home", "end", "page up", "page down", "f1", "f2", "f3", "f4", "f5", "f6", "f7", "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15", "f16", "f17", "f18", "f19", "f20", "f21", "f22", "f23", "f24", "f25", "f26", "f27", "f28", "f29", "f30", "f31", "f32", "f33", "f34", "f35", "numlock"})
|
||||||
|
|
||||||
func parseKey(key string) (string, bool) {
|
func parseKey(key string) (string, bool) {
|
||||||
|
|
||||||
// Lowercase!
|
// Lowercase!
|
||||||
key = strings.ToLower(key)
|
key = strings.ToLower(key)
|
||||||
|
|
||||||
@ -38,11 +37,9 @@ func parseKey(key string) (string, bool) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return "", false
|
return "", false
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func Parse(shortcut string) (*Accelerator, error) {
|
func Parse(shortcut string) (*Accelerator, error) {
|
||||||
|
|
||||||
var result Accelerator
|
var result Accelerator
|
||||||
|
|
||||||
// Split the shortcut by +
|
// Split the shortcut by +
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
package keys
|
package keys
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/leaanthony/slicer"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/leaanthony/slicer"
|
||||||
)
|
)
|
||||||
|
|
||||||
var modifierStringMap = map[string]map[Modifier]string{
|
var modifierStringMap = map[string]map[Modifier]string{
|
||||||
|
@ -59,8 +59,7 @@ func (m *Menu) Prepend(item *MenuItem) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewMenuFromItems(first *MenuItem, rest ...*MenuItem) *Menu {
|
func NewMenuFromItems(first *MenuItem, rest ...*MenuItem) *Menu {
|
||||||
|
result := NewMenu()
|
||||||
var result = NewMenu()
|
|
||||||
result.Append(first)
|
result.Append(first)
|
||||||
for _, item := range rest {
|
for _, item := range rest {
|
||||||
result.Append(item)
|
result.Append(item)
|
||||||
|
@ -106,7 +106,6 @@ func (m *MenuItem) removeChild(item *MenuItem) {
|
|||||||
// menu. If there is no parent menu (we are a top level menu) then false is
|
// menu. If there is no parent menu (we are a top level menu) then false is
|
||||||
// returned
|
// returned
|
||||||
func (m *MenuItem) InsertAfter(item *MenuItem) bool {
|
func (m *MenuItem) InsertAfter(item *MenuItem) bool {
|
||||||
|
|
||||||
// We need to find my parent
|
// We need to find my parent
|
||||||
if m.parent == nil {
|
if m.parent == nil {
|
||||||
return false
|
return false
|
||||||
@ -120,7 +119,6 @@ func (m *MenuItem) InsertAfter(item *MenuItem) bool {
|
|||||||
// menu. If there is no parent menu (we are a top level menu) then false is
|
// menu. If there is no parent menu (we are a top level menu) then false is
|
||||||
// returned
|
// returned
|
||||||
func (m *MenuItem) InsertBefore(item *MenuItem) bool {
|
func (m *MenuItem) InsertBefore(item *MenuItem) bool {
|
||||||
|
|
||||||
// We need to find my parent
|
// We need to find my parent
|
||||||
if m.parent == nil {
|
if m.parent == nil {
|
||||||
return false
|
return false
|
||||||
@ -134,8 +132,8 @@ func (m *MenuItem) InsertBefore(item *MenuItem) bool {
|
|||||||
// in this item's submenu. If we are not a submenu,
|
// in this item's submenu. If we are not a submenu,
|
||||||
// then something bad has happened :/
|
// then something bad has happened :/
|
||||||
func (m *MenuItem) insertNewItemAfterGivenItem(target *MenuItem,
|
func (m *MenuItem) insertNewItemAfterGivenItem(target *MenuItem,
|
||||||
newItem *MenuItem) bool {
|
newItem *MenuItem,
|
||||||
|
) bool {
|
||||||
if !m.isSubMenu() {
|
if !m.isSubMenu() {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@ -154,8 +152,8 @@ func (m *MenuItem) insertNewItemAfterGivenItem(target *MenuItem,
|
|||||||
// target in this item's submenu. If we are not a submenu, then something bad
|
// target in this item's submenu. If we are not a submenu, then something bad
|
||||||
// has happened :/
|
// has happened :/
|
||||||
func (m *MenuItem) insertNewItemBeforeGivenItem(target *MenuItem,
|
func (m *MenuItem) insertNewItemBeforeGivenItem(target *MenuItem,
|
||||||
newItem *MenuItem) bool {
|
newItem *MenuItem,
|
||||||
|
) bool {
|
||||||
if !m.isSubMenu() {
|
if !m.isSubMenu() {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@ -176,7 +174,6 @@ func (m *MenuItem) isSubMenu() bool {
|
|||||||
|
|
||||||
// getItemIndex returns the index of the given target relative to this menu
|
// getItemIndex returns the index of the given target relative to this menu
|
||||||
func (m *MenuItem) getItemIndex(target *MenuItem) int {
|
func (m *MenuItem) getItemIndex(target *MenuItem) int {
|
||||||
|
|
||||||
// This should only be called on submenus
|
// This should only be called on submenus
|
||||||
if !m.isSubMenu() {
|
if !m.isSubMenu() {
|
||||||
return -1
|
return -1
|
||||||
@ -196,7 +193,6 @@ func (m *MenuItem) getItemIndex(target *MenuItem) int {
|
|||||||
// the given index
|
// the given index
|
||||||
// Credit: https://stackoverflow.com/a/61822301
|
// Credit: https://stackoverflow.com/a/61822301
|
||||||
func (m *MenuItem) insertItemAtIndex(index int, target *MenuItem) bool {
|
func (m *MenuItem) insertItemAtIndex(index int, target *MenuItem) bool {
|
||||||
|
|
||||||
// If index is OOB, return false
|
// If index is OOB, return false
|
||||||
if index > len(m.SubMenu.Items) {
|
if index > len(m.SubMenu.Items) {
|
||||||
return false
|
return false
|
||||||
|
@ -29,24 +29,31 @@ type StyledText struct {
|
|||||||
func (s *StyledText) Bold() bool {
|
func (s *StyledText) Bold() bool {
|
||||||
return s.Style&Bold == Bold
|
return s.Style&Bold == Bold
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *StyledText) Faint() bool {
|
func (s *StyledText) Faint() bool {
|
||||||
return s.Style&Faint == Faint
|
return s.Style&Faint == Faint
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *StyledText) Italic() bool {
|
func (s *StyledText) Italic() bool {
|
||||||
return s.Style&Italic == Italic
|
return s.Style&Italic == Italic
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *StyledText) Blinking() bool {
|
func (s *StyledText) Blinking() bool {
|
||||||
return s.Style&Blinking == Blinking
|
return s.Style&Blinking == Blinking
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *StyledText) Inversed() bool {
|
func (s *StyledText) Inversed() bool {
|
||||||
return s.Style&Inversed == Inversed
|
return s.Style&Inversed == Inversed
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *StyledText) Invisible() bool {
|
func (s *StyledText) Invisible() bool {
|
||||||
return s.Style&Invisible == Invisible
|
return s.Style&Invisible == Invisible
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *StyledText) Underlined() bool {
|
func (s *StyledText) Underlined() bool {
|
||||||
return s.Style&Underlined == Underlined
|
return s.Style&Underlined == Underlined
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *StyledText) Strikethrough() bool {
|
func (s *StyledText) Strikethrough() bool {
|
||||||
return s.Style&Strikethrough == Strikethrough
|
return s.Style&Strikethrough == Strikethrough
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@ package menu
|
|||||||
|
|
||||||
// TrayMenu are the options
|
// TrayMenu are the options
|
||||||
type TrayMenu struct {
|
type TrayMenu struct {
|
||||||
|
|
||||||
// Label is the text we wish to display in the tray
|
// Label is the text we wish to display in the tray
|
||||||
Label string
|
Label string
|
||||||
|
|
||||||
|
@ -2,8 +2,10 @@ package mac
|
|||||||
|
|
||||||
import "github.com/leaanthony/u"
|
import "github.com/leaanthony/u"
|
||||||
|
|
||||||
var Enabled = u.True
|
var (
|
||||||
var Disabled = u.False
|
Enabled = u.True
|
||||||
|
Disabled = u.False
|
||||||
|
)
|
||||||
|
|
||||||
// Preferences allows to set webkit preferences
|
// Preferences allows to set webkit preferences
|
||||||
type Preferences struct {
|
type Preferences struct {
|
||||||
|
@ -41,7 +41,6 @@ func TitleBarHidden() *TitleBar {
|
|||||||
// TitleBarHiddenInset results in a hidden title bar with an alternative look where
|
// TitleBarHiddenInset results in a hidden title bar with an alternative look where
|
||||||
// the traffic light buttons are slightly more inset from the window edge.
|
// the traffic light buttons are slightly more inset from the window edge.
|
||||||
func TitleBarHiddenInset() *TitleBar {
|
func TitleBarHiddenInset() *TitleBar {
|
||||||
|
|
||||||
return &TitleBar{
|
return &TitleBar{
|
||||||
TitlebarAppearsTransparent: true,
|
TitlebarAppearsTransparent: true,
|
||||||
HideTitle: true,
|
HideTitle: true,
|
||||||
@ -50,5 +49,4 @@ func TitleBarHiddenInset() *TitleBar {
|
|||||||
UseToolbar: true,
|
UseToolbar: true,
|
||||||
HideToolbarSeparator: true,
|
HideToolbarSeparator: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -28,8 +28,7 @@ const (
|
|||||||
Fullscreen WindowStartState = 3
|
Fullscreen WindowStartState = 3
|
||||||
)
|
)
|
||||||
|
|
||||||
type Experimental struct {
|
type Experimental struct{}
|
||||||
}
|
|
||||||
|
|
||||||
// App contains options for creating the App
|
// App contains options for creating the App
|
||||||
type App struct {
|
type App struct {
|
||||||
|
@ -36,7 +36,7 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func RGB(r, g, b uint8) int32 {
|
func RGB(r, g, b uint8) int32 {
|
||||||
var col = int32(b)
|
col := int32(b)
|
||||||
col = col<<8 | int32(g)
|
col = col<<8 | int32(g)
|
||||||
col = col<<8 | int32(r)
|
col = col<<8 | int32(r)
|
||||||
return col
|
return col
|
||||||
|
@ -3,6 +3,7 @@ package runtime
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/wailsapp/wails/v2/internal/frontend"
|
"github.com/wailsapp/wails/v2/internal/frontend"
|
||||||
"github.com/wailsapp/wails/v2/internal/fs"
|
"github.com/wailsapp/wails/v2/internal/fs"
|
||||||
)
|
)
|
||||||
|
@ -10,7 +10,7 @@ func EventsOn(ctx context.Context, eventName string, callback func(optionalData
|
|||||||
return events.On(eventName, callback)
|
return events.On(eventName, callback)
|
||||||
}
|
}
|
||||||
|
|
||||||
// EventsOff unregisters a listener for the given event name, optionally multiple listeneres can be unregistered via `additionalEventNames`
|
// EventsOff unregisters a listener for the given event name, optionally multiple listeners can be unregistered via `additionalEventNames`
|
||||||
func EventsOff(ctx context.Context, eventName string, additionalEventNames ...string) {
|
func EventsOff(ctx context.Context, eventName string, additionalEventNames ...string) {
|
||||||
events := getEvents(ctx)
|
events := getEvents(ctx)
|
||||||
events.Off(eventName)
|
events.Off(eventName)
|
||||||
@ -22,7 +22,7 @@ func EventsOff(ctx context.Context, eventName string, additionalEventNames ...st
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// EventsOff unregisters a listener for the given event name, optionally multiple listeneres can be unregistered via `additionalEventNames`
|
// EventsOff unregisters a listener for the given event name, optionally multiple listeners can be unregistered via `additionalEventNames`
|
||||||
func EventsOffAll(ctx context.Context) {
|
func EventsOffAll(ctx context.Context) {
|
||||||
events := getEvents(ctx)
|
events := getEvents(ctx)
|
||||||
events.OffAll()
|
events.OffAll()
|
||||||
|
@ -3,6 +3,7 @@ package runtime
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/wailsapp/wails/v2/pkg/logger"
|
"github.com/wailsapp/wails/v2/pkg/logger"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@ package runtime
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/wailsapp/wails/v2/pkg/menu"
|
"github.com/wailsapp/wails/v2/pkg/menu"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@ func getFrontend(ctx context.Context) frontend.Frontend {
|
|||||||
log.Fatalf("cannot call '%s': %s", funcName, contextError)
|
log.Fatalf("cannot call '%s': %s", funcName, contextError)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func getLogger(ctx context.Context) *logger.Logger {
|
func getLogger(ctx context.Context) *logger.Logger {
|
||||||
if ctx == nil {
|
if ctx == nil {
|
||||||
pc, _, _, _ := goruntime.Caller(1)
|
pc, _, _, _ := goruntime.Caller(1)
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
package runtime
|
package runtime
|
||||||
|
|
||||||
import "context"
|
import (
|
||||||
import "github.com/wailsapp/wails/v2/internal/frontend"
|
"context"
|
||||||
|
|
||||||
|
"github.com/wailsapp/wails/v2/internal/frontend"
|
||||||
|
)
|
||||||
|
|
||||||
type Screen = frontend.Screen
|
type Screen = frontend.Screen
|
||||||
|
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user