waveobj

package
v0.10.4 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	MetaKey_View = "view"

	MetaKey_Controller = "controller"

	MetaKey_File = "file"

	MetaKey_Url = "url"

	MetaKey_PinnedUrl = "pinnedurl"

	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_FrameClear             = "frame:*"
	MetaKey_Frame                  = "frame"
	MetaKey_FrameBorderColor       = "frame:bordercolor"
	MetaKey_FrameActiveBorderColor = "frame:activebordercolor"
	MetaKey_FrameTitle             = "frame:title"
	MetaKey_FrameIcon              = "frame:icon"
	MetaKey_FrameText              = "frame:text"

	MetaKey_CmdClear            = "cmd:*"
	MetaKey_Cmd                 = "cmd"
	MetaKey_CmdInteractive      = "cmd:interactive"
	MetaKey_CmdLogin            = "cmd:login"
	MetaKey_CmdRunOnStart       = "cmd:runonstart"
	MetaKey_CmdClearOnStart     = "cmd:clearonstart"
	MetaKey_CmdRunOnce          = "cmd:runonce"
	MetaKey_CmdCloseOnExit      = "cmd:closeonexit"
	MetaKey_CmdCloseOnExitForce = "cmd:closeonexitforce"
	MetaKey_CmdCloseOnExitDelay = "cmd:closeonexitdelay"
	MetaKey_CmdEnv              = "cmd:env"
	MetaKey_CmdCwd              = "cmd:cwd"
	MetaKey_CmdNoWsh            = "cmd:nowsh"
	MetaKey_CmdArgs             = "cmd:args"
	MetaKey_CmdShell            = "cmd:shell"

	MetaKey_AiClear      = "ai:*"
	MetaKey_AiPresetKey  = "ai:preset"
	MetaKey_AiApiType    = "ai:apitype"
	MetaKey_AiBaseURL    = "ai:baseurl"
	MetaKey_AiApiToken   = "ai:apitoken"
	MetaKey_AiName       = "ai:name"
	MetaKey_AiModel      = "ai:model"
	MetaKey_AiOrgID      = "ai:orgid"
	MetaKey_AIApiVersion = "ai:apiversion"
	MetaKey_AiMaxTokens  = "ai:maxtokens"
	MetaKey_AiTimeoutMs  = "ai:timeoutms"

	MetaKey_EditorClear               = "editor:*"
	MetaKey_EditorMinimapEnabled      = "editor:minimapenabled"
	MetaKey_EditorStickyScrollEnabled = "editor:stickyscrollenabled"
	MetaKey_EditorWordWrap            = "editor:wordwrap"

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

	MetaKey_SysinfoType = "sysinfo:type"

	MetaKey_BgClear             = "bg:*"
	MetaKey_Bg                  = "bg"
	MetaKey_BgOpacity           = "bg:opacity"
	MetaKey_BgBlendMode         = "bg:blendmode"
	MetaKey_BgBorderColor       = "bg:bordercolor"
	MetaKey_BgActiveBorderColor = "bg:activebordercolor"

	MetaKey_TermClear              = "term:*"
	MetaKey_TermFontSize           = "term:fontsize"
	MetaKey_TermFontFamily         = "term:fontfamily"
	MetaKey_TermMode               = "term:mode"
	MetaKey_TermTheme              = "term:theme"
	MetaKey_TermLocalShellPath     = "term:localshellpath"
	MetaKey_TermLocalShellOpts     = "term:localshellopts"
	MetaKey_TermScrollback         = "term:scrollback"
	MetaKey_TermVDomSubBlockId     = "term:vdomblockid"
	MetaKey_TermVDomToolbarBlockId = "term:vdomtoolbarblockid"
	MetaKey_TermTransparency       = "term:transparency"

	MetaKey_WebZoom = "web:zoom"

	MetaKey_MarkdownFontSize      = "markdown:fontsize"
	MetaKey_MarkdownFixedFontSize = "markdown:fixedfontsize"

	MetaKey_VDomClear         = "vdom:*"
	MetaKey_VDomInitialized   = "vdom:initialized"
	MetaKey_VDomCorrelationId = "vdom:correlationid"
	MetaKey_VDomRoute         = "vdom:route"
	MetaKey_VDomPersist       = "vdom:persist"

	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"
	OType_Temp        = "temp"
)
View Source
const Entity_Any = "any"

Variables

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 ActiveTabUpdate added in v0.10.0

type ActiveTabUpdate struct {
	WorkspaceId    string `json:"workspaceid"`
	NewActiveTabId string `json:"newactivetabid"`
}

type Block

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

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"`
	HasOldHistory bool        `json:"hasoldhistory,omitempty"`
	TempOID       string      `json:"tempoid,omitempty"`
}

func (*Client) GetOType

func (*Client) GetOType() string

type FileDef

type FileDef struct {
	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"`
	Ephemeral  bool   `json:"ephemeral"`
}

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

func (MetaMapType) GetStringList added in v0.8.8

func (m MetaMapType) GetStringList(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"`
	File           string   `json:"file,omitempty"`
	Url            string   `json:"url,omitempty"`
	PinnedUrl      string   `json:"pinnedurl,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"`

	FrameClear             bool   `json:"frame:*,omitempty"`
	Frame                  bool   `json:"frame,omitempty"`
	FrameBorderColor       string `json:"frame:bordercolor,omitempty"`
	FrameActiveBorderColor string `json:"frame:activebordercolor,omitempty"`
	FrameTitle             string `json:"frame:title,omitempty"`
	FrameIcon              string `json:"frame:icon,omitempty"`
	FrameText              string `json:"frame:text,omitempty"`

	CmdClear            bool              `json:"cmd:*,omitempty"`
	Cmd                 string            `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"`
	CmdRunOnce          bool              `json:"cmd:runonce,omitempty"`
	CmdCloseOnExit      bool              `json:"cmd:closeonexit,omitempty"`
	CmdCloseOnExitForce bool              `json:"cmd:closeonexitforce,omitempty"`
	CmdCloseOnExitDelay float64           `json:"cmd:closeonexitdelay,omitempty"`
	CmdEnv              map[string]string `json:"cmd:env,omitempty"`
	CmdCwd              string            `json:"cmd:cwd,omitempty"`
	CmdNoWsh            bool              `json:"cmd:nowsh,omitempty"`
	CmdArgs             []string          `json:"cmd:args,omitempty"`  // args for cmd (only if cmd:shell is false)
	CmdShell            bool              `json:"cmd:shell,omitempty"` // shell expansion for cmd+args (defaults to true)

	// AI options match settings
	AiClear      bool    `json:"ai:*,omitempty"`
	AiPresetKey  string  `json:"ai:preset,omitempty"`
	AiApiType    string  `json:"ai:apitype,omitempty"`
	AiBaseURL    string  `json:"ai:baseurl,omitempty"`
	AiApiToken   string  `json:"ai:apitoken,omitempty"`
	AiName       string  `json:"ai:name,omitempty"`
	AiModel      string  `json:"ai:model,omitempty"`
	AiOrgID      string  `json:"ai:orgid,omitempty"`
	AIApiVersion string  `json:"ai:apiversion,omitempty"`
	AiMaxTokens  float64 `json:"ai:maxtokens,omitempty"`
	AiTimeoutMs  float64 `json:"ai:timeoutms,omitempty"`

	EditorClear               bool `json:"editor:*,omitempty"`
	EditorMinimapEnabled      bool `json:"editor:minimapenabled,omitempty"`
	EditorStickyScrollEnabled bool `json:"editor:stickyscrollenabled,omitempty"`
	EditorWordWrap            bool `json:"editor:wordwrap,omitempty"`

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

	SysinfoType string `json:"sysinfo:type,omitempty"`

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

	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"`
	TermLocalShellPath     string   `json:"term:localshellpath,omitempty"` // matches settings
	TermLocalShellOpts     []string `json:"term:localshellopts,omitempty"` // matches settings
	TermScrollback         *int     `json:"term:scrollback,omitempty"`
	TermVDomSubBlockId     string   `json:"term:vdomblockid,omitempty"`
	TermVDomToolbarBlockId string   `json:"term:vdomtoolbarblockid,omitempty"`
	TermTransparency       *float64 `json:"term:transparency,omitempty"` // default 0.5

	WebZoom float64 `json:"web:zoom,omitempty"`

	MarkdownFontSize      float64 `json:"markdown:fontsize,omitempty"`
	MarkdownFixedFontSize float64 `json:"markdown:fixedfontsize,omitempty"`

	VDomClear         bool   `json:"vdom:*,omitempty"`
	VDomInitialized   bool   `json:"vdom:initialized,omitempty"`
	VDomCorrelationId string `json:"vdom:correlationid,omitempty"`
	VDomRoute         string `json:"vdom:route,omitempty"`
	VDomPersist       bool   `json:"vdom:persist,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 ParseORefNoErr added in v0.9.0

func ParseORefNoErr(orefStr string) *ORef

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"`
	IsNew       bool        `json:"isnew,omitempty"` // set when a window is created on the backend so the FE can size it properly.  cleared on first resize
	Pos         Point       `json:"pos"`
	WinSize     WinSize     `json:"winsize"`
	LastFocusTs int64       `json:"lastfocusts"`
	Meta        MetaMapType `json:"meta"`
}

stores the ui-context of the window, points to a workspace containing the actual data being displayed in the window

func (*Window) GetOType

func (*Window) GetOType() string

type Workspace

type Workspace struct {
	OID          string      `json:"oid"`
	Version      int         `json:"version"`
	Name         string      `json:"name,omitempty"`
	Icon         string      `json:"icon,omitempty"`
	Color        string      `json:"color,omitempty"`
	TabIds       []string    `json:"tabids"`
	PinnedTabIds []string    `json:"pinnedtabids"`
	ActiveTabId  string      `json:"activetabid"`
	Meta         MetaMapType `json:"meta"`
}

func (*Workspace) GetOType

func (*Workspace) GetOType() string

type WorkspaceList added in v0.10.0

type WorkspaceList []*WorkspaceListEntry

type WorkspaceListEntry added in v0.10.0

type WorkspaceListEntry struct {
	WorkspaceId string `json:"workspaceid"`
	WindowId    string `json:"windowid"`
}

Jump to

Keyboard shortcuts

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