Compare commits

...

14 Commits

Author SHA1 Message Date
Lea Anthony
825dfaaf9c Merge branch 'develop' into backport 2019-11-02 21:00:01 +11:00
Lea Anthony
5f85d855cf chore: latest assets 2019-11-02 06:49:17 +11:00
Lea Anthony
4c40d93e0a chore: remove legacy bridge files 2019-11-02 06:48:48 +11:00
Lea Anthony
b76597b75e fix: allow any line endings 2019-11-02 06:48:28 +11:00
Lea Anthony
61377f08cd fix: remove invoke patch 2019-11-02 06:48:04 +11:00
Lea Anthony
094ea186e1 fix: make runtime ES2015 compliant 2019-11-02 06:47:22 +11:00
Lea Anthony
f9834dc9ca feat: go build script 2019-11-02 06:46:46 +11:00
Lea Anthony
58847055f5 fix: allow IE for serve 2019-11-02 06:46:32 +11:00
Lea Anthony
e9f7899b09 fix: npm/node versions 2019-11-02 06:45:50 +11:00
Lea Anthony
66c1c72c52 feat: migrate command 2019-11-02 06:45:32 +11:00
Lea Anthony
a68d74ffcd fix: allow spaces in gcc path 2019-11-02 06:43:18 +11:00
Lea Anthony
ca48a042da feat: adjust binary name for OS 2019-11-02 06:41:21 +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
15 changed files with 115 additions and 73 deletions

View File

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

File diff suppressed because one or more lines are too long

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

File diff suppressed because one or more lines are too long

View File

@@ -95,13 +95,6 @@ function startBridge() {
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.
// Removes it if second parameter is true.
function addScript(script, remove) {
@@ -214,4 +207,4 @@ function Init(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 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")}]);
!function(n){var e={};function t(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return n[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}t.m=n,t.c=e,t.d=function(n,e,r){t.o(n,e)||Object.defineProperty(n,e,{enumerable:!0,get:r})},t.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})},t.t=function(n,e){if(1&e&&(n=t(n)),8&e)return n;if(4&e&&"object"==typeof n&&n&&n.__esModule)return n;var r=Object.create(null);if(t.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:n}),2&e&&"string"!=typeof n)for(var o in n)t.d(r,o,function(e){return n[e]}.bind(null,o));return r},t.n=function(n){var e=n&&n.__esModule?function(){return n.default}:function(){return n};return t.d(e,"a",e),e},t.o=function(n,e){return Object.prototype.hasOwnProperty.call(n,e)},t.p="",t(t.s=0)}([function(n,e,t){"use strict";t.r(e);var r={};t.r(r),t.d(r,"Debug",function(){return c}),t.d(r,"Info",function(){return u}),t.d(r,"Warning",function(){return l}),t.d(r,"Error",function(){return f}),t.d(r,"Fatal",function(){return d});var o={};function i(n,e,t){var r={type:n,callbackID:t,payload:e};!function(n){window.wailsbridge?window.wailsbridge.websocket.send(n):window.external.invoke(n)}(JSON.stringify(r))}function a(n,e){i("log",{level:n,message:e})}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)}t.r(o),t.d(o,"OpenURL",function(){return y}),t.d(o,"OpenFile",function(){return g});var s,p={};function w(n,e,t){return null!=t&&null!=t||(t=0),new Promise(function(r,o){var a;do{a=n+"-"+s()}while(p[a]);if(t>0)var c=setTimeout(function(){o(Error("Call to "+n+" timed out. Request ID: "+a))},t);p[a]={timeoutHandle:c,reject:o,resolve:r};try{i("call",{bindingName:n,data:JSON.stringify(e)},a)}catch(n){console.error(n)}})}function v(n,e){return w(".wails."+n,e)}function y(n){return v("Browser.OpenURL",n)}function g(n){return v("Browser.OpenFile",n)}s=window.crypto?function(){var n=new Uint32Array(1);return window.crypto.getRandomValues(n)[0]}:function(){return 9007199254740991*Math.random()};var b=function n(e,t){!function(n,e){if(!(n instanceof e))throw new TypeError("Cannot call a class as a function")}(this,n),t=t||-1,this.Callback=function(n){return e.apply(null,n),-1!==t&&0===(t-=1)}},m={};function h(n,e,t){m[n]=m[n]||[];var r=new b(e,t);m[n].push(r)}function O(n){i("event",{name:n,data:JSON.stringify([].slice.apply(arguments).slice(1))})}var S={};function k(n){try{return new Function("var "+n),!0}catch(n){return!1}}function j(){return(j=Object.assign||function(n){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])}return n}).apply(this,arguments)}window.backend={},t.d(e,"Init",function(){return N}),window.wails=window.wails||{},window.backend={};var E={NewBinding:function(n){var e=[].concat(n.split(".").splice(1)),t=window.backend;if(e.length>1)for(var r=0;r<e.length-1;r+=1){var o=e[r];if(!k(o))return new Error("".concat(o," is not a valid javascript identifier."));t[o]||(t[o]={}),t=t[o]}var i=e.pop();if(!k(i))return new Error("".concat(i," is not a valid javascript identifier."));t[i]=function(){var e=0;function t(){var t=[].slice.call(arguments);return w(n,t,e)}return t.setTimeout=function(n){e=n},t.getTimeout=function(){return e},t}()},Callback:function(n){var e;n=decodeURIComponent(n.replace(/\s+/g,"").replace(/[0-9a-f]{2}/g,"%$&"));try{e=JSON.parse(n)}catch(e){var t="Invalid JSON passed to callback: ".concat(e.message,". Message: ").concat(n);throw c(t),new Error(t)}var r=e.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],e.error?o.reject(e.error):o.resolve(e.data)},Notify:function(n,e){if(m[n]){for(var t=m[n].slice(),r=0;r<m[n].length;r+=1){var o=m[n][r],i=[];if(e)try{i=JSON.parse(e)}catch(e){f("Invalid JSON data sent to notify. Event name = "+n)}o.Callback(i)&&t.splice(r,1)}m[n]=t}},AddScript:function(n,e){var t=document.createElement("script");t.text=n,document.body.appendChild(t),e&&O(e)},InjectCSS:function(n){var e=document.createElement("style");e.setAttribute("type","text/css"),e.styleSheet?e.styleSheet.cssText=n:e.appendChild(document.createTextNode(n)),(document.head||document.getElementsByTagName("head")[0]).appendChild(e)},Init:N},C={Log:r,Browser:o,Events:{On:function(n,e){h(n,e)},OnMultiple:h,Emit:O,Heartbeat:function(n,e,t){var r=null;S[n]=function(){clearInterval(r),t()},r=setInterval(function(){O(n)},e)},Acknowledge:function(n){if(!S[n])throw new f("Cannot acknowledge unknown heartbeat '".concat(n,"'"));S[n]()}},_:E};function N(n){n()}j(window.wails,C),O("wails:loaded")}]);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

83
scripts/build.go Normal file
View File

@@ -0,0 +1,83 @@
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.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")
}