mirror of
https://github.com/taigrr/wails.git
synced 2026-04-17 04:05:12 -07:00
Compare commits
9 Commits
v2.0.0-alp
...
v2.0.0-alp
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7661082d58 | ||
|
|
34da4f056a | ||
|
|
642c1d5ec5 | ||
|
|
1f3351ffa5 | ||
|
|
30e96118b1 | ||
|
|
efd768ac5d | ||
|
|
6dbcd4fc45 | ||
|
|
11cd51c9ca | ||
|
|
3de38003bf |
@@ -21,6 +21,7 @@ The build command processes the Wails project and generates an application binar
|
|||||||
| -upx | Compress final binary with UPX (if installed) | |
|
| -upx | Compress final binary with UPX (if installed) | |
|
||||||
| -upxflags "custom flags" | Flags to pass to upx | |
|
| -upxflags "custom flags" | Flags to pass to upx | |
|
||||||
| -v int | Verbosity level (0 - silent, 1 - default, 2 - verbose) | 1 |
|
| -v int | Verbosity level (0 - silent, 1 - default, 2 - verbose) | 1 |
|
||||||
|
| -delve | If true, runs delve on the compiled binary | false |
|
||||||
|
|
||||||
## The Build Process
|
## The Build Process
|
||||||
|
|
||||||
@@ -44,11 +45,4 @@ The build process is as follows:
|
|||||||
- If the `-upx` flag was provided, `upx` is invoked to compress the binary. Custom flags may be provided using the `-upxflags` flag.
|
- If the `-upx` flag was provided, `upx` is invoked to compress the binary. Custom flags may be provided using the `-upxflags` flag.
|
||||||
- If the `package` flag is given for a non Windows target, the application is bundled for the platform. On Mac, this creates a `.app` with the processed icons, the `Info.plist` in `build/darwin` and the compiled binary.
|
- If the `package` flag is given for a non Windows target, the application is bundled for the platform. On Mac, this creates a `.app` with the processed icons, the `Info.plist` in `build/darwin` and the compiled binary.
|
||||||
|
|
||||||
### Server Target
|
|
||||||
|
|
||||||
TBD
|
|
||||||
|
|
||||||
### Hybrid Target
|
|
||||||
|
|
||||||
TBD
|
|
||||||
|
|
||||||
|
|||||||
@@ -4,11 +4,16 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
|
"os/exec"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
"text/tabwriter"
|
"text/tabwriter"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/wailsapp/wails/v2/internal/system"
|
||||||
|
|
||||||
|
"github.com/wailsapp/wails/v2/internal/shell"
|
||||||
|
|
||||||
"github.com/leaanthony/clir"
|
"github.com/leaanthony/clir"
|
||||||
"github.com/leaanthony/slicer"
|
"github.com/leaanthony/slicer"
|
||||||
"github.com/wailsapp/wails/v2/pkg/clilogger"
|
"github.com/wailsapp/wails/v2/pkg/clilogger"
|
||||||
@@ -72,6 +77,9 @@ func AddBuildSubcommand(app *clir.Cli, w io.Writer) {
|
|||||||
webview2 := "download"
|
webview2 := "download"
|
||||||
command.StringFlag("webview2", "WebView2 installer strategy: download,embed,browser,error.", &webview2)
|
command.StringFlag("webview2", "WebView2 installer strategy: download,embed,browser,error.", &webview2)
|
||||||
|
|
||||||
|
runDelve := false
|
||||||
|
command.BoolFlag("delve", "Runs the built binary in delve for debugging", &runDelve)
|
||||||
|
|
||||||
command.Action(func() error {
|
command.Action(func() error {
|
||||||
|
|
||||||
quiet := verbosity == 0
|
quiet := verbosity == 0
|
||||||
@@ -116,6 +124,12 @@ func AddBuildSubcommand(app *clir.Cli, w io.Writer) {
|
|||||||
compress = false
|
compress = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Lookup compiler path
|
||||||
|
compilerPath, err := exec.LookPath(compilerCommand)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("unable to find compiler: %s", compilerCommand)
|
||||||
|
}
|
||||||
|
|
||||||
// Tags
|
// Tags
|
||||||
userTags := []string{}
|
userTags := []string{}
|
||||||
for _, tag := range strings.Split(tags, " ") {
|
for _, tag := range strings.Split(tags, " ") {
|
||||||
@@ -144,6 +158,11 @@ func AddBuildSubcommand(app *clir.Cli, w io.Writer) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If we want to use delve we need to compile in DEBUG mode
|
||||||
|
if runDelve {
|
||||||
|
mode = build.Debug
|
||||||
|
}
|
||||||
|
|
||||||
// Create BuildOptions
|
// Create BuildOptions
|
||||||
buildOptions := &build.Options{
|
buildOptions := &build.Options{
|
||||||
Logger: logger,
|
Logger: logger,
|
||||||
@@ -160,16 +179,23 @@ func AddBuildSubcommand(app *clir.Cli, w io.Writer) {
|
|||||||
CompressFlags: compressFlags,
|
CompressFlags: compressFlags,
|
||||||
UserTags: userTags,
|
UserTags: userTags,
|
||||||
WebView2Strategy: wv2rtstrategy,
|
WebView2Strategy: wv2rtstrategy,
|
||||||
|
RunDelve: runDelve,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate platform and arch
|
// Calculate platform and arch
|
||||||
platformSplit := strings.Split(platform, "/")
|
platformSplit := strings.Split(platform, "/")
|
||||||
buildOptions.Platform = platformSplit[0]
|
buildOptions.Platform = platformSplit[0]
|
||||||
buildOptions.Arch = runtime.GOARCH
|
if system.IsAppleSilicon() {
|
||||||
|
buildOptions.Arch = "arm64"
|
||||||
|
} else {
|
||||||
|
buildOptions.Arch = runtime.GOARCH
|
||||||
|
}
|
||||||
if len(platformSplit) == 2 {
|
if len(platformSplit) == 2 {
|
||||||
buildOptions.Arch = platformSplit[1]
|
buildOptions.Arch = platformSplit[1]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
println("Build arch =", buildOptions.Arch)
|
||||||
|
|
||||||
// Start a new tabwriter
|
// Start a new tabwriter
|
||||||
w := new(tabwriter.Writer)
|
w := new(tabwriter.Writer)
|
||||||
w.Init(os.Stdout, 8, 8, 0, '\t', 0)
|
w.Init(os.Stdout, 8, 8, 0, '\t', 0)
|
||||||
@@ -184,7 +210,7 @@ func AddBuildSubcommand(app *clir.Cli, w io.Writer) {
|
|||||||
fmt.Fprintf(w, "App Type: \t%s\n", buildOptions.OutputType)
|
fmt.Fprintf(w, "App Type: \t%s\n", buildOptions.OutputType)
|
||||||
fmt.Fprintf(w, "Platform: \t%s\n", buildOptions.Platform)
|
fmt.Fprintf(w, "Platform: \t%s\n", buildOptions.Platform)
|
||||||
fmt.Fprintf(w, "Arch: \t%s\n", buildOptions.Arch)
|
fmt.Fprintf(w, "Arch: \t%s\n", buildOptions.Arch)
|
||||||
fmt.Fprintf(w, "Compiler: \t%s\n", buildOptions.Compiler)
|
fmt.Fprintf(w, "Compiler: \t%s\n", compilerPath)
|
||||||
fmt.Fprintf(w, "Compress: \t%t\n", buildOptions.Compress)
|
fmt.Fprintf(w, "Compress: \t%t\n", buildOptions.Compress)
|
||||||
fmt.Fprintf(w, "Build Mode: \t%s\n", buildModeText)
|
fmt.Fprintf(w, "Build Mode: \t%s\n", buildModeText)
|
||||||
fmt.Fprintf(w, "Package: \t%t\n", buildOptions.Pack)
|
fmt.Fprintf(w, "Package: \t%t\n", buildOptions.Pack)
|
||||||
@@ -219,5 +245,40 @@ func doBuild(buildOptions *build.Options) error {
|
|||||||
buildOptions.Logger.Println(fmt.Sprintf("Built '%s' in %s.", outputFilename, elapsed.Round(time.Millisecond).String()))
|
buildOptions.Logger.Println(fmt.Sprintf("Built '%s' in %s.", outputFilename, elapsed.Round(time.Millisecond).String()))
|
||||||
buildOptions.Logger.Println("")
|
buildOptions.Logger.Println("")
|
||||||
|
|
||||||
|
if buildOptions.RunDelve {
|
||||||
|
// Check delve exists
|
||||||
|
delveExists := shell.CommandExists("dlv")
|
||||||
|
if !delveExists {
|
||||||
|
return fmt.Errorf("cannot launch delve (Is it installed?)")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get cwd
|
||||||
|
cwd, err := os.Getwd()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Launch delve
|
||||||
|
buildOptions.Logger.Println("Launching Delve on port 2345...")
|
||||||
|
cmdArgs := slicer.String([]string{"--listen=:2345", "--headless=true", "--api-version=2", "--accept-multiclient", "exec", outputFilename})
|
||||||
|
if buildOptions.Verbosity == build.VERBOSE {
|
||||||
|
buildOptions.Logger.Println("\tRunning: dlv %s", cmdArgs.Join(" "))
|
||||||
|
}
|
||||||
|
stdout, stderr, err := shell.RunCommand(cwd, "dlv", cmdArgs.AsSlice()...)
|
||||||
|
if buildOptions.Verbosity == build.VERBOSE || err != nil {
|
||||||
|
trimstdout := strings.TrimSpace(stdout)
|
||||||
|
if trimstdout != "" {
|
||||||
|
buildOptions.Logger.Println(trimstdout)
|
||||||
|
}
|
||||||
|
trimstderr := strings.TrimSpace(stderr)
|
||||||
|
if trimstderr != "" {
|
||||||
|
buildOptions.Logger.Println(trimstderr)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,123 +0,0 @@
|
|||||||
package debug
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"github.com/wailsapp/wails/v2/internal/shell"
|
|
||||||
"io"
|
|
||||||
"os"
|
|
||||||
"runtime"
|
|
||||||
"strings"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/leaanthony/clir"
|
|
||||||
"github.com/leaanthony/slicer"
|
|
||||||
"github.com/wailsapp/wails/v2/pkg/clilogger"
|
|
||||||
"github.com/wailsapp/wails/v2/pkg/commands/build"
|
|
||||||
)
|
|
||||||
|
|
||||||
// AddSubcommand adds the `debug` command for the Wails application
|
|
||||||
func AddSubcommand(app *clir.Cli, w io.Writer) error {
|
|
||||||
|
|
||||||
outputType := "desktop"
|
|
||||||
|
|
||||||
validTargetTypes := slicer.String([]string{"desktop", "hybrid", "server"})
|
|
||||||
|
|
||||||
command := app.NewSubCommand("debug", "Builds the application then runs delve on the binary")
|
|
||||||
|
|
||||||
// Setup target type flag
|
|
||||||
description := "Type of application to build. Valid types: " + validTargetTypes.Join(",")
|
|
||||||
command.StringFlag("t", description, &outputType)
|
|
||||||
|
|
||||||
compilerCommand := "go"
|
|
||||||
command.StringFlag("compiler", "Use a different go compiler to build, eg go1.15beta1", &compilerCommand)
|
|
||||||
|
|
||||||
quiet := false
|
|
||||||
command.BoolFlag("q", "Suppress output to console", &quiet)
|
|
||||||
|
|
||||||
// ldflags to pass to `go`
|
|
||||||
ldflags := ""
|
|
||||||
command.StringFlag("ldflags", "optional ldflags", &ldflags)
|
|
||||||
|
|
||||||
// Log to file
|
|
||||||
logFile := ""
|
|
||||||
command.StringFlag("l", "Log to file", &logFile)
|
|
||||||
|
|
||||||
command.Action(func() error {
|
|
||||||
|
|
||||||
// Create logger
|
|
||||||
logger := clilogger.New(w)
|
|
||||||
logger.Mute(quiet)
|
|
||||||
|
|
||||||
// Validate output type
|
|
||||||
if !validTargetTypes.Contains(outputType) {
|
|
||||||
return fmt.Errorf("output type '%s' is not valid", outputType)
|
|
||||||
}
|
|
||||||
|
|
||||||
if !quiet {
|
|
||||||
app.PrintBanner()
|
|
||||||
}
|
|
||||||
|
|
||||||
task := fmt.Sprintf("Building %s Application", strings.Title(outputType))
|
|
||||||
logger.Println(task)
|
|
||||||
logger.Println(strings.Repeat("-", len(task)))
|
|
||||||
|
|
||||||
// Setup mode
|
|
||||||
mode := build.Debug
|
|
||||||
|
|
||||||
// Create BuildOptions
|
|
||||||
buildOptions := &build.Options{
|
|
||||||
Logger: logger,
|
|
||||||
OutputType: outputType,
|
|
||||||
Mode: mode,
|
|
||||||
Pack: false,
|
|
||||||
Platform: runtime.GOOS,
|
|
||||||
LDFlags: ldflags,
|
|
||||||
Compiler: compilerCommand,
|
|
||||||
KeepAssets: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
outputFilename, err := doDebugBuild(buildOptions)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check delve exists
|
|
||||||
delveExists := shell.CommandExists("dlv")
|
|
||||||
if !delveExists {
|
|
||||||
return fmt.Errorf("cannot launch delve (Is it installed?)")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get cwd
|
|
||||||
cwd, err := os.Getwd()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Launch delve
|
|
||||||
println("Launching Delve on port 2345...")
|
|
||||||
command := shell.CreateCommand(cwd, "dlv", "--listen=:2345", "--headless=true", "--api-version=2", "--accept-multiclient", "exec", outputFilename)
|
|
||||||
return command.Run()
|
|
||||||
})
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// doDebugBuild is our main build command
|
|
||||||
func doDebugBuild(buildOptions *build.Options) (string, error) {
|
|
||||||
|
|
||||||
// Start Time
|
|
||||||
start := time.Now()
|
|
||||||
|
|
||||||
outputFilename, err := build.Build(buildOptions)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Output stats
|
|
||||||
elapsed := time.Since(start)
|
|
||||||
buildOptions.Logger.Println("")
|
|
||||||
buildOptions.Logger.Println(fmt.Sprintf("Built '%s' in %s.", outputFilename, elapsed.Round(time.Millisecond).String()))
|
|
||||||
buildOptions.Logger.Println("")
|
|
||||||
|
|
||||||
return outputFilename, nil
|
|
||||||
}
|
|
||||||
@@ -12,13 +12,14 @@ The next steps to complete the template are:
|
|||||||
- `html` - path to your `index.html`
|
- `html` - path to your `index.html`
|
||||||
- `frontend:install` - The command to install your frontend dependencies
|
- `frontend:install` - The command to install your frontend dependencies
|
||||||
- `frontend:build` - The command to build your frontend
|
- `frontend:build` - The command to build your frontend
|
||||||
4. Delete this file.
|
4. Remove any `public` or `dist` directories.
|
||||||
|
5. Delete this file.
|
||||||
|
|
||||||
## Testing your template
|
## Testing your template
|
||||||
|
|
||||||
You can test your template by running this command:
|
You can test your template by running this command:
|
||||||
|
|
||||||
`wails init -name test -t /path/to/your/new/template`
|
`wails init -name test -t {{.TemplateDir}}`
|
||||||
|
|
||||||
### Checklist
|
### Checklist
|
||||||
Once generated, do the following tests:
|
Once generated, do the following tests:
|
||||||
@@ -6,29 +6,29 @@ import (
|
|||||||
"github.com/wailsapp/wails/v2"
|
"github.com/wailsapp/wails/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Basic application struct
|
// App struct
|
||||||
type Basic struct {
|
type App struct {
|
||||||
runtime *wails.Runtime
|
runtime *wails.Runtime
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewBasic creates a new Basic application struct
|
// NewApp creates a new App application struct
|
||||||
func NewBasic() *Basic {
|
func NewApp() *App {
|
||||||
return &Basic{}
|
return &App{}
|
||||||
}
|
}
|
||||||
|
|
||||||
// startup is called at application startup
|
// startup is called at application startup
|
||||||
func (b *Basic) startup(runtime *wails.Runtime) {
|
func (b *App) startup(runtime *wails.Runtime) {
|
||||||
// Perform your setup here
|
// Perform your setup here
|
||||||
b.runtime = runtime
|
b.runtime = runtime
|
||||||
runtime.Window.SetTitle("{{.ProjectName}}")
|
runtime.Window.SetTitle("{{.ProjectName}}")
|
||||||
}
|
}
|
||||||
|
|
||||||
// shutdown is called at application termination
|
// shutdown is called at application termination
|
||||||
func (b *Basic) shutdown() {
|
func (b *App) shutdown() {
|
||||||
// Perform your teardown here
|
// Perform your teardown here
|
||||||
}
|
}
|
||||||
|
|
||||||
// Greet returns a greeting for the given name
|
// Greet returns a greeting for the given name
|
||||||
func (b *Basic) Greet(name string) string {
|
func (b *App) Greet(name string) string {
|
||||||
return fmt.Sprintf("Hello %s!", name)
|
return fmt.Sprintf("Hello %s!", name)
|
||||||
}
|
}
|
||||||
@@ -15,7 +15,7 @@ import (
|
|||||||
func main() {
|
func main() {
|
||||||
|
|
||||||
// Create application with options
|
// Create application with options
|
||||||
app := NewBasic()
|
app := NewApp()
|
||||||
|
|
||||||
err := wails.Run(&options.App{
|
err := wails.Run(&options.App{
|
||||||
Title: "{{.ProjectName}}",
|
Title: "{{.ProjectName}}",
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
"outputfilename": "{{.BinaryName}}",
|
"outputfilename": "{{.BinaryName}}",
|
||||||
"html": "frontend/dist/index.html",
|
"html": "frontend/dist/index.html",
|
||||||
"frontend:build": "npm run build",
|
"frontend:build": "npm run build",
|
||||||
"frontend:install": "npm ci",
|
"frontend:install": "npm install",
|
||||||
"author": {
|
"author": {
|
||||||
"name": "{{.AuthorName}}",
|
"name": "{{.AuthorName}}",
|
||||||
"email": "{{.AuthorEmail}}"
|
"email": "{{.AuthorEmail}}"
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import (
|
|||||||
"github.com/wailsapp/wails/v2/internal/fs"
|
"github.com/wailsapp/wails/v2/internal/fs"
|
||||||
|
|
||||||
"github.com/leaanthony/clir"
|
"github.com/leaanthony/clir"
|
||||||
|
"github.com/tidwall/sjson"
|
||||||
)
|
)
|
||||||
|
|
||||||
//go:embed base
|
//go:embed base
|
||||||
@@ -25,8 +26,8 @@ func AddSubCommand(app *clir.Cli, parent *clir.Command, w io.Writer) {
|
|||||||
name := ""
|
name := ""
|
||||||
command.StringFlag("name", "The name of the template", &name)
|
command.StringFlag("name", "The name of the template", &name)
|
||||||
|
|
||||||
useLocalFilesAsFrontend := false
|
migrate := false
|
||||||
command.BoolFlag("frontend", "This indicates that the current directory is a frontend project and should be used by the template", &useLocalFilesAsFrontend)
|
command.BoolFlag("migrate", "This indicates that the current directory is a frontend project and should be used by the template", &migrate)
|
||||||
|
|
||||||
// Quiet Init
|
// Quiet Init
|
||||||
quiet := false
|
quiet := false
|
||||||
@@ -46,6 +47,7 @@ func AddSubCommand(app *clir.Cli, parent *clir.Command, w io.Writer) {
|
|||||||
}
|
}
|
||||||
if !empty {
|
if !empty {
|
||||||
templateDir = filepath.Join(cwd, name)
|
templateDir = filepath.Join(cwd, name)
|
||||||
|
println("Creating new template directory:", name)
|
||||||
err = fs.Mkdir(templateDir)
|
err = fs.Mkdir(templateDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -68,16 +70,21 @@ func AddSubCommand(app *clir.Cli, parent *clir.Command, w io.Writer) {
|
|||||||
type templateData struct {
|
type templateData struct {
|
||||||
Name string
|
Name string
|
||||||
Description string
|
Description string
|
||||||
|
TemplateDir string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
println("Extracting base template files...")
|
||||||
|
|
||||||
err = g.Extract(templateDir, &templateData{
|
err = g.Extract(templateDir, &templateData{
|
||||||
Name: name,
|
Name: name,
|
||||||
|
TemplateDir: templateDir,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if useLocalFilesAsFrontend == false {
|
// If we aren't migrating the files, just exit
|
||||||
|
if migrate == false {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,44 +95,94 @@ func AddSubCommand(app *clir.Cli, parent *clir.Command, w io.Writer) {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = fs.CopyDirExtended(cwd, frontendDir, []string{name})
|
// Move the files into a new frontend directory
|
||||||
|
println("Migrating files to frontend directory...")
|
||||||
|
err = fs.MoveDirExtended(cwd, frontendDir, []string{name})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
//// Create logger
|
// Process package.json
|
||||||
//logger := clilogger.New(w)
|
err = processPackageJSON(frontendDir)
|
||||||
//logger.Mute(quiet)
|
if err != nil {
|
||||||
//
|
return err
|
||||||
//app.PrintBanner()
|
}
|
||||||
//
|
|
||||||
//logger.Print("Generating Javascript module for Go code...")
|
// Process package-lock.json
|
||||||
//
|
err = processPackageLockJSON(frontendDir)
|
||||||
//// Start Time
|
if err != nil {
|
||||||
//start := time.Now()
|
return err
|
||||||
//
|
}
|
||||||
//p, err := parser.GenerateWailsFrontendPackage()
|
|
||||||
//if err != nil {
|
// Remove node_modules - ignore error, eg it doesn't exist
|
||||||
// return err
|
_ = os.RemoveAll(filepath.Join(frontendDir, "node_modules"))
|
||||||
//}
|
|
||||||
//
|
|
||||||
//logger.Println("done.")
|
|
||||||
//logger.Println("")
|
|
||||||
//
|
|
||||||
//elapsed := time.Since(start)
|
|
||||||
//packages := p.Packages
|
|
||||||
//
|
|
||||||
//// Print report
|
|
||||||
//for _, pkg := range p.Packages {
|
|
||||||
// if pkg.ShouldGenerate() {
|
|
||||||
// generate.logPackage(pkg, logger)
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//logger.Println("%d packages parsed in %s.", len(packages), elapsed)
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func processPackageJSON(frontendDir string) error {
|
||||||
|
var err error
|
||||||
|
|
||||||
|
packageJSON := filepath.Join(frontendDir, "package.json")
|
||||||
|
if !fs.FileExists(packageJSON) {
|
||||||
|
println("No package.json found - cannot process.")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
data, err := os.ReadFile(packageJSON)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
json := string(data)
|
||||||
|
|
||||||
|
// We will ignore these errors - it's not critical
|
||||||
|
println("Updating package.json data...")
|
||||||
|
json, _ = sjson.Set(json, "name", "{{.ProjectName}}")
|
||||||
|
json, _ = sjson.Set(json, "author", "{{.AuthorName}}")
|
||||||
|
|
||||||
|
err = os.WriteFile(packageJSON, []byte(json), 0644)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
baseDir := filepath.Dir(packageJSON)
|
||||||
|
println("Renaming package.json -> package.tmpl.json...")
|
||||||
|
err = os.Rename(packageJSON, filepath.Join(baseDir, "package.tmpl.json"))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func processPackageLockJSON(frontendDir string) error {
|
||||||
|
var err error
|
||||||
|
|
||||||
|
filename := filepath.Join(frontendDir, "package-lock.json")
|
||||||
|
if !fs.FileExists(filename) {
|
||||||
|
println("No package-lock.json found - cannot process.")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
data, err := os.ReadFile(filename)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
json := string(data)
|
||||||
|
|
||||||
|
// We will ignore these errors - it's not critical
|
||||||
|
println("Updating package-lock.json data...")
|
||||||
|
json, _ = sjson.Set(json, "name", "{{.ProjectName}}")
|
||||||
|
|
||||||
|
err = os.WriteFile(filename, []byte(json), 0644)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
baseDir := filepath.Dir(filename)
|
||||||
|
println("Renaming package-lock.json -> package-lock.tmpl.json...")
|
||||||
|
err = os.Rename(filename, filepath.Join(baseDir, "package-lock.tmpl.json"))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
# README
|
||||||
|
|
||||||
|
## About
|
||||||
|
|
||||||
|
This is a basic Svelte template, using rollup to bundle the assets into a single JS file.
|
||||||
|
Rollup is configured to do the following:
|
||||||
|
|
||||||
|
- Convert imported images to base64 strings
|
||||||
|
- Convert `url()` in `@font-face` declarations to base64 strings
|
||||||
|
- Bundle all css into the JS bundle
|
||||||
|
- Copy `index.html` from `frontend/src/` to `frontend/dist/`
|
||||||
|
|
||||||
|
Clicking the button will call the backend
|
||||||
|
|
||||||
|
## Building
|
||||||
|
|
||||||
|
To build this project in debug mode, use `wails build`. For production, use `wails build -production`.
|
||||||
|
To generate a platform native package, add the `-package` flag.
|
||||||
|
|
||||||
|
## Live Development
|
||||||
|
|
||||||
|
To run in live development mode, run `wails dev` in the project directory. In another terminal, go into the `frontend`
|
||||||
|
directory and run `npm run dev`. The frontend dev server will run on http://localhost:5000. Connect to this
|
||||||
|
in your browser and connect to your application.
|
||||||
@@ -6,29 +6,29 @@ import (
|
|||||||
"github.com/wailsapp/wails/v2"
|
"github.com/wailsapp/wails/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Basic application struct
|
// App application struct
|
||||||
type Basic struct {
|
type App struct {
|
||||||
runtime *wails.Runtime
|
runtime *wails.Runtime
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewBasic creates a new Basic application struct
|
// NewApp creates a new App application struct
|
||||||
func NewBasic() *Basic {
|
func NewApp() *App {
|
||||||
return &Basic{}
|
return &App{}
|
||||||
}
|
}
|
||||||
|
|
||||||
// startup is called at application startup
|
// startup is called at application startup
|
||||||
func (b *Basic) startup(runtime *wails.Runtime) {
|
func (b *App) startup(runtime *wails.Runtime) {
|
||||||
// Perform your setup here
|
// Perform your setup here
|
||||||
b.runtime = runtime
|
b.runtime = runtime
|
||||||
runtime.Window.SetTitle("{{.ProjectName}}")
|
runtime.Window.SetTitle("{{.ProjectName}}")
|
||||||
}
|
}
|
||||||
|
|
||||||
// shutdown is called at application termination
|
// shutdown is called at application termination
|
||||||
func (b *Basic) shutdown() {
|
func (b *App) shutdown() {
|
||||||
// Perform your teardown here
|
// Perform your teardown here
|
||||||
}
|
}
|
||||||
|
|
||||||
// Greet returns a greeting for the given name
|
// Greet returns a greeting for the given name
|
||||||
func (b *Basic) Greet(name string) string {
|
func (b *App) Greet(name string) string {
|
||||||
return fmt.Sprintf("Hello %s!", name)
|
return fmt.Sprintf("Hello %s!", name)
|
||||||
}
|
}
|
||||||
4
v2/cmd/wails/internal/commands/initialise/templates/templates/svelte/frontend/.gitignore
vendored
Normal file
4
v2/cmd/wails/internal/commands/initialise/templates/templates/svelte/frontend/.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
/node_modules/
|
||||||
|
/dist/build/
|
||||||
|
|
||||||
|
.DS_Store
|
||||||
@@ -0,0 +1,105 @@
|
|||||||
|
*Looking for a shareable component template? Go here --> [sveltejs/component-template](https://github.com/sveltejs/component-template)*
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
# svelte app
|
||||||
|
|
||||||
|
This is a project template for [Svelte](https://svelte.dev) apps. It lives at https://github.com/sveltejs/template.
|
||||||
|
|
||||||
|
To create a new project based on this template using [degit](https://github.com/Rich-Harris/degit):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npx degit sveltejs/template svelte-app
|
||||||
|
cd svelte-app
|
||||||
|
```
|
||||||
|
|
||||||
|
*Note that you will need to have [Node.js](https://nodejs.org) installed.*
|
||||||
|
|
||||||
|
|
||||||
|
## Get started
|
||||||
|
|
||||||
|
Install the dependencies...
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd svelte-app
|
||||||
|
npm install
|
||||||
|
```
|
||||||
|
|
||||||
|
...then start [Rollup](https://rollupjs.org):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run dev
|
||||||
|
```
|
||||||
|
|
||||||
|
Navigate to [localhost:5000](http://localhost:5000). You should see your app running. Edit a component file in `src`, save it, and reload the page to see your changes.
|
||||||
|
|
||||||
|
By default, the server will only respond to requests from localhost. To allow connections from other computers, edit the `sirv` commands in package.json to include the option `--host 0.0.0.0`.
|
||||||
|
|
||||||
|
If you're using [Visual Studio Code](https://code.visualstudio.com/) we recommend installing the official extension [Svelte for VS Code](https://marketplace.visualstudio.com/items?itemName=svelte.svelte-vscode). If you are using other editors you may need to install a plugin in order to get syntax highlighting and intellisense.
|
||||||
|
|
||||||
|
## Building and running in production mode
|
||||||
|
|
||||||
|
To create an optimised version of the app:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run build
|
||||||
|
```
|
||||||
|
|
||||||
|
You can run the newly built app with `npm run start`. This uses [sirv](https://github.com/lukeed/sirv), which is included in your package.json's `dependencies` so that the app will work when you deploy to platforms like [Heroku](https://heroku.com).
|
||||||
|
|
||||||
|
|
||||||
|
## Single-page app mode
|
||||||
|
|
||||||
|
By default, sirv will only respond to requests that match files in `public`. This is to maximise compatibility with static fileservers, allowing you to deploy your app anywhere.
|
||||||
|
|
||||||
|
If you're building a single-page app (SPA) with multiple routes, sirv needs to be able to respond to requests for *any* path. You can make it so by editing the `"start"` command in package.json:
|
||||||
|
|
||||||
|
```js
|
||||||
|
"start": "sirv public --single"
|
||||||
|
```
|
||||||
|
|
||||||
|
## Using TypeScript
|
||||||
|
|
||||||
|
This template comes with a script to set up a TypeScript development environment, you can run it immediately after cloning the template with:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
node scripts/setupTypeScript.js
|
||||||
|
```
|
||||||
|
|
||||||
|
Or remove the script via:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
rm scripts/setupTypeScript.js
|
||||||
|
```
|
||||||
|
|
||||||
|
## Deploying to the web
|
||||||
|
|
||||||
|
### With [Vercel](https://vercel.com)
|
||||||
|
|
||||||
|
Install `vercel` if you haven't already:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm install -g vercel
|
||||||
|
```
|
||||||
|
|
||||||
|
Then, from within your project folder:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd public
|
||||||
|
vercel deploy --name my-project
|
||||||
|
```
|
||||||
|
|
||||||
|
### With [surge](https://surge.sh/)
|
||||||
|
|
||||||
|
Install `surge` if you haven't already:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm install -g surge
|
||||||
|
```
|
||||||
|
|
||||||
|
Then, from within your project folder:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run build
|
||||||
|
surge public my-project.surge.sh
|
||||||
|
```
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,27 @@
|
|||||||
|
{
|
||||||
|
"name": "{{.ProjectName}}",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"private": true,
|
||||||
|
"scripts": {
|
||||||
|
"build": "rollup -c",
|
||||||
|
"dev": "rollup -c -w",
|
||||||
|
"start": "sirv dist --no-clear"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@rollup/plugin-commonjs": "^17.0.0",
|
||||||
|
"@rollup/plugin-image": "^2.0.6",
|
||||||
|
"@rollup/plugin-node-resolve": "^11.0.0",
|
||||||
|
"postcss": "^8.3.5",
|
||||||
|
"postcss-url": "^10.1.3",
|
||||||
|
"rollup": "^2.3.4",
|
||||||
|
"rollup-plugin-copy": "^3.4.0",
|
||||||
|
"rollup-plugin-livereload": "^2.0.0",
|
||||||
|
"rollup-plugin-postcss": "^4.0.0",
|
||||||
|
"rollup-plugin-svelte": "^7.0.0",
|
||||||
|
"rollup-plugin-terser": "^7.0.0",
|
||||||
|
"svelte": "^3.0.0"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"sirv-cli": "^1.0.0"
|
||||||
|
}
|
||||||
|
,"author":"{{.AuthorName}}"}
|
||||||
@@ -0,0 +1,91 @@
|
|||||||
|
import svelte from 'rollup-plugin-svelte';
|
||||||
|
import commonjs from '@rollup/plugin-commonjs';
|
||||||
|
import resolve from '@rollup/plugin-node-resolve';
|
||||||
|
import livereload from 'rollup-plugin-livereload';
|
||||||
|
import { terser } from 'rollup-plugin-terser';
|
||||||
|
import copy from 'rollup-plugin-copy';
|
||||||
|
import image from '@rollup/plugin-image';
|
||||||
|
import postcss from 'rollup-plugin-postcss'
|
||||||
|
import url from 'postcss-url';
|
||||||
|
|
||||||
|
const production = !process.env.ROLLUP_WATCH;
|
||||||
|
|
||||||
|
function serve() {
|
||||||
|
let server;
|
||||||
|
|
||||||
|
function toExit() {
|
||||||
|
if (server) server.kill(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
writeBundle() {
|
||||||
|
if (server) return;
|
||||||
|
server = require('child_process').spawn('npm', ['run', 'start', '--', '--dev'], {
|
||||||
|
stdio: ['ignore', 'inherit', 'inherit'],
|
||||||
|
shell: true
|
||||||
|
});
|
||||||
|
|
||||||
|
process.on('SIGTERM', toExit);
|
||||||
|
process.on('exit', toExit);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export default {
|
||||||
|
input: 'src/main.js',
|
||||||
|
output: {
|
||||||
|
sourcemap: true,
|
||||||
|
format: 'iife',
|
||||||
|
name: 'app',
|
||||||
|
file: 'dist/bundle.js'
|
||||||
|
},
|
||||||
|
plugins: [
|
||||||
|
image({
|
||||||
|
include: './src/assets/images/**'
|
||||||
|
}),
|
||||||
|
svelte({
|
||||||
|
compilerOptions: {
|
||||||
|
// enable run-time checks when not in production
|
||||||
|
dev: !production
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
postcss({
|
||||||
|
minimize: true,
|
||||||
|
plugins: [
|
||||||
|
url({
|
||||||
|
url: "inline"
|
||||||
|
})
|
||||||
|
]
|
||||||
|
}),
|
||||||
|
// If you have external dependencies installed from
|
||||||
|
// npm, you'll most likely need these plugins. In
|
||||||
|
// some cases you'll need additional configuration -
|
||||||
|
// consult the documentation for details:
|
||||||
|
// https://github.com/rollup/plugins/tree/master/packages/commonjs
|
||||||
|
resolve({
|
||||||
|
browser: true,
|
||||||
|
dedupe: ['svelte']
|
||||||
|
}),
|
||||||
|
commonjs(),
|
||||||
|
copy({
|
||||||
|
targets: [
|
||||||
|
{ src: 'src/index.html', dest: 'dist/' },
|
||||||
|
]
|
||||||
|
}),
|
||||||
|
|
||||||
|
// In dev mode, call `npm run start` once
|
||||||
|
// the bundle has been generated
|
||||||
|
!production && serve(),
|
||||||
|
|
||||||
|
// Watch the `dist` directory and refresh the
|
||||||
|
// browser on changes when not in production
|
||||||
|
!production && livereload('dist'),
|
||||||
|
|
||||||
|
// If we're building for production (npm run build
|
||||||
|
// instead of npm run dev), minify
|
||||||
|
production && terser()
|
||||||
|
],
|
||||||
|
watch: {
|
||||||
|
clearScreen: false
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,121 @@
|
|||||||
|
// @ts-check
|
||||||
|
|
||||||
|
/** This script modifies the project to support TS code in .svelte files like:
|
||||||
|
|
||||||
|
<script lang="ts">
|
||||||
|
export let name: string;
|
||||||
|
</script>
|
||||||
|
|
||||||
|
As well as validating the code for CI.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** To work on this script:
|
||||||
|
rm -rf test-template template && git clone sveltejs/template test-template && node scripts/setupTypeScript.js test-template
|
||||||
|
*/
|
||||||
|
|
||||||
|
const fs = require("fs")
|
||||||
|
const path = require("path")
|
||||||
|
const { argv } = require("process")
|
||||||
|
|
||||||
|
const projectRoot = argv[2] || path.join(__dirname, "..")
|
||||||
|
|
||||||
|
// Add deps to pkg.json
|
||||||
|
const packageJSON = JSON.parse(fs.readFileSync(path.join(projectRoot, "package.json"), "utf8"))
|
||||||
|
packageJSON.devDependencies = Object.assign(packageJSON.devDependencies, {
|
||||||
|
"svelte-check": "^2.0.0",
|
||||||
|
"svelte-preprocess": "^4.0.0",
|
||||||
|
"@rollup/plugin-typescript": "^8.0.0",
|
||||||
|
"typescript": "^4.0.0",
|
||||||
|
"tslib": "^2.0.0",
|
||||||
|
"@tsconfig/svelte": "^2.0.0"
|
||||||
|
})
|
||||||
|
|
||||||
|
// Add script for checking
|
||||||
|
packageJSON.scripts = Object.assign(packageJSON.scripts, {
|
||||||
|
"check": "svelte-check --tsconfig ./tsconfig.json"
|
||||||
|
})
|
||||||
|
|
||||||
|
// Write the package JSON
|
||||||
|
fs.writeFileSync(path.join(projectRoot, "package.json"), JSON.stringify(packageJSON, null, " "))
|
||||||
|
|
||||||
|
// mv src/main.js to main.ts - note, we need to edit rollup.config.js for this too
|
||||||
|
const beforeMainJSPath = path.join(projectRoot, "src", "main.js")
|
||||||
|
const afterMainTSPath = path.join(projectRoot, "src", "main.ts")
|
||||||
|
fs.renameSync(beforeMainJSPath, afterMainTSPath)
|
||||||
|
|
||||||
|
// Switch the app.svelte file to use TS
|
||||||
|
const appSveltePath = path.join(projectRoot, "src", "App.svelte")
|
||||||
|
let appFile = fs.readFileSync(appSveltePath, "utf8")
|
||||||
|
appFile = appFile.replace("<script>", '<script lang="ts">')
|
||||||
|
appFile = appFile.replace("export let name;", 'export let name: string;')
|
||||||
|
fs.writeFileSync(appSveltePath, appFile)
|
||||||
|
|
||||||
|
// Edit rollup config
|
||||||
|
const rollupConfigPath = path.join(projectRoot, "rollup.config.js")
|
||||||
|
let rollupConfig = fs.readFileSync(rollupConfigPath, "utf8")
|
||||||
|
|
||||||
|
// Edit imports
|
||||||
|
rollupConfig = rollupConfig.replace(`'rollup-plugin-terser';`, `'rollup-plugin-terser';
|
||||||
|
import sveltePreprocess from 'svelte-preprocess';
|
||||||
|
import typescript from '@rollup/plugin-typescript';`)
|
||||||
|
|
||||||
|
// Replace name of entry point
|
||||||
|
rollupConfig = rollupConfig.replace(`'src/main.js'`, `'src/main.ts'`)
|
||||||
|
|
||||||
|
// Add preprocessor
|
||||||
|
rollupConfig = rollupConfig.replace(
|
||||||
|
'compilerOptions:',
|
||||||
|
'preprocess: sveltePreprocess({ sourceMap: !production }),\n\t\t\tcompilerOptions:'
|
||||||
|
);
|
||||||
|
|
||||||
|
// Add TypeScript
|
||||||
|
rollupConfig = rollupConfig.replace(
|
||||||
|
'commonjs(),',
|
||||||
|
'commonjs(),\n\t\ttypescript({\n\t\t\tsourceMap: !production,\n\t\t\tinlineSources: !production\n\t\t}),'
|
||||||
|
);
|
||||||
|
fs.writeFileSync(rollupConfigPath, rollupConfig)
|
||||||
|
|
||||||
|
// Add TSConfig
|
||||||
|
const tsconfig = `{
|
||||||
|
"extends": "@tsconfig/svelte/tsconfig.json",
|
||||||
|
|
||||||
|
"include": ["src/**/*"],
|
||||||
|
"exclude": ["node_modules/*", "__sapper__/*", "public/*"]
|
||||||
|
}`
|
||||||
|
const tsconfigPath = path.join(projectRoot, "tsconfig.json")
|
||||||
|
fs.writeFileSync(tsconfigPath, tsconfig)
|
||||||
|
|
||||||
|
// Add global.d.ts
|
||||||
|
const dtsPath = path.join(projectRoot, "src", "global.d.ts")
|
||||||
|
fs.writeFileSync(dtsPath, `/// <reference types="svelte" />`)
|
||||||
|
|
||||||
|
// Delete this script, but not during testing
|
||||||
|
if (!argv[2]) {
|
||||||
|
// Remove the script
|
||||||
|
fs.unlinkSync(path.join(__filename))
|
||||||
|
|
||||||
|
// Check for Mac's DS_store file, and if it's the only one left remove it
|
||||||
|
const remainingFiles = fs.readdirSync(path.join(__dirname))
|
||||||
|
if (remainingFiles.length === 1 && remainingFiles[0] === '.DS_store') {
|
||||||
|
fs.unlinkSync(path.join(__dirname, '.DS_store'))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if the scripts folder is empty
|
||||||
|
if (fs.readdirSync(path.join(__dirname)).length === 0) {
|
||||||
|
// Remove the scripts folder
|
||||||
|
fs.rmdirSync(path.join(__dirname))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Adds the extension recommendation
|
||||||
|
fs.mkdirSync(path.join(projectRoot, ".vscode"), { recursive: true })
|
||||||
|
fs.writeFileSync(path.join(projectRoot, ".vscode", "extensions.json"), `{
|
||||||
|
"recommendations": ["svelte.svelte-vscode"]
|
||||||
|
}
|
||||||
|
`)
|
||||||
|
|
||||||
|
console.log("Converted to TypeScript.")
|
||||||
|
|
||||||
|
if (fs.existsSync(path.join(projectRoot, "node_modules"))) {
|
||||||
|
console.log("\nYou will need to re-run your dependency manager to get started.")
|
||||||
|
}
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
<script>
|
||||||
|
let name = "";
|
||||||
|
let greeting = "";
|
||||||
|
|
||||||
|
function greet() {
|
||||||
|
window.backend.main.App.Greet(name).then((result) => {
|
||||||
|
greeting = result;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<main>
|
||||||
|
<div id="logo"></div>
|
||||||
|
<div id="input" data-wails-no-drag>
|
||||||
|
<input id="name" type="text" bind:value={name}>
|
||||||
|
<button class="button" on:click={greet}>Greet</button>
|
||||||
|
</div>
|
||||||
|
{#if greeting}
|
||||||
|
<div id="result">{greeting}</div>
|
||||||
|
{/if}
|
||||||
|
</main>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
|
||||||
|
main {
|
||||||
|
height: 100%;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
#result {
|
||||||
|
margin-top: 1rem;
|
||||||
|
font-size: 1.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
button {
|
||||||
|
-webkit-appearance: default-button;
|
||||||
|
padding: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#name {
|
||||||
|
border-radius: 3px;
|
||||||
|
outline: none;
|
||||||
|
-webkit-font-smoothing: antialiased;
|
||||||
|
}
|
||||||
|
|
||||||
|
#logo {
|
||||||
|
width: 40%;
|
||||||
|
height: 40%;
|
||||||
|
padding-top: 20%;
|
||||||
|
margin: auto;
|
||||||
|
display: block;
|
||||||
|
background-position: center;
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
background-image: url("assets/images/logo-dark.svg");
|
||||||
|
}
|
||||||
|
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,93 @@
|
|||||||
|
Copyright 2016 The Nunito Project Authors (contact@sansoxygen.com),
|
||||||
|
|
||||||
|
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
||||||
|
This license is copied below, and is also available with a FAQ at:
|
||||||
|
http://scripts.sil.org/OFL
|
||||||
|
|
||||||
|
|
||||||
|
-----------------------------------------------------------
|
||||||
|
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
||||||
|
-----------------------------------------------------------
|
||||||
|
|
||||||
|
PREAMBLE
|
||||||
|
The goals of the Open Font License (OFL) are to stimulate worldwide
|
||||||
|
development of collaborative font projects, to support the font creation
|
||||||
|
efforts of academic and linguistic communities, and to provide a free and
|
||||||
|
open framework in which fonts may be shared and improved in partnership
|
||||||
|
with others.
|
||||||
|
|
||||||
|
The OFL allows the licensed fonts to be used, studied, modified and
|
||||||
|
redistributed freely as long as they are not sold by themselves. The
|
||||||
|
fonts, including any derivative works, can be bundled, embedded,
|
||||||
|
redistributed and/or sold with any software provided that any reserved
|
||||||
|
names are not used by derivative works. The fonts and derivatives,
|
||||||
|
however, cannot be released under any other type of license. The
|
||||||
|
requirement for fonts to remain under this license does not apply
|
||||||
|
to any document created using the fonts or their derivatives.
|
||||||
|
|
||||||
|
DEFINITIONS
|
||||||
|
"Font Software" refers to the set of files released by the Copyright
|
||||||
|
Holder(s) under this license and clearly marked as such. This may
|
||||||
|
include source files, build scripts and documentation.
|
||||||
|
|
||||||
|
"Reserved Font Name" refers to any names specified as such after the
|
||||||
|
copyright statement(s).
|
||||||
|
|
||||||
|
"Original Version" refers to the collection of Font Software components as
|
||||||
|
distributed by the Copyright Holder(s).
|
||||||
|
|
||||||
|
"Modified Version" refers to any derivative made by adding to, deleting,
|
||||||
|
or substituting -- in part or in whole -- any of the components of the
|
||||||
|
Original Version, by changing formats or by porting the Font Software to a
|
||||||
|
new environment.
|
||||||
|
|
||||||
|
"Author" refers to any designer, engineer, programmer, technical
|
||||||
|
writer or other person who contributed to the Font Software.
|
||||||
|
|
||||||
|
PERMISSION & CONDITIONS
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
||||||
|
redistribute, and sell modified and unmodified copies of the Font
|
||||||
|
Software, subject to the following conditions:
|
||||||
|
|
||||||
|
1) Neither the Font Software nor any of its individual components,
|
||||||
|
in Original or Modified Versions, may be sold by itself.
|
||||||
|
|
||||||
|
2) Original or Modified Versions of the Font Software may be bundled,
|
||||||
|
redistributed and/or sold with any software, provided that each copy
|
||||||
|
contains the above copyright notice and this license. These can be
|
||||||
|
included either as stand-alone text files, human-readable headers or
|
||||||
|
in the appropriate machine-readable metadata fields within text or
|
||||||
|
binary files as long as those fields can be easily viewed by the user.
|
||||||
|
|
||||||
|
3) No Modified Version of the Font Software may use the Reserved Font
|
||||||
|
Name(s) unless explicit written permission is granted by the corresponding
|
||||||
|
Copyright Holder. This restriction only applies to the primary font name as
|
||||||
|
presented to the users.
|
||||||
|
|
||||||
|
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
||||||
|
Software shall not be used to promote, endorse or advertise any
|
||||||
|
Modified Version, except to acknowledge the contribution(s) of the
|
||||||
|
Copyright Holder(s) and the Author(s) or with their explicit written
|
||||||
|
permission.
|
||||||
|
|
||||||
|
5) The Font Software, modified or unmodified, in part or in whole,
|
||||||
|
must be distributed entirely under this license, and must not be
|
||||||
|
distributed under any other license. The requirement for fonts to
|
||||||
|
remain under this license does not apply to any document created
|
||||||
|
using the Font Software.
|
||||||
|
|
||||||
|
TERMINATION
|
||||||
|
This license becomes null and void if any of the above conditions are
|
||||||
|
not met.
|
||||||
|
|
||||||
|
DISCLAIMER
|
||||||
|
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||||
|
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
||||||
|
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
||||||
|
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
||||||
|
OTHER DEALINGS IN THE FONT SOFTWARE.
|
||||||
Binary file not shown.
@@ -0,0 +1,53 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||||
|
<svg width="100%" height="100%" viewBox="0 0 551 436" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
|
||||||
|
<g transform="matrix(1.27527,0,0,1.27527,104.01,410.563)">
|
||||||
|
<path d="M0,-51.891L14.429,-51.891L13.043,-21.183L22.568,-51.891L34.226,-51.891L34.084,-21.183L42.365,-51.891L56.794,-51.891L38.526,0L25.198,0L25.34,-32.45L15.211,0L1.919,0L0,-51.891Z" style="fill:white;fill-rule:nonzero;"/>
|
||||||
|
</g>
|
||||||
|
<g transform="matrix(1.27527,0,0,1.27527,224.985,367.503)">
|
||||||
|
<path d="M0,15.639L5.793,15.639L5.971,-3.589L0,15.639ZM-20.187,33.765L-0.675,-18.126L16.42,-18.126L20.08,33.765L5.437,33.765L5.509,26.123L-3.057,26.123L-5.332,33.765L-20.187,33.765Z" style="fill:white;fill-rule:nonzero;"/>
|
||||||
|
</g>
|
||||||
|
<g transform="matrix(0.19929,-1.2596,-1.2596,-0.19929,332.323,396.949)">
|
||||||
|
<path d="M-16.046,33.107L36.491,33.107L38.757,18.784L-13.785,18.82L-16.046,33.107Z" style="fill:white;fill-rule:nonzero;"/>
|
||||||
|
</g>
|
||||||
|
<g transform="matrix(1.27527,0,0,1.27527,353.217,344.388)">
|
||||||
|
<path d="M0,51.891L8.246,0L22.781,0L16.597,39.024L27.224,39.024L25.199,51.891L0,51.891Z" style="fill:white;fill-rule:nonzero;"/>
|
||||||
|
</g>
|
||||||
|
<g transform="matrix(1.27527,0,0,1.27527,427.939,364.922)">
|
||||||
|
<path d="M0,19.83C1.611,21.181 3.305,22.224 5.083,22.959C6.859,23.693 8.565,24.06 10.2,24.06C11.645,24.06 12.794,23.663 13.647,22.87C14.5,22.076 14.927,20.992 14.927,19.617C14.927,18.434 14.571,17.254 13.861,16.081C13.15,14.908 11.775,13.351 9.738,11.408C7.273,9.015 5.58,6.906 4.655,5.081C3.731,3.257 3.27,1.243 3.27,-0.96C3.27,-5.912 4.839,-9.846 7.979,-12.76C11.118,-15.674 15.377,-17.132 20.756,-17.132C22.936,-17.132 25.008,-16.889 26.975,-16.403C28.941,-15.917 30.943,-15.165 32.982,-14.146L30.92,-1.493C29.356,-2.583 27.834,-3.412 26.354,-3.981C24.872,-4.551 23.457,-4.835 22.106,-4.835C20.898,-4.835 19.943,-4.521 19.245,-3.894C18.546,-3.265 18.196,-2.406 18.196,-1.316C18.196,0.154 19.535,2.215 22.213,4.868C22.544,5.2 22.805,5.46 22.995,5.649C25.696,8.304 27.473,10.578 28.326,12.475C29.179,14.37 29.605,16.56 29.605,19.049C29.605,24.594 27.893,28.965 24.469,32.163C21.046,35.361 16.36,36.962 10.413,36.962C7.877,36.962 5.479,36.66 3.216,36.056C0.953,35.45 -0.948,34.615 -2.488,33.549L0,19.83Z" style="fill:white;fill-rule:nonzero;"/>
|
||||||
|
</g>
|
||||||
|
<g transform="matrix(-166.599,4.57132,4.57132,166.599,147.403,167.648)">
|
||||||
|
<path d="M0.883,-0.081L0.121,0.081L0.256,-0.063L0.883,-0.081Z" style="fill:url(#_Linear1);fill-rule:nonzero;"/>
|
||||||
|
</g>
|
||||||
|
<g transform="matrix(-106.443,-16.0669,-16.0669,106.443,428.19,188.033)">
|
||||||
|
<path d="M0.878,-0.285L-0.073,0.71L-1.186,0.542L0.015,0.207L-0.846,0.077L0.355,-0.258L-0.505,-0.388L0.649,-0.71L0.878,-0.285Z" style="fill:url(#_Linear2);fill-rule:nonzero;"/>
|
||||||
|
</g>
|
||||||
|
<g transform="matrix(-114.484,-162.408,-162.408,114.484,333.291,285.804)">
|
||||||
|
<path d="M0.44,-0.04L0.44,-0.04L0.44,-0.04L0.265,-0.056L0.177,0.437L-0.311,-0.255L0.262,-0.437L0.568,-0.437L0.44,-0.04Z" style="fill:url(#_Linear3);fill-rule:nonzero;"/>
|
||||||
|
</g>
|
||||||
|
<g transform="matrix(61.6919,58.8091,58.8091,-61.6919,258.631,180.413)">
|
||||||
|
<path d="M0.5,0L0.5,-0L0.5,0L0.5,0Z" style="fill:url(#_Linear4);fill-rule:nonzero;"/>
|
||||||
|
</g>
|
||||||
|
<g transform="matrix(238.126,298.893,298.893,-238.126,113.516,-150.536)">
|
||||||
|
<path d="M0.622,-0.115L0.761,-0.115L0.806,-0.013L0.826,0.182L0.622,-0.115Z" style="fill:url(#_Linear5);fill-rule:nonzero;"/>
|
||||||
|
</g>
|
||||||
|
<g transform="matrix(-369.529,-97.4118,-97.4118,369.529,582.38,94.027)">
|
||||||
|
<path d="M0.467,0.005L0.49,0.062L0.271,-0.062L0.467,0.005Z" style="fill:url(#_Linear6);fill-rule:nonzero;"/>
|
||||||
|
</g>
|
||||||
|
<g transform="matrix(-496.156,-53.9751,-53.9751,496.156,367.888,125.085)">
|
||||||
|
<path d="M0.2,0.001L0.219,-0.018L0.614,0.012L0.519,0.089L0.282,0.068L0.2,0.135L0.463,0.194L0.374,0.266L0.138,0.186L0.138,0.186L0.138,0.186L0.047,0.033L-0.131,-0.266L0.2,0.001Z" style="fill:url(#_Linear7);fill-rule:nonzero;"/>
|
||||||
|
</g>
|
||||||
|
<g transform="matrix(185.076,176.427,176.427,-185.076,153.446,80.1488)">
|
||||||
|
<path d="M0.735,-0L0.735,-0L0.735,0L0.735,-0Z" style="fill:url(#_Linear8);fill-rule:nonzero;"/>
|
||||||
|
</g>
|
||||||
|
<defs>
|
||||||
|
<linearGradient id="_Linear1" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="matrix(1,-3.46945e-18,-3.46945e-18,-1,0,-3.05761e-06)"><stop offset="0" style="stop-color:rgb(227,50,50);stop-opacity:1"/><stop offset="1" style="stop-color:rgb(107,0,13);stop-opacity:1"/></linearGradient>
|
||||||
|
<linearGradient id="_Linear2" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="matrix(1,0,0,-1,0,-2.75467e-06)"><stop offset="0" style="stop-color:rgb(227,50,50);stop-opacity:1"/><stop offset="1" style="stop-color:rgb(107,0,13);stop-opacity:1"/></linearGradient>
|
||||||
|
<linearGradient id="_Linear3" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="matrix(1,-1.11022e-16,-1.11022e-16,-1,0,-2.61861e-06)"><stop offset="0" style="stop-color:rgb(227,50,50);stop-opacity:1"/><stop offset="1" style="stop-color:rgb(107,0,13);stop-opacity:1"/></linearGradient>
|
||||||
|
<linearGradient id="_Linear4" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="matrix(1,-5.55112e-17,-5.55112e-17,-1,0,-1.57562e-06)"><stop offset="0" style="stop-color:rgb(227,50,50);stop-opacity:1"/><stop offset="1" style="stop-color:rgb(107,0,13);stop-opacity:1"/></linearGradient>
|
||||||
|
<linearGradient id="_Linear5" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="matrix(-0.801899,-0.59746,-0.59746,0.801899,1.3495,0.447457)"><stop offset="0" style="stop-color:rgb(227,50,50);stop-opacity:1"/><stop offset="1" style="stop-color:rgb(107,0,13);stop-opacity:1"/></linearGradient>
|
||||||
|
<linearGradient id="_Linear6" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="matrix(1,-2.77556e-17,-2.77556e-17,-1,0,-1.92826e-06)"><stop offset="0" style="stop-color:rgb(227,50,50);stop-opacity:1"/><stop offset="1" style="stop-color:rgb(107,0,13);stop-opacity:1"/></linearGradient>
|
||||||
|
<linearGradient id="_Linear7" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="matrix(1,0,0,-1,0,9.68429e-07)"><stop offset="0" style="stop-color:rgb(227,50,50);stop-opacity:1"/><stop offset="1" style="stop-color:rgb(107,0,13);stop-opacity:1"/></linearGradient>
|
||||||
|
<linearGradient id="_Linear8" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="matrix(1,0,0,-1,0,1.43665e-07)"><stop offset="0" style="stop-color:rgb(227,50,50);stop-opacity:1"/><stop offset="1" style="stop-color:rgb(107,0,13);stop-opacity:1"/></linearGradient>
|
||||||
|
</defs>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 6.8 KiB |
@@ -0,0 +1,24 @@
|
|||||||
|
|
||||||
|
html {
|
||||||
|
text-align: center;
|
||||||
|
color: white;
|
||||||
|
background-color: rgba(1,1,1,0.1);
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
color: white;
|
||||||
|
font-family: 'Nunito', -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;
|
||||||
|
margin: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
@font-face {
|
||||||
|
font-family: 'Nunito';
|
||||||
|
font-style: normal;
|
||||||
|
font-weight: 400;
|
||||||
|
src: local(''),
|
||||||
|
url('./assets/fonts/nunito-v16-latin-regular.woff2') format('woff2')
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset='utf-8'>
|
||||||
|
<meta name='viewport' content='width=device-width,initial-scale=1'>
|
||||||
|
|
||||||
|
<title>Svelte app</title>
|
||||||
|
|
||||||
|
<script defer src='bundle.js'></script>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body data-wails-drag>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
|
||||||
|
import App from './App.svelte';
|
||||||
|
import './global.css';
|
||||||
|
|
||||||
|
const app = new App({
|
||||||
|
target: document.body,
|
||||||
|
});
|
||||||
|
|
||||||
|
export default app;
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
module test
|
||||||
|
|
||||||
|
go 1.16
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/wailsapp/wails/v2 v2.0.0-alpha
|
||||||
|
)
|
||||||
|
|
||||||
|
replace github.com/wailsapp/wails/v2 v2.0.0-alpha => {{.WailsDirectory}}
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"log"
|
||||||
|
|
||||||
|
"github.com/wailsapp/wails/v2/pkg/options/windows"
|
||||||
|
|
||||||
|
"github.com/wailsapp/wails/v2"
|
||||||
|
"github.com/wailsapp/wails/v2/pkg/logger"
|
||||||
|
"github.com/wailsapp/wails/v2/pkg/menu"
|
||||||
|
"github.com/wailsapp/wails/v2/pkg/options"
|
||||||
|
"github.com/wailsapp/wails/v2/pkg/options/mac"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
|
||||||
|
// Create application with options
|
||||||
|
app := NewApp()
|
||||||
|
|
||||||
|
err := wails.Run(&options.App{
|
||||||
|
Title: "{{.ProjectName}}",
|
||||||
|
Width: 800,
|
||||||
|
Height: 600,
|
||||||
|
MinWidth: 400,
|
||||||
|
MinHeight: 400,
|
||||||
|
MaxWidth: 1280,
|
||||||
|
MaxHeight: 1024,
|
||||||
|
DisableResize: false,
|
||||||
|
Fullscreen: false,
|
||||||
|
Frameless: false,
|
||||||
|
StartHidden: false,
|
||||||
|
HideWindowOnClose: false,
|
||||||
|
DevTools: false,
|
||||||
|
RGBA: 0x000000FF,
|
||||||
|
Windows: &windows.Options{
|
||||||
|
WebviewIsTransparent: true,
|
||||||
|
WindowBackgroundIsTranslucent: true,
|
||||||
|
DisableWindowIcon: true,
|
||||||
|
},
|
||||||
|
Mac: &mac.Options{
|
||||||
|
WebviewIsTransparent: true,
|
||||||
|
WindowBackgroundIsTranslucent: true,
|
||||||
|
TitleBar: mac.TitleBarHiddenInset(),
|
||||||
|
Menu: menu.DefaultMacMenu(),
|
||||||
|
},
|
||||||
|
LogLevel: logger.DEBUG,
|
||||||
|
Startup: app.startup,
|
||||||
|
Shutdown: app.shutdown,
|
||||||
|
Bind: []interface{}{
|
||||||
|
app,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"name": "Basic Svelte + Rollup",
|
||||||
|
"shortname": "svelte",
|
||||||
|
"author": "Lea Anthony",
|
||||||
|
"description": "Svelte template using rollup to bundle css, images and fonts",
|
||||||
|
"helpurl": "https://github.com/wailsapp/wails"
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"name": "{{.ProjectName}}",
|
||||||
|
"outputfilename": "{{.BinaryName}}",
|
||||||
|
"html": "frontend/dist/index.html",
|
||||||
|
"frontend:build": "npm run build",
|
||||||
|
"frontend:install": "npm install",
|
||||||
|
"author": {
|
||||||
|
"name": "{{.AuthorName}}",
|
||||||
|
"email": "{{.AuthorEmail}}"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/wailsapp/wails/v2"
|
||||||
|
)
|
||||||
|
|
||||||
|
// App struct
|
||||||
|
type App struct {
|
||||||
|
runtime *wails.Runtime
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewApp creates a new App application struct
|
||||||
|
func NewApp() *App {
|
||||||
|
return &App{}
|
||||||
|
}
|
||||||
|
|
||||||
|
// startup is called at application startup
|
||||||
|
func (b *App) startup(runtime *wails.Runtime) {
|
||||||
|
// Perform your setup here
|
||||||
|
b.runtime = runtime
|
||||||
|
runtime.Window.SetTitle("{{.ProjectName}}")
|
||||||
|
}
|
||||||
|
|
||||||
|
// shutdown is called at application termination
|
||||||
|
func (b *App) shutdown() {
|
||||||
|
// Perform your teardown here
|
||||||
|
}
|
||||||
|
|
||||||
|
// Greet returns a greeting for the given name
|
||||||
|
func (b *App) Greet(name string) string {
|
||||||
|
return fmt.Sprintf("Hello %s!", name)
|
||||||
|
}
|
||||||
@@ -12,9 +12,9 @@ ready( () => {
|
|||||||
// Get name
|
// Get name
|
||||||
let name = nameElement.value;
|
let name = nameElement.value;
|
||||||
|
|
||||||
// Call Basic.Greet(name)
|
// Call App.Greet(name)
|
||||||
window.backend.main.Basic.Greet(name).then((result) => {
|
window.backend.main.App.Greet(name).then((result) => {
|
||||||
// Update result with data back from Basic.Greet()
|
// Update result with data back from App.Greet()
|
||||||
document.getElementById("result").innerText = result;
|
document.getElementById("result").innerText = result;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/wailsapp/wails/v2/pkg/options/windows"
|
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
|
"github.com/wailsapp/wails/v2/pkg/options/windows"
|
||||||
|
|
||||||
"github.com/wailsapp/wails/v2"
|
"github.com/wailsapp/wails/v2"
|
||||||
"github.com/wailsapp/wails/v2/pkg/logger"
|
"github.com/wailsapp/wails/v2/pkg/logger"
|
||||||
"github.com/wailsapp/wails/v2/pkg/menu"
|
"github.com/wailsapp/wails/v2/pkg/menu"
|
||||||
@@ -14,7 +15,7 @@ import (
|
|||||||
func main() {
|
func main() {
|
||||||
|
|
||||||
// Create application with options
|
// Create application with options
|
||||||
app := NewBasic()
|
app := NewApp()
|
||||||
|
|
||||||
err := wails.Run(&options.App{
|
err := wails.Run(&options.App{
|
||||||
Title: "{{.ProjectName}}",
|
Title: "{{.ProjectName}}",
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
"outputfilename": "{{.BinaryName}}",
|
"outputfilename": "{{.BinaryName}}",
|
||||||
"html": "frontend/dist/index.html",
|
"html": "frontend/dist/index.html",
|
||||||
"frontend:build": "npm run build",
|
"frontend:build": "npm run build",
|
||||||
"frontend:install": "npm ci",
|
"frontend:install": "npm install",
|
||||||
"author": {
|
"author": {
|
||||||
"name": "{{.AuthorName}}",
|
"name": "{{.AuthorName}}",
|
||||||
"email": "{{.AuthorEmail}}"
|
"email": "{{.AuthorEmail}}"
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import (
|
|||||||
|
|
||||||
"github.com/leaanthony/clir"
|
"github.com/leaanthony/clir"
|
||||||
"github.com/wailsapp/wails/v2/cmd/wails/internal/commands/build"
|
"github.com/wailsapp/wails/v2/cmd/wails/internal/commands/build"
|
||||||
"github.com/wailsapp/wails/v2/cmd/wails/internal/commands/debug"
|
|
||||||
"github.com/wailsapp/wails/v2/cmd/wails/internal/commands/dev"
|
"github.com/wailsapp/wails/v2/cmd/wails/internal/commands/dev"
|
||||||
"github.com/wailsapp/wails/v2/cmd/wails/internal/commands/doctor"
|
"github.com/wailsapp/wails/v2/cmd/wails/internal/commands/doctor"
|
||||||
"github.com/wailsapp/wails/v2/cmd/wails/internal/commands/generate"
|
"github.com/wailsapp/wails/v2/cmd/wails/internal/commands/generate"
|
||||||
@@ -40,10 +39,6 @@ func main() {
|
|||||||
fatal(err.Error())
|
fatal(err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
err = debug.AddSubcommand(app, os.Stdout)
|
|
||||||
if err != nil {
|
|
||||||
fatal(err.Error())
|
|
||||||
}
|
|
||||||
err = doctor.AddSubcommand(app, os.Stdout)
|
err = doctor.AddSubcommand(app, os.Stdout)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fatal(err.Error())
|
fatal(err.Error())
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
var version = "v2.0.0-alpha.69"
|
var version = "v2.0.0-alpha.71"
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ require (
|
|||||||
github.com/tdewolff/minify v2.3.6+incompatible
|
github.com/tdewolff/minify v2.3.6+incompatible
|
||||||
github.com/tdewolff/parse v2.3.4+incompatible // indirect
|
github.com/tdewolff/parse v2.3.4+incompatible // indirect
|
||||||
github.com/tdewolff/test v1.0.6 // indirect
|
github.com/tdewolff/test v1.0.6 // indirect
|
||||||
|
github.com/tidwall/sjson v1.1.7
|
||||||
github.com/wzshiming/ctc v1.2.3
|
github.com/wzshiming/ctc v1.2.3
|
||||||
github.com/xyproto/xpm v1.2.1
|
github.com/xyproto/xpm v1.2.1
|
||||||
golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b // indirect
|
golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b // indirect
|
||||||
|
|||||||
@@ -145,6 +145,14 @@ github.com/tdewolff/parse v2.3.4+incompatible h1:x05/cnGwIMf4ceLuDMBOdQ1qGniMoxp
|
|||||||
github.com/tdewolff/parse v2.3.4+incompatible/go.mod h1:8oBwCsVmUkgHO8M5iCzSIDtpzXOT0WXX9cWhz+bIzJQ=
|
github.com/tdewolff/parse v2.3.4+incompatible/go.mod h1:8oBwCsVmUkgHO8M5iCzSIDtpzXOT0WXX9cWhz+bIzJQ=
|
||||||
github.com/tdewolff/test v1.0.6 h1:76mzYJQ83Op284kMT+63iCNCI7NEERsIN8dLM+RiKr4=
|
github.com/tdewolff/test v1.0.6 h1:76mzYJQ83Op284kMT+63iCNCI7NEERsIN8dLM+RiKr4=
|
||||||
github.com/tdewolff/test v1.0.6/go.mod h1:6DAvZliBAAnD7rhVgwaM7DE5/d9NMOAJ09SqYqeK4QE=
|
github.com/tdewolff/test v1.0.6/go.mod h1:6DAvZliBAAnD7rhVgwaM7DE5/d9NMOAJ09SqYqeK4QE=
|
||||||
|
github.com/tidwall/gjson v1.8.0 h1:Qt+orfosKn0rbNTZqHYDqBrmm3UDA4KRkv70fDzG+PQ=
|
||||||
|
github.com/tidwall/gjson v1.8.0/go.mod h1:5/xDoumyyDNerp2U36lyolv46b3uF/9Bu6OfyQ9GImk=
|
||||||
|
github.com/tidwall/match v1.0.3 h1:FQUVvBImDutD8wJLN6c5eMzWtjgONK9MwIBCOrUJKeE=
|
||||||
|
github.com/tidwall/match v1.0.3/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
|
||||||
|
github.com/tidwall/pretty v1.1.0 h1:K3hMW5epkdAVwibsQEfR/7Zj0Qgt4DxtNumTq/VloO8=
|
||||||
|
github.com/tidwall/pretty v1.1.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
|
||||||
|
github.com/tidwall/sjson v1.1.7 h1:sgVPwu/yygHJ2m1pJDLgGM/h+1F5odx5Q9ljG3imRm8=
|
||||||
|
github.com/tidwall/sjson v1.1.7/go.mod h1:w/yG+ezBeTdUxiKs5NcPicO9diP38nk96QBAbIIGeFs=
|
||||||
github.com/ugorji/go v1.1.7 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo=
|
github.com/ugorji/go v1.1.7 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo=
|
||||||
github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw=
|
github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw=
|
||||||
github.com/ugorji/go/codec v1.1.7 h1:2SvQaVZ1ouYrrKKwoSk2pzd4A9evlKJb9oTL+OaLUSs=
|
github.com/ugorji/go/codec v1.1.7 h1:2SvQaVZ1ouYrrKKwoSk2pzd4A9evlKJb9oTL+OaLUSs=
|
||||||
|
|||||||
@@ -117,6 +117,7 @@ func (a *App) Run() error {
|
|||||||
var subsystemWaitGroup sync.WaitGroup
|
var subsystemWaitGroup sync.WaitGroup
|
||||||
parentContext := context.WithValue(context.Background(), "waitgroup", &subsystemWaitGroup)
|
parentContext := context.WithValue(context.Background(), "waitgroup", &subsystemWaitGroup)
|
||||||
ctx, cancel := context.WithCancel(parentContext)
|
ctx, cancel := context.WithCancel(parentContext)
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
// Start the service bus
|
// Start the service bus
|
||||||
a.servicebus.Debug()
|
a.servicebus.Debug()
|
||||||
@@ -125,7 +126,7 @@ func (a *App) Run() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
runtimesubsystem, err := subsystem.NewRuntime(ctx, a.servicebus, a.logger, a.startupCallback, nil)
|
runtimesubsystem, err := subsystem.NewRuntime(ctx, a.servicebus, a.logger, a.startupCallback)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,15 @@ func (b BridgeClient) CallResult(message string) {
|
|||||||
b.session.sendMessage("c" + message)
|
b.session.sendMessage("c" + message)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b BridgeClient) OpenDialog(dialogOptions *dialog.OpenDialog, callbackID string) {
|
func (b BridgeClient) OpenFileDialog(dialogOptions *dialog.OpenDialog, callbackID string) {
|
||||||
|
// Handled by dialog_client
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b BridgeClient) OpenMultipleFilesDialog(dialogOptions *dialog.OpenDialog, callbackID string) {
|
||||||
|
// Handled by dialog_client
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b BridgeClient) OpenDirectoryDialog(dialogOptions *dialog.OpenDialog, callbackID string) {
|
||||||
// Handled by dialog_client
|
// Handled by dialog_client
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,11 @@ func (d *DialogClient) NotifyEvent(message string) {
|
|||||||
func (d *DialogClient) CallResult(message string) {
|
func (d *DialogClient) CallResult(message string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *DialogClient) OpenDialog(dialogOptions *dialog.OpenDialog, callbackID string) {
|
func (d *DialogClient) OpenDirectoryDialog(dialogOptions *dialog.OpenDialog, callbackID string) {
|
||||||
|
}
|
||||||
|
func (d *DialogClient) OpenFileDialog(dialogOptions *dialog.OpenDialog, callbackID string) {
|
||||||
|
}
|
||||||
|
func (d *DialogClient) OpenMultipleFilesDialog(dialogOptions *dialog.OpenDialog, callbackID string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *DialogClient) SaveDialog(dialogOptions *dialog.SaveDialog, callbackID string) {
|
func (d *DialogClient) SaveDialog(dialogOptions *dialog.SaveDialog, callbackID string) {
|
||||||
|
|||||||
@@ -1808,7 +1808,7 @@ void* NewApplication(const char *title, int width, int height, int resizable, in
|
|||||||
|
|
||||||
result->running = false;
|
result->running = false;
|
||||||
|
|
||||||
result->pool = objc_msgSend(c("NSAutoreleasePool"), s("new"));
|
result->pool = msg_reg(c("NSAutoreleasePool"), s("new"));
|
||||||
|
|
||||||
return (void*) result;
|
return (void*) result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -375,7 +375,7 @@ id createMenu(id title) {
|
|||||||
id menu = ALLOC("NSMenu");
|
id menu = ALLOC("NSMenu");
|
||||||
msg_id(menu, s("initWithTitle:"), title);
|
msg_id(menu, s("initWithTitle:"), title);
|
||||||
msg_bool(menu, s("setAutoenablesItems:"), NO);
|
msg_bool(menu, s("setAutoenablesItems:"), NO);
|
||||||
msg(menu, s("autorelease"));
|
msg_reg(menu, s("autorelease"));
|
||||||
return menu;
|
return menu;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -140,7 +140,6 @@ void ShowTrayMenu(TrayMenu* trayMenu) {
|
|||||||
|
|
||||||
// Create delegate
|
// Create delegate
|
||||||
id trayMenuDelegate = msg_reg((id)trayMenuDelegateClass, s("new"));
|
id trayMenuDelegate = msg_reg((id)trayMenuDelegateClass, s("new"));
|
||||||
msg_reg(trayMenuDelegate, s("autorelease"));
|
|
||||||
msg_id(menu, s("setDelegate:"), trayMenuDelegate);
|
msg_id(menu, s("setDelegate:"), trayMenuDelegate);
|
||||||
objc_setAssociatedObject(trayMenuDelegate, "menu", menu, OBJC_ASSOCIATION_ASSIGN);
|
objc_setAssociatedObject(trayMenuDelegate, "menu", menu, OBJC_ASSOCIATION_ASSIGN);
|
||||||
|
|
||||||
@@ -156,6 +155,10 @@ void UpdateTrayMenuInPlace(TrayMenu* currentMenu, TrayMenu* newMenu) {
|
|||||||
|
|
||||||
// Delete the old menu
|
// Delete the old menu
|
||||||
DeleteMenu(currentMenu->menu);
|
DeleteMenu(currentMenu->menu);
|
||||||
|
if( currentMenu->delegate != NULL ) {
|
||||||
|
msg_reg(currentMenu->delegate, s("release"));
|
||||||
|
currentMenu->delegate = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
// Set the new one
|
// Set the new one
|
||||||
currentMenu->menu = newMenu->menu;
|
currentMenu->menu = newMenu->menu;
|
||||||
@@ -179,6 +182,10 @@ void DeleteTrayMenu(TrayMenu* trayMenu) {
|
|||||||
|
|
||||||
// Delete the menu
|
// Delete the menu
|
||||||
DeleteMenu(trayMenu->menu);
|
DeleteMenu(trayMenu->menu);
|
||||||
|
if( trayMenu->delegate != NULL ) {
|
||||||
|
msg_reg(trayMenu->delegate, s("release"));
|
||||||
|
trayMenu->delegate = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
// Free JSON
|
// Free JSON
|
||||||
if (trayMenu->processedJSON != NULL ) {
|
if (trayMenu->processedJSON != NULL ) {
|
||||||
@@ -200,6 +207,10 @@ void DeleteTrayMenuKeepStatusBarItem(TrayMenu* trayMenu) {
|
|||||||
|
|
||||||
// Delete the menu
|
// Delete the menu
|
||||||
DeleteMenu(trayMenu->menu);
|
DeleteMenu(trayMenu->menu);
|
||||||
|
if( trayMenu->delegate != NULL ) {
|
||||||
|
msg_reg(trayMenu->delegate, s("release"));
|
||||||
|
trayMenu->delegate = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
// Free JSON
|
// Free JSON
|
||||||
if (trayMenu->processedJSON != NULL ) {
|
if (trayMenu->processedJSON != NULL ) {
|
||||||
|
|||||||
@@ -338,3 +338,60 @@ func CopyDirExtended(src string, dst string, ignore []string) (err error) {
|
|||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MoveDirExtended recursively moves a directory tree, attempting to preserve permissions.
|
||||||
|
// Source directory must exist, destination directory must *not* exist. It ignores any files or
|
||||||
|
// directories that are given through the ignore parameter.
|
||||||
|
// Symlinks are ignored and skipped.
|
||||||
|
func MoveDirExtended(src string, dst string, ignore []string) (err error) {
|
||||||
|
|
||||||
|
ignoreList := slicer.String(ignore)
|
||||||
|
src = filepath.Clean(src)
|
||||||
|
dst = filepath.Clean(dst)
|
||||||
|
|
||||||
|
si, err := os.Stat(src)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if !si.IsDir() {
|
||||||
|
return fmt.Errorf("source is not a directory")
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = os.Stat(dst)
|
||||||
|
if err != nil && !os.IsNotExist(err) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err == nil {
|
||||||
|
return fmt.Errorf("destination already exists")
|
||||||
|
}
|
||||||
|
|
||||||
|
err = MkDirs(dst)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
entries, err := ioutil.ReadDir(src)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, entry := range entries {
|
||||||
|
if ignoreList.Contains(entry.Name()) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
srcPath := filepath.Join(src, entry.Name())
|
||||||
|
dstPath := filepath.Join(dst, entry.Name())
|
||||||
|
|
||||||
|
// Skip symlinks.
|
||||||
|
if entry.Mode()&os.ModeSymlink != 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
err := os.Rename(srcPath, dstPath)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
package system
|
package system
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/wailsapp/wails/v2/internal/system/operatingsystem"
|
|
||||||
"github.com/wailsapp/wails/v2/internal/system/packagemanager"
|
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"strings"
|
"strings"
|
||||||
|
"syscall"
|
||||||
|
|
||||||
|
"github.com/wailsapp/wails/v2/internal/system/operatingsystem"
|
||||||
|
"github.com/wailsapp/wails/v2/internal/system/packagemanager"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Info holds information about the current operating system,
|
// Info holds information about the current operating system,
|
||||||
@@ -105,3 +107,14 @@ func checkDocker() *packagemanager.Dependancy {
|
|||||||
External: false,
|
External: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IsAppleSilicon returns true if the app is running on Apple Silicon
|
||||||
|
// Credit: https://www.yellowduck.be/posts/detecting-apple-silicon-via-go/
|
||||||
|
func IsAppleSilicon() bool {
|
||||||
|
r, err := syscall.Sysctl("sysctl.proc_translated")
|
||||||
|
if err != nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
return r == "\x00\x00\x00" || r == "\x01\x00\x00"
|
||||||
|
}
|
||||||
|
|||||||
@@ -171,6 +171,9 @@ func (b *BaseBuilder) OutputFilename(options *Options) string {
|
|||||||
case "windows":
|
case "windows":
|
||||||
outputFile = target + ".exe"
|
outputFile = target + ".exe"
|
||||||
case "darwin", "linux":
|
case "darwin", "linux":
|
||||||
|
if b.options.Arch == "" {
|
||||||
|
b.options.Arch = runtime.GOARCH
|
||||||
|
}
|
||||||
outputFile = fmt.Sprintf("%s-%s-%s", target, b.options.Platform, b.options.Arch)
|
outputFile = fmt.Sprintf("%s-%s-%s", target, b.options.Platform, b.options.Arch)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ type Options struct {
|
|||||||
CompressFlags string // Flags to pass to UPX
|
CompressFlags string // Flags to pass to UPX
|
||||||
AppleIdentity string
|
AppleIdentity string
|
||||||
WebView2Strategy string // WebView2 installer strategy
|
WebView2Strategy string // WebView2 installer strategy
|
||||||
|
RunDelve bool // Indicates if we should run delve after the build
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build the project!
|
// Build the project!
|
||||||
|
|||||||
Reference in New Issue
Block a user