Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/src/content/docs/changelog.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Add `//wails:ignore` directive to prevent binding generation for chosen service methods by [@fbbdev](https://github.com/fbbdev) in [#4045](https://github.com/wailsapp/wails/pull/4045)
- Add `//wails:internal` directive on services and models to allow for types that are exported in Go but not in JS/TS by [@fbbdev](https://github.com/fbbdev) in [#4045](https://github.com/wailsapp/wails/pull/4045)
- Add binding generator support for constants of alias type to allow for weakly typed enums by [@fbbdev](https://github.com/fbbdev) in [#4045](https://github.com/wailsapp/wails/pull/4045)
- Add binding generator tests for Go 1.24 features by [@fbbdev](https://github.com/fbbdev) in [#4068](https://github.com/wailsapp/wails/pull/4068)
- Add support for macOS 15 "Sequoia" to `OSInfo.Branding` for improved OS version detection in [#4065](https://github.com/wailsapp/wails/pull/4065)
- Add `PostShutdown` hook for running custom code after the shutdown process completes by [@fbbdev](https://github.com/fbbdev) in [#4066](https://github.com/wailsapp/wails/pull/4066)
- Add `FatalError` struct to support detection of fatal errors in custom error handlers by [@fbbdev](https://github.com/fbbdev) in [#4066](https://github.com/wailsapp/wails/pull/4066)
Expand Down
45 changes: 23 additions & 22 deletions v3/internal/generator/testcases/aliases/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
_ "embed"
"encoding"
"log"

nobindingshere "github.com/wailsapp/wails/v3/internal/generator/testcases/no_bindings_here"
Expand Down Expand Up @@ -54,37 +55,37 @@ type GenericPerson[T any] struct {
type StrangelyAliasedPerson = Person

// A generic alias that forwards to a type parameter.
// type GenericAlias[T any] = T
type GenericAlias[T any] = T

// A generic alias that wraps a pointer type.
// type GenericPtrAlias[T any] = *GenericAlias[T]
type GenericPtrAlias[T any] = *GenericAlias[T]

// A generic alias that wraps a map.
// type GenericMapAlias[T interface {
// comparable
// encoding.TextMarshaler
// }, U any] = map[T]U
type GenericMapAlias[T interface {
comparable
encoding.TextMarshaler
}, U any] = map[T]U

// A generic alias that wraps a generic struct.
// type GenericPersonAlias[T any] = GenericPerson[[]GenericPtrAlias[T]]
type GenericPersonAlias[T any] = GenericPerson[[]GenericPtrAlias[T]]

// An alias that wraps a class through a non-typeparam alias.
// type IndirectPersonAlias = GenericPersonAlias[bool]
type IndirectPersonAlias = GenericPersonAlias[bool]

// An alias that wraps a class through a typeparam alias.
// type TPIndirectPersonAlias = GenericAlias[GenericPerson[bool]]
type TPIndirectPersonAlias = GenericAlias[GenericPerson[bool]]

// A class whose fields have various aliased types.
// type AliasGroup struct {
// GAi GenericAlias[int]
// GAP GenericAlias[GenericPerson[bool]]
// GPAs GenericPtrAlias[[]string]
// GPAP GenericPtrAlias[GenericPerson[[]int]]
// GMA GenericMapAlias[struct{ encoding.TextMarshaler }, float32]
// GPA GenericPersonAlias[bool]
// IPA IndirectPersonAlias
// TPIPA TPIndirectPersonAlias
// }
type AliasGroup struct {
GAi GenericAlias[int]
GAP GenericAlias[GenericPerson[bool]]
GPAs GenericPtrAlias[[]string]
GPAP GenericPtrAlias[GenericPerson[[]int]]
GMA GenericMapAlias[struct{ encoding.TextMarshaler }, float32]
GPA GenericPersonAlias[bool]
IPA IndirectPersonAlias
TPIPA TPIndirectPersonAlias
}

// Get someone.
func (GreetService) Get(aliasValue Alias) Person {
Expand All @@ -105,9 +106,9 @@ func (GreetService) GetButForeignPrivateAlias() (_ nobindingshere.PrivatePerson)
return
}

// func (GreetService) GetButGenericAliases() (_ AliasGroup) {
// return
// }
func (GreetService) GetButGenericAliases() (_ AliasGroup) {
return
}

// Greet a lot of unusual things.
func (GreetService) Greet(EmptyAliasStruct, EmptyStruct) AliasStruct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,7 @@
".Service11",
".Service12",
".Service13",
".Service14",
".Service15",
"/other.Service16"
]
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type Service13 struct{}
type Service14 struct{}
type Service15 struct{}

// type SimplifiedFactory[T any] = Factory[T, Service15]
type SimplifiedFactory[T any] = Factory[T, Service15]

func main() {
factory := NewFactory[Service1, Service2]()
Expand All @@ -42,7 +42,7 @@ func main() {
other.CustomNewService(Service7{}),
other.ServiceInitialiser[Service8]()(&Service8{}),
application.NewServiceWithOptions(&Service13{}, application.ServiceOptions{Name: "custom name"}),
// SimplifiedFactory[Service14]{}.Get(),
SimplifiedFactory[Service14]{}.Get(),
other.LocalService,
},
CustomNewServices[Service9, Service10]()...),
Expand Down
2 changes: 1 addition & 1 deletion v3/internal/generator/testcases/complex_json/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ type Embedded3 string
// Person represents a person
type Person struct {
// Titles is optional in JSON
Titles []Title `json:",omitempty"`
Titles []Title `json:",omitzero"`
Comment thread
leaanthony marked this conversation as resolved.

// Names has a
// multiline comment
Expand Down
150 changes: 75 additions & 75 deletions v3/internal/generator/testcases/map_keys/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,24 +106,24 @@ type InterfacePtrType *encoding.TextMarshaler
type InterfaceAlias = encoding.TextMarshaler
type InterfacePtrAlias = *encoding.TextMarshaler

// type ComparableCstrAlias[R comparable] = R
// type ComparableCstrPtrAlias[R comparable] = *R
// type BasicCstrAlias[S BasicConstraint] = S
// type BasicCstrPtrAlias[S BasicConstraint] = *S
// type BadTildeCstrAlias[T BadTildeConstraint] = T
// type BadTildeCstrPtrAlias[T BadTildeConstraint] = *T
// type GoodTildeCstrAlias[U GoodTildeConstraint] = U
// type GoodTildeCstrPtrAlias[U GoodTildeConstraint] = *U
// type NonBasicCstrAlias[V NonBasicConstraint] = V
// type NonBasicCstrPtrAlias[V NonBasicConstraint] = *V
// type PointableCstrAlias[W PointableConstraint] = W
// type PointableCstrPtrAlias[W PointableConstraint] = *W
// type MixedCstrAlias[X MixedConstraint] = X
// type MixedCstrPtrAlias[X MixedConstraint] = *X
// type InterfaceCstrAlias[Y InterfaceConstraint] = Y
// type InterfaceCstrPtrAlias[Y InterfaceConstraint] = *Y
// type PointerCstrAlias[R comparable, Z PointerConstraint[R]] = Z
// type PointerCstrPtrAlias[R comparable, Z PointerConstraint[R]] = *Z
type ComparableCstrAlias[R comparable] = R
type ComparableCstrPtrAlias[R comparable] = *R
type BasicCstrAlias[S BasicConstraint] = S
type BasicCstrPtrAlias[S BasicConstraint] = *S
type BadTildeCstrAlias[T BadTildeConstraint] = T
type BadTildeCstrPtrAlias[T BadTildeConstraint] = *T
type GoodTildeCstrAlias[U GoodTildeConstraint] = U
type GoodTildeCstrPtrAlias[U GoodTildeConstraint] = *U
type NonBasicCstrAlias[V NonBasicConstraint] = V
type NonBasicCstrPtrAlias[V NonBasicConstraint] = *V
type PointableCstrAlias[W PointableConstraint] = W
type PointableCstrPtrAlias[W PointableConstraint] = *W
type MixedCstrAlias[X MixedConstraint] = X
type MixedCstrPtrAlias[X MixedConstraint] = *X
type InterfaceCstrAlias[Y InterfaceConstraint] = Y
type InterfaceCstrPtrAlias[Y InterfaceConstraint] = *Y
type PointerCstrAlias[R comparable, Z PointerConstraint[R]] = Z
type PointerCstrPtrAlias[R comparable, Z PointerConstraint[R]] = *Z

type Maps[R comparable, S BasicConstraint, T BadTildeConstraint, U GoodTildeConstraint, V NonBasicConstraint, W PointableConstraint, X MixedConstraint, Y InterfaceConstraint, Z PointerConstraint[R]] struct {
Bool map[bool]int // Reject
Expand Down Expand Up @@ -226,63 +226,63 @@ type Maps[R comparable, S BasicConstraint, T BadTildeConstraint, U GoodTildeCons
TPZ map[Z]int // Accept, hide
TPZPtr map[*Z]int // Soft reject

// GAR map[ComparableCstrAlias[R]]int // Soft reject
// GARPtr map[ComparableCstrPtrAlias[R]]int // Soft reject
// GAS map[BasicCstrAlias[S]]int // Accept, hide
// GASPtr map[BasicCstrPtrAlias[S]]int // Soft reject
// GAT map[BadTildeCstrAlias[T]]int // Soft reject
// GATPtr map[BadTildeCstrPtrAlias[T]]int // Soft reject
// GAU map[GoodTildeCstrAlias[U]]int // Accept, hide
// GAUPtr map[GoodTildeCstrPtrAlias[U]]int // Soft reject
// GAV map[NonBasicCstrAlias[V]]int // Accept, hide
// GAVPtr map[NonBasicCstrPtrAlias[V]]int // Soft reject
// GAW map[PointableCstrAlias[W]]int // Soft reject
// GAWPtr map[PointableCstrPtrAlias[W]]int // Accept, hide
// GAX map[MixedCstrAlias[X]]int // Accept, hide
// GAXPtr map[MixedCstrPtrAlias[X]]int // Soft reject
// GAY map[InterfaceCstrAlias[Y]]int // Accept, hide
// GAYPtr map[InterfaceCstrPtrAlias[Y]]int // Soft reject
// GAZ map[PointerCstrAlias[R, Z]]int // Accept, hide
// GAZPtr map[PointerCstrPtrAlias[R, Z]]int // Soft reject

// GACi map[ComparableCstrAlias[int]]int // Accept, hide
// GACV map[ComparableCstrAlias[ValueTextMarshaler]]int // Accept
// GACP map[ComparableCstrAlias[PointerTextMarshaler]]int // Reject
// GACiPtr map[ComparableCstrPtrAlias[int]]int // Reject
// GACVPtr map[ComparableCstrPtrAlias[ValueTextMarshaler]]int // Accept, hide
// GACPPtr map[ComparableCstrPtrAlias[PointerTextMarshaler]]int // Accept, hide
// GABi map[BasicCstrAlias[int]]int // Accept, hide
// GABs map[BasicCstrAlias[string]]int // Accept
// GABiPtr map[BasicCstrPtrAlias[int]]int // Reject
// GABT map[BadTildeCstrAlias[struct{}]]int // Reject
// GABTPtr map[BadTildeCstrPtrAlias[struct{}]]int // Reject
// GAGT map[GoodTildeCstrAlias[ValueTextMarshaler]]int // Accept
// GAGTPtr map[GoodTildeCstrPtrAlias[ValueTextMarshaler]]int // Accept, hide
// GANBV map[NonBasicCstrAlias[ValueTextMarshaler]]int // Accept
// GANBP map[NonBasicCstrAlias[*PointerTextMarshaler]]int // Accept, hide
// GANBVPtr map[NonBasicCstrPtrAlias[ValueTextMarshaler]]int // Accept, hide
// GANBPPtr map[NonBasicCstrPtrAlias[*PointerTextMarshaler]]int // Reject
// GAPlV1 map[PointableCstrAlias[ValueTextMarshaler]]int // Accept
// GAPlV2 map[*PointableCstrAlias[ValueTextMarshaler]]int // Accept
// GAPlP1 map[PointableCstrAlias[PointerTextMarshaler]]int // Reject
// GAPlP2 map[*PointableCstrAlias[PointerTextMarshaler]]int // Accept
// GAPlVPtr map[PointableCstrPtrAlias[ValueTextMarshaler]]int // Accept, hide
// GAPlPPtr map[PointableCstrPtrAlias[PointerTextMarshaler]]int // Accept, hide
// GAMi map[MixedCstrAlias[uint]]int // Accept, hide
// GAMS map[MixedCstrAlias[StringType]]int // Accept
// GAMV map[MixedCstrAlias[ValueTextMarshaler]]int // Accept
// GAMSPtr map[MixedCstrPtrAlias[StringType]]int // Reject
// GAMVPtr map[MixedCstrPtrAlias[ValueTextMarshaler]]int // Accept, hide
// GAII map[InterfaceCstrAlias[encoding.TextMarshaler]]int // Accept, hide
// GAIV map[InterfaceCstrAlias[ValueTextMarshaler]]int // Accept
// GAIP map[InterfaceCstrAlias[*PointerTextMarshaler]]int // Accept, hide
// GAIIPtr map[InterfaceCstrPtrAlias[encoding.TextMarshaler]]int // Reject
// GAIVPtr map[InterfaceCstrPtrAlias[ValueTextMarshaler]]int // Accept, hide
// GAIPPtr map[InterfaceCstrPtrAlias[*PointerTextMarshaler]]int // Reject
// GAPrV map[PointerCstrAlias[ValueTextMarshaler, *ValueTextMarshaler]]int // Accept, hide
// GAPrP map[PointerCstrAlias[PointerTextMarshaler, *PointerTextMarshaler]]int // Accept, hide
// GAPrVPtr map[PointerCstrPtrAlias[ValueTextMarshaler, *ValueTextMarshaler]]int // Reject
// GAPrPPtr map[PointerCstrPtrAlias[PointerTextMarshaler, *PointerTextMarshaler]]int // Reject
GAR map[ComparableCstrAlias[R]]int // Soft reject
GARPtr map[ComparableCstrPtrAlias[R]]int // Soft reject
GAS map[BasicCstrAlias[S]]int // Accept, hide
GASPtr map[BasicCstrPtrAlias[S]]int // Soft reject
GAT map[BadTildeCstrAlias[T]]int // Soft reject
GATPtr map[BadTildeCstrPtrAlias[T]]int // Soft reject
GAU map[GoodTildeCstrAlias[U]]int // Accept, hide
GAUPtr map[GoodTildeCstrPtrAlias[U]]int // Soft reject
GAV map[NonBasicCstrAlias[V]]int // Accept, hide
GAVPtr map[NonBasicCstrPtrAlias[V]]int // Soft reject
GAW map[PointableCstrAlias[W]]int // Soft reject
GAWPtr map[PointableCstrPtrAlias[W]]int // Accept, hide
GAX map[MixedCstrAlias[X]]int // Accept, hide
GAXPtr map[MixedCstrPtrAlias[X]]int // Soft reject
GAY map[InterfaceCstrAlias[Y]]int // Accept, hide
GAYPtr map[InterfaceCstrPtrAlias[Y]]int // Soft reject
GAZ map[PointerCstrAlias[R, Z]]int // Accept, hide
GAZPtr map[PointerCstrPtrAlias[R, Z]]int // Soft reject

GACi map[ComparableCstrAlias[int]]int // Accept, hide
GACV map[ComparableCstrAlias[ValueTextMarshaler]]int // Accept
GACP map[ComparableCstrAlias[PointerTextMarshaler]]int // Reject
GACiPtr map[ComparableCstrPtrAlias[int]]int // Reject
GACVPtr map[ComparableCstrPtrAlias[ValueTextMarshaler]]int // Accept, hide
GACPPtr map[ComparableCstrPtrAlias[PointerTextMarshaler]]int // Accept, hide
GABi map[BasicCstrAlias[int]]int // Accept, hide
GABs map[BasicCstrAlias[string]]int // Accept
GABiPtr map[BasicCstrPtrAlias[int]]int // Reject
GABT map[BadTildeCstrAlias[struct{}]]int // Reject
GABTPtr map[BadTildeCstrPtrAlias[struct{}]]int // Reject
GAGT map[GoodTildeCstrAlias[ValueTextMarshaler]]int // Accept
GAGTPtr map[GoodTildeCstrPtrAlias[ValueTextMarshaler]]int // Accept, hide
GANBV map[NonBasicCstrAlias[ValueTextMarshaler]]int // Accept
GANBP map[NonBasicCstrAlias[*PointerTextMarshaler]]int // Accept, hide
GANBVPtr map[NonBasicCstrPtrAlias[ValueTextMarshaler]]int // Accept, hide
GANBPPtr map[NonBasicCstrPtrAlias[*PointerTextMarshaler]]int // Reject
GAPlV1 map[PointableCstrAlias[ValueTextMarshaler]]int // Accept
GAPlV2 map[*PointableCstrAlias[ValueTextMarshaler]]int // Accept
GAPlP1 map[PointableCstrAlias[PointerTextMarshaler]]int // Reject
GAPlP2 map[*PointableCstrAlias[PointerTextMarshaler]]int // Accept
GAPlVPtr map[PointableCstrPtrAlias[ValueTextMarshaler]]int // Accept, hide
GAPlPPtr map[PointableCstrPtrAlias[PointerTextMarshaler]]int // Accept, hide
GAMi map[MixedCstrAlias[uint]]int // Accept, hide
GAMS map[MixedCstrAlias[StringType]]int // Accept
GAMV map[MixedCstrAlias[ValueTextMarshaler]]int // Accept
GAMSPtr map[MixedCstrPtrAlias[StringType]]int // Reject
GAMVPtr map[MixedCstrPtrAlias[ValueTextMarshaler]]int // Accept, hide
GAII map[InterfaceCstrAlias[encoding.TextMarshaler]]int // Accept, hide
GAIV map[InterfaceCstrAlias[ValueTextMarshaler]]int // Accept
GAIP map[InterfaceCstrAlias[*PointerTextMarshaler]]int // Accept, hide
GAIIPtr map[InterfaceCstrPtrAlias[encoding.TextMarshaler]]int // Reject
GAIVPtr map[InterfaceCstrPtrAlias[ValueTextMarshaler]]int // Accept, hide
GAIPPtr map[InterfaceCstrPtrAlias[*PointerTextMarshaler]]int // Reject
GAPrV map[PointerCstrAlias[ValueTextMarshaler, *ValueTextMarshaler]]int // Accept, hide
GAPrP map[PointerCstrAlias[PointerTextMarshaler, *PointerTextMarshaler]]int // Accept, hide
GAPrVPtr map[PointerCstrPtrAlias[ValueTextMarshaler, *ValueTextMarshaler]]int // Reject
GAPrPPtr map[PointerCstrPtrAlias[PointerTextMarshaler, *PointerTextMarshaler]]int // Reject
}

func (*Service) Method() (_ Maps[PointerTextMarshaler, int, int, ValueTextMarshaler, *PointerTextMarshaler, ValueTextMarshaler, StringType, ValueTextMarshaler, *PointerTextMarshaler]) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,18 @@ export function GetButForeignPrivateAlias() {
return $typingPromise;
}

/**
* @returns {Promise<$models.AliasGroup> & { cancel(): void }}
*/
export function GetButGenericAliases() {
let $resultPromise = /** @type {any} */($Call.ByID(914093800));
let $typingPromise = /** @type {any} */($resultPromise.then(($result) => {
return $$createType3($result);
}));
$typingPromise.cancel = $resultPromise.cancel.bind($resultPromise);
return $typingPromise;
}

/**
* Greet a lot of unusual things.
* @param {$models.EmptyAliasStruct} $0
Expand All @@ -81,7 +93,7 @@ export function GetButForeignPrivateAlias() {
export function Greet($0, $1) {
let $resultPromise = /** @type {any} */($Call.ByID(1411160069, $0, $1));
let $typingPromise = /** @type {any} */($resultPromise.then(($result) => {
return $$createType6($result);
return $$createType7($result);
}));
$typingPromise.cancel = $resultPromise.cancel.bind($resultPromise);
return $typingPromise;
Expand All @@ -91,12 +103,13 @@ export function Greet($0, $1) {
const $$createType0 = $models.Person.createFrom;
const $$createType1 = $models.GenericPerson.createFrom($Create.Any);
const $$createType2 = nobindingshere$0.personImpl.createFrom;
const $$createType3 = $Create.Array($Create.Any);
const $$createType3 = $models.AliasGroup.createFrom;
const $$createType4 = $Create.Array($Create.Any);
const $$createType5 = $Create.Struct({
"NoMoreIdeas": $$createType4,
});
const $$createType5 = $Create.Array($Create.Any);
const $$createType6 = $Create.Struct({
"Foo": $$createType3,
"Other": $$createType5,
"NoMoreIdeas": $$createType5,
});
const $$createType7 = $Create.Struct({
"Foo": $$createType4,
"Other": $$createType6,
});
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,15 @@ export {
};

export {
AliasGroup,
AliasedPerson,
EmptyStruct,
GenericPerson,
GenericPersonAlias,
IndirectPersonAlias,
Person,
StrangelyAliasedPerson
StrangelyAliasedPerson,
TPIndirectPersonAlias
} from "./models.js";

import * as $models from "./models.js";
Expand All @@ -33,6 +37,24 @@ import * as $models from "./models.js";
* @typedef {$models.EmptyAliasStruct} EmptyAliasStruct
*/

/**
* A generic alias that forwards to a type parameter.
* @template T
* @typedef {$models.GenericAlias<T>} GenericAlias
*/

/**
* A generic alias that wraps a map.
* @template T,U
* @typedef {$models.GenericMapAlias<T, U>} GenericMapAlias
*/

/**
* A generic alias that wraps a pointer type.
* @template T
* @typedef {$models.GenericPtrAlias<T>} GenericPtrAlias
*/

/**
* Another struct alias.
* @typedef {$models.OtherAliasStruct} OtherAliasStruct
Expand Down
Loading