compactor

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddPlugin added in v0.0.12

func AddPlugin(plugin *Plugin)

AddPlugin add a new plugin to the index

func AppendFile added in v0.1.0

func AppendFile(path string, root string) error

AppendFile appends file information to index from its path

func Delete added in v0.1.0

func Delete(options *Options, file *File) error

Delete removes the destination file(s) for given file

func IndexFiles added in v0.1.0

func IndexFiles(options *Options, root string) error

IndexFile index the root path files to the index, resolve related and determine destination

func Process

func Process(options *Options, file *File) error

Process execute file packaging by running plugin methods

func RemoveFile added in v0.1.0

func RemoveFile(path string)

RemoveFile removes the file information from index if match path

func RemovePlugin added in v0.0.12

func RemovePlugin(namespace string)

RemovePlugin removes all plugins from index that match the given namespace

func Shutdown added in v0.2.0

func Shutdown(options *Options) error

Shutdown make sure every plugin has properly shutdown

func UpdateFile added in v0.1.0

func UpdateFile(path string) error

UpdateFile updates file information on index if matches path

Types

type Compress added in v0.0.2

type Compress struct {
	Enabled bool
	Include []string
	Exclude []string
}

Compress struct

type Destination added in v0.0.3

type Destination struct {
	Path   string
	Hashed bool
}

Destination struct

type File added in v0.1.0

type File struct {
	Path        string      // Full path (root + location)
	Destination string      // Full destination path
	Root        string      // Root location
	Location    string      // Location from root
	Folder      string      // Location folder
	File        string      // File name with extension
	Name        string      // File name
	Extension   string      // File Extension
	Content     string      // File content
	Permission  fs.FileMode // File permissions
	Exists      bool        // File exists flag
	Checksum    []string    // Checksum history
	Related     []Related   // Related items
}

File struct

func FindPackage added in v0.1.0

func FindPackage(options *Options, path string) *File

FindPackage retrieves the related package from given path

func FindPackages added in v0.1.0

func FindPackages(options *Options) []*File

FindPackages retrieves the full list of detected packages

func GetFile added in v0.1.0

func GetFile(path string) *File

GetFile retrieves the file that match path on index

func GetFiles added in v0.1.0

func GetFiles() []*File

GetFiles retrieve the indexed files

func (*File) FindRelated added in v0.1.0

func (f *File) FindRelated(onlyDependencies bool) []Related

FindRelated retrieve the related paths of the item recursively

type InitFunc added in v0.0.6

type InitFunc = func(options *Options) error

Init function Used to start up the plugin and check for their dependencies

type OptimizeFunc added in v0.0.12

type OptimizeFunc = func(options *Options, file *File) error

Optimize function Used to run optimizations algorithms to compress file

type Options

type Options struct {
	Source      Source
	Destination Destination
	Compress    Compress
	SourceMap   SourceMap
	Progressive Progressive
}

Options struct

func (*Options) CleanPath added in v0.1.0

func (o *Options) CleanPath(path string) string

CleanPath return the clean path, without source and destination path

func (*Options) MatchPatterns added in v0.1.0

func (o *Options) MatchPatterns(file string, patterns []string) bool

MatchPatterns return if file match one of the given patterns

func (*Options) ShouldCompress added in v0.0.2

func (o *Options) ShouldCompress(path string) bool

ShouldCompress return if compress should be enabled for given path

func (*Options) ShouldGenerateProgressive added in v0.1.0

func (o *Options) ShouldGenerateProgressive(path string) bool

ShouldGenerateProgressive return if progressive formats should be generated for given path

func (*Options) ShouldGenerateSourceMap added in v0.1.0

func (o *Options) ShouldGenerateSourceMap(path string) bool

ShouldGenerateSourceMap return if source map should be generated for given path

func (*Options) ShouldInclude added in v0.1.0

func (o *Options) ShouldInclude(path string) bool

ShouldInclude return if path should be included on the bundle

func (*Options) ToDestination added in v0.1.0

func (o *Options) ToDestination(path string) string

ToDestination transform and return the full destination path for given path

func (*Options) ToExtension added in v0.1.0

func (o *Options) ToExtension(path string, extension string) string

ToExtension return a file path converted to a specific extension

func (*Options) ToHashed added in v0.1.0

func (o *Options) ToHashed(path string, hash string) string

ToHashed return a file path converted to a hashed name to avoid caching

func (*Options) ToNonHashed added in v0.1.0

func (o *Options) ToNonHashed(path string, hash string) string

ToNonHashed return a file path converted back to a non hashed name

func (*Options) ToSource added in v0.1.0

func (o *Options) ToSource(path string) string

ToSource transform and return the full source path for given path

type Plugin added in v0.0.4

type Plugin struct {
	Namespace   string
	Extensions  []string
	Initialized bool
	Init        InitFunc
	Shutdown    ShutdownFunc
	Resolve     ResolveFunc
	Related     RelatedFunc
	Transform   TransformFunc
	Optimize    OptimizeFunc
}

Plugin struct

func GetPlugin added in v0.0.12

func GetPlugin(extension string) *Plugin

GetPlugin retrieves the first found plugin for the given extension

type Progressive added in v0.0.2

type Progressive struct {
	Enabled bool
	Include []string
	Exclude []string
}

Progressive struct

type Related struct {
	Type       string
	Dependency bool
	Source     string
	Path       string
	File       *File
}

Related struct

type RelatedFunc added in v0.0.12

type RelatedFunc = func(options *Options, file *File) ([]Related, error)

Related function Detects and generates the list of related files to the given item, being a dependency or not

type ResolveFunc added in v0.0.4

type ResolveFunc = func(options *Options, file *File) (string, error)

Resolve function Used to transform the source path to the final destination path

type ShutdownFunc added in v0.2.0

type ShutdownFunc = func(options *Options) error

Shutdown function Used to shutdown the plugin and cleanup resources

type Source added in v0.0.3

type Source struct {
	Path    string
	Include []string
	Exclude []string
}

Source struct

type SourceMap added in v0.0.2

type SourceMap struct {
	Enabled bool
	Include []string
	Exclude []string
}

SourceMap struct

type TransformFunc added in v0.1.0

type TransformFunc = func(options *Options, file *File) error

Transform function Used to transform the file content to the final format by applying compilation if necessary

Jump to

Keyboard shortcuts

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