5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-02 16:02:07 +08:00
Commit Graph

81 Commits

Author SHA1 Message Date
joshuapare
bc7b816c37
postfix [] in instance is element accessor, not array type declaration 2025-04-10 08:50:12 -05:00
Jeremy Jay
c4fdfd6415
Fix miscellaneous bindings and typescript export bugs (#3978)
* Do not attempt to export fields that cannot be json-encoded

* update changelog w/ PR

* also skip UnsafePointers

* WIP to allow conversion from Go generic types to typescript

* support for non-primitive generics also :)

* fix generic types in parameters / return args

* fixes a namespacing bug when mapping to pointer to struct

* fixing invalid knownstructs

* found a place it mattered, pushing the star replacement to the generate side

* descend as much as necessary to find structs

caught these examples in http.Request.TLS:

PeerCertificates []*x509.Certificate
VerifiedChains [][]*x509.Certificate

* accidently reverted other fix

* switch syntax for typescript record outputs

prior syntax is primarily useful for naming keys
so not useful here, and this syntax avoids square
brackets in output which greatly simplifies
generation for Go generics

* better handle edge cases for nested arrays and slices

* lots o tests

* update changelog

---------

Co-authored-by: Lea Anthony <lea.anthony@gmail.com>
2025-01-13 20:14:54 +11:00
Jeremy Jay
7566ed4ba6
Do not attempt to export fields that cannot be json-encoded (#3975)
Some checks are pending
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>
2025-01-10 15:11:13 +11:00
Jeremy Jay
fe1f23b0fd
If a field is exported, generate json even in the absence of tags (#3678)
* if no JSON tag, check if field is exported

* add no-tags binding test case

* update changelog for #3678
2024-08-14 07:49:08 +10:00
Gjergji Ramku
2f5398664f
Bindingings for empty go structs (#3489) 2024-05-18 07:39:27 +10:00
Gjergji Ramku
a7a4341f79
Special chars bindings unit tests (#3485)
* JSON fields that start with special characters generate wrong typescript bindings

* Update changelong
2024-05-17 18:32:54 +10:00
Leo
c10dfbce78
Fixed issue where createFrom would misidentify strings as arrays (#3435)
* Update check for Array-like variables

* Updated binding tests to reflect changes

* Update documentation to reflect changes

* Fixed PR number in changelog

---------

Co-authored-by: Lea Anthony <lea.anthony@gmail.com>
2024-04-27 16:30:04 +10:00
lvyaoting
aad811391b
chore: fix function names in comment (#3383)
Signed-off-by: lvyaoting <lvyaoting@outlook.com>
2024-04-09 17:19:06 -05:00
Andrey Pshenkin
674042df36
fix obfuscated build binding ordering (#3071)
* fix obfuscated build binding ordering

* remove unused string method

* add to changelog

---------

Co-authored-by: Lea Anthony <lea.anthony@gmail.com>
2023-11-26 07:16:24 +11:00
Andrey Pshenkin
b9de31e38e
Add support for interface generation and enums (#3047)
* Add support to output ts models as interfaces

* Add support to generate enums from golang

* cleanup logs

* add missing documentation

* fix package names for enum. Fix processing enums that are in separate packages

* revert golang 1.21

* Fix spelling

* Add support for simplified version of Enum for typescriptify

* update docs

* removed unused logs

* Add tests. Fix imported enums types in models

---------

Co-authored-by: Lea Anthony <lea.anthony@gmail.com>
2023-11-26 06:50:49 +11:00
Lea Anthony
9ce0ddb4f8 [chore] lint fixes 2023-11-12 12:30:49 +11:00
Dominic Lee
d249c2207b
fix: parse struct references for type generation (#2552)
* fix: parse struct references for type generation

* chore: update changelog for typescript generation fix
2023-04-26 23:23:39 +10:00
Adam Tenderholt
88549a14ac
Fix differeng bugs when generating bindings (#2326)
* Bindings: work in better typescript generation

* More work on generating typescript

* Bindings: fix a couple of failing tests

* Binding: fix map bindings

* Bindings: comment out debug statement

* Bindings: misc cleanup
2023-01-26 18:40:05 +11:00
Oleg Gulevskyy
651a1a5d66
Bugfix: Include ts pref & suffixes in module generation (#2227)
* include ts gen pref and suff in class fields

* fix nested namespaces not prefixed

* add basic unit test for parent child

* test for diff namespaces imports

* make entityReturn type func more generic

* get full entity name for TS args list

* fix failing test on empty struct

* wire up gen tests

* remove comment

* remove redundant line
2023-01-23 21:18:17 +11:00
Adam Tenderholt
52f872b65c
[binding] TS returns Promise<void> when go returns error (#2247) 2022-12-28 22:32:29 +11:00
Vadim Shchepotev
e2f1429c67
Fix issue with anonymous structures (#2186)
Co-authored-by: Lea Anthony <lea.anthony@gmail.com>
2022-12-20 22:54:11 +11:00
Oleg Gulevskyy
ca8a1fab36
Ability to define prefix / suffix for TS module (#2101)
* add tspostfix and tsprefix flags + organise under struct

* postifx -> suffix

* tsPrefix options on bindings struct

* pass prefix and suffix to the executable

* add support for CLI flags for generating module

* method to set TSpref/suff to bindings

* use passed ts prefix for typescriptify

* add brief Readme udpate to include new flags

* create reusable common flags

* use common flags instead of hardcoded text

* support tsprefix & suffix for dev

* add tsPrefix & tsSuffix for build cmd

* take pref & suff in account when gen d.ts

* export colorsful log functions into utils for reuse

* detect and warn the user about usage of reserved keyword

* fmt

* add TrimSpace on fn input

* refactor utils -> logutils

* add bindings -> ts_generation options to wailsjson parse

* use wailsjson for ts generation

* update warning message + extract to func

* remove suff/pref info from readme

* update json schema

* add tests for prefix and suffix case

* rename suffix method

* Update v2/internal/typescriptify/typescriptify.go

Co-authored-by: Lea Anthony <lea.anthony@gmail.com>

* Update website/static/schemas/config.v2.json

Co-authored-by: Lea Anthony <lea.anthony@gmail.com>

* Update website/static/schemas/config.v2.json

Co-authored-by: Lea Anthony <lea.anthony@gmail.com>

* update changelog

* Minor tweaks

Co-authored-by: Lea Anthony <lea.anthony@gmail.com>
2022-11-24 21:33:58 +11:00
ParkourLiu
dc65f77baf
repair panic (#1999)
* repair panic

* Add empty struct field test

Co-authored-by: Lea Anthony <lea.anthony@gmail.com>
2022-10-22 21:04:49 +11:00
Lea Anthony
2d4f7f4de8
Sort structs in models.ts. Fixes #1958 (#1961) 2022-10-14 07:50:22 +11:00
Valentin Trinqué
2a20049ea7
fix: Prevent type parsing to interfere with package name in typescript generation (#1942)
Before that fix:

The method...

```go
func (h *Handler) RespondToInteraction(interaction interactor.Interaction) {}
```

... would generate...

```ts
export function RespondToInteraction(arg1:number):Promise<Error>;
```

... because the `interaction` package starts with `int` and anything starting with `int` is interpreted as `number`.
2022-10-10 23:50:55 +11:00
Lea Anthony
6a3b89d212
fix: exemption typo 2022-10-01 19:03:20 +10:00
JulioDRF
40e326a708
Fix binding generation special cases (#1902)
* Make binding.go easier to test

* Fix non-deterministic namespace order for bindings

* Add binding tests

* Fix nested import structs, non-string map keys, and escape invalid variable names

Co-authored-by: Lea Anthony <lea.anthony@gmail.com>
2022-10-01 15:49:51 +10:00
Lea Anthony
052b9222c1
Add garble support (#1793)
Co-authored-by: AlbinoDrought <sean@albinodrought.com>
Co-authored-by: stffabi <stffabi@users.noreply.github.com>
2022-09-13 10:05:37 +10:00
SheetJSDev
53ebb67b72
Use Promise<void> when Go routine does not output (#1821) 2022-09-03 09:56:18 +10:00
Valentin Trinqué
cf3c65f0cc
Fix registration of exposed fields (#1727) 2022-08-11 08:41:37 +10:00
Lea Anthony
461d0c4448
Add compatibility for Go1.17 (#1605) 2022-07-20 07:10:05 +10:00
Lea Anthony
1cbc34eff8
Fixes #1546 2022-07-11 20:56:05 +10:00
Lea Anthony
d4662bd797
Support Maps in TS conversion (#1435) 2022-07-10 20:54:49 +10:00
Lea Anthony
bf2d83d939
Change: Order of generated bindings now consistent
Closes #1531
2022-07-08 20:18:31 +10:00
Lea Anthony
fe341741b5
Always use return in wrapped method (#1410) 2022-06-06 00:41:44 -10:00
Lea Anthony
55115742c1 fix: TS conversion of interface{} 2022-05-11 08:21:17 +10:00
Lea Anthony
84b6273baf
Bugfix/incorrect bindings (#1383)
* Print struct path

* Better handling of anon structs
2022-05-05 23:07:33 +10:00
Lea Anthony
781a0df72e
Fix for TS/JS generation on methods with no returns (#1356) 2022-04-27 19:09:55 +10:00
Lea Anthony
43f8a1f773 fix: blank namespaces, unknown structs 2022-04-06 19:13:10 +10:00
Lea Anthony
55855ccc4d fix: duplicate model generation 2022-04-05 21:30:55 +10:00
Lea Anthony
eb97f53124 Feature: Don't generate models.ts if there are no models. 2022-04-05 21:30:55 +10:00
Lea Anthony
625eca27f6 Feature: TS namespaces 2022-04-05 18:11:56 +10:00
Lea Anthony
2465538448 Fix: TS namespace inference 2022-04-05 08:26:54 +10:00
Lea Anthony
bb2da2f810 Chore: remove debug output 2022-04-04 21:19:36 +10:00
Lea Anthony
6b38f0c68e
Improved TS Generation (#1310)
Improve TS Generation
2022-04-04 21:01:00 +10:00
Lea Anthony
8bb3af2282
Refactor TS imports 2022-04-04 07:19:39 +10:00
Ariel
d5a8ee0132
Do not duplicate imports (#1307)
* Do not duplicate imports

* Fix warning as first element
2022-04-03 20:17:20 +10:00
Lea Anthony
55cec7af17 Fix: Handle struct pointers in new TS generation 2022-04-03 17:58:53 +10:00
Lea Anthony
4721949657
Improved bindings generation 2022-04-03 07:31:07 +10:00
Lea Anthony
f6cdafa5ff Bugfix: generate correct model reference in bindings.d.ts 2022-04-01 13:08:56 +11:00
Lea Anthony
a5bf76b30f Fix up dev. Pull in go-webview and winc 2022-03-29 21:45:16 +11:00
Ariel
9097c9086b
import models on binding definition (#1231) 2022-03-09 07:44:32 +11:00
Albert Sun
f5c3907fac added interface{} test case and fixed 2022-01-22 10:23:02 -05:00
Albert Sun
4118f348f5 fixed generate test 2022-01-22 00:59:26 -05:00
Albert Sun
1e4af8991b added export 2022-01-22 00:40:55 -05:00