vela

package
v0.3.16 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2026 License: GPL-3.0 Imports: 43 Imported by: 0

Documentation

Overview

Package vela presents the Vela v0 protocol through neutral host services.

Index

Constants

View Source
const (
	MaxAppNameChars   = 40
	MaxWordmarkBytes  = 512 << 10
	MaxWordmarkWidth  = 1024
	MaxWordmarkHeight = 256
)
View Source
const (
	MaxSkinArchiveBytes  = 8 << 20  // 8 MB .vskin archive
	MaxSkinExpandedBytes = 32 << 20 // 32 MB expanded contents
	MaxSkinArchiveFiles  = 200      // max files in .vskin
	MaxSkinPackBytes     = 64 << 10 // 64 KB SkinPack JSON
	MaxSkinDocumentBytes = 2 << 20  // 2 MB SkinDocument JSON

)

Variables

View Source
var (
	ErrBuiltinSkin  = errors.New("built-in skins cannot be modified or removed")
	ErrSkinNotFound = errors.New("skin not found")
	ErrSkinInvalid  = errors.New("invalid skin package")
)
View Source
var (
	ErrWordmarkTooLarge = errors.New("wordmark exceeds 512 KB")
)

Functions

func AppearanceChanged

func AppearanceChanged(before, after map[string]any) bool

AppearanceChanged reports whether two Vela settings maps produce a different appearance/branding snapshot.

func IsBuiltinSkinID

func IsBuiltinSkinID(id string) bool

IsBuiltinSkinID reports whether id names the compiled cinematic engine alias or one of Vela's non-removable built-in skin documents.

func NativeLibraryType

func NativeLibraryType(mt frontend.MediaType) string

func NormalizeSettings

func NormalizeSettings(s frontend.Settings) frontend.Settings

NormalizeSettings trims appName, omits unset branding keys, and clones wordmark maps.

func ProjectLibrary

func ProjectLibrary(p frontend.Presentations, fallback frontend.MediaType) (frontend.MediaType, string, bool)

ProjectLibrary interprets this adapter's presentation declaration. Console-only and adapter-only sources remain unpublished; visibility is still applied by Experience.Views.

func PruneWordmarks

func PruneWordmarks(ctx context.Context, db *sql.DB, settings map[string]any)

PruneWordmarks removes unreferenced wordmarks older than an hour so an uploaded draft is never deleted mid-edit while old assets do not accumulate.

func ValidSkinID

func ValidSkinID(id string) bool

ValidSkinID reports whether id matches the Vela skin identifier grammar.

Types

type BuiltinSkin

type BuiltinSkin struct {
	ID       string
	Name     string
	Version  string
	Swatches []string
}

BuiltinSkin describes a non-removable skin shipped with Vela.

func BuiltinSkins

func BuiltinSkins() []BuiltinSkin

BuiltinSkins returns the non-removable built-in skin documents in display order.

type Frontend

type Frontend struct {
	AssetsDir string
	DB        *sql.DB
	ReplayKey []byte
	Skins     *SkinStore
}

func (Frontend) Describe

func (Frontend) Describe() frontend.Descriptor

func (Frontend) Mount

func (f Frontend) Mount(ctx context.Context, host frontend.Host) (frontend.Instance, error)

func (Frontend) ValidateSettings

func (f Frontend) ValidateSettings(s frontend.Settings) error

ValidateSettings keeps the owner setting additive without accepting arbitrary config.

type SkinDocumentEntry

type SkinDocumentEntry struct {
	ID       string   `json:"id"`
	Name     string   `json:"name"`
	Version  string   `json:"version"`
	URL      string   `json:"url"`
	Preview  string   `json:"preview,omitempty"`
	Swatches []string `json:"swatches"`
}

SkinDocumentEntry is an entry in GET /vela/v0/appearance documents[].

type SkinStore

type SkinStore struct {
	// contains filtered or unexported fields
}

SkinStore manages owner-installed Vela skins on disk and in the database.

func NewSkinStore

func NewSkinStore(db *sql.DB, dir string) *SkinStore

NewSkinStore creates a store backed by db and dir (typically <dataDir>/vela-skins).

func (*SkinStore) HasInstalled

func (s *SkinStore) HasInstalled(ctx context.Context, id string) bool

HasInstalled reports whether id is currently installed.

func (*SkinStore) InstallArchive

func (s *SkinStore) InstallArchive(ctx context.Context, pkg []byte) (SkinSummary, error)

InstallArchive validates, rewrites, atomically unpacks, and persists a .vskin archive.

func (*SkinStore) List

func (s *SkinStore) List(ctx context.Context, velaClientDir string) []SkinSummary

List returns built-in skins followed by owner-installed skins. When velaClientDir contains skins/catalog.json, built-in previews, versions, and swatches are enriched from it.

func (*SkinStore) Remove

func (s *SkinStore) Remove(ctx context.Context, id string) error

Remove deletes an owner-installed skin from the database and disk.

func (*SkinStore) Snapshot

func (s *SkinStore) Snapshot(ctx context.Context) (generation uint64, packs []json.RawMessage, documents []SkinDocumentEntry, kinds map[string]string)

Snapshot returns the cached appearance entries and installed skin kinds.

type SkinSummary

type SkinSummary struct {
	ID          string   `json:"id"`
	Name        string   `json:"name"`
	Version     string   `json:"version"`
	Kind        string   `json:"kind"` // "pack" or "document"
	Builtin     bool     `json:"builtin"`
	Preview     string   `json:"preview,omitempty"`
	Swatches    []string `json:"swatches"`
	InstalledAt int64    `json:"installedAt,omitempty"`
}

SkinSummary describes a built-in or owner-installed skin for the console.

type Wordmark

type Wordmark struct {
	URL    string `json:"url"`
	Width  int    `json:"width"`
	Height int    `json:"height"`
	Digest string `json:"digest"`
}

Wordmark is a validated, content-addressed owner wordmark asset.

func UploadWordmark

func UploadWordmark(ctx context.Context, db *sql.DB, r io.Reader) (Wordmark, error)

UploadWordmark validates a PNG, SVG, or WebP wordmark (<= 512 KB, <= 1024x256 px) and stores it by SHA-256 digest for unauthenticated immutable serving under /vela/v0/branding/.

type WordmarkValidationError

type WordmarkValidationError struct {
	Message string
}

WordmarkValidationError reports an invalid wordmark image or dimension check.

func (*WordmarkValidationError) Error

func (e *WordmarkValidationError) Error() string

Jump to

Keyboard shortcuts

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