mirror of
https://github.com/taigrr/wails.git
synced 2026-04-13 18:38:11 -07:00
Compare commits
16 Commits
migrate-to
...
windows-fi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
68f7c4c7bd | ||
|
|
c07900e555 | ||
|
|
dafd9bcb24 | ||
|
|
7f75f27f6b | ||
|
|
d77fa1ee74 | ||
|
|
82e00ff83a | ||
|
|
14f91ab109 | ||
|
|
19706a12a4 | ||
|
|
52e6091f0f | ||
|
|
2db1624faf | ||
|
|
f5d3fb0848 | ||
|
|
85a64914aa | ||
|
|
0819207e33 | ||
|
|
50a0bc7701 | ||
|
|
c51f0cad6f | ||
|
|
6795f6c678 |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -16,4 +16,5 @@ examples/**/example*
|
|||||||
cmd/wails/wails
|
cmd/wails/wails
|
||||||
.DS_Store
|
.DS_Store
|
||||||
tmp
|
tmp
|
||||||
node_modules/
|
node_modules/
|
||||||
|
/runtime/js/runtime/dist
|
||||||
@@ -20,3 +20,4 @@ Wails is what it is because of the time and effort given by these great people.
|
|||||||
* [Toyam Cox](https://github.com/Vaelatern)
|
* [Toyam Cox](https://github.com/Vaelatern)
|
||||||
* [Robin Eklind](https://github.com/mewmew)
|
* [Robin Eklind](https://github.com/mewmew)
|
||||||
* [Kris Raney](https://github.com/kraney)
|
* [Kris Raney](https://github.com/kraney)
|
||||||
|
* [soon cheol shin](https://github.com/scshin0572)
|
||||||
|
|||||||
8
app.go
8
app.go
@@ -2,6 +2,7 @@ package wails
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
|
"runtime"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"github.com/syossan27/tebata"
|
"github.com/syossan27/tebata"
|
||||||
@@ -43,7 +44,7 @@ func CreateApp(optionalConfig ...*AppConfig) *App {
|
|||||||
}
|
}
|
||||||
|
|
||||||
result := &App{
|
result := &App{
|
||||||
logLevel: "info",
|
logLevel: "debug",
|
||||||
renderer: renderer.NewWebView(),
|
renderer: renderer.NewWebView(),
|
||||||
ipc: ipc.NewManager(),
|
ipc: ipc.NewManager(),
|
||||||
bindingManager: binding.NewManager(),
|
bindingManager: binding.NewManager(),
|
||||||
@@ -102,6 +103,11 @@ func (a *App) start() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set debug mode
|
||||||
|
if runtime.GOOS == "windows" && BuildMode == cmd.BuildModeDebug {
|
||||||
|
a.renderer.EnableDebug()
|
||||||
|
}
|
||||||
|
|
||||||
// Start signal handler
|
// Start signal handler
|
||||||
t := tebata.New(os.Interrupt, os.Kill, syscall.SIGTERM, syscall.SIGINT, syscall.SIGKILL)
|
t := tebata.New(os.Interrupt, os.Kill, syscall.SIGTERM, syscall.SIGINT, syscall.SIGKILL)
|
||||||
t.Reserve(func() {
|
t.Reserve(func() {
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -7,6 +7,7 @@ import (
|
|||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/leaanthony/mewn"
|
"github.com/leaanthony/mewn"
|
||||||
@@ -87,6 +88,17 @@ func BuildApplication(binaryName string, forceRebuild bool, buildMode string, pa
|
|||||||
buildCommand.Add("build")
|
buildCommand.Add("build")
|
||||||
|
|
||||||
if binaryName != "" {
|
if binaryName != "" {
|
||||||
|
// Alter binary name based on OS
|
||||||
|
switch runtime.GOOS {
|
||||||
|
case "windows":
|
||||||
|
if !strings.HasSuffix(binaryName, ".exe") {
|
||||||
|
binaryName += ".exe"
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
if strings.HasSuffix(binaryName, ".exe") {
|
||||||
|
binaryName = strings.TrimSuffix(binaryName, ".exe")
|
||||||
|
}
|
||||||
|
}
|
||||||
buildCommand.Add("-o")
|
buildCommand.Add("-o")
|
||||||
buildCommand.Add(binaryName)
|
buildCommand.Add(binaryName)
|
||||||
}
|
}
|
||||||
@@ -103,7 +115,7 @@ func BuildApplication(binaryName string, forceRebuild bool, buildMode string, pa
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add windows flags
|
// Add windows flags
|
||||||
if runtime.GOOS == "windows" {
|
if runtime.GOOS == "windows" && buildMode == BuildModeProd {
|
||||||
ldflags += "-H windowsgui "
|
ldflags += "-H windowsgui "
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -191,8 +191,15 @@ func (b *PackageHelper) PackageWindows(po *ProjectOptions, cleanUp bool) error {
|
|||||||
|
|
||||||
// Build syso
|
// Build syso
|
||||||
sysofile := filepath.Join(b.fs.Cwd(), basename+"-res.syso")
|
sysofile := filepath.Join(b.fs.Cwd(), basename+"-res.syso")
|
||||||
windresCommand := []string{"windres", "-o", sysofile, tgtRCFile}
|
|
||||||
err := NewProgramHelper().RunCommandArray(windresCommand)
|
batfile, err := fs.LocalDir(".")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
windresBatFile := filepath.Join(batfile.fullPath, "windres.bat")
|
||||||
|
windresCommand := []string{windresBatFile, sysofile, tgtRCFile}
|
||||||
|
err = NewProgramHelper().RunCommandArray(windresCommand)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -128,6 +128,7 @@ func (p *ProgramHelper) RunCommandArray(args []string, dir ...string) error {
|
|||||||
fmt.Printf("ERROR: Looks like '%s' isn't installed. Please install and try again.", program)
|
fmt.Printf("ERROR: Looks like '%s' isn't installed. Please install and try again.", program)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
args = args[1:]
|
args = args[1:]
|
||||||
var stderr string
|
var stderr string
|
||||||
var stdout string
|
var stdout string
|
||||||
|
|||||||
@@ -9,4 +9,4 @@
|
|||||||
last 2 versions
|
last 2 versions
|
||||||
Firefox ESR
|
Firefox ESR
|
||||||
not dead
|
not dead
|
||||||
not IE 9-11 # For IE 9-11 support, remove 'not'.
|
IE 9-11 # For IE 9-11 support, remove 'not'.
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
/*
|
|
||||||
Wails Bridge (c) 2019-present Lea Anthony
|
|
||||||
|
|
||||||
This prod version is to get around having to rewrite your code
|
|
||||||
for production. When doing a release build, this file will be used
|
|
||||||
instead of the full version.
|
|
||||||
*/
|
|
||||||
|
|
||||||
export default {
|
|
||||||
// The main function
|
|
||||||
// Passes the main Wails object to the callback if given.
|
|
||||||
Start: function(callback) {
|
|
||||||
if (callback) {
|
|
||||||
window.wails.events.on("wails:ready", callback);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
/*
|
|
||||||
Wails Bridge (c) 2019-present Lea Anthony
|
|
||||||
|
|
||||||
This prod version is to get around having to rewrite your code
|
|
||||||
for production. When doing a release build, this file will be used
|
|
||||||
instead of the full version.
|
|
||||||
*/
|
|
||||||
|
|
||||||
export default {
|
|
||||||
// The main function
|
|
||||||
// Passes the main Wails object to the callback if given.
|
|
||||||
Start: function (callback) {
|
|
||||||
if (callback) {
|
|
||||||
window.wails.Events.On("wails:ready", callback);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
// Version - Wails version
|
// Version - Wails version
|
||||||
const Version = "v0.18.7-pre"
|
const Version = "v0.18.14-pre"
|
||||||
|
|||||||
@@ -80,15 +80,16 @@ To help you in this process, we will ask for some information, add Go/Wails deta
|
|||||||
npm := program.FindProgram("npm")
|
npm := program.FindProgram("npm")
|
||||||
if npm != nil {
|
if npm != nil {
|
||||||
stdout, _, _, _ := npm.Run("--version")
|
stdout, _, _, _ := npm.Run("--version")
|
||||||
nodeVersion = stdout
|
npmVersion = stdout
|
||||||
nodeVersion = nodeVersion[:len(nodeVersion)-1]
|
npmVersion = npmVersion[:len(npmVersion)-1]
|
||||||
|
npmVersion = strings.TrimSpace(npmVersion)
|
||||||
}
|
}
|
||||||
|
|
||||||
node := program.FindProgram("node")
|
node := program.FindProgram("node")
|
||||||
if node != nil {
|
if node != nil {
|
||||||
stdout, _, _, _ := node.Run("--version")
|
stdout, _, _, _ := node.Run("--version")
|
||||||
npmVersion = stdout
|
nodeVersion = stdout
|
||||||
npmVersion = npmVersion[:len(npmVersion)-1]
|
nodeVersion = nodeVersion[:len(nodeVersion)-1]
|
||||||
}
|
}
|
||||||
|
|
||||||
str.WriteString("\n| Name | Value |\n| ----- | ----- |\n")
|
str.WriteString("\n| Name | Value |\n| ----- | ----- |\n")
|
||||||
|
|||||||
1
cmd/windres.bat
Normal file
1
cmd/windres.bat
Normal file
@@ -0,0 +1 @@
|
|||||||
|
windres.exe -o %1 %2
|
||||||
12
config.go
12
config.go
@@ -94,12 +94,12 @@ func (a *AppConfig) merge(in *AppConfig) error {
|
|||||||
// Creates the default configuration
|
// Creates the default configuration
|
||||||
func newConfig(userConfig *AppConfig) (*AppConfig, error) {
|
func newConfig(userConfig *AppConfig) (*AppConfig, error) {
|
||||||
result := &AppConfig{
|
result := &AppConfig{
|
||||||
Width: 800,
|
Width: 800,
|
||||||
Height: 600,
|
Height: 600,
|
||||||
Resizable: true,
|
Resizable: true,
|
||||||
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"),
|
defaultHTML: mewn.String("./runtime/assets/default.html"),
|
||||||
}
|
}
|
||||||
|
|
||||||
if userConfig != nil {
|
if userConfig != nil {
|
||||||
|
|||||||
2
go.mod
2
go.mod
@@ -30,4 +30,4 @@ require (
|
|||||||
golang.org/x/text v0.3.0
|
golang.org/x/text v0.3.0
|
||||||
gopkg.in/AlecAivazis/survey.v1 v1.8.4
|
gopkg.in/AlecAivazis/survey.v1 v1.8.4
|
||||||
gopkg.in/yaml.v3 v3.0.0-20190709130402-674ba3eaed22
|
gopkg.in/yaml.v3 v3.0.0-20190709130402-674ba3eaed22
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -3,10 +3,12 @@ package interfaces
|
|||||||
import (
|
import (
|
||||||
"github.com/wailsapp/wails/lib/messages"
|
"github.com/wailsapp/wails/lib/messages"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Renderer is an interface describing a Wails target to render the app to
|
// Renderer is an interface describing a Wails target to render the app to
|
||||||
type Renderer interface {
|
type Renderer interface {
|
||||||
Initialise(AppConfig, IPCManager, EventManager) error
|
Initialise(AppConfig, IPCManager, EventManager) error
|
||||||
Run() error
|
Run() error
|
||||||
|
EnableDebug()
|
||||||
|
|
||||||
// Binding
|
// Binding
|
||||||
NewBinding(bindingName string) error
|
NewBinding(bindingName string) error
|
||||||
|
|||||||
@@ -48,6 +48,9 @@ type Bridge struct {
|
|||||||
|
|
||||||
// Mutex for writing to the socket
|
// Mutex for writing to the socket
|
||||||
lock sync.Mutex
|
lock sync.Mutex
|
||||||
|
|
||||||
|
// debug
|
||||||
|
debug bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialise the Bridge Renderer
|
// Initialise the Bridge Renderer
|
||||||
@@ -74,6 +77,11 @@ func (h *Bridge) evalJS(js string, mtype messageType) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// EnableDebug enables debug!
|
||||||
|
func (h *Bridge) EnableDebug() {
|
||||||
|
h.debug = true
|
||||||
|
}
|
||||||
|
|
||||||
func (h *Bridge) injectCSS(css string) {
|
func (h *Bridge) injectCSS(css string) {
|
||||||
// Minify css to overcome issues in the browser with carriage returns
|
// Minify css to overcome issues in the browser with carriage returns
|
||||||
minified, err := htmlmin.Minify([]byte(css), &htmlmin.Options{
|
minified, err := htmlmin.Minify([]byte(css), &htmlmin.Options{
|
||||||
@@ -117,7 +125,6 @@ func (h *Bridge) sendMessage(conn *websocket.Conn, msg string) {
|
|||||||
|
|
||||||
func (h *Bridge) start(conn *websocket.Conn) {
|
func (h *Bridge) start(conn *websocket.Conn) {
|
||||||
|
|
||||||
// set external.invoke
|
|
||||||
h.log.Infof("Connected to frontend.")
|
h.log.Infof("Connected to frontend.")
|
||||||
|
|
||||||
wailsRuntime := mewn.String("../../runtime/assets/wails.js")
|
wailsRuntime := mewn.String("../../runtime/assets/wails.js")
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -25,6 +25,7 @@ type WebView struct {
|
|||||||
config interfaces.AppConfig
|
config interfaces.AppConfig
|
||||||
eventManager interfaces.EventManager
|
eventManager interfaces.EventManager
|
||||||
bindingCache []string
|
bindingCache []string
|
||||||
|
debug bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewWebView returns a new WebView struct
|
// NewWebView returns a new WebView struct
|
||||||
@@ -48,13 +49,22 @@ func (w *WebView) Initialise(config interfaces.AppConfig, ipc interfaces.IPCMana
|
|||||||
// Save the config
|
// Save the config
|
||||||
w.config = config
|
w.config = config
|
||||||
|
|
||||||
|
// defaulthtml
|
||||||
|
HTML := config.GetDefaultHTML()
|
||||||
|
if len(HTML) == 0 {
|
||||||
|
HTML = mewn.String("../../runtime/assets/default.html")
|
||||||
|
}
|
||||||
|
|
||||||
|
HTML = fmt.Sprintf("data:text/html,%s", HTML)
|
||||||
|
fmt.Printf("*** %s ***", HTML)
|
||||||
|
w.log.Infof("URL: %s", HTML)
|
||||||
// Create the WebView instance
|
// Create the WebView instance
|
||||||
w.window = wv.NewWebview(wv.Settings{
|
w.window = wv.NewWebview(wv.Settings{
|
||||||
Width: config.GetWidth(),
|
Width: config.GetWidth(),
|
||||||
Height: config.GetHeight(),
|
Height: config.GetHeight(),
|
||||||
Title: config.GetTitle(),
|
Title: config.GetTitle(),
|
||||||
Resizable: config.GetResizable(),
|
Resizable: config.GetResizable(),
|
||||||
URL: config.GetDefaultHTML(),
|
URL: HTML,
|
||||||
Debug: !config.GetDisableInspector(),
|
Debug: !config.GetDisableInspector(),
|
||||||
ExternalInvokeCallback: func(_ wv.WebView, message string) {
|
ExternalInvokeCallback: func(_ wv.WebView, message string) {
|
||||||
w.ipc.Dispatch(message)
|
w.ipc.Dispatch(message)
|
||||||
@@ -95,6 +105,7 @@ func (w *WebView) evalJS(js string) error {
|
|||||||
if len(js) > 45 {
|
if len(js) > 45 {
|
||||||
outputJS += "..."
|
outputJS += "..."
|
||||||
}
|
}
|
||||||
|
// var outputJS = js
|
||||||
w.log.DebugFields("Eval", logger.Fields{"js": outputJS})
|
w.log.DebugFields("Eval", logger.Fields{"js": outputJS})
|
||||||
//
|
//
|
||||||
w.window.Dispatch(func() {
|
w.window.Dispatch(func() {
|
||||||
@@ -103,6 +114,11 @@ func (w *WebView) evalJS(js string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// EnableDebug enables debug!
|
||||||
|
func (w *WebView) EnableDebug() {
|
||||||
|
w.debug = true
|
||||||
|
}
|
||||||
|
|
||||||
// Escape the Javascripts!
|
// Escape the Javascripts!
|
||||||
func escapeJS(js string) (string, error) {
|
func escapeJS(js string) (string, error) {
|
||||||
result := strings.Replace(js, "\\", "\\\\", -1)
|
result := strings.Replace(js, "\\", "\\\\", -1)
|
||||||
@@ -172,51 +188,58 @@ func (w *WebView) Run() error {
|
|||||||
|
|
||||||
w.log.Info("Running...")
|
w.log.Info("Running...")
|
||||||
|
|
||||||
// Runtime assets
|
// Inject firebug in debug mode on Windows
|
||||||
wailsRuntime := mewn.String("../../runtime/assets/wails.js")
|
if w.debug {
|
||||||
w.evalJS(wailsRuntime)
|
w.log.Debug("Injecting firebug")
|
||||||
|
// firebugLite := mewn.String("../../runtime/assets/injectFirebug.js")
|
||||||
|
// w.evalJS(firebugLite)
|
||||||
|
}
|
||||||
|
|
||||||
// Ping the wait channel when the wails runtime is loaded
|
// // Runtime assets
|
||||||
w.eventManager.On("wails:loaded", func(...interface{}) {
|
// wailsRuntime := mewn.String("../../runtime/assets/wails.js")
|
||||||
|
// w.evalJS(wailsRuntime)
|
||||||
|
|
||||||
// Run this in a different go routine to free up the main process
|
// // Ping the wait channel when the wails runtime is loaded
|
||||||
go func() {
|
// w.eventManager.On("wails:loaded", func(...interface{}) {
|
||||||
|
|
||||||
// Inject Bindings
|
// // Run this in a different go routine to free up the main process
|
||||||
for _, binding := range w.bindingCache {
|
// go func() {
|
||||||
w.evalJSSync(binding)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Inject user CSS
|
// // Inject Bindings
|
||||||
if w.config.GetCSS() != "" {
|
// for _, binding := range w.bindingCache {
|
||||||
outputCSS := fmt.Sprintf("%.45s", w.config.GetCSS())
|
// w.evalJSSync(binding)
|
||||||
if len(outputCSS) > 45 {
|
// }
|
||||||
outputCSS += "..."
|
|
||||||
}
|
|
||||||
w.log.DebugFields("Inject User CSS", logger.Fields{"css": outputCSS})
|
|
||||||
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)
|
// // Inject user CSS
|
||||||
}
|
// if w.config.GetCSS() != "" {
|
||||||
|
// outputCSS := fmt.Sprintf("%.45s", w.config.GetCSS())
|
||||||
|
// if len(outputCSS) > 45 {
|
||||||
|
// outputCSS += "..."
|
||||||
|
// }
|
||||||
|
// w.log.DebugFields("Inject User CSS", logger.Fields{"css": outputCSS})
|
||||||
|
// w.injectCSS(w.config.GetCSS())
|
||||||
|
// } else {
|
||||||
|
// // Use default wails css
|
||||||
|
// w.log.Debug("Injecting Default Wails CSS")
|
||||||
|
// defaultCSS := mewn.String("../../runtime/assets/wails.css")
|
||||||
|
|
||||||
// Inject user JS
|
// w.injectCSS(defaultCSS)
|
||||||
if w.config.GetJS() != "" {
|
// }
|
||||||
outputJS := fmt.Sprintf("%.45s", w.config.GetJS())
|
|
||||||
if len(outputJS) > 45 {
|
|
||||||
outputJS += "..."
|
|
||||||
}
|
|
||||||
w.log.DebugFields("Inject User JS", logger.Fields{"js": outputJS})
|
|
||||||
w.evalJSSync(w.config.GetJS())
|
|
||||||
}
|
|
||||||
|
|
||||||
// Emit that everything is loaded and ready
|
// // Inject user JS
|
||||||
w.eventManager.Emit("wails:ready")
|
// if w.config.GetJS() != "" {
|
||||||
}()
|
// outputJS := fmt.Sprintf("%.45s", w.config.GetJS())
|
||||||
})
|
// if len(outputJS) > 45 {
|
||||||
|
// outputJS += "..."
|
||||||
|
// }
|
||||||
|
// w.log.DebugFields("Inject User JS", logger.Fields{"js": outputJS})
|
||||||
|
// w.evalJSSync(w.config.GetJS())
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // Emit that everything is loaded and ready
|
||||||
|
// w.eventManager.Emit("wails:ready")
|
||||||
|
// }()
|
||||||
|
// })
|
||||||
|
|
||||||
// Kick off main window loop
|
// Kick off main window loop
|
||||||
w.window.Run()
|
w.window.Run()
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
// Package wails implements Go bindings to https://github.com/zserge/webview C library.
|
// Package webview implements Go bindings to https://github.com/zserge/webview C library.
|
||||||
// It is a modified version of webview.go from that repository
|
// It is a modified version of webview.go from that repository
|
||||||
|
|
||||||
// Bindings closely repeat the C APIs and include both, a simplified
|
// Bindings closely repeat the C APIs and include both, a simplified
|
||||||
// single-function API to just open a full-screen webview window, and a more
|
// single-function API to just open a full-screen webview window, and a more
|
||||||
// advanced and featureful set of APIs, including Go-to-JavaScript bindings.
|
// advanced and featureful set of APIs, including Go-to-JavaScript bindings.
|
||||||
@@ -14,7 +13,7 @@ package webview
|
|||||||
#cgo linux openbsd freebsd CFLAGS: -DWEBVIEW_GTK=1 -Wno-deprecated-declarations
|
#cgo linux openbsd freebsd CFLAGS: -DWEBVIEW_GTK=1 -Wno-deprecated-declarations
|
||||||
#cgo linux openbsd freebsd pkg-config: gtk+-3.0 webkit2gtk-4.0
|
#cgo linux openbsd freebsd pkg-config: gtk+-3.0 webkit2gtk-4.0
|
||||||
|
|
||||||
#cgo windows CFLAGS: -DWEBVIEW_WINAPI=1
|
#cgo windows CFLAGS: -DWEBVIEW_WINAPI=1 -std=c99 -DUNICODE=1 -D_UNICODE=1
|
||||||
#cgo windows LDFLAGS: -lole32 -lcomctl32 -loleaut32 -luuid -lgdi32
|
#cgo windows LDFLAGS: -lole32 -lcomctl32 -loleaut32 -luuid -lgdi32
|
||||||
|
|
||||||
#cgo darwin CFLAGS: -DWEBVIEW_COCOA=1 -x objective-c
|
#cgo darwin CFLAGS: -DWEBVIEW_COCOA=1 -x objective-c
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ extern "C"
|
|||||||
#elif defined(WEBVIEW_WINAPI)
|
#elif defined(WEBVIEW_WINAPI)
|
||||||
#define CINTERFACE
|
#define CINTERFACE
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
#include <tchar.h>
|
||||||
|
|
||||||
#include <commctrl.h>
|
#include <commctrl.h>
|
||||||
#include <exdisp.h>
|
#include <exdisp.h>
|
||||||
@@ -1038,7 +1039,7 @@ struct webview_priv
|
|||||||
return S_FALSE;
|
return S_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const TCHAR *classname = "WebView";
|
static const TCHAR *classname = TEXT("WebView");
|
||||||
static const SAFEARRAYBOUND ArrayBound = {1, 0};
|
static const SAFEARRAYBOUND ArrayBound = {1, 0};
|
||||||
|
|
||||||
static IOleClientSiteVtbl MyIOleClientSiteTable = {
|
static IOleClientSiteVtbl MyIOleClientSiteTable = {
|
||||||
@@ -1227,7 +1228,7 @@ struct webview_priv
|
|||||||
}
|
}
|
||||||
VariantInit(&myURL);
|
VariantInit(&myURL);
|
||||||
myURL.vt = VT_BSTR;
|
myURL.vt = VT_BSTR;
|
||||||
#ifndef UNICODE
|
// #ifndef UNICODE
|
||||||
{
|
{
|
||||||
wchar_t *buffer = webview_to_utf16(webPageName);
|
wchar_t *buffer = webview_to_utf16(webPageName);
|
||||||
if (buffer == NULL)
|
if (buffer == NULL)
|
||||||
@@ -1237,9 +1238,9 @@ struct webview_priv
|
|||||||
myURL.bstrVal = SysAllocString(buffer);
|
myURL.bstrVal = SysAllocString(buffer);
|
||||||
GlobalFree(buffer);
|
GlobalFree(buffer);
|
||||||
}
|
}
|
||||||
#else
|
// #else
|
||||||
myURL.bstrVal = SysAllocString(webPageName);
|
// myURL.bstrVal = SysAllocString(webPageName);
|
||||||
#endif
|
// #endif
|
||||||
if (!myURL.bstrVal)
|
if (!myURL.bstrVal)
|
||||||
{
|
{
|
||||||
badalloc:
|
badalloc:
|
||||||
@@ -1277,7 +1278,7 @@ struct webview_priv
|
|||||||
if (!SafeArrayAccessData(sfArray, (void **)&pVar))
|
if (!SafeArrayAccessData(sfArray, (void **)&pVar))
|
||||||
{
|
{
|
||||||
pVar->vt = VT_BSTR;
|
pVar->vt = VT_BSTR;
|
||||||
#ifndef UNICODE
|
// #ifndef UNICODE
|
||||||
{
|
{
|
||||||
wchar_t *buffer = webview_to_utf16(url);
|
wchar_t *buffer = webview_to_utf16(url);
|
||||||
if (buffer == NULL)
|
if (buffer == NULL)
|
||||||
@@ -1287,9 +1288,9 @@ struct webview_priv
|
|||||||
bstr = SysAllocString(buffer);
|
bstr = SysAllocString(buffer);
|
||||||
GlobalFree(buffer);
|
GlobalFree(buffer);
|
||||||
}
|
}
|
||||||
#else
|
// #else
|
||||||
bstr = SysAllocString(string);
|
// bstr = SysAllocString(url);
|
||||||
#endif
|
// #endif
|
||||||
if ((pVar->bstrVal = bstr))
|
if ((pVar->bstrVal = bstr))
|
||||||
{
|
{
|
||||||
htmlDoc2->lpVtbl->write(htmlDoc2, sfArray);
|
htmlDoc2->lpVtbl->write(htmlDoc2, sfArray);
|
||||||
@@ -1350,8 +1351,8 @@ struct webview_priv
|
|||||||
}
|
}
|
||||||
|
|
||||||
#define WEBVIEW_KEY_FEATURE_BROWSER_EMULATION \
|
#define WEBVIEW_KEY_FEATURE_BROWSER_EMULATION \
|
||||||
"Software\\Microsoft\\Internet " \
|
_T("Software\\Microsoft\\Internet " \
|
||||||
"Explorer\\Main\\FeatureControl\\FEATURE_BROWSER_EMULATION"
|
"Explorer\\Main\\FeatureControl\\FEATURE_BROWSER_EMULATION")
|
||||||
|
|
||||||
static int webview_fix_ie_compat_mode()
|
static int webview_fix_ie_compat_mode()
|
||||||
{
|
{
|
||||||
@@ -1363,7 +1364,7 @@ struct webview_priv
|
|||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
for (p = &appname[strlen(appname) - 1]; p != appname && *p != '\\'; p--)
|
for (p = &appname[_tcslen(appname) - 1]; p != appname && *p != _T('\\'); p--)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
p++;
|
p++;
|
||||||
@@ -1404,6 +1405,7 @@ struct webview_priv
|
|||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ZeroMemory(&wc, sizeof(WNDCLASSEX));
|
ZeroMemory(&wc, sizeof(WNDCLASSEX));
|
||||||
wc.cbSize = sizeof(WNDCLASSEX);
|
wc.cbSize = sizeof(WNDCLASSEX);
|
||||||
wc.hInstance = hInstance;
|
wc.hInstance = hInstance;
|
||||||
@@ -1431,10 +1433,24 @@ struct webview_priv
|
|||||||
rect.bottom = rect.bottom - rect.top + top;
|
rect.bottom = rect.bottom - rect.top + top;
|
||||||
rect.top = top;
|
rect.top = top;
|
||||||
|
|
||||||
|
#ifdef UNICODE
|
||||||
|
wchar_t *u16title = webview_to_utf16(w->title);
|
||||||
|
if (u16title == NULL)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
w->priv.hwnd =
|
w->priv.hwnd =
|
||||||
|
CreateWindowEx(0, classname, u16title, style, rect.left, rect.top,
|
||||||
|
rect.right - rect.left, rect.bottom - rect.top,
|
||||||
|
HWND_DESKTOP, NULL, hInstance, (void *)w);
|
||||||
|
#else
|
||||||
|
w->priv.hwnd =
|
||||||
CreateWindowEx(0, classname, w->title, style, rect.left, rect.top,
|
CreateWindowEx(0, classname, w->title, style, rect.left, rect.top,
|
||||||
rect.right - rect.left, rect.bottom - rect.top,
|
rect.right - rect.left, rect.bottom - rect.top,
|
||||||
HWND_DESKTOP, NULL, hInstance, (void *)w);
|
HWND_DESKTOP, NULL, hInstance, (void *)w);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (w->priv.hwnd == 0)
|
if (w->priv.hwnd == 0)
|
||||||
{
|
{
|
||||||
OleUninitialize();
|
OleUninitialize();
|
||||||
@@ -1445,7 +1461,14 @@ struct webview_priv
|
|||||||
|
|
||||||
DisplayHTMLPage(w);
|
DisplayHTMLPage(w);
|
||||||
|
|
||||||
|
#ifdef UNICODE
|
||||||
|
SetWindowText(w->priv.hwnd, u16title);
|
||||||
|
GlobalFree(u16title);
|
||||||
|
#else
|
||||||
SetWindowText(w->priv.hwnd, w->title);
|
SetWindowText(w->priv.hwnd, w->title);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
ShowWindow(w->priv.hwnd, SW_SHOWDEFAULT);
|
ShowWindow(w->priv.hwnd, SW_SHOWDEFAULT);
|
||||||
UpdateWindow(w->priv.hwnd);
|
UpdateWindow(w->priv.hwnd);
|
||||||
SetFocus(w->priv.hwnd);
|
SetFocus(w->priv.hwnd);
|
||||||
@@ -1581,9 +1604,20 @@ struct webview_priv
|
|||||||
|
|
||||||
WEBVIEW_API void webview_set_title(struct webview *w, const char *title)
|
WEBVIEW_API void webview_set_title(struct webview *w, const char *title)
|
||||||
{
|
{
|
||||||
|
#ifdef UNICODE
|
||||||
|
wchar_t *u16title = webview_to_utf16(title);
|
||||||
|
if (u16title == NULL)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
SetWindowText(w->priv.hwnd, u16title);
|
||||||
|
GlobalFree(u16title);
|
||||||
|
#else
|
||||||
SetWindowText(w->priv.hwnd, title);
|
SetWindowText(w->priv.hwnd, title);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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)
|
||||||
@@ -1839,14 +1873,30 @@ struct webview_priv
|
|||||||
type |= MB_ICONERROR;
|
type |= MB_ICONERROR;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
#ifdef UNICODE
|
||||||
|
WCHAR *wtitle = webview_to_utf16(title);
|
||||||
|
WCHAR *warg = webview_to_utf16(arg);
|
||||||
|
MessageBox(w->priv.hwnd, warg, wtitle, type);
|
||||||
|
GlobalFree(warg);
|
||||||
|
GlobalFree(wtitle);
|
||||||
|
#else
|
||||||
MessageBox(w->priv.hwnd, arg, title, type);
|
MessageBox(w->priv.hwnd, arg, title, type);
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
WEBVIEW_API void webview_terminate(struct webview *w) { PostQuitMessage(0); }
|
WEBVIEW_API void webview_terminate(struct webview *w) { PostQuitMessage(0); }
|
||||||
WEBVIEW_API void webview_exit(struct webview *w) { OleUninitialize(); }
|
WEBVIEW_API void webview_exit(struct webview *w) { OleUninitialize(); }
|
||||||
WEBVIEW_API void webview_print_log(const char *s) { OutputDebugString(s); }
|
WEBVIEW_API void webview_print_log(const char *s) {
|
||||||
|
#ifdef UNICODE
|
||||||
|
WCHAR *ws = webview_to_utf16(s);
|
||||||
|
OutputDebugString(ws);
|
||||||
|
GlobalFree(ws);
|
||||||
|
#else
|
||||||
|
OutputDebugString(s);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* WEBVIEW_WINAPI */
|
#endif /* WEBVIEW_WINAPI */
|
||||||
|
|
||||||
|
|||||||
@@ -95,13 +95,6 @@ function startBridge() {
|
|||||||
window.wailsbridge.reconnectOverlay.style.display = 'none';
|
window.wailsbridge.reconnectOverlay.style.display = 'none';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bridge external.invoke
|
|
||||||
window.external = {
|
|
||||||
invoke: function (msg) {
|
|
||||||
window.wailsbridge.websocket.send(msg);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Adds a script to the Dom.
|
// Adds a script to the Dom.
|
||||||
// Removes it if second parameter is true.
|
// Removes it if second parameter is true.
|
||||||
function addScript(script, remove) {
|
function addScript(script, remove) {
|
||||||
@@ -211,6 +204,11 @@ function start(callback) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function Init(callback) {
|
function Init(callback) {
|
||||||
|
// Bridge window.invoke
|
||||||
|
window.invoke = function (message) {
|
||||||
|
window.wailsbridge.websocket.send(message);
|
||||||
|
}
|
||||||
|
|
||||||
start(callback);
|
start(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,18 +1 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><script src="https://raw.githubusercontent.com/firebug/firebug-lite/master/build/firebug-lite-debug.js#startOpened=true"></script></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>
|
||||||
<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>
|
|
||||||
10945
runtime/assets/firebug-lite.js
Normal file
10945
runtime/assets/firebug-lite.js
Normal file
File diff suppressed because one or more lines are too long
1
runtime/assets/injectFirebug.js
Normal file
1
runtime/assets/injectFirebug.js
Normal file
@@ -0,0 +1 @@
|
|||||||
|
(function(){console.log=function(message){document.body.innerHTML=document.body.innerHTML+'<p>'+message+'</p>';};var script=document.createElement('script');script.src="https://raw.githubusercontent.com/firebug/firebug-lite/master/build/firebug-lite-debug.js#startOpened=true";document.body.appendChild(script);})();
|
||||||
File diff suppressed because one or more lines are too long
@@ -15,10 +15,7 @@
|
|||||||
"error",
|
"error",
|
||||||
"tab"
|
"tab"
|
||||||
],
|
],
|
||||||
"linebreak-style": [
|
"linebreak-style": 0,
|
||||||
"error",
|
|
||||||
"unix"
|
|
||||||
],
|
|
||||||
"quotes": [
|
"quotes": [
|
||||||
"error",
|
"error",
|
||||||
"single"
|
"single"
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ module.exports = function (api) {
|
|||||||
[
|
[
|
||||||
"@babel/preset-env",
|
"@babel/preset-env",
|
||||||
{
|
{
|
||||||
"useBuiltIns": "entry",
|
"useBuiltIns": "usage",
|
||||||
"corejs": {
|
"corejs": {
|
||||||
"version": 3,
|
"version": 3,
|
||||||
"proposals": true
|
"proposals": true
|
||||||
@@ -16,7 +16,10 @@ module.exports = function (api) {
|
|||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const plugins = ["@babel/plugin-transform-object-assign", "transform-es2015-shorthand-properties"]
|
||||||
|
|
||||||
return {
|
return {
|
||||||
presets,
|
presets,
|
||||||
|
plugins
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
37
runtime/js/bridge/webpack.config.js
Normal file
37
runtime/js/bridge/webpack.config.js
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
/* eslint-disable */
|
||||||
|
|
||||||
|
const path = require('path');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
entry: './bridge.js',
|
||||||
|
mode: 'production',
|
||||||
|
output: {
|
||||||
|
path: path.resolve(__dirname, '..', 'assets'),
|
||||||
|
filename: 'bridge.js',
|
||||||
|
libraryTarget: 'this'
|
||||||
|
},
|
||||||
|
module: {
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
test: /\.m?js$/,
|
||||||
|
exclude: /(node_modules|bower_components)/,
|
||||||
|
use: {
|
||||||
|
loader: 'babel-loader',
|
||||||
|
options: {
|
||||||
|
plugins: [],
|
||||||
|
presets: [
|
||||||
|
[
|
||||||
|
'@babel/preset-env',
|
||||||
|
{
|
||||||
|
'useBuiltIns': 'usage',
|
||||||
|
'corejs': 3,
|
||||||
|
'targets': { "browsers": ["last 2 versions", "ie >= 9"] }
|
||||||
|
}
|
||||||
|
]
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -15,7 +15,11 @@ The lightweight framework for web-like apps
|
|||||||
* @param {string} message
|
* @param {string} message
|
||||||
*/
|
*/
|
||||||
function Invoke(message) {
|
function Invoke(message) {
|
||||||
window.external.invoke(message);
|
if ( window.wailsbridge ) {
|
||||||
|
window.wailsbridge.websocket.send(message);
|
||||||
|
} else {
|
||||||
|
window.external.invoke(message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
1838
runtime/js/package-lock.json
generated
1838
runtime/js/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -33,11 +33,15 @@
|
|||||||
"@babel/core": "^7.5.4",
|
"@babel/core": "^7.5.4",
|
||||||
"@babel/plugin-transform-object-assign": "^7.2.0",
|
"@babel/plugin-transform-object-assign": "^7.2.0",
|
||||||
"@babel/preset-env": "^7.5.4",
|
"@babel/preset-env": "^7.5.4",
|
||||||
|
"babel-core": "^6.26.3",
|
||||||
"babel-loader": "^8.0.6",
|
"babel-loader": "^8.0.6",
|
||||||
|
"babel-plugin-transform-es2015-shorthand-properties": "^6.24.1",
|
||||||
|
"babel-preset-es2015": "^6.24.1",
|
||||||
"babel-preset-minify": "^0.5.0",
|
"babel-preset-minify": "^0.5.0",
|
||||||
"core-js": "^3.1.4",
|
"core-js": "^3.1.4",
|
||||||
"eslint": "^6.5.1",
|
"eslint": "^6.5.1",
|
||||||
"webpack": "^4.35.3",
|
"webpack": "^4.41.2",
|
||||||
"webpack-cli": "^3.3.5"
|
"webpack-cli": "^3.3.5"
|
||||||
}
|
},
|
||||||
|
"dependencies": {}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,6 +32,6 @@ function OpenFile(filename) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
OpenURL,
|
OpenURL: OpenURL,
|
||||||
OpenFile
|
OpenFile: OpenFile
|
||||||
};
|
};
|
||||||
@@ -80,10 +80,10 @@ function Acknowledge(eventName) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
OnMultiple,
|
OnMultiple: OnMultiple,
|
||||||
On,
|
On: On,
|
||||||
Once,
|
Once: Once,
|
||||||
Emit,
|
Emit: Emit,
|
||||||
Heartbeat,
|
Heartbeat: Heartbeat,
|
||||||
Acknowledge
|
Acknowledge: Acknowledge
|
||||||
};
|
};
|
||||||
@@ -62,9 +62,9 @@ function Fatal(message) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
Debug,
|
Debug: Debug,
|
||||||
Info,
|
Info: Info,
|
||||||
Warning,
|
Warning: Warning,
|
||||||
Error,
|
Error: Error,
|
||||||
Fatal
|
Fatal: Fatal
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -15,8 +15,8 @@ const Events = require('./events');
|
|||||||
const Init = require('./init');
|
const Init = require('./init');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
Log,
|
Log: Log,
|
||||||
Browser,
|
Browser: Browser,
|
||||||
Events,
|
Events: Events,
|
||||||
Init
|
Init: Init
|
||||||
};
|
};
|
||||||
4322
runtime/js/runtime/package-lock.json
generated
Normal file
4322
runtime/js/runtime/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,11 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "@wailsapp/runtime",
|
"name": "@wailsapp/runtime",
|
||||||
"version": "1.0.6",
|
"version": "1.0.8",
|
||||||
"description": "Wails Javascript runtime library",
|
"description": "Wails Javascript runtime library",
|
||||||
"main": "main.js",
|
"main": "main.js",
|
||||||
"types": "runtime.d.ts",
|
"types": "runtime.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
"test": "echo \"Error: no test specified\" && exit 1",
|
||||||
|
"build": "webpack"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@@ -21,8 +22,18 @@
|
|||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/wailsapp/wails/issues"
|
"url": "https://github.com/wailsapp/wails/issues"
|
||||||
},
|
},
|
||||||
|
"files": [
|
||||||
|
"*.js",
|
||||||
|
"!webpack.config.js",
|
||||||
|
"runtime.d.ts",
|
||||||
|
"README.md"
|
||||||
|
],
|
||||||
"homepage": "https://github.com/wailsapp/wails#readme",
|
"homepage": "https://github.com/wailsapp/wails#readme",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"dts-gen": "^0.5.8"
|
"babel-core": "^6.26.3",
|
||||||
|
"babel-loader": "^8.0.6",
|
||||||
|
"babel-preset-es2015": "^6.24.1",
|
||||||
|
"dts-gen": "^0.5.8",
|
||||||
|
"webpack": "^4.41.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
37
runtime/js/runtime/webpack.config.js
Normal file
37
runtime/js/runtime/webpack.config.js
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
/* eslint-disable */
|
||||||
|
|
||||||
|
const path = require('path');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
entry: './main.js',
|
||||||
|
mode: 'production',
|
||||||
|
output: {
|
||||||
|
path: path.resolve(__dirname, 'dist'),
|
||||||
|
filename: 'main.js',
|
||||||
|
libraryTarget: 'this'
|
||||||
|
},
|
||||||
|
module: {
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
test: /\.m?js$/,
|
||||||
|
exclude: /(node_modules|bower_components)/,
|
||||||
|
use: {
|
||||||
|
loader: 'babel-loader',
|
||||||
|
options: {
|
||||||
|
plugins: [],
|
||||||
|
presets: [
|
||||||
|
[
|
||||||
|
'@babel/preset-env',
|
||||||
|
{
|
||||||
|
'useBuiltIns': 'usage',
|
||||||
|
'corejs': 3,
|
||||||
|
'targets': { "browsers": ["last 2 versions", "ie >= 9"] }
|
||||||
|
}
|
||||||
|
]
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -17,16 +17,14 @@ module.exports = {
|
|||||||
use: {
|
use: {
|
||||||
loader: 'babel-loader',
|
loader: 'babel-loader',
|
||||||
options: {
|
options: {
|
||||||
plugins: ['@babel/plugin-transform-object-assign'],
|
plugins: [],
|
||||||
presets: [
|
presets: [
|
||||||
[
|
[
|
||||||
'@babel/preset-env',
|
'@babel/preset-env',
|
||||||
{
|
{
|
||||||
'useBuiltIns': 'entry',
|
'useBuiltIns': 'usage',
|
||||||
'corejs': {
|
'corejs': 3,
|
||||||
'version': 3,
|
'targets': { "browsers": ["last 2 versions", "ie >= 9"] }
|
||||||
'proposals': true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
|||||||
82
scripts/build.go
Normal file
82
scripts/build.go
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"log"
|
||||||
|
"os"
|
||||||
|
"os/exec"
|
||||||
|
"path/filepath"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Default target to run when none is specified
|
||||||
|
// If not set, running mage will list available targets
|
||||||
|
// var Default = Build
|
||||||
|
|
||||||
|
/*
|
||||||
|
# Build runtime
|
||||||
|
echo "**** Building Runtime ****"
|
||||||
|
cd runtime/js
|
||||||
|
npm install
|
||||||
|
npm run build
|
||||||
|
cd ../..
|
||||||
|
|
||||||
|
echo "**** Packing Assets ****"
|
||||||
|
cd cmd
|
||||||
|
mewn
|
||||||
|
cd ..
|
||||||
|
cd lib/renderer
|
||||||
|
mewn
|
||||||
|
cd ../..
|
||||||
|
|
||||||
|
echo "**** Installing Wails locally ****"
|
||||||
|
cd cmd/wails
|
||||||
|
go install
|
||||||
|
cd ../..
|
||||||
|
|
||||||
|
echo "**** Tidying the mods! ****"
|
||||||
|
go mod tidy
|
||||||
|
|
||||||
|
echo "**** WE ARE DONE! ****"
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
func runCommand(command string, args ...string) {
|
||||||
|
cmd := exec.Command(command, args...)
|
||||||
|
output, err := cmd.CombinedOutput()
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
cmd.Run()
|
||||||
|
fmt.Println(string(output))
|
||||||
|
}
|
||||||
|
|
||||||
|
// A build step that requires additional params, or platform specific steps for example
|
||||||
|
func main() {
|
||||||
|
|
||||||
|
dir, _ := os.Getwd()
|
||||||
|
|
||||||
|
// Build Runtime
|
||||||
|
fmt.Println("**** Building Runtime ****")
|
||||||
|
runtimeDir, _ := filepath.Abs(filepath.Join(dir, "..", "runtime", "js"))
|
||||||
|
os.Chdir(runtimeDir)
|
||||||
|
runCommand("npm", "run", "build")
|
||||||
|
|
||||||
|
// Pack assets
|
||||||
|
fmt.Println("**** Packing Assets ****")
|
||||||
|
rendererDir, _ := filepath.Abs(filepath.Join(dir, "..", "lib", "renderer"))
|
||||||
|
os.Chdir(rendererDir)
|
||||||
|
runCommand("mewn")
|
||||||
|
cmdDir, _ := filepath.Abs(filepath.Join(dir, "..", "cmd"))
|
||||||
|
os.Chdir(cmdDir)
|
||||||
|
runCommand("mewn")
|
||||||
|
|
||||||
|
// Install Wails
|
||||||
|
fmt.Println("**** Installing Wails locally ****")
|
||||||
|
execDir, _ := filepath.Abs(filepath.Join(dir, "..", "cmd", "wails"))
|
||||||
|
os.Chdir(execDir)
|
||||||
|
runCommand("go", "install")
|
||||||
|
|
||||||
|
baseDir, _ := filepath.Abs(filepath.Join(dir, ".."))
|
||||||
|
os.Chdir(baseDir)
|
||||||
|
runCommand("go", "mod", "tidy")
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user