-
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathinterface.go
More file actions
73 lines (63 loc) · 2.4 KB
/
interface.go
File metadata and controls
73 lines (63 loc) · 2.4 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
package app
import (
"net/http"
"sync"
"github.com/tinywasm/kvdb"
"github.com/tinywasm/mcp"
)
type DB interface {
kvdb.KVStore
}
type TuiInterface interface {
NewTabSection(title, description string) any // returns *tabSection
AddHandler(Handler any, color string, tabSection any)
Start(syncWaitGroup ...any) // syncWaitGroup is optional
RefreshUI()
ReturnFocus() error // returns focus to main UI
SetActiveTab(section any) // sets the active tab section
// GetHandlerStates returns the current handler state as JSON bytes.
// Format: []StateEntry (devtui wire format).
// HeadlessTUI: populated by AddHandler calls (daemon mode).
// DevTUI: returns nil (client mode, not a state server).
GetHandlerStates() []byte
// DispatchAction routes a remote action to the handler registered for that key.
// Returns true if a registered handler handled it; false means caller must handle.
// HeadlessTUI: iterates handlers slice built in AddHandler, matches by shortcut key.
// DevTUI: always returns false (actions are sent to daemon, not dispatched locally).
DispatchAction(key, value string) bool
Shutdown() // signals graceful stop; no-op on HeadlessTUI
}
// BrowserInterface defines the browser operations needed by the app.
// Implementations: devbrowser.DevBrowser (production), MockBrowser (tests)
type BrowserInterface interface {
Reload() error
OpenBrowser(port string, https bool)
SetLog(f func(message ...any))
GetLog() func(message ...any)
GetMCPTools() []mcp.Tool
}
// ServerInterface is the common contract for all server backends.
// Implemented by: tinywasm/server.ServerHandler, tinywasm/wasi.WasiServer
type ServerInterface interface {
// Lifecycle
StartServer(wg *sync.WaitGroup)
StopServer() error
RestartServer() error
// devwatch.FilesEventHandler
NewFileEvent(fileName, extension, filePath, event string) error
UnobservedFiles() []string
SupportedExtensions() []string
MainInputFileRelativePath() string
// TUI (devtui.HandlerEdit)
Name() string
Label() string
Value() string
Change(v string)
RefreshUI()
// Route Registration
RegisterRoutes(fn func(*http.ServeMux))
}
// ServerFactory creates and configures the concrete server.
// Routes and callbacks are NOT passed here — they are registered directly
// on the returned ServerInterface after InitBuildHandlers creates them.
type ServerFactory func(exitChan chan bool, ui TuiInterface, browser BrowserInterface) ServerInterface