Documentation
¶
Overview ¶
Package viewer presents a served site to the user. It has two implementations chosen at build time: by default (pure Go, CGO_ENABLED=0) it opens the system browser, and with the "webview" build tag (which needs cgo) it opens a native window backed by the operating system's WebView, so a packed kage binary feels like a standalone app rather than a browser tab.
Both builds expose the same three symbols: Native, LockMainThread, and Show. The caller starts an HTTP server, then calls Show on the main goroutine; Show blocks until the window is closed (native) or the context is cancelled (browser), at which point the caller shuts the server down.
Index ¶
Constants ¶
const Native = false
Native is false in the default pure-Go build: there is no native window, so the viewer hands the URL to the system browser.
Variables ¶
This section is empty.
Functions ¶
func LockMainThread ¶
func LockMainThread()
LockMainThread is a no-op without a native UI to pin to the main thread.
func Show ¶
Show opens the system browser at o.URL when o.Browser is set, then blocks until the context is cancelled (Ctrl-C), leaving the caller's HTTP server up in the meantime. Launching the browser is best-effort; a failure is ignored because the URL has already been printed for the user to open by hand.
Types ¶
type Options ¶
type Options struct {
Title string // window title; the archive's M/Title, falling back to "kage"
URL string // local URL the server is listening on
// Browser, in the default build, opens the system browser. The native build
// ignores it and always shows its own window.
Browser bool
}
Options configures a viewer window.