-
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathhandler.go
More file actions
80 lines (66 loc) · 2.13 KB
/
handler.go
File metadata and controls
80 lines (66 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package app
import (
"sync"
"github.com/tinywasm/assetmin"
"github.com/tinywasm/imagemin"
"github.com/tinywasm/client"
"github.com/tinywasm/deploy"
"github.com/tinywasm/devflow"
"github.com/tinywasm/devwatch"
"github.com/tinywasm/mcp"
)
// Handler contains application state and dependencies
// CRITICAL: This struct does NOT import DevTUI
type Handler struct {
FrameworkName string // eg: "TINYWASM", "DEVGO", etc.
DevMode bool // True if running in development mode (read from DB)
RootDir string
Config *Config
Tui TuiInterface // Interface defined in TINYWASM, not DevTUI
ExitChan chan bool
Logger func(messages ...any) // Main logger for passing to components
DB DB // Key-value store interface
// Build dependencies
Server ServerInterface
serverFactory ServerFactory
AssetsHandler *assetmin.AssetMin
ImageHandler *imagemin.Handler
GitHandler devflow.GitClient
GoHandler *devflow.Go
GoNew *devflow.GoNew
WasmClient *client.WasmClient
Watcher *devwatch.DevWatch
Browser BrowserInterface
GitHubAuth any
// Deploy dependencies
DeployManager *deploy.Daemon
// Lifecycle management
startOnce sync.Once
SectionBuild any // Store reference to build tab
SectionDeploy any // Store reference to deploy tab
SectionMCP any // Store reference to mcp tab
RestartRequested bool
// MCP Server for LLM integration (owns /mcp, /logs, /action, /state, /version routes)
MCP *mcp.Server
// GoMod Handler
GoModHandler devflow.GoModInterface
// Optional listModules function (for tests)
ListModulesFn func(rootDir string) ([]string, error)
}
func (h *Handler) SetBrowser(b BrowserInterface) {
h.Browser = b
}
func (h *Handler) SetServerFactory(f ServerFactory) {
h.serverFactory = f
}
// CheckDevMode checks the DB for "dev_mode" key and sets the DevMode field
func (h *Handler) CheckDevMode() {
if h.DB != nil {
val, err := h.DB.Get("dev_mode")
// Default to true if not found (err != nil), empty, or explicitly "true"
if err != nil || val == "" || val == "true" {
h.DevMode = true
h.DB.Set("dev_mode", "true")
}
}
}