authoring

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2026 License: MIT Imports: 21 Imported by: 1 module, 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 authoring owns the shared plugin lifecycle; it imports no feature implementation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Action

func Action(id string) string

Extract the action suffix from its qualified identifier

func Active

func Active(ev sdk.Event) bool

Recognize an activating key or dial input

func CloneFeedback

func CloneFeedback(source map[string]any) map[string]any

Clone feedback so later mutation cannot change render history

func CloneSetting

func CloneSetting(value any) any

Clone one supported settings value

func CloneSettings

func CloneSettings(value map[string]any) map[string]any

Clone a settings map without sharing nested mutable values

func DisplayLayout

func DisplayLayout(wide bool) []byte

Select the embedded wide or square display layout

func DisplayLines

func DisplayLines(text string, columns int) []string

Wrap text into bounded display lines

func DisplayMessages

func DisplayMessages(id string, previous *Display, view Display, rich, states bool) []sdk.Event

DisplayMessages computes one desired revision. Commit the snapshot only after every queued write succeeds; reset it after host/context/theme changes

func FeedbackEqual

func FeedbackEqual(a, b any) bool

Compare feedback with consistent JSON numeric semantics

func ResultText

func ResultText(value any) string

Convert a job result to concise display text

func StartObservationJob

func StartObservationJob(ctx context.Context, e *Engine, id string, work func(context.Context) (string, any, error), apply func(context.Context, *sdk.Client, JobResult, BackgroundJob) error) bool

StartObservationJob schedules a read after a command. Admission, cancellation, and read failures never change the command receipt. Apply receives read errors in JobResult; use StartJob for work that determines command success

func ThemeAsset

func ThemeAsset(path, ThemeName string) string

Choose a themed variant of an asset path

func ValidateViewTargets

func ValidateViewTargets(def Definition) error

Validate complete and unambiguous view-target declarations

Types

type ActionHooks

type ActionHooks struct {
	Input       func(context.Context, *sdk.Client, sdk.Event, Binding) error
	Appeared    func(context.Context, *sdk.Client, sdk.Event, Binding) error
	Changed     func(context.Context, *sdk.Client, sdk.Event, Binding) error
	Disappeared func(context.Context, *sdk.Client, sdk.Event, Binding) error
	Render      func(context.Context, *sdk.Client, string, Binding) (Display, error)
}

type BackgroundJob

type BackgroundJob struct {
	Cancel     context.CancelFunc
	StopCancel func() bool
	Generation uint64
	Complete   func(error)
	Owner      string
	Refresh    bool
	ActionCtx  context.Context
	Poll       any
	Apply      func(context.Context, *sdk.Client, JobResult, BackgroundJob) error
}

type Binding

type Binding struct {
	Action   string
	Settings map[string]any
	Surface  *sdk.Surface
}

type Definition

type Definition struct {
	ID string `json:"id,omitempty"`
	// RuntimeAssets lists feature-owned paths selected dynamically rather than by action metadata
	RuntimeAssets        []string     `json:"-"`
	ViewTargets          []ViewTarget `json:"-"`
	Slug                 string       `json:"slug"`
	Name                 string       `json:"name"`
	Version              string       `json:"version"`
	MinimumManager       string       `json:"minimum_manager"`
	RequiredCapabilities []string     `json:"required_capabilities"`
	Actions              []string     `json:"actions"`
}

type Display

type Display struct {
	Layout   string
	Image    string
	Title    string
	State    int
	Feedback map[string]any
}

func CompactDisplay

func CompactDisplay(view Display, width, height int) Display

CompactDisplay gives a semantic value and label more room on small square keys It preserves the full title, saved element identities, and the input snapshot

func Present

func Present(view Display, content *Presentation, width, height int) Display

Present selects semantic rows without changing layout identities, legacy element keys, canvas sources, or the full live-text customization source

func StatusDisplay

func StatusDisplay(status DisplayStatus, surface *sdk.Surface, visual Visual, theme string) Display

Convert status and visual preferences into a display

type DisplayStatus

type DisplayStatus struct {
	Content     *Presentation
	Icon        string
	Text        string
	State       int
	Unavailable bool
}

type Engine

type Engine struct {
	Now        func() time.Time
	Registered map[string]ActionHooks
	Store      *storage.Store

	Slug, Path, Theme          string
	Global                     map[string]any
	Bindings                   map[string]Binding
	Statuses, Samples          map[string]SampledStatus
	Probes                     *sdk.ProbePool
	WakeChannel                chan struct{}
	PendingWrite, NextPeriodic time.Time
	Written                    []byte
	DirtyState, Closed         bool
	ProbeKeys                  map[string]string
	Effective                  map[string]map[string]any
	DisplayTicks               map[string]int
	Jobs                       map[string]BackgroundJob
	Generation                 uint64
	Completed                  chan JobResult
	ResultsText                map[string]string
	Results                    map[string]any
	Checked                    map[string]time.Time
	Last                       map[string]Display
	LastStatus                 map[string]DisplayStatus
	Mu                         sync.Mutex
	Feature                    Feature
	ViewTargets                map[string]ViewTarget
	ViewActive                 map[string]bool
	// contains filtered or unexported fields
}

func New

func New(def Definition, path string, factory Factory) *Engine

Construct the action engine and initialize its state maps

func (*Engine) ActionKey

func (e *Engine) ActionKey(action string) string

Resolve a registered action key from a qualified identifier

func (*Engine) ActivateView

func (e *Engine) ActivateView(id string)

Mark a binding as activated for subsequent live updates

func (*Engine) ApplyJobResult

func (e *Engine) ApplyJobResult(ctx context.Context, c *sdk.Client, result JobResult) (err error)

Completion callbacks are attached to individual jobs, never selected by plugin identity

func (*Engine) BatchDial

func (e *Engine) BatchDial(id string) bool

Check whether this action permits dial event coalescing

func (*Engine) BuildDisplayView

func (e *Engine) BuildDisplayView(id string, status DisplayStatus) Display

Build a binding display using its current surface and theme

func (*Engine) CanUpdateView

func (e *Engine) CanUpdateView(ctx context.Context, id string) bool

Authorize rendering using origin, activation and shared identity

func (*Engine) CancelJob

func (e *Engine) CancelJob(id string)

Cancel a binding job and settle its deferred action

func (*Engine) ClearContext

func (e *Engine) ClearContext(id string)

Cancel binding-owned work and clear transient context

func (*Engine) Close

func (e *Engine) Close() error

Stop feature work and flush pending state

func (*Engine) CollectStatus

func (e *Engine) CollectStatus(ctx context.Context, id string, b Binding) DisplayStatus

Collect feature status and cached job outcomes

func (*Engine) DisplayView

func (e *Engine) DisplayView(id string, status DisplayStatus) Display

Build a display without sending host messages

func (*Engine) DrainJobs

func (e *Engine) DrainJobs(ctx context.Context, c *sdk.Client) error

Drain completed background jobs on the owner loop

func (*Engine) EffectiveSettings

func (e *Engine) EffectiveSettings(id string, settings map[string]any) map[string]any

Return the cached effective settings for a binding

func (*Engine) FinishJob

func (e *Engine) FinishJob(ctx context.Context, c *sdk.Client, result JobResult, job BackgroundJob) error

Finish a job and settle its deferred action

func (*Engine) Handle

func (e *Engine) Handle(ctx context.Context, c *sdk.Client, ev sdk.Event) (err error)

Dispatch lifecycle and input events through feature hooks

func (*Engine) InspectBasic

func (e *Engine) InspectBasic(ctx context.Context, c *sdk.Client, ev sdk.Event) (bool, error)

Handle shared inspector requests before feature-specific requests

func (*Engine) InvalidateProbe

func (e *Engine) InvalidateProbe(id string)

Invalidate the shared probe associated with a binding

func (*Engine) MergedSettings

func (e *Engine) MergedSettings(settings map[string]any) map[string]any

Clone global settings and overlay binding-specific values

func (*Engine) NextPoll

func (e *Engine) NextPoll(now time.Time) time.Time

Choose the next explicit job or feature deadline

func (*Engine) Persist

func (e *Engine) Persist() error

Write changed feature state only after a successful read

func (*Engine) Poll

func (e *Engine) Poll(ctx context.Context, c *sdk.Client) error

Process scheduled feature work and completed jobs

func (*Engine) ProbeKey

func (e *Engine) ProbeKey(id string, b Binding) string

Resolve the shared sampling key for a binding

func (*Engine) RefreshProbe

func (e *Engine) RefreshProbe(id string)

Request a new sample for the binding probe

func (*Engine) Register

func (e *Engine) Register(action string, hooks ActionHooks) error

Register adds a complete action UUID with live rendering by default

func (*Engine) Render

func (e *Engine) Render(ctx context.Context, c *sdk.Client, id string) error

Build and send the current binding display

func (*Engine) RenderViewTargets

func (e *Engine) RenderViewTargets(ctx context.Context, c *sdk.Client) error

Refresh other bindings explicitly targeted by this event

func (*Engine) Restore

func (e *Engine) Restore(dst any) error

Restore loads file-backed state atomically and reports failures directly Rejected state remains protected until an explicit successful restore

func (*Engine) RoutinePersist

func (e *Engine) RoutinePersist() error

Persist dirty state once its debounce deadline is due

func (*Engine) SendDisplay

func (e *Engine) SendDisplay(ctx context.Context, c *sdk.Client, id string, status DisplayStatus) error

Build and send the binding status display

func (*Engine) SendDisplayView

func (e *Engine) SendDisplayView(ctx context.Context, c *sdk.Client, id string, view Display, states bool) error

Send a display subject to the current view-update scope

func (*Engine) ShouldLogAction

func (e *Engine) ShouldLogAction(ev sdk.Event) bool

Decide whether an input event merits an action log

func (*Engine) StartJob

func (e *Engine) StartJob(ctx context.Context, id string, work func(context.Context) (string, any, error), apply func(context.Context, *sdk.Client, JobResult, BackgroundJob) error) bool

Schedule bounded background work with binding ownership

func (*Engine) StartOrReplaceJob

func (e *Engine) StartOrReplaceJob(ctx context.Context, id string, replace bool, work func(context.Context) (string, any, error), apply func(context.Context, *sdk.Client, JobResult, BackgroundJob) error) bool

Admit a job or explicitly replace the existing binding job

func (*Engine) ThemeName

func (e *Engine) ThemeName() string

Return the current theme name

func (*Engine) ThemedAsset

func (e *Engine) ThemedAsset(path string) string

Resolve an asset using the current plugin theme

func (*Engine) ThemedLayout

func (e *Engine) ThemedLayout(path string) string

Resolve a layout using the current plugin theme

func (*Engine) Time

func (e *Engine) Time() time.Time

Read the injected clock or the system clock

func (*Engine) ViewIsActive

func (e *Engine) ViewIsActive(id string) bool

Report whether the binding has been activated

func (*Engine) Wake

func (e *Engine) Wake() <-chan struct{}

Expose the wake signal used by the host event loop

func (*Engine) WantsLiveView

func (e *Engine) WantsLiveView(id string) bool

Decide whether live updates are enabled for this binding

type Factory

type Factory func(*Engine) Feature

type Feature

type Feature struct {
	ShouldLogAction func(sdk.Event) bool
	DemandChanged   func()
	Present         func(string, DisplayStatus) Presentation
	Actions         map[string]func(context.Context, *sdk.Client, sdk.Event, Binding) error
	Before          func(context.Context, *sdk.Client, sdk.Event) (bool, error)
	After           func(context.Context, *sdk.Client, sdk.Event) error
	Action          func(context.Context, *sdk.Client, sdk.Event, Binding) error
	Inspector       func(context.Context, *sdk.Client, sdk.Event) (bool, error)
	Settings        func(string)
	Clear           func(string)
	Unbound         func(string)
	Status          func(context.Context, string, Binding) DisplayStatus
	Collect         func(context.Context, string, Binding) DisplayStatus
	Poll            func(context.Context, *sdk.Client) (bool, error)
	Deadline        func(time.Time) time.Time
	View            func(string, DisplayStatus) Display
	Render          func(context.Context, *sdk.Client, string) error
	Close           func()
	Progress        func()
	Snapshot        func() any
	Apply           func(context.Context, *sdk.Client, JobResult, BackgroundJob) error
	Visuals         map[string]Visual
	DynamicDisplay  bool
	AdditiveDial    func(string) bool
}

Feature callbacks run on the SDK event loop. Background work receives immutable snapshots

type JobResult

type JobResult struct {
	ID         string
	Generation uint64
	Text       string
	Value      any
	Err        error
}

type Presentation

type Presentation struct {
	Kind         string
	Primary      string
	Label        string
	Detail       string
	Progress     float64
	ShowProgress bool
}

Presentation is optional semantic content. Text remains the legacy/customized live-text source; zero content preserves historical rendering

func ConciseStatus

func ConciseStatus(text string) Presentation

ConciseStatus is a safe default for a connector that still returns legacy text. Drivers may supply richer content through optional Presentation below

type Renderer

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

func (*Renderer) Render

func (r *Renderer) Render(ctx context.Context, c *sdk.Client, id string, view Display) error

Send changed display messages and retain successful rendering state

func (*Renderer) Reset

func (r *Renderer) Reset(id string)

Forget the renderer history for one binding

type SampledStatus

type SampledStatus struct {
	Status   DisplayStatus
	At       time.Time
	Failures int
	Next     time.Time
}

type ViewTarget

type ViewTarget struct {
	Action          string
	UpdatedBy       []string
	Shared          bool
	Live            bool
	AfterActivation bool
}

ViewTarget declares which actions may refresh a view. Command feedback uses exact binding contexts; Shared requires an explicit matching shared_id Live views observe their own state. AfterActivation reserves live progress for a control that has actually been used, rather than every copy of its action

type Visual

type Visual struct {
	Icon   string
	States []string
}

Jump to

Keyboard shortcuts

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