Compare commits

...

49 Commits

Author SHA1 Message Date
Lea Anthony
3f50b95f26 Add helpful message after serving 2019-01-31 18:59:07 +11:00
Lea Anthony
259eec97d6 Added serve.
Serve only builds backend.
Build is always release build.
2019-01-31 18:48:12 +11:00
Lea Anthony
8b2168abe7 upgraded spinner to 0.5.0 2019-01-31 18:47:27 +11:00
Lea Anthony
c5cee79ff7 add webview license 2019-01-30 20:28:21 +11:00
Lea Anthony
0ca039e914 Initial commit of simplification 2019-01-30 09:00:46 +11:00
Lea Anthony
cd8b4f088f Merge pull request #29 from wailsapp/Move-headless-capability-into-own-library
Move headless capability into own library
2019-01-29 08:37:33 +11:00
Lea Anthony
847842504b Merge branch 'master' into Move-headless-capability-into-own-library 2019-01-29 08:36:27 +11:00
Lea Anthony
8ab91d31fe reduce function complexity 2019-01-29 08:36:21 +11:00
Lea Anthony
bb4d891549 Merge pull request #28 from wailsapp/Create-consistent-templates
Updated custom html
2019-01-29 08:31:21 +11:00
Lea Anthony
4a316a76fa Updated custom html 2019-01-29 08:30:38 +11:00
Lea Anthony
529e4cc07e Merge pull request #27 from wailsapp/Create-consistent-templates
update basic templates to use a frontend dir
2019-01-29 08:29:40 +11:00
Lea Anthony
579747d0f7 update basic templates to use a frontend dir 2019-01-29 08:28:59 +11:00
Lea Anthony
6880c53082 Merge pull request #26 from wailsapp/Move-headless-capability-into-own-library
Move headless capability into own library
2019-01-23 08:36:02 +11:00
Lea Anthony
6e011e75c3 updated vue template 2019-01-23 08:35:12 +11:00
Lea Anthony
683ba7dc59 support bridge mode
streamline some messaging
2019-01-23 06:01:45 +11:00
Lea Anthony
717e598330 Linter fix 2019-01-16 08:19:30 +11:00
Lea Anthony
a6489a1044 Merge pull request #25 from wailsapp/create-wails-css
Update basic template to use default CSS
2019-01-15 18:53:12 +11:00
Lea Anthony
df911adcae Update basic template to use default CSS 2019-01-15 18:52:18 +11:00
Lea Anthony
d7c0b1ec58 Merge pull request #24 from wailsapp/create-wails-css
inject default css if none given
2019-01-15 18:51:08 +11:00
Lea Anthony
7135d4fa27 inject default css if none given 2019-01-15 18:50:26 +11:00
Lea Anthony
83e063bf2b Merge pull request #23 from wailsapp/Update-execution-order-in-Headless-mode
Update execution order in headless mode
2019-01-15 08:36:10 +11:00
Lea Anthony
6e0773b355 fix for rendering fragments via headless 2019-01-15 08:34:32 +11:00
Lea Anthony
60f34223b0 bugfix for force rebuild 2019-01-15 08:33:48 +11:00
Lea Anthony
539be2ce84 Updated comments 2019-01-14 22:46:45 +11:00
Lea Anthony
561198b81b Fix unicode escaping 2019-01-14 19:18:03 +11:00
Lea Anthony
c823215eb6 Merge pull request #21 from wailsapp/Fix-npm-project-name
Fix npm package name
2019-01-13 18:04:39 +11:00
Lea Anthony
93f890f6d9 Fix npm package name 2019-01-13 18:02:51 +11:00
Lea Anthony
8a3aec6866 Merge pull request #20 from wailsapp/Update-execution-order-in-Headless-mode
Numerous fixes for headless mode.
2019-01-13 17:58:34 +11:00
Lea Anthony
1ef8ed73ab Remove debug statements 2019-01-13 17:57:21 +11:00
Lea Anthony
9004c3955e Numerous fixes for headless mode.
Remove script dom elements for internal calls.
2019-01-13 17:54:38 +11:00
Lea Anthony
4c98ce7da1 Merge pull request #19 from wailsapp/Update-execution-order-in-Headless-mode
fix for ipc binding
2019-01-12 16:00:44 +11:00
Lea Anthony
0ae5381203 fix for ipc binding
made reconnect modal a bit better
2019-01-12 15:56:49 +11:00
Lea Anthony
3f2f1b45f6 Merge pull request #18 from wailsapp/Support-Packaging
Add Licenses
2019-01-12 09:37:27 +11:00
Lea Anthony
e6bec8f7cc Add Licenses 2019-01-12 09:26:51 +11:00
Lea Anthony
f1f15fc1c5 Merge pull request #17 from wailsapp/Support-Packaging
Initial port of packager
2019-01-11 21:17:53 +11:00
Lea Anthony
bcca09563c Initial port of packager 2019-01-11 21:16:52 +11:00
Lea Anthony
ee355659ce Merge pull request #16 from wailsapp/change-code-mount-point
now binds go code to window.backend
2019-01-11 20:03:20 +11:00
Lea Anthony
a660e4a9da now binds go code to window.backend 2019-01-11 20:02:43 +11:00
Lea Anthony
a44fd57e98 Merge pull request #15 from wailsapp/Port-Build
Port build
2019-01-11 07:01:18 +11:00
Lea Anthony
c0371f141a Merge pull request #14 from wailsapp/Port-Build
Update vue template to use BoxString
2019-01-11 06:49:31 +11:00
Lea Anthony
a3c41d1740 Merge pull request #13 from wailsapp/Port-Build
Fix frameworkspinner
2019-01-11 06:32:41 +11:00
Lea Anthony
fb081b4876 Merge pull request #12 from wailsapp/Port-Build
Port build
2019-01-11 06:16:30 +11:00
Lea Anthony
9167063976 Merge pull request #11 from wailsapp/Port-Build
Made init less verbose
2019-01-09 08:26:56 +11:00
Lea Anthony
ffdbb0af64 Merge pull request #10 from wailsapp/Port-Build
updated runtime assets
2019-01-09 08:10:14 +11:00
Lea Anthony
d4b2563e9b Merge pull request #9 from wailsapp/Port-Build
mute logging of injected scripts
2019-01-09 06:35:52 +11:00
Lea Anthony
ab6e7531b4 Merge pull request #8 from wailsapp/Port-Build
Add assets
2019-01-08 21:33:04 +11:00
Lea Anthony
13efa58c9a Merge pull request #7 from wailsapp/Port-Build
fixes building on linux
2019-01-08 21:04:35 +11:00
Lea Anthony
0011e39c55 Merge pull request #6 from wailsapp/Port-Build
Initial Port
2019-01-08 20:15:49 +11:00
Lea Anthony
733258cc83 Merge pull request #5 from wailsapp/Port-Build
Initial commit of wails build
2019-01-08 07:59:22 +11:00
80 changed files with 1281 additions and 769 deletions

View File

@@ -1,17 +0,0 @@
lib/project/templates/vue
lib/project/templates/blank
tools
test
.vscode/
tmp
examples/**/example*
!examples/**/*.*
node_modules
cmd.old
lib.old
cmd/wails/wails
.DS_Store
rewrite
.rewrite
examples/WIP/*
docs

File diff suppressed because one or more lines are too long

15
app.go
View File

@@ -2,7 +2,6 @@ package wails
import (
"github.com/wailsapp/wails/cmd"
"github.com/wailsapp/wails/cmd/frameworks"
)
// -------------------------------- Compile time Flags ------------------------------
@@ -18,7 +17,6 @@ type App struct {
cli *cmd.Cli // In debug mode, we have a cli
renderer Renderer // The renderer is what we will render the app to
logLevel string // The log level of the app
headless bool // Indicates if the app should be started in headless mode
ipc *ipcManager // Handles the IPC calls
log *CustomLogger // Logger
bindingManager *bindingManager // Handles binding of Go code to renderer
@@ -69,10 +67,10 @@ func CreateApp(optionalConfig ...*AppConfig) *App {
func (a *App) Run() error {
if DebugMode == "true" {
return a.cli.Run()
} else {
a.logLevel = "error"
return a.start()
}
a.logLevel = "error"
return a.start()
}
func (a *App) start() error {
@@ -84,7 +82,7 @@ func (a *App) start() error {
a.log.Info("Starting")
// Check if we are to run in headless mode
if a.headless {
if DebugMode == "true" {
a.renderer = &Headless{}
}
@@ -109,11 +107,6 @@ func (a *App) start() error {
return err
}
// Inject framework, if specified
if frameworks.FrameworkToUse != nil {
a.renderer.InjectFramework(frameworks.FrameworkToUse.JS, frameworks.FrameworkToUse.CSS)
}
// Inject CSS
a.renderer.AddCSSList(a.cssCache)

View File

@@ -15,7 +15,7 @@ func (app *App) setupCli() *cmd.Cli {
// Setup cli to handle loglevel and headless flags
result.
StringFlag("loglevel", "Sets the log level [debug|info|error|panic|fatal]. Default debug", &app.logLevel).
BoolFlag("headless", "Runs the app in headless mode", &app.headless).
// BoolFlag("headless", "Runs the app in headless mode", &app.headless).
Action(app.start)
// Banner

File diff suppressed because one or more lines are too long

39
assets/default/wails.css Normal file

File diff suppressed because one or more lines are too long

View File

@@ -1,9 +1,8 @@
// Wails runtime JS
(function () {
window.wails = window.wails || {
$: {}
};
window.wails = window.wails || {};
window.backend = {};
/****************** Utility Functions ************************/
@@ -63,7 +62,7 @@
/************************* Bindings *************************/
var bindingsBasePath = window.wails.$;
var bindingsBasePath = window.backend;
// Creates the path given in the bindings path
function addBindingPath(pathSections) {
@@ -92,11 +91,14 @@
function newBinding(bindingName) {
// Get all the sections of the binding
var bindingSections = bindingName.split('.');
var bindingSections = bindingName.split('.').splice(1);
// Get the actual function/method call name
var callName = bindingSections.pop();
let pathToBinding;
let err;
// Add path to binding
[pathToBinding, err] = addBindingPath(bindingSections)

View File

@@ -0,0 +1,214 @@
/*
Wails Bridge (c) 2019-present Lea Anthony
This library creates a bridge between your application
and the frontend, allowing you to develop your app using
standard tooling (browser extensions, live reload, etc).
Usage:
```
import Bridge from "./wailsbridge";
Bridge.Start(startApp);
```
The given callback (startApp in the example) will be called
when the bridge has successfully initialised. It passes the
window.wails object back, in case it is not accessible directly.
*/
// Bridge object
window.wailsbridge = {
reconnectOverlay: null,
reconnectTimer: 300,
wsURL: "ws://localhost:34115/bridge",
connectionState: null,
config: {},
websocket: null,
callback: null,
overlayHTML:
'<div class="wails-reconnect-overlay"><div class="wails-reconnect-overlay-content"><div class="wails-reconnect-overlay-title">Wails Bridge</div><br><div class="wails-reconnect-overlay-loadingspinner"></div><br><div id="wails-reconnect-overlay-message">Waiting for backend</div></div></div>',
overlayCSS:
".wails-reconnect-overlay{position:fixed;top:0;left:0;width:100%;height:100%;background:rgba(0,0,0,.6);font-family:sans-serif;display:none;z-index:999999}.wails-reconnect-overlay-content{padding:20px 30px;text-align:center;width:20em;position:relative;height:14em;border-radius:1em;margin:5% auto 0;background-color:#fff;box-shadow:1px 1px 20px 3px;background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAC8AAAAuCAMAAACPpbA7AAAAqFBMVEUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEBAQAAAAAAAAEBAQAAAAAAAAAAAAEBAQEBAQDAwMBAQEAAAABAQEAAAAAAAAAAAABAQEAAAAAAAACAgICAgIBAQEAAAAAAAAAAAAAAAAAAAAAAAABAQEAAAACAgIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFBQWKCj6oAAAAN3RSTlMALiIqDhkGBAswJjP0GxP6NR4W9/ztjRDMhWU50G9g5eHXvbZ9XEI9xZTcqZl2aldKo55QwoCvZUgzhAAAAs9JREFUSMeNleeWqjAUhU0BCaH3Itiw9zKT93+zG02QK1hm/5HF+jzZJ6fQe6cyXE+jg9X7o9wxuylIIf4Tv2V3+bOrEXnf8dwQ/KQIGDN2/S+4OmVCVXL/ScBnfibxURqIByP/hONE8r8T+bDMlQ98KSl7Y8hzjpS8v1qtDh8u5f8KQpGpfnPPhqG8JeogN37Hq9eaN2xRhIwAaGnvws8F1ShxqK5ob2twYi1FAMD4rXsYtnC/JEiRbl4cUrCWhnMCLRFemXezXbb59QK4WASOsm6n2W1+4CBT2JmtzQ6fsrbGubR/NFbd2g5Y179+5w/GEHaKsHjYCet7CgrXU3txarNC7YxOVJtIj4/ERzMdZfzc31hp+8cD6eGILgarZY9uZ12hAs03vfBD9C171gS5Omz7OcvxALQIn4u8RRBBBcsi9WW2woO9ipLgfzpYlggg3ZRdROUC8KT7QLqq3W9KB5BbdFVg4929kdwp6+qaZnMCCNBdj+NyN1W885Ry/AL3D4AQbsVV4noCiM/C83kyYq80XlDAYQtralOiDzoRAHlotWl8q2tjvYlOgcg1A8jEApZa+C06TBdAz2Qv0wu11I/zZOyJQ6EwGez2P2b8PIQr1hwwnAZsAxwA4UAYOyXUxM/xp6tHAn4GUmPGM9R28oVxgC0e/zQJJI6DyhyZ1r7uzRQhpcW7x7vTaWSzKSG6aep77kroTEl3U81uSVaUTtgEINfC8epx+Q4F9SpplHG84Ek6m4RAq9/TLkOBrxyeuddZhHvGIp1XXfFy3Z3vtwNblKGiDn+J+92vwwABHghj7HnzlS1H5kB49AZvdGCFgiBPq69qfXPr3y++yilF0ON4R8eR7spAsLpZ95NqAW5tab1c4vkZm6aleajchMwYTdILQQTwE2OV411ZM9WztDjPql12caBi6gDpUKmDd4U1XNdQxZ4LIXQ5/Tr4P7I9tYcFrDK3AAAAAElFTkSuQmCC);background-repeat:no-repeat;background-position:center}.wails-reconnect-overlay-title{font-size:2em}.wails-reconnect-overlay-message{font-size:1.3em}.wails-reconnect-overlay-loadingspinner{pointer-events:none;width:2.5em;height:2.5em;border:.4em solid transparent;border-color:#3E67EC #eee #eee;border-radius:50%;animation:loadingspin 1s linear infinite;margin:auto;padding:2.5em}@keyframes loadingspin{100%{transform:rotate(360deg)}}",
log: function(message) {
console.log(
"%c wails bridge %c " + message + " ",
"background: #aa0000; color: #fff; border-radius: 3px 0px 0px 3px; padding: 1px; font-size: 0.7rem",
"background: #009900; color: #fff; border-radius: 0px 3px 3px 0px; padding: 1px; font-size: 0.7rem"
);
}
};
// Adapted from webview - thanks zserge!
function injectCSS(css) {
var elem = document.createElement("style");
elem.setAttribute("type", "text/css");
if (elem.styleSheet) {
elem.styleSheet.cssText = css;
} else {
elem.appendChild(document.createTextNode(css));
}
var head = document.head || document.getElementsByTagName("head")[0];
head.appendChild(elem);
}
// Creates a node in the Dom
function createNode(parent, elementType, id, className, content) {
var d = document.createElement(elementType);
if (id) {
d.id = id;
}
if (className) {
d.className = className;
}
if (content) {
d.innerHTML = content;
}
parent.appendChild(d);
return d;
}
// Sets up the overlay
function setupOverlay() {
var body = document.body;
var wailsBridgeNode = createNode(body, "div", "wails-bridge");
wailsBridgeNode.innerHTML = window.wailsbridge.overlayHTML;
// Inject the overlay CSS
injectCSS(window.wailsbridge.overlayCSS);
}
// Start the Wails Bridge
function startBridge() {
// Setup the overlay
setupOverlay();
window.wailsbridge.websocket = null;
window.wailsbridge.connectTimer = null;
window.wailsbridge.reconnectOverlay = document.querySelector(
".wails-reconnect-overlay"
);
window.wailsbridge.connectionState = "disconnected";
// Shows the overlay
function showReconnectOverlay() {
window.wailsbridge.reconnectOverlay.style.display = "block";
}
// Hides the overlay
function hideReconnectOverlay() {
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) {
var s = document.createElement("script");
s.textContent = script;
document.head.appendChild(s);
// Remove internal messages from the DOM
if (remove) {
s.parentNode.removeChild(s);
}
}
// Handles incoming websocket connections
function handleConnect() {
window.wailsbridge.log("Connected to backend");
hideReconnectOverlay();
clearInterval(window.wailsbridge.connectTimer);
window.wailsbridge.websocket.onclose = handleDisconnect;
window.wailsbridge.websocket.onmessage = handleMessage;
window.wailsbridge.connectionState = "connected";
}
// Handles websocket disconnects
function handleDisconnect() {
window.wailsbridge.log("Disconnected from backend");
window.wailsbridge.websocket = null;
window.wailsbridge.connectionState = "disconnected";
showReconnectOverlay();
connect();
}
// Try to connect to the backend every 300ms (default value).
// Change this value in the main wailsbridge object.
function connect() {
window.wailsbridge.connectTimer = setInterval(function() {
if (window.wailsbridge.websocket == null) {
window.wailsbridge.websocket = new WebSocket(window.wailsbridge.wsURL);
window.wailsbridge.websocket.onopen = handleConnect;
window.wailsbridge.websocket.onerror = function(e) {
e.stopImmediatePropagation();
e.stopPropagation();
e.preventDefault();
window.wailsbridge.websocket = null;
return false;
};
}
}, window.wailsbridge.reconnectTimer);
}
function handleMessage(message) {
// As a bridge we ignore js and css injections
switch (message.data[0]) {
// Wails library - inject!
case "w":
addScript(message.data.slice(1));
// Now wails runtime is loaded, wails for the ready event
// and callback to the main app
window.wails.events.on("wails:loaded", function() {
window.wailsbridge.log("Wails Ready");
if (window.wailsbridge.callback) {
window.wailsbridge.log("Notifying application");
window.wailsbridge.callback(window.wails);
}
});
window.wailsbridge.log("Loaded Wails Runtime");
break;
// Notifications
case "n":
addScript(message.data.slice(1), true);
break;
// Binding
case "b":
var binding = message.data.slice(1);
//log("Binding: " + binding)
window.wails._.newBinding(binding);
break;
// Call back
case "c":
var callbackData = message.data.slice(1);
log("Callback = " + callbackData);
window.wails._.callback(callbackData);
break;
}
}
// Start by showing the overlay...
showReconnectOverlay();
// ...and attempt to connect
connect();
}
export default {
// The main function
// Passes the main Wails object to the callback if given.
Start: function(callback) {
// Save the callback
window.wailsbridge.callback = callback;
// Start Bridge
startBridge();
}
};

View File

@@ -0,0 +1,17 @@
/*
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) {
callback();
}
}
};

View File

@@ -1,179 +0,0 @@
<html>
<head>
<title>Wails Headless</title>
<style>
.wails-reconnect-overlay {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.6);
font-family: sans-serif;
display: none;
z-index: 999999;
}
.wails-reconnect-overlay-content {
padding: 20px 30px;
text-align: center;
width: 20em;
position: relative;
height: 17em;
border-radius: 1em;
margin: 5% auto 0;
background-color: white;
box-shadow: 1px 1px 20px 3px;
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAC8AAAAuCAMAAACPpbA7AAAAqFBMVEUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEBAQAAAAAAAAEBAQAAAAAAAAAAAAEBAQEBAQDAwMBAQEAAAABAQEAAAAAAAAAAAABAQEAAAAAAAACAgICAgIBAQEAAAAAAAAAAAAAAAAAAAAAAAABAQEAAAACAgIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFBQWKCj6oAAAAN3RSTlMALiIqDhkGBAswJjP0GxP6NR4W9/ztjRDMhWU50G9g5eHXvbZ9XEI9xZTcqZl2aldKo55QwoCvZUgzhAAAAs9JREFUSMeNleeWqjAUhU0BCaH3Itiw9zKT93+zG02QK1hm/5HF+jzZJ6fQe6cyXE+jg9X7o9wxuylIIf4Tv2V3+bOrEXnf8dwQ/KQIGDN2/S+4OmVCVXL/ScBnfibxURqIByP/hONE8r8T+bDMlQ98KSl7Y8hzjpS8v1qtDh8u5f8KQpGpfnPPhqG8JeogN37Hq9eaN2xRhIwAaGnvws8F1ShxqK5ob2twYi1FAMD4rXsYtnC/JEiRbl4cUrCWhnMCLRFemXezXbb59QK4WASOsm6n2W1+4CBT2JmtzQ6fsrbGubR/NFbd2g5Y179+5w/GEHaKsHjYCet7CgrXU3txarNC7YxOVJtIj4/ERzMdZfzc31hp+8cD6eGILgarZY9uZ12hAs03vfBD9C171gS5Omz7OcvxALQIn4u8RRBBBcsi9WW2woO9ipLgfzpYlggg3ZRdROUC8KT7QLqq3W9KB5BbdFVg4929kdwp6+qaZnMCCNBdj+NyN1W885Ry/AL3D4AQbsVV4noCiM/C83kyYq80XlDAYQtralOiDzoRAHlotWl8q2tjvYlOgcg1A8jEApZa+C06TBdAz2Qv0wu11I/zZOyJQ6EwGez2P2b8PIQr1hwwnAZsAxwA4UAYOyXUxM/xp6tHAn4GUmPGM9R28oVxgC0e/zQJJI6DyhyZ1r7uzRQhpcW7x7vTaWSzKSG6aep77kroTEl3U81uSVaUTtgEINfC8epx+Q4F9SpplHG84Ek6m4RAq9/TLkOBrxyeuddZhHvGIp1XXfFy3Z3vtwNblKGiDn+J+92vwwABHghj7HnzlS1H5kB49AZvdGCFgiBPq69qfXPr3y++yilF0ON4R8eR7spAsLpZ95NqAW5tab1c4vkZm6aleajchMwYTdILQQTwE2OV411ZM9WztDjPql12caBi6gDpUKmDd4U1XNdQxZ4LIXQ5/Tr4P7I9tYcFrDK3AAAAAElFTkSuQmCC");
background-repeat: no-repeat;
background-position: center;
}
.wails-reconnect-overlay-title {
font-size: 2em;
}
.wails-reconnect-overlay-message {
font-size: 1.3em;
}
/* https://codepen.io/EastingAndNorthing/pen/aNWrZz - Cheers Mark! */
.wails-reconnect-overlay-loadingspinner {
pointer-events: none;
width: 2.5em;
height: 2.5em;
border: 0.4em solid transparent;
border-color: #eee;
border-top-color: #3E67EC;
border-radius: 50%;
animation: loadingspin 1s linear infinite;
margin: auto;
padding: 2.5em;
}
@keyframes loadingspin {
100% {
transform: rotate(360deg)
}
}
</style>
</head>
<body>
<div class="wails-reconnect-overlay">
<div class="wails-reconnect-overlay-content">
<div class="wails-reconnect-overlay-title">Disconnected</div><br>
<div class="wails-reconnect-overlay-loadingspinner"></div><br>
<div class="wails-reconnect-overlay-message">Waiting for backend</div>
</div>
</div>
<div id="app"></div>
<script id="wails-headless-runtime">
(function () {
var websocket = null;
var connectTimer = null;
var reconnectOverlay = document.querySelector(".wails-reconnect-overlay");
var connectionState = "disconnected";
function showReconnectOverlay() {
reconnectOverlay.style.display = 'block';
}
function hideReconnectOverlay() {
reconnectOverlay.style.display = 'none';
}
window.external = {
invoke: function (msg) {
websocket.send(msg);
}
};
function addScript(script, id) {
var s = document.createElement("script")
if (id) {
s.id = id;
}
s.textContent = script;
document.head.appendChild(s)
}
function handleConnect() {
console.log("[Wails] Connected to backend");
addKeyListener();
hideReconnectOverlay();
clearInterval(connectTimer);
websocket.onclose = handleDisconnect;
websocket.onmessage = handleMessage;
connectionState = "connected";
// websocket.onerror = function () { }
}
function handleDisconnect() {
console.log("[Wails] Disconnected from backend");
websocket = null;
removeKeyListener();
connectionState = "disconnected";
showReconnectOverlay();
connect();
}
function connect() {
connectTimer = setInterval(function () {
if (websocket == null) {
websocket = new WebSocket("ws://localhost:34115/ws")
websocket.onopen = handleConnect;
websocket.onerror = function (e) {
e.stopImmediatePropagation();
e.stopPropagation();
e.preventDefault();
websocket = null;
return false
}
}
}, 300);
}
function handleMessage(e) {
addScript(e.data);
}
// Key listener
var delta = 300;
var lastKeypressTime = 0;
function KeyHandler(event) {
if (event.key === "`") {
var thisKeypressTime = new Date();
if (thisKeypressTime - lastKeypressTime <= delta) {
console.log("Double tap!")
// optional - if we'd rather not detect a triple-press
// as a second double-press, reset the timestamp
thisKeypressTime = 0;
}
lastKeypressTime = thisKeypressTime;
}
}
function addKeyListener() {
document.body.addEventListener('keydown', KeyHandler);
}
function removeKeyListener() {
document.body.removeEventListener('keydown', KeyHandler);
}
connect();
}());
</script>
</body>
</html>

View File

@@ -1,69 +0,0 @@
package cmd
import (
"encoding/json"
"io/ioutil"
"path"
"path/filepath"
"runtime"
)
// FrameworkMetadata contains information about a given framework
type FrameworkMetadata struct {
Name string `json:"name"`
BuildTag string `json:"buildtag"`
Description string `json:"description"`
}
// Utility function for creating new FrameworkMetadata structs
func loadFrameworkMetadata(pathToMetadataJSON string) (*FrameworkMetadata, error) {
result := &FrameworkMetadata{}
configData, err := ioutil.ReadFile(pathToMetadataJSON)
if err != nil {
return nil, err
}
// Load and unmarshall!
err = json.Unmarshal(configData, result)
if err != nil {
return nil, err
}
return result, nil
}
// GetFrameworks returns information about all the available frameworks
func GetFrameworks() ([]*FrameworkMetadata, error) {
var err error
// Calculate framework base dir
_, filename, _, _ := runtime.Caller(1)
frameworksBaseDir := filepath.Join(path.Dir(filename), "frameworks")
// Get the subdirectories
fs := NewFSHelper()
frameworkDirs, err := fs.GetSubdirs(frameworksBaseDir)
if err != nil {
return nil, err
}
// Prepare result
result := []*FrameworkMetadata{}
// Iterate framework directories, looking for metadata.json files
for _, frameworkDir := range frameworkDirs {
var frameworkMetadata FrameworkMetadata
metadataFile := filepath.Join(frameworkDir, "metadata.json")
jsonData, err := ioutil.ReadFile(metadataFile)
if err != nil {
return nil, err
}
err = json.Unmarshal(jsonData, &frameworkMetadata)
if err != nil {
return nil, err
}
result = append(result, &frameworkMetadata)
}
// Read in framework metadata
return result, nil
}

File diff suppressed because one or more lines are too long

View File

@@ -1,16 +0,0 @@
// +build frameworkbootstrap4
package frameworks
import (
"github.com/gobuffalo/packr"
)
func init() {
assets := packr.NewBox("./bootstrap4default/assets")
FrameworkToUse = &Framework{
Name: "Bootstrap 4",
JS: BoxString(&assets, "bootstrap.bundle.min.js"),
CSS: BoxString(&assets, "bootstrap.min.css"),
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1,17 +0,0 @@
// +build frameworkbootstrap4
package bootstrap4
import (
"github.com/gobuffalo/packr"
"github.com/wailsapp/wails/frameworks"
)
func init() {
assets := packr.NewBox("./assets")
frameworks.FrameworkToUse = &frameworks.Framework{
Name: "Bootstrap 4",
JS: BoxString(&assets, "bootstrap.bundle.min.js"),
CSS: BoxString(&assets, "bootstrap.min.css"),
}
}

View File

@@ -1,5 +0,0 @@
{
"Name": "Bootstrap 4",
"Description": "Standard Bootstrap 4 with default theme",
"BuildTag": "frameworkbootstrap4"
}

View File

@@ -1,16 +0,0 @@
// +build frameworkbootstrap4lux
package frameworks
import (
"github.com/gobuffalo/packr"
)
func init() {
assets := packr.NewBox("./bootstrap4lux/assets")
FrameworkToUse = &Framework{
Name: "Bootstrap 4 (Lux)",
JS: BoxString(&assets, "bootstrap.bundle.min.js"),
CSS: BoxString(&assets, "bootstrap.min.css"),
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1,17 +0,0 @@
// +build frameworkbootstrap4lux
package bootstrap4
import (
"github.com/gobuffalo/packr"
"github.com/wailsapp/wails/frameworks"
)
func init() {
assets := packr.NewBox("./assets")
frameworks.FrameworkToUse = &frameworks.Framework{
Name: "Bootstrap 4 (Lux)",
JS: BoxString(&assets, "bootstrap.bundle.min.js"),
CSS: BoxString(&assets, "bootstrap.min.css"),
}
}

View File

@@ -1,5 +0,0 @@
{
"Name": "Bootstrap 4 (Lux)",
"Description": "Bootstrap with Lux theme",
"BuildTag": "frameworkbootstrap4lux"
}

View File

@@ -1,28 +0,0 @@
package frameworks
import (
"log"
"github.com/gobuffalo/packr"
)
// Framework has details about a specific framework
type Framework struct {
Name string
JS string
CSS string
Options string
}
// FrameworkToUse is the framework we will use when building
// Set by `wails init`, used by `wails build`
var FrameworkToUse *Framework
// BoxString extracts a string from a packr box
func BoxString(box *packr.Box, filename string) string {
result, err := box.FindString(filename)
if err != nil {
log.Fatal(err)
}
return result
}

View File

@@ -16,16 +16,16 @@ import (
"github.com/jackmordaunt/icns"
)
// BundleHelper helps with the 'wails bundle' command
type BundleHelper struct {
// PackageHelper helps with the 'wails package' command
type PackageHelper struct {
fs *FSHelper
log *Logger
system *SystemHelper
}
// NewBundleHelper creates a new BundleHelper!
func NewBundleHelper() *BundleHelper {
return &BundleHelper{
// NewPackageHelper creates a new PackageHelper!
func NewPackageHelper() *PackageHelper {
return &PackageHelper{
fs: NewFSHelper(),
log: NewLogger(),
system: NewSystemHelper(),
@@ -33,23 +33,23 @@ func NewBundleHelper() *BundleHelper {
}
type plistData struct {
Title string
Exe string
BundleID string
Version string
Author string
Date string
Title string
Exe string
PackageID string
Version string
Author string
Date string
}
func newPlistData(title, exe, bundleID, version, author string) *plistData {
func newPlistData(title, exe, packageID, version, author string) *plistData {
now := time.Now().Format(time.RFC822)
return &plistData{
Title: title,
Exe: exe,
Version: version,
BundleID: bundleID,
Author: author,
Date: now,
Title: title,
Exe: exe,
Version: version,
PackageID: packageID,
Author: author,
Date: now,
}
}
@@ -60,26 +60,32 @@ func defaultString(val string, defaultVal string) string {
return defaultVal
}
func (b *BundleHelper) getBundleFileBaseDir() string {
return filepath.Join(b.system.homeDir, "go", "src", "github.com", "wailsapp", "wails", "cmd", "bundle", runtime.GOOS)
func (b *PackageHelper) getPackageFileBaseDir() string {
// Calculate template base dir
_, filename, _, _ := runtime.Caller(1)
return filepath.Join(path.Dir(filename), "packages", runtime.GOOS)
}
// Bundle the application into a platform specific package
func (b *BundleHelper) Bundle(po *ProjectOptions) error {
// Package the application into a platform specific package
func (b *PackageHelper) Package(po *ProjectOptions) error {
// Check we have the exe
if !b.fs.FileExists(po.BinaryName) {
return fmt.Errorf("cannot bundle non-existant binary file '%s'. Please build with 'wails build' first", po.BinaryName)
}
switch runtime.GOOS {
case "darwin":
return b.bundleOSX(po)
return b.packageOSX(po)
case "windows":
return fmt.Errorf("windows is not supported at this time. Please see https://github.com/wailsapp/wails/issues/3")
case "linux":
return fmt.Errorf("linux is not supported at this time. Please see https://github.com/wailsapp/wails/issues/2")
default:
return fmt.Errorf("platform '%s' not supported for bundling yet", runtime.GOOS)
}
}
// Bundle the application
func (b *BundleHelper) bundleOSX(po *ProjectOptions) error {
// Package the application for OSX
func (b *PackageHelper) packageOSX(po *ProjectOptions) error {
system := NewSystemHelper()
config, err := system.LoadConfig()
@@ -91,8 +97,8 @@ func (b *BundleHelper) bundleOSX(po *ProjectOptions) error {
exe := defaultString(po.BinaryName, name)
version := defaultString(po.Version, "0.1.0")
author := defaultString(config.Name, "Anonymous")
bundleID := strings.Join([]string{"wails", name, version}, ".")
plistData := newPlistData(name, exe, bundleID, version, author)
packageID := strings.Join([]string{"wails", name, version}, ".")
plistData := newPlistData(name, exe, packageID, version, author)
appname := po.Name + ".app"
// Check binary exists
@@ -102,7 +108,7 @@ func (b *BundleHelper) bundleOSX(po *ProjectOptions) error {
return fmt.Errorf("Target '%s' not available. Has it been compiled yet?", exe)
}
// REmove the existing bundle
// Remove the existing package
os.RemoveAll(appname)
exeDir := path.Join(b.fs.Cwd(), appname, "/Contents/MacOS")
@@ -110,7 +116,7 @@ func (b *BundleHelper) bundleOSX(po *ProjectOptions) error {
resourceDir := path.Join(b.fs.Cwd(), appname, "/Contents/Resources")
b.fs.MkDirs(resourceDir, 0755)
tmpl := template.New("infoPlist")
plistFile := filepath.Join(b.getBundleFileBaseDir(), "info.plist")
plistFile := filepath.Join(b.getPackageFileBaseDir(), "info.plist")
infoPlist, err := ioutil.ReadFile(plistFile)
if err != nil {
return err
@@ -140,11 +146,11 @@ func (b *BundleHelper) bundleOSX(po *ProjectOptions) error {
if err != nil {
return err
}
err = b.bundleIcon(resourceDir)
err = b.packageIcon(resourceDir)
return err
}
func (b *BundleHelper) bundleIcon(resourceDir string) error {
func (b *PackageHelper) packageIcon(resourceDir string) error {
// TODO: Read this from project.json
const appIconFilename = "appicon.png"
@@ -155,7 +161,7 @@ func (b *BundleHelper) bundleIcon(resourceDir string) error {
if !b.fs.FileExists(srcIcon) {
// Install default icon
iconfile := filepath.Join(b.getBundleFileBaseDir(), "icon.png")
iconfile := filepath.Join(b.getPackageFileBaseDir(), "icon.png")
iconData, err := ioutil.ReadFile(iconfile)
if err != nil {
return err

Binary file not shown.

After

Width:  |  Height:  |  Size: 106 KiB

View File

@@ -0,0 +1,11 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0"><dict>
<key>CFBundleName</key><string>{{.Title}}</string>
<key>CFBundleExecutable</key><string>{{.Exe}}</string>
<key>CFBundleIdentifier</key><string>{{.PackageID}}</string>
<key>CFBundleVersion</key><string>{{.Version}}</string>
<key>CFBundleGetInfoString</key><string>Built by {{.Author}} at {{.Date}} using Wails (https://wails.app)</string>
<key>CFBundleShortVersionString</key><string>{{.Version}}</string>
<key>CFBundleIconFile</key><string>iconfile</string>
<key>NSHighResolutionCapable</key><string>true</string>
</dict></plist>

View File

@@ -19,6 +19,8 @@ type frontend struct {
Dir string `json:"dir"`
Install string `json:"install"`
Build string `json:"build"`
Bridge string `json:"bridge"`
Serve string `json:"serve"`
}
type framework struct {
@@ -151,17 +153,16 @@ func InputQuestion(name, message string, defaultValue string, required bool) *su
// ProjectOptions holds all the options available for a project
type ProjectOptions struct {
Name string `json:"name"`
Description string `json:"description"`
Author *author `json:"author,omitempty"`
Version string `json:"version"`
OutputDirectory string `json:"-"`
UseDefaults bool `json:"-"`
Template string `json:"-"`
BinaryName string `json:"binaryname"`
FrontEnd *frontend `json:"frontend,omitempty"`
NPMProjectName string `json:"-"`
Framework *framework `json:"framework,omitempty"`
Name string `json:"name"`
Description string `json:"description"`
Author *author `json:"author,omitempty"`
Version string `json:"version"`
OutputDirectory string `json:"-"`
UseDefaults bool `json:"-"`
Template string `json:"-"`
BinaryName string `json:"binaryname"`
FrontEnd *frontend `json:"frontend,omitempty"`
NPMProjectName string `json:"-"`
system *SystemHelper
log *Logger
templates *TemplateHelper
@@ -249,39 +250,7 @@ func (po *ProjectOptions) PromptForInputs() error {
}
// Setup NPM Project name
po.NPMProjectName = strings.Replace(po.Name, " ", "_", -1)
// If we selected custom, prompt for framework
if po.Template == "custom - Choose your own CSS Framework" {
// Ask for the framework
var frameworkName string
frameworks, err := GetFrameworks()
frameworkNames := []string{}
metadataMap := make(map[string]*FrameworkMetadata)
for _, frameworkMetadata := range frameworks {
frameworkDetails := fmt.Sprintf("%s - %s", frameworkMetadata.Name, frameworkMetadata.Description)
metadataMap[frameworkDetails] = frameworkMetadata
frameworkNames = append(frameworkNames, frameworkDetails)
}
if err != nil {
return err
}
var frameworkQuestion []*survey.Question
frameworkQuestion = append(frameworkQuestion, SelectQuestion("Framework", "Select framework", frameworkNames, frameworkNames[0], true))
err = survey.Ask(frameworkQuestion, &frameworkName)
if err != nil {
return err
}
// Get metadata
metadata := metadataMap[frameworkName]
// Add to project config
po.Framework = &framework{
Name: metadata.Name,
BuildTag: metadata.BuildTag,
}
}
po.NPMProjectName = strings.ToLower(strings.Replace(po.Name, " ", "_", -1))
// Fix template name
if po.templateNameMap[po.Template] != "" {
@@ -307,6 +276,20 @@ func (po *ProjectOptions) PromptForInputs() error {
po.FrontEnd.Build = templateMetadata["build"].(string)
}
if templateMetadata["bridge"] != nil {
if po.FrontEnd == nil {
return fmt.Errorf("bridge set in template metadata but not frontenddir")
}
po.FrontEnd.Bridge = templateMetadata["bridge"].(string)
}
if templateMetadata["serve"] != nil {
if po.FrontEnd == nil {
return fmt.Errorf("serve set in template metadata but not frontenddir")
}
po.FrontEnd.Serve = templateMetadata["serve"].(string)
}
return nil
}

View File

@@ -1 +0,0 @@
module {{.BinaryName}}

View File

@@ -1,24 +0,0 @@
package main
import (
wails "github.com/wailsapp/wails"
)
var html = `
<div style='text-align:center'>
<h1> Basic Template </h1>
Welcome to your basic Wails app!
</div>
`
func main() {
// Initialise the app
app := wails.CreateApp(&wails.AppConfig{
Width: 1024,
Height: 768,
Title: "{{.Name}}",
HTML: html,
})
app.Run()
}

View File

@@ -1,7 +0,0 @@
{
"name": "Basic",
"shortdescription": "A basic template",
"description": "A basic template using vanilla JS",
"author": "Lea Anthony<lea.anthony@gmail.com>",
"created": "2018-10-18"
}

View File

@@ -1 +0,0 @@
module {{.BinaryName}}

View File

@@ -1,24 +0,0 @@
package main
import (
wails "github.com/wailsapp/wails"
)
var html = `
<div style='text-align:center'>
<h1> Custom </h1>
Welcome to your basic Wails app with added CSS!
</div>
`
func main() {
// Initialise the app
app := wails.CreateApp(&wails.AppConfig{
Width: 800,
Height: 600,
Title: "{{.Name}}",
HTML: html,
})
app.Run()
}

View File

@@ -1,7 +0,0 @@
{
"name": "Custom",
"shortdescription": "Choose your own CSS Framework",
"description": "A basic template allowing use of CSS Frameworks",
"author": "Lea Anthony<lea.anthony@gmail.com>",
"created": "2018-10-22"
}

View File

@@ -8,6 +8,7 @@
<script>
import "../assets/css/quote.css";
import { eventBus } from "../main";
export default {
data() {
@@ -18,13 +19,17 @@ export default {
methods: {
getNewQuote: function() {
var self = this;
wails.$.main.QuotesCollection.GetQuote().then(result => {
backend.QuotesCollection.GetQuote().then(result => {
self.quote = result;
});
}
},
created() {
this.getNewQuote();
if( !backend ) {
eventBus.$on("ready", this.getNewQuote);
} else {
this.getNewQuote();
}
}
};
</script>

View File

@@ -1,8 +1,13 @@
import Vue from 'vue'
import App from './App.vue'
Vue.config.productionTip = false
import Vue from "vue";
export const eventBus = new Vue();
import App from "./App.vue";
new Vue({
render: h => h(App),
}).$mount('#app')
render: h => h(App)
}).$mount("#app");
import Bridge from "./wailsbridge";
Bridge.OnReady(() => {
eventBus.$emit("ready");
});
Bridge.Start();

View File

@@ -6,5 +6,7 @@
"created": "2018-12-01",
"frontenddir": "frontend",
"install": "npm install",
"build": "npm run build"
}
"build": "npm run build",
"serve": "npm run serve",
"bridge": "src"
}

View File

@@ -4,6 +4,9 @@ import (
"fmt"
"io/ioutil"
"os"
"path"
"path/filepath"
"runtime"
"github.com/leaanthony/slicer"
"github.com/leaanthony/spinner"
@@ -12,19 +15,16 @@ import (
func init() {
var bundle = false
var packageApp = false
var forceRebuild = false
var releaseMode = false
buildSpinner := spinner.NewSpinner()
buildSpinner.SetSpinSpeed(50)
commandDescription := `This command will check to ensure all pre-requistes are installed prior to building. If not, it will attempt to install them. Building comprises of a number of steps: install frontend dependencies, build frontend, pack frontend, compile main application.`
initCmd := app.Command("build", "Builds your Wails project").
LongDescription(commandDescription).
BoolFlag("b", "Bundle application on successful build", &bundle).
BoolFlag("f", "Force rebuild of application components", &forceRebuild).
BoolFlag("r", "Build in Release mode", &releaseMode)
BoolFlag("p", "Package application on successful build", &packageApp).
BoolFlag("f", "Force rebuild of application components", &forceRebuild)
initCmd.Action(func() error {
log := cmd.NewLogger()
message := "Building Application"
@@ -56,6 +56,10 @@ func init() {
if projectOptions.FrontEnd.Install == "" {
return fmt.Errorf("Frontend install command not set in project.json")
}
if projectOptions.FrontEnd.Bridge == "" {
return fmt.Errorf("Frontend bridge config not set in project.json")
}
}
// Check pre-requisites are installed
@@ -137,6 +141,18 @@ func init() {
ioutil.WriteFile(md5sumFile, []byte(packageJSONMD5), 0644)
}
// Determine which wails bridge to install
bridgeFile := "wailsbridge.prod.js"
// Copy bridge to project
_, filename, _, _ := runtime.Caller(1)
bridgeFileSource := filepath.Join(path.Dir(filename), "..", "assets", "default", bridgeFile)
bridgeFileTarget := filepath.Join(projectDir, projectOptions.FrontEnd.Dir, projectOptions.FrontEnd.Bridge, "wailsbridge.js")
err = fs.CopyFile(bridgeFileSource, bridgeFileTarget)
if err != nil {
return err
}
// Build frontend
buildFESpinner := spinner.New("Building frontend...")
buildFESpinner.SetSpinSpeed(50)
@@ -158,26 +174,6 @@ func init() {
// Support build tags
buildTags := []string{}
// Do we have any frameworks specified?
frameworkSpinner := spinner.New()
frameworkSpinner.SetSpinSpeed(50)
if projectOptions.Framework != nil {
frameworkSpinner.Start()
frameworkSpinner.Success("Compiling support for " + projectOptions.Framework.Name)
buildTags = append(buildTags, projectOptions.Framework.BuildTag)
}
// // Initialise Go Module - if go.mod doesn't exist
// if !fs.FileExists("go.mod") {
// buildSpinner.Start("Initialising Go module...")
// err = program.RunCommand("go mod init " + projectOptions.BinaryName)
// if err != nil {
// buildSpinner.Error()
// return err
// }
// buildSpinner.Success()
// }
depSpinner := spinner.New("Installing Dependencies...")
depSpinner.SetSpinSpeed(50)
depSpinner.Start()
@@ -190,9 +186,6 @@ func init() {
depSpinner.Success()
compileMessage := "Packing + Compiling project"
if releaseMode {
compileMessage += " (Release Mode)"
}
packSpinner := spinner.New(compileMessage + "...")
packSpinner.SetSpinSpeed(50)
@@ -215,13 +208,12 @@ func init() {
// If we are forcing a rebuild
if forceRebuild {
buildCommand.Add(" -a")
buildCommand.Add("-a")
}
// Release mode
if releaseMode {
buildCommand.AddSlice([]string{"-ldflags", "-X github.com/wailsapp/wails.DebugMode=false"})
}
buildCommand.AddSlice([]string{"-ldflags", "-X github.com/wailsapp/wails.DebugMode=false"})
err = program.RunCommandArray(buildCommand.AsSlice())
if err != nil {
packSpinner.Error()
@@ -229,22 +221,22 @@ func init() {
}
packSpinner.Success()
if bundle == false {
if packageApp == false {
logger.Yellow("Awesome! Project '%s' built!", projectOptions.Name)
return nil
}
// Bundle app
bundleSpinner := spinner.New("Bundling Application")
bundleSpinner.SetSpinSpeed(50)
bundleSpinner.Start()
bundler := cmd.NewBundleHelper()
err = bundler.Bundle(projectOptions)
// Package app
packageSpinner := spinner.New("Packaging Application")
packageSpinner.SetSpinSpeed(50)
packageSpinner.Start()
packager := cmd.NewPackageHelper()
err = packager.Package(projectOptions)
if err != nil {
bundleSpinner.Error()
packageSpinner.Error()
return err
}
bundleSpinner.Success()
packageSpinner.Success()
logger.Yellow("Awesome! Project '%s' built!", projectOptions.Name)
return nil
})

236
cmd/wails/6_serve.go Normal file
View File

@@ -0,0 +1,236 @@
package main
import (
"os"
"os/exec"
"path"
"path/filepath"
"runtime"
"time"
"github.com/leaanthony/slicer"
"github.com/leaanthony/spinner"
"github.com/wailsapp/wails/cmd"
)
func init() {
var forceRebuild = false
buildSpinner := spinner.NewSpinner()
buildSpinner.SetSpinSpeed(50)
commandDescription := `This command builds then serves your application in bridge mode. Useful for developing your app in a browser.`
initCmd := app.Command("serve", "Runs your Wails project in bridge mode").
LongDescription(commandDescription).
BoolFlag("f", "Force rebuild of application components", &forceRebuild)
initCmd.Action(func() error {
log := cmd.NewLogger()
message := "Building Application"
if forceRebuild {
message += " (force rebuild)"
}
log.WhiteUnderline(message)
// Project options
projectOptions := &cmd.ProjectOptions{}
// Check we are in project directory
// Check project.json loads correctly
fs := cmd.NewFSHelper()
err := projectOptions.LoadConfig(fs.Cwd())
if err != nil {
return err
}
// // Validate config
// // Check if we have a frontend
// if projectOptions.FrontEnd != nil {
// if projectOptions.FrontEnd.Dir == "" {
// return fmt.Errorf("Frontend directory not set in project.json")
// }
// if projectOptions.FrontEnd.Build == "" {
// return fmt.Errorf("Frontend build command not set in project.json")
// }
// if projectOptions.FrontEnd.Install == "" {
// return fmt.Errorf("Frontend install command not set in project.json")
// }
// if projectOptions.FrontEnd.Bridge == "" {
// return fmt.Errorf("Frontend bridge config not set in project.json")
// }
// }
// // Check pre-requisites are installed
// Program checker
program := cmd.NewProgramHelper()
// if projectOptions.FrontEnd != nil {
// // npm
// if !program.IsInstalled("npm") {
// return fmt.Errorf("it appears npm is not installed. Please install and run again")
// }
// }
// packr
if !program.IsInstalled("packr") {
buildSpinner.Start("Installing packr...")
err := program.InstallGoPackage("github.com/gobuffalo/packr/...")
if err != nil {
buildSpinner.Error()
return err
}
buildSpinner.Success()
}
// Save project directory
projectDir := fs.Cwd()
// Install backend deps - needed?
// if projectOptions.FrontEnd != nil {
// // Install frontend deps
// err = os.Chdir(projectOptions.FrontEnd.Dir)
// if err != nil {
// return err
// }
// // Check if frontend deps have been updated
// feSpinner := spinner.New("Installing frontend dependencies (This may take a while)...")
// feSpinner.SetSpinSpeed(50)
// feSpinner.Start()
// requiresNPMInstall := true
// // Read in package.json MD5
// packageJSONMD5, err := fs.FileMD5("package.json")
// if err != nil {
// return err
// }
// const md5sumFile = "package.json.md5"
// // If we aren't forcing the install and the md5sum file exists
// if !forceRebuild && fs.FileExists(md5sumFile) {
// // Yes - read contents
// savedMD5sum, err := fs.LoadAsString(md5sumFile)
// // File exists
// if err == nil {
// // Compare md5
// if savedMD5sum == packageJSONMD5 {
// // Same - no need for reinstall
// requiresNPMInstall = false
// feSpinner.Success("Skipped frontend dependencies (-f to force rebuild)")
// }
// }
// }
// // Md5 sum package.json
// // Different? Build
// if requiresNPMInstall || forceRebuild {
// // Install dependencies
// err = program.RunCommand(projectOptions.FrontEnd.Install)
// if err != nil {
// feSpinner.Error()
// return err
// }
// feSpinner.Success()
// // Update md5sum file
// ioutil.WriteFile(md5sumFile, []byte(packageJSONMD5), 0644)
// }
// Copy bridge to project
var bridgeFile = "wailsbridge.js"
_, filename, _, _ := runtime.Caller(1)
bridgeFileSource := filepath.Join(path.Dir(filename), "..", "assets", "default", bridgeFile)
bridgeFileTarget := filepath.Join(projectDir, projectOptions.FrontEnd.Dir, projectOptions.FrontEnd.Bridge, "wailsbridge.js")
err = fs.CopyFile(bridgeFileSource, bridgeFileTarget)
if err != nil {
return err
}
// // Build frontend
// buildFESpinner := spinner.New("Building frontend...")
// buildFESpinner.SetSpinSpeed(50)
// buildFESpinner.Start()
// err = program.RunCommand(projectOptions.FrontEnd.Build)
// if err != nil {
// buildFESpinner.Error()
// return err
// }
// buildFESpinner.Success()
// }
// Run packr in project directory
err = os.Chdir(projectDir)
if err != nil {
return err
}
// Support build tags
buildTags := []string{}
depSpinner := spinner.New("Installing Dependencies...")
depSpinner.SetSpinSpeed(50)
depSpinner.Start()
installCommand := "go get"
err = program.RunCommand(installCommand)
if err != nil {
depSpinner.Error()
return err
}
depSpinner.Success()
compileMessage := "Packing + Compiling project"
packSpinner := spinner.New(compileMessage + "...")
packSpinner.SetSpinSpeed(50)
packSpinner.Start()
buildCommand := slicer.String()
buildCommand.AddSlice([]string{"packr", "build"})
// Add build tags
if len(buildTags) > 0 {
buildCommand.Add("--tags")
buildCommand.AddSlice(buildTags)
}
if projectOptions.BinaryName != "" {
buildCommand.Add("-o")
buildCommand.Add(projectOptions.BinaryName)
}
// If we are forcing a rebuild
if forceRebuild {
buildCommand.Add("-a")
}
err = program.RunCommandArray(buildCommand.AsSlice())
if err != nil {
packSpinner.Error()
return err
}
packSpinner.Success()
// Run the App
logger.Yellow("Awesome! Project '%s' built!", projectOptions.Name)
go func() {
time.Sleep(2 * time.Second)
logger.Green(">>>>> To connect, you will need to run '" + projectOptions.FrontEnd.Serve + "' in the '" + projectOptions.FrontEnd.Dir + "' directory <<<<<")
}()
logger.Yellow("Serving Application: " + projectOptions.BinaryName)
cmd := exec.Command(projectOptions.BinaryName)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
err = cmd.Run()
if err != nil {
return err
}
return nil
})
}

4
go.mod
View File

@@ -2,7 +2,7 @@ module github.com/wailsapp/wails
require (
github.com/AlecAivazis/survey v1.7.1
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc // indirect
github.com/dchest/cssmin v0.0.0-20151210170030-fb8d9b44afdc // indirect
github.com/dchest/htmlmin v0.0.0-20150526090704-e254725e81ac
github.com/dchest/jsmin v0.0.0-20160823214000-faeced883947 // indirect
@@ -13,7 +13,7 @@ require (
github.com/jackmordaunt/icns v1.0.0
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
github.com/leaanthony/slicer v0.0.0-20190110113548-aa9ea12f976a
github.com/leaanthony/spinner v0.4.0
github.com/leaanthony/spinner v0.5.0
github.com/leaanthony/synx v0.0.0-20180923230033-60efbd9984b0 // indirect
github.com/leaanthony/wincursor v0.0.0-20180705115120-056510f32d15 // indirect
github.com/mattn/go-colorable v0.0.9 // indirect

4
go.sum
View File

@@ -13,6 +13,7 @@ github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc
github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk=
github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dchest/cssmin v0.0.0-20151210170030-fb8d9b44afdc h1:VBS1z48BFEe00G81z8MKOtwX7f/ISkuH38NscT8iVPw=
github.com/dchest/cssmin v0.0.0-20151210170030-fb8d9b44afdc/go.mod h1:ABJPuor7YlcsHmvJ1QxX38e2NcufLY3hm0yXv+cy9sI=
@@ -211,6 +212,7 @@ github.com/karrick/godirwalk v1.7.7/go.mod h1:2c9FRhkDxdIbgkOnCEvnSWs71Bhugbl46s
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs=
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8=
github.com/konsorten/go-windows-terminal-sequences v0.0.0-20180402223658-b729f2633dfe/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
@@ -271,6 +273,7 @@ github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1Cpa
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
github.com/pkg/errors v0.8.0 h1:WdK/asTD0HN+q6hsWO3/vpuAkAr+tw6aNJNDFFf0+qw=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rogpeppe/go-internal v1.0.0 h1:o4VLZ5jqHE+HahLT6drNtSGTrrUA3wPBmtpgqtdbClo=
github.com/rogpeppe/go-internal v1.0.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
@@ -301,6 +304,7 @@ github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnIn
github.com/spf13/viper v1.2.1/go.mod h1:P4AexN0a+C9tGAnUFNwDMYYZv3pjFuvmeiMyKRaNVlI=
github.com/spf13/viper v1.3.1/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
github.com/unrolled/secure v0.0.0-20180918153822-f340ee86eb8b/go.mod h1:mnPT77IAdsi/kV7+Es7y+pXALeV3h7G6dQF6mNYjcLA=

View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2018 Alec Aivazis
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -0,0 +1,29 @@
Go Port:
Copyright (c) 2013 Dmitry Chestnykh <dmitry@codingrobots.com>
Original:
Copyright (c) 2008 Ryan Grove <ryan@wonko.com>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of this project nor the names of its contributors may be
used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@@ -0,0 +1,24 @@
Copyright (c) 2013 Dmitry Chestnykh. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@@ -0,0 +1,20 @@
The MIT License (MIT)
Copyright (c) 2013 Fatih Arslan
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@@ -0,0 +1,22 @@
The MIT License (MIT)
Copyright (c) 2015 Dean Karn
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -0,0 +1,8 @@
The MIT License (MIT)
Copyright (c) 2018 Mark Bates
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2018 Mark Bates
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -0,0 +1,8 @@
The MIT License (MIT)
Copyright (c) 2016 Mark Bates
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2018 Mark Bates
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -0,0 +1,22 @@
Copyright (c) 2013 The Gorilla WebSocket Authors. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2018 Jack Mordaunt
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -0,0 +1,19 @@
Copyright (C) 2014 Kevin Ballard
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@@ -0,0 +1,9 @@
(The MIT License)
Copyright (c) 2017 marvin + konsorten GmbH (open-source@konsorten.de)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2019 Lea Anthony
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -0,0 +1,20 @@
The MIT License (MIT)
Copyright (c) 2018 Lea Anthony
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@@ -1,7 +1,6 @@
The MIT License (MIT)
Copyright (c) 2011-2018 Twitter, Inc.
Copyright (c) 2011-2018 The Bootstrap Authors
Copyright (c) 2018-Present Lea Anthony
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2018 Mark Bates
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2016 Yasuhiro Matsumoto
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -0,0 +1,9 @@
Copyright (c) Yasuhiro MATSUMOTO <mattn.jp@gmail.com>
MIT License (Expat)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@@ -0,0 +1,9 @@
The MIT License (MIT)
Copyright (c) 2013 Mario L. Gutierrez
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@@ -1,7 +1,6 @@
The MIT License (MIT)
Copyright (c) 2011-2018 Twitter, Inc.
Copyright (c) 2011-2018 The Bootstrap Authors
Copyright (c) 2013 Mitchell Hashimoto
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -19,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
THE SOFTWARE.

View File

@@ -0,0 +1,13 @@
Copyright (c) 2012, Jan Schlicht <jan.schlicht@gmail.com>
Permission to use, copy, modify, and/or distribute this software for any purpose
with or without fee is hereby granted, provided that the above copyright notice
and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
THIS SOFTWARE.

View File

@@ -0,0 +1,23 @@
Copyright (c) 2015, Dave Cheney <dave@cheney.net>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2014 Simon Eskildsen
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@@ -0,0 +1,27 @@
Copyright (c) 2009 The Go Authors. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@@ -0,0 +1,27 @@
Copyright (c) 2009 The Go Authors. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@@ -0,0 +1,27 @@
Copyright (c) 2009 The Go Authors. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2018 Alec Aivazis
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -0,0 +1,22 @@
Copyright (c) 2014 Takashi Kokubun
MIT License
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@@ -13,7 +13,6 @@ type Renderer interface {
NotifyEvent(eventData *eventData) error
// Injection
InjectFramework(js string, css string)
AddJSList(js []string)
AddCSSList(css []string)

View File

@@ -11,9 +11,24 @@ import (
"github.com/gorilla/websocket"
)
var headlessAssets = packr.NewBox("./assets/headless")
var defaultAssets = packr.NewBox("./assets/default")
type messageType int
const (
jsMessage messageType = iota
cssMessage
htmlMessage
notifyMessage
bindingMessage
callbackMessage
wailsRuntimeMessage
)
func (m messageType) toString() string {
return [...]string{"j", "s", "h", "n", "b", "c", "w"}[m]
}
// Headless is a backend that opens a local web server
// and renders the files over a websocket
type Headless struct {
@@ -39,15 +54,20 @@ func (h *Headless) Initialise(appConfig *AppConfig, ipcManager *ipcManager, even
h.ipcManager = ipcManager
h.appConfig = appConfig
h.eventManager = eventManager
ipcManager.bindRenderer(h)
h.log = newCustomLogger("Headless")
return nil
}
func (h *Headless) evalJS(js string) error {
func (h *Headless) evalJS(js string, mtype messageType) error {
message := mtype.toString() + js
if h.theConnection == nil {
h.initialisationJS = append(h.initialisationJS, js)
h.initialisationJS = append(h.initialisationJS, message)
} else {
h.sendMessage(h.theConnection, js)
// Prepend message type to message
h.sendMessage(h.theConnection, message)
}
return nil
@@ -62,26 +82,22 @@ func (h *Headless) injectCSS(css string) {
h.log.Fatal("Unable to minify CSS: " + css)
}
minifiedCSS := string(minified)
minifiedCSS = strings.Replace(minifiedCSS, "\\", "\\\\", -1)
minifiedCSS = strings.Replace(minifiedCSS, "'", "\\'", -1)
minifiedCSS = strings.Replace(minifiedCSS, "\n", " ", -1)
inject := fmt.Sprintf("wails._.injectCSS('%s')", minifiedCSS)
h.evalJS(inject)
h.evalJS(inject, cssMessage)
}
func (h *Headless) rootHandler(w http.ResponseWriter, r *http.Request) {
indexHTML := BoxString(&headlessAssets, "index.html")
fmt.Fprintf(w, "%s", indexHTML)
}
func (h *Headless) wsHandler(w http.ResponseWriter, r *http.Request) {
func (h *Headless) wsBridgeHandler(w http.ResponseWriter, r *http.Request) {
conn, err := websocket.Upgrade(w, r, w.Header(), 1024, 1024)
if err != nil {
http.Error(w, "Could not open websocket connection", http.StatusBadRequest)
}
h.theConnection = conn
h.log.Infof("Connection %p accepted.", h.theConnection)
h.log.Infof("Connection from frontend accepted.", h.theConnection)
conn.SetCloseHandler(func(int, string) error {
h.log.Infof("Connection %p dropped.", h.theConnection)
h.log.Infof("Connection dropped [%p].", h.theConnection)
h.theConnection = nil
return nil
})
@@ -99,74 +115,21 @@ func (h *Headless) start(conn *websocket.Conn) {
// set external.invoke
h.log.Infof("Connected to frontend.")
// If we are given an HTML fragment, load jquery
// for the html() function
if h.appConfig.isHTMLFragment {
// Inject jquery
jquery := BoxString(&defaultAssets, "jquery.3.3.1.min.js")
h.evalJS(jquery)
}
wailsRuntime := BoxString(&defaultAssets, "wails.js")
h.evalJS(wailsRuntime)
h.evalJS(wailsRuntime, wailsRuntimeMessage)
// Inject the initial JS
for _, js := range h.initialisationJS {
h.sendMessage(conn, js)
h.sendMessage(h.theConnection, js)
}
// Inject bindings
for _, binding := range h.bindingCache {
h.evalJS(binding)
h.evalJS(binding, bindingMessage)
}
// Inject Framework
if h.frameworkJS != "" {
h.evalJS(h.frameworkJS)
}
if h.frameworkCSS != "" {
h.injectCSS(h.frameworkCSS)
}
// If given an HMTL fragment, mount it on #app
// Otherwise, replace the html tag
var injectHTML string
if h.appConfig.isHTMLFragment {
injectHTML = fmt.Sprintf("$('#app').html('%s')", h.appConfig.HTML)
} else {
injectHTML = fmt.Sprintf("$('html').html('%s')", h.appConfig.HTML)
}
h.evalJS(injectHTML)
// Inject user CSS
if h.appConfig.CSS != "" {
outputCSS := fmt.Sprintf("%.45s", h.appConfig.CSS)
if len(outputCSS) > 45 {
outputCSS += "..."
}
h.log.DebugFields("Inject User CSS", Fields{"css": outputCSS})
h.injectCSS(h.appConfig.CSS)
}
// Inject all the CSS files that have been added
for _, css := range h.cssCache {
h.injectCSS(css)
}
// Inject all the JS files that have been added
for _, js := range h.jsCache {
h.evalJS(js)
}
// Inject user JS
if h.appConfig.JS != "" {
outputJS := fmt.Sprintf("%.45s", h.appConfig.JS)
if len(outputJS) > 45 {
outputJS += "..."
}
h.log.DebugFields("Inject User JS", Fields{"js": outputJS})
h.evalJS(h.appConfig.JS)
}
// Emit that everything is loaded and ready
h.eventManager.Emit("wails:ready")
for {
messageType, buffer, err := conn.ReadMessage()
@@ -187,11 +150,10 @@ func (h *Headless) start(conn *websocket.Conn) {
// Run the app in headless mode!
func (h *Headless) Run() error {
h.server = &http.Server{Addr: ":34115"}
http.HandleFunc("/ws", h.wsHandler)
http.HandleFunc("/", h.rootHandler)
http.HandleFunc("/bridge", h.wsBridgeHandler)
h.log.Info("Started on port 34115")
h.log.Info("Application running at http://localhost:34115")
h.log.Info("Headless mode started.")
h.log.Info("The Wails bridge will connect automatically.")
err := h.server.ListenAndServe()
if err != nil {
@@ -202,18 +164,10 @@ func (h *Headless) Run() error {
// NewBinding creates a new binding with the frontend
func (h *Headless) NewBinding(methodName string) error {
objectCode := fmt.Sprintf("window.wails._.newBinding(`%s`);", methodName)
h.bindingCache = append(h.bindingCache, objectCode)
h.bindingCache = append(h.bindingCache, methodName)
return nil
}
// InjectFramework sets up what JS/CSS should be injected
// at startup
func (h *Headless) InjectFramework(js, css string) {
h.frameworkJS = js
h.frameworkCSS = css
}
// SelectFile is unsupported for Headless but required
// for the Renderer interface
func (h *Headless) SelectFile() string {
@@ -249,8 +203,7 @@ func (h *Headless) AddCSSList(cssCache []string) {
// Callback sends a callback to the frontend
func (h *Headless) Callback(data string) error {
callbackCMD := fmt.Sprintf("window.wails._.callback('%s');", data)
return h.evalJS(callbackCMD)
return h.evalJS(data, callbackMessage)
}
// NotifyEvent notifies the frontend of an event
@@ -277,8 +230,8 @@ func (h *Headless) NotifyEvent(event *eventData) error {
}
}
message := fmt.Sprintf("wails._.notify('%s','%s')", event.Name, data)
return h.evalJS(message)
message := fmt.Sprintf("window.wails._.notify('%s','%s')", event.Name, data)
return h.evalJS(message, notifyMessage)
}
// SetColour is unsupported for Headless but required

View File

@@ -171,10 +171,6 @@ func (w *webViewRenderer) Run() error {
// Run this in a different go routine to free up the main process
go func() {
// Will we mount a custom component
// Inject jquery
jquery := BoxString(&assets, "jquery.3.3.1.min.js")
w.evalJSSync(jquery)
// Inject Bindings
for _, binding := range w.bindingCache {
@@ -189,17 +185,6 @@ func (w *webViewRenderer) Run() error {
w.injectCSS(w.frameworkCSS)
}
// Do we have custom html?
// If given an HMTL fragment, mount it on #app
// Otherwise, replace the html tag
var injectHTML string
if w.config.isHTMLFragment {
injectHTML = fmt.Sprintf("$('#app').html('%s')", w.config.HTML)
} else {
injectHTML = fmt.Sprintf("$('html').html('%s')", w.config.HTML)
}
w.evalJSSync(injectHTML)
// Inject user CSS
if w.config.CSS != "" {
outputCSS := fmt.Sprintf("%.45s", w.config.CSS)
@@ -208,6 +193,12 @@ func (w *webViewRenderer) Run() error {
}
w.log.DebugFields("Inject User CSS", Fields{"css": outputCSS})
w.injectCSS(w.config.CSS)
} else {
// Use default wails css
w.log.Debug("Injecting Default Wails CSS")
defaultCSS := BoxString(&defaultAssets, "wails.css")
w.injectCSS(defaultCSS)
}
// Inject all the CSS files that have been added
@@ -248,11 +239,6 @@ func (w *webViewRenderer) NewBinding(methodName string) error {
return nil
}
func (w *webViewRenderer) InjectFramework(js, css string) {
w.frameworkJS = js
w.frameworkCSS = css
}
func (w *webViewRenderer) SelectFile() string {
var result string

View File

@@ -1,5 +1,6 @@
package wails
// Runtime is the Wails Runtime Interface, given to a user who has defined the WailsInit method
type Runtime struct {
Events *RuntimeEvents
Log *RuntimeLog

View File

@@ -1,23 +1,28 @@
package wails
// RuntimeDialog exposes an interface to native dialogs
type RuntimeDialog struct {
renderer Renderer
}
// newRuntimeDialog creates a new RuntimeDialog struct
func newRuntimeDialog(renderer Renderer) *RuntimeDialog {
return &RuntimeDialog{
renderer: renderer,
}
}
// SelectFile prompts the user to select a file
func (r *RuntimeDialog) SelectFile() string {
return r.renderer.SelectFile()
}
// SelectDirectory prompts the user to select a directory
func (r *RuntimeDialog) SelectDirectory() string {
return r.renderer.SelectDirectory()
}
// SelectSaveFile prompts the user to select a file for saving
func (r *RuntimeDialog) SelectSaveFile() string {
return r.renderer.SelectSaveFile()
}

View File

@@ -1,5 +1,6 @@
package wails
// RuntimeEvents exposes the events interface
type RuntimeEvents struct {
eventManager *eventManager
}

View File

@@ -1,5 +1,6 @@
package wails
// RuntimeLog exposes the logging interface to the runtime
type RuntimeLog struct {
}
@@ -7,6 +8,7 @@ func newRuntimeLog() *RuntimeLog {
return &RuntimeLog{}
}
// New creates a new logger
func (r *RuntimeLog) New(prefix string) *CustomLogger {
return newCustomLogger(prefix)
}

View File

@@ -1,5 +1,6 @@
package wails
// RuntimeWindow exposes an interface for manipulating the window
type RuntimeWindow struct {
renderer Renderer
}
@@ -10,23 +11,27 @@ func newRuntimeWindow(renderer Renderer) *RuntimeWindow {
}
}
// SetColour sets the the window colour
func (r *RuntimeWindow) SetColour(colour string) error {
return r.renderer.SetColour(colour)
}
// Fullscreen makes the window fullscreen
func (r *RuntimeWindow) Fullscreen() {
r.renderer.Fullscreen()
}
// UnFullscreen attempts to restore the window to the size/position before fullscreen
func (r *RuntimeWindow) UnFullscreen() {
r.renderer.UnFullscreen()
}
// SetTitle sets the the window title
func (r *RuntimeWindow) SetTitle(title string) {
r.renderer.SetTitle(title)
}
// Close shuts down the window and therefore the app
func (r *RuntimeWindow) Close() {
// TODO: Add shutdown mechanism
r.renderer.Close()
}

21
webview/LICENSE Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2017 Serge Zaitsev
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.