Compare commits

...

12 Commits

Author SHA1 Message Date
Lea Anthony
288feee1d9 angular windows fixes 2019-11-27 22:30:27 +11:00
Lea Anthony
416bd7bfc4 Merge branch 'develop' of https://github.com/wailsapp/wails into develop 2019-11-27 22:22:38 +11:00
Lea Anthony
aca72d3f7a Hidpi fix (#297)
* Add global error handler for runtime

* Set DPI Aware on windows
2019-11-27 22:22:10 +11:00
Lea Anthony
ad20e2622b Add global error handler for runtime 2019-11-27 21:28:33 +11:00
Lea Anthony
daeda501f4 Merge branch 'master' into develop 2019-11-05 14:45:30 +11:00
lea
fb1e8647bc release v0.19.0 2019-11-05 14:43:37 +11:00
Lea Anthony
723236f348 chore: bump version 2019-11-04 04:06:47 +11:00
Lea Anthony
394a823d82 fix: remove unicode flag 2019-11-04 04:02:42 +11:00
Lea Anthony
afe57802ad v0.18.15-pre 2019-11-02 21:07:02 +11:00
Lea Anthony
914642bd1d Backport (#283)
* Develop (#265)


* Patch for file dialog on OSX

* Update CONTRIBUTORS.md

* 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

* chore: version bump

* chore: version bump

* feat: adjust binary name for OS

* fix: allow spaces in gcc path

* feat: migrate command

* fix: npm/node versions

* fix: allow IE for serve

* feat: go build script

* fix: make runtime ES2015 compliant

* fix: remove invoke patch

* fix: allow any line endings

* chore: remove legacy bridge files

* chore: latest assets
2019-11-02 21:06:02 +11:00
Lea Anthony
d572418ec3 chore: version bump 2019-10-23 14:12:38 +11:00
Lea Anthony
8c7480d277 Develop (#265)
* Patch for file dialog on OSX

* Update CONTRIBUTORS.md

* 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

* chore: version bump
2019-10-23 14:08:56 +11:00
24 changed files with 156 additions and 79 deletions

View File

@@ -20,4 +20,4 @@ Wails is what it is because of the time and effort given by these great people.
* [Toyam Cox](https://github.com/Vaelatern) * [Toyam Cox](https://github.com/Vaelatern)
* [Robin Eklind](https://github.com/mewmew) * [Robin Eklind](https://github.com/mewmew)
* [Kris Raney](https://github.com/kraney) * [Kris Raney](https://github.com/kraney)
* [soon cheol shin](https://github.com/scshin0572) * [Jack Mordaunt](https://github.com/JackMordaunt)

21
app.go
View File

@@ -1,7 +1,9 @@
package wails package wails
import ( import (
"fmt"
"os" "os"
"runtime"
"syscall" "syscall"
"github.com/syossan27/tebata" "github.com/syossan27/tebata"
@@ -65,9 +67,28 @@ func CreateApp(optionalConfig ...*AppConfig) *App {
result.config.DisableInspector = true result.config.DisableInspector = true
} }
// If running windows, do a hidpi fix
if runtime.GOOS == "windows" {
err := SetProcessDPIAware()
if err != nil {
result.log.Fatalf(err.Error())
}
}
return result return result
} }
// SetProcessDPIAware via user32.dll
// https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setprocessdpiaware
// Also, thanks Jack Mordaunt! https://github.com/wailsapp/wails/issues/293
func SetProcessDPIAware() error {
status, r, err := syscall.NewLazyDLL("user32.dll").NewProc("SetProcessDPIAware").Call()
if status == 0 {
return fmt.Errorf("exit status %d: %v %v", status, r, err)
}
return nil
}
// Run the app // Run the app
func (a *App) Run() error { func (a *App) Run() error {

File diff suppressed because one or more lines are too long

View File

@@ -9,4 +9,4 @@
last 2 versions last 2 versions
Firefox ESR Firefox ESR
not dead not dead
not IE 9-11 # For IE 9-11 support, remove 'not'. IE 9-11 # For IE 9-11 support, remove 'not'.

View File

@@ -22,6 +22,7 @@
"@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", "@wailsapp/runtime": "^1.0.0",
"core-js": "^3.4.4",
"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",

View File

@@ -1,3 +1,4 @@
import 'core-js/stable';
import { enableProdMode } from '@angular/core'; import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';

View File

@@ -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);
}
}
};

View File

@@ -11,7 +11,7 @@
"module": "esnext", "module": "esnext",
"moduleResolution": "node", "moduleResolution": "node",
"importHelpers": true, "importHelpers": true,
"target": "es2015", "target": "es5",
"typeRoots": [ "typeRoots": [
"node_modules/@types" "node_modules/@types"
], ],
@@ -20,4 +20,4 @@
"dom" "dom"
] ]
} }
} }

View File

@@ -11,7 +11,7 @@ func basic() string {
func main() { func main() {
js := mewn.String("./frontend/dist/my-app/main-es2015.js") js := mewn.String("./frontend/dist/my-app/main.js")
css := mewn.String("./frontend/dist/my-app/styles.css") css := mewn.String("./frontend/dist/my-app/styles.css")
app := wails.CreateApp(&wails.AppConfig{ app := wails.CreateApp(&wails.AppConfig{

View File

@@ -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);
}
}
};

View File

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

File diff suppressed because one or more lines are too long

View File

@@ -13,7 +13,7 @@ package webview
#cgo linux openbsd freebsd CFLAGS: -DWEBVIEW_GTK=1 -Wno-deprecated-declarations #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 -std=c99 -DUNICODE=1 #cgo windows CFLAGS: -DWEBVIEW_WINAPI=1 -std=c99
#cgo windows LDFLAGS: -lole32 -lcomctl32 -loleaut32 -luuid -lgdi32 #cgo windows LDFLAGS: -lole32 -lcomctl32 -loleaut32 -luuid -lgdi32
#cgo darwin CFLAGS: -DWEBVIEW_COCOA=1 -x objective-c #cgo darwin CFLAGS: -DWEBVIEW_COCOA=1 -x objective-c

View File

@@ -95,13 +95,6 @@ function startBridge() {
window.wailsbridge.reconnectOverlay.style.display = 'none'; window.wailsbridge.reconnectOverlay.style.display = 'none';
} }
// Bridge external.invoke
window.external = {
invoke: function (msg) {
window.wailsbridge.websocket.send(msg);
}
};
// Adds a script to the Dom. // Adds a script to the Dom.
// Removes it if second parameter is true. // Removes it if second parameter is true.
function addScript(script, remove) { function addScript(script, remove) {
@@ -214,4 +207,4 @@ function Init(callback) {
start(callback); start(callback);
} }
module.exports = Init; module.exports = Init;

File diff suppressed because one or more lines are too long

View File

@@ -15,10 +15,7 @@
"error", "error",
"tab" "tab"
], ],
"linebreak-style": [ "linebreak-style": 0,
"error",
"unix"
],
"quotes": [ "quotes": [
"error", "error",
"single" "single"
@@ -28,4 +25,4 @@
"always" "always"
] ]
} }
} }

View File

@@ -15,7 +15,11 @@ The lightweight framework for web-like apps
* @param {string} message * @param {string} message
*/ */
function Invoke(message) { function Invoke(message) {
window.external.invoke(message); if ( window.wailsbridge ) {
window.wailsbridge.websocket.send(message);
} else {
window.external.invoke(message);
}
} }
/** /**

View File

@@ -46,6 +46,16 @@ var runtime = {
// Augment global // Augment global
Object.assign(window.wails, runtime); Object.assign(window.wails, runtime);
// Setup global error handler
window.onerror = function (msg, url, lineNo, columnNo, error) {
window.wails.Log.Error('**** Caught Unhandled Error ****');
window.wails.Log.Error('Message: ' + msg);
window.wails.Log.Error('URL: ' + url);
window.wails.Log.Error('Line No: ' + lineNo);
window.wails.Log.Error('Column No: ' + columnNo);
window.wails.Log.Error('error: ' + error);
};
// Emit loaded event // Emit loaded event
Emit('wails:loaded'); Emit('wails:loaded');

View File

@@ -32,6 +32,6 @@ function OpenFile(filename) {
} }
module.exports = { module.exports = {
OpenURL, OpenURL: OpenURL,
OpenFile OpenFile: OpenFile
}; };

View File

@@ -80,10 +80,10 @@ function Acknowledge(eventName) {
} }
module.exports = { module.exports = {
OnMultiple, OnMultiple: OnMultiple,
On, On: On,
Once, Once: Once,
Emit, Emit: Emit,
Heartbeat, Heartbeat: Heartbeat,
Acknowledge Acknowledge: Acknowledge
}; };

View File

@@ -62,9 +62,9 @@ function Fatal(message) {
} }
module.exports = { module.exports = {
Debug, Debug: Debug,
Info, Info: Info,
Warning, Warning: Warning,
Error, Error: Error,
Fatal Fatal: Fatal
}; };

View File

@@ -15,8 +15,8 @@ const Events = require('./events');
const Init = require('./init'); const Init = require('./init');
module.exports = { module.exports = {
Log, Log: Log,
Browser, Browser: Browser,
Events, Events: Events,
Init Init: Init
}; };

View File

@@ -1,6 +1,6 @@
{ {
"name": "@wailsapp/runtime", "name": "@wailsapp/runtime",
"version": "1.0.6", "version": "1.0.9",
"description": "Wails Javascript runtime library", "description": "Wails Javascript runtime library",
"main": "main.js", "main": "main.js",
"types": "runtime.d.ts", "types": "runtime.d.ts",

84
scripts/build.go Normal file
View File

@@ -0,0 +1,84 @@
package main
import (
"fmt"
"log"
"os"
"os/exec"
"path/filepath"
)
// Default target to run when none is specified
// If not set, running mage will list available targets
// var Default = Build
/*
# Build runtime
echo "**** Building Runtime ****"
cd runtime/js
npm install
npm run build
cd ../..
echo "**** Packing Assets ****"
cd cmd
mewn
cd ..
cd lib/renderer
mewn
cd ../..
echo "**** Installing Wails locally ****"
cd cmd/wails
go install
cd ../..
echo "**** Tidying the mods! ****"
go mod tidy
echo "**** WE ARE DONE! ****"
*/
func runCommand(command string, args ...string) {
cmd := exec.Command(command, args...)
output, err := cmd.CombinedOutput()
if err != nil {
log.Println(string(output))
log.Fatal(err)
}
cmd.Run()
fmt.Println(string(output))
}
// A build step that requires additional params, or platform specific steps for example
func main() {
dir, _ := os.Getwd()
// Build Runtime
fmt.Println("**** Building Runtime ****")
runtimeDir, _ := filepath.Abs(filepath.Join(dir, "..", "runtime", "js"))
os.Chdir(runtimeDir)
runCommand("npm", "install")
runCommand("npm", "run", "build")
// Pack assets
fmt.Println("**** Packing Assets ****")
rendererDir, _ := filepath.Abs(filepath.Join(dir, "..", "lib", "renderer"))
os.Chdir(rendererDir)
runCommand("mewn")
cmdDir, _ := filepath.Abs(filepath.Join(dir, "..", "cmd"))
os.Chdir(cmdDir)
runCommand("mewn")
// Install Wails
fmt.Println("**** Installing Wails locally ****")
execDir, _ := filepath.Abs(filepath.Join(dir, "..", "cmd", "wails"))
os.Chdir(execDir)
runCommand("go", "install")
baseDir, _ := filepath.Abs(filepath.Join(dir, ".."))
os.Chdir(baseDir)
runCommand("go", "mod", "tidy")
}