lib

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ColorBlack   = "\033[0;30m"
	ColorRed     = "\033[0;31m"
	ColorGreen   = "\033[0;32m"
	ColorYellow  = "\033[0;33m"
	ColorBlue    = "\033[0;34m"
	ColorMagenta = "\033[0;35m"
	ColortCyan   = "\033[0;36m"
	ColortWhite  = "\033[0;37m"
	ColorClear   = "\033[0m"
)

Variables

View Source
var DASH = "–"
View Source
var ERR = "× ERR:"
View Source
var INFO = ">"
View Source
var ITEM = "-"
View Source
var OK = "✓"
View Source
var RELOAD = "↻"
View Source
var Version = "dev"

Version will contain nrb build number on build

View Source
var WARN = "⚠"

Functions

func Black

func Black(s string) string

func Blue

func Blue(s string) string

func BuildChain

func BuildChain(f http.HandlerFunc, m ...Middleware) http.HandlerFunc

BuildChain builds the middlware chain recursively, functions are first class

func CopyDir

func CopyDir(dst, src string) error

CopyDir copies the content of src to dst. src should be a full path.

func Cyan

func Cyan(s string) string

func FileExists

func FileExists(filename string) bool

FileExists does?

func Green

func Green(s string) string

func InjectVarsIntoIndex

func InjectVarsIntoIndex(indexFile []byte, entryFileName, assetsDir, publicUrl string) ([]byte, bool)

InjectVarsIntoIndex injects js/css import to index.html content, returns bool if injected into content

func IsFlagPassed

func IsFlagPassed(name string) bool

func Magenta

func Magenta(s string) string

func ParseBrowserTarget

func ParseBrowserTarget(customBrowserTarget string) (api.Target, error)

func ParseLoader

func ParseLoader(text string) (api.Loader, error)

func ParseVersion added in v0.1.8

func ParseVersion() string

ParseVersion will use git to get current revision to use as version string

func PipedFileServer

func PipedFileServer(baseDir string, pipe http.HandlerFunc) http.HandlerFunc

PipedFileServer wraps your http.FileServer with neutered fs to remove dir browsing and pipes 404 to next handler

func PipedFileServerWithMiddleware

func PipedFileServerWithMiddleware(baseDir string, pipe http.HandlerFunc, middleware func(next http.HandlerFunc) http.HandlerFunc) http.HandlerFunc

PipedFileServerWithMiddleware wraps PipedFileServer with middleware

func Print

func Print(a ...any)

func PrintError

func PrintError(a ...any)

func PrintErrorf

func PrintErrorf(format string, a ...any)

func PrintInfo

func PrintInfo(a ...any)

func PrintInfof

func PrintInfof(format string, a ...any)

func PrintItem

func PrintItem(a ...any)

func PrintItemf

func PrintItemf(format string, a ...any)

func PrintOk

func PrintOk(a ...any)

func PrintOkf

func PrintOkf(format string, a ...any)

func PrintReload

func PrintReload(a ...any)

func PrintReloadf

func PrintReloadf(format string, a ...any)

func PrintWarn

func PrintWarn(a ...any)

func PrintWarnf

func PrintWarnf(format string, a ...any)

func Printe

func Printe(a ...any)

func Printef

func Printef(format string, a ...any)

func Printf

func Printf(format string, a ...any)

func RealQuickPath

func RealQuickPath(fpath string) string

RealQuickPath just quickly gets path, without caring about errors

func Realpath

func Realpath(fpath string) (string, error)

Realpath returns the real path of a given file in the os

func Red

func Red(s string) string

func StringifyLoader

func StringifyLoader(loader api.Loader) (string, error)

func UseColor

func UseColor(use bool)

func White

func White(s string) string

func WrappedFileServer

func WrappedFileServer(baseDir string) http.HandlerFunc

WrappedFileServer wraps your http.FileServer with neutered fs to remove dir browsing and redirects 404 to index.html

func Yellow

func Yellow(s string) string

Types

type ArrayFlags added in v0.1.8

type ArrayFlags []string

func (*ArrayFlags) Set added in v0.1.8

func (i *ArrayFlags) Set(value string) error

func (*ArrayFlags) String added in v0.1.8

func (i *ArrayFlags) String() string

type Broker

type Broker struct {
	// Events are pushed to this channel by the main events-gathering routine
	Notifier chan []byte
	// contains filtered or unexported fields
}

A Broker holds open client connections, listens for incoming events on its Notifier channel and broadcast event data to all registered connections

func NewStreamServer

func NewStreamServer() (broker *Broker)

func (*Broker) ServeHTTP

func (broker *Broker) ServeHTTP(rw http.ResponseWriter, req *http.Request)

type Config added in v0.1.8

type Config struct {
	AliasPackages            MapFlags
	ResolveModules           MapFlags
	PreloadPathsStartingWith ArrayFlags
	Injects                  ArrayFlags
	InlineSize               int64
	InlineExtensions         []string
	Loaders                  LoaderFlags
	Splitting                bool
}

func ParseJsonConfig added in v0.1.8

func ParseJsonConfig(packageJson PackageJson) (*Config, error)

type LoaderFlags added in v0.1.8

type LoaderFlags map[string]api.Loader

func (*LoaderFlags) Set added in v0.1.8

func (i *LoaderFlags) Set(value string) error

func (*LoaderFlags) String added in v0.1.8

func (i *LoaderFlags) String() string

type MapFlags added in v0.1.8

type MapFlags map[string]string

func (*MapFlags) Set added in v0.1.8

func (i *MapFlags) Set(value string) error

func (*MapFlags) String added in v0.1.8

func (i *MapFlags) String() string

type Middleware

type Middleware func(http.HandlerFunc) http.HandlerFunc

Middleware is a definition of what a middleware is, take in one handlerfunc and wrap it within another handlerfunc

type NotFoundRedirectRespWr

type NotFoundRedirectRespWr struct {
	http.ResponseWriter // We embed http.ResponseWriter
	// contains filtered or unexported fields
}

NotFoundRedirectRespWr response for neutered fs

func (*NotFoundRedirectRespWr) Write

func (w *NotFoundRedirectRespWr) Write(p []byte) (int, error)

func (*NotFoundRedirectRespWr) WriteHeader

func (w *NotFoundRedirectRespWr) WriteHeader(status int)

type PackageJson added in v0.1.8

type PackageJson map[string]any

func ParsePackageJson added in v0.1.8

func ParsePackageJson(packagePath string) (PackageJson, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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