mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-02 05:11:29 +08:00
Do not attempt to export fields that cannot be json-encoded (#3975)
Some checks are pending
Build + Test v2 / Test Templates (1.22, macos-latest, lit-ts) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, macos-latest, plain) (push) Blocked by required conditions
Build + Test v2 / Run Go Tests (1.22, macos-latest) (push) Waiting to run
Build + Test v2 / Run Go Tests (1.22, ubuntu-22.04) (push) Waiting to run
Build + Test v2 / Run Go Tests (1.22, ubuntu-24.04) (push) Waiting to run
Build + Test v2 / Run Go Tests (1.22, windows-latest) (push) Waiting to run
Build + Test v2 / Run JS Tests (20.x) (push) Waiting to run
Build + Test v2 / Test Templates (1.22, macos-latest, lit) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, macos-latest, preact) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, macos-latest, preact-ts) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, macos-latest, react) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, macos-latest, react-ts) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, macos-latest, svelte) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, macos-latest, svelte-ts) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, macos-latest, vanilla) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, macos-latest, vanilla-ts) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, macos-latest, vue) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, macos-latest, vue-ts) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, ubuntu-22.04, lit) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, ubuntu-22.04, lit-ts) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, ubuntu-22.04, plain) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, ubuntu-22.04, preact) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, ubuntu-22.04, preact-ts) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, ubuntu-22.04, react) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, ubuntu-22.04, react-ts) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, ubuntu-22.04, svelte) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, ubuntu-22.04, svelte-ts) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, ubuntu-22.04, vanilla) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, ubuntu-22.04, vanilla-ts) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, ubuntu-22.04, vue) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, ubuntu-22.04, vue-ts) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, ubuntu-24.04, lit) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, ubuntu-24.04, lit-ts) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, ubuntu-24.04, plain) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, ubuntu-24.04, preact) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, ubuntu-24.04, preact-ts) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, ubuntu-24.04, react) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, ubuntu-24.04, react-ts) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, ubuntu-24.04, svelte) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, ubuntu-24.04, svelte-ts) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, ubuntu-24.04, vanilla) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, ubuntu-24.04, vanilla-ts) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, ubuntu-24.04, vue) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, ubuntu-24.04, vue-ts) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, windows-latest, lit) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, windows-latest, lit-ts) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, windows-latest, plain) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, windows-latest, preact) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, windows-latest, preact-ts) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, windows-latest, react) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, windows-latest, react-ts) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, windows-latest, svelte) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, windows-latest, svelte-ts) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, windows-latest, vanilla) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, windows-latest, vanilla-ts) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, windows-latest, vue) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, windows-latest, vue-ts) (push) Blocked by required conditions
Upload Source Documents / Push files to Crowdin (push) Waiting to run
Some checks are pending
Build + Test v2 / Test Templates (1.22, macos-latest, lit-ts) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, macos-latest, plain) (push) Blocked by required conditions
Build + Test v2 / Run Go Tests (1.22, macos-latest) (push) Waiting to run
Build + Test v2 / Run Go Tests (1.22, ubuntu-22.04) (push) Waiting to run
Build + Test v2 / Run Go Tests (1.22, ubuntu-24.04) (push) Waiting to run
Build + Test v2 / Run Go Tests (1.22, windows-latest) (push) Waiting to run
Build + Test v2 / Run JS Tests (20.x) (push) Waiting to run
Build + Test v2 / Test Templates (1.22, macos-latest, lit) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, macos-latest, preact) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, macos-latest, preact-ts) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, macos-latest, react) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, macos-latest, react-ts) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, macos-latest, svelte) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, macos-latest, svelte-ts) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, macos-latest, vanilla) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, macos-latest, vanilla-ts) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, macos-latest, vue) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, macos-latest, vue-ts) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, ubuntu-22.04, lit) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, ubuntu-22.04, lit-ts) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, ubuntu-22.04, plain) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, ubuntu-22.04, preact) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, ubuntu-22.04, preact-ts) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, ubuntu-22.04, react) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, ubuntu-22.04, react-ts) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, ubuntu-22.04, svelte) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, ubuntu-22.04, svelte-ts) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, ubuntu-22.04, vanilla) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, ubuntu-22.04, vanilla-ts) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, ubuntu-22.04, vue) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, ubuntu-22.04, vue-ts) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, ubuntu-24.04, lit) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, ubuntu-24.04, lit-ts) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, ubuntu-24.04, plain) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, ubuntu-24.04, preact) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, ubuntu-24.04, preact-ts) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, ubuntu-24.04, react) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, ubuntu-24.04, react-ts) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, ubuntu-24.04, svelte) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, ubuntu-24.04, svelte-ts) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, ubuntu-24.04, vanilla) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, ubuntu-24.04, vanilla-ts) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, ubuntu-24.04, vue) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, ubuntu-24.04, vue-ts) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, windows-latest, lit) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, windows-latest, lit-ts) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, windows-latest, plain) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, windows-latest, preact) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, windows-latest, preact-ts) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, windows-latest, react) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, windows-latest, react-ts) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, windows-latest, svelte) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, windows-latest, svelte-ts) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, windows-latest, vanilla) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, windows-latest, vanilla-ts) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, windows-latest, vue) (push) Blocked by required conditions
Build + Test v2 / Test Templates (1.22, windows-latest, vue-ts) (push) Blocked by required conditions
Upload Source Documents / Push files to Crowdin (push) Waiting to run
* Do not attempt to export fields that cannot be json-encoded * update changelog w/ PR * also skip UnsafePointers --------- Co-authored-by: Lea Anthony <lea.anthony@gmail.com>
This commit is contained in:
parent
90be707d9c
commit
7566ed4ba6
@ -350,6 +350,14 @@ func (b *Bindings) hasExportedJSONFields(typeOf reflect.Type) bool {
|
|||||||
for i := 0; i < typeOf.NumField(); i++ {
|
for i := 0; i < typeOf.NumField(); i++ {
|
||||||
jsonFieldName := ""
|
jsonFieldName := ""
|
||||||
f := typeOf.Field(i)
|
f := typeOf.Field(i)
|
||||||
|
// function, complex, and channel types cannot be json-encoded
|
||||||
|
if f.Type.Kind() == reflect.Chan ||
|
||||||
|
f.Type.Kind() == reflect.Func ||
|
||||||
|
f.Type.Kind() == reflect.UnsafePointer ||
|
||||||
|
f.Type.Kind() == reflect.Complex128 ||
|
||||||
|
f.Type.Kind() == reflect.Complex64 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
jsonTag, hasTag := f.Tag.Lookup("json")
|
jsonTag, hasTag := f.Tag.Lookup("json")
|
||||||
if !hasTag && f.IsExported() {
|
if !hasTag && f.IsExported() {
|
||||||
return true
|
return true
|
||||||
|
@ -5,6 +5,7 @@ type NoFieldTags struct {
|
|||||||
Address string
|
Address string
|
||||||
Zip *string
|
Zip *string
|
||||||
Spouse *NoFieldTags
|
Spouse *NoFieldTags
|
||||||
|
NoFunc func() string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n NoFieldTags) Get() NoFieldTags {
|
func (n NoFieldTags) Get() NoFieldTags {
|
||||||
|
@ -553,6 +553,14 @@ func (t *TypeScriptify) getFieldOptions(structType reflect.Type, field reflect.S
|
|||||||
|
|
||||||
func (t *TypeScriptify) getJSONFieldName(field reflect.StructField, isPtr bool) string {
|
func (t *TypeScriptify) getJSONFieldName(field reflect.StructField, isPtr bool) string {
|
||||||
jsonFieldName := ""
|
jsonFieldName := ""
|
||||||
|
// function, complex, and channel types cannot be json-encoded
|
||||||
|
if field.Type.Kind() == reflect.Chan ||
|
||||||
|
field.Type.Kind() == reflect.Func ||
|
||||||
|
field.Type.Kind() == reflect.UnsafePointer ||
|
||||||
|
field.Type.Kind() == reflect.Complex128 ||
|
||||||
|
field.Type.Kind() == reflect.Complex64 {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
jsonTag, hasTag := field.Tag.Lookup("json")
|
jsonTag, hasTag := field.Tag.Lookup("json")
|
||||||
if !hasTag && field.IsExported() {
|
if !hasTag && field.IsExported() {
|
||||||
jsonFieldName = field.Name
|
jsonFieldName = field.Name
|
||||||
|
@ -28,7 +28,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
- Fixed incorrect TS definition of `WindowSetSize` by @leaanthony
|
- Fixed incorrect TS definition of `WindowSetSize` by @leaanthony
|
||||||
- chore: fix some comments in [PR](https://github.com/wailsapp/wails/pull/3932) by @lvyaoting
|
- chore: fix some comments in [PR](https://github.com/wailsapp/wails/pull/3932) by @lvyaoting
|
||||||
- [windows] Fixed frameless window flickering when minimizing/restoring by preventing unnecessary redraws [#3951](https://github.com/wailsapp/wails/issues/3951)
|
- [windows] Fixed frameless window flickering when minimizing/restoring by preventing unnecessary redraws [#3951](https://github.com/wailsapp/wails/issues/3951)
|
||||||
|
- Fixed failed models.ts build due to non-json-encodable Go types [PR](https://github.com/wailsapp/wails/pull/3975) by [@pbnjay](https://github.com/pbnjay)
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- Allow to specify macos-min-version externally. Implemented by @APshenkin in [PR](https://github.com/wailsapp/wails/pull/3756)
|
- Allow to specify macos-min-version externally. Implemented by @APshenkin in [PR](https://github.com/wailsapp/wails/pull/3756)
|
||||||
|
Loading…
Reference in New Issue
Block a user