waveobj

package
v0.8.0-beta.11 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MetaKey_View = "view"

	MetaKey_Controller = "controller"

	MetaKey_Title = "title"

	MetaKey_File = "file"

	MetaKey_Url = "url"

	MetaKey_Connection = "connection"

	MetaKey_Edit = "edit"

	MetaKey_History        = "history"
	MetaKey_HistoryForward = "history:forward"

	MetaKey_DisplayName  = "display:name"
	MetaKey_DisplayOrder = "display:order"

	MetaKey_Icon      = "icon"
	MetaKey_IconColor = "icon:color"

	MetaKey_Frame                    = "frame"
	MetaKey_FrameClear               = "frame:*"
	MetaKey_FrameBorderColor         = "frame:bordercolor"
	MetaKey_FrameBorderColor_Focused = "frame:bordercolor:focused"

	MetaKey_Cmd               = "cmd"
	MetaKey_CmdClear          = "cmd:*"
	MetaKey_CmdInteractive    = "cmd:interactive"
	MetaKey_CmdLogin          = "cmd:login"
	MetaKey_CmdRunOnStart     = "cmd:runonstart"
	MetaKey_CmdClearOnStart   = "cmd:clearonstart"
	MetaKey_CmdClearOnRestart = "cmd:clearonrestart"
	MetaKey_CmdEnv            = "cmd:env"
	MetaKey_CmdCwd            = "cmd:cwd"
	MetaKey_CmdNoWsh          = "cmd:nowsh"

	MetaKey_GraphClear     = "graph:*"
	MetaKey_GraphNumPoints = "graph:numpoints"
	MetaKey_GraphMetrics   = "graph:metrics"

	MetaKey_Bg          = "bg"
	MetaKey_BgClear     = "bg:*"
	MetaKey_BgOpacity   = "bg:opacity"
	MetaKey_BgBlendMode = "bg:blendmode"

	MetaKey_TermClear      = "term:*"
	MetaKey_TermFontSize   = "term:fontsize"
	MetaKey_TermFontFamily = "term:fontfamily"
	MetaKey_TermMode       = "term:mode"
	MetaKey_TermTheme      = "term:theme"

	MetaKey_Count = "count"
)
View Source
const (
	OTypeKeyName   = "otype"
	OIDKeyName     = "oid"
	VersionKeyName = "version"
	MetaKeyName    = "meta"

	OIDGoFieldName     = "OID"
	VersionGoFieldName = "Version"
	MetaGoFieldName    = "Meta"
)
View Source
const (
	UpdateType_Update = "update"
	UpdateType_Delete = "delete"
)
View Source
const (
	OType_Client      = "client"
	OType_Window      = "window"
	OType_Workspace   = "workspace"
	OType_Tab         = "tab"
	OType_LayoutState = "layout"
	OType_Block       = "block"
)
View Source
const Entity_Any = "any"

Variables

This section is empty.

Functions

func AllWaveObjTypes

func AllWaveObjTypes() []reflect.Type

func ContextAddUpdate

func ContextAddUpdate(ctx context.Context, update WaveObjUpdate)

func ContextGetUpdates

func ContextGetUpdates(ctx context.Context) map[ORef]WaveObjUpdate

func ContextPrintUpdates

func ContextPrintUpdates(ctx context.Context)

func ContextUpdatesBeginTx

func ContextUpdatesBeginTx(ctx context.Context) context.Context

func ContextUpdatesCommitTx

func ContextUpdatesCommitTx(ctx context.Context)

func ContextUpdatesRollbackTx

func ContextUpdatesRollbackTx(ctx context.Context)

func ContextWithUpdates

func ContextWithUpdates(ctx context.Context) context.Context

func FromJsonGen

func FromJsonGen[T WaveObj](data []byte) (T, error)

func GetOID

func GetOID(waveObj WaveObj) string

func GetVersion

func GetVersion(waveObj WaveObj) int

func RegisterType

func RegisterType(rtype reflect.Type)

func SetMeta

func SetMeta(waveObj WaveObj, meta map[string]any)

func SetOID

func SetOID(waveObj WaveObj, oid string)

func SetVersion

func SetVersion(waveObj WaveObj, version int)

func ToJson

func ToJson(w WaveObj) ([]byte, error)

func ToJsonMap

func ToJsonMap(w WaveObj) (map[string]any, error)

Types

type Block

type Block struct {
	OID         string         `json:"oid"`
	Version     int            `json:"version"`
	BlockDef    *BlockDef      `json:"blockdef"`
	RuntimeOpts *RuntimeOpts   `json:"runtimeopts,omitempty"`
	Stickers    []*StickerType `json:"stickers,omitempty"`
	Meta        MetaMapType    `json:"meta"`
}

func (*Block) GetOType

func (*Block) GetOType() string

type BlockDef

type BlockDef struct {
	Files map[string]*FileDef `json:"files,omitempty"`
	Meta  MetaMapType         `json:"meta,omitempty"`
}

type Client

type Client struct {
	OID             string      `json:"oid"`
	Version         int         `json:"version"`
	WindowIds       []string    `json:"windowids"`
	Meta            MetaMapType `json:"meta"`
	TosAgreed       int64       `json:"tosagreed,omitempty"`
	HistoryMigrated bool        `json:"historymigrated,omitempty"`
}

func (*Client) GetOType

func (*Client) GetOType() string

type FileDef

type FileDef struct {
	FileType string         `json:"filetype,omitempty"`
	Path     string         `json:"path,omitempty"`
	Url      string         `json:"url,omitempty"`
	Content  string         `json:"content,omitempty"`
	Meta     map[string]any `json:"meta,omitempty"`
}

type LayoutActionData

type LayoutActionData struct {
	ActionType string `json:"actiontype"`
	BlockId    string `json:"blockid"`
	NodeSize   *uint  `json:"nodesize,omitempty"`
	IndexArr   *[]int `json:"indexarr,omitempty"`
	Focused    bool   `json:"focused"`
	Magnified  bool   `json:"magnified"`
}

type LayoutState

type LayoutState struct {
	OID                   string              `json:"oid"`
	Version               int                 `json:"version"`
	RootNode              any                 `json:"rootnode,omitempty"`
	MagnifiedNodeId       string              `json:"magnifiednodeid,omitempty"`
	FocusedNodeId         string              `json:"focusednodeid,omitempty"`
	LeafOrder             *[]LeafOrderEntry   `json:"leaforder,omitempty"`
	PendingBackendActions *[]LayoutActionData `json:"pendingbackendactions,omitempty"`
	Meta                  MetaMapType         `json:"meta,omitempty"`
}

func (*LayoutState) GetOType

func (*LayoutState) GetOType() string

type LeafOrderEntry

type LeafOrderEntry struct {
	NodeId  string `json:"nodeid"`
	BlockId string `json:"blockid"`
}

type MetaDataDecl

type MetaDataDecl struct {
	Key        string   `json:"key"`
	Desc       string   `json:"desc,omitempty"`
	Type       string   `json:"type"` // string, int, float, bool, array, object
	Default    any      `json:"default,omitempty"`
	StrOptions []string `json:"stroptions,omitempty"`
	NumRange   []*int   `json:"numrange,omitempty"` // inclusive, null means no limit
	Entity     []string `json:"entity"`             // what entities this applies to, e.g. "block", "tab", "any", etc.
	Special    []string `json:"special,omitempty"`  // special handling.  things that need to happen if this gets updated
}

type MetaMapType

type MetaMapType map[string]any

func GetMeta

func GetMeta(waveObj WaveObj) MetaMapType

func MergeMeta

func MergeMeta(meta MetaMapType, metaUpdate MetaMapType, mergeSpecial bool) MetaMapType

returns a clean copy of meta with mergeMeta merged in if mergeSpecial is false, then special keys will not be merged (like display:*)

func (MetaMapType) GetArray

func (m MetaMapType) GetArray(key string) []any

func (MetaMapType) GetBool

func (m MetaMapType) GetBool(key string, def bool) bool

func (MetaMapType) GetFloat

func (m MetaMapType) GetFloat(key string, def float64) float64

func (MetaMapType) GetInt

func (m MetaMapType) GetInt(key string, def int) int

func (MetaMapType) GetMap

func (m MetaMapType) GetMap(key string) MetaMapType

func (MetaMapType) GetString

func (m MetaMapType) GetString(key string, def string) string

func (MetaMapType) GetStringArray

func (m MetaMapType) GetStringArray(key string) []string

type MetaPresetDecl

type MetaPresetDecl struct {
	Preset string   `json:"preset"`
	Desc   string   `json:"desc,omitempty"`
	Keys   []string `json:"keys"`
	Entity []string `json:"entity"` // what entities this applies to, e.g. "block", "tab", etc.
}

type MetaTSType

type MetaTSType struct {
	// shared
	View           string   `json:"view,omitempty"`
	Controller     string   `json:"controller,omitempty"`
	Title          string   `json:"title,omitempty"`
	File           string   `json:"file,omitempty"`
	Url            string   `json:"url,omitempty"`
	Connection     string   `json:"connection,omitempty"`
	Edit           bool     `json:"edit,omitempty"`
	History        []string `json:"history,omitempty"`
	HistoryForward []string `json:"history:forward,omitempty"`

	DisplayName  string  `json:"display:name,omitempty"`
	DisplayOrder float64 `json:"display:order,omitempty"`

	Icon      string `json:"icon,omitempty"`
	IconColor string `json:"icon:color,omitempty"`

	Frame                    bool   `json:"frame,omitempty"`
	FrameClear               bool   `json:"frame:*,omitempty"`
	FrameBorderColor         string `json:"frame:bordercolor,omitempty"`
	FrameBorderColor_Focused string `json:"frame:bordercolor:focused,omitempty"`

	Cmd               string            `json:"cmd,omitempty"`
	CmdClear          bool              `json:"cmd:*,omitempty"`
	CmdInteractive    bool              `json:"cmd:interactive,omitempty"`
	CmdLogin          bool              `json:"cmd:login,omitempty"`
	CmdRunOnStart     bool              `json:"cmd:runonstart,omitempty"`
	CmdClearOnStart   bool              `json:"cmd:clearonstart,omitempty"`
	CmdClearOnRestart bool              `json:"cmd:clearonrestart,omitempty"`
	CmdEnv            map[string]string `json:"cmd:env,omitempty"`
	CmdCwd            string            `json:"cmd:cwd,omitempty"`
	CmdNoWsh          bool              `json:"cmd:nowsh,omitempty"`

	GraphClear     bool     `json:"graph:*,omitempty"`
	GraphNumPoints int      `json:"graph:numpoints,omitempty"`
	GraphMetrics   []string `json:"graph:metrics,omitempty"`

	// for tabs
	Bg          string  `json:"bg,omitempty"`
	BgClear     bool    `json:"bg:*,omitempty"`
	BgOpacity   float64 `json:"bg:opacity,omitempty"`
	BgBlendMode string  `json:"bg:blendmode,omitempty"`

	TermClear      bool   `json:"term:*,omitempty"`
	TermFontSize   int    `json:"term:fontsize,omitempty"`
	TermFontFamily string `json:"term:fontfamily,omitempty"`
	TermMode       string `json:"term:mode,omitempty"`
	TermTheme      string `json:"term:theme,omitempty"`
	Count          int    `json:"count,omitempty"` // temp for cpu plot. will remove later
}

for typescript typing

type ORef

type ORef struct {
	// special JSON marshalling to string
	OType string `json:"otype" mapstructure:"otype"`
	OID   string `json:"oid" mapstructure:"oid"`
}

func MakeORef

func MakeORef(otype string, oid string) ORef

func ORefFromMap

func ORefFromMap(m map[string]any) (*ORef, error)

func ORefFromWaveObj

func ORefFromWaveObj(w WaveObj) *ORef

func ParseORef

func ParseORef(orefStr string) (ORef, error)

func (ORef) IsEmpty

func (oref ORef) IsEmpty() bool

func (ORef) MarshalJSON

func (oref ORef) MarshalJSON() ([]byte, error)

func (ORef) String

func (oref ORef) String() string

func (*ORef) UnmarshalJSON

func (oref *ORef) UnmarshalJSON(data []byte) error

type Point

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

type RuntimeOpts

type RuntimeOpts struct {
	TermSize TermSize `json:"termsize,omitempty"`
	WinSize  WinSize  `json:"winsize,omitempty"`
}

type StickerClickOptsType

type StickerClickOptsType struct {
	SendInput   string    `json:"sendinput,omitempty"`
	CreateBlock *BlockDef `json:"createblock,omitempty"`
}

type StickerDisplayOptsType

type StickerDisplayOptsType struct {
	Icon    string `json:"icon"`
	ImgSrc  string `json:"imgsrc"`
	SvgBlob string `json:"svgblob,omitempty"`
}

type StickerType

type StickerType struct {
	StickerType string                  `json:"stickertype"`
	Style       map[string]any          `json:"style"`
	ClickOpts   *StickerClickOptsType   `json:"clickopts,omitempty"`
	Display     *StickerDisplayOptsType `json:"display"`
}

type Tab

type Tab struct {
	OID         string      `json:"oid"`
	Version     int         `json:"version"`
	Name        string      `json:"name"`
	LayoutState string      `json:"layoutstate"`
	BlockIds    []string    `json:"blockids"`
	Meta        MetaMapType `json:"meta"`
}

func (*Tab) GetBlockORefs

func (t *Tab) GetBlockORefs() []ORef

func (*Tab) GetOType

func (*Tab) GetOType() string

type TermSize

type TermSize struct {
	Rows int `json:"rows"`
	Cols int `json:"cols"`
}

type UIContext

type UIContext struct {
	WindowId    string `json:"windowid"`
	ActiveTabId string `json:"activetabid"`
}

type UpdatesRtnType

type UpdatesRtnType = []WaveObjUpdate

func ContextGetUpdatesRtn

func ContextGetUpdatesRtn(ctx context.Context) UpdatesRtnType

type WaveObj

type WaveObj interface {
	GetOType() string // should not depend on object state (should work with nil value)
}

func FromJson

func FromJson(data []byte) (WaveObj, error)

func FromJsonMap

func FromJsonMap(m map[string]any) (WaveObj, error)

type WaveObjUpdate

type WaveObjUpdate struct {
	UpdateType string  `json:"updatetype"`
	OType      string  `json:"otype"`
	OID        string  `json:"oid"`
	Obj        WaveObj `json:"obj,omitempty"`
}

func ContextGetUpdate

func ContextGetUpdate(ctx context.Context, oref ORef) *WaveObjUpdate

func MakeUpdate

func MakeUpdate(obj WaveObj) WaveObjUpdate

func MakeUpdates

func MakeUpdates(objs []WaveObj) []WaveObjUpdate

func (WaveObjUpdate) MarshalJSON

func (update WaveObjUpdate) MarshalJSON() ([]byte, error)

func (*WaveObjUpdate) UnmarshalJSON

func (update *WaveObjUpdate) UnmarshalJSON(data []byte) error

type WinSize

type WinSize struct {
	Width  int `json:"width"`
	Height int `json:"height"`
}

type Window

type Window struct {
	OID         string      `json:"oid"`
	Version     int         `json:"version"`
	WorkspaceId string      `json:"workspaceid"`
	ActiveTabId string      `json:"activetabid"`
	Pos         Point       `json:"pos"`
	WinSize     WinSize     `json:"winsize"`
	LastFocusTs int64       `json:"lastfocusts"`
	Meta        MetaMapType `json:"meta"`
}

stores the ui-context of the window workspaceid, active tab, active block within each tab, window size, etc.

func (*Window) GetOType

func (*Window) GetOType() string

type Workspace

type Workspace struct {
	OID     string      `json:"oid"`
	Version int         `json:"version"`
	Name    string      `json:"name"`
	TabIds  []string    `json:"tabids"`
	Meta    MetaMapType `json:"meta"`
}

func (*Workspace) GetOType

func (*Workspace) GetOType() string

Jump to

Keyboard shortcuts

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