engine

package module
v0.0.0-...-aebed5a Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: MPL-2.0 Imports: 39 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

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrStale = errors.New("stale version")
)

Functions

func Register

func Register(b Behavior, kinds ...string)

Types

type Behavior

type Behavior interface {
	Name() string
	Targets(l *Layout) []Target
	Candidates(l *Layout, t Target, p Point) []Edit
	Build(ctx context.Context, base *Layout, source string, e Edit) (*Candidate, error)
}

type Candidate

type Candidate struct {
	Key      string       `json:"key"`
	Label    string       `json:"label"`
	Edit     Edit         `json:"edit"`
	Landing  Shape        `json:"landing"`
	Route    [][2]float64 `json:"route,omitempty"`
	Diff     []DiffLine   `json:"diff"`
	PinLines int          `json:"pinLines"`
	MS       float64      `json:"ms"`
	Cached   bool         `json:"cached"`
	// contains filtered or unexported fields
}

type Catalog

type Catalog struct {
	Themes     []ThemeChoice `json:"themes"`
	DarkThemes []ThemeChoice `json:"darkThemes"`
	Engines    []Choice      `json:"engines"`
	Charsets   []Choice      `json:"charsets"`
	Theme      int64         `json:"theme"`
	DarkTheme  int64         `json:"darkTheme"`
}

func Describe

func Describe() Catalog

type Choice

type Choice struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

type Config

type Config struct {
	Engine      string `json:"engine"`
	Sketch      bool   `json:"sketch"`
	ThemeID     *int64 `json:"themeId,omitempty"`
	DarkThemeID *int64 `json:"darkThemeId,omitempty"`
}

type Conn

type Conn struct {
	ID    string       `json:"id"`
	Src   string       `json:"src"`
	Dst   string       `json:"dst"`
	Route [][2]float64 `json:"route"`
}

type DiffLine

type DiffLine struct {
	Op   string `json:"op"`
	Text string `json:"text"`
}

type Drift

type Drift struct {
	MaxDelta float64 `json:"maxDelta"`
	Moved    int     `json:"moved"`
	Shapes   int     `json:"shapes"`
}

type Edit

type Edit struct {
	Kind   string `json:"kind"`
	Key    string `json:"key"`
	To     string `json:"to"`
	End    string `json:"end"`
	Left   int    `json:"left"`
	Top    int    `json:"top"`
	Width  int    `json:"width"`
	Height int    `json:"height"`
}

func (Edit) ID

func (e Edit) ID() string

type Layout

type Layout struct {
	Scene    Scene   `json:"scene"`
	Config   Config  `json:"config"`
	Shapes   []Shape `json:"shapes"`
	Conns    []Conn  `json:"conns"`
	LayoutMS float64 `json:"layoutMs"`
	// contains filtered or unexported fields
}

type Path

type Path struct {
	ID    string       `json:"id"`
	Src   string       `json:"src"`
	Dst   string       `json:"dst"`
	Route [][2]float64 `json:"route"`
}

type Piece

type Piece struct {
	ID  string `json:"id"`
	SVG string `json:"svg"`
}

type Point

type Point struct {
	X float64 `json:"x"`
	Y float64 `json:"y"`
}

type Scene

type Scene struct {
	CSS    string  `json:"css"`
	Defs   string  `json:"defs"`
	Shapes []Piece `json:"shapes"`
	Conns  []Piece `json:"connections"`
}

type Session

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

func NewSession

func NewSession(write Writer) *Session

func (*Session) Candidate

func (s *Session) Candidate(ctx context.Context, e Edit, version int64) (*Candidate, error)

func (*Session) Commit

func (s *Session) Commit(ctx context.Context, e Edit, version int64) (string, View, error)

func (*Session) ExportSVG

func (s *Session) ExportSVG(ctx context.Context, dark bool) ([]byte, error)

func (*Session) Open

func (s *Session) Open(source string) (View, error)

func (*Session) Plan

func (s *Session) Plan(t Target, p Point, version int64) ([]Edit, error)

func (*Session) Preview

func (s *Session) Preview(ctx context.Context, t Target, p Point, version int64) (<-chan *Candidate, error)

func (*Session) Redo

func (s *Session) Redo() (View, error)

func (*Session) Reload

func (s *Session) Reload(source string) (View, error)

func (*Session) Route

func (s *Session) Route(t Target, delta Point, version int64) ([]Path, error)

func (*Session) Snapshot

func (s *Session) Snapshot() View

func (*Session) Text

func (s *Session) Text(ctx context.Context, unicode bool) (TextResult, error)

func (*Session) Undo

func (s *Session) Undo() (View, error)

func (*Session) Verify

func (s *Session) Verify(ctx context.Context) (Drift, error)

func (*Session) Wait

func (s *Session) Wait(ctx context.Context, since int64) View

type Shape

type Shape struct {
	ID     string   `json:"id"`
	Type   string   `json:"type"`
	X      int      `json:"x"`
	Y      int      `json:"y"`
	Width  int      `json:"width"`
	Height int      `json:"height"`
	Pinned bool     `json:"pinned"`
	Cols   []string `json:"cols,omitempty"`
	PK     int      `json:"pk"`
}

type Target

type Target struct {
	Kind string `json:"kind"`
	ID   string `json:"id"`
	Edge string `json:"edge"`
	End  string `json:"end"`
}

type TextResult

type TextResult struct {
	Version int64  `json:"version"`
	Text    string `json:"text"`
	Note    string `json:"note"`
}

type ThemeChoice

type ThemeChoice struct {
	ID   int64  `json:"id"`
	Name string `json:"name"`
}

type View

type View struct {
	Version int64   `json:"version"`
	Source  string  `json:"source"`
	Error   string  `json:"error,omitempty"`
	Cause   string  `json:"cause"`
	Changed []int   `json:"changed"`
	CanUndo bool    `json:"canUndo"`
	CanRedo bool    `json:"canRedo"`
	MS      float64 `json:"ms"`
	*Layout
}

type Writer

type Writer func(source string) error

Directories

Path Synopsis
cmd
d2squared command

Jump to

Keyboard shortcuts

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