Documentation
¶
Overview ¶
Package tooling provides build-time and dev-time functionality for Wave. This package has heavy dependencies and should not be imported at runtime.
Index ¶
- Variables
- func BuildWave(cfg *wave.ParsedConfig, log *slog.Logger)
- func BuildWaveWithHook(cfg *wave.ParsedConfig, log *slog.Logger, hook func(isDev bool) error)
- func RunDev(cfg *wave.ParsedConfig, log *slog.Logger) error
- func SetupDistDir(cfg *wave.ParsedConfig) error
- func ValidateConfig(cfg *wave.ParsedConfig) error
- type BuildOpts
- type Builder
- func (b *Builder) AddPublicAssetKeys(statements *tsgen.Statements) *tsgen.Statements
- func (b *Builder) Build(opts BuildOpts) error
- func (b *Builder) BuildCriticalCSS(isDev bool) error
- func (b *Builder) BuildNormalCSS(isDev bool) error
- func (b *Builder) Close() error
- func (b *Builder) CompileGoOnly(isDev bool) error
- func (b *Builder) Config() *wave.ParsedConfig
- func (b *Builder) GetPublicURLBuildtime(original string) (string, error)
- func (b *Builder) IsCSSFile(path string) bool
- func (b *Builder) IsCriticalCSSFile(path string) bool
- func (b *Builder) IsNormalCSSFile(path string) bool
- func (b *Builder) LoadPublicFileMap() (wave.FileMap, error)
- func (b *Builder) MustGetPublicURLBuildtime(original string) string
- func (b *Builder) NewViteDevContext() (*viteutil.BuildCtx, error)
- func (b *Builder) ProcessFilesOnly(isRebuild bool, isDev bool) error
- func (b *Builder) ProcessPrivateFilesOnly() error
- func (b *Builder) ProcessPublicFilesOnly() error
- func (b *Builder) PublicFileMapKeys() ([]string, error)
- func (b *Builder) ReadCriticalCSS() (string, error)
- func (b *Builder) ReadNormalCSSURL() (string, error)
- func (b *Builder) RegisterSchemaSection(name string, schema jsonschema.Entry)
- func (b *Builder) SimplePublicFileMap() (map[string]string, error)
- func (b *Builder) ViteProdBuild() error
- func (b *Builder) WritePublicFileMapTS(outDir string) error
- type Debouncer
- type Watcher
- func (w *Watcher) AddDir(root string) error
- func (w *Watcher) Close() error
- func (w *Watcher) Errors() <-chan error
- func (w *Watcher) Events() <-chan fsnotify.Event
- func (w *Watcher) FindWatchedFile(path string) *wave.WatchedFile
- func (w *Watcher) IsIgnored(path string, patterns []string) bool
- func (w *Watcher) IsIgnoredDir(path string) bool
- func (w *Watcher) IsIgnoredFile(path string) bool
- func (w *Watcher) IsPrivateStaticFile(path string) bool
- func (w *Watcher) IsPublicStaticFile(path string) bool
- func (w *Watcher) MatchPattern(pattern, path string) bool
- func (w *Watcher) RemoveStale()
Constants ¶
This section is empty.
Variables ¶
var ErrLockHeld = errors.New("another wave dev instance is running on this project")
ErrLockHeld is returned when another wave dev instance is running on this project.
Functions ¶
func BuildWave ¶
func BuildWave(cfg *wave.ParsedConfig, log *slog.Logger)
BuildWave is a simplified entry point without a custom hook.
func BuildWaveWithHook ¶
BuildWaveWithHook provides CLI integration for build commands with a custom hook.
func RunDev ¶
func RunDev(cfg *wave.ParsedConfig, log *slog.Logger) error
RunDev starts the development server
func SetupDistDir ¶
func SetupDistDir(cfg *wave.ParsedConfig) error
SetupDistDir creates the required dist directory structure
func ValidateConfig ¶
func ValidateConfig(cfg *wave.ParsedConfig) error
ValidateConfig performs full validation of the Wave configuration. This should be called at build time before any build operations.
Types ¶
type BuildOpts ¶
type BuildOpts struct {
CompileGo bool
IsDev bool
IsRebuild bool
FileOnlyMode bool // Skip hooks and binary
}
BuildOpts configures a build
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder handles build operations. It is safe to reuse across multiple builds.
func NewBuilder ¶
func NewBuilder(cfg *wave.ParsedConfig, log *slog.Logger) *Builder
NewBuilder creates a new Builder
func (*Builder) AddPublicAssetKeys ¶
func (b *Builder) AddPublicAssetKeys(statements *tsgen.Statements) *tsgen.Statements
AddPublicAssetKeys adds public asset keys for TypeScript generation
func (*Builder) BuildCriticalCSS ¶
BuildCriticalCSS builds only critical CSS
func (*Builder) BuildNormalCSS ¶
BuildNormalCSS builds only normal CSS
func (*Builder) Close ¶
Close releases resources held by the builder (e.g., esbuild contexts). Should be called when the builder is no longer needed.
func (*Builder) CompileGoOnly ¶
CompileGoOnly compiles the Go binary without running the full build
func (*Builder) Config ¶
func (b *Builder) Config() *wave.ParsedConfig
Config returns the builder's config (read-only access)
func (*Builder) GetPublicURLBuildtime ¶
GetPublicURLBuildtime resolves a public URL at build time without panicking. Returns the resolved URL and any error that occurred.
func (*Builder) IsCriticalCSSFile ¶
IsCriticalCSSFile checks if a path is a critical CSS file or import
func (*Builder) IsNormalCSSFile ¶
IsNormalCSSFile checks if a path is a normal CSS file or import
func (*Builder) LoadPublicFileMap ¶
LoadPublicFileMap loads the public file map from disk (for build-time use)
func (*Builder) MustGetPublicURLBuildtime ¶
MustGetPublicURLBuildtime resolves a public URL at build time. This function reads the file map from disk on each call and panics on error. For hot paths (like CSS URL resolution), use getPublicURLBuildtimeCached instead.
func (*Builder) NewViteDevContext ¶
NewViteDevContext creates a new Vite dev context
func (*Builder) ProcessFilesOnly ¶
ProcessFilesOnly runs file processing without hooks or binary compilation
func (*Builder) ProcessPrivateFilesOnly ¶
ProcessPrivateFilesOnly reprocesses just the private static files (for dev hot reload)
func (*Builder) ProcessPublicFilesOnly ¶
ProcessPublicFilesOnly reprocesses just the public static files (for dev hot reload)
func (*Builder) PublicFileMapKeys ¶
PublicFileMapKeys returns sorted keys of non-prehashed public files
func (*Builder) ReadCriticalCSS ¶
ReadCriticalCSS reads the critical CSS content from dist
func (*Builder) ReadNormalCSSURL ¶
ReadNormalCSSURL reads the normal CSS URL from the ref file
func (*Builder) RegisterSchemaSection ¶
func (b *Builder) RegisterSchemaSection(name string, schema jsonschema.Entry)
RegisterSchemaSection adds a custom section to the generated JSON schema. This allows frameworks to extend wave.config.json with their own configuration while maintaining IDE autocomplete support.
func (*Builder) SimplePublicFileMap ¶
SimplePublicFileMap returns a simple path->distName map
func (*Builder) ViteProdBuild ¶
ViteProdBuild runs a Vite production build
func (*Builder) WritePublicFileMapTS ¶
WritePublicFileMapTS writes the public file map as a TypeScript file to the specified directory. This enables Vite HMR to pick up public static file changes without running Go.
type Debouncer ¶
type Debouncer struct {
// contains filtered or unexported fields
}
Debouncer batches rapid file events and ensures callbacks don't overlap.
type Watcher ¶
type Watcher struct {
// contains filtered or unexported fields
}
Watcher manages file watching for the dev server
func NewWatcher ¶
NewWatcher creates a new file watcher
func (*Watcher) FindWatchedFile ¶
func (w *Watcher) FindWatchedFile(path string) *wave.WatchedFile
FindWatchedFile finds and merges all matching WatchedFile configs for a path. Framework patterns are matched first, then user patterns. Settings are merged with "strongest wins" semantics: destructive flags use OR, suppressive flags use AND, and hooks are concatenated (framework first, then user).
func (*Watcher) IsIgnored ¶
IsIgnored checks if a path matches any of the ignored patterns. Normalizes the path before matching.
func (*Watcher) IsIgnoredDir ¶
IsIgnoredDir checks if a directory path should be ignored
func (*Watcher) IsIgnoredFile ¶
IsIgnoredFile checks if a file path should be ignored
func (*Watcher) IsPrivateStaticFile ¶
IsPrivateStaticFile checks if a path is within the private static directory
func (*Watcher) IsPublicStaticFile ¶
IsPublicStaticFile checks if a path is within the public static directory
func (*Watcher) MatchPattern ¶
MatchPattern checks if a path matches a glob pattern. Both pattern and path should already be normalized (absolute + forward slashes).
func (*Watcher) RemoveStale ¶
func (w *Watcher) RemoveStale()
RemoveStale removes watches for directories that no longer exist