Documentation
¶
Overview ¶
Package waveenv provides runtime-safe environment and path primitives used by Wave runtime and config parsing.
This package intentionally excludes build/dev-only helpers (for example lock management and glob utilities) so importing wave runtime APIs does not pull those heavier dependencies into runtime binaries.
Index ¶
- Constants
- func Absolute(path string) string
- func AbsoluteDirectory(path string) string
- func AbsoluteSlash(path string) string
- func CanonicalizePathForLocationComparison(path string) string
- func GetIsDev() bool
- func IsMachineAbsoluteFilesystemPath(pathForCheck string) bool
- func ParseEnvPort() int
- func ParseRefreshServerPort() int
- func PathsReferToSameLocation(pathA string, pathB string) bool
- func ResolveFromReferencedPath(publicPathPrefix string, referencedPath string) string
- func SetEnvPort(port int)
- func SetModeToDev()
- func SetRefreshServerPort(port int)
- func TrimAndCleanPath(path string) string
- type Resolver
Constants ¶
const ( // EnvMode stores the current Wave runtime mode. EnvMode = "__WAVE_MODE" // EnvModeDev is the development-mode value for EnvMode. EnvModeDev = "development" // EnvPort is the application runtime port environment variable. EnvPort = "PORT" // EnvPortSet marks that Wave has already resolved and set EnvPort in this // process. EnvPortSet = "__WAVE_PORT_HAS_BEEN_SET" // EnvRefreshServerPort stores the dev refresh websocket server port. EnvRefreshServerPort = "__WAVE_REFRESH_SERVER_PORT" )
Variables ¶
This section is empty.
Functions ¶
func AbsoluteDirectory ¶
AbsoluteDirectory resolves an input path to an absolute directory path.
func AbsoluteSlash ¶
AbsoluteSlash resolves one absolute path and normalizes separators to '/'.
func CanonicalizePathForLocationComparison ¶
CanonicalizePathForLocationComparison resolves one path for location equality checks.
func GetIsDev ¶
func GetIsDev() bool
GetIsDev reports whether EnvMode is currently set to development.
func IsMachineAbsoluteFilesystemPath ¶
IsMachineAbsoluteFilesystemPath reports whether a path is machine-absolute.
This treats both OS-native absolute paths and slash-rooted strings (for example "/dist") as machine-absolute filesystem paths.
func ParseEnvPort ¶
func ParseEnvPort() int
ParseEnvPort parses EnvPort and returns 0 when unset or invalid.
func ParseRefreshServerPort ¶
func ParseRefreshServerPort() int
ParseRefreshServerPort parses EnvRefreshServerPort and returns 0 when unset or invalid.
func PathsReferToSameLocation ¶
PathsReferToSameLocation reports whether both paths normalize to the same location.
func ResolveFromReferencedPath ¶
ResolveFromReferencedPath resolves a referenced asset path under publicPathPrefix. It trims, normalizes, and rejects empty/effectively-empty referenced paths.
func SetRefreshServerPort ¶
func SetRefreshServerPort(port int)
SetRefreshServerPort writes one refresh websocket port value into env.
func TrimAndCleanPath ¶
TrimAndCleanPath trims surrounding whitespace and applies filepath.Clean.
Types ¶
type Resolver ¶
type Resolver struct {
// contains filtered or unexported fields
}
Resolver caches resolved runtime port values for a given mode view.
func NewResolver ¶
func NewResolver() *Resolver
NewResolver constructs a resolver that reads mode dynamically from env.
func NewResolverForMode ¶
NewResolverForMode constructs a resolver pinned to an explicit mode snapshot.
func NewResolverWithFreePortResolver ¶
NewResolverWithFreePortResolver constructs a resolver with one injected free-port lookup function. This is primarily used when callers need deterministic behavior.
func (*Resolver) MustGetPort ¶
MustGetPort returns the runtime port. In dev mode, empty PORT uses framework default base-port selection. It panics in dev mode when PORT is invalid or a free port cannot be resolved. It panics in non-dev mode when PORT is missing or invalid.