library

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FileNameMin added in v1.3.0

func FileNameMin(filename string) string

Types

type File added in v0.5.0

type File struct {
	Path      string
	LocalPath string
	Type      FileType
}

type FileType added in v0.5.0

type FileType string
const (
	// FileTypeJS represents a JavaScript file
	FileTypeJS FileType = "js"
	// FileTypeCSS represents a CSS file
	FileTypeCSS FileType = "css"
	// FileTypeOther represents a file that is not a JavaScript or CSS file
	FileTypeOther FileType = "other"
)

func ExtractFileType added in v0.5.0

func ExtractFileType(filename string) FileType

type Files added in v0.5.0

type Files []File

type Include added in v0.5.0

type Include struct {
	File string
	Raw  string
	As   string
}

func (Include) Name added in v0.5.0

func (I Include) Name() string

type Includes added in v0.5.0

type Includes []Include

func (Includes) Get added in v0.5.0

func (I Includes) Get(s string) *Include

type Package

type Package struct {
	Name     string
	Version  string
	Provider Provider
	Require  Includes // Patterns to specify which files to include
}

func (*Package) Assets added in v1.1.0

func (p *Package) Assets(assetsDir string, filePath string) (Files, string, error)

func (*Package) AssetsAt added in v1.4.0

func (p *Package) AssetsAt(rootDir, assetsDir, filePath string) (Files, string, error)

AssetsAt reads assets below rootDir while keeping browser URLs relative to assetsDir. RootDir is a filesystem location, not a public URL prefix.

func (*Package) AssetsDir

func (p *Package) AssetsDir(assets string) string

AssetsDir returns the assets dir for the current package, we will store all files in here

func (*Package) CacheDir

func (p *Package) CacheDir(cacheDir string) string

CacheDir returns the cache dir for the current package, we will store all files in here

func (*Package) CacheFiles added in v1.4.0

func (p *Package) CacheFiles(rootDir, cacheDir string) (Files, error)

CacheFiles reads the versioned cache with paths relative to the package.

func (*Package) HasAssetFile added in v0.5.0

func (p *Package) HasAssetFile(rootDir string, assetsDir string, filePath string) bool

func (*Package) HasAssets

func (p *Package) HasAssets(rootDir string, assetsDir string) bool

HasAssets checks if the package has assets on disk

func (*Package) HasCache

func (p *Package) HasCache(rootDir string, cacheDir string) bool

HasCache checks if the package has cache on disk

func (*Package) HasCacheFile added in v1.4.0

func (p *Package) HasCacheFile(rootDir, cacheDir, filePath string) bool

HasCacheFile reports whether one complete cache file is present.

func (*Package) MakeAssets

func (p *Package) MakeAssets(rootDir string, cacheDir string, assetsDir string, filePath string, src string) error

MakeAssets copies the cache files to the asset path without the version

func (*Package) MakeAssetsContext added in v1.4.0

func (p *Package) MakeAssetsContext(ctx context.Context, rootDir, cacheDir, assetsDir, filePath, src string) error

MakeAssetsContext copies a complete cache file or downloads it atomically.

func (*Package) MakeCache

func (p *Package) MakeCache(rootDir string, cacheDir string, filePath string, src string) error

MakeCache retrieves the file from the remote server and stores it locally

func (*Package) MakeCacheContext added in v1.4.0

func (p *Package) MakeCacheContext(ctx context.Context, rootDir, cacheDir, filePath, src string) error

MakeCacheContext downloads a cache file with cancellation and atomic writes.

type Provider added in v1.0.0

type Provider interface {
	FetchPackageFiles(ctx context.Context, name, version string) (Files, string, error)
}

Jump to

Keyboard shortcuts

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