dev

package
v0.18.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 6, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package dev implements `trilha dev`: a polling file watcher, a builder and a supervisor that runs the app behind a reverse proxy with live reload.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Diff

func Diff(a, b Snapshot) []string

Diff returns the paths that changed between a and b.

func Watch

func Watch(root string, interval, debounce time.Duration, stop <-chan struct{}) <-chan Change

Watch polls root every interval and sends batches of changes on the returned channel, debounced so bursts of saves become one event.

func Watchable

func Watchable(rel string) bool

Watchable reports whether a path (relative, slash-separated) matters for a rebuild: Go sources, go.mod/go.sum and anything under public/.

Types

type Change

type Change struct {
	Paths []string
	// StaticOnly is true when only files under public/ changed and public/
	// neither appeared nor disappeared: the app can reload without a rebuild.
	StaticOnly bool
}

Change is one debounced batch of file changes.

func Classify

func Classify(paths []string, hadPublic, hasPublic bool) Change

Classify decides whether a batch needs a rebuild. hadPublic/hasPublic are the public/ presence before and after the batch.

type Generator

type Generator func() error

Generator regenerates trilha_gen.go; injected by the CLI.

type Server

type Server struct {
	Root     string
	Addr     string
	Generate Generator
	Out      io.Writer
	// contains filtered or unexported fields
}

Server is the dev supervisor: public listener + proxy + child process.

func (*Server) Run

func (s *Server) Run(ctx context.Context) error

Run generates, builds, starts the child and watches for changes until ctx is cancelled.

type Snapshot

type Snapshot map[string]string

Snapshot maps a relative path to its modification time and size.

func Take

func Take(root string) Snapshot

Take walks root and records every watchable file.

func (Snapshot) HasPublic

func (s Snapshot) HasPublic() bool

HasPublic reports whether the snapshot contains files under public/.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL