Compare commits

...

34 Commits

Author SHA1 Message Date
Lea Anthony
544fa7319c fix: force install when node_modules missing 2019-10-24 09:33:26 +11:00
Lea Anthony
96fc70df26 Merge branch 'master' into develop 2019-10-23 14:07:22 +11:00
Lea Anthony
1c8d4c902a Merge branch 'develop' of github.com:wailsapp/wails into develop 2019-10-23 14:06:19 +11:00
Lea Anthony
08fc1d53d0 chore: version bump 2019-10-23 14:06:14 +11:00
Lea Anthony
6c5d5e40f4 262 add wails shutdown method (#264)
* feat: support close in bridge mode

* feat: WailsShutdown callback

Now handles proper shutdown through:
  * runtime.Window.Close()
  * Killing the main window
  * Ctrl-C
2019-10-23 14:04:41 +11:00
Lea Anthony
3f1dfe931c Update CONTRIBUTORS.md 2019-10-14 09:37:01 +11:00
Kris Raney
cb850c9653 Patch for file dialog on OSX (#258)
* Patch for file dialog on OSX
2019-10-14 09:34:50 +11:00
Lea Anthony
8d8f47363a chore: supress warnings 2019-10-12 20:19:05 +11:00
Lea Anthony
d399b7580d Develop (#255)
Hotfix
2019-10-09 19:34:24 +11:00
Lea Anthony
1b04b71254 fix: importing runtime (#254) 2019-10-09 19:33:13 +11:00
Lea Anthony
0b19ad1427 chore: version bump 2019-10-09 19:30:53 +11:00
Lea Anthony
9aca99911e Update CONTRIBUTORS.md 2019-10-09 04:47:00 +11:00
Robin Eklind
a7f61e335e cmd/wails: report error status code to OS (#252)
Fixes #251.
2019-10-09 04:44:32 +11:00
Lea Anthony
9fff0a513e chore: merge master 2019-10-08 06:30:22 +11:00
Lea Anthony
f453be12c8 hotfix: version number 2019-10-08 06:20:30 +11:00
Lea Anthony
20428b0407 Develop (#250) 2019-10-08 06:12:08 +11:00
Lea Anthony
7fd5b77cbe chore: version bump 2019-10-08 06:06:02 +11:00
Lea Anthony
d2cac50f93 fix: update runtime 2019-10-07 22:16:29 +11:00
Lea Anthony
00f1f82520 Merge branch 'master' into develop 2019-10-07 21:35:52 +11:00
Lea Anthony
02fbb14e34 chore: version bump 2019-10-07 21:32:27 +11:00
Byron
f961659ada manjaro (#248)
* manjaro

* Update go.mod
2019-10-06 19:14:05 +11:00
Lea Anthony
93942111bc fix: multiple runtime fixes 2019-10-06 14:20:59 +11:00
Lea Anthony
dc5a68acce feat: add runtime typings 2019-10-06 13:36:20 +11:00
Lea Anthony
12ff0f8c97 fix: binding more than one struct method (#245) 2019-10-01 06:13:55 +10:00
Lea Anthony
c375c281ee chore: remove some debug output 2019-09-19 08:57:40 +10:00
Lea Anthony
7d86b0f7c4 chore: version bump 2019-09-14 05:56:52 +10:00
Byron
990f7dd06c feat: KDE neon support (#234) 2019-09-14 05:51:29 +10:00
Lea Anthony
694f80434a fix: revert fix
Masterminds have fixed it upstream
2019-09-05 08:50:40 +10:00
Lea Anthony
099967ae94 hotfix: semver changed api 2019-09-03 21:52:45 +10:00
Lea Anthony
718bb1b852 patch 2019-09-03 21:46:47 +10:00
Lea Anthony
3d9e9a1342 build: fix filename 2019-08-19 22:54:06 +10:00
Lea Anthony
1a82406d2b build: add azure-pipelines script 2019-08-19 22:53:05 +10:00
Lea Anthony
54b4b157b3 Update README.md 2019-08-19 22:30:25 +10:00
Lea Anthony
add7e89097 Update README.md 2019-08-19 22:29:04 +10:00
40 changed files with 473 additions and 99 deletions

View File

@@ -18,3 +18,5 @@ Wails is what it is because of the time and effort given by these great people.
* [Florian Didran](https://github.com/fdidron) * [Florian Didran](https://github.com/fdidron)
* [Nikolai Zimmermann](https://github.com/Chronophylos) * [Nikolai Zimmermann](https://github.com/Chronophylos)
* [Toyam Cox](https://github.com/Vaelatern) * [Toyam Cox](https://github.com/Vaelatern)
* [Robin Eklind](https://github.com/mewmew)
* [Kris Raney](https://github.com/kraney)

View File

@@ -8,9 +8,10 @@
<a href="http://godoc.org/github.com/wailsapp/wails"><img src="https://img.shields.io/badge/godoc-reference-blue.svg"/></a> <a href="http://godoc.org/github.com/wailsapp/wails"><img src="https://img.shields.io/badge/godoc-reference-blue.svg"/></a>
<a href="https://www.codefactor.io/repository/github/wailsapp/wails"><img src="https://www.codefactor.io/repository/github/wailsapp/wails/badge" alt="CodeFactor" /></a> <a href="https://www.codefactor.io/repository/github/wailsapp/wails"><img src="https://www.codefactor.io/repository/github/wailsapp/wails/badge" alt="CodeFactor" /></a>
<a href="https://github.com/wailsapp/wails/issues"><img src="https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat" alt="CodeFactor" /></a> <a href="https://github.com/wailsapp/wails/issues"><img src="https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat" alt="CodeFactor" /></a>
<a href="https://app.fossa.io/projects/git%2Bgithub.com%2Fwailsapp%2Fwails?ref=badge_shield" alt="FOSSA Status"><img src="https://app.fossa.io/api/projects/git%2Bgithub.com%2Fwailsapp%2Fwails.svg?type=shield"/></a>
<a href="https://houndci.com"><img src="https://img.shields.io/badge/Reviewed_by-Hound-8E64B0.svg"/></a> <a href="https://houndci.com"><img src="https://img.shields.io/badge/Reviewed_by-Hound-8E64B0.svg"/></a>
<a href="https://github.com/avelino/awesome-go" rel="nofollow"><img src="https://cdn.rawgit.com/sindresorhus/awesome/d7305f38d29fed78fa85652e3a63e154dd8e8829/media/badge.svg" alt="Awesome"></a> <a href="https://github.com/avelino/awesome-go" rel="nofollow"><img src="https://cdn.rawgit.com/sindresorhus/awesome/d7305f38d29fed78fa85652e3a63e154dd8e8829/media/badge.svg" alt="Awesome"></a>
<a href="https://dashboard.guardrails.io/default/gh/wailsapp/wails"><img src="https://badges.guardrails.io/wailsapp/wails.svg?token=53657bc22ec360d7673c894fdd70568e918ec581d10d84427ed4de5fe1eeff1a"></a> <a href="https://dev.azure.com/leaanthony/Wails/_build/latest?definitionId=1&branchName=master" rel="nofollow"><img src="https://dev.azure.com/leaanthony/Wails/_apis/build/status/wailsapp.wails?branchName=master" alt="Pipelines"></a>
</p> </p>
The traditional method of providing web interfaces to Go programs is via a built-in web server. Wails offers a different approach: it provides the ability to wrap both Go code and a web frontend into a single binary. Tools are provided to make this easy for you by handling project creation, compilation and bundling. All you have to do is get creative! The traditional method of providing web interfaces to Go programs is via a built-in web server. Wails offers a different approach: it provides the ability to wrap both Go code and a web frontend into a single binary. Tools are provided to make this easy for you by handling project creation, compilation and bundling. All you have to do is get creative!
@@ -51,15 +52,16 @@ Make sure you have the xcode command line tools installed. This can be done by r
`sudo apt install libgtk-3-dev libwebkit2gtk-4.0-dev` `sudo apt install libgtk-3-dev libwebkit2gtk-4.0-dev`
_Debian: 8, 9, 10_ _Debian: 8, 9, 10_
_Ubuntu: 16.04, 18.04, 19.04_ _Ubuntu: 16.04, 18.04, 19.04_
_Also succesfully tested on: Zorin 15, Parrot 4.7, Linuxmint 19, Elementary 5, Kali-Rolling_ _Also succesfully tested on: Zorin 15, Parrot 4.7, Linuxmint 19, Elementary 5, Kali, Neon_
#### Arch Linux #### Arch Linux
`sudo pacman -S webkit2gtk gtk3` `sudo pacman -S webkit2gtk gtk3`
_Also succesfully test on: ArcoLinuxB_ _Also succesfully test on: Manjaro & ArcoLinux_
#### Centos #### Centos
@@ -142,3 +144,7 @@ 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)
## Licensing
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fwailsapp%2Fwails.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fwailsapp%2Fwails?ref=badge_large)

39
app.go
View File

@@ -1,6 +1,10 @@
package wails package wails
import ( import (
"os"
"syscall"
"github.com/syossan27/tebata"
"github.com/wailsapp/wails/cmd" "github.com/wailsapp/wails/cmd"
"github.com/wailsapp/wails/lib/binding" "github.com/wailsapp/wails/lib/binding"
"github.com/wailsapp/wails/lib/event" "github.com/wailsapp/wails/lib/event"
@@ -66,6 +70,7 @@ func CreateApp(optionalConfig ...*AppConfig) *App {
// Run the app // Run the app
func (a *App) Run() error { func (a *App) Run() error {
if BuildMode != cmd.BuildModeProd { if BuildMode != cmd.BuildModeProd {
return a.cli.Run() return a.cli.Run()
} }
@@ -97,6 +102,13 @@ func (a *App) start() error {
return err return err
} }
// Start signal handler
t := tebata.New(os.Interrupt, os.Kill, syscall.SIGTERM, syscall.SIGINT, syscall.SIGKILL)
t.Reserve(func() {
a.log.Debug("SIGNAL CAUGHT! Starting Shutdown")
a.renderer.Close()
})
// Start event manager and give it our renderer // Start event manager and give it our renderer
a.eventManager.Start(a.renderer) a.eventManager.Start(a.renderer)
@@ -112,8 +124,33 @@ func (a *App) start() error {
return err return err
} }
// Defer the shutdown
defer a.shutdown()
// Run the renderer // Run the renderer
return a.renderer.Run() err = a.renderer.Run()
if err != nil {
return err
}
return nil
}
// shutdown the app
func (a *App) shutdown() {
// Make sure this is only called once
a.log.Debug("Shutting down")
// Shutdown Binding Manager
a.bindingManager.Shutdown()
// Shutdown IPC Manager
a.ipc.Shutdown()
// Shutdown Event Manager
a.eventManager.Shutdown()
a.log.Debug("Cleanly Shutdown")
} }
// Bind allows the user to bind the given object // Bind allows the user to bind the given object

138
azure-pipelines.yml Normal file
View File

@@ -0,0 +1,138 @@
# avoid double trigger by applying some rules
# start a pipeline when push to 'master' branch
trigger:
- master
# or when pull request on 'develop' branch
pr:
- develop
# for now there is only one stage 'Build'
# in the future we could use multistage strategy for releases
stages:
- stage: Build
# there are 3 jobs
# one for each os
jobs:
- deployment: Linux
displayName: Lin
variables:
GOPATH: '$(Agent.BuildDirectory)/gopath' # Go workspace path
GOROOT: '$(Agent.BuildDirectory)/go' # Go installation path
GOBIN: '$(GOPATH)/bin' # Go binaries path
GOMODULE: 'on'
modulePath: '$(Agent.BuildDirectory)/wails' # Path to the module's code
pool:
vmImage: 'Ubuntu-16.04'
environment: 'linux-dev'
strategy:
runOnce:
deploy:
steps:
- checkout: self # self represents the repo where the initial Pipelines YAML file was found
clean: true # whether to fetch clean each time
path: wails # path to check out source code, relative to the agent's build directory (e.g. \_work\1)
# go version 1.12.7
- script: |
wget "https://storage.googleapis.com/golang/go1.12.7.linux-amd64.tar.gz" --output-document "$(Agent.BuildDirectory)/go1.12.7.tar.gz"
tar -C '$(Agent.BuildDirectory)' -xzf "$(Agent.BuildDirectory)/go1.12.7.tar.gz"
displayName: 'Install Go 1.12.7 Linux'
- script: |
mkdir -p '$(GOBIN)'
mkdir -p '$(GOPATH)/pkg'
mkdir -p '$(GOROOT)'
shopt -s extglob
shopt -s dotglob
echo '##vso[task.prependpath]$(GOBIN)'
echo '##vso[task.prependpath]$(GOROOT)/bin'
displayName: 'Set up the Go workspace'
- script: |
go version
go get -v -d ./...
cd cmd/wails
go install
workingDirectory: '$(modulePath)'
displayName: 'Get dependencies, then build'
- script: |
wails version
workingDirectory: '$(modulePath)'
displayName: 'Check we have output'
- deployment: Mac
displayName: Mac
variables:
GOPATH: '$(Agent.BuildDirectory)/gopath' # Go workspace path
GOROOT: '$(Agent.BuildDirectory)/go' # Go installation path
GOBIN: '$(GOPATH)/bin' # Go binaries path
GOMODULE: 'on'
modulePath: '$(Agent.BuildDirectory)/wails' # Path to the module's code
pool:
vmImage: 'macOS-10.14'
environment: 'mac-dev'
strategy:
runOnce:
deploy:
steps:
- checkout: self # self represents the repo where the initial Pipelines YAML file was found
clean: true # whether to fetch clean each time
path: wails # path to check out source code, relative to the agent's build directory (e.g. \_work\1)
# go version 1.12.7
- script: |
wget "https://storage.googleapis.com/golang/go1.12.7.darwin-amd64.tar.gz" --output-document "$(Agent.BuildDirectory)/go1.12.7.tar.gz"
tar -C '$(Agent.BuildDirectory)' -xzf "$(Agent.BuildDirectory)/go1.12.7.tar.gz"
displayName: 'Install Go 1.12.7 Linux'
- script: |
mkdir -p '$(GOBIN)'
mkdir -p '$(GOPATH)/pkg'
mkdir -p '$(GOROOT)'
shopt -s extglob
shopt -s dotglob
echo '##vso[task.prependpath]$(GOBIN)'
echo '##vso[task.prependpath]$(GOROOT)/bin'
displayName: 'Set up the Go workspace'
- script: |
go version
go get -v -d ./...
cd cmd/wails
go install
workingDirectory: '$(modulePath)'
displayName: 'Get dependencies, then build'
- script: |
wails version
workingDirectory: '$(modulePath)'
displayName: 'Check we have output'
- deployment: Win
displayName: Win
variables:
GOMODULE: 'on'
modulePath: '$(Agent.BuildDirectory)/wails' # Path to the module's code
pool:
vmImage: 'windows-2019'
environment: 'win-dev'
strategy:
runOnce:
deploy:
steps:
- checkout: self # self represents the repo where the initial Pipelines YAML file was found
clean: true # whether to fetch clean each time
path: wails # path to check out source code, relative to the agent's build directory (e.g. \_work\1)
# Go tool installer
# Find in cache or download a specific version of Go and add it to the PATH
- task: GoTool@0
inputs:
version: '1.12.7'
goPath: '$(Agent.BuildDirectory)/go'
goBin: '$(Agent.BuildDirectory)/go/bin'
displayName: 'Set up the Go workspace'
- script: |
go version
go get -v -d ./...
cd cmd/wails
go install
workingDirectory: '$(modulePath)'
displayName: 'Get dependencies, then build'
- script: |
wails version
workingDirectory: '$(Agent.BuildDirectory)/go/bin'
displayName: 'Check we have output'

File diff suppressed because one or more lines are too long

View File

@@ -219,6 +219,15 @@ func InstallFrontendDeps(projectDir string, projectOptions *ProjectOptions, forc
const md5sumFile = "package.json.md5" const md5sumFile = "package.json.md5"
// If node_modules does not exist, force a rebuild.
nodeModulesPath, err := filepath.Abs(filepath.Join(".", "node_modules"))
if err != nil {
return err
}
if !fs.DirExists(nodeModulesPath) {
forceRebuild = true
}
// If we aren't forcing the install and the md5sum file exists // If we aren't forcing the install and the md5sum file exists
if !forceRebuild && fs.FileExists(md5sumFile) { if !forceRebuild && fs.FileExists(md5sumFile) {
// Yes - read contents // Yes - read contents
@@ -275,7 +284,7 @@ func InstallRuntime(caller string, projectDir string, projectOptions *ProjectOpt
// InstallBridge installs the relevant bridge javascript library // InstallBridge installs the relevant bridge javascript library
func InstallBridge(projectDir string, projectOptions *ProjectOptions) error { func InstallBridge(projectDir string, projectOptions *ProjectOptions) error {
bridgeFileData := mewn.String("../runtime/assets/bridge.js") bridgeFileData := mewn.String("../runtime/assets/bridge.js")
bridgeFileTarget := filepath.Join(projectDir, projectOptions.FrontEnd.Dir, "node_modules", "@wailsapp", "runtime", "main.js") bridgeFileTarget := filepath.Join(projectDir, projectOptions.FrontEnd.Dir, "node_modules", "@wailsapp", "runtime", "init.js")
err := fs.CreateFile(bridgeFileTarget, []byte(bridgeFileData)) err := fs.CreateFile(bridgeFileTarget, []byte(bridgeFileData))
return err return err
} }
@@ -283,7 +292,7 @@ func InstallBridge(projectDir string, projectOptions *ProjectOptions) error {
// InstallProdRuntime installs the production runtime // InstallProdRuntime installs the production runtime
func InstallProdRuntime(projectDir string, projectOptions *ProjectOptions) error { func InstallProdRuntime(projectDir string, projectOptions *ProjectOptions) error {
prodInit := mewn.String("../runtime/js/runtime/init.js") prodInit := mewn.String("../runtime/js/runtime/init.js")
bridgeFileTarget := filepath.Join(projectDir, projectOptions.FrontEnd.Dir, "node_modules", "@wailsapp", "runtime", "main.js") bridgeFileTarget := filepath.Join(projectDir, projectOptions.FrontEnd.Dir, "node_modules", "@wailsapp", "runtime", "init.js")
err := fs.CreateFile(bridgeFileTarget, []byte(prodInit)) err := fs.CreateFile(bridgeFileTarget, []byte(prodInit))
return err return err
} }

View File

@@ -41,6 +41,10 @@ const (
Elementary Elementary
// Kali distribution // Kali distribution
Kali Kali
// Neon distribution
Neon
// Manjaro distribution
Manjaro
) )
// DistroInfo contains all the information relating to a linux distribution // DistroInfo contains all the information relating to a linux distribution
@@ -122,6 +126,10 @@ func parseOsRelease(osRelease string) *DistroInfo {
result.Distribution = Elementary result.Distribution = Elementary
case "kali": case "kali":
result.Distribution = Kali result.Distribution = Kali
case "neon":
result.Distribution = Neon
case "manjaro":
result.Distribution = Manjaro
default: default:
result.Distribution = Unknown result.Distribution = Unknown
} }

View File

@@ -73,6 +73,15 @@ distributions:
gccversioncommand: *gccdumpfullversion gccversioncommand: *gccdumpfullversion
programs: *debiandefaultprograms programs: *debiandefaultprograms
libraries: *debiandefaultlibraries libraries: *debiandefaultlibraries
neon:
id: neon
releases:
default:
version: default
name: KDE neon
gccversioncommand: *gccdumpfullversion
programs: *debiandefaultprograms
libraries: *debiandefaultlibraries
void: void:
id: void id: void
releases: releases:
@@ -137,18 +146,27 @@ distributions:
version: default version: default
name: Arch Linux name: Arch Linux
gccversioncommand: *gccdumpversion gccversioncommand: *gccdumpversion
programs: programs: &archdefaultprograms
- name: gcc - name: gcc
help: Please install with `sudo pacman -S gcc` and try again help: Please install with `sudo pacman -S gcc` and try again
- name: pkgconf - name: pkgconf
help: Please install with `sudo pacman -S pkgconf` and try again help: Please install with `sudo pacman -S pkgconf` and try again
- name: npm - name: npm
help: Please install with `sudo pacman -S npm` and try again help: Please install with `sudo pacman -S npm` and try again
libraries: libraries: &archdefaultlibraries
- name: gtk3 - name: gtk3
help: Please install with `sudo pacman -S gtk3` and try again help: Please install with `sudo pacman -S gtk3` and try again
- name: webkit2gtk - name: webkit2gtk
help: Please install with `sudo pacman -S webkit2gtk` and try again help: Please install with `sudo pacman -S webkit2gtk` and try again
manjaro:
id: manjaro
releases:
default:
version: default
name: Manjaro Linux
gccversioncommand: *gccdumpversion
programs: *archdefaultprograms
libraries: *archdefaultlibraries
gentoo: gentoo:
id: gentoo id: gentoo
releases: releases:

View File

@@ -274,9 +274,9 @@ func CheckDependencies(logger *Logger) (bool, error) {
distroInfo := GetLinuxDistroInfo() distroInfo := GetLinuxDistroInfo()
switch distroInfo.Distribution { switch distroInfo.Distribution {
case Ubuntu, Debian, Zorin, Parrot, Linuxmint, Elementary, Kali: case Ubuntu, Debian, Zorin, Parrot, Linuxmint, Elementary, Kali, Neon:
libraryChecker = DpkgInstalled libraryChecker = DpkgInstalled
case Arch: case Arch, Manjaro:
libraryChecker = PacmanInstalled libraryChecker = PacmanInstalled
case CentOS, Fedora: case CentOS, Fedora:
libraryChecker = RpmInstalled libraryChecker = RpmInstalled

View File

@@ -6,7 +6,7 @@ import { environment } from './environments/environment';
import 'zone.js' import 'zone.js'
import Wails from '@wailsapp/runtime'; import * as Wails from '@wailsapp/runtime';
if (environment.production) { if (environment.production) {
enableProdMode(); enableProdMode();

View File

@@ -4,7 +4,7 @@ import 'core-js/stable';
import './index.css'; import './index.css';
import App from './App'; import App from './App';
import Wails from '@wailsapp/runtime'; import * as Wails from '@wailsapp/runtime';
Wails.Init(() => { Wails.Init(() => {
ReactDOM.render(<App />, document.getElementById('app')); ReactDOM.render(<App />, document.getElementById('app'));

View File

@@ -4,7 +4,7 @@ import App from './App.vue';
Vue.config.productionTip = false; Vue.config.productionTip = false;
Vue.config.devtools = true; Vue.config.devtools = true;
import Wails from '@wailsapp/runtime'; import * as Wails from '@wailsapp/runtime';
Wails.Init(() => { Wails.Init(() => {
new Vue({ new Vue({

View File

@@ -12,7 +12,7 @@ import App from './App.vue';
Vue.config.productionTip = false; Vue.config.productionTip = false;
Vue.config.devtools = true; Vue.config.devtools = true;
import Wails from '@wailsapp/runtime'; import * as Wails from '@wailsapp/runtime';
Wails.Init(() => { Wails.Init(() => {
new Vue({ new Vue({

View File

@@ -1,4 +1,4 @@
package cmd package cmd
// Version - Wails version // Version - Wails version
const Version = "v0.17.14-pre" const Version = "v0.18.4"

View File

@@ -1,6 +1,9 @@
package main package main
import ( import (
"os"
"os/exec"
"github.com/wailsapp/wails/cmd" "github.com/wailsapp/wails/cmd"
) )
@@ -15,5 +18,9 @@ func main() {
err := app.Run() err := app.Run()
if err != nil { if err != nil {
logger.Error(err.Error()) logger.Error(err.Error())
if exitErr, ok := err.(*exec.ExitError); ok {
os.Exit(exitErr.ExitCode())
}
os.Exit(1)
} }
} }

1
go.mod
View File

@@ -22,6 +22,7 @@ require (
github.com/pkg/errors v0.8.1 // indirect github.com/pkg/errors v0.8.1 // indirect
github.com/sirupsen/logrus v1.4.1 github.com/sirupsen/logrus v1.4.1
github.com/stretchr/testify v1.3.0 // indirect github.com/stretchr/testify v1.3.0 // indirect
github.com/syossan27/tebata v0.0.0-20180602121909-b283fe4bc5ba
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529 // indirect golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529 // indirect
golang.org/x/net v0.0.0-20190509222800-a4d6f7feada5 // indirect golang.org/x/net v0.0.0-20190509222800-a4d6f7feada5 // indirect
golang.org/x/sys v0.0.0-20190509141414-a5b02f93d862 golang.org/x/sys v0.0.0-20190509141414-a5b02f93d862

2
go.sum
View File

@@ -68,6 +68,8 @@ github.com/stretchr/testify v1.2.1/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXf
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/syossan27/tebata v0.0.0-20180602121909-b283fe4bc5ba h1:2DHfQOxcpWdGf5q5IzCUFPNvRX9Icf+09RvQK2VnJq0=
github.com/syossan27/tebata v0.0.0-20180602121909-b283fe4bc5ba/go.mod h1:iLnlXG2Pakcii2CU0cbY07DRCSvpWNa7nFxtevhOChk=
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/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=

View File

@@ -16,6 +16,7 @@ type Manager struct {
functions map[string]*boundFunction functions map[string]*boundFunction
internalMethods *internalMethods internalMethods *internalMethods
initMethods []*boundMethod initMethods []*boundMethod
shutdownMethods []*boundMethod
log *logger.CustomLogger log *logger.CustomLogger
renderer interfaces.Renderer renderer interfaces.Renderer
runtime interfaces.Runtime // The runtime object to pass to bound structs runtime interfaces.Runtime // The runtime object to pass to bound structs
@@ -127,6 +128,9 @@ func (b *Manager) bindMethod(object interface{}) error {
if newMethod.isWailsInit { if newMethod.isWailsInit {
b.log.Debugf("Detected WailsInit function: %s", fullMethodName) b.log.Debugf("Detected WailsInit function: %s", fullMethodName)
b.initMethods = append(b.initMethods, newMethod) b.initMethods = append(b.initMethods, newMethod)
} else if newMethod.isWailsShutdown {
b.log.Debugf("Detected WailsShutdown function: %s", fullMethodName)
b.shutdownMethods = append(b.shutdownMethods, newMethod)
} else { } else {
// Save boundMethod // Save boundMethod
b.log.Infof("Bound Method: %s()", fullMethodName) b.log.Infof("Bound Method: %s()", fullMethodName)
@@ -292,3 +296,13 @@ func (b *Manager) callWailsInitMethods() error {
} }
return nil return nil
} }
// Shutdown the binding manager
func (b *Manager) Shutdown() {
b.log.Debug("Shutdown called")
for _, method := range b.shutdownMethods {
b.log.Debugf("Calling Shutdown for method: %s", method.fullName)
method.call("[]")
}
b.log.Debug("Shutdown complete")
}

View File

@@ -18,6 +18,7 @@ type boundMethod struct {
log *logger.CustomLogger log *logger.CustomLogger
hasErrorReturnType bool // Indicates if there is an error return type hasErrorReturnType bool // Indicates if there is an error return type
isWailsInit bool isWailsInit bool
isWailsShutdown bool
} }
// Creates a new bound method based on the given method + type // Creates a new bound method based on the given method + type
@@ -39,6 +40,11 @@ func newBoundMethod(name string, fullName string, method reflect.Value, objectTy
err = result.processWailsInit() err = result.processWailsInit()
} }
// Are we a WailsShutdown method?
if result.Name == "WailsShutdown" {
err = result.processWailsShutdown()
}
return result, err return result, err
} }
@@ -211,3 +217,20 @@ func (b *boundMethod) processWailsInit() error {
return nil return nil
} }
func (b *boundMethod) processWailsShutdown() error {
// We must have only 1 input, it must be *wails.Runtime
if len(b.inputs) != 0 {
return fmt.Errorf("Invalid WailsShutdown() definition. Expected 0 inputs, but got %d", len(b.inputs))
}
// We must have only 1 output, it must be error
if len(b.returnTypes) != 0 {
return fmt.Errorf("Invalid WailsShutdown() definition. Expected 0 return types, but got %d", len(b.returnTypes))
}
// We are indeed a wails Shutdown method
b.isWailsShutdown = true
return nil
}

View File

@@ -3,18 +3,21 @@ package event
import ( import (
"fmt" "fmt"
"sync" "sync"
"time"
"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"
) )
// Manager handles and processes events // Manager handles and processes events
type Manager struct { type Manager struct {
incomingEvents chan *messages.EventData incomingEvents chan *messages.EventData
listeners map[string][]*eventListener listeners map[string][]*eventListener
exit bool running bool
log *logger.CustomLogger log *logger.CustomLogger
renderer interfaces.Renderer // Messages will be dispatched to the frontend renderer interfaces.Renderer // Messages will be dispatched to the frontend
wg sync.WaitGroup
} }
// NewManager creates a new event manager with a 100 event buffer // NewManager creates a new event manager with a 100 event buffer
@@ -22,7 +25,7 @@ func NewManager() interfaces.EventManager {
return &Manager{ return &Manager{
incomingEvents: make(chan *messages.EventData, 100), incomingEvents: make(chan *messages.EventData, 100),
listeners: make(map[string][]*eventListener), listeners: make(map[string][]*eventListener),
exit: false, running: false,
log: logger.NewCustomLogger("Events"), log: logger.NewCustomLogger("Events"),
} }
} }
@@ -87,15 +90,14 @@ func (e *Manager) Start(renderer interfaces.Renderer) {
// Store renderer // Store renderer
e.renderer = renderer e.renderer = renderer
// Set up waitgroup so we can wait for goroutine to start // Set up waitgroup so we can wait for goroutine to quit
var wg sync.WaitGroup e.running = true
wg.Add(1) e.wg.Add(1)
// Run main loop in separate goroutine // Run main loop in separate goroutine
go func() { go func() {
wg.Done()
e.log.Info("Listening") e.log.Info("Listening")
for e.exit == false { for e.running {
// TODO: Listen for application exit // TODO: Listen for application exit
select { select {
case event := <-e.incomingEvents: case event := <-e.incomingEvents:
@@ -139,14 +141,18 @@ func (e *Manager) Start(renderer interfaces.Renderer) {
} }
} }
} }
default:
time.Sleep(1 * time.Millisecond)
} }
} }
e.wg.Done()
}() }()
// Wait for goroutine to start
wg.Wait()
} }
func (e *Manager) stop() { // Shutdown is called when exiting the Application
e.exit = true func (e *Manager) Shutdown() {
e.log.Debug("Shutting Down")
e.running = false
e.log.Debug("Waiting for main loop to exit")
e.wg.Wait()
} }

View File

@@ -7,4 +7,5 @@ type BindingManager interface {
Bind(object interface{}) Bind(object interface{})
Start(renderer Renderer, runtime Runtime) error Start(renderer Renderer, runtime Runtime) error
ProcessCall(callData *messages.CallData) (result interface{}, err error) ProcessCall(callData *messages.CallData) (result interface{}, err error)
Shutdown()
} }

View File

@@ -8,4 +8,5 @@ type EventManager interface {
Emit(eventName string, optionalData ...interface{}) Emit(eventName string, optionalData ...interface{})
On(eventName string, callback func(...interface{})) On(eventName string, callback func(...interface{}))
Start(Renderer) Start(Renderer)
Shutdown()
} }

View File

@@ -5,4 +5,5 @@ type IPCManager interface {
BindRenderer(Renderer) BindRenderer(Renderer)
Dispatch(message string) Dispatch(message string)
Start(eventManager EventManager, bindingManager BindingManager) Start(eventManager EventManager, bindingManager BindingManager)
Shutdown()
} }

View File

@@ -2,6 +2,8 @@ package ipc
import ( import (
"fmt" "fmt"
"sync"
"time"
"github.com/wailsapp/wails/lib/interfaces" "github.com/wailsapp/wails/lib/interfaces"
"github.com/wailsapp/wails/lib/logger" "github.com/wailsapp/wails/lib/logger"
@@ -12,18 +14,20 @@ import (
type Manager struct { type Manager struct {
renderer interfaces.Renderer // The renderer renderer interfaces.Renderer // The renderer
messageQueue chan *ipcMessage messageQueue chan *ipcMessage
// quitChannel chan struct{} quitChannel chan struct{}
// signals chan os.Signal // signals chan os.Signal
log *logger.CustomLogger log *logger.CustomLogger
eventManager interfaces.EventManager eventManager interfaces.EventManager
bindingManager interfaces.BindingManager bindingManager interfaces.BindingManager
running bool
wg sync.WaitGroup
} }
// NewManager creates a new IPC Manager // NewManager creates a new IPC Manager
func NewManager() interfaces.IPCManager { func NewManager() interfaces.IPCManager {
result := &Manager{ result := &Manager{
messageQueue: make(chan *ipcMessage, 100), messageQueue: make(chan *ipcMessage, 100),
// quitChannel: make(chan struct{}), quitChannel: make(chan struct{}),
// signals: make(chan os.Signal, 1), // signals: make(chan os.Signal, 1),
log: logger.NewCustomLogger("IPC"), log: logger.NewCustomLogger("IPC"),
} }
@@ -44,9 +48,12 @@ func (i *Manager) Start(eventManager interfaces.EventManager, bindingManager int
i.log.Info("Starting") i.log.Info("Starting")
// signal.Notify(manager.signals, os.Interrupt) // signal.Notify(manager.signals, os.Interrupt)
i.running = true
// Keep track of this goroutine
i.wg.Add(1)
go func() { go func() {
running := true for i.running {
for running {
select { select {
case incomingMessage := <-i.messageQueue: case incomingMessage := <-i.messageQueue:
i.log.DebugFields("Processing message", logger.Fields{ i.log.DebugFields("Processing message", logger.Fields{
@@ -117,15 +124,12 @@ func (i *Manager) Start(eventManager interfaces.EventManager, bindingManager int
i.log.DebugFields("Finished processing message", logger.Fields{ i.log.DebugFields("Finished processing message", logger.Fields{
"1D": &incomingMessage, "1D": &incomingMessage,
}) })
// case <-manager.quitChannel: default:
// Debug("[MessageQueue] Quit caught") time.Sleep(1 * time.Millisecond)
// running = false
// case <-manager.signals:
// Debug("[MessageQueue] Signal caught")
// running = false
} }
} }
i.log.Debug("Stopping") i.log.Debug("Stopping")
i.wg.Done()
}() }()
} }
@@ -167,3 +171,11 @@ func (i *Manager) SendResponse(response *ipcResponse) error {
// Call back to the front end // Call back to the front end
return i.renderer.Callback(data) return i.renderer.Callback(data)
} }
// Shutdown is called when exiting the Application
func (i *Manager) Shutdown() {
i.log.Debug("Shutdown called")
i.running = false
i.log.Debug("Waiting of main loop shutdown")
i.wg.Wait()
}

View File

@@ -156,7 +156,7 @@ func (h *Bridge) Run() error {
h.log.Info("The frontend will connect automatically.") h.log.Info("The frontend will connect automatically.")
err := h.server.ListenAndServe() err := h.server.ListenAndServe()
if err != nil { if err != nil && err != http.ErrServerClosed {
h.log.Fatal(err.Error()) h.log.Fatal(err.Error())
} }
return err return err
@@ -250,5 +250,9 @@ func (h *Bridge) SetTitle(title string) {
// Close is unsupported for Bridge but required // Close is unsupported for Bridge but required
// for the Renderer interface // for the Renderer interface
func (h *Bridge) Close() { func (h *Bridge) Close() {
h.log.Warn("Close() unsupported in bridge mode") h.log.Debug("Shutting down")
err := h.server.Close()
if err != nil {
h.log.Errorf(err.Error())
}
} }

File diff suppressed because one or more lines are too long

View File

@@ -170,16 +170,12 @@ func (w *WebView) Exit() {
// Run the window main loop // Run the window main loop
func (w *WebView) Run() error { func (w *WebView) Run() error {
w.log.Info("Run()") w.log.Info("Running...")
// Runtime assets // Runtime assets
wailsRuntime := mewn.String("../../runtime/assets/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{}) {

View File

@@ -11,7 +11,7 @@
package webview package webview
/* /*
#cgo linux openbsd freebsd CFLAGS: -DWEBVIEW_GTK=1 #cgo linux openbsd freebsd CFLAGS: -DWEBVIEW_GTK=1 -Wno-deprecated-declarations
#cgo linux openbsd freebsd pkg-config: gtk+-3.0 webkit2gtk-4.0 #cgo linux openbsd freebsd pkg-config: gtk+-3.0 webkit2gtk-4.0
#cgo windows CFLAGS: -DWEBVIEW_WINAPI=1 #cgo windows CFLAGS: -DWEBVIEW_WINAPI=1

View File

@@ -86,7 +86,7 @@ struct webview_priv
NSAutoreleasePool *pool; NSAutoreleasePool *pool;
NSWindow *window; NSWindow *window;
WebView *webview; WebView *webview;
id windowDelegate; id delegate;
int should_exit; int should_exit;
}; };
#else #else
@@ -1894,6 +1894,22 @@ struct webview_priv
[script setValue:self forKey:@"external"]; [script setValue:self forKey:@"external"];
} }
static void webview_run_input_open_panel(id self, SEL cmd, id webview,
id listener, BOOL allowMultiple) {
char filename[256] = "";
struct webview *w =
(struct webview *)objc_getAssociatedObject(self, "webview");
webview_dialog(w, WEBVIEW_DIALOG_TYPE_OPEN, WEBVIEW_DIALOG_FLAG_FILE, "", "",
filename, 255);
if (strlen(filename)) {
[listener chooseFilename:[NSString stringWithUTF8String:filename]];
} else {
[listener cancel];
}
}
static void webview_external_invoke(id self, SEL cmd, id arg) static void webview_external_invoke(id self, SEL cmd, id arg)
{ {
struct webview *w = struct webview *w =
@@ -1927,12 +1943,17 @@ struct webview_priv
class_addMethod(webViewDelegateClass, class_addMethod(webViewDelegateClass,
sel_registerName("webView:didClearWindowObject:forFrame:"), sel_registerName("webView:didClearWindowObject:forFrame:"),
(IMP)webview_did_clear_window_object, "v@:@@@"); (IMP)webview_did_clear_window_object, "v@:@@@");
class_addMethod(
webViewDelegateClass,
sel_registerName("webView:runOpenPanelForFileButtonWithResultListener:"
"allowMultipleFiles:"),
(IMP)webview_run_input_open_panel, "v@:@@c");
class_addMethod(webViewDelegateClass, sel_registerName("invoke:"), class_addMethod(webViewDelegateClass, sel_registerName("invoke:"),
(IMP)webview_external_invoke, "v@:@"); (IMP)webview_external_invoke, "v@:@");
objc_registerClassPair(webViewDelegateClass); objc_registerClassPair(webViewDelegateClass);
w->priv.windowDelegate = [[webViewDelegateClass alloc] init]; w->priv.delegate = [[webViewDelegateClass alloc] init];
objc_setAssociatedObject(w->priv.windowDelegate, "webview", (id)(w), objc_setAssociatedObject(w->priv.delegate, "webview", (id)(w),
OBJC_ASSOCIATION_ASSIGN); OBJC_ASSOCIATION_ASSIGN);
NSRect r = NSMakeRect(0, 0, w->width, w->height); NSRect r = NSMakeRect(0, 0, w->width, w->height);
@@ -1960,7 +1981,7 @@ struct webview_priv
NSString *nsTitle = [NSString stringWithUTF8String:w->title]; NSString *nsTitle = [NSString stringWithUTF8String:w->title];
[w->priv.window setTitle:nsTitle]; [w->priv.window setTitle:nsTitle];
[w->priv.window setDelegate:w->priv.windowDelegate]; [w->priv.window setDelegate:w->priv.delegate];
[w->priv.window center]; [w->priv.window center];
// NSToolbar *toolbar = [[NSToolbar alloc] initWithIdentifier:@"wat"]; // NSToolbar *toolbar = [[NSToolbar alloc] initWithIdentifier:@"wat"];
@@ -1989,7 +2010,8 @@ struct webview_priv
[w->priv.webview setAutoresizesSubviews:YES]; [w->priv.webview setAutoresizesSubviews:YES];
[w->priv.webview [w->priv.webview
setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable]; setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
w->priv.webview.frameLoadDelegate = w->priv.windowDelegate; w->priv.webview.frameLoadDelegate = w->priv.delegate;
w->priv.webview.UIDelegate = w->priv.delegate;
[[w->priv.window contentView] addSubview:w->priv.webview]; [[w->priv.window contentView] addSubview:w->priv.webview];
[w->priv.window orderFrontRegardless]; [w->priv.window orderFrontRegardless];

View File

@@ -214,4 +214,4 @@ function Init(callback) {
start(callback); start(callback);
} }
module.exports = { Init }; module.exports = Init;

View File

@@ -1 +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")}]); !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 i(n,t,e){var r={type:n,callbackID:e,payload:t};!function(n){window.external.invoke(n)}(JSON.stringify(r))}function a(n,t){i("log",{level:n,message:t})}function c(n){a("debug",n)}function u(n){a("info",n)}function l(n){a("warning",n)}function f(n){a("error",n)}function d(n){a("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 a;do{a=n+"-"+s()}while(p[a]);if(e>0)var c=setTimeout(function(){o(Error("Call to "+n+" timed out. Request ID: "+a))},e);p[a]={timeoutHandle:c,reject:o,resolve:r};try{i("call",{bindingName:n,data:JSON.stringify(t)},a)}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){i("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[o]={}),e=e[o]}var i=t.pop();if(!j(i))return new Error("".concat(i," is not a valid javascript identifier."));e[i]=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 i="Callback '".concat(r,"' not registed!!!");throw console.error(i),new Error(i)}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],i=[];if(t)try{i=JSON.parse(t)}catch(t){f("Invalid JSON data sent to notify. Event name = "+n)}o.Callback(i)&&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)},OnMultiple:h,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")}]);

View File

@@ -46,13 +46,15 @@ export function NewBinding(bindingName) {
// Check if we have a path (IE Struct) // Check if we have a path (IE Struct)
if (bindingSections.length > 1) { if (bindingSections.length > 1) {
// Iterate over binding sections, adding them to the window.backend object // Iterate over binding sections, adding them to the window.backend object
for (let index = 0; index < bindingSections.length - 1; index += 1) { for (let index = 0; index < bindingSections.length-1; index += 1) {
const name = bindingSections[index]; const name = bindingSections[index];
// Is name a valid javascript identifier? // Is name a valid javascript identifier?
if (!isValidIdentifier(name)) { if (!isValidIdentifier(name)) {
return new Error(`${name} is not a valid javascript identifier.`); return new Error(`${name} is not a valid javascript identifier.`);
} }
pathToBinding[name] = {}; if (!pathToBinding[name]) {
pathToBinding[name] = {};
}
pathToBinding = pathToBinding[name]; pathToBinding = pathToBinding[name];
} }
} }

View File

@@ -10,7 +10,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 * as Browser from './browser';
import { On, Emit, Notify, Heartbeat, Acknowledge } from './events'; import { On, OnMultiple, Emit, Notify, Heartbeat, Acknowledge } from './events';
import { NewBinding } from './bindings'; import { NewBinding } from './bindings';
import { Callback } from './calls'; import { Callback } from './calls';
import { AddScript, InjectCSS } from './utils'; import { AddScript, InjectCSS } from './utils';
@@ -35,6 +35,7 @@ var runtime = {
Browser, Browser,
Events: { Events: {
On, On,
OnMultiple,
Emit, Emit,
Heartbeat, Heartbeat,
Acknowledge, Acknowledge,

View File

@@ -56,13 +56,15 @@
"version": "0.3.2", "version": "0.3.2",
"resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz", "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz",
"integrity": "sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg=", "integrity": "sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg=",
"dev": true "dev": true,
"optional": true
}, },
"braces": { "braces": {
"version": "2.3.2", "version": "2.3.2",
"resolved": "https://registry.npmjs.org/braces/-/braces-2.3.2.tgz", "resolved": "https://registry.npmjs.org/braces/-/braces-2.3.2.tgz",
"integrity": "sha512-aNdbnj9P8PjdXU4ybaWLK2IF3jc/EoDYbC7AazW6to3TRsfXxscC9UXOB5iDiEQrkyIbWp2SLQda4+QAa7nc3w==", "integrity": "sha512-aNdbnj9P8PjdXU4ybaWLK2IF3jc/EoDYbC7AazW6to3TRsfXxscC9UXOB5iDiEQrkyIbWp2SLQda4+QAa7nc3w==",
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"arr-flatten": "^1.1.0", "arr-flatten": "^1.1.0",
"array-unique": "^0.3.2", "array-unique": "^0.3.2",
@@ -81,6 +83,7 @@
"resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz",
"integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=",
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"is-extendable": "^0.1.0" "is-extendable": "^0.1.0"
} }
@@ -253,6 +256,7 @@
"resolved": "https://registry.npmjs.org/fill-range/-/fill-range-4.0.0.tgz", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-4.0.0.tgz",
"integrity": "sha1-1USBHUKPmOsGpj3EAtJAPDKMOPc=", "integrity": "sha1-1USBHUKPmOsGpj3EAtJAPDKMOPc=",
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"extend-shallow": "^2.0.1", "extend-shallow": "^2.0.1",
"is-number": "^3.0.0", "is-number": "^3.0.0",
@@ -265,6 +269,7 @@
"resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz",
"integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=",
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"is-extendable": "^0.1.0" "is-extendable": "^0.1.0"
} }
@@ -330,7 +335,8 @@
"version": "2.1.1", "version": "2.1.1",
"resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz",
"integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=",
"dev": true "dev": true,
"optional": true
}, },
"is-glob": { "is-glob": {
"version": "4.0.1", "version": "4.0.1",
@@ -347,6 +353,7 @@
"resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz",
"integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=",
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"kind-of": "^3.0.2" "kind-of": "^3.0.2"
}, },
@@ -356,6 +363,7 @@
"resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz",
"integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=",
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"is-buffer": "^1.1.5" "is-buffer": "^1.1.5"
} }
@@ -366,13 +374,15 @@
"version": "3.0.1", "version": "3.0.1",
"resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz",
"integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=",
"dev": true "dev": true,
"optional": true
}, },
"kind-of": { "kind-of": {
"version": "6.0.2", "version": "6.0.2",
"resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz",
"integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==", "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==",
"dev": true "dev": true,
"optional": true
}, },
"micromatch": { "micromatch": {
"version": "3.1.10", "version": "3.1.10",
@@ -2881,9 +2891,9 @@
"dev": true "dev": true
}, },
"eslint": { "eslint": {
"version": "6.2.2", "version": "6.5.1",
"resolved": "https://registry.npmjs.org/eslint/-/eslint-6.2.2.tgz", "resolved": "https://registry.npmjs.org/eslint/-/eslint-6.5.1.tgz",
"integrity": "sha512-mf0elOkxHbdyGX1IJEUsNBzCDdyoUgljF3rRlgfyYh0pwGnreLc0jjD6ZuleOibjmnUWZLY2eXwSooeOgGJ2jw==", "integrity": "sha512-32h99BoLYStT1iq1v2P9uwpyznQ4M2jRiFB6acitKz52Gqn+vPaMDUTB1bYi1WN4Nquj2w+t+bimYUG83DC55A==",
"dev": true, "dev": true,
"requires": { "requires": {
"@babel/code-frame": "^7.0.0", "@babel/code-frame": "^7.0.0",
@@ -3001,9 +3011,9 @@
}, },
"dependencies": { "dependencies": {
"acorn": { "acorn": {
"version": "7.0.0", "version": "7.1.0",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-7.0.0.tgz", "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.1.0.tgz",
"integrity": "sha512-PaF/MduxijYYt7unVGRuds1vBC9bFxbNf+VWqhOClfdgy7RlVkQqt610ig1/yxTgsDIfW1cWDel5EBbOy3jdtQ==", "integrity": "sha512-kL5CuoXA/dgxlBbVrflsflzQ3PAas7RYZB52NOm/6839iVYJgKMJ3cQJD+t2i5+qFa8h3MDpEOJiS64E8JLnSQ==",
"dev": true "dev": true
} }
} }
@@ -3577,7 +3587,8 @@
"ansi-regex": { "ansi-regex": {
"version": "2.1.1", "version": "2.1.1",
"bundled": true, "bundled": true,
"dev": true "dev": true,
"optional": true
}, },
"aproba": { "aproba": {
"version": "1.2.0", "version": "1.2.0",
@@ -3598,12 +3609,14 @@
"balanced-match": { "balanced-match": {
"version": "1.0.0", "version": "1.0.0",
"bundled": true, "bundled": true,
"dev": true "dev": true,
"optional": true
}, },
"brace-expansion": { "brace-expansion": {
"version": "1.1.11", "version": "1.1.11",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"balanced-match": "^1.0.0", "balanced-match": "^1.0.0",
"concat-map": "0.0.1" "concat-map": "0.0.1"
@@ -3618,17 +3631,20 @@
"code-point-at": { "code-point-at": {
"version": "1.1.0", "version": "1.1.0",
"bundled": true, "bundled": true,
"dev": true "dev": true,
"optional": true
}, },
"concat-map": { "concat-map": {
"version": "0.0.1", "version": "0.0.1",
"bundled": true, "bundled": true,
"dev": true "dev": true,
"optional": true
}, },
"console-control-strings": { "console-control-strings": {
"version": "1.1.0", "version": "1.1.0",
"bundled": true, "bundled": true,
"dev": true "dev": true,
"optional": true
}, },
"core-util-is": { "core-util-is": {
"version": "1.0.2", "version": "1.0.2",
@@ -3745,7 +3761,8 @@
"inherits": { "inherits": {
"version": "2.0.3", "version": "2.0.3",
"bundled": true, "bundled": true,
"dev": true "dev": true,
"optional": true
}, },
"ini": { "ini": {
"version": "1.3.5", "version": "1.3.5",
@@ -3757,6 +3774,7 @@
"version": "1.0.0", "version": "1.0.0",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"number-is-nan": "^1.0.0" "number-is-nan": "^1.0.0"
} }
@@ -3771,6 +3789,7 @@
"version": "3.0.4", "version": "3.0.4",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"brace-expansion": "^1.1.7" "brace-expansion": "^1.1.7"
} }
@@ -3778,12 +3797,14 @@
"minimist": { "minimist": {
"version": "0.0.8", "version": "0.0.8",
"bundled": true, "bundled": true,
"dev": true "dev": true,
"optional": true
}, },
"minipass": { "minipass": {
"version": "2.3.5", "version": "2.3.5",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"safe-buffer": "^5.1.2", "safe-buffer": "^5.1.2",
"yallist": "^3.0.0" "yallist": "^3.0.0"
@@ -3802,6 +3823,7 @@
"version": "0.5.1", "version": "0.5.1",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"minimist": "0.0.8" "minimist": "0.0.8"
} }
@@ -3882,7 +3904,8 @@
"number-is-nan": { "number-is-nan": {
"version": "1.0.1", "version": "1.0.1",
"bundled": true, "bundled": true,
"dev": true "dev": true,
"optional": true
}, },
"object-assign": { "object-assign": {
"version": "4.1.1", "version": "4.1.1",
@@ -3894,6 +3917,7 @@
"version": "1.4.0", "version": "1.4.0",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"wrappy": "1" "wrappy": "1"
} }
@@ -3979,7 +4003,8 @@
"safe-buffer": { "safe-buffer": {
"version": "5.1.2", "version": "5.1.2",
"bundled": true, "bundled": true,
"dev": true "dev": true,
"optional": true
}, },
"safer-buffer": { "safer-buffer": {
"version": "2.1.2", "version": "2.1.2",
@@ -4015,6 +4040,7 @@
"version": "1.0.2", "version": "1.0.2",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"code-point-at": "^1.0.0", "code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^1.0.0", "is-fullwidth-code-point": "^1.0.0",
@@ -4034,6 +4060,7 @@
"version": "3.0.1", "version": "3.0.1",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"ansi-regex": "^2.0.0" "ansi-regex": "^2.0.0"
} }
@@ -4077,12 +4104,14 @@
"wrappy": { "wrappy": {
"version": "1.0.2", "version": "1.0.2",
"bundled": true, "bundled": true,
"dev": true "dev": true,
"optional": true
}, },
"yallist": { "yallist": {
"version": "3.0.3", "version": "3.0.3",
"bundled": true, "bundled": true,
"dev": true "dev": true,
"optional": true
} }
} }
}, },
@@ -4134,9 +4163,9 @@
} }
}, },
"glob-parent": { "glob-parent": {
"version": "5.0.0", "version": "5.1.0",
"resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.0.0.tgz", "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.0.tgz",
"integrity": "sha512-Z2RwiujPRGluePM6j699ktJYxmPpJKCfpGA13jz2hmFZC7gKetzrWvg5KN3+OsIFmydGyZ1AVwERCq1w/ZZwRg==", "integrity": "sha512-qjtRgnIVmOfnKUE3NJAQEdk+lKrxfw8t5ke7SXtfMTHcjsBfOfWXCQfdb30zfDoZQ2IRSIiidmjtbHZPZ++Ihw==",
"dev": true, "dev": true,
"requires": { "requires": {
"is-glob": "^4.0.1" "is-glob": "^4.0.1"
@@ -5972,9 +6001,9 @@
} }
}, },
"rxjs": { "rxjs": {
"version": "6.5.2", "version": "6.5.3",
"resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.5.2.tgz", "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.5.3.tgz",
"integrity": "sha512-HUb7j3kvb7p7eCUHE3FqjoDsC1xfZQ4AHFWfTKSpZ+sAhhz5X1WX0ZuUqWbzB2QhSLp3DoLUG+hMdEDKqWo2Zg==", "integrity": "sha512-wuYsAYYFdWTAnAaPoKGNhfpWwKZbJW+HgAJ+mImp+Epl7BG8oNWBCTyRM8gba9k4lk8BgWdoYm21Mo/RYhhbgA==",
"dev": true, "dev": true,
"requires": { "requires": {
"tslib": "^1.9.0" "tslib": "^1.9.0"

View File

@@ -4,8 +4,8 @@
"description": "The Javascript Wails Runtime", "description": "The Javascript Wails Runtime",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"build": "eslint core/ && npm run build:prod", "build": "./node_modules/.bin/eslint core/ && npm run build:prod",
"build:prod": "webpack --env prod --colors", "build:prod": "./node_modules/.bin/webpack --env prod --colors",
"test": "echo \"Error: no test specified\" && exit 1" "test": "echo \"Error: no test specified\" && exit 1"
}, },
"repository": { "repository": {
@@ -36,7 +36,7 @@
"babel-loader": "^8.0.6", "babel-loader": "^8.0.6",
"babel-preset-minify": "^0.5.0", "babel-preset-minify": "^0.5.0",
"core-js": "^3.1.4", "core-js": "^3.1.4",
"eslint": "^6.2.2", "eslint": "^6.5.1",
"webpack": "^4.35.3", "webpack": "^4.35.3",
"webpack-cli": "^3.3.5" "webpack-cli": "^3.3.5"
} }

View File

@@ -61,9 +61,9 @@ function Emit(eventName) {
* the event is acknowledged via `Event.Acknowledge`. Once this happens, `callback` is invoked ONCE * the event is acknowledged via `Event.Acknowledge`. Once this happens, `callback` is invoked ONCE
* *
* @export * @export
* @param {*} eventName * @param {string} eventName
* @param {*} timeInMilliseconds * @param {number} timeInMilliseconds
* @param {*} callback * @param {function} callback
*/ */
function Heartbeat(eventName, timeInMilliseconds, callback) { function Heartbeat(eventName, timeInMilliseconds, callback) {
window.wails.Events.Heartbeat(eventName, timeInMilliseconds, callback); window.wails.Events.Heartbeat(eventName, timeInMilliseconds, callback);

View File

@@ -18,6 +18,4 @@ function Init(callback) {
window.wails._.Init(callback); window.wails._.Init(callback);
} }
module.exports = { module.exports = Init;
Init
};

View File

@@ -1,8 +1,9 @@
{ {
"name": "@wailsapp/runtime", "name": "@wailsapp/runtime",
"version": "1.0.2", "version": "1.0.6",
"description": "Wails Javascript runtime library", "description": "Wails Javascript runtime library",
"main": "main.js", "main": "main.js",
"types": "runtime.d.ts",
"scripts": { "scripts": {
"test": "echo \"Error: no test specified\" && exit 1" "test": "echo \"Error: no test specified\" && exit 1"
}, },
@@ -20,5 +21,8 @@
"bugs": { "bugs": {
"url": "https://github.com/wailsapp/wails/issues" "url": "https://github.com/wailsapp/wails/issues"
}, },
"homepage": "https://github.com/wailsapp/wails#readme" "homepage": "https://github.com/wailsapp/wails#readme",
} "devDependencies": {
"dts-gen": "^0.5.8"
}
}

26
runtime/js/runtime/runtime.d.ts vendored Normal file
View File

@@ -0,0 +1,26 @@
export = wailsapp__runtime;
declare const wailsapp__runtime: {
Browser: {
OpenFile(filename: string): Promise<any>;
OpenURL(url: string): Promise<any>;
};
Events: {
Acknowledge(eventName: string): void;
Emit(eventName: string): void;
Heartbeat(eventName: string, timeInMilliseconds: number, callback: () => void): void;
On(eventName: string, callback: () => void): void;
OnMultiple(eventName: string, callback: () => void, maxCallbacks: number): void;
Once(eventName: string, callback: () => void): void;
};
Init(callback: () => void): void;
Log: {
Debug(message: string): void;
Error(message: string): void;
Fatal(message: string): void;
Info(message: string): void;
Warning(message: string): void;
};
};

View File

@@ -3,11 +3,17 @@
# Build runtime # Build runtime
echo "**** Building Runtime ****" echo "**** Building Runtime ****"
cd runtime/js cd runtime/js
npm install
npm run build npm run build
cd ../.. cd ../..
echo "**** Packing Assets ****" echo "**** Packing Assets ****"
cd cmd
mewn mewn
cd ..
cd lib/renderer
mewn
cd ../..
echo "**** Installing Wails locally ****" echo "**** Installing Wails locally ****"
cd cmd/wails cd cmd/wails