Compare commits

..

3 Commits

Author SHA1 Message Date
Lea Anthony
02d6fe609c Remove windows message 2020-10-28 21:16:33 +11:00
Lea Anthony
93e7432ba9 Merge branch 'develop' into firebug 2020-10-28 21:14:39 +11:00
Lea Anthony
cb933cc987 Initial support for firebug 2020-10-28 21:11:13 +11:00
34 changed files with 91 additions and 355 deletions

View File

@@ -39,10 +39,3 @@ Wails is what it is because of the time and effort given by these great people.
* [Kyle](https://github.com/kmuchmore) * [Kyle](https://github.com/kmuchmore)
* [Balakrishna Prasad Ganne](https://github.com/aayush420) * [Balakrishna Prasad Ganne](https://github.com/aayush420)
* [Charaf Rezrazi](https://github.com/Rezrazi) * [Charaf Rezrazi](https://github.com/Rezrazi)
* [misitebao](https://github.com/misitebao)
* [Elie Grenon](https://github.com/DrunkenPoney)
* [SophieAu](https://github.com/SophieAu)
* [Alexander Matviychuk](https://github.com/alexmat)
* [RH12503](https://github.com/RH12503)
* [hi019](https://github.com/hi019)

View File

@@ -2,7 +2,7 @@
<img src="logo_cropped.png" width="40%"><br/> <img src="logo_cropped.png" width="40%"><br/>
</p> </p>
<p align="center"> <p align="center">
Build desktop applications using Go & Web Technologies.<br/><br/> 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://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="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="http://godoc.org/github.com/wailsapp/wails"><img src="https://img.shields.io/badge/godoc-reference-blue.svg"/></a>
@@ -20,7 +20,7 @@ The official docs can be found at [https://wails.app](https://wails.app).
## Features ## Features
- Use standard Go for the backend - Use standard Go libraries/frameworks for the backend
- Use any frontend technology to build your UI - Use any frontend technology to build your UI
- Quickly create Vue, Vuetify or React frontends for your Go programs - Quickly create Vue, Vuetify or React frontends for your Go programs
- Expose Go methods/functions to the frontend via a single bind command - Expose Go methods/functions to the frontend via a single bind command
@@ -30,14 +30,6 @@ The official docs can be found at [https://wails.app](https://wails.app).
- Powerful cli tool - Powerful cli tool
- Multiplatform - Multiplatform
## Sponsors
This project is supported by these kind people:
<a href="https://pace.dev" style="width:100px"><img src="pace.jpeg" width="100"/></a>
<a href="https://github.com/tc-hib" style="width:50px">
<img src="https://github.com/tc-hib.png?size=50" width="50"/>
</a>
## Installation ## Installation
@@ -155,13 +147,7 @@ This project was mainly coded to the following albums:
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fwailsapp%2Fwails.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fwailsapp%2Fwails?ref=badge_large) [![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fwailsapp%2Fwails.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fwailsapp%2Fwails?ref=badge_large)
## Special Thanks ## Special Thank You
<p align="center" style="text-align: center">
<a href="https://pace.dev"><img src="pace.jpeg"/></a><br/>
A *huge* thanks to <a href="https://pace.dev">Pace</a> for sponsoring the project and helping the efforts to get Wails ported to Apple Silicon!<br/><br/>
If you are looking for a Project Management tool that's powerful but quick and easy to use, check them out!<br/><br/>
</p>
<p align="center" style="text-align: center"> <p align="center" style="text-align: center">
A special thank you to JetBrains for donating licenses to us!<br/><br/> A special thank you to JetBrains for donating licenses to us!<br/><br/>

File diff suppressed because one or more lines are too long

View File

@@ -24,7 +24,7 @@ func (g *GitHubHelper) GetVersionTags() ([]*SemanticVersion, error) {
result := []*SemanticVersion{} result := []*SemanticVersion{}
var err error var err error
resp, err := http.Get("https://api.github.com/repos/wailsapp/wails/releases") resp, err := http.Get("https://api.github.com/repos/wailsapp/wails/tags")
if err != nil { if err != nil {
return result, err return result, err
} }

View File

@@ -595,9 +595,3 @@ func ldFlags(po *ProjectOptions, buildMode string) string {
} }
return ldflags return ldflags
} }
func getGitConfigValue(key string) (string, error) {
output, err := exec.Command("git", "config", "--get", "--null", key).Output()
// When using --null git appends a null character (\u0000) to the command output
return strings.TrimRight(string(output), "\u0000"), err
}

View File

@@ -65,10 +65,6 @@ const (
Solus Solus
// Ctlos Linux distribution // Ctlos Linux distribution
Ctlos Ctlos
// EndeavourOS linux distribution
EndeavourOS
// Crux linux distribution
Crux
) )
// DistroInfo contains all the information relating to a linux distribution // DistroInfo contains all the information relating to a linux distribution
@@ -136,7 +132,7 @@ func parseOsRelease(osRelease string) *DistroInfo {
case "archlabs": case "archlabs":
result.Distribution = ArchLabs result.Distribution = ArchLabs
case "ctlos": case "ctlos":
result.Distribution = Ctlos result.Distribution = Ctlos
case "debian": case "debian":
result.Distribution = Debian result.Distribution = Debian
case "ubuntu": case "ubuntu":
@@ -175,10 +171,6 @@ func parseOsRelease(osRelease string) *DistroInfo {
result.Distribution = PopOS result.Distribution = PopOS
case "solus": case "solus":
result.Distribution = Solus result.Distribution = Solus
case "endeavouros":
result.Distribution = EndeavourOS
case "crux":
result.Distribution = Crux
default: default:
result.Distribution = Unknown result.Distribution = Unknown
} }
@@ -259,17 +251,6 @@ func RpmInstalled(packageName string) (bool, error) {
return exitCode == 0, nil return exitCode == 0, nil
} }
// PrtGetInstalled uses prt-get to see if a package is installed
func PrtGetInstalled(packageName string) (bool, error) {
program := NewProgramHelper()
prtget := program.FindProgram("prt-get")
if prtget == nil {
return false, fmt.Errorf("cannot check dependencies: prt-get not found")
}
_, _, exitCode, _ := prtget.Run("isinst", packageName)
return exitCode == 0, nil
}
// RequestSupportForDistribution promts the user to submit a request to support their // RequestSupportForDistribution promts the user to submit a request to support their
// currently unsupported distribution // currently unsupported distribution
func RequestSupportForDistribution(distroInfo *DistroInfo) error { func RequestSupportForDistribution(distroInfo *DistroInfo) error {

View File

@@ -202,16 +202,7 @@ distributions:
name: Ctlos Linux name: Ctlos Linux
gccversioncommand: *gccdumpversion gccversioncommand: *gccdumpversion
programs: *archdefaultprograms programs: *archdefaultprograms
libraries: *archdefaultlibraries libraries: *archdefaultlibraries
endeavouros:
id: endeavouros
releases:
default:
version: default
name: EndeavourOS
gccversioncommand: *gccdumpversion
programs: *archdefaultprograms
libraries: *archdefaultlibraries
manjaro: manjaro:
id: manjaro id: manjaro
releases: releases:
@@ -307,22 +298,3 @@ distributions:
gccversioncommand: *gccdumpfullversion gccversioncommand: *gccdumpfullversion
programs: *opensusedefaultprograms programs: *opensusedefaultprograms
libraries: *opensusedefaultlibraries libraries: *opensusedefaultlibraries
crux:
id: crux
releases:
default:
version: default
name: Crux Linux
gccversioncommand: *gccdumpversion
programs:
- name: gcc
help: Please install with `sudo prt-get depinst gcc-c++ make` and try again
- name: pkg-config
help: Please install with `sudo prt-get depinst pkg-config` and try again
- name: npm
help: Please install with `sudo prt-get depinst nodejs` and try again
libraries:
- name: gtk3
help: Please install with `sudo prt-get depinst gtk3` and try again
- name: webkitgtk
help: Please install with `sudo prt-get depinst webkitgtk` and try again

View File

@@ -24,19 +24,11 @@ func NewSemanticVersion(version string) (*SemanticVersion, error) {
// IsRelease returns true if it's a release version // IsRelease returns true if it's a release version
func (s *SemanticVersion) IsRelease() bool { func (s *SemanticVersion) IsRelease() bool {
// Limit to v1
if s.Version.Major() != 1 {
return false
}
return len(s.Version.Prerelease()) == 0 && len(s.Version.Metadata()) == 0 return len(s.Version.Prerelease()) == 0 && len(s.Version.Metadata()) == 0
} }
// IsPreRelease returns true if it's a prerelease version // IsPreRelease returns true if it's a prerelease version
func (s *SemanticVersion) IsPreRelease() bool { func (s *SemanticVersion) IsPreRelease() bool {
// Limit to v1
if s.Version.Major() != 1 {
return false
}
return len(s.Version.Prerelease()) > 0 return len(s.Version.Prerelease()) > 0
} }

View File

@@ -1,65 +0,0 @@
package cmd
import (
"testing"
)
func TestSemanticVersion_IsPreRelease(t *testing.T) {
tests := []struct {
name string
version string
want bool
}{
{"v1.6.7-pre0", "v1.6.7-pre0", true},
{"v2.6.7+pre0", "v2.6.7+pre0", false},
{"v2.6.7", "v2.6.7", false},
{"v2.0.0+alpha.1", "v2.0.0+alpha.1", false},
{"v2.0.0-alpha.1", "v2.0.0-alpha.1", false},
{"v1.6.7", "v1.6.7", false},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
semanticversion, err := NewSemanticVersion(tt.version)
if err != nil {
t.Errorf("Invalid semantic version: %s", semanticversion)
return
}
s := &SemanticVersion{
Version: semanticversion.Version,
}
if got := s.IsPreRelease(); got != tt.want {
t.Errorf("IsPreRelease() = %v, want %v", got, tt.want)
}
})
}
}
func TestSemanticVersion_IsRelease(t *testing.T) {
tests := []struct {
name string
version string
want bool
}{
{"v1.6.7", "v1.6.7", true},
{"v2.6.7-pre0", "v2.6.7-pre0", false},
{"v2.6.7", "v2.6.7", false},
{"v2.6.7+release", "v2.6.7+release", false},
{"v2.0.0-alpha.1", "v2.0.0-alpha.1", false},
{"v1.6.7-pre0", "v1.6.7-pre0", false},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
semanticversion, err := NewSemanticVersion(tt.version)
if err != nil {
t.Errorf("Invalid semantic version: %s", semanticversion)
return
}
s := &SemanticVersion{
Version: semanticversion.Version,
}
if got := s.IsRelease(); got != tt.want {
t.Errorf("IsRelease() = %v, want %v", got, tt.want)
}
})
}
}

View File

@@ -99,16 +99,11 @@ func (s *SystemHelper) setup() error {
if config.Name != "" { if config.Name != "" {
systemConfig["name"] = PromptRequired("What is your name", config.Name) systemConfig["name"] = PromptRequired("What is your name", config.Name)
} else if n, err := getGitConfigValue("user.name"); err == nil && n != "" {
systemConfig["name"] = PromptRequired("What is your name", n)
} else { } else {
systemConfig["name"] = PromptRequired("What is your name") systemConfig["name"] = PromptRequired("What is your name")
} }
if config.Email != "" { if config.Email != "" {
systemConfig["email"] = PromptRequired("What is your email address", config.Email) systemConfig["email"] = PromptRequired("What is your email address", config.Email)
} else if e, err := getGitConfigValue("user.email"); err == nil && e != "" {
systemConfig["email"] = PromptRequired("What is your email address", e)
} else { } else {
systemConfig["email"] = PromptRequired("What is your email address") systemConfig["email"] = PromptRequired("What is your email address")
} }
@@ -185,7 +180,7 @@ func (s *SystemHelper) Initialise() error {
return s.setup() return s.setup()
} }
// SystemConfig - Defines system wide configuration data // SystemConfig - Defines system wode configuration data
type SystemConfig struct { type SystemConfig struct {
Name string `json:"name"` Name string `json:"name"`
Email string `json:"email"` Email string `json:"email"`
@@ -281,7 +276,7 @@ func CheckDependencies(logger *Logger) (bool, error) {
switch distroInfo.Distribution { switch distroInfo.Distribution {
case Ubuntu, Debian, Zorin, Parrot, Linuxmint, Elementary, Kali, Neon, Deepin, Raspbian, PopOS: case Ubuntu, Debian, Zorin, Parrot, Linuxmint, Elementary, Kali, Neon, Deepin, Raspbian, PopOS:
libraryChecker = DpkgInstalled libraryChecker = DpkgInstalled
case Arch, ArcoLinux, ArchLabs, Ctlos, Manjaro, ManjaroARM, EndeavourOS: case Arch, ArcoLinux, ArchLabs, Ctlos, Manjaro, ManjaroARM:
libraryChecker = PacmanInstalled libraryChecker = PacmanInstalled
case CentOS, Fedora, Tumbleweed, Leap: case CentOS, Fedora, Tumbleweed, Leap:
libraryChecker = RpmInstalled libraryChecker = RpmInstalled
@@ -291,8 +286,6 @@ func CheckDependencies(logger *Logger) (bool, error) {
libraryChecker = XbpsInstalled libraryChecker = XbpsInstalled
case Solus: case Solus:
libraryChecker = EOpkgInstalled libraryChecker = EOpkgInstalled
case Crux:
libraryChecker = PrtGetInstalled
default: default:
return false, RequestSupportForDistribution(distroInfo) return false, RequestSupportForDistribution(distroInfo)
} }

View File

@@ -3,7 +3,7 @@
"version": "0.0.0", "version": "0.0.0",
"scripts": { "scripts": {
"ng": "npx ng", "ng": "npx ng",
"serve": "npx ng serve --poll=2000 --host=0.0.0.0", "start": "npx ng serve --poll=2000 --host=0.0.0.0",
"build": "npx ng build --single-bundle true --output-hashing none --prod --bundle-styles false", "build": "npx ng build --single-bundle true --output-hashing none --prod --bundle-styles false",
"test": "npx ng test", "test": "npx ng test",
"lint": "npx ng lint", "lint": "npx ng lint",

View File

@@ -14,7 +14,7 @@
"author": "bh90210 <ktc@pm.me>", "author": "bh90210 <ktc@pm.me>",
"created": "2019-06-15 18:23:48.666414555 +0300 EEST m=+223.934866008", "created": "2019-06-15 18:23:48.666414555 +0300 EEST m=+223.934866008",
"frontenddir": "frontend", "frontenddir": "frontend",
"serve": "npm run serve", "serve": "npx ng serve --poll=2000",
"bridge": "src", "bridge": "src",
"wailsdir": "" "wailsdir": ""
} }

View File

@@ -12,7 +12,7 @@
"@wailsapp/runtime": "^1.0.10" "@wailsapp/runtime": "^1.0.10"
}, },
"scripts": { "scripts": {
"serve": "react-scripts start", "start": "react-scripts start",
"build": "react-scripts build", "build": "react-scripts build",
"test": "react-scripts test", "test": "react-scripts test",
"eject": "react-scripts eject" "eject": "react-scripts eject"

View File

@@ -8,7 +8,7 @@
"author": "bh90210 <ktc@pm.me>", "author": "bh90210 <ktc@pm.me>",
"created": "2019-06-07 18:23:48.666414555 +0300 EEST m=+223.934866008", "created": "2019-06-07 18:23:48.666414555 +0300 EEST m=+223.934866008",
"frontenddir": "frontend", "frontenddir": "frontend",
"serve": "npm run serve", "serve": "npm run start",
"bridge": "src", "bridge": "src",
"wailsdir": "" "wailsdir": ""
} }

View File

@@ -3,7 +3,7 @@
"author": "{{.Author.Name}}<{{.Author.Email}}>", "author": "{{.Author.Name}}<{{.Author.Email}}>",
"scripts": { "scripts": {
"build": "rollup -c", "build": "rollup -c",
"serve": "rollup -c -w", "dev": "rollup -c -w",
"start": "sirv public" "start": "sirv public"
}, },
"devDependencies": { "devDependencies": {

View File

@@ -80,6 +80,7 @@ export default {
{ {
targets: '> 0.25%, not dead, IE 11', targets: '> 0.25%, not dead, IE 11',
modules: false, modules: false,
spec: true,
useBuiltIns: 'usage', useBuiltIns: 'usage',
forceAllTransforms: true, forceAllTransforms: true,
corejs: 3, corejs: 3,

View File

@@ -8,7 +8,7 @@
"author": "Tim Kipp <timkipp.22.developer@gmail.com>", "author": "Tim Kipp <timkipp.22.developer@gmail.com>",
"created": "2020-09-06 13:06:10.469848 -0700 PDT m=+213.578828559", "created": "2020-09-06 13:06:10.469848 -0700 PDT m=+213.578828559",
"frontenddir": "frontend", "frontenddir": "frontend",
"serve": "npm run serve", "serve": "npm run dev",
"bridge": "src", "bridge": "src",
"wailsdir": "" "wailsdir": ""
} }

View File

@@ -19,16 +19,16 @@
"@types/mocha": "^8.0.3", "@types/mocha": "^8.0.3",
"@typescript-eslint/eslint-plugin": "^4.3.0", "@typescript-eslint/eslint-plugin": "^4.3.0",
"@typescript-eslint/parser": "^4.3.0", "@typescript-eslint/parser": "^4.3.0",
"@vue/cli-plugin-eslint": "~4.5.9", "@vue/cli-plugin-eslint": "~4.5.6",
"@vue/cli-plugin-router": "~4.5.9", "@vue/cli-plugin-router": "~4.5.6",
"@vue/cli-plugin-typescript": "~4.5.9", "@vue/cli-plugin-typescript": "~4.5.6",
"@vue/cli-plugin-unit-mocha": "~4.5.9", "@vue/cli-plugin-unit-mocha": "~4.5.6",
"@vue/cli-service": "~4.5.9", "@vue/cli-service": "~4.5.6",
"@vue/compiler-sfc": "^3.0.0", "@vue/compiler-sfc": "^3.0.0",
"@vue/eslint-config-typescript": "^7.0.0", "@vue/eslint-config-typescript": "^5.1.0",
"@vue/test-utils": "^2.0.0-0", "@vue/test-utils": "^2.0.0-0",
"chai": "^4.2.0", "chai": "^4.2.0",
"eslint": "<7.0.0", "eslint": "^7.10.0",
"eslint-plugin-vue": "^7.0.0", "eslint-plugin-vue": "^7.0.0",
"node-sass": "^4.14.1", "node-sass": "^4.14.1",
"sass-loader": "^10.0.2", "sass-loader": "^10.0.2",

View File

@@ -1,4 +1,4 @@
package cmd package cmd
// Version - Wails version // Version - Wails version
const Version = "v1.12.3" const Version = "v1.8.1-pre6"

View File

@@ -83,9 +83,6 @@ func init() {
return fmt.Errorf("Unable to find 'project.json'. Please check you are in a Wails project directory") return fmt.Errorf("Unable to find 'project.json'. Please check you are in a Wails project directory")
} }
// Set firebug flag
projectOptions.UseFirebug = usefirebug
// Check that this platform is supported // Check that this platform is supported
if !projectOptions.PlatformSupported() { if !projectOptions.PlatformSupported() {
logger.Yellow("WARNING: This project is unsupported on %s - it probably won't work!\n Valid platforms: %s\n", runtime.GOOS, strings.Join(projectOptions.Platforms, ", ")) logger.Yellow("WARNING: This project is unsupported on %s - it probably won't work!\n Valid platforms: %s\n", runtime.GOOS, strings.Join(projectOptions.Platforms, ", "))

View File

@@ -1,37 +1,20 @@
package wails package wails
import ( import (
"net/url" "github.com/leaanthony/mewn"
"strings"
"github.com/wailsapp/wails/runtime" "github.com/wailsapp/wails/runtime"
) )
// AppConfig is the configuration structure used when creating a Wails App object // AppConfig is the configuration structure used when creating a Wails App object
type AppConfig struct { type AppConfig struct {
// The width and height of your application in pixels Width, Height int
Width, Height int Title string
defaultHTML string
// The title to put in the title bar HTML string
Title string JS string
CSS string
// The HTML your app should use. If you leave it blank, a default will be used: Colour string
// <!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta http-equiv="IE=edge" content="IE=edge"></head><body><div id="app"></div><script type="text/javascript"></script></body></html> Resizable bool
HTML string
// The Javascript your app should use. Normally this should be generated by a bundler.
JS string
// The CSS your app should use. Normally this should be generated by a bundler.
CSS string
// The colour of your window. Can take "#fff", "rgb(255,255,255)", "rgba(255,255,255,1)" formats
Colour string
// Indicates whether your app should be resizable
Resizable bool
// Indicated if the devtools should be disabled
DisableInspector bool DisableInspector bool
} }
@@ -50,14 +33,9 @@ func (a *AppConfig) GetTitle() string {
return a.Title return a.Title
} }
// GetHTML returns the default HTML // GetDefaultHTML returns the default HTML
func (a *AppConfig) GetHTML() string { func (a *AppConfig) GetDefaultHTML() string {
if len(a.HTML) > 0 { return a.defaultHTML
a.HTML = url.QueryEscape(a.HTML)
a.HTML = "data:text/html," + strings.ReplaceAll(a.HTML, "+", "%20")
a.HTML = strings.ReplaceAll(a.HTML, "%3D", "=")
}
return a.HTML
} }
// GetResizable returns true if the window should be resizable // GetResizable returns true if the window should be resizable
@@ -97,18 +75,10 @@ func (a *AppConfig) merge(in *AppConfig) error {
a.Colour = in.Colour a.Colour = in.Colour
} }
if in.HTML != "" {
a.HTML = in.HTML
}
if in.JS != "" { if in.JS != "" {
a.JS = in.JS a.JS = in.JS
} }
if in.HTML != "" {
a.HTML = in.HTML
}
if in.Width != 0 { if in.Width != 0 {
a.Width = in.Width a.Width = in.Width
} }
@@ -129,7 +99,7 @@ func newConfig(userConfig *AppConfig) (*AppConfig, error) {
Resizable: true, Resizable: true,
Title: "My Wails App", Title: "My Wails App",
Colour: "#FFF", // White by default Colour: "#FFF", // White by default
HTML: defaultHTML, HTML: mewn.String("./runtime/assets/default.html"),
} }
if userConfig != nil { if userConfig != nil {
@@ -141,17 +111,3 @@ func newConfig(userConfig *AppConfig) (*AppConfig, error) {
return result, nil return result, nil
} }
var defaultHTML = `<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
</head>
<body>
<div id="app"></div>
</body>
</html>`

View File

@@ -18,7 +18,6 @@ type Manager struct {
log *logger.CustomLogger log *logger.CustomLogger
renderer interfaces.Renderer // Messages will be dispatched to the frontend renderer interfaces.Renderer // Messages will be dispatched to the frontend
wg sync.WaitGroup wg sync.WaitGroup
mu sync.Mutex
} }
// NewManager creates a new event manager with a 100 event buffer // NewManager creates a new event manager with a 100 event buffer
@@ -43,12 +42,12 @@ func (e *Manager) PushEvent(eventData *messages.EventData) {
// means it does not expire (default). // means it does not expire (default).
type eventListener struct { type eventListener struct {
callback func(...interface{}) // Function to call with emitted event data callback func(...interface{}) // Function to call with emitted event data
counter uint // Expire after counter callbacks. 0 = infinite counter int // Expire after counter callbacks. 0 = infinite
expired bool // Indicates if the listener has expired expired bool // Indicates if the listener has expired
} }
// Creates a new event listener from the given callback function // Creates a new event listener from the given callback function
func (e *Manager) addEventListener(eventName string, callback func(...interface{}), counter uint) error { func (e *Manager) addEventListener(eventName string, callback func(...interface{}), counter int) error {
// Sanity check inputs // Sanity check inputs
if callback == nil { if callback == nil {
@@ -76,30 +75,7 @@ func (e *Manager) addEventListener(eventName string, callback func(...interface{
// On adds a listener for the given event // On adds a listener for the given event
func (e *Manager) On(eventName string, callback func(...interface{})) { func (e *Manager) On(eventName string, callback func(...interface{})) {
// Add a persistent eventListener (counter = 0) // Add a persistent eventListener (counter = 0)
err := e.addEventListener(eventName, callback, 0) e.addEventListener(eventName, callback, 0)
if err != nil {
e.log.Error(err.Error())
}
}
// Once adds a listener for the given event that will auto remove
// after one callback
func (e *Manager) Once(eventName string, callback func(...interface{})) {
// Add a persistent eventListener (counter = 0)
err := e.addEventListener(eventName, callback, 1)
if err != nil {
e.log.Error(err.Error())
}
}
// OnMultiple adds a listener for the given event that will trigger
// at most <counter> times.
func (e *Manager) OnMultiple(eventName string, callback func(...interface{}), counter uint) {
// Add a persistent eventListener (counter = 0)
err := e.addEventListener(eventName, callback, counter)
if err != nil {
e.log.Error(err.Error())
}
} }
// Emit broadcasts the given event to the subscribed listeners // Emit broadcasts the given event to the subscribed listeners
@@ -132,24 +108,20 @@ func (e *Manager) Start(renderer interfaces.Renderer) {
}) })
// Notify renderer // Notify renderer
err := e.renderer.NotifyEvent(event) e.renderer.NotifyEvent(event)
if err != nil {
e.log.Error(err.Error())
}
e.mu.Lock() // Notify Go listeners
var listenersToRemove []*eventListener
// Iterate listeners // Iterate listeners
for _, listener := range e.listeners[event.Name] { for _, listener := range e.listeners[event.Name] {
if !listener.expired { // Call listener, perhaps with data
// Call listener, perhaps with data if event.Data == nil {
if event.Data == nil { go listener.callback()
go listener.callback() } else {
} else { unpacked := event.Data.([]interface{})
unpacked := event.Data.([]interface{}) go listener.callback(unpacked...)
go listener.callback(unpacked...)
}
} }
// Update listen counter // Update listen counter
@@ -161,8 +133,15 @@ func (e *Manager) Start(renderer interfaces.Renderer) {
} }
} }
e.mu.Unlock() // Remove expired listeners in place
if len(listenersToRemove) > 0 {
listeners := e.listeners[event.Name][:0]
for _, listener := range listeners {
if !listener.expired {
listeners = append(listeners, listener)
}
}
}
case <-e.quitChannel: case <-e.quitChannel:
e.running = false e.running = false
} }

View File

@@ -6,9 +6,9 @@ type AppConfig interface {
GetHeight() int GetHeight() int
GetTitle() string GetTitle() string
GetResizable() bool GetResizable() bool
GetHTML() string GetDefaultHTML() string
GetDisableInspector() bool GetDisableInspector() bool
GetColour() string GetColour() string
GetCSS() string GetCSS() string
GetJS() string GetJS() string
} }

View File

@@ -6,8 +6,6 @@ import "github.com/wailsapp/wails/lib/messages"
type EventManager interface { type EventManager interface {
PushEvent(*messages.EventData) PushEvent(*messages.EventData)
Emit(eventName string, optionalData ...interface{}) Emit(eventName string, optionalData ...interface{})
OnMultiple(eventName string, callback func(...interface{}), counter uint)
Once(eventName string, callback func(...interface{}))
On(eventName string, callback func(...interface{})) On(eventName string, callback func(...interface{}))
Start(Renderer) Start(Renderer)
Shutdown() Shutdown()

File diff suppressed because one or more lines are too long

View File

@@ -58,7 +58,7 @@ func (w *WebView) Initialise(config interfaces.AppConfig, ipc interfaces.IPCMana
Height: config.GetHeight(), Height: config.GetHeight(),
Title: config.GetTitle(), Title: config.GetTitle(),
Resizable: config.GetResizable(), Resizable: config.GetResizable(),
URL: config.GetHTML(), URL: config.GetDefaultHTML(),
Debug: !config.GetDisableInspector(), Debug: !config.GetDisableInspector(),
ExternalInvokeCallback: func(_ wv.WebView, message string) { ExternalInvokeCallback: func(_ wv.WebView, message string) {
w.ipc.Dispatch(message, w.callback) w.ipc.Dispatch(message, w.callback)
@@ -256,9 +256,6 @@ func (w *WebView) SelectFile(title string, filter string) string {
wg.Done() wg.Done()
}) })
}() }()
defer w.focus() // Ensure the main window is put back into focus afterwards
wg.Wait() wg.Wait()
return result return result
} }
@@ -277,9 +274,6 @@ func (w *WebView) SelectDirectory() string {
wg.Done() wg.Done()
}) })
}() }()
defer w.focus() // Ensure the main window is put back into focus afterwards
wg.Wait() wg.Wait()
return result return result
} }
@@ -298,20 +292,10 @@ func (w *WebView) SelectSaveFile(title string, filter string) string {
wg.Done() wg.Done()
}) })
}() }()
defer w.focus() // Ensure the main window is put back into focus afterwards
wg.Wait() wg.Wait()
return result return result
} }
// focus puts the main window into focus
func (w *WebView) focus() {
w.window.Dispatch(func() {
w.window.Focus()
})
}
// callback sends a callback to the frontend // callback sends a callback to the frontend
func (w *WebView) callback(data string) error { func (w *WebView) callback(data string) error {
callbackCMD := fmt.Sprintf("window.wails._.Callback('%s');", data) callbackCMD := fmt.Sprintf("window.wails._.Callback('%s');", data)

View File

@@ -65,10 +65,6 @@ static inline void CgoWebViewSetTitle(void *w, char *title) {
webview_set_title((struct webview *)w, title); webview_set_title((struct webview *)w, title);
} }
static inline void CgoWebViewFocus(void *w) {
webview_focus((struct webview *)w);
}
static inline void CgoWebViewSetFullscreen(void *w, int fullscreen) { static inline void CgoWebViewSetFullscreen(void *w, int fullscreen) {
webview_set_fullscreen((struct webview *)w, fullscreen); webview_set_fullscreen((struct webview *)w, fullscreen);
} }
@@ -174,10 +170,6 @@ type WebView interface {
// SetTitle() changes window title. This method must be called from the main // SetTitle() changes window title. This method must be called from the main
// thread only. See Dispatch() for more details. // thread only. See Dispatch() for more details.
SetTitle(title string) SetTitle(title string)
// Focus() puts the main window into focus
Focus()
// SetFullscreen() controls window full-screen mode. This method must be // SetFullscreen() controls window full-screen mode. This method must be
// called from the main thread only. See Dispatch() for more details. // called from the main thread only. See Dispatch() for more details.
SetFullscreen(fullscreen bool) SetFullscreen(fullscreen bool)
@@ -315,10 +307,6 @@ func (w *webview) SetColor(r, g, b, a uint8) {
C.CgoWebViewSetColor(w.w, C.uint8_t(r), C.uint8_t(g), C.uint8_t(b), C.uint8_t(a)) C.CgoWebViewSetColor(w.w, C.uint8_t(r), C.uint8_t(g), C.uint8_t(b), C.uint8_t(a))
} }
func (w *webview) Focus() {
C.CgoWebViewFocus(w.w)
}
func (w *webview) SetFullscreen(fullscreen bool) { func (w *webview) SetFullscreen(fullscreen bool) {
C.CgoWebViewSetFullscreen(w.w, C.int(boolToInt(fullscreen))) C.CgoWebViewSetFullscreen(w.w, C.int(boolToInt(fullscreen)))
} }
@@ -365,9 +353,7 @@ func _webviewDispatchGoCallback(index unsafe.Pointer) {
f = fns[uintptr(index)] f = fns[uintptr(index)]
delete(fns, uintptr(index)) delete(fns, uintptr(index))
m.Unlock() m.Unlock()
if f != nil { f()
f()
}
} }
//export _webviewExternalInvokeCallback //export _webviewExternalInvokeCallback
@@ -383,7 +369,5 @@ func _webviewExternalInvokeCallback(w unsafe.Pointer, data unsafe.Pointer) {
} }
} }
m.Unlock() m.Unlock()
if cb != nil { cb(wv, C.GoString((*C.char)(data)))
cb(wv, C.GoString((*C.char)(data)))
}
} }

View File

@@ -168,7 +168,6 @@ struct webview_priv
WEBVIEW_API int webview_eval(struct webview *w, const char *js); WEBVIEW_API int webview_eval(struct webview *w, const char *js);
WEBVIEW_API int webview_inject_css(struct webview *w, const char *css); WEBVIEW_API int webview_inject_css(struct webview *w, const char *css);
WEBVIEW_API void webview_set_title(struct webview *w, const char *title); WEBVIEW_API void webview_set_title(struct webview *w, const char *title);
WEBVIEW_API void webview_focus(struct webview *w);
WEBVIEW_API void webview_set_fullscreen(struct webview *w, int fullscreen); WEBVIEW_API void webview_set_fullscreen(struct webview *w, int fullscreen);
WEBVIEW_API void webview_set_color(struct webview *w, uint8_t r, uint8_t g, WEBVIEW_API void webview_set_color(struct webview *w, uint8_t r, uint8_t g,
uint8_t b, uint8_t a); uint8_t b, uint8_t a);
@@ -365,7 +364,6 @@ struct webview_priv
webkit_web_view_get_settings(WEBKIT_WEB_VIEW(w->priv.webview)); webkit_web_view_get_settings(WEBKIT_WEB_VIEW(w->priv.webview));
webkit_settings_set_enable_write_console_messages_to_stdout(settings, true); webkit_settings_set_enable_write_console_messages_to_stdout(settings, true);
webkit_settings_set_enable_developer_extras(settings, true); webkit_settings_set_enable_developer_extras(settings, true);
webkit_settings_set_hardware_acceleration_policy(settings, WEBKIT_HARDWARE_ACCELERATION_POLICY_ALWAYS);
} }
else else
{ {
@@ -397,11 +395,6 @@ struct webview_priv
gtk_window_set_title(GTK_WINDOW(w->priv.window), title); gtk_window_set_title(GTK_WINDOW(w->priv.window), title);
} }
WEBVIEW_API void webview_focus(struct webview *w)
{
gtk_window_present(GTK_WINDOW(w->priv.window));
}
WEBVIEW_API void webview_set_fullscreen(struct webview *w, int fullscreen) WEBVIEW_API void webview_set_fullscreen(struct webview *w, int fullscreen)
{ {
if (fullscreen) if (fullscreen)
@@ -1647,11 +1640,6 @@ struct webview_priv
#endif #endif
} }
WEBVIEW_API void webview_focus(struct webview *w)
{
SetFocus(w->priv.hwnd);
}
WEBVIEW_API void webview_set_fullscreen(struct webview *w, int fullscreen) WEBVIEW_API void webview_set_fullscreen(struct webview *w, int fullscreen)
{ {
if (w->priv.is_fullscreen == !!fullscreen) if (w->priv.is_fullscreen == !!fullscreen)
@@ -2219,11 +2207,6 @@ struct webview_priv
[w->priv.window setTitle:nsTitle]; [w->priv.window setTitle:nsTitle];
} }
WEBVIEW_API void webview_focus(struct webview *w)
{
[w->priv.window makeKeyWindow];
}
WEBVIEW_API void webview_set_fullscreen(struct webview *w, int fullscreen) WEBVIEW_API void webview_set_fullscreen(struct webview *w, int fullscreen)
{ {
int b = ((([w->priv.window styleMask] & NSWindowStyleMaskFullScreen) == int b = ((([w->priv.window styleMask] & NSWindowStyleMaskFullScreen) ==

BIN
pace.jpeg

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

View File

@@ -0,0 +1,18 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
</head>
<body>
<div id="app"></div>
<script type="text/javascript">function AddScript(js, callbackID) {
var script = document.createElement('script');
script.text = js;
document.body.appendChild(script);
}</script>
</body>
</html>

View File

@@ -19,16 +19,6 @@ func (r *Events) On(eventName string, callback func(optionalData ...interface{})
r.eventManager.On(eventName, callback) r.eventManager.On(eventName, callback)
} }
// Once pass through
func (r *Events) Once(eventName string, callback func(optionalData ...interface{})) {
r.eventManager.Once(eventName, callback)
}
// OnMultiple pass through
func (r *Events) OnMultiple(eventName string, callback func(optionalData ...interface{}), counter uint) {
r.eventManager.OnMultiple(eventName, callback, counter)
}
// Emit pass through // Emit pass through
func (r *Events) Emit(eventName string, optionalData ...interface{}) { func (r *Events) Emit(eventName string, optionalData ...interface{}) {
r.eventManager.Emit(eventName, optionalData...) r.eventManager.Emit(eventName, optionalData...)

View File

@@ -3959,9 +3959,9 @@
"dev": true "dev": true
}, },
"ini": { "ini": {
"version": "1.3.8", "version": "1.3.5",
"resolved": "https://registry.npmjs.org/ini/-/ini-1.3.8.tgz", "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz",
"integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==", "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==",
"dev": true "dev": true
}, },
"interpret": { "interpret": {

View File

@@ -1,6 +1,6 @@
{ {
"name": "@wailsapp/runtime", "name": "@wailsapp/runtime",
"version": "1.1.1", "version": "1.1.0",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {
@@ -130,9 +130,9 @@
"dev": true "dev": true
}, },
"ini": { "ini": {
"version": "1.3.8", "version": "1.3.5",
"resolved": "https://registry.npmjs.org/ini/-/ini-1.3.8.tgz", "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz",
"integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==", "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==",
"dev": true "dev": true
}, },
"invert-kv": { "invert-kv": {

View File

@@ -1,7 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
echo "**** Checking if Wails passes unit tests ****" echo "**** Checking if Wails passes unit tests ****"
if ! go test ./lib/... ./runtime/... ./cmd/... if ! go test ./...
then then
echo "" echo ""
echo "ERROR: Unit tests failed!" echo "ERROR: Unit tests failed!"