Documentation
¶
Overview ¶
Package pluginhost is the cockpit's side of the plugin package: the public package is contract only, and the implementations behind its interfaces live here, construction, sealing and collection included. The helpers below read the sealed Serves the plugins filled at ConfigureServe and hand each surface exactly the view it renders.
Index ¶
- func AssetPrefix(s *Serve) string
- func ServesHTTP(s *Serve) bool
- func SlotHTML(serves []*Serve, slot string) template.HTML
- func Starter(s *Serve, resolve func(string) string) (string, bool)
- func StarterPath(s *Serve) string
- type Element
- type Registration
- type Serve
- func (s *Serve) AddAssets(files fs.FS)
- func (s *Serve) AddCustomElement(name, module string) plugin.CustomElement
- func (s *Serve) AddRoutes(handler http.Handler) plugin.Routes
- func (s *Serve) AddSlotHTML(slot, html string)
- func (s *Serve) Assets() fs.FS
- func (s *Serve) CustomElements() []Registration
- func (s *Serve) Handler() http.Handler
- func (s *Serve) ID() string
- func (s *Serve) Projects() plugin.Projects
- func (s *Serve) ProjectsDir() string
- func (s *Serve) SlotHTML(slot string) string
- func (s *Serve) StateDir() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssetPrefix ¶
AssetPrefix is the manifest path prefix of one plugin's added assets, without the leading slash, the way the asset manifest names files.
func ServesHTTP ¶
ServesHTTP reports whether the plugin's subtree answers anything, which is what decides whether the router registers it at all.
func SlotHTML ¶
SlotHTML concatenates what every plugin added for the named slot. The markup is compiled in plugin code and deliberately not escaped, that is the whole point of a slot.
func Starter ¶
Starter generates the starter module for one plugin: it imports the class module of every added element through resolve, which answers the hashed URL of a raw asset path, and defines each element under its final name with a get guard. False when the plugin added no elements.
func StarterPath ¶
StarterPath is the raw URL of the cockpit's generated starter module for one plugin, the module the import map binds the plugin's element names to. The path is reserved inside the plugin's subtree.
Types ¶
type Element ¶
Element is one final element name with the URL of the starter module that defines it, ready for the import map: the lazy loader imports unknown element names, so binding the name to the starter is what loads a plugin's code the first time one of its elements is on a page.
type Registration ¶
Registration is one added custom element as the cockpit reads it: the final name next to the module path inside the added assets.
type Serve ¶
type Serve struct {
// contains filtered or unexported fields
}
Serve implements plugin.Serve for one wired plugin, and it is also the cockpit's reading side of what that plugin added. What each method means is documented on the plugin package's interfaces, the contract; this is the construction, the sealing and the collection behind it.
func ConfigureServe ¶
func ConfigureServe(plugins []plugin.Named[plugin.ServePlugin], projectsDir, stateDir string, createProject func(ctx context.Context, name string) (string, error), projectChanged func(ctx context.Context) error) ([]*Serve, error)
ConfigureServe runs every pair's ConfigureServe, each with a fresh Serve bound to the pair's id and to the serving instance, and answers the sealed Serves in pair order. It is the cockpit's call at serve start, after the configuration is loaded and before the server listens; the ids are validated before, see distro.Main. createProject is the web UI's own project creation path and projectChanged its announcement path, which is what the projects facade delegates to. A failing plugin aborts the start with its id on the error.
func (*Serve) AddCustomElement ¶
func (s *Serve) AddCustomElement(name, module string) plugin.CustomElement
func (*Serve) AddSlotHTML ¶
func (*Serve) CustomElements ¶
func (s *Serve) CustomElements() []Registration
CustomElements answers the added elements, in call order.