From 371e57588f7ea6b269bb2ffed52ee87fee4ea28e Mon Sep 17 00:00:00 2001 From: Lea Anthony Date: Sat, 16 Dec 2023 20:57:00 +1100 Subject: [PATCH] Update bindings example --- .../assets/{bindings_main.js => main.js} | 13 +++++---- v3/examples/binding/assets/models.ts | 29 +++++++++---------- v3/examples/binding/go.mod | 8 ++--- v3/examples/binding/go.sum | 8 ++--- 4 files changed, 29 insertions(+), 29 deletions(-) rename v3/examples/binding/assets/{bindings_main.js => main.js} (77%) diff --git a/v3/examples/binding/assets/bindings_main.js b/v3/examples/binding/assets/main.js similarity index 77% rename from v3/examples/binding/assets/bindings_main.js rename to v3/examples/binding/assets/main.js index d7dab3886d5..81542712f13 100644 --- a/v3/examples/binding/assets/bindings_main.js +++ b/v3/examples/binding/assets/main.js @@ -2,15 +2,16 @@ // Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL // This file is automatically generated. DO NOT EDIT +/** + * @typedef {import('./models').main.Person} mainPerson + */ -window.go = window.go || {}; -window.go.main = { - GreetService: { +export const GreetService = { /** * GreetService.Greet * Greet greets a person - * @param name {string} + * @param name {string} * @returns {Promise} **/ Greet: function(name) { return wails.CallByID(1411160069, ...Array.prototype.slice.call(arguments, 0)); }, @@ -18,9 +19,9 @@ window.go.main = { /** * GreetService.GreetPerson * GreetPerson greets a person - * @param person {main.Person} + * @param person {mainPerson} * @returns {Promise} **/ GreetPerson: function(person) { return wails.CallByID(4021313248, ...Array.prototype.slice.call(arguments, 0)); }, - }, }; + diff --git a/v3/examples/binding/assets/models.ts b/v3/examples/binding/assets/models.ts index 01cb6495942..f8924363a45 100644 --- a/v3/examples/binding/assets/models.ts +++ b/v3/examples/binding/assets/models.ts @@ -3,22 +3,21 @@ // This file is automatically generated. DO NOT EDIT export namespace main { - - export class Person { - name: string; // Warning: this is unexported in the Go struct. - static createFrom(source: any = {}) { - return new Person(source); - } + + export class Person { + name: string; // Warning: this is unexported in the Go struct. + + constructor(source: Partial = {}) { + const { name = "" } = source; + this.name = name; + } - constructor(source: any = {}) { - if ('string' === typeof source) { - source = JSON.parse(source); - } + static createFrom(source: string | object = {}): Person { + let parsedSource = typeof source === 'string' ? JSON.parse(source) : source; + return new Person(parsedSource as Partial); + } - this.name = source['name']; - } - } - -} + +} \ No newline at end of file diff --git a/v3/examples/binding/go.mod b/v3/examples/binding/go.mod index 48b19a593ea..cbbb135aa87 100644 --- a/v3/examples/binding/go.mod +++ b/v3/examples/binding/go.mod @@ -1,8 +1,8 @@ module binding -go 1.21 +go 1.21.1 -toolchain go1.21.0 +toolchain go1.21.4 require github.com/wailsapp/wails/v3 v3.0.0-alpha.0 @@ -25,7 +25,7 @@ require ( github.com/kr/pretty v0.3.1 // indirect github.com/leaanthony/go-ansi-parser v1.6.1 // indirect github.com/leaanthony/u v1.1.0 // indirect - github.com/lmittmann/tint v1.0.0 // indirect + github.com/lmittmann/tint v1.0.3 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.19 // indirect github.com/mitchellh/go-homedir v1.1.0 // indirect @@ -43,7 +43,7 @@ require ( golang.org/x/crypto v0.9.0 // indirect golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df // indirect golang.org/x/net v0.10.0 // indirect - golang.org/x/sys v0.13.0 // indirect + golang.org/x/sys v0.14.0 // indirect gopkg.in/warnings.v0 v0.1.2 // indirect ) diff --git a/v3/examples/binding/go.sum b/v3/examples/binding/go.sum index 0df9fda8f5d..14e16011ee3 100644 --- a/v3/examples/binding/go.sum +++ b/v3/examples/binding/go.sum @@ -62,8 +62,8 @@ github.com/leaanthony/go-ansi-parser v1.6.1 h1:xd8bzARK3dErqkPFtoF9F3/HgN8UQk0ed github.com/leaanthony/go-ansi-parser v1.6.1/go.mod h1:+vva/2y4alzVmmIEpk9QDhA7vLC5zKDTRwfZGOp3IWU= github.com/leaanthony/u v1.1.0 h1:2n0d2BwPVXSUq5yhe8lJPHdxevE2qK5G99PMStMZMaI= github.com/leaanthony/u v1.1.0/go.mod h1:9+o6hejoRljvZ3BzdYlVL0JYCwtnAsVuN9pVTQcaRfI= -github.com/lmittmann/tint v1.0.0 h1:fzEj70K1L58uyoePQxKe+ezDZJ5pybiWGdA0JeFvvyw= -github.com/lmittmann/tint v1.0.0/go.mod h1:HIS3gSy7qNwGCj+5oRjAutErFBl4BzdQP6cJZ0NfMwE= +github.com/lmittmann/tint v1.0.3 h1:W5PHeA2D8bBJVvabNfQD/XW9HPLZK1XoPZH0cq8NouQ= +github.com/lmittmann/tint v1.0.3/go.mod h1:HIS3gSy7qNwGCj+5oRjAutErFBl4BzdQP6cJZ0NfMwE= github.com/matryer/is v1.4.0 h1:sosSmIWwkYITGrxZ25ULNDeKiMNzFSr4V/eqBQP0PeE= github.com/matryer/is v1.4.0/go.mod h1:8I/i5uYgLzgsgEloJE1U6xx5HkBQpAZvepWuujKwMRU= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= @@ -136,8 +136,8 @@ golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= -golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q= +golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.13.0 h1:bb+I9cTfFazGW51MZqBVmZy7+JEJMouUHTUSKVQLBek= golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U=