Documentation
¶
Overview ¶
Package viewspec is the Go port of AppKit ViewSpec validation (@braedonsaunders/appkit-viewspec). Plugin pages arrive as untrusted JSON documents (docs/extend/SPEC.md §5.6); Ether validates them server-side with this package and again in the console before rendering. The two validators share the same rules so they can never disagree:
- The block and cell unions are closed. An unknown kind or a stray property is a rejection, never a best-effort render.
- Block nesting depth is measured on the raw document before any structural parse, so an over-deep document is refused cheaply.
- Field paths may not name __proto__, constructor or prototype.
ValidatePlugin adds the Ether plugin rules on top: class-name fields are rejected (plugins cannot restyle the console), widget and frame names must come from the closed Ether registry, filter bars may only use the controls that make sense for Ether, and tables use the app variant.
Index ¶
Constants ¶
const MaxBlockDepth = 6
MaxBlockDepth caps nested block containers (paper, grid, panel, repeat, frame), mirroring MAX_BLOCK_DEPTH in the TypeScript package.
const SpecVersion = 1
SpecVersion is the only ViewSpec version Ether accepts.
Variables ¶
var ( EtherWidgets = []string{ "ether.posterGrid", "ether.posterShelf", "ether.titleCard", "ether.liveChart", "ether.settingsForm", "ether.actionButton", "ether.titleMatch", "ether.healthStrip", "ether.channelRow", "ether.badge", } EtherFrames = []string{ "ether.section", "ether.tabs", "ether.drawer", } )
The closed Ether widget and frame registry (SPEC §5.6). A plugin document may only name these; anything else is a rejection. The console registry in web/src/viewspec/registry.ts mirrors this list and its prop shapes.
Functions ¶
func ClassFields ¶
func ClassFields() []string
ClassFields returns the field names plugin documents may never carry.
func IsEtherFrame ¶
IsEtherFrame reports whether name is a registered Ether frame.
func IsEtherWidget ¶
IsEtherWidget reports whether name is a registered Ether widget.
func ResolvePath ¶
ResolvePath reads a dot path off a scope value, mirroring resolvePath in the TypeScript package. A missing path returns (nil, nil); a path that names __proto__, constructor or prototype is an error. The guard lives here, not only in validation, so it holds for every caller.
func WidgetNames ¶
func WidgetNames() []string
WidgetNames returns the registered Ether widget names.
Types ¶
type Result ¶
Result is the outcome of validation. When OK is false, Errors names every problem found, each prefixed with the document path that caused it.
func Validate ¶
Validate checks a raw ViewSpec document against the base language: closed unions, strict objects, depth cap and path guards. Class-name fields are allowed here; they are a built-in-spec privilege.
func ValidatePlugin ¶
ValidatePlugin checks a document that came from a plugin. On top of the base language it rejects class-name fields, requires widget and frame names from the Ether registry (with prop shape checks), limits filter-bar controls to search, and requires the app table variant.