mirror of
https://github.com/taigrr/wails.git
synced 2026-04-11 09:31:31 -07:00
Compare commits
103 Commits
firebug
...
feature/1.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c582aafd25 | ||
|
|
626b989eb2 | ||
|
|
d0f753776a | ||
|
|
38c68d8189 | ||
|
|
c5391c927e | ||
|
|
ec468888be | ||
|
|
b2c8b32f09 | ||
|
|
22cabfe704 | ||
|
|
b383ac9942 | ||
|
|
2659d9d0c2 | ||
|
|
57bbadf57b | ||
|
|
77fb1e070a | ||
|
|
9ae95f86a1 | ||
|
|
79af447109 | ||
|
|
21bdc94941 | ||
|
|
a1bd1013cb | ||
|
|
2b6860b6c3 | ||
|
|
984c5f58f2 | ||
|
|
17b28a26bd | ||
|
|
5088c1647f | ||
|
|
9cb0ded9ed | ||
|
|
befcf14d40 | ||
|
|
eea6ee28aa | ||
|
|
5b30db47ac | ||
|
|
d4de8b4af0 | ||
|
|
a706b3f7e5 | ||
|
|
5e89392fce | ||
|
|
97160037ff | ||
|
|
97e6ef7894 | ||
|
|
c4b56e27a5 | ||
|
|
074961d139 | ||
|
|
0bbf1fd098 | ||
|
|
5329157240 | ||
|
|
ed2da4c349 | ||
|
|
1a7e762564 | ||
|
|
cb16ad1938 | ||
|
|
779095c988 | ||
|
|
eb7349efbc | ||
|
|
8ddc3e9527 | ||
|
|
0393cb3dec | ||
|
|
872b57eb4c | ||
|
|
17421552fe | ||
|
|
e8f269ca0a | ||
|
|
1b5ac3d2b6 | ||
|
|
c88aedc890 | ||
|
|
ec7fa44b44 | ||
|
|
4ce5aef237 | ||
|
|
f3c7ce2061 | ||
|
|
49a9a93e4e | ||
|
|
36feb41e3f | ||
|
|
9167508302 | ||
|
|
cbd9eca6c3 | ||
|
|
181a34f38d | ||
|
|
15556ad389 | ||
|
|
3fc0f05fab | ||
|
|
7c249e9c6b | ||
|
|
cb03409e3a | ||
|
|
40db3587cb | ||
|
|
6228328278 | ||
|
|
17a9cf4afb | ||
|
|
4a6e9d059c | ||
|
|
76b12b5b80 | ||
|
|
3567ec9865 | ||
|
|
1a3cefd180 | ||
|
|
7b603a2776 | ||
|
|
5ced28cb74 | ||
|
|
0d49a8cc83 | ||
|
|
9cd5ad69ce | ||
|
|
7dbf74c3e0 | ||
|
|
6613cff1d5 | ||
|
|
6a2700e0bf | ||
|
|
2a6162a91f | ||
|
|
4e54229dfb | ||
|
|
ce58e9eb6c | ||
|
|
3c49577d5b | ||
|
|
fb8aa8cc24 | ||
|
|
b45e04f2db | ||
|
|
026daf5e57 | ||
|
|
7c04a854da | ||
|
|
7832a3be19 | ||
|
|
39d687fa31 | ||
|
|
8a768cce77 | ||
|
|
ee04a9235d | ||
|
|
7e67562e19 | ||
|
|
25d8a8763a | ||
|
|
7929584ec5 | ||
|
|
73ee9ef530 | ||
|
|
003eecc4ff | ||
|
|
f97341abbe | ||
|
|
e2599c0f76 | ||
|
|
0c2c56e1dd | ||
|
|
39878c1a52 | ||
|
|
c0932f3fa4 | ||
|
|
dc605c1683 | ||
|
|
c7c9ace232 | ||
|
|
5be197b68f | ||
|
|
3e5c406c95 | ||
|
|
be6bebebe4 | ||
|
|
5b33ed28fd | ||
|
|
5267968151 | ||
|
|
7b31c8ddd2 | ||
|
|
1e2bc5728a | ||
|
|
e0aab7c27f |
12
.github/FUNDING.yml
vendored
Normal file
12
.github/FUNDING.yml
vendored
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
# These are supported funding model platforms
|
||||||
|
|
||||||
|
github: [leaanthony]
|
||||||
|
patreon: # Replace with a single Patreon username
|
||||||
|
open_collective: # Replace with a single Open Collective username
|
||||||
|
ko_fi: # Replace with a single Ko-fi username
|
||||||
|
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
||||||
|
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
||||||
|
liberapay: # Replace with a single Liberapay username
|
||||||
|
issuehunt: # Replace with a single IssueHunt username
|
||||||
|
otechie: # Replace with a single Otechie username
|
||||||
|
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
|
||||||
4
.github/workflows/latest-pre.yml
vendored
4
.github/workflows/latest-pre.yml
vendored
@@ -13,10 +13,10 @@ jobs:
|
|||||||
os: [ubuntu-latest, windows-latest, macOS-latest]
|
os: [ubuntu-latest, windows-latest, macOS-latest]
|
||||||
steps:
|
steps:
|
||||||
|
|
||||||
- name: Set up Go 1.13
|
- name: Set up Go 1.16
|
||||||
uses: actions/setup-go@v1
|
uses: actions/setup-go@v1
|
||||||
with:
|
with:
|
||||||
go-version: 1.13
|
go-version: 1.16
|
||||||
id: go
|
id: go
|
||||||
|
|
||||||
- name: Check out code into the Go module directory
|
- name: Check out code into the Go module directory
|
||||||
|
|||||||
4
.github/workflows/pr.yml
vendored
4
.github/workflows/pr.yml
vendored
@@ -13,10 +13,10 @@ jobs:
|
|||||||
os: [ubuntu-latest, windows-latest, macOS-latest]
|
os: [ubuntu-latest, windows-latest, macOS-latest]
|
||||||
steps:
|
steps:
|
||||||
|
|
||||||
- name: Set up Go 1.13
|
- name: Set up Go 1.16
|
||||||
uses: actions/setup-go@v1
|
uses: actions/setup-go@v1
|
||||||
with:
|
with:
|
||||||
go-version: 1.13
|
go-version: 1.16
|
||||||
id: go
|
id: go
|
||||||
|
|
||||||
- name: Check out code into the Go module directory
|
- name: Check out code into the Go module directory
|
||||||
|
|||||||
4
.github/workflows/release.yml
vendored
4
.github/workflows/release.yml
vendored
@@ -15,10 +15,10 @@ jobs:
|
|||||||
os: [ubuntu-latest, windows-latest, macOS-latest]
|
os: [ubuntu-latest, windows-latest, macOS-latest]
|
||||||
steps:
|
steps:
|
||||||
|
|
||||||
- name: Set up Go 1.13
|
- name: Set up Go 1.16
|
||||||
uses: actions/setup-go@v1
|
uses: actions/setup-go@v1
|
||||||
with:
|
with:
|
||||||
go-version: 1.13
|
go-version: 1.16
|
||||||
id: go
|
id: go
|
||||||
|
|
||||||
- name: Check out code into the Go module directory
|
- name: Check out code into the Go module directory
|
||||||
|
|||||||
@@ -39,3 +39,10 @@ Wails is what it is because of the time and effort given by these great people.
|
|||||||
* [Kyle](https://github.com/kmuchmore)
|
* [Kyle](https://github.com/kmuchmore)
|
||||||
* [Balakrishna Prasad Ganne](https://github.com/aayush420)
|
* [Balakrishna Prasad Ganne](https://github.com/aayush420)
|
||||||
* [Charaf Rezrazi](https://github.com/Rezrazi)
|
* [Charaf Rezrazi](https://github.com/Rezrazi)
|
||||||
|
* [misitebao](https://github.com/misitebao)
|
||||||
|
* [Elie Grenon](https://github.com/DrunkenPoney)
|
||||||
|
* [SophieAu](https://github.com/SophieAu)
|
||||||
|
* [Alexander Matviychuk](https://github.com/alexmat)
|
||||||
|
* [RH12503](https://github.com/RH12503)
|
||||||
|
* [hi019](https://github.com/hi019)
|
||||||
|
|
||||||
26
README.md
26
README.md
@@ -2,7 +2,7 @@
|
|||||||
<img src="logo_cropped.png" width="40%"><br/>
|
<img src="logo_cropped.png" width="40%"><br/>
|
||||||
</p>
|
</p>
|
||||||
<p align="center">
|
<p align="center">
|
||||||
A framework for building desktop applications using Go & Web Technologies.<br/><br/>
|
Build desktop applications using Go & Web Technologies.<br/><br/>
|
||||||
<a href="https://github.com/wailsapp/wails/blob/master/LICENSE"><img src="https://img.shields.io/badge/License-MIT-blue.svg"></a>
|
<a href="https://github.com/wailsapp/wails/blob/master/LICENSE"><img src="https://img.shields.io/badge/License-MIT-blue.svg"></a>
|
||||||
<a href="https://goreportcard.com/report/github.com/wailsapp/wails"><img src="https://goreportcard.com/badge/github.com/wailsapp/wails"/></a>
|
<a href="https://goreportcard.com/report/github.com/wailsapp/wails"><img src="https://goreportcard.com/badge/github.com/wailsapp/wails"/></a>
|
||||||
<a href="http://godoc.org/github.com/wailsapp/wails"><img src="https://img.shields.io/badge/godoc-reference-blue.svg"/></a>
|
<a href="http://godoc.org/github.com/wailsapp/wails"><img src="https://img.shields.io/badge/godoc-reference-blue.svg"/></a>
|
||||||
@@ -20,7 +20,7 @@ The official docs can be found at [https://wails.app](https://wails.app).
|
|||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
- Use standard Go libraries/frameworks for the backend
|
- Use standard Go for the backend
|
||||||
- Use any frontend technology to build your UI
|
- Use any frontend technology to build your UI
|
||||||
- Quickly create Vue, Vuetify or React frontends for your Go programs
|
- Quickly create Vue, Vuetify or React frontends for your Go programs
|
||||||
- Expose Go methods/functions to the frontend via a single bind command
|
- Expose Go methods/functions to the frontend via a single bind command
|
||||||
@@ -30,6 +30,20 @@ The official docs can be found at [https://wails.app](https://wails.app).
|
|||||||
- Powerful cli tool
|
- Powerful cli tool
|
||||||
- Multiplatform
|
- Multiplatform
|
||||||
|
|
||||||
|
## Sponsors
|
||||||
|
|
||||||
|
This project is supported by these kind people:
|
||||||
|
|
||||||
|
<a href="https://pace.dev" style="width:100px"><img src="pace.jpeg" width="100"/></a>
|
||||||
|
<a href="https://github.com/tc-hib" style="width:50px;border-radius: 50%">
|
||||||
|
<img src="https://github.com/tc-hib.png?size=50" width="50" style="border-radius: 50%"/>
|
||||||
|
</a>
|
||||||
|
<a href="https://github.com/picatz" style="width:50px;border-radius: 50%">
|
||||||
|
<img src="https://github.com/picatz.png?size=50" width="50" style="border-radius: 50%"/>
|
||||||
|
</a>
|
||||||
|
<a href="https://github.com/tylertravisty" style="width:50px;border-radius: 50%">
|
||||||
|
<img src="https://github.com/tylertravisty.png?size=50" width="50" style="border-radius: 50%"/>
|
||||||
|
</a>
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
@@ -147,7 +161,13 @@ This project was mainly coded to the following albums:
|
|||||||
|
|
||||||
[](https://app.fossa.io/projects/git%2Bgithub.com%2Fwailsapp%2Fwails?ref=badge_large)
|
[](https://app.fossa.io/projects/git%2Bgithub.com%2Fwailsapp%2Fwails?ref=badge_large)
|
||||||
|
|
||||||
## Special Thank You
|
## Special Thanks
|
||||||
|
|
||||||
|
<p align="center" style="text-align: center">
|
||||||
|
<a href="https://pace.dev"><img src="pace.jpeg"/></a><br/>
|
||||||
|
A *huge* thanks to <a href="https://pace.dev">Pace</a> for sponsoring the project and helping the efforts to get Wails ported to Apple Silicon!<br/><br/>
|
||||||
|
If you are looking for a Project Management tool that's powerful but quick and easy to use, check them out!<br/><br/>
|
||||||
|
</p>
|
||||||
|
|
||||||
<p align="center" style="text-align: center">
|
<p align="center" style="text-align: center">
|
||||||
A special thank you to JetBrains for donating licenses to us!<br/><br/>
|
A special thank you to JetBrains for donating licenses to us!<br/><br/>
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -24,7 +24,7 @@ func (g *GitHubHelper) GetVersionTags() ([]*SemanticVersion, error) {
|
|||||||
result := []*SemanticVersion{}
|
result := []*SemanticVersion{}
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
resp, err := http.Get("https://api.github.com/repos/wailsapp/wails/tags")
|
resp, err := http.Get("https://api.github.com/repos/wailsapp/wails/releases")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
|
|||||||
114
cmd/helpers.go
114
cmd/helpers.go
@@ -2,7 +2,6 @@ package cmd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"os/user"
|
"os/user"
|
||||||
@@ -12,10 +11,9 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/leaanthony/mewn"
|
|
||||||
"github.com/leaanthony/mewn/lib"
|
|
||||||
"github.com/leaanthony/slicer"
|
"github.com/leaanthony/slicer"
|
||||||
"github.com/leaanthony/spinner"
|
"github.com/leaanthony/spinner"
|
||||||
|
wailsruntime "github.com/wailsapp/wails/runtime"
|
||||||
)
|
)
|
||||||
|
|
||||||
const xgoVersion = "1.0.1"
|
const xgoVersion = "1.0.1"
|
||||||
@@ -61,30 +59,6 @@ func InstallGoDependencies(verbose bool) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// EmbedAssets will embed the built frontend assets via mewn.
|
|
||||||
func EmbedAssets() ([]string, error) {
|
|
||||||
mewnFiles := lib.GetMewnFiles([]string{}, false)
|
|
||||||
|
|
||||||
referencedAssets, err := lib.GetReferencedAssets(mewnFiles)
|
|
||||||
if err != nil {
|
|
||||||
return []string{}, err
|
|
||||||
}
|
|
||||||
|
|
||||||
targetFiles := []string{}
|
|
||||||
|
|
||||||
for _, referencedAsset := range referencedAssets {
|
|
||||||
packfileData, err := lib.GeneratePackFileString(referencedAsset, false)
|
|
||||||
if err != nil {
|
|
||||||
return []string{}, err
|
|
||||||
}
|
|
||||||
targetFile := filepath.Join(referencedAsset.BaseDir, referencedAsset.PackageName+"-mewn.go")
|
|
||||||
targetFiles = append(targetFiles, targetFile)
|
|
||||||
ioutil.WriteFile(targetFile, []byte(packfileData), 0644)
|
|
||||||
}
|
|
||||||
|
|
||||||
return targetFiles, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func InitializeCrossCompilation(verbose bool) error {
|
func InitializeCrossCompilation(verbose bool) error {
|
||||||
// Check Docker
|
// Check Docker
|
||||||
if err := CheckIfInstalled("docker"); err != nil {
|
if err := CheckIfInstalled("docker"); err != nil {
|
||||||
@@ -127,7 +101,10 @@ func BuildDocker(binaryName string, buildMode string, projectOptions *ProjectOpt
|
|||||||
// Check build directory
|
// Check build directory
|
||||||
buildDirectory := filepath.Join(fs.Cwd(), "build")
|
buildDirectory := filepath.Join(fs.Cwd(), "build")
|
||||||
if !fs.DirExists(buildDirectory) {
|
if !fs.DirExists(buildDirectory) {
|
||||||
fs.MkDir(buildDirectory)
|
err := fs.MkDir(buildDirectory)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
buildCommand := slicer.String()
|
buildCommand := slicer.String()
|
||||||
@@ -198,11 +175,6 @@ func BuildDocker(binaryName string, buildMode string, projectOptions *ProjectOpt
|
|||||||
// BuildNative builds on the target platform itself.
|
// BuildNative builds on the target platform itself.
|
||||||
func BuildNative(binaryName string, forceRebuild bool, buildMode string, projectOptions *ProjectOptions) error {
|
func BuildNative(binaryName string, forceRebuild bool, buildMode string, projectOptions *ProjectOptions) error {
|
||||||
|
|
||||||
// Check Mewn is installed
|
|
||||||
if err := CheckMewn(projectOptions.Verbose); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := CheckWindres(); err != nil {
|
if err := CheckWindres(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -275,12 +247,6 @@ func BuildNative(binaryName string, forceRebuild bool, buildMode string, project
|
|||||||
func BuildApplication(binaryName string, forceRebuild bool, buildMode string, packageApp bool, projectOptions *ProjectOptions) error {
|
func BuildApplication(binaryName string, forceRebuild bool, buildMode string, packageApp bool, projectOptions *ProjectOptions) error {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
// embed resources
|
|
||||||
targetFiles, err := EmbedAssets()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if projectOptions.CrossCompile {
|
if projectOptions.CrossCompile {
|
||||||
if err := InitializeCrossCompilation(projectOptions.Verbose); err != nil {
|
if err := InitializeCrossCompilation(projectOptions.Verbose); err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -296,20 +262,6 @@ func BuildApplication(binaryName string, forceRebuild bool, buildMode string, pa
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// cleanup temporary embedded assets
|
|
||||||
defer func() {
|
|
||||||
for _, filename := range targetFiles {
|
|
||||||
if err := os.Remove(filename); err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Removed by popular demand
|
|
||||||
// TODO: Potentially add a flag to cleanup
|
|
||||||
// if projectOptions.Platform == "windows" {
|
|
||||||
// helper.CleanWindows(projectOptions)
|
|
||||||
// }
|
|
||||||
}()
|
|
||||||
|
|
||||||
if projectOptions.CrossCompile {
|
if projectOptions.CrossCompile {
|
||||||
err = BuildDocker(binaryName, buildMode, projectOptions)
|
err = BuildDocker(binaryName, buildMode, projectOptions)
|
||||||
} else {
|
} else {
|
||||||
@@ -374,30 +326,6 @@ func BuildFrontend(projectOptions *ProjectOptions) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// CheckMewn checks if mewn is installed and if not, attempts to fetch it
|
|
||||||
func CheckMewn(verbose bool) (err error) {
|
|
||||||
programHelper := NewProgramHelper(verbose)
|
|
||||||
if !programHelper.IsInstalled("mewn") {
|
|
||||||
var buildSpinner *spinner.Spinner
|
|
||||||
if !verbose {
|
|
||||||
buildSpinner = spinner.New()
|
|
||||||
buildSpinner.SetSpinSpeed(50)
|
|
||||||
buildSpinner.Start("Installing Mewn asset packer...")
|
|
||||||
}
|
|
||||||
err := programHelper.InstallGoPackage("github.com/leaanthony/mewn/cmd/mewn")
|
|
||||||
if err != nil {
|
|
||||||
if buildSpinner != nil {
|
|
||||||
buildSpinner.Error()
|
|
||||||
}
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if buildSpinner != nil {
|
|
||||||
buildSpinner.Success()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// CheckWindres checks if Windres is installed and if not, aborts
|
// CheckWindres checks if Windres is installed and if not, aborts
|
||||||
func CheckWindres() (err error) {
|
func CheckWindres() (err error) {
|
||||||
if runtime.GOOS != "windows" { // FIXME: Handle windows cross-compile for windows!
|
if runtime.GOOS != "windows" { // FIXME: Handle windows cross-compile for windows!
|
||||||
@@ -493,11 +421,18 @@ func InstallFrontendDeps(projectDir string, projectOptions *ProjectOptions, forc
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Update md5sum file
|
// Update md5sum file
|
||||||
ioutil.WriteFile(md5sumFile, []byte(packageJSONMD5), 0644)
|
err := os.WriteFile(md5sumFile, []byte(packageJSONMD5), 0644)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Install the runtime
|
// Install the runtime
|
||||||
err = InstallRuntime(caller, projectDir, projectOptions)
|
if caller == "build" {
|
||||||
|
err = InstallProdRuntime(projectDir, projectOptions)
|
||||||
|
} else {
|
||||||
|
err = InstallBridge(projectDir, projectOptions)
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -510,28 +445,17 @@ func InstallFrontendDeps(projectDir string, projectOptions *ProjectOptions, forc
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// InstallRuntime installs the correct runtime for the type of build
|
|
||||||
func InstallRuntime(caller string, projectDir string, projectOptions *ProjectOptions) error {
|
|
||||||
if caller == "build" {
|
|
||||||
return InstallProdRuntime(projectDir, projectOptions)
|
|
||||||
}
|
|
||||||
|
|
||||||
return InstallBridge(projectDir, projectOptions)
|
|
||||||
}
|
|
||||||
|
|
||||||
// InstallBridge installs the relevant bridge javascript library
|
// InstallBridge installs the relevant bridge javascript library
|
||||||
func InstallBridge(projectDir string, projectOptions *ProjectOptions) error {
|
func InstallBridge(projectDir string, projectOptions *ProjectOptions) error {
|
||||||
bridgeFileData := mewn.String("../runtime/assets/bridge.js")
|
|
||||||
bridgeFileTarget := filepath.Join(projectDir, projectOptions.FrontEnd.Dir, "node_modules", "@wailsapp", "runtime", "init.js")
|
bridgeFileTarget := filepath.Join(projectDir, projectOptions.FrontEnd.Dir, "node_modules", "@wailsapp", "runtime", "init.js")
|
||||||
err := fs.CreateFile(bridgeFileTarget, []byte(bridgeFileData))
|
err := fs.CreateFile(bridgeFileTarget, wailsruntime.BridgeJS)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// InstallProdRuntime installs the production runtime
|
// InstallProdRuntime installs the production runtime
|
||||||
func InstallProdRuntime(projectDir string, projectOptions *ProjectOptions) error {
|
func InstallProdRuntime(projectDir string, projectOptions *ProjectOptions) error {
|
||||||
prodInit := mewn.String("../runtime/js/runtime/init.js")
|
|
||||||
bridgeFileTarget := filepath.Join(projectDir, projectOptions.FrontEnd.Dir, "node_modules", "@wailsapp", "runtime", "init.js")
|
bridgeFileTarget := filepath.Join(projectDir, projectOptions.FrontEnd.Dir, "node_modules", "@wailsapp", "runtime", "init.js")
|
||||||
err := fs.CreateFile(bridgeFileTarget, []byte(prodInit))
|
err := fs.CreateFile(bridgeFileTarget, wailsruntime.InitJS)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -595,3 +519,9 @@ func ldFlags(po *ProjectOptions, buildMode string) string {
|
|||||||
}
|
}
|
||||||
return ldflags
|
return ldflags
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getGitConfigValue(key string) (string, error) {
|
||||||
|
output, err := exec.Command("git", "config", "--get", "--null", key).Output()
|
||||||
|
// When using --null git appends a null character (\u0000) to the command output
|
||||||
|
return strings.TrimRight(string(output), "\u0000"), err
|
||||||
|
}
|
||||||
|
|||||||
21
cmd/linux.go
21
cmd/linux.go
@@ -65,6 +65,10 @@ const (
|
|||||||
Solus
|
Solus
|
||||||
// Ctlos Linux distribution
|
// Ctlos Linux distribution
|
||||||
Ctlos
|
Ctlos
|
||||||
|
// EndeavourOS linux distribution
|
||||||
|
EndeavourOS
|
||||||
|
// Crux linux distribution
|
||||||
|
Crux
|
||||||
)
|
)
|
||||||
|
|
||||||
// DistroInfo contains all the information relating to a linux distribution
|
// DistroInfo contains all the information relating to a linux distribution
|
||||||
@@ -132,7 +136,7 @@ func parseOsRelease(osRelease string) *DistroInfo {
|
|||||||
case "archlabs":
|
case "archlabs":
|
||||||
result.Distribution = ArchLabs
|
result.Distribution = ArchLabs
|
||||||
case "ctlos":
|
case "ctlos":
|
||||||
result.Distribution = Ctlos
|
result.Distribution = Ctlos
|
||||||
case "debian":
|
case "debian":
|
||||||
result.Distribution = Debian
|
result.Distribution = Debian
|
||||||
case "ubuntu":
|
case "ubuntu":
|
||||||
@@ -171,6 +175,10 @@ func parseOsRelease(osRelease string) *DistroInfo {
|
|||||||
result.Distribution = PopOS
|
result.Distribution = PopOS
|
||||||
case "solus":
|
case "solus":
|
||||||
result.Distribution = Solus
|
result.Distribution = Solus
|
||||||
|
case "endeavouros":
|
||||||
|
result.Distribution = EndeavourOS
|
||||||
|
case "crux":
|
||||||
|
result.Distribution = Crux
|
||||||
default:
|
default:
|
||||||
result.Distribution = Unknown
|
result.Distribution = Unknown
|
||||||
}
|
}
|
||||||
@@ -251,6 +259,17 @@ func RpmInstalled(packageName string) (bool, error) {
|
|||||||
return exitCode == 0, nil
|
return exitCode == 0, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PrtGetInstalled uses prt-get to see if a package is installed
|
||||||
|
func PrtGetInstalled(packageName string) (bool, error) {
|
||||||
|
program := NewProgramHelper()
|
||||||
|
prtget := program.FindProgram("prt-get")
|
||||||
|
if prtget == nil {
|
||||||
|
return false, fmt.Errorf("cannot check dependencies: prt-get not found")
|
||||||
|
}
|
||||||
|
_, _, exitCode, _ := prtget.Run("isinst", packageName)
|
||||||
|
return exitCode == 0, nil
|
||||||
|
}
|
||||||
|
|
||||||
// RequestSupportForDistribution promts the user to submit a request to support their
|
// RequestSupportForDistribution promts the user to submit a request to support their
|
||||||
// currently unsupported distribution
|
// currently unsupported distribution
|
||||||
func RequestSupportForDistribution(distroInfo *DistroInfo) error {
|
func RequestSupportForDistribution(distroInfo *DistroInfo) error {
|
||||||
|
|||||||
@@ -202,7 +202,16 @@ distributions:
|
|||||||
name: Ctlos Linux
|
name: Ctlos Linux
|
||||||
gccversioncommand: *gccdumpversion
|
gccversioncommand: *gccdumpversion
|
||||||
programs: *archdefaultprograms
|
programs: *archdefaultprograms
|
||||||
libraries: *archdefaultlibraries
|
libraries: *archdefaultlibraries
|
||||||
|
endeavouros:
|
||||||
|
id: endeavouros
|
||||||
|
releases:
|
||||||
|
default:
|
||||||
|
version: default
|
||||||
|
name: EndeavourOS
|
||||||
|
gccversioncommand: *gccdumpversion
|
||||||
|
programs: *archdefaultprograms
|
||||||
|
libraries: *archdefaultlibraries
|
||||||
manjaro:
|
manjaro:
|
||||||
id: manjaro
|
id: manjaro
|
||||||
releases:
|
releases:
|
||||||
@@ -298,3 +307,22 @@ distributions:
|
|||||||
gccversioncommand: *gccdumpfullversion
|
gccversioncommand: *gccdumpfullversion
|
||||||
programs: *opensusedefaultprograms
|
programs: *opensusedefaultprograms
|
||||||
libraries: *opensusedefaultlibraries
|
libraries: *opensusedefaultlibraries
|
||||||
|
crux:
|
||||||
|
id: crux
|
||||||
|
releases:
|
||||||
|
default:
|
||||||
|
version: default
|
||||||
|
name: Crux Linux
|
||||||
|
gccversioncommand: *gccdumpversion
|
||||||
|
programs:
|
||||||
|
- name: gcc
|
||||||
|
help: Please install with `sudo prt-get depinst gcc-c++ make` and try again
|
||||||
|
- name: pkg-config
|
||||||
|
help: Please install with `sudo prt-get depinst pkg-config` and try again
|
||||||
|
- name: npm
|
||||||
|
help: Please install with `sudo prt-get depinst nodejs` and try again
|
||||||
|
libraries:
|
||||||
|
- name: gtk3
|
||||||
|
help: Please install with `sudo prt-get depinst gtk3` and try again
|
||||||
|
- name: webkitgtk
|
||||||
|
help: Please install with `sudo prt-get depinst webkitgtk` and try again
|
||||||
|
|||||||
@@ -24,11 +24,19 @@ func NewSemanticVersion(version string) (*SemanticVersion, error) {
|
|||||||
|
|
||||||
// IsRelease returns true if it's a release version
|
// IsRelease returns true if it's a release version
|
||||||
func (s *SemanticVersion) IsRelease() bool {
|
func (s *SemanticVersion) IsRelease() bool {
|
||||||
|
// Limit to v1
|
||||||
|
if s.Version.Major() != 1 {
|
||||||
|
return false
|
||||||
|
}
|
||||||
return len(s.Version.Prerelease()) == 0 && len(s.Version.Metadata()) == 0
|
return len(s.Version.Prerelease()) == 0 && len(s.Version.Metadata()) == 0
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsPreRelease returns true if it's a prerelease version
|
// IsPreRelease returns true if it's a prerelease version
|
||||||
func (s *SemanticVersion) IsPreRelease() bool {
|
func (s *SemanticVersion) IsPreRelease() bool {
|
||||||
|
// Limit to v1
|
||||||
|
if s.Version.Major() != 1 {
|
||||||
|
return false
|
||||||
|
}
|
||||||
return len(s.Version.Prerelease()) > 0
|
return len(s.Version.Prerelease()) > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
65
cmd/semver_test.go
Normal file
65
cmd/semver_test.go
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
package cmd
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestSemanticVersion_IsPreRelease(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
version string
|
||||||
|
want bool
|
||||||
|
}{
|
||||||
|
{"v1.6.7-pre0", "v1.6.7-pre0", true},
|
||||||
|
{"v2.6.7+pre0", "v2.6.7+pre0", false},
|
||||||
|
{"v2.6.7", "v2.6.7", false},
|
||||||
|
{"v2.0.0+alpha.1", "v2.0.0+alpha.1", false},
|
||||||
|
{"v2.0.0-alpha.1", "v2.0.0-alpha.1", false},
|
||||||
|
{"v1.6.7", "v1.6.7", false},
|
||||||
|
}
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
semanticversion, err := NewSemanticVersion(tt.version)
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("Invalid semantic version: %s", semanticversion)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
s := &SemanticVersion{
|
||||||
|
Version: semanticversion.Version,
|
||||||
|
}
|
||||||
|
if got := s.IsPreRelease(); got != tt.want {
|
||||||
|
t.Errorf("IsPreRelease() = %v, want %v", got, tt.want)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestSemanticVersion_IsRelease(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
version string
|
||||||
|
want bool
|
||||||
|
}{
|
||||||
|
{"v1.6.7", "v1.6.7", true},
|
||||||
|
{"v2.6.7-pre0", "v2.6.7-pre0", false},
|
||||||
|
{"v2.6.7", "v2.6.7", false},
|
||||||
|
{"v2.6.7+release", "v2.6.7+release", false},
|
||||||
|
{"v2.0.0-alpha.1", "v2.0.0-alpha.1", false},
|
||||||
|
{"v1.6.7-pre0", "v1.6.7-pre0", false},
|
||||||
|
}
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
semanticversion, err := NewSemanticVersion(tt.version)
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("Invalid semantic version: %s", semanticversion)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
s := &SemanticVersion{
|
||||||
|
Version: semanticversion.Version,
|
||||||
|
}
|
||||||
|
if got := s.IsRelease(); got != tt.want {
|
||||||
|
t.Errorf("IsRelease() = %v, want %v", got, tt.want)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -99,11 +99,16 @@ func (s *SystemHelper) setup() error {
|
|||||||
|
|
||||||
if config.Name != "" {
|
if config.Name != "" {
|
||||||
systemConfig["name"] = PromptRequired("What is your name", config.Name)
|
systemConfig["name"] = PromptRequired("What is your name", config.Name)
|
||||||
|
} else if n, err := getGitConfigValue("user.name"); err == nil && n != "" {
|
||||||
|
systemConfig["name"] = PromptRequired("What is your name", n)
|
||||||
} else {
|
} else {
|
||||||
systemConfig["name"] = PromptRequired("What is your name")
|
systemConfig["name"] = PromptRequired("What is your name")
|
||||||
}
|
}
|
||||||
|
|
||||||
if config.Email != "" {
|
if config.Email != "" {
|
||||||
systemConfig["email"] = PromptRequired("What is your email address", config.Email)
|
systemConfig["email"] = PromptRequired("What is your email address", config.Email)
|
||||||
|
} else if e, err := getGitConfigValue("user.email"); err == nil && e != "" {
|
||||||
|
systemConfig["email"] = PromptRequired("What is your email address", e)
|
||||||
} else {
|
} else {
|
||||||
systemConfig["email"] = PromptRequired("What is your email address")
|
systemConfig["email"] = PromptRequired("What is your email address")
|
||||||
}
|
}
|
||||||
@@ -180,7 +185,7 @@ func (s *SystemHelper) Initialise() error {
|
|||||||
return s.setup()
|
return s.setup()
|
||||||
}
|
}
|
||||||
|
|
||||||
// SystemConfig - Defines system wode configuration data
|
// SystemConfig - Defines system wide configuration data
|
||||||
type SystemConfig struct {
|
type SystemConfig struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Email string `json:"email"`
|
Email string `json:"email"`
|
||||||
@@ -276,7 +281,7 @@ func CheckDependencies(logger *Logger) (bool, error) {
|
|||||||
switch distroInfo.Distribution {
|
switch distroInfo.Distribution {
|
||||||
case Ubuntu, Debian, Zorin, Parrot, Linuxmint, Elementary, Kali, Neon, Deepin, Raspbian, PopOS:
|
case Ubuntu, Debian, Zorin, Parrot, Linuxmint, Elementary, Kali, Neon, Deepin, Raspbian, PopOS:
|
||||||
libraryChecker = DpkgInstalled
|
libraryChecker = DpkgInstalled
|
||||||
case Arch, ArcoLinux, ArchLabs, Ctlos, Manjaro, ManjaroARM:
|
case Arch, ArcoLinux, ArchLabs, Ctlos, Manjaro, ManjaroARM, EndeavourOS:
|
||||||
libraryChecker = PacmanInstalled
|
libraryChecker = PacmanInstalled
|
||||||
case CentOS, Fedora, Tumbleweed, Leap:
|
case CentOS, Fedora, Tumbleweed, Leap:
|
||||||
libraryChecker = RpmInstalled
|
libraryChecker = RpmInstalled
|
||||||
@@ -286,6 +291,8 @@ func CheckDependencies(logger *Logger) (bool, error) {
|
|||||||
libraryChecker = XbpsInstalled
|
libraryChecker = XbpsInstalled
|
||||||
case Solus:
|
case Solus:
|
||||||
libraryChecker = EOpkgInstalled
|
libraryChecker = EOpkgInstalled
|
||||||
|
case Crux:
|
||||||
|
libraryChecker = PrtGetInstalled
|
||||||
default:
|
default:
|
||||||
return false, RequestSupportForDistribution(distroInfo)
|
return false, RequestSupportForDistribution(distroInfo)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"ng": "npx ng",
|
"ng": "npx ng",
|
||||||
"start": "npx ng serve --poll=2000 --host=0.0.0.0",
|
"serve": "npx ng serve --poll=2000 --host=0.0.0.0",
|
||||||
"build": "npx ng build --single-bundle true --output-hashing none --prod --bundle-styles false",
|
"build": "npx ng build --single-bundle true --output-hashing none --prod --bundle-styles false",
|
||||||
"test": "npx ng test",
|
"test": "npx ng test",
|
||||||
"lint": "npx ng lint",
|
"lint": "npx ng lint",
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/leaanthony/mewn"
|
_ "embed"
|
||||||
"github.com/wailsapp/wails"
|
"github.com/wailsapp/wails"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -9,10 +9,13 @@ func basic() string {
|
|||||||
return "World!"
|
return "World!"
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
//go:embed frontend/dist/my-app/main.js
|
||||||
|
var js string
|
||||||
|
|
||||||
js := mewn.String("./frontend/dist/my-app/main.js")
|
//go:embed frontend/dist/my-app/styles.css
|
||||||
css := mewn.String("./frontend/dist/my-app/styles.css")
|
var css string
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
|
||||||
app := wails.CreateApp(&wails.AppConfig{
|
app := wails.CreateApp(&wails.AppConfig{
|
||||||
Width: 1024,
|
Width: 1024,
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
"author": "bh90210 <ktc@pm.me>",
|
"author": "bh90210 <ktc@pm.me>",
|
||||||
"created": "2019-06-15 18:23:48.666414555 +0300 EEST m=+223.934866008",
|
"created": "2019-06-15 18:23:48.666414555 +0300 EEST m=+223.934866008",
|
||||||
"frontenddir": "frontend",
|
"frontenddir": "frontend",
|
||||||
"serve": "npx ng serve --poll=2000",
|
"serve": "npm run serve",
|
||||||
"bridge": "src",
|
"bridge": "src",
|
||||||
"wailsdir": ""
|
"wailsdir": ""
|
||||||
}
|
}
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
"@wailsapp/runtime": "^1.0.10"
|
"@wailsapp/runtime": "^1.0.10"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "react-scripts start",
|
"serve": "react-scripts start",
|
||||||
"build": "react-scripts build",
|
"build": "react-scripts build",
|
||||||
"test": "react-scripts test",
|
"test": "react-scripts test",
|
||||||
"eject": "react-scripts eject"
|
"eject": "react-scripts eject"
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/leaanthony/mewn"
|
_ "embed"
|
||||||
"github.com/wailsapp/wails"
|
"github.com/wailsapp/wails"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -9,10 +9,13 @@ func basic() string {
|
|||||||
return "World!"
|
return "World!"
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
//go:embed frontend/build/static/js/main.js
|
||||||
|
var js string
|
||||||
|
|
||||||
js := mewn.String("./frontend/build/static/js/main.js")
|
//go:embed frontend/build/static/css/main.css
|
||||||
css := mewn.String("./frontend/build/static/css/main.css")
|
var css string
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
|
||||||
app := wails.CreateApp(&wails.AppConfig{
|
app := wails.CreateApp(&wails.AppConfig{
|
||||||
Width: 1024,
|
Width: 1024,
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
"author": "bh90210 <ktc@pm.me>",
|
"author": "bh90210 <ktc@pm.me>",
|
||||||
"created": "2019-06-07 18:23:48.666414555 +0300 EEST m=+223.934866008",
|
"created": "2019-06-07 18:23:48.666414555 +0300 EEST m=+223.934866008",
|
||||||
"frontenddir": "frontend",
|
"frontenddir": "frontend",
|
||||||
"serve": "npm run start",
|
"serve": "npm run serve",
|
||||||
"bridge": "src",
|
"bridge": "src",
|
||||||
"wailsdir": ""
|
"wailsdir": ""
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
"author": "{{.Author.Name}}<{{.Author.Email}}>",
|
"author": "{{.Author.Name}}<{{.Author.Email}}>",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "rollup -c",
|
"build": "rollup -c",
|
||||||
"dev": "rollup -c -w",
|
"serve": "rollup -c -w",
|
||||||
"start": "sirv public"
|
"start": "sirv public"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|||||||
@@ -80,7 +80,6 @@ export default {
|
|||||||
{
|
{
|
||||||
targets: '> 0.25%, not dead, IE 11',
|
targets: '> 0.25%, not dead, IE 11',
|
||||||
modules: false,
|
modules: false,
|
||||||
spec: true,
|
|
||||||
useBuiltIns: 'usage',
|
useBuiltIns: 'usage',
|
||||||
forceAllTransforms: true,
|
forceAllTransforms: true,
|
||||||
corejs: 3,
|
corejs: 3,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/leaanthony/mewn"
|
_ "embed"
|
||||||
"github.com/wailsapp/wails"
|
"github.com/wailsapp/wails"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -9,9 +9,13 @@ func basic() string {
|
|||||||
return "World!"
|
return "World!"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//go:embed frontend/public/build/bundle.js
|
||||||
|
var js string
|
||||||
|
|
||||||
|
//go:embed frontend/public/build/bundle.css
|
||||||
|
var css string
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
js := mewn.String("./frontend/public/build/bundle.js")
|
|
||||||
css := mewn.String("./frontend/public/build/bundle.css")
|
|
||||||
|
|
||||||
app := wails.CreateApp(&wails.AppConfig{
|
app := wails.CreateApp(&wails.AppConfig{
|
||||||
Width: 1024,
|
Width: 1024,
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
"author": "Tim Kipp <timkipp.22.developer@gmail.com>",
|
"author": "Tim Kipp <timkipp.22.developer@gmail.com>",
|
||||||
"created": "2020-09-06 13:06:10.469848 -0700 PDT m=+213.578828559",
|
"created": "2020-09-06 13:06:10.469848 -0700 PDT m=+213.578828559",
|
||||||
"frontenddir": "frontend",
|
"frontenddir": "frontend",
|
||||||
"serve": "npm run dev",
|
"serve": "npm run serve",
|
||||||
"bridge": "src",
|
"bridge": "src",
|
||||||
"wailsdir": ""
|
"wailsdir": ""
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,17 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/leaanthony/mewn"
|
_ "embed"
|
||||||
"github.com/wailsapp/wails"
|
"github.com/wailsapp/wails"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
//go:embed frontend/build/main.js
|
||||||
|
var js string
|
||||||
|
|
||||||
js := mewn.String("./frontend/build/main.js")
|
//go:embed frontend/build/main.css
|
||||||
css := mewn.String("./frontend/build/main.css")
|
var css string
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
|
||||||
app := wails.CreateApp(&wails.AppConfig{
|
app := wails.CreateApp(&wails.AppConfig{
|
||||||
Width: 1024,
|
Width: 1024,
|
||||||
|
|||||||
@@ -19,16 +19,16 @@
|
|||||||
"@types/mocha": "^8.0.3",
|
"@types/mocha": "^8.0.3",
|
||||||
"@typescript-eslint/eslint-plugin": "^4.3.0",
|
"@typescript-eslint/eslint-plugin": "^4.3.0",
|
||||||
"@typescript-eslint/parser": "^4.3.0",
|
"@typescript-eslint/parser": "^4.3.0",
|
||||||
"@vue/cli-plugin-eslint": "~4.5.6",
|
"@vue/cli-plugin-eslint": "~4.5.9",
|
||||||
"@vue/cli-plugin-router": "~4.5.6",
|
"@vue/cli-plugin-router": "~4.5.9",
|
||||||
"@vue/cli-plugin-typescript": "~4.5.6",
|
"@vue/cli-plugin-typescript": "~4.5.9",
|
||||||
"@vue/cli-plugin-unit-mocha": "~4.5.6",
|
"@vue/cli-plugin-unit-mocha": "~4.5.9",
|
||||||
"@vue/cli-service": "~4.5.6",
|
"@vue/cli-service": "~4.5.9",
|
||||||
"@vue/compiler-sfc": "^3.0.0",
|
"@vue/compiler-sfc": "^3.0.0",
|
||||||
"@vue/eslint-config-typescript": "^5.1.0",
|
"@vue/eslint-config-typescript": "^7.0.0",
|
||||||
"@vue/test-utils": "^2.0.0-0",
|
"@vue/test-utils": "^2.0.0-0",
|
||||||
"chai": "^4.2.0",
|
"chai": "^4.2.0",
|
||||||
"eslint": "^7.10.0",
|
"eslint": "<7.0.0",
|
||||||
"eslint-plugin-vue": "^7.0.0",
|
"eslint-plugin-vue": "^7.0.0",
|
||||||
"node-sass": "^4.14.1",
|
"node-sass": "^4.14.1",
|
||||||
"sass-loader": "^10.0.2",
|
"sass-loader": "^10.0.2",
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/leaanthony/mewn"
|
_ "embed"
|
||||||
"github.com/wailsapp/wails"
|
"github.com/wailsapp/wails"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -9,10 +9,13 @@ func basic() string {
|
|||||||
return "Hello World!"
|
return "Hello World!"
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
//go:embed frontend/dist/app.js
|
||||||
|
var js string
|
||||||
|
|
||||||
js := mewn.String("./frontend/dist/app.js")
|
//go:embed frontend/dist/app.css
|
||||||
css := mewn.String("./frontend/dist/app.css")
|
var css string
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
|
||||||
app := wails.CreateApp(&wails.AppConfig{
|
app := wails.CreateApp(&wails.AppConfig{
|
||||||
Width: 1024,
|
Width: 1024,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/leaanthony/mewn"
|
_ "embed"
|
||||||
"github.com/wailsapp/wails"
|
"github.com/wailsapp/wails"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -9,10 +9,13 @@ func basic() string {
|
|||||||
return "Hello World!"
|
return "Hello World!"
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
//go:embed frontend/dist/app.js
|
||||||
|
var js string
|
||||||
|
|
||||||
js := mewn.String("./frontend/dist/app.js")
|
//go:embed frontend/dist/app.css
|
||||||
css := mewn.String("./frontend/dist/app.css")
|
var css string
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
|
||||||
app := wails.CreateApp(&wails.AppConfig{
|
app := wails.CreateApp(&wails.AppConfig{
|
||||||
Width: 1024,
|
Width: 1024,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/leaanthony/mewn"
|
_ "embed"
|
||||||
"github.com/wailsapp/wails"
|
"github.com/wailsapp/wails"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -9,10 +9,13 @@ func basic() string {
|
|||||||
return "Hello World!"
|
return "Hello World!"
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
//go:embed frontend/dist/app.js
|
||||||
|
var js string
|
||||||
|
|
||||||
js := mewn.String("./frontend/dist/app.js")
|
//go:embed frontend/dist/app.css
|
||||||
css := mewn.String("./frontend/dist/app.css")
|
var css string
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
|
||||||
app := wails.CreateApp(&wails.AppConfig{
|
app := wails.CreateApp(&wails.AppConfig{
|
||||||
Width: 1024,
|
Width: 1024,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/leaanthony/mewn"
|
_ "embed"
|
||||||
"github.com/wailsapp/wails"
|
"github.com/wailsapp/wails"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -9,10 +9,13 @@ func basic() string {
|
|||||||
return "Hello World!"
|
return "Hello World!"
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
//go:embed frontend/dist/app.js
|
||||||
|
var js string
|
||||||
|
|
||||||
js := mewn.String("./frontend/dist/app.js")
|
//go:embed frontend/dist/app.css
|
||||||
css := mewn.String("./frontend/dist/app.css")
|
var css string
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
|
||||||
app := wails.CreateApp(&wails.AppConfig{
|
app := wails.CreateApp(&wails.AppConfig{
|
||||||
Width: 1024,
|
Width: 1024,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
// Version - Wails version
|
// Version - Wails version
|
||||||
const Version = "v1.8.1-pre6"
|
const Version = "v1.16.0"
|
||||||
|
|||||||
@@ -39,12 +39,6 @@ Create your first project by running 'wails init'.`
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check Mewn
|
|
||||||
err = cmd.CheckMewn(false)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check for errors
|
// Check for errors
|
||||||
// CheckDependencies() returns !errors
|
// CheckDependencies() returns !errors
|
||||||
// so to get the right message in this
|
// so to get the right message in this
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -52,7 +53,10 @@ func init() {
|
|||||||
|
|
||||||
var b strings.Builder
|
var b strings.Builder
|
||||||
for _, plat := range getSupportedPlatforms() {
|
for _, plat := range getSupportedPlatforms() {
|
||||||
fmt.Fprintf(&b, " - %s\n", plat)
|
_, err := fmt.Fprintf(&b, " - %s\n", plat)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
initCmd.StringFlag("x",
|
initCmd.StringFlag("x",
|
||||||
fmt.Sprintf("Cross-compile application to specified platform via xgo\n%s", b.String()),
|
fmt.Sprintf("Cross-compile application to specified platform via xgo\n%s", b.String()),
|
||||||
@@ -80,9 +84,12 @@ func init() {
|
|||||||
fs := cmd.NewFSHelper()
|
fs := cmd.NewFSHelper()
|
||||||
err := projectOptions.LoadConfig(fs.Cwd())
|
err := projectOptions.LoadConfig(fs.Cwd())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Unable to find 'project.json'. Please check you are in a Wails project directory")
|
return fmt.Errorf("unable to find 'project.json'. Please check you are in a Wails project directory")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set firebug flag
|
||||||
|
projectOptions.UseFirebug = usefirebug
|
||||||
|
|
||||||
// Check that this platform is supported
|
// Check that this platform is supported
|
||||||
if !projectOptions.PlatformSupported() {
|
if !projectOptions.PlatformSupported() {
|
||||||
logger.Yellow("WARNING: This project is unsupported on %s - it probably won't work!\n Valid platforms: %s\n", runtime.GOOS, strings.Join(projectOptions.Platforms, ", "))
|
logger.Yellow("WARNING: This project is unsupported on %s - it probably won't work!\n Valid platforms: %s\n", runtime.GOOS, strings.Join(projectOptions.Platforms, ", "))
|
||||||
@@ -140,12 +147,6 @@ func init() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure that runtime init.js is the production version
|
|
||||||
err = cmd.InstallProdRuntime(projectDir, projectOptions)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move to project directory
|
// Move to project directory
|
||||||
|
|||||||
@@ -27,19 +27,13 @@ func init() {
|
|||||||
logger.PrintSmallBanner(message)
|
logger.PrintSmallBanner(message)
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
|
|
||||||
// Check Mewn is installed
|
|
||||||
err := cmd.CheckMewn(verbose)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Project options
|
// Project options
|
||||||
projectOptions := &cmd.ProjectOptions{}
|
projectOptions := &cmd.ProjectOptions{}
|
||||||
|
|
||||||
// Check we are in project directory
|
// Check we are in project directory
|
||||||
// Check project.json loads correctly
|
// Check project.json loads correctly
|
||||||
fs := cmd.NewFSHelper()
|
fs := cmd.NewFSHelper()
|
||||||
err = projectOptions.LoadConfig(fs.Cwd())
|
err := projectOptions.LoadConfig(fs.Cwd())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
123
config.go
123
config.go
@@ -1,20 +1,49 @@
|
|||||||
package wails
|
package wails
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/leaanthony/mewn"
|
"net/url"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/wailsapp/wails/runtime"
|
"github.com/wailsapp/wails/runtime"
|
||||||
)
|
)
|
||||||
|
|
||||||
// AppConfig is the configuration structure used when creating a Wails App object
|
// AppConfig is the configuration structure used when creating a Wails App object
|
||||||
type AppConfig struct {
|
type AppConfig struct {
|
||||||
Width, Height int
|
// The width and height of your application in pixels
|
||||||
Title string
|
Width, Height int
|
||||||
defaultHTML string
|
|
||||||
HTML string
|
// The title to put in the title bar
|
||||||
JS string
|
Title string
|
||||||
CSS string
|
|
||||||
Colour string
|
// The HTML your app should use. If you leave it blank, a default will be used:
|
||||||
Resizable bool
|
// <!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta http-equiv="IE=edge" content="IE=edge"></head><body><div id="app"></div><script type="text/javascript"></script></body></html>
|
||||||
|
HTML string
|
||||||
|
|
||||||
|
// The Javascript your app should use. Normally this should be generated by a bundler.
|
||||||
|
JS string
|
||||||
|
|
||||||
|
// The CSS your app should use. Normally this should be generated by a bundler.
|
||||||
|
CSS string
|
||||||
|
|
||||||
|
// The colour of your window. Can take "#fff", "rgb(255,255,255)", "rgba(255,255,255,1)" formats
|
||||||
|
Colour string
|
||||||
|
|
||||||
|
// Indicates whether your app should be resizable
|
||||||
|
Resizable bool
|
||||||
|
|
||||||
|
// Minimum width of a resizable window. If set, MinHeight should also be set.
|
||||||
|
MinWidth int
|
||||||
|
|
||||||
|
// Minimum height of a resizable window. If set, MinWidth should also be set.
|
||||||
|
MinHeight int
|
||||||
|
|
||||||
|
// Maximum width of a resizable window. If set, MaxHeight should also be set.
|
||||||
|
MaxWidth int
|
||||||
|
|
||||||
|
// Maximum height of a resizable window. If set, MaxWidth should also be set.
|
||||||
|
MaxHeight int
|
||||||
|
|
||||||
|
// Indicated if the devtools should be disabled
|
||||||
DisableInspector bool
|
DisableInspector bool
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -33,9 +62,14 @@ func (a *AppConfig) GetTitle() string {
|
|||||||
return a.Title
|
return a.Title
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetDefaultHTML returns the default HTML
|
// GetHTML returns the default HTML
|
||||||
func (a *AppConfig) GetDefaultHTML() string {
|
func (a *AppConfig) GetHTML() string {
|
||||||
return a.defaultHTML
|
if len(a.HTML) > 0 {
|
||||||
|
a.HTML = url.QueryEscape(a.HTML)
|
||||||
|
a.HTML = "data:text/html," + strings.ReplaceAll(a.HTML, "+", "%20")
|
||||||
|
a.HTML = strings.ReplaceAll(a.HTML, "%3D", "=")
|
||||||
|
}
|
||||||
|
return a.HTML
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetResizable returns true if the window should be resizable
|
// GetResizable returns true if the window should be resizable
|
||||||
@@ -43,6 +77,26 @@ func (a *AppConfig) GetResizable() bool {
|
|||||||
return a.Resizable
|
return a.Resizable
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetMinWidth returns the minimum width of the window
|
||||||
|
func (a *AppConfig) GetMinWidth() int {
|
||||||
|
return a.MinWidth
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetMinHeight returns the minimum height of the window
|
||||||
|
func (a *AppConfig) GetMinHeight() int {
|
||||||
|
return a.MinHeight
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetMaxWidth returns the maximum width of the window
|
||||||
|
func (a *AppConfig) GetMaxWidth() int {
|
||||||
|
return a.MaxWidth
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetMaxHeight returns the maximum height of the window
|
||||||
|
func (a *AppConfig) GetMaxHeight() int {
|
||||||
|
return a.MaxHeight
|
||||||
|
}
|
||||||
|
|
||||||
// GetDisableInspector returns true if the inspector should be disabled
|
// GetDisableInspector returns true if the inspector should be disabled
|
||||||
func (a *AppConfig) GetDisableInspector() bool {
|
func (a *AppConfig) GetDisableInspector() bool {
|
||||||
return a.DisableInspector
|
return a.DisableInspector
|
||||||
@@ -75,16 +129,41 @@ func (a *AppConfig) merge(in *AppConfig) error {
|
|||||||
a.Colour = in.Colour
|
a.Colour = in.Colour
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if in.HTML != "" {
|
||||||
|
a.HTML = in.HTML
|
||||||
|
}
|
||||||
|
|
||||||
if in.JS != "" {
|
if in.JS != "" {
|
||||||
a.JS = in.JS
|
a.JS = in.JS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if in.HTML != "" {
|
||||||
|
a.HTML = in.HTML
|
||||||
|
}
|
||||||
|
|
||||||
if in.Width != 0 {
|
if in.Width != 0 {
|
||||||
a.Width = in.Width
|
a.Width = in.Width
|
||||||
}
|
}
|
||||||
if in.Height != 0 {
|
if in.Height != 0 {
|
||||||
a.Height = in.Height
|
a.Height = in.Height
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if in.MinWidth != 0 {
|
||||||
|
a.MinWidth = in.MinWidth
|
||||||
|
}
|
||||||
|
|
||||||
|
if in.MinHeight != 0 {
|
||||||
|
a.MinHeight = in.MinHeight
|
||||||
|
}
|
||||||
|
|
||||||
|
if in.MaxWidth != 0 {
|
||||||
|
a.MaxWidth = in.MaxWidth
|
||||||
|
}
|
||||||
|
|
||||||
|
if in.MaxHeight != 0 {
|
||||||
|
a.MaxHeight = in.MaxHeight
|
||||||
|
}
|
||||||
|
|
||||||
a.Resizable = in.Resizable
|
a.Resizable = in.Resizable
|
||||||
a.DisableInspector = in.DisableInspector
|
a.DisableInspector = in.DisableInspector
|
||||||
|
|
||||||
@@ -97,9 +176,13 @@ func newConfig(userConfig *AppConfig) (*AppConfig, error) {
|
|||||||
Width: 800,
|
Width: 800,
|
||||||
Height: 600,
|
Height: 600,
|
||||||
Resizable: true,
|
Resizable: true,
|
||||||
|
MinWidth: -1,
|
||||||
|
MinHeight: -1,
|
||||||
|
MaxWidth: -1,
|
||||||
|
MaxHeight: -1,
|
||||||
Title: "My Wails App",
|
Title: "My Wails App",
|
||||||
Colour: "#FFF", // White by default
|
Colour: "#FFF", // White by default
|
||||||
HTML: mewn.String("./runtime/assets/default.html"),
|
HTML: defaultHTML,
|
||||||
}
|
}
|
||||||
|
|
||||||
if userConfig != nil {
|
if userConfig != nil {
|
||||||
@@ -111,3 +194,17 @@ func newConfig(userConfig *AppConfig) (*AppConfig, error) {
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var defaultHTML = `<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div id="app"></div>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>`
|
||||||
|
|||||||
3
go.mod
3
go.mod
@@ -9,7 +9,6 @@ require (
|
|||||||
github.com/jackmordaunt/icns v1.0.0
|
github.com/jackmordaunt/icns v1.0.0
|
||||||
github.com/kennygrant/sanitize v1.2.4
|
github.com/kennygrant/sanitize v1.2.4
|
||||||
github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect
|
github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect
|
||||||
github.com/leaanthony/mewn v0.10.7
|
|
||||||
github.com/leaanthony/slicer v1.4.0
|
github.com/leaanthony/slicer v1.4.0
|
||||||
github.com/leaanthony/spinner v0.5.3
|
github.com/leaanthony/spinner v0.5.3
|
||||||
github.com/mattn/go-colorable v0.1.1 // indirect
|
github.com/mattn/go-colorable v0.1.1 // indirect
|
||||||
@@ -28,4 +27,4 @@ require (
|
|||||||
gopkg.in/yaml.v3 v3.0.0-20190709130402-674ba3eaed22
|
gopkg.in/yaml.v3 v3.0.0-20190709130402-674ba3eaed22
|
||||||
)
|
)
|
||||||
|
|
||||||
go 1.13
|
go 1.16
|
||||||
|
|||||||
3
go.sum
3
go.sum
@@ -26,8 +26,6 @@ github.com/konsorten/go-windows-terminal-sequences v1.0.2 h1:DB17ag19krx9CFsz4o3
|
|||||||
github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||||
github.com/kr/pty v1.1.1 h1:VkoXIwSboBpnk99O/KFauAEILuNHv5DVFKZMBN/gUgw=
|
github.com/kr/pty v1.1.1 h1:VkoXIwSboBpnk99O/KFauAEILuNHv5DVFKZMBN/gUgw=
|
||||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||||
github.com/leaanthony/mewn v0.10.7 h1:jCcNJyIUOpwj+I5SuATvCugDjHkoo+j6ubEOxxrxmPA=
|
|
||||||
github.com/leaanthony/mewn v0.10.7/go.mod h1:CRkTx8unLiSSilu/Sd7i1LwrdaAL+3eQ3ses99qGMEQ=
|
|
||||||
github.com/leaanthony/slicer v1.4.0 h1:Q9u4w+UBU4WHjXnEDdz+eRLMKF/rnyosRBiqULnc1J8=
|
github.com/leaanthony/slicer v1.4.0 h1:Q9u4w+UBU4WHjXnEDdz+eRLMKF/rnyosRBiqULnc1J8=
|
||||||
github.com/leaanthony/slicer v1.4.0/go.mod h1:FwrApmf8gOrpzEWM2J/9Lh79tyq8KTX5AzRtwV7m4AY=
|
github.com/leaanthony/slicer v1.4.0/go.mod h1:FwrApmf8gOrpzEWM2J/9Lh79tyq8KTX5AzRtwV7m4AY=
|
||||||
github.com/leaanthony/spinner v0.5.3 h1:IMTvgdQCec5QA4qRy0wil4XsRP+QcG1OwLWVK/LPZ5Y=
|
github.com/leaanthony/spinner v0.5.3 h1:IMTvgdQCec5QA4qRy0wil4XsRP+QcG1OwLWVK/LPZ5Y=
|
||||||
@@ -66,7 +64,6 @@ github.com/syossan27/tebata v0.0.0-20180602121909-b283fe4bc5ba h1:2DHfQOxcpWdGf5
|
|||||||
github.com/syossan27/tebata v0.0.0-20180602121909-b283fe4bc5ba/go.mod h1:iLnlXG2Pakcii2CU0cbY07DRCSvpWNa7nFxtevhOChk=
|
github.com/syossan27/tebata v0.0.0-20180602121909-b283fe4bc5ba/go.mod h1:iLnlXG2Pakcii2CU0cbY07DRCSvpWNa7nFxtevhOChk=
|
||||||
golang.org/x/crypto v0.0.0-20190123085648-057139ce5d2b/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
golang.org/x/crypto v0.0.0-20190123085648-057139ce5d2b/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnkZWQJsqcURM6tKiBApRjXI=
|
|
||||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||||
golang.org/x/image v0.0.0-20200430140353-33d19683fad8 h1:6WW6V3x1P/jokJBpRQYUJnMHRP6isStQwCozxnU7XQw=
|
golang.org/x/image v0.0.0-20200430140353-33d19683fad8 h1:6WW6V3x1P/jokJBpRQYUJnMHRP6isStQwCozxnU7XQw=
|
||||||
golang.org/x/image v0.0.0-20200430140353-33d19683fad8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
golang.org/x/image v0.0.0-20200430140353-33d19683fad8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ type Manager struct {
|
|||||||
log *logger.CustomLogger
|
log *logger.CustomLogger
|
||||||
renderer interfaces.Renderer // Messages will be dispatched to the frontend
|
renderer interfaces.Renderer // Messages will be dispatched to the frontend
|
||||||
wg sync.WaitGroup
|
wg sync.WaitGroup
|
||||||
|
mu sync.Mutex
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewManager creates a new event manager with a 100 event buffer
|
// NewManager creates a new event manager with a 100 event buffer
|
||||||
@@ -42,12 +43,12 @@ func (e *Manager) PushEvent(eventData *messages.EventData) {
|
|||||||
// means it does not expire (default).
|
// means it does not expire (default).
|
||||||
type eventListener struct {
|
type eventListener struct {
|
||||||
callback func(...interface{}) // Function to call with emitted event data
|
callback func(...interface{}) // Function to call with emitted event data
|
||||||
counter int // Expire after counter callbacks. 0 = infinite
|
counter uint // Expire after counter callbacks. 0 = infinite
|
||||||
expired bool // Indicates if the listener has expired
|
expired bool // Indicates if the listener has expired
|
||||||
}
|
}
|
||||||
|
|
||||||
// Creates a new event listener from the given callback function
|
// Creates a new event listener from the given callback function
|
||||||
func (e *Manager) addEventListener(eventName string, callback func(...interface{}), counter int) error {
|
func (e *Manager) addEventListener(eventName string, callback func(...interface{}), counter uint) error {
|
||||||
|
|
||||||
// Sanity check inputs
|
// Sanity check inputs
|
||||||
if callback == nil {
|
if callback == nil {
|
||||||
@@ -75,7 +76,30 @@ func (e *Manager) addEventListener(eventName string, callback func(...interface{
|
|||||||
// On adds a listener for the given event
|
// On adds a listener for the given event
|
||||||
func (e *Manager) On(eventName string, callback func(...interface{})) {
|
func (e *Manager) On(eventName string, callback func(...interface{})) {
|
||||||
// Add a persistent eventListener (counter = 0)
|
// Add a persistent eventListener (counter = 0)
|
||||||
e.addEventListener(eventName, callback, 0)
|
err := e.addEventListener(eventName, callback, 0)
|
||||||
|
if err != nil {
|
||||||
|
e.log.Error(err.Error())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Once adds a listener for the given event that will auto remove
|
||||||
|
// after one callback
|
||||||
|
func (e *Manager) Once(eventName string, callback func(...interface{})) {
|
||||||
|
// Add a persistent eventListener (counter = 0)
|
||||||
|
err := e.addEventListener(eventName, callback, 1)
|
||||||
|
if err != nil {
|
||||||
|
e.log.Error(err.Error())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// OnMultiple adds a listener for the given event that will trigger
|
||||||
|
// at most <counter> times.
|
||||||
|
func (e *Manager) OnMultiple(eventName string, callback func(...interface{}), counter uint) {
|
||||||
|
// Add a persistent eventListener (counter = 0)
|
||||||
|
err := e.addEventListener(eventName, callback, counter)
|
||||||
|
if err != nil {
|
||||||
|
e.log.Error(err.Error())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Emit broadcasts the given event to the subscribed listeners
|
// Emit broadcasts the given event to the subscribed listeners
|
||||||
@@ -108,20 +132,24 @@ func (e *Manager) Start(renderer interfaces.Renderer) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
// Notify renderer
|
// Notify renderer
|
||||||
e.renderer.NotifyEvent(event)
|
err := e.renderer.NotifyEvent(event)
|
||||||
|
if err != nil {
|
||||||
|
e.log.Error(err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
// Notify Go listeners
|
e.mu.Lock()
|
||||||
var listenersToRemove []*eventListener
|
|
||||||
|
|
||||||
// Iterate listeners
|
// Iterate listeners
|
||||||
for _, listener := range e.listeners[event.Name] {
|
for _, listener := range e.listeners[event.Name] {
|
||||||
|
|
||||||
// Call listener, perhaps with data
|
if !listener.expired {
|
||||||
if event.Data == nil {
|
// Call listener, perhaps with data
|
||||||
go listener.callback()
|
if event.Data == nil {
|
||||||
} else {
|
go listener.callback()
|
||||||
unpacked := event.Data.([]interface{})
|
} else {
|
||||||
go listener.callback(unpacked...)
|
unpacked := event.Data.([]interface{})
|
||||||
|
go listener.callback(unpacked...)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update listen counter
|
// Update listen counter
|
||||||
@@ -133,15 +161,8 @@ func (e *Manager) Start(renderer interfaces.Renderer) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove expired listeners in place
|
e.mu.Unlock()
|
||||||
if len(listenersToRemove) > 0 {
|
|
||||||
listeners := e.listeners[event.Name][:0]
|
|
||||||
for _, listener := range listeners {
|
|
||||||
if !listener.expired {
|
|
||||||
listeners = append(listeners, listener)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case <-e.quitChannel:
|
case <-e.quitChannel:
|
||||||
e.running = false
|
e.running = false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,10 +5,14 @@ type AppConfig interface {
|
|||||||
GetWidth() int
|
GetWidth() int
|
||||||
GetHeight() int
|
GetHeight() int
|
||||||
GetTitle() string
|
GetTitle() string
|
||||||
|
GetMinWidth() int
|
||||||
|
GetMinHeight() int
|
||||||
|
GetMaxWidth() int
|
||||||
|
GetMaxHeight() int
|
||||||
GetResizable() bool
|
GetResizable() bool
|
||||||
GetDefaultHTML() string
|
GetHTML() string
|
||||||
GetDisableInspector() bool
|
GetDisableInspector() bool
|
||||||
GetColour() string
|
GetColour() string
|
||||||
GetCSS() string
|
GetCSS() string
|
||||||
GetJS() string
|
GetJS() string
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ import "github.com/wailsapp/wails/lib/messages"
|
|||||||
type EventManager interface {
|
type EventManager interface {
|
||||||
PushEvent(*messages.EventData)
|
PushEvent(*messages.EventData)
|
||||||
Emit(eventName string, optionalData ...interface{})
|
Emit(eventName string, optionalData ...interface{})
|
||||||
|
OnMultiple(eventName string, callback func(...interface{}), counter uint)
|
||||||
|
Once(eventName string, callback func(...interface{}))
|
||||||
On(eventName string, callback func(...interface{}))
|
On(eventName string, callback func(...interface{}))
|
||||||
Start(Renderer)
|
Start(Renderer)
|
||||||
Shutdown()
|
Shutdown()
|
||||||
|
|||||||
@@ -22,6 +22,10 @@ type Renderer interface {
|
|||||||
|
|
||||||
// Window Runtime
|
// Window Runtime
|
||||||
SetColour(string) error
|
SetColour(string) error
|
||||||
|
|
||||||
|
SetMinSize(width, height int)
|
||||||
|
SetMaxSize(width, height int)
|
||||||
|
|
||||||
Fullscreen()
|
Fullscreen()
|
||||||
UnFullscreen()
|
UnFullscreen()
|
||||||
SetTitle(title string)
|
SetTitle(title string)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package interfaces
|
package interfaces
|
||||||
|
|
||||||
// Runtime interface
|
// Runtime interface
|
||||||
type Runtime interface {}
|
type Runtime interface{}
|
||||||
|
|||||||
@@ -186,6 +186,18 @@ func (h *Bridge) SetColour(colour string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetMinSize is unsupported for Bridge but required
|
||||||
|
// for the Renderer interface
|
||||||
|
func (h *Bridge) SetMinSize(width, height int) {
|
||||||
|
h.log.Warn("SetMinSize() unsupported in bridge mode")
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetMaxSize is unsupported for Bridge but required
|
||||||
|
// for the Renderer interface
|
||||||
|
func (h *Bridge) SetMaxSize(width, height int) {
|
||||||
|
h.log.Warn("SetMaxSize() unsupported in bridge mode")
|
||||||
|
}
|
||||||
|
|
||||||
// Fullscreen is unsupported for Bridge but required
|
// Fullscreen is unsupported for Bridge but required
|
||||||
// for the Renderer interface
|
// for the Renderer interface
|
||||||
func (h *Bridge) Fullscreen() {
|
func (h *Bridge) Fullscreen() {
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -3,8 +3,9 @@ package renderer
|
|||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/wailsapp/wails/runtime"
|
||||||
|
|
||||||
"github.com/gorilla/websocket"
|
"github.com/gorilla/websocket"
|
||||||
"github.com/leaanthony/mewn"
|
|
||||||
"github.com/wailsapp/wails/lib/interfaces"
|
"github.com/wailsapp/wails/lib/interfaces"
|
||||||
"github.com/wailsapp/wails/lib/logger"
|
"github.com/wailsapp/wails/lib/logger"
|
||||||
)
|
)
|
||||||
@@ -58,8 +59,7 @@ func (s *session) start(firstSession bool) {
|
|||||||
s.log.Infof("Connected to frontend.")
|
s.log.Infof("Connected to frontend.")
|
||||||
go s.writePump()
|
go s.writePump()
|
||||||
|
|
||||||
wailsRuntime := mewn.String("../../runtime/assets/wails.js")
|
s.evalJS(runtime.WailsJS, wailsRuntimeMessage)
|
||||||
s.evalJS(wailsRuntime, wailsRuntimeMessage)
|
|
||||||
|
|
||||||
// Inject bindings
|
// Inject bindings
|
||||||
for _, binding := range s.bindingCache {
|
for _, binding := range s.bindingCache {
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -8,8 +8,9 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/wailsapp/wails/runtime"
|
||||||
|
|
||||||
"github.com/go-playground/colors"
|
"github.com/go-playground/colors"
|
||||||
"github.com/leaanthony/mewn"
|
|
||||||
"github.com/wailsapp/wails/lib/interfaces"
|
"github.com/wailsapp/wails/lib/interfaces"
|
||||||
"github.com/wailsapp/wails/lib/logger"
|
"github.com/wailsapp/wails/lib/logger"
|
||||||
"github.com/wailsapp/wails/lib/messages"
|
"github.com/wailsapp/wails/lib/messages"
|
||||||
@@ -29,6 +30,7 @@ type WebView struct {
|
|||||||
config interfaces.AppConfig
|
config interfaces.AppConfig
|
||||||
eventManager interfaces.EventManager
|
eventManager interfaces.EventManager
|
||||||
bindingCache []string
|
bindingCache []string
|
||||||
|
maximumSizeSet bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewWebView returns a new WebView struct
|
// NewWebView returns a new WebView struct
|
||||||
@@ -52,18 +54,63 @@ func (w *WebView) Initialise(config interfaces.AppConfig, ipc interfaces.IPCMana
|
|||||||
// Save the config
|
// Save the config
|
||||||
w.config = config
|
w.config = config
|
||||||
|
|
||||||
|
width := config.GetWidth()
|
||||||
|
height := config.GetHeight()
|
||||||
|
|
||||||
|
// Clamp width and height
|
||||||
|
minWidth, minHeight := config.GetMinWidth(), config.GetMinHeight()
|
||||||
|
maxWidth, maxHeight := config.GetMaxWidth(), config.GetMaxHeight()
|
||||||
|
setMinSize := minWidth != -1 && minHeight != -1
|
||||||
|
setMaxSize := maxWidth != -1 && maxHeight != -1
|
||||||
|
|
||||||
|
if setMinSize {
|
||||||
|
if width < minWidth {
|
||||||
|
width = minWidth
|
||||||
|
}
|
||||||
|
if height < minHeight {
|
||||||
|
height = minHeight
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if setMaxSize {
|
||||||
|
if width > maxWidth {
|
||||||
|
width = maxWidth
|
||||||
|
}
|
||||||
|
if height > maxHeight {
|
||||||
|
height = maxHeight
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Create the WebView instance
|
// Create the WebView instance
|
||||||
w.window = wv.NewWebview(wv.Settings{
|
w.window = wv.NewWebview(wv.Settings{
|
||||||
Width: config.GetWidth(),
|
Width: width,
|
||||||
Height: config.GetHeight(),
|
Height: height,
|
||||||
Title: config.GetTitle(),
|
Title: config.GetTitle(),
|
||||||
Resizable: config.GetResizable(),
|
Resizable: config.GetResizable(),
|
||||||
URL: config.GetDefaultHTML(),
|
URL: config.GetHTML(),
|
||||||
Debug: !config.GetDisableInspector(),
|
Debug: !config.GetDisableInspector(),
|
||||||
ExternalInvokeCallback: func(_ wv.WebView, message string) {
|
ExternalInvokeCallback: func(_ wv.WebView, message string) {
|
||||||
w.ipc.Dispatch(message, w.callback)
|
w.ipc.Dispatch(message, w.callback)
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
fmt.Println("Control")
|
||||||
|
|
||||||
|
// Set minimum and maximum sizes
|
||||||
|
if setMinSize {
|
||||||
|
w.SetMinSize(minWidth, minHeight)
|
||||||
|
}
|
||||||
|
if setMaxSize {
|
||||||
|
w.SetMaxSize(maxWidth, maxHeight)
|
||||||
|
fmt.Println("Max")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set minimum and maximum sizes
|
||||||
|
if setMinSize {
|
||||||
|
w.SetMinSize(minWidth, minHeight)
|
||||||
|
}
|
||||||
|
if setMaxSize {
|
||||||
|
w.SetMaxSize(maxWidth, maxHeight)
|
||||||
|
}
|
||||||
|
|
||||||
// SignalManager.OnExit(w.Exit)
|
// SignalManager.OnExit(w.Exit)
|
||||||
|
|
||||||
@@ -74,6 +121,7 @@ func (w *WebView) Initialise(config interfaces.AppConfig, ipc interfaces.IPCMana
|
|||||||
}
|
}
|
||||||
|
|
||||||
w.log.Info("Initialised")
|
w.log.Info("Initialised")
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -183,8 +231,8 @@ func (w *WebView) Run() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Runtime assets
|
// Runtime assets
|
||||||
wailsRuntime := mewn.String("../../runtime/assets/wails.js")
|
w.log.DebugFields("Injecting wails JS runtime", logger.Fields{"js": runtime.WailsJS})
|
||||||
w.evalJS(wailsRuntime)
|
w.evalJS(runtime.WailsJS)
|
||||||
|
|
||||||
// Ping the wait channel when the wails runtime is loaded
|
// Ping the wait channel when the wails runtime is loaded
|
||||||
w.eventManager.On("wails:loaded", func(...interface{}) {
|
w.eventManager.On("wails:loaded", func(...interface{}) {
|
||||||
@@ -207,10 +255,9 @@ func (w *WebView) Run() error {
|
|||||||
w.injectCSS(w.config.GetCSS())
|
w.injectCSS(w.config.GetCSS())
|
||||||
} else {
|
} else {
|
||||||
// Use default wails css
|
// Use default wails css
|
||||||
w.log.Debug("Injecting Default Wails CSS")
|
|
||||||
defaultCSS := mewn.String("../../runtime/assets/wails.css")
|
|
||||||
|
|
||||||
w.injectCSS(defaultCSS)
|
w.log.Debug("Injecting Default Wails CSS: " + runtime.WailsCSS)
|
||||||
|
w.injectCSS(runtime.WailsCSS)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Inject user JS
|
// Inject user JS
|
||||||
@@ -256,6 +303,9 @@ func (w *WebView) SelectFile(title string, filter string) string {
|
|||||||
wg.Done()
|
wg.Done()
|
||||||
})
|
})
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
defer w.focus() // Ensure the main window is put back into focus afterwards
|
||||||
|
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
@@ -274,6 +324,9 @@ func (w *WebView) SelectDirectory() string {
|
|||||||
wg.Done()
|
wg.Done()
|
||||||
})
|
})
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
defer w.focus() // Ensure the main window is put back into focus afterwards
|
||||||
|
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
@@ -292,10 +345,20 @@ func (w *WebView) SelectSaveFile(title string, filter string) string {
|
|||||||
wg.Done()
|
wg.Done()
|
||||||
})
|
})
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
defer w.focus() // Ensure the main window is put back into focus afterwards
|
||||||
|
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// focus puts the main window into focus
|
||||||
|
func (w *WebView) focus() {
|
||||||
|
w.window.Dispatch(func() {
|
||||||
|
w.window.Focus()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// callback sends a callback to the frontend
|
// callback sends a callback to the frontend
|
||||||
func (w *WebView) callback(data string) error {
|
func (w *WebView) callback(data string) error {
|
||||||
callbackCMD := fmt.Sprintf("window.wails._.Callback('%s');", data)
|
callbackCMD := fmt.Sprintf("window.wails._.Callback('%s');", data)
|
||||||
@@ -337,11 +400,37 @@ func (w *WebView) NotifyEvent(event *messages.EventData) error {
|
|||||||
return w.evalJS(message)
|
return w.evalJS(message)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetMinSize sets the minimum size of a resizable window
|
||||||
|
func (w *WebView) SetMinSize(width, height int) {
|
||||||
|
if w.config.GetResizable() == false {
|
||||||
|
w.log.Warn("Cannot call SetMinSize() - App.Resizable = false")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
w.window.Dispatch(func() {
|
||||||
|
w.window.SetMinSize(width, height)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetMaxSize sets the maximum size of a resizable window
|
||||||
|
func (w *WebView) SetMaxSize(width, height int) {
|
||||||
|
if w.config.GetResizable() == false {
|
||||||
|
w.log.Warn("Cannot call SetMaxSize() - App.Resizable = false")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
w.maximumSizeSet = true
|
||||||
|
w.window.Dispatch(func() {
|
||||||
|
w.window.SetMaxSize(width, height)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// Fullscreen makes the main window go fullscreen
|
// Fullscreen makes the main window go fullscreen
|
||||||
func (w *WebView) Fullscreen() {
|
func (w *WebView) Fullscreen() {
|
||||||
if w.config.GetResizable() == false {
|
if w.config.GetResizable() == false {
|
||||||
w.log.Warn("Cannot call Fullscreen() - App.Resizable = false")
|
w.log.Warn("Cannot call Fullscreen() - App.Resizable = false")
|
||||||
return
|
return
|
||||||
|
} else if w.maximumSizeSet {
|
||||||
|
w.log.Warn("Cannot call Fullscreen() - Maximum size of window set")
|
||||||
|
return
|
||||||
}
|
}
|
||||||
w.window.Dispatch(func() {
|
w.window.Dispatch(func() {
|
||||||
w.window.SetFullscreen(true)
|
w.window.SetFullscreen(true)
|
||||||
|
|||||||
@@ -65,6 +65,18 @@ static inline void CgoWebViewSetTitle(void *w, char *title) {
|
|||||||
webview_set_title((struct webview *)w, title);
|
webview_set_title((struct webview *)w, title);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void CgoWebViewFocus(void *w) {
|
||||||
|
webview_focus((struct webview *)w);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void CgoWebViewMinSize(void *w, int width, int height) {
|
||||||
|
webview_minsize((struct webview *)w, width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void CgoWebViewMaxSize(void *w, int width, int height) {
|
||||||
|
webview_maxsize((struct webview *)w, width, height);
|
||||||
|
}
|
||||||
|
|
||||||
static inline void CgoWebViewSetFullscreen(void *w, int fullscreen) {
|
static inline void CgoWebViewSetFullscreen(void *w, int fullscreen) {
|
||||||
webview_set_fullscreen((struct webview *)w, fullscreen);
|
webview_set_fullscreen((struct webview *)w, fullscreen);
|
||||||
}
|
}
|
||||||
@@ -170,6 +182,16 @@ type WebView interface {
|
|||||||
// SetTitle() changes window title. This method must be called from the main
|
// SetTitle() changes window title. This method must be called from the main
|
||||||
// thread only. See Dispatch() for more details.
|
// thread only. See Dispatch() for more details.
|
||||||
SetTitle(title string)
|
SetTitle(title string)
|
||||||
|
|
||||||
|
// Focus() puts the main window into focus
|
||||||
|
Focus()
|
||||||
|
|
||||||
|
// SetMinSize() sets the minimum size of the window
|
||||||
|
SetMinSize(width, height int)
|
||||||
|
|
||||||
|
// SetMaxSize() sets the maximum size of the window
|
||||||
|
SetMaxSize(width, height int)
|
||||||
|
|
||||||
// SetFullscreen() controls window full-screen mode. This method must be
|
// SetFullscreen() controls window full-screen mode. This method must be
|
||||||
// called from the main thread only. See Dispatch() for more details.
|
// called from the main thread only. See Dispatch() for more details.
|
||||||
SetFullscreen(fullscreen bool)
|
SetFullscreen(fullscreen bool)
|
||||||
@@ -307,6 +329,18 @@ func (w *webview) SetColor(r, g, b, a uint8) {
|
|||||||
C.CgoWebViewSetColor(w.w, C.uint8_t(r), C.uint8_t(g), C.uint8_t(b), C.uint8_t(a))
|
C.CgoWebViewSetColor(w.w, C.uint8_t(r), C.uint8_t(g), C.uint8_t(b), C.uint8_t(a))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (w *webview) Focus() {
|
||||||
|
C.CgoWebViewFocus(w.w)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w *webview) SetMinSize(width, height int) {
|
||||||
|
C.CgoWebViewMinSize(w.w, C.int(width), C.int(height))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w *webview) SetMaxSize(width, height int) {
|
||||||
|
C.CgoWebViewMaxSize(w.w, C.int(width), C.int(height))
|
||||||
|
}
|
||||||
|
|
||||||
func (w *webview) SetFullscreen(fullscreen bool) {
|
func (w *webview) SetFullscreen(fullscreen bool) {
|
||||||
C.CgoWebViewSetFullscreen(w.w, C.int(boolToInt(fullscreen)))
|
C.CgoWebViewSetFullscreen(w.w, C.int(boolToInt(fullscreen)))
|
||||||
}
|
}
|
||||||
@@ -353,7 +387,9 @@ func _webviewDispatchGoCallback(index unsafe.Pointer) {
|
|||||||
f = fns[uintptr(index)]
|
f = fns[uintptr(index)]
|
||||||
delete(fns, uintptr(index))
|
delete(fns, uintptr(index))
|
||||||
m.Unlock()
|
m.Unlock()
|
||||||
f()
|
if f != nil {
|
||||||
|
f()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//export _webviewExternalInvokeCallback
|
//export _webviewExternalInvokeCallback
|
||||||
@@ -369,5 +405,7 @@ func _webviewExternalInvokeCallback(w unsafe.Pointer, data unsafe.Pointer) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
m.Unlock()
|
m.Unlock()
|
||||||
cb(wv, C.GoString((*C.char)(data)))
|
if cb != nil {
|
||||||
|
cb(wv, C.GoString((*C.char)(data)))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,6 +54,11 @@ extern "C"
|
|||||||
int ready;
|
int ready;
|
||||||
int js_busy;
|
int js_busy;
|
||||||
int should_exit;
|
int should_exit;
|
||||||
|
|
||||||
|
int min_width;
|
||||||
|
int min_height;
|
||||||
|
int max_width;
|
||||||
|
int max_height;
|
||||||
};
|
};
|
||||||
#elif defined(WEBVIEW_WINAPI)
|
#elif defined(WEBVIEW_WINAPI)
|
||||||
#define CINTERFACE
|
#define CINTERFACE
|
||||||
@@ -75,6 +80,11 @@ struct webview_priv
|
|||||||
DWORD saved_style;
|
DWORD saved_style;
|
||||||
DWORD saved_ex_style;
|
DWORD saved_ex_style;
|
||||||
RECT saved_rect;
|
RECT saved_rect;
|
||||||
|
|
||||||
|
int min_width;
|
||||||
|
int min_height;
|
||||||
|
int max_width;
|
||||||
|
int max_height;
|
||||||
};
|
};
|
||||||
#elif defined(WEBVIEW_COCOA)
|
#elif defined(WEBVIEW_COCOA)
|
||||||
#import <Cocoa/Cocoa.h>
|
#import <Cocoa/Cocoa.h>
|
||||||
@@ -168,6 +178,9 @@ struct webview_priv
|
|||||||
WEBVIEW_API int webview_eval(struct webview *w, const char *js);
|
WEBVIEW_API int webview_eval(struct webview *w, const char *js);
|
||||||
WEBVIEW_API int webview_inject_css(struct webview *w, const char *css);
|
WEBVIEW_API int webview_inject_css(struct webview *w, const char *css);
|
||||||
WEBVIEW_API void webview_set_title(struct webview *w, const char *title);
|
WEBVIEW_API void webview_set_title(struct webview *w, const char *title);
|
||||||
|
WEBVIEW_API void webview_focus(struct webview *w);
|
||||||
|
WEBVIEW_API void webview_minsize(struct webview *w, int width, int height);
|
||||||
|
WEBVIEW_API void webview_maxsize(struct webview *w, int width, int height);
|
||||||
WEBVIEW_API void webview_set_fullscreen(struct webview *w, int fullscreen);
|
WEBVIEW_API void webview_set_fullscreen(struct webview *w, int fullscreen);
|
||||||
WEBVIEW_API void webview_set_color(struct webview *w, uint8_t r, uint8_t g,
|
WEBVIEW_API void webview_set_color(struct webview *w, uint8_t r, uint8_t g,
|
||||||
uint8_t b, uint8_t a);
|
uint8_t b, uint8_t a);
|
||||||
@@ -329,6 +342,12 @@ struct webview_priv
|
|||||||
w->priv.should_exit = 0;
|
w->priv.should_exit = 0;
|
||||||
w->priv.queue = g_async_queue_new();
|
w->priv.queue = g_async_queue_new();
|
||||||
w->priv.window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
w->priv.window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
||||||
|
|
||||||
|
w->priv.min_width = -1;
|
||||||
|
w->priv.min_height = -1;
|
||||||
|
w->priv.max_width = -1;
|
||||||
|
w->priv.max_height = -1;
|
||||||
|
|
||||||
gtk_window_set_title(GTK_WINDOW(w->priv.window), w->title);
|
gtk_window_set_title(GTK_WINDOW(w->priv.window), w->title);
|
||||||
|
|
||||||
if (w->resizable)
|
if (w->resizable)
|
||||||
@@ -364,6 +383,7 @@ struct webview_priv
|
|||||||
webkit_web_view_get_settings(WEBKIT_WEB_VIEW(w->priv.webview));
|
webkit_web_view_get_settings(WEBKIT_WEB_VIEW(w->priv.webview));
|
||||||
webkit_settings_set_enable_write_console_messages_to_stdout(settings, true);
|
webkit_settings_set_enable_write_console_messages_to_stdout(settings, true);
|
||||||
webkit_settings_set_enable_developer_extras(settings, true);
|
webkit_settings_set_enable_developer_extras(settings, true);
|
||||||
|
webkit_settings_set_hardware_acceleration_policy(settings, WEBKIT_HARDWARE_ACCELERATION_POLICY_ALWAYS);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -395,6 +415,49 @@ struct webview_priv
|
|||||||
gtk_window_set_title(GTK_WINDOW(w->priv.window), title);
|
gtk_window_set_title(GTK_WINDOW(w->priv.window), title);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WEBVIEW_API void webview_focus(struct webview *w)
|
||||||
|
{
|
||||||
|
gtk_window_present(GTK_WINDOW(w->priv.window));
|
||||||
|
}
|
||||||
|
|
||||||
|
WEBVIEW_API void webview_minsize(struct webview *w, int width, int height) {
|
||||||
|
|
||||||
|
w->priv.min_width = width;
|
||||||
|
w->priv.min_height = height;
|
||||||
|
|
||||||
|
GdkGeometry hints;
|
||||||
|
GdkWindowHints usedHints = (GdkWindowHints) GDK_HINT_MIN_SIZE;
|
||||||
|
|
||||||
|
hints.min_width = w->priv.min_width;
|
||||||
|
hints.min_height = w->priv.min_height;
|
||||||
|
if (w->priv.max_width != -1) {
|
||||||
|
hints.max_width = w->priv.max_width;
|
||||||
|
hints.max_height = w->priv.max_height;
|
||||||
|
usedHints = (GdkWindowHints)(GDK_HINT_MIN_SIZE | GDK_HINT_MAX_SIZE);
|
||||||
|
}
|
||||||
|
|
||||||
|
gtk_window_set_geometry_hints(GTK_WINDOW(w->priv.window), w->priv.window, &hints, usedHints);
|
||||||
|
}
|
||||||
|
|
||||||
|
WEBVIEW_API void webview_maxsize(struct webview *w, int width, int height) {
|
||||||
|
|
||||||
|
w->priv.max_width = width;
|
||||||
|
w->priv.max_height = height;
|
||||||
|
|
||||||
|
GdkGeometry hints;
|
||||||
|
GdkWindowHints usedHints = (GdkWindowHints) GDK_HINT_MAX_SIZE;
|
||||||
|
|
||||||
|
if (w->priv.min_width != -1) {
|
||||||
|
hints.min_width = w->priv.min_width;
|
||||||
|
hints.min_height = w->priv.min_height;
|
||||||
|
usedHints = (GdkWindowHints)(GDK_HINT_MIN_SIZE | GDK_HINT_MAX_SIZE);
|
||||||
|
}
|
||||||
|
hints.max_width = w->priv.max_width;
|
||||||
|
hints.max_height = w->priv.max_height;
|
||||||
|
|
||||||
|
gtk_window_set_geometry_hints(GTK_WINDOW(w->priv.window), w->priv.window, &hints, usedHints);
|
||||||
|
}
|
||||||
|
|
||||||
WEBVIEW_API void webview_set_fullscreen(struct webview *w, int fullscreen)
|
WEBVIEW_API void webview_set_fullscreen(struct webview *w, int fullscreen)
|
||||||
{
|
{
|
||||||
if (fullscreen)
|
if (fullscreen)
|
||||||
@@ -1330,7 +1393,39 @@ struct webview_priv
|
|||||||
case WM_CREATE:
|
case WM_CREATE:
|
||||||
w = (struct webview *)((CREATESTRUCT *)lParam)->lpCreateParams;
|
w = (struct webview *)((CREATESTRUCT *)lParam)->lpCreateParams;
|
||||||
w->priv.hwnd = hwnd;
|
w->priv.hwnd = hwnd;
|
||||||
|
|
||||||
return EmbedBrowserObject(w);
|
return EmbedBrowserObject(w);
|
||||||
|
case WM_GETMINMAXINFO:
|
||||||
|
{
|
||||||
|
if (w != NULL) {
|
||||||
|
// get pixel density
|
||||||
|
HDC hDC = GetDC(NULL);
|
||||||
|
double DPIScaleX = GetDeviceCaps(hDC, 88)/96.0;
|
||||||
|
double DPIScaleY = GetDeviceCaps(hDC, 90)/96.0;
|
||||||
|
ReleaseDC(NULL, hDC);
|
||||||
|
|
||||||
|
RECT rcClient, rcWind;
|
||||||
|
POINT ptDiff;
|
||||||
|
GetClientRect(hwnd, &rcClient);
|
||||||
|
GetWindowRect(hwnd, &rcWind);
|
||||||
|
|
||||||
|
int widthExtra = (rcWind.right - rcWind.left) - rcClient.right;
|
||||||
|
int heightExtra = (rcWind.bottom - rcWind.top) - rcClient.bottom;
|
||||||
|
|
||||||
|
LPMINMAXINFO lpMMI = (LPMINMAXINFO)lParam;
|
||||||
|
|
||||||
|
if (w->priv.min_width != -1) {
|
||||||
|
lpMMI->ptMinTrackSize.x = w->priv.min_width * DPIScaleX + widthExtra;
|
||||||
|
lpMMI->ptMinTrackSize.y = w->priv.min_height * DPIScaleY + heightExtra;
|
||||||
|
}
|
||||||
|
if (w->priv.max_width != -1) {
|
||||||
|
lpMMI->ptMaxTrackSize.x = w->priv.max_width * DPIScaleX + widthExtra;
|
||||||
|
lpMMI->ptMaxTrackSize.y = w->priv.max_height * DPIScaleY + heightExtra;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
case WM_DESTROY:
|
case WM_DESTROY:
|
||||||
UnEmbedBrowserObject(w);
|
UnEmbedBrowserObject(w);
|
||||||
PostQuitMessage(0);
|
PostQuitMessage(0);
|
||||||
@@ -1395,6 +1490,9 @@ struct webview_priv
|
|||||||
|
|
||||||
WEBVIEW_API int webview_init(struct webview *w)
|
WEBVIEW_API int webview_init(struct webview *w)
|
||||||
{
|
{
|
||||||
|
w->priv.min_width = -1;
|
||||||
|
w->priv.max_width = -1;
|
||||||
|
|
||||||
WNDCLASSEX wc;
|
WNDCLASSEX wc;
|
||||||
HINSTANCE hInstance;
|
HINSTANCE hInstance;
|
||||||
DWORD style;
|
DWORD style;
|
||||||
@@ -1640,6 +1738,21 @@ struct webview_priv
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WEBVIEW_API void webview_focus(struct webview *w)
|
||||||
|
{
|
||||||
|
SetFocus(w->priv.hwnd);
|
||||||
|
}
|
||||||
|
|
||||||
|
WEBVIEW_API void webview_minsize(struct webview *w, int width, int height) {
|
||||||
|
w->priv.min_width = width;
|
||||||
|
w->priv.min_height = height;
|
||||||
|
}
|
||||||
|
|
||||||
|
WEBVIEW_API void webview_maxsize(struct webview *w, int width, int height) {
|
||||||
|
w->priv.max_width = width;
|
||||||
|
w->priv.max_height = height;
|
||||||
|
}
|
||||||
|
|
||||||
WEBVIEW_API void webview_set_fullscreen(struct webview *w, int fullscreen)
|
WEBVIEW_API void webview_set_fullscreen(struct webview *w, int fullscreen)
|
||||||
{
|
{
|
||||||
if (w->priv.is_fullscreen == !!fullscreen)
|
if (w->priv.is_fullscreen == !!fullscreen)
|
||||||
@@ -2207,6 +2320,30 @@ struct webview_priv
|
|||||||
[w->priv.window setTitle:nsTitle];
|
[w->priv.window setTitle:nsTitle];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WEBVIEW_API void webview_focus(struct webview *w)
|
||||||
|
{
|
||||||
|
[w->priv.window makeKeyWindow];
|
||||||
|
}
|
||||||
|
|
||||||
|
WEBVIEW_API void webview_minsize(struct webview *w, int width, int height) {
|
||||||
|
NSSize size;
|
||||||
|
size.width = width;
|
||||||
|
size.height = height;
|
||||||
|
[w->priv.window setMinSize:size];
|
||||||
|
}
|
||||||
|
|
||||||
|
WEBVIEW_API void webview_maxsize(struct webview *w, int width, int height) {
|
||||||
|
NSSize size;
|
||||||
|
size.width = width;
|
||||||
|
size.height = height;
|
||||||
|
[w->priv.window setMaxSize:size];
|
||||||
|
|
||||||
|
[w->priv.window setCollectionBehavior:NSWindowCollectionBehaviorFullScreenAuxiliary|NSWindowCollectionBehaviorFullScreenNone|NSWindowCollectionBehaviorFullScreenDisallowsTiling];
|
||||||
|
|
||||||
|
NSButton *button = [w->priv.window standardWindowButton:NSWindowZoomButton];
|
||||||
|
[button setEnabled: NO];
|
||||||
|
}
|
||||||
|
|
||||||
WEBVIEW_API void webview_set_fullscreen(struct webview *w, int fullscreen)
|
WEBVIEW_API void webview_set_fullscreen(struct webview *w, int fullscreen)
|
||||||
{
|
{
|
||||||
int b = ((([w->priv.window styleMask] & NSWindowStyleMaskFullScreen) ==
|
int b = ((([w->priv.window styleMask] & NSWindowStyleMaskFullScreen) ==
|
||||||
@@ -2361,4 +2498,4 @@ struct webview_priv
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* WEBVIEW_H */
|
#endif /* WEBVIEW_H */
|
||||||
3
package-lock.json
generated
Normal file
3
package-lock.json
generated
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"lockfileVersion": 1
|
||||||
|
}
|
||||||
15
runtime/assets.go
Normal file
15
runtime/assets.go
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
package runtime
|
||||||
|
|
||||||
|
import _ "embed"
|
||||||
|
|
||||||
|
//go:embed assets/bridge.js
|
||||||
|
var BridgeJS []byte
|
||||||
|
|
||||||
|
//go:embed assets/wails.js
|
||||||
|
var WailsJS string
|
||||||
|
|
||||||
|
//go:embed assets/wails.css
|
||||||
|
var WailsCSS string
|
||||||
|
|
||||||
|
//go:embed js/runtime/init.js
|
||||||
|
var InitJS []byte
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
<div id="app"></div>
|
|
||||||
<script type="text/javascript">function AddScript(js, callbackID) {
|
|
||||||
var script = document.createElement('script');
|
|
||||||
script.text = js;
|
|
||||||
document.body.appendChild(script);
|
|
||||||
}</script>
|
|
||||||
</body>
|
|
||||||
|
|
||||||
</html>
|
|
||||||
@@ -19,6 +19,16 @@ func (r *Events) On(eventName string, callback func(optionalData ...interface{})
|
|||||||
r.eventManager.On(eventName, callback)
|
r.eventManager.On(eventName, callback)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Once pass through
|
||||||
|
func (r *Events) Once(eventName string, callback func(optionalData ...interface{})) {
|
||||||
|
r.eventManager.Once(eventName, callback)
|
||||||
|
}
|
||||||
|
|
||||||
|
// OnMultiple pass through
|
||||||
|
func (r *Events) OnMultiple(eventName string, callback func(optionalData ...interface{}), counter uint) {
|
||||||
|
r.eventManager.OnMultiple(eventName, callback, counter)
|
||||||
|
}
|
||||||
|
|
||||||
// Emit pass through
|
// Emit pass through
|
||||||
func (r *Events) Emit(eventName string, optionalData ...interface{}) {
|
func (r *Events) Emit(eventName string, optionalData ...interface{}) {
|
||||||
r.eventManager.Emit(eventName, optionalData...)
|
r.eventManager.Emit(eventName, optionalData...)
|
||||||
|
|||||||
38
runtime/js/package-lock.json
generated
38
runtime/js/package-lock.json
generated
@@ -2681,26 +2681,18 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"elliptic": {
|
"elliptic": {
|
||||||
"version": "6.5.3",
|
"version": "6.5.4",
|
||||||
"resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.3.tgz",
|
"resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz",
|
||||||
"integrity": "sha512-IMqzv5wNQf+E6aHeIqATs0tOLeOTwj1QKbRcS3jBbYkl5oLAserA8yJTT7/VyHUYG91PRmPyeQDObKLPpeS4dw==",
|
"integrity": "sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"bn.js": "^4.4.0",
|
"bn.js": "^4.11.9",
|
||||||
"brorand": "^1.0.1",
|
"brorand": "^1.1.0",
|
||||||
"hash.js": "^1.0.0",
|
"hash.js": "^1.0.0",
|
||||||
"hmac-drbg": "^1.0.0",
|
"hmac-drbg": "^1.0.1",
|
||||||
"inherits": "^2.0.1",
|
"inherits": "^2.0.4",
|
||||||
"minimalistic-assert": "^1.0.0",
|
"minimalistic-assert": "^1.0.1",
|
||||||
"minimalistic-crypto-utils": "^1.0.0"
|
"minimalistic-crypto-utils": "^1.0.1"
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"bn.js": {
|
|
||||||
"version": "4.11.9",
|
|
||||||
"resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.9.tgz",
|
|
||||||
"integrity": "sha512-E6QoYqCKZfgatHTdHzs1RRKP7ip4vvm+EyRUeE2RF0NblwVvb0p6jSVeNTOFxPn26QXN2o6SMfNxKp6kU8zQaw==",
|
|
||||||
"dev": true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"emoji-regex": {
|
"emoji-regex": {
|
||||||
@@ -3959,9 +3951,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"ini": {
|
"ini": {
|
||||||
"version": "1.3.5",
|
"version": "1.3.8",
|
||||||
"resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz",
|
"resolved": "https://registry.npmjs.org/ini/-/ini-1.3.8.tgz",
|
||||||
"integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==",
|
"integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"interpret": {
|
"interpret": {
|
||||||
@@ -6590,9 +6582,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"y18n": {
|
"y18n": {
|
||||||
"version": "4.0.0",
|
"version": "4.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.1.tgz",
|
||||||
"integrity": "sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w==",
|
"integrity": "sha512-wNcy4NvjMYL8gogWWYAO7ZFWFfHcbdbE57tZO8e4cbpj8tfUcwrwqSl3ad8HxpYWCdXcJUCeKKZS62Av1affwQ==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"yallist": {
|
"yallist": {
|
||||||
|
|||||||
14
runtime/js/runtime/package-lock.json
generated
14
runtime/js/runtime/package-lock.json
generated
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@wailsapp/runtime",
|
"name": "@wailsapp/runtime",
|
||||||
"version": "1.1.0",
|
"version": "1.1.1",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -130,9 +130,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"ini": {
|
"ini": {
|
||||||
"version": "1.3.5",
|
"version": "1.3.8",
|
||||||
"resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz",
|
"resolved": "https://registry.npmjs.org/ini/-/ini-1.3.8.tgz",
|
||||||
"integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==",
|
"integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"invert-kv": {
|
"invert-kv": {
|
||||||
@@ -451,9 +451,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"y18n": {
|
"y18n": {
|
||||||
"version": "3.2.1",
|
"version": "3.2.2",
|
||||||
"resolved": "https://registry.npmjs.org/y18n/-/y18n-3.2.1.tgz",
|
"resolved": "https://registry.npmjs.org/y18n/-/y18n-3.2.2.tgz",
|
||||||
"integrity": "sha1-bRX7qITAhnnA136I53WegR4H+kE=",
|
"integrity": "sha512-uGZHXkHnhF0XeeAPgnKfPv1bgKAYyVvmNL1xlKsPYZPaIHxGti2hHqvOCQv71XMsLxu1QjergkqogUnms5D3YQ==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"yargs": {
|
"yargs": {
|
||||||
|
|||||||
@@ -67,6 +67,16 @@ func (r *Window) SetColour(colour string) error {
|
|||||||
return r.renderer.SetColour(colour)
|
return r.renderer.SetColour(colour)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetMinSize sets the minimum size of a resizable window
|
||||||
|
func (r *Window) SetMinSize(width, height int) {
|
||||||
|
r.renderer.SetMinSize(width, height)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetMaxSize sets the maximum size of a resizable window
|
||||||
|
func (r *Window) SetMaxSize(width, height int) {
|
||||||
|
r.renderer.SetMaxSize(width, height)
|
||||||
|
}
|
||||||
|
|
||||||
// Fullscreen makes the window fullscreen
|
// Fullscreen makes the window fullscreen
|
||||||
func (r *Window) Fullscreen() {
|
func (r *Window) Fullscreen() {
|
||||||
r.renderer.Fullscreen()
|
r.renderer.Fullscreen()
|
||||||
|
|||||||
@@ -8,38 +8,6 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Default target to run when none is specified
|
|
||||||
// If not set, running mage will list available targets
|
|
||||||
// var Default = Build
|
|
||||||
|
|
||||||
/*
|
|
||||||
# Build runtime
|
|
||||||
echo "**** Building Runtime ****"
|
|
||||||
cd runtime/js
|
|
||||||
npm install
|
|
||||||
npm run build
|
|
||||||
cd ../..
|
|
||||||
|
|
||||||
echo "**** Packing Assets ****"
|
|
||||||
cd cmd
|
|
||||||
mewn
|
|
||||||
cd ..
|
|
||||||
cd lib/renderer
|
|
||||||
mewn
|
|
||||||
cd ../..
|
|
||||||
|
|
||||||
echo "**** Installing Wails locally ****"
|
|
||||||
cd cmd/wails
|
|
||||||
go install
|
|
||||||
cd ../..
|
|
||||||
|
|
||||||
echo "**** Tidying the mods! ****"
|
|
||||||
go mod tidy
|
|
||||||
|
|
||||||
echo "**** WE ARE DONE! ****"
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
func runCommand(command string, args ...string) {
|
func runCommand(command string, args ...string) {
|
||||||
cmd := exec.Command(command, args...)
|
cmd := exec.Command(command, args...)
|
||||||
output, err := cmd.CombinedOutput()
|
output, err := cmd.CombinedOutput()
|
||||||
@@ -48,7 +16,6 @@ func runCommand(command string, args ...string) {
|
|||||||
log.Println(string(output))
|
log.Println(string(output))
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
cmd.Run()
|
|
||||||
fmt.Println(string(output))
|
fmt.Println(string(output))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,26 +27,26 @@ func main() {
|
|||||||
// Build Runtime
|
// Build Runtime
|
||||||
fmt.Println("**** Building Runtime ****")
|
fmt.Println("**** Building Runtime ****")
|
||||||
runtimeDir, _ := filepath.Abs(filepath.Join(dir, "..", "runtime", "js"))
|
runtimeDir, _ := filepath.Abs(filepath.Join(dir, "..", "runtime", "js"))
|
||||||
os.Chdir(runtimeDir)
|
err := os.Chdir(runtimeDir)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
runCommand("npm", "install")
|
runCommand("npm", "install")
|
||||||
runCommand("npm", "run", "build")
|
runCommand("npm", "run", "build")
|
||||||
|
|
||||||
// Pack assets
|
|
||||||
fmt.Println("**** Packing Assets ****")
|
|
||||||
rendererDir, _ := filepath.Abs(filepath.Join(dir, "..", "lib", "renderer"))
|
|
||||||
os.Chdir(rendererDir)
|
|
||||||
runCommand("mewn")
|
|
||||||
cmdDir, _ := filepath.Abs(filepath.Join(dir, "..", "cmd"))
|
|
||||||
os.Chdir(cmdDir)
|
|
||||||
runCommand("mewn")
|
|
||||||
|
|
||||||
// Install Wails
|
// Install Wails
|
||||||
fmt.Println("**** Installing Wails locally ****")
|
fmt.Println("**** Installing Wails locally ****")
|
||||||
execDir, _ := filepath.Abs(filepath.Join(dir, "..", "cmd", "wails"))
|
execDir, _ := filepath.Abs(filepath.Join(dir, "..", "cmd", "wails"))
|
||||||
os.Chdir(execDir)
|
err = os.Chdir(execDir)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
runCommand("go", "install")
|
runCommand("go", "install")
|
||||||
|
|
||||||
baseDir, _ := filepath.Abs(filepath.Join(dir, ".."))
|
baseDir, _ := filepath.Abs(filepath.Join(dir, ".."))
|
||||||
os.Chdir(baseDir)
|
err = os.Chdir(baseDir)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
runCommand("go", "mod", "tidy")
|
runCommand("go", "mod", "tidy")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
echo "**** Checking if Wails passes unit tests ****"
|
echo "**** Checking if Wails passes unit tests ****"
|
||||||
if ! go test ./...
|
if ! go test ./lib/... ./runtime/... ./cmd/...
|
||||||
then
|
then
|
||||||
echo ""
|
echo ""
|
||||||
echo "ERROR: Unit tests failed!"
|
echo "ERROR: Unit tests failed!"
|
||||||
@@ -15,15 +15,6 @@ npm install
|
|||||||
npm run build
|
npm run build
|
||||||
cd ../..
|
cd ../..
|
||||||
|
|
||||||
echo "**** Packing Assets ****"
|
|
||||||
cd cmd
|
|
||||||
mewn
|
|
||||||
cd ..
|
|
||||||
cd lib/renderer
|
|
||||||
mewn
|
|
||||||
cd ../..
|
|
||||||
|
|
||||||
|
|
||||||
cd cmd/wails
|
cd cmd/wails
|
||||||
echo "**** Checking if Wails compiles ****"
|
echo "**** Checking if Wails compiles ****"
|
||||||
if ! go build .
|
if ! go build .
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ cd runtime/js
|
|||||||
npm run build
|
npm run build
|
||||||
|
|
||||||
cd ../..
|
cd ../..
|
||||||
mewn
|
|
||||||
|
|
||||||
git add cmd/version.go
|
git add cmd/version.go
|
||||||
git commit cmd/version.go -m "Bump to ${TAG}"
|
git commit cmd/version.go -m "Bump to ${TAG}"
|
||||||
|
|||||||
Reference in New Issue
Block a user