mirror of
https://github.com/wavetermdev/wails.git
synced 2026-04-22 15:26:15 -07:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9c4b412aea | |||
| 71b2edc0fe | |||
| 7661cd189f | |||
| 0833a6d6d3 | |||
| 7d851d8434 |
@@ -23,7 +23,7 @@ jobs:
|
||||
|
||||
- name: Install linux dependencies
|
||||
if: matrix.os == 'ubuntu-latest'
|
||||
run: sudo apt-get update -y && sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.0-dev javascriptcoregtk-4.1-dev build-essential pkg-config
|
||||
run: sudo apt-get update -y && sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.1-dev javascriptcoregtk-4.1-dev build-essential pkg-config
|
||||
|
||||
- name: Setup Go
|
||||
uses: actions/setup-go@v3
|
||||
@@ -122,7 +122,7 @@ jobs:
|
||||
|
||||
- name: Install linux dependencies
|
||||
if: matrix.os == 'ubuntu-latest'
|
||||
run: sudo apt-get update -y && sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.0-dev javascriptcoregtk-4.1-dev build-essential pkg-config
|
||||
run: sudo apt-get update -y && sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.1-dev javascriptcoregtk-4.1-dev build-essential pkg-config
|
||||
|
||||
- name: Build Wails3 CLI
|
||||
run: |
|
||||
|
||||
@@ -62,8 +62,12 @@ jobs:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Install linux dependencies
|
||||
if: matrix.os == 'ubuntu-latest'
|
||||
- name: Install linux dependencies (v3)
|
||||
if: ${{ matrix.os == 'ubuntu-latest' && github.event.pull_request.base.ref == 'v3-alpha' }}
|
||||
run: sudo apt-get update -y && sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.1-dev build-essential pkg-config
|
||||
|
||||
- name: Install linux dependencies (v2)
|
||||
if: ${{ matrix.os == 'ubuntu-latest' && github.event.pull_request.base.ref == 'master' }}
|
||||
run: sudo apt-get update -y && sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.0-dev build-essential pkg-config
|
||||
|
||||
- name: Setup Go
|
||||
|
||||
@@ -37,6 +37,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed react template css to show footer by [atterpac](https://github.com/atterpac) in [#3477](https://github.com/wailsapp/wails/pull/3477)
|
||||
- Fixed zombie processes when working in devmode by updating to latest refresh by [Atterpac](https://github.com/atterpac) in [#3320](https://github.com/wailsapp/wails/pull/3320).
|
||||
- Fixed appimage webkit file sourcing by [Atterpac](https://github.com/atterpac) in [#3306](https://github.com/wailsapp/wails/pull/3306).
|
||||
- Fixed Doctor apt package verify by [Atterpac](https://github.com/Atterpac) in [#2972](https://github.com/wailsapp/wails/pull/2972).
|
||||
@@ -64,9 +65,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- Fix registering events causing a nil map assignment by [@hfoxy](https://github.com/hfoxy) in [#3426](https://github.com/wailsapp/wails/pull/3426)
|
||||
- Fix unmarshaling of bound method parameters by [@fbbdev](https://github.com/fbbdev) in [#3431](https://github.com/wailsapp/wails/pull/3431)
|
||||
- Fix handling of multiple return values from bound methods by [@fbbdev](https://github.com/fbbdev) in [#3431](https://github.com/wailsapp/wails/pull/3431)
|
||||
- Fix doctor detection of npm that is not installed with system package manager by [@pekim](https://github.com/pekim) in [#3458](https://github.com/wailsapp/wails/pull/3458)
|
||||
|
||||
### Changed
|
||||
|
||||
- Update linux webkit dependency to webkit2gtk-4.1 over webkitgtk2-4.0 to support Ubuntu 24.04 LTS by [atterpac](https://github.com/atterpac) in [#3461](https://github.com/wailsapp/wails/pull/3461)
|
||||
- The bundled JS runtime script is now an ESM module: script tags importing it must have the `type="module"` attribute. By [@fbbdev](https://github.com/fbbdev) in [#3295](https://github.com/wailsapp/wails/pull/3295)
|
||||
- The `@wailsio/runtime` package does not publish its API on the `window.wails` object, and does not start the WML system. This has been done to improve encapsulation. The WML system can be started manually if desired by calling the new `WML.Enable` method. The bundled JS runtime script still performs both operations automatically. By [@fbbdev](https://github.com/fbbdev) in [#3295](https://github.com/wailsapp/wails/pull/3295)
|
||||
- The Window API module `@wailsio/runtime/src/window` now exposes the containing window object as a default export. It is not possible anymore to import individual methods through ESM named or namespace import syntax.
|
||||
|
||||
@@ -1,26 +1,17 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/wailsapp/wails/v3/pkg/application"
|
||||
)
|
||||
import "github.com/wailsapp/wails/v3/examples/binding/data"
|
||||
|
||||
// GreetService is a service that greets people
|
||||
type GreetService struct {
|
||||
}
|
||||
|
||||
// Greet greets a person
|
||||
func (*GreetService) Greet(win application.Window, name string) string {
|
||||
return "Hello " + name + " on " + win.Name()
|
||||
func (*GreetService) Greet(name string) string {
|
||||
return "Hello " + name
|
||||
}
|
||||
|
||||
// GreetWithCtx greets a person
|
||||
func (*GreetService) GreetWithCtx(ctx context.Context, name string) string {
|
||||
win := ctx.Value("window").(application.Window)
|
||||
return "[ctx] Hello " + name + " on " + win.Name()
|
||||
}
|
||||
|
||||
// GreetWithCtx greets a person
|
||||
func (*GreetService) GreetWithBoth(_ context.Context, win application.Window, name string) string {
|
||||
return "[ctx+win] Hello " + name + " on " + win.Name()
|
||||
// GreetPerson greets a person
|
||||
func (*GreetService) GreetPerson(person data.Person) string {
|
||||
return "Hello " + person.Name
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
// @ts-check
|
||||
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Ă‚ MODIWL
|
||||
// This file is automatically generated. DO NOT EDIT
|
||||
|
||||
// Person holds someone's most important attributes
|
||||
export const Person = class {
|
||||
/**
|
||||
* Creates a new Person instance.
|
||||
* @constructor
|
||||
* @param {Object} source - The source object to create the Person.
|
||||
* @param {string} source.Name
|
||||
*/
|
||||
constructor(source = {}) {
|
||||
const { name = "" } = source;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new Person instance from a string or object.
|
||||
* @param {string|object} source - The source data to create a Person instance from.
|
||||
* @returns {Person} A new Person instance.
|
||||
*/
|
||||
static createFrom(source) {
|
||||
let parsedSource = typeof source === 'string' ? JSON.parse(source) : source;
|
||||
return new Person(parsedSource);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -19,20 +19,10 @@ export async function Greet(name) {
|
||||
|
||||
/**
|
||||
* GreetPerson greets a person
|
||||
* @function GreetWithCtx
|
||||
* @param name {string}
|
||||
* @function GreetPerson
|
||||
* @param person {dataPerson}
|
||||
* @returns {Promise<string>}
|
||||
**/
|
||||
export async function GreetWithCtx(name) {
|
||||
return Call.ByName("main.GreetService.GreetWithCtx", ...Array.prototype.slice.call(arguments, 0));
|
||||
}
|
||||
|
||||
/**
|
||||
* GreetPerson greets a person
|
||||
* @function GreetWithBoth
|
||||
* @param name {string}
|
||||
* @returns {Promise<string>}
|
||||
**/
|
||||
export async function GreetWithBoth(name) {
|
||||
return Call.ByName("main.GreetService.GreetWithBoth", ...Array.prototype.slice.call(arguments, 0));
|
||||
export async function GreetPerson(person) {
|
||||
return Call.ByName("main.GreetService.GreetPerson", ...Array.prototype.slice.call(arguments, 0));
|
||||
}
|
||||
|
||||
@@ -83,19 +83,9 @@
|
||||
<script type="module">
|
||||
import * as GreetService from "./bindings/main/GreetService.js";
|
||||
|
||||
let state = 0;
|
||||
async function greet() {
|
||||
if(state % 3 === 0) {
|
||||
document.getElementById("result").innerHTML =
|
||||
await GreetService.Greet(document.getElementById("name").value);
|
||||
} else if(state % 3 === 1) {
|
||||
document.getElementById("result").innerHTML =
|
||||
await GreetService.GreetWithCtx(document.getElementById("name").value);
|
||||
} else {
|
||||
document.getElementById("result").innerHTML =
|
||||
await GreetService.GreetWithBoth(document.getElementById("name").value);
|
||||
}
|
||||
state++;
|
||||
document.getElementById("result").innerHTML =
|
||||
await GreetService.Greet(document.getElementById("name").value);
|
||||
}
|
||||
|
||||
document.getElementById("greet-btn").onclick = greet;
|
||||
|
||||
@@ -26,8 +26,6 @@ func main() {
|
||||
|
||||
app.NewWebviewWindowWithOptions(application.WebviewWindowOptions{
|
||||
URL: "/",
|
||||
Name: "Window 1",
|
||||
Title: "Window 1",
|
||||
DevToolsEnabled: true,
|
||||
})
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
module github.com/wailsapp/wails/v3
|
||||
|
||||
go 1.21
|
||||
go 1.22
|
||||
|
||||
require (
|
||||
github.com/atterpac/refresh v0.8.0
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
package webview
|
||||
|
||||
/*
|
||||
#cgo linux pkg-config: gtk+-3.0 webkit2gtk-4.0 gio-unix-2.0
|
||||
#cgo linux pkg-config: gtk+-3.0 webkit2gtk-4.1 gio-unix-2.0
|
||||
|
||||
#include "gtk/gtk.h"
|
||||
#include "webkit2/webkit2.h"
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
package webview
|
||||
|
||||
/*
|
||||
#cgo linux pkg-config: gtk+-3.0 webkit2gtk-4.0 gio-unix-2.0
|
||||
#cgo linux pkg-config: gtk+-3.0 webkit2gtk-4.1 gio-unix-2.0
|
||||
|
||||
#include "gtk/gtk.h"
|
||||
#include "webkit2/webkit2.h"
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
package webview
|
||||
|
||||
/*
|
||||
#cgo linux pkg-config: gtk+-3.0 webkit2gtk-4.0 libsoup-2.4
|
||||
#cgo linux pkg-config: gtk+-3.0 webkit2gtk-4.1 libsoup-3.0
|
||||
|
||||
#include "gtk/gtk.h"
|
||||
#include "webkit2/webkit2.h"
|
||||
|
||||
@@ -23,6 +23,8 @@ func checkCommonDependencies(result map[string]string, ok *bool) {
|
||||
if major < 7 {
|
||||
*ok = false
|
||||
npmVersion = append(npmVersion, []byte(". Installed, but requires npm >= 7.0.0")...)
|
||||
} else {
|
||||
*ok = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package operatingsystem
|
||||
|
||||
/*
|
||||
#cgo linux pkg-config: gtk+-3.0 webkit2gtk-4.0
|
||||
#cgo linux pkg-config: gtk+-3.0 webkit2gtk-4.1
|
||||
#include <webkit2/webkit2.h>
|
||||
*/
|
||||
import "C"
|
||||
|
||||
@@ -114,7 +114,6 @@ h1 {
|
||||
margin-top: 1rem;
|
||||
align-content: center;
|
||||
text-align: center;
|
||||
color: rgba(255, 255, 255, 0.67);
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: light) {
|
||||
@@ -158,4 +157,4 @@ h1 {
|
||||
.input-box .input:focus {
|
||||
border: none;
|
||||
background-color: rgba(255, 255, 255, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,7 +114,6 @@ h1 {
|
||||
margin-top: 1rem;
|
||||
align-content: center;
|
||||
text-align: center;
|
||||
color: rgba(255, 255, 255, 0.67);
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: light) {
|
||||
@@ -158,4 +157,4 @@ h1 {
|
||||
.input-box .input:focus {
|
||||
border: none;
|
||||
background-color: rgba(255, 255, 255, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,7 +114,6 @@ h1 {
|
||||
margin-top: 1rem;
|
||||
align-content: center;
|
||||
text-align: center;
|
||||
color: rgba(255, 255, 255, 0.67);
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: light) {
|
||||
@@ -158,4 +157,4 @@ h1 {
|
||||
.input-box .input:focus {
|
||||
border: none;
|
||||
background-color: rgba(255, 255, 255, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,7 +114,6 @@ h1 {
|
||||
margin-top: 1rem;
|
||||
align-content: center;
|
||||
text-align: center;
|
||||
color: rgba(255, 255, 255, 0.67);
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: light) {
|
||||
@@ -158,4 +157,4 @@ h1 {
|
||||
.input-box .input:focus {
|
||||
border: none;
|
||||
background-color: rgba(255, 255, 255, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -308,7 +308,7 @@ func (b *Bindings) getMethods(value interface{}, isPlugin bool) ([]*BoundMethod,
|
||||
var errorType = reflect.TypeFor[error]()
|
||||
|
||||
// Call will attempt to call this bound method with the given args
|
||||
func (b *BoundMethod) Call(ctx context.Context, window Window, args []json.RawMessage) (returnValue interface{}, err error) {
|
||||
func (b *BoundMethod) Call(ctx context.Context, args []json.RawMessage) (returnValue interface{}, err error) {
|
||||
// Use a defer statement to capture panics
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
@@ -333,8 +333,14 @@ func (b *BoundMethod) Call(ctx context.Context, window Window, args []json.RawMe
|
||||
argCount++
|
||||
}
|
||||
|
||||
if argCount != len(b.Inputs) {
|
||||
err = fmt.Errorf("%s expects %d arguments, received %d", b.Name, len(b.Inputs), argCount)
|
||||
return
|
||||
}
|
||||
|
||||
// Convert inputs to values of appropriate type
|
||||
callArgs := make([]reflect.Value, len(b.Inputs))
|
||||
|
||||
callArgs := make([]reflect.Value, argCount)
|
||||
base := 0
|
||||
|
||||
if b.needsContext {
|
||||
@@ -342,23 +348,6 @@ func (b *BoundMethod) Call(ctx context.Context, window Window, args []json.RawMe
|
||||
base++
|
||||
}
|
||||
|
||||
firstArgIsWindow := len(b.Inputs) > 0 && b.Inputs[0].ReflectType == reflect.TypeFor[Window]()
|
||||
secondArgIsWindow := len(b.Inputs) > 1 && b.Inputs[1].ReflectType == reflect.TypeFor[Window]()
|
||||
if secondArgIsWindow && !b.needsContext {
|
||||
return nil, fmt.Errorf("second argument is a Window but first argument is not a context")
|
||||
}
|
||||
if firstArgIsWindow || (b.needsContext && secondArgIsWindow) {
|
||||
// Create a reflect.Value from the window interface
|
||||
callArgs[base] = reflect.ValueOf(window)
|
||||
base++
|
||||
argCount++
|
||||
}
|
||||
|
||||
if argCount != len(b.Inputs) {
|
||||
err = fmt.Errorf("%s expects %d arguments, received %d", b.Name, len(b.Inputs), argCount)
|
||||
return
|
||||
}
|
||||
|
||||
// Iterate over given arguments
|
||||
for index, arg := range args {
|
||||
value := reflect.New(b.Inputs[base+index].ReflectType)
|
||||
|
||||
@@ -52,27 +52,6 @@ func (t *TestService) Slice(a []int) []int {
|
||||
return a
|
||||
}
|
||||
|
||||
func (t *TestService) WithWindow(window application.Window, s string) string {
|
||||
_ = window
|
||||
return s
|
||||
}
|
||||
|
||||
func (t *TestService) WithContext(ctx context.Context, s string) string {
|
||||
_ = ctx
|
||||
return s
|
||||
}
|
||||
|
||||
func (t *TestService) WithContextAndWindow(ctx context.Context, window application.Window, s string) string {
|
||||
_ = ctx
|
||||
_ = window
|
||||
return s
|
||||
}
|
||||
|
||||
func (t *TestService) WithBadWindow(s string, window application.Window) string {
|
||||
_ = window
|
||||
return s
|
||||
}
|
||||
|
||||
func newArgs(jsonArgs ...string) []json.RawMessage {
|
||||
args := []json.RawMessage{}
|
||||
|
||||
@@ -85,12 +64,11 @@ func newArgs(jsonArgs ...string) []json.RawMessage {
|
||||
func TestBoundMethodCall(t *testing.T) {
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
method string
|
||||
args []json.RawMessage
|
||||
wantWindow bool
|
||||
err error
|
||||
expected interface{}
|
||||
name string
|
||||
method string
|
||||
args []json.RawMessage
|
||||
err error
|
||||
expected interface{}
|
||||
}{
|
||||
{
|
||||
name: "nil",
|
||||
@@ -176,41 +154,10 @@ func TestBoundMethodCall(t *testing.T) {
|
||||
err: nil,
|
||||
expected: []int{1, 2, 3},
|
||||
},
|
||||
{
|
||||
name: "with window",
|
||||
method: "WithWindow",
|
||||
args: newArgs(`"foo"`),
|
||||
wantWindow: true,
|
||||
err: nil,
|
||||
expected: "foo",
|
||||
},
|
||||
{
|
||||
name: "with context",
|
||||
method: "WithContext",
|
||||
args: newArgs(`"foo"`),
|
||||
err: nil,
|
||||
expected: "foo",
|
||||
},
|
||||
{
|
||||
name: "with context and window",
|
||||
method: "WithContextAndWindow",
|
||||
args: newArgs(`"foo"`),
|
||||
wantWindow: true,
|
||||
err: nil,
|
||||
expected: "foo",
|
||||
},
|
||||
{
|
||||
name: "with bad window",
|
||||
method: "WithBadWindow",
|
||||
args: newArgs(`"foo"`),
|
||||
wantWindow: true,
|
||||
err: errors.New("second argument is a Window but first argument is not a context"),
|
||||
expected: nil,
|
||||
},
|
||||
}
|
||||
|
||||
// init globalApplication
|
||||
app := application.New(application.Options{})
|
||||
_ = application.New(application.Options{})
|
||||
|
||||
bindings, err := application.NewBindings(
|
||||
[]any{
|
||||
@@ -233,12 +180,8 @@ func TestBoundMethodCall(t *testing.T) {
|
||||
if method == nil {
|
||||
t.Fatalf("bound method not found: %s", callOptions.Name())
|
||||
}
|
||||
var window application.Window
|
||||
if tt.wantWindow {
|
||||
window = app.NewWebviewWindow()
|
||||
}
|
||||
|
||||
result, err := method.Call(context.TODO(), window, tt.args)
|
||||
result, err := method.Call(context.TODO(), tt.args)
|
||||
if tt.err != err && (tt.err == nil || err == nil || !strings.Contains(err.Error(), tt.err.Error())) {
|
||||
t.Fatalf("error: %v, expected error: %v", err, tt.err)
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user