Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DevWatcher ¶
type DevWatcher struct {
// contains filtered or unexported fields
}
DevWatcher watches a Zyra project's actions and pages directories and keeps generated code, the client bundle, and connected dev clients in sync as files change:
- actions/*.go -> codegen.ScanActions + GenerateClient, then "action-update"
- pages/*.tsx -> router.ScanPages + compiler.BuildClient, then "reload"
- any .tsx/.ts change -> compiler.BuildStyles only, then "css-update"
Each of these three follow-ups is debounced independently by 200ms, and a failure at any step notifies the client with a build error instead of the usual reload/update message.
func New ¶
func New(cfg *config.Config, notifier Notifier) (*DevWatcher, error)
New creates a DevWatcher for cfg's actionsDir and pagesDir, notifying notifier as changes are processed. Missing directories are skipped rather than causing an error.
func (*DevWatcher) Close ¶
func (w *DevWatcher) Close() error
Close stops the watch loop and releases underlying OS resources.
func (*DevWatcher) Start ¶
func (w *DevWatcher) Start() error
Start begins the watch loop. It blocks until Close is called.
type Notifier ¶
type Notifier interface {
// BroadcastBuildStart tells clients a rebuild has started.
BroadcastBuildStart()
// BroadcastReload tells clients to perform a full page reload.
BroadcastReload()
// BroadcastCSSUpdate tells clients to hot-swap the stylesheet.
BroadcastCSSUpdate()
// BroadcastActionUpdate tells clients that generated action
// bindings for pkg have changed.
BroadcastActionUpdate(pkg string)
// BroadcastError tells clients a build/codegen step failed, so
// they can show a build-error overlay.
BroadcastError(message, stack string)
}
Notifier is the subset of Zyra's dev server that DevWatcher needs to push hot-reload notifications to connected clients. It exists so this package doesn't need to import internal/server; *server.Server satisfies it directly.