view

package
v2.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2026 License: MIT Imports: 4 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package view defines shared declarative product-view definitions and rendering primitives for Compa and its consumer products.

Layer 1 of view architecture:

  • Primitive: rendering shapes (video, audio, markdown, slides, etc.)
  • Card: host presentation of one artifact with provenance
  • ViewDefinition: product-owned declarative workbench screens shared identically between standalone apps (F-APP, M-APP) and Compa module views (F-MOD, M-MOD).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Describe

func Describe(p Primitive) string

Describe returns a human description for the primitive.

func Known

func Known(p Primitive) bool

Known reports whether p is a recognized primitive.

Types

type ActionDefinition

type ActionDefinition struct {
	ID               string         `json:"id"`
	Label            string         `json:"label"`
	Tool             string         `json:"tool"`
	InputTemplate    map[string]any `json:"input_template,omitempty"`
	RequiresApproval bool           `json:"requires_approval,omitempty"`
	KeyboardShortcut string         `json:"keyboard_shortcut,omitempty"`
	DisabledWhen     string         `json:"disabled_when,omitempty"`
}

ActionDefinition defines an explicit user action mapped to a product tool.

type Card

type Card struct {
	ArtifactID string          `json:"artifact_id"`
	Kind       string          `json:"kind"`
	Module     string          `json:"module"`
	Primitive  Primitive       `json:"primitive"`
	MediaType  string          `json:"media_type"`
	Bytes      int64           `json:"bytes"`
	Digest     string          `json:"digest"`
	Title      string          `json:"title,omitempty"`
	URL        string          `json:"url"`
	Inline     json.RawMessage `json:"inline,omitempty"`
}

Card is the host presentation of one artifact.

type Primitive

type Primitive string

Primitive is a rendering shape the host UI knows how to draw.

const (
	Video     Primitive = "video"
	Audio     Primitive = "audio"
	Image     Primitive = "image"
	ImageGrid Primitive = "image_grid"
	Timeline  Primitive = "timeline"
	Markdown  Primitive = "markdown"
	Text      Primitive = "text"
	JSON      Primitive = "json"
	Document  Primitive = "document"
	Diagram   Primitive = "diagram"
	Slides    Primitive = "slides"
	Table     Primitive = "table"
	Download  Primitive = "download"
)

func All

func All() []Primitive

All returns all known primitives.

func FromMediaType

func FromMediaType(mediaType string) Primitive

FromMediaType maps a MIME content type to a standard rendering primitive.

type Registry

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

Registry manages primitive activation state per user.

func NewRegistry

func NewRegistry() *Registry

NewRegistry constructs a new Primitive Registry.

func (*Registry) Enabled

func (r *Registry) Enabled(p Primitive) bool

Enabled reports whether a primitive is active.

func (*Registry) Resolve

func (r *Registry) Resolve(mediaType, presentationHint string) Primitive

Resolve chooses how to render an artifact based on media type and hint.

func (*Registry) SetEnabled

func (r *Registry) SetEnabled(p Primitive, enabled bool)

SetEnabled toggles a primitive on or off.

type SectionDefinition

type SectionDefinition struct {
	ID        string              `json:"id"`
	Title     string              `json:"title,omitempty"`
	Type      string              `json:"type"` // "tab", "row", "col", "viewer", "card"
	Primitive Primitive           `json:"primitive,omitempty"`
	Binding   string              `json:"binding,omitempty"` // json path into state or artifact
	EmptyText string              `json:"empty_text,omitempty"`
	Children  []SectionDefinition `json:"children,omitempty"`
}

SectionDefinition is a node in the view composition tree.

type ViewDefinition

type ViewDefinition struct {
	ID             string              `json:"id"`
	SchemaVersion  string              `json:"schema_version"`
	Title          string              `json:"title"`
	Module         string              `json:"module"`
	ArtifactSchema string              `json:"artifact_schema,omitempty"`
	Sections       []SectionDefinition `json:"sections"`
	Actions        []ActionDefinition  `json:"actions,omitempty"`
}

ViewDefinition is the shared declarative specification of a product workbench.

func (*ViewDefinition) Digest

func (v *ViewDefinition) Digest() string

Digest returns the deterministic sha256: prefix digest of the canonical JSON definition. F-APP/F-MOD and M-APP/M-MOD use this to verify matching view definitions.

type ViewState

type ViewState string

ViewState identifies standard operational states for view rendering.

const (
	StateLoading          ViewState = "loading"
	StateEmpty            ViewState = "empty"
	StateFailed           ViewState = "failed"
	StateAwaitingApproval ViewState = "awaiting_approval"
	StateCompleted        ViewState = "completed"
	StateUnsupported      ViewState = "unsupported"
)

Jump to

Keyboard shortcuts

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