workbenchlayout

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: May 30, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventTypeLayoutReplaced      = "layout.replaced"
	EventTypeWidgetStateUpserted = "widget_state.upserted"

	WidgetTypeFiles    = "redeven.files"
	WidgetTypeTerminal = "redeven.terminal"
	WidgetTypePreview  = "redeven.preview"

	WidgetStateKindFiles    = "files"
	WidgetStateKindTerminal = "terminal"
	WidgetStateKindPreview  = "preview"

	OpenPreviewStrategySameFileOrCreate    = "same_file_or_create"
	OpenPreviewStrategyFocusLatestOrCreate = "focus_latest_or_create"
	OpenPreviewStrategyCreateNew           = "create_new"

	DefaultPreviewWidgetWidth  = 900
	DefaultPreviewWidgetHeight = 620

	TerminalMinFontSize = 10
	TerminalMaxFontSize = 20

	StickyNoteKind         = "sticky_note"
	TextAnnotationKind     = "text"
	DefaultStickyNoteBody  = "Untitled note"
	DefaultStickyNoteColor = "amber"

	DefaultAnnotationText       = "Text"
	DefaultAnnotationFontFamily = `ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif`
	DefaultAnnotationFontWeight = 800
	DefaultAnnotationFontSize   = 45
	DefaultAnnotationColor      = "#6b7280"
	DefaultAnnotationAlign      = "left"

	DefaultBackgroundLayerName     = "Canvas region"
	DefaultBackgroundLayerFill     = "#9da8a1"
	DefaultBackgroundLayerOpacity  = 0.72
	DefaultBackgroundLayerMaterial = "dotted"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BackgroundLayer

type BackgroundLayer struct {
	ID              string  `json:"id"`
	Name            string  `json:"name"`
	Fill            string  `json:"fill"`
	Opacity         float64 `json:"opacity"`
	Material        string  `json:"material"`
	X               float64 `json:"x"`
	Y               float64 `json:"y"`
	Width           float64 `json:"width"`
	Height          float64 `json:"height"`
	ZIndex          int     `json:"z_index"`
	CreatedAtUnixMs int64   `json:"created_at_unix_ms"`
	UpdatedAtUnixMs int64   `json:"updated_at_unix_ms"`
}

type Event

type Event struct {
	Seq             int64           `json:"seq"`
	Type            string          `json:"type"`
	CreatedAtUnixMs int64           `json:"created_at_unix_ms"`
	Payload         json.RawMessage `json:"payload"`
}

type OpenPreviewRequest added in v0.6.4

type OpenPreviewRequest struct {
	RequestID    string                  `json:"request_id,omitempty"`
	Item         PreviewItem             `json:"item"`
	OpenStrategy string                  `json:"open_strategy,omitempty"`
	Viewport     OpenPreviewViewportHint `json:"viewport,omitempty"`
}

type OpenPreviewResponse added in v0.6.4

type OpenPreviewResponse struct {
	RequestID   string      `json:"request_id,omitempty"`
	WidgetID    string      `json:"widget_id"`
	Created     bool        `json:"created"`
	Snapshot    Snapshot    `json:"snapshot"`
	WidgetState WidgetState `json:"widget_state"`
}

type OpenPreviewViewportHint added in v0.6.4

type OpenPreviewViewportHint struct {
	CenterX       *float64 `json:"center_x,omitempty"`
	CenterY       *float64 `json:"center_y,omitempty"`
	DefaultWidth  float64  `json:"default_width,omitempty"`
	DefaultHeight float64  `json:"default_height,omitempty"`
}

type PreviewItem

type PreviewItem struct {
	ID   string `json:"id"`
	Type string `json:"type"`
	Path string `json:"path"`
	Name string `json:"name"`
	Size *int64 `json:"size,omitempty"`
}

type PutLayoutRequest

type PutLayoutRequest struct {
	BaseRevision     int64             `json:"base_revision"`
	Widgets          []WidgetLayout    `json:"widgets"`
	StickyNotes      []StickyNote      `json:"sticky_notes"`
	Annotations      []TextAnnotation  `json:"annotations"`
	BackgroundLayers []BackgroundLayer `json:"background_layers"`
}

type PutWidgetStateRequest

type PutWidgetStateRequest struct {
	BaseRevision int64           `json:"base_revision"`
	WidgetType   string          `json:"widget_type"`
	State        WidgetStateData `json:"state"`
}

type RevisionConflictError

type RevisionConflictError struct {
	CurrentRevision int64
}

func (*RevisionConflictError) Error

func (e *RevisionConflictError) Error() string

type Service

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

func Open

func Open(path string) (*Service, error)

func (*Service) AppendTerminalSession

func (s *Service) AppendTerminalSession(ctx context.Context, widgetID string, sessionID string) (WidgetState, error)

func (*Service) Close

func (s *Service) Close() error

func (*Service) OpenPreview added in v0.6.4

func (s *Service) OpenPreview(ctx context.Context, req OpenPreviewRequest) (OpenPreviewResponse, error)

func (*Service) PruneTerminalSessions

func (s *Service) PruneTerminalSessions(ctx context.Context, liveSessionIDs []string) ([]WidgetState, error)

func (*Service) PutWidgetState

func (s *Service) PutWidgetState(ctx context.Context, widgetID string, req PutWidgetStateRequest) (WidgetState, error)

func (*Service) RemoveTerminalSession

func (s *Service) RemoveTerminalSession(ctx context.Context, widgetID string, sessionID string) (WidgetState, error)

func (*Service) RemoveTerminalSessionFromAllWidgets

func (s *Service) RemoveTerminalSessionFromAllWidgets(ctx context.Context, sessionID string) ([]WidgetState, error)

func (*Service) Replace

func (s *Service) Replace(ctx context.Context, req PutLayoutRequest) (Snapshot, error)

func (*Service) Snapshot

func (s *Service) Snapshot(ctx context.Context) (Snapshot, error)

func (*Service) Subscribe

func (s *Service) Subscribe(ctx context.Context, afterSeq int64) ([]Event, <-chan Event, error)

type Snapshot

type Snapshot struct {
	Seq              int64             `json:"seq"`
	Revision         int64             `json:"revision"`
	UpdatedAtUnixMs  int64             `json:"updated_at_unix_ms"`
	Widgets          []WidgetLayout    `json:"widgets"`
	StickyNotes      []StickyNote      `json:"sticky_notes"`
	Annotations      []TextAnnotation  `json:"annotations"`
	BackgroundLayers []BackgroundLayer `json:"background_layers"`
	WidgetStates     []WidgetState     `json:"widget_states"`
}

type StickyNote

type StickyNote struct {
	ID              string  `json:"id"`
	Kind            string  `json:"kind"`
	Body            string  `json:"body"`
	Color           string  `json:"color"`
	X               float64 `json:"x"`
	Y               float64 `json:"y"`
	Width           float64 `json:"width"`
	Height          float64 `json:"height"`
	ZIndex          int     `json:"z_index"`
	CreatedAtUnixMs int64   `json:"created_at_unix_ms"`
	UpdatedAtUnixMs int64   `json:"updated_at_unix_ms"`
}

type Store

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

type TextAnnotation

type TextAnnotation struct {
	ID              string  `json:"id"`
	Kind            string  `json:"kind"`
	Text            string  `json:"text"`
	FontFamily      string  `json:"font_family"`
	FontSize        int     `json:"font_size"`
	FontWeight      int     `json:"font_weight"`
	Color           string  `json:"color"`
	Align           string  `json:"align"`
	X               float64 `json:"x"`
	Y               float64 `json:"y"`
	Width           float64 `json:"width"`
	Height          float64 `json:"height"`
	ZIndex          int     `json:"z_index"`
	CreatedAtUnixMs int64   `json:"created_at_unix_ms"`
	UpdatedAtUnixMs int64   `json:"updated_at_unix_ms"`
}

type ValidationError

type ValidationError struct {
	Message string
}

func (*ValidationError) Error

func (e *ValidationError) Error() string

type WidgetLayout

type WidgetLayout struct {
	WidgetID        string  `json:"widget_id"`
	WidgetType      string  `json:"widget_type"`
	X               float64 `json:"x"`
	Y               float64 `json:"y"`
	Width           float64 `json:"width"`
	Height          float64 `json:"height"`
	ZIndex          int     `json:"z_index"`
	CreatedAtUnixMs int64   `json:"created_at_unix_ms"`
}

type WidgetNotFoundError

type WidgetNotFoundError struct {
	WidgetID string
}

func (*WidgetNotFoundError) Error

func (e *WidgetNotFoundError) Error() string

type WidgetState

type WidgetState struct {
	WidgetID        string          `json:"widget_id"`
	WidgetType      string          `json:"widget_type"`
	Revision        int64           `json:"revision"`
	UpdatedAtUnixMs int64           `json:"updated_at_unix_ms"`
	State           WidgetStateData `json:"state"`
}

type WidgetStateData

type WidgetStateData struct {
	Kind         string       `json:"kind"`
	CurrentPath  string       `json:"current_path,omitempty"`
	RootID       string       `json:"root_id,omitempty"`
	SessionIDs   []string     `json:"session_ids,omitempty"`
	FontSize     *int         `json:"font_size,omitempty"`
	FontFamilyID string       `json:"font_family_id,omitempty"`
	Item         *PreviewItem `json:"item,omitempty"`
}

type WidgetStateRevisionConflictError

type WidgetStateRevisionConflictError struct {
	WidgetID        string
	CurrentRevision int64
}

func (*WidgetStateRevisionConflictError) Error

type WidgetTypeMismatchError

type WidgetTypeMismatchError struct {
	WidgetID     string
	ExpectedType string
	ActualType   string
}

func (*WidgetTypeMismatchError) Error

func (e *WidgetTypeMismatchError) Error() string

Jump to

Keyboard shortcuts

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