tooling

package
v0.85.0-pre.0 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2026 License: BSD-3-Clause Imports: 41 Imported by: 0

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

Constants

This section is empty.

Variables

View Source
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

func BuildWaveWithHook(cfg *wave.ParsedConfig, log *slog.Logger, hook func(isDev bool) error)

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) Build

func (b *Builder) Build(opts BuildOpts) error

Build performs a full build

func (*Builder) BuildCriticalCSS

func (b *Builder) BuildCriticalCSS(isDev bool) error

BuildCriticalCSS builds only critical CSS

func (*Builder) BuildNormalCSS

func (b *Builder) BuildNormalCSS(isDev bool) error

BuildNormalCSS builds only normal CSS

func (*Builder) Close

func (b *Builder) Close() error

Close releases resources held by the builder (e.g., esbuild contexts). Should be called when the builder is no longer needed.

func (*Builder) CompileGoOnly

func (b *Builder) CompileGoOnly(isDev bool) error

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

func (b *Builder) GetPublicURLBuildtime(original string) (string, error)

GetPublicURLBuildtime resolves a public URL at build time without panicking. Returns the resolved URL and any error that occurred.

func (*Builder) IsCSSFile

func (b *Builder) IsCSSFile(path string) bool

IsCSSFile checks if a path is any CSS file tracked by the builder

func (*Builder) IsCriticalCSSFile

func (b *Builder) IsCriticalCSSFile(path string) bool

IsCriticalCSSFile checks if a path is a critical CSS file or import

func (*Builder) IsNormalCSSFile

func (b *Builder) IsNormalCSSFile(path string) bool

IsNormalCSSFile checks if a path is a normal CSS file or import

func (*Builder) LoadPublicFileMap

func (b *Builder) LoadPublicFileMap() (wave.FileMap, error)

LoadPublicFileMap loads the public file map from disk (for build-time use)

func (*Builder) MustGetPublicURLBuildtime

func (b *Builder) MustGetPublicURLBuildtime(original string) string

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

func (b *Builder) NewViteDevContext() (*viteutil.BuildCtx, error)

NewViteDevContext creates a new Vite dev context

func (*Builder) ProcessFilesOnly

func (b *Builder) ProcessFilesOnly(isRebuild bool, isDev bool) error

ProcessFilesOnly runs file processing without hooks or binary compilation

func (*Builder) ProcessPrivateFilesOnly

func (b *Builder) ProcessPrivateFilesOnly() error

ProcessPrivateFilesOnly reprocesses just the private static files (for dev hot reload)

func (*Builder) ProcessPublicFilesOnly

func (b *Builder) ProcessPublicFilesOnly() error

ProcessPublicFilesOnly reprocesses just the public static files (for dev hot reload)

func (*Builder) PublicFileMapKeys

func (b *Builder) PublicFileMapKeys() ([]string, error)

PublicFileMapKeys returns sorted keys of non-prehashed public files

func (*Builder) ReadCriticalCSS

func (b *Builder) ReadCriticalCSS() (string, error)

ReadCriticalCSS reads the critical CSS content from dist

func (*Builder) ReadNormalCSSURL

func (b *Builder) ReadNormalCSSURL() (string, error)

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

func (b *Builder) SimplePublicFileMap() (map[string]string, error)

SimplePublicFileMap returns a simple path->distName map

func (*Builder) ViteProdBuild

func (b *Builder) ViteProdBuild() error

ViteProdBuild runs a Vite production build

func (*Builder) WritePublicFileMapTS

func (b *Builder) WritePublicFileMapTS(outDir string) error

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.

func NewDebouncer

func NewDebouncer(d time.Duration, cb func([]fsnotify.Event)) *Debouncer

func (*Debouncer) Add

func (d *Debouncer) Add(evt fsnotify.Event)

func (*Debouncer) Stop

func (d *Debouncer) Stop()

Stop cancels any pending debounced callback and prevents future events. This should be called when the watcher is being closed to prevent callbacks from firing during or after cleanup.

type Watcher

type Watcher struct {
	// contains filtered or unexported fields
}

Watcher manages file watching for the dev server

func NewWatcher

func NewWatcher(cfg *wave.ParsedConfig, log *slog.Logger) (*Watcher, error)

NewWatcher creates a new file watcher

func (*Watcher) AddDir

func (w *Watcher) AddDir(root string) error

AddDir adds a directory and its subdirectories to the watcher

func (*Watcher) Close

func (w *Watcher) Close() error

func (*Watcher) Errors

func (w *Watcher) Errors() <-chan error

func (*Watcher) Events

func (w *Watcher) Events() <-chan fsnotify.Event

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

func (w *Watcher) IsIgnored(path string, patterns []string) bool

IsIgnored checks if a path matches any of the ignored patterns. Normalizes the path before matching.

func (*Watcher) IsIgnoredDir

func (w *Watcher) IsIgnoredDir(path string) bool

IsIgnoredDir checks if a directory path should be ignored

func (*Watcher) IsIgnoredFile

func (w *Watcher) IsIgnoredFile(path string) bool

IsIgnoredFile checks if a file path should be ignored

func (*Watcher) IsPrivateStaticFile

func (w *Watcher) IsPrivateStaticFile(path string) bool

IsPrivateStaticFile checks if a path is within the private static directory

func (*Watcher) IsPublicStaticFile

func (w *Watcher) IsPublicStaticFile(path string) bool

IsPublicStaticFile checks if a path is within the public static directory

func (*Watcher) MatchPattern

func (w *Watcher) MatchPattern(pattern, path string) bool

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

Jump to

Keyboard shortcuts

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