mirror of
https://github.com/taigrr/wails.git
synced 2026-04-02 13:19:00 -07:00
Compare commits
35 Commits
fix-packag
...
v0.11.8
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
46307469e5 | ||
|
|
31a67f3aed | ||
|
|
44919d2750 | ||
|
|
cff87c641b | ||
|
|
abbd71d057 | ||
|
|
aacfe8386a | ||
|
|
97944d771a | ||
|
|
3f1b616a5e | ||
|
|
fdcc2fd2e5 | ||
|
|
855032ed1e | ||
|
|
760e109aab | ||
|
|
4c799bca8f | ||
|
|
2d08ebc054 | ||
|
|
91ab2c2b31 | ||
|
|
13ad57d49f | ||
|
|
a109e3078d | ||
|
|
2e61a3c309 | ||
|
|
0373bea4e5 | ||
|
|
2d5825d73d | ||
|
|
c4a042cb1d | ||
|
|
205f9476fa | ||
|
|
a1230fcbb6 | ||
|
|
ba5c32a4a1 | ||
|
|
58eee64326 | ||
|
|
41d786a13c | ||
|
|
a2b7906c89 | ||
|
|
eeb6fa4677 | ||
|
|
6a36d75774 | ||
|
|
6078f3c780 | ||
|
|
fc11197725 | ||
|
|
8c40b99194 | ||
|
|
de53fc6510 | ||
|
|
d4f4feb429 | ||
|
|
02973c49ff | ||
|
|
01dce9f139 |
@@ -1,12 +1,20 @@
|
||||
# This is an example goreleaser.yaml file with some sane defaults.
|
||||
# Make sure to check the documentation at http://goreleaser.com
|
||||
before:
|
||||
hooks:
|
||||
- ./scripts/updateversion.sh
|
||||
|
||||
builds:
|
||||
- env:
|
||||
- CGO_ENABLED=0
|
||||
main: ./cmd/wails/main.go
|
||||
goos:
|
||||
- windows
|
||||
- linux
|
||||
- darwin
|
||||
goarch:
|
||||
- 386
|
||||
- amd64
|
||||
ignore:
|
||||
- goos: darwin
|
||||
goarch: 386
|
||||
main: ./cmd/wails/main.go
|
||||
archive:
|
||||
replacements:
|
||||
darwin: Darwin
|
||||
|
||||
3
.vscode/settings.json
vendored
Normal file
3
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"go.formatTool": "goimports"
|
||||
}
|
||||
2
LICENSE
2
LICENSE
@@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2018 wailsapp
|
||||
Copyright (c) 2018-Present Lea Anthony
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
110
README.md
110
README.md
@@ -1 +1,109 @@
|
||||
# Coming Soon
|
||||
<p align="center" style="text-align: center">
|
||||
<img src="https://github.com/wailsapp/docs/raw/master/.vuepress/public/media/logo_cropped.png" width="40%"><br/>
|
||||
</p>
|
||||
<p align="center">
|
||||
A framework for building desktop applications using Go & Web Technologies.<br/><br/>
|
||||
<a href="https://github.com/wailsapp/wails/blob/master/LICENSE"><img src="https://img.shields.io/badge/License-MIT-blue.svg"></a>
|
||||
<a href="https://goreportcard.com/report/github.com/wailsapp/wails"><img src="https://goreportcard.com/badge/github.com/wailsapp/wails"/></a>
|
||||
<a href="http://godoc.org/github.com/wailsapp/wails"><img src="https://img.shields.io/badge/godoc-reference-blue.svg"/></a>
|
||||
<a href="https://www.codefactor.io/repository/github/wailsapp/wails"><img src="https://www.codefactor.io/repository/github/wailsapp/wails/badge" alt="CodeFactor" /></a>
|
||||
<a href="https://github.com/wailsapp/wails/issues"><img src="https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat" alt="CodeFactor" /></a>
|
||||
<a href="https://houndci.com"><img src="https://img.shields.io/badge/Reviewed_by-Hound-8E64B0.svg"/></a>
|
||||
</p>
|
||||
|
||||
The traditional method of providing web interfaces to Go programs is via a built-in web server. Wails offers a different approach: it provides the ability to wrap both Go code and a web frontend into a single binary. Tools are provided to make this easy for you by handling project creation, compilation and bundling. All you have to do is get creative!
|
||||
|
||||
## Features
|
||||
|
||||
- Use standard Go libraries/frameworks for the backend
|
||||
- Use any frontend technology to build your UI
|
||||
- Expose Go methods/functions to the frontend via a single bind command
|
||||
- Uses native rendering engines - no embedded browser
|
||||
- Shared events system
|
||||
- Native file dialogs
|
||||
- Powerful cli tool
|
||||
- Multiplatform
|
||||
|
||||
## Project Status
|
||||
|
||||
Wails is currently in Beta. Please make sure you read the [Project Status](https://wails.app/project_status.html) if you are interested in using this project.
|
||||
|
||||
## Installation
|
||||
|
||||
Wails uses cgo to bind to the native rendering engines so a number of platform dependent libraries are needed as well as an installation of Go. The basic requirements are:
|
||||
|
||||
- Go 1.11 or above
|
||||
- npm
|
||||
|
||||
### MacOS
|
||||
|
||||
Make sure you have the xcode command line tools installed. This can be done by running:
|
||||
|
||||
`xcode-select --install`
|
||||
|
||||
### Linux
|
||||
|
||||
#### Ubuntu 18.04
|
||||
|
||||
`sudo apt install pkg-config build-essential libgtk-3-dev libwebkit2gtk-4.0-dev`
|
||||
|
||||
Note: If you have successfully installed these dependencies on a different flavour of Linux, please consider submitting a PR.
|
||||
|
||||
### Windows
|
||||
|
||||
Windows requires gcc and related tooling. The recommended download is from [http://tdm-gcc.tdragon.net/download](http://tdm-gcc.tdragon.net/download). Once this is installed, you are good to go.
|
||||
|
||||
## Installation
|
||||
|
||||
Installation is as simple as running the following command:
|
||||
|
||||
<pre style='color:white'>
|
||||
go get -u github.com/wailsapp/wails/cmd/wails
|
||||
</pre>
|
||||
|
||||
## Next Steps
|
||||
|
||||
It is recommended at this stage to read the comprehensive documentation at [https://wails.app](https://wails.app).
|
||||
|
||||
## FAQ
|
||||
|
||||
* Is this an alternative to Electron?
|
||||
|
||||
Depends on your requirements. It's designed to make it easy for Go programmers to make lightweight desktop applications or add a frontend to their existing applications. Whilst Wails does not currently offer hooks into native elements such as menus, this may change in the future.
|
||||
|
||||
* Who is this project aimed at?
|
||||
|
||||
Go programmers who want to bundle an HMTL/JS/CSS frontend with their applications, without resorting to creating a server and opening a browser to view it.
|
||||
|
||||
* What's with the name?
|
||||
|
||||
When I saw WebView, I thought "What I really want is tooling around building a WebView app, a bit like Rails is to Ruby". So initially it was a play on words (Webview on Rails). It just so happened to also be a homophone of the English name for the [Country](https://en.wikipedia.org/wiki/Wales) I am from. So it stuck.
|
||||
|
||||
## Shoulders of Giants
|
||||
|
||||
Without the following people, this project would never have existed:
|
||||
|
||||
* [Dustin Krysak](https://wiki.ubuntu.com/bashfulrobot) - His support and feedback has been immense. More patience than you can throw a stick at (Not long now Dustin!).
|
||||
* [Serge Zaitsev](https://github.com/zserge) - Creator of [Webview](https://github.com/zserge/webview) which Wails uses for the windowing.
|
||||
|
||||
Special Mentions:
|
||||
|
||||
* [Bill Kennedy](https://twitter.com/goinggodotnet) - Go guru, encourager and all-round nice guy, whose infectious energy and inspiration powered me on when I had none left.
|
||||
* [Mark Bates](https://github.com/markbates) - Creator of [Packr](https://github.com/gobuffalo/packr), inspiration for packing strategies which fed into some of the tooling.
|
||||
|
||||
This project was mainly coded to the following albums:
|
||||
|
||||
* [Manic Street Preachers - Resistance Is Futile](https://open.spotify.com/album/1R2rsEUqXjIvAbzM0yHrxA)
|
||||
* [Manic Street Preachers - This Is My Truth, Tell Me Yours](https://open.spotify.com/album/4VzCL9kjhgGQeKCiojK1YN)
|
||||
* [The Midnight - Endless Summer](https://open.spotify.com/album/4Krg8zvprquh7TVn9OxZn8)
|
||||
* [Gary Newman - Savage (Songs from a Broken World)](https://open.spotify.com/album/3kMfsD07Q32HRWKRrpcexr)
|
||||
* [Steve Vai - Passion & Warfare](https://open.spotify.com/album/0oL0OhrE2rYVns4IGj8h2m)
|
||||
* [Ben Howard - Every Kingdom](https://open.spotify.com/album/1nJsbWm3Yy2DW1KIc1OKle)
|
||||
* [Ben Howard - Noonday Dream](https://open.spotify.com/album/6astw05cTiXEc2OvyByaPs)
|
||||
* [Adwaith - Melyn](https://open.spotify.com/album/2vBE40Rp60tl7rNqIZjaXM)
|
||||
* [Gwidaith Hen Fran - Cedors Hen Wrach](https://open.spotify.com/album/3v2hrfNGINPLuDP0YDTOjm)
|
||||
* [Metallica - Metallica](https://open.spotify.com/album/2Kh43m04B1UkVcpcRa1Zug)
|
||||
* [Bloc Party - Silent Alarm](https://open.spotify.com/album/6SsIdN05HQg2GwYLfXuzLB)
|
||||
* [Maxthor - Another World](https://open.spotify.com/album/3tklE2Fgw1hCIUstIwPBJF)
|
||||
* [Alun Tan Lan - Y Distawrwydd](https://open.spotify.com/album/0c32OywcLpdJCWWMC6vB8v)
|
||||
|
||||
|
||||
10
app.go
10
app.go
@@ -70,7 +70,11 @@ func (a *App) Run() error {
|
||||
}
|
||||
|
||||
a.logLevel = "error"
|
||||
return a.start()
|
||||
err := a.start()
|
||||
if err != nil {
|
||||
a.log.Error(err.Error())
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (a *App) start() error {
|
||||
@@ -114,9 +118,7 @@ func (a *App) start() error {
|
||||
a.renderer.AddJSList(a.jsCache)
|
||||
|
||||
// Run the renderer
|
||||
a.renderer.Run()
|
||||
|
||||
return nil
|
||||
return a.renderer.Run()
|
||||
}
|
||||
|
||||
// Bind allows the user to bind the given object
|
||||
|
||||
@@ -9,6 +9,7 @@ func (app *App) setupCli() *cmd.Cli {
|
||||
|
||||
// Create a new cli
|
||||
result := cmd.NewCli(app.config.Title, "Debug build")
|
||||
result.Version(cmd.Version)
|
||||
|
||||
// Setup cli to handle loglevel and headless flags
|
||||
result.
|
||||
|
||||
@@ -195,10 +195,7 @@ func (c *Command) Action(callback Action) *Command {
|
||||
// PrintHelp - Output the help text for this command
|
||||
func (c *Command) PrintHelp() {
|
||||
c.log.PrintBanner()
|
||||
versionString := c.AppVersion
|
||||
if versionString != "" {
|
||||
versionString = " " + versionString
|
||||
}
|
||||
|
||||
commandTitle := c.CommandPath
|
||||
if c.Shortdescription != "" {
|
||||
commandTitle += " - " + c.Shortdescription
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -36,7 +36,7 @@ func ValidateFrontendConfig(projectOptions *ProjectOptions) error {
|
||||
|
||||
// InstallGoDependencies will run go get in the current directory
|
||||
func InstallGoDependencies() error {
|
||||
depSpinner := spinner.New("Installing Dependencies...")
|
||||
depSpinner := spinner.New("Ensuring Dependencies are up to date...")
|
||||
depSpinner.SetSpinSpeed(50)
|
||||
depSpinner.Start()
|
||||
err := NewProgramHelper().RunCommand("go get")
|
||||
@@ -203,7 +203,7 @@ func InstallFrontendDeps(projectDir string, projectOptions *ProjectOptions, forc
|
||||
}
|
||||
|
||||
// Check if frontend deps have been updated
|
||||
feSpinner := spinner.New("Installing frontend dependencies (This may take a while)...")
|
||||
feSpinner := spinner.New("Ensuring frontend dependencies are up to date (This may take a while)")
|
||||
feSpinner.SetSpinSpeed(50)
|
||||
feSpinner.Start()
|
||||
|
||||
@@ -248,6 +248,22 @@ func InstallFrontendDeps(projectDir string, projectOptions *ProjectOptions, forc
|
||||
ioutil.WriteFile(md5sumFile, []byte(packageJSONMD5), 0644)
|
||||
}
|
||||
|
||||
// Install the bridge library
|
||||
err = InstallBridge(caller, projectDir, projectOptions)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Build frontend
|
||||
err = BuildFrontend(projectOptions.FrontEnd.Build)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// InstallBridge installs the relevant bridge javascript library
|
||||
func InstallBridge(caller string, projectDir string, projectOptions *ProjectOptions) error {
|
||||
bridgeFile := "wailsbridge.prod.js"
|
||||
if caller == "serve" {
|
||||
bridgeFile = "wailsbridge.js"
|
||||
@@ -257,13 +273,7 @@ func InstallFrontendDeps(projectDir string, projectOptions *ProjectOptions, forc
|
||||
bridgeAssets := mewn.Group("../wailsruntimeassets/bridge/")
|
||||
bridgeFileData := bridgeAssets.Bytes(bridgeFile)
|
||||
bridgeFileTarget := filepath.Join(projectDir, projectOptions.FrontEnd.Dir, projectOptions.FrontEnd.Bridge, "wailsbridge.js")
|
||||
err = fs.CreateFile(bridgeFileTarget, bridgeFileData)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Build frontend
|
||||
err = BuildFrontend(projectOptions.FrontEnd.Build)
|
||||
err := fs.CreateFile(bridgeFileTarget, bridgeFileData)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ const (
|
||||
// Unknown is the catch-all distro
|
||||
Unknown LinuxDistribution = 0
|
||||
// Ubuntu distribution
|
||||
Ubuntu LinuxDistribution = 1
|
||||
Ubuntu LinuxDistribution = 1
|
||||
)
|
||||
|
||||
// DistroInfo contains all the information relating to a linux distribution
|
||||
@@ -67,13 +67,11 @@ func GetLinuxDistroInfo() *DistroInfo {
|
||||
|
||||
// DpkgInstalled uses dpkg to see if a package is installed
|
||||
func DpkgInstalled(packageName string) (bool, error) {
|
||||
result := false
|
||||
program := NewProgramHelper()
|
||||
dpkg := program.FindProgram("dpkg")
|
||||
if dpkg == nil {
|
||||
return false, fmt.Errorf("cannot check dependencies: dpkg not found")
|
||||
}
|
||||
_, _, exitCode, _ := dpkg.Run("-L", packageName)
|
||||
result = exitCode == 0
|
||||
return result, nil
|
||||
return exitCode == 0, nil
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ func (b *PackageHelper) Package(po *ProjectOptions) error {
|
||||
case "darwin":
|
||||
// Check we have the exe
|
||||
if !b.fs.FileExists(po.BinaryName) {
|
||||
return fmt.Errorf("cannot bundle non-existant binary file '%s'. Please build with 'wails build' first", po.BinaryName)
|
||||
return fmt.Errorf("cannot bundle non-existent binary file '%s'. Please build with 'wails build' first", po.BinaryName)
|
||||
}
|
||||
return b.packageOSX(po)
|
||||
case "windows":
|
||||
@@ -255,9 +255,5 @@ func (b *PackageHelper) packageIconOSX(resourceDir string) error {
|
||||
|
||||
}
|
||||
defer dest.Close()
|
||||
if err := icns.Encode(dest, srcImg); err != nil {
|
||||
return err
|
||||
|
||||
}
|
||||
return nil
|
||||
return icns.Encode(dest, srcImg)
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ func (p *Program) GetFullPathToBinary() (string, error) {
|
||||
}
|
||||
|
||||
// Run will execute the program with the given parameters
|
||||
// Returns stdout + stderr as strings and an error if one occured
|
||||
// Returns stdout + stderr as strings and an error if one occurred
|
||||
func (p *Program) Run(vars ...string) (stdout, stderr string, exitCode int, err error) {
|
||||
command, err := p.GetFullPathToBinary()
|
||||
if err != nil {
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
package cmd
|
||||
@@ -81,21 +81,24 @@ func (s *SystemHelper) BackupConfig() (string, error) {
|
||||
|
||||
func (s *SystemHelper) setup() error {
|
||||
|
||||
systemConfig := make(map[string]string)
|
||||
|
||||
// Try to load current values - ignore errors
|
||||
config, err := s.LoadConfig()
|
||||
defaultName := ""
|
||||
defaultEmail := ""
|
||||
if config != nil {
|
||||
defaultName = config.Name
|
||||
defaultEmail = config.Email
|
||||
config, _ := s.LoadConfig()
|
||||
|
||||
if config.Name != "" {
|
||||
systemConfig["name"] = PromptRequired("What is your name", config.Name)
|
||||
} else {
|
||||
systemConfig["name"] = PromptRequired("What is your name")
|
||||
}
|
||||
if config.Email != "" {
|
||||
systemConfig["email"] = PromptRequired("What is your email address", config.Email)
|
||||
} else {
|
||||
systemConfig["email"] = PromptRequired("What is your email address")
|
||||
}
|
||||
|
||||
systemConfig := make(map[string]string)
|
||||
systemConfig["name"] = PromptRequired("What is your name", defaultName)
|
||||
systemConfig["email"] = PromptRequired("What is your email address", defaultEmail)
|
||||
|
||||
// Create the directory
|
||||
err = s.fs.MkDirs(s.wailsSystemDir)
|
||||
err := s.fs.MkDirs(s.wailsSystemDir)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.1 KiB |
@@ -1,17 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
||||
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
|
||||
<title>my-vue-app-01</title>
|
||||
</head>
|
||||
<body>
|
||||
<noscript>
|
||||
<strong>We're sorry but my-vue-app-01 doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
|
||||
</noscript>
|
||||
<div id="app"></div>
|
||||
<!-- built files will be auto injected -->
|
||||
</body>
|
||||
</html>
|
||||
@@ -2,6 +2,7 @@ import Vue from "vue";
|
||||
import App from "./App.vue";
|
||||
|
||||
Vue.config.productionTip = false;
|
||||
Vue.config.devtools = true;
|
||||
|
||||
import Bridge from "./wailsbridge";
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package cmd
|
||||
|
||||
// Version - Wails version
|
||||
const Version = "v0.11.0"
|
||||
const Version = "v0.11.7"
|
||||
|
||||
@@ -18,11 +18,13 @@ func init() {
|
||||
|
||||
setupCommand.Action(func() error {
|
||||
|
||||
logger.PrintBanner();
|
||||
logger.PrintBanner()
|
||||
|
||||
var err error
|
||||
|
||||
system := cmd.NewSystemHelper()
|
||||
err := system.Initialise()
|
||||
if err != nil {
|
||||
err = system.Initialise()
|
||||
if err == nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -39,13 +41,15 @@ Create your first project by running 'wails init'.`
|
||||
|
||||
// Check we have a cgo capable environment
|
||||
logger.Yellow("Checking for prerequisites...")
|
||||
errors, err := checkRequiredPrograms()
|
||||
var requiredProgramErrors bool
|
||||
requiredProgramErrors, err = checkRequiredPrograms()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Linux has library deps
|
||||
errors, err = checkLibraries()
|
||||
var libraryErrors bool
|
||||
libraryErrors, err = checkLibraries()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -58,6 +62,8 @@ Create your first project by running 'wails init'.`
|
||||
|
||||
logger.White("")
|
||||
|
||||
// Check for errors
|
||||
var errors = libraryErrors || requiredProgramErrors
|
||||
if !errors {
|
||||
logger.Yellow(successMessage)
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ func init() {
|
||||
fs := cmd.NewFSHelper()
|
||||
err := projectOptions.LoadConfig(fs.Cwd())
|
||||
if err != nil {
|
||||
return err
|
||||
return fmt.Errorf("Unable to find 'project.json'. Please check you are in a Wails project directory")
|
||||
}
|
||||
|
||||
// Validate config
|
||||
|
||||
@@ -2,7 +2,6 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/leaanthony/spinner"
|
||||
"github.com/wailsapp/wails/cmd"
|
||||
@@ -42,36 +41,11 @@ func init() {
|
||||
return err
|
||||
}
|
||||
|
||||
// Validate config
|
||||
// Check if we have a frontend
|
||||
err = cmd.ValidateFrontendConfig(projectOptions)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Program checker
|
||||
program := cmd.NewProgramHelper()
|
||||
|
||||
if projectOptions.FrontEnd != nil {
|
||||
// npm
|
||||
if !program.IsInstalled("npm") {
|
||||
return fmt.Errorf("it appears npm is not installed. Please install and run again")
|
||||
}
|
||||
}
|
||||
|
||||
// Save project directory
|
||||
projectDir := fs.Cwd()
|
||||
|
||||
// Install deps
|
||||
if projectOptions.FrontEnd != nil {
|
||||
err = cmd.InstallFrontendDeps(projectDir, projectOptions, forceRebuild, "serve")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
// Move to project directory
|
||||
err = os.Chdir(projectDir)
|
||||
// Install the bridge library
|
||||
err = cmd.InstallBridge("serve", projectDir, projectOptions)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"io/ioutil"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
|
||||
"github.com/leaanthony/spinner"
|
||||
"github.com/wailsapp/wails/cmd"
|
||||
@@ -54,7 +54,7 @@ func init() {
|
||||
updateSpinner := spinner.NewSpinner()
|
||||
updateSpinner.SetSpinSpeed(40)
|
||||
updateSpinner.Start("Updating to : " + latestVersion)
|
||||
err = cmd.NewProgramHelper().RunCommandArray([]string{"go","get","-u","github.com/wailsapp/wails/cmd/wails"})
|
||||
err = cmd.NewProgramHelper().RunCommandArray([]string{"go", "get", "-u", "github.com/wailsapp/wails/cmd/wails"})
|
||||
if err != nil {
|
||||
updateSpinner.Error(err.Error())
|
||||
return err
|
||||
|
||||
@@ -87,7 +87,7 @@ func (e *eventManager) start(renderer Renderer) {
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(1)
|
||||
|
||||
// Run main loop in seperate goroutine
|
||||
// Run main loop in separate goroutine
|
||||
go func() {
|
||||
wg.Done()
|
||||
e.log.Info("Listening")
|
||||
@@ -126,7 +126,7 @@ func (e *eventManager) start(renderer Renderer) {
|
||||
}
|
||||
}
|
||||
|
||||
// Remove expired listners in place
|
||||
// Remove expired listeners in place
|
||||
if len(listenersToRemove) > 0 {
|
||||
listeners := e.listeners[event.Name][:0]
|
||||
for _, listener := range listeners {
|
||||
|
||||
4
go.mod
4
go.mod
@@ -9,7 +9,7 @@ require (
|
||||
github.com/gorilla/websocket v1.4.0
|
||||
github.com/jackmordaunt/icns v1.0.0
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect
|
||||
github.com/leaanthony/mewn v0.10.2
|
||||
github.com/leaanthony/mewn v0.10.4
|
||||
github.com/leaanthony/slicer v1.3.1
|
||||
github.com/leaanthony/spinner v0.5.0
|
||||
github.com/mattn/go-colorable v0.1.1 // indirect
|
||||
@@ -20,7 +20,7 @@ require (
|
||||
github.com/pkg/errors v0.8.1 // indirect
|
||||
github.com/sirupsen/logrus v1.3.0
|
||||
github.com/stretchr/testify v1.3.0 // indirect
|
||||
github.com/wailsapp/webview v0.2.5
|
||||
github.com/wailsapp/webview v0.2.7
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 // indirect
|
||||
golang.org/x/net v0.0.0-20190310014029-b774fd8d5c0f // indirect
|
||||
golang.org/x/sys v0.0.0-20190310054646-10058d7d4faa // indirect
|
||||
|
||||
8
go.sum
8
go.sum
@@ -21,8 +21,8 @@ github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGi
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.2 h1:DB17ag19krx9CFsz4o3enTrPXyIXCl+2iCXH/aMAp9s=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/leaanthony/mewn v0.10.2 h1:Kzu1NqHHXriuMyGiHDMLk4aTzydZ3qbvz/qmoquGkvQ=
|
||||
github.com/leaanthony/mewn v0.10.2/go.mod h1:i3ygCWW96qVQlGa8sjWnTM0IKAijoFvTwATDIZgK4k0=
|
||||
github.com/leaanthony/mewn v0.10.4 h1:b16/E0r6CuXN8WYuDJIgwRocLQlmMjfBsooEJr6FdqY=
|
||||
github.com/leaanthony/mewn v0.10.4/go.mod h1:i3ygCWW96qVQlGa8sjWnTM0IKAijoFvTwATDIZgK4k0=
|
||||
github.com/leaanthony/slicer v1.3.1 h1:n2iIV2sxvL/3bpnmVY0vBjXf3yYFWcB6CYLVMrzJxRw=
|
||||
github.com/leaanthony/slicer v1.3.1/go.mod h1:VMB/HGvr3uR3MRpFWHWAm0w+DHQLzPHYe2pKfpFlQIQ=
|
||||
github.com/leaanthony/spinner v0.5.0 h1:HQykt/iTy7fmINEREtRbWrt+8j4MxC8dtvWBxEWM9oA=
|
||||
@@ -60,8 +60,8 @@ github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/wailsapp/webview v0.2.5 h1:/VacryPEUeMBb2VHHOjpoIze6ki8tW3qYX04MnI0b7o=
|
||||
github.com/wailsapp/webview v0.2.5/go.mod h1:XO9HJbKWokDxUYTWQEBCYg95n/To1v7PxvanDNVf8hY=
|
||||
github.com/wailsapp/webview v0.2.7 h1:fN5L5H9Oivg9IJPk7uaXQnjqB68Fny11ZWkIaTIZHmk=
|
||||
github.com/wailsapp/webview v0.2.7/go.mod h1:XO9HJbKWokDxUYTWQEBCYg95n/To1v7PxvanDNVf8hY=
|
||||
github.com/zserge/webview v0.0.0-20190123072648-16c93bcaeaeb/go.mod h1:a1CV8KR4Dd1eP2g+mEijGOp+HKczwdKHWyx0aPHKvo4=
|
||||
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793 h1:u+LnwYTOOW7Ukr/fppxEb1Nwz0AtPflrblfvUudpo+I=
|
||||
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
|
||||
@@ -57,7 +57,7 @@ func (h *Headless) Initialise(appConfig *AppConfig, ipcManager *ipcManager, even
|
||||
h.appConfig = appConfig
|
||||
h.eventManager = eventManager
|
||||
ipcManager.bindRenderer(h)
|
||||
h.log = newCustomLogger("Headless")
|
||||
h.log = newCustomLogger("Bridge")
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -153,8 +153,8 @@ func (h *Headless) Run() error {
|
||||
h.server = &http.Server{Addr: ":34115"}
|
||||
http.HandleFunc("/bridge", h.wsBridgeHandler)
|
||||
|
||||
h.log.Info("Headless mode started.")
|
||||
h.log.Info("The Wails bridge will connect automatically.")
|
||||
h.log.Info("Bridge mode started.")
|
||||
h.log.Info("The frontend will connect automatically.")
|
||||
|
||||
err := h.server.ListenAndServe()
|
||||
if err != nil {
|
||||
@@ -172,21 +172,21 @@ func (h *Headless) NewBinding(methodName string) error {
|
||||
// SelectFile is unsupported for Headless but required
|
||||
// for the Renderer interface
|
||||
func (h *Headless) SelectFile() string {
|
||||
h.log.Error("SelectFile() unsupported in headless mode")
|
||||
h.log.Warn("SelectFile() unsupported in bridge mode")
|
||||
return ""
|
||||
}
|
||||
|
||||
// SelectDirectory is unsupported for Headless but required
|
||||
// for the Renderer interface
|
||||
func (h *Headless) SelectDirectory() string {
|
||||
h.log.Error("SelectDirectory() unsupported in headless mode")
|
||||
h.log.Warn("SelectDirectory() unsupported in bridge mode")
|
||||
return ""
|
||||
}
|
||||
|
||||
// SelectSaveFile is unsupported for Headless but required
|
||||
// for the Renderer interface
|
||||
func (h *Headless) SelectSaveFile() string {
|
||||
h.log.Error("SelectSaveFile() unsupported in headless mode")
|
||||
h.log.Warn("SelectSaveFile() unsupported in bridge mode")
|
||||
return ""
|
||||
}
|
||||
|
||||
@@ -245,23 +245,23 @@ func (h *Headless) SetColour(colour string) error {
|
||||
// Fullscreen is unsupported for Headless but required
|
||||
// for the Renderer interface
|
||||
func (h *Headless) Fullscreen() {
|
||||
h.log.Warn("Fullscreen() unsupported in headless mode")
|
||||
h.log.Warn("Fullscreen() unsupported in bridge mode")
|
||||
}
|
||||
|
||||
// UnFullscreen is unsupported for Headless but required
|
||||
// for the Renderer interface
|
||||
func (h *Headless) UnFullscreen() {
|
||||
h.log.Warn("UnFullscreen() unsupported in headless mode")
|
||||
h.log.Warn("UnFullscreen() unsupported in bridge mode")
|
||||
}
|
||||
|
||||
// SetTitle is currently unsupported for Headless but required
|
||||
// for the Renderer interface
|
||||
func (h *Headless) SetTitle(title string) {
|
||||
h.log.WarnFields("SetTitle() unsupported in headless mode", Fields{"title": title})
|
||||
h.log.WarnFields("SetTitle() unsupported in bridge mode", Fields{"title": title})
|
||||
}
|
||||
|
||||
// Close is unsupported for Headless but required
|
||||
// for the Renderer interface
|
||||
func (h *Headless) Close() {
|
||||
h.log.Warn("Close() unsupported in headless mode")
|
||||
h.log.Warn("Close() unsupported in bridge mode")
|
||||
}
|
||||
|
||||
@@ -122,7 +122,7 @@ func (w *webViewRenderer) evalJSSync(js string) error {
|
||||
|
||||
go func() {
|
||||
exit := false
|
||||
// We are done when we recieve the Callback ID
|
||||
// We are done when we receive the Callback ID
|
||||
w.log.Debug("SyncJS: sending with ID = " + ID)
|
||||
w.eventManager.On(ID, func(...interface{}) {
|
||||
w.log.Debug("SyncJS: Got callback ID = " + ID)
|
||||
|
||||
18
runtime.go
18
runtime.go
@@ -2,17 +2,19 @@ package wails
|
||||
|
||||
// Runtime is the Wails Runtime Interface, given to a user who has defined the WailsInit method
|
||||
type Runtime struct {
|
||||
Events *RuntimeEvents
|
||||
Log *RuntimeLog
|
||||
Dialog *RuntimeDialog
|
||||
Window *RuntimeWindow
|
||||
Events *RuntimeEvents
|
||||
Log *RuntimeLog
|
||||
Dialog *RuntimeDialog
|
||||
Window *RuntimeWindow
|
||||
FileSystem *RuntimeFileSystem
|
||||
}
|
||||
|
||||
func newRuntime(eventManager *eventManager, renderer Renderer) *Runtime {
|
||||
return &Runtime{
|
||||
Events: newRuntimeEvents(eventManager),
|
||||
Log: newRuntimeLog(),
|
||||
Dialog: newRuntimeDialog(renderer),
|
||||
Window: newRuntimeWindow(renderer),
|
||||
Events: newRuntimeEvents(eventManager),
|
||||
Log: newRuntimeLog(),
|
||||
Dialog: newRuntimeDialog(renderer),
|
||||
Window: newRuntimeWindow(renderer),
|
||||
FileSystem: newRuntimeFileSystem(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,5 +18,5 @@ func (r *RuntimeEvents) On(eventName string, callback func(optionalData ...inter
|
||||
|
||||
// Emit pass through
|
||||
func (r *RuntimeEvents) Emit(eventName string, optionalData ...interface{}) {
|
||||
r.eventManager.Emit(eventName, optionalData)
|
||||
r.eventManager.Emit(eventName, optionalData...)
|
||||
}
|
||||
|
||||
16
runtime_filesystem.go
Normal file
16
runtime_filesystem.go
Normal file
@@ -0,0 +1,16 @@
|
||||
package wails
|
||||
|
||||
import homedir "github.com/mitchellh/go-homedir"
|
||||
|
||||
// RuntimeFileSystem exposes file system utilities to the runtime
|
||||
type RuntimeFileSystem struct {
|
||||
}
|
||||
|
||||
func newRuntimeFileSystem() *RuntimeFileSystem {
|
||||
return &RuntimeFileSystem{}
|
||||
}
|
||||
|
||||
// HomeDir returns the user's home directory
|
||||
func (r *RuntimeFileSystem) HomeDir() (string, error) {
|
||||
return homedir.Dir()
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@@ -111,6 +111,7 @@ function startBridge() {
|
||||
// Removes it if second parameter is true.
|
||||
function addScript(script, remove) {
|
||||
var s = document.createElement("script");
|
||||
s.setAttribute('type', 'text/javascript');
|
||||
s.textContent = script;
|
||||
document.head.appendChild(s);
|
||||
|
||||
|
||||
40
wailsruntimeassets/default/wails.min.1.js
Normal file
40
wailsruntimeassets/default/wails.min.1.js
Normal file
@@ -0,0 +1,40 @@
|
||||
(function(){window.wails=window.wails||{};window.backend={};function cryptoRandom(){var array=new Uint32Array(1);return window.crypto.getRandomValues(array)[0]}function basicRandom(){return Math.random()*9007199254740991}var randomFunc;if(window.crypto){randomFunc=cryptoRandom}else{randomFunc=basicRandom}function isValidIdentifier(name){try{new Function("var "+name);return true}catch(e){return false}}function addScript(js,callbackID){var script=document.createElement("script");script.text=js;document.body.appendChild(script);window.wails.events.emit(callbackID)}function injectCSS(css){var elem=document.createElement('style');elem.setAttribute('type','text/css');if(elem.styleSheet){elem.styleSheet.cssText=css}else{elem.appendChild(document.createTextNode(css))}var head=document.head||document.getElementsByTagName('head')[0];head.appendChild(elem)}var bindingsBasePath=window.backend;function addBindingPath(pathSections){var currentPath=bindingsBasePath;for(var sectionIndex in pathSections){var section=pathSections[sectionIndex];if(!isValidIdentifier(section)){var errMessage=section+" is not a valid javascript identifier.";var err=new Error(errMessage);return[null,err]}if(!currentPath[section]){currentPath[section]={}}currentPath=currentPath[section]}return[currentPath,null]}function newBinding(bindingName){var bindingSections=bindingName.split('.').splice(1);var callName=bindingSections.pop();var pathToBinding;var err;var bs=addBindingPath(bindingSections);var pathToBinding=bs[0];var err=bs[1];if(err!=null){return err}pathToBinding[callName]=function(){var timeout=0;function dynamic(){var args=[].slice.call(arguments);return call(bindingName,args,timeout)}dynamic.setTimeout=function(newTimeout){timeout=newTimeout};dynamic.getTimeout=function(){return timeout};return dynamic}()}var callbacks={};function call(bindingName,data,timeout){if(timeout==null||timeout==undefined){timeout=0}return new Promise(function(resolve,reject){var callbackID;do{callbackID=bindingName+"-"+randomFunc()}while(callbacks[callbackID]);if(timeout>0){var timeoutHandle=setTimeout(function(){reject(Error("Call to "+bindingName+" timed out. Request ID: "+callbackID))},timeout)}callbacks[callbackID]={timeoutHandle:timeoutHandle,reject:reject,resolve:resolve};try{var payloaddata=JSON.stringify(data);message={type:"call",callbackid:callbackID,payload:{bindingName:bindingName,data:payloaddata}};var payload=JSON.stringify(message);external.invoke(payload)}catch(e){console.error(e)}})}function callback(incomingMessage){var message;try{message=JSON.parse(incomingMessage)}catch(e){wails.log.debug("Invalid JSON passed to callback: "+e.message);wails.log.debug("Message: "+incomingMessage);return}callbackID=message.callbackid;callbackData=callbacks[callbackID];if(!callbackData){console.error("Callback '"+callbackID+"' not registed!!!");return}clearTimeout(callbackData.timeoutHandle);delete callbacks[callbackID];if(message.error){return callbackData.reject(message.error)}return callbackData.resolve(message.data)}var eventListeners={};function on(eventName,callback){eventListeners[eventName]=eventListeners[eventName]||[];eventListeners[eventName].push(callback)}function notify(eventName,data){if(eventListeners[eventName]){eventListeners[eventName].forEach(function(element){var parsedData=[];if(data){try{parsedData=JSON.parse(data)}catch(e){wails.log.error("Invalid JSON data sent to notify. Event name = "+eventName)}}element.apply(null,parsedData)})}}function emit(eventName){var data=JSON.stringify([].slice.apply(arguments).slice(1));message={type:"event",payload:{name:eventName,data:data}};external.invoke(JSON.stringify(message))}window.wails.events={emit:emit,on:on};function sendLogMessage(level,message){message={type:"log",payload:{level:level,message:message}};external.invoke(JSON.stringify(message))}function logDebug(message){sendLogMessage("debug",message)}function logInfo(message){sendLogMessage("info",message)}function logWarning(message){sendLogMessage("warning",message)}function logError(message){sendLogMessage("error",message)}function logFatal(message){sendLogMessage("fatal",message)}window.wails.log={debug:logDebug,info:logInfo,warning:logWarning,error:logError,fatal:logFatal};window.wails._={newBinding:newBinding,callback:callback,notify:notify,sendLogMessage:sendLogMessage,callbacks:callbacks,injectCSS:injectCSS,addScript:addScript};window.wails.events.emit("wails:loaded");})();
|
||||
(function(){window.wails=window.wails||{};window.backend={};function cryptoRandom(){var array=new Uint32Array(1);return window.crypto.getRandomValues(array)[0]}
|
||||
function basicRandom(){return Math.random()*9007199254740991}
|
||||
var randomFunc;if(window.crypto){randomFunc=cryptoRandom}else{randomFunc=basicRandom}
|
||||
function isValidIdentifier(name){try{new Function("var "+name);return!0}catch(e){return!1}}
|
||||
function addScript(js,callbackID){var script=document.createElement("script");script.text=js;document.body.appendChild(script);window.wails.events.emit(callbackID)}
|
||||
function injectCSS(css){var elem=document.createElement('style');elem.setAttribute('type','text/css');if(elem.styleSheet){elem.styleSheet.cssText=css}else{elem.appendChild(document.createTextNode(css))}
|
||||
var head=document.head||document.getElementsByTagName('head')[0];head.appendChild(elem)}
|
||||
var bindingsBasePath=window.backend;function addBindingPath(pathSections){var currentPath=bindingsBasePath;for(var sectionIndex in pathSections){var section=pathSections[sectionIndex];if(!isValidIdentifier(section)){var errMessage=section+" is not a valid javascript identifier.";var err=new Error(errMessage);return[null,err]}
|
||||
if(!currentPath[section]){currentPath[section]={}}
|
||||
currentPath=currentPath[section]}
|
||||
return[currentPath,null]}
|
||||
function newBinding(bindingName){var bindingSections=bindingName.split('.').splice(1);var callName=bindingSections.pop();var pathToBinding;var err;var bs=addBindingPath(bindingSections);var pathToBinding=bs[0];var err=bs[1];if(err!=null){return err}
|
||||
pathToBinding[callName]=function(){var timeout=0;function dynamic(){var args=[].slice.call(arguments);return call(bindingName,args,timeout)}
|
||||
dynamic.setTimeout=function(newTimeout){timeout=newTimeout}
|
||||
dynamic.getTimeout=function(){return timeout}
|
||||
return dynamic}()}
|
||||
var callbacks={};function call(bindingName,data,timeout){if(timeout==null||timeout==undefined){timeout=0}
|
||||
return new Promise(function(resolve,reject){var callbackID;do{callbackID=bindingName+"-"+randomFunc()}while(callbacks[callbackID]);if(timeout>0){var timeoutHandle=setTimeout(function(){reject(Error("Call to "+bindingName+" timed out. Request ID: "+callbackID))},timeout)}
|
||||
callbacks[callbackID]={timeoutHandle:timeoutHandle,reject:reject,resolve:resolve}
|
||||
try{var payloaddata=JSON.stringify(data);message={type:"call",callbackid:callbackID,payload:{bindingName:bindingName,data:payloaddata,}}
|
||||
var payload=JSON.stringify(message);external.invoke(payload)}catch(e){console.error(e)}})}
|
||||
function callback(incomingMessage){incomingMessage=decodeURIComponent(incomingMessage.replace(/\s+/g,'').replace(/[0-9a-f]{2}/g,'%$&'));var message;try{message=JSON.parse(incomingMessage)}catch(e){wails.log.debug("Invalid JSON passed to callback: "+e.message);wails.log.debug("Message: "+incomingMessage);return}
|
||||
callbackID=message.callbackid;callbackData=callbacks[callbackID];if(!callbackData){console.error("Callback '"+callbackID+"' not registed!!!");return}
|
||||
clearTimeout(callbackData.timeoutHandle);delete callbacks[callbackID];if(message.error){return callbackData.reject(message.error)}
|
||||
return callbackData.resolve(message.data)}
|
||||
var eventListeners={};function on(eventName,callback){eventListeners[eventName]=eventListeners[eventName]||[];eventListeners[eventName].push(callback)}
|
||||
function notify(eventName,data){if(eventListeners[eventName]){eventListeners[eventName].forEach(function(element){var parsedData=[];if(data){try{parsedData=JSON.parse(data)}catch(e){wails.log.error("Invalid JSON data sent to notify. Event name = "+eventName)}}
|
||||
element.apply(null,parsedData)})}}
|
||||
function emit(eventName){var data=JSON.stringify([].slice.apply(arguments).slice(1));message={type:"event",payload:{name:eventName,data:data,}}
|
||||
external.invoke(JSON.stringify(message))}
|
||||
window.wails.events={emit:emit,on:on};function sendLogMessage(level,message){message={type:"log",payload:{level:level,message:message,}}
|
||||
external.invoke(JSON.stringify(message))}
|
||||
function logDebug(message){sendLogMessage("debug",message)}
|
||||
function logInfo(message){sendLogMessage("info",message)}
|
||||
function logWarning(message){sendLogMessage("warning",message)}
|
||||
function logError(message){sendLogMessage("error",message)}
|
||||
function logFatal(message){sendLogMessage("fatal",message)}
|
||||
window.wails.log={debug:logDebug,info:logInfo,warning:logWarning,error:logError,fatal:logFatal,};window.wails._={newBinding:newBinding,callback:callback,notify:notify,sendLogMessage:sendLogMessage,callbacks:callbacks,injectCSS:injectCSS,addScript:addScript,}
|
||||
window.wails.events.emit("wails:loaded")})()
|
||||
Reference in New Issue
Block a user