viewspec

package
v0.3.4 Latest Latest
Warning

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

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

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

View Source
const MaxBlockDepth = 6

MaxBlockDepth caps nested block containers (paper, grid, panel, repeat, frame), mirroring MAX_BLOCK_DEPTH in the TypeScript package.

View Source
const SpecVersion = 1

SpecVersion is the only ViewSpec version Ether accepts.

Variables

View Source
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 IsEtherFrame

func IsEtherFrame(name string) bool

IsEtherFrame reports whether name is a registered Ether frame.

func IsEtherWidget

func IsEtherWidget(name string) bool

IsEtherWidget reports whether name is a registered Ether widget.

Types

type Result

type Result struct {
	OK     bool
	Errors []string
}

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 ValidatePlugin

func ValidatePlugin(raw []byte) Result

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.

Jump to

Keyboard shortcuts

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