mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-03 05:00:31 +08:00
Merge branch 'develop'
# Conflicts: # README.md # cmd/version.go # lib/renderer/webview.go
This commit is contained in:
commit
94bed2a093
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]
|
||||
steps:
|
||||
|
||||
- name: Set up Go 1.13
|
||||
- name: Set up Go 1.16
|
||||
uses: actions/setup-go@v1
|
||||
with:
|
||||
go-version: 1.13
|
||||
go-version: 1.16
|
||||
id: go
|
||||
|
||||
- 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]
|
||||
steps:
|
||||
|
||||
- name: Set up Go 1.13
|
||||
- name: Set up Go 1.16
|
||||
uses: actions/setup-go@v1
|
||||
with:
|
||||
go-version: 1.13
|
||||
go-version: 1.16
|
||||
id: go
|
||||
|
||||
- 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]
|
||||
steps:
|
||||
|
||||
- name: Set up Go 1.13
|
||||
- name: Set up Go 1.16
|
||||
uses: actions/setup-go@v1
|
||||
with:
|
||||
go-version: 1.13
|
||||
go-version: 1.16
|
||||
id: go
|
||||
|
||||
- name: Check out code into the Go module directory
|
||||
|
57
README.md
57
README.md
@ -32,7 +32,7 @@ The official docs can be found at [https://wails.app](https://wails.app).
|
||||
|
||||
## Sponsors
|
||||
|
||||
This project is supported by these kind people:
|
||||
This project is supported by these kind people / companies:
|
||||
|
||||
<a href="https://github.com/matryer" style="width:100px"><img src="https://github.com/matryer.png" width="100"/></a>
|
||||
<a href="https://www.jetbrains.com?from=Wails" style="width:100px"><img src="jetbrains-grayscale.png" width="100"/></a>
|
||||
@ -46,7 +46,6 @@ This project is supported by these kind people:
|
||||
<img src="https://github.com/tylertravisty.png?size=50" width="50" style="border-radius: 50%"/>
|
||||
</a>
|
||||
|
||||
|
||||
## Installation
|
||||
|
||||
Wails uses cgo to bind to the native rendering engines so a number of platform dependent libraries are needed as well as an installation of Go. The basic requirements are:
|
||||
@ -130,17 +129,59 @@ It is recommended at this stage to read the comprehensive documentation at [http
|
||||
|
||||
When I saw WebView, I thought "What I really want is tooling around building a WebView app, a bit like Rails is to Ruby". So initially it was a play on words (Webview on Rails). It just so happened to also be a homophone of the English name for the [Country](https://en.wikipedia.org/wiki/Wales) I am from. So it stuck.
|
||||
|
||||
## Shoulders of Giants
|
||||
## Contributors
|
||||
|
||||
<a href="https://github.com/qaisjp"><img src="https://github.com/qaisjp.png?size=40" width="40"/></a>
|
||||
<a href="https://github.com/alee792"><img src="https://github.com/alee792.png?size=40" width="40"/></a>
|
||||
<a href="https://github.com/lanzafame"><img src="https://github.com/lanzafame.png?size=40" width="40"/></a>
|
||||
<a href="https://github.com/mattn"><img src="https://github.com/mattn.png?size=40" width="40"/></a>
|
||||
<a href="https://github.com/0xflotus"><img src="https://github.com/0xflotus.png?size=40" width="40"/></a>
|
||||
<a href="https://github.com/mdhender"><img src="https://github.com/mdhender.png?size=40" width="40"/></a>
|
||||
<a href="https://github.com/fishfishfish2104"><img src="https://github.com/fishfishfish2104.png?size=40" width="40"/></a>
|
||||
<a href="https://github.com/intelwalk"><img src="https://github.com/intelwalk.png?size=40" width="40"/></a>
|
||||
<a href="https://github.com/ocelotsloth"><img src="https://github.com/ocelotsloth.png?size=40" width="40"/></a>
|
||||
<a href="https://github.com/bh90210"><img src="https://github.com/bh90210.png?size=40" width="40"/></a>
|
||||
<a href="https://github.com/iceleo-com"><img src="https://github.com/iceleo-com.png?size=40" width="40"/></a>
|
||||
<a href="https://github.com/fallendusk"><img src="https://github.com/fallendusk.png?size=40" width="40"/></a>
|
||||
<a href="https://github.com/Chronophylos"><img src="https://github.com/Chronophylos.png?size=40" width="40"/></a>
|
||||
<a href="https://github.com/Vaelatern"><img src="https://github.com/Vaelatern.png?size=40" width="40"/></a>
|
||||
<a href="https://github.com/mewmew"><img src="https://github.com/mewmew.png?size=40" width="40"/></a>
|
||||
<a href="https://github.com/kraney"><img src="https://github.com/kraney.png?size=40" width="40"/></a>
|
||||
<a href="https://github.com/JackMordaunt"><img src="https://github.com/JackMordaunt.png?size=40" width="40"/></a>
|
||||
<a href="https://github.com/MichaelHipp"><img src="https://github.com/MichaelHipp.png?size=40" width="40"/></a>
|
||||
<a href="https://github.com/tmclane"><img src="https://github.com/tmclane.png?size=40" width="40"/></a>
|
||||
<a href="https://github.com/Rested"><img src="https://github.com/Rested.png?size=40" width="40"/></a>
|
||||
<a href="https://github.com/Jarek-SRT"><img src="https://github.com/Jarek-SRT.png?size=40" width="40"/></a>
|
||||
<a href="https://github.com/konez2k"><img src="https://github.com/konez2k.png?size=40" width="40"/></a>
|
||||
<a href="https://github.com/sayuthisobri"><img src="https://github.com/sayuthisobri.png?size=40" width="40"/></a>
|
||||
<a href="https://github.com/dedo1911"><img src="https://github.com/dedo1911.png?size=40" width="40"/></a>
|
||||
<a href="https://github.com/fdidron"><img src="https://github.com/fdidron.png?size=40" width="40"/></a>
|
||||
<a href="https://github.com/Splode"><img src="https://github.com/Splode.png?size=40" width="40"/></a>
|
||||
<a href="https://github.com/Lyimmi"><img src="https://github.com/Lyimmi.png?size=40" width="40"/></a>
|
||||
<a href="https://github.com/Unix4ever"><img src="https://github.com/Unix4ever.png?size=40" width="40"/></a>
|
||||
<a href="https://github.com/timkippdev"><img src="https://github.com/timkippdev.png?size=40" width="40"/></a>
|
||||
<a href="https://github.com/kyoto44"><img src="https://github.com/kyoto44.png?size=40" width="40"/></a>
|
||||
<a href="https://github.com/artooro"><img src="https://github.com/artooro.png?size=40" width="40"/></a>
|
||||
<a href="https://github.com/ilgityildirim"><img src="https://github.com/ilgityildirim.png?size=40" width="40"/></a>
|
||||
<a href="https://github.com/gelleson"><img src="https://github.com/gelleson.png?size=40" width="40"/></a>
|
||||
<a href="https://github.com/kmuchmore"><img src="https://github.com/kmuchmore.png?size=40" width="40"/></a>
|
||||
<a href="https://github.com/aayush420"><img src="https://github.com/aayush420.png?size=40" width="40"/></a>
|
||||
<a href="https://github.com/Rezrazi"><img src="https://github.com/Rezrazi.png?size=40" width="40"/></a>
|
||||
<a href="https://github.com/misitebao"><img src="https://github.com/misitebao.png?size=40" width="40"/></a>
|
||||
<a href="https://github.com/DrunkenPoney"><img src="https://github.com/DrunkenPoney.png?size=40" width="40"/></a>
|
||||
<a href="https://github.com/SophieAu"><img src="https://github.com/SophieAu.png?size=40" width="40"/></a>
|
||||
<a href="https://github.com/alexmat"><img src="https://github.com/alexmat.png?size=40" width="40"/></a>
|
||||
<a href="https://github.com/RH12503"><img src="https://github.com/RH12503.png?size=40" width="40"/></a>
|
||||
<a href="https://github.com/hi019"><img src="https://github.com/hi019.png?size=40" width="40"/></a></a>
|
||||
<a href="https://github.com/Igogrek"><img src="https://github.com/Igogrek.png?size=40" width="40"/></a></a>
|
||||
|
||||
|
||||
## Special Mentions
|
||||
|
||||
Without the following people, this project would never have existed:
|
||||
|
||||
* [Dustin Krysak](https://wiki.ubuntu.com/bashfulrobot) - His support and feedback has been immense. More patience than you can throw a stick at (Not long now Dustin!).
|
||||
* [Serge Zaitsev](https://github.com/zserge) - Creator of [Webview](https://github.com/zserge/webview) which Wails uses for the windowing.
|
||||
|
||||
And without [these people](CONTRIBUTORS.md), it wouldn't be what it is today. A huge thank you to each and every one of you!
|
||||
|
||||
Special Mentions:
|
||||
|
||||
* [Byron](https://github.com/bh90210) - At times, Byron has single handedly kept this project alive. Without his incredible input, we never would have got to v1.
|
||||
|
||||
This project was mainly coded to the following albums:
|
||||
|
File diff suppressed because one or more lines are too long
108
cmd/helpers.go
108
cmd/helpers.go
@ -2,7 +2,6 @@ package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"os/user"
|
||||
@ -12,10 +11,9 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/leaanthony/mewn"
|
||||
"github.com/leaanthony/mewn/lib"
|
||||
"github.com/leaanthony/slicer"
|
||||
"github.com/leaanthony/spinner"
|
||||
wailsruntime "github.com/wailsapp/wails/runtime"
|
||||
)
|
||||
|
||||
const xgoVersion = "1.0.1"
|
||||
@ -61,30 +59,6 @@ func InstallGoDependencies(verbose bool) error {
|
||||
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 {
|
||||
// Check Docker
|
||||
if err := CheckIfInstalled("docker"); err != nil {
|
||||
@ -127,7 +101,10 @@ func BuildDocker(binaryName string, buildMode string, projectOptions *ProjectOpt
|
||||
// Check build directory
|
||||
buildDirectory := filepath.Join(fs.Cwd(), "build")
|
||||
if !fs.DirExists(buildDirectory) {
|
||||
fs.MkDir(buildDirectory)
|
||||
err := fs.MkDir(buildDirectory)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
buildCommand := slicer.String()
|
||||
@ -198,11 +175,6 @@ func BuildDocker(binaryName string, buildMode string, projectOptions *ProjectOpt
|
||||
// BuildNative builds on the target platform itself.
|
||||
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 {
|
||||
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 {
|
||||
var err error
|
||||
|
||||
// embed resources
|
||||
targetFiles, err := EmbedAssets()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if projectOptions.CrossCompile {
|
||||
if err := InitializeCrossCompilation(projectOptions.Verbose); err != nil {
|
||||
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 {
|
||||
err = BuildDocker(binaryName, buildMode, projectOptions)
|
||||
} else {
|
||||
@ -374,30 +326,6 @@ func BuildFrontend(projectOptions *ProjectOptions) error {
|
||||
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
|
||||
func CheckWindres() (err error) {
|
||||
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
|
||||
ioutil.WriteFile(md5sumFile, []byte(packageJSONMD5), 0644)
|
||||
err := os.WriteFile(md5sumFile, []byte(packageJSONMD5), 0644)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
// Install the runtime
|
||||
err = InstallRuntime(caller, projectDir, projectOptions)
|
||||
if caller == "build" {
|
||||
err = InstallProdRuntime(projectDir, projectOptions)
|
||||
} else {
|
||||
err = InstallBridge(projectDir, projectOptions)
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -510,28 +445,17 @@ func InstallFrontendDeps(projectDir string, projectOptions *ProjectOptions, forc
|
||||
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
|
||||
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")
|
||||
err := fs.CreateFile(bridgeFileTarget, []byte(bridgeFileData))
|
||||
err := fs.CreateFile(bridgeFileTarget, wailsruntime.BridgeJS)
|
||||
return err
|
||||
}
|
||||
|
||||
// InstallProdRuntime installs the production runtime
|
||||
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")
|
||||
err := fs.CreateFile(bridgeFileTarget, []byte(prodInit))
|
||||
err := fs.CreateFile(bridgeFileTarget, wailsruntime.InitJS)
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/leaanthony/mewn"
|
||||
_ "embed"
|
||||
"github.com/wailsapp/wails"
|
||||
)
|
||||
|
||||
@ -9,10 +9,13 @@ func basic() string {
|
||||
return "World!"
|
||||
}
|
||||
|
||||
func main() {
|
||||
//go:embed frontend/dist/my-app/main.js
|
||||
var js string
|
||||
|
||||
js := mewn.String("./frontend/dist/my-app/main.js")
|
||||
css := mewn.String("./frontend/dist/my-app/styles.css")
|
||||
//go:embed frontend/dist/my-app/styles.css
|
||||
var css string
|
||||
|
||||
func main() {
|
||||
|
||||
app := wails.CreateApp(&wails.AppConfig{
|
||||
Width: 1024,
|
||||
|
@ -1,7 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/leaanthony/mewn"
|
||||
_ "embed"
|
||||
"github.com/wailsapp/wails"
|
||||
)
|
||||
|
||||
@ -9,10 +9,13 @@ func basic() string {
|
||||
return "World!"
|
||||
}
|
||||
|
||||
func main() {
|
||||
//go:embed frontend/build/static/js/main.js
|
||||
var js string
|
||||
|
||||
js := mewn.String("./frontend/build/static/js/main.js")
|
||||
css := mewn.String("./frontend/build/static/css/main.css")
|
||||
//go:embed frontend/build/static/css/main.css
|
||||
var css string
|
||||
|
||||
func main() {
|
||||
|
||||
app := wails.CreateApp(&wails.AppConfig{
|
||||
Width: 1024,
|
||||
|
@ -1,7 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/leaanthony/mewn"
|
||||
_ "embed"
|
||||
"github.com/wailsapp/wails"
|
||||
)
|
||||
|
||||
@ -9,9 +9,13 @@ func basic() string {
|
||||
return "World!"
|
||||
}
|
||||
|
||||
//go:embed frontend/public/build/bundle.js
|
||||
var js string
|
||||
|
||||
//go:embed frontend/public/build/bundle.css
|
||||
var css string
|
||||
|
||||
func main() {
|
||||
js := mewn.String("./frontend/public/build/bundle.js")
|
||||
css := mewn.String("./frontend/public/build/bundle.css")
|
||||
|
||||
app := wails.CreateApp(&wails.AppConfig{
|
||||
Width: 1024,
|
||||
|
@ -1,14 +1,17 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/leaanthony/mewn"
|
||||
_ "embed"
|
||||
"github.com/wailsapp/wails"
|
||||
)
|
||||
|
||||
func main() {
|
||||
//go:embed frontend/build/main.js
|
||||
var js string
|
||||
|
||||
js := mewn.String("./frontend/build/main.js")
|
||||
css := mewn.String("./frontend/build/main.css")
|
||||
//go:embed frontend/build/main.css
|
||||
var css string
|
||||
|
||||
func main() {
|
||||
|
||||
app := wails.CreateApp(&wails.AppConfig{
|
||||
Width: 1024,
|
||||
|
@ -1,7 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/leaanthony/mewn"
|
||||
_ "embed"
|
||||
"github.com/wailsapp/wails"
|
||||
)
|
||||
|
||||
@ -9,10 +9,13 @@ func basic() string {
|
||||
return "Hello World!"
|
||||
}
|
||||
|
||||
func main() {
|
||||
//go:embed frontend/dist/app.js
|
||||
var js string
|
||||
|
||||
js := mewn.String("./frontend/dist/app.js")
|
||||
css := mewn.String("./frontend/dist/app.css")
|
||||
//go:embed frontend/dist/app.css
|
||||
var css string
|
||||
|
||||
func main() {
|
||||
|
||||
app := wails.CreateApp(&wails.AppConfig{
|
||||
Width: 1024,
|
||||
|
@ -1,7 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/leaanthony/mewn"
|
||||
_ "embed"
|
||||
"github.com/wailsapp/wails"
|
||||
)
|
||||
|
||||
@ -9,10 +9,13 @@ func basic() string {
|
||||
return "Hello World!"
|
||||
}
|
||||
|
||||
func main() {
|
||||
//go:embed frontend/dist/app.js
|
||||
var js string
|
||||
|
||||
js := mewn.String("./frontend/dist/app.js")
|
||||
css := mewn.String("./frontend/dist/app.css")
|
||||
//go:embed frontend/dist/app.css
|
||||
var css string
|
||||
|
||||
func main() {
|
||||
|
||||
app := wails.CreateApp(&wails.AppConfig{
|
||||
Width: 1024,
|
||||
|
@ -1,7 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/leaanthony/mewn"
|
||||
_ "embed"
|
||||
"github.com/wailsapp/wails"
|
||||
)
|
||||
|
||||
@ -9,10 +9,13 @@ func basic() string {
|
||||
return "Hello World!"
|
||||
}
|
||||
|
||||
func main() {
|
||||
//go:embed frontend/dist/app.js
|
||||
var js string
|
||||
|
||||
js := mewn.String("./frontend/dist/app.js")
|
||||
css := mewn.String("./frontend/dist/app.css")
|
||||
//go:embed frontend/dist/app.css
|
||||
var css string
|
||||
|
||||
func main() {
|
||||
|
||||
app := wails.CreateApp(&wails.AppConfig{
|
||||
Width: 1024,
|
||||
|
@ -1,7 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/leaanthony/mewn"
|
||||
_ "embed"
|
||||
"github.com/wailsapp/wails"
|
||||
)
|
||||
|
||||
@ -9,10 +9,13 @@ func basic() string {
|
||||
return "Hello World!"
|
||||
}
|
||||
|
||||
func main() {
|
||||
//go:embed frontend/dist/app.js
|
||||
var js string
|
||||
|
||||
js := mewn.String("./frontend/dist/app.js")
|
||||
css := mewn.String("./frontend/dist/app.css")
|
||||
//go:embed frontend/dist/app.css
|
||||
var css string
|
||||
|
||||
func main() {
|
||||
|
||||
app := wails.CreateApp(&wails.AppConfig{
|
||||
Width: 1024,
|
||||
|
@ -1,4 +1,4 @@
|
||||
package cmd
|
||||
|
||||
// Version - Wails version
|
||||
const Version = "v1.13.0"
|
||||
const Version = "v1.16.0"
|
||||
|
@ -39,12 +39,6 @@ Create your first project by running 'wails init'.`
|
||||
return err
|
||||
}
|
||||
|
||||
// Check Mewn
|
||||
err = cmd.CheckMewn(false)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Check for errors
|
||||
// CheckDependencies() returns !errors
|
||||
// so to get the right message in this
|
||||
|
@ -2,6 +2,7 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"runtime"
|
||||
"strings"
|
||||
@ -52,7 +53,10 @@ func init() {
|
||||
|
||||
var b strings.Builder
|
||||
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",
|
||||
fmt.Sprintf("Cross-compile application to specified platform via xgo\n%s", b.String()),
|
||||
@ -80,7 +84,7 @@ func init() {
|
||||
fs := cmd.NewFSHelper()
|
||||
err := projectOptions.LoadConfig(fs.Cwd())
|
||||
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
|
||||
@ -143,12 +147,6 @@ func init() {
|
||||
if err != nil {
|
||||
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
|
||||
|
@ -27,19 +27,13 @@ func init() {
|
||||
logger.PrintSmallBanner(message)
|
||||
fmt.Println()
|
||||
|
||||
// Check Mewn is installed
|
||||
err := cmd.CheckMewn(verbose)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Project options
|
||||
projectOptions := &cmd.ProjectOptions{}
|
||||
|
||||
// Check we are in project directory
|
||||
// Check project.json loads correctly
|
||||
fs := cmd.NewFSHelper()
|
||||
err = projectOptions.LoadConfig(fs.Cwd())
|
||||
err := projectOptions.LoadConfig(fs.Cwd())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
3
go.mod
3
go.mod
@ -9,7 +9,6 @@ require (
|
||||
github.com/jackmordaunt/icns v1.0.0
|
||||
github.com/kennygrant/sanitize v1.2.4
|
||||
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/spinner v0.5.3
|
||||
github.com/mattn/go-colorable v0.1.1 // indirect
|
||||
@ -28,4 +27,4 @@ require (
|
||||
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/kr/pty v1.1.1 h1:VkoXIwSboBpnk99O/KFauAEILuNHv5DVFKZMBN/gUgw=
|
||||
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/go.mod h1:FwrApmf8gOrpzEWM2J/9Lh79tyq8KTX5AzRtwV7m4AY=
|
||||
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=
|
||||
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-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnkZWQJsqcURM6tKiBApRjXI=
|
||||
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/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
||||
|
@ -115,15 +115,15 @@ func (b *Manager) generateTypescriptDefinitions() error {
|
||||
|
||||
for structname, methodList := range b.structList {
|
||||
structname = strings.SplitN(structname, ".", 2)[1]
|
||||
output.WriteString(fmt.Sprintf("Interface %s {\n", structname))
|
||||
output.WriteString(fmt.Sprintf("interface %s {\n", structname))
|
||||
for _, method := range methodList {
|
||||
output.WriteString(fmt.Sprintf("\t%s: (...args : any[]) => Promise\n", method))
|
||||
output.WriteString(fmt.Sprintf("\t%s(...args : any[]):Promise<any>\n", method))
|
||||
}
|
||||
output.WriteString("}\n")
|
||||
}
|
||||
|
||||
output.WriteString("\n")
|
||||
output.WriteString("Interface Backend {\n")
|
||||
output.WriteString("interface Backend {\n")
|
||||
|
||||
for structname := range b.structList {
|
||||
structname = strings.SplitN(structname, ".", 2)[1]
|
||||
@ -136,7 +136,8 @@ declare global {
|
||||
interface Window {
|
||||
backend: Backend;
|
||||
}
|
||||
}`
|
||||
}
|
||||
export {};`
|
||||
output.WriteString(globals)
|
||||
|
||||
b.log.Info("Written Typescript file: " + typescriptDefinitionFilename)
|
||||
|
File diff suppressed because one or more lines are too long
@ -3,8 +3,9 @@ package renderer
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/wailsapp/wails/runtime"
|
||||
|
||||
"github.com/gorilla/websocket"
|
||||
"github.com/leaanthony/mewn"
|
||||
"github.com/wailsapp/wails/lib/interfaces"
|
||||
"github.com/wailsapp/wails/lib/logger"
|
||||
)
|
||||
@ -58,8 +59,7 @@ func (s *session) start(firstSession bool) {
|
||||
s.log.Infof("Connected to frontend.")
|
||||
go s.writePump()
|
||||
|
||||
wailsRuntime := mewn.String("../../runtime/assets/wails.js")
|
||||
s.evalJS(wailsRuntime, wailsRuntimeMessage)
|
||||
s.evalJS(runtime.WailsJS, wailsRuntimeMessage)
|
||||
|
||||
// Inject bindings
|
||||
for _, binding := range s.bindingCache {
|
||||
|
File diff suppressed because one or more lines are too long
@ -8,8 +8,9 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/wailsapp/wails/runtime"
|
||||
|
||||
"github.com/go-playground/colors"
|
||||
"github.com/leaanthony/mewn"
|
||||
"github.com/wailsapp/wails/lib/interfaces"
|
||||
"github.com/wailsapp/wails/lib/logger"
|
||||
"github.com/wailsapp/wails/lib/messages"
|
||||
@ -29,7 +30,6 @@ type WebView struct {
|
||||
config interfaces.AppConfig
|
||||
eventManager interfaces.EventManager
|
||||
bindingCache []string
|
||||
|
||||
maximumSizeSet bool
|
||||
}
|
||||
|
||||
@ -93,7 +93,6 @@ func (w *WebView) Initialise(config interfaces.AppConfig, ipc interfaces.IPCMana
|
||||
w.ipc.Dispatch(message, w.callback)
|
||||
},
|
||||
})
|
||||
fmt.Println("Control")
|
||||
|
||||
// Set minimum and maximum sizes
|
||||
if setMinSize {
|
||||
@ -101,7 +100,14 @@ func (w *WebView) Initialise(config interfaces.AppConfig, ipc interfaces.IPCMana
|
||||
}
|
||||
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)
|
||||
@ -113,7 +119,6 @@ func (w *WebView) Initialise(config interfaces.AppConfig, ipc interfaces.IPCMana
|
||||
}
|
||||
|
||||
w.log.Info("Initialised")
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -223,8 +228,8 @@ func (w *WebView) Run() error {
|
||||
}
|
||||
|
||||
// Runtime assets
|
||||
wailsRuntime := mewn.String("../../runtime/assets/wails.js")
|
||||
w.evalJS(wailsRuntime)
|
||||
w.log.DebugFields("Injecting wails JS runtime", logger.Fields{"js": runtime.WailsJS})
|
||||
w.evalJS(runtime.WailsJS)
|
||||
|
||||
// Ping the wait channel when the wails runtime is loaded
|
||||
w.eventManager.On("wails:loaded", func(...interface{}) {
|
||||
@ -247,10 +252,9 @@ func (w *WebView) Run() error {
|
||||
w.injectCSS(w.config.GetCSS())
|
||||
} else {
|
||||
// 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
|
||||
|
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
|
@ -8,38 +8,6 @@ import (
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
// Default target to run when none is specified
|
||||
// If not set, running mage will list available targets
|
||||
// var Default = Build
|
||||
|
||||
/*
|
||||
# Build runtime
|
||||
echo "**** Building Runtime ****"
|
||||
cd runtime/js
|
||||
npm install
|
||||
npm run build
|
||||
cd ../..
|
||||
|
||||
echo "**** Packing Assets ****"
|
||||
cd cmd
|
||||
mewn
|
||||
cd ..
|
||||
cd lib/renderer
|
||||
mewn
|
||||
cd ../..
|
||||
|
||||
echo "**** Installing Wails locally ****"
|
||||
cd cmd/wails
|
||||
go install
|
||||
cd ../..
|
||||
|
||||
echo "**** Tidying the mods! ****"
|
||||
go mod tidy
|
||||
|
||||
echo "**** WE ARE DONE! ****"
|
||||
|
||||
*/
|
||||
|
||||
func runCommand(command string, args ...string) {
|
||||
cmd := exec.Command(command, args...)
|
||||
output, err := cmd.CombinedOutput()
|
||||
@ -48,7 +16,6 @@ func runCommand(command string, args ...string) {
|
||||
log.Println(string(output))
|
||||
log.Fatal(err)
|
||||
}
|
||||
cmd.Run()
|
||||
fmt.Println(string(output))
|
||||
}
|
||||
|
||||
@ -60,26 +27,26 @@ func main() {
|
||||
// Build Runtime
|
||||
fmt.Println("**** Building Runtime ****")
|
||||
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", "run", "build")
|
||||
|
||||
// Pack assets
|
||||
fmt.Println("**** Packing Assets ****")
|
||||
rendererDir, _ := filepath.Abs(filepath.Join(dir, "..", "lib", "renderer"))
|
||||
os.Chdir(rendererDir)
|
||||
runCommand("mewn")
|
||||
cmdDir, _ := filepath.Abs(filepath.Join(dir, "..", "cmd"))
|
||||
os.Chdir(cmdDir)
|
||||
runCommand("mewn")
|
||||
|
||||
// Install Wails
|
||||
fmt.Println("**** Installing Wails locally ****")
|
||||
execDir, _ := filepath.Abs(filepath.Join(dir, "..", "cmd", "wails"))
|
||||
os.Chdir(execDir)
|
||||
err = os.Chdir(execDir)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
runCommand("go", "install")
|
||||
|
||||
baseDir, _ := filepath.Abs(filepath.Join(dir, ".."))
|
||||
os.Chdir(baseDir)
|
||||
err = os.Chdir(baseDir)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
runCommand("go", "mod", "tidy")
|
||||
}
|
||||
|
@ -15,15 +15,6 @@ npm install
|
||||
npm run build
|
||||
cd ../..
|
||||
|
||||
echo "**** Packing Assets ****"
|
||||
cd cmd
|
||||
mewn
|
||||
cd ..
|
||||
cd lib/renderer
|
||||
mewn
|
||||
cd ../..
|
||||
|
||||
|
||||
cd cmd/wails
|
||||
echo "**** Checking if Wails compiles ****"
|
||||
if ! go build .
|
||||
|
@ -16,7 +16,6 @@ cd runtime/js
|
||||
npm run build
|
||||
|
||||
cd ../..
|
||||
mewn
|
||||
|
||||
git add cmd/version.go
|
||||
git commit cmd/version.go -m "Bump to ${TAG}"
|
||||
|
Loading…
Reference in New Issue
Block a user