mirror of
https://github.com/taigrr/wails.git
synced 2026-04-10 00:51:30 -07:00
Compare commits
39 Commits
runtime-re
...
gitbash-fi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9164bf17c0 | ||
|
|
bb86d770a1 | ||
|
|
33daa8621e | ||
|
|
6c124fcff4 | ||
|
|
45833574b3 | ||
|
|
5cb00eb481 | ||
|
|
e2105331c1 | ||
|
|
21d2383e63 | ||
|
|
6c945a4eed | ||
|
|
6c8d34dfd3 | ||
|
|
b9b42c059e | ||
|
|
3f657b34cf | ||
|
|
6e81a36ada | ||
|
|
ddec01a429 | ||
|
|
21fdb3be7d | ||
|
|
c1a13ab6d0 | ||
|
|
750a02efc6 | ||
|
|
5e047debfc | ||
|
|
9cac336708 | ||
|
|
827c2b9a95 | ||
|
|
b36a3c4abb | ||
|
|
0bac205565 | ||
|
|
67a8ad8e12 | ||
|
|
9de2f66f50 | ||
|
|
9370030ff3 | ||
|
|
e38d6e7ef0 | ||
|
|
2f21fc3575 | ||
|
|
63e73f5f64 | ||
|
|
e1adc1ba49 | ||
|
|
030e911ea4 | ||
|
|
d2f114e44e | ||
|
|
700d3f84d3 | ||
|
|
1d49042013 | ||
|
|
8671b1e6cf | ||
|
|
517d6c44ec | ||
|
|
a082a659ea | ||
|
|
083153efc9 | ||
|
|
65a2560153 | ||
|
|
29535c10a3 |
@@ -1 +1 @@
|
|||||||
runtime/js/dist/wails.js
|
runtime/assets/default.html
|
||||||
@@ -1,7 +1,8 @@
|
|||||||
{
|
{
|
||||||
"env": {
|
"env": {
|
||||||
"browser": true,
|
"browser": true,
|
||||||
"es6": true
|
"es6": true,
|
||||||
|
"node": true,
|
||||||
},
|
},
|
||||||
"extends": "eslint:recommended",
|
"extends": "eslint:recommended",
|
||||||
"parserOptions": {
|
"parserOptions": {
|
||||||
|
|||||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -16,4 +16,4 @@ examples/**/example*
|
|||||||
cmd/wails/wails
|
cmd/wails/wails
|
||||||
.DS_Store
|
.DS_Store
|
||||||
tmp
|
tmp
|
||||||
node_modules
|
node_modules/
|
||||||
@@ -1,3 +1,9 @@
|
|||||||
|
|
||||||
|
2019-07-20 **v0.17.6-pre**
|
||||||
|
* Significant refactor of runtime
|
||||||
|
* Removed wailsbridge file - now a unified approach taken
|
||||||
|
* Fixed React on Windows - Thanks [Florian Didran](https://github.com/fdidron)!
|
||||||
|
|
||||||
2019-06-18 **v0.16.0**
|
2019-06-18 **v0.16.0**
|
||||||
* React template FTW! - Thanks [admin_3.exe](https://github.com/bh90210)!
|
* React template FTW! - Thanks [admin_3.exe](https://github.com/bh90210)!
|
||||||
* Updated contributors
|
* Updated contributors
|
||||||
|
|||||||
@@ -14,3 +14,5 @@ Wails is what it is because of the time and effort given by these great people.
|
|||||||
* [admin_3.exe](https://github.com/bh90210)
|
* [admin_3.exe](https://github.com/bh90210)
|
||||||
* [iceleo-com](https://github.com/iceleo-com)
|
* [iceleo-com](https://github.com/iceleo-com)
|
||||||
* [fallendusk](https://github.com/fallendusk)
|
* [fallendusk](https://github.com/fallendusk)
|
||||||
|
* [Florian Didran](https://github.com/fdidron)
|
||||||
|
* [Nikolai Zimmermann](https://github.com/Chronophylos)
|
||||||
|
|||||||
11
README.md
11
README.md
@@ -48,17 +48,19 @@ Make sure you have the xcode command line tools installed. This can be done by r
|
|||||||
|
|
||||||
#### Ubuntu 18.04, Debian 9, Zorin 15
|
#### Ubuntu 18.04, Debian 9, Zorin 15
|
||||||
|
|
||||||
`sudo apt install pkg-config build-essential libgtk-3-dev libwebkit2gtk-4.0-dev`
|
`sudo apt install libgtk-3-dev libwebkit2gtk-4.0-dev`
|
||||||
|
|
||||||
#### Arch Linux
|
#### Arch Linux
|
||||||
|
|
||||||
`sudo pacman -S webkit2gtk gtk3`
|
`sudo pacman -S webkit2gtk gtk3`
|
||||||
|
|
||||||
#### Red Hat Based Distros
|
#### Fedora 30
|
||||||
|
|
||||||
`sudo yum install webkit2gtk-devel gtk3-devel`
|
`sudo yum install webkit2gtk3-devel gtk3-devel`
|
||||||
|
|
||||||
Note: If you have successfully installed these dependencies on a different flavour of Linux, please consider submitting a PR.
|
#### Centos 7
|
||||||
|
|
||||||
|
`sudo yum install webkitgtk3-devel gtk3-devel`
|
||||||
|
|
||||||
### Windows
|
### Windows
|
||||||
|
|
||||||
@@ -121,4 +123,3 @@ This project was mainly coded to the following albums:
|
|||||||
* [Bloc Party - Silent Alarm](https://open.spotify.com/album/6SsIdN05HQg2GwYLfXuzLB)
|
* [Bloc Party - Silent Alarm](https://open.spotify.com/album/6SsIdN05HQg2GwYLfXuzLB)
|
||||||
* [Maxthor - Another World](https://open.spotify.com/album/3tklE2Fgw1hCIUstIwPBJF)
|
* [Maxthor - Another World](https://open.spotify.com/album/3tklE2Fgw1hCIUstIwPBJF)
|
||||||
* [Alun Tan Lan - Y Distawrwydd](https://open.spotify.com/album/0c32OywcLpdJCWWMC6vB8v)
|
* [Alun Tan Lan - Y Distawrwydd](https://open.spotify.com/album/0c32OywcLpdJCWWMC6vB8v)
|
||||||
|
|
||||||
|
|||||||
13
app.go
13
app.go
@@ -2,13 +2,12 @@ package wails
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/wailsapp/wails/cmd"
|
"github.com/wailsapp/wails/cmd"
|
||||||
"github.com/wailsapp/wails/lib/logger"
|
|
||||||
"github.com/wailsapp/wails/runtime/go/runtime"
|
|
||||||
"github.com/wailsapp/wails/lib/renderer"
|
|
||||||
"github.com/wailsapp/wails/lib/binding"
|
"github.com/wailsapp/wails/lib/binding"
|
||||||
"github.com/wailsapp/wails/lib/ipc"
|
|
||||||
"github.com/wailsapp/wails/lib/event"
|
"github.com/wailsapp/wails/lib/event"
|
||||||
"github.com/wailsapp/wails/lib/interfaces"
|
"github.com/wailsapp/wails/lib/interfaces"
|
||||||
|
"github.com/wailsapp/wails/lib/ipc"
|
||||||
|
"github.com/wailsapp/wails/lib/logger"
|
||||||
|
"github.com/wailsapp/wails/lib/renderer"
|
||||||
)
|
)
|
||||||
|
|
||||||
// -------------------------------- Compile time Flags ------------------------------
|
// -------------------------------- Compile time Flags ------------------------------
|
||||||
@@ -87,9 +86,9 @@ func (a *App) start() error {
|
|||||||
// Log starup
|
// Log starup
|
||||||
a.log.Info("Starting")
|
a.log.Info("Starting")
|
||||||
|
|
||||||
// Check if we are to run in headless mode
|
// Check if we are to run in bridge mode
|
||||||
if BuildMode == cmd.BuildModeBridge {
|
if BuildMode == cmd.BuildModeBridge {
|
||||||
a.renderer = &renderer.Headless{}
|
a.renderer = &renderer.Bridge{}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialise the renderer
|
// Initialise the renderer
|
||||||
@@ -105,7 +104,7 @@ func (a *App) start() error {
|
|||||||
a.ipc.Start(a.eventManager, a.bindingManager)
|
a.ipc.Start(a.eventManager, a.bindingManager)
|
||||||
|
|
||||||
// Create the runtime
|
// Create the runtime
|
||||||
a.runtime = runtime.NewRuntime(a.eventManager, a.renderer)
|
a.runtime = NewRuntime(a.eventManager, a.renderer)
|
||||||
|
|
||||||
// Start binding manager and give it our renderer
|
// Start binding manager and give it our renderer
|
||||||
err = a.bindingManager.Start(a.renderer, a.runtime)
|
err = a.bindingManager.Start(a.renderer, a.runtime)
|
||||||
|
|||||||
3
cli.go
3
cli.go
@@ -11,10 +11,9 @@ func (app *App) setupCli() *cmd.Cli {
|
|||||||
result := cmd.NewCli(app.config.Title, "Debug build")
|
result := cmd.NewCli(app.config.Title, "Debug build")
|
||||||
result.Version(cmd.Version)
|
result.Version(cmd.Version)
|
||||||
|
|
||||||
// Setup cli to handle loglevel and headless flags
|
// Setup cli to handle loglevel
|
||||||
result.
|
result.
|
||||||
StringFlag("loglevel", "Sets the log level [debug|info|error|panic|fatal]. Default debug", &app.logLevel).
|
StringFlag("loglevel", "Sets the log level [debug|info|error|panic|fatal]. Default debug", &app.logLevel).
|
||||||
// BoolFlag("headless", "Runs the app in headless mode", &app.headless).
|
|
||||||
Action(app.start)
|
Action(app.start)
|
||||||
|
|
||||||
// Banner
|
// Banner
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -9,7 +9,7 @@ import (
|
|||||||
"runtime"
|
"runtime"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
mewn "github.com/leaanthony/mewn"
|
"github.com/leaanthony/mewn"
|
||||||
"github.com/leaanthony/slicer"
|
"github.com/leaanthony/slicer"
|
||||||
"github.com/leaanthony/spinner"
|
"github.com/leaanthony/spinner"
|
||||||
)
|
)
|
||||||
@@ -249,8 +249,8 @@ func InstallFrontendDeps(projectDir string, projectOptions *ProjectOptions, forc
|
|||||||
ioutil.WriteFile(md5sumFile, []byte(packageJSONMD5), 0644)
|
ioutil.WriteFile(md5sumFile, []byte(packageJSONMD5), 0644)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Install the bridge library
|
// Install the runtime
|
||||||
err = InstallBridge(caller, projectDir, projectOptions)
|
err = InstallRuntime(caller, projectDir, projectOptions)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -263,22 +263,29 @@ func InstallFrontendDeps(projectDir string, projectOptions *ProjectOptions, forc
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// InstallBridge installs the relevant bridge javascript library
|
// InstallRuntime installs the correct runtime for the type of build
|
||||||
func InstallBridge(caller string, projectDir string, projectOptions *ProjectOptions) error {
|
func InstallRuntime(caller string, projectDir string, projectOptions *ProjectOptions) error {
|
||||||
bridgeFile := "wailsbridge.prod.js"
|
if caller == "build" {
|
||||||
if caller == "serve" {
|
return InstallProdRuntime(projectDir, projectOptions)
|
||||||
bridgeFile = "wailsbridge.js"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy bridge to project
|
return InstallBridge(projectDir, projectOptions)
|
||||||
bridgeAssets := mewn.Group("../runtime/bridge/")
|
}
|
||||||
bridgeFileData := bridgeAssets.Bytes(bridgeFile)
|
|
||||||
bridgeFileTarget := filepath.Join(projectDir, projectOptions.FrontEnd.Dir, projectOptions.FrontEnd.Bridge, "wailsbridge.js")
|
// InstallBridge installs the relevant bridge javascript library
|
||||||
err := fs.CreateFile(bridgeFileTarget, bridgeFileData)
|
func InstallBridge(projectDir string, projectOptions *ProjectOptions) error {
|
||||||
if err != nil {
|
bridgeFileData := mewn.String("../runtime/assets/bridge.js")
|
||||||
|
bridgeFileTarget := filepath.Join(projectDir, projectOptions.FrontEnd.Dir, "node_modules", "@wailsapp", "runtime", "main.js")
|
||||||
|
err := fs.CreateFile(bridgeFileTarget, []byte(bridgeFileData))
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
|
||||||
|
// InstallProdRuntime installs the production runtime
|
||||||
|
func InstallProdRuntime(projectDir string, projectOptions *ProjectOptions) error {
|
||||||
|
prodInit := mewn.String("../runtime/js/runtime/init.js")
|
||||||
|
bridgeFileTarget := filepath.Join(projectDir, projectOptions.FrontEnd.Dir, "node_modules", "@wailsapp", "runtime", "main.js")
|
||||||
|
err := fs.CreateFile(bridgeFileTarget, []byte(prodInit))
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// ServeProject attempts to serve up the current project so that it may be connected to
|
// ServeProject attempts to serve up the current project so that it may be connected to
|
||||||
|
|||||||
100
cmd/linux.go
100
cmd/linux.go
@@ -23,6 +23,10 @@ const (
|
|||||||
Arch
|
Arch
|
||||||
// RedHat linux distribution
|
// RedHat linux distribution
|
||||||
RedHat
|
RedHat
|
||||||
|
// CentOS linux distribution
|
||||||
|
CentOS
|
||||||
|
// Fedora linux distribution
|
||||||
|
Fedora
|
||||||
// Debian distribution
|
// Debian distribution
|
||||||
Debian
|
Debian
|
||||||
// Gentoo distribution
|
// Gentoo distribution
|
||||||
@@ -34,62 +38,22 @@ const (
|
|||||||
// DistroInfo contains all the information relating to a linux distribution
|
// DistroInfo contains all the information relating to a linux distribution
|
||||||
type DistroInfo struct {
|
type DistroInfo struct {
|
||||||
Distribution LinuxDistribution
|
Distribution LinuxDistribution
|
||||||
|
Name string
|
||||||
|
ID string
|
||||||
Description string
|
Description string
|
||||||
Release string
|
Release string
|
||||||
Codename string
|
|
||||||
DistributorID string
|
|
||||||
DiscoveredBy string
|
DiscoveredBy string
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetLinuxDistroInfo returns information about the running linux distribution
|
// GetLinuxDistroInfo returns information about the running linux distribution
|
||||||
func GetLinuxDistroInfo() *DistroInfo {
|
func GetLinuxDistroInfo() *DistroInfo {
|
||||||
result := &DistroInfo{Distribution: Unknown}
|
result := &DistroInfo{Distribution: Unknown}
|
||||||
program := NewProgramHelper()
|
|
||||||
// Does lsb_release exist?
|
|
||||||
|
|
||||||
lsbRelease := program.FindProgram("lsb_release")
|
_, err := os.Stat("/etc/os-release")
|
||||||
if lsbRelease != nil {
|
if !os.IsNotExist(err) {
|
||||||
stdout, _, _, err := lsbRelease.Run("-a")
|
|
||||||
if err != nil {
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
result.DiscoveredBy = "lsb"
|
|
||||||
for _, line := range strings.Split(stdout, "\n") {
|
|
||||||
if strings.Contains(line, ":") {
|
|
||||||
// Iterate lines a
|
|
||||||
details := strings.Split(line, ":")
|
|
||||||
key := strings.TrimSpace(details[0])
|
|
||||||
value := strings.TrimSpace(details[1])
|
|
||||||
switch key {
|
|
||||||
case "Distributor ID":
|
|
||||||
result.DistributorID = value
|
|
||||||
switch value {
|
|
||||||
case "Ubuntu":
|
|
||||||
result.Distribution = Ubuntu
|
|
||||||
case "Arch", "ManjaroLinux":
|
|
||||||
result.Distribution = Arch
|
|
||||||
case "Debian":
|
|
||||||
result.Distribution = Debian
|
|
||||||
case "Gentoo":
|
|
||||||
result.Distribution = Gentoo
|
|
||||||
case "Zorin":
|
|
||||||
result.Distribution = Zorin
|
|
||||||
case "Fedora":
|
|
||||||
result.Distribution = RedHat
|
|
||||||
}
|
|
||||||
case "Description":
|
|
||||||
result.Description = value
|
|
||||||
case "Release":
|
|
||||||
result.Release = value
|
|
||||||
case "Codename":
|
|
||||||
result.Codename = value
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// check if /etc/os-release exists
|
|
||||||
} else if _, err := os.Stat("/etc/os-release"); !os.IsNotExist(err) {
|
|
||||||
// Default value
|
// Default value
|
||||||
osName := "Unknown"
|
osID := "unknown"
|
||||||
|
osNAME := "Unknown"
|
||||||
version := ""
|
version := ""
|
||||||
// read /etc/os-release
|
// read /etc/os-release
|
||||||
osRelease, _ := ioutil.ReadFile("/etc/os-release")
|
osRelease, _ := ioutil.ReadFile("/etc/os-release")
|
||||||
@@ -104,8 +68,10 @@ func GetLinuxDistroInfo() *DistroInfo {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
switch splitLine[0] {
|
switch splitLine[0] {
|
||||||
|
case "ID":
|
||||||
|
osID = strings.Trim(splitLine[1], "\"")
|
||||||
case "NAME":
|
case "NAME":
|
||||||
osName = strings.Trim(splitLine[1], "\"")
|
osNAME = strings.Trim(splitLine[1], "\"")
|
||||||
case "VERSION_ID":
|
case "VERSION_ID":
|
||||||
version = strings.Trim(splitLine[1], "\"")
|
version = strings.Trim(splitLine[1], "\"")
|
||||||
}
|
}
|
||||||
@@ -113,22 +79,28 @@ func GetLinuxDistroInfo() *DistroInfo {
|
|||||||
}
|
}
|
||||||
// Check distro name against list of distros
|
// Check distro name against list of distros
|
||||||
result.Release = version
|
result.Release = version
|
||||||
result.DiscoveredBy = "os-release"
|
result.DiscoveredBy = "/etc/os-release"
|
||||||
switch osName {
|
switch osID {
|
||||||
case "Fedora":
|
case "fedora":
|
||||||
result.Distribution = RedHat
|
result.Distribution = Fedora
|
||||||
case "CentOS":
|
case "centos":
|
||||||
result.Distribution = RedHat
|
result.Distribution = CentOS
|
||||||
case "Arch Linux":
|
case "arch":
|
||||||
result.Distribution = Arch
|
result.Distribution = Arch
|
||||||
case "Debian GNU/Linux":
|
case "debian":
|
||||||
result.Distribution = Debian
|
result.Distribution = Debian
|
||||||
case "Gentoo/Linux":
|
case "ubuntu":
|
||||||
|
result.Distribution = Ubuntu
|
||||||
|
case "gentoo":
|
||||||
result.Distribution = Gentoo
|
result.Distribution = Gentoo
|
||||||
|
case "zorin":
|
||||||
|
result.Distribution = Zorin
|
||||||
default:
|
default:
|
||||||
result.Distribution = Unknown
|
result.Distribution = Unknown
|
||||||
result.DistributorID = osName
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
result.ID = osID
|
||||||
|
result.Name = osNAME
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
@@ -181,16 +153,16 @@ func RpmInstalled(packageName string) (bool, error) {
|
|||||||
// currently unsupported distribution
|
// currently unsupported distribution
|
||||||
func RequestSupportForDistribution(distroInfo *DistroInfo, libraryName string) error {
|
func RequestSupportForDistribution(distroInfo *DistroInfo, libraryName string) error {
|
||||||
var logger = NewLogger()
|
var logger = NewLogger()
|
||||||
defaultError := fmt.Errorf("unable to check libraries on distribution '%s'. Please ensure that the '%s' equivalent is installed", distroInfo.DistributorID, libraryName)
|
defaultError := fmt.Errorf("unable to check libraries on distribution '%s'. Please ensure that the '%s' equivalent is installed", distroInfo.Name, libraryName)
|
||||||
|
|
||||||
logger.Yellow("Distribution '%s' is not currently supported, but we would love to!", distroInfo.DistributorID)
|
logger.Yellow("Distribution '%s' is not currently supported, but we would love to!", distroInfo.Name)
|
||||||
q := fmt.Sprintf("Would you like to submit a request to support distribution '%s'?", distroInfo.DistributorID)
|
q := fmt.Sprintf("Would you like to submit a request to support distribution '%s'?", distroInfo.Name)
|
||||||
result := Prompt(q, "yes")
|
result := Prompt(q, "yes")
|
||||||
if strings.ToLower(result) != "yes" {
|
if strings.ToLower(result) != "yes" {
|
||||||
return defaultError
|
return defaultError
|
||||||
}
|
}
|
||||||
|
|
||||||
title := fmt.Sprintf("Support Distribution '%s'", distroInfo.DistributorID)
|
title := fmt.Sprintf("Support Distribution '%s'", distroInfo.Name)
|
||||||
|
|
||||||
var str strings.Builder
|
var str strings.Builder
|
||||||
|
|
||||||
@@ -205,16 +177,16 @@ func RequestSupportForDistribution(distroInfo *DistroInfo, libraryName string) e
|
|||||||
str.WriteString(fmt.Sprintf("| Platform | %s |\n", runtime.GOOS))
|
str.WriteString(fmt.Sprintf("| Platform | %s |\n", runtime.GOOS))
|
||||||
str.WriteString(fmt.Sprintf("| Arch | %s |\n", runtime.GOARCH))
|
str.WriteString(fmt.Sprintf("| Arch | %s |\n", runtime.GOARCH))
|
||||||
str.WriteString(fmt.Sprintf("| GO111MODULE | %s |\n", gomodule))
|
str.WriteString(fmt.Sprintf("| GO111MODULE | %s |\n", gomodule))
|
||||||
str.WriteString(fmt.Sprintf("| Distribution ID | %s |\n", distroInfo.DistributorID))
|
str.WriteString(fmt.Sprintf("| Distribution ID | %s |\n", distroInfo.ID))
|
||||||
|
str.WriteString(fmt.Sprintf("| Distribution Name | %s |\n", distroInfo.Name))
|
||||||
str.WriteString(fmt.Sprintf("| Distribution Version | %s |\n", distroInfo.Release))
|
str.WriteString(fmt.Sprintf("| Distribution Version | %s |\n", distroInfo.Release))
|
||||||
str.WriteString(fmt.Sprintf("| Discovered by | %s |\n", distroInfo.DiscoveredBy))
|
str.WriteString(fmt.Sprintf("| Discovered by | %s |\n", distroInfo.DiscoveredBy))
|
||||||
|
|
||||||
body := fmt.Sprintf("**Description**\nDistribution '%s' is currently 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())
|
body := fmt.Sprintf("**Description**\nDistribution '%s' is currently 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.ID, str.String())
|
||||||
fullURL := "https://github.com/wailsapp/wails/issues/new?"
|
fullURL := "https://github.com/wailsapp/wails/issues/new?"
|
||||||
params := "title=" + title + "&body=" + body
|
params := "title=" + title + "&body=" + body
|
||||||
|
|
||||||
fmt.Println("Opening browser to file request.")
|
fmt.Println("Opening browser to file request.")
|
||||||
browser.OpenURL(fullURL + url.PathEscape(params))
|
browser.OpenURL(fullURL + url.PathEscape(params))
|
||||||
return nil
|
return nil
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,15 +49,30 @@ func getRequiredProgramsLinux() *Prerequisites {
|
|||||||
result := &Prerequisites{}
|
result := &Prerequisites{}
|
||||||
distroInfo := GetLinuxDistroInfo()
|
distroInfo := GetLinuxDistroInfo()
|
||||||
switch distroInfo.Distribution {
|
switch distroInfo.Distribution {
|
||||||
case Ubuntu, Debian, Zorin:
|
case Debian:
|
||||||
|
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("npm", "Please install with `curl -sL https://deb.nodesource.com/setup_12.x | sudo bash - && sudo apt-get install -y nodejs` and try again"))
|
||||||
|
case Ubuntu:
|
||||||
|
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("npm", "Please install with `curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash - && sudo apt-get install -y nodejs` and try again"))
|
||||||
|
case Zorin:
|
||||||
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"))
|
||||||
|
case Fedora:
|
||||||
|
result.Add(newPrerequisite("gcc", "Please install with `sudo yum install gcc-c++ make` and try again"))
|
||||||
|
result.Add(newPrerequisite("pkg-config", "Please install with `sudo yum install pkgconf-pkg-config` and try again"))
|
||||||
|
result.Add(newPrerequisite("npm", "Please install with `curl -sL https://rpm.nodesource.com/setup_12.x | sudo bash - && sudo yum install -y nodejs` and try again"))
|
||||||
|
case CentOS:
|
||||||
|
result.Add(newPrerequisite("gcc", "Please install with `sudo yum install gcc gcc-c++ make` and try again"))
|
||||||
|
result.Add(newPrerequisite("pkg-config", "Please install with `sudo yum install pkgconfig` and try again"))
|
||||||
|
result.Add(newPrerequisite("npm", "Please install with `curl -sL https://rpm.nodesource.com/setup_12.x | sudo bash - && sudo yum install -y nodejs` 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"))
|
||||||
result.Add(newPrerequisite("npm", "Please install from https://nodejs.org/en/download/ and try again"))
|
result.Add(newPrerequisite("npm", "Please install from https://nodejs.org/en/download/ and try again"))
|
||||||
|
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
@@ -93,7 +108,13 @@ func getRequiredLibrariesLinux() (*Prerequisites, error) {
|
|||||||
result := &Prerequisites{}
|
result := &Prerequisites{}
|
||||||
distroInfo := GetLinuxDistroInfo()
|
distroInfo := GetLinuxDistroInfo()
|
||||||
switch distroInfo.Distribution {
|
switch distroInfo.Distribution {
|
||||||
case Ubuntu, Debian, Zorin:
|
case Debian:
|
||||||
|
result.Add(newPrerequisite("libgtk-3-dev", "Please install with `sudo apt install libgtk-3-dev` and try again"))
|
||||||
|
result.Add(newPrerequisite("libwebkit2gtk-4.0-dev", "Please install with `sudo apt install libwebkit2gtk-4.0-dev` and try again"))
|
||||||
|
case Ubuntu:
|
||||||
|
result.Add(newPrerequisite("libgtk-3-dev", "Please install with `sudo apt install libgtk-3-dev` and try again"))
|
||||||
|
result.Add(newPrerequisite("libwebkit2gtk-4.0-dev", "Please install with `sudo apt install libwebkit2gtk-4.0-dev` and try again"))
|
||||||
|
case Zorin:
|
||||||
result.Add(newPrerequisite("libgtk-3-dev", "Please install with `sudo apt install libgtk-3-dev` and try again"))
|
result.Add(newPrerequisite("libgtk-3-dev", "Please install with `sudo apt install libgtk-3-dev` and try again"))
|
||||||
result.Add(newPrerequisite("libwebkit2gtk-4.0-dev", "Please install with `sudo apt install libwebkit2gtk-4.0-dev` and try again"))
|
result.Add(newPrerequisite("libwebkit2gtk-4.0-dev", "Please install with `sudo apt install libwebkit2gtk-4.0-dev` and try again"))
|
||||||
case Gentoo:
|
case Gentoo:
|
||||||
@@ -102,9 +123,12 @@ func getRequiredLibrariesLinux() (*Prerequisites, error) {
|
|||||||
case Arch:
|
case Arch:
|
||||||
result.Add(newPrerequisite("gtk3", "Please install with `sudo pacman -S gtk3` and try again"))
|
result.Add(newPrerequisite("gtk3", "Please install with `sudo pacman -S gtk3` and try again"))
|
||||||
result.Add(newPrerequisite("webkit2gtk", "Please install with `sudo pacman -S webkit2gtk` and try again"))
|
result.Add(newPrerequisite("webkit2gtk", "Please install with `sudo pacman -S webkit2gtk` and try again"))
|
||||||
case RedHat:
|
case Fedora:
|
||||||
result.Add(newPrerequisite("gtk3-devel", "Please install with `sudo yum install gtk3-devel` and try again"))
|
result.Add(newPrerequisite("gtk3-devel", "Please install with `sudo yum install gtk3-devel` and try again"))
|
||||||
result.Add(newPrerequisite("webkit2gtk3-devel", "Please install with `sudo yum install webkit2gtk3-devel` and try again"))
|
result.Add(newPrerequisite("webkit2gtk3-devel", "Please install with `sudo yum install webkit2gtk3-devel` and try again"))
|
||||||
|
case CentOS:
|
||||||
|
result.Add(newPrerequisite("gtk3-devel", "Please install with `sudo yum install gtk3-devel` and try again"))
|
||||||
|
result.Add(newPrerequisite("webkitgtk3-devel", "Please install with `sudo yum install webkitgtk3-devel` and try again"))
|
||||||
default:
|
default:
|
||||||
result.Add(newPrerequisite("libgtk-3-dev", "Please install with your system package manager and try again"))
|
result.Add(newPrerequisite("libgtk-3-dev", "Please install with your system package manager and try again"))
|
||||||
result.Add(newPrerequisite("libwebkit2gtk-4.0-dev", "Please install with your system package manager and try again"))
|
result.Add(newPrerequisite("libwebkit2gtk-4.0-dev", "Please install with your system package manager and try again"))
|
||||||
|
|||||||
@@ -117,14 +117,15 @@ func (p *ProgramHelper) RunCommandArray(args []string, dir ...string) error {
|
|||||||
}
|
}
|
||||||
args = args[1:]
|
args = args[1:]
|
||||||
var stderr string
|
var stderr string
|
||||||
// fmt.Printf("RunCommandArray = %s %+v\n", program, args)
|
var stdout string
|
||||||
if len(dir) > 0 {
|
if len(dir) > 0 {
|
||||||
_, stderr, err = p.shell.RunInDirectory(dir[0], program, args...)
|
stdout, stderr, err = p.shell.RunInDirectory(dir[0], program, args...)
|
||||||
} else {
|
} else {
|
||||||
_, stderr, err = p.shell.Run(program, args...)
|
stdout, stderr, err = p.shell.Run(program, args...)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(stderr)
|
fmt.Println(stderr)
|
||||||
|
fmt.Println(stdout)
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import (
|
|||||||
"bufio"
|
"bufio"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"runtime"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
@@ -20,11 +19,7 @@ func Prompt(question string, defaultValue ...string) string {
|
|||||||
fmt.Printf(question + ": ")
|
fmt.Printf(question + ": ")
|
||||||
reader := bufio.NewReader(os.Stdin)
|
reader := bufio.NewReader(os.Stdin)
|
||||||
input, _ := reader.ReadString('\n')
|
input, _ := reader.ReadString('\n')
|
||||||
EOL := "\n"
|
input = strings.TrimSpace(input)
|
||||||
if runtime.GOOS == "windows" {
|
|
||||||
EOL = "\r\n"
|
|
||||||
}
|
|
||||||
input = strings.Replace(input, EOL, "", -1)
|
|
||||||
|
|
||||||
if input != "" {
|
if input != "" {
|
||||||
answer = input
|
answer = input
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package cmd
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/masterminds/semver"
|
"github.com/Masterminds/semver"
|
||||||
)
|
)
|
||||||
|
|
||||||
// SemanticVersion is a struct containing a semantic version
|
// SemanticVersion is a struct containing a semantic version
|
||||||
|
|||||||
@@ -294,7 +294,7 @@ func CheckDependencies(logger *Logger) (bool, error) {
|
|||||||
} else {
|
} else {
|
||||||
logger.Green("Library '%s' installed.", library.Name)
|
logger.Green("Library '%s' installed.", library.Name)
|
||||||
}
|
}
|
||||||
case RedHat:
|
case RedHat, Fedora, CentOS:
|
||||||
installed, err := RpmInstalled(library.Name)
|
installed, err := RpmInstalled(library.Name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
"@angular/platform-browser": "~8.0.1",
|
"@angular/platform-browser": "~8.0.1",
|
||||||
"@angular/platform-browser-dynamic": "~8.0.1",
|
"@angular/platform-browser-dynamic": "~8.0.1",
|
||||||
"@angular/router": "~8.0.1",
|
"@angular/router": "~8.0.1",
|
||||||
|
"@wailsapp/runtime": "^1.0.0",
|
||||||
"ngx-build-plus": "^8.0.3",
|
"ngx-build-plus": "^8.0.3",
|
||||||
"rxjs": "~6.4.0",
|
"rxjs": "~6.4.0",
|
||||||
"tslib": "^1.9.0",
|
"tslib": "^1.9.0",
|
||||||
|
|||||||
@@ -6,13 +6,13 @@ import { environment } from './environments/environment';
|
|||||||
|
|
||||||
import 'zone.js'
|
import 'zone.js'
|
||||||
|
|
||||||
import Bridge from './wailsbridge';
|
import Wails from '@wailsapp/runtime';
|
||||||
|
|
||||||
if (environment.production) {
|
if (environment.production) {
|
||||||
enableProdMode();
|
enableProdMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
Bridge.Start(() => {
|
Wails.Init(() => {
|
||||||
platformBrowserDynamic().bootstrapModule(AppModule)
|
platformBrowserDynamic().bootstrapModule(AppModule)
|
||||||
.catch(err => console.error(err));
|
.catch(err => console.error(err));
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -4,10 +4,12 @@
|
|||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"core-js": "^3.1.4",
|
||||||
"react": "^16.8.6",
|
"react": "^16.8.6",
|
||||||
"react-dom": "^16.8.6",
|
"react-dom": "^16.8.6",
|
||||||
"wails-react-scripts": "3.0.1-2",
|
"wails-react-scripts": "3.0.1-2",
|
||||||
"react-modal": "3.8.1"
|
"react-modal": "3.8.1",
|
||||||
|
"@wailsapp/runtime": "^1.0.0"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "react-scripts start",
|
"start": "react-scripts start",
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import ReactDOM from 'react-dom';
|
import ReactDOM from 'react-dom';
|
||||||
|
import 'core-js/stable';
|
||||||
import './index.css';
|
import './index.css';
|
||||||
import App from './App';
|
import App from './App';
|
||||||
|
|
||||||
import Bridge from "./wailsbridge";
|
import Wails from '@wailsapp/runtime';
|
||||||
|
|
||||||
Bridge.Start(() => {
|
Wails.Init(() => {
|
||||||
ReactDOM.render(<App />, document.getElementById('app'));
|
ReactDOM.render(<App />, document.getElementById('app'));
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -9,7 +9,8 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"core-js": "^2.6.4",
|
"core-js": "^2.6.4",
|
||||||
"vue": "^2.5.22"
|
"vue": "^2.5.22",
|
||||||
|
"@wailsapp/runtime": "^1.0.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@vue/cli-plugin-babel": "^3.4.0",
|
"@vue/cli-plugin-babel": "^3.4.0",
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
import Vue from "vue";
|
import Vue from 'vue';
|
||||||
import App from "./App.vue";
|
import App from './App.vue';
|
||||||
|
|
||||||
Vue.config.productionTip = false;
|
Vue.config.productionTip = false;
|
||||||
Vue.config.devtools = true;
|
Vue.config.devtools = true;
|
||||||
|
|
||||||
import Bridge from "./wailsbridge";
|
import Wails from '@wailsapp/runtime';
|
||||||
|
|
||||||
Bridge.Start(() => {
|
Wails.Init(() => {
|
||||||
new Vue({
|
new Vue({
|
||||||
render: h => h(App)
|
render: h => h(App)
|
||||||
}).$mount("#app");
|
}).$mount('#app');
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,17 +0,0 @@
|
|||||||
/*
|
|
||||||
Wails Bridge (c) 2019-present Lea Anthony
|
|
||||||
|
|
||||||
This prod version is to get around having to rewrite your code
|
|
||||||
for production. When doing a release build, this file will be used
|
|
||||||
instead of the full version.
|
|
||||||
*/
|
|
||||||
|
|
||||||
export default {
|
|
||||||
// The main function
|
|
||||||
// Passes the main Wails object to the callback if given.
|
|
||||||
Start: function (callback) {
|
|
||||||
if (callback) {
|
|
||||||
window.wails.Events.On("wails:ready", callback);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@@ -12,7 +12,8 @@
|
|||||||
"core-js": "^2.6.4",
|
"core-js": "^2.6.4",
|
||||||
"material-design-icons-iconfont": "^5.0.1",
|
"material-design-icons-iconfont": "^5.0.1",
|
||||||
"vue": "^2.5.22",
|
"vue": "^2.5.22",
|
||||||
"vuetify": "^1.5.14"
|
"vuetify": "^1.5.14",
|
||||||
|
"@wailsapp/runtime": "^1.0.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@vue/cli-plugin-babel": "^3.4.0",
|
"@vue/cli-plugin-babel": "^3.4.0",
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import 'babel-polyfill';
|
import 'babel-polyfill';
|
||||||
import Vue from "vue";
|
import Vue from 'vue';
|
||||||
|
|
||||||
// Setup Vuetify
|
// Setup Vuetify
|
||||||
import Vuetify from 'vuetify';
|
import Vuetify from 'vuetify';
|
||||||
@@ -7,15 +7,15 @@ Vue.use(Vuetify);
|
|||||||
import 'vuetify/dist/vuetify.min.css';
|
import 'vuetify/dist/vuetify.min.css';
|
||||||
import 'material-design-icons-iconfont';
|
import 'material-design-icons-iconfont';
|
||||||
|
|
||||||
import App from "./App.vue";
|
import App from './App.vue';
|
||||||
|
|
||||||
Vue.config.productionTip = false;
|
Vue.config.productionTip = false;
|
||||||
Vue.config.devtools = true;
|
Vue.config.devtools = true;
|
||||||
|
|
||||||
import Bridge from "./wailsbridge";
|
import Wails from '@wailsapp/runtime';
|
||||||
|
|
||||||
Bridge.Start(() => {
|
Wails.Init(() => {
|
||||||
new Vue({
|
new Vue({
|
||||||
render: h => h(App)
|
render: h => h(App)
|
||||||
}).$mount("#app");
|
}).$mount('#app');
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
// Version - Wails version
|
// Version - Wails version
|
||||||
const Version = "v0.17.4-pre"
|
const Version = "v0.17.9-pre"
|
||||||
|
|||||||
@@ -72,7 +72,16 @@ func init() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ensure that runtime init.js is the production version
|
||||||
|
err = cmd.InstallProdRuntime(projectDir, projectOptions)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Move to project directory
|
// Move to project directory
|
||||||
err = os.Chdir(projectDir)
|
err = os.Chdir(projectDir)
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ func init() {
|
|||||||
projectDir := fs.Cwd()
|
projectDir := fs.Cwd()
|
||||||
|
|
||||||
// Install the bridge library
|
// Install the bridge library
|
||||||
err = cmd.InstallBridge("serve", projectDir, projectOptions)
|
err = cmd.InstallBridge(projectDir, projectOptions)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,12 +42,51 @@ To help you in this process, we will ask for some information, add Go/Wails deta
|
|||||||
gomodule = "(Not Set)"
|
gomodule = "(Not Set)"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get versions for GCC, node & npm
|
||||||
|
program := cmd.NewProgramHelper()
|
||||||
|
var gccVersion, nodeVersion, npmVersion string
|
||||||
|
|
||||||
|
switch runtime.GOOS {
|
||||||
|
case "darwin":
|
||||||
|
gcc := program.FindProgram("gcc")
|
||||||
|
if gcc != nil {
|
||||||
|
stdout, _, _, _ := gcc.Run("-dumpversion")
|
||||||
|
gccVersion = strings.TrimSpace(stdout)
|
||||||
|
}
|
||||||
|
case "linux":
|
||||||
|
gcc := program.FindProgram("gcc")
|
||||||
|
if gcc != nil {
|
||||||
|
gccVersion, _, _, _ := gcc.Run("-dumpfullversion")
|
||||||
|
gccVersion = gccVersion[:len(gccVersion)-1]
|
||||||
|
gccVersion = strings.TrimSpace(gccVersion)
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: windows support
|
||||||
|
}
|
||||||
|
|
||||||
|
npm := program.FindProgram("npm")
|
||||||
|
if npm != nil {
|
||||||
|
stdout, _, _, _ := npm.Run("--version")
|
||||||
|
nodeVersion = stdout
|
||||||
|
nodeVersion = nodeVersion[:len(nodeVersion)-1]
|
||||||
|
}
|
||||||
|
|
||||||
|
node := program.FindProgram("node")
|
||||||
|
if node != nil {
|
||||||
|
stdout, _, _, _ := node.Run("--version")
|
||||||
|
npmVersion = stdout
|
||||||
|
npmVersion = npmVersion[:len(npmVersion)-1]
|
||||||
|
}
|
||||||
|
|
||||||
str.WriteString("\n| Name | Value |\n| ----- | ----- |\n")
|
str.WriteString("\n| Name | Value |\n| ----- | ----- |\n")
|
||||||
str.WriteString(fmt.Sprintf("| Wails Version | %s |\n", cmd.Version))
|
str.WriteString(fmt.Sprintf("| Wails Version | %s |\n", cmd.Version))
|
||||||
str.WriteString(fmt.Sprintf("| Go Version | %s |\n", runtime.Version()))
|
str.WriteString(fmt.Sprintf("| Go Version | %s |\n", runtime.Version()))
|
||||||
str.WriteString(fmt.Sprintf("| Platform | %s |\n", runtime.GOOS))
|
str.WriteString(fmt.Sprintf("| Platform | %s |\n", runtime.GOOS))
|
||||||
str.WriteString(fmt.Sprintf("| Arch | %s |\n", runtime.GOARCH))
|
str.WriteString(fmt.Sprintf("| Arch | %s |\n", runtime.GOARCH))
|
||||||
str.WriteString(fmt.Sprintf("| GO111MODULE | %s |\n", gomodule))
|
str.WriteString(fmt.Sprintf("| GO111MODULE | %s |\n", gomodule))
|
||||||
|
str.WriteString(fmt.Sprintf("| GCC | %s |\n", gccVersion))
|
||||||
|
str.WriteString(fmt.Sprintf("| Npm | %s |\n", npmVersion))
|
||||||
|
str.WriteString(fmt.Sprintf("| Node | %s |\n", nodeVersion))
|
||||||
|
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
fmt.Println("Processing template and preparing for upload.")
|
fmt.Println("Processing template and preparing for upload.")
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package wails
|
package wails
|
||||||
|
|
||||||
|
import "github.com/leaanthony/mewn"
|
||||||
|
|
||||||
// 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 {
|
||||||
@@ -29,7 +30,7 @@ func (a *AppConfig) GetTitle() string {
|
|||||||
return a.Title
|
return a.Title
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetDefaultHTML returns the desired window title
|
// GetDefaultHTML returns the default HTML
|
||||||
func (a *AppConfig) GetDefaultHTML() string {
|
func (a *AppConfig) GetDefaultHTML() string {
|
||||||
return a.defaultHTML
|
return a.defaultHTML
|
||||||
}
|
}
|
||||||
@@ -95,6 +96,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: mewn.String("./runtime/assets/default.html"),
|
||||||
}
|
}
|
||||||
|
|
||||||
if userConfig != nil {
|
if userConfig != nil {
|
||||||
|
|||||||
3
go.mod
3
go.mod
@@ -1,7 +1,7 @@
|
|||||||
module github.com/wailsapp/wails
|
module github.com/wailsapp/wails
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/Masterminds/semver v1.4.2 // indirect
|
github.com/Masterminds/semver v1.4.2
|
||||||
github.com/dchest/cssmin v0.0.0-20151210170030-fb8d9b44afdc // indirect
|
github.com/dchest/cssmin v0.0.0-20151210170030-fb8d9b44afdc // indirect
|
||||||
github.com/dchest/htmlmin v0.0.0-20150526090704-e254725e81ac
|
github.com/dchest/htmlmin v0.0.0-20150526090704-e254725e81ac
|
||||||
github.com/dchest/jsmin v0.0.0-20160823214000-faeced883947 // indirect
|
github.com/dchest/jsmin v0.0.0-20160823214000-faeced883947 // indirect
|
||||||
@@ -14,7 +14,6 @@ require (
|
|||||||
github.com/leaanthony/mewn v0.10.7
|
github.com/leaanthony/mewn v0.10.7
|
||||||
github.com/leaanthony/slicer v1.3.2
|
github.com/leaanthony/slicer v1.3.2
|
||||||
github.com/leaanthony/spinner v0.5.3
|
github.com/leaanthony/spinner v0.5.3
|
||||||
github.com/masterminds/semver v1.4.2
|
|
||||||
github.com/mattn/go-colorable v0.1.1 // indirect
|
github.com/mattn/go-colorable v0.1.1 // indirect
|
||||||
github.com/mattn/go-isatty v0.0.7 // indirect
|
github.com/mattn/go-isatty v0.0.7 // indirect
|
||||||
github.com/mitchellh/go-homedir v1.1.0
|
github.com/mitchellh/go-homedir v1.1.0
|
||||||
|
|||||||
8
go.sum
8
go.sum
@@ -25,7 +25,6 @@ github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNU
|
|||||||
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8=
|
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8=
|
||||||
github.com/kennygrant/sanitize v1.2.4 h1:gN25/otpP5vAsO2djbMhF/LQX6R7+O1TB4yv8NzpJ3o=
|
github.com/kennygrant/sanitize v1.2.4 h1:gN25/otpP5vAsO2djbMhF/LQX6R7+O1TB4yv8NzpJ3o=
|
||||||
github.com/kennygrant/sanitize v1.2.4/go.mod h1:LGsjYYtgxbetdg5owWB2mpgUL6e2nfw2eObZ0u0qvak=
|
github.com/kennygrant/sanitize v1.2.4/go.mod h1:LGsjYYtgxbetdg5owWB2mpgUL6e2nfw2eObZ0u0qvak=
|
||||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk=
|
|
||||||
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.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 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/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||||
@@ -41,14 +40,10 @@ github.com/leaanthony/synx v0.1.0 h1:R0lmg2w6VMb8XcotOwAe5DLyzwjLrskNkwU7LLWsyL8
|
|||||||
github.com/leaanthony/synx v0.1.0/go.mod h1:Iz7eybeeG8bdq640iR+CwYb8p+9EOsgMWghkSRyZcqs=
|
github.com/leaanthony/synx v0.1.0/go.mod h1:Iz7eybeeG8bdq640iR+CwYb8p+9EOsgMWghkSRyZcqs=
|
||||||
github.com/leaanthony/wincursor v0.1.0 h1:Dsyp68QcF5cCs65AMBmxoYNEm0n8K7mMchG6a8fYxf8=
|
github.com/leaanthony/wincursor v0.1.0 h1:Dsyp68QcF5cCs65AMBmxoYNEm0n8K7mMchG6a8fYxf8=
|
||||||
github.com/leaanthony/wincursor v0.1.0/go.mod h1:7TVwwrzSH/2Y9gLOGH+VhA+bZhoWXBRgbGNTMk+yimE=
|
github.com/leaanthony/wincursor v0.1.0/go.mod h1:7TVwwrzSH/2Y9gLOGH+VhA+bZhoWXBRgbGNTMk+yimE=
|
||||||
github.com/masterminds/semver v1.4.2 h1:BgrAYDjlAebjtOwS7C/1QZoh5WgyXx4b59ydc+Ph8xI=
|
|
||||||
github.com/masterminds/semver v1.4.2/go.mod h1:s7KNT9fnd7edGzwwP7RBX4H0v/CYd5qdOLfkL1V75yg=
|
|
||||||
github.com/mattn/go-colorable v0.0.9 h1:UVL0vNpWh04HeJXV0KLcaT7r06gOH2l4OW6ddYRUIY4=
|
|
||||||
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
|
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
|
||||||
github.com/mattn/go-colorable v0.1.1 h1:G1f5SKeVxmagw/IyvzvtZE4Gybcc4Tr1tf7I8z0XgOg=
|
github.com/mattn/go-colorable v0.1.1 h1:G1f5SKeVxmagw/IyvzvtZE4Gybcc4Tr1tf7I8z0XgOg=
|
||||||
github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ=
|
github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ=
|
||||||
github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
|
github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
|
||||||
github.com/mattn/go-isatty v0.0.4 h1:bnP0vzxcAdeI1zdubAl5PjU6zsERjGZb7raWodagDYs=
|
|
||||||
github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
|
github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
|
||||||
github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
|
github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
|
||||||
github.com/mattn/go-isatty v0.0.7 h1:UvyT9uN+3r7yLEYSlJsbQGdsaB/a0DlgWP3pql6iwOc=
|
github.com/mattn/go-isatty v0.0.7 h1:UvyT9uN+3r7yLEYSlJsbQGdsaB/a0DlgWP3pql6iwOc=
|
||||||
@@ -77,7 +72,6 @@ github.com/wailsapp/webview v0.2.7 h1:fN5L5H9Oivg9IJPk7uaXQnjqB68Fny11ZWkIaTIZHm
|
|||||||
github.com/wailsapp/webview v0.2.7/go.mod h1:XO9HJbKWokDxUYTWQEBCYg95n/To1v7PxvanDNVf8hY=
|
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=
|
github.com/zserge/webview v0.0.0-20190123072648-16c93bcaeaeb/go.mod h1:a1CV8KR4Dd1eP2g+mEijGOp+HKczwdKHWyx0aPHKvo4=
|
||||||
golang.org/x/crypto v0.0.0-20190123085648-057139ce5d2b/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
golang.org/x/crypto v0.0.0-20190123085648-057139ce5d2b/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M=
|
|
||||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529 h1:iMGN4xG0cnqj3t+zOM8wUB0BiPKHEwSxEZCvzcbZuvk=
|
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529 h1:iMGN4xG0cnqj3t+zOM8wUB0BiPKHEwSxEZCvzcbZuvk=
|
||||||
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||||
@@ -86,10 +80,8 @@ golang.org/x/net v0.0.0-20190509222800-a4d6f7feada5 h1:6M3SDHlHHDCx2PcQw3S4KsR17
|
|||||||
golang.org/x/net v0.0.0-20190509222800-a4d6f7feada5/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
golang.org/x/net v0.0.0-20190509222800-a4d6f7feada5/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||||
golang.org/x/sys v0.0.0-20180606202747-9527bec2660b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20180606202747-9527bec2660b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20181228144115-9a3f9b0469bb h1:pf3XwC90UUdNPYWZdFjhGBE7DUFuK3Ct1zWmZ65QN30=
|
|
||||||
golang.org/x/sys v0.0.0-20181228144115-9a3f9b0469bb/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20181228144115-9a3f9b0469bb/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223 h1:DH4skfRX4EBpamg7iV4ZlCpblAHI6s6TDM39bFZumv8=
|
|
||||||
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20190509141414-a5b02f93d862 h1:rM0ROo5vb9AdYJi1110yjWGMej9ITfKddS89P3Fkhug=
|
golang.org/x/sys v0.0.0-20190509141414-a5b02f93d862 h1:rM0ROo5vb9AdYJi1110yjWGMej9ITfKddS89P3Fkhug=
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
|
|
||||||
"github.com/wailsapp/wails/lib/logger"
|
"github.com/wailsapp/wails/lib/logger"
|
||||||
"github.com/wailsapp/wails/lib/messages"
|
"github.com/wailsapp/wails/lib/messages"
|
||||||
"github.com/wailsapp/wails/runtime/go/runtime"
|
"github.com/wailsapp/wails/runtime"
|
||||||
)
|
)
|
||||||
|
|
||||||
type internalMethods struct {
|
type internalMethods struct {
|
||||||
|
|||||||
@@ -94,17 +94,17 @@ func (i *Manager) Start(eventManager interfaces.EventManager, bindingManager int
|
|||||||
logdata := incomingMessage.Payload.(*messages.LogData)
|
logdata := incomingMessage.Payload.(*messages.LogData)
|
||||||
switch logdata.Level {
|
switch logdata.Level {
|
||||||
case "info":
|
case "info":
|
||||||
i.log.Info(logdata.Message)
|
logger.GlobalLogger.Info(logdata.Message)
|
||||||
case "debug":
|
case "debug":
|
||||||
i.log.Debug(logdata.Message)
|
logger.GlobalLogger.Debug(logdata.Message)
|
||||||
case "warning":
|
case "warning":
|
||||||
i.log.Warn(logdata.Message)
|
logger.GlobalLogger.Warn(logdata.Message)
|
||||||
case "error":
|
case "error":
|
||||||
i.log.Error(logdata.Message)
|
logger.GlobalLogger.Error(logdata.Message)
|
||||||
case "fatal":
|
case "fatal":
|
||||||
i.log.Fatal(logdata.Message)
|
logger.GlobalLogger.Fatal(logdata.Message)
|
||||||
default:
|
default:
|
||||||
i.log.ErrorFields("Invalid log level sent", logger.Fields{
|
logger.ErrorFields("Invalid log level sent", logger.Fields{
|
||||||
"level": logdata.Level,
|
"level": logdata.Level,
|
||||||
"message": logdata.Message,
|
"message": logdata.Message,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -15,90 +15,90 @@ func NewCustomLogger(prefix string) *CustomLogger {
|
|||||||
|
|
||||||
// Info level message
|
// Info level message
|
||||||
func (c *CustomLogger) Info(message string) {
|
func (c *CustomLogger) Info(message string) {
|
||||||
logger.Info(c.prefix + message)
|
GlobalLogger.Info(c.prefix + message)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Infof - formatted message
|
// Infof - formatted message
|
||||||
func (c *CustomLogger) Infof(message string, args ...interface{}) {
|
func (c *CustomLogger) Infof(message string, args ...interface{}) {
|
||||||
logger.Infof(c.prefix+message, args...)
|
GlobalLogger.Infof(c.prefix+message, args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// InfoFields - message with fields
|
// InfoFields - message with fields
|
||||||
func (c *CustomLogger) InfoFields(message string, fields Fields) {
|
func (c *CustomLogger) InfoFields(message string, fields Fields) {
|
||||||
logger.WithFields(map[string]interface{}(fields)).Info(c.prefix + message)
|
GlobalLogger.WithFields(map[string]interface{}(fields)).Info(c.prefix + message)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Debug level message
|
// Debug level message
|
||||||
func (c *CustomLogger) Debug(message string) {
|
func (c *CustomLogger) Debug(message string) {
|
||||||
logger.Debug(c.prefix + message)
|
GlobalLogger.Debug(c.prefix + message)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Debugf - formatted message
|
// Debugf - formatted message
|
||||||
func (c *CustomLogger) Debugf(message string, args ...interface{}) {
|
func (c *CustomLogger) Debugf(message string, args ...interface{}) {
|
||||||
logger.Debugf(c.prefix+message, args...)
|
GlobalLogger.Debugf(c.prefix+message, args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// DebugFields - message with fields
|
// DebugFields - message with fields
|
||||||
func (c *CustomLogger) DebugFields(message string, fields Fields) {
|
func (c *CustomLogger) DebugFields(message string, fields Fields) {
|
||||||
logger.WithFields(map[string]interface{}(fields)).Debug(c.prefix + message)
|
GlobalLogger.WithFields(map[string]interface{}(fields)).Debug(c.prefix + message)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Warn level message
|
// Warn level message
|
||||||
func (c *CustomLogger) Warn(message string) {
|
func (c *CustomLogger) Warn(message string) {
|
||||||
logger.Warn(c.prefix + message)
|
GlobalLogger.Warn(c.prefix + message)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Warnf - formatted message
|
// Warnf - formatted message
|
||||||
func (c *CustomLogger) Warnf(message string, args ...interface{}) {
|
func (c *CustomLogger) Warnf(message string, args ...interface{}) {
|
||||||
logger.Warnf(c.prefix+message, args...)
|
GlobalLogger.Warnf(c.prefix+message, args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// WarnFields - message with fields
|
// WarnFields - message with fields
|
||||||
func (c *CustomLogger) WarnFields(message string, fields Fields) {
|
func (c *CustomLogger) WarnFields(message string, fields Fields) {
|
||||||
logger.WithFields(map[string]interface{}(fields)).Warn(c.prefix + message)
|
GlobalLogger.WithFields(map[string]interface{}(fields)).Warn(c.prefix + message)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Error level message
|
// Error level message
|
||||||
func (c *CustomLogger) Error(message string) {
|
func (c *CustomLogger) Error(message string) {
|
||||||
logger.Error(c.prefix + message)
|
GlobalLogger.Error(c.prefix + message)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Errorf - formatted message
|
// Errorf - formatted message
|
||||||
func (c *CustomLogger) Errorf(message string, args ...interface{}) {
|
func (c *CustomLogger) Errorf(message string, args ...interface{}) {
|
||||||
logger.Errorf(c.prefix+message, args...)
|
GlobalLogger.Errorf(c.prefix+message, args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ErrorFields - message with fields
|
// ErrorFields - message with fields
|
||||||
func (c *CustomLogger) ErrorFields(message string, fields Fields) {
|
func (c *CustomLogger) ErrorFields(message string, fields Fields) {
|
||||||
logger.WithFields(map[string]interface{}(fields)).Error(c.prefix + message)
|
GlobalLogger.WithFields(map[string]interface{}(fields)).Error(c.prefix + message)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fatal level message
|
// Fatal level message
|
||||||
func (c *CustomLogger) Fatal(message string) {
|
func (c *CustomLogger) Fatal(message string) {
|
||||||
logger.Fatal(c.prefix + message)
|
GlobalLogger.Fatal(c.prefix + message)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fatalf - formatted message
|
// Fatalf - formatted message
|
||||||
func (c *CustomLogger) Fatalf(message string, args ...interface{}) {
|
func (c *CustomLogger) Fatalf(message string, args ...interface{}) {
|
||||||
logger.Fatalf(c.prefix+message, args...)
|
GlobalLogger.Fatalf(c.prefix+message, args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// FatalFields - message with fields
|
// FatalFields - message with fields
|
||||||
func (c *CustomLogger) FatalFields(message string, fields Fields) {
|
func (c *CustomLogger) FatalFields(message string, fields Fields) {
|
||||||
logger.WithFields(map[string]interface{}(fields)).Fatal(c.prefix + message)
|
GlobalLogger.WithFields(map[string]interface{}(fields)).Fatal(c.prefix + message)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Panic level message
|
// Panic level message
|
||||||
func (c *CustomLogger) Panic(message string) {
|
func (c *CustomLogger) Panic(message string) {
|
||||||
logger.Panic(c.prefix + message)
|
GlobalLogger.Panic(c.prefix + message)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Panicf - formatted message
|
// Panicf - formatted message
|
||||||
func (c *CustomLogger) Panicf(message string, args ...interface{}) {
|
func (c *CustomLogger) Panicf(message string, args ...interface{}) {
|
||||||
logger.Panicf(c.prefix+message, args...)
|
GlobalLogger.Panicf(c.prefix+message, args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// PanicFields - message with fields
|
// PanicFields - message with fields
|
||||||
func (c *CustomLogger) PanicFields(message string, fields Fields) {
|
func (c *CustomLogger) PanicFields(message string, fields Fields) {
|
||||||
logger.WithFields(map[string]interface{}(fields)).Panic(c.prefix + message)
|
GlobalLogger.WithFields(map[string]interface{}(fields)).Panic(c.prefix + message)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ import (
|
|||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Global logger reference
|
// GlobalLogger is the global logger
|
||||||
var logger = logrus.New()
|
var GlobalLogger = logrus.New()
|
||||||
|
|
||||||
// Fields is used by the customLogger object to output
|
// Fields is used by the customLogger object to output
|
||||||
// fields along with a message
|
// fields along with a message
|
||||||
@@ -16,27 +16,32 @@ type Fields map[string]interface{}
|
|||||||
|
|
||||||
// Default options for the global logger
|
// Default options for the global logger
|
||||||
func init() {
|
func init() {
|
||||||
logger.SetOutput(os.Stdout)
|
GlobalLogger.SetOutput(os.Stdout)
|
||||||
logger.SetLevel(logrus.DebugLevel)
|
GlobalLogger.SetLevel(logrus.DebugLevel)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ErrorFields is a helper for logging fields to the global logger
|
||||||
|
func ErrorFields(message string, fields Fields) {
|
||||||
|
GlobalLogger.WithFields(map[string]interface{}(fields)).Error(message)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetLogLevel sets the log level to the given level
|
// SetLogLevel sets the log level to the given level
|
||||||
func SetLogLevel(level string) {
|
func SetLogLevel(level string) {
|
||||||
switch strings.ToLower(level) {
|
switch strings.ToLower(level) {
|
||||||
case "info":
|
case "info":
|
||||||
logger.SetLevel(logrus.InfoLevel)
|
GlobalLogger.SetLevel(logrus.InfoLevel)
|
||||||
case "debug":
|
case "debug":
|
||||||
logger.SetLevel(logrus.DebugLevel)
|
GlobalLogger.SetLevel(logrus.DebugLevel)
|
||||||
case "warn":
|
case "warn":
|
||||||
logger.SetLevel(logrus.WarnLevel)
|
GlobalLogger.SetLevel(logrus.WarnLevel)
|
||||||
case "error":
|
case "error":
|
||||||
logger.SetLevel(logrus.ErrorLevel)
|
GlobalLogger.SetLevel(logrus.ErrorLevel)
|
||||||
case "fatal":
|
case "fatal":
|
||||||
logger.SetLevel(logrus.FatalLevel)
|
GlobalLogger.SetLevel(logrus.FatalLevel)
|
||||||
case "panic":
|
case "panic":
|
||||||
logger.SetLevel(logrus.PanicLevel)
|
GlobalLogger.SetLevel(logrus.PanicLevel)
|
||||||
default:
|
default:
|
||||||
logger.SetLevel(logrus.DebugLevel)
|
GlobalLogger.SetLevel(logrus.DebugLevel)
|
||||||
logger.Warnf("Log level '%s' not recognised. Setting to Debug.", level)
|
GlobalLogger.Warnf("Log level '%s' not recognised. Setting to Debug.", level)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,9 +31,9 @@ func (m messageType) toString() string {
|
|||||||
return [...]string{"j", "s", "h", "n", "b", "c", "w"}[m]
|
return [...]string{"j", "s", "h", "n", "b", "c", "w"}[m]
|
||||||
}
|
}
|
||||||
|
|
||||||
// Headless is a backend that opens a local web server
|
// Bridge is a backend that opens a local web server
|
||||||
// and renders the files over a websocket
|
// and renders the files over a websocket
|
||||||
type Headless struct {
|
type Bridge struct {
|
||||||
// Common
|
// Common
|
||||||
log *logger.CustomLogger
|
log *logger.CustomLogger
|
||||||
ipcManager interfaces.IPCManager
|
ipcManager interfaces.IPCManager
|
||||||
@@ -41,7 +41,7 @@ type Headless struct {
|
|||||||
eventManager interfaces.EventManager
|
eventManager interfaces.EventManager
|
||||||
bindingCache []string
|
bindingCache []string
|
||||||
|
|
||||||
// Headless specific
|
// Bridge specific
|
||||||
initialisationJS []string
|
initialisationJS []string
|
||||||
server *http.Server
|
server *http.Server
|
||||||
theConnection *websocket.Conn
|
theConnection *websocket.Conn
|
||||||
@@ -50,8 +50,8 @@ type Headless struct {
|
|||||||
lock sync.Mutex
|
lock sync.Mutex
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialise the Headless Renderer
|
// Initialise the Bridge Renderer
|
||||||
func (h *Headless) Initialise(appConfig interfaces.AppConfig, ipcManager interfaces.IPCManager, eventManager interfaces.EventManager) error {
|
func (h *Bridge) Initialise(appConfig interfaces.AppConfig, ipcManager interfaces.IPCManager, eventManager interfaces.EventManager) error {
|
||||||
h.ipcManager = ipcManager
|
h.ipcManager = ipcManager
|
||||||
h.appConfig = appConfig
|
h.appConfig = appConfig
|
||||||
h.eventManager = eventManager
|
h.eventManager = eventManager
|
||||||
@@ -60,7 +60,7 @@ func (h *Headless) Initialise(appConfig interfaces.AppConfig, ipcManager interfa
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *Headless) evalJS(js string, mtype messageType) error {
|
func (h *Bridge) evalJS(js string, mtype messageType) error {
|
||||||
|
|
||||||
message := mtype.toString() + js
|
message := mtype.toString() + js
|
||||||
|
|
||||||
@@ -74,7 +74,7 @@ func (h *Headless) evalJS(js string, mtype messageType) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *Headless) injectCSS(css string) {
|
func (h *Bridge) injectCSS(css string) {
|
||||||
// Minify css to overcome issues in the browser with carriage returns
|
// Minify css to overcome issues in the browser with carriage returns
|
||||||
minified, err := htmlmin.Minify([]byte(css), &htmlmin.Options{
|
minified, err := htmlmin.Minify([]byte(css), &htmlmin.Options{
|
||||||
MinifyStyles: true,
|
MinifyStyles: true,
|
||||||
@@ -90,7 +90,7 @@ func (h *Headless) injectCSS(css string) {
|
|||||||
h.evalJS(inject, cssMessage)
|
h.evalJS(inject, cssMessage)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *Headless) wsBridgeHandler(w http.ResponseWriter, r *http.Request) {
|
func (h *Bridge) wsBridgeHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
conn, err := websocket.Upgrade(w, r, w.Header(), 1024, 1024)
|
conn, err := websocket.Upgrade(w, r, w.Header(), 1024, 1024)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, "Could not open websocket connection", http.StatusBadRequest)
|
http.Error(w, "Could not open websocket connection", http.StatusBadRequest)
|
||||||
@@ -105,7 +105,7 @@ func (h *Headless) wsBridgeHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
go h.start(conn)
|
go h.start(conn)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *Headless) sendMessage(conn *websocket.Conn, msg string) {
|
func (h *Bridge) sendMessage(conn *websocket.Conn, msg string) {
|
||||||
|
|
||||||
h.lock.Lock()
|
h.lock.Lock()
|
||||||
defer h.lock.Unlock()
|
defer h.lock.Unlock()
|
||||||
@@ -115,12 +115,12 @@ func (h *Headless) sendMessage(conn *websocket.Conn, msg string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *Headless) start(conn *websocket.Conn) {
|
func (h *Bridge) start(conn *websocket.Conn) {
|
||||||
|
|
||||||
// set external.invoke
|
// set external.invoke
|
||||||
h.log.Infof("Connected to frontend.")
|
h.log.Infof("Connected to frontend.")
|
||||||
|
|
||||||
wailsRuntime := mewn.String("../../runtime/js/dist/wails.js")
|
wailsRuntime := mewn.String("../../runtime/assets/wails.js")
|
||||||
h.evalJS(wailsRuntime, wailsRuntimeMessage)
|
h.evalJS(wailsRuntime, wailsRuntimeMessage)
|
||||||
|
|
||||||
// Inject bindings
|
// Inject bindings
|
||||||
@@ -147,8 +147,8 @@ func (h *Headless) start(conn *websocket.Conn) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run the app in headless mode!
|
// Run the app in Bridge mode!
|
||||||
func (h *Headless) Run() error {
|
func (h *Bridge) Run() error {
|
||||||
h.server = &http.Server{Addr: ":34115"}
|
h.server = &http.Server{Addr: ":34115"}
|
||||||
http.HandleFunc("/bridge", h.wsBridgeHandler)
|
http.HandleFunc("/bridge", h.wsBridgeHandler)
|
||||||
|
|
||||||
@@ -163,39 +163,39 @@ func (h *Headless) Run() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewBinding creates a new binding with the frontend
|
// NewBinding creates a new binding with the frontend
|
||||||
func (h *Headless) NewBinding(methodName string) error {
|
func (h *Bridge) NewBinding(methodName string) error {
|
||||||
h.bindingCache = append(h.bindingCache, methodName)
|
h.bindingCache = append(h.bindingCache, methodName)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// SelectFile is unsupported for Headless but required
|
// SelectFile is unsupported for Bridge but required
|
||||||
// for the Renderer interface
|
// for the Renderer interface
|
||||||
func (h *Headless) SelectFile() string {
|
func (h *Bridge) SelectFile() string {
|
||||||
h.log.Warn("SelectFile() unsupported in bridge mode")
|
h.log.Warn("SelectFile() unsupported in bridge mode")
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
// SelectDirectory is unsupported for Headless but required
|
// SelectDirectory is unsupported for Bridge but required
|
||||||
// for the Renderer interface
|
// for the Renderer interface
|
||||||
func (h *Headless) SelectDirectory() string {
|
func (h *Bridge) SelectDirectory() string {
|
||||||
h.log.Warn("SelectDirectory() unsupported in bridge mode")
|
h.log.Warn("SelectDirectory() unsupported in bridge mode")
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
// SelectSaveFile is unsupported for Headless but required
|
// SelectSaveFile is unsupported for Bridge but required
|
||||||
// for the Renderer interface
|
// for the Renderer interface
|
||||||
func (h *Headless) SelectSaveFile() string {
|
func (h *Bridge) SelectSaveFile() string {
|
||||||
h.log.Warn("SelectSaveFile() unsupported in bridge mode")
|
h.log.Warn("SelectSaveFile() unsupported in bridge mode")
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
// Callback sends a callback to the frontend
|
// Callback sends a callback to the frontend
|
||||||
func (h *Headless) Callback(data string) error {
|
func (h *Bridge) Callback(data string) error {
|
||||||
return h.evalJS(data, callbackMessage)
|
return h.evalJS(data, callbackMessage)
|
||||||
}
|
}
|
||||||
|
|
||||||
// NotifyEvent notifies the frontend of an event
|
// NotifyEvent notifies the frontend of an event
|
||||||
func (h *Headless) NotifyEvent(event *messages.EventData) error {
|
func (h *Bridge) NotifyEvent(event *messages.EventData) error {
|
||||||
|
|
||||||
// Look out! Nils about!
|
// Look out! Nils about!
|
||||||
var err error
|
var err error
|
||||||
@@ -222,33 +222,33 @@ func (h *Headless) NotifyEvent(event *messages.EventData) error {
|
|||||||
return h.evalJS(message, notifyMessage)
|
return h.evalJS(message, notifyMessage)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetColour is unsupported for Headless but required
|
// SetColour is unsupported for Bridge but required
|
||||||
// for the Renderer interface
|
// for the Renderer interface
|
||||||
func (h *Headless) SetColour(colour string) error {
|
func (h *Bridge) SetColour(colour string) error {
|
||||||
h.log.WarnFields("SetColour ignored for headless more", logger.Fields{"col": colour})
|
h.log.WarnFields("SetColour ignored for Bridge more", logger.Fields{"col": colour})
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fullscreen is unsupported for Headless but required
|
// Fullscreen is unsupported for Bridge but required
|
||||||
// for the Renderer interface
|
// for the Renderer interface
|
||||||
func (h *Headless) Fullscreen() {
|
func (h *Bridge) Fullscreen() {
|
||||||
h.log.Warn("Fullscreen() unsupported in bridge mode")
|
h.log.Warn("Fullscreen() unsupported in bridge mode")
|
||||||
}
|
}
|
||||||
|
|
||||||
// UnFullscreen is unsupported for Headless but required
|
// UnFullscreen is unsupported for Bridge but required
|
||||||
// for the Renderer interface
|
// for the Renderer interface
|
||||||
func (h *Headless) UnFullscreen() {
|
func (h *Bridge) UnFullscreen() {
|
||||||
h.log.Warn("UnFullscreen() unsupported in bridge mode")
|
h.log.Warn("UnFullscreen() unsupported in bridge mode")
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetTitle is currently unsupported for Headless but required
|
// SetTitle is currently unsupported for Bridge but required
|
||||||
// for the Renderer interface
|
// for the Renderer interface
|
||||||
func (h *Headless) SetTitle(title string) {
|
func (h *Bridge) SetTitle(title string) {
|
||||||
h.log.WarnFields("SetTitle() unsupported in bridge mode", logger.Fields{"title": title})
|
h.log.WarnFields("SetTitle() unsupported in bridge mode", logger.Fields{"title": title})
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close is unsupported for Headless but required
|
// Close is unsupported for Bridge but required
|
||||||
// for the Renderer interface
|
// for the Renderer interface
|
||||||
func (h *Headless) Close() {
|
func (h *Bridge) Close() {
|
||||||
h.log.Warn("Close() unsupported in bridge mode")
|
h.log.Warn("Close() unsupported in bridge mode")
|
||||||
}
|
}
|
||||||
File diff suppressed because one or more lines are too long
@@ -10,9 +10,9 @@ import (
|
|||||||
|
|
||||||
"github.com/go-playground/colors"
|
"github.com/go-playground/colors"
|
||||||
"github.com/leaanthony/mewn"
|
"github.com/leaanthony/mewn"
|
||||||
|
"github.com/wailsapp/wails/lib/interfaces"
|
||||||
"github.com/wailsapp/wails/lib/logger"
|
"github.com/wailsapp/wails/lib/logger"
|
||||||
"github.com/wailsapp/wails/lib/messages"
|
"github.com/wailsapp/wails/lib/messages"
|
||||||
"github.com/wailsapp/wails/lib/interfaces"
|
|
||||||
"github.com/wailsapp/webview"
|
"github.com/wailsapp/webview"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -29,7 +29,7 @@ type WebView struct {
|
|||||||
|
|
||||||
// NewWebView returns a new WebView struct
|
// NewWebView returns a new WebView struct
|
||||||
func NewWebView() *WebView {
|
func NewWebView() *WebView {
|
||||||
return &WebView{};
|
return &WebView{}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialise sets up the WebView
|
// Initialise sets up the WebView
|
||||||
@@ -173,9 +173,13 @@ func (w *WebView) Run() error {
|
|||||||
w.log.Info("Run()")
|
w.log.Info("Run()")
|
||||||
|
|
||||||
// Runtime assets
|
// Runtime assets
|
||||||
wailsRuntime := mewn.String("../../runtime/js/dist/wails.js")
|
wailsRuntime := mewn.String("../../runtime/assets/wails.js")
|
||||||
|
w.log.Info("1")
|
||||||
|
|
||||||
w.evalJS(wailsRuntime)
|
w.evalJS(wailsRuntime)
|
||||||
|
|
||||||
|
w.log.Info("2")
|
||||||
|
|
||||||
// Ping the wait channel when the wails runtime is loaded
|
// Ping the wait channel when the wails runtime is loaded
|
||||||
w.eventManager.On("wails:loaded", func(...interface{}) {
|
w.eventManager.On("wails:loaded", func(...interface{}) {
|
||||||
|
|
||||||
|
|||||||
32
runtime.go
Normal file
32
runtime.go
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
package wails
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/wailsapp/wails/lib/interfaces"
|
||||||
|
"github.com/wailsapp/wails/lib/logger"
|
||||||
|
"github.com/wailsapp/wails/runtime"
|
||||||
|
)
|
||||||
|
|
||||||
|
// CustomLogger type alias
|
||||||
|
type CustomLogger = logger.CustomLogger
|
||||||
|
|
||||||
|
// Runtime is the Wails Runtime Interface, given to a user who has defined the WailsInit method
|
||||||
|
type Runtime struct {
|
||||||
|
Events *runtime.Events
|
||||||
|
Log *runtime.Log
|
||||||
|
Dialog *runtime.Dialog
|
||||||
|
Window *runtime.Window
|
||||||
|
Browser *runtime.Browser
|
||||||
|
FileSystem *runtime.FileSystem
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewRuntime creates a new Runtime struct
|
||||||
|
func NewRuntime(eventManager interfaces.EventManager, renderer interfaces.Renderer) *Runtime {
|
||||||
|
return &Runtime{
|
||||||
|
Events: runtime.NewEvents(eventManager),
|
||||||
|
Log: runtime.NewLog(),
|
||||||
|
Dialog: runtime.NewDialog(renderer),
|
||||||
|
Window: runtime.NewWindow(renderer),
|
||||||
|
Browser: runtime.NewBrowser(),
|
||||||
|
FileSystem: runtime.NewFileSystem(),
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,21 +1,15 @@
|
|||||||
/*
|
/*
|
||||||
Wails Bridge (c) 2019-present Lea Anthony
|
_ __ _ __
|
||||||
|
| | / /___ _(_) /____
|
||||||
This library creates a bridge between your application
|
| | /| / / __ `/ / / ___/
|
||||||
and the frontend, allowing you to develop your app using
|
| |/ |/ / /_/ / / (__ )
|
||||||
standard tooling (browser extensions, live reload, etc).
|
|__/|__/\__,_/_/_/____/
|
||||||
|
The lightweight framework for web-like apps
|
||||||
Usage:
|
(c) Lea Anthony 2019-present
|
||||||
```
|
|
||||||
import Bridge from "./wailsbridge";
|
|
||||||
Bridge.Start(startApp);
|
|
||||||
```
|
|
||||||
|
|
||||||
The given callback (startApp in the example) will be called
|
|
||||||
when the bridge has successfully initialised. It passes the
|
|
||||||
window.wails object back, in case it is not accessible directly.
|
|
||||||
*/
|
*/
|
||||||
|
/* jshint esversion: 6 */
|
||||||
|
|
||||||
|
function init() {
|
||||||
// Bridge object
|
// Bridge object
|
||||||
window.wailsbridge = {
|
window.wailsbridge = {
|
||||||
reconnectOverlay: null,
|
reconnectOverlay: null,
|
||||||
@@ -38,6 +32,7 @@ window.wailsbridge = {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
// Adapted from webview - thanks zserge!
|
// Adapted from webview - thanks zserge!
|
||||||
function injectCSS(css) {
|
function injectCSS(css) {
|
||||||
@@ -203,14 +198,20 @@ function startBridge() {
|
|||||||
connect();
|
connect();
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
function start(callback) {
|
||||||
// The main function
|
|
||||||
// Passes the main Wails object to the callback if given.
|
// Set up the bridge
|
||||||
Start: function (callback) {
|
init();
|
||||||
|
|
||||||
// Save the callback
|
// Save the callback
|
||||||
window.wailsbridge.callback = callback;
|
window.wailsbridge.callback = callback;
|
||||||
|
|
||||||
// Start Bridge
|
// Start Bridge
|
||||||
startBridge();
|
startBridge();
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
function Init(callback) {
|
||||||
|
start(callback);
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = { Init };
|
||||||
@@ -1,5 +1,18 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<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"></script></body>
|
<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>
|
</html>
|
||||||
1
runtime/assets/wails.js
Normal file
1
runtime/assets/wails.js
Normal file
@@ -0,0 +1 @@
|
|||||||
|
!function(n){var t={};function e(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return n[r].call(o.exports,o,o.exports,e),o.l=!0,o.exports}e.m=n,e.c=t,e.d=function(n,t,r){e.o(n,t)||Object.defineProperty(n,t,{enumerable:!0,get:r})},e.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})},e.t=function(n,t){if(1&t&&(n=e(n)),8&t)return n;if(4&t&&"object"==typeof n&&n&&n.__esModule)return n;var r=Object.create(null);if(e.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:n}),2&t&&"string"!=typeof n)for(var o in n)e.d(r,o,function(t){return n[t]}.bind(null,o));return r},e.n=function(n){var t=n&&n.__esModule?function(){return n.default}:function(){return n};return e.d(t,"a",t),t},e.o=function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},e.p="",e(e.s=0)}([function(n,t,e){"use strict";e.r(t);var r={};e.r(r),e.d(r,"Debug",function(){return c}),e.d(r,"Info",function(){return u}),e.d(r,"Warning",function(){return l}),e.d(r,"Error",function(){return f}),e.d(r,"Fatal",function(){return d});var o={};function a(n,t,e){var r={type:n,callbackID:e,payload:t};!function(n){window.external.invoke(n)}(JSON.stringify(r))}function i(n,t){a("log",{level:n,message:t})}function c(n){i("debug",n)}function u(n){i("info",n)}function l(n){i("warning",n)}function f(n){i("error",n)}function d(n){i("fatal",n)}e.r(o),e.d(o,"OpenURL",function(){return y}),e.d(o,"OpenFile",function(){return g});var s,p={};function v(n,t,e){return null!=e&&null!=e||(e=0),new Promise(function(r,o){var i;do{i=n+"-"+s()}while(p[i]);if(e>0)var c=setTimeout(function(){o(Error("Call to "+n+" timed out. Request ID: "+i))},e);p[i]={timeoutHandle:c,reject:o,resolve:r};try{a("call",{bindingName:n,data:JSON.stringify(t)},i)}catch(n){console.error(n)}})}function w(n,t){return v(".wails."+n,t)}function y(n){return w("Browser.OpenURL",n)}function g(n){return w("Browser.OpenFile",n)}s=window.crypto?function(){var n=new Uint32Array(1);return window.crypto.getRandomValues(n)[0]}:function(){return 9007199254740991*Math.random()};var m=function n(t,e){!function(n,t){if(!(n instanceof t))throw new TypeError("Cannot call a class as a function")}(this,n),e=e||-1,this.Callback=function(n){return t.apply(null,n),-1!==e&&0===(e-=1)}},b={};function h(n,t,e){b[n]=b[n]||[];var r=new m(t,e);b[n].push(r)}function O(n){a("event",{name:n,data:JSON.stringify([].slice.apply(arguments).slice(1))})}var S={};function j(n){try{return new Function("var "+n),!0}catch(n){return!1}}function k(){return(k=Object.assign||function(n){for(var t=1;t<arguments.length;t++){var e=arguments[t];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r])}return n}).apply(this,arguments)}window.backend={},e.d(t,"Init",function(){return N}),window.wails=window.wails||{},window.backend={};var E={NewBinding:function(n){var t=[].concat(n.split(".").splice(1)),e=window.backend;if(t.length>1)for(var r=0;r<t.length-1;r+=1){var o=t[r];if(!j(o))return new Error("".concat(o," is not a valid javascript identifier."));e[o]={},e=e[o]}var a=t.pop();if(!j(a))return new Error("".concat(a," is not a valid javascript identifier."));e[a]=function(){var t=0;function e(){var e=[].slice.call(arguments);return v(n,e,t)}return e.setTimeout=function(n){t=n},e.getTimeout=function(){return t},e}()},Callback:function(n){var t;n=decodeURIComponent(n.replace(/\s+/g,"").replace(/[0-9a-f]{2}/g,"%$&"));try{t=JSON.parse(n)}catch(t){var e="Invalid JSON passed to callback: ".concat(t.message,". Message: ").concat(n);throw c(e),new Error(e)}var r=t.callbackid,o=p[r];if(!o){var a="Callback '".concat(r,"' not registed!!!");throw console.error(a),new Error(a)}clearTimeout(o.timeoutHandle),delete p[r],t.error?o.reject(t.error):o.resolve(t.data)},Notify:function(n,t){if(b[n]){for(var e=b[n].slice(),r=0;r<b[n].length;r+=1){var o=b[n][r],a=[];if(t)try{a=JSON.parse(t)}catch(t){f("Invalid JSON data sent to notify. Event name = "+n)}o.Callback(a)&&e.splice(r,1)}b[n]=e}},AddScript:function(n,t){var e=document.createElement("script");e.text=n,document.body.appendChild(e),t&&O(t)},InjectCSS:function(n){var t=document.createElement("style");t.setAttribute("type","text/css"),t.styleSheet?t.styleSheet.cssText=n:t.appendChild(document.createTextNode(n)),(document.head||document.getElementsByTagName("head")[0]).appendChild(t)},Init:N},C={Log:r,Browser:o,Events:{On:function(n,t){h(n,t)},Emit:O,Heartbeat:function(n,t,e){var r=null;S[n]=function(){clearInterval(r),e()},r=setInterval(function(){O(n)},t)},Acknowledge:function(n){if(!S[n])throw new f("Cannot acknowledge unknown heartbeat '".concat(n,"'"));S[n]()}},_:E};function N(n){n()}k(window.wails,C),O("wails:loaded")}]);
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
/*
|
|
||||||
Wails Bridge (c) 2019-present Lea Anthony
|
|
||||||
|
|
||||||
This prod version is to get around having to rewrite your code
|
|
||||||
for production. When doing a release build, this file will be used
|
|
||||||
instead of the full version.
|
|
||||||
*/
|
|
||||||
|
|
||||||
export default {
|
|
||||||
// The main function
|
|
||||||
// Passes the main Wails object to the callback if given.
|
|
||||||
Start: function (callback) {
|
|
||||||
if (callback) {
|
|
||||||
window.wails.Events.On('wails:ready', callback);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@@ -7,8 +7,8 @@ type Dialog struct {
|
|||||||
renderer interfaces.Renderer
|
renderer interfaces.Renderer
|
||||||
}
|
}
|
||||||
|
|
||||||
// newDialog creates a new Dialog struct
|
// NewDialog creates a new Dialog struct
|
||||||
func newDialog(renderer interfaces.Renderer) *Dialog {
|
func NewDialog(renderer interfaces.Renderer) *Dialog {
|
||||||
return &Dialog{
|
return &Dialog{
|
||||||
renderer: renderer,
|
renderer: renderer,
|
||||||
}
|
}
|
||||||
@@ -7,7 +7,8 @@ type Events struct {
|
|||||||
eventManager interfaces.EventManager
|
eventManager interfaces.EventManager
|
||||||
}
|
}
|
||||||
|
|
||||||
func newEvents(eventManager interfaces.EventManager) *Events {
|
// NewEvents creates a new Events struct
|
||||||
|
func NewEvents(eventManager interfaces.EventManager) *Events {
|
||||||
return &Events{
|
return &Events{
|
||||||
eventManager: eventManager,
|
eventManager: eventManager,
|
||||||
}
|
}
|
||||||
@@ -5,8 +5,8 @@ import homedir "github.com/mitchellh/go-homedir"
|
|||||||
// FileSystem exposes file system utilities to the runtime
|
// FileSystem exposes file system utilities to the runtime
|
||||||
type FileSystem struct {}
|
type FileSystem struct {}
|
||||||
|
|
||||||
// Creates a new FileSystem struct
|
// NewFileSystem creates a new FileSystem struct
|
||||||
func newFileSystem() *FileSystem {
|
func NewFileSystem() *FileSystem {
|
||||||
return &FileSystem{}
|
return &FileSystem{}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
package runtime
|
|
||||||
|
|
||||||
import "github.com/wailsapp/wails/lib/interfaces"
|
|
||||||
|
|
||||||
// Runtime is the Wails Runtime Interface, given to a user who has defined the WailsInit method
|
|
||||||
type Runtime struct {
|
|
||||||
Events *Events
|
|
||||||
Log *Log
|
|
||||||
Dialog *Dialog
|
|
||||||
Window *Window
|
|
||||||
Browser *Browser
|
|
||||||
FileSystem *FileSystem
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewRuntime creates a new Runtime struct
|
|
||||||
func NewRuntime(eventManager interfaces.EventManager, renderer interfaces.Renderer) *Runtime {
|
|
||||||
return &Runtime{
|
|
||||||
Events: newEvents(eventManager),
|
|
||||||
Log: newLog(),
|
|
||||||
Dialog: newDialog(renderer),
|
|
||||||
Window: newWindow(renderer),
|
|
||||||
Browser: NewBrowser(),
|
|
||||||
FileSystem: newFileSystem(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,280 +1,31 @@
|
|||||||
{
|
{
|
||||||
"env": {
|
"env": {
|
||||||
"browser": true,
|
"browser": true,
|
||||||
"es6": true
|
"es6": true,
|
||||||
|
"amd": true,
|
||||||
|
"node": true,
|
||||||
},
|
},
|
||||||
"extends": "eslint:recommended",
|
"extends": "eslint:recommended",
|
||||||
"parserOptions": {
|
"parserOptions": {
|
||||||
"ecmaVersion": 2015,
|
"ecmaVersion": 2016,
|
||||||
"sourceType": "module"
|
"sourceType": "module",
|
||||||
},
|
},
|
||||||
"rules": {
|
"rules": {
|
||||||
"accessor-pairs": "error",
|
"indent": [
|
||||||
"array-bracket-newline": "error",
|
|
||||||
"array-bracket-spacing": [
|
|
||||||
"error",
|
"error",
|
||||||
"never"
|
"tab"
|
||||||
],
|
],
|
||||||
"array-callback-return": "error",
|
|
||||||
"array-element-newline": "off",
|
|
||||||
"arrow-body-style": "error",
|
|
||||||
"arrow-parens": "error",
|
|
||||||
"arrow-spacing": "error",
|
|
||||||
"block-scoped-var": "off",
|
|
||||||
"block-spacing": "error",
|
|
||||||
"brace-style": [
|
|
||||||
"error",
|
|
||||||
"1tbs"
|
|
||||||
],
|
|
||||||
"callback-return": "error",
|
|
||||||
"camelcase": "error",
|
|
||||||
"capitalized-comments": "off",
|
|
||||||
"class-methods-use-this": "error",
|
|
||||||
"comma-dangle": "off",
|
|
||||||
"comma-spacing": [
|
|
||||||
"error",
|
|
||||||
{
|
|
||||||
"after": true,
|
|
||||||
"before": false
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"comma-style": [
|
|
||||||
"error",
|
|
||||||
"last"
|
|
||||||
],
|
|
||||||
"complexity": "error",
|
|
||||||
"computed-property-spacing": [
|
|
||||||
"error",
|
|
||||||
"never"
|
|
||||||
],
|
|
||||||
"consistent-return": "off",
|
|
||||||
"consistent-this": "error",
|
|
||||||
"curly": "error",
|
|
||||||
"default-case": "error",
|
|
||||||
"dot-location": "error",
|
|
||||||
"dot-notation": "error",
|
|
||||||
"eol-last": "off",
|
|
||||||
"eqeqeq": "off",
|
|
||||||
"func-call-spacing": "error",
|
|
||||||
"func-name-matching": "error",
|
|
||||||
"func-names": [
|
|
||||||
"error",
|
|
||||||
"never"
|
|
||||||
],
|
|
||||||
"func-style": [
|
|
||||||
"error",
|
|
||||||
"declaration"
|
|
||||||
],
|
|
||||||
"function-paren-newline": "error",
|
|
||||||
"generator-star-spacing": "error",
|
|
||||||
"global-require": "error",
|
|
||||||
"guard-for-in": "off",
|
|
||||||
"handle-callback-err": "error",
|
|
||||||
"id-blacklist": "error",
|
|
||||||
"id-length": "off",
|
|
||||||
"id-match": "error",
|
|
||||||
"implicit-arrow-linebreak": "error",
|
|
||||||
"indent": "off",
|
|
||||||
"indent-legacy": "off",
|
|
||||||
"init-declarations": "off",
|
|
||||||
"jsx-quotes": "error",
|
|
||||||
"key-spacing": "error",
|
|
||||||
"keyword-spacing": [
|
|
||||||
"error",
|
|
||||||
{
|
|
||||||
"after": true,
|
|
||||||
"before": true
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"line-comment-position": "error",
|
|
||||||
"linebreak-style": [
|
"linebreak-style": [
|
||||||
"error",
|
"error",
|
||||||
"unix"
|
"unix"
|
||||||
],
|
],
|
||||||
"lines-around-comment": "error",
|
|
||||||
"lines-around-directive": "error",
|
|
||||||
"lines-between-class-members": "error",
|
|
||||||
"max-classes-per-file": "error",
|
|
||||||
"max-depth": "error",
|
|
||||||
"max-len": "off",
|
|
||||||
"max-lines": "error",
|
|
||||||
"max-lines-per-function": "error",
|
|
||||||
"max-nested-callbacks": "error",
|
|
||||||
"max-params": "error",
|
|
||||||
"max-statements": "off",
|
|
||||||
"max-statements-per-line": "error",
|
|
||||||
"multiline-comment-style": "off",
|
|
||||||
"multiline-ternary": "error",
|
|
||||||
"new-parens": "error",
|
|
||||||
"newline-after-var": "off",
|
|
||||||
"newline-before-return": "off",
|
|
||||||
"newline-per-chained-call": "error",
|
|
||||||
"no-alert": "error",
|
|
||||||
"no-array-constructor": "error",
|
|
||||||
"no-await-in-loop": "error",
|
|
||||||
"no-bitwise": "error",
|
|
||||||
"no-buffer-constructor": "error",
|
|
||||||
"no-caller": "error",
|
|
||||||
"no-catch-shadow": "error",
|
|
||||||
"no-confusing-arrow": "error",
|
|
||||||
"no-continue": "error",
|
|
||||||
"no-div-regex": "error",
|
|
||||||
"no-duplicate-imports": "error",
|
|
||||||
"no-else-return": "error",
|
|
||||||
"no-empty-function": "error",
|
|
||||||
"no-eq-null": "off",
|
|
||||||
"no-eval": "error",
|
|
||||||
"no-extend-native": "error",
|
|
||||||
"no-extra-bind": "error",
|
|
||||||
"no-extra-label": "error",
|
|
||||||
"no-extra-parens": "error",
|
|
||||||
"no-floating-decimal": "error",
|
|
||||||
"no-implicit-coercion": "error",
|
|
||||||
"no-implicit-globals": "error",
|
|
||||||
"no-implied-eval": "error",
|
|
||||||
"no-inline-comments": "error",
|
|
||||||
"no-inner-declarations": [
|
|
||||||
"error",
|
|
||||||
"functions"
|
|
||||||
],
|
|
||||||
"no-invalid-this": "error",
|
|
||||||
"no-iterator": "error",
|
|
||||||
"no-label-var": "error",
|
|
||||||
"no-labels": "error",
|
|
||||||
"no-lone-blocks": "error",
|
|
||||||
"no-lonely-if": "error",
|
|
||||||
"no-loop-func": "error",
|
|
||||||
"no-magic-numbers": "off",
|
|
||||||
"no-mixed-operators": "error",
|
|
||||||
"no-mixed-requires": "error",
|
|
||||||
"no-multi-assign": "error",
|
|
||||||
"no-multi-spaces": "error",
|
|
||||||
"no-multi-str": "error",
|
|
||||||
"no-multiple-empty-lines": "error",
|
|
||||||
"no-native-reassign": "error",
|
|
||||||
"no-negated-condition": "error",
|
|
||||||
"no-negated-in-lhs": "error",
|
|
||||||
"no-nested-ternary": "error",
|
|
||||||
"no-new": "off",
|
|
||||||
"no-new-func": "off",
|
|
||||||
"no-new-object": "error",
|
|
||||||
"no-new-require": "error",
|
|
||||||
"no-new-wrappers": "error",
|
|
||||||
"no-octal-escape": "error",
|
|
||||||
"no-param-reassign": "off",
|
|
||||||
"no-path-concat": "error",
|
|
||||||
"no-plusplus": "error",
|
|
||||||
"no-process-env": "error",
|
|
||||||
"no-process-exit": "error",
|
|
||||||
"no-proto": "error",
|
|
||||||
"no-prototype-builtins": "error",
|
|
||||||
"no-restricted-globals": "error",
|
|
||||||
"no-restricted-imports": "error",
|
|
||||||
"no-restricted-modules": "error",
|
|
||||||
"no-restricted-properties": "error",
|
|
||||||
"no-restricted-syntax": "error",
|
|
||||||
"no-return-assign": "error",
|
|
||||||
"no-return-await": "error",
|
|
||||||
"no-script-url": "error",
|
|
||||||
"no-self-compare": "error",
|
|
||||||
"no-sequences": "error",
|
|
||||||
"no-shadow": "error",
|
|
||||||
"no-shadow-restricted-names": "error",
|
|
||||||
"no-spaced-func": "error",
|
|
||||||
"no-sync": "error",
|
|
||||||
"no-tabs": "error",
|
|
||||||
"no-template-curly-in-string": "error",
|
|
||||||
"no-ternary": "error",
|
|
||||||
"no-throw-literal": "error",
|
|
||||||
"no-undef-init": "error",
|
|
||||||
"no-undefined": "off",
|
|
||||||
"no-underscore-dangle": "error",
|
|
||||||
"no-unmodified-loop-condition": "error",
|
|
||||||
"no-unneeded-ternary": "error",
|
|
||||||
"no-unused-expressions": "error",
|
|
||||||
"no-use-before-define": "error",
|
|
||||||
"no-useless-call": "error",
|
|
||||||
"no-useless-computed-key": "error",
|
|
||||||
"no-useless-concat": "error",
|
|
||||||
"no-useless-constructor": "error",
|
|
||||||
"no-useless-rename": "error",
|
|
||||||
"no-useless-return": "error",
|
|
||||||
"no-var": "off",
|
|
||||||
"no-void": "error",
|
|
||||||
"no-warning-comments": "error",
|
|
||||||
"no-whitespace-before-property": "error",
|
|
||||||
"no-with": "error",
|
|
||||||
"nonblock-statement-body-position": "error",
|
|
||||||
"object-curly-newline": "error",
|
|
||||||
"object-curly-spacing": [
|
|
||||||
"error",
|
|
||||||
"always"
|
|
||||||
],
|
|
||||||
"object-property-newline": "error",
|
|
||||||
"object-shorthand": "off",
|
|
||||||
"one-var": "off",
|
|
||||||
"one-var-declaration-per-line": "error",
|
|
||||||
"operator-assignment": "error",
|
|
||||||
"operator-linebreak": "error",
|
|
||||||
"padded-blocks": "off",
|
|
||||||
"padding-line-between-statements": "error",
|
|
||||||
"prefer-arrow-callback": "off",
|
|
||||||
"prefer-const": "error",
|
|
||||||
"prefer-destructuring": "off",
|
|
||||||
"prefer-numeric-literals": "error",
|
|
||||||
"prefer-object-spread": "error",
|
|
||||||
"prefer-promise-reject-errors": "error",
|
|
||||||
"prefer-reflect": "off",
|
|
||||||
"prefer-rest-params": "off",
|
|
||||||
"prefer-spread": "off",
|
|
||||||
"prefer-template": "off",
|
|
||||||
"quote-props": "off",
|
|
||||||
"quotes": [
|
"quotes": [
|
||||||
"error",
|
"error",
|
||||||
"single"
|
"single"
|
||||||
],
|
],
|
||||||
"radix": "error",
|
"semi": [
|
||||||
"require-await": "error",
|
|
||||||
"require-jsdoc": "off",
|
|
||||||
"rest-spread-spacing": "error",
|
|
||||||
"semi": "off",
|
|
||||||
"semi-spacing": "error",
|
|
||||||
"semi-style": [
|
|
||||||
"error",
|
|
||||||
"last"
|
|
||||||
],
|
|
||||||
"sort-imports": "off",
|
|
||||||
"sort-keys": "off",
|
|
||||||
"sort-vars": "error",
|
|
||||||
"space-before-blocks": "error",
|
|
||||||
"space-before-function-paren": "off",
|
|
||||||
"space-in-parens": [
|
|
||||||
"error",
|
|
||||||
"never"
|
|
||||||
],
|
|
||||||
"space-infix-ops": "error",
|
|
||||||
"space-unary-ops": "error",
|
|
||||||
"spaced-comment": [
|
|
||||||
"error",
|
"error",
|
||||||
"always"
|
"always"
|
||||||
],
|
|
||||||
"strict": "error",
|
|
||||||
"switch-colon-spacing": "error",
|
|
||||||
"symbol-description": "error",
|
|
||||||
"template-curly-spacing": "error",
|
|
||||||
"template-tag-spacing": "error",
|
|
||||||
"unicode-bom": [
|
|
||||||
"error",
|
|
||||||
"never"
|
|
||||||
],
|
|
||||||
"valid-jsdoc": "error",
|
|
||||||
"vars-on-top": "off",
|
|
||||||
"wrap-iife": "off",
|
|
||||||
"wrap-regex": "error",
|
|
||||||
"yield-star-spacing": "error",
|
|
||||||
"yoda": [
|
|
||||||
"error",
|
|
||||||
"never"
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -13,7 +13,12 @@ import { Call } from './calls';
|
|||||||
|
|
||||||
window.backend = {};
|
window.backend = {};
|
||||||
|
|
||||||
// Determines if the given identifier is valid Javascript
|
/**
|
||||||
|
* Determines if the given identifier is valid Javascript
|
||||||
|
*
|
||||||
|
* @param {boolean} name
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
function isValidIdentifier(name) {
|
function isValidIdentifier(name) {
|
||||||
// Don't xss yourself :-)
|
// Don't xss yourself :-)
|
||||||
try {
|
try {
|
||||||
@@ -24,6 +29,13 @@ function isValidIdentifier(name) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* NewBinding creates a new binding from the given binding name
|
||||||
|
*
|
||||||
|
* @export
|
||||||
|
* @param {string} bindingName
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
// eslint-disable-next-line max-lines-per-function
|
// eslint-disable-next-line max-lines-per-function
|
||||||
export function NewBinding(bindingName) {
|
export function NewBinding(bindingName) {
|
||||||
|
|
||||||
@@ -11,10 +11,24 @@ The lightweight framework for web-like apps
|
|||||||
|
|
||||||
import { SystemCall } from './calls';
|
import { SystemCall } from './calls';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Opens the given URL in the system browser
|
||||||
|
*
|
||||||
|
* @export
|
||||||
|
* @param {string} url
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
export function OpenURL(url) {
|
export function OpenURL(url) {
|
||||||
return SystemCall('Browser.OpenURL', url);
|
return SystemCall('Browser.OpenURL', url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Opens the given filename using the system's default file handler
|
||||||
|
*
|
||||||
|
* @export
|
||||||
|
* @param {sting} filename
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
export function OpenFile(filename) {
|
export function OpenFile(filename) {
|
||||||
return SystemCall('Browser.OpenFile', filename);
|
return SystemCall('Browser.OpenFile', filename);
|
||||||
}
|
}
|
||||||
@@ -14,18 +14,27 @@ import { SendMessage } from './ipc';
|
|||||||
|
|
||||||
var callbacks = {};
|
var callbacks = {};
|
||||||
|
|
||||||
// AwesomeRandom
|
/**
|
||||||
|
* Returns a number from the native browser random function
|
||||||
|
*
|
||||||
|
* @returns number
|
||||||
|
*/
|
||||||
function cryptoRandom() {
|
function cryptoRandom() {
|
||||||
var array = new Uint32Array(1);
|
var array = new Uint32Array(1);
|
||||||
return window.crypto.getRandomValues(array)[0];
|
return window.crypto.getRandomValues(array)[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
// LOLRandom
|
/**
|
||||||
|
* Returns a number using da old-skool Math.Random
|
||||||
|
* I likes to call it LOLRandom
|
||||||
|
*
|
||||||
|
* @returns number
|
||||||
|
*/
|
||||||
function basicRandom() {
|
function basicRandom() {
|
||||||
return Math.random() * 9007199254740991;
|
return Math.random() * 9007199254740991;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pick one based on browser capability
|
// Pick a random number function based on browser capability
|
||||||
var randomFunc;
|
var randomFunc;
|
||||||
if (window.crypto) {
|
if (window.crypto) {
|
||||||
randomFunc = cryptoRandom;
|
randomFunc = cryptoRandom;
|
||||||
@@ -34,13 +43,22 @@ if (window.crypto) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Call sends a message to the backend to call the binding with the
|
|
||||||
// given data. A promise is returned and will be completed when the
|
|
||||||
// backend responds. This will be resolved when the call was successful
|
|
||||||
// or rejected if an error is passed back.
|
|
||||||
// There is a timeout mechanism. If the call doesn't respond in the given
|
|
||||||
// time (in milliseconds) then the promise is rejected.
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call sends a message to the backend to call the binding with the
|
||||||
|
* given data. A promise is returned and will be completed when the
|
||||||
|
* backend responds. This will be resolved when the call was successful
|
||||||
|
* or rejected if an error is passed back.
|
||||||
|
* There is a timeout mechanism. If the call doesn't respond in the given
|
||||||
|
* time (in milliseconds) then the promise is rejected.
|
||||||
|
*
|
||||||
|
* @export
|
||||||
|
* @param {string} bindingName
|
||||||
|
* @param {string} data
|
||||||
|
* @param {number=} timeout
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
export function Call(bindingName, data, timeout) {
|
export function Call(bindingName, data, timeout) {
|
||||||
|
|
||||||
// Timeout infinite by default
|
// Timeout infinite by default
|
||||||
@@ -87,8 +105,14 @@ export function Call(bindingName, data, timeout) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Called by the backend to return data to a previously called
|
|
||||||
// binding invocation
|
/**
|
||||||
|
* Called by the backend to return data to a previously called
|
||||||
|
* binding invocation
|
||||||
|
*
|
||||||
|
* @export
|
||||||
|
* @param {string} incomingMessage
|
||||||
|
*/
|
||||||
export function Callback(incomingMessage) {
|
export function Callback(incomingMessage) {
|
||||||
|
|
||||||
// Decode the message - Credit: https://stackoverflow.com/a/13865680
|
// Decode the message - Credit: https://stackoverflow.com/a/13865680
|
||||||
@@ -115,12 +139,20 @@ export function Callback(incomingMessage) {
|
|||||||
delete callbacks[callbackID];
|
delete callbacks[callbackID];
|
||||||
|
|
||||||
if (message.error) {
|
if (message.error) {
|
||||||
return callbackData.reject(message.error);
|
callbackData.reject(message.error);
|
||||||
|
} else {
|
||||||
|
callbackData.resolve(message.data);
|
||||||
}
|
}
|
||||||
return callbackData.resolve(message.data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// systemCall is used to call wails methods from the frontend
|
/**
|
||||||
|
* SystemCall is used to call wails methods from the frontend
|
||||||
|
*
|
||||||
|
* @export
|
||||||
|
* @param {string} method
|
||||||
|
* @param {any[]=} data
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
export function SystemCall(method, data) {
|
export function SystemCall(method, data) {
|
||||||
return Call('.wails.' + method, data);
|
return Call('.wails.' + method, data);
|
||||||
}
|
}
|
||||||
@@ -13,7 +13,18 @@ import { Error } from './log';
|
|||||||
import { SendMessage } from './ipc';
|
import { SendMessage } from './ipc';
|
||||||
|
|
||||||
// Defines a single listener with a maximum number of times to callback
|
// Defines a single listener with a maximum number of times to callback
|
||||||
|
/**
|
||||||
|
* The Listener class defines a listener! :-)
|
||||||
|
*
|
||||||
|
* @class Listener
|
||||||
|
*/
|
||||||
class Listener {
|
class Listener {
|
||||||
|
/**
|
||||||
|
* Creates an instance of Listener.
|
||||||
|
* @param {function} callback
|
||||||
|
* @param {number} maxCallbacks
|
||||||
|
* @memberof Listener
|
||||||
|
*/
|
||||||
constructor(callback, maxCallbacks) {
|
constructor(callback, maxCallbacks) {
|
||||||
// Default of -1 means infinite
|
// Default of -1 means infinite
|
||||||
maxCallbacks = maxCallbacks || -1;
|
maxCallbacks = maxCallbacks || -1;
|
||||||
@@ -34,24 +45,49 @@ class Listener {
|
|||||||
|
|
||||||
var eventListeners = {};
|
var eventListeners = {};
|
||||||
|
|
||||||
// Registers an event listener that will be invoked `maxCallbacks` times before being destroyed
|
/**
|
||||||
|
* Registers an event listener that will be invoked `maxCallbacks` times before being destroyed
|
||||||
|
*
|
||||||
|
* @export
|
||||||
|
* @param {string} eventName
|
||||||
|
* @param {function} callback
|
||||||
|
* @param {number} maxCallbacks
|
||||||
|
*/
|
||||||
export function OnMultiple(eventName, callback, maxCallbacks) {
|
export function OnMultiple(eventName, callback, maxCallbacks) {
|
||||||
eventListeners[eventName] = eventListeners[eventName] || [];
|
eventListeners[eventName] = eventListeners[eventName] || [];
|
||||||
const thisListener = new Listener(callback, maxCallbacks);
|
const thisListener = new Listener(callback, maxCallbacks);
|
||||||
eventListeners[eventName].push(thisListener);
|
eventListeners[eventName].push(thisListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Registers an event listener that will be invoked every time the event is emitted
|
/**
|
||||||
|
* Registers an event listener that will be invoked every time the event is emitted
|
||||||
|
*
|
||||||
|
* @export
|
||||||
|
* @param {string} eventName
|
||||||
|
* @param {function} callback
|
||||||
|
*/
|
||||||
export function On(eventName, callback) {
|
export function On(eventName, callback) {
|
||||||
OnMultiple(eventName, callback);
|
OnMultiple(eventName, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Registers an event listener that will be invoked once then destroyed
|
/**
|
||||||
|
* Registers an event listener that will be invoked once then destroyed
|
||||||
|
*
|
||||||
|
* @export
|
||||||
|
* @param {string} eventName
|
||||||
|
* @param {function} callback
|
||||||
|
*/
|
||||||
export function Once(eventName, callback) {
|
export function Once(eventName, callback) {
|
||||||
OnMultiple(eventName, callback, 1);
|
OnMultiple(eventName, callback, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Notify informs frontend listeners that an event was emitted with the given data
|
/**
|
||||||
|
* Notify informs frontend listeners that an event was emitted with the given data
|
||||||
|
*
|
||||||
|
* @export
|
||||||
|
* @param {string} eventName
|
||||||
|
* @param {string} data
|
||||||
|
*/
|
||||||
export function Notify(eventName, data) {
|
export function Notify(eventName, data) {
|
||||||
|
|
||||||
// Check if we have any listeners for this event
|
// Check if we have any listeners for this event
|
||||||
@@ -88,7 +124,12 @@ export function Notify(eventName, data) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Emit an event with the given name and data
|
/**
|
||||||
|
* Emit an event with the given name and data
|
||||||
|
*
|
||||||
|
* @export
|
||||||
|
* @param {string} eventName
|
||||||
|
*/
|
||||||
export function Emit(eventName) {
|
export function Emit(eventName) {
|
||||||
|
|
||||||
// Calculate the data
|
// Calculate the data
|
||||||
@@ -102,10 +143,18 @@ export function Emit(eventName) {
|
|||||||
SendMessage('event', payload);
|
SendMessage('event', payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Callbacks for the heartbeat calls
|
||||||
const heartbeatCallbacks = {};
|
const heartbeatCallbacks = {};
|
||||||
|
|
||||||
// Heartbeat emits the event `eventName`, every `timeInMilliseconds` milliseconds until
|
/**
|
||||||
// the event is acknowledged via `Event.Acknowledge`. Once this happens, `callback` is invoked ONCE
|
* Heartbeat emits the event `eventName`, every `timeInMilliseconds` milliseconds until
|
||||||
|
* the event is acknowledged via `Event.Acknowledge`. Once this happens, `callback` is invoked ONCE
|
||||||
|
*
|
||||||
|
* @export
|
||||||
|
* @param {string} eventName
|
||||||
|
* @param {number} timeInMilliseconds
|
||||||
|
* @param {function} callback
|
||||||
|
*/
|
||||||
export function Heartbeat(eventName, timeInMilliseconds, callback) {
|
export function Heartbeat(eventName, timeInMilliseconds, callback) {
|
||||||
|
|
||||||
// Declare interval variable
|
// Declare interval variable
|
||||||
@@ -128,6 +177,12 @@ export function Heartbeat(eventName, timeInMilliseconds, callback) {
|
|||||||
}, timeInMilliseconds);
|
}, timeInMilliseconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Acknowledges a heartbeat event by name
|
||||||
|
*
|
||||||
|
* @export
|
||||||
|
* @param {string} eventName
|
||||||
|
*/
|
||||||
export function Acknowledge(eventName) {
|
export function Acknowledge(eventName) {
|
||||||
// If we are waiting for acknowledgement for this event type
|
// If we are waiting for acknowledgement for this event type
|
||||||
if (heartbeatCallbacks[eventName]) {
|
if (heartbeatCallbacks[eventName]) {
|
||||||
@@ -9,14 +9,23 @@ The lightweight framework for web-like apps
|
|||||||
*/
|
*/
|
||||||
/* jshint esversion: 6 */
|
/* jshint esversion: 6 */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Invoke sends the given message to the backend
|
||||||
|
*
|
||||||
|
* @param {string} message
|
||||||
|
*/
|
||||||
function Invoke(message) {
|
function Invoke(message) {
|
||||||
if (window && window.external && window.external.invoke) {
|
|
||||||
window.external.invoke(message);
|
window.external.invoke(message);
|
||||||
} else {
|
|
||||||
console.log(`[No external.invoke] ${message}`); // eslint-disable-line
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends a message to the backend based on the given type, payload and callbackID
|
||||||
|
*
|
||||||
|
* @export
|
||||||
|
* @param {string} type
|
||||||
|
* @param {string} payload
|
||||||
|
* @param {string=} callbackID
|
||||||
|
*/
|
||||||
export function SendMessage(type, payload, callbackID) {
|
export function SendMessage(type, payload, callbackID) {
|
||||||
const message = {
|
const message = {
|
||||||
type,
|
type,
|
||||||
@@ -7,12 +7,17 @@
|
|||||||
The lightweight framework for web-like apps
|
The lightweight framework for web-like apps
|
||||||
(c) Lea Anthony 2019-present
|
(c) Lea Anthony 2019-present
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* jshint esversion: 6 */
|
/* jshint esversion: 6 */
|
||||||
|
|
||||||
import { SendMessage } from './ipc';
|
import { SendMessage } from './ipc';
|
||||||
|
|
||||||
// Sends a log message to the backend with the given
|
/**
|
||||||
// level + message
|
* Sends a log message to the backend with the given level + message
|
||||||
|
*
|
||||||
|
* @param {string} level
|
||||||
|
* @param {string} message
|
||||||
|
*/
|
||||||
function sendLogMessage(level, message) {
|
function sendLogMessage(level, message) {
|
||||||
|
|
||||||
// Log Message
|
// Log Message
|
||||||
@@ -23,22 +28,52 @@ function sendLogMessage(level, message) {
|
|||||||
SendMessage('log', payload);
|
SendMessage('log', payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log the given debug message with the backend
|
||||||
|
*
|
||||||
|
* @export
|
||||||
|
* @param {string} message
|
||||||
|
*/
|
||||||
export function Debug(message) {
|
export function Debug(message) {
|
||||||
sendLogMessage('debug', message);
|
sendLogMessage('debug', message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log the given info message with the backend
|
||||||
|
*
|
||||||
|
* @export
|
||||||
|
* @param {string} message
|
||||||
|
*/
|
||||||
export function Info(message) {
|
export function Info(message) {
|
||||||
sendLogMessage('info', message);
|
sendLogMessage('info', message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log the given warning message with the backend
|
||||||
|
*
|
||||||
|
* @export
|
||||||
|
* @param {string} message
|
||||||
|
*/
|
||||||
export function Warning(message) {
|
export function Warning(message) {
|
||||||
sendLogMessage('warning', message);
|
sendLogMessage('warning', message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log the given error message with the backend
|
||||||
|
*
|
||||||
|
* @export
|
||||||
|
* @param {string} message
|
||||||
|
*/
|
||||||
export function Error(message) {
|
export function Error(message) {
|
||||||
sendLogMessage('error', message);
|
sendLogMessage('error', message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log the given fatal message with the backend
|
||||||
|
*
|
||||||
|
* @export
|
||||||
|
* @param {string} message
|
||||||
|
*/
|
||||||
export function Fatal(message) {
|
export function Fatal(message) {
|
||||||
sendLogMessage('fatal', message);
|
sendLogMessage('fatal', message);
|
||||||
}
|
}
|
||||||
@@ -9,6 +9,7 @@ The lightweight framework for web-like apps
|
|||||||
*/
|
*/
|
||||||
/* jshint esversion: 6 */
|
/* jshint esversion: 6 */
|
||||||
import * as Log from './log';
|
import * as Log from './log';
|
||||||
|
import * as Browser from './browser';
|
||||||
import { On, Emit, Notify, Heartbeat, Acknowledge } from './events';
|
import { On, Emit, Notify, Heartbeat, Acknowledge } from './events';
|
||||||
import { NewBinding } from './bindings';
|
import { NewBinding } from './bindings';
|
||||||
import { Callback } from './calls';
|
import { Callback } from './calls';
|
||||||
@@ -24,12 +25,14 @@ var internal = {
|
|||||||
Callback,
|
Callback,
|
||||||
Notify,
|
Notify,
|
||||||
AddScript,
|
AddScript,
|
||||||
InjectCSS
|
InjectCSS,
|
||||||
|
Init,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Setup runtime structure
|
// Setup runtime structure
|
||||||
var runtime = {
|
var runtime = {
|
||||||
Log,
|
Log,
|
||||||
|
Browser,
|
||||||
Events: {
|
Events: {
|
||||||
On,
|
On,
|
||||||
Emit,
|
Emit,
|
||||||
@@ -44,3 +47,8 @@ Object.assign(window.wails, runtime);
|
|||||||
|
|
||||||
// Emit loaded event
|
// Emit loaded event
|
||||||
Emit('wails:loaded');
|
Emit('wails:loaded');
|
||||||
|
|
||||||
|
// Nothing to init in production
|
||||||
|
export function Init(callback) {
|
||||||
|
callback();
|
||||||
|
}
|
||||||
1
runtime/js/dist/wails.js
vendored
1
runtime/js/dist/wails.js
vendored
@@ -1 +0,0 @@
|
|||||||
!function(n){var e={};function t(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return n[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}t.m=n,t.c=e,t.d=function(n,e,r){t.o(n,e)||Object.defineProperty(n,e,{enumerable:!0,get:r})},t.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})},t.t=function(n,e){if(1&e&&(n=t(n)),8&e)return n;if(4&e&&"object"==typeof n&&n&&n.__esModule)return n;var r=Object.create(null);if(t.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:n}),2&e&&"string"!=typeof n)for(var o in n)t.d(r,o,function(e){return n[e]}.bind(null,o));return r},t.n=function(n){var e=n&&n.__esModule?function(){return n.default}:function(){return n};return t.d(e,"a",e),e},t.o=function(n,e){return Object.prototype.hasOwnProperty.call(n,e)},t.p="",t(t.s=0)}([function(n,e,t){"use strict";t.r(e);var r={};function o(n,e,t){!function(n){window&&window.external&&window.external.invoke?window.external.invoke(n):console.log("[No external.invoke] ".concat(n))}(JSON.stringify({type:n,callbackID:t,payload:e}))}function a(n,e){o("log",{level:n,message:e})}function i(n){a("debug",n)}function c(n){a("info",n)}function u(n){a("warning",n)}function l(n){a("error",n)}function f(n){a("fatal",n)}t.r(r),t.d(r,"Debug",function(){return i}),t.d(r,"Info",function(){return c}),t.d(r,"Warning",function(){return u}),t.d(r,"Error",function(){return l}),t.d(r,"Fatal",function(){return f});var d=function n(e,t){(function(n,e){if(!(n instanceof e))throw new TypeError("Cannot call a class as a function")})(this,n),t=t||-1,this.Callback=function(n){return e.apply(null,n),-1!==t&&0===(t-=1)}},s={};function p(n,e,t){s[n]=s[n]||[];var r=new d(e,t);s[n].push(r)}function v(n){o("event",{name:n,data:JSON.stringify([].slice.apply(arguments).slice(1))})}var w={};var y={};var g=window.crypto?function(){var n=new Uint32Array(1);return window.crypto.getRandomValues(n)[0]}:function(){return 9007199254740991*Math.random()};function m(n,e,t){return(null==t||null==t)&&(t=0),new Promise(function(r,a){var i;do{i=n+"-"+g()}while(y[i]);if(0<t)var c=setTimeout(function(){a(Error("Call to "+n+" timed out. Request ID: "+i))},t);y[i]={timeoutHandle:c,reject:a,resolve:r};try{o("call",{bindingName:n,data:JSON.stringify(e)},i)}catch(n){console.error(n)}})}function b(n){try{return new Function("var "+n),!0}catch(n){return!1}}function h(){return(h=Object.assign||function(n){for(var e,t=1;t<arguments.length;t++)for(var r in e=arguments[t])Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n}).apply(this,arguments)}window.backend={},window.wails=window.wails||{},window.backend={};var O={NewBinding:function(n){var e=[].concat(n.split(".").splice(1)),t=window.backend;if(1<e.length)for(var r,o=0;o<e.length-1;o+=1){if(!b(r=e[o]))return new Error("".concat(r," is not a valid javascript identifier."));t[r]={},t=t[r]}var a=e.pop();return b(a)?void(t[a]=function(){function e(){var e=[].slice.call(arguments);return m(n,e,t)}var t=0;return e.setTimeout=function(n){t=n},e.getTimeout=function(){return t},e}()):new Error("".concat(a," is not a valid javascript identifier."))},Callback:function(n){var e;n=decodeURIComponent(n.replace(/\s+/g,"").replace(/[0-9a-f]{2}/g,"%$&"));try{e=JSON.parse(n)}catch(e){return i("Invalid JSON passed to callback: "+e.message),void i("Message: "+n)}var t=e.callbackid,r=y[t];return r?(clearTimeout(r.timeoutHandle),delete y[t],e.error?r.reject(e.error):r.resolve(e.data)):void console.error("Callback '".concat(t,"' not registed!!!"))},Notify:function(n,e){if(s[n]){for(var t=s[n].slice(),r=0;r<s[n].length;r+=1){var o=s[n][r],a=[];if(e)try{a=JSON.parse(e)}catch(e){l("Invalid JSON data sent to notify. Event name = "+n)}o.Callback(a)&&t.splice(r,1)}s[n]=t}},AddScript:function(n,e){var t=document.createElement("script");t.text=n,document.body.appendChild(t),e&&v(e)},InjectCSS:function(n){var e=document.createElement("style");e.setAttribute("type","text/css"),e.styleSheet?e.styleSheet.cssText=n:e.appendChild(document.createTextNode(n)),(document.head||document.getElementsByTagName("head")[0]).appendChild(e)}},S={Log:r,Events:{On:function(n,e){p(n,e)},Emit:v,Heartbeat:function(n,e,t){var r=null;w[n]=function(){clearInterval(r),t()},r=setInterval(function(){v(n)},e)},Acknowledge:function(n){if(!w[n])throw new l("Cannot acknowledge unknown heartbeat '".concat(n,"'"));w[n]()}},_:O};h(window.wails,S),v("wails:loaded")}]);
|
|
||||||
@@ -4,7 +4,8 @@
|
|||||||
"description": "The Javascript Wails Runtime",
|
"description": "The Javascript Wails Runtime",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "eslint src/ && webpack --config webpack.config.js",
|
"build": "eslint core/ && npm run build:prod",
|
||||||
|
"build:prod": "webpack --env prod --colors",
|
||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|||||||
1
runtime/js/runtime/.npmignore
Normal file
1
runtime/js/runtime/.npmignore
Normal file
@@ -0,0 +1 @@
|
|||||||
|
bridge.js
|
||||||
3
runtime/js/runtime/README.md
Normal file
3
runtime/js/runtime/README.md
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
# Wails Runtime
|
||||||
|
|
||||||
|
This module is the Javascript runtime library for the [Wails](https://wails.app) framework. It is intended to be installed as part of a [Wails](https://wails.app) project, not a standalone module.
|
||||||
37
runtime/js/runtime/browser.js
Normal file
37
runtime/js/runtime/browser.js
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
_ __ _ __
|
||||||
|
| | / /___ _(_) /____
|
||||||
|
| | /| / / __ `/ / / ___/
|
||||||
|
| |/ |/ / /_/ / / (__ )
|
||||||
|
|__/|__/\__,_/_/_/____/
|
||||||
|
The lightweight framework for web-like apps
|
||||||
|
(c) Lea Anthony 2019-present
|
||||||
|
*/
|
||||||
|
/* jshint esversion: 6 */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Opens the given URL in the system browser
|
||||||
|
*
|
||||||
|
* @export
|
||||||
|
* @param {string} url
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
function OpenURL(url) {
|
||||||
|
return window.wails.Browser.OpenURL(url);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Opens the given filename using the system's default file handler
|
||||||
|
*
|
||||||
|
* @export
|
||||||
|
* @param {sting} filename
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
function OpenFile(filename) {
|
||||||
|
return window.wails.Browser.OpenFile(filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
OpenURL,
|
||||||
|
OpenFile
|
||||||
|
};
|
||||||
89
runtime/js/runtime/events.js
Normal file
89
runtime/js/runtime/events.js
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
/*
|
||||||
|
_ __ _ __
|
||||||
|
| | / /___ _(_) /____
|
||||||
|
| | /| / / __ `/ / / ___/
|
||||||
|
| |/ |/ / /_/ / / (__ )
|
||||||
|
|__/|__/\__,_/_/_/____/
|
||||||
|
The lightweight framework for web-like apps
|
||||||
|
(c) Lea Anthony 2019-present
|
||||||
|
*/
|
||||||
|
/* jshint esversion: 6 */
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers an event listener that will be invoked `maxCallbacks` times before being destroyed
|
||||||
|
*
|
||||||
|
* @export
|
||||||
|
* @param {string} eventName
|
||||||
|
* @param {function} callback
|
||||||
|
* @param {number} maxCallbacks
|
||||||
|
*/
|
||||||
|
function OnMultiple(eventName, callback, maxCallbacks) {
|
||||||
|
window.wails.Events.OnMultiple(eventName, callback, maxCallbacks);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers an event listener that will be invoked every time the event is emitted
|
||||||
|
*
|
||||||
|
* @export
|
||||||
|
* @param {string} eventName
|
||||||
|
* @param {function} callback
|
||||||
|
*/
|
||||||
|
function On(eventName, callback) {
|
||||||
|
OnMultiple(eventName, callback);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers an event listener that will be invoked once then destroyed
|
||||||
|
*
|
||||||
|
* @export
|
||||||
|
* @param {string} eventName
|
||||||
|
* @param {function} callback
|
||||||
|
*/
|
||||||
|
function Once(eventName, callback) {
|
||||||
|
OnMultiple(eventName, callback, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Emit an event with the given name and data
|
||||||
|
*
|
||||||
|
* @export
|
||||||
|
* @param {string} eventName
|
||||||
|
*/
|
||||||
|
function Emit(eventName) {
|
||||||
|
return window.wails.Events.Emit(eventName);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Heartbeat emits the event `eventName`, every `timeInMilliseconds` milliseconds until
|
||||||
|
* the event is acknowledged via `Event.Acknowledge`. Once this happens, `callback` is invoked ONCE
|
||||||
|
*
|
||||||
|
* @export
|
||||||
|
* @param {*} eventName
|
||||||
|
* @param {*} timeInMilliseconds
|
||||||
|
* @param {*} callback
|
||||||
|
*/
|
||||||
|
function Heartbeat(eventName, timeInMilliseconds, callback) {
|
||||||
|
window.wails.Events.Heartbeat(eventName, timeInMilliseconds, callback);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Acknowledges a heartbeat event by name
|
||||||
|
*
|
||||||
|
* @export
|
||||||
|
* @param {string} eventName
|
||||||
|
*/
|
||||||
|
function Acknowledge(eventName) {
|
||||||
|
return window.wails.Events.Acknowledge(eventName);
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
OnMultiple,
|
||||||
|
On,
|
||||||
|
Once,
|
||||||
|
Emit,
|
||||||
|
Heartbeat,
|
||||||
|
Acknowledge
|
||||||
|
};
|
||||||
23
runtime/js/runtime/init.js
Normal file
23
runtime/js/runtime/init.js
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
/*
|
||||||
|
_ __ _ __
|
||||||
|
| | / /___ _(_) /____
|
||||||
|
| | /| / / __ `/ / / ___/
|
||||||
|
| |/ |/ / /_/ / / (__ )
|
||||||
|
|__/|__/\__,_/_/_/____/
|
||||||
|
The lightweight framework for web-like apps
|
||||||
|
(c) Lea Anthony 2019-present
|
||||||
|
*/
|
||||||
|
/* jshint esversion: 6 */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialises the Wails runtime
|
||||||
|
*
|
||||||
|
* @param {function} callback
|
||||||
|
*/
|
||||||
|
function Init(callback) {
|
||||||
|
window.wails._.Init(callback);
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
Init
|
||||||
|
};
|
||||||
70
runtime/js/runtime/log.js
Normal file
70
runtime/js/runtime/log.js
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
/*
|
||||||
|
_ __ _ __
|
||||||
|
| | / /___ _(_) /____
|
||||||
|
| | /| / / __ `/ / / ___/
|
||||||
|
| |/ |/ / /_/ / / (__ )
|
||||||
|
|__/|__/\__,_/_/_/____/
|
||||||
|
The lightweight framework for web-like apps
|
||||||
|
(c) Lea Anthony 2019-present
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* jshint esversion: 6 */
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log the given debug message with the backend
|
||||||
|
*
|
||||||
|
* @export
|
||||||
|
* @param {string} message
|
||||||
|
*/
|
||||||
|
function Debug(message) {
|
||||||
|
window.wails.Log.Debug(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log the given info message with the backend
|
||||||
|
*
|
||||||
|
* @export
|
||||||
|
* @param {string} message
|
||||||
|
*/
|
||||||
|
function Info(message) {
|
||||||
|
window.wails.Log.Info(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log the given warning message with the backend
|
||||||
|
*
|
||||||
|
* @export
|
||||||
|
* @param {string} message
|
||||||
|
*/
|
||||||
|
function Warning(message) {
|
||||||
|
window.wails.Log.Warning(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log the given error message with the backend
|
||||||
|
*
|
||||||
|
* @export
|
||||||
|
* @param {string} message
|
||||||
|
*/
|
||||||
|
function Error(message) {
|
||||||
|
window.wails.Log.Error(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log the given fatal message with the backend
|
||||||
|
*
|
||||||
|
* @export
|
||||||
|
* @param {string} message
|
||||||
|
*/
|
||||||
|
function Fatal(message) {
|
||||||
|
window.wails.Log.Fatal(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
Debug,
|
||||||
|
Info,
|
||||||
|
Warning,
|
||||||
|
Error,
|
||||||
|
Fatal
|
||||||
|
};
|
||||||
22
runtime/js/runtime/main.js
Normal file
22
runtime/js/runtime/main.js
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
/*
|
||||||
|
_ __ _ __
|
||||||
|
| | / /___ _(_) /____
|
||||||
|
| | /| / / __ `/ / / ___/
|
||||||
|
| |/ |/ / /_/ / / (__ )
|
||||||
|
|__/|__/\__,_/_/_/____/
|
||||||
|
The lightweight framework for web-like apps
|
||||||
|
(c) Lea Anthony 2019-present
|
||||||
|
*/
|
||||||
|
/* jshint esversion: 6 */
|
||||||
|
|
||||||
|
const Log = require('./log');
|
||||||
|
const Browser = require('./browser');
|
||||||
|
const Events = require('./events');
|
||||||
|
const Init = require('./init');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
Log,
|
||||||
|
Browser,
|
||||||
|
Events,
|
||||||
|
Init
|
||||||
|
};
|
||||||
24
runtime/js/runtime/package.json
Normal file
24
runtime/js/runtime/package.json
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
{
|
||||||
|
"name": "@wailsapp/runtime",
|
||||||
|
"version": "1.0.2",
|
||||||
|
"description": "Wails Javascript runtime library",
|
||||||
|
"main": "main.js",
|
||||||
|
"scripts": {
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/wailsapp/wails.git"
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"Wails",
|
||||||
|
"Javascript",
|
||||||
|
"Go"
|
||||||
|
],
|
||||||
|
"author": "Lea Anthony <lea.anthony@gmail.com>",
|
||||||
|
"license": "MIT",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/wailsapp/wails/issues"
|
||||||
|
},
|
||||||
|
"homepage": "https://github.com/wailsapp/wails#readme"
|
||||||
|
}
|
||||||
@@ -1,38 +1,4 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
|
module.exports = (env) => {
|
||||||
const path = require('path');
|
return require(`./webpack.${env}.js`);
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
entry: './src/main',
|
|
||||||
mode: 'production',
|
|
||||||
output: {
|
|
||||||
path: path.resolve(__dirname, 'dist'),
|
|
||||||
filename: 'wails.js'
|
|
||||||
},
|
|
||||||
module: {
|
|
||||||
rules: [
|
|
||||||
{
|
|
||||||
test: /\.m?js$/,
|
|
||||||
exclude: /(node_modules|bower_components)/,
|
|
||||||
use: {
|
|
||||||
loader: 'babel-loader',
|
|
||||||
options: {
|
|
||||||
plugins: ['@babel/plugin-transform-object-assign'],
|
|
||||||
presets: [
|
|
||||||
[
|
|
||||||
'@babel/preset-env',
|
|
||||||
{
|
|
||||||
'useBuiltIns': 'entry',
|
|
||||||
'corejs': {
|
|
||||||
'version': 3,
|
|
||||||
'proposals': true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
], ['minify']
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
38
runtime/js/webpack.prod.js
Normal file
38
runtime/js/webpack.prod.js
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
/* eslint-disable */
|
||||||
|
|
||||||
|
const path = require('path');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
entry: './core/main',
|
||||||
|
mode: 'production',
|
||||||
|
output: {
|
||||||
|
path: path.resolve(__dirname, '..', 'assets'),
|
||||||
|
filename: 'wails.js'
|
||||||
|
},
|
||||||
|
module: {
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
test: /\.m?js$/,
|
||||||
|
exclude: /(node_modules|bower_components)/,
|
||||||
|
use: {
|
||||||
|
loader: 'babel-loader',
|
||||||
|
options: {
|
||||||
|
plugins: ['@babel/plugin-transform-object-assign'],
|
||||||
|
presets: [
|
||||||
|
[
|
||||||
|
'@babel/preset-env',
|
||||||
|
{
|
||||||
|
'useBuiltIns': 'entry',
|
||||||
|
'corejs': {
|
||||||
|
'version': 3,
|
||||||
|
'proposals': true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -5,8 +5,8 @@ import "github.com/wailsapp/wails/lib/logger"
|
|||||||
// Log exposes the logging interface to the runtime
|
// Log exposes the logging interface to the runtime
|
||||||
type Log struct{}
|
type Log struct{}
|
||||||
|
|
||||||
// newLog creates a new Log struct
|
// NewLog creates a new Log struct
|
||||||
func newLog() *Log {
|
func NewLog() *Log {
|
||||||
return &Log{}
|
return &Log{}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -7,7 +7,8 @@ type Window struct {
|
|||||||
renderer interfaces.Renderer
|
renderer interfaces.Renderer
|
||||||
}
|
}
|
||||||
|
|
||||||
func newWindow(renderer interfaces.Renderer) *Window {
|
// NewWindow creates a new Window struct
|
||||||
|
func NewWindow(renderer interfaces.Renderer) *Window {
|
||||||
return &Window{
|
return &Window{
|
||||||
renderer: renderer,
|
renderer: renderer,
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,20 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# Build runtime
|
# Build runtime
|
||||||
|
echo "**** Building Runtime ****"
|
||||||
cd runtime/js
|
cd runtime/js
|
||||||
npm run build
|
npm run build
|
||||||
|
|
||||||
cd ../..
|
cd ../..
|
||||||
|
|
||||||
|
echo "**** Packing Assets ****"
|
||||||
mewn
|
mewn
|
||||||
|
|
||||||
|
echo "**** Installing Wails locally ****"
|
||||||
|
cd cmd/wails
|
||||||
|
go install
|
||||||
|
cd ../..
|
||||||
|
|
||||||
|
echo "**** Tidying the mods! ****"
|
||||||
|
go mod tidy
|
||||||
|
|
||||||
|
echo "**** WE ARE DONE! ****"
|
||||||
|
|||||||
4
wails-mewn.go
Normal file
4
wails-mewn.go
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
package wails
|
||||||
|
|
||||||
|
// Autogenerated by Mewn - Do not alter
|
||||||
|
|
||||||
Reference in New Issue
Block a user