Files
2026-08-11 09:00:01 +02:00

36 lines
784 B
Go

// Package webui embeds the built web application into the binary so the tool
// ships as a single file with no runtime assets to install.
package webui
import (
"embed"
"io/fs"
)
//go:embed all:dist
var dist embed.FS
// FS returns the built web app rooted at its index.html, or nil when the
// frontend has not been built into this binary.
func FS() fs.FS {
sub, err := fs.Sub(dist, "dist")
if err != nil {
return nil
}
if _, err := fs.Stat(sub, "index.html"); err != nil {
return nil
}
return sub
}
// Built reports whether a real UI is embedded, as opposed to the placeholder
// that keeps the package compiling before the frontend is built.
func Built() bool {
sub := FS()
if sub == nil {
return false
}
_, err := fs.Stat(sub, "assets")
return err == nil
}