mirror of
https://github.com/wavetermdev/waveterm.git
synced 2025-11-28 05:00:26 +08:00
Huge PR. 135 commits here to rebuild waveapps into the "Tsunami" framework.
* Simplified API
* Updated system.md prompt
* Basic applications building and running
* /api/config and /api/data support
* tailwind styling
* no need for async updates
* goroutine/timer primitives for async routing handling
* POC for integrating 3rd party react frameworks (recharts)
* POC for server side components (table.go)
* POC for interacting with apps via /api/config (tsunamiconfig)
Checkpoint. Still needs to be tightly integrated with Wave (lifecycle, AI interaction, etc.) but looking very promising 🚀
52 lines
2 KiB
Go
52 lines
2 KiB
Go
// Copyright 2025, Command Line Inc.
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package engine
|
|
|
|
import "github.com/wavetermdev/waveterm/tsunami/vdom"
|
|
|
|
// so components either render to another component (or fragment)
|
|
// or to a base element (text or vdom). base elements can then render children
|
|
|
|
type ChildKey struct {
|
|
Tag string
|
|
Idx int
|
|
Key string
|
|
}
|
|
|
|
// ComponentImpl 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.
|
|
type ComponentImpl struct {
|
|
WaveId string // Unique identifier for this component instance
|
|
Tag string // Component type (HTML tag, custom component name, "#text", etc.)
|
|
Key string // User-provided key for reconciliation (like React keys)
|
|
ContainingComp string // Which vdom component's render function created this ComponentImpl
|
|
Elem *vdom.VDomElem // Reference to the current input VDomElem being rendered
|
|
Mounted bool // Whether this component is currently mounted
|
|
|
|
// Hooks system (React-like)
|
|
Hooks []*Hook // Array of hooks (state, effects, etc.) attached to this component
|
|
|
|
// Atom dependency tracking
|
|
UsedAtoms map[string]bool // atomName -> true, tracks which atoms this component uses
|
|
|
|
// Component content - exactly ONE of these patterns is used:
|
|
|
|
// Pattern 1: Text nodes
|
|
Text string // For "#text" components - stores the actual text content
|
|
|
|
// Pattern 2: Base/DOM elements with children
|
|
Children []*ComponentImpl // For HTML tags, fragments - array of child components
|
|
|
|
// Pattern 3: Custom components that render to other components
|
|
RenderedComp *ComponentImpl // For custom components - points to what this component rendered to
|
|
}
|
|
|
|
func (c *ComponentImpl) compMatch(tag string, key string) bool {
|
|
if c == nil {
|
|
return false
|
|
}
|
|
return c.Tag == tag && c.Key == key
|
|
}
|