5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-04 01:19:12 +08:00
wails/v2/pkg/parser/testproject/basic.go
Lea Anthony 62374b9b53
Js package generation (#554)
* WIP

* Generation of index.js

* Add RelativeToCwd

* Add JSDoc comments

* Convert to ES6 syntax

* Fix typo

* Initial generation of typescript declarations

* Typescript improvements

* Improved @returns jsdoc

* Improved declaration files

* Simplified output

* Rename file

* Tidy up

* Revert "Simplified output"

This reverts commit 15cdf7382b.

* Now parsing actual code

* Support Array types

* Reimagined parser

* Wrap parsing in Parser

* Rewritten module generator (TS Only)

* Final touches

* Slight refactor to improve output

* Struct comments. External struct literal binding

* Reworked project parser *working*

* remove debug info

* Refactor of parser

* remove the spew

* Better Ts support

* Better project generation logic

* Support local functions in bind()

* JS Object generation. Linting.

* Support json tags in module generation

* Updated mod files

* Support vscode file generation

* Better global.d.ts

* add ts-check to templates

* Support TS declaration files

* improved 'generate' command for module
2020-11-15 09:25:38 +11:00

67 lines
1.4 KiB
Go

package main
import (
"fmt"
"testproject/mypackage"
wails "github.com/wailsapp/wails/v2"
)
// Basic application struct
type Basic struct {
runtime *wails.Runtime
}
// // Another application struct
// type Another struct {
// runtime *wails.Runtime
// }
// func (a *Another) Doit() {
// }
// // newBasicPointer creates a new Basic application struct
// func newBasicPointer() *Basic {
// return &Basic{}
// }
// // newBasic creates a new Basic application struct
// func newBasic() Basic {
// return Basic{}
// }
// WailsInit is called at application startup
func (b *Basic) WailsInit(runtime *wails.Runtime) error {
// Perform your setup here
b.runtime = runtime
runtime.Window.SetTitle("jsbundle")
return nil
}
// WailsShutdown is called at application termination
func (b *Basic) WailsShutdown() {
// Perform your teardown here
}
// NewPerson creates a new person
func (b *Basic) NewPerson(name string, age int) *mypackage.Person {
return &mypackage.Person{Name: name, Age: age}
}
// Greet returns a greeting for the given name
func (b *Basic) Greet(name string) string {
return fmt.Sprintf("Hello %s!", name)
}
// MultipleGreets returns greetings for the given name
func (b *Basic) MultipleGreets(name string) []string {
return []string{"hi", "hello", "croeso!"}
}
// RemovePerson Removes the given person
func (b *Basic) RemovePerson(p *mypackage.Person) {
// dummy
}