webui

package module
v2.4.2 Latest Latest
Warning

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

Go to latest
Published: May 26, 2024 License: MIT Imports: 8 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bind

func Bind[T any](w Window, element string, callback func(Event) T)

Bind binds a specific html element click event with a function. Empty element means all events.

func Clean added in v2.4.2

func Clean()

Clean frees all memory resources. It should only be called at the end.

func Decode

func Decode(str string) string

Decode decodes Base64 encoded text received from the the UI.

func DeleteAllProfiles added in v2.4.2

func DeleteAllProfiles()

DeleteAllProfiles deletes all local web-browser profile folders. It should only be called at the end.

func Encode

func Encode(str string) string

Encode sends text based data to the UI using base64 encoding.

func Exit

func Exit()

Exit closes all open windows. `Wait()` will return (Break).

func GetArg added in v2.4.1

func GetArg[T any](e Event) (arg T, err error)

GetArg parses the JavaScript argument into a Go data type.

func GetArgAt added in v2.4.1

func GetArgAt[T any](e Event, idx uint) (arg T, err error)

GetArgAt parses the JavaScript argument with the specified index into a Go data type.

func SetDefaultRootFolder added in v2.4.2

func SetDefaultRootFolder(path string)

SetDefaultRootFolder sets the web-server root folder path for all windows.

func SetRootFolder added in v2.4.1

func SetRootFolder(path string)

SetRootFolder sets the web-server root folder path for all windows. Deprecated: use SetDefaultRootFolder instead

func SetTLSCertificate added in v2.4.2

func SetTLSCertificate(certificate_pem string, private_key_pem string)

SetTLSCertificate sets the SSL/TLS certificate and the private key content, both in PEM format. This works only with the `webui-2-secure` library. If set to empty, WebUI will generate a self-signed certificate.

func SetTimeout

func SetTimeout(seconds uint)

SetTimeout sets the maximum time in seconds to wait for the browser to start.

func Wait

func Wait()

Wait waits until all opened windows get closed.

Types

type Browser added in v2.4.1

type Browser uint8
const (
	NoBrowser Browser = iota
	AnyBrowser
	Chrome
	Firefox
	Edge
	Safari
	Chromium
	Opera
	Brave
	Vivaldi
	Epic
	Yandex
	ChromiumBased
)

type Event

type Event struct {
	Window    Window
	EventType EventType
	Element   string
	// contains filtered or unexported fields
}

func (Event) GetSize added in v2.4.1

func (e Event) GetSize() uint

GetSize returns the size of the first JavaScript argument.

func (Event) GetSizeAt added in v2.4.1

func (e Event) GetSizeAt(idx uint) uint

GetSize returns the size of the JavaScript at the specified index.

type EventType added in v2.4.1

type EventType uint8
const (
	Disconnected EventType = iota
	Connected
	MouseClick
	Navigation
	Callback
)

type Runtime added in v2.4.1

type Runtime uint8
const (
	None Runtime = iota
	Deno
	Nodejs
)

type ScriptOptions added in v2.4.1

type ScriptOptions struct {
	Timeout    uint
	BufferSize uint
}

type Void added in v2.4.1

type Void *struct{}

type Window added in v2.4.1

type Window uint

func NewWindow

func NewWindow() Window

NewWindow creates a new WebUI window object and returns the window number.

func NewWindowId added in v2.4.1

func NewWindowId() Window

NewWindowId returns a free window number that can be used with `NewWindow`.

func (Window) Bind added in v2.4.1

func (w Window) Bind(element string, callback func(Event) any)

Bind binds a specific html element click event with a function. Empty element means all events.

func (Window) Close added in v2.4.1

func (w Window) Close()

Close closes the window. The window object will still exist.

func (Window) DeleteProfile added in v2.4.2

func (w Window) DeleteProfile()

DeleteProfile deletes the specified windows local web-browser profile folder.

func (Window) Destroy added in v2.4.1

func (w Window) Destroy()

Destroy closes the window and free all memory resources.

func (Window) GetChildProcessID added in v2.4.2

func (w Window) GetChildProcessID() uint64

GetParentProcessID returns the ID of the last child process.

func (Window) GetParentProcessID added in v2.4.2

func (w Window) GetParentProcessID() uint64

GetParentProcessID returns the ID of the parent process (The web browser may re-create another new process).

func (Window) GetUrl added in v2.4.1

func (w Window) GetUrl() string

GetUrl returns the full current URL

func (Window) IsShown added in v2.4.1

func (w Window) IsShown() bool

IsShown checks if the window it's still running.

func (Window) Navigate added in v2.4.1

func (w Window) Navigate(url string)

Navigate navigates to a specific URL.

func (Window) NewWindow added in v2.4.1

func (w Window) NewWindow()

NewWindow creates a new webui window object using a specified window number.

func (Window) Run added in v2.4.1

func (w Window) Run(script string)

Run executres JavaScript without waiting for the response.

func (Window) Script added in v2.4.1

func (w Window) Script(script string, options ScriptOptions) (resp string, err error)

Script executes JavaScript and returns the response (Make sure the response buffer can hold the response). The default BufferSize is 8KiB.

func (Window) SetHide added in v2.4.1

func (w Window) SetHide(status bool)

SetHide determines whether the window is run in hidden mode.

func (Window) SetIcon added in v2.4.1

func (w Window) SetIcon(icon string, icon_type string)

SetIcon sets the default embedded HTML favicon.

func (Window) SetKiosk added in v2.4.1

func (w Window) SetKiosk(enable bool)

SetKiosk determines whether Kiosk mode (full screen) is enabled for the window.

func (Window) SetPort added in v2.4.2

func (w Window) SetPort(port uint) bool

SetPort sets a custom web-server network port to be used by WebUI.

func (Window) SetPosition added in v2.4.1

func (w Window) SetPosition(x uint, y uint)

SetPosition sets the window position.

func (Window) SetProfile added in v2.4.1

func (w Window) SetProfile(name string, path string)

SetProfile sets the web browser profile to use. An empty `name` and `path` means the default user profile. Needs to be called before `webui_show()`.

func (Window) SetProxy added in v2.4.2

func (w Window) SetProxy(name string, proxyServer string)

SetProxy sets the web browser proxyServer to use. Need to be called before `Show()`.

func (Window) SetPublic added in v2.4.2

func (w Window) SetPublic(name string, status bool)

SetPublic allows a specific window address to be accessible from a public network.

func (Window) SetRootFolder added in v2.4.1

func (w Window) SetRootFolder(path string)

SetRootFolder sets the web-server root folder path for the window.

func (Window) SetRuntime added in v2.4.1

func (w Window) SetRuntime(runtime Runtime)

SetRuntime sets the runtime for .js and .ts files to Deno and Nodejs.

func (Window) SetSize added in v2.4.1

func (w Window) SetSize(width uint, height uint)

SetSize sets the window size.

func (Window) Show added in v2.4.1

func (w Window) Show(content string) (err error)

Show opens a window using embedded HTML, or a file. If the window is already open, it will be refreshed.

func (Window) ShowBrowser added in v2.4.1

func (w Window) ShowBrowser(content string, browser Browser) (err error)

ShowBrowser opens a window using embedded HTML, or a file in a specific web browser. If the window is already open, it will be refreshed.

Jump to

Keyboard shortcuts

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