gui/core.go
Snider 032c426ac3 feat: initial Wails v3 desktop framework
GUI packages, examples, and documentation for building
desktop applications with Go and web technologies.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 08:44:23 +00:00

52 lines
1.2 KiB
Go

// Package core provides the main runtime and plugin system for Core applications.
package core
import (
"context"
"github.com/host-uk/core-gui/pkg/plugin"
"github.com/host-uk/core-gui/pkg/plugin/builtin/system"
"github.com/host-uk/core-gui/pkg/runtime"
"github.com/wailsapp/wails/v3/pkg/application"
)
// Runtime wraps the internal runtime and plugin system.
type Runtime struct {
*runtime.Runtime
Plugins *plugin.Router
}
// NewRuntime creates a new Core runtime with plugin support.
func NewRuntime() (*Runtime, error) {
// Create the base runtime
rt, err := runtime.New()
if err != nil {
return nil, err
}
// Create the plugin router
plugins := plugin.NewRouter()
// Register built-in plugins
ctx := context.Background()
if err := plugins.Register(ctx, system.New()); err != nil {
return nil, err
}
return &Runtime{
Runtime: rt,
Plugins: plugins,
}, nil
}
// RegisterPlugin adds a plugin to the router.
func (r *Runtime) RegisterPlugin(p plugin.Plugin) error {
return r.Plugins.Register(context.Background(), p)
}
// PluginServices returns Wails services for the plugin system.
func (r *Runtime) PluginServices() []application.Service {
return []application.Service{
application.NewService(r.Plugins),
}
}