{"modulePath":"github.com/wavetermdev/waveterm/tsunami","version":"v0.12.4","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package engine\n\n## Constants\n\n```go\nconst (\n\tGlobalContextType_async  = \"async\"\n\tGlobalContextType_render = \"render\"\n\tGlobalContextType_effect = \"effect\"\n\tGlobalContextType_event  = \"event\"\n)\n```\n\n```go\nconst ChildrenPropKey = \"children\"\n```\n\n```go\nconst DefaultComponentName = \"App\"\n```\n\n```go\nconst DefaultListenAddr = \"localhost:0\"\n```\n\n```go\nconst NotifyDebounceTime = 500 * time.Microsecond\n```\n\n```go\nconst NotifyMaxCadence = 10 * time.Millisecond\n```\n\n```go\nconst NotifyMaxDebounceTime = 2 * time.Millisecond\n```\n\n```go\nconst SSEKeepAliveDuration = 5 * time.Second\n```\n\n```go\nconst TsunamiListenAddrEnvVar = \"TSUNAMI_LISTENADDR\"\n```\n\n## Functions\n\n```go\nfunc DefineComponentEx[P any](client *ClientImpl, name string, renderFn func(props P) any) vdom.Component[P]\n```\n\n```go\nfunc GenerateConfigSchema(root *RootElem) map[string]any\n```\nGenerateConfigSchema generates a JSON schema for all config atoms\n\n```go\nfunc GenerateDataSchema(root *RootElem) map[string]any\n```\nGenerateDataSchema generates a JSON schema for all data atoms\n\n```go\nfunc UseEffect(vc *RenderContextImpl, fn func() func(), deps []any)\n```\n\n```go\nfunc UseId(vc *RenderContextImpl) string\n```\n\n```go\nfunc UseLocal(vc *RenderContextImpl, initialVal any) string\n```\n\n```go\nfunc UseRef(vc *RenderContextImpl, hookInitialVal any) any\n```\n\n```go\nfunc UseRenderTs(vc *RenderContextImpl) int64\n```\n\n```go\nfunc UseResync(vc *RenderContextImpl) bool\n```\n\n```go\nfunc UseVDomRef(vc *RenderContextImpl) any\n```\n\n## Types\n\n```go\ntype AppManifest struct {\n\tAppMeta      AppMeta               `json:\"appmeta\"`\n\tConfigSchema map[string]any        `json:\"configschema\"`\n\tDataSchema   map[string]any        `json:\"dataschema\"`\n\tSecrets      map[string]SecretMeta `json:\"secrets\"`\n}\n```\n\n```go\ntype AppMeta struct {\n\tTitle     string `json:\"title\"`\n\tShortDesc string `json:\"shortdesc\"`\n\tIcon      string `json:\"icon\"`      // for waveapps, the icon to use (fontawesome names)\n\tIconColor string `json:\"iconcolor\"` // for waveapps, the icon color to use (HTML color -- name, hex, rgb)\n}\n```\n\n```go\ntype AtomImpl[T any] struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc MakeAtomImpl[T any](initialVal T, meta *AtomMeta) *AtomImpl[T]\n```\n\n```go\nfunc (a *AtomImpl[T]) GetAtomType() reflect.Type\n```\n\n```go\nfunc (a *AtomImpl[T]) GetMeta() *AtomMeta\n```\n\n```go\nfunc (a *AtomImpl[T]) GetUsedBy() []string\n```\n\n```go\nfunc (a *AtomImpl[T]) GetVal() any\n```\n\n```go\nfunc (a *AtomImpl[T]) SetUsedBy(waveId string, used bool)\n```\n\n```go\nfunc (a *AtomImpl[T]) SetVal(val any) error\n```\n\n```go\ntype AtomMeta struct {\n\tDescription string   // short, user-facing\n\tUnits       string   // \"ms\", \"GiB\", etc.\n\tMin         *float64 // optional minimum (numeric types)\n\tMax         *float64 // optional maximum (numeric types)\n\tEnum        []string // allowed values if finite set\n\tPattern     string   // regex constraint for strings\n}\n```\nAtomMeta provides metadata about an atom for validation and documentation\n\n```go\ntype ChildKey struct {\n\tTag string\n\tIdx int\n\tKey string\n}\n```\n\n```go\ntype ClientImpl struct {\n\tLock               *sync.Mutex\n\tRoot               *RootElem\n\tRootElem           *vdom.VDomElem\n\tCurrentClientId    string\n\tMeta               AppMeta\n\tServerId           string\n\tIsDone             bool\n\tDoneReason         string\n\tDoneCh             chan struct{}\n\tSSEChannels        map[string]chan ssEvent // map of connectionId to SSE channel\n\tSSEChannelsLock    *sync.Mutex\n\tGlobalEventHandler func(event vdom.VDomEvent)\n\tUrlHandlerMux      *http.ServeMux\n\tAppInitFn          func() error\n\tAssetsFS           fs.FS\n\tStaticFS           fs.FS\n\tManifestFileBytes  []byte\n\n\t// for modals\n\tOpenModals     map[string]*ModalState // map of modalId to modal state\n\tOpenModalsLock *sync.Mutex\n\n\t// for secrets\n\tSecrets     map[string]SecretMeta // map of secret name to metadata\n\tSecretsLock *sync.Mutex\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc GetDefaultClient() *ClientImpl\n```\n\n```go\nfunc (c *ClientImpl) CloseAllModals()\n```\nCloseAllModals closes all open modals with cancelled result This is called when the FE requests a resync (page refresh or new client)\n\n```go\nfunc (c *ClientImpl) CloseModal(modalId string, result bool)\n```\nCloseModal closes a modal with the given result\n\n```go\nfunc (c *ClientImpl) DeclareSecret(name string, desc string, optional bool)\n```\n\n```go\nfunc (c *ClientImpl) GetAppManifest() AppManifest\n```\n\n```go\nfunc (c *ClientImpl) GetAppMeta() AppMeta\n```\n\n```go\nfunc (c *ClientImpl) GetIsDone() bool\n```\n\n```go\nfunc (c *ClientImpl) GetSecrets() map[string]SecretMeta\n```\n\n```go\nfunc (c *ClientImpl) HandleDynFunc(pattern string, fn func(http.ResponseWriter, *http.Request))\n```\n\n```go\nfunc (c *ClientImpl) PrintAppManifest()\n```\n\n```go\nfunc (c *ClientImpl) RegisterAppInitFn(fn func() error)\n```\n\n```go\nfunc (c *ClientImpl) RegisterSSEChannel(connectionId string) chan ssEvent\n```\n\n```go\nfunc (c *ClientImpl) RunEvents(events []vdom.VDomEvent)\n```\n\n```go\nfunc (c *ClientImpl) RunMain()\n```\n\n```go\nfunc (c *ClientImpl) SendAsyncInitiation() error\n```\n\n```go\nfunc (c *ClientImpl) SendSSEvent(event ssEvent) error\n```\n\n```go\nfunc (c *ClientImpl) SetAppMeta(m AppMeta)\n```\n\n```go\nfunc (c *ClientImpl) SetGlobalEventHandler(handler func(event vdom.VDomEvent))\n```\n\n```go\nfunc (c *ClientImpl) ShowModal(config rpctypes.ModalConfig) chan bool\n```\nShowModal displays a modal and returns a channel that will receive the result\n\n```go\nfunc (c *ClientImpl) UnregisterSSEChannel(connectionId string)\n```\n\n```go\ntype ComponentImpl struct {\n\tWaveId         string         // Unique identifier for this component instance\n\tTag            string         // Component type (HTML tag, custom component name, \"#text\", etc.)\n\tKey            string         // User-provided key for reconciliation (like React keys)\n\tContainingComp string         // Which vdom component's render function created this ComponentImpl\n\tElem           *vdom.VDomElem // Reference to the current input VDomElem being rendered\n\tMounted        bool           // Whether this component is currently mounted\n\n\t// Hooks system (React-like)\n\tHooks []*Hook // Array of hooks (state, effects, etc.) attached to this component\n\n\t// Atom dependency tracking\n\tUsedAtoms map[string]bool // atomName -\u003e true, tracks which atoms this component uses\n\n\t// Pattern 1: Text nodes\n\tText string // For \"#text\" components - stores the actual text content\n\n\t// Pattern 2: Base/DOM elements with children\n\tChildren []*ComponentImpl // For HTML tags, fragments - array of child components\n\n\t// Pattern 3: Custom components that render to other components\n\tRenderedComp *ComponentImpl // For custom components - points to what this component rendered to\n}\n```\nComponentImpl represents a node in the persistent shadow component tree. This is Tsunami's equivalent to React's Fiber nodes - it maintains component identity, state, and lifecycle across renders while the VDomElem input/output structures are ephemeral.\n\n```go\ntype EffectContextImpl struct {\n\tWorkElem EffectWorkElem\n\tWorkType string // \"run\" or \"unmount\"\n\tRoot     *RootElem\n}\n```\n\n```go\nfunc GetGlobalEffectContext() *EffectContextImpl\n```\n\n```go\ntype EffectWorkElem struct {\n\tWaveId      string\n\tEffectIndex int\n\tCompTag     string\n}\n```\n\n```go\ntype EventContextImpl struct {\n\tEvent vdom.VDomEvent\n\tRoot  *RootElem\n}\n```\n\n```go\nfunc GetGlobalEventContext() *EventContextImpl\n```\n\n```go\ntype Hook struct {\n\tInit      bool          // is initialized\n\tIdx       int           // index in the hook array\n\tFn        func() func() // for useEffect\n\tUnmountFn func()        // for useEffect\n\tVal       any           // for useState, useMemo, useRef\n\tDeps      []any\n}\n```\ngeneric hook structure\n\n```go\ntype ModalState struct {\n\tConfig     rpctypes.ModalConfig\n\tResultChan chan bool // Channel to receive the result (true = confirmed/ok, false = cancelled)\n}\n```\n\n```go\ntype RenderContextImpl struct {\n\tRoot       *RootElem\n\tComp       *ComponentImpl\n\tHookIdx    int\n\tRenderOpts *RenderOpts\n\tUsedAtoms  map[string]bool // Track atoms used during this render\n}\n```\n\n```go\nfunc GetGlobalRenderContext() *RenderContextImpl\n```\n\n```go\nfunc (vc *RenderContextImpl) GetCompWaveId() string\n```\n\n```go\ntype RenderOpts struct {\n\tResync bool\n}\n```\n\n```go\ntype RootElem struct {\n\tRoot            *ComponentImpl\n\tRenderTs        int64\n\tCFuncs          map[string]any            // component name =\u003e render function\n\tCompMap         map[string]*ComponentImpl // component waveid -\u003e component\n\tEffectWorkQueue []*EffectWorkElem\n\n\tAtoms map[string]genAtom // key: atomName\n\n\tRefOperations []vdom.VDomRefOperation\n\tClient        *ClientImpl\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc MakeRoot(client *ClientImpl) *RootElem\n```\n\n```go\nfunc (r *RootElem) AtomAddRenderWork(atomName string)\n```\n\n```go\nfunc (r *RootElem) Event(event vdom.VDomEvent, globalEventHandler func(vdom.VDomEvent))\n```\n\n```go\nfunc (r *RootElem) GetAtomVal(name string) any\n```\n\n```go\nfunc (r *RootElem) GetConfigMap() map[string]any\n```\n\n```go\nfunc (r *RootElem) GetDataMap() map[string]any\n```\n\n```go\nfunc (r *RootElem) GetRefOperations() []vdom.VDomRefOperation\n```\n\n```go\nfunc (r *RootElem) MakeRendered() *rpctypes.RenderedElem\n```\n\n```go\nfunc (r *RootElem) QueueRefOp(op vdom.VDomRefOperation)\n```\n\n```go\nfunc (r *RootElem) RegisterAtom(name string, atom genAtom)\n```\n\n```go\nfunc (r *RootElem) RegisterComponent(name string, cfunc any) error\n```\n\n```go\nfunc (r *RootElem) RemoveAtom(name string)\n```\n\n```go\nfunc (r *RootElem) Render(elem *vdom.VDomElem, opts *RenderOpts)\n```\n\n```go\nfunc (r *RootElem) RunWork(opts *RenderOpts)\n```\nthis will be called by the frontend to say the DOM has been mounted it will eventually send any updated \"refs\" to the backend as well\n\n```go\nfunc (r *RootElem) SetAtomVal(name string, val any) error\n```\n\n```go\nfunc (r *RootElem) UpdateRef(updateRef rpctypes.VDomRefUpdate)\n```\n\n```go\ntype SecretMeta struct {\n\tDesc     string `json:\"desc\"`\n\tOptional bool   `json:\"optional\"`\n}\n```\n\n","path":"github.com/wavetermdev/waveterm/tsunami/engine","name":"engine","synopsis":"","isRedistributable":true}
