Compare commits

..

2 Commits

Author SHA1 Message Date
Lea Anthony
68f7c4c7bd Unicode updates 2019-10-30 08:21:12 +11:00
Lea Anthony
c07900e555 WIP 2019-10-29 21:36:53 +11:00
40 changed files with 16638 additions and 1101 deletions

3
.gitignore vendored
View File

@@ -16,4 +16,5 @@ examples/**/example*
cmd/wails/wails cmd/wails/wails
.DS_Store .DS_Store
tmp tmp
node_modules/ node_modules/
/runtime/js/runtime/dist

View File

@@ -2,22 +2,22 @@
Wails is what it is because of the time and effort given by these great people. A huge thank you to each and every one! Wails is what it is because of the time and effort given by these great people. A huge thank you to each and every one!
* [Dustin Krysak](https://wiki.ubuntu.com/bashfulrobot) * [Dustin Krysak](https://wiki.ubuntu.com/bashfulrobot)
* [Qais Patankar](https://github.com/qaisjp) * [Qais Patankar](https://github.com/qaisjp)
* [Anthony Lee](https://github.com/alee792) * [Anthony Lee](https://github.com/alee792)
* [Adrian Lanzafame](https://github.com/lanzafame) * [Adrian Lanzafame](https://github.com/lanzafame)
* [Mattn](https://github.com/mattn) * [Mattn](https://github.com/mattn)
* [0xflotus](https://github.com/0xflotus) * [0xflotus](https://github.com/0xflotus)
* [Michael D Henderson](https://github.com/mdhender) * [Michael D Henderson](https://github.com/mdhender)
* [fred2104](https://github.com/fishfishfish2104) * [fred2104](https://github.com/fishfishfish2104)
* [intelwalk](https://github.com/intelwalk) * [intelwalk](https://github.com/intelwalk)
* [Mark Stenglein](https://github.com/ocelotsloth) * [Mark Stenglein](https://github.com/ocelotsloth)
* [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) * [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) * [Robin Eklind](https://github.com/mewmew)
* [Kris Raney](https://github.com/kraney) * [Kris Raney](https://github.com/kraney)
* [Jack Mordaunt](https://github.com/JackMordaunt) * [soon cheol shin](https://github.com/scshin0572)

View File

@@ -1,5 +1,5 @@
<p align="center" style="text-align: center"> <p align="center" style="text-align: center">
<img src="logo_cropped.png" width="40%"><br/> <img src="https://github.com/wailsapp/docs/raw/master/.vuepress/public/media/logo_cropped.png" width="40%"><br/>
</p> </p>
<p align="center"> <p align="center">
A framework for building desktop applications using Go & Web Technologies.<br/><br/> A framework for building desktop applications using Go & Web Technologies.<br/><br/>
@@ -16,8 +16,6 @@
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!
The official docs can be found at [https://wails.app](https://wails.app).
## Features ## Features
- Use standard Go libraries/frameworks for the backend - Use standard Go libraries/frameworks for the backend
@@ -30,6 +28,9 @@ The official docs can be found at [https://wails.app](https://wails.app).
- Powerful cli tool - Powerful cli tool
- Multiplatform - Multiplatform
## Project Status
Wails is currently in Beta. Please make sure you read the [Project Status](https://wails.app/project_status.html) if you are interested in using this project.
## Installation ## Installation
@@ -125,7 +126,8 @@ And without [these people](CONTRIBUTORS.md), it wouldn't be what it is today. A
Special Mentions: Special Mentions:
* [Byron](https://github.com/bh90210) - At times, Byron has single handedly kept this project alive. Without his incredible input, we never would have got to v1. * [Bill Kennedy](https://twitter.com/goinggodotnet) - Go guru, encourager and all-round nice guy, whose infectious energy and inspiration powered me on when I had none left.
* [Mark Bates](https://github.com/markbates) - Creator of [Packr](https://github.com/gobuffalo/packr), inspiration for packing strategies which fed into some of the tooling.
This project was mainly coded to the following albums: This project was mainly coded to the following albums:

7
app.go
View File

@@ -66,9 +66,6 @@ func CreateApp(optionalConfig ...*AppConfig) *App {
result.config.DisableInspector = true result.config.DisableInspector = true
} }
// Platform specific init
platformInit()
return result return result
} }
@@ -106,9 +103,9 @@ func (a *App) start() error {
return err return err
} }
// Enable console for Windows debug builds // Set debug mode
if runtime.GOOS == "windows" && BuildMode == cmd.BuildModeDebug { if runtime.GOOS == "windows" && BuildMode == cmd.BuildModeDebug {
a.renderer.EnableConsole() a.renderer.EnableDebug()
} }
// Start signal handler // Start signal handler

View File

@@ -1,7 +0,0 @@
// +build +linux +darwin !windows
package wails
func platformInit() {
}

View File

@@ -1,27 +0,0 @@
// +build windows !linux !darwin
package wails
import (
"fmt"
"log"
"syscall"
)
func platformInit() {
err := SetProcessDPIAware()
if err != nil {
log.Fatalf(err.Error())
}
}
// 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
}

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
IE 9-11 # For IE 9-11 support, remove 'not'. IE 9-11 # For IE 9-11 support, remove 'not'.

View File

@@ -22,7 +22,6 @@
"@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,4 +1,3 @@
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

@@ -11,7 +11,7 @@
"module": "esnext", "module": "esnext",
"moduleResolution": "node", "moduleResolution": "node",
"importHelpers": true, "importHelpers": true,
"target": "es5", "target": "es2015",
"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.js") js := mewn.String("./frontend/dist/my-app/main-es2015.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,4 +1,4 @@
package cmd package cmd
// Version - Wails version // Version - Wails version
const Version = "v1.0.1" const Version = "v0.18.14-pre"

View File

@@ -94,12 +94,12 @@ func (a *AppConfig) merge(in *AppConfig) error {
// Creates the default configuration // Creates the default configuration
func newConfig(userConfig *AppConfig) (*AppConfig, error) { func newConfig(userConfig *AppConfig) (*AppConfig, error) {
result := &AppConfig{ result := &AppConfig{
Width: 800, Width: 800,
Height: 600, Height: 600,
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"), defaultHTML: mewn.String("./runtime/assets/default.html"),
} }
if userConfig != nil { if userConfig != nil {

2
go.mod
View File

@@ -31,5 +31,3 @@ require (
gopkg.in/AlecAivazis/survey.v1 v1.8.4 gopkg.in/AlecAivazis/survey.v1 v1.8.4
gopkg.in/yaml.v3 v3.0.0-20190709130402-674ba3eaed22 gopkg.in/yaml.v3 v3.0.0-20190709130402-674ba3eaed22
) )
go 1.13

View File

@@ -8,7 +8,7 @@ import (
type Renderer interface { type Renderer interface {
Initialise(AppConfig, IPCManager, EventManager) error Initialise(AppConfig, IPCManager, EventManager) error
Run() error Run() error
EnableConsole() EnableDebug()
// Binding // Binding
NewBinding(bindingName string) error NewBinding(bindingName string) error

View File

@@ -48,6 +48,9 @@ type Bridge struct {
// Mutex for writing to the socket // Mutex for writing to the socket
lock sync.Mutex lock sync.Mutex
// debug
debug bool
} }
// Initialise the Bridge Renderer // Initialise the Bridge Renderer
@@ -74,8 +77,9 @@ func (h *Bridge) evalJS(js string, mtype messageType) error {
return nil return nil
} }
// EnableConsole not needed for bridge! // EnableDebug enables debug!
func (h *Bridge) EnableConsole() { func (h *Bridge) EnableDebug() {
h.debug = true
} }
func (h *Bridge) injectCSS(css string) { func (h *Bridge) injectCSS(css string) {
@@ -121,7 +125,6 @@ func (h *Bridge) sendMessage(conn *websocket.Conn, msg string) {
func (h *Bridge) start(conn *websocket.Conn) { func (h *Bridge) start(conn *websocket.Conn) {
// set external.invoke
h.log.Infof("Connected to frontend.") h.log.Infof("Connected to frontend.")
wailsRuntime := mewn.String("../../runtime/assets/wails.js") wailsRuntime := mewn.String("../../runtime/assets/wails.js")

File diff suppressed because one or more lines are too long

View File

@@ -19,13 +19,13 @@ import (
// WebView defines the main webview application window // WebView defines the main webview application window
// Default values in [] // Default values in []
type WebView struct { type WebView struct {
window wv.WebView // The webview object window wv.WebView // The webview object
ipc interfaces.IPCManager ipc interfaces.IPCManager
log *logger.CustomLogger log *logger.CustomLogger
config interfaces.AppConfig config interfaces.AppConfig
eventManager interfaces.EventManager eventManager interfaces.EventManager
bindingCache []string bindingCache []string
enableConsole bool debug bool
} }
// NewWebView returns a new WebView struct // NewWebView returns a new WebView struct
@@ -49,13 +49,22 @@ func (w *WebView) Initialise(config interfaces.AppConfig, ipc interfaces.IPCMana
// Save the config // Save the config
w.config = config w.config = config
// defaulthtml
HTML := config.GetDefaultHTML()
if len(HTML) == 0 {
HTML = mewn.String("../../runtime/assets/default.html")
}
HTML = fmt.Sprintf("data:text/html,%s", HTML)
fmt.Printf("*** %s ***", HTML)
w.log.Infof("URL: %s", HTML)
// Create the WebView instance // Create the WebView instance
w.window = wv.NewWebview(wv.Settings{ w.window = wv.NewWebview(wv.Settings{
Width: config.GetWidth(), Width: config.GetWidth(),
Height: config.GetHeight(), Height: config.GetHeight(),
Title: config.GetTitle(), Title: config.GetTitle(),
Resizable: config.GetResizable(), Resizable: config.GetResizable(),
URL: config.GetDefaultHTML(), URL: HTML,
Debug: !config.GetDisableInspector(), Debug: !config.GetDisableInspector(),
ExternalInvokeCallback: func(_ wv.WebView, message string) { ExternalInvokeCallback: func(_ wv.WebView, message string) {
w.ipc.Dispatch(message) w.ipc.Dispatch(message)
@@ -96,6 +105,7 @@ func (w *WebView) evalJS(js string) error {
if len(js) > 45 { if len(js) > 45 {
outputJS += "..." outputJS += "..."
} }
// var outputJS = js
w.log.DebugFields("Eval", logger.Fields{"js": outputJS}) w.log.DebugFields("Eval", logger.Fields{"js": outputJS})
// //
w.window.Dispatch(func() { w.window.Dispatch(func() {
@@ -104,9 +114,9 @@ func (w *WebView) evalJS(js string) error {
return nil return nil
} }
// EnableConsole enables the console! // EnableDebug enables debug!
func (w *WebView) EnableConsole() { func (w *WebView) EnableDebug() {
w.enableConsole = true w.debug = true
} }
// Escape the Javascripts! // Escape the Javascripts!
@@ -179,57 +189,57 @@ func (w *WebView) Run() error {
w.log.Info("Running...") w.log.Info("Running...")
// Inject firebug in debug mode on Windows // Inject firebug in debug mode on Windows
if w.enableConsole { if w.debug {
w.log.Debug("Enabling Wails console") w.log.Debug("Injecting firebug")
console := mewn.String("../../runtime/assets/console.js") // firebugLite := mewn.String("../../runtime/assets/injectFirebug.js")
w.evalJS(console) // w.evalJS(firebugLite)
} }
// Runtime assets // // Runtime assets
wailsRuntime := mewn.String("../../runtime/assets/wails.js") // wailsRuntime := mewn.String("../../runtime/assets/wails.js")
w.evalJS(wailsRuntime) // w.evalJS(wailsRuntime)
// 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{}) {
// Run this in a different go routine to free up the main process // // Run this in a different go routine to free up the main process
go func() { // go func() {
// Inject Bindings // // Inject Bindings
for _, binding := range w.bindingCache { // for _, binding := range w.bindingCache {
w.evalJSSync(binding) // w.evalJSSync(binding)
} // }
// Inject user CSS // // Inject user CSS
if w.config.GetCSS() != "" { // if w.config.GetCSS() != "" {
outputCSS := fmt.Sprintf("%.45s", w.config.GetCSS()) // outputCSS := fmt.Sprintf("%.45s", w.config.GetCSS())
if len(outputCSS) > 45 { // if len(outputCSS) > 45 {
outputCSS += "..." // outputCSS += "..."
} // }
w.log.DebugFields("Inject User CSS", logger.Fields{"css": outputCSS}) // w.log.DebugFields("Inject User CSS", logger.Fields{"css": outputCSS})
w.injectCSS(w.config.GetCSS()) // w.injectCSS(w.config.GetCSS())
} else { // } else {
// Use default wails css // // Use default wails css
w.log.Debug("Injecting Default Wails CSS") // w.log.Debug("Injecting Default Wails CSS")
defaultCSS := mewn.String("../../runtime/assets/wails.css") // defaultCSS := mewn.String("../../runtime/assets/wails.css")
w.injectCSS(defaultCSS) // w.injectCSS(defaultCSS)
} // }
// Inject user JS // // Inject user JS
if w.config.GetJS() != "" { // if w.config.GetJS() != "" {
outputJS := fmt.Sprintf("%.45s", w.config.GetJS()) // outputJS := fmt.Sprintf("%.45s", w.config.GetJS())
if len(outputJS) > 45 { // if len(outputJS) > 45 {
outputJS += "..." // outputJS += "..."
} // }
w.log.DebugFields("Inject User JS", logger.Fields{"js": outputJS}) // w.log.DebugFields("Inject User JS", logger.Fields{"js": outputJS})
w.evalJSSync(w.config.GetJS()) // w.evalJSSync(w.config.GetJS())
} // }
// Emit that everything is loaded and ready // // Emit that everything is loaded and ready
w.eventManager.Emit("wails:ready") // w.eventManager.Emit("wails:ready")
}() // }()
}) // })
// Kick off main window loop // Kick off main window loop
w.window.Run() w.window.Run()

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 #cgo windows CFLAGS: -DWEBVIEW_WINAPI=1 -std=c99 -DUNICODE=1 -D_UNICODE=1
#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

@@ -58,6 +58,7 @@ extern "C"
#elif defined(WEBVIEW_WINAPI) #elif defined(WEBVIEW_WINAPI)
#define CINTERFACE #define CINTERFACE
#include <windows.h> #include <windows.h>
#include <tchar.h>
#include <commctrl.h> #include <commctrl.h>
#include <exdisp.h> #include <exdisp.h>
@@ -1350,8 +1351,8 @@ struct webview_priv
} }
#define WEBVIEW_KEY_FEATURE_BROWSER_EMULATION \ #define WEBVIEW_KEY_FEATURE_BROWSER_EMULATION \
"Software\\Microsoft\\Internet " \ _T("Software\\Microsoft\\Internet " \
"Explorer\\Main\\FeatureControl\\FEATURE_BROWSER_EMULATION" "Explorer\\Main\\FeatureControl\\FEATURE_BROWSER_EMULATION")
static int webview_fix_ie_compat_mode() static int webview_fix_ie_compat_mode()
{ {
@@ -1363,7 +1364,7 @@ struct webview_priv
{ {
return -1; return -1;
} }
for (p = &appname[strlen(appname) - 1]; p != appname && *p != '\\'; p--) for (p = &appname[_tcslen(appname) - 1]; p != appname && *p != _T('\\'); p--)
{ {
} }
p++; p++;
@@ -1872,14 +1873,30 @@ struct webview_priv
type |= MB_ICONERROR; type |= MB_ICONERROR;
break; break;
} }
#ifdef UNICODE
WCHAR *wtitle = webview_to_utf16(title);
WCHAR *warg = webview_to_utf16(arg);
MessageBox(w->priv.hwnd, warg, wtitle, type);
GlobalFree(warg);
GlobalFree(wtitle);
#else
MessageBox(w->priv.hwnd, arg, title, type); MessageBox(w->priv.hwnd, arg, title, type);
#endif
#endif #endif
} }
} }
WEBVIEW_API void webview_terminate(struct webview *w) { PostQuitMessage(0); } WEBVIEW_API void webview_terminate(struct webview *w) { PostQuitMessage(0); }
WEBVIEW_API void webview_exit(struct webview *w) { OleUninitialize(); } WEBVIEW_API void webview_exit(struct webview *w) { OleUninitialize(); }
WEBVIEW_API void webview_print_log(const char *s) { OutputDebugString(s); } WEBVIEW_API void webview_print_log(const char *s) {
#ifdef UNICODE
WCHAR *ws = webview_to_utf16(s);
OutputDebugString(ws);
GlobalFree(ws);
#else
OutputDebugString(s);
#endif
}
#endif /* WEBVIEW_WINAPI */ #endif /* WEBVIEW_WINAPI */

Binary file not shown.

Before

Width:  |  Height:  |  Size: 122 KiB

View File

@@ -204,7 +204,12 @@ function start(callback) {
} }
function Init(callback) { function Init(callback) {
// Bridge window.invoke
window.invoke = function (message) {
window.wailsbridge.websocket.send(message);
}
start(callback); start(callback);
} }
module.exports = Init; module.exports = Init;

View File

@@ -1,175 +0,0 @@
(function () {
window.wailsconsole = {};
var debugconsole = document.createElement("div");
var header = document.createElement("div");
var consoleOut = document.createElement("div");
document.addEventListener('keyup', logKey);
debugconsole.id = "wailsdebug";
debugconsole.style.fontSize = "18px";
debugconsole.style.width = "100%";
debugconsole.style.height = "35%";
debugconsole.style.maxHeight = "35%";
debugconsole.style.position = "fixed";
debugconsole.style.left = "0px";
debugconsole.style.backgroundColor = "rgba(255,255,255,0.8)";
debugconsole.style.borderTop = '1px solid black';
debugconsole.style.color = "black";
debugconsole.style.display = "none";
header.style.width = "100%";
header.style.height = "30px";
header.style.display = "block";
// header.style.paddingTop = "3px";
header.style.verticalAlign = "middle";
header.style.paddingLeft = "10px";
header.style.background = "rgba(255,255,255,0.8)";
header.innerHTML = " <span style='vertical-align: middle'> Wails Console > <input id='conin' style='border: solid 1px black; width: 50%'></input><span style='padding-left: 5px; cursor:pointer;' onclick='window.wailsconsole.clearConsole()'>Clear</span></span>";
consoleOut.style.position = "absolute";
consoleOut.style.width = "100%";
consoleOut.style.height = "auto";
consoleOut.style.top = "30px";
// consoleOut.style.paddingLeft = "10px";
consoleOut.style.bottom = "0px";
consoleOut.style.backgroundColor = "rgba(200,200,200,1)";
consoleOut.style.overflowY = "scroll";
consoleOut.style.msOverflowStyle = "-ms-autohiding-scrollbar";
debugconsole.appendChild(header);
debugconsole.appendChild(consoleOut);
document.body.appendChild(debugconsole);
console.log(debugconsole.style.display)
function logKey(e) {
var conin = document.getElementById('conin');
if (e.which == 27 && e.shiftKey) {
toggleConsole(conin);
}
if (e.which == 13 && consoleVisible()) {
var command = conin.value.trim();
if (command.length > 0) {
console.log("> " + command)
try {
evaluateInput(command);
} catch (e) {
console.error(e.message);
}
conin.value = "";
}
}
};
function consoleVisible() {
return debugconsole.style.display == "block";
}
function toggleConsole(conin) {
var display = "none"
if (debugconsole.style.display == "none") display = "block";
debugconsole.style.display = display;
if (display == "block") {
conin.focus();
}
}
function evaluateExpression(expression) {
var pathSegments = [].concat(expression.split('.'));
if (pathSegments[0] == 'window') {
pathSegments.shift()
}
var currentObject = window;
for (var i = 0; i < pathSegments.length; i++) {
var pathSegment = pathSegments[i];
if (currentObject[pathSegment] == undefined) {
return false;
}
currentObject = currentObject[pathSegment];
}
console.log(JSON.stringify(currentObject));
return true;
}
function evaluateInput(command) {
try {
if (evaluateExpression(command)) {
return
} else {
eval(command);
}
} catch (e) {
console.error(e.message)
}
}
// Set us up as a listener
function hookIntoIPC() {
if (window.wails && window.wails._ && window.wails._.AddIPCListener) {
window.wails._.AddIPCListener(processIPCMessage);
} else {
setTimeout(hookIntoIPC, 100);
}
}
hookIntoIPC();
function processIPCMessage(message) {
console.log(message);
var parsedMessage;
try {
parsedMessage = JSON.parse(message);
} catch (e) {
console.error("Error in parsing IPC message: " + e.message);
return false;
}
var logmessage = "[IPC] "
switch (parsedMessage.type) {
case 'call':
logmessage += " Call: " + parsedMessage.payload.bindingName;
var params = "";
var parsedParams = JSON.parse(parsedMessage.payload.data);
if (parsedParams.length > 0) {
params = parsedParams;
}
logmessage += "(" + params + ")";
break;
case 'log':
logmessage += "Log (" + parsedMessage.payload.level + "): " + parsedMessage.payload.message;
break;
default:
logmessage = message;
}
console.log(logmessage);
}
window.wailsconsole.clearConsole = function () {
consoleOut.innerHTML = "";
}
console.log = function (message) {
consoleOut.innerHTML = consoleOut.innerHTML + "<span style='padding-left: 5px'>" + message + '</span><br/>';
consoleOut.scrollTop = consoleOut.scrollHeight;
};
console.error = function (message) {
consoleOut.innerHTML = consoleOut.innerHTML + "<span style='color:red; padding-left: 5px'> Error: " + message + '</span><br/>';
consoleOut.scrollTop = consoleOut.scrollHeight;
};
// var h = document.getElementsByTagName("html")[0];
// console.log("html margin: " + h.style.marginLeft);
// console.log("html padding: " + h.style.paddingLeft);
// setInterval(function() { console.log("test");}, 1000);
// setInterval(function() { console.error("oops");}, 3000);
// var script = document.createElement('script');
// script.src = "https://cdnjs.cloudflare.com/ajax/libs/firebug-lite/1.4.0/firebug-lite.js#startOpened=true";
// document.body.appendChild(script);
})();

View File

@@ -1,18 +1 @@
<!DOCTYPE html> <!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><script src="https://raw.githubusercontent.com/firebug/firebug-lite/master/build/firebug-lite-debug.js#startOpened=true"></script></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 lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
</head>
<body>
<div id="app"></div>
<script type="text/javascript">function AddScript(js, callbackID) {
var script = document.createElement('script');
script.text = js;
document.body.appendChild(script);
}</script>
</body>
</html>

10945
runtime/assets/firebug-lite.js Normal file

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
(function(){console.log=function(message){document.body.innerHTML=document.body.innerHTML+'<p>'+message+'</p>';};var script=document.createElement('script');script.src="https://raw.githubusercontent.com/firebug/firebug-lite/master/build/firebug-lite-debug.js#startOpened=true";document.body.appendChild(script);})();

File diff suppressed because one or more lines are too long

View File

@@ -25,4 +25,4 @@
"always" "always"
] ]
} }
} }

View File

@@ -7,7 +7,7 @@ module.exports = function (api) {
[ [
"@babel/preset-env", "@babel/preset-env",
{ {
"useBuiltIns": "entry", "useBuiltIns": "usage",
"corejs": { "corejs": {
"version": 3, "version": 3,
"proposals": true "proposals": true
@@ -16,7 +16,10 @@ module.exports = function (api) {
] ]
]; ];
const plugins = ["@babel/plugin-transform-object-assign", "transform-es2015-shorthand-properties"]
return { return {
presets, presets,
plugins
}; };
} }

View File

@@ -0,0 +1,37 @@
/* eslint-disable */
const path = require('path');
module.exports = {
entry: './bridge.js',
mode: 'production',
output: {
path: path.resolve(__dirname, '..', 'assets'),
filename: 'bridge.js',
libraryTarget: 'this'
},
module: {
rules: [
{
test: /\.m?js$/,
exclude: /(node_modules|bower_components)/,
use: {
loader: 'babel-loader',
options: {
plugins: [],
presets: [
[
'@babel/preset-env',
{
'useBuiltIns': 'usage',
'corejs': 3,
'targets': { "browsers": ["last 2 versions", "ie >= 9"] }
}
]
]
}
}
}
]
}
};

View File

@@ -9,35 +9,17 @@ The lightweight framework for web-like apps
*/ */
/* jshint esversion: 6 */ /* jshint esversion: 6 */
// IPC Listeners
var listeners = [];
/**
* Adds a listener to IPC messages
* @param {function} callback
*/
export function AddIPCListener(callback) {
listeners.push(callback);
}
/** /**
* Invoke sends the given message to the backend * Invoke sends the given message to the backend
* *
* @param {string} message * @param {string} message
*/ */
function Invoke(message) { function Invoke(message) {
if (window.wailsbridge) { if ( window.wailsbridge ) {
window.wailsbridge.websocket.send(message); window.wailsbridge.websocket.send(message);
} else { } else {
window.external.invoke(message); window.external.invoke(message);
} }
// Also send to listeners
if (listeners.length > 0) {
for (var i = 0; i < listeners.length; i++) {
listeners[i](message);
}
}
} }
/** /**

View File

@@ -14,7 +14,6 @@ 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';
import { AddIPCListener } from './ipc';
// Initialise global if not already // Initialise global if not already
window.wails = window.wails || {}; window.wails = window.wails || {};
@@ -28,7 +27,6 @@ var internal = {
AddScript, AddScript,
InjectCSS, InjectCSS,
Init, Init,
AddIPCListener,
}; };
// Setup runtime structure // Setup runtime structure
@@ -48,16 +46,6 @@ 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');

File diff suppressed because it is too large Load Diff

View File

@@ -33,11 +33,15 @@
"@babel/core": "^7.5.4", "@babel/core": "^7.5.4",
"@babel/plugin-transform-object-assign": "^7.2.0", "@babel/plugin-transform-object-assign": "^7.2.0",
"@babel/preset-env": "^7.5.4", "@babel/preset-env": "^7.5.4",
"babel-core": "^6.26.3",
"babel-loader": "^8.0.6", "babel-loader": "^8.0.6",
"babel-plugin-transform-es2015-shorthand-properties": "^6.24.1",
"babel-preset-es2015": "^6.24.1",
"babel-preset-minify": "^0.5.0", "babel-preset-minify": "^0.5.0",
"core-js": "^3.1.4", "core-js": "^3.1.4",
"eslint": "^6.5.1", "eslint": "^6.5.1",
"webpack": "^4.35.3", "webpack": "^4.41.2",
"webpack-cli": "^3.3.5" "webpack-cli": "^3.3.5"
} },
"dependencies": {}
} }

4322
runtime/js/runtime/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,11 +1,12 @@
{ {
"name": "@wailsapp/runtime", "name": "@wailsapp/runtime",
"version": "1.0.9", "version": "1.0.8",
"description": "Wails Javascript runtime library", "description": "Wails Javascript runtime library",
"main": "main.js", "main": "main.js",
"types": "runtime.d.ts", "types": "runtime.d.ts",
"scripts": { "scripts": {
"test": "echo \"Error: no test specified\" && exit 1" "test": "echo \"Error: no test specified\" && exit 1",
"build": "webpack"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
@@ -21,8 +22,18 @@
"bugs": { "bugs": {
"url": "https://github.com/wailsapp/wails/issues" "url": "https://github.com/wailsapp/wails/issues"
}, },
"files": [
"*.js",
"!webpack.config.js",
"runtime.d.ts",
"README.md"
],
"homepage": "https://github.com/wailsapp/wails#readme", "homepage": "https://github.com/wailsapp/wails#readme",
"devDependencies": { "devDependencies": {
"dts-gen": "^0.5.8" "babel-core": "^6.26.3",
"babel-loader": "^8.0.6",
"babel-preset-es2015": "^6.24.1",
"dts-gen": "^0.5.8",
"webpack": "^4.41.2"
} }
} }

View File

@@ -0,0 +1,37 @@
/* eslint-disable */
const path = require('path');
module.exports = {
entry: './main.js',
mode: 'production',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'main.js',
libraryTarget: 'this'
},
module: {
rules: [
{
test: /\.m?js$/,
exclude: /(node_modules|bower_components)/,
use: {
loader: 'babel-loader',
options: {
plugins: [],
presets: [
[
'@babel/preset-env',
{
'useBuiltIns': 'usage',
'corejs': 3,
'targets': { "browsers": ["last 2 versions", "ie >= 9"] }
}
]
]
}
}
}
]
}
};

View File

@@ -17,16 +17,14 @@ module.exports = {
use: { use: {
loader: 'babel-loader', loader: 'babel-loader',
options: { options: {
plugins: ['@babel/plugin-transform-object-assign'], plugins: [],
presets: [ presets: [
[ [
'@babel/preset-env', '@babel/preset-env',
{ {
'useBuiltIns': 'entry', 'useBuiltIns': 'usage',
'corejs': { 'corejs': 3,
'version': 3, 'targets': { "browsers": ["last 2 versions", "ie >= 9"] }
'proposals': true
}
} }
] ]
] ]

View File

@@ -43,9 +43,7 @@ echo "**** WE ARE DONE! ****"
func runCommand(command string, args ...string) { func runCommand(command string, args ...string) {
cmd := exec.Command(command, args...) cmd := exec.Command(command, args...)
output, err := cmd.CombinedOutput() output, err := cmd.CombinedOutput()
fmt.Println(string(output))
if err != nil { if err != nil {
log.Println(string(output))
log.Fatal(err) log.Fatal(err)
} }
cmd.Run() cmd.Run()
@@ -61,7 +59,6 @@ func main() {
fmt.Println("**** Building Runtime ****") fmt.Println("**** Building Runtime ****")
runtimeDir, _ := filepath.Abs(filepath.Join(dir, "..", "runtime", "js")) runtimeDir, _ := filepath.Abs(filepath.Join(dir, "..", "runtime", "js"))
os.Chdir(runtimeDir) os.Chdir(runtimeDir)
runCommand("npm", "install")
runCommand("npm", "run", "build") runCommand("npm", "run", "build")
// Pack assets // Pack assets