composition

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2026 License: Apache-2.0 Imports: 12 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 composition promotes DocumentSpecs into deterministic RenderManifests. It is the pure pipeline between collected document data and target-specific filesystem/compilation boundaries.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrCatalogRequired = errors.New("composition catalog is required")
	ErrTargetRequired  = errors.New("composition target is required")
)

Functions

func DirtySet

func DirtySet(previous, next RenderManifest) []string

DirtySet compares two manifests and propagates changed component identities through reverse dependency edges.

Types

type Cache

type Cache interface {
	Get(key string) (Fragment, bool)
	Put(key string, fragment Fragment)
}

Cache stores immutable fragments by promoted component input hash.

type Composer

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

Composer promotes and renders immutable document values.

func New

func New(catalog *component.Catalog, target string, options Options) (*Composer, error)

func (*Composer) Compose

func (composer *Composer) Compose(ctx context.Context, spec document.DocumentSpec) (RenderManifest, error)

Compose performs validation, promotion, bounded rendering, and deterministic manifest assembly. Effects belong after this method.

type Fragment

type Fragment struct {
	ComponentID  string                   `json:"componentId"`
	Key          component.Key            `json:"key"`
	Mode         document.CompositionMode `json:"mode"`
	Content      []byte                   `json:"content,omitempty"`
	Assets       []document.AssetRef      `json:"assets,omitempty"`
	Children     []string                 `json:"children,omitempty"`
	Dependencies []string                 `json:"dependencies,omitempty"`
	Hash         string                   `json:"hash"`
}

Fragment is one content-addressed projection of a component.

type MemoryCache

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

MemoryCache is a race-safe content cache for long-lived composers and preview sessions.

func NewMemoryCache

func NewMemoryCache() *MemoryCache

func (*MemoryCache) Get

func (cache *MemoryCache) Get(key string) (Fragment, bool)

func (*MemoryCache) Put

func (cache *MemoryCache) Put(key string, fragment Fragment)

type Options

type Options struct {
	MaxWorkers int
	Cache      Cache
	Values     map[string]any
}

Options controls bounded execution and reuse.

type RenderManifest

type RenderManifest struct {
	DocumentID   string                         `json:"documentId,omitempty"`
	Theme        string                         `json:"theme,omitempty"`
	Target       string                         `json:"target"`
	RootOrder    []string                       `json:"rootOrder"`
	Fragments    []Fragment                     `json:"fragments"`
	SourceMap    map[string]SourceLocation      `json:"sourceMap"`
	Dependencies map[string][]string            `json:"dependencies"`
	Sources      map[string][]document.AssetRef `json:"sources"`
	Hash         string                         `json:"hash"`
	Stats        Stats                          `json:"stats"`
}

RenderManifest is the stable boundary value produced by composition.

type SourceLocation

type SourceLocation struct {
	FragmentHash string `json:"fragmentHash"`
	Order        int    `json:"order"`
}

SourceLocation maps user-facing component identity to generated material.

type Stats

type Stats struct {
	Rendered  int `json:"rendered"`
	CacheHits int `json:"cacheHits"`
}

Stats reports work avoidance without changing the manifest's semantics.

Jump to

Keyboard shortcuts

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