ui

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 4, 2022 License: MIT Imports: 23 Imported by: 6

Documentation

Index

Constants

View Source
const ContextBindingName = "context"
View Source
const ReadyFuncName = "Vuego"

ReadyFuncName is an async ready function in api object.

Variables

View Source
var ChromeBinary string

Functions

func BasicAuth

func BasicAuth(auth func(user string, pass string) bool) func(http.HandlerFunc) http.HandlerFunc

func NewHtmlRoot

func NewHtmlRoot(html string) *simpleRoot

func NewSimpleRoot

func NewSimpleRoot(files map[string]string) *simpleRoot

Types

type Bindable

type Bindable interface {
	Bind(b Bindings)
	BindPrefix(name string, b Bindings)
	BindFunc(name string, fn interface{})
	BindObject(obj interface{})
	BindMap(m map[string]interface{})
	GetBindings() []Bindings
}

type Binder

type Binder interface {
	Bind(b Bindings) error
}

type BindingFunc

type BindingFunc interface{}

type Bindings

type Bindings interface {
	Names() []string
	Map(*UIContext) map[string]BindingFunc
	Error() error
}

Bindings represent an api. Every binding has a name and a callable object.

func Delay

func Delay(names []string, factory func(*UIContext) Bindings) Bindings

func DelayMap

func DelayMap(prototype map[string]interface{}, factory func(*UIContext) Bindings) Bindings

func DelayObject

func DelayObject(prototype interface{}, factory func(*UIContext) Bindings) Bindings

func Func

func Func(name string, fn interface{}) Bindings

func Map

func Map(m map[string]interface{}) Bindings

func Object

func Object(obj interface{}) Bindings

func Prefix

func Prefix(name string, b Bindings) Bindings

type ClientOptions

type ClientOptions struct {
	BlurOnClose bool
}

type Context

type Context struct {
	Seq int `json:"seq"`
	// contains filtered or unexported fields
}

func (*Context) Deadline

func (c *Context) Deadline() (deadline time.Time, ok bool)

func (*Context) Done

func (c *Context) Done() <-chan struct{}

func (*Context) Err

func (c *Context) Err() error

func (*Context) Value

func (c *Context) Value(key interface{}) interface{}

func (*Context) WithCancel

func (c *Context) WithCancel() context.CancelFunc

type FileServer

type FileServer struct {
	Addr          string
	ServerPath    string
	Listener      net.Listener
	Prefix        string // path prefix
	Auth          func(http.HandlerFunc) http.HandlerFunc
	HistoryMode   bool
	ClientOptions *ClientOptions
	// contains filtered or unexported fields
}

func NewFileServer

func NewFileServer(root http.FileSystem) *FileServer

func (*FileServer) Bind

func (s *FileServer) Bind(b Bindings) error

func (*FileServer) Close

func (s *FileServer) Close() error

func (*FileServer) Done

func (s *FileServer) Done() <-chan struct{}

func (*FileServer) ListenAndServe

func (s *FileServer) ListenAndServe() error

func (*FileServer) ListenAndServeTLS

func (s *FileServer) ListenAndServeTLS(certFile, keyFile string) error

func (*FileServer) ServeExistingServer

func (s *FileServer) ServeExistingServer(server HTTPServer)

func (*FileServer) ServeExistingServerTLS

func (s *FileServer) ServeExistingServerTLS(server HTTPServer)

func (*FileServer) Shutdown

func (s *FileServer) Shutdown(ctx context.Context) error

type Function

type Function struct {
	BindingName string `json:"bindingName"`
	Seq         int    `json:"seq"`
	// contains filtered or unexported fields
}

Function wraps a js callback function.

func (*Function) Call

func (c *Function) Call(args ...interface{}) Value

Call method.

type HTTPServer

type HTTPServer interface {
	Handle(pattern string, handler http.Handler)
}

type HTTPServerFunc

type HTTPServerFunc func(pattern string, handler http.Handler)

func (HTTPServerFunc) Handle

func (f HTTPServerFunc) Handle(pattern string, handler http.Handler)

type NativeWindow

type NativeWindow interface {
	Open(url string) error
	Close()
}

type ObjectFactory

type ObjectFactory func(*UIContext) interface{}

type Option

type Option func(*uiConfig) error

func AppChromeArgs

func AppChromeArgs(args ...string) Option

func AppChromeBinary

func AppChromeBinary(path string) Option

func AppFullScreen

func AppFullScreen() Option

func AppWindow

func AppWindow(x, y, width, height int) Option

func BlurOnClose

func BlurOnClose(blur bool) Option

func HistoryMode

func HistoryMode(enable bool) Option

func LocalExitDelay

func LocalExitDelay(d time.Duration) Option

LocalExitDelay contorl auto exit behaviour of a local server. By default, when all clients where lost, a local server will wait for a new client and exit if timeout. A local server will exit immediately after any client lost when duration is 0, and never exit when duration is less than 0.

func LocalMapURL

func LocalMapURL(mapURL func(net.Listener) string) Option

func Mode

func Mode(mod string) Option

func OnlineAddr

func OnlineAddr(addr string) Option

func OnlineAttach

func OnlineAttach(existingServer HTTPServer, tls bool) Option

func OnlineAuth

func OnlineAuth(auth func(http.HandlerFunc) http.HandlerFunc) Option

func OnlineListener

func OnlineListener(listener net.Listener) Option

func OnlinePort

func OnlinePort(port int) Option

func OnlinePrefix

func OnlinePrefix(prefix string) Option

func OnlineTLS

func OnlineTLS(certFile, keyFile string) Option

func Quiet

func Quiet() Option

func Root

func Root(root http.FileSystem) Option

func RootFiles

func RootFiles(files map[string]string) Option

func RootHtml

func RootHtml(html string) Option

func RootVueHtml

func RootVueHtml(html string) Option

type Page

type Page interface {
	Bind(name string, f interface{}) error
	Eval(js string) Value
	SetReady() error // nofity server ready ( all functions binded )
	Close()
	Done() <-chan struct{}
}

Page of a javascript client.

type RunMode

type RunMode interface {
	IsApp() bool
	IsPage() bool
	IsOnline() bool
	IsLocal() bool
}

type UI

type UI interface {
	Run() error
	Bindable
	RunMode
	Add(name string, child UI) // add sub UI
}

func New

func New(ops ...Option) UI

type UIContext

type UIContext struct {
	Request *http.Request
	Done    <-chan bool
}

type Value

type Value interface {
	Err() error
	To(interface{}) error
	Float() float32
	Int() int
	String() string
	Bool() bool
	Object() map[string]Value
	Array() []Value
}

Value is JSON value or error.

type Window

type Window interface {
	Bind(b Bindings) error
	Open() error
	Server() *FileServer
	SetExitDelay(d time.Duration)
	Eval(js string) Value
	Done() <-chan struct{}
	Close() error
}

func NewApp

func NewApp(root http.FileSystem, x, y int, width, height int, chromeArgs ...string) Window

func NewAppMapURL

func NewAppMapURL(root http.FileSystem, x, y int, width, height int, mapURL func(net.Listener) string, chromeArgs ...string) Window

func NewChromePage

func NewChromePage(root http.FileSystem) Window

func NewNativeWindow

func NewNativeWindow(root http.FileSystem, win NativeWindow, mapURL func(net.Listener) string) Window

func NewPage

func NewPage(root http.FileSystem) Window

func NewPageMapURL

func NewPageMapURL(root http.FileSystem, mapURL func(net.Listener) string) Window

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL