mirror of
https://github.com/taigrr/wails.git
synced 2026-04-16 19:55:05 -07:00
Compare commits
21 Commits
v0.16.0
...
135-Add-De
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
105073e412 | ||
|
|
9d1f1fff47 | ||
|
|
08050ec35e | ||
|
|
bd9751d888 | ||
|
|
7d171b0907 | ||
|
|
5b8f311465 | ||
|
|
801465ac51 | ||
|
|
a84e2ae9b3 | ||
|
|
9496d1d47f | ||
|
|
36e575e0a2 | ||
|
|
70ccb8942b | ||
|
|
d3cd3d43bd | ||
|
|
9116f0d06c | ||
|
|
2c91e26add | ||
|
|
f1647443dc | ||
|
|
b6b6ce2d4a | ||
|
|
abcc869537 | ||
|
|
3e02e1676a | ||
|
|
5c8a4de446 | ||
|
|
7cabef946e | ||
|
|
f2519e5af2 |
@@ -10,6 +10,7 @@
|
|||||||
<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://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>
|
<a href="https://houndci.com"><img src="https://img.shields.io/badge/Reviewed_by-Hound-8E64B0.svg"/></a>
|
||||||
<a href="https://github.com/avelino/awesome-go" rel="nofollow"><img src="https://cdn.rawgit.com/sindresorhus/awesome/d7305f38d29fed78fa85652e3a63e154dd8e8829/media/badge.svg" alt="Awesome"></a>
|
<a href="https://github.com/avelino/awesome-go" rel="nofollow"><img src="https://cdn.rawgit.com/sindresorhus/awesome/d7305f38d29fed78fa85652e3a63e154dd8e8829/media/badge.svg" alt="Awesome"></a>
|
||||||
|
<a href="https://dashboard.guardrails.io/default/gh/wailsapp/wails"><img src="https://badges.guardrails.io/wailsapp/wails.svg?token=53657bc22ec360d7673c894fdd70568e918ec581d10d84427ed4de5fe1eeff1a"></a>
|
||||||
</p>
|
</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!
|
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!
|
||||||
@@ -45,7 +46,7 @@ Make sure you have the xcode command line tools installed. This can be done by r
|
|||||||
|
|
||||||
### Linux
|
### Linux
|
||||||
|
|
||||||
#### Ubuntu 18.04
|
#### Ubuntu 18.04, Debian 9
|
||||||
|
|
||||||
`sudo apt install pkg-config build-essential libgtk-3-dev libwebkit2gtk-4.0-dev`
|
`sudo apt install pkg-config build-essential libgtk-3-dev libwebkit2gtk-4.0-dev`
|
||||||
|
|
||||||
|
|||||||
65
binding_internal.go
Normal file
65
binding_internal.go
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
package wails
|
||||||
|
|
||||||
|
import "strings"
|
||||||
|
import "fmt"
|
||||||
|
|
||||||
|
type internalMethods struct{
|
||||||
|
log *CustomLogger
|
||||||
|
browser *RuntimeBrowser
|
||||||
|
}
|
||||||
|
|
||||||
|
func newInternalMethods() *internalMethods {
|
||||||
|
return &internalMethods{
|
||||||
|
log: newCustomLogger("InternalCall"),
|
||||||
|
browser: newRuntimeBrowser(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i *internalMethods) processCall(callData *callData) (interface{}, error) {
|
||||||
|
if !strings.HasPrefix(callData.BindingName, ".wails.") {
|
||||||
|
return nil, fmt.Errorf("Invalid call signature '%s'", callData.BindingName)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Strip prefix
|
||||||
|
var splitCall = strings.Split(callData.BindingName,".")[2:]
|
||||||
|
if len(splitCall) != 2 {
|
||||||
|
return nil, fmt.Errorf("Invalid call signature '%s'", callData.BindingName)
|
||||||
|
}
|
||||||
|
|
||||||
|
group := splitCall[0]
|
||||||
|
switch group {
|
||||||
|
case "Browser":
|
||||||
|
return i.processBrowserCommand(splitCall[1], callData.Data)
|
||||||
|
default:
|
||||||
|
return nil, fmt.Errorf("Unknown internal command group '%s'", group)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i *internalMethods) processBrowserCommand(command string, data interface{}) (interface{}, error) {
|
||||||
|
switch command {
|
||||||
|
case "OpenURL":
|
||||||
|
url := data.(string)
|
||||||
|
// Strip string quotes. Credit: https://stackoverflow.com/a/44222648
|
||||||
|
if url[0] == '"' {
|
||||||
|
url = url[1:]
|
||||||
|
}
|
||||||
|
if i := len(url)-1; url[i] == '"' {
|
||||||
|
url = url[:i]
|
||||||
|
}
|
||||||
|
i.log.Debugf("Calling Browser.OpenURL with '%s'", url)
|
||||||
|
return nil, i.browser.OpenURL(url)
|
||||||
|
case "OpenFile":
|
||||||
|
filename := data.(string)
|
||||||
|
// Strip string quotes. Credit: https://stackoverflow.com/a/44222648
|
||||||
|
if filename[0] == '"' {
|
||||||
|
filename = filename[1:]
|
||||||
|
}
|
||||||
|
if i := len(filename)-1; filename[i] == '"' {
|
||||||
|
filename = filename[:i]
|
||||||
|
}
|
||||||
|
i.log.Debugf("Calling Browser.OpenFile with '%s'", filename)
|
||||||
|
return nil, i.browser.OpenFile(filename)
|
||||||
|
default:
|
||||||
|
return nil, fmt.Errorf("Unknown Browser command '%s'", command)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -17,6 +17,7 @@ binding:
|
|||||||
type bindingManager struct {
|
type bindingManager struct {
|
||||||
methods map[string]*boundMethod
|
methods map[string]*boundMethod
|
||||||
functions map[string]*boundFunction
|
functions map[string]*boundFunction
|
||||||
|
internalMethods *internalMethods
|
||||||
initMethods []*boundMethod
|
initMethods []*boundMethod
|
||||||
log *CustomLogger
|
log *CustomLogger
|
||||||
renderer Renderer
|
renderer Renderer
|
||||||
@@ -27,9 +28,10 @@ type bindingManager struct {
|
|||||||
|
|
||||||
func newBindingManager() *bindingManager {
|
func newBindingManager() *bindingManager {
|
||||||
result := &bindingManager{
|
result := &bindingManager{
|
||||||
methods: make(map[string]*boundMethod),
|
methods: make(map[string]*boundMethod),
|
||||||
functions: make(map[string]*boundFunction),
|
functions: make(map[string]*boundFunction),
|
||||||
log: newCustomLogger("Bind"),
|
log: newCustomLogger("Bind"),
|
||||||
|
internalMethods: newInternalMethods(),
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
@@ -163,6 +165,11 @@ func (b *bindingManager) bind(object interface{}) {
|
|||||||
b.objectsToBind = append(b.objectsToBind, object)
|
b.objectsToBind = append(b.objectsToBind, object)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (b *bindingManager) processInternalCall(callData *callData) (interface{}, error) {
|
||||||
|
// Strip prefix
|
||||||
|
return b.internalMethods.processCall(callData)
|
||||||
|
}
|
||||||
|
|
||||||
func (b *bindingManager) processFunctionCall(callData *callData) (interface{}, error) {
|
func (b *bindingManager) processFunctionCall(callData *callData) (interface{}, error) {
|
||||||
// Return values
|
// Return values
|
||||||
var result []reflect.Value
|
var result []reflect.Value
|
||||||
@@ -254,6 +261,8 @@ func (b *bindingManager) processCall(callData *callData) (result interface{}, er
|
|||||||
result, err = b.processFunctionCall(callData)
|
result, err = b.processFunctionCall(callData)
|
||||||
case 2:
|
case 2:
|
||||||
result, err = b.processMethodCall(callData)
|
result, err = b.processMethodCall(callData)
|
||||||
|
case 3:
|
||||||
|
result, err = b.processInternalCall(callData)
|
||||||
default:
|
default:
|
||||||
result = nil
|
result = nil
|
||||||
err = fmt.Errorf("Invalid binding name '%s'", callData.BindingName)
|
err = fmt.Errorf("Invalid binding name '%s'", callData.BindingName)
|
||||||
|
|||||||
10
cmd/cmd-mewn.go
Normal file
10
cmd/cmd-mewn.go
Normal file
File diff suppressed because one or more lines are too long
89
cmd/linux.go
89
cmd/linux.go
@@ -3,9 +3,12 @@ package cmd
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"regexp"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/pkg/browser"
|
||||||
)
|
)
|
||||||
|
|
||||||
// LinuxDistribution is of type int
|
// LinuxDistribution is of type int
|
||||||
@@ -20,6 +23,8 @@ const (
|
|||||||
Arch
|
Arch
|
||||||
// RedHat linux distribution
|
// RedHat linux distribution
|
||||||
RedHat
|
RedHat
|
||||||
|
// Debian distribution
|
||||||
|
Debian
|
||||||
)
|
)
|
||||||
|
|
||||||
// DistroInfo contains all the information relating to a linux distribution
|
// DistroInfo contains all the information relating to a linux distribution
|
||||||
@@ -29,6 +34,7 @@ type DistroInfo struct {
|
|||||||
Release string
|
Release string
|
||||||
Codename string
|
Codename string
|
||||||
DistributorID string
|
DistributorID string
|
||||||
|
DiscoveredBy string
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetLinuxDistroInfo returns information about the running linux distribution
|
// GetLinuxDistroInfo returns information about the running linux distribution
|
||||||
@@ -43,7 +49,7 @@ func GetLinuxDistroInfo() *DistroInfo {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
result.DiscoveredBy = "lsb"
|
||||||
for _, line := range strings.Split(stdout, "\n") {
|
for _, line := range strings.Split(stdout, "\n") {
|
||||||
if strings.Contains(line, ":") {
|
if strings.Contains(line, ":") {
|
||||||
// Iterate lines a
|
// Iterate lines a
|
||||||
@@ -58,6 +64,8 @@ func GetLinuxDistroInfo() *DistroInfo {
|
|||||||
result.Distribution = Ubuntu
|
result.Distribution = Ubuntu
|
||||||
case "Arch", "ManjaroLinux":
|
case "Arch", "ManjaroLinux":
|
||||||
result.Distribution = Arch
|
result.Distribution = Arch
|
||||||
|
case "Debian":
|
||||||
|
result.Distribution = Debian
|
||||||
}
|
}
|
||||||
case "Description":
|
case "Description":
|
||||||
result.Description = value
|
result.Description = value
|
||||||
@@ -65,21 +73,37 @@ func GetLinuxDistroInfo() *DistroInfo {
|
|||||||
result.Release = value
|
result.Release = value
|
||||||
case "Codename":
|
case "Codename":
|
||||||
result.Codename = value
|
result.Codename = value
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// check if /etc/os-release exists
|
// check if /etc/os-release exists
|
||||||
} else if _, err := os.Stat("/etc/os-release"); !os.IsNotExist(err) {
|
} else if _, err := os.Stat("/etc/os-release"); !os.IsNotExist(err) {
|
||||||
|
// Default value
|
||||||
|
osName := "Unknown"
|
||||||
|
version := ""
|
||||||
// read /etc/os-release
|
// read /etc/os-release
|
||||||
osRelease, _ := ioutil.ReadFile("/etc/os-release")
|
osRelease, _ := ioutil.ReadFile("/etc/os-release")
|
||||||
// compile a regex to find NAME=distro
|
// Split into lines
|
||||||
re := regexp.MustCompile(`^NAME=(.*)\n`)
|
lines := strings.Split(string(osRelease), "\n")
|
||||||
// extract the distro name
|
// Iterate lines
|
||||||
osName := string(re.FindSubmatch(osRelease)[1])
|
for _, line := range lines {
|
||||||
// strip quotations
|
// Split each line by the equals char
|
||||||
osName = strings.Trim(osName, "\"")
|
splitLine := strings.SplitN(line, "=", 2)
|
||||||
|
// Check we have
|
||||||
|
if len(splitLine) != 2 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
switch splitLine[0] {
|
||||||
|
case "NAME":
|
||||||
|
osName = strings.Trim(splitLine[1], "\"")
|
||||||
|
case "VERSION_ID":
|
||||||
|
version = strings.Trim(splitLine[1], "\"")
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
// Check distro name against list of distros
|
// Check distro name against list of distros
|
||||||
|
result.Release = version
|
||||||
|
result.DiscoveredBy = "os-release"
|
||||||
switch osName {
|
switch osName {
|
||||||
case "Fedora":
|
case "Fedora":
|
||||||
result.Distribution = RedHat
|
result.Distribution = RedHat
|
||||||
@@ -87,6 +111,11 @@ func GetLinuxDistroInfo() *DistroInfo {
|
|||||||
result.Distribution = RedHat
|
result.Distribution = RedHat
|
||||||
case "Arch Linux":
|
case "Arch Linux":
|
||||||
result.Distribution = Arch
|
result.Distribution = Arch
|
||||||
|
case "Debian GNU/Linux":
|
||||||
|
result.Distribution = Debian
|
||||||
|
default:
|
||||||
|
result.Distribution = Unknown
|
||||||
|
result.DistributorID = osName
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
@@ -124,3 +153,45 @@ func RpmInstalled(packageName string) (bool, error) {
|
|||||||
_, _, exitCode, _ := rpm.Run("--query", packageName)
|
_, _, exitCode, _ := rpm.Run("--query", packageName)
|
||||||
return exitCode == 0, nil
|
return exitCode == 0, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RequestSupportForDistribution promts the user to submit a request to support their
|
||||||
|
// currently unsupported distribution
|
||||||
|
func RequestSupportForDistribution(distroInfo *DistroInfo, libraryName string) error {
|
||||||
|
var logger = NewLogger()
|
||||||
|
defaultError := fmt.Errorf("unable to check libraries on distribution '%s'. Please ensure that the '%s' equivalent is installed", distroInfo.DistributorID, libraryName)
|
||||||
|
|
||||||
|
logger.Yellow("Distribution '%s' is not currently supported, but we would love to!", distroInfo.DistributorID)
|
||||||
|
q := fmt.Sprintf("Would you like to submit a request to support distribution '%s'?", distroInfo.DistributorID)
|
||||||
|
result := Prompt(q, "yes")
|
||||||
|
if strings.ToLower(result) != "yes" {
|
||||||
|
return defaultError
|
||||||
|
}
|
||||||
|
|
||||||
|
title := fmt.Sprintf("Support Distribution '%s'", distroInfo.DistributorID)
|
||||||
|
|
||||||
|
var str strings.Builder
|
||||||
|
|
||||||
|
gomodule, exists := os.LookupEnv("GO111MODULE")
|
||||||
|
if !exists {
|
||||||
|
gomodule = "(Not Set)"
|
||||||
|
}
|
||||||
|
|
||||||
|
str.WriteString("\n| Name | Value |\n| ----- | ----- |\n")
|
||||||
|
str.WriteString(fmt.Sprintf("| Wails Version | %s |\n", Version))
|
||||||
|
str.WriteString(fmt.Sprintf("| Go Version | %s |\n", runtime.Version()))
|
||||||
|
str.WriteString(fmt.Sprintf("| Platform | %s |\n", runtime.GOOS))
|
||||||
|
str.WriteString(fmt.Sprintf("| Arch | %s |\n", runtime.GOARCH))
|
||||||
|
str.WriteString(fmt.Sprintf("| GO111MODULE | %s |\n", gomodule))
|
||||||
|
str.WriteString(fmt.Sprintf("| Distribution ID | %s |\n", distroInfo.DistributorID))
|
||||||
|
str.WriteString(fmt.Sprintf("| Distribution Version | %s |\n", distroInfo.Release))
|
||||||
|
str.WriteString(fmt.Sprintf("| Discovered by | %s |\n", distroInfo.DiscoveredBy))
|
||||||
|
|
||||||
|
body := fmt.Sprintf("**Description**\nDistribution '%s' is curently unsupported.\n\n**Further Information**\n\n%s\n\n*Please add any extra information here, EG: libraries that are needed to make the distribution work, or commands to install them*", distroInfo.DistributorID, str.String())
|
||||||
|
fullURL := "https://github.com/wailsapp/wails/issues/new?"
|
||||||
|
params := "title=" + title + "&body=" + body
|
||||||
|
|
||||||
|
fmt.Println("Opening browser to file request.")
|
||||||
|
browser.OpenURL(fullURL + url.PathEscape(params))
|
||||||
|
return nil
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
@@ -49,11 +49,10 @@ func getRequiredProgramsLinux() *Prerequisites {
|
|||||||
result := &Prerequisites{}
|
result := &Prerequisites{}
|
||||||
distroInfo := GetLinuxDistroInfo()
|
distroInfo := GetLinuxDistroInfo()
|
||||||
switch distroInfo.Distribution {
|
switch distroInfo.Distribution {
|
||||||
case Ubuntu:
|
case Ubuntu, Debian:
|
||||||
result.Add(newPrerequisite("gcc", "Please install with `sudo apt install build-essentials` and try again"))
|
result.Add(newPrerequisite("gcc", "Please install with `sudo apt install build-essentials` and try again"))
|
||||||
result.Add(newPrerequisite("pkg-config", "Please install with `sudo apt install pkg-config` and try again"))
|
result.Add(newPrerequisite("pkg-config", "Please install with `sudo apt install pkg-config` and try again"))
|
||||||
result.Add(newPrerequisite("npm", "Please install with `sudo snap install node --channel=12/stable --classic` and try again"))
|
result.Add(newPrerequisite("npm", "Please install with `sudo snap install node --channel=12/stable --classic` and try again"))
|
||||||
|
|
||||||
default:
|
default:
|
||||||
result.Add(newPrerequisite("gcc", "Please install with your system package manager and try again"))
|
result.Add(newPrerequisite("gcc", "Please install with your system package manager and try again"))
|
||||||
result.Add(newPrerequisite("pkg-config", "Please install with your system package manager and try again"))
|
result.Add(newPrerequisite("pkg-config", "Please install with your system package manager and try again"))
|
||||||
|
|||||||
@@ -272,7 +272,7 @@ func CheckDependencies(logger *Logger) (bool, error) {
|
|||||||
distroInfo := GetLinuxDistroInfo()
|
distroInfo := GetLinuxDistroInfo()
|
||||||
for _, library := range *requiredLibraries {
|
for _, library := range *requiredLibraries {
|
||||||
switch distroInfo.Distribution {
|
switch distroInfo.Distribution {
|
||||||
case Ubuntu:
|
case Ubuntu, Debian:
|
||||||
installed, err := DpkgInstalled(library.Name)
|
installed, err := DpkgInstalled(library.Name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
@@ -295,7 +295,6 @@ func CheckDependencies(logger *Logger) (bool, error) {
|
|||||||
logger.Green("Library '%s' installed.", library.Name)
|
logger.Green("Library '%s' installed.", library.Name)
|
||||||
}
|
}
|
||||||
case RedHat:
|
case RedHat:
|
||||||
|
|
||||||
installed, err := RpmInstalled(library.Name)
|
installed, err := RpmInstalled(library.Name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
@@ -307,7 +306,7 @@ func CheckDependencies(logger *Logger) (bool, error) {
|
|||||||
logger.Green("Library '%s' installed.", library.Name)
|
logger.Green("Library '%s' installed.", library.Name)
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
return false, fmt.Errorf("unable to check libraries on distribution '%s'. Please ensure that the '%s' equivalent is installed", distroInfo.DistributorID, library.Name)
|
return false, RequestSupportForDistribution(distroInfo, library.Name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,22 +26,8 @@ class HelloWorld extends React.Component {
|
|||||||
this.setState({ showModal: false });
|
this.setState({ showModal: false });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
startAsync() {
|
|
||||||
this.setState({
|
|
||||||
loading: true
|
|
||||||
});
|
|
||||||
|
|
||||||
window.backend.basic().then(result =>
|
|
||||||
this.setState({
|
|
||||||
loading: false,
|
|
||||||
result
|
|
||||||
})
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { loading, result } = this.state;
|
const { result } = this.state;
|
||||||
return (
|
return (
|
||||||
<div className="App">
|
<div className="App">
|
||||||
<button onClick={this.handleOpenModal} type="button">
|
<button onClick={this.handleOpenModal} type="button">
|
||||||
|
|||||||
@@ -9,9 +9,9 @@
|
|||||||
export default {
|
export default {
|
||||||
// The main function
|
// The main function
|
||||||
// Passes the main Wails object to the callback if given.
|
// Passes the main Wails object to the callback if given.
|
||||||
Start: function(callback) {
|
Start: function (callback) {
|
||||||
if (callback) {
|
if (callback) {
|
||||||
window.wails.events.on("wails:ready", callback);
|
window.wails.Events.On("wails:ready", callback);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -9,9 +9,9 @@
|
|||||||
export default {
|
export default {
|
||||||
// The main function
|
// The main function
|
||||||
// Passes the main Wails object to the callback if given.
|
// Passes the main Wails object to the callback if given.
|
||||||
Start: function(callback) {
|
Start: function (callback) {
|
||||||
if (callback) {
|
if (callback) {
|
||||||
window.wails.events.on("wails:ready", callback);
|
window.wails.Events.On("wails:ready", callback);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
// Version - Wails version
|
// Version - Wails version
|
||||||
const Version = "v0.16.0"
|
const Version = "v0.16.1-pre"
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ func checkLibraries() (errors bool, err error) {
|
|||||||
distroInfo := cmd.GetLinuxDistroInfo()
|
distroInfo := cmd.GetLinuxDistroInfo()
|
||||||
for _, library := range *requiredLibraries {
|
for _, library := range *requiredLibraries {
|
||||||
switch distroInfo.Distribution {
|
switch distroInfo.Distribution {
|
||||||
case cmd.Ubuntu:
|
case cmd.Ubuntu, cmd.Debian:
|
||||||
installed, err := cmd.DpkgInstalled(library.Name)
|
installed, err := cmd.DpkgInstalled(library.Name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
@@ -108,7 +108,7 @@ func checkLibraries() (errors bool, err error) {
|
|||||||
logger.Green("Library '%s' installed.", library.Name)
|
logger.Green("Library '%s' installed.", library.Name)
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
return false, fmt.Errorf("unable to check libraries on distribution '%s'. Please ensure that the '%s' equivalent is installed", distroInfo.DistributorID, library.Name)
|
return false, cmd.RequestSupportForDistribution(distroInfo, library.Name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ type Runtime struct {
|
|||||||
Log *RuntimeLog
|
Log *RuntimeLog
|
||||||
Dialog *RuntimeDialog
|
Dialog *RuntimeDialog
|
||||||
Window *RuntimeWindow
|
Window *RuntimeWindow
|
||||||
|
Browser *RuntimeBrowser
|
||||||
FileSystem *RuntimeFileSystem
|
FileSystem *RuntimeFileSystem
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -15,6 +16,7 @@ func newRuntime(eventManager *eventManager, renderer Renderer) *Runtime {
|
|||||||
Log: newRuntimeLog(),
|
Log: newRuntimeLog(),
|
||||||
Dialog: newRuntimeDialog(renderer),
|
Dialog: newRuntimeDialog(renderer),
|
||||||
Window: newRuntimeWindow(renderer),
|
Window: newRuntimeWindow(renderer),
|
||||||
|
Browser: newRuntimeBrowser(),
|
||||||
FileSystem: newRuntimeFileSystem(),
|
FileSystem: newRuntimeFileSystem(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
25
runtime_browser.go
Normal file
25
runtime_browser.go
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
package wails
|
||||||
|
|
||||||
|
import "github.com/pkg/browser"
|
||||||
|
|
||||||
|
// GlobalRuntimeBrowser is the global instance of the RuntimeBrowser object
|
||||||
|
// Why? Because we need to use it in both the runtime and from the frontend
|
||||||
|
var GlobalRuntimeBrowser = newRuntimeBrowser()
|
||||||
|
|
||||||
|
// RuntimeBrowser exposes browser methods to the runtime
|
||||||
|
type RuntimeBrowser struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
func newRuntimeBrowser() *RuntimeBrowser {
|
||||||
|
return &RuntimeBrowser{}
|
||||||
|
}
|
||||||
|
|
||||||
|
// OpenURL opens the given url in the system's default browser
|
||||||
|
func (r *RuntimeBrowser) OpenURL(url string) error {
|
||||||
|
return browser.OpenURL(url)
|
||||||
|
}
|
||||||
|
|
||||||
|
// OpenFile opens the given file in the system's default browser
|
||||||
|
func (r *RuntimeBrowser) OpenFile(filePath string) error {
|
||||||
|
return browser.OpenFile(filePath)
|
||||||
|
}
|
||||||
File diff suppressed because one or more lines are too long
@@ -167,7 +167,7 @@ function startBridge() {
|
|||||||
|
|
||||||
// Now wails runtime is loaded, wails for the ready event
|
// Now wails runtime is loaded, wails for the ready event
|
||||||
// and callback to the main app
|
// and callback to the main app
|
||||||
window.wails.events.on("wails:loaded", function () {
|
window.wails.Events.On("wails:loaded", function () {
|
||||||
window.wailsbridge.log("Wails Ready");
|
window.wailsbridge.log("Wails Ready");
|
||||||
if (window.wailsbridge.callback) {
|
if (window.wailsbridge.callback) {
|
||||||
window.wailsbridge.log("Notifying application");
|
window.wailsbridge.log("Notifying application");
|
||||||
|
|||||||
@@ -9,9 +9,9 @@
|
|||||||
export default {
|
export default {
|
||||||
// The main function
|
// The main function
|
||||||
// Passes the main Wails object to the callback if given.
|
// Passes the main Wails object to the callback if given.
|
||||||
Start: function(callback) {
|
Start: function (callback) {
|
||||||
if (callback) {
|
if (callback) {
|
||||||
window.wails.events.on("wails:ready", callback);
|
window.wails.Events.On("wails:ready", callback);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,40 +0,0 @@
|
|||||||
(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")})()
|
|
||||||
2
wailsruntimeassets/default/wails.min.js
vendored
2
wailsruntimeassets/default/wails.min.js
vendored
@@ -1 +1 @@
|
|||||||
!function(){var e;function n(e){try{return new Function("var "+e),!0}catch(e){return!1}}window.wails=window.wails||{},window.backend={},e=window.crypto?function(){var e=new Uint32Array(1);return window.crypto.getRandomValues(e)[0]}:function(){return 9007199254740991*Math.random()};var a=window.backend;var t={};var i={};function r(e,n){n={type:"log",payload:{level:e,message:n}},external.invoke(JSON.stringify(n))}window.wails.events={emit:function(e){var n=JSON.stringify([].slice.apply(arguments).slice(1));message={type:"event",payload:{name:e,data:n}},external.invoke(JSON.stringify(message))},on:function(e,n){i[e]=i[e]||[],i[e].push(n)}},window.wails.log={debug:function(e){r("debug",e)},info:function(e){r("info",e)},warning:function(e){r("warning",e)},error:function(e){r("error",e)},fatal:function(e){r("fatal",e)}},window.wails._={newBinding:function(i){var r,l=i.split(".").splice(1),o=l.pop(),c=function(e){var t=a;for(var i in e){var r=e[i];if(!n(r))return[null,new Error(r+" is not a valid javascript identifier.")];t[r]||(t[r]={}),t=t[r]}return[t,null]}(l),s=c[0];if(null!=(r=c[1]))return r;s[o]=function(){var n=0;function a(){var a=[].slice.call(arguments);return function(n,a,i){return null!=i&&null!=i||(i=0),new Promise(function(r,l){var o;do{o=n+"-"+e()}while(t[o]);if(i>0)var c=setTimeout(function(){l(Error("Call to "+n+" timed out. Request ID: "+o))},i);t[o]={timeoutHandle:c,reject:l,resolve:r};try{var s=JSON.stringify(a);message={type:"call",callbackid:o,payload:{bindingName:n,data:s}};var u=JSON.stringify(message);external.invoke(u)}catch(e){console.error(e)}})}(i,a,n)}return a.setTimeout=function(e){n=e},a.getTimeout=function(){return n},a}()},callback:function(e){var n;e=decodeURIComponent(e.replace(/\s+/g,"").replace(/[0-9a-f]{2}/g,"%$&"));try{n=JSON.parse(e)}catch(n){return wails.log.debug("Invalid JSON passed to callback: "+n.message),void wails.log.debug("Message: "+e)}if(callbackID=n.callbackid,callbackData=t[callbackID],callbackData)return clearTimeout(callbackData.timeoutHandle),delete t[callbackID],n.error?callbackData.reject(n.error):callbackData.resolve(n.data);console.error("Callback '"+callbackID+"' not registed!!!")},notify:function(e,n){i[e]&&i[e].forEach(function(a){var t=[];if(n)try{t=JSON.parse(n)}catch(n){wails.log.error("Invalid JSON data sent to notify. Event name = "+e)}a.apply(null,t)})},sendLogMessage:r,callbacks:t,injectCSS:function(e){var n=document.createElement("style");n.setAttribute("type","text/css"),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e)),(document.head||document.getElementsByTagName("head")[0]).appendChild(n)},addScript:function(e,n){var a=document.createElement("script");a.text=e,document.body.appendChild(a),window.wails.events.emit(n)}},window.wails.events.emit("wails:loaded")}();
|
!function(){var e;function n(e){try{return new Function("var "+e),!0}catch(e){return!1}}window.wails=window.wails||{},window.backend={},e=window.crypto?function(){var e=new Uint32Array(1);return window.crypto.getRandomValues(e)[0]}:function(){return 9007199254740991*Math.random()};var t=window.backend;var a={};function r(n,t,r){return null!=r&&null!=r||(r=0),new Promise(function(i,o){var l;do{l=n+"-"+e()}while(a[l]);if(r>0)var c=setTimeout(function(){o(Error("Call to "+n+" timed out. Request ID: "+l))},r);a[l]={timeoutHandle:c,reject:o,resolve:i};try{var s=JSON.stringify(t);message={type:"call",callbackid:l,payload:{bindingName:n,data:s}};var u=JSON.stringify(message);external.invoke(u)}catch(e){console.error(e)}})}function i(e,n){return r(".wails."+e,n)}var o={};function l(e,n){o[e]=o[e]||[],o[e].push(n)}function c(e){var n=JSON.stringify([].slice.apply(arguments).slice(1));message={type:"event",payload:{name:e,data:n}},external.invoke(JSON.stringify(message))}function s(e,n){var t=n[0].toUpperCase()+n.substring(1);return function(a,r){return console.warn("Method events."+n+" has been deprecated. Please use Events."+t),e(a,r)}}function u(e,n){n={type:"log",payload:{level:e,message:n}},external.invoke(JSON.stringify(n))}function d(e,n){var t=n[0].toUpperCase()+n.substring(1);return function(a){return console.warn("Method Log."+n+" has been deprecated. Please use Log."+t),e(a)}}function w(e){u("debug",e)}function f(e){u("info",e)}function g(e){u("warning",e)}function p(e){u("error",e)}function v(e){u("fatal",e)}window.wails.events={emit:s(c,"emit"),on:s(l,"on")},window.wails.Events={Emit:c,On:l},window.wails.Browser={OpenURL:function(e){return i("Browser.OpenURL",e)},OpenFile:function(e){return i("Browser.OpenFile",e)}},window.wails.log={debug:d(w,"debug"),info:d(f,"info"),warning:d(g,"warning"),error:d(p,"error"),fatal:d(v,"fatal")},window.wails.Log={Debug:w,Info:f,Warning:g,Error:p,Fatal:v},window.wails._={newBinding:function(e){var a,i=e.split(".").splice(1),o=i.pop(),l=function(e){var a=t;for(var r in e){var i=e[r];if(!n(i))return[null,new Error(i+" is not a valid javascript identifier.")];a[i]||(a[i]={}),a=a[i]}return[a,null]}(i),c=l[0];if(null!=(a=l[1]))return a;c[o]=function(){var n=0;function t(){var t=[].slice.call(arguments);return r(e,t,n)}return t.setTimeout=function(e){n=e},t.getTimeout=function(){return n},t}()},callback:function(e){var n;e=decodeURIComponent(e.replace(/\s+/g,"").replace(/[0-9a-f]{2}/g,"%$&"));try{n=JSON.parse(e)}catch(n){return wails.Log.Debug("Invalid JSON passed to callback: "+n.message),void wails.Log.Debug("Message: "+e)}if(callbackID=n.callbackid,callbackData=a[callbackID],callbackData)return clearTimeout(callbackData.timeoutHandle),delete a[callbackID],n.error?callbackData.reject(n.error):callbackData.resolve(n.data);console.error("Callback '"+callbackID+"' not registed!!!")},notify:function(e,n){o[e]&&o[e].forEach(function(t){var a=[];if(n)try{a=JSON.parse(n)}catch(n){wails.Log.Error("Invalid JSON data sent to notify. Event name = "+e)}t.apply(null,a)})},sendLogMessage:u,callbacks:a,injectCSS:function(e){var n=document.createElement("style");n.setAttribute("type","text/css"),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e)),(document.head||document.getElementsByTagName("head")[0]).appendChild(n)},addScript:function(e,n){var t=document.createElement("script");t.text=e,document.body.appendChild(t),window.wails.Events.Emit(n)}},window.wails.Events.Emit("wails:loaded")}();
|
||||||
@@ -43,7 +43,7 @@
|
|||||||
var script = document.createElement("script");
|
var script = document.createElement("script");
|
||||||
script.text = js;
|
script.text = js;
|
||||||
document.body.appendChild(script);
|
document.body.appendChild(script);
|
||||||
window.wails.events.emit(callbackID);
|
window.wails.Events.Emit(callbackID);
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------- CSS ---------------
|
// -------------- CSS ---------------
|
||||||
@@ -200,6 +200,11 @@
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// systemCall is used to call wails methods from the frontend
|
||||||
|
function systemCall(method, data) {
|
||||||
|
return call(".wails." + method, data);
|
||||||
|
}
|
||||||
|
|
||||||
// Called by the backend to return data to a previously called
|
// Called by the backend to return data to a previously called
|
||||||
// binding invocation
|
// binding invocation
|
||||||
function callback(incomingMessage) {
|
function callback(incomingMessage) {
|
||||||
@@ -212,8 +217,8 @@
|
|||||||
try {
|
try {
|
||||||
message = JSON.parse(incomingMessage);
|
message = JSON.parse(incomingMessage);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
wails.log.debug("Invalid JSON passed to callback: " + e.message);
|
wails.Log.Debug("Invalid JSON passed to callback: " + e.message);
|
||||||
wails.log.debug("Message: " + incomingMessage);
|
wails.Log.Debug("Message: " + incomingMessage);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
callbackID = message.callbackid;
|
callbackID = message.callbackid;
|
||||||
@@ -254,7 +259,7 @@
|
|||||||
try {
|
try {
|
||||||
parsedData = JSON.parse(data);
|
parsedData = JSON.parse(data);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
wails.log.error("Invalid JSON data sent to notify. Event name = " + eventName)
|
wails.Log.Error("Invalid JSON data sent to notify. Event name = " + eventName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
element.apply(null, parsedData);
|
element.apply(null, parsedData);
|
||||||
@@ -279,12 +284,46 @@
|
|||||||
external.invoke(JSON.stringify(message));
|
external.invoke(JSON.stringify(message));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function deprecatedEventsFunction(fn, oldName) {
|
||||||
|
var newName = oldName[0].toUpperCase() + oldName.substring(1);
|
||||||
|
return function (eventName, eventData) {
|
||||||
|
console.warn('Method events.' + oldName + ' has been deprecated. Please use Events.' + newName);
|
||||||
|
return fn(eventName, eventData);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deprecated Events calls
|
||||||
|
window.wails.events = {
|
||||||
|
emit: deprecatedEventsFunction(emit, 'emit'),
|
||||||
|
on: deprecatedEventsFunction(on, 'on'),
|
||||||
|
};
|
||||||
|
|
||||||
// Events calls
|
// Events calls
|
||||||
window.wails.events = { emit: emit, on: on };
|
window.wails.Events = {
|
||||||
|
Emit: emit,
|
||||||
|
On: on
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/************************************************************/
|
/************************************************************/
|
||||||
|
|
||||||
|
/************************* Browser **************************/
|
||||||
|
|
||||||
|
|
||||||
|
function OpenURL(url) {
|
||||||
|
return systemCall("Browser.OpenURL", url);
|
||||||
|
}
|
||||||
|
|
||||||
|
function OpenFile(filename) {
|
||||||
|
return systemCall("Browser.OpenFile", filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
window.wails.Browser = {
|
||||||
|
OpenURL,
|
||||||
|
OpenFile,
|
||||||
|
};
|
||||||
|
|
||||||
/************************* Logging **************************/
|
/************************* Logging **************************/
|
||||||
|
|
||||||
// Sends a log message to the backend with the given
|
// Sends a log message to the backend with the given
|
||||||
@@ -302,6 +341,14 @@
|
|||||||
external.invoke(JSON.stringify(message));
|
external.invoke(JSON.stringify(message));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function deprecatedLogFunction(fn, oldName) {
|
||||||
|
var newName = oldName[0].toUpperCase() + oldName.substring(1);
|
||||||
|
return function (message) {
|
||||||
|
console.warn('Method Log.' + oldName + ' has been deprecated. Please use Log.' + newName);
|
||||||
|
return fn(message);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
function logDebug(message) {
|
function logDebug(message) {
|
||||||
sendLogMessage("debug", message);
|
sendLogMessage("debug", message);
|
||||||
}
|
}
|
||||||
@@ -319,13 +366,22 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
window.wails.log = {
|
window.wails.log = {
|
||||||
debug: logDebug,
|
debug: deprecatedLogFunction(logDebug, 'debug'),
|
||||||
info: logInfo,
|
info: deprecatedLogFunction(logInfo, 'info'),
|
||||||
warning: logWarning,
|
warning: deprecatedLogFunction(logWarning, 'warning'),
|
||||||
error: logError,
|
error: deprecatedLogFunction(logError, 'error'),
|
||||||
fatal: logFatal,
|
fatal: deprecatedLogFunction(logFatal, 'fatal'),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
window.wails.Log = {
|
||||||
|
Debug: logDebug,
|
||||||
|
Info: logInfo,
|
||||||
|
Warning: logWarning,
|
||||||
|
Error: logError,
|
||||||
|
Fatal: logFatal,
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/************************** Exports *************************/
|
/************************** Exports *************************/
|
||||||
|
|
||||||
window.wails._ = {
|
window.wails._ = {
|
||||||
@@ -336,12 +392,12 @@
|
|||||||
callbacks: callbacks,
|
callbacks: callbacks,
|
||||||
injectCSS: injectCSS,
|
injectCSS: injectCSS,
|
||||||
addScript: addScript,
|
addScript: addScript,
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
/************************************************************/
|
/************************************************************/
|
||||||
|
|
||||||
// Notify backend that the runtime has finished loading
|
// Notify backend that the runtime has finished loading
|
||||||
window.wails.events.emit("wails:loaded");
|
window.wails.Events.Emit("wails:loaded");
|
||||||
|
|
||||||
})()
|
})()
|
||||||
Reference in New Issue
Block a user