Compare commits

..

3 Commits

Author SHA1 Message Date
Lea Anthony
397094485b Fix CWE-126 2020-05-09 06:04:55 +10:00
Lea Anthony
72aa820761 lint fix 2020-05-09 05:55:54 +10:00
Lea Anthony
5e923ab200 Disable F5 key on windows 2020-05-09 05:46:40 +10:00
12 changed files with 41 additions and 77 deletions

View File

@@ -57,7 +57,7 @@ _Ubuntu: 16.04, 18.04, 19.04_
_Also succesfully tested on: Zorin 15, Parrot 4.7, Linuxmint 19, Elementary 5, Kali, Neon_
#### Arch Linux / ArchLabs
#### Arch Linux
`sudo pacman -S webkit2gtk gtk3`

File diff suppressed because one or more lines are too long

View File

@@ -510,8 +510,6 @@ func InstallRuntime(caller string, projectDir string, projectOptions *ProjectOpt
// InstallBridge installs the relevant bridge javascript library
func InstallBridge(projectDir string, projectOptions *ProjectOptions) error {
bridgeFileData := mewn.String("../runtime/assets/bridge.js")
// Inject the custom serve port
bridgeFileData = strings.ReplaceAll(bridgeFileData, "$SERVEPORT$", projectOptions.ServePort)
bridgeFileTarget := filepath.Join(projectDir, projectOptions.FrontEnd.Dir, "node_modules", "@wailsapp", "runtime", "init.js")
err := fs.CreateFile(bridgeFileTarget, []byte(bridgeFileData))
return err
@@ -563,10 +561,6 @@ func ldFlags(po *ProjectOptions, buildMode string) string {
ldflags += "-X github.com/wailsapp/wails.BuildMode=" + buildMode
// Inject port if we are using bridge mode
if buildMode == BuildModeBridge {
ldflags += " -X github.com/wailsapp/wails/lib/renderer/bridge.ServePort=" + po.ServePort
}
// If we wish to generate typescript
if po.typescriptDefsFilename != "" {
cwd, err := os.Getwd()

View File

@@ -53,12 +53,10 @@ const (
Deepin
// Raspbian distribution
Raspbian
// Tumbleweed (OpenSUSE) distribution
// openSUSE Tumbleweed distribution
Tumbleweed
// Leap (OpenSUSE) distribution
// openSUSE Leap distribution
Leap
// ArchLabs distribution
ArchLabs
)
// DistroInfo contains all the information relating to a linux distribution
@@ -116,15 +114,13 @@ func parseOsRelease(osRelease string) *DistroInfo {
}
// Check distro name against list of distros
switch strings.ToLower(osID) {
switch osID {
case "fedora":
result.Distribution = Fedora
case "centos":
result.Distribution = CentOS
case "arch":
result.Distribution = Arch
case "archlabs":
result.Distribution = ArchLabs
case "debian":
result.Distribution = Debian
case "ubuntu":

View File

@@ -176,15 +176,6 @@ distributions:
gccversioncommand: *gccdumpversion
programs: *archdefaultprograms
libraries: *archdefaultlibraries
archlabs:
id: archlabs
releases:
default:
version: default
name: ArchLabs
gccversioncommand: *gccdumpversion
programs: *archdefaultprograms
libraries: *archdefaultlibraries
manjaro:
id: manjaro
releases:

View File

@@ -161,7 +161,6 @@ type ProjectOptions struct {
CrossCompile bool
Platform string
Architecture string
ServePort string
}
// Defaults sets the default project template

View File

@@ -276,7 +276,7 @@ func CheckDependencies(logger *Logger) (bool, error) {
switch distroInfo.Distribution {
case Ubuntu, Debian, Zorin, Parrot, Linuxmint, Elementary, Kali, Neon, Deepin, Raspbian:
libraryChecker = DpkgInstalled
case Arch, ArcoLinux, ArchLabs, Manjaro, ManjaroARM:
case Arch, ArcoLinux, Manjaro, ManjaroARM:
libraryChecker = PacmanInstalled
case CentOS, Fedora, Tumbleweed, Leap:
libraryChecker = RpmInstalled

View File

@@ -1,4 +1,4 @@
package cmd
// Version - Wails version
const Version = "v1.6.0-pre2"
const Version = "v1.5.0"

View File

@@ -2,7 +2,6 @@ package main
import (
"fmt"
"strconv"
"github.com/leaanthony/spinner"
"github.com/wailsapp/wails/cmd"
@@ -11,7 +10,6 @@ import (
func init() {
var forceRebuild = false
var servePort = "34115"
var verbose = false
buildSpinner := spinner.NewSpinner()
buildSpinner.SetSpinSpeed(50)
@@ -20,8 +18,7 @@ func init() {
initCmd := app.Command("serve", "Run your Wails project in bridge mode").
LongDescription(commandDescription).
BoolFlag("verbose", "Verbose output", &verbose).
BoolFlag("f", "Force rebuild of application components", &forceRebuild).
StringFlag("p", "Port to serve on", &servePort)
BoolFlag("f", "Force rebuild of application components", &forceRebuild)
initCmd.Action(func() error {
@@ -37,6 +34,7 @@ func init() {
// Project options
projectOptions := &cmd.ProjectOptions{}
projectOptions.Verbose = verbose
// Check we are in project directory
// Check project.json loads correctly
@@ -46,16 +44,6 @@ func init() {
return err
}
// Set Verbose flag
projectOptions.Verbose = verbose
// Check port
port, err := strconv.Atoi(servePort)
if err != nil || port <= 0 {
return fmt.Errorf("invalid port value: %s", servePort)
}
projectOptions.ServePort = servePort
// Save project directory
projectDir := fs.Cwd()

View File

@@ -1,4 +1,4 @@
package bridge
package renderer
import (
"encoding/json"
@@ -14,10 +14,6 @@ import (
type messageType int
// ServePort indicates which port to serve the backend on when using
// `wails serve`
var ServePort = "34115"
const (
jsMessage messageType = iota
cssMessage
@@ -97,7 +93,7 @@ func (h *Bridge) startSession(conn *websocket.Conn) {
// Run the app in Bridge mode!
func (h *Bridge) Run() error {
h.server = &http.Server{Addr: ":" + ServePort}
h.server = &http.Server{Addr: ":34115"}
http.HandleFunc("/bridge", h.wsBridgeHandler)
h.log.Info("Bridge mode started.")

View File

@@ -1,4 +1,4 @@
package bridge
package renderer
import (
"time"

View File

@@ -14,7 +14,7 @@ function init() {
window.wailsbridge = {
reconnectOverlay: null,
reconnectTimer: 300,
wsURL: 'ws://' + window.location.hostname + ':$SERVEPORT$/bridge',
wsURL: 'ws://' + window.location.hostname + ':34115/bridge',
connectionState: null,
config: {},
websocket: null,
@@ -149,38 +149,38 @@ function startBridge() {
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));
// 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;
// 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;
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;
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);
window.wails._.Callback(callbackData);
break;
default:
window.wails.Log.Error('Unknown message type received: ' + message.data[0]);
case 'c':
var callbackData = message.data.slice(1);
window.wails._.Callback(callbackData);
break;
default:
window.wails.Log.Error('Unknown message type received: ' + message.data[0]);
}
}