Documentation
¶
Overview ¶
Package library describes the packages an import map fetches or vendors: a Package with its version and the files it requires (Include). Provider is the interface of the CDN clients in the client packages.
Index ¶
- func FileNameMin(filename string) string
- type File
- type FileType
- type Files
- type Include
- type Includes
- type Package
- func (p *Package) Assets(assetsDir string, filePath string) (Files, string, error)
- func (p *Package) AssetsAt(rootDir, assetsDir, filePath string) (Files, string, error)
- func (p *Package) AssetsDir(assets string) string
- func (p *Package) CacheDir(cacheDir string) string
- func (p *Package) CacheFiles(rootDir, cacheDir string) (Files, error)
- func (p *Package) HasAssetFile(rootDir string, assetsDir string, filePath string) bool
- func (p *Package) HasAssets(rootDir string, assetsDir string) bool
- func (p *Package) HasCache(rootDir string, cacheDir string) bool
- func (p *Package) HasCacheFile(rootDir, cacheDir, filePath string) bool
- func (p *Package) MakeAssets(rootDir string, cacheDir string, assetsDir string, filePath string, src string) error
- func (p *Package) MakeAssetsContext(ctx context.Context, rootDir, cacheDir, assetsDir, filePath, src string) error
- func (p *Package) MakeCache(rootDir string, cacheDir string, filePath string, src string) error
- func (p *Package) MakeCacheContext(ctx context.Context, rootDir, cacheDir, filePath, src string) error
- type Provider
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FileNameMin ¶ added in v1.3.0
Types ¶
type Includes ¶ added in v0.5.0
type Includes []Include
type Package ¶
type Package struct {
Name string
Version string
Provider Provider
Require Includes // Patterns to specify which files to include
// License is the licence text Vendor copies with the package: a file of
// the package or a URL. Without it Vendor looks for a LICENSE, LICENCE
// or COPYING file among the package's files.
License string
// Local marks files the application builds itself, such as a bundle
// made with esbuild, rather than a package to download. Vendor records
// the integrity of the files Require lists, by their exact paths
// relative to the vendor directory (they may start with "../"), in the
// lock, so FromFS and importmap verify check them like vendored files.
// License is such a path too. Nothing is downloaded, and Fetch and
// CacheOrFetch leave local packages out.
Local bool
}
func (*Package) AssetsAt ¶ added in v1.4.0
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 ¶
AssetsDir returns the assets dir for the current package, we will store all files in here
func (*Package) CacheDir ¶
CacheDir returns the cache dir for the current package, we will store all files in here
func (*Package) CacheFiles ¶ added in v1.4.0
CacheFiles reads the versioned cache with paths relative to the package.
func (*Package) HasAssetFile ¶ added in v0.5.0
func (*Package) HasCacheFile ¶ added in v1.4.0
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.